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,903 changes: 2,409 additions & 494 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/contentstack-audit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $ npm install -g @contentstack/cli-audit
$ csdx COMMAND
running command...
$ csdx (--version|-v)
@contentstack/cli-audit/1.6.5 darwin-arm64 node-v22.2.0
@contentstack/cli-audit/1.6.6 darwin-arm64 node-v22.2.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
4 changes: 2 additions & 2 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.6.5",
"version": "1.7.0",
"description": "Contentstack audit plugin",
"author": "Contentstack CLI",
"homepage": "https://github.com/contentstack/cli",
Expand Down Expand Up @@ -31,7 +31,7 @@
},
"devDependencies": {
"@contentstack/cli-dev-dependencies": "^1.2.4",
"@oclif/test": "^2.5.6",
"@oclif/test": "^4.0.8",
"@types/chai": "^4.3.5",
"@types/fs-extra": "^11.0.2",
"@types/mocha": "^10.0.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import winston from 'winston';
import { resolve } from 'path';
import { fancy } from 'fancy-test';
import { PassThrough } from 'stream';
import { expect } from '@oclif/test';
import { expect } from 'chai';
import { ux, cliux } from '@contentstack/cli-utilities';

import { AuditBaseCommand } from '../../src/audit-base-command';
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-audit/test/unit/base-command.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import winston from 'winston';
import { resolve } from 'path';
import { fancy } from 'fancy-test';
import { expect } from '@oclif/test';
import { expect } from 'chai';
import { FileTransportInstance } from 'winston/lib/winston/transports';

import { BaseCommand } from '../../src/base-command';
Expand Down
31 changes: 15 additions & 16 deletions packages/contentstack-audit/test/unit/commands/fix.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import fs from 'fs';
import winston from 'winston';
import { expect } from '@oclif/test';
import { fancy } from '@contentstack/cli-dev-dependencies';
import { expect } from 'chai';
import { runCommand } from '@oclif/test';
import * as sinon from 'sinon';
import { FileTransportInstance } from 'winston/lib/winston/transports';

import { AuditBaseCommand } from '../../../src/audit-base-command';
Expand All @@ -12,19 +13,17 @@ describe('AuditFix command', () => {
} as FileTransportInstance;

describe('AuditFix run method', () => {
const test = fancy.loadConfig({ root: process.cwd() });
test
.stdout({ print: process.env.PRINT === 'true' || false })
.stub(fs, 'rmSync', () => {})
.stub(winston.transports, 'File', () => fsTransport)
.stub(winston, 'createLogger', () => ({ log: () => {}, error: () => {} }))
.stub(AuditBaseCommand.prototype, 'start', () => {})
.spy(AuditBaseCommand.prototype, 'start')
.command(['cm:stacks:audit:fix'])
.it('should trigger AuditBaseCommand start method', ({ stdout, spy }) => {
expect(stdout).to.be.empty.string;
expect(spy.start.callCount).to.be.equals(1);
expect(spy.start.args).deep.equal([['cm:stacks:audit:fix']]);
});
sinon.stub(fs, 'rmSync').callsFake(() => {});
sinon.stub(winston.transports, 'File').callsFake(() => fsTransport);
sinon.stub(winston, 'createLogger').call(() => ({ log: () => {}, error: () => {} }));
const startSpy = sinon.stub(AuditBaseCommand.prototype, 'start').callsFake(() => {
return Promise.resolve(true);
});

it('should trigger AuditBaseCommand start method', async () => {
const { stdout } = await runCommand(['cm:stacks:audit:fix'], { root: process.cwd() });
expect(stdout).to.be.empty.string;
expect(startSpy.args).to.be.eql([['cm:stacks:audit:fix']]);
});
});
});
28 changes: 14 additions & 14 deletions packages/contentstack-audit/test/unit/commands/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
import winston from 'winston';
import { expect, test as fancy } from '@oclif/test';
import { expect } from 'chai';
import { runCommand } from '@oclif/test';
import fancy from 'fancy-test';
import { FileTransportInstance } from 'winston/lib/winston/transports';

import { AuditBaseCommand } from '../../../src/audit-base-command';

describe('Audit command', () => {
const fsTransport = class FsTransport {
filename!: string;
} as FileTransportInstance;

describe('Audit run method', () => {
const test = fancy.loadConfig({ root: process.cwd() });
test
fancy
.stdout({ print: process.env.PRINT === 'true' || false })
.stub(winston.transports, 'File', () => fsTransport)
.stub(winston, 'createLogger', () => ({ log: () => {}, error: () => {} }))
.stub(AuditBaseCommand.prototype, 'start', () => {})
.command(['cm:stacks:audit'])
.it('should trigger AuditBaseCommand start method', ({ stdout }) => {
.it('should trigger AuditBaseCommand start method', async () => {
const { stdout } = await runCommand(['cm:stacks:audit'], { root: process.cwd() });
expect(stdout).to.be.string;
});

test
fancy
.stderr({ print: false })
.stdout({ print: process.env.PRINT === 'true' || false })
.stub(winston.transports, 'File', () => fsTransport)
.stub(winston, 'createLogger', () => ({ log: console.log, error: console.error }))
.stub(AuditBaseCommand.prototype, 'start', () => Promise.reject('process failed'))
.command(['cm:stacks:audit'])
.exit(1)
.it('should log any error and exit with status code 1');
.it('should log any error and exit with status code 1', async () => {
await runCommand(['cm:stacks:audit'], { root: process.cwd() });
});

test
fancy
.stderr({ print: false })
.stdout({ print: process.env.PRINT === 'true' || false })
.stub(winston.transports, 'File', () => fsTransport)
.stub(winston, 'createLogger', () => ({ log: console.log, error: console.error }))
.stub(AuditBaseCommand.prototype, 'start', () => {
throw Error('process failed');
})
.command(['cm:stacks:audit'])
.exit(1)
.it('should log the error objet message and exit with status code 1');
.it('should log the error objet message and exit with status code 1', async () => {
await runCommand(['cm:stacks:audit'], { root: process.cwd() });
});
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fancy } from 'fancy-test';
import { expect } from '@oclif/test';
import { expect } from 'chai';

import { $t, auditMsg } from '../../../src/messages';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from 'fs';
import sinon from 'sinon';
import { resolve } from 'path';
import { fancy } from 'fancy-test';
import { expect } from '@oclif/test';
import { expect } from 'chai';
import cloneDeep from 'lodash/cloneDeep';
import { ux } from '@contentstack/cli-utilities';

Expand Down
Loading