Skip to content

Commit

Permalink
added prompt for mapper directory
Browse files Browse the repository at this point in the history
  • Loading branch information
cs-raj committed Jun 10, 2024
1 parent ecba472 commit b35b9cd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
12 changes: 7 additions & 5 deletions packages/contentstack-import/src/utils/import-config-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { omit, filter, includes, isArray } from 'lodash';
import { configHandler, isAuthenticated, cliux, sanitizePath } from '@contentstack/cli-utilities';
import defaultConfig from '../config';
import { readFile, fileExistsSync } from './file-helper';
import { askContentDir, askAPIKey } from './interactive';
import { askContentDir, askAPIKey, askMapperDir } from './interactive';
import login from './login-handler';
import { ImportConfig } from '../types';

Expand Down Expand Up @@ -95,14 +95,16 @@ const setupConfig = async (importCmdFlags: any): Promise<ImportConfig> => {
config.replaceExisting = importCmdFlags['replace-existing'];
config.skipExisting = importCmdFlags['skip-existing'];

if (importCmdFlags['mapper-dir']) {
config['mapper-dir'] = importCmdFlags['mapper-dir'];
}

if (importCmdFlags['exclude-global-modules']) {
config['exclude-global-modules'] = importCmdFlags['exclude-global-modules'];
}

if (importCmdFlags['mapper-dir'] && importCmdFlags['exclude-global-modules']) {
config['mapper-dir'] = importCmdFlags['mapper-dir'];
} else if (importCmdFlags['exclude-global-modules']) {
config['mapper-dir'] = await askMapperDir();
}

return config;
};

Expand Down
13 changes: 12 additions & 1 deletion packages/contentstack-import/src/utils/interactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,15 @@ export const selectConfiguration = async():Promise<string> =>{
name: 'value',
message: 'Choose the option to proceed',
});
}
}

export const askMapperDir = async (): Promise<string> => {
let result = await cliux.inquire<string>({
type: 'input',
message: 'Enter the path for the Backup Directory of the imported branch',
name: 'dir',
validate: validatePath,
});
result = result.replace(/["']/g, '');
return path.resolve(result);
};

0 comments on commit b35b9cd

Please sign in to comment.