Skip to content

Commit 2cbf0e6

Browse files
Merge pull request #1927 from contentstack/staging
DX | 19-05-2025 | Release
2 parents 0faba53 + 34b0a42 commit 2cbf0e6

File tree

12 files changed

+593
-520
lines changed

12 files changed

+593
-520
lines changed

.github/workflows/unit-test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ jobs:
3535
- name: Run tests for Contentstack Migration
3636
working-directory: ./packages/contentstack-migration
3737
run: npm run test
38+
39+
- name: Run tests for Contentstack Export To CSV
40+
working-directory: ./packages/contentstack-export-to-csv
41+
run: npm run test:unit
3842
# - name: Fetch latest references
3943
# run: |
4044
# git fetch --prune

.talismanrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,5 @@ fileignoreconfig:
115115
- filename: pnpm-lock.yaml
116116
checksum: fc379207a835de8d851caa256837e2a50e0278c43e0251372f2a5292bee41fac
117117
- filename: package-lock.json
118-
checksum: 0cb373716595912a75e9fd356e7a90a67eb1d2de712c454701231e2d5dd3caf7
119-
version: ""
118+
checksum: 36dd3bdea6ccd75f6198be5bd268181def99a84c5db9ad7a4f8c20c06c6d6592
119+
version: "1.0"

package-lock.json

Lines changed: 541 additions & 492 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/contentstack-export-to-csv/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@contentstack/cli-cm-export-to-csv",
33
"description": "Export entities to csv",
4-
"version": "1.8.0",
4+
"version": "1.8.1",
55
"author": "Abhinav Gupta @abhinav-from-contentstack",
66
"bugs": "https://github.com/contentstack/cli/issues",
77
"dependencies": {

packages/contentstack-export-to-csv/test/unit/commands/export-to-csv.test.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ const { configHandler } = require('@contentstack/cli-utilities');
88
const { runCommand } = require('@oclif/test')
99
const sinon = require('sinon');
1010

11-
const { cma } = configHandler.get('region');
11+
const regionConfig = configHandler.get('region') || {};
12+
const cma = regionConfig.cma || 'https://api.contentstack.io/v3';
1213
let sandbox;
1314

1415
describe('Export to CSV functionality', () => {
1516
beforeEach(() => {
17+
if (!configHandler.get('authorisationType')) {
18+
configHandler.set('authorisationType', 'BASIC');
19+
configHandler.set('delete', true);
20+
}
1621
sandbox = sinon.createSandbox()
1722
sandbox.stub(fs, 'createWriteStream').returns(new PassThrough())
1823
nock(cma)
@@ -21,6 +26,10 @@ describe('Export to CSV functionality', () => {
2126
});
2227

2328
afterEach(() => {
29+
if (configHandler.get('delete')) {
30+
configHandler.delete('delete');
31+
configHandler.delete('authorisationType');
32+
}
2433
sandbox.restore();
2534
nock.cleanAll();
2635
});
@@ -204,9 +213,17 @@ describe('Export to CSV functionality', () => {
204213

205214
describe("Testing teams support in CLI export-to-csv", () => {
206215
beforeEach(() => {
216+
if (!configHandler.get('authorisationType')) {
217+
configHandler.set('authorisationType', 'BASIC');
218+
configHandler.set('delete', true);
219+
}
207220
sandbox = sinon.createSandbox();
208221
});
209222
afterEach(() => {
223+
if (configHandler.get('delete')) {
224+
configHandler.delete('delete');
225+
configHandler.delete('authorisationType');
226+
}
210227
sandbox.restore();
211228
nock.cleanAll();
212229
});
Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,42 @@
1-
const { fancy } = require('fancy-test');
21
const { expect } = require('chai');
3-
const { runCommand } = require('@oclif/test')
42
const inquirer = require('inquirer');
53
const sinon = require('sinon');
6-
const { cliux, configHandler, managementSDKClient } = require('@contentstack/cli-utilities');
4+
const { configHandler, managementSDKClient } = require('@contentstack/cli-utilities');
75
const mockData = require('../mock-data/common.mock.json');
86
const { getStacks, chooseBranch } = require('../../src/util/index');
97
const nock = require('nock');
10-
const { cma } = configHandler.get('region');
8+
const regionConfig = configHandler.get('region') || {};
9+
const cma = regionConfig.cma || 'https://api.contentstack.io/v3';
1110

1211
describe('common utils', () => {
1312
let managementSdk;
14-
let sandbox
13+
let sandbox;
14+
1515
beforeEach(async () => {
1616
managementSdk = await managementSDKClient({
1717
host: cma.replace('https://', ''),
1818
});
19-
sandbox = sinon.createSandbox()
19+
sandbox = sinon.createSandbox();
2020
});
21+
2122
afterEach(() => {
2223
sandbox.restore();
2324
nock.cleanAll();
2425
});
2526

26-
describe('chooseStack', () => {
27-
describe('choose stack from list of stacks', async () => {
28-
beforeEach(() => {
29-
sandbox.stub(inquirer, 'prompt').returns({
30-
branch: mockData.stacks[0].name,
31-
});
27+
describe('getStacks', () => {
28+
it('should return a list of stacks for a given organization', async () => {
29+
sandbox.stub(inquirer, 'prompt').resolves({
30+
stack: mockData.stacks[0].name,
3231
});
33-
it('Returns list of stacks', async () => {
34-
nock(cma)
35-
.get(`/v3/stacks?&query={"org_uid":"${mockData.organizations[0].uid}"}`)
36-
.reply(200, { stacks: mockData.stacks });
37-
})
38-
await getStacks(managementSdk, mockData.organizations[0].uid);
32+
33+
nock(cma)
34+
.get(`/v3/stacks?query={"org_uid":"${mockData.organizations[0].uid}"}`)
35+
.reply(200, { stacks: mockData.stacks });
36+
37+
const result = await getStacks(managementSdk, mockData.organizations[0].uid);
38+
39+
expect(result).to.be.an('object');
3940
});
4041
});
4142

@@ -49,7 +50,7 @@ describe('common utils', () => {
4950
it('Returns list of stacks', async () => {
5051
const { branch } = await chooseBranch([mockData.branch]);
5152
expect(branch).to.equal(mockData.branch.uid);
52-
})
53+
});
5354
});
5455
});
5556
});

packages/contentstack-export-to-csv/test/util/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const {
1414
determineUserOrgRole,
1515
} = require('../../src/util/index');
1616
const sinon = require('sinon');
17-
const util = require('../../src/util')
17+
const util = require('../../src/util');
1818

1919
describe('Test Util functions', () => {
2020
let managementAPIClientMock;

packages/contentstack-import/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@contentstack/cli-cm-import",
33
"description": "Contentstack CLI plugin to import content into stack",
4-
"version": "1.21.3",
4+
"version": "1.21.4",
55
"author": "Contentstack",
66
"bugs": "https://github.com/contentstack/cli/issues",
77
"dependencies": {

packages/contentstack-import/src/config/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ const config: DefaultConfig = {
439439
},
440440
//'taxonomies', 'environments', 'marketplace_apps', workflows, custom-roles --> Add this incase need to extend to the other global modules
441441
globalModules: ['webhooks'],
442+
entriesPublish: true,
442443
};
443444

444445
export default config;

packages/contentstack-import/src/types/default-config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,5 @@ export default interface DefaultConfig {
199199
globalModules: string[];
200200
skipAssetsPublish?: boolean;
201201
skipEntriesPublish?: boolean;
202+
entriesPublish: boolean,
202203
}

0 commit comments

Comments
 (0)