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: package-lock.json
checksum: 0cac869eb2f174e45751388de3eb46d48fbc8f5dbc56faf06000dbad7b5e8466
checksum: 26be769c9d3bcc7095237527dd0004c3981be0dc7bf5c01f650b05a0ea09ecb6
- filename: pnpm-lock.yaml
checksum: cf7ddbd499ceb5d26ceb94381db0ecd576745b96b4deedd7442d3c8aa820ba92
checksum: 44d84111971dd7c108417a3e6e35bb3c61347d3eff4ea113a636429085d8502b
- 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 @@ -273,4 +273,8 @@ fileignoreconfig:
checksum: 6912e5ea32b4456ad04d1645750c72bbb29ab1895368c3a242ab39e9350ec531
- filename: packages/contentstack-audit/test/unit/mock/contents/composable_studio/invalid_composable_studio.json
checksum: e6465aa0011d1565a2de848d9cca74395d11419e6ac840e7dfb52e1d255b1c4f
- filename: packages/contentstack-audit/src/modules/modulesData.ts
checksum: 1e6c1fba1172512401038d5454c8d218201ec62262449c5c878609592e0124c4
- filename: packages/contentstack-audit/src/modules/composable-studio.ts
checksum: 4fc97ff582d6dff9a54b3a50dfa3cbb5febd38a55aeb8737034b97188ad543ba
version: '1.0'
1,547 changes: 775 additions & 772 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions packages/contentstack-auth/src/base-command.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { Command } from '@contentstack/cli-command';
import { configHandler, createLogContext, Flags, getAuthenticationMethod, Interfaces, log } from '@contentstack/cli-utilities';
import {
configHandler,
createLogContext,
Flags,
getAuthenticationMethod,
Interfaces,
log,
} from '@contentstack/cli-utilities';
import { Context } from './interfaces';

export type Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>;
Expand All @@ -17,8 +24,9 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
public async init(): Promise<void> {
await super.init();
// this.contextDetails = { ...this.createExportContext() };
this.contextDetails = { ...createLogContext(this.context?.info?.command || 'auth', '',) };

this.contextDetails = {
...createLogContext(this.context?.info?.command || 'auth', '', configHandler.get('authenticationMethod')),
};
}

/**
Expand Down
41 changes: 19 additions & 22 deletions packages/contentstack-auth/test/run.test.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import { join, resolve } from "path";
import { existsSync, readdirSync } from "fs";
import config from "./config.json" with { type: "json" };
import filter from "lodash/filter.js";
import forEach from "lodash/forEach.js";
import isEmpty from "lodash/isEmpty.js";
import isArray from "lodash/isArray.js";
import includes from "lodash/includes.js";
import { join, resolve } from 'path';
import { existsSync, readdirSync } from 'fs';
import config from './config.json';
import filter from 'lodash/filter.js';
import forEach from 'lodash/forEach.js';
import isEmpty from 'lodash/isEmpty.js';
import isArray from 'lodash/isArray.js';
import includes from 'lodash/includes.js';
import dotenv from 'dotenv';

// NOTE init env variables
dotenv.config();

const { IS_TS, UNIT_EXECUTION_ORDER, INTEGRATION_EXECUTION_ORDER } = config;

const testFileExtension = IS_TS ? ".ts" : ".js";
process.env.TS_NODE_PROJECT = resolve("test/tsconfig.json");
const testFileExtension = IS_TS ? '.ts' : '.js';
process.env.TS_NODE_PROJECT = resolve('test/tsconfig.json');

/**
* @method getFileName
* @param {string} file
* @returns {string}
*/
const getFileName = (file: string): string => {
if (includes(file, ".test") && includes(file, testFileExtension)) return file;
else if (includes(file, ".test")) return `${file}${testFileExtension}`;
else if (!includes(file, ".test")) return `${file}.test${testFileExtension}`;
if (includes(file, '.test') && includes(file, testFileExtension)) return file;
else if (includes(file, '.test')) return `${file}${testFileExtension}`;
else if (!includes(file, '.test')) return `${file}.test${testFileExtension}`;
else return `${file}.test${testFileExtension}`;
};

Expand All @@ -33,7 +33,7 @@ const getFileName = (file: string): string => {
* @param {Array<string>} files
* @param {string} basePath
*/
const includeTestFiles = (files: Array<string>, basePath = "integration") => {
const includeTestFiles = (files: Array<string>, basePath = 'integration') => {
forEach(files, (file) => {
const filename = getFileName(file);
const filePath = join(__dirname, basePath, filename);
Expand All @@ -52,27 +52,24 @@ const includeTestFiles = (files: Array<string>, basePath = "integration") => {
* @param {Array<string> | undefined | null} executionOrder
* @param {boolean} isIntegrationTest
*/
const run = (
executionOrder: Array<string> | undefined | null,
isIntegrationTest = true
) => {
const testFolder = isIntegrationTest ? "integration" : "unit";
const run = (executionOrder: Array<string> | undefined | null, isIntegrationTest = true) => {
const testFolder = isIntegrationTest ? 'integration' : 'unit';

if (executionOrder && isArray(executionOrder) && !isEmpty(executionOrder)) {
includeTestFiles(executionOrder, testFolder);
} else {
const basePath = join(__dirname, testFolder);
const allIntegrationTestFiles = filter(readdirSync(basePath), (file) =>
includes(file, `.test${testFileExtension}`)
includes(file, `.test${testFileExtension}`),
);
includeTestFiles(allIntegrationTestFiles);
}
};

const args = process.argv.slice(2);

if (includes(args, "--integration-test")) {
if (includes(args, '--integration-test')) {
run(INTEGRATION_EXECUTION_ORDER);
} else if (includes(args, "--unit-test")) {
} else if (includes(args, '--unit-test')) {
// run(UNIT_EXECUTION_ORDER, false);
}
2 changes: 1 addition & 1 deletion packages/contentstack-bulk-publish/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-cm-bulk-publish
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-cm-bulk-publish/1.10.4 darwin-arm64 node-v22.14.0
@contentstack/cli-cm-bulk-publish/1.10.5 darwin-arm64 node-v22.14.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-bulk-publish/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "@contentstack/cli-cm-bulk-publish",
"description": "Contentstack CLI plugin for bulk publish actions",
"version": "1.10.4",
"version": "1.10.5",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-command": "~1.7.1",
"@contentstack/cli-config": "~1.16.2",
"@contentstack/cli-config": "~1.17.0",
"@contentstack/cli-utilities": "~1.16.0",
"@oclif/core": "^4.3.0",
"@oclif/plugin-help": "^6.2.28",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-config
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-config/1.16.2 darwin-arm64 node-v22.14.0
@contentstack/cli-config/1.17.0 darwin-arm64 node-v22.14.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-config/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-config",
"description": "Contentstack CLI plugin for configuration",
"version": "1.16.2",
"version": "1.17.0",
"author": "Contentstack",
"scripts": {
"build": "npm run clean && npm run compile",
Expand Down
23 changes: 17 additions & 6 deletions packages/contentstack-config/src/base-command.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
import { Command } from '@contentstack/cli-command';
import { ArgInput, FlagInput, Flags, Interfaces, LoggerService } from '@contentstack/cli-utilities';
import { ArgInput, FlagInput, Flags, Interfaces, configHandler, createLogContext } from '@contentstack/cli-utilities';

export type Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>;
export type Flags<T extends typeof Command> = Interfaces.InferredFlags<(typeof BaseCommand)['baseFlags'] & T['flags']>;

export abstract class BaseCommand<T extends typeof Command> extends Command {
public logger!: LoggerService;
public contextDetails!: {
command: string;
module: string;
userId: string;
email: string;
sessionId: string;
apiKey: string;
orgId: string;
authenticationMethod: string;
};
protected args!: Args<T>;
protected flags!: Flags<T>;

static args: ArgInput<{ [arg: string]: any; }>;
static args: ArgInput<{ [arg: string]: any }>;
/**
* The `init` function initializes the command by parsing arguments and flags, registering search
* plugins, registering the configuration, and initializing the logger.
*/
public async init(): Promise<void> {
await super.init();

// Init logger
this.logger = new LoggerService(process.cwd(), 'cli-log');
// Init logger context
this.contextDetails = {
...createLogContext(this.context?.info?.command || 'config', '', configHandler.get('authenticationMethod')),
};
}

/**
Expand Down Expand Up @@ -46,4 +57,4 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
// called after run and catch regardless of whether or not the command errored
return super.finally(_);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command } from '@contentstack/cli-command';
import { cliux, configHandler, messageHandler, TableHeader } from '@contentstack/cli-utilities';
import { cliux, configHandler, messageHandler, TableHeader, handleAndLogError } from '@contentstack/cli-utilities';

export default class BranchGetCommand extends Command {
static description = 'Get current branch set for CLI';
Expand All @@ -25,7 +25,7 @@ export default class BranchGetCommand extends Command {
cliux.print(`error: ${messageHandler.parse('CLI_CONFIG_BRANCH_LIST_NO_BRANCHES')}`, { color: 'red' });
}
} catch (error) {
cliux.error('Error', error);
handleAndLogError(error, { module: 'config-get-base-branch' });
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cliux, configHandler } from '@contentstack/cli-utilities';
import { cliux, configHandler, handleAndLogError } from '@contentstack/cli-utilities';
import { Command } from '@contentstack/cli-command';

export default class GetEarlyAccessHeaderCommand extends Command {
Expand Down Expand Up @@ -27,7 +27,7 @@ export default class GetEarlyAccessHeaderCommand extends Command {
cliux.print(`Early Access header not found.`, { color: 'red' });
}
} catch (error) {
this.log('Unable to retrieve the Early Access header config', error instanceof Error ? error.message : error);
handleAndLogError(error, { module: 'config-get-early-access-header' });
}
}
}
4 changes: 2 additions & 2 deletions packages/contentstack-config/src/commands/config/get/log.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command } from '@contentstack/cli-command';
import { cliux, configHandler, TableHeader } from '@contentstack/cli-utilities';
import { cliux, configHandler, TableHeader, handleAndLogError } from '@contentstack/cli-utilities';
import { getEffectiveLogConfig } from '../../../utils/log-config-defaults';

export default class LogGetCommand extends Command {
Expand Down Expand Up @@ -34,7 +34,7 @@ export default class LogGetCommand extends Command {
color: 'dim',
});
} catch (error) {
cliux.error('Error', error);
handleAndLogError(error, { module: 'config-get-log' });
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cliux, configHandler, TableHeader } from '@contentstack/cli-utilities';
import { cliux, configHandler, TableHeader, handleAndLogError } from '@contentstack/cli-utilities';
import { Command } from '@contentstack/cli-command';
import { RateLimitConfig } from '../../../interfaces';

Expand Down Expand Up @@ -34,7 +34,7 @@ export default class RateLimitGetCommand extends Command {

cliux.table(headers, tableData);
} catch (error) {
this.log('Unable to retrieve the rate limits configuration', error instanceof Error ? error.message : error);
handleAndLogError(error, { module: 'config-get-rate-limit' });
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command } from '@contentstack/cli-command';
import { cliux } from '@contentstack/cli-utilities';
import { cliux, log } from '@contentstack/cli-utilities';

import { Region } from '../../../interfaces';
import { BaseCommand } from '../../../base-command';
Expand All @@ -10,7 +10,7 @@ export default class RegionGetCommand extends BaseCommand<typeof RegionGetComman
async run() {
let currentRegion: Region = this.region;
if (!currentRegion) {
this.logger.error('No region is set.');
log.error('No region is set.', this.contextDetails);
cliux.error('CLI_CONFIG_GET_REGION_NOT_FOUND');
this.exit();
}
Expand All @@ -21,6 +21,6 @@ export default class RegionGetCommand extends BaseCommand<typeof RegionGetComman
cliux.print(`Developer Hub URL: ${currentRegion.developerHubUrl}`);
cliux.print(`Launch URL: ${currentRegion.launchHubUrl}`);
cliux.print(`Personalize URL: ${currentRegion.personalizeUrl}`);
this.logger.error(`Currently using ${currentRegion.name} region`);
log.info(`Currently using ${currentRegion.name} region`, this.contextDetails);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command } from '@contentstack/cli-command';
import { cliux, flags, configHandler, FlagInput } from '@contentstack/cli-utilities';
import { cliux, flags, configHandler, FlagInput, handleAndLogError } from '@contentstack/cli-utilities';
import { interactive } from '../../../utils';

export default class RemoveBranchConfigCommand extends Command {
Expand Down Expand Up @@ -40,7 +40,7 @@ export default class RemoveBranchConfigCommand extends Command {
}
}
} catch (error) {
cliux.error('error', error);
handleAndLogError(error, { module: 'config-remove-base-branch' });
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cliux, flags, configHandler, FlagInput } from '@contentstack/cli-utilities';
import { cliux, flags, configHandler, FlagInput, handleAndLogError } from '@contentstack/cli-utilities';
import { interactive } from '../../../utils';
import { Command } from '@contentstack/cli-command';

Expand All @@ -7,7 +7,10 @@ export default class RemoveEarlyAccessHeader extends Command {
static aliases: string[] = ['config:remove:ea-header'];
static flags: FlagInput = {
'header-alias': flags.string({ description: '(optional) Provide the Early Access header alias name.' }),
yes: flags.boolean({ char: 'y', description: '(optional) Force the removal of Early Access header configuration by skipping the confirmation.' }),
yes: flags.boolean({
char: 'y',
description: '(optional) Force the removal of Early Access header configuration by skipping the confirmation.',
}),
};
static examples: string[] = [
'$ <%= config.bin %> <%= command.id %>',
Expand Down Expand Up @@ -35,7 +38,7 @@ export default class RemoveEarlyAccessHeader extends Command {
configHandler.delete(`earlyAccessHeaders.${earlyAccessHeaderAlias}`);
cliux.success(`Early Access header has been successfully removed`);
} catch (error) {
this.log('Unable to remove the Early Access header config', error instanceof Error ? error.message : error);
handleAndLogError(error, { module: 'config-remove-early-access-header' });
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cliux, configHandler, FlagInput, flags } from '@contentstack/cli-utilities';
import { cliux, configHandler, FlagInput, flags, handleAndLogError } from '@contentstack/cli-utilities';
import { Command } from '@contentstack/cli-command';
import { askOrgID } from '../../../utils/interactive';

Expand Down Expand Up @@ -27,7 +27,7 @@ export default class RateLimitRemoveCommand extends Command {
configHandler.delete(`rateLimit.${org}`);
cliux.print(`Rate limit entry for organization UID ${org} has been removed.`, { color: 'green' });
} catch (error) {
this.log('Unable to remove the rate limit entry', error instanceof Error ? error.message : error);
handleAndLogError(error, { module: 'config-remove-rate-limit' });
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command } from '@contentstack/cli-command';
import { cliux, flags, configHandler, FlagInput } from '@contentstack/cli-utilities';
import { cliux, flags, configHandler, FlagInput, handleAndLogError, log } from '@contentstack/cli-utilities';
import { interactive } from '../../../utils';

export default class BranchSetCommand extends Command {
Expand Down Expand Up @@ -35,7 +35,7 @@ export default class BranchSetCommand extends Command {
`Base branch configuration for stack-api-key: ${apiKey} and branch: ${baseBranch} set successfully`,
);
} catch (error) {
cliux.error('error', error);
handleAndLogError(error, { module: 'config-set-base-branch' });
}
}
}
Loading
Loading