Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DX | 14-11-2024 | Release #1674

Merged
merged 80 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
d98a73c
fixed the test cases with oclif/test v4
cs-raj Aug 16, 2024
e82757a
fixed entries test cases
cs-raj Aug 20, 2024
0421e19
fixed other test cases
cs-raj Aug 20, 2024
d2b0d16
version bump
cs-raj Aug 21, 2024
d02d788
Merge branch 'development' into fix/DX-1121
cs-raj Aug 21, 2024
b2e5c59
lockfile fix
cs-raj Aug 21, 2024
b7d4073
removed spy
cs-raj Aug 21, 2024
09d0229
audit version bump to minor version
cs-raj Aug 21, 2024
d8317b7
Merge branch 'development' into fix/DX-1121
cs-raj Aug 21, 2024
2cf2973
PR comment
cs-raj Aug 21, 2024
f57b271
minor var name change
cs-raj Aug 21, 2024
ec696b9
Merge pull request #1524 from contentstack/fix/DX-1121
cs-raj Aug 21, 2024
c261a67
Merge branch 'development' into fix-oclif-test-cases
cs-raj Sep 16, 2024
a290186
commits
cs-raj Sep 18, 2024
759a752
fixed the print in test cases
cs-raj Sep 18, 2024
c487ec0
Merge branch 'development' into fix-oclif-test-cases
cs-raj Sep 20, 2024
3fc1054
fix lock
cs-raj Sep 20, 2024
886fd42
fixed the test cases for marketplace sdk and helpers
cs-raj Sep 20, 2024
77c56dd
version bump
cs-raj Sep 20, 2024
cc71116
Merge pull request #1575 from contentstack/fix/DX-1351
cs-raj Sep 20, 2024
af2ebba
Merge branch 'development' into fix-oclif-test-cases
cs-raj Sep 30, 2024
eaa1f07
lock-file update
cs-raj Sep 30, 2024
1e8ae36
version bumps
cs-raj Sep 30, 2024
eaeebbc
fixed auth Test cases
cs-raj Oct 1, 2024
952ef02
Merge pull request #1599 from contentstack/fix/DX-1338
cs-raj Oct 1, 2024
bcdf1b3
updated test cases
harshithad0703 Oct 7, 2024
15c0676
improve code coverage for region-handler utils
harshithad0703 Oct 7, 2024
06ce6ab
improve code coverage for interactive prompts handlers
harshithad0703 Oct 7, 2024
ef182ef
updated test cases
harshithad0703 Oct 7, 2024
5dabdcb
setting ea header before getting
harshithad0703 Oct 7, 2024
fdcddc2
Merge pull request #1607 from contentstack/test/dx-1343-config-plugin…
harshithad0703 Oct 7, 2024
ea1850d
updated 5 test cases
harshithad0703 Oct 8, 2024
9117162
Testing teams support in CLI export-to-csv
harshithad0703 Oct 10, 2024
200e026
Testing utils function support in CLI export-to-csv
harshithad0703 Oct 10, 2024
6ac536d
export-to-csv with action users
harshithad0703 Oct 10, 2024
9968532
updated test cases which uses prompting
harshithad0703 Oct 10, 2024
4c91645
updated packgae.json to run test for test/util folder
harshithad0703 Oct 10, 2024
b9d366a
updated package-lock
harshithad0703 Oct 10, 2024
0991194
Merge pull request #1623 from contentstack/test/dx-1183-export-to-csv
harshithad0703 Oct 10, 2024
f66a83e
Migrated testcases from v2 to v4 (#1630)
sunil-lakshman Oct 21, 2024
6cf1e2d
fix current test cases
cs-raj Oct 26, 2024
e2026b4
Merge pull request #1648 from contentstack/fix/DX-1356-dev
cs-raj Oct 28, 2024
0134843
fixed existing test cases for running
cs-raj Oct 28, 2024
a8f3031
Merge branch 'development' into fix/DX-1358-fix-development
cs-raj Oct 28, 2024
ec88890
Merge pull request #1649 from contentstack/fix/DX-1358-fix-development
cs-raj Oct 28, 2024
cbbcb2d
Merge branch 'development' into fix-oclif-test-cases
cs-raj Oct 28, 2024
025246d
merged latest development changes
cs-raj Oct 28, 2024
b53b07a
fixed the test cases for oclif v4
cs-raj Oct 30, 2024
55fd751
update ui text changes
harshithad0703 Oct 30, 2024
fda2b45
updated readme for few packages
harshithad0703 Oct 30, 2024
fce404d
File update and readme
cs-raj Oct 30, 2024
034e345
Test migration to v4
cs-raj Oct 30, 2024
1478d02
Merge pull request #1650 from contentstack/fix/DX-1356-test-fix
cs-raj Oct 30, 2024
13e3660
Merge branch 'fix-oclif-test-cases' into fix/DX-1358
cs-raj Oct 30, 2024
8c684f5
Merge pull request #1653 from contentstack/fix/DX-1358
cs-raj Oct 30, 2024
8ce5546
fixed failing test cases
cs-raj Oct 30, 2024
c27b0dc
Merge pull request #1654 from contentstack/fix/test-cases
cs-raj Oct 31, 2024
d526773
fix breaking test cases
cs-raj Oct 31, 2024
e4bac61
Merge pull request #1655 from contentstack/fix/migration-test-cases
cs-raj Oct 31, 2024
6300a2e
Merge pull request #1652 from contentstack/fix/dx-872-ui-text-changes
harshithad0703 Nov 5, 2024
f87d5f2
Merged latest development code
cs-raj Nov 7, 2024
20a104e
lock-file update
cs-raj Nov 7, 2024
6d7235e
Merge pull request #1665 from contentstack/fix/branhc
harshithad0703 Nov 8, 2024
7eddc1c
Merge branch 'staging' into development
cs-raj Nov 8, 2024
b4edb37
lock-file update and package version bump
cs-raj Nov 8, 2024
21a8afa
Merge pull request #1670 from contentstack/fix/dev3
cs-raj Nov 8, 2024
0578df2
fixed the case where multiple select field contains null value
cs-raj Nov 11, 2024
4b0762a
Variants bulk publish and unpublish (#1664)
sunil-lakshman Nov 11, 2024
e6b67a4
Merge branch 'development' into fix/DX-1700
cs-raj Nov 11, 2024
404804a
Merge pull request #1671 from contentstack/fix/DX-1700
cs-raj Nov 11, 2024
618d934
Merge branch 'development' into fix-oclif-test-cases
cs-raj Nov 11, 2024
74feac4
lock-file update
cs-raj Nov 11, 2024
6e06d62
Merge pull request #1672 from contentstack/fix/branch
cs-raj Nov 11, 2024
0f98531
Merge branch 'fix-oclif-test-cases' into fix/DX-1269
cs-raj Nov 11, 2024
bdd645d
fixed the test case
cs-raj Nov 11, 2024
ff6b40a
Merge branch 'fix-oclif-test-cases' into fix/DX-1269
cs-raj Nov 11, 2024
0a63510
Merge pull request #1570 from contentstack/fix/DX-1269
cs-raj Nov 11, 2024
595b7b1
Merge pull request #1673 from contentstack/fix-oclif-test-cases
cs-raj Nov 11, 2024
f134cc2
version bump
cs-raj Nov 11, 2024
c22d002
Merge pull request #1675 from contentstack/version/bump
cs-raj Nov 11, 2024
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,067 changes: 1,379 additions & 2,688 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions 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.7.2 darwin-arm64 node-v22.2.0
@contentstack/cli-audit/1.7.3 darwin-arm64 node-v22.8.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down Expand Up @@ -269,7 +269,7 @@ EXAMPLES
$ csdx plugins
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.14/src/commands/plugins/index.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.15/src/commands/plugins/index.ts)_

## `csdx plugins:add PLUGIN`

Expand Down Expand Up @@ -343,7 +343,7 @@ EXAMPLES
$ csdx plugins:inspect myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.14/src/commands/plugins/inspect.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.15/src/commands/plugins/inspect.ts)_

## `csdx plugins:install PLUGIN`

Expand Down Expand Up @@ -392,7 +392,7 @@ EXAMPLES
$ csdx plugins:install someuser/someplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.14/src/commands/plugins/install.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.15/src/commands/plugins/install.ts)_

## `csdx plugins:link PATH`

Expand Down Expand Up @@ -423,7 +423,7 @@ EXAMPLES
$ csdx plugins:link myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.14/src/commands/plugins/link.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.15/src/commands/plugins/link.ts)_

## `csdx plugins:remove [PLUGIN]`

Expand Down Expand Up @@ -464,7 +464,7 @@ FLAGS
--reinstall Reinstall all plugins after uninstalling.
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.14/src/commands/plugins/reset.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.15/src/commands/plugins/reset.ts)_

## `csdx plugins:uninstall [PLUGIN]`

Expand Down Expand Up @@ -492,7 +492,7 @@ EXAMPLES
$ csdx plugins:uninstall myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.14/src/commands/plugins/uninstall.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.15/src/commands/plugins/uninstall.ts)_

## `csdx plugins:unlink [PLUGIN]`

Expand Down Expand Up @@ -536,5 +536,5 @@ DESCRIPTION
Update installed plugins.
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.14/src/commands/plugins/update.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.15/src/commands/plugins/update.ts)_
<!-- commandsstop -->
16 changes: 8 additions & 8 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.7.2",
"version": "1.7.3",
"description": "Contentstack audit plugin",
"author": "Contentstack CLI",
"homepage": "https://github.com/contentstack/cli",
Expand All @@ -20,35 +20,35 @@
"dependencies": {
"@contentstack/cli-command": "~1.3.2",
"@contentstack/cli-utilities": "~1.8.0",
"@oclif/plugin-help": "^5",
"@oclif/plugin-help": "^5.2.20",
"@oclif/plugin-plugins": "^5.4.15",
"chalk": "^4.1.2",
"fast-csv": "^4.3.6",
"fs-extra": "^11.2.0",
"lodash": "^4.17.21",
"uuid": "^9.0.1",
"winston": "^3.15.0"
"winston": "^3.17.0"
},
"devDependencies": {
"@contentstack/cli-dev-dependencies": "^1.2.4",
"@oclif/test": "^2.5.6",
"@oclif/test": "^4.1.0",
"@types/chai": "^4.3.20",
"@types/fs-extra": "^11.0.4",
"@types/mocha": "^10.0.9",
"@types/node": "^20.16.14",
"@types/node": "^20.17.6",
"@types/uuid": "^9.0.8",
"chai": "^4.5.0",
"eslint": "^8.57.1",
"eslint-config-oclif": "^4.0.0",
"eslint-config-oclif-typescript": "^3.1.12",
"mocha": "^10.7.3",
"mocha": "^10.8.2",
"nyc": "^15.1.0",
"oclif": "^3",
"oclif": "^3.17.2",
"shx": "^0.3.4",
"sinon": "^19.0.2",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"tslib": "^2.8.0",
"tslib": "^2.8.1",
"typescript": "^5.6.3"
},
"oclif": {
Expand Down
21 changes: 12 additions & 9 deletions packages/contentstack-audit/src/modules/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -890,24 +890,27 @@ export default class Entries {
}

/**
*
* this is called in case the select field has multiple optins to chose from
* @param field It contains the value to be searched
* @param selectOptions It contains the options that were added in CT
* @returns An Array of entry containing only the values that were present in CT, An array of not present entries
*/
findNotPresentSelectField(field: any, selectOptions: any) {
if(!field){
field = []
}
let present = [];
let notPresent = [];
const choicesMap = new Map(selectOptions.choices.map((choice: { value: any }) => [choice.value, choice]));
for (const value of field) {
const choice: any = choicesMap.get(value);

if (choice) {
present.push(choice.value);
} else {
notPresent.push(value);
for (const value of field) {
const choice: any = choicesMap.get(value);

if (choice) {
present.push(choice.value);
} else {
notPresent.push(value);
}
}
}
return { filteredFeild: present, notPresent };
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import fs from 'fs';
import winston from 'winston';
import sinon from 'sinon';
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';
import { ContentType, Entries, GlobalField, Extensions, Workflows } from '../../src/modules';
import { FileTransportInstance } from 'winston/lib/winston/transports';
import { $t, auditMsg } from '../../src/messages';

describe('AuditBaseCommand class', () => {

class AuditCMD extends AuditBaseCommand {
async run() {
console.warn('warn Reports ready. Please find the reports at');
await this.start('cm:stacks:audit');
}
}
Expand All @@ -28,6 +30,14 @@ describe('AuditBaseCommand class', () => {
filename!: string;
} as FileTransportInstance;

let consoleWarnSpy: sinon.SinonSpy;
beforeEach(() => {
consoleWarnSpy = sinon.spy(console, 'warn');
});
afterEach(() => {
consoleWarnSpy.restore();
sinon.restore(); // Restore all stubs and mocks
});
describe('Audit command flow', () => {
fancy
.stdout({ print: process.env.PRINT === 'true' || false })
Expand All @@ -44,9 +54,13 @@ describe('AuditBaseCommand class', () => {
.stub(Extensions.prototype, 'run', () => ({ ext_1: {} }))
.stub(AuditBaseCommand.prototype, 'showOutputOnScreenWorkflowsAndExtension', () => {})
.stub(fs, 'createWriteStream', () => new PassThrough())
.it('should show audit report path', async (ctx) => {
.it('should show audit report path', async () => {
await AuditCMD.run(['--data-dir', resolve(__dirname, 'mock', 'contents')]);
expect(ctx.stdout).to.includes('warn Reports ready. Please find the reports at');
const warnOutput = consoleWarnSpy
.getCalls()
.map((call) => call.args[0])
.join('');
expect(warnOutput).to.includes('warn Reports ready. Please find the reports at');
});

fancy
Expand Down
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 @@ -11,20 +12,18 @@ describe('AuditFix command', () => {
filename!: string;
} as FileTransportInstance;

// Check this test case later
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 () => {
await runCommand(['cm:stacks:audit:fix','-d','data-dir'], { root: process.cwd() });
expect(startSpy.args).to.be.eql([['cm:stacks:audit']]);
});
});
});
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
Loading