Skip to content
Closed
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
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
@@ -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
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

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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ const regexMessages = require('../../../../messages/index.json').validateRegex

export default class ValidateRegex extends Command {
static description = regexMessages.command.description

static examples = [
'$ csdx cm:stacks:validate-regex',
'$ csdx cm:stacks:validate-regex -a <management_token_alias>',
'$ csdx cm:stacks:validate-regex -c',
'$ csdx cm:stacks:validate-regex -g',
'$ csdx cm:stacks:validate-regex -f <path/to/the/directory>',
'$ csdx cm:stacks:validate-regex -a <management_token_alias> -c -g',
'$ csdx cm:stacks:validate-regex -a <management_token_alias> -c -g -f <path/to/the/directory>',
]
static flags: any = {
alias: flags.string({
char: 'a',
Expand All @@ -17,26 +25,16 @@ export default class ValidateRegex extends Command {
char: 'c',
description: regexMessages.command.contentTypes,
}),
globalField: flags.boolean({
char: 'g',
description: regexMessages.command.globalFields,
}),
filePath: flags.string({
char: 'f',
description: regexMessages.command.filePath,
}),
globalField: flags.boolean({
char: 'g',
description: regexMessages.command.globalFields,
}),
}

static examples = [
'$ csdx cm:stacks:validate-regex',
'$ csdx cm:stacks:validate-regex -a <management_token_alias>',
'$ csdx cm:stacks:validate-regex -c',
'$ csdx cm:stacks:validate-regex -g',
'$ csdx cm:stacks:validate-regex -f <path/to/the/directory>',
'$ csdx cm:stacks:validate-regex -a <management_token_alias> -c -g',
'$ csdx cm:stacks:validate-regex -a <management_token_alias> -c -g -f <path/to/the/directory>',
]

async run() {
const commandObject = await this.parse(ValidateRegex)
await inquireAlias(commandObject.flags)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as contentstackSdk from '@contentstack/management'
import {configHandler, ux} from '@contentstack/cli-utilities'
import * as contentstackSdk from '@contentstack/management'

import processStack from './process-stack'
const regexMessages = require('../../messages/index.json').validateRegex

Expand All @@ -13,7 +14,7 @@ export default async function connectStack(
ux.action.start(regexMessages.cliAction.connectStackStart)

const option: contentstackSdk.ContentstackConfig = {
host: host,
host,
}

// Adding early access headers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,49 +1,42 @@
import jsonexport from 'jsonexport'
import Table from 'cli-table3'
import * as path from 'path'
import * as fs from 'fs'
import {cliux, sanitizePath} from '@contentstack/cli-utilities'
const regexMessages = require('../../messages/index.json').validateRegex
import { cliux, sanitizePath } from '@contentstack/cli-utilities';
import Table from 'cli-table3';
import * as fs from 'fs';
import jsonexport from 'jsonexport';
import * as path from 'path';
const regexMessages = require('../../messages/index.json').validateRegex;

export default async function generateOutput(
flags: any,
invalidRegex: any,
tableData: any,
) {
export default async function generateOutput(flags: any, invalidRegex: any, tableData: any) {
if (invalidRegex.length > 0) {
const resultFile = 'results.csv'
let storagePath = path.resolve(__dirname, '../../results')
const resultFile = 'results.csv';
let storagePath = path.resolve(__dirname, '../../results');
if (flags.filePath) {
storagePath = flags.filePath
storagePath = flags.filePath;
}

if (!fs.existsSync(storagePath)) {
fs.mkdirSync(storagePath, {recursive: true})
fs.mkdirSync(storagePath, { recursive: true });
}

storagePath = path.resolve(
sanitizePath(storagePath),
sanitizePath(resultFile),
)
jsonexport(invalidRegex, function (error: any, csv: any) {
storagePath = path.resolve(sanitizePath(storagePath), sanitizePath(resultFile));
jsonexport(invalidRegex, (error: any, csv: any) => {
if (error) {
throw new Error(regexMessages.errors.csvOutput)
throw new Error(regexMessages.errors.csvOutput);
}

fs.writeFileSync(storagePath, csv)
})
console.log(regexMessages.output.tableOutput)
fs.writeFileSync(storagePath, csv);
});
console.log(regexMessages.output.tableOutput);
const table = new Table({
head: ['Module', 'Title', 'UID', 'Invalid Regex Count'],
})
});
tableData.forEach((row: any) => {
table.push(row)
})
const messageAndPath = `${regexMessages.output.csvOutput} ${storagePath}`
cliux.print(table.toString())
cliux.print(messageAndPath)
cliux.print(regexMessages.output.docsLink)
table.push(row);
});
const messageAndPath = `${regexMessages.output.csvOutput} ${storagePath}`;
cliux.print(table.toString());
cliux.print(messageAndPath);
cliux.print(regexMessages.output.docsLink);
} else {
cliux.print(regexMessages.output.noInvalidRegex)
cliux.print(regexMessages.output.noInvalidRegex);
}
}
Loading
Loading