Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
fileignoreconfig:
- filename: pnpm-lock.yaml
checksum: 7ec6345eb15ed0be001753ee49733421a8a07096dc8a18465cdad1b82562fed8
- filename: pnpm-lock.yaml
checksum: 24619b075664a197c8f648b04dd86ee79d653fbb583b33e4a3768f02378912ef
- filename: packages/contentstack-import/src/utils/import-config-handler.ts
checksum: 25b986edf20dfd555f9ffc6f124d7d6eb7ac1134a5a67224a49ba48aa50b86f3
- filename: packages/contentstack-export/src/utils/export-config-handler.ts
checksum: a024cdb82e21496794f49fd905f983c0d6677ac9d6761f2e46266fea9932041d
version: '1.0'
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"pnpm": "^10.28.0"
},
"engines": {
"node": ">=18.0.0"
"node": ">=22.0.0"
},
"private": true,
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-apps-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"test:unit:report:json": "mocha --reporter json --reporter-options output=report.json --forbid-only \"test/unit/**/*.test.ts\" && nyc --reporter=clover --extension .ts mocha --forbid-only \"test/unit/**/*.test.ts\""
},
"engines": {
"node": ">=16"
"node": ">=22.0.0"
},
"bugs": "https://github.com/contentstack/cli-plugins/issues",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-audit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"test:unit": "mocha --timeout 10000 --forbid-only --file test/unit/logger-config.js \"test/unit/**/*.test.ts\""
},
"engines": {
"node": ">=16"
"node": ">=22.0.0"
},
"bugs": "https://github.com/contentstack/cli/issues",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-bootstrap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"typescript": "^5.9.3"
},
"engines": {
"node": ">=14.0.0"
"node": ">=22.0.0"
},
"files": [
"/lib",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-branches/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"test:unit:report": "nyc --extension .ts mocha --forbid-only \"test/unit/**/*.test.ts\""
},
"engines": {
"node": ">=14.0.0"
"node": ">=22.0.0"
},
"files": [
"/lib",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-bulk-operations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"clean": "rm -rf ./lib tsconfig.tsbuildinfo oclif.manifest.json"
},
"engines": {
"node": ">=20.19.0"
"node": ">=22.0.0"
},
"bugs": "https://github.com/contentstack/cli-plugins/issues",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-cli-cm-regex-validate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"typescript": "^5.9.3"
},
"engines": {
"node": ">=14.0.0"
"node": ">=22.0.0"
},
"files": [
"/bin",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-cli-tsgen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"typescript": "^5.9.3"
},
"engines": {
"node": ">=18.0.0"
"node": ">=22.0.0"
},
"files": [
"/lib",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-clone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"typescript": "^5.9.3"
},
"engines": {
"node": ">=14.0.0"
"node": ">=22.0.0"
},
"files": [
"/bin",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-content-type/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"typescript": "^5.9.3"
},
"engines": {
"node": ">=14.0.0"
"node": ">=22.0.0"
},
"files": [
"/bin",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-export-to-csv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"typescript": "^5.8.3"
},
"engines": {
"node": ">=18.0.0"
"node": ">=22.0.0"
},
"files": [
"/bin",
Expand Down
9 changes: 5 additions & 4 deletions packages/contentstack-export/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-command": "~2.0.0-beta.8",
"@contentstack/cli-utilities": "~2.0.0-beta.9",
"@contentstack/cli-utilities": "~2.0.0-beta.10",
"@contentstack/cli-variants": "~2.0.0-beta.16",
"@contentstack/cli-asset-management": "~1.0.0-beta.4",
"@oclif/core": "^4.11.4",
Expand Down Expand Up @@ -64,7 +64,7 @@
"test:unit:report": "nyc --reporter=text --extension .ts mocha --forbid-only \"test/unit/**/*.test.ts\""
},
"engines": {
"node": ">=14.0.0"
"node": ">=22.0.0"
},
"files": [
"/lib",
Expand Down Expand Up @@ -96,7 +96,8 @@
"csdxConfig": {
"shortCommandName": {
"cm:stacks:export": "EXPRT"
}
},
"planProtectedFeatures": ["assetsScan"]
},
"repository": "https://github.com/contentstack/cli"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ export default class ExportCommand extends Command {
let exportDir: string = pathValidator('logs');
try {
const { flags } = await this.parse(ExportCommand);
const exportConfig = await setupExportConfig(flags);
const exportConfig = await setupExportConfig(flags, this.context);

console.log('Context', this.context);
// Prepare the context object
const context = this.createExportContext(exportConfig.apiKey, exportConfig.authenticationMethod);
exportConfig.context = { ...context };
Expand Down
1 change: 1 addition & 0 deletions packages/contentstack-export/src/types/export-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default interface ExportConfig extends DefaultConfig {
skipDependencies?: boolean;
authenticationMethod?: string;
linkedWorkspaces?: Array<{ uid: string; space_uid: string; is_default: boolean }>;
planStatus: any;
}

type branch = {
Expand Down
51 changes: 41 additions & 10 deletions packages/contentstack-export/src/utils/export-config-handler.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import merge from 'merge';
import * as path from 'path';
import { configHandler, isAuthenticated, cliux, sanitizePath, log } from '@contentstack/cli-utilities';
import {
configHandler,
isAuthenticated,
cliux,
sanitizePath,
log,
assertFeatureEnabled,
FeatureCtx,
isFeatureEnabled,
} from '@contentstack/cli-utilities';
import defaultConfig from '../config';
import { readFile, isDirectoryNonEmpty } from './file-helper';
import { askExportDir, askAPIKey } from './interactive';
import login from './basic-login';
import { filter, includes } from 'lodash';
import { ExportConfig } from '../types';

const setupConfig = async (exportCmdFlags: any): Promise<ExportConfig> => {
const setupConfig = async (exportCmdFlags: any, context: any): Promise<ExportConfig> => {
// Set progress supported module FIRST, before any log calls
// This ensures the logger respects the showConsoleLogs setting correctly
configHandler.set('log.progressSupportedModule', 'export');
Expand All @@ -29,12 +38,9 @@ const setupConfig = async (exportCmdFlags: any): Promise<ExportConfig> => {
if (legacyCsAssetsConfig) {
externalConfig.modules['cs-assets'] = externalConfig.modules['cs-assets'] || legacyCsAssetsConfig;
delete externalConfig.modules['asset-management'];
log.warn(
'Config key "modules.asset-management" is deprecated. Please rename it to "modules.cs-assets".',
);
log.warn('Config key "modules.asset-management" is deprecated. Please rename it to "modules.cs-assets".');
}


config = merge.recursive(config, externalConfig);
}
config.exportDir = sanitizePath(
Expand All @@ -52,10 +58,9 @@ const setupConfig = async (exportCmdFlags: any): Promise<ExportConfig> => {
config.exportDir = path.resolve(config.exportDir);

if (isDirectoryNonEmpty(config.exportDir)) {
cliux.print(
'\nThe export directory is not empty. Existing files in this folder may be overwritten.',
{ color: 'yellow' },
);
cliux.print('\nThe export directory is not empty. Existing files in this folder may be overwritten.', {
color: 'yellow',
});
}

const managementTokenAlias = exportCmdFlags['management-token-alias'] || exportCmdFlags['alias'];
Expand Down Expand Up @@ -152,6 +157,32 @@ const setupConfig = async (exportCmdFlags: any): Promise<ExportConfig> => {
config.authenticationMethod = authenticationMethod;
log.debug('Export configuration setup completed.', { ...config });

// Deferred plan check — credentials now available after setupExportConfig
const deferredFeatures: string[] = context?.planCheckRequired ?? [];
if (deferredFeatures.length > 0) {
const planCtx: FeatureCtx = {
apiKey: config.apiKey,
managementToken: config.management_token,
authToken: config.auth_token,
};
for (const featureUid of deferredFeatures) {
try {
const status = await isFeatureEnabled(featureUid, planCtx);
if (context) {
context.planStatus[featureUid] = status;
}

log.debug(`[export] Deferred plan status fetched for "${featureUid}".`);
} catch (error) {
log.warn(`[export] Could not fetch deferred plan status for "${featureUid}": ${(error as Error).message}`);
}
}
}

if (context?.planStatus) {
config.planStatus = context.planStatus;
}

return config;
};

Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-external-migrate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@
"plugin"
],
"engines": {
"node": ">=20.0.0"
"node": ">=22.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"root":["./src/index.ts","./src/adapters/registry.ts","./src/adapters/types.ts","./src/adapters/contentful/convert.ts","./src/adapters/contentful/export.ts","./src/adapters/contentful/index.ts","./src/adapters/contentful/validator.ts","./src/commands/external-migrate/audit.ts","./src/commands/external-migrate/convert.ts","./src/commands/external-migrate/create.ts","./src/commands/external-migrate/export.ts","./src/commands/external-migrate/import.ts","./src/commands/external-migrate/status.ts","./src/lib/bundle.ts","./src/lib/clear-import-state.ts","./src/lib/contentful-cli-spawn.ts","./src/lib/conversion-summary.ts","./src/lib/create-stack.ts","./src/lib/csdx-spawn.ts","./src/lib/local-date.ts","./src/lib/log.ts","./src/lib/manifest.ts","./src/lib/parse-json-loose.ts","./src/services/contentful/config.ts","./src/services/contentful/constants.ts","./src/services/contentful/content-type-creator.ts","./src/services/contentful/contentful.service.ts","./src/services/contentful/extension.service.ts","./src/services/contentful/market-app.utils.ts","./src/services/contentful/marketplace.service.ts","./src/services/contentful/releases.ts","./src/services/contentful/scheduled.ts","./src/services/contentful/tasks.ts","./src/services/contentful/types.ts","./src/services/contentful/users.ts","./src/services/contentful/workflows.ts","./src/services/contentful/contentful/jsonrte.ts","./src/services/contentful/contentful/markdown.ts","./src/services/contentful/contentful/roles.ts","./src/services/contentful/contentful/taxonomy.service.ts","./src/services/contentful/mapper/write.ts","./src/services/contentful/migration-contentful/index.js","./src/services/contentful/migration-contentful/libs/contenttypemapper.js","./src/services/contentful/migration-contentful/libs/createinitialmapper.js","./src/services/contentful/migration-contentful/libs/extractcontenttypes.js","./src/services/contentful/migration-contentful/libs/extractlocale.js","./src/services/contentful/migration-contentful/libs/extracttaxonomy.js","./src/services/contentful/migration-contentful/utils/helper.js","./src/services/contentful/prompts/master-locale.ts","./src/services/contentful/utils/custom-logger.utils.ts","./src/services/contentful/utils/index.ts"],"version":"5.9.3"}
{"root":["./src/index.ts","./src/adapters/registry.ts","./src/adapters/types.ts","./src/adapters/contentful/convert.ts","./src/adapters/contentful/export.ts","./src/adapters/contentful/index.ts","./src/adapters/contentful/validator.ts","./src/commands/migrate/audit.ts","./src/commands/migrate/convert.ts","./src/commands/migrate/create.ts","./src/commands/migrate/export.ts","./src/commands/migrate/import.ts","./src/commands/migrate/status.ts","./src/lib/bundle.ts","./src/lib/clear-import-state.ts","./src/lib/contentful-cli-spawn.ts","./src/lib/conversion-summary.ts","./src/lib/create-stack.ts","./src/lib/csdx-spawn.ts","./src/lib/local-date.ts","./src/lib/log.ts","./src/lib/manifest.ts","./src/lib/parse-json-loose.ts","./src/services/contentful/config.ts","./src/services/contentful/constants.ts","./src/services/contentful/content-type-creator.ts","./src/services/contentful/contentful.service.ts","./src/services/contentful/extension.service.ts","./src/services/contentful/market-app.utils.ts","./src/services/contentful/marketplace.service.ts","./src/services/contentful/releases.ts","./src/services/contentful/scheduled.ts","./src/services/contentful/tasks.ts","./src/services/contentful/types.ts","./src/services/contentful/users.ts","./src/services/contentful/workflows.ts","./src/services/contentful/contentful/jsonrte.ts","./src/services/contentful/contentful/markdown.ts","./src/services/contentful/contentful/roles.ts","./src/services/contentful/contentful/taxonomy.service.ts","./src/services/contentful/mapper/write.ts","./src/services/contentful/migration-contentful/index.js","./src/services/contentful/migration-contentful/libs/contenttypemapper.js","./src/services/contentful/migration-contentful/libs/createinitialmapper.js","./src/services/contentful/migration-contentful/libs/extractcontenttypes.js","./src/services/contentful/migration-contentful/libs/extractlocale.js","./src/services/contentful/migration-contentful/libs/extracttaxonomy.js","./src/services/contentful/migration-contentful/utils/helper.js","./src/services/contentful/prompts/master-locale.ts","./src/services/contentful/utils/custom-logger.utils.ts","./src/services/contentful/utils/index.ts"],"version":"5.9.3"}
2 changes: 1 addition & 1 deletion packages/contentstack-import-setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"test:unit": "mocha --timeout 10000 --forbid-only \"test/unit/**/*.test.ts\""
},
"engines": {
"node": ">=14.0.0"
"node": ">=22.0.0"
},
"files": [
"/bin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect } from 'chai';
import * as path from 'path';
import * as os from 'os';
import * as fs from 'fs';
import { stub, restore, SinonStub } from 'sinon';
import { stub, restore, SinonStub, createSandbox } from 'sinon';
import * as utilities from '@contentstack/cli-utilities';
import * as cliAm from '@contentstack/cli-asset-management';
import setupConfig from '../../src/utils/import-config-handler';
Expand Down Expand Up @@ -153,11 +153,13 @@ describe('Import Config Handler', () => {
});

it('should merge Asset Management export flags from detectAssetManagementExportFromContentDir into config', async () => {
const detectStub = stub(cliAm, 'detectAssetManagementExportFromContentDir').returns({
const sandbox = createSandbox();
const detectFake = sandbox.fake.returns({
assetManagementEnabled: true,
source_stack: 'branch-source-key',
assetManagementUrl: 'https://am.example.com',
});
sandbox.replaceGetter(cliAm, 'detectAssetManagementExportFromContentDir', () => detectFake);

try {
const config = await setupConfig({
Expand All @@ -166,12 +168,12 @@ describe('Import Config Handler', () => {
module: ['assets'],
});

expect(detectStub.calledOnce).to.be.true;
expect(config.assetManagementEnabled).to.equal(true);
expect(config.assetManagementUrl).to.equal('https://am.example.com');
expect(detectFake.calledOnce).to.be.true;
expect(config.csAssetsEnabled).to.equal(true);
expect(config.csAssetsUrl).to.equal('https://am.example.com');
expect(config.source_stack).to.equal('branch-source-key');
} finally {
detectStub.restore();
sandbox.restore();
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@ describe('AssetImportSetup Asset Management export', () => {
backupDir,
region: {
cma: 'https://api.contentstack.io/v3',
assetManagementUrl: 'https://am.example.com',
csAssetsUrl: 'https://am.example.com',
},
host: 'https://api.contentstack.io/v3',
fetchConcurrency: 2,
writeConcurrency: 1,
assetManagementEnabled: true,
csAssetsEnabled: true,
org_uid: 'org-uid-test',
source_stack: 'source-api-key',
context: {},
Expand Down
8 changes: 5 additions & 3 deletions packages/contentstack-import/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"test:unit": "mocha --forbid-only \"test/**/*.test.ts\" --exit"
},
"engines": {
"node": ">=14.0.0"
"node": ">=22.0.0"
},
"files": [
"/bin",
Expand Down Expand Up @@ -88,7 +88,9 @@
"csdxConfig": {
"shortCommandName": {
"cm:stacks:import": "IMPRT"
}
},
"planProtectedFeatures": ["assetsScan"]

},
"repository": "https://github.com/contentstack/cli"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export default class ImportCommand extends Command {
let importConfig: ImportConfig;
try {
const { flags } = await this.parse(ImportCommand);
importConfig = await setupImportConfig(flags);
importConfig = await setupImportConfig(flags, this.context);
// Prepare the context object
createLogContext(
this.context?.info?.command || 'cm:stacks:import',
Expand Down Expand Up @@ -162,7 +162,9 @@ export default class ImportCommand extends Command {
if (importConfig.assetScanningEnabled) {
cliux.print('\nAsset Scanning is enabled — assets were not published.', { color: 'yellow' });
cliux.print(' Once scanning completes, publish your assets using:', { color: 'yellow' });
cliux.print(` csdx cm:stacks:bulk-assets --data-dir ${backupDir} --stack-api-key ${importConfig.apiKey}`, { color: 'cyan' });
cliux.print(` csdx cm:stacks:bulk-assets --data-dir ${backupDir} --stack-api-key ${importConfig.apiKey}`, {
color: 'cyan',
});
}
this.logSuccessAndBackupMessages(backupDir, importConfig);
// Clear progress module setting now that import is complete
Expand Down
6 changes: 0 additions & 6 deletions packages/contentstack-import/src/import/module-importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ class ModuleImporter {
const stackDetails: Record<string, unknown> = await this.stackAPIClient.fetch();
this.importConfig.stackName = stackDetails.name as string;
this.importConfig.org_uid = stackDetails.org_uid as string;

const assetScanningEnabled = await this.detectAssetScanning(this.importConfig.org_uid);
if (assetScanningEnabled) {
this.importConfig.assetScanningEnabled = true;
this.importConfig.skipAssetsPublish = true;
}
}

await this.resolveImportPath();
Expand Down
Loading
Loading