GeezerVison is showing github.com — Merge branch 'v2-dev' into feat/Asset-Scanning · contentstack/cli-plugins@5127b41
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +5-49Lines changed: 5 additions & 49 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | fileignoreconfig: | 2 | 2 | - filename: pnpm-lock.yaml | 3 | | - checksum: 5655958b698c47f8d7de9cbdb635b5141ebb350c126d2d7e445c36c81dbf2f5a | 4 | | -- filename: packages/contentstack-branches/test/unit/helpers/stub-auth.ts | 5 | | - checksum: 8cafd5994d3ec13ba9af74c80b330bfd14721ea4e0359b456598964a6c2913ce | 6 | | -- filename: packages/contentstack-external-migrate/src/lib/create-stack.ts | 7 | | - checksum: 68a9510db6f2746ac5006c091d276c1ba619a9e15c76a3edae3967e4f9c2dd4e | 8 | | -- filename: packages/contentstack-export/src/config/index.ts | 9 | | - checksum: 0219426b1873decef4d74bef5bfd50d1ed8f2567a2136122d869e4e53e4b4b99 | 10 | | -- filename: packages/contentstack-external-migrate/test/adapters/contentful/export.test.ts | 11 | | - checksum: 118cc140edf3b68191d1ef770c4142f9f5aa7af87a5a1832d6b3edee53d61c83 | 12 | | -- filename: packages/contentstack-external-migrate/test/commands/migrate/import.test.ts | 13 | | - checksum: 1d955eb34ab7e7e11cfad35cdbcb00692e39568bc690f46089fcbc0ca22a4852 | | 3 | + checksum: e37e3f40d68a726bd19d13f93cfc1279d726f1509b9bfbffcdf657df4efad70b | 14 | 4 | - filename: packages/contentstack-import/src/import/modules/assets.ts | 15 | | - checksum: feeded23026aaafe0d37cf48f793e39961a10631a1341847b9093c09fdb93978 | 16 | | -- filename: packages/contentstack-migration/README.md | 17 | | - checksum: ceb7631888ee81711a32e2ac07762957bbf0f9c6c7f3f6bbc5d86326bd4352cc | 18 | | -- filename: packages/contentstack-bulk-operations/src/messages/index.ts | 19 | | - checksum: 89b7a29368d7906243c549451b574bde86183e20024fd03324e40b1c859dd274 | 20 | | -- filename: packages/contentstack-bulk-operations/src/commands/cm/stacks/bulk-assets.ts | 21 | | - checksum: 1d0afda53710a14b9e93a0dd4c9412471ae155bbd8a8272694ee354e76670db7 | 22 | | -- filename: packages/contentstack-bulk-operations/src/base-bulk-command.ts | 23 | | - checksum: 4949eacff2d3fe2d4729da68baf28fd639ddba576f86fb19d163c2a04367cb71 | 24 | | -- filename: packages/contentstack-bulk-operations/test/unit/services/taxonomy-service.test.ts | 25 | | - checksum: abc5ac707341760cf59d5b8b1c4e13cf2c79955e2735c33e2db3ec6bc48eddb6 | 26 | | -- filename: packages/contentstack-bulk-operations/src/utils/operation-flag-matrix.ts | 27 | | - checksum: 99a3c3eb422a17f73f4c8f15088004fa4c95df3545bdf510310c1f3a20e4c2c2 | 28 | | -- filename: packages/contentstack-bulk-operations/test/unit/base-bulk-command.test.ts | 29 | | - checksum: ca699a9d73757d44ded4d9d27beb4f460f911a7c88a14551a9402a3ac0c69873 | 30 | | -- filename: packages/contentstack-cli-cm-regex-validate/test/utils/connect-stack.test.ts | 31 | | - checksum: 018980aa2b919967b9ef9ab1bdf635d4867fe21593fba5890afa443f440228ff | 32 | | -- filename: packages/contentstack-bulk-operations/test/unit/commands/bulk-assets-cs-assets.test.ts | 33 | | - checksum: 1b6b5b0302d3efd9508e2e5d4fe3783da97a110735ca3106ce829cfe93874150 | 34 | | -- filename: packages/contentstack-clone/README.md | 35 | | - checksum: fad666bf6290c980406ddd18caec2dd89d9c7a22b422010865199659956ab523 | 36 | | -- filename: packages/contentstack-bulk-operations/test/unit/utils/operation-flag-matrix.test.ts | 37 | | - checksum: 35451ca4c03359b06531a8461091f4a3a45c4dea1f8853081fb53e4ce28c1cc3 | 38 | | -- filename: packages/contentstack-external-migrate/test/lib/create-stack.test.ts | 39 | | - checksum: 2dcbc359ee275e59e0536f3c325416eac8c43eb341b04da0d3757f5b5e556d9c | 40 | | -- filename: packages/contentstack-cli-tsgen/test/unit/helper.test.ts | 41 | | - checksum: 146ff2a85a8f5ec463e51821f54c5f08143fa04209541a51017270e83b6ed46d | 42 | | -- filename: packages/contentstack-bulk-operations/test/unit/commands/bulk-assets-init.test.ts | 43 | | - checksum: 590b1cfe42d46d0917ac90f363b1ccd05200b180bd9c58c770ffd1f12eb18327 | 44 | | -- filename: packages/contentstack-asset-management/src/utils/export-helpers.ts | 45 | | - checksum: 726d1632110ebc203ce70dc1cbe7d4b3011f56349ed371b6645d0375e7818cad | 46 | | -- filename: packages/contentstack-export/src/utils/export-config-handler.ts | 47 | | - checksum: 3ff8e8ea60f92311f8224bce457f7aaab026194de61e13eebdc6ca5a39f66bc9 | 48 | | -- filename: packages/contentstack-asset-management/src/utils/cs-assets-api-adapter.ts | 49 | | - checksum: bc4a53f96be6a10786e00133245c7bdc43c965c8a98b753e3879e1110cf9c601 | 50 | | -- filename: packages/contentstack-asset-management/test/unit/utils/cs-assets-api-adapter.test.ts | 51 | | - checksum: 63c6bff4d51842d8fa3cce88545259d0a2c3cfe71df95d303d993f692cee883b | 52 | | -version: '1.0' | | 5 | + checksum: f00f743e50ddc040e79e40677bfd2f220b55bab02d8924265cb2c0ef508e9008 | | 6 | +- filename: packages/contentstack-import/src/utils/import-config-handler.ts | | 7 | + checksum: 5b2050b283ea3d990e8ad3207b054c6932b76d2bd82a9f659b287ef11dec9f83 | | 8 | + version: "" |
Collapse file Copy file name to clipboardExpand all lines: packages/contentstack-apps-cli/package.json +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 110 | 110 | "app:deploy": "APDP" | 111 | 111 | } | 112 | 112 | } | 113 | | -} | | 113 | +} |
Collapse file Copy file name to clipboardExpand all lines: packages/contentstack-export/package.json +2-4Lines changed: 2 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 91 | 91 | "shortCommandName": { | 92 | 92 | "cm:stacks:export": "EXPRT" | 93 | 93 | }, | 94 | | - "planProtectedFeatures": [ | 95 | | - "amAssets" | 96 | | - ] | | 94 | + "planProtectedFeatures": ["assetsScan", "amAssets"] | 97 | 95 | }, | 98 | 96 | "repository": { | 99 | 97 | "type": "git", | 100 | 98 | "url": "git+https://github.com/contentstack/cli-plugins.git", | 101 | 99 | "directory": "packages/contentstack-export" | 102 | 100 | } | 103 | | -} | | 101 | +} |
Collapse file Copy file name to clipboardExpand all lines: packages/contentstack-export/src/utils/export-config-handler.ts +4-8Lines changed: 4 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -37,12 +37,9 @@ const setupConfig = async (exportCmdFlags: any, context?: any): Promise<ExportCo | 37 | 37 | if (legacyCsAssetsConfig) { | 38 | 38 | externalConfig.modules['cs-assets'] = externalConfig.modules['cs-assets'] || legacyCsAssetsConfig; | 39 | 39 | delete externalConfig.modules['asset-management']; | 40 | | - log.warn( | 41 | | - 'Config key "modules.asset-management" is deprecated. Please rename it to "modules.cs-assets".', | 42 | | - ); | | 40 | + log.warn('Config key "modules.asset-management" is deprecated. Please rename it to "modules.cs-assets".'); | 43 | 41 | } | 44 | 42 |
| 45 | | - | 46 | 43 | config = merge.recursive(config, externalConfig); | 47 | 44 | } | 48 | 45 | config.exportDir = sanitizePath( | @@ -60,10 +57,9 @@ const setupConfig = async (exportCmdFlags: any, context?: any): Promise<ExportCo | 60 | 57 | config.exportDir = path.resolve(config.exportDir); | 61 | 58 |
| 62 | 59 | if (isDirectoryNonEmpty(config.exportDir)) { | 63 | | - cliux.print( | 64 | | - '\nThe export directory is not empty. Existing files in this folder may be overwritten.', | 65 | | - { color: 'yellow' }, | 66 | | - ); | | 60 | + cliux.print('\nThe export directory is not empty. Existing files in this folder may be overwritten.', { | | 61 | + color: 'yellow', | | 62 | + }); | 67 | 63 | } | 68 | 64 |
| 69 | 65 | const managementTokenAlias = exportCmdFlags['management-token-alias'] || exportCmdFlags['alias']; | |
Collapse file Copy file name to clipboardExpand all lines: packages/contentstack-import/package.json +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 83 | 83 | "csdxConfig": { | 84 | 84 | "shortCommandName": { | 85 | 85 | "cm:stacks:import": "IMPRT" | 86 | | - } | | 86 | + }, | | 87 | + "planProtectedFeatures": ["assetsScan"] | | 88 | + | 87 | 89 | }, | 88 | 90 | "repository": { | 89 | 91 | "type": "git", | 90 | 92 | "url": "git+https://github.com/contentstack/cli-plugins.git", | 91 | 93 | "directory": "packages/contentstack-import" | 92 | 94 | } | 93 | | -} | | 95 | +} |
Collapse file Copy file name to clipboardExpand all lines: packages/contentstack-import/src/commands/cm/stacks/import.ts +5-2Lines changed: 5 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -144,7 +144,7 @@ export default class ImportCommand extends Command { | 144 | 144 | let importConfig: ImportConfig; | 145 | 145 | try { | 146 | 146 | const { flags } = await this.parse(ImportCommand); | 147 | | - importConfig = await setupImportConfig(flags); | | 147 | + importConfig = await setupImportConfig(flags, this.context); | 148 | 148 | // Prepare the context object | 149 | 149 | createLogContext( | 150 | 150 | this.context?.info?.command || 'cm:stacks:import', | @@ -182,7 +182,10 @@ export default class ImportCommand extends Command { | 182 | 182 | if (importConfig.assetScanningEnabled) { | 183 | 183 | cliux.print('\nAsset Scanning is enabled — assets were not published.', { color: 'yellow' }); | 184 | 184 | cliux.print(' Once scanning completes, publish your assets using:', { color: 'yellow' }); | 185 | | - cliux.print(` csdx cm:stacks:bulk-assets --data-dir ${backupDir} --stack-api-key ${importConfig.apiKey} --operation publish`, { color: 'cyan' }); | | 185 | + cliux.print( | | 186 | + ` csdx cm:stacks:bulk-assets --data-dir ${backupDir} --stack-api-key ${importConfig.apiKey} --operation publish`, | | 187 | + { color: 'cyan' }, | | 188 | + ); | 186 | 189 | } | 187 | 190 | this.logSuccessAndBackupMessages(backupDir, importConfig); | 188 | 191 | // Clear progress module setting now that import is complete | |
Collapse file Copy file name to clipboardExpand all lines: packages/contentstack-import/src/import/module-importer.ts -6Lines changed: 0 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -26,12 +26,6 @@ class ModuleImporter { | 26 | 26 | const stackDetails: Record<string, unknown> = await this.stackAPIClient.fetch(); | 27 | 27 | this.importConfig.stackName = stackDetails.name as string; | 28 | 28 | this.importConfig.org_uid = stackDetails.org_uid as string; | 29 | | - | 30 | | - const assetScanningEnabled = await this.detectAssetScanning(this.importConfig.org_uid); | 31 | | - if (assetScanningEnabled) { | 32 | | - this.importConfig.assetScanningEnabled = true; | 33 | | - this.importConfig.skipAssetsPublish = true; | 34 | | - } | 35 | 29 | } | 36 | 30 |
| 37 | 31 | await this.resolveImportPath(); | |
Collapse file Copy file name to clipboardExpand all lines: packages/contentstack-import/src/import/modules/assets.ts +14-5Lines changed: 14 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -8,7 +8,7 @@ import uniq from 'lodash/uniq'; | 8 | 8 | import { existsSync } from 'node:fs'; | 9 | 9 | import includes from 'lodash/includes'; | 10 | 10 | import { resolve as pResolve, join } from 'node:path'; | 11 | | -import { FsUtility, log, handleAndLogError, generateUid } from '@contentstack/cli-utilities'; | | 11 | +import { FsUtility, log, handleAndLogError, generateUid, FeatureStatus } from '@contentstack/cli-utilities'; | 12 | 12 | import { ImportSpaces, type SpaceMapping } from '@contentstack/cli-asset-management'; | 13 | 13 | import { PATH_CONSTANTS } from '../../constants'; | 14 | 14 |
| @@ -39,11 +39,13 @@ export default class ImportAssets extends BaseClass { | 39 | 39 | private assetsUrlMap: Record<string, unknown> = {}; | 40 | 40 | private assetsFolderMap: Record<string, unknown> = {}; | 41 | 41 | private rootFolder: { uid: string; name: string; parent_uid: string; created_at: string }; | | 42 | + private planStatus: Record<string, FeatureStatus> = {}; | 42 | 43 |
| 43 | 44 | constructor({ importConfig, stackAPIClient }: ModuleClassParams) { | 44 | 45 | super({ importConfig, stackAPIClient }); | 45 | 46 | this.importConfig.context.module = MODULE_CONTEXTS.ASSETS; | 46 | 47 | this.currentModuleName = MODULE_NAMES[MODULE_CONTEXTS.ASSETS]; | | 48 | + this.planStatus = this.importConfig.planStatus || {}; | 47 | 49 |
| 48 | 50 | this.assetsPath = join(this.importConfig.backupDir, PATH_CONSTANTS.CONTENT_DIRS.ASSETS); | 49 | 51 | this.mapperDirPath = join(this.importConfig.backupDir, PATH_CONSTANTS.MAPPER, PATH_CONSTANTS.MAPPER_MODULES.ASSETS); | @@ -66,6 +68,10 @@ export default class ImportAssets extends BaseClass { | 66 | 68 | try { | 67 | 69 | log.debug('Starting assets import process...', this.importConfig.context); | 68 | 70 |
| | 71 | + if (this.planStatus['assetsScan']?.is_part_of_plan) { | | 72 | + log.info('Assets Scanning is enabled in this stack', this.importConfig.context); | | 73 | + log.warn('Assets publishing will be skipped', this.importConfig.context); | | 74 | + } | 69 | 75 | // CS Assets: csAssetsEnabled is set in the config handler when spaces/ + am_v2 are detected. | 70 | 76 | if (this.importConfig.csAssetsEnabled) { | 71 | 77 | if (!this.importConfig.csAssetsUrl) { | @@ -203,10 +209,13 @@ export default class ImportAssets extends BaseClass { | 203 | 209 | log.success('Assets imported successfully!', this.importConfig.context); | 204 | 210 |
| 205 | 211 | if (this.importConfig.assetScanningEnabled) { | 206 | | - log.info(' Asset Scanning is enabled for this stack.', this.importConfig.context); | 207 | | - log.info(' Assets cannot be published immediately — scanning must complete first.', this.importConfig.context); | 208 | | - log.info(' Once scanning is done, publish your assets using:', this.importConfig.context); | 209 | | - log.info(' csdx cm:stacks:bulk-assets --data-dir ./content --stack-api-key <key> --operation publish', this.importConfig.context); | | 212 | + log.info('Asset Scanning is enabled for this stack.', this.importConfig.context); | | 213 | + log.info('Assets cannot be published immediately — scanning must complete first.', this.importConfig.context); | | 214 | + log.info('Once scanning is done, publish your assets using:', this.importConfig.context); | | 215 | + log.info( | | 216 | + 'csdx cm:stacks:bulk-assets --data-dir ./content --stack-api-key <key> --operation publish', | | 217 | + this.importConfig.context, | | 218 | + ); | 210 | 219 | } | 211 | 220 | } catch (error) { | 212 | 221 | this.completeProgress(false, error?.message || 'Asset import failed'); | |
Collapse file Copy file name to clipboardExpand all lines: packages/contentstack-import/src/types/import-config.ts +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +import { FeatureStatus } from '@contentstack/cli-utilities'; | 1 | 2 | import { Context, Modules, Region } from '.'; | 2 | 3 | import DefaultConfig from './default-config'; | 3 | 4 |
| @@ -61,6 +62,7 @@ export default interface ImportConfig extends DefaultConfig, ExternalConfig { | 61 | 62 | context: Context; | 62 | 63 | csAssetsUrl?: string; | 63 | 64 | csAssetsEnabled?: boolean; | | 65 | + planStatus?: Record<string, FeatureStatus>; | 64 | 66 | } | 65 | 67 |
| 66 | 68 | type branch = { | |
Collapse file Copy file name to clipboardExpand all lines: packages/contentstack-import/src/utils/import-config-handler.ts +37-2Lines changed: 37 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import merge from 'merge'; | 2 | 2 | import * as path from 'path'; | 3 | 3 | import { omit, filter, includes, isArray } from 'lodash'; | 4 | | -import { configHandler, isAuthenticated, cliux, sanitizePath, log } from '@contentstack/cli-utilities'; | | 4 | +import { | | 5 | + configHandler, | | 6 | + isAuthenticated, | | 7 | + cliux, | | 8 | + sanitizePath, | | 9 | + log, | | 10 | + isFeatureEnabled, | | 11 | + FeatureCtx, | | 12 | +} from '@contentstack/cli-utilities'; | 5 | 13 | import defaultConfig from '../config'; | 6 | 14 | import { readFile, readFileSync } from './file-helper'; | 7 | 15 | import { askContentDir, askAPIKey } from './interactive'; | 8 | 16 | import login from './login-handler'; | 9 | 17 | import { ImportConfig } from '../types'; | 10 | 18 | import { existsSync } from 'fs'; | 11 | 19 |
| 12 | | -const setupConfig = async (importCmdFlags: any): Promise<ImportConfig> => { | | 20 | +const setupConfig = async (importCmdFlags: any, context?: any): Promise<ImportConfig> => { | 13 | 21 | // Set progress supported module FIRST, before any log calls | 14 | 22 | // This ensures the logger respects the showConsoleLogs setting correctly | 15 | 23 | configHandler.set('log.progressSupportedModule', 'import'); | @@ -167,6 +175,33 @@ const setupConfig = async (importCmdFlags: any): Promise<ImportConfig> => { | 167 | 175 | config.authenticationMethod = authenticationMethod; | 168 | 176 | log.debug('Import configuration setup completed.', { ...config }); | 169 | 177 |
| | 178 | + // Deferred plan check — credentials now available after setupImportConfig | | 179 | + const deferredFeatures: string[] = context?.planCheckRequired ?? []; | | 180 | + if (deferredFeatures.length > 0) { | | 181 | + const planCtx: FeatureCtx = { | | 182 | + apiKey: config.apiKey, | | 183 | + managementToken: config.management_token, | | 184 | + authToken: config.auth_token, | | 185 | + }; | | 186 | + for (const featureUid of deferredFeatures) { | | 187 | + try { | | 188 | + const status = await isFeatureEnabled(featureUid, planCtx); | | 189 | + if (context) context.planStatus[featureUid] = status; | | 190 | + log.debug(`[import] Deferred plan status fetched for "${featureUid}".`); | | 191 | + } catch (error) { | | 192 | + log.warn(`[import] Could not fetch deferred plan status for "${featureUid}": ${(error as Error).message}`); | | 193 | + } | | 194 | + } | | 195 | + } | | 196 | + | | 197 | + if (context?.planStatus) { | | 198 | + config.planStatus = context.planStatus; | | 199 | + if (config.planStatus['assetsScan']?.is_part_of_plan) { | | 200 | + config.assetScanningEnabled = true; | | 201 | + config.skipAssetsPublish = true; | | 202 | + } | | 203 | + } | | 204 | + | 170 | 205 | return config; | 171 | 206 | }; | 172 | 207 |
| |
|