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
2 changes: 1 addition & 1 deletion .github/workflows/tsgen-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: csdx plugins:link

- name: Run integration tests
run: pnpm --filter contentstack-cli-tsgen run test:integration
run: pnpm --filter contentstack-cli-tsgen run test
env:
TOKEN_ALIAS: ${{ secrets.TOKEN_ALIAS }}

Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,8 @@ jobs:

- name: Run tests for Contentstack Apps CLI
working-directory: ./packages/contentstack-apps-cli
run: npm run test:unit:report:json
run: npm run test:unit:report

- name: Run tests for Contentstack Tsgen plugin
working-directory: ./packages/contentstack-cli-tsgen
run: npm run test

- name: Run tests for Contentstack Content Type plugin
working-directory: ./packages/contentstack-content-type
run: npm run test:unit
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-apps-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@
"@types/tmp": "^0.2.6",
"@typescript-eslint/eslint-plugin": "^8.58.2",
"@typescript-eslint/parser": "^8.58.2",
"axios": "^1.15.0",
"axios": "^1.16.1",
"chai": "^4.5.0",
"dotenv": "^16.6.1",
"eslint": "^8.57.1",
"eslint-config-oclif": "^6.0.157",
"eslint-config-oclif-typescript": "^3.1.14",
"mocha": "^10.8.2",
"nyc": "^15.1.0",
"oclif": "^4.23.0",
"oclif": "^4.23.8",
"shx": "^0.4.0",
"ts-node": "^10.9.2",
"tslib": "^2.8.1",
Expand Down
13 changes: 12 additions & 1 deletion packages/contentstack-apps-cli/test/helpers/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,15 @@ process.env.NODE_ENV = 'development'

global.oclif = global.oclif || {}
global.oclif.columns = 80
global.commonMock = require(path.join(__dirname, '../unit/mock/common.mock.json'))
global.commonMock = require(path.join(__dirname, '../unit/mock/common.mock.json'))

// Set a mock region so tests that call configHandler.get('region') or
// getDeveloperHubUrl() at module-load time don't throw in CI environments
const { configHandler } = require('@contentstack/cli-utilities')
if (!configHandler.get('region')) {
configHandler.set('region', {
name: 'NA',
cma: 'https://api.contentstack.io',
cda: 'https://cdn.contentstack.io',
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,12 @@ import sinon from "sinon";
import { stubAuthentication } from "../../helpers/auth-stub-helper";
import Deploy from "../../../../src/commands/app/deploy";
import { BaseCommand } from "../../../../src/base-command";
import { join } from "path";
import * as libCommonUtils from "../../../../src/util/common-utils";
import * as libInquirer from "../../../../src/util/inquirer";

const region = configHandler.get("region");
// Commands run from lib/ (oclif.commands); stub the same classes/modules the running command uses
let BaseCommandToStub: typeof BaseCommand;
let LibDeploy: typeof Deploy;
let libCommonUtils: any;
let libInquirer: any;
try {
BaseCommandToStub = require(join(process.cwd(), "lib", "base-command")).BaseCommand;
} catch {
BaseCommandToStub = BaseCommand;
}
try {
LibDeploy = require(join(process.cwd(), "lib", "commands", "app", "deploy")).default;
} catch {
LibDeploy = Deploy;
}
try {
libCommonUtils = require(join(process.cwd(), "lib", "util", "common-utils"));
} catch {
libCommonUtils = require("../../../../src/util/common-utils");
}
try {
libInquirer = require(join(process.cwd(), "lib", "util", "inquirer"));
} catch {
libInquirer = require("../../../../src/util/inquirer");
}
const BaseCommandToStub = BaseCommand;
const LibDeploy = Deploy;
const developerHubBaseUrl = getDeveloperHubUrl();

describe("app:deploy", () => {
Expand Down Expand Up @@ -76,7 +54,7 @@ describe("app:deploy", () => {
sandbox.stub(libInquirer, "getAppUrl").resolves("https://example.com");
sandbox.stub(libInquirer, "askProjectType").resolves("existing");
sandbox.stub(libInquirer, "askConfirmation").resolves(false);
sandbox.stub(libInquirer, "selectProject").resolves(null);
sandbox.stub(libInquirer, "selectProject").resolves(undefined);
sandbox.stub(libInquirer, "askProjectName").resolves("test-project");

// Stub Launch.run
Expand Down Expand Up @@ -355,14 +333,15 @@ describe("app:deploy", () => {
sandbox.stub(libInquirer, "askProjectType").resolves("new");
sandbox.stub(libInquirer, "askProjectName").resolves("new-project");
sandbox.stub(libInquirer, "askConfirmation").resolves(false);
sandbox.stub(libInquirer, "selectProject").resolves(null);
sandbox.stub(libInquirer, "selectProject").resolves(undefined);

sandbox.stub(libCommonUtils, "getProjects").resolves([
{
name: "new-project",
uid: "project-2",
url: "https://new-project.com",
environmentUid: "env-2",
developerHubAppUid: null,
},
]);
sandbox.stub(libCommonUtils, "setupConfig").returns({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { join } from "path";
import { expect } from "chai";
import { cliux, configHandler } from "@contentstack/cli-utilities";
import { runCommand } from "@oclif/test";
Expand All @@ -8,25 +7,16 @@ import manifestData from "../../config/manifest.json";
import sinon from "sinon";
import nock from "nock";
import fs from "fs";
import { join } from "path";
import { stubAuthentication } from "../../helpers/auth-stub-helper";
import Update from "../../../../src/commands/app/update";
import { BaseCommand } from "../../../../src/base-command";

const region = configHandler.get("region");

// Commands run from lib/ (oclif); stub the same class the running command uses
let BaseCommandToStub: typeof BaseCommand;
let LibUpdate: typeof Update;
try {
BaseCommandToStub = require(join(process.cwd(), "lib", "base-command")).BaseCommand;
} catch {
BaseCommandToStub = BaseCommand;
}
try {
LibUpdate = require(join(process.cwd(), "lib", "commands", "app", "update")).default;
} catch {
LibUpdate = Update;
}
// oclif loads commands from src/ (ts-node is registered), so stub the src classes directly
const BaseCommandToStub = BaseCommand;
const LibUpdate = Update;

/** Optional override: return a custom marketplace SDK mock for this test. */
let marketplaceMockOverride: any = null;
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-asset-management/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"eslint-config-oclif": "^6.0.68",
"mocha": "^10.8.2",
"nyc": "^15.1.0",
"oclif": "^4.17.46",
"oclif": "^4.23.8",
"sinon": "^17.0.1",
"source-map-support": "^0.5.21",
"ts-node": "^10.9.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-audit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"dependencies": {
"@contentstack/cli-command": "~2.0.0-beta.7",
"@contentstack/cli-utilities": "~2.0.0-beta.8",
"@oclif/core": "^4.3.0",
"@oclif/core": "^4.11.4",
"chalk": "^5.6.2",
"fast-csv": "^4.3.6",
"fs-extra": "^11.3.0",
Expand All @@ -39,7 +39,7 @@
"eslint-config-oclif-typescript": "^3.1.14",
"mocha": "^10.8.2",
"nyc": "^15.1.0",
"oclif": "^4.17.46",
"oclif": "^4.23.8",
"shx": "^0.4.0",
"sinon": "^21.0.1",
"ts-node": "^10.9.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/contentstack-bootstrap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"@contentstack/cli-command": "~2.0.0-beta.7",
"@contentstack/cli-utilities": "~2.0.0-beta.8",
"@contentstack/cli-config": "~2.0.0-beta.10",
"@oclif/core": "^4.3.0",
"@oclif/core": "^4.11.4",
"inquirer": "12.11.1",
"mkdirp": "^2.1.6",
"tar": "^7.5.11"
"tar": "^7.5.15"
},
"devDependencies": {
"@oclif/test": "^4.1.18",
Expand All @@ -35,7 +35,7 @@
"eslint": "^9.26.0",
"mocha": "10.8.2",
"nyc": "^15.1.0",
"oclif": "^4.17.46",
"oclif": "^4.23.8",
"tmp": "^0.2.5",
"ts-node": "^8.10.2",
"typescript": "^5.9.3"
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-branches/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.7",
"@oclif/core": "^4.3.0",
"@oclif/core": "^4.11.4",
"@contentstack/cli-utilities": "~2.0.0-beta.8",
"chalk": "^5.6.2",
"just-diff": "^6.0.2",
Expand All @@ -20,7 +20,7 @@
"eslint-config-oclif": "^6.0.62",
"mocha": "10.8.2",
"nyc": "^15.1.0",
"oclif": "^4.17.46",
"oclif": "^4.23.8",
"sinon": "^21.0.1",
"ts-node": "^10.9.2",
"typescript": "^4.9.5"
Expand Down
5 changes: 5 additions & 0 deletions packages/contentstack-bulk-operations/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ module.exports = [
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
'@typescript-eslint/only-throw-error': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/no-unsafe-unary-minus': 'off',
},
}),
];
2 changes: 1 addition & 1 deletion packages/contentstack-bulk-operations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"lint-staged": "^17.0.2",
"mocha": "^11.7.5",
"nyc": "^18.0.0",
"oclif": "^4.23.0",
"oclif": "^4.23.8",
"prettier": "^3.8.3",
"shx": "^0.4.0",
"sinon": "^22.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class AssetService {
const batchUids = uids.slice(i, i + BATCH_CONSTANTS.assetFetchBatchSize);
const batchPromises = batchUids.map(async (uid) => {
try {
const asset = await this.deliveryStack?.asset(uid).fetch();
const asset = this.deliveryStack ? await this.deliveryStack.asset(uid).fetch() : undefined;
return asset;
} catch (error: any) {
// Asset might not exist or not be published to this environment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function setupBatchQueueListeners(config: BatchQueueConfig) {
}

logger.info(
`Processing batch ${batch.batchNumber}/${batch.totalBatches}: ` +
`Processing batch ${batch.batchNumber ?? 0}/${batch.totalBatches ?? 0}: ` +
`${batch.items.length} items, ` +
`${batch.locales.length} locales, ` +
`${batch.environments.length} environments`
Expand Down Expand Up @@ -76,7 +76,7 @@ export function setupBatchQueueListeners(config: BatchQueueConfig) {
if (!batch) return;

handleAndLogError(error, {
batchNumber: `${batch.batchNumber}/${batch.totalBatches}`,
batchNumber: `${batch.batchNumber ?? 0}/${batch.totalBatches ?? 0}`,
itemCount: batch.items.length,
});

Expand Down Expand Up @@ -109,7 +109,7 @@ async function handleRetryOrFailure({
: retryStrategy.getDelay(item.retryCount);

logger.warn(
`Batch ${batch.batchNumber}/${batch.totalBatches} failed with ${
`Batch ${batch.batchNumber ?? 0}/${batch.totalBatches ?? 0} failed with ${
isRateLimit ? '429 Rate Limit' : getErrorCode(error)
}, retrying in ${Math.ceil(delay / 1000)}s`
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function confirmOperation(
const publishMode = config.publishMode || PublishMode.BULK;

console.log(chalk.yellow(`\n${$t(messages.OPERATION_CONFIG_HEADER)}\n`));
console.log(` ${$t(messages.OPERATION_LABEL)}: ${config.operation}`);
console.log(` ${$t(messages.OPERATION_LABEL)}: ${config.operation ?? ''}`);
console.log(` ${$t(messages.RESOURCE_TYPE_LABEL)}: ${resourceType}`);
console.log(` ${$t(messages.TOTAL_ITEMS_LABEL)}: ${itemCount}`);

Expand Down
1 change: 1 addition & 0 deletions packages/contentstack-bulk-operations/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"declaration": true,
"importHelpers": true,
"module": "commonjs",
"moduleResolution": "bundler",
"outDir": "lib",
"rootDir": "src",
"strict": true,
Expand Down
1 change: 0 additions & 1 deletion packages/contentstack-cli-cm-regex-validate/.eslintignore

This file was deleted.

26 changes: 26 additions & 0 deletions packages/contentstack-cli-cm-regex-validate/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import oclif from 'eslint-config-oclif'

export default [
{
ignores: ['lib/**', 'node_modules/**'],
},
...oclif,
{
rules: {
'unicorn/prefer-module': 'off',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'unicorn/no-array-for-each': 'off',
'camelcase': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'quotes': ['error', 'single', {avoidEscape: true}],
'semi': ['error', 'never'],
'unicorn/import-style': 'off',
'unicorn/prefer-node-protocol': 'off',
'unicorn/consistent-function-scoping': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'object-curly-spacing': ['error', 'never'],
'node/no-missing-import': 'off',
},
},
]
10 changes: 4 additions & 6 deletions packages/contentstack-cli-cm-regex-validate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@
"@types/mocha": "^10.0.10",
"@types/node": "^18.19.130",
"@types/safe-regex": "^1.1.6",
"@typescript-eslint/eslint-plugin": "^8.59.2",
"chai": "^4.5.0",
"eslint": "^8.57.1",
"eslint": "^9.26.0",
"eslint-config-oclif": "^6.0.62",
"eslint-config-oclif-typescript": "^3.1.14",
"eslint-plugin-unicorn": "^48.0.1",
"globby": "^11.1.0",
"jest": "^30.4.2",
"mocha": "^10.8.2",
"nyc": "^15.1.0",
"oclif": "^4.23.0",
"oclif": "^4.23.8",
"ts-jest": "^29.4.9",
"ts-node": "^10.9.2",
"typescript": "^5.9.3"
Expand Down Expand Up @@ -76,8 +74,8 @@
"postpack": "rm -f oclif.manifest.json",
"test": "jest --detectOpenHandles --silent",
"test:unit": "jest --detectOpenHandles --silent",
"posttest": "eslint . --ext .ts --config .eslintrc",
"lint": "eslint . --ext .ts --config .eslintrc",
"posttest": "eslint src/**/*.ts",
"lint": "eslint src/**/*.ts",
"clean": "rm -rf ./lib ./node_modules tsconfig.tsbuildinfo oclif.manifest.json",
"version": "oclif readme && git add README.md"
},
Expand Down
Loading
Loading