Skip to content
Merged
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,8 +1,8 @@
fileignoreconfig:
- filename: pnpm-lock.yaml
checksum: f0d2b2bc5a7b24b2cd8ba12d8ccaa119d74cf73c9462ae0ddd1e1685d03967c9
checksum: f20d4336b379ba896f0092ed8dd03df2c6e5bc34fe200e58002efc2c77fd9359
- filename: package-lock.json
checksum: ed904450857be36b3792ab8650a9ba91ae2f55e67db945915743d1316593a573
checksum: b41714137255ba498375116ae9410e04af150d75ba323c8dbaeb8995564a4677
- filename: packages/contentstack-audit/test/unit/mock/contents/composable_studio/environments/environments.json
checksum: 0402604e5919a7e38ecb5ff0916d6ae5ab7d98fe78ff6ac9eba8a9b8130af34d
- filename: packages/contentstack-utilities/src/helpers.ts
Expand All @@ -21,4 +21,8 @@ fileignoreconfig:
checksum: 4fc97ff582d6dff9a54b3a50dfa3cbb5febd38a55aeb8737034b97188ad543ba
- filename: packages/contentstack-utilities/test/unit/logger.test.ts
checksum: a1939dea16166b1893a248179524a76f2ed20b04b99c83bd1a5a13fcf6f0dadc
- filename: packages/contentstack-clone/README.md
checksum: 8580ab3f52a079a6411c27cbaad66e3a70d9ac5ea59fc429a8f17c95d09399f8
- filename: packages/contentstack/README.md
checksum: 72850c976661f2912b5bca39734de09d56c311c2266fc67696c45ed3fb0b7511
version: "1.0"
178 changes: 89 additions & 89 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/contentstack-auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-auth
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-auth/2.0.0-beta.1 darwin-arm64 node-v24.12.0
@contentstack/cli-auth/2.0.0-beta.3 darwin-arm64 node-v24.12.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-auth/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-auth",
"description": "Contentstack CLI plugin for authentication activities",
"version": "2.0.0-beta.2",
"version": "2.0.0-beta.3",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"scripts": {
Expand Down
27 changes: 14 additions & 13 deletions packages/contentstack-auth/src/utils/auth-handler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cliux, log, handleAndLogError, messageHandler } from '@contentstack/cli-utilities';
import { cliux, log, messageHandler } from '@contentstack/cli-utilities';
import { User } from '../interfaces';
import { askOTPChannel, askOTP } from './interactive';

Expand Down Expand Up @@ -118,25 +118,26 @@ class AuthHandler {
if (result.user) {
log.debug('Login successful, user found', { module: 'auth-handler', userEmail: result.user.email });
resolve(result.user as User);
} else if (result.error_code === 294) {
const tfToken = await this.handleOTPFlow(tfaToken, loginPayload);

} else {
log.debug('Login failed: no user found.', { module: 'auth-handler', result });
reject(new Error(messageHandler.parse('CLI_AUTH_LOGIN_NO_USER')));
}
})
.catch(async (error: any) => {
if (error.errorCode === 294) {
try {
const tfToken = await this.handleOTPFlow(tfaToken, loginPayload);
resolve(await this.login(email, password, tfToken));
} catch (error) {
log.debug('Login with TFA token failed.', { module: 'auth-handler', error });
cliux.print('CLI_AUTH_2FA_FAILED', { color: 'red' });
reject(error);
}
} else {
log.debug('Login failed: no user found.', { module: 'auth-handler', result });
reject(new Error(messageHandler.parse('CLI_AUTH_LOGIN_NO_USER')));
log.debug('Login API call failed.', { module: 'auth-handler', error: error?.errorMessage || error });
cliux.print('CLI_AUTH_LOGIN_FAILED', { color: 'yellow' });
reject(error);
}
})
.catch((error: any) => {
log.debug('Login API call failed.', { module: 'auth-handler', error: error?.errorMessage || error });
cliux.print('CLI_AUTH_LOGIN_FAILED', { color: 'yellow' });
handleAndLogError(error, { module: 'auth-handler' });
});
} else {
const hasEmail = !!email;
Expand Down Expand Up @@ -203,7 +204,7 @@ class AuthHandler {
.catch((error: Error) => {
log.debug('Token validation failed.', { module: 'auth-handler', error: error.message });
cliux.print('CLI_AUTH_TOKEN_VALIDATION_FAILED', { color: 'yellow' });
handleAndLogError(error, { module: 'auth-handler' });
reject(error);
});
} else {
log.debug('Token validation failed: no auth token provided.', { module: 'auth-handler' });
Expand All @@ -213,4 +214,4 @@ class AuthHandler {
}
}

export default new AuthHandler();
export default new AuthHandler();
16 changes: 1 addition & 15 deletions packages/contentstack-auth/src/utils/mfa-handler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cliux, configHandler, NodeCrypto, log, handleAndLogError, messageHandler } from '@contentstack/cli-utilities';
import { cliux, NodeCrypto, log, messageHandler } from '@contentstack/cli-utilities';
import { authenticator } from 'otplib';
import { askOTP } from './interactive';

Expand Down Expand Up @@ -87,20 +87,6 @@ class MFAHandler {
}
}

if (!secret) {
log.debug('Checking stored MFA secret', { module: 'mfa-handler' });
const mfaConfig = configHandler.get('mfa');
if (mfaConfig?.secret) {
try {
secret = this.encrypter.decrypt(mfaConfig.secret);
source = 'stored configuration';
} catch (error) {
log.debug('Failed to decrypt stored MFA secret', { module: 'mfa-handler', error });
handleAndLogError(error, { module: 'mfa-handler' }, messageHandler.parse('CLI_AUTH_MFA_DECRYPT_FAILED'));
}
}
}

if (secret) {
try {
const code = this.generateMFACode(secret);
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-auth/test/integration/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ describe('contentstack-auth plugin test', () => {
mockClient.login.resetHistory();

mockClient.login
.onFirstCall().resolves({ error_code: 294 })
.onFirstCall().rejects({ errorCode: 294 })
.onSecondCall().resolves({ user: { email: credentials.email, authtoken: 'test-token' } });

await authHandler.login(credentials.email, credentials.password);
Expand Down
3 changes: 2 additions & 1 deletion packages/contentstack-auth/test/unit/auth-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ describe('Auth Handler', function () {
return Promise.reject(new Error('Invalid 2FA code'));
}
} else {
return Promise.resolve({ error_code: 294 });
// Handler expects 2FA required as a rejection (catch path checks error.errorCode === 294)
return Promise.reject({ errorCode: 294 });
}
}
return Promise.resolve({ user });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ describe('Auth Handler', function () {
return Promise.reject(new Error('Invalid 2FA code'));
}
} else {
return Promise.resolve({ error_code: 294 });
// Handler expects 2FA required as a rejection (catch path checks error.errorCode === 294)
return Promise.reject({ errorCode: 294 });
}
}
return Promise.resolve({ user });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('MFAHandler', () => {
expect(authenticator.verify({ token: code, secret: validSecret })).to.be.true;
});

it('should fallback to stored configuration when environment variable is not set', async () => {
it.skip('should fallback to stored configuration when environment variable is not set', async () => {
const encryptedSecret = 'encrypted-secret';
configStub.returns({ secret: encryptedSecret });
encrypterStub.decrypt.returns(validSecret);
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-bootstrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $ npm install -g @contentstack/cli-cm-bootstrap
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-cm-bootstrap/2.0.0-beta.4 darwin-arm64 node-v24.12.0
@contentstack/cli-cm-bootstrap/2.0.0-beta.5 darwin-arm64 node-v24.12.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-bootstrap/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-cm-bootstrap",
"description": "Bootstrap contentstack apps",
"version": "2.0.0-beta.4",
"version": "2.0.0-beta.5",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"scripts": {
Expand All @@ -16,7 +16,7 @@
"test:report": "nyc --reporter=lcov mocha \"test/**/*.test.js\""
},
"dependencies": {
"@contentstack/cli-cm-seed": "~2.0.0-beta.4",
"@contentstack/cli-cm-seed": "~2.0.0-beta.5",
"@contentstack/cli-command": "~1.7.2",
"@contentstack/cli-utilities": "~1.17.0",
"@oclif/core": "^4.3.0",
Expand Down
63 changes: 61 additions & 2 deletions packages/contentstack-clone/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $ npm install -g @contentstack/cli-cm-clone
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-cm-clone/2.0.0-beta.5 darwin-arm64 node-v24.12.0
@contentstack/cli-cm-clone/2.0.0-beta.6 darwin-arm64 node-v24.12.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand All @@ -38,6 +38,62 @@ USAGE

<!-- commands -->
* [`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)
* [`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)

## `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]`

Clone data (structure/content or both) of a stack into another stack

```
USAGE
$ csdx cm:stack-clone 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]

FLAGS
-c, --config=<value> Path for the external configuration
-n, --stack-name=<value> Provide a name for the new stack to store the cloned content.
-y, --yes Force override all Marketplace prompts.
--destination-management-token-alias=<value> Destination management token alias.
--destination-stack-api-key=<value> Destination stack API key
--import-webhook-status=<option> [default: disable] [default: disable] (optional) The status of the
import webhook. <options: disable|current>
<options: disable|current>
--skip-audit (optional) Skips the audit fix that occurs during an import
operation.
--source-branch=<value> Branch of the source stack.
--source-branch-alias=<value> Alias of Branch of the source stack.
--source-management-token-alias=<value> Source management token alias.
--source-stack-api-key=<value> Source stack API key
--target-branch=<value> Branch of the target stack.
--target-branch-alias=<value> Alias of Branch of the target stack.
--type=<option> Type of data to clone. You can select option a or b.
a) Structure (all modules except entries & assets).
b) Structure with content (all modules including entries & assets).

<options: a|b>

DESCRIPTION
Clone data (structure/content or both) of a stack into another stack
Use this plugin to automate the process of cloning a stack in few steps.


ALIASES
$ csdx cm:stack-clone

EXAMPLES
$ csdx cm:stacks:clone

$ csdx cm:stacks:clone --source-branch <source-branch-name> --target-branch <target-branch-name> --yes

$ csdx cm:stacks:clone --source-stack-api-key <apiKey> --destination-stack-api-key <apiKey>

$ csdx cm:stacks:clone --source-management-token-alias <management token alias> --destination-management-token-alias <management token alias>

$ csdx cm:stacks:clone --source-branch --target-branch --source-management-token-alias <management token alias> --destination-management-token-alias <management token alias>

$ csdx cm:stacks:clone --source-branch --target-branch --source-management-token-alias <management token alias> --destination-management-token-alias <management token alias> --type <value a or b>
```

## `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]`

Expand Down Expand Up @@ -77,6 +133,9 @@ DESCRIPTION
Use this plugin to automate the process of cloning a stack in few steps.


ALIASES
$ csdx cm:stack-clone

EXAMPLES
$ csdx cm:stacks:clone

Expand All @@ -91,5 +150,5 @@ EXAMPLES
$ csdx cm:stacks:clone --source-branch --target-branch --source-management-token-alias <management token alias> --destination-management-token-alias <management token alias> --type <value a or b>
```

_See code: [src/commands/cm/stacks/clone.js](https://github.com/contentstack/cli/blob/main/packages/contentstack-clone/src/commands/cm/stacks/clone.js)_
_See code: [src/commands/cm/stacks/clone.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-clone/src/commands/cm/stacks/clone.ts)_
<!-- commandsstop -->
4 changes: 2 additions & 2 deletions packages/contentstack-clone/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@contentstack/cli-cm-clone",
"description": "Contentstack stack clone plugin",
"version": "2.0.0-beta.5",
"version": "2.0.0-beta.6",
"author": "Contentstack",
"bugs": "https://github.com/rohitmishra209/cli-cm-clone/issues",
"dependencies": {
"@colors/colors": "^1.6.0",
"@contentstack/cli-cm-export": "~2.0.0-beta.5",
"@contentstack/cli-cm-import": "~2.0.0-beta.4",
"@contentstack/cli-cm-import": "~2.0.0-beta.5",
"@contentstack/cli-command": "~1.7.2",
"@contentstack/cli-utilities": "~1.17.0",
"@oclif/core": "^4.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-export/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"winston": "^3.17.0"
},
"devDependencies": {
"@contentstack/cli-auth": "~2.0.0-beta.1",
"@contentstack/cli-auth": "~2.0.0-beta.3",
"@contentstack/cli-config": "~1.18.0",
"@contentstack/cli-dev-dependencies": "~1.3.1",
"@oclif/plugin-help": "^6.2.28",
Expand Down
2 changes: 1 addition & 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/2.0.0-beta.2 darwin-arm64 node-v24.12.0
@contentstack/cli-cm-import-setup/2.0.0-beta.3 darwin-arm64 node-v24.12.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-import/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
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-cm-import/2.0.0-beta.4 darwin-arm64 node-v24.12.0
@contentstack/cli-cm-import/2.0.0-beta.5 darwin-arm64 node-v24.12.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-import/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-cm-import",
"description": "Contentstack CLI plugin to import content into stack",
"version": "2.0.0-beta.4",
"version": "2.0.0-beta.5",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,18 @@ export default class ContentTypesImport extends BaseClass {

// Initialize composable studio paths if config exists
if (this.importConfig.modules['composable-studio']) {
// Use contentDir as fallback if data is not available
const basePath = this.importConfig.data || this.importConfig.contentDir;

this.composableStudioSuccessPath = path.join(
sanitizePath(this.importConfig.data),
sanitizePath(basePath),
'mapper',
this.importConfig.modules['composable-studio'].dirName,
this.importConfig.modules['composable-studio'].fileName,
);

this.composableStudioExportPath = path.join(
sanitizePath(this.importConfig.data),
sanitizePath(basePath),
this.importConfig.modules['composable-studio'].dirName,
this.importConfig.modules['composable-studio'].fileName,
);
Expand Down
7 changes: 5 additions & 2 deletions packages/contentstack-import/src/import/modules/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,18 @@ export default class EntriesImport extends BaseClass {

// Initialize composable studio paths if config exists
if (this.importConfig.modules['composable-studio']) {
// Use contentDir as fallback if data is not available
const basePath = this.importConfig.data || this.importConfig.contentDir;

this.composableStudioSuccessPath = path.join(
sanitizePath(this.importConfig.data),
sanitizePath(basePath),
'mapper',
this.importConfig.modules['composable-studio'].dirName,
this.importConfig.modules['composable-studio'].fileName,
);

this.composableStudioExportPath = path.join(
sanitizePath(this.importConfig.data),
sanitizePath(basePath),
this.importConfig.modules['composable-studio'].dirName,
this.importConfig.modules['composable-studio'].fileName,
);
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-seed/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@contentstack/cli-cm-seed",
"description": "create a Stack from existing content types, entries, assets, etc.",
"version": "2.0.0-beta.4",
"version": "2.0.0-beta.5",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-cm-import": "~2.0.0-beta.4",
"@contentstack/cli-cm-import": "~2.0.0-beta.5",
"@contentstack/cli-command": "~1.7.2",
"@contentstack/cli-utilities": "~1.17.0",
"@contentstack/management": "~1.27.3",
Expand Down
Loading
Loading