Skip to content

Commit 2cf1582

Browse files
author
naman-contentstack
committed
Merge branch 'feat/AM2.0' into feat/DX-5836
2 parents b5f9489 + 248ce74 commit 2cf1582

14 files changed

Lines changed: 3875 additions & 2394 deletions

File tree

.talismanrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
fileignoreconfig:
22
- filename: pnpm-lock.yaml
3-
checksum: fa2ccdf09da9561c5c359d68e1886ebe31542fb1b601c0806cd597e8dc807a0a
3+
checksum: ad02b19a546d5d90424fed77f1342dd63b7d55b027a173db0046063e727929ba
44
version: '1.0'

packages/contentstack-clone/test/lib/util/clone-handler.commands.test.ts

Lines changed: 91 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { expect } from 'chai';
22
import { CloneHandler } from '../../../src/core/util/clone-handler';
33
import { CloneConfig } from '../../../src/types/clone-config';
4+
import { STRUCTURE_LIST } from '../../../src/utils/constants';
45
import sinon from 'sinon';
56
import inquirer from 'inquirer';
67

@@ -137,6 +138,94 @@ describe('CloneHandler - Commands', () => {
137138
expect(cmdArgs).to.include('-a');
138139
expect(cmdArgs).to.include('source-alias');
139140
});
141+
142+
it('should set filteredModules for structure-only export without assets (AM 2.0 needs full export)', async () => {
143+
const exportCmdStub = {
144+
run: sandbox.stub().returns(Promise.resolve()),
145+
};
146+
sandbox.stub(require('@contentstack/cli-cm-export'), 'default').value(exportCmdStub);
147+
148+
await handler.cmdExport();
149+
150+
expect(fsStub.writeFileSync.calledOnce).to.be.true;
151+
const written = JSON.parse(fsStub.writeFileSync.firstCall.args[1] as string);
152+
expect(written.filteredModules).to.deep.equal(['stack', ...STRUCTURE_LIST]);
153+
expect(written.filteredModules).to.not.include('assets');
154+
expect(written.filteredModules).to.not.include('entries');
155+
});
156+
157+
it('should not set filteredModules for full clone so default export includes assets', async () => {
158+
const config: CloneConfig = {
159+
cloneContext: {
160+
command: 'test',
161+
module: 'clone',
162+
email: 'test@example.com',
163+
},
164+
source_stack: 'test-key',
165+
cloneType: 'b',
166+
};
167+
handler = new CloneHandler(config);
168+
const exportCmdStub = {
169+
run: sandbox.stub().returns(Promise.resolve()),
170+
};
171+
sandbox.stub(require('@contentstack/cli-cm-export'), 'default').value(exportCmdStub);
172+
173+
await handler.cmdExport();
174+
175+
expect(fsStub.writeFileSync.calledOnce).to.be.true;
176+
const written = JSON.parse(fsStub.writeFileSync.firstCall.args[1] as string);
177+
expect(written).to.not.have.property('filteredModules');
178+
});
179+
180+
it('should preserve region.assetManagementUrl in serialized export config for AM 2.0 export', async () => {
181+
const amUrl = 'https://asset-management.example.com';
182+
const config: CloneConfig = {
183+
cloneContext: {
184+
command: 'test',
185+
module: 'clone',
186+
email: 'test@example.com',
187+
},
188+
source_stack: 'test-key',
189+
cloneType: 'b',
190+
region: { assetManagementUrl: amUrl },
191+
};
192+
handler = new CloneHandler(config);
193+
const exportCmdStub = {
194+
run: sandbox.stub().returns(Promise.resolve()),
195+
};
196+
sandbox.stub(require('@contentstack/cli-cm-export'), 'default').value(exportCmdStub);
197+
198+
await handler.cmdExport();
199+
200+
const written = JSON.parse(fsStub.writeFileSync.firstCall.args[1] as string);
201+
expect(written.region).to.be.an('object');
202+
expect(written.region.assetManagementUrl).to.equal(amUrl);
203+
});
204+
205+
it('should merge export.region.assetManagementUrl from external export config', async () => {
206+
const amUrl = 'https://asset-management-merged.example.com';
207+
const config: CloneConfig = {
208+
cloneContext: {
209+
command: 'test',
210+
module: 'clone',
211+
email: 'test@example.com',
212+
},
213+
source_stack: 'test-key',
214+
cloneType: 'b',
215+
export: { region: { assetManagementUrl: amUrl } },
216+
};
217+
handler = new CloneHandler(config);
218+
const exportCmdStub = {
219+
run: sandbox.stub().returns(Promise.resolve()),
220+
};
221+
sandbox.stub(require('@contentstack/cli-cm-export'), 'default').value(exportCmdStub);
222+
223+
await handler.cmdExport();
224+
225+
const written = JSON.parse(fsStub.writeFileSync.firstCall.args[1] as string);
226+
expect(written.region.assetManagementUrl).to.equal(amUrl);
227+
expect(written).to.not.have.property('export');
228+
});
140229
});
141230

142231
describe('cmdImport', () => {
@@ -398,7 +487,7 @@ describe('CloneHandler - Commands', () => {
398487
// Mock configHandler FIRST before creating handler - following import plugin pattern
399488
const configHandler = require('@contentstack/cli-utilities').configHandler;
400489
configHandlerGetStub = sandbox.stub(configHandler, 'get').returns(undefined);
401-
490+
402491
// Stub ora spinner - following import plugin pattern
403492
const oraModule = require('ora');
404493
const mockSpinner = {
@@ -412,7 +501,7 @@ describe('CloneHandler - Commands', () => {
412501
writable: true,
413502
configurable: true,
414503
});
415-
504+
416505
const config: CloneConfig = {
417506
cloneContext: {
418507
command: 'test',

packages/contentstack-export/test/unit/export/modules/assets.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,11 @@ describe('ExportAssets', () => {
139139
},
140140
'asset-management': {
141141
chunkFileSizeMb: 1,
142+
<<<<<<< HEAD
142143
apiConcurrency: 5,
143144
downloadAssetsConcurrency: 5,
145+
=======
146+
>>>>>>> feat/AM2.0
144147
},
145148
content_types: {
146149
dirName: 'content_types',

packages/contentstack-export/test/unit/export/modules/base-class.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ describe('BaseClass', () => {
154154
enableDownloadStatus: false,
155155
includeVersionedAssets: false,
156156
},
157+
'asset-management': {
158+
chunkFileSizeMb: 1,
159+
},
157160
content_types: {
158161
dirName: 'content_types',
159162
fileName: 'content_types.json',

packages/contentstack-import/src/import/modules/base-class.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export default abstract class BaseClass {
218218
processName,
219219
indexerCount,
220220
currentIndexer,
221-
concurrencyLimit = this.importConfig.modules.apiConcurrency,
221+
concurrencyLimit = this.importConfig.fetchConcurrency,
222222
} = env;
223223

224224
/* eslint-disable no-async-promise-executor */

packages/contentstack-import/src/utils/build-import-spaces-options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function buildImportSpacesOptions(
2323
sourceApiKey: importConfig.source_stack,
2424
context: importConfig.context as unknown as Record<string, unknown>,
2525
backupDir: importConfig.backupDir,
26-
apiConcurrency: importConfig.modules?.apiConcurrency ?? importConfig.fetchConcurrency,
26+
apiConcurrency: importConfig.fetchConcurrency,
2727
uploadAssetsConcurrency: am?.uploadAssetsConcurrency,
2828
importFoldersConcurrency: am?.importFoldersConcurrency,
2929
spacesDirName: am?.dirName,

packages/contentstack-import/test/unit/import/modules/assets.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ describe('ImportAssets', () => {
3939
region: 'us',
4040
master_locale: { code: 'en-us' },
4141
masterLocale: { code: 'en-us' },
42+
fetchConcurrency: 5,
43+
writeConcurrency: 1,
4244
context: {
4345
command: 'cm:stacks:import',
4446
module: 'assets',
@@ -55,7 +57,6 @@ describe('ImportAssets', () => {
5557
dirName: 'assets',
5658
validKeys: ['title', 'filename', 'content_type', 'parent_uid', 'description', 'tags'],
5759
folderValidKeys: ['name', 'parent_uid'],
58-
apiConcurrency: 5,
5960
importFoldersConcurrency: 3,
6061
uploadAssetsConcurrency: 5,
6162
includeVersionedAssets: true,

packages/contentstack-import/test/unit/import/modules/base-class.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,10 @@ describe('BaseClass', () => {
101101
orgId: 'org-123',
102102
authenticationMethod: 'Management Token',
103103
},
104+
fetchConcurrency: 5,
105+
writeConcurrency: 1,
104106
modules: {
105107
types: ['assets', 'content-types'],
106-
apiConcurrency: 5,
107108
assets: {
108109
dirName: 'assets',
109110
fileName: 'assets.json',
@@ -120,7 +121,6 @@ describe('BaseClass', () => {
120121
dirName: 'content_types',
121122
fileName: 'content_types.json',
122123
validKeys: ['title', 'uid', 'schema'],
123-
apiConcurrency: 1,
124124
},
125125
} as any,
126126
backupDir: '/test/backup',

packages/contentstack-import/test/unit/import/modules/content-types.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ describe('ImportContentTypes', () => {
131131
master_locale: { code: 'en-us' },
132132
masterLocale: { code: 'en-us' },
133133
writeConcurrency: 2,
134+
fetchConcurrency: 5,
134135
context: {
135136
command: 'cm:stacks:import',
136137
module: 'content-types',
@@ -146,15 +147,13 @@ describe('ImportContentTypes', () => {
146147
'content-types': {
147148
dirName: 'content_types',
148149
validKeys: ['title', 'uid', 'schema'],
149-
apiConcurrency: 5,
150150
writeConcurrency: 3,
151151
fileName: 'content_types.json',
152152
limit: 100,
153153
},
154154
'global-fields': {
155155
dirName: 'global_fields',
156156
validKeys: ['title', 'uid', 'schema'],
157-
apiConcurrency: 5,
158157
writeConcurrency: 1,
159158
fileName: 'globalfields.json',
160159
limit: 100,

packages/contentstack-import/test/unit/import/modules/global-fields.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ describe('ImportGlobalFields', () => {
5252
master_locale: { code: 'en-us' },
5353
masterLocale: { code: 'en-us' },
5454
writeConcurrency: 2,
55+
fetchConcurrency: 5,
5556
context: {
5657
command: 'cm:stacks:import',
5758
module: 'global-fields',
@@ -67,7 +68,6 @@ describe('ImportGlobalFields', () => {
6768
'global-fields': {
6869
dirName: 'global_fields',
6970
validKeys: ['title', 'uid', 'schema'],
70-
apiConcurrency: 5,
7171
writeConcurrency: 3,
7272
fileName: 'globalfields.json',
7373
limit: 100,

0 commit comments

Comments
 (0)