Skip to content
Merged
9 changes: 5 additions & 4 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
fileignoreconfig:

- filename: pnpm-lock.yaml
checksum: 90ca97ef1a06fb5b7d8071f1317e079de6a34fce91559f70f80d9d958b5a834e
version: '1.0'
- filename: pnpm-lock.yaml
ignore_detectors:
- filecontent
- base64content
version: '1.0'
14 changes: 7 additions & 7 deletions packages/contentstack-apps-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/apps-cli",
"version": "1.7.5",
"version": "1.7.6",
"description": "App ClI",
"author": "Contentstack CLI",
"homepage": "https://github.com/contentstack/cli-plugins/tree/main/packages/contentstack-apps-cli",
Expand All @@ -22,14 +22,15 @@
],
"dependencies": {
"@apollo/client": "^3.14.1",
"@contentstack/cli-command": "~1.8.7",
"@contentstack/cli-launch": "^1.11.1",
"@contentstack/cli-utilities": "~1.19.2",
"adm-zip": "^0.6.0",
"@contentstack/cli-command": "~1.8.9",
"@contentstack/cli-launch": "^1.11.3",
"@contentstack/cli-utilities": "~1.20.1",
"adm-zip": "^0.6.1",
"chalk": "^4.1.2",
"lodash": "^4.18.1",
"shelljs": "^0.10.0",
"tmp": "^0.2.7",
"tslib": "^2.8.1",
"winston": "^3.19.0"
},
"devDependencies": {
Expand All @@ -43,7 +44,7 @@
"@types/tmp": "^0.2.6",
"@typescript-eslint/eslint-plugin": "^8.58.2",
"@typescript-eslint/parser": "^8.58.2",
"axios": "^1.16.1",
"axios": "^1.20.0",
"chai": "^4.5.0",
"dotenv": "^16.6.1",
"eslint": "^10.5.0",
Expand All @@ -54,7 +55,6 @@
"oclif": "^4.23.8",
"shx": "^0.4.0",
"ts-node": "^10.9.2",
"tslib": "^2.8.1",
"typescript": "^5.9.3"
},
"oclif": {
Expand Down
7 changes: 4 additions & 3 deletions packages/contentstack-audit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/cli-audit",
"version": "1.21.1",
"version": "1.22.0",
"description": "Contentstack audit plugin",
"author": "Contentstack CLI",
"homepage": "https://github.com/contentstack/cli",
Expand All @@ -18,13 +18,14 @@
"/oclif.manifest.json"
],
"dependencies": {
"@contentstack/cli-command": "~1.8.7",
"@contentstack/cli-utilities": "~1.19.2",
"@contentstack/cli-command": "~1.8.9",
"@contentstack/cli-utilities": "~1.20.1",
"@oclif/core": "^4.11.4",
"chalk": "^4.1.2",
"fast-csv": "^4.3.6",
"fs-extra": "^11.3.0",
"lodash": "^4.18.1",
"tslib": "^2.8.1",
"winston": "^3.19.0"
},
"devDependencies": {
Expand Down
6 changes: 5 additions & 1 deletion packages/contentstack-audit/src/modules/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ export default class Extensions {
} else {
log.debug(`Extension ${title} has no valid content types or scope not found`, this.config.auditContext);
cliux.print($t(commonMsg.EXTENSION_FIX_WARN, { title: title, uid }), { color: 'yellow' });
const shouldDelete = this.config.flags.yes || (await cliux.confirm(commonMsg.EXTENSION_FIX_CONFIRMATION));
const shouldDelete =
this.config.flags['copy-dir'] ||
this.config.flags['external-config']?.skipConfirm ||
this.config.flags.yes ||
(await cliux.confirm(commonMsg.EXTENSION_FIX_CONFIRMATION));
if (shouldDelete) {
log.debug(`Deleting extension: ${title} (${uid})`, this.config.auditContext);
delete newExtensionSchema[uid];
Expand Down
7 changes: 6 additions & 1 deletion packages/contentstack-audit/src/modules/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,12 @@ export default class Workflows {

cliux.print(warningMessage, { color: 'yellow' });

if (this.config.flags.yes || (await cliux.confirm(commonMsg.WORKFLOW_FIX_CONFIRMATION))) {
if (
this.config.flags['copy-dir'] ||
this.config.flags['external-config']?.skipConfirm ||
this.config.flags.yes ||
(await cliux.confirm(commonMsg.WORKFLOW_FIX_CONFIRMATION))
) {
log.debug(`Deleting workflow ${name} (${uid})`, this.config.auditContext);
delete newWorkflowSchema[workflow.uid];
} else {
Expand Down
65 changes: 64 additions & 1 deletion packages/contentstack-audit/test/unit/modules/extensions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ux, cliux } from '@contentstack/cli-utilities';

import config from '../../../src/config';
import { Extensions } from '../../../src/modules';
import { $t, auditMsg } from '../../../src/messages';
import { $t, auditMsg, commonMsg } from '../../../src/messages';
import sinon from 'sinon';
import { Extension } from '../../../src/types';
import { mockLogger } from '../mock-logger';
Expand Down Expand Up @@ -387,4 +387,67 @@ describe('Extensions scope containing content_types uids', () => {
},
);
});

describe('fixExtensionsScope confirmation before removing an extension', () => {
class ExtensionsWithCapturedFix extends Extensions {
public fixedExtensions: Record<string, Extension> = {};

async writeFixContent(fixedExtensions: Record<string, Extension>) {
this.fixedExtensions = fixedExtensions;
}
}

// ext1 and ext2 are scoped only to missing content types, so the fix removes them.
const createExtensions = (flags: Record<string, unknown>) =>
new ExtensionsWithCapturedFix({
moduleName: 'extensions',
ctSchema: cloneDeep(require('./../mock/contents/extensions/ctSchema.json')),
config: Object.assign(cloneDeep(config), {
basePath: resolve(`./test/unit/mock/contents/extensions/invalidExtensions/`),
flags,
}),
fix: true,
});

it('should remove the extensions without prompting when external-config skipConfirm is set', async () => {
const confirm = sinon.stub(cliux, 'confirm').resolves(false);
const ext = createExtensions({ 'external-config': { skipConfirm: true } });

await ext.run();

expect(confirm.notCalled).to.be.true;
expect(ext.fixedExtensions).to.not.have.any.keys('ext1', 'ext2');
});

it('should remove the extensions without prompting when copy-dir is set', async () => {
const confirm = sinon.stub(cliux, 'confirm').resolves(false);
const ext = createExtensions({ 'copy-dir': true });

await ext.run();

expect(confirm.notCalled).to.be.true;
expect(ext.fixedExtensions).to.not.have.any.keys('ext1', 'ext2');
});

it('should remove the extensions without prompting when yes is set', async () => {
const confirm = sinon.stub(cliux, 'confirm').resolves(false);
const ext = createExtensions({ yes: true });

await ext.run();

expect(confirm.notCalled).to.be.true;
expect(ext.fixedExtensions).to.not.have.any.keys('ext1', 'ext2');
});

it('should ask once per extension to remove and keep them when the user declines', async () => {
const confirm = sinon.stub(cliux, 'confirm').resolves(false);
const ext = createExtensions({});

await ext.run();

expect(confirm.callCount).to.equal(2);
expect(confirm.alwaysCalledWithExactly(commonMsg.EXTENSION_FIX_CONFIRMATION)).to.be.true;
expect(ext.fixedExtensions).to.include.all.keys('ext1', 'ext2');
});
});
});
70 changes: 68 additions & 2 deletions packages/contentstack-audit/test/unit/modules/workflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import { resolve } from 'path';
import { fancy } from 'fancy-test';
import { expect } from 'chai';
import cloneDeep from 'lodash/cloneDeep';
import { ux } from '@contentstack/cli-utilities';
import { ux, cliux } from '@contentstack/cli-utilities';
import sinon from 'sinon';

import config from '../../../src/config';
import { Workflows } from '../../../src/modules';
import { $t, auditMsg } from '../../../src/messages';
import { $t, auditMsg, commonMsg } from '../../../src/messages';
import { Workflow } from '../../../src/types';
import { values } from 'lodash';
import { mockLogger } from '../mock-logger';

Expand Down Expand Up @@ -147,4 +148,69 @@ describe('Workflows', () => {
]);
});
});

describe('fixWorkflowSchema confirmation before removing a workflow', () => {
class WorkflowsWithCapturedFix extends Workflows {
public fixedWorkflows: Record<string, Workflow> = {};

async writeFixContent(newWorkflowSchema: Record<string, Workflow>) {
this.fixedWorkflows = newWorkflowSchema;
}
}

const createWorkflows = (flags: Record<string, unknown>) =>
new WorkflowsWithCapturedFix({
moduleName: 'workflows',
// Without ct2, every content type on wf3 is missing, so the fix removes wf3.
ctSchema: cloneDeep(require('./../mock/contents/workflows/ctSchema.json')).filter(
(ct: { uid: string }) => ct.uid !== 'ct2',
),
config: Object.assign(cloneDeep(config), {
basePath: resolve(`./test/unit/mock/contents/`),
branch: undefined,
flags,
}),
fix: true,
});

it('should remove the workflow without prompting when external-config skipConfirm is set', async () => {
const confirm = sinon.stub(cliux, 'confirm').resolves(false);
const wf = createWorkflows({ 'external-config': { skipConfirm: true } });

await wf.run();

expect(confirm.notCalled).to.be.true;
expect(wf.fixedWorkflows).to.not.have.property('wf3');
});

it('should remove the workflow without prompting when copy-dir is set', async () => {
const confirm = sinon.stub(cliux, 'confirm').resolves(false);
const wf = createWorkflows({ 'copy-dir': true });

await wf.run();

expect(confirm.notCalled).to.be.true;
expect(wf.fixedWorkflows).to.not.have.property('wf3');
});

it('should remove the workflow without prompting when yes is set', async () => {
const confirm = sinon.stub(cliux, 'confirm').resolves(false);
const wf = createWorkflows({ yes: true });

await wf.run();

expect(confirm.notCalled).to.be.true;
expect(wf.fixedWorkflows).to.not.have.property('wf3');
});

it('should ask once per workflow to remove and keep it when the user declines', async () => {
const confirm = sinon.stub(cliux, 'confirm').resolves(false);
const wf = createWorkflows({});

await wf.run();

expect(confirm.calledOnceWithExactly(commonMsg.WORKFLOW_FIX_CONFIRMATION)).to.be.true;
expect(wf.fixedWorkflows).to.have.property('wf3');
});
});
});
12 changes: 6 additions & 6 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": "1.19.10",
"version": "1.19.11",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"scripts": {
Expand All @@ -17,14 +17,14 @@
"lint": "eslint \"src/**/*.ts\""
},
"dependencies": {
"@contentstack/cli-cm-seed": "~1.15.11",
"@contentstack/cli-command": "~1.8.7",
"@contentstack/cli-config": "~1.21.2",
"@contentstack/cli-utilities": "~1.19.2",
"@contentstack/cli-cm-seed": "~1.15.12",
"@contentstack/cli-command": "~1.8.9",
"@contentstack/cli-config": "~1.21.4",
"@contentstack/cli-utilities": "~1.20.1",
"@oclif/core": "^4.11.4",
"inquirer": "8.2.7",
"mkdirp": "^2.1.6",
"tar": "^7.5.19"
"tar": "^7.5.22"
},
"devDependencies": {
"@oclif/test": "^4.1.18",
Expand Down
9 changes: 5 additions & 4 deletions packages/contentstack-branches/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"name": "@contentstack/cli-cm-branches",
"description": "Contentstack CLI plugin to do branches operations",
"version": "1.8.6",
"version": "1.8.7",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-command": "~1.8.7",
"@contentstack/cli-utilities": "~1.19.2",
"@contentstack/cli-command": "~1.8.9",
"@contentstack/cli-utilities": "~1.20.1",
"@oclif/core": "^4.11.4",
"chalk": "^4.1.2",
"just-diff": "^6.0.2",
"lodash": "^4.18.1"
"lodash": "^4.18.1",
"tslib": "^2.8.1"
},
"devDependencies": {
"chai": "^4.5.0",
Expand Down
14 changes: 7 additions & 7 deletions packages/contentstack-bulk-operations/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/cli-bulk-operations",
"version": "1.2.5",
"version": "1.2.6",
"description": "Contentstack CLI plugin for bulk operations",
"author": "Contentstack CLI",
"homepage": "https://github.com/contentstack/cli-plugins/tree/main/packages/contentstack-bulk-operations",
Expand All @@ -20,12 +20,13 @@
"/oclif.manifest.json"
],
"dependencies": {
"@contentstack/cli-command": "~1.8.7",
"@contentstack/cli-utilities": "~1.19.2",
"@contentstack/delivery-sdk": "^5.4.0",
"@contentstack/management": "^1.30.3",
"@contentstack/cli-command": "~1.8.9",
"@contentstack/cli-utilities": "~1.20.1",
"@contentstack/delivery-sdk": "^5.6.1",
"@contentstack/management": "^1.31.2",
"lodash": "^4.18.1",
"uuid": "^14.0.1"
"tslib": "^2.8.1",
"uuid": "^14.0.2"
},
"devDependencies": {
"@eslint/eslintrc": "^3.3.1",
Expand Down Expand Up @@ -53,7 +54,6 @@
"shx": "^0.4.0",
"sinon": "^22.0.0",
"ts-node": "^10.9.2",
"tslib": "^2.8.1",
"typescript": "~6.0.3"
},
"oclif": {
Expand Down
8 changes: 4 additions & 4 deletions packages/contentstack-bulk-publish/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@contentstack/cli-cm-bulk-publish",
"description": "Contentstack CLI plugin for bulk publish actions",
"version": "1.13.1",
"version": "1.13.2",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-command": "~1.8.7",
"@contentstack/cli-config": "~1.21.2",
"@contentstack/cli-utilities": "~1.19.2",
"@contentstack/cli-command": "~1.8.9",
"@contentstack/cli-config": "~1.21.4",
"@contentstack/cli-utilities": "~1.20.1",
"@oclif/core": "^4.11.4",
"chalk": "^4.1.2",
"dotenv": "^16.6.1",
Expand Down
8 changes: 4 additions & 4 deletions packages/contentstack-cli-cm-regex-validate/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-cm-regex-validate",
"description": "Validate Fields with Regex Property of Content Type and Global Field in a Stack",
"version": "1.0.4",
"version": "1.0.5",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli-cm-regex-validate/issues",
"devDependencies": {
Expand Down Expand Up @@ -65,9 +65,9 @@
"lint": "eslint \"src/**/*.ts\""
},
"dependencies": {
"@contentstack/cli-command": "^1.8.7",
"@contentstack/cli-utilities": "^1.19.2",
"@contentstack/management": "^1.30.4",
"@contentstack/cli-command": "^1.8.9",
"@contentstack/cli-utilities": "^1.20.1",
"@contentstack/management": "^1.31.2",
"cli-table3": "^0.6.5",
"cli-ux": "^6.0.9",
"inquirer": "12.11.1",
Expand Down
Loading
Loading