Skip to content

Commit 21714d4

Browse files
committed
feat: integrate import setup with import plugin
1 parent 574bb3d commit 21714d4

File tree

16 files changed

+102
-22
lines changed

16 files changed

+102
-22
lines changed

package-lock.json

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

packages/contentstack-clone/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dependencies": {
88
"@colors/colors": "^1.5.0",
99
"@contentstack/cli-cm-export": "~1.14.1",
10-
"@contentstack/cli-cm-import": "~1.19.1",
10+
"@contentstack/cli-cm-import": "~1.20.0",
1111
"@contentstack/cli-command": "~1.3.2",
1212
"@contentstack/cli-utilities": "~1.8.0",
1313
"async": "^3.2.4",

packages/contentstack-import-setup/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ FLAGS
7373
-a, --alias=<value> alias of the management token
7474
-d, --data-dir=<value> path and location where data is stored
7575
-k, --stack-api-key=<value> API key of the target stack
76+
--backup-dir=<value> [optional] backup directory name when using specific module
7677
--modules=<option> [optional] specific module name
7778
<options: content-types|entries|both>
7879
@@ -98,6 +99,7 @@ FLAGS
9899
-a, --alias=<value> alias of the management token
99100
-d, --data-dir=<value> path and location where data is stored
100101
-k, --stack-api-key=<value> API key of the target stack
102+
--backup-dir=<value> [optional] backup directory name when using specific module
101103
--modules=<option> [optional] specific module name
102104
<options: content-types|entries|both>
103105

packages/contentstack-import-setup/src/commands/cm/stacks/import-setup.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ export default class ImportSetupCommand extends Command {
3838
options: ['content-types', 'entries', 'both'], // only allow the value to be from a discrete set
3939
description: '[optional] specific module name',
4040
}),
41+
'backup-dir': flags.string({
42+
description: '[optional] backup directory name when using specific module',
43+
}),
4144
};
4245

4346
static aliases: string[] = ['cm:import'];

packages/contentstack-import-setup/src/import/modules/extensions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default class ExtensionImportSetup {
4040
for (const extension of Object.values(extensions) as any) {
4141
const targetExtension: any = await this.getExtension(extension);
4242
if (!targetExtension) {
43-
log(this.config, `Extension with title '${extension.title}' not found in the stack!`, 'error');
43+
log(this.config, `Extension with title '${extension.title}' not found in the stack!`, 'info');
4444
continue;
4545
}
4646
this.extensionMapper[extension.uid] = targetExtension.uid;

packages/contentstack-import/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ $ npm install -g @contentstack/cli-cm-import
4747
$ csdx COMMAND
4848
running command...
4949
$ csdx (--version)
50-
@contentstack/cli-cm-import/1.19.1 darwin-arm64 node-v22.2.0
50+
@contentstack/cli-cm-import/1.20.0 darwin-arm64 node-v22.2.0
5151
$ csdx --help [COMMAND]
5252
USAGE
5353
$ csdx COMMAND

packages/contentstack-import/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
{
22
"name": "@contentstack/cli-cm-import",
33
"description": "Contentstack CLI plugin to import content into stack",
4-
"version": "1.19.1",
4+
"version": "1.20.0",
55
"author": "Contentstack",
66
"bugs": "https://github.com/contentstack/cli/issues",
77
"dependencies": {
88
"@contentstack/cli-audit": "~1.7.2",
9+
"@contentstack/cli-cm-import-setup": "~1.0.0-beta.0",
910
"@contentstack/cli-command": "~1.3.2",
1011
"@contentstack/cli-utilities": "~1.8.0",
11-
"@contentstack/management": "~1.17.0",
1212
"@contentstack/cli-variants": "~1.1.1",
13+
"@contentstack/management": "~1.17.0",
1314
"@oclif/core": "^3.26.5",
1415
"big-json": "^3.2.0",
1516
"bluebird": "^3.7.2",

packages/contentstack-import/src/import/modules/content-types.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
import * as path from 'path';
99
import { isEmpty, find, cloneDeep, map } from 'lodash';
10-
import { fsUtil, log, formatError, schemaTemplate, lookupExtension, lookUpTaxonomy } from '../../utils';
10+
import { sanitizePath } from '@contentstack/cli-utilities';
11+
import { fsUtil, log, formatError, schemaTemplate, lookupExtension, lookUpTaxonomy, checkAndCreateMapperFile } from '../../utils';
1112
import { ImportConfig, ModuleClassParams } from '../../types';
1213
import BaseClass, { ApiOptions } from './base-class';
1314
import { updateFieldRules } from '../../utils/content-type-helper';
14-
import { sanitizePath } from '@contentstack/cli-utilities';
1515

1616
export default class ContentTypesImport extends BaseClass {
1717
private cTsMapperPath: string;
@@ -108,6 +108,11 @@ export default class ContentTypesImport extends BaseClass {
108108
return;
109109
}
110110
await fsUtil.makeDirectory(this.cTsMapperPath);
111+
112+
// check and create mapper file
113+
log(this.importConfig, 'Checking and generating CT import dependant mapper file...', 'info');
114+
await checkAndCreateMapperFile(this.importConfig);
115+
111116
this.installedExtensions = (
112117
((await fsUtil.readFile(this.marketplaceAppMapperPath)) as any) || { extension_uid: {} }
113118
).extension_uid;

packages/contentstack-import/src/import/modules/entries.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
lookupAssets,
2222
fileHelper,
2323
lookUpTerms,
24+
checkAndCreateMapperFile,
2425
} from '../../utils';
2526
import { ModuleClassParams } from '../../types';
2627
import BaseClass, { ApiOptions } from './base-class';
@@ -112,6 +113,11 @@ export default class EntriesImport extends BaseClass {
112113
log(this.importConfig, 'No content type found', 'info');
113114
return;
114115
}
116+
117+
// check and create mapper file
118+
log(this.importConfig, 'Checking and generating entries import dependant mapper file...', 'info');
119+
await checkAndCreateMapperFile(this.importConfig);
120+
115121
this.installedExtensions = (
116122
((await fsUtil.readFile(this.marketplaceAppMapperPath)) as any) || { extension_uid: {} }
117123
).extension_uid;
@@ -954,8 +960,8 @@ export default class EntriesImport extends BaseClass {
954960
...content,
955961
locale: publish.locale,
956962
publish_details: [publish],
957-
}))
958-
);
963+
})),
964+
);
959965
apiContent = apiContentDuplicate;
960966
await this.makeConcurrentCall({
961967
apiContent,
@@ -1010,7 +1016,7 @@ export default class EntriesImport extends BaseClass {
10101016
apiOptions.apiData = null;
10111017
return apiOptions;
10121018
}
1013-
if(requestObject.environments.length === 0 || requestObject.locales.length === 0 ){
1019+
if (requestObject.environments.length === 0 || requestObject.locales.length === 0) {
10141020
apiOptions.apiData = null;
10151021
return apiOptions;
10161022
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export default interface ImportConfig extends DefaultConfig, ExternalConfig {
5454
region: Region;
5555
personalizeProjectName?: string;
5656
'exclude-global-modules': false;
57+
alias?: string;
5758
}
5859

5960
type branch = {

0 commit comments

Comments
 (0)