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

Main <- Staging : 16/08/2023 #984

Merged
merged 100 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
24240d4
Modified error statement to show the name or uid of the modules in ca…
cs-raj Jul 18, 2023
39c28db
Version bump
cs-raj Jul 18, 2023
3f0cb00
Merge branch 'development' into bugfix/CS-39464
cs-raj Jul 19, 2023
09d702e
Updated the message and merged latest development changes
cs-raj Jul 19, 2023
9a5ad85
Modified error message for entries
cs-raj Jul 19, 2023
14bb800
Formated
cs-raj Jul 19, 2023
1fac9b5
Merge pull request #936 from contentstack/refactor/CS-40254
shafeeqd959 Jul 20, 2023
9846892
handle read/write persmission error
akashbhosale97 Jul 21, 2023
1e7336f
comment added
akashbhosale97 Jul 21, 2023
300b452
comment edit
akashbhosale97 Jul 21, 2023
0afe1b3
workflow export rewrite
aman19K Jul 21, 2023
9e8ab78
added jira ticket for changing api call to sdk later
akashbhosale97 Jul 24, 2023
75eb56a
test(bulk-publish): added tests for assets:publish, cross-publish, en…
Jul 24, 2023
db1945c
Merge pull request #948 from contentstack/fix/backup-dir-revert
shafeeqd959 Jul 25, 2023
6ba3961
Merge branch 'development' into fix/management-sdk-version
aman19K Jul 26, 2023
3f8d63c
Merge pull request #950 from contentstack/fix/management-sdk-version
shafeeqd959 Jul 26, 2023
ae7a5bd
Merge branch 'development' into fix/CS-40364
aman19K Jul 26, 2023
fe5da62
fix: backup dir flag issue
aman19K Jul 26, 2023
04425ea
revert: backup dir changes
aman19K Jul 26, 2023
3e6fd7b
Merge pull request #951 from contentstack/fix/CS-40364
shafeeqd959 Jul 26, 2023
f46b319
fix: backup-dir import command
aman19K Jul 26, 2023
e31cc84
enable new file structure export & import
aman19K Jul 26, 2023
1cb5b4f
test: added test for entries non localized and modified cmds
Jul 26, 2023
7491089
fix: create backup directory using config
aman19K Jul 27, 2023
2883961
updated example config
aman19K Jul 27, 2023
0b44964
refactor: import config
aman19K Jul 27, 2023
39deaf3
Merge branch 'export-import-rewrite' into fix/CS-40364
aman19K Jul 27, 2023
101d518
Merge pull request #952 from contentstack/fix/CS-40364
shafeeqd959 Jul 27, 2023
aabbc06
entries export
Jul 27, 2023
9b5b83d
merged latest
Jul 27, 2023
68b71bc
Merge pull request #953 from contentstack/feat/CS-32980
shafeeqd959 Jul 27, 2023
f8f4684
Merge branch 'development' into bugfix/CS-40181-read-write-permission…
akashbhosale97 Jul 28, 2023
6c59739
Merge pull request #937 from contentstack/bugfix/CS-40181-read-write-…
akashbhosale97 Jul 28, 2023
fe75a18
Merge branch 'development' into Bugfix/CS-39464
cs-raj Jul 28, 2023
36b6e71
Merge branch 'export-import-rewrite' into feat/CS-39984
aman19K Jul 28, 2023
a5614b8
fix(import): fixed field rules issue
Jul 30, 2023
184ba2b
workflow import rewrite
aman19K Jul 31, 2023
67d0729
Merge pull request #956 from contentstack/feat/CS-39984
aman19K Aug 1, 2023
62567c5
Changes Done in modules of import command to handle errors
cs-raj Aug 1, 2023
49f1653
Removed stray character
cs-raj Aug 1, 2023
30499ed
PR changes
cs-raj Aug 1, 2023
f98a78e
feat: stack export rewrite
aman19K Aug 1, 2023
c9e413e
refactor: remove management dependency from clone
aman19K Aug 1, 2023
cd7740d
refactor: stack export
aman19K Aug 1, 2023
576660e
Merge pull request #957 from contentstack/feat/CS-40281
aman19K Aug 1, 2023
fe4b6ba
refactor: remove temp file
aman19K Aug 2, 2023
93e8582
Merge branch 'export-import-rewrite' into fix/CS-40364
aman19K Aug 2, 2023
386ce3e
PR changes
cs-raj Aug 2, 2023
74275b3
Merge pull request #958 from contentstack/fix/CS-40364
aman19K Aug 2, 2023
b529c3d
test: added test for stacks unpublish
Aug 2, 2023
5395a02
Removed comments and added white space
cs-raj Aug 2, 2023
39fb1b9
fix: added error handling for script to continue
Aug 2, 2023
7ca00a2
entries import
Aug 2, 2023
49cd1eb
Merge branch 'export-import-rewrite' of github.com:contentstack/cli i…
Aug 2, 2023
5d50e65
adding quotes for global field name while logging
cs-raj Aug 3, 2023
99beadc
fix: export plugin test cases
aman19K Aug 3, 2023
01ee9b3
refactor: test report
aman19K Aug 3, 2023
6b108de
added entries import
Aug 3, 2023
04ad82a
Merge pull request #955 from contentstack/fix/CS-40441
netrajpatel Aug 3, 2023
a798c2f
test: added tests for stacks publish
Aug 3, 2023
6314766
Merge branch 'development' into test/CS-38932
Aug 3, 2023
c911669
Merge branch 'development' into test/CS-38932
Aug 3, 2023
3ff9be5
Changes added
cs-raj Aug 3, 2023
810c618
Merge pull request #959 from contentstack/feat/40250
aman19K Aug 3, 2023
129d51d
fixed issues
Aug 3, 2023
9aaef4a
added removal of autocreated entries in masterlocale feature
Aug 4, 2023
ccf5150
added quotes in error message and changed an error message
cs-raj Aug 4, 2023
b3b82a5
ci: Deleted the .github/workflows/sast-scan.yml due to workflow failure
antonyagustine Aug 4, 2023
60bff70
Merge pull request #965 from contentstack/bugfix/CS-40608
antonyagustine Aug 4, 2023
a822361
changed error message. Added .
cs-raj Aug 4, 2023
eea1d19
Merge branch 'development' into bugfix/CS-39464
cs-raj Aug 4, 2023
6c1cf77
Merge pull request #927 from contentstack/bugfix/CS-39464
netrajpatel Aug 7, 2023
a099c3e
fix: stack module rewrite
aman19K Aug 7, 2023
e7d93e6
fix: mg token with login issue
aman19K Aug 7, 2023
ccad889
fix: handle workflow & webhook error
aman19K Aug 7, 2023
980e91b
fix: import-webhook-status flag issue
aman19K Aug 8, 2023
29db862
Merge pull request #967 from contentstack/fix/stack-rewrite-issue
aman19K Aug 8, 2023
67d1953
Merge branch 'export-import-rewrite' of github.com:contentstack/cli i…
Aug 8, 2023
f9cbeea
fixed type issues
Aug 9, 2023
040b652
Fix: Importing data on dev environment giving error while importing M…
antonyagustine Aug 9, 2023
3281fc2
Merge pull request #961 from contentstack/feat/CS-40246
shafeeqd959 Aug 9, 2023
bca5568
fix
Aug 9, 2023
fd4e663
Merge branch 'export-import-rewrite' of github.com:contentstack/cli i…
Aug 9, 2023
c7785eb
rewrite changes
Aug 9, 2023
aa3658a
Merge branch 'main' into fix/CS-40776
abhinav-from-contentstack Aug 10, 2023
bd119ab
Merge pull request #981 from contentstack/fix/CS-40776
abhinav-from-contentstack Aug 10, 2023
e9dc272
Merge branch 'development' of https://github.com/contentstack/cli int…
antonyagustine Aug 10, 2023
800e0e3
merged lates
Aug 10, 2023
edb35d4
entries update
Aug 10, 2023
c735445
version bumps
Aug 10, 2023
5c2eb74
version bump
Aug 10, 2023
917512c
Merge pull request #982 from contentstack/bugfix/CS-40712
antonyagustine Aug 10, 2023
ee1518e
Merge branch 'development' into test/CS-38932
abhinav-from-contentstack Aug 10, 2023
670ca04
Merge branch 'development' of github.com:contentstack/cli into refact…
Aug 10, 2023
697adb1
Merge pull request #975 from contentstack/refactor/rewrite-release2
shafeeqd959 Aug 10, 2023
37692be
Merge branch 'development' into test/CS-38932
abhinav-from-contentstack Aug 10, 2023
16b4a12
Merge pull request #963 from contentstack/test/CS-38932
abhinav-from-contentstack Aug 10, 2023
10f745c
Merge pull request #983 from contentstack/development
abhinav-from-contentstack Aug 10, 2023
bd88c47
Restricting packages to minor version updates
cs-raj Aug 10, 2023
c005a13
Merge pull request #985 from contentstack/fix/CS-40714
abhinav-from-contentstack Aug 10, 2023
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
226 changes: 112 additions & 114 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/contentstack-auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-auth
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-auth/1.3.12 darwin-arm64 node-v20.3.1
@contentstack/cli-auth/1.3.12 darwin-arm64 node-v18.11.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"test:unit:report": "nyc --extension .ts mocha --forbid-only \"test/unit/**/*.test.ts\""
},
"dependencies": {
"@contentstack/cli-command": "^1.2.11",
"@contentstack/cli-utilities": "^1.5.1",
"@contentstack/cli-command": "~1.2.11",
"@contentstack/cli-utilities": "~1.5.1",
"chalk": "^4.0.0",
"debug": "^4.1.1",
"inquirer": "8.2.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-bootstrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $ npm install -g @contentstack/cli-cm-bootstrap
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-cm-bootstrap/1.4.13 darwin-arm64 node-v20.3.1
@contentstack/cli-cm-bootstrap/1.4.14 darwin-arm64 node-v18.11.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
10 changes: 5 additions & 5 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.4.13",
"version": "1.4.14",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"scripts": {
Expand All @@ -17,9 +17,9 @@
"test:report": "nyc --reporter=lcov mocha \"test/**/*.test.js\""
},
"dependencies": {
"@contentstack/cli-cm-seed": "^1.4.13",
"@contentstack/cli-command": "^1.2.11",
"@contentstack/cli-utilities": "^1.5.1",
"@contentstack/cli-cm-seed": "~1.4.14",
"@contentstack/cli-command": "~1.2.11",
"@contentstack/cli-utilities": "~1.5.1",
"inquirer": "8.2.4",
"mkdirp": "^1.0.4",
"tar": "^6.1.13"
Expand Down Expand Up @@ -73,4 +73,4 @@
}
},
"repository": "contentstack/cli"
}
}
2 changes: 1 addition & 1 deletion packages/contentstack-branches/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $ npm install -g @contentstack/cli-cm-branches
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-cm-branches/1.0.10 darwin-arm64 node-v20.3.1
@contentstack/cli-cm-branches/1.0.10 darwin-arm64 node-v18.11.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
10 changes: 5 additions & 5 deletions packages/contentstack-branches/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-command": "^1.2.11",
"@contentstack/cli-utilities": "^1.5.1",
"@contentstack/cli-command": "~1.2.11",
"@contentstack/cli-utilities": "~1.5.1",
"@oclif/command": "^1.8.16",
"@oclif/config": "^1.18.3",
"@oclif/core": "^2.9.3",
Expand All @@ -27,9 +27,9 @@
"winston": "^3.7.2"
},
"devDependencies": {
"@contentstack/cli-auth": "^1.3.11",
"@contentstack/cli-config": "^1.4.9",
"@contentstack/cli-dev-dependencies": "^1.2.3",
"@contentstack/cli-auth": "~1.3.11",
"@contentstack/cli-config": "~1.4.9",
"@contentstack/cli-dev-dependencies": "~1.2.3",
"@oclif/plugin-help": "^5.1.19",
"@oclif/test": "^1.2.6",
"@types/flat": "^5.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-bulk-publish/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-cm-bulk-publish
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-cm-bulk-publish/1.3.10 darwin-arm64 node-v20.3.1
@contentstack/cli-cm-bulk-publish/1.3.10 darwin-arm64 node-v18.11.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-bulk-publish/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-command": "^1.2.11",
"@contentstack/cli-utilities": "^1.5.1",
"@contentstack/cli-command": "~1.2.11",
"@contentstack/cli-utilities": "~1.5.1",
"bluebird": "^3.7.2",
"chalk": "^4.1.2",
"dotenv": "^16.1.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ class UnpublishCommand extends Command {

if (await this.confirmFlags(updatedFlags)) {
try {
if (process.env.NODE_ENV === 'test') {
return;
}
if (!updatedFlags.retryFailed) {
await start(updatedFlags, stack, config);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const getSelectedCommand = async () => {
name: 'selectedOption',
loop: false,
}];
const { selectedOption } = await inquirer.prompt(inquirerOptions);
const selectedOption = await inquirer.prompt(inquirerOptions);
return COMMAND_CODE_MAP[selectedOption];
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,43 @@
const { describe, it } = require('mocha');
const AssetsPublish = require('../../../../src/commands/cm/assets/publish');
const { cliux } = require('@contentstack/cli-utilities');
const sinon = require('sinon');
const { expect } = require('chai');
const { config } = require('dotenv');

const { stub } = sinon;
const AssetsPublish = require('../../../../src/commands/cm/assets/publish');

config();

const environments = process.env.ENVIRONMENTS.split(',');
const locales = process.env.LOCALES.split(',');

describe('AssetsPublish', () => {
it('Should run the command when all the flags are passed', async function () {
it('Should run the command when all the flags are passed', async () => {
const args = ['--environments', environments[0], '--locales', locales[0], '--alias', process.env.MANAGEMENT_ALIAS, '--yes'];
const inquireStub = stub(cliux, 'inquire');
const assetPublishSpy = sinon.spy(AssetsPublish.prototype, 'run');
await AssetsPublish.run(args);
expect(assetPublishSpy.calledOnce).to.be.true;
assetPublishSpy.restore();
});

it('Should fail when alias and stack api key flags are not passed', async () => {
const args = ['--environments', environments[0], '--locales', locales[0], '--yes'];
const assetPublishSpy = sinon.spy(AssetsPublish.prototype, 'run');
const expectedError = 'Please use `--alias` or `--stack-api-key` to proceed.';
try {
await AssetsPublish.run(args);
} catch (error) {
expect(error).to.be.an.instanceOf(Error);
expect(error.message).to.equal(expectedError);
expect(assetPublishSpy.calledOnce).to.be.true;
}
assetPublishSpy.restore();
});

it('Should run successfully when user is logged in and stack api key is passed', async () => {
const args = ['--environments', environments[0], '--locales', locales[0], '--stack-api-key', process.env.STACK_API_KEY, '--yes'];
const assetPublishSpy = sinon.spy(AssetsPublish.prototype, 'run');
await AssetsPublish.run(args);
sinon.assert.notCalled(inquireStub);
inquireStub.restore();
expect(assetPublishSpy.calledOnce).to.be.true;
assetPublishSpy.restore();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ const { cliux } = require('@contentstack/cli-utilities');
const sinon = require('sinon');
const { config } = require('dotenv');
const { expect } = require('chai');

const AssetsUnpublish = require('../../../../src/commands/cm/assets/unpublish');
// const LogoutCommand = require('@contentstack/cli');
const { test } = require('@oclif/test');

const { stub } = sinon;

Expand All @@ -31,7 +30,7 @@ describe('AssetsUnpublish', () => {
inquireStub.restore();
});

it('Should fail when alias and stack api key flags are not passed', async function () {
it('Should fail when alias and stack api key flags are not passed', async () => {
const args = ['--environment', environments[0], '--locale', locales[0], '--yes'];
const inquireStub = stub(cliux, 'prompt');
const assetUnpublishSpy = sinon.spy(AssetsUnpublish.prototype, 'run');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const CrossPublish = require('../../../../src/commands/cm/bulk-publish/cross-pub
const { cliux } = require('@contentstack/cli-utilities');
const sinon = require('sinon');
const { config } = require('dotenv');
const { expect } = require('chai');

const { stub } = sinon;

Expand All @@ -14,9 +15,59 @@ const locales = process.env.LOCALES.split(',');
describe('CrossPublish', () => {
it('Should run the command when all the flags are passed', async function () {
const args = ['--source-env', environments[0], '--environments', process.env.DESTINATION_ENV, '--locale', locales[0], '--alias', process.env.MANAGEMENT_ALIAS, '--delivery-token', process.env.DELIVERY_TOKEN, '--onlyAssets', '--yes'];
const inquireStub = stub(cliux, 'inquire');
const inquireStub = stub(cliux, 'prompt');
await CrossPublish.run(args);
sinon.assert.notCalled(inquireStub);
inquireStub.restore();
});

it('Should ask for delivery token when the flag is not passed', async () => {
const args = ['--source-env', environments[0], '--environments', process.env.DESTINATION_ENV, '--locale', locales[0], '--alias', process.env.MANAGEMENT_ALIAS, '--onlyAssets', '--yes'];
const inquireStub = stub(cliux, 'prompt').resolves(process.env.DELIVERY_TOKEN);
await CrossPublish.run(args);
sinon.assert.calledOnce(inquireStub);
inquireStub.restore();
});

it('Should fail when alias and stack api key flags are not passed', async () => {
const args = ['--source-env', environments[0], '--environments', process.env.DESTINATION_ENV, '--locale', locales[0], '--delivery-token', process.env.DELIVERY_TOKEN, '--onlyAssets', '--yes'];
const inquireStub = stub(cliux, 'prompt');
const crossPublishSpy = sinon.spy(CrossPublish.prototype, 'run');
const expectedError = 'Please use `--alias` or `--stack-api-key` to proceed.';
try {
await CrossPublish.run(args);
} catch (error) {
expect(error).to.be.instanceOf(Error);
expect(error.message).to.equal(expectedError);
expect(crossPublishSpy.calledOnce).to.be.true;
}
sinon.assert.notCalled(inquireStub);
inquireStub.restore();
crossPublishSpy.restore();
});

it('Should run successfully when user is logged in and stack api key is passed', async () => {
const args = ['--source-env', environments[0], '--environments', process.env.DESTINATION_ENV, '--locale', locales[0], '--stack-api-key', process.env.STACK_API_KEY, '--delivery-token', process.env.DELIVERY_TOKEN, '--onlyAssets', '--yes'];
const inquireStub = stub(cliux, 'prompt');
await CrossPublish.run(args);
sinon.assert.notCalled(inquireStub);
inquireStub.restore();
});

it('Should fail when onlyAssets and onlyEntries flags are passed together', async () => {
const args = ['--source-env', environments[0], '--environments', process.env.DESTINATION_ENV, '--locale', locales[0], '--stack-api-key', process.env.STACK_API_KEY, '--delivery-token', process.env.DELIVERY_TOKEN, '--onlyAssets', '--onlyEntries', '--yes'];
const inquireStub = stub(cliux, 'prompt');
const crossPublishSpy = sinon.spy(CrossPublish.prototype, 'run');
const expectedError = 'The flags onlyAssets and onlyEntries need not be used at the same time. Unpublish command unpublishes entries and assts at the same time by default';
try {
await CrossPublish.run(args);
} catch (error) {
expect(error).to.be.instanceOf(Error);
expect(error.message).to.equal(expectedError);
expect(crossPublishSpy.calledOnce).to.be.true;
}
sinon.assert.notCalled(inquireStub);
inquireStub.restore();
crossPublishSpy.restore();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const { describe, it } = require('mocha');
const sinon = require('sinon');
const { expect } = require('chai');
const { config } = require('dotenv');

const EntriesPublishModified = require('../../../../src/commands/cm/entries/publish-modified');

config();

const environments = process.env.ENVIRONMENTS.split(',');
const locales = process.env.LOCALES.split(',');
const contentTypes = process.env.CONTENT_TYPES.split(',');

describe('EntriesPublishModified', () => {
it('Should run the command when all the flags are passed', async () => {
const args = ['--content-types', contentTypes[0], '--source-env', environments[0], '-e', process.env.DESTINATION_ENV, '--locales', locales[0], '--alias', process.env.MANAGEMENT_ALIAS, '--yes'];
const entriesPublishedModifiedSpy = sinon.spy(EntriesPublishModified.prototype, 'run');
await EntriesPublishModified.run(args);
expect(entriesPublishedModifiedSpy.calledOnce).to.be.true;
entriesPublishedModifiedSpy.restore();
});

it('Should fail when alias and stack api key flags are not passed', async () => {
const args = ['--content-types', contentTypes[0], '--source-env', environments[0], '-e', process.env.DESTINATION_ENV, '--locales', locales[0], '--yes'];
const entriesPublishedModifiedSpy = sinon.spy(EntriesPublishModified.prototype, 'run');
const expectedError = 'Please use `--alias` or `--stack-api-key` to proceed.';
try {
await EntriesPublishModified.run(args);
} catch (error) {
expect(error).to.be.an.instanceOf(Error);
expect(error.message).to.equal(expectedError);
expect(entriesPublishedModifiedSpy.calledOnce).to.be.true;
}
entriesPublishedModifiedSpy.restore();
});

it('Should run successfully when user is logged in and stack api key is passed', async () => {
const args = ['--content-types', contentTypes[0], '--source-env', environments[0], '-e', process.env.DESTINATION_ENV, '--locales', locales[0], '--stack-api-key', process.env.STACK_API_KEY, '--yes'];
const entriesPublishedModifiedSpy = sinon.spy(EntriesPublishModified.prototype, 'run');
await EntriesPublishModified.run(args);
expect(entriesPublishedModifiedSpy.calledOnce).to.be.true;
entriesPublishedModifiedSpy.restore();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const { describe, it } = require('mocha');
const sinon = require('sinon');
const { expect } = require('chai');
const { config } = require('dotenv');

const EntriesPublishNonLocalizedFields = require('../../../../src/commands/cm/entries/publish-non-localized-fields');

config();

const environments = process.env.ENVIRONMENTS.split(',');
// const locales = process.env.LOCALES.split(',');
const contentTypes = process.env.CONTENT_TYPES.split(',');

describe('EntriesPublishNonLocalizedFields', () => {
it('Should run the command when all the flags are passed', async () => {
const args = ['--content-types', contentTypes[0], '--source-env', environments[0], '--environments', process.env.DESTINATION_ENV, '--alias', process.env.MANAGEMENT_ALIAS, '--yes'];
const entriesPublishNonLocalizedFieldsSpy = sinon.spy(EntriesPublishNonLocalizedFields.prototype, 'run');
await EntriesPublishNonLocalizedFields.run(args);
expect(entriesPublishNonLocalizedFieldsSpy.calledOnce).to.be.true;
entriesPublishNonLocalizedFieldsSpy.restore();
});

it('Should fail when alias and stack api key flags are not passed', async () => {
const args = ['--content-types', contentTypes[0], '--source-env', environments[0], '--environments', process.env.DESTINATION_ENV, '--yes'];
const entriesPublishNonLocalizedFieldsSpy = sinon.spy(EntriesPublishNonLocalizedFields.prototype, 'run');
const expectedError = 'Please use `--alias` or `--stack-api-key` to proceed.';
try {
await EntriesPublishNonLocalizedFields.run(args);
} catch (error) {
expect(error).to.be.an.instanceOf(Error);
expect(error.message).to.equal(expectedError);
expect(entriesPublishNonLocalizedFieldsSpy.calledOnce).to.be.true;
}
entriesPublishNonLocalizedFieldsSpy.restore();
});

it('Should run successfully when user is logged in and stack api key is passed', async () => {
const args = ['--content-types', contentTypes[0], '--source-env', environments[0], '--environments', process.env.DESTINATION_ENV, '--stack-api-key', process.env.STACK_API_KEY, '--yes'];
const entriesPublishNonLocalizedFieldsSpy = sinon.spy(EntriesPublishNonLocalizedFields.prototype, 'run');
await EntriesPublishNonLocalizedFields.run(args);
expect(entriesPublishNonLocalizedFieldsSpy.calledOnce).to.be.true;
entriesPublishNonLocalizedFieldsSpy.restore();
});
});
Loading