@contentstack/cli 1.60.0-beta.5 → 1.60.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli
18
18
  $ csdx COMMAND
19
19
  running command...
20
20
  $ csdx (--version|-v)
21
- @contentstack/cli/1.60.0-beta.0 darwin-arm64 node-v22.13.1
21
+ @contentstack/cli/1.60.0-beta.7 linux-x64 node-v22.22.1
22
22
  $ csdx --help [COMMAND]
23
23
  USAGE
24
24
  $ csdx COMMAND
@@ -70,7 +70,7 @@ USAGE
70
70
  * [`csdx cm:stacks:import-setup [-k <value>] [-d <value>] [-a <value>] [--modules <value,value>]`](#csdx-cmstacksimport-setup--k-value--d-value--a-value---modules-valuevalue)
71
71
  * [`csdx cm:migrate-rte`](#csdx-cmmigrate-rte)
72
72
  * [`csdx cm:stacks:migration [-k <value>] [-a <value>] [--file-path <value>] [--branch <value>] [--config-file <value>] [--config <value>] [--multiple]`](#csdx-cmstacksmigration--k-value--a-value---file-path-value---branch-value---config-file-value---config-value---multiple)
73
- * [`csdx cm:stacks:seed [--repo <value>] [--org <value>] [-k <value>] [-n <value>] [-y <value>] [-s <value>] [--locale <value>]`](#csdx-cmstacksseed---repo-value---org-value--k-value--n-value--y-value--s-value---locale-value)
73
+ * [`csdx cm:stacks:seed [--repo <value>] [--org <value>] [-k <value>] [-n <value>] [-y] [-s <value>] [--locale <value>]`](#csdx-cmstacksseed---repo-value---org-value--k-value--n-value--y--s-value---locale-value)
74
74
  * [`csdx cm:stacks:clone [--source-branch <value>] [--target-branch <value>] [--source-management-token-alias <value>] [--destination-management-token-alias <value>] [-n <value>] [--type a|b] [--source-stack-api-key <value>] [--destination-stack-api-key <value>] [--import-webhook-status disable|current]`](#csdx-cmstacksclone---source-branch-value---target-branch-value---source-management-token-alias-value---destination-management-token-alias-value--n-value---type-ab---source-stack-api-key-value---destination-stack-api-key-value---import-webhook-status-disablecurrent)
75
75
  * [`csdx cm:stacks:audit`](#csdx-cmstacksaudit)
76
76
  * [`csdx cm:stacks:audit:fix`](#csdx-cmstacksauditfix)
@@ -83,7 +83,7 @@ USAGE
83
83
  * [`csdx cm:stacks:publish-clear-logs`](#csdx-cmstackspublish-clear-logs)
84
84
  * [`csdx cm:stacks:publish-configure`](#csdx-cmstackspublish-configure)
85
85
  * [`csdx cm:stacks:publish-revert`](#csdx-cmstackspublish-revert)
86
- * [`csdx cm:stacks:seed [--repo <value>] [--org <value>] [-k <value>] [-n <value>] [-y <value>] [-s <value>] [--locale <value>]`](#csdx-cmstacksseed---repo-value---org-value--k-value--n-value--y-value--s-value---locale-value)
86
+ * [`csdx cm:stacks:seed [--repo <value>] [--org <value>] [-k <value>] [-n <value>] [-y] [-s <value>] [--locale <value>]`](#csdx-cmstacksseed---repo-value---org-value--k-value--n-value--y--s-value---locale-value)
87
87
  * [`csdx csdx cm:stacks:unpublish [-a <value>] [-e <value>] [-c <value>] [-y] [--locale <value>] [--branch <value>] [--retry-failed <value>] [--bulk-unpublish <value>] [--content-type <value>] [--delivery-token <value>] [--only-assets] [--only-entries]`](#csdx-csdx-cmstacksunpublish--a-value--e-value--c-value--y---locale-value---branch-value---retry-failed-value---bulk-unpublish-value---content-type-value---delivery-token-value---only-assets---only-entries)
88
88
  * [`csdx config:get:base-branch`](#csdx-configgetbase-branch)
89
89
  * [`csdx config:get:ea-header`](#csdx-configgetea-header)
@@ -582,14 +582,14 @@ Bootstrap contentstack apps
582
582
 
583
583
  ```
584
584
  USAGE
585
- $ csdx cm:bootstrap [--app-name <value>] [--project-dir <value>] [-k <value> | --org <value> | -n <value>] [-y
586
- <value>] [--run-dev-server] [-a <value>]
585
+ $ csdx cm:bootstrap [--app-name <value>] [--project-dir <value>] [-k <value> | --org <value> | -n <value>] [-y]
586
+ [--run-dev-server] [-a <value>]
587
587
 
588
588
  FLAGS
589
589
  -a, --alias=<value> Alias of the management token
590
590
  -k, --stack-api-key=<value> Provide stack API key to seed content
591
591
  -n, --stack-name=<value> Name of the new stack that will be created.
592
- -y, --yes=<value> [Optional] Skip stack confirmation
592
+ -y, --yes [Optional] Skip stack confirmation
593
593
  --app-name=<value> App name, kickstart-next, kickstart-next-ssr, kickstart-next-ssg, kickstart-next-graphql,
594
594
  kickstart-next-middleware, kickstart-nuxt, kickstart-nuxt-ssr
595
595
  --org=<value> Provide organization UID to create a new stack
@@ -2566,14 +2566,14 @@ EXAMPLES
2566
2566
  $ csdx cm:migration --alias --file-path <migration/script/file/path> -k <api-key>
2567
2567
  ```
2568
2568
 
2569
- ## `csdx cm:stacks:seed [--repo <value>] [--org <value>] [-k <value>] [-n <value>] [-y <value>] [-s <value>] [--locale <value>]`
2569
+ ## `csdx cm:stacks:seed [--repo <value>] [--org <value>] [-k <value>] [-n <value>] [-y] [-s <value>] [--locale <value>]`
2570
2570
 
2571
2571
  Create a stack from existing content types, entries, assets, etc
2572
2572
 
2573
2573
  ```
2574
2574
  USAGE
2575
- $ csdx cm:seed cm:stacks:seed [--repo <value>] [--org <value>] [-k <value>] [-n <value>] [-y <value>] [-s
2576
- <value>] [--locale <value>]
2575
+ $ csdx cm:seed cm:stacks:seed [--repo <value>] [--org <value>] [-k <value>] [-n <value>] [-y] [-s <value>]
2576
+ [--locale <value>]
2577
2577
 
2578
2578
  FLAGS
2579
2579
  -a, --alias=<value> Alias of the management token
@@ -2582,7 +2582,7 @@ FLAGS
2582
2582
  -o, --org=<value> Provide Organization UID to create a new stack
2583
2583
  -r, --repo=<value> GitHub organization name or GitHub user name/repository name.
2584
2584
  -s, --stack=<value> Provide the stack UID to seed content.
2585
- -y, --yes=<value> [Optional] Skip the stack confirmation.
2585
+ -y, --yes [Optional] Skip the stack confirmation.
2586
2586
 
2587
2587
  DESCRIPTION
2588
2588
  Create a stack from existing content types, entries, assets, etc
@@ -3213,14 +3213,14 @@ EXAMPLES
3213
3213
 
3214
3214
  _See code: [@contentstack/cli-cm-bulk-publish](https://github.com/contentstack/cli/blob/main/packages/contentstack-bulk-publish/src/commands/cm/stacks/publish-revert.js)_
3215
3215
 
3216
- ## `csdx cm:stacks:seed [--repo <value>] [--org <value>] [-k <value>] [-n <value>] [-y <value>] [-s <value>] [--locale <value>]`
3216
+ ## `csdx cm:stacks:seed [--repo <value>] [--org <value>] [-k <value>] [-n <value>] [-y] [-s <value>] [--locale <value>]`
3217
3217
 
3218
3218
  Create a stack from existing content types, entries, assets, etc
3219
3219
 
3220
3220
  ```
3221
3221
  USAGE
3222
- $ csdx cm:stacks:seed [--repo <value>] [--org <value>] [-k <value>] [-n <value>] [-y <value>] [-s <value>]
3223
- [--locale <value>]
3222
+ $ csdx cm:stacks:seed [--repo <value>] [--org <value>] [-k <value>] [-n <value>] [-y] [-s <value>] [--locale
3223
+ <value>]
3224
3224
 
3225
3225
  FLAGS
3226
3226
  -a, --alias=<value> Alias of the management token
@@ -3229,7 +3229,7 @@ FLAGS
3229
3229
  -o, --org=<value> Provide Organization UID to create a new stack
3230
3230
  -r, --repo=<value> GitHub organization name or GitHub user name/repository name.
3231
3231
  -s, --stack=<value> Provide the stack UID to seed content.
3232
- -y, --yes=<value> [Optional] Skip the stack confirmation.
3232
+ -y, --yes [Optional] Skip the stack confirmation.
3233
3233
 
3234
3234
  DESCRIPTION
3235
3235
  Create a stack from existing content types, entries, assets, etc
@@ -0,0 +1,8 @@
1
+ declare const _default: {
2
+ logger: {
3
+ level: string;
4
+ silent: boolean;
5
+ };
6
+ commandRegexPattern: RegExp;
7
+ };
8
+ export default _default;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ logger: {
5
+ level: 'error',
6
+ silent: false,
7
+ },
8
+ commandRegexPattern: /^(config|auth)+:/,
9
+ };
package/lib/help.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { Help } from '@contentstack/cli-utilities';
2
+ export default class MyHelpClass extends Help {
3
+ constructor(config: any, opts: any);
4
+ showRootHelp(): any;
5
+ showCommandHelp(command: any): any;
6
+ formatCommands(commands: any): string;
7
+ }
package/lib/help.js ADDED
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const figlet = tslib_1.__importStar(require("figlet"));
5
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
6
+ class MyHelpClass extends cli_utilities_1.Help {
7
+ constructor(config, opts) {
8
+ super(config, opts);
9
+ }
10
+ showRootHelp() {
11
+ // Shows Contentstack graphics
12
+ cli_utilities_1.cliux.print(figlet.textSync('Contentstack', {
13
+ horizontalLayout: 'default',
14
+ verticalLayout: 'default',
15
+ }));
16
+ super.showRootHelp();
17
+ }
18
+ showCommandHelp(command) {
19
+ if (command.id === 'cm:bulk-publish') {
20
+ let { context: { plugin: { commands = [] } = {} } = {} } = this.config;
21
+ commands = commands.map((c) => {
22
+ return Object.assign(Object.assign({}, c), { name: c.id });
23
+ });
24
+ const title = command.description && this.render(command.description).split('\n')[0];
25
+ if (title)
26
+ console.log(title + '\n');
27
+ console.log(this.formatCommand(command));
28
+ console.log('');
29
+ if (commands.length > 0) {
30
+ console.log(this.formatCommands(commands));
31
+ console.log('');
32
+ }
33
+ return;
34
+ }
35
+ super.showCommandHelp(command);
36
+ }
37
+ formatCommands(commands) {
38
+ if (commands.length === 0)
39
+ return '';
40
+ const body = this.renderList(commands
41
+ // if aliases do not contain the current command's id it is the main command
42
+ .filter(c => !c.aliases.some(a => a === c.id))
43
+ .map(c => {
44
+ if (this.config.topicSeparator !== ':')
45
+ c.id = c.id.replace(/:/g, this.config.topicSeparator);
46
+ // Add aliases at the end of summary
47
+ const summary = c.aliases.length > 0 ? `${this.summary(c)} (ALIASES: ${c.aliases.join(', ')})` : this.summary(c);
48
+ return [c.id, summary];
49
+ }), {
50
+ spacer: '\n',
51
+ stripAnsi: this.opts.stripAnsi,
52
+ indentation: 2
53
+ });
54
+ return this.section('COMMANDS', body);
55
+ }
56
+ }
57
+ exports.default = MyHelpClass;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Set the cli context
3
+ */
4
+ export default function (opts: any): void;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("../../utils");
4
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
5
+ /**
6
+ * Set the cli context
7
+ */
8
+ function default_1(opts) {
9
+ // Store command ID for session-based log organization
10
+ if (opts.id) {
11
+ cli_utilities_1.configHandler.set('currentCommandId', opts.id);
12
+ }
13
+ this.config.context = new utils_1.CsdxContext(opts, this.config);
14
+ }
15
+ exports.default = default_1;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Initialize the utilities
3
+ */
4
+ export default function (_opts: any): void;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
4
+ /**
5
+ * Initialize the utilities
6
+ */
7
+ function default_1(_opts) {
8
+ const { context } = this.config;
9
+ cli_utilities_1.messageHandler.init(context);
10
+ cli_utilities_1.cliux.init(context);
11
+ cli_utilities_1.managementSDKInitiator.init(context);
12
+ cli_utilities_1.marketplaceSDKInitiator.init(context);
13
+ }
14
+ exports.default = default_1;
@@ -0,0 +1 @@
1
+ export default function (opts: any): Promise<void>;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
4
+ // TBD: run region command if region is not there
5
+ async function default_1(opts) {
6
+ const { context: { plugin: { config: { protectedCommands = {} } = {} } = {}, region = null } = {} } = this.config;
7
+ if (opts.Command.id !== 'config:set:region') {
8
+ if (!region) {
9
+ cli_utilities_1.cliux.error('No region found, please set a region $config:set:region');
10
+ this.exit();
11
+ return;
12
+ }
13
+ cli_utilities_1.cliux.print(`Currently using region: ${region.name}`, { color: 'grey' });
14
+ }
15
+ // Auth guard
16
+ if (protectedCommands[opts.Command.id]) {
17
+ if (!(0, cli_utilities_1.isAuthenticated)()) {
18
+ (0, cli_utilities_1.handleAndLogError)(new Error('Authentication required for this command'), { module: 'auth-guard', commandId: opts.Command.id });
19
+ cli_utilities_1.cliux.error('Please log in to execute the command');
20
+ this.exit();
21
+ }
22
+ const client = await (0, cli_utilities_1.managementSDKClient)({ host: region.cma });
23
+ try {
24
+ const result = await client.getUser();
25
+ if (!result) {
26
+ (0, cli_utilities_1.handleAndLogError)(new Error('Error in auth validation'), { module: 'auth-guard' });
27
+ cli_utilities_1.cliux.error('Please log in to execute the command');
28
+ this.exit();
29
+ }
30
+ cli_utilities_1.log.debug('Logged-in user', { module: 'auth-guard', userData: result.data });
31
+ }
32
+ catch (error) {
33
+ (0, cli_utilities_1.handleAndLogError)(error, { module: 'auth-guard' }, 'Error in auth validation');
34
+ cli_utilities_1.cliux.error('Please log in to execute the command');
35
+ process.exit();
36
+ }
37
+ }
38
+ }
39
+ exports.default = default_1;
@@ -0,0 +1 @@
1
+ export default function (_opts: any): Promise<void>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
4
+ async function default_1(_opts) {
5
+ const { context: { plugin: { config: { expiredCommands = {} } = {} } = {}, info: { command = null } = {} } = {} } = this.config;
6
+ if (expiredCommands.hasOwnProperty(command)) {
7
+ cli_utilities_1.cliux.print(`WARNING!!! You're using the old (soon to be deprecated) Contentstack CLI command. We recommend you to use the latest ${expiredCommands[command]} command.`, { color: 'yellow' });
8
+ }
9
+ }
10
+ exports.default = default_1;
@@ -0,0 +1 @@
1
+ export default function (): void;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
4
+ function default_1() {
5
+ const rateLimit = cli_utilities_1.configHandler.get('rateLimit');
6
+ if (!(rateLimit === null || rateLimit === void 0 ? void 0 : rateLimit.default)) {
7
+ const defaultPlan = {
8
+ getLimit: { value: 10, utilize: 50 },
9
+ limit: { value: 10, utilize: 50 },
10
+ bulkLimit: { value: 1, utilize: 50 },
11
+ };
12
+ cli_utilities_1.configHandler.set('rateLimit', { default: defaultPlan });
13
+ cli_utilities_1.cliux.print(`Default rate limit configuration is set to ${JSON.stringify(defaultPlan)}. Please use this command csdx config:set:rate-limit to set the custom rate limit config.`, { color: 'blue' });
14
+ }
15
+ }
16
+ exports.default = default_1;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * When an invalid command is corrected (e.g. loginasda → login), init ran with the invalid
3
+ * command so context.messageFilePath was never set. Re-build context and re-init utilities
4
+ * for the actual command so i18n prompts show human-readable text.
5
+ */
6
+ export default function (opts: {
7
+ Command?: {
8
+ id?: string;
9
+ };
10
+ config?: any;
11
+ }): Promise<void>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
4
+ const utils_1 = require("../../utils");
5
+ /**
6
+ * When an invalid command is corrected (e.g. loginasda → login), init ran with the invalid
7
+ * command so context.messageFilePath was never set. Re-build context and re-init utilities
8
+ * for the actual command so i18n prompts show human-readable text.
9
+ */
10
+ async function default_1(opts) {
11
+ var _a, _b, _c;
12
+ const config = (_a = opts === null || opts === void 0 ? void 0 : opts.config) !== null && _a !== void 0 ? _a : this.config;
13
+ const commandId = (_b = opts === null || opts === void 0 ? void 0 : opts.Command) === null || _b === void 0 ? void 0 : _b.id;
14
+ if (!((_c = config === null || config === void 0 ? void 0 : config.context) === null || _c === void 0 ? void 0 : _c.messageFilePath) && commandId) {
15
+ config.context = new utils_1.CsdxContext({ id: commandId }, config);
16
+ cli_utilities_1.messageHandler.init(config.context);
17
+ cli_utilities_1.cliux.init(config.context);
18
+ cli_utilities_1.managementSDKInitiator.init(config.context);
19
+ cli_utilities_1.marketplaceSDKInitiator.init(config.context);
20
+ }
21
+ }
22
+ exports.default = default_1;
@@ -0,0 +1 @@
1
+ export default function (_opts: any): Promise<void>;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
5
+ const semver = tslib_1.__importStar(require("semver"));
6
+ const versionUpgradeWarningFrequency = {
7
+ versionSyncDuration: 3 * 24 * 60 * 60 * 1000, // 3 days
8
+ };
9
+ async function default_1(_opts) {
10
+ var _a, _b;
11
+ const now = Date.now();
12
+ const today = new Date().toISOString().split('T')[0];
13
+ let cache = { lastChecked: 0, lastWarnedDate: '', latestVersion: '' };
14
+ // if CLI_VERSION is not set or is not the same as the current version, set it
15
+ if (!cli_utilities_1.configHandler.get('CLI_VERSION') || cli_utilities_1.configHandler.get('CLI_VERSION') !== this.config.version) {
16
+ cli_utilities_1.configHandler.set('CLI_VERSION', this.config.version); // set current version in configHandler
17
+ }
18
+ if (!cli_utilities_1.configHandler.get('versionUpgradeWarningFrequency')) {
19
+ cli_utilities_1.configHandler.set('versionUpgradeWarningFrequency', versionUpgradeWarningFrequency);
20
+ }
21
+ const versionUpgradeWarningFrequencyConfig = cli_utilities_1.configHandler.get('versionUpgradeWarningFrequency');
22
+ // Load cache if it exists
23
+ if (cli_utilities_1.configHandler.get('versionUpgradeWarningCache')) {
24
+ cache = cli_utilities_1.configHandler.get('versionUpgradeWarningCache');
25
+ }
26
+ // Perform update check if needed
27
+ const httpClient = new cli_utilities_1.HttpClient();
28
+ if (now - cache.lastChecked > versionUpgradeWarningFrequencyConfig.versionSyncDuration) {
29
+ try {
30
+ const latestVersion = (_b = (_a = (await httpClient.get(`https://registry.npmjs.org/@contentstack/cli/latest`))) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.version;
31
+ if (!latestVersion) {
32
+ (0, cli_utilities_1.handleAndLogError)(new Error('Failed to retrieve the latest version from the registry.'), { module: 'latest-version-warning' });
33
+ return;
34
+ }
35
+ cache.latestVersion = latestVersion;
36
+ cache.lastChecked = now;
37
+ // Save updated cache
38
+ cli_utilities_1.configHandler.set('versionUpgradeWarningCache', cache);
39
+ }
40
+ catch (error) {
41
+ (0, cli_utilities_1.handleAndLogError)(error, { module: 'latest-version-warning' }, 'Failed to check the latest version');
42
+ return;
43
+ }
44
+ }
45
+ // Show warning if an update is available and last warning was yesterday
46
+ if (semver.gt(cache.latestVersion, this.config.version) && cache.lastWarnedDate !== today) {
47
+ cli_utilities_1.cliux.print(`You are not using the most recent CLI release. Please update to the latest version for an improved experience.`, { color: 'yellow' });
48
+ // Update the last warned timestamp
49
+ cache.lastWarnedDate = today;
50
+ cli_utilities_1.configHandler.set('versionUpgradeWarningCache', cache);
51
+ }
52
+ }
53
+ exports.default = default_1;
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ declare const _default: "@oclif/core";
2
+ export default _default;
package/lib/index.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = '@oclif/core';
@@ -0,0 +1,39 @@
1
+ import { Config, Plugin } from '@contentstack/cli-utilities';
2
+ export interface PrintOptions {
3
+ color?: string;
4
+ }
5
+ export interface InquirePayload {
6
+ type: string;
7
+ name: string;
8
+ message: string;
9
+ choices?: Array<any>;
10
+ transformer?: Function;
11
+ }
12
+ export interface Region {
13
+ name: string;
14
+ cma: string;
15
+ cda: string;
16
+ }
17
+ export interface Context {
18
+ id: string;
19
+ user: {
20
+ authtoken: string;
21
+ email: string;
22
+ };
23
+ region: any;
24
+ plugin: Plugin;
25
+ config: any;
26
+ info: any;
27
+ messageFilePath: any;
28
+ }
29
+ export interface CLIConfig extends Config {
30
+ context: Context;
31
+ }
32
+ export interface IVersionUpgradeCache {
33
+ lastChecked: number;
34
+ lastWarnedDate: string;
35
+ latestVersion: string;
36
+ }
37
+ export interface IVersionUpgradeWarningFrequency {
38
+ versionSyncDuration: number;
39
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,17 @@
1
+ export default class CsdxContext {
2
+ readonly sessionId: string;
3
+ readonly clientId: string;
4
+ readonly user?: object;
5
+ readonly region?: object;
6
+ readonly config: object;
7
+ readonly info: any;
8
+ readonly plugin: any;
9
+ readonly pluginConfig: any;
10
+ readonly messageFilePath: string;
11
+ readonly analyticsInfo: string;
12
+ flagWarningPrintState: any;
13
+ flags: any;
14
+ cliVersion: string;
15
+ constructor(cliOpts: any, cliConfig: any);
16
+ getToken(alias: string): any;
17
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const shortUUID = tslib_1.__importStar(require("short-uuid"));
5
+ const path = tslib_1.__importStar(require("path"));
6
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
7
+ const node_machine_id_1 = require("node-machine-id");
8
+ class CsdxContext {
9
+ constructor(cliOpts, cliConfig) {
10
+ var _a, _b, _c;
11
+ const analyticsInfo = [];
12
+ const command = cliConfig.findCommand(cliOpts.id) || {};
13
+ const config = cli_utilities_1.configHandler;
14
+ const platform = cliConfig.platform && cliConfig.arch ? `${cliConfig.platform}-${cliConfig.arch}` : 'none';
15
+ analyticsInfo.push(platform);
16
+ const nodeVersion = process.versions.node ? `v${process.versions.node}` : process.version;
17
+ analyticsInfo.push(nodeVersion || 'none');
18
+ analyticsInfo.push(cliConfig.version || 'none');
19
+ this.clientId = cli_utilities_1.configHandler.get('clientId');
20
+ if (!this.clientId) {
21
+ this.clientId = (0, node_machine_id_1.machineIdSync)(true);
22
+ cli_utilities_1.configHandler.set('clientId', this.clientId);
23
+ }
24
+ analyticsInfo.push(this.clientId);
25
+ const sessionId = shortUUID.generate();
26
+ cli_utilities_1.configHandler.set('sessionId', sessionId);
27
+ this.sessionId = sessionId;
28
+ analyticsInfo.push(this.sessionId);
29
+ this.user = {
30
+ authtoken: cli_utilities_1.configHandler.get('authtoken'),
31
+ email: cli_utilities_1.configHandler.get('email'),
32
+ };
33
+ this.config = Object.assign({}, config);
34
+ this.cliVersion = cliConfig.version;
35
+ this.region = cli_utilities_1.configHandler.get('region');
36
+ this.info = { command: cliOpts.id };
37
+ if (command.pluginName) {
38
+ this.plugin = (cliConfig.plugins || new Map()).get(command.pluginName) || {};
39
+ this.plugin.name = command.pluginName;
40
+ this.plugin.config = Object.assign({}, ((this.plugin.pjson && this.plugin.pjson.csdxConfig) || {}));
41
+ this.messageFilePath = (0, cli_utilities_1.pathValidator)(path.resolve((0, cli_utilities_1.sanitizePath)(this.plugin.root), (0, cli_utilities_1.sanitizePath)(this.plugin.config.messageFilePath) || './messages/index.json'));
42
+ this.info.shortCommandName = (_c = (_b = (_a = this.plugin) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.shortCommandName) === null || _c === void 0 ? void 0 : _c[cliOpts.id];
43
+ analyticsInfo.push(this.info.shortCommandName || cliOpts.id);
44
+ }
45
+ this.flagWarningPrintState = {};
46
+ this.analyticsInfo = analyticsInfo.join(';');
47
+ }
48
+ getToken(alias) {
49
+ if (alias) {
50
+ const token = cli_utilities_1.configHandler.get(`tokens.${alias}`);
51
+ if (token)
52
+ return token;
53
+ }
54
+ }
55
+ }
56
+ exports.default = CsdxContext;
@@ -0,0 +1 @@
1
+ export { default as CsdxContext } from './context-handler';
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CsdxContext = void 0;
7
+ var context_handler_1 = require("./context-handler");
8
+ Object.defineProperty(exports, "CsdxContext", { enumerable: true, get: function () { return __importDefault(context_handler_1).default; } });
@@ -0,0 +1,4 @@
1
+ {
2
+ "commands": {},
3
+ "version": "1.60.0-beta.7"
4
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@contentstack/cli",
3
3
  "description": "Command-line tool (CLI) to interact with Contentstack v1-beta",
4
- "version": "1.60.0-beta.5",
4
+ "version": "1.60.0-beta.7",
5
5
  "author": "Contentstack",
6
6
  "bin": {
7
7
  "csdx": "./bin/run.js"
@@ -22,24 +22,24 @@
22
22
  "prepack": "pnpm compile && oclif manifest && oclif readme"
23
23
  },
24
24
  "dependencies": {
25
- "@contentstack/cli-audit": "~1.19.0-beta.0",
26
- "@contentstack/cli-cm-export": "~1.24.0-beta.0",
27
- "@contentstack/cli-cm-import": "~1.32.0-beta.0",
28
- "@contentstack/cli-auth": "~1.8.0-beta.0",
29
- "@contentstack/cli-cm-bootstrap": "~1.19.0-beta.0",
30
- "@contentstack/cli-cm-branches": "~1.7.0-beta.0",
31
- "@contentstack/cli-cm-bulk-publish": "~1.11.0-beta.0",
32
- "@contentstack/cli-cm-clone": "~1.21.0-beta.0",
33
- "@contentstack/cli-cm-export-to-csv": "~1.12.0-beta.0",
34
- "@contentstack/cli-cm-import-setup": "~1.8.0-beta.0",
25
+ "@contentstack/cli-audit": "~1.19.0-beta.1",
26
+ "@contentstack/cli-cm-export": "~1.24.0-beta.1",
27
+ "@contentstack/cli-cm-import": "~1.32.0-beta.1",
28
+ "@contentstack/cli-auth": "~1.8.0-beta.1",
29
+ "@contentstack/cli-cm-bootstrap": "~1.19.0-beta.1",
30
+ "@contentstack/cli-cm-branches": "~1.7.0-beta.1",
31
+ "@contentstack/cli-cm-bulk-publish": "~1.11.0-beta.1",
32
+ "@contentstack/cli-cm-clone": "~1.21.0-beta.1",
33
+ "@contentstack/cli-cm-export-to-csv": "~1.12.0-beta.1",
34
+ "@contentstack/cli-cm-import-setup": "~1.8.0-beta.1",
35
35
  "@contentstack/cli-cm-migrate-rte": "~1.6.4",
36
- "@contentstack/cli-cm-seed": "~1.15.0-beta.0",
37
- "@contentstack/cli-command": "~1.8.0-beta.0",
38
- "@contentstack/cli-config": "~1.20.0-beta.0",
36
+ "@contentstack/cli-cm-seed": "~1.15.0-beta.1",
37
+ "@contentstack/cli-command": "~1.8.0-beta.1",
38
+ "@contentstack/cli-config": "~1.20.0-beta.1",
39
39
  "@contentstack/cli-launch": "^1.9.6",
40
- "@contentstack/cli-migration": "~1.12.0-beta.0",
41
- "@contentstack/cli-utilities": "~1.18.0-beta.0",
42
- "@contentstack/cli-variants": "~1.4.0-beta.0",
40
+ "@contentstack/cli-migration": "~1.12.0-beta.1",
41
+ "@contentstack/cli-utilities": "~1.19.0-beta.0",
42
+ "@contentstack/cli-variants": "~1.4.0-beta.1",
43
43
  "@contentstack/management": "~1.27.5",
44
44
  "@oclif/core": "^4.3.0",
45
45
  "@oclif/plugin-help": "^6.2.28",
@@ -156,6 +156,7 @@
156
156
  ],
157
157
  "hooks": {
158
158
  "prerun": [
159
+ "./lib/hooks/prerun/init-context-for-command",
159
160
  "./lib/hooks/prerun/command-deprecation-check",
160
161
  "./lib/hooks/prerun/default-rate-limit-check",
161
162
  "./lib/hooks/prerun/latest-version-warning"
@@ -167,4 +168,4 @@
167
168
  }
168
169
  },
169
170
  "repository": "https://github.com/contentstack/cli"
170
- }
171
+ }