Skip to content

Commit 3233750

Browse files
Merge pull request #2101 from contentstack/fix/DX-3246
add path validation while import
2 parents b5b7a87 + 38b3f26 commit 3233750

File tree

21 files changed

+1807
-1618
lines changed

21 files changed

+1807
-1618
lines changed

.talismanrc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
fileignoreconfig:
22
- filename: package-lock.json
3-
checksum: 59d20d0ac10b0d5d4014817c8453e4aa9fe0be396f7902999373273a9d471658
3+
checksum: b7a69ac42575d552fa99e0f7b62fa16485cdb8bb83efec3c5d46c22537e8bc37
44
- filename: pnpm-lock.yaml
5-
checksum: 7cade45c0e4ff4755b6e7d0f7ce0e40fa5b62131513d9f800635ef4288fdc058
5+
checksum: 62fc7744149464cc3a0b285544e90739d48e8e1384ac211d4799389c3c78db10
66
- filename: packages/contentstack-import-setup/test/unit/backup-handler.test.ts
77
checksum: 0582d62b88834554cf12951c8690a73ef3ddbb78b82d2804d994cf4148e1ef93
88
- filename: packages/contentstack-import-setup/test/config.json
@@ -81,4 +81,10 @@ fileignoreconfig:
8181
checksum: 7024f22a6ed3908d7cf074bbd8e7107e2d9f43bbcc42939b28d360c89d44cc29
8282
- filename: packages/contentstack-bulk-publish/src/util/generate-bulk-publish-url.js
8383
checksum: 5f7c1e2fac3e7fab21e861d609c54ca7191ee09fd076dd0adc66604043bf7a43
84+
- filename: packages/contentstack-import/src/utils/interactive.ts
85+
checksum: b401a6166313c184712ff623ea8d95a5548fb3d8b8229c053ae44a1850b54a72
86+
- filename: packages/contentstack-import-setup/src/utils/backup-handler.ts
87+
checksum: 7db02c6f2627400b28fc96d505bf074d477080a45ba13943709d4845b6ca0908
88+
- filename: packages/contentstack-import/src/utils/backup-handler.ts
89+
checksum: 4f7a8bea92ebffbc34a0979b3a63fef327562a899b773481d67a675140cfa4bf
8490
version: "1.0"

package-lock.json

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

packages/contentstack-bootstrap/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"test:report": "nyc --reporter=lcov mocha \"test/**/*.test.js\""
1717
},
1818
"dependencies": {
19-
"@contentstack/cli-cm-seed": "~1.12.1",
19+
"@contentstack/cli-cm-seed": "~1.12.2",
2020
"@contentstack/cli-command": "~1.6.1",
2121
"@contentstack/cli-utilities": "~1.14.0",
2222
"@oclif/core": "^4.3.0",

packages/contentstack-clone/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $ npm install -g @contentstack/cli-cm-clone
1616
$ csdx COMMAND
1717
running command...
1818
$ csdx (--version)
19-
@contentstack/cli-cm-clone/1.15.0 darwin-arm64 node-v22.13.1
19+
@contentstack/cli-cm-clone/1.16.1 darwin-arm64 node-v22.13.1
2020
$ csdx --help [COMMAND]
2121
USAGE
2222
$ csdx COMMAND

packages/contentstack-clone/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "@contentstack/cli-cm-clone",
33
"description": "Contentstack stack clone plugin",
4-
"version": "1.16.0",
4+
"version": "1.16.1",
55
"author": "Contentstack",
66
"bugs": "https://github.com/rohitmishra209/cli-cm-clone/issues",
77
"dependencies": {
88
"@colors/colors": "^1.6.0",
99
"@contentstack/cli-cm-export": "~1.20.1",
10-
"@contentstack/cli-cm-import": "~1.27.0",
10+
"@contentstack/cli-cm-import": "~1.28.0",
1111
"@contentstack/cli-command": "~1.6.1",
1212
"@contentstack/cli-utilities": "~1.14.0",
1313
"@oclif/core": "^4.3.0",

packages/contentstack-import-setup/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-setup
4747
$ csdx COMMAND
4848
running command...
4949
$ csdx (--version)
50-
@contentstack/cli-cm-import-setup/1.4.0 darwin-arm64 node-v22.13.1
50+
@contentstack/cli-cm-import-setup/1.5.0 darwin-arm64 node-v22.13.1
5151
$ csdx --help [COMMAND]
5252
USAGE
5353
$ csdx COMMAND

packages/contentstack-import-setup/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-setup",
33
"description": "Contentstack CLI plugin to setup the mappers and configurations for the import command",
4-
"version": "1.4.2",
4+
"version": "1.5.0",
55
"author": "Contentstack",
66
"bugs": "https://github.com/contentstack/cli/issues",
77
"dependencies": {

packages/contentstack-import-setup/src/utils/backup-handler.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ export default async function backupHandler(importConfig: ImportConfig): Promise
1010
return importConfig.useBackedupDir;
1111
}
1212

13+
const sourceDir = importConfig.branchDir || importConfig.contentDir;
14+
1315
let backupDirPath: string;
14-
const subDir = isSubDirectory(importConfig);
16+
const subDir = isSubDirectory(importConfig, sourceDir);
1517

1618
if (subDir) {
17-
backupDirPath = path.resolve(
18-
sanitizePath(importConfig.contentDir),
19-
'..',
20-
'_backup_' + Math.floor(Math.random() * 1000),
21-
);
19+
backupDirPath = path.resolve(sanitizePath(sourceDir), '..', '_backup_' + Math.floor(Math.random() * 1000));
2220
if (importConfig.createBackupDir) {
2321
cliux.print(
2422
`Warning!!! Provided backup directory path is a sub directory of the content directory, Cannot copy to a sub directory. Hence new backup directory created - ${backupDirPath}`,
@@ -42,7 +40,7 @@ export default async function backupHandler(importConfig: ImportConfig): Promise
4240
if (backupDirPath) {
4341
cliux.print('Copying content to the backup directory...');
4442
return new Promise((resolve, reject) => {
45-
return copy(importConfig.contentDir, backupDirPath, (error: any) => {
43+
return copy(sourceDir, backupDirPath, (error: any) => {
4644
if (error) {
4745
trace(error, 'error', true);
4846
return reject(error);
@@ -58,8 +56,8 @@ export default async function backupHandler(importConfig: ImportConfig): Promise
5856
* @param importConfig
5957
* @returns
6058
*/
61-
function isSubDirectory(importConfig: ImportConfig) {
62-
const parent = importConfig.contentDir;
59+
function isSubDirectory(importConfig: ImportConfig, sourceDir: string) {
60+
const parent = sourceDir;
6361
const child = importConfig.createBackupDir ? importConfig.createBackupDir : process.cwd();
6462
const relative = path.relative(parent, child);
6563

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.27.0 darwin-arm64 node-v22.14.0
50+
@contentstack/cli-cm-import/1.28.0 darwin-arm64 node-v22.14.0
5151
$ csdx --help [COMMAND]
5252
USAGE
5353
$ csdx COMMAND

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.27.0",
4+
"version": "1.28.0",
55
"author": "Contentstack",
66
"bugs": "https://github.com/contentstack/cli/issues",
77
"dependencies": {

0 commit comments

Comments
 (0)