Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
af62148
enh(config): optimize config initialization for development mode to p…
aman19K Sep 18, 2025
82f2e4b
Feat: Added Branch Alias Support for import setup and version bump
cs-raj Sep 18, 2025
7a9b36f
chore(setup): use --ignore-scripts during install to prevent config c…
aman19K Sep 19, 2025
466d3ac
chore(setup): use Process-Specific Config Files
aman19K Sep 21, 2025
7867d57
Merge pull request #2130 from contentstack/main
harshithad0703 Sep 22, 2025
2af1312
Merge pull request #2131 from contentstack/staging
harshithad0703 Sep 22, 2025
df8edc1
chore(setup): use In-Memory Config During Prepack
aman19K Sep 22, 2025
61fc1b8
version bump @contentstack/cli-utilities from 114.2 to 1.14.3
aman19K Sep 23, 2025
cef3f50
Merge branch 'development' into enh/DX-3560
aman19K Sep 23, 2025
0dbe05e
Updated the Ui texts
cs-raj Sep 23, 2025
b7c1eec
Merge branch 'development' into feat/DX-3513
cs-raj Sep 23, 2025
67ac8c9
Lock File Updated
cs-raj Sep 23, 2025
b18e330
reverted lazy load changes
aman19K Sep 24, 2025
3342a08
Merge pull request #2132 from contentstack/enh/DX-3560
aman19K Sep 24, 2025
1d446d6
chore: bump version to 1.48.1
harshithad0703 Sep 25, 2025
97329cc
Merge pull request #2135 from contentstack/fix/version-bump
harshithad0703 Sep 25, 2025
fa8063c
Merge pull request #2134 from contentstack/development
harshithad0703 Sep 25, 2025
9104330
Merge pull request #2137 from contentstack/staging
harshithad0703 Sep 29, 2025
c61851a
Merge pull request #2138 from contentstack/main
harshithad0703 Sep 29, 2025
5654f14
Merge pull request #2139 from contentstack/staging
harshithad0703 Sep 29, 2025
afba85f
Merge branch 'development' into feat/DX-3513
cs-raj Sep 30, 2025
e254c74
Merge pull request #2129 from contentstack/feat/DX-3513
cs-raj Sep 30, 2025
34e9d33
bump version to 1.49.0 in package.json and package-lock.json
harshithad0703 Sep 30, 2025
8bbb599
Merge pull request #2141 from contentstack/fix/version-bump1.49.0
harshithad0703 Sep 30, 2025
c4fb14c
Merge pull request #2142 from contentstack/development
harshithad0703 Sep 30, 2025
7b0f713
Merge pull request #2143 from contentstack/staging
harshithad0703 Oct 6, 2025
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
6 changes: 3 additions & 3 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
fileignoreconfig:
- filename: package-lock.json
checksum: b07cb236b78aa3149b89e2ed18851ee005db8ef735062f91e0e91b2adf013c12
checksum: 1625bf05fa92826c389d702552d5027df7632a96bac74a970f78f866bbb59e7e
- filename: pnpm-lock.yaml
checksum: 577582ed82062ad359d8bc2bc0a309ab4d344a2a4122573d8cf77aeb481268f2
checksum: 87a6d67aa28e2675ac544cebd0cad703382b799fb46abfe96398c96522374624
- filename: packages/contentstack-import-setup/test/unit/backup-handler.test.ts
checksum: 0582d62b88834554cf12951c8690a73ef3ddbb78b82d2804d994cf4148e1ef93
- filename: packages/contentstack-import-setup/test/config.json
Expand Down Expand Up @@ -87,4 +87,4 @@ fileignoreconfig:
checksum: 7db02c6f2627400b28fc96d505bf074d477080a45ba13943709d4845b6ca0908
- filename: packages/contentstack-import/src/utils/backup-handler.ts
checksum: 0a9accdafce01837166223ed00cd801e2ebb39a4ef952231f67232859a5beea8
version: "1.0"
version: "1.0"
1,532 changes: 823 additions & 709 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion packages/contentstack-import-setup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ $ npm install -g @contentstack/cli-cm-import-setup
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-cm-import-setup/1.5.0 darwin-arm64 node-v22.13.1
@contentstack/cli-cm-import-setup/1.6.0 darwin-arm64 node-v22.13.1
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down Expand Up @@ -78,6 +78,8 @@ FLAGS
branches involved, then the path should point till the particular branch. For example,
“-d "C:\Users\Name\Desktop\cli\content\branch_name"
-k, --stack-api-key=<value> API key of the target stack
--branch-alias=<value> The alias of the branch where you want to import your content. If you don't mention the
branch alias, then by default the content will be imported to the main branch.
--module=<option>... [optional] Specify the modules/module to import into the target stack. currently options
are global-fields, content-types, entries
<options: global-fields|content-types|entries>
Expand Down Expand Up @@ -113,6 +115,8 @@ FLAGS
branches involved, then the path should point till the particular branch. For example,
“-d "C:\Users\Name\Desktop\cli\content\branch_name"
-k, --stack-api-key=<value> API key of the target stack
--branch-alias=<value> The alias of the branch where you want to import your content. If you don't mention the
branch alias, then by default the content will be imported to the main branch.
--module=<option>... [optional] Specify the modules/module to import into the target stack. currently options
are global-fields, content-types, entries
<options: global-fields|content-types|entries>
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-import-setup/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-cm-import-setup",
"description": "Contentstack CLI plugin to setup the mappers and configurations for the import command",
"version": "1.5.0",
"version": "1.6.0",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ export default class ImportSetupCommand extends Command {
description:
"The name of the branch where you want to import your content. If you don't mention the branch name, then by default the content will be imported to the main branch.",
parse: printFlagDeprecation(['-B'], ['--branch']),
exclusive: ['branch-alias']
}),
'branch-alias': flags.string({
description:
"Specify the branch alias where you want to import your content. If not specified, the content is imported into the main branch by default.",
exclusive: ['branch'],
}),
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ImportConfig, Modules } from '../types';
import { backupHandler, log } from '../utils';
import { backupHandler, log, setupBranchConfig } from '../utils';
import { ContentstackClient } from '@contentstack/cli-utilities';
import { validateBranch } from '../utils';

Expand Down Expand Up @@ -102,9 +102,7 @@ export default class ImportSetup {
if (backupDir) {
this.config.backupDir = backupDir;
}
if (this.config.branchName) {
await validateBranch(this.stackAPIClient, this.config, this.config.branchName);
}
await setupBranchConfig(this.config, this.stackAPIClient);

await this.generateDependencyTree();
await this.runModuleImports();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default interface ImportConfig extends DefaultConfig, ExternalConfig {
branches?: branch[];
branchEnabled?: boolean;
branchDir?: string;
branchAlias?: string;
moduleName?: Modules;
master_locale: masterLocale;
headers?: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ const setupConfig = async (importCmdFlags: any): Promise<ImportConfig> => {
config.branchName = importCmdFlags['branch'];
}

if (importCmdFlags['branch-alias']) {
config.branchAlias = importCmdFlags['branch-alias'];
}

config.selectedModules = importCmdFlags['module'] || [await askSelectedModules()];
if (importCmdFlags['backup-dir']) {
config.useBackedupDir = importCmdFlags['backup-dir'];
Expand Down
1 change: 1 addition & 0 deletions packages/contentstack-import-setup/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export { default as backupHandler } from './backup-handler';
export { log, unlinkFileLogger } from './logger';
export * from './log';
export * from './common-helper';
export { setupBranchConfig } from './setup-branch';
35 changes: 35 additions & 0 deletions packages/contentstack-import-setup/src/utils/setup-branch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { ContentstackClient, getBranchFromAlias, log } from '@contentstack/cli-utilities';
import { validateBranch } from './common-helper';
import { ImportConfig } from 'src/types';

export const setupBranchConfig = async (
config: ImportConfig,
stackAPIClient: ReturnType<ContentstackClient['stack']>,
): Promise<void> => {

if (config.branchName) {
await validateBranch(stackAPIClient, config, config.branchName);
return;
}

if (config.branchAlias) {
config.branchName = await getBranchFromAlias(stackAPIClient, config.branchAlias);
return;
}

try {
const branches = await stackAPIClient
.branch()
.query()
.find()
.then(({ items }) => items);
if (branches.length) {
log.info(`The stack is branch-enabled, and branches exist. By default, content will be imported into the main branch.`);

config.branchName = 'main';
log.debug(`Setting default target branch to 'main'`);
}
} catch (error) {
log.debug('Failed to fetch branches', { error });
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default class ImportCommand extends Command {
}),
'branch-alias': flags.string({
description:
"The alias of the branch where you want to import your content. If you don't mention the branch alias, then by default the content will be imported to the main branch.",
"Specify the branch alias where you want to import your content. If not specified, the content is imported into the main branch by default.",
exclusive: ['branch'],
}),
'import-webhook-status': flags.string({
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-import/src/utils/setup-branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const setupBranchConfig = async (
.find()
.then(({ items }) => items);
if (branches.length) {
log.info(`Stack is branch enabled and branches exist. Default import will be done in main branch.`);
log.info(`The stack is branch-enabled, and branches exist. By default, content will be imported into the main branch.`);

config.branchName = 'main';
log.debug(`Setting default target branch to 'main'`);
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-utilities/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/cli-utilities",
"version": "1.14.2",
"version": "1.14.3",
"description": "Utilities for contentstack projects",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
27 changes: 26 additions & 1 deletion packages/contentstack-utilities/src/config-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,23 @@ const cwd = process.env.CS_CLI_CONFIG_PATH;

class Config {
private config: Conf;
private inMemoryStore: Map<string, any> = new Map();
private isPrepackMode: boolean;

constructor() {
this.isPrepackMode = process.env.NODE_ENV === 'PREPACK_MODE';
this.init();
this.importOldConfig();
if (!this.isPrepackMode) {
this.importOldConfig();
}
}

init() {
// Skip file-based config during prepack to prevent race conditions
if (this.isPrepackMode) {
// Initialize with empty in-memory store for prepack
return;
}
return ENCRYPT_CONF === true ? this.getEncryptedConfig() : this.getDecryptedConfig();
}

Expand Down Expand Up @@ -204,20 +214,35 @@ class Config {
}

get(key): string | any {
if (this.isPrepackMode) {
return this.inMemoryStore.get(key);
}
return this.config?.get(key);
}

set(key, value) {
if (this.isPrepackMode) {
this.inMemoryStore.set(key, value);
return this;
}
this.config?.set(key, value);
return this.config;
}

delete(key) {
if (this.isPrepackMode) {
this.inMemoryStore.delete(key);
return this;
}
this.config?.delete(key);
return this.config;
}

clear() {
if (this.isPrepackMode) {
this.inMemoryStore.clear();
return;
}
this.config?.clear();
}
}
Expand Down
4 changes: 4 additions & 0 deletions packages/contentstack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2424,6 +2424,8 @@ FLAGS
branches involved, then the path should point till the particular branch. For example,
“-d "C:\Users\Name\Desktop\cli\content\branch_name"
-k, --stack-api-key=<value> API key of the target stack
--branch-alias=<value> The alias of the branch where you want to import your content. If you don't mention the
branch alias, then by default the content will be imported to the main branch.
--module=<option>... [optional] Specify the modules/module to import into the target stack. currently options
are global-fields, content-types, entries
<options: global-fields|content-types|entries>
Expand Down Expand Up @@ -2945,6 +2947,8 @@ FLAGS
branches involved, then the path should point till the particular branch. For example,
“-d "C:\Users\Name\Desktop\cli\content\branch_name"
-k, --stack-api-key=<value> API key of the target stack
--branch-alias=<value> The alias of the branch where you want to import your content. If you don't mention the
branch alias, then by default the content will be imported to the main branch.
--module=<option>... [optional] Specify the modules/module to import into the target stack. currently options
are global-fields, content-types, entries
<options: global-fields|content-types|entries>
Expand Down
6 changes: 3 additions & 3 deletions packages/contentstack/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli",
"description": "Command-line tool (CLI) to interact with Contentstack",
"version": "1.48.0",
"version": "1.49.0",
"author": "Contentstack",
"bin": {
"csdx": "./bin/run.js"
Expand Down Expand Up @@ -31,14 +31,14 @@
"@contentstack/cli-cm-export": "~1.20.1",
"@contentstack/cli-cm-export-to-csv": "~1.9.1",
"@contentstack/cli-cm-import": "~1.28.1",
"@contentstack/cli-cm-import-setup": "1.5.0",
"@contentstack/cli-cm-import-setup": "1.6.0",
"@contentstack/cli-cm-migrate-rte": "~1.6.1",
"@contentstack/cli-cm-seed": "~1.12.2",
"@contentstack/cli-command": "~1.6.1",
"@contentstack/cli-config": "~1.15.2",
"@contentstack/cli-launch": "^1.9.2",
"@contentstack/cli-migration": "~1.8.1",
"@contentstack/cli-utilities": "~1.14.2",
"@contentstack/cli-utilities": "~1.14.3",
"@contentstack/cli-variants": "~1.3.1",
"@contentstack/management": "~1.22.0",
"@oclif/core": "^4.3.0",
Expand Down
Loading
Loading