diff --git a/package-lock.json b/package-lock.json index 8d12b089a7..6960c2abd9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24301,12 +24301,12 @@ }, "packages/contentstack": { "name": "@contentstack/cli", - "version": "1.21.2", + "version": "1.22.0", "license": "MIT", "dependencies": { "@contentstack/cli-audit": "~1.6.4", "@contentstack/cli-auth": "~1.3.20", - "@contentstack/cli-cm-bootstrap": "~1.9.4", + "@contentstack/cli-cm-bootstrap": "~1.10.0", "@contentstack/cli-cm-branches": "~1.1.2", "@contentstack/cli-cm-bulk-publish": "~1.4.8", "@contentstack/cli-cm-clone": "~1.10.7", @@ -24314,7 +24314,7 @@ "@contentstack/cli-cm-export-to-csv": "~1.7.2", "@contentstack/cli-cm-import": "~1.16.4", "@contentstack/cli-cm-migrate-rte": "~1.4.18", - "@contentstack/cli-cm-seed": "~1.7.7", + "@contentstack/cli-cm-seed": "~1.7.8", "@contentstack/cli-command": "~1.2.19", "@contentstack/cli-config": "~1.6.5", "@contentstack/cli-launch": "~1.1.0", @@ -24700,7 +24700,7 @@ }, "packages/contentstack-bootstrap": { "name": "@contentstack/cli-cm-bootstrap", - "version": "1.9.4", + "version": "1.10.0", "license": "MIT", "dependencies": { "@contentstack/cli-cm-seed": "~1.7.6", @@ -26472,7 +26472,7 @@ }, "packages/contentstack-seed": { "name": "@contentstack/cli-cm-seed", - "version": "1.7.7", + "version": "1.7.8", "license": "MIT", "dependencies": { "@contentstack/cli-cm-import": "~1.16.4", diff --git a/packages/contentstack-bootstrap/README.md b/packages/contentstack-bootstrap/README.md index 91066d0405..982912d9ae 100644 --- a/packages/contentstack-bootstrap/README.md +++ b/packages/contentstack-bootstrap/README.md @@ -15,7 +15,7 @@ $ npm install -g @contentstack/cli-cm-bootstrap $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-cm-bootstrap/1.9.4 darwin-arm64 node-v22.2.0 +@contentstack/cli-cm-bootstrap/1.10.0 darwin-arm64 node-v22.2.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-bootstrap/package.json b/packages/contentstack-bootstrap/package.json index f0041f120f..8254ee5dc1 100644 --- a/packages/contentstack-bootstrap/package.json +++ b/packages/contentstack-bootstrap/package.json @@ -1,7 +1,7 @@ { "name": "@contentstack/cli-cm-bootstrap", "description": "Bootstrap contentstack apps", - "version": "1.9.4", + "version": "1.10.0", "author": "Contentstack", "bugs": "https://github.com/contentstack/cli/issues", "scripts": { diff --git a/packages/contentstack-bootstrap/src/bootstrap/index.ts b/packages/contentstack-bootstrap/src/bootstrap/index.ts index b0e8e9ae0f..43de31b33e 100644 --- a/packages/contentstack-bootstrap/src/bootstrap/index.ts +++ b/packages/contentstack-bootstrap/src/bootstrap/index.ts @@ -19,6 +19,7 @@ export interface BootstrapOptions { accessToken?: string; appType: string; livePreviewEnabled?: boolean; + master_locale: any; } export interface SeedParams { @@ -97,6 +98,9 @@ export default class Bootstrap { if (this.options.seedParams.managementTokenAlias) { cmd.push('--alias', this.options.seedParams.managementTokenAlias); } + if (this.options.master_locale) { + cmd.push('--locale', this.options.master_locale); + } const result = await ContentStackSeed.run(cmd); if (result && result.api_key) { @@ -127,4 +131,4 @@ export default class Bootstrap { cliux.error(messageHandler.parse('CLI_BOOTSTRAP_STACK_CREATION_FAILED', this.appConfig.stack)); } } -} +} \ No newline at end of file diff --git a/packages/contentstack-bootstrap/src/bootstrap/utils.ts b/packages/contentstack-bootstrap/src/bootstrap/utils.ts index a2fcebcead..e01d67a689 100644 --- a/packages/contentstack-bootstrap/src/bootstrap/utils.ts +++ b/packages/contentstack-bootstrap/src/bootstrap/utils.ts @@ -19,7 +19,7 @@ interface EnviornmentVariables { * Create delivery token * Create enviroment */ - +let managementTokenResult: any; export const setupEnvironments = async ( managementAPIClient: any, api_key: string, @@ -34,6 +34,51 @@ export const setupEnvironments = async ( .environment() .query() .find(); + + //create management token if not present + if(!managementToken){ + const managementBody = { + "token":{ + "name":"sample app", + "description":"This is a sample management token.", + "scope":[ + { + "module":"content_type", + "acl":{ + "read":true, + "write":true + } + }, + { + "module":"branch", + "branches":[ + "main" + ], + "acl":{ + "read":true + } + } + ], + "expires_on": "3000-01-01", + "is_email_notification_enabled":false + } + } + managementTokenResult = await managementAPIClient + .stack({ api_key: api_key }) + .managementToken() + .create(managementBody); + if(!managementTokenResult.uid){ + cliux.print( + `Info: Failed to generate a management token.\nNote: Management token is not available in your plan. Please contact the admin for support.`, + { + color: 'yellow', + }, + ); + if ((await continueBootstrapCommand()) === 'no') { + return; + } + } + } if (Array.isArray(environmentResult.items) && environmentResult.items.length > 0) { for (const environment of environmentResult.items) { if (environment.name) { @@ -144,6 +189,7 @@ const envFileHandler = async ( const managementAPIHost = region?.cma?.substring('8'); const regionName = region && region.name && region.name.toLowerCase(); previewHost = region?.uiHost?.substring(8)?.replace('app', 'rest-preview'); + const cdnHost = region?.cda?.substring('8'); appHost = region?.uiHost?.substring(8); const isUSRegion = regionName === 'us' || regionName === 'na'; if (regionName !== 'eu' && !isUSRegion) { @@ -194,19 +240,20 @@ const envFileHandler = async ( filePath = pathValidator(path.join(sanitizePath(clonedDirectory), sanitizePath(fileName))); content = `CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nCONTENTSTACK_DELIVERY_TOKEN=${ environmentVariables.deliveryToken - }\n${ + }\nCONTENTSTACK_BRANCH=main${ livePreviewEnabled ? `\nCONTENTSTACK_PREVIEW_TOKEN=${ environmentVariables.preview_token || `''` - }\nCONTENTSTACK_PREVIEW_HOST=${previewHost}\nCONTENTSTACK_APP_HOST=${appHost}\n` + }\nCONTENTSTACK_PREVIEW_HOST=${previewHost}\n` : '\n' - }CONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}\nCONTENTSTACK_API_HOST=${ + }CONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}${ + !isUSRegion && !customHost ? '\nCONTENTSTACK_REGION=' + region.name : '' + }\nCONTENTSTACK_LIVE_PREVIEW=${livePreviewEnabled}\nCONTENTSTACK_LIVE_EDIT_TAGS=false\nCONTENTSTACK_API_HOST=${ customHost ? customHost : managementAPIHost }${ !isUSRegion && !customHost ? '\nCONTENTSTACK_REGION=' + region.name : '' - }\nCONTENTSTACK_LIVE_PREVIEW=${livePreviewEnabled}\nCONTENTSTACK_LIVE_EDIT_TAGS=false`; + }\nCONTENTSTACK_APP_HOST=${appHost}\nCONTENTSTACK_MANAGEMENT_TOKEN=${managementTokenResult.uid}\nCONTENTSTACK_HOST=${cdnHost}`; result = await writeEnvFile(content, filePath); - break; case 'gatsby': case 'gatsby-starter': fileName = `.env.${environmentVariables.environment}`; diff --git a/packages/contentstack-bootstrap/src/commands/cm/bootstrap.ts b/packages/contentstack-bootstrap/src/commands/cm/bootstrap.ts index 7aef231b8c..d45d155f73 100644 --- a/packages/contentstack-bootstrap/src/commands/cm/bootstrap.ts +++ b/packages/contentstack-bootstrap/src/commands/cm/bootstrap.ts @@ -18,6 +18,7 @@ import { import config, { getAppLevelConfigByName, AppConfig } from '../../config'; import messageHandler from '../../messages'; +export const DEFAULT_MASTER_LOCALE = 'en-us'; export default class BootstrapCommand extends Command { private bootstrapManagementAPIClient: any; @@ -152,6 +153,8 @@ export default class BootstrapCommand extends Command { const yes = bootstrapCommandFlags.yes as string; const appConfig: AppConfig = getAppLevelConfigByName(selectedAppName || selectedApp.configKey); + + let master_locale = appConfig.master_locale || DEFAULT_MASTER_LOCALE; let cloneDirectory = (bootstrapCommandFlags.directory as string) || (bootstrapCommandFlags['project-dir'] as string); @@ -187,6 +190,7 @@ export default class BootstrapCommand extends Command { region: this.region, appType, livePreviewEnabled, + master_locale, }; const bootstrap = new Bootstrap(options); await bootstrap.run(); @@ -194,4 +198,4 @@ export default class BootstrapCommand extends Command { this.error(error, { exit: 1, suggestions: error.suggestions }); } } -} +} \ No newline at end of file diff --git a/packages/contentstack-bootstrap/src/config.ts b/packages/contentstack-bootstrap/src/config.ts index 82d281e016..ee012cc46f 100644 --- a/packages/contentstack-bootstrap/src/config.ts +++ b/packages/contentstack-bootstrap/src/config.ts @@ -11,6 +11,7 @@ export interface AppConfig { private?: boolean; branch?: string; appConfigKey?: string; + master_locale?: string; } const config: Configuration = { @@ -49,8 +50,9 @@ const config: Configuration = { stack: 'contentstack/stack-contentstack-angular-modularblock-example', }, 'compass-app': { - source: 'SunilLsagar/universal-demo', - stack: 'SunilLsagar/stack-universal-demo', + source: 'SunilLsagar/universal-demo-latest', + stack: 'SunilLsagar/stack-universal-demo-latest', + master_locale: 'en', }, 'nuxtjs-disabled': { source: 'contentstack/contentstack-nuxtjs-vue-universal-demo', @@ -98,4 +100,4 @@ export function getAppLevelConfigByName(appConfigKey: string): any { } config.appLevelConfig[appConfigKey].appConfigKey = appConfigKey; return config.appLevelConfig[appConfigKey]; -} +} \ No newline at end of file diff --git a/packages/contentstack-import/src/import/modules/custom-roles.ts b/packages/contentstack-import/src/import/modules/custom-roles.ts index 240db7a680..bd45ac73d0 100644 --- a/packages/contentstack-import/src/import/modules/custom-roles.ts +++ b/packages/contentstack-import/src/import/modules/custom-roles.ts @@ -59,7 +59,7 @@ export default class ImportCustomRoles extends BaseClass { this.customRoles = fsUtil.readFile(join(this.customRolesFolderPath, this.customRolesConfig.fileName),true) as Record; this.customRolesLocales = fsUtil.readFile(join(this.customRolesFolderPath, this.customRolesConfig.customRolesLocalesFileName),true) as Record; } else { - log(this.importConfig, `No such file or directory - '${this.customRolesFolderPath}'`, 'error'); + log(this.importConfig, `No custom-rules are found - '${this.customRolesFolderPath}'`, 'info'); return; } diff --git a/packages/contentstack-import/src/import/modules/environments.ts b/packages/contentstack-import/src/import/modules/environments.ts index 3695b61d4c..811c5873e5 100644 --- a/packages/contentstack-import/src/import/modules/environments.ts +++ b/packages/contentstack-import/src/import/modules/environments.ts @@ -45,7 +45,7 @@ export default class ImportEnvironments extends BaseClass { unknown >; } else { - log(this.importConfig, `No such file or directory - '${this.environmentsFolderPath}'`, 'error'); + log(this.importConfig, `No Environments Found - '${this.environmentsFolderPath}'`, 'info'); return; } diff --git a/packages/contentstack-import/src/import/modules/extensions.ts b/packages/contentstack-import/src/import/modules/extensions.ts index ce92433ca9..e63f867d2c 100644 --- a/packages/contentstack-import/src/import/modules/extensions.ts +++ b/packages/contentstack-import/src/import/modules/extensions.ts @@ -52,7 +52,7 @@ export default class ImportExtensions extends BaseClass { Record >; } else { - log(this.importConfig, `No such file or directory - '${this.extensionsFolderPath}'`, 'error'); + log(this.importConfig, `No Extensions Found - '${this.extensionsFolderPath}'`, 'info'); return; } diff --git a/packages/contentstack-import/src/import/modules/labels.ts b/packages/contentstack-import/src/import/modules/labels.ts index 2ba0d5eddb..13c8344baf 100644 --- a/packages/contentstack-import/src/import/modules/labels.ts +++ b/packages/contentstack-import/src/import/modules/labels.ts @@ -44,7 +44,7 @@ export default class Importlabels extends BaseClass { if (fileHelper.fileExistsSync(this.labelsFolderPath)) { this.labels = fsUtil.readFile(join(this.labelsFolderPath, 'labels.json'), true) as Record; } else { - log(this.importConfig, `No such file or directory - '${this.labelsFolderPath}'`, 'error'); + log(this.importConfig, `No labels found - '${this.labelsFolderPath}'`, 'info'); return; } @@ -71,7 +71,7 @@ export default class Importlabels extends BaseClass { async importlabels() { if (this.labels === undefined || isEmpty(this.labels)) { - log(this.importConfig, 'No Label Found', 'info'); + log(this.importConfig, 'No Labels Found', 'info'); return; } diff --git a/packages/contentstack-import/src/import/modules/marketplace-apps.ts b/packages/contentstack-import/src/import/modules/marketplace-apps.ts index f938847c11..330af3b3dd 100644 --- a/packages/contentstack-import/src/import/modules/marketplace-apps.ts +++ b/packages/contentstack-import/src/import/modules/marketplace-apps.ts @@ -80,7 +80,7 @@ export default class ImportMarketplaceApps { true, ) as Installation[]; } else { - log(this.importConfig, `No such file or directory - '${this.marketPlaceFolderPath}'`, 'error'); + log(this.importConfig, `No Marketplace apps are found - '${this.marketPlaceFolderPath}'`, 'info'); return; } diff --git a/packages/contentstack-import/src/import/modules/taxonomies.ts b/packages/contentstack-import/src/import/modules/taxonomies.ts index ce2bd885f5..c23994c6c1 100644 --- a/packages/contentstack-import/src/import/modules/taxonomies.ts +++ b/packages/contentstack-import/src/import/modules/taxonomies.ts @@ -47,7 +47,7 @@ export default class ImportTaxonomies extends BaseClass { unknown >; } else { - log(this.importConfig, `No such file or directory - '${this.taxonomiesFolderPath}'`, 'error'); + log(this.importConfig, `No Taxonomies Found! - '${this.taxonomiesFolderPath}'`, 'info'); return; } diff --git a/packages/contentstack-import/src/import/modules/webhooks.ts b/packages/contentstack-import/src/import/modules/webhooks.ts index 35dc814d93..ce1d87de3a 100644 --- a/packages/contentstack-import/src/import/modules/webhooks.ts +++ b/packages/contentstack-import/src/import/modules/webhooks.ts @@ -43,7 +43,7 @@ export default class ImportWebhooks extends BaseClass { if (fileHelper.fileExistsSync(this.webhooksFolderPath)) { this.webhooks = fsUtil.readFile(join(this.webhooksFolderPath, 'webhooks.json'), true) as Record; } else { - log(this.importConfig, `No such file or directory - '${this.webhooksFolderPath}'`, 'error'); + log(this.importConfig, `No Webhooks Found - '${this.webhooksFolderPath}'`, 'info'); return; } diff --git a/packages/contentstack-import/src/import/modules/workflows.ts b/packages/contentstack-import/src/import/modules/workflows.ts index 4cbd4ebcee..735efc0e92 100644 --- a/packages/contentstack-import/src/import/modules/workflows.ts +++ b/packages/contentstack-import/src/import/modules/workflows.ts @@ -54,7 +54,7 @@ export default class ImportWorkflows extends BaseClass { unknown >; } else { - log(this.importConfig, `No such file or directory - '${this.workflowsFolderPath}'`, 'error'); + log(this.importConfig, `No Workflows Found - '${this.workflowsFolderPath}'`, 'info'); return; } diff --git a/packages/contentstack-migration/examples/taxonomies/import-taxonomies.js b/packages/contentstack-migration/examples/taxonomies/import-taxonomies.js index f6bb70503c..985bfe3f74 100644 --- a/packages/contentstack-migration/examples/taxonomies/import-taxonomies.js +++ b/packages/contentstack-migration/examples/taxonomies/import-taxonomies.js @@ -81,7 +81,7 @@ module.exports = ({ migration, stackSDKInstance, managementAPIClient, config }) task: async (params) => { try { stack = stackClient(); - if (!fs.existsSync(dataDir)) throw new Error(`No such file or directory - ${dataDir}`); + if (!fs.existsSync(dataDir)) throw new Error(`No Taxonomies folder found! - ${dataDir}`); const taxonomies = await readCsv(dataDir, { headers: true, delimiter }); if (!taxonomies?.length) throw new Error('No Taxonomies found!'); diff --git a/packages/contentstack-seed/README.md b/packages/contentstack-seed/README.md index 87c01dc7b9..f6de1ce652 100644 --- a/packages/contentstack-seed/README.md +++ b/packages/contentstack-seed/README.md @@ -10,16 +10,17 @@ To import content to your stack, you can choose from the following two sources: ## Commands -* [`csdx cm:stacks:seed [--repo ] [--org ] [-k ] [-n ] [-y ] [-s ]`](#csdx-cmstacksseed---repo-value---org-value--k-value--n-value--y-value--s-value) -* [`csdx cm:stacks:seed [--repo ] [--org ] [-k ] [-n ] [-y ] [-s ]`](#csdx-cmstacksseed---repo-value---org-value--k-value--n-value--y-value--s-value-1) +* [`csdx cm:stacks:seed [--repo ] [--org ] [-k ] [-n ] [-y ] [-s ] [--locale ]`](#csdx-cmstacksseed---repo-value---org-value--k-value--n-value--y-value--s-value---locale-value) +* [`csdx cm:stacks:seed [--repo ] [--org ] [-k ] [-n ] [-y ] [-s ] [--locale ]`](#csdx-cmstacksseed---repo-value---org-value--k-value--n-value--y-value--s-value---locale-value-1) -## `csdx cm:stacks:seed [--repo ] [--org ] [-k ] [-n ] [-y ] [-s ]` +## `csdx cm:stacks:seed [--repo ] [--org ] [-k ] [-n ] [-y ] [-s ] [--locale ]` Create a stack from existing content types, entries, assets, etc ``` USAGE - $ csdx cm:stacks:seed [--repo ] [--org ] [-k ] [-n ] [-y ] [-s ] + $ csdx cm:stacks:seed [--repo ] [--org ] [-k ] [-n ] [-y ] [-s ] [--locale + ] FLAGS -a, --alias= Alias of the management token @@ -48,13 +49,14 @@ EXAMPLES $ csdx cm:stacks:seed --repo "account/repository" --org "your-org-uid" --stack-name "stack-name" //create a new stack in given org uid ``` -## `csdx cm:stacks:seed [--repo ] [--org ] [-k ] [-n ] [-y ] [-s ]` +## `csdx cm:stacks:seed [--repo ] [--org ] [-k ] [-n ] [-y ] [-s ] [--locale ]` Create a stack from existing content types, entries, assets, etc ``` USAGE - $ csdx cm:stacks:seed [--repo ] [--org ] [-k ] [-n ] [-y ] [-s ] + $ csdx cm:stacks:seed [--repo ] [--org ] [-k ] [-n ] [-y ] [-s ] [--locale + ] FLAGS -a, --alias= Alias of the management token diff --git a/packages/contentstack-seed/package.json b/packages/contentstack-seed/package.json index 222b79bec7..f18d5ce106 100644 --- a/packages/contentstack-seed/package.json +++ b/packages/contentstack-seed/package.json @@ -1,7 +1,7 @@ { "name": "@contentstack/cli-cm-seed", "description": "create a Stack from existing content types, entries, assets, etc.", - "version": "1.7.7", + "version": "1.7.8", "author": "Contentstack", "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { diff --git a/packages/contentstack-seed/src/commands/cm/stacks/seed.ts b/packages/contentstack-seed/src/commands/cm/stacks/seed.ts index 13da29d801..649a1856fa 100644 --- a/packages/contentstack-seed/src/commands/cm/stacks/seed.ts +++ b/packages/contentstack-seed/src/commands/cm/stacks/seed.ts @@ -20,7 +20,7 @@ export default class SeedCommand extends Command { '$ csdx cm:stacks:seed --repo "account/repository" --org "your-org-uid" --stack-name "stack-name" //create a new stack in given org uid', ]; - static usage = 'cm:stacks:seed [--repo ] [--org ] [-k ] [-n ] [-y ] [-s ]'; + static usage = 'cm:stacks:seed [--repo ] [--org ] [-k ] [-n ] [-y ] [-s ] [--locale ]'; static flags: FlagInput = { repo: flags.string({ @@ -78,6 +78,10 @@ export default class SeedCommand extends Command { char: 'a', description: 'Alias of the management token', }), + locale: flags.string({ + description: 'Master Locale of the stack', + hidden: true, + }), }; static aliases = ['cm:seed']; @@ -105,6 +109,7 @@ export default class SeedCommand extends Command { skipStackConfirmation: seedFlags['yes'], isAuthenticated: isAuthenticated(), alias: managementTokenAlias, + master_locale: seedFlags['locale'], }; const listOfTokens = configHandler.get('tokens'); @@ -127,4 +132,4 @@ export default class SeedCommand extends Command { this.error(errorObj, { exit: 1, suggestions: errorObj.suggestions }); } } -} +} \ No newline at end of file diff --git a/packages/contentstack-seed/src/seed/contentstack/client.ts b/packages/contentstack-seed/src/seed/contentstack/client.ts index 178e8aa30f..4ef01bedc1 100644 --- a/packages/contentstack-seed/src/seed/contentstack/client.ts +++ b/packages/contentstack-seed/src/seed/contentstack/client.ts @@ -16,6 +16,12 @@ export interface Stack { org_uid: string; } +export interface ManagementToken { + response_code: string; + response_message: string; +} + + export interface CreateStackOptions { name: string; description: string; @@ -23,6 +29,20 @@ export interface CreateStackOptions { org_uid: string; } +export interface createManagementTokenOptions{ + name: string; + description: string; + expires_on: string; + scope: { + module: string; + acl: { + read: boolean; + write?: boolean; + }; + branches?: string[]; + }[]; +} + export default class ContentstackClient { instance: Promise; @@ -167,6 +187,37 @@ export default class ContentstackClient { } } + async createManagementToken(api_key: string, managementToken: any, options: createManagementTokenOptions): Promise { + try { + const client = await this.instance; + const body = { + token: { + name: options.name, + description: options.description, + scope: options.scope, + expires_on: options.expires_on, + }, + }; + + const response = await client.stack({ api_key: api_key, management_token: managementToken }).managementToken().create(body); + return { + response_code: response.errorCode, + response_message: response.errorMessage + }; + } catch (error: unknown) { + const typedError = error as { errorCode: string }; + + if (typedError.errorCode === '401') { + return { + response_code: '401', + response_message: 'You do not have access to create management tokens. Please try again or ask an Administrator for assistance.' + } + } + throw this.buildError(typedError); + } + + } + private buildError(error: any) { const message = error.errorMessage || error.response.data?.errorMessage || error.response.statusText; const status = error.status; diff --git a/packages/contentstack-seed/src/seed/index.ts b/packages/contentstack-seed/src/seed/index.ts index 6d9a074baa..4223acb0a3 100644 --- a/packages/contentstack-seed/src/seed/index.ts +++ b/packages/contentstack-seed/src/seed/index.ts @@ -31,6 +31,7 @@ export interface ContentModelSeederOptions { isAuthenticated: boolean | false; managementToken?: string | undefined; alias?: string | undefined; + master_locale?: string | undefined; } export default class ContentModelSeeder { @@ -83,12 +84,13 @@ export default class ContentModelSeeder { const tmpPath = await this.downloadRelease(); cliux.print(`Importing into ${this.managementToken ? 'your stack' : `'${stackResponse.name}'`}.`); + await importer.run({ api_key: api_key, cdaHost: this.options.cdaHost, cmaHost: this.options.cmaHost, - master_locale: ENGLISH_LOCALE, + master_locale : this.options.master_locale || ENGLISH_LOCALE, tmpPath: tmpPath, isAuthenticated: this.options.isAuthenticated, alias: this.options.alias, @@ -169,7 +171,7 @@ export default class ContentModelSeeder { const newStack = await this.csClient.createStack({ name: stackName, description: '', - master_locale: ENGLISH_LOCALE, + master_locale: this.options.master_locale || ENGLISH_LOCALE, org_uid: organization.uid, }); @@ -180,6 +182,48 @@ export default class ContentModelSeeder { async shouldProceed(api_key: string) { let count; + const stack_details = await this.csClient.getStack(api_key); + if(this.options.master_locale != stack_details.master_locale){ + cliux.print(`Compass app requires the master locale to be set to English (en).`,{ + color: "yellow", + bold: true, + }); + return false; + } + const managementBody = { + "name":"Checking roles for creating management token", + "description":"This is a compass app management token.", + "scope":[ + { + "module":"content_type", + "acl":{ + "read":true, + "write":true + } + }, + { + "module":"branch", + "branches":[ + "main" + ], + "acl":{ + "read":true + } + } + ], + "expires_on": "3000-01-01", + "is_email_notification_enabled":false + } + let managementTokenResult = await this.csClient.createManagementToken(api_key, this.managementToken, managementBody); + if(managementTokenResult?.response_code == "161" || managementTokenResult?.response_code == "401"){ + cliux.print( + `Info: Failed to generate a management token.\nNote: Management token is not available in your plan. Please contact the admin for support.`, + { + color: 'red', + }, + ); + return false; + } count = await this.csClient.getContentTypeCount(api_key, this.managementToken); if (count > 0 && this._options.skipStackConfirmation !== 'yes') { @@ -228,4 +272,4 @@ export default class ContentModelSeeder { ); } } -} +} \ No newline at end of file diff --git a/packages/contentstack/README.md b/packages/contentstack/README.md index 961ab99ec3..c814f26738 100644 --- a/packages/contentstack/README.md +++ b/packages/contentstack/README.md @@ -69,7 +69,7 @@ USAGE * [`csdx cm:stacks:import [-c ] [-k ] [-d ] [-a ] [--module ] [--backup-dir ] [--branch ] [--import-webhook-status disable|current]`](#csdx-cmstacksimport--c-value--k-value--d-value--a-value---module-value---backup-dir-value---branch-value---import-webhook-status-disablecurrent) * [`csdx cm:migrate-rte`](#csdx-cmmigrate-rte) * [`csdx cm:stacks:migration [-k ] [-a ] [--file-path ] [--branch ] [--config-file ] [--config ] [--multiple]`](#csdx-cmstacksmigration--k-value--a-value---file-path-value---branch-value---config-file-value---config-value---multiple) -* [`csdx cm:stacks:seed [--repo ] [--org ] [-k ] [-n ] [-y ] [-s ]`](#csdx-cmstacksseed---repo-value---org-value--k-value--n-value--y-value--s-value) +* [`csdx cm:stacks:seed [--repo ] [--org ] [-k ] [-n ] [-y ] [-s ] [--locale ]`](#csdx-cmstacksseed---repo-value---org-value--k-value--n-value--y-value--s-value---locale-value) * [`csdx cm:stacks:clone [--source-branch ] [--target-branch ] [--source-management-token-alias ] [--destination-management-token-alias ] [-n ] [--type a|b] [--source-stack-api-key ] [--destination-stack-api-key ] [--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) * [`csdx cm:stacks:audit`](#csdx-cmstacksaudit) * [`csdx cm:stacks:audit:fix`](#csdx-cmstacksauditfix) @@ -81,7 +81,7 @@ USAGE * [`csdx cm:stacks:publish-clear-logs`](#csdx-cmstackspublish-clear-logs) * [`csdx cm:stacks:publish-configure`](#csdx-cmstackspublish-configure) * [`csdx cm:stacks:publish-revert`](#csdx-cmstackspublish-revert) -* [`csdx cm:stacks:seed [--repo ] [--org ] [-k ] [-n ] [-y ] [-s ]`](#csdx-cmstacksseed---repo-value---org-value--k-value--n-value--y-value--s-value-1) +* [`csdx cm:stacks:seed [--repo ] [--org ] [-k ] [-n ] [-y ] [-s ] [--locale ]`](#csdx-cmstacksseed---repo-value---org-value--k-value--n-value--y-value--s-value---locale-value-1) * [`csdx csdx cm:stacks:unpublish [-a ] [-e ] [-c ] [-y] [--locale ] [--branch ] [--retry-failed ] [--bulk-unpublish ] [--content-type ] [--delivery-token ] [--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-1) * [`csdx config:get:base-branch`](#csdx-configgetbase-branch) * [`csdx config:get:ea-header`](#csdx-configgetea-header) @@ -2283,14 +2283,14 @@ EXAMPLES $ csdx cm:migration --alias --file-path -k ``` -## `csdx cm:stacks:seed [--repo ] [--org ] [-k ] [-n ] [-y ] [-s ]` +## `csdx cm:stacks:seed [--repo ] [--org ] [-k ] [-n ] [-y ] [-s ] [--locale ]` Create a stack from existing content types, entries, assets, etc ``` USAGE $ csdx cm:seed cm:stacks:seed [--repo ] [--org ] [-k ] [-n ] [-y ] [-s - ] + ] [--locale ] FLAGS -a, --alias= Alias of the management token @@ -2800,13 +2800,14 @@ EXAMPLES _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)_ -## `csdx cm:stacks:seed [--repo ] [--org ] [-k ] [-n ] [-y ] [-s ]` +## `csdx cm:stacks:seed [--repo ] [--org ] [-k ] [-n ] [-y ] [-s ] [--locale ]` Create a stack from existing content types, entries, assets, etc ``` USAGE $ csdx cm:stacks:seed [--repo ] [--org ] [-k ] [-n ] [-y ] [-s ] + [--locale ] FLAGS -a, --alias= Alias of the management token @@ -3583,7 +3584,11 @@ EXAMPLES $ csdx plugins:inspect myplugin ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.2/src/commands/plugins/inspect.ts)_ + + +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/inspect.ts)_ + + ## `csdx plugins:install PLUGIN` @@ -3632,7 +3637,9 @@ EXAMPLES $ csdx plugins:install someuser/someplugin ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.2/src/commands/plugins/install.ts)_ + +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/install.ts)_ + ## `csdx plugins:link PATH` @@ -3662,7 +3669,9 @@ EXAMPLES $ csdx plugins:link myplugin ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.2/src/commands/plugins/link.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/link.ts)_ + + ## `csdx plugins:remove [PLUGIN]` @@ -3703,7 +3712,10 @@ FLAGS --reinstall Reinstall all plugins after uninstalling. ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.2/src/commands/plugins/reset.ts)_ + +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/reset.ts)_ + + ## `csdx plugins:uninstall [PLUGIN]` @@ -3731,7 +3743,9 @@ EXAMPLES $ csdx plugins:uninstall myplugin ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.2/src/commands/plugins/uninstall.ts)_ + +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/uninstall.ts)_ + ## `csdx plugins:unlink [PLUGIN]` @@ -3775,7 +3789,8 @@ DESCRIPTION Update installed plugins. ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.2/src/commands/plugins/update.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/update.ts)_ + ## `csdx tokens` diff --git a/packages/contentstack/package.json b/packages/contentstack/package.json index 952caf0416..11f41fd90c 100755 --- a/packages/contentstack/package.json +++ b/packages/contentstack/package.json @@ -1,7 +1,7 @@ { "name": "@contentstack/cli", "description": "Command-line tool (CLI) to interact with Contentstack", - "version": "1.21.2", + "version": "1.22.0", "author": "Contentstack", "bin": { "csdx": "./bin/run.js" @@ -24,7 +24,7 @@ "dependencies": { "@contentstack/cli-audit": "~1.6.4", "@contentstack/cli-auth": "~1.3.20", - "@contentstack/cli-cm-bootstrap": "~1.9.4", + "@contentstack/cli-cm-bootstrap": "~1.10.0", "@contentstack/cli-cm-branches": "~1.1.2", "@contentstack/cli-cm-bulk-publish": "~1.4.8", "@contentstack/cli-cm-export": "~1.11.6", @@ -32,7 +32,7 @@ "@contentstack/cli-cm-export-to-csv": "~1.7.2", "@contentstack/cli-cm-import": "~1.16.4", "@contentstack/cli-cm-migrate-rte": "~1.4.18", - "@contentstack/cli-cm-seed": "~1.7.7", + "@contentstack/cli-cm-seed": "~1.7.8", "@contentstack/cli-command": "~1.2.19", "@contentstack/cli-config": "~1.6.5", "@contentstack/cli-launch": "~1.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2ff65dc3dc..4646256b7a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,7 +12,7 @@ importers: specifiers: '@contentstack/cli-audit': ~1.6.4 '@contentstack/cli-auth': ~1.3.20 - '@contentstack/cli-cm-bootstrap': ~1.9.4 + '@contentstack/cli-cm-bootstrap': ~1.10.0 '@contentstack/cli-cm-branches': ~1.1.2 '@contentstack/cli-cm-bulk-publish': ~1.4.8 '@contentstack/cli-cm-clone': ~1.10.7 @@ -20,7 +20,7 @@ importers: '@contentstack/cli-cm-export-to-csv': ~1.7.2 '@contentstack/cli-cm-import': ~1.16.4 '@contentstack/cli-cm-migrate-rte': ~1.4.18 - '@contentstack/cli-cm-seed': ~1.7.7 + '@contentstack/cli-cm-seed': ~1.7.8 '@contentstack/cli-command': ~1.2.19 '@contentstack/cli-config': ~1.6.5 '@contentstack/cli-launch': ~1.1.0