From 74b402b1cafe83d33cd991f40a81b0014eae7e77 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Mon, 1 Jul 2024 11:23:07 +0530 Subject: [PATCH 1/5] fixed the snyk code issues --- packages/contentstack-auth/test/config.json | 5 +- .../test/integration/auth.test.ts | 4 +- .../test/integration/config.json | 3 +- .../test/unit/auth-handler.test.ts | 5 +- .../test/unit/commands/login.test.ts | 5 +- .../test/unit/commands/tokens-add.test.ts | 3 +- .../test/unit/interactive.test.ts | 3 +- .../src/utils/create-merge-scripts.ts | 3 +- .../contentstack-branches/test/config.json | 6 +- .../unit/commands/cm/branches/create.test.js | 58 +++ .../unit/commands/cm/branches/delete.test.js | 46 +++ .../unit/commands/cm/branches/diff.test.js | 56 +++ .../unit/commands/cm/branches/list.test.js | 35 ++ .../unit/commands/cm/branches/merge.test.js | 38 ++ .../test/unit/mock/data.ts | 69 ++-- .../unit/utils/create-branch-handler.test.js | 0 .../unit/utils/create-merge-scripts.test.js | 49 +++ .../unit/utils/diff-branch-handler.test.js | 230 +++++++++++ .../test/unit/utils/interactive.test.js | 122 ++++++ .../unit/utils/merge-branch-handler.test.js | 362 ++++++++++++++++++ .../test/dummyConfig/config.json | 3 + .../test/dummyConfig/index.js | 4 +- packages/contentstack-export/test/config.json | 3 +- .../test/integration/config.json | 3 +- .../test/integration/init.test.js | 4 +- .../contentstack-export/test/tsconfig.json | 2 +- .../test/unit/mock/assets.ts | 8 +- .../test/integration/init.test.js | 4 +- packages/contentstack-seed/tests/config.json | 7 + .../tests/contentstack.test.ts | 3 +- .../tests/interactive.test.ts | 7 +- .../contentstack-seed/tests/seeder.test.ts | 3 +- .../test/unit/auth-handler.test.ts | 5 +- .../test/unit/config.json | 4 + 34 files changed, 1098 insertions(+), 64 deletions(-) create mode 100644 packages/contentstack-branches/test/unit/commands/cm/branches/create.test.js create mode 100644 packages/contentstack-branches/test/unit/commands/cm/branches/delete.test.js create mode 100644 packages/contentstack-branches/test/unit/commands/cm/branches/diff.test.js create mode 100644 packages/contentstack-branches/test/unit/commands/cm/branches/list.test.js create mode 100644 packages/contentstack-branches/test/unit/commands/cm/branches/merge.test.js create mode 100644 packages/contentstack-branches/test/unit/utils/create-branch-handler.test.js create mode 100644 packages/contentstack-branches/test/unit/utils/create-merge-scripts.test.js create mode 100644 packages/contentstack-branches/test/unit/utils/diff-branch-handler.test.js create mode 100644 packages/contentstack-branches/test/unit/utils/interactive.test.js create mode 100644 packages/contentstack-branches/test/unit/utils/merge-branch-handler.test.js create mode 100644 packages/contentstack-clone/test/dummyConfig/config.json create mode 100644 packages/contentstack-seed/tests/config.json create mode 100644 packages/contentstack-utilities/test/unit/config.json diff --git a/packages/contentstack-auth/test/config.json b/packages/contentstack-auth/test/config.json index c7dbf55074..3ff208ec06 100644 --- a/packages/contentstack-auth/test/config.json +++ b/packages/contentstack-auth/test/config.json @@ -1,5 +1,8 @@ { "IS_TS": true, "UNIT_EXECUTION_ORDER": [], - "INTEGRATION_EXECUTION_ORDER": [] + "INTEGRATION_EXECUTION_ORDER": [], + "password": "testpassword", + "invalidPassowrd": "invalidpassword", + "validAPIKey": "adasdfagsf" } \ No newline at end of file diff --git a/packages/contentstack-auth/test/integration/auth.test.ts b/packages/contentstack-auth/test/integration/auth.test.ts index 410f69636d..cc5fa2b821 100644 --- a/packages/contentstack-auth/test/integration/auth.test.ts +++ b/packages/contentstack-auth/test/integration/auth.test.ts @@ -3,14 +3,14 @@ import { expect, test } from '@oclif/test'; // @ts-ignore import { Helper } from './helper'; // @ts-ignore -import { PRINT_LOGS } from './config.json'; +import { PRINT_LOGS, encryptionKey } from './config.json'; import { cliux as CliUx, messageHandler, NodeCrypto } from '@contentstack/cli-utilities'; const messageFilePath = path.join(__dirname, '..', '..', '..', 'contentstack-utilities', 'messages/auth.json'); const crypto = new NodeCrypto({ typeIdentifier: '◈', algorithm: 'aes-192-cbc', - encryptionKey: process.env.ENCRYPTION_KEY || '***REMOVED***' + encryptionKey: process.env.ENCRYPTION_KEY || encryptionKey }); const username = process.env.ENCRYPTION_KEY ? crypto.decrypt(process.env.USERNAME) : process.env.USERNAME const password = process.env.ENCRYPTION_KEY ? crypto.decrypt(process.env.PASSWORD) : process.env.PASSWORD diff --git a/packages/contentstack-auth/test/integration/config.json b/packages/contentstack-auth/test/integration/config.json index 8f526f9fc8..a83644de5e 100644 --- a/packages/contentstack-auth/test/integration/config.json +++ b/packages/contentstack-auth/test/integration/config.json @@ -1,3 +1,4 @@ { - "PRINT_LOGS": false + "PRINT_LOGS": false, + "encryptionKey": "***REMOVED***" } \ No newline at end of file diff --git a/packages/contentstack-auth/test/unit/auth-handler.test.ts b/packages/contentstack-auth/test/unit/auth-handler.test.ts index ead258f36f..a200ff0f71 100644 --- a/packages/contentstack-auth/test/unit/auth-handler.test.ts +++ b/packages/contentstack-auth/test/unit/auth-handler.test.ts @@ -3,10 +3,11 @@ import * as sinon from 'sinon'; import { authHandler, interactive } from '../../src/utils'; import { CLIError, cliux } from '@contentstack/cli-utilities'; import { User } from '../../src/interfaces'; +import * as config from '../config.json'; const user: User = { email: '***REMOVED***', authtoken: 'testtoken' }; -const credentials = { email: '***REMOVED***', password: 'testpassword' }; -const invalidCredentials = { email: '***REMOVED***', password: 'invalidpassword' }; +const credentials = { email: '***REMOVED***', password: config.password }; +const invalidCredentials = { email: '***REMOVED***', password: config.invalidPassowrd }; let TFAEnabled = false; let TFAChannel = 'authy'; const TFATestToken = '24563992'; diff --git a/packages/contentstack-auth/test/unit/commands/login.test.ts b/packages/contentstack-auth/test/unit/commands/login.test.ts index c91a4d106f..21ed79e743 100644 --- a/packages/contentstack-auth/test/unit/commands/login.test.ts +++ b/packages/contentstack-auth/test/unit/commands/login.test.ts @@ -3,12 +3,13 @@ import * as sinon from 'sinon'; import LoginCommand from '../../../src/commands/auth/login'; import { authHandler, interactive } from '../../../src/utils'; import { configHandler, cliux } from '@contentstack/cli-utilities'; +import * as conf from '../../config.json'; const config = configHandler; const user = { email: '***REMOVED***', authtoken: 'testtoken' }; -const credentials = { email: '***REMOVED***', password: 'testpassword' }; -const invalidCredentials = { email: '***REMOVED***', password: 'invalidpassword' }; +const credentials = { email: '***REMOVED***', password: conf.password }; +const invalidCredentials = { email: '***REMOVED***', password: conf.invalidPassowrd }; const TFATestToken = '24563992'; describe('Login Command', () => { diff --git a/packages/contentstack-auth/test/unit/commands/tokens-add.test.ts b/packages/contentstack-auth/test/unit/commands/tokens-add.test.ts index 091d4806f8..d7003bfa23 100644 --- a/packages/contentstack-auth/test/unit/commands/tokens-add.test.ts +++ b/packages/contentstack-auth/test/unit/commands/tokens-add.test.ts @@ -5,6 +5,7 @@ import TokensAddCommand from '../../../src/commands/auth/tokens/add'; import { tokenValidation } from '../../../src/utils'; import { stub, assert } from 'sinon'; import { config as dotenvConfig } from 'dotenv'; +import * as conf from '../../config.json'; dotenvConfig(); @@ -24,7 +25,7 @@ describe('Tokens Add Command', () => { let managementTokenValidationStub; let environmentTokenValidationStub; let printStub; - const validAPIKey = 'adasdfagsf'; + const validAPIKey = conf.validAPIKey; const validDeliveryToken = '***REMOVED***'; const validmanagementToken = 'cmajhsd98939482'; const validEnvironment = 'textenv'; diff --git a/packages/contentstack-auth/test/unit/interactive.test.ts b/packages/contentstack-auth/test/unit/interactive.test.ts index c6012112d0..4e39338e1a 100644 --- a/packages/contentstack-auth/test/unit/interactive.test.ts +++ b/packages/contentstack-auth/test/unit/interactive.test.ts @@ -2,6 +2,7 @@ import { expect } from 'chai'; import * as sinon from 'sinon'; import { interactive } from '../../src/utils'; import { cliux } from '@contentstack/cli-utilities'; +import * as config from '../config.json' describe('Interactive', () => { let inquireStub; @@ -31,7 +32,7 @@ describe('Interactive', () => { }); it('ask password', async function () { - const password = 'testpassword'; + const password = config.password inquireStub.callsFake(function () { return Promise.resolve(password); }); diff --git a/packages/contentstack-branches/src/utils/create-merge-scripts.ts b/packages/contentstack-branches/src/utils/create-merge-scripts.ts index 7b86b04358..3778f7f7b2 100644 --- a/packages/contentstack-branches/src/utils/create-merge-scripts.ts +++ b/packages/contentstack-branches/src/utils/create-merge-scripts.ts @@ -7,8 +7,9 @@ import { assetFolderCreateScript } from './asset-folder-create-script'; type CreateMergeScriptsProps = { uid: string; - entry_merge_strategy: string; + entry_merge_strategy?: string; type?: string; + status: string }; export function generateMergeScripts(mergeSummary, mergeJobUID) { diff --git a/packages/contentstack-branches/test/config.json b/packages/contentstack-branches/test/config.json index 8b9e929db3..17fdfacb56 100644 --- a/packages/contentstack-branches/test/config.json +++ b/packages/contentstack-branches/test/config.json @@ -1,5 +1,9 @@ { "IS_TS": false, "UNIT_EXECUTION_ORDER": [], - "INTEGRATION_EXECUTION_ORDER": [] + "INTEGRATION_EXECUTION_ORDER": [], + "stackAPIKey": "sfgfdsg223", + "apiKey": "afdgaffsdg", + "stackAPIKey2": "abcdscdxx", + "api_key": "bltxxxxxxxxxxxx" } \ No newline at end of file diff --git a/packages/contentstack-branches/test/unit/commands/cm/branches/create.test.js b/packages/contentstack-branches/test/unit/commands/cm/branches/create.test.js new file mode 100644 index 0000000000..18e27ade09 --- /dev/null +++ b/packages/contentstack-branches/test/unit/commands/cm/branches/create.test.js @@ -0,0 +1,58 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +const mocha_1 = require("mocha"); +const chai_1 = require("chai"); +const sinon_1 = require("sinon"); +const create_1 = tslib_1.__importDefault(require("../../../../../src/commands/cm/branches/create")); +const data_1 = require("../../../mock/data"); +const utils_1 = require("../../../../../src/utils"); +(0, mocha_1.describe)('Create branch', () => { + (0, mocha_1.it)('Create branch with all flags, should be successful', async function () { + const stub1 = (0, sinon_1.stub)(create_1.default.prototype, 'run').resolves(data_1.createBranchMockData.flags); + const args = [ + '--stack-api-key', + data_1.createBranchMockData.flags.apiKey, + '--source', + data_1.createBranchMockData.flags.source, + '--uid', + data_1.createBranchMockData.flags.uid, + ]; + await create_1.default.run(args); + (0, chai_1.expect)(stub1.calledOnce).to.be.true; + stub1.restore(); + }); + (0, mocha_1.it)('Should prompt when api key is not passed', async () => { + const askStackAPIKey = (0, sinon_1.stub)(utils_1.interactive, 'askStackAPIKey').resolves(data_1.createBranchMockData.flags.apiKey); + await create_1.default.run([ + '--source', + data_1.createBranchMockData.flags.source, + '--uid', + data_1.createBranchMockData.flags.uid, + ]); + (0, chai_1.expect)(askStackAPIKey.calledOnce).to.be.true; + askStackAPIKey.restore(); + }); + (0, mocha_1.it)('Should prompt when source branch is not passed', async () => { + const askSourceBranch = (0, sinon_1.stub)(utils_1.interactive, 'askSourceBranch').resolves(data_1.createBranchMockData.flags.source); + await create_1.default.run([ + '--stack-api-key', + data_1.createBranchMockData.flags.apiKey, + '--uid', + data_1.createBranchMockData.flags.uid, + ]); + (0, chai_1.expect)(askSourceBranch.calledOnce).to.be.true; + askSourceBranch.restore(); + }); + (0, mocha_1.it)('Should prompt when new branch uid is not passed', async () => { + const askBranchUid = (0, sinon_1.stub)(utils_1.interactive, 'askBranchUid').resolves(data_1.createBranchMockData.flags.uid); + await create_1.default.run([ + '--stack-api-key', + data_1.createBranchMockData.flags.apiKey, + '--source', + data_1.createBranchMockData.flags.source, + ]); + (0, chai_1.expect)(askBranchUid.calledOnce).to.be.true; + askBranchUid.restore(); + }); +}); diff --git a/packages/contentstack-branches/test/unit/commands/cm/branches/delete.test.js b/packages/contentstack-branches/test/unit/commands/cm/branches/delete.test.js new file mode 100644 index 0000000000..b14b619802 --- /dev/null +++ b/packages/contentstack-branches/test/unit/commands/cm/branches/delete.test.js @@ -0,0 +1,46 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +const mocha_1 = require("mocha"); +const chai_1 = require("chai"); +const sinon_1 = require("sinon"); +const delete_1 = tslib_1.__importDefault(require("../../../../../src/commands/cm/branches/delete")); +const data_1 = require("../../../mock/data"); +const utils_1 = require("../../../../../src/utils"); +(0, mocha_1.describe)('Delete branch', () => { + (0, mocha_1.it)('Delete branch with all flags, should be successful', async function () { + const stub1 = (0, sinon_1.stub)(delete_1.default.prototype, 'run').resolves(data_1.deleteBranchMockData.flags); + await delete_1.default.run([ + '--stack-api-key', + data_1.deleteBranchMockData.flags.apiKey, + '--uid', + data_1.deleteBranchMockData.flags.uid, + '-y', + ]); + (0, chai_1.expect)(stub1.calledOnce).to.be.true; + stub1.restore(); + }); + (0, mocha_1.it)('Should prompt when api key is not passed', async () => { + const askStackAPIKey = (0, sinon_1.stub)(utils_1.interactive, 'askStackAPIKey').resolves(data_1.deleteBranchMockData.flags.apiKey); + await delete_1.default.run(['--uid', data_1.deleteBranchMockData.flags.uid, "--yes"]); + (0, chai_1.expect)(askStackAPIKey.calledOnce).to.be.true; + askStackAPIKey.restore(); + }); + (0, mocha_1.it)('Should prompt when branch is not passed and also ask confirmation wihtout -y flag', async () => { + const askSourceBranch = (0, sinon_1.stub)(utils_1.interactive, 'askBranchUid').resolves(data_1.deleteBranchMockData.flags.uid); + await delete_1.default.run(['--stack-api-key', data_1.deleteBranchMockData.flags.apiKey, "--yes"]); + (0, chai_1.expect)(askSourceBranch.calledOnce).to.be.true; + askSourceBranch.restore(); + }); + (0, mocha_1.it)('Should ask branch name confirmation if yes not provided, success if same branch uid provided', async () => { + const askConfirmation = (0, sinon_1.stub)(utils_1.interactive, 'askBranchNameConfirmation').resolves(data_1.deleteBranchMockData.flags.uid); + await delete_1.default.run([ + '--stack-api-key', + data_1.deleteBranchMockData.flags.apiKey, + '--uid', + data_1.deleteBranchMockData.flags.uid + ]); + (0, chai_1.expect)(askConfirmation.called).to.be.true; + askConfirmation.restore(); + }); +}); diff --git a/packages/contentstack-branches/test/unit/commands/cm/branches/diff.test.js b/packages/contentstack-branches/test/unit/commands/cm/branches/diff.test.js new file mode 100644 index 0000000000..f6eb27af70 --- /dev/null +++ b/packages/contentstack-branches/test/unit/commands/cm/branches/diff.test.js @@ -0,0 +1,56 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +const mocha_1 = require("mocha"); +const chai_1 = require("chai"); +const sinon_1 = require("sinon"); +const diff_1 = tslib_1.__importDefault(require("../../../../../src/commands/cm/branches/diff")); +const branch_1 = require("../../../../../src/branch"); +const data_1 = require("../../../mock/data"); +(0, mocha_1.describe)('Diff Command', () => { + (0, mocha_1.it)('Branch diff with all flags, should be successful', async function () { + const stub1 = (0, sinon_1.stub)(branch_1.BranchDiffHandler.prototype, 'run').resolves(data_1.mockData.data); + await diff_1.default.run([ + '--compare-branch', + data_1.mockData.flags.compareBranch, + '--module', + data_1.mockData.flags.module, + '-k', + data_1.mockData.flags.stackAPIKey, + '--base-branch', + data_1.mockData.flags.baseBranch, + ]); + (0, chai_1.expect)(stub1.calledOnce).to.be.true; + stub1.restore(); + }); + (0, mocha_1.it)('Branch diff when format type is verbose, should display verbose view', async function () { + const stub1 = (0, sinon_1.stub)(diff_1.default.prototype, 'run').resolves(data_1.mockData.verboseContentTypeRes); + await diff_1.default.run([ + '--compare-branch', + data_1.mockData.flags.compareBranch, + '--base-branch', + data_1.mockData.flags.baseBranch, + '--module', + data_1.mockData.flags.module, + '-k', + data_1.mockData.flags.stackAPIKey, + '--format', + 'verbose' + ]); + stub1.restore(); + }).timeout(10000); + (0, mocha_1.it)('Branch summary when module is of both type(content_types & global fields)', async function () { + const stub1 = (0, sinon_1.stub)(diff_1.default.prototype, 'run').resolves(data_1.mockData.data); + await diff_1.default.run([ + '--compare-branch', + data_1.mockData.flags.compareBranch, + '--base-branch', + data_1.mockData.flags.baseBranch, + '--module', + 'all', + '-k', + data_1.mockData.flags.stackAPIKey + ]); + stub1.restore(); + }); +}); diff --git a/packages/contentstack-branches/test/unit/commands/cm/branches/list.test.js b/packages/contentstack-branches/test/unit/commands/cm/branches/list.test.js new file mode 100644 index 0000000000..6a6b5fdf75 --- /dev/null +++ b/packages/contentstack-branches/test/unit/commands/cm/branches/list.test.js @@ -0,0 +1,35 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +const mocha_1 = require("mocha"); +const chai_1 = require("chai"); +const sinon_1 = require("sinon"); +const index_1 = tslib_1.__importDefault(require("../../../../../src/commands/cm/branches/index")); +const data_1 = require("../../../mock/data"); +const utils_1 = require("../../../../../src/utils"); +const cli_utilities_1 = require("@contentstack/cli-utilities"); +(0, mocha_1.describe)('List branches', () => { + (0, mocha_1.it)('List branches with all flags, should be successful', async function () { + const stub1 = (0, sinon_1.stub)(index_1.default.prototype, 'run').resolves(data_1.branchMockData.flags); + const args = ['--stack-api-key', data_1.branchMockData.flags.apiKey]; + await index_1.default.run(args); + (0, chai_1.expect)(stub1.calledOnce).to.be.true; + stub1.restore(); + }); + (0, mocha_1.it)('Should prompt when api key is not passed', async () => { + const askStackAPIKey = (0, sinon_1.stub)(utils_1.interactive, 'askStackAPIKey').resolves(data_1.branchMockData.flags.apiKey); + await index_1.default.run([]); + (0, chai_1.expect)(askStackAPIKey.calledOnce).to.be.true; + askStackAPIKey.restore(); + }); + (0, mocha_1.it)('branches with verbose flag, should list branches in table', async () => { + const branchStub = (0, sinon_1.stub)(cli_utilities_1.cliux, 'table').callsFake((branches) => { + (0, chai_1.expect)(branches).to.have.length.greaterThan(0); + }); + await index_1.default.run(['-k', data_1.branchMockData.flags.apiKey, '--verbose']); + branchStub.restore(); + }); + (0, mocha_1.it)('Branch diff when format type is verbose, should display verbose view', async function () { + await index_1.default.run(['-k', data_1.branchMockData.flags.apiKey, '--verbose']); + }); +}); diff --git a/packages/contentstack-branches/test/unit/commands/cm/branches/merge.test.js b/packages/contentstack-branches/test/unit/commands/cm/branches/merge.test.js new file mode 100644 index 0000000000..af73405991 --- /dev/null +++ b/packages/contentstack-branches/test/unit/commands/cm/branches/merge.test.js @@ -0,0 +1,38 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +const mocha_1 = require("mocha"); +const chai_1 = require("chai"); +const sinon_1 = require("sinon"); +const merge_1 = tslib_1.__importDefault(require("../../../../../src/commands/cm/branches/merge")); +const cli_utilities_1 = require("@contentstack/cli-utilities"); +const data_1 = require("../../../mock/data"); +const mergeHelper = tslib_1.__importStar(require("../../../../../src/utils/merge-helper")); +const index_1 = require("../../../../../src/branch/index"); +(0, mocha_1.describe)('Merge Command', () => { + let successMessageStub; + (0, mocha_1.beforeEach)(function () { + successMessageStub = (0, sinon_1.stub)(cli_utilities_1.cliux, 'print'); + }); + (0, mocha_1.afterEach)(function () { + successMessageStub.restore(); + }); + (0, mocha_1.it)('Merge branch changes with all flags, should be successful', async function () { + const mergeInputStub = (0, sinon_1.stub)(mergeHelper, 'setupMergeInputs').resolves(data_1.mockData.mergeData.flags); + const displayBranchStatusStub = (0, sinon_1.stub)(mergeHelper, 'displayBranchStatus').resolves(data_1.mockData.mergeData.branchCompareData); + const mergeHandlerStub = (0, sinon_1.stub)(index_1.MergeHandler.prototype, 'start').resolves(); + await merge_1.default.run([ + '--compare-branch', + data_1.mockData.flags.compareBranch, + '-k', + data_1.mockData.flags.stackAPIKey, + '--base-branch', + data_1.mockData.flags.baseBranch, + ]); + (0, chai_1.expect)(mergeHandlerStub.calledOnce).to.be.true; + mergeInputStub.restore(); + displayBranchStatusStub.restore(); + mergeHandlerStub.restore(); + }); +}); +// commands diff --git a/packages/contentstack-branches/test/unit/mock/data.ts b/packages/contentstack-branches/test/unit/mock/data.ts index 83f144ec10..bcfb7a3237 100644 --- a/packages/contentstack-branches/test/unit/mock/data.ts +++ b/packages/contentstack-branches/test/unit/mock/data.ts @@ -1,23 +1,24 @@ +const config = require('../../config.json'); const mockData = { flags: { baseBranch: 'main', compareBranch: 'dev', - stackAPIKey: 'sfgfdsg223', + stackAPIKey: config.stackAPIKey, module: 'content-types', format: 'compactfield', }, withoutBaseFlag: { compareBranch: 'dev', - stackAPIKey: 'sfgfdsg223', + stackAPIKey: config.stackAPIKey, module: 'content-types', format: 'compactfield', }, withoutCompareFlag: { baseBranch: 'main', - stackAPIKey: 'sfgfdsg223', + stackAPIKey: config.stackAPIKey, module: 'content-types', format: 'compactfield', - compareBranch:'' + compareBranch: '', }, withoutAPIKeyFlag: { baseBranch: 'main', @@ -29,9 +30,9 @@ const mockData = { withoutModuleFlag: { baseBranch: 'main', compareBranch: 'dev', - stackAPIKey: 'sfgfdsg223', + stackAPIKey: config.stackAPIKey, format: 'compactfield', - module:'' + module: '', }, data: { base: 'main', @@ -142,7 +143,7 @@ const mockData = { }, branchDiffPayload: { module: 'content_type', - apiKey: 'afdgaffsdg', + apiKey: config.apiKey, baseBranch: 'main', compareBranch: 'dev', }, @@ -406,7 +407,7 @@ const mockData = { strategy: 'merge_prefer_base', strategySubOption: 'merge_new_only', branchCompareData: '', - stackAPIKey: 'abcdscdxx', + stackAPIKey: config.stackAPIKey2, baseBranch: 'main', host: '', enableEntryExp: false, @@ -416,7 +417,7 @@ const mockData = { strategy: '', strategySubOption: '', branchCompareData: {}, - stackAPIKey: 'abcdscdxx', + stackAPIKey: config.stackAPIKey2, baseBranch: 'main', host: '', enableEntryExp: false, @@ -533,7 +534,7 @@ const branchMockData = { items: [ { stackHeaders: { - api_key: 'bltxxxxxxxxxxxx', + api_key: config.api_key, }, urlPath: '/stacks/branches/new_branch', uid: 'new_branch', @@ -547,7 +548,7 @@ const branchMockData = { }, { stackHeaders: { - api_key: 'bltxxxxxxxxxxxxxxx', + api_key: config.api_key, }, urlPath: '/stacks/branches/test_branch', uid: 'test_branch', @@ -561,7 +562,7 @@ const branchMockData = { }, { stackHeaders: { - api_key: 'bltxxxxxxxxxxxxxxx', + api_key: config.api_key, }, urlPath: '/stacks/branches/new', uid: 'new', @@ -575,7 +576,7 @@ const branchMockData = { }, { stackHeaders: { - api_key: 'bltxxxxxxxxxxxxxxx', + api_key: config.api_key, }, urlPath: '/stacks/branches/main', uid: 'main', @@ -589,7 +590,7 @@ const branchMockData = { }, { stackHeaders: { - api_key: 'bltxxxxxxxxxxxxxxx', + api_key: config.api_key, }, urlPath: '/stacks/branches/release', uid: 'release', @@ -805,8 +806,8 @@ const baseAndCompareChanges = { path: 'social', uid: 'social', displayName: 'Social', - fieldType: 'group' - } + fieldType: 'group', + }, }, added: {}, deleted: { @@ -814,9 +815,9 @@ const baseAndCompareChanges = { path: 'social.social_share', uid: 'social_share', displayName: 'Social Share', - fieldType: 'group' - } - } + fieldType: 'group', + }, + }, }, compareHavingSchema: { modified: { @@ -824,45 +825,45 @@ const baseAndCompareChanges = { path: 'social', uid: 'social', displayName: 'Social', - fieldType: 'group' - } + fieldType: 'group', + }, }, added: { 'social.social_share': { path: 'social.social_share', uid: 'social_share', displayName: 'Social Share', - fieldType: 'group' - } + fieldType: 'group', + }, }, - deleted: {} + deleted: {}, }, - modifiedFieldRes:{ + modifiedFieldRes: { listOfAddedFields: [ { path: undefined, displayName: undefined, uid: undefined, - field: undefined - } + field: undefined, + }, ], listOfDeletedFields: [ { path: 'single_line_fieldbox33', displayName: 'Single Line fieldbox33', uid: 'single_line_fieldbox33', - field: 'compactfield' - } + field: 'compactfield', + }, ], listOfModifiedFields: [ { path: 'title', displayName: 'Name', uid: 'title', - field: 'metadata' - } - ] - } + field: 'metadata', + }, + ], + }, }; export { @@ -874,5 +875,5 @@ export { compareBranchDiff, compareBranchNoSchema, baseBranchNoSchema, - baseAndCompareChanges + baseAndCompareChanges, }; diff --git a/packages/contentstack-branches/test/unit/utils/create-branch-handler.test.js b/packages/contentstack-branches/test/unit/utils/create-branch-handler.test.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/contentstack-branches/test/unit/utils/create-merge-scripts.test.js b/packages/contentstack-branches/test/unit/utils/create-merge-scripts.test.js new file mode 100644 index 0000000000..540beae1bd --- /dev/null +++ b/packages/contentstack-branches/test/unit/utils/create-merge-scripts.test.js @@ -0,0 +1,49 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +const mocha_1 = require("mocha"); +const utils_1 = require("../../../src/utils"); +const fs_1 = tslib_1.__importDefault(require("fs")); +const chai_1 = require("chai"); +(0, mocha_1.describe)('File system operations', () => { + const content = `const API = 'hello world'`; + const folderName = (0, utils_1.createMergeScripts)({ status: 'modified', uid: 'blog' }, content, '1234-1234'); + (0, mocha_1.it)('Should proceed to generate or throw error when permission not provided', () => { + const { W_OK: writePermission } = fs_1.default.constants; + const checkPermissions = fs_1.default.accessSync('./', writePermission); + (0, chai_1.expect)(checkPermissions).to.equal(undefined); + }); + (0, mocha_1.it)('Should create a root folder for scripts', () => { + const doesFolderExist = fs_1.default.existsSync(folderName); + (0, chai_1.expect)(doesFolderExist).to.equal(true); + }); + (0, mocha_1.it)('Check if folder name contains createdAt timestamp and the end', () => { + const splitCreatedAt = folderName.split('_'); + const createdAt = splitCreatedAt[splitCreatedAt.length - 1]; + (0, chai_1.expect)(createdAt.length).to.oneOf([12, 13, 14]); + }); + (0, mocha_1.it)('Check if file name contains the timestamp prefix from the foldername', () => { + const splitCreatedAt = folderName.split('_'); + const createdAt = splitCreatedAt[splitCreatedAt.length - 1]; + const filesInFolder = fs_1.default.readdirSync(folderName); + const doesFileExistWithCreatedAtPrefix = filesInFolder.some((file) => file.includes(createdAt)); + (0, chai_1.expect)(doesFileExistWithCreatedAtPrefix).to.equal(true); + }); + (0, mocha_1.it)('Check if the content that is passed as argument to the function is present in the file', () => { + const filesInFolder = fs_1.default.readdirSync(folderName); + if (filesInFolder.length !== 0) { + const contentFromFile = fs_1.default.readFileSync(`${folderName}/${filesInFolder[0]}`, { encoding: 'utf-8', flag: 'r' }); + (0, chai_1.expect)(contentFromFile).to.equal(content); + } + }); +}); +(0, mocha_1.describe)('Check for operation status', () => { + (0, mocha_1.it)('Should return updated when modified is passed', () => { + const operation = (0, utils_1.getContentypeMergeStatus)('modified'); + (0, chai_1.expect)(operation).to.equal('updated'); + }); + (0, mocha_1.it)('Should return created when compare_only is passed', () => { + const operation = (0, utils_1.getContentypeMergeStatus)('compare_only'); + (0, chai_1.expect)(operation).to.equal('created'); + }); +}); diff --git a/packages/contentstack-branches/test/unit/utils/diff-branch-handler.test.js b/packages/contentstack-branches/test/unit/utils/diff-branch-handler.test.js new file mode 100644 index 0000000000..a44f6b4499 --- /dev/null +++ b/packages/contentstack-branches/test/unit/utils/diff-branch-handler.test.js @@ -0,0 +1,230 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +const mocha_1 = require("mocha"); +const chai_1 = require("chai"); +const sinon_1 = require("sinon"); +const utils_1 = require("../../../src/utils"); +const data_1 = require("../mock/data"); +const branch_1 = require("../../../src/branch"); +const util = tslib_1.__importStar(require("../../../src/utils")); +const cli_utilities_1 = require("@contentstack/cli-utilities"); +(0, mocha_1.describe)('Branch Diff Utility Testcases', () => { + let apiRequestStub, fetchBranchesDiffStub, loaderV2Stub; + (0, mocha_1.beforeEach)(function () { + apiRequestStub = (0, sinon_1.stub)(utils_1.branchDiffUtility, 'branchCompareSDK').callsFake(function (param, skip, limit) { + if (param.baseBranch === 'xyz') { + return Promise.resolve('Base branch is invalid'); + } + else { + return Promise.resolve(data_1.mockData.branchDiff); + } + }); + fetchBranchesDiffStub = (0, sinon_1.stub)(utils_1.branchDiffUtility, 'fetchBranchesDiff').callsFake(function (param) { + if (param) { + const result = apiRequestStub(param); + return Promise.resolve(result); + } + }); + loaderV2Stub = (0, sinon_1.stub)(cli_utilities_1.cliux, 'loaderV2'); + }); + (0, mocha_1.afterEach)(function () { + apiRequestStub.restore(); + fetchBranchesDiffStub.restore(); + loaderV2Stub.restore(); + }); + (0, mocha_1.it)('fetch branch differences', async function () { + const result = await fetchBranchesDiffStub(data_1.mockData.branchDiffPayload); + (0, chai_1.expect)(fetchBranchesDiffStub.calledOnce).to.be.true; + (0, chai_1.expect)(result).to.be.equal(data_1.mockData.branchDiff); + }); + (0, mocha_1.it)('API request, should be failed', async function () { + data_1.mockData.branchDiffPayload.baseBranch = 'xyz'; + const result = await fetchBranchesDiffStub(data_1.mockData.branchDiffPayload); + (0, chai_1.expect)(fetchBranchesDiffStub.calledOnce).to.be.true; + (0, chai_1.expect)(result).to.be.equal('Base branch is invalid'); + }); + (0, mocha_1.it)('parse branch summary', async function () { + const result = utils_1.branchDiffUtility.parseSummary(data_1.mockData.contentTypesDiff, 'main', 'dev'); + (0, chai_1.expect)(result).to.deep.equal(data_1.mockData.branchSummary); + }); + (0, mocha_1.it)('print branch summary', async function () { + utils_1.branchDiffUtility.printSummary(data_1.mockData.branchSummary); + }); + (0, mocha_1.it)('parse compact text', async function () { + const result = utils_1.branchDiffUtility.parseCompactText(data_1.mockData.contentTypesDiff); + (0, chai_1.expect)(result).to.deep.equal(data_1.mockData.branchTextData); + }); + (0, mocha_1.it)('print compact text', async function () { + utils_1.branchDiffUtility.printCompactTextView(data_1.mockData.branchCompactData); + }); + (0, mocha_1.it)('print compact text view, nothing to display', async function () { + utils_1.branchDiffUtility.printCompactTextView(data_1.mockData.noModifiedData); + }); + (0, mocha_1.it)('parse detailedText', async function () { + const parseCompactStub = (0, sinon_1.stub)(utils_1.branchDiffUtility, 'parseCompactText'); + parseCompactStub.withArgs(data_1.mockData.contentTypesDiff); + const parseVerboseStub = (0, sinon_1.stub)(utils_1.branchDiffUtility, 'parseVerbose'); + parseVerboseStub + .withArgs(data_1.mockData.contentTypesDiff, data_1.mockData.branchDiffPayload) + .resolves(data_1.mockData.verboseContentTypeRes); + const result = await utils_1.branchDiffUtility.parseVerbose(data_1.mockData.contentTypesDiff, data_1.mockData.branchDiffPayload); + (0, chai_1.expect)(parseVerboseStub.calledOnce).to.be.true; + (0, chai_1.expect)(result).to.be.equal(data_1.mockData.verboseContentTypeRes); + parseCompactStub.restore(); + parseVerboseStub.restore(); + }); + (0, mocha_1.it)('prepare branch detailedText response', async function () { + const result = await utils_1.branchDiffUtility.prepareBranchVerboseRes(data_1.mockData.globalFieldDetailDiff); + (0, chai_1.expect)(result).deep.be.equal(data_1.mockData.verboseRes); + }); + (0, mocha_1.it)('print detailedText text view', async function () { + utils_1.branchDiffUtility.printVerboseTextView(data_1.mockData.verboseContentTypeRes); + }); + (0, mocha_1.it)('print detailedText text view, nothing to display', async function () { + utils_1.branchDiffUtility.printVerboseTextView(data_1.mockData.noModifiedData); + }); + (0, mocha_1.it)('filter out branch differences on basis of module like content_types, global_fields', async function () { + const result = utils_1.branchDiffUtility.filterBranchDiffDataByModule(data_1.mockData.contentTypesDiff); + (0, chai_1.expect)(result).to.deep.equal(data_1.mockData.contentTypesDiffData); + }); + (0, mocha_1.it)('base and compare branch having schema, differences', async function () { + const result = await utils_1.branchDiffUtility.deepDiff(data_1.baseBranchDiff, data_1.compareBranchDiff); + (0, chai_1.expect)(result).to.deep.equal(data_1.baseAndCompareChanges.baseAndCompareHavingSchema); + }); + (0, mocha_1.it)('base branch having only schema, differences', async function () { + const result = await utils_1.branchDiffUtility.deepDiff(data_1.baseBranchDiff, data_1.compareBranchNoSchema); + (0, chai_1.expect)(result).to.deep.equal(data_1.baseAndCompareChanges.baseHavingSchema); + }); + (0, mocha_1.it)('compare branch having only schema, differences', async function () { + const result = await utils_1.branchDiffUtility.deepDiff(data_1.baseBranchNoSchema, data_1.compareBranchDiff); + (0, chai_1.expect)(result).to.deep.equal(data_1.baseAndCompareChanges.compareHavingSchema); + }); + (0, mocha_1.it)('prepare base and compare branch modified differences', async function () { + const deepDiffStub = (0, sinon_1.stub)(utils_1.branchDiffUtility, 'deepDiff').resolves(data_1.baseAndCompareChanges.baseAndCompareHavingSchema); + await utils_1.branchDiffUtility.prepareModifiedDiff({ + baseBranchFieldExists: data_1.baseBranchDiff, + compareBranchFieldExists: data_1.compareBranchDiff, + diffData: data_1.mockData.branchDiff, + listOfModifiedFields: [], + listOfAddedFields: [], + listOfDeletedFields: [], + }); + deepDiffStub.restore(); + }); +}); +(0, mocha_1.describe)('Branch Diff handler Testcases', () => { + let fetchBranchDiffStub, filterBranchDiffDataByModuleStub, displaySummaryStub, loaderV2Stub; + (0, mocha_1.beforeEach)(function () { + fetchBranchDiffStub = (0, sinon_1.stub)(utils_1.branchDiffUtility, 'fetchBranchesDiff'); + filterBranchDiffDataByModuleStub = (0, sinon_1.stub)(utils_1.branchDiffUtility, 'filterBranchDiffDataByModule'); + displaySummaryStub = (0, sinon_1.stub)(branch_1.BranchDiffHandler.prototype, 'displaySummary'); + loaderV2Stub = (0, sinon_1.stub)(cli_utilities_1.cliux, 'loaderV2'); + }); + (0, mocha_1.afterEach)(function () { + fetchBranchDiffStub.restore(); + filterBranchDiffDataByModuleStub.restore(); + displaySummaryStub.restore(); + loaderV2Stub.restore(); + }); + (0, mocha_1.it)('Branch diff without compare branch flag, should prompt for compare branch', async function () { + const askCompareBranch = (0, sinon_1.stub)(utils_1.interactive, 'askCompareBranch').resolves(data_1.mockData.flags.compareBranch); + new branch_1.BranchDiffHandler(data_1.mockData.withoutCompareFlag).validateMandatoryFlags(); + (0, chai_1.expect)(askCompareBranch.calledOnce).to.be.true; + askCompareBranch.restore(); + }); + (0, mocha_1.it)('Branch diff without base branch flag, should prompt for base branch', async function () { + const askBaseBranch = (0, sinon_1.stub)(utils_1.interactive, 'askBaseBranch').resolves(data_1.mockData.flags.baseBranch); + new branch_1.BranchDiffHandler(data_1.mockData.withoutBaseFlag).validateMandatoryFlags(); + (0, chai_1.expect)(askBaseBranch.calledOnce).to.be.true; + askBaseBranch.restore(); + }); + (0, mocha_1.it)('Branch diff without stack api flag, should prompt for stack api key', async function () { + const askStackAPIKey = (0, sinon_1.stub)(utils_1.interactive, 'askStackAPIKey').resolves(data_1.mockData.flags.stackAPIKey); + new branch_1.BranchDiffHandler(data_1.mockData.withoutAPIKeyFlag).validateMandatoryFlags(); + (0, chai_1.expect)(askStackAPIKey.calledOnce).to.be.true; + askStackAPIKey.restore(); + }); + (0, mocha_1.it)('Branch diff without module flag, should prompt for module', async function () { + const askModule = (0, sinon_1.stub)(utils_1.interactive, 'selectModule').resolves(data_1.mockData.flags.module); + new branch_1.BranchDiffHandler(data_1.mockData.withoutModuleFlag).validateMandatoryFlags(); + (0, chai_1.expect)(askModule.calledOnce).to.be.true; + askModule.restore(); + }); + (0, mocha_1.it)('Branch diff with global config, should take the base branch from config', async function () { + const stubBranchConfig = (0, sinon_1.stub)(util, 'getbranchConfig').resolves(data_1.mockData.flags.baseBranch); + delete data_1.mockData.flags.baseBranch; + new branch_1.BranchDiffHandler(data_1.mockData.flags).validateMandatoryFlags(); + (0, chai_1.expect)(stubBranchConfig.calledOnce).to.be.true; + stubBranchConfig.restore(); + }); + (0, mocha_1.it)('display content types summary', async function () { + const parseSummaryStub = (0, sinon_1.stub)(utils_1.branchDiffUtility, 'parseSummary'); + parseSummaryStub.withArgs(data_1.mockData.contentTypesDiff, 'main', 'dev').returns(data_1.mockData.branchSummary); + const printSummaryStub = (0, sinon_1.stub)(utils_1.branchDiffUtility, 'printSummary'); + printSummaryStub.withArgs(data_1.mockData.branchSummary).returns(); + new branch_1.BranchDiffHandler(data_1.mockData.flags).displaySummary(data_1.mockData.contentTypesDiff, data_1.mockData.flags.module); + parseSummaryStub.restore(); + printSummaryStub.restore(); + }); + (0, mocha_1.it)('display global fields summary', async function () { + const parseSummaryStub = (0, sinon_1.stub)(utils_1.branchDiffUtility, 'parseSummary'); + parseSummaryStub.withArgs(data_1.mockData.globalFieldDiff, 'main', 'dev').returns(data_1.mockData.branchSummary); + const printSummaryStub = (0, sinon_1.stub)(utils_1.branchDiffUtility, 'printSummary'); + printSummaryStub.withArgs(data_1.mockData.branchSummary).returns(); + data_1.mockData.flags.module = 'global_fields'; + new branch_1.BranchDiffHandler(data_1.mockData.flags).displaySummary(data_1.mockData.globalFieldDiff, data_1.mockData.flags.module); + parseSummaryStub.restore(); + printSummaryStub.restore(); + }); + (0, mocha_1.it)('display branch diff, compact text view', async function () { + const parseCompactTextStub = (0, sinon_1.stub)(utils_1.branchDiffUtility, 'parseCompactText'); + parseCompactTextStub.withArgs(data_1.mockData.contentTypesDiff).returns(data_1.mockData.branchCompactData); + const printCompactTextViewStub = (0, sinon_1.stub)(utils_1.branchDiffUtility, 'printCompactTextView'); + printCompactTextViewStub.withArgs(data_1.mockData.branchCompactData).returns(); + new branch_1.BranchDiffHandler(data_1.mockData.flags).displayBranchDiffTextAndVerbose(data_1.mockData.contentTypesDiff, data_1.mockData.branchDiffPayload); + //expect(parseCompactTextStub.calledOnce).to.be.true; + //expect(printCompactTextViewStub.calledOnce).to.be.true; + parseCompactTextStub.restore(); + printCompactTextViewStub.restore(); + }); + (0, mocha_1.it)('display branch diff, detailedText view', async function () { + const parseVerboseStub = (0, sinon_1.stub)(utils_1.branchDiffUtility, 'parseVerbose'); + parseVerboseStub + .withArgs(data_1.mockData.contentTypesDiff, data_1.mockData.branchDiffPayload) + .resolves(data_1.mockData.verboseContentTypeRes); + const printVerboseTextViewStub = (0, sinon_1.stub)(utils_1.branchDiffUtility, 'printVerboseTextView'); + printVerboseTextViewStub.withArgs(data_1.mockData.verboseContentTypeRes).returns(); + data_1.mockData.flags.format = 'detailedText'; + new branch_1.BranchDiffHandler(data_1.mockData.flags).displayBranchDiffTextAndVerbose(data_1.mockData.contentTypesDiff, data_1.mockData.branchDiffPayload); + parseVerboseStub.restore(); + printVerboseTextViewStub.restore(); + }); + (0, mocha_1.it)('BranchDiffHandler initBranchDiffUtility, content_types module', async function () { + fetchBranchDiffStub.withArgs(data_1.mockData.branchDiffPayload).resolves(data_1.mockData.contentTypesDiff); + filterBranchDiffDataByModuleStub.withArgs(data_1.mockData.contentTypesDiff).resolves(data_1.mockData.contentTypesDiffData); + displaySummaryStub.withArgs(data_1.mockData.contentTypesDiff, data_1.mockData.flags.module).returns(); + const contentTypeVerbose = (0, sinon_1.stub)(branch_1.BranchDiffHandler.prototype, 'displayBranchDiffTextAndVerbose'); + contentTypeVerbose.withArgs(data_1.mockData.contentTypesDiff, data_1.mockData.branchDiffPayload); + new branch_1.BranchDiffHandler(data_1.mockData.flags).initBranchDiffUtility(); + contentTypeVerbose.restore(); + }); + (0, mocha_1.it)('BranchDiffHandler initBranchDiffUtility, global_fields module', async function () { + data_1.mockData.flags.module = 'global_fields'; + fetchBranchDiffStub.withArgs(data_1.mockData.branchDiffPayload).resolves(data_1.mockData.globalFieldDiff); + filterBranchDiffDataByModuleStub.withArgs(data_1.mockData.globalFieldDiff).resolves(data_1.mockData.globalFieldsDiffData); + displaySummaryStub.withArgs(data_1.mockData.globalFieldDiff, data_1.mockData.flags.module).returns(); + const globalFieldVerbose = (0, sinon_1.stub)(branch_1.BranchDiffHandler.prototype, 'displayBranchDiffTextAndVerbose'); + globalFieldVerbose.withArgs(data_1.mockData.globalFieldDiff, data_1.mockData.branchDiffPayload); + data_1.mockData.flags.module = 'global_fields'; + new branch_1.BranchDiffHandler(data_1.mockData.flags).initBranchDiffUtility(); + globalFieldVerbose.restore(); + }); + (0, mocha_1.it)('execute BranchDiffHandler run method', async function () { + const stub1 = (0, sinon_1.stub)(branch_1.BranchDiffHandler.prototype, 'initBranchDiffUtility'); + const stub2 = (0, sinon_1.stub)(branch_1.BranchDiffHandler.prototype, 'validateMandatoryFlags'); + new branch_1.BranchDiffHandler(data_1.mockData.flags).run(); + stub1.restore(); + stub2.restore(); + }); +}); diff --git a/packages/contentstack-branches/test/unit/utils/interactive.test.js b/packages/contentstack-branches/test/unit/utils/interactive.test.js new file mode 100644 index 0000000000..ccd58a7bcd --- /dev/null +++ b/packages/contentstack-branches/test/unit/utils/interactive.test.js @@ -0,0 +1,122 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const chai_1 = require("chai"); +const mocha_1 = require("mocha"); +const sinon_1 = require("sinon"); +const cli_utilities_1 = require("@contentstack/cli-utilities"); +const utils_1 = require("../../../src/utils"); +(0, mocha_1.describe)('Interactive', () => { + let inquireStub; + (0, mocha_1.beforeEach)(function () { + inquireStub = (0, sinon_1.stub)(cli_utilities_1.cliux, 'inquire'); + }); + (0, mocha_1.afterEach)(function () { + inquireStub.restore(); + }); + (0, mocha_1.it)('select module', async function () { + const module = 'content_types'; + inquireStub.callsFake(function () { + return Promise.resolve(module); + }); + const result = await utils_1.interactive.selectModule(); + const isValid = utils_1.interactive.inquireRequireFieldValidation(result); + (0, chai_1.expect)(result).to.be.equal(module); + (0, chai_1.expect)(isValid).to.be.equal(true); + }); + (0, mocha_1.it)('ask compare branch', async function () { + const compareBranch = 'dev'; + inquireStub.callsFake(function () { + return Promise.resolve(compareBranch); + }); + const result = await utils_1.interactive.askCompareBranch(); + (0, chai_1.expect)(result).to.be.equal(compareBranch); + }); + (0, mocha_1.it)('ask stack api key', async function () { + const stackAPIKey = 'abcd'; + inquireStub.callsFake(function () { + return Promise.resolve(stackAPIKey); + }); + const result = await utils_1.interactive.askStackAPIKey(); + (0, chai_1.expect)(result).to.be.equal(stackAPIKey); + }); + (0, mocha_1.it)('ask base branch', async function () { + const baseBranch = 'main'; + inquireStub.callsFake(function () { + return Promise.resolve(baseBranch); + }); + const result = await utils_1.interactive.askBaseBranch(); + (0, chai_1.expect)(result).to.be.equal(baseBranch); + }); + (0, mocha_1.it)('ask source branch', async function () { + const sourceBranch = 'dev'; + inquireStub.callsFake(function () { + return Promise.resolve(sourceBranch); + }); + const result = await utils_1.interactive.askSourceBranch(); + (0, chai_1.expect)(result).to.be.equal(sourceBranch); + }); + (0, mocha_1.it)('ask branch uid', async function () { + const branchUid = 'new_branch'; + inquireStub.callsFake(function () { + return Promise.resolve(branchUid); + }); + const result = await utils_1.interactive.askBranchUid(); + (0, chai_1.expect)(result).to.be.equal(branchUid); + }); + (0, mocha_1.it)('confirm delete branch', async function () { + inquireStub.callsFake(function () { + return Promise.resolve(true); + }); + const result = await utils_1.interactive.askConfirmation(); + (0, chai_1.expect)(result).to.be.equal(true); + }); + (0, mocha_1.it)('Without input value, should be failed', async function () { + const msg = 'CLI_BRANCH_REQUIRED_FIELD'; + const result = utils_1.interactive.inquireRequireFieldValidation(''); + (0, chai_1.expect)(result).to.be.equal(msg); + }); + (0, mocha_1.it)('With input value, should be success', async function () { + const result = utils_1.interactive.inquireRequireFieldValidation('main'); + (0, chai_1.expect)(result).to.be.equal(true); + }); + (0, mocha_1.it)('select merge strategy, should be successful', async function () { + const strategy = 'merge_prefer_base'; + inquireStub.callsFake(function () { + return Promise.resolve(strategy); + }); + const result = await utils_1.interactive.selectMergeStrategy(); + (0, chai_1.expect)(result).to.be.equal(strategy); + }); + (0, mocha_1.it)('select merge strategy sub options, should be successful', async function () { + const strategy = 'new'; + inquireStub.callsFake(function () { + return Promise.resolve(strategy); + }); + const result = await utils_1.interactive.selectMergeStrategySubOptions(); + (0, chai_1.expect)(result).to.be.equal(strategy); + }); + (0, mocha_1.it)('select merge executions, should be successful', async function () { + const strategy = 'export'; + inquireStub.callsFake(function () { + return Promise.resolve(strategy); + }); + const result = await utils_1.interactive.selectMergeExecution(); + (0, chai_1.expect)(result).to.be.equal(strategy); + }); + (0, mocha_1.it)('ask export merge summary path', async function () { + const filePath = 'sfgfdsg223'; + inquireStub.callsFake(function () { + return Promise.resolve(filePath); + }); + const result = await utils_1.interactive.askExportMergeSummaryPath(); + (0, chai_1.expect)(result).to.be.equal(filePath); + }); + (0, mocha_1.it)('ask merge comment', async function () { + const comment = 'changes'; + inquireStub.callsFake(function () { + return Promise.resolve(comment); + }); + const result = await utils_1.interactive.askMergeComment(); + (0, chai_1.expect)(result).to.be.equal(comment); + }); +}); diff --git a/packages/contentstack-branches/test/unit/utils/merge-branch-handler.test.js b/packages/contentstack-branches/test/unit/utils/merge-branch-handler.test.js new file mode 100644 index 0000000000..0fe8ecb545 --- /dev/null +++ b/packages/contentstack-branches/test/unit/utils/merge-branch-handler.test.js @@ -0,0 +1,362 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +const mocha_1 = require("mocha"); +const chai_1 = require("chai"); +const sinon_1 = require("sinon"); +const cli_utilities_1 = require("@contentstack/cli-utilities"); +const data_1 = require("../mock/data"); +const utils_1 = require("../../../src/utils"); +const mergeHelper = tslib_1.__importStar(require("../../../src/utils/merge-helper")); +const util = tslib_1.__importStar(require("../../../src/utils")); +const diffUtility = tslib_1.__importStar(require("../../../src/utils/branch-diff-utility")); +const index_1 = require("../../../src/branch/index"); +(0, mocha_1.describe)('Merge helper', () => { + let successMessageStub; + let successMessageStub2; + (0, mocha_1.beforeEach)(function () { + successMessageStub = (0, sinon_1.stub)(cli_utilities_1.cliux, 'print'); + successMessageStub2 = (0, sinon_1.stub)(cli_utilities_1.cliux, 'inquire'); + }); + (0, mocha_1.afterEach)(function () { + successMessageStub.restore(); + successMessageStub2.restore(); + }); + (0, mocha_1.it)('Set up merge inputs', async function () { + const mergeInputStub = (0, sinon_1.stub)(mergeHelper, 'setupMergeInputs').resolves(data_1.mockData.mergeData.flags); + const result = await mergeHelper.setupMergeInputs(data_1.mockData.mergeData.flags); + (0, chai_1.expect)(mergeInputStub.calledOnce).to.be.true; + (0, chai_1.expect)(result).to.be.equal(data_1.mockData.mergeData.flags); + mergeInputStub.restore(); + }); + (0, mocha_1.it)('Merge branch changes without stack api key, should prompt for stack api key', async function () { + const askStackAPIKey = (0, sinon_1.stub)(utils_1.interactive, 'askStackAPIKey').resolves(data_1.mockData.mergeData.flags['stack-api-key']); + await mergeHelper.setupMergeInputs(data_1.mockData.mergeData.withoutAPIKeyFlag); + (0, chai_1.expect)(askStackAPIKey.calledOnce).to.be.true; + askStackAPIKey.restore(); + }); + (0, mocha_1.it)('Merge branch changes without compare branch, should prompt for compare branch', async function () { + const askCompareBranch = (0, sinon_1.stub)(utils_1.interactive, 'askCompareBranch').resolves(data_1.mockData.mergeData.flags['compare-branch']); + await mergeHelper.setupMergeInputs(data_1.mockData.mergeData.withoutCompareFlag); + (0, chai_1.expect)(askCompareBranch.calledOnce).to.be.true; + askCompareBranch.restore(); + }); + (0, mocha_1.it)('Merge branch changes without base branch, should prompt for base branch', async function () { + const askCompareBranch = (0, sinon_1.stub)(utils_1.interactive, 'askBaseBranch').resolves(data_1.mockData.mergeData.flags['base-branch']); + await mergeHelper.setupMergeInputs(data_1.mockData.mergeData.withoutBaseFlag); + (0, chai_1.expect)(askCompareBranch.calledOnce).to.be.true; + askCompareBranch.restore(); + }); + (0, mocha_1.it)('Merge branch changes with global config, should take the base branch from config', async function () { + const stubBranchConfig = (0, sinon_1.stub)(util, 'getbranchConfig').returns(data_1.mockData.flags.baseBranch); + const result = await mergeHelper.setupMergeInputs(data_1.mockData.mergeData.withoutBaseFlag); + (0, chai_1.expect)(result).to.deep.equal(data_1.mockData.mergeData.flags); + stubBranchConfig.restore(); + }); + (0, mocha_1.it)('Prepare Merge Request Payload', async function () { + const payloadStub = (0, sinon_1.stub)(mergeHelper, 'prepareMergeRequestPayload').returns(data_1.mockData.mergePayload); + const result = mergeHelper.prepareMergeRequestPayload(data_1.mockData.mergeSettings); + (0, chai_1.expect)(result).to.deep.equal(data_1.mockData.mergePayload); + (0, chai_1.expect)(payloadStub.calledOnce).to.be.true; + payloadStub.restore(); + }); + (0, mocha_1.describe)('Display branch status', () => { + let fetchBranchStub, filterByModuleStub, parseSummaryStub, printSummaryStub; + (0, mocha_1.beforeEach)(function () { + fetchBranchStub = (0, sinon_1.stub)(diffUtility, 'fetchBranchesDiff').resolves(data_1.mockData.allDiffData); + filterByModuleStub = (0, sinon_1.stub)(diffUtility, 'filterBranchDiffDataByModule').returns(data_1.mockData.moduleWiseData); + parseSummaryStub = (0, sinon_1.stub)(diffUtility, 'parseSummary').returns(data_1.mockData.branchSummary); + printSummaryStub = (0, sinon_1.stub)(diffUtility, 'printSummary').returns(); + }); + (0, mocha_1.afterEach)(function () { + fetchBranchStub.restore(); + filterByModuleStub.restore(); + parseSummaryStub.restore(); + printSummaryStub.restore(); + }); + (0, mocha_1.it)('Display branch status, format is compactText', async function () { + const parseCompactTextStub = (0, sinon_1.stub)(diffUtility, 'parseCompactText').returns(data_1.mockData.branchCompactData); + const printCompactTextViewStub = (0, sinon_1.stub)(diffUtility, 'printCompactTextView').returns(); + data_1.mockData.mergeData.flags.format = 'text'; + await mergeHelper.displayBranchStatus(data_1.mockData.mergeData.flags); + parseCompactTextStub.restore(); + printCompactTextViewStub.restore(); + }); + (0, mocha_1.it)('Display branch status, format is detailedText', async function () { + const parseVerboseStub = (0, sinon_1.stub)(diffUtility, 'parseVerbose').resolves(data_1.mockData.verboseContentTypeRes); + const printCompactTextViewStub = (0, sinon_1.stub)(diffUtility, 'printVerboseTextView').returns(); + data_1.mockData.mergeData.flags.format = 'verbose'; + await mergeHelper.displayBranchStatus(data_1.mockData.mergeData.flags); + parseVerboseStub.restore(); + printCompactTextViewStub.restore(); + }); + }); + (0, mocha_1.describe)('Display merge summary', () => { + (0, mocha_1.it)('format is compactText', async function () { + const mergeOptions = { + format: 'text', + compareData: data_1.mockData.mergeData.branchCompareData, + }; + mergeHelper.displayMergeSummary(mergeOptions); + }); + (0, mocha_1.it)('format is detailedText', async function () { + const mergeOptions = { + format: 'verbose', + compareData: data_1.mockData.verboseContentTypeRes, + }; + mergeHelper.displayMergeSummary(mergeOptions); + }); + }); + (0, mocha_1.describe)('Execute merge', () => { + let executeMergeRequestStub; + (0, mocha_1.beforeEach)(function () { + executeMergeRequestStub = (0, sinon_1.stub)(util, 'executeMergeRequest'); + }); + (0, mocha_1.afterEach)(function () { + executeMergeRequestStub.restore(); + }); + (0, mocha_1.it)('status is complete', async function () { + executeMergeRequestStub.resolves(data_1.mockData.mergeCompleteStatusRes); + const result = await mergeHelper.executeMerge(data_1.mockData.mergeData.flags['stack-api-key'], data_1.mockData.mergePayload, 'dev16'); + (0, chai_1.expect)(executeMergeRequestStub.calledOnce).to.be.true; + (0, chai_1.expect)(result).to.deep.equal(data_1.mockData.mergeCompleteStatusRes); + }); + (0, mocha_1.it)('status is in progress', async function () { + executeMergeRequestStub.resolves(data_1.mockData.mergeProgressStatusRes); + const fetchMergeStatusStub = (0, sinon_1.stub)(mergeHelper, 'fetchMergeStatus').resolves(data_1.mockData.mergeCompleteStatusRes); + const result = await mergeHelper.executeMerge(data_1.mockData.mergeData.flags['stack-api-key'], data_1.mockData.mergePayload, 'dev16'); + (0, chai_1.expect)(result).to.deep.equal(data_1.mockData.mergeCompleteStatusRes); + fetchMergeStatusStub.restore(); + }); + }); + (0, mocha_1.describe)('Fetch merge status', () => { + let getMergeQueueStatusStub; + (0, mocha_1.beforeEach)(function () { + getMergeQueueStatusStub = (0, sinon_1.stub)(util, 'getMergeQueueStatus'); + }); + (0, mocha_1.afterEach)(function () { + getMergeQueueStatusStub.restore(); + }); + (0, mocha_1.it)('status is complete', async function () { + const res = { queue: [{ merge_details: data_1.mockData.mergeCompleteStatusRes.merge_details }] }; + getMergeQueueStatusStub.resolves(res); + const result = await mergeHelper.fetchMergeStatus('', data_1.mockData.mergePayload); + (0, chai_1.expect)(getMergeQueueStatusStub.calledOnce).to.be.true; + (0, chai_1.expect)(result).to.deep.equal(data_1.mockData.mergeCompleteStatusRes); + }); + (0, mocha_1.it)('status is in progress', async function () { + const res = { queue: [{ merge_details: data_1.mockData.mergeProgressStatusRes.merge_details }] }; + getMergeQueueStatusStub.resolves(res); + const fetchMergeStatusStub = (0, sinon_1.stub)(mergeHelper, 'fetchMergeStatus').resolves(data_1.mockData.mergeCompleteStatusRes); + const result = await mergeHelper.fetchMergeStatus('', data_1.mockData.mergePayload); + (0, chai_1.expect)(result).to.deep.equal(data_1.mockData.mergeCompleteStatusRes); + fetchMergeStatusStub.restore(); + }); + (0, mocha_1.it)('status is failed', async function () { + const res = { queue: [{ merge_details: data_1.mockData.mergeFailedStatusRes.merge_details }] }; + getMergeQueueStatusStub.resolves(res); + const result = await mergeHelper.fetchMergeStatus('', data_1.mockData.mergePayload).catch(err => err); + (0, chai_1.expect)(result).to.be.equal(`merge uid: ${data_1.mockData.mergePayload.uid}`); + }); + (0, mocha_1.it)('No status', async function () { + const res = { queue: [{ merge_details: data_1.mockData.mergeNoStatusRes.merge_details }] }; + getMergeQueueStatusStub.resolves(res); + const result = await mergeHelper.fetchMergeStatus('', data_1.mockData.mergePayload).catch(err => err); + (0, chai_1.expect)(result).to.be.equal(`Invalid merge status found with merge ID ${data_1.mockData.mergePayload.uid}`); + }); + (0, mocha_1.it)('Empty queue', async function () { + const res = { queue: [] }; + getMergeQueueStatusStub.resolves(res); + const result = await mergeHelper.fetchMergeStatus('', data_1.mockData.mergePayload).catch(err => err); + (0, chai_1.expect)(result).to.be.equal(`No queue found with merge ID ${data_1.mockData.mergePayload.uid}`); + }); + }); +}); +(0, mocha_1.describe)('Merge Handler', () => { + let successMessageStub, successMessageStub2, loaderMessageStub, errorMessageStub; + (0, mocha_1.beforeEach)(function () { + successMessageStub = (0, sinon_1.stub)(cli_utilities_1.cliux, 'print'); + successMessageStub2 = (0, sinon_1.stub)(cli_utilities_1.cliux, 'success'); + loaderMessageStub = (0, sinon_1.stub)(cli_utilities_1.cliux, 'loader'); + errorMessageStub = (0, sinon_1.stub)(cli_utilities_1.cliux, 'error'); + }); + (0, mocha_1.afterEach)(function () { + successMessageStub.restore(); + successMessageStub2.restore(); + loaderMessageStub.restore(); + errorMessageStub.restore(); + }); + (0, mocha_1.describe)('Start', () => { + let collectMergeSettingsStub, displayMergeSummaryStub, selectMergeExecutionStub, mergeRequestStub, exportSummaryStub, executeMergeStub; + (0, mocha_1.beforeEach)(function () { + collectMergeSettingsStub = (0, sinon_1.stub)(index_1.MergeHandler.prototype, 'collectMergeSettings').resolves(); + displayMergeSummaryStub = (0, sinon_1.stub)(index_1.MergeHandler.prototype, 'displayMergeSummary').resolves(); + selectMergeExecutionStub = (0, sinon_1.stub)(utils_1.interactive, 'selectMergeExecution'); + mergeRequestStub = (0, sinon_1.stub)(mergeHelper, 'prepareMergeRequestPayload').resolves(data_1.mockData.mergePayload); + exportSummaryStub = (0, sinon_1.stub)(index_1.MergeHandler.prototype, 'exportSummary').resolves(); + executeMergeStub = (0, sinon_1.stub)(index_1.MergeHandler.prototype, 'executeMerge').resolves(); + }); + (0, mocha_1.afterEach)(function () { + collectMergeSettingsStub.restore(); + displayMergeSummaryStub.restore(); + selectMergeExecutionStub.restore(); + mergeRequestStub.restore(); + exportSummaryStub.restore(); + executeMergeStub.restore(); + }); + (0, mocha_1.it)('ExecuteOption is export', async function () { + selectMergeExecutionStub.resolves('export'); + new index_1.MergeHandler(data_1.mockData.mergeInputOptions).start(); + }); + (0, mocha_1.it)('ExecuteOption is execute', async function () { + selectMergeExecutionStub.resolves('execute'); + new index_1.MergeHandler(data_1.mockData.mergeInputOptions).start(); + }); + (0, mocha_1.it)('ExecuteOption is both', async function () { + selectMergeExecutionStub.resolves('both'); + new index_1.MergeHandler(data_1.mockData.mergeInputOptions).start(); + }); + (0, mocha_1.it)('Restart merge process', async function () { + selectMergeExecutionStub.resolves('export'); + new index_1.MergeHandler(data_1.mockData.mergeInputOptions).restartMergeProcess(); + }); + }); + (0, mocha_1.it)('Export summary', async () => { + const msg = 'Exported the summary successfully'; + const askExportMergeSummaryPathStub = (0, sinon_1.stub)(utils_1.interactive, 'askExportMergeSummaryPath').resolves('abcd'); + const writeFileStub = (0, sinon_1.stub)(util, 'writeFile').resolves('done'); + successMessageStub2.callsFake(function () { + return Promise.resolve(msg); + }); + await new index_1.MergeHandler(data_1.mockData.mergeInputOptions).exportSummary(data_1.mockData.mergePayload); + (0, chai_1.expect)(successMessageStub2.calledOnce).to.be.true; + askExportMergeSummaryPathStub.restore(); + writeFileStub.restore(); + }); + (0, mocha_1.describe)('Execute merge', () => { + let askMergeCommentStub, executeMergeStub; + (0, mocha_1.beforeEach)(function () { + askMergeCommentStub = (0, sinon_1.stub)(utils_1.interactive, 'askMergeComment').resolves('changes'); + executeMergeStub = (0, sinon_1.stub)(mergeHelper, 'executeMerge'); + }); + (0, mocha_1.afterEach)(function () { + askMergeCommentStub.restore(); + executeMergeStub.restore(); + }); + (0, mocha_1.it)('Merged the changes successfully', async () => { + executeMergeStub.resolves(data_1.mockData.mergeCompleteStatusRes); + await new index_1.MergeHandler(data_1.mockData.mergeInputOptions).executeMerge(data_1.mockData.mergePayload); + (0, chai_1.expect)(successMessageStub2.calledOnce).to.be.true; + }); + (0, mocha_1.it)('Failed to merge the changes', async () => { + executeMergeStub.rejects('Failed to merge the changes'); + await new index_1.MergeHandler(data_1.mockData.mergeInputOptions).executeMerge(data_1.mockData.mergePayload); + (0, chai_1.expect)(errorMessageStub.calledOnce).to.be.true; + }); + }); + (0, mocha_1.describe)('collect merge settings', () => { + let selectMergeStrategyStub, strategySubOptionStub, displayMergeSummaryStub, selectMergeExecutionStub, restartMergeProcessStub; + (0, mocha_1.beforeEach)(function () { + selectMergeStrategyStub = (0, sinon_1.stub)(utils_1.interactive, 'selectMergeStrategy'); + strategySubOptionStub = (0, sinon_1.stub)(utils_1.interactive, 'selectMergeStrategySubOptions'); + displayMergeSummaryStub = (0, sinon_1.stub)(index_1.MergeHandler.prototype, 'displayMergeSummary').resolves(); + selectMergeExecutionStub = (0, sinon_1.stub)(utils_1.interactive, 'selectMergeExecution'); + restartMergeProcessStub = (0, sinon_1.stub)(index_1.MergeHandler.prototype, 'restartMergeProcess').resolves(); + }); + (0, mocha_1.afterEach)(function () { + selectMergeStrategyStub.restore(); + strategySubOptionStub.restore(); + displayMergeSummaryStub.restore(); + selectMergeExecutionStub.restore(); + restartMergeProcessStub.restore(); + }); + (0, mocha_1.it)('custom_preferences strategy, new strategySubOption', async () => { + selectMergeStrategyStub.resolves('custom_preferences'); + const selectCustomPreferencesStub = (0, sinon_1.stub)(utils_1.interactive, 'selectCustomPreferences').resolves(); + selectMergeExecutionStub.resolves("export"); + await new index_1.MergeHandler(data_1.mockData.mergeInputOptionsWithoutStartegy).collectMergeSettings(); + (0, chai_1.expect)(selectMergeStrategyStub.calledOnce).to.be.true; + selectCustomPreferencesStub.restore(); + }); + (0, mocha_1.it)('merge_prefer_base strategy, new strategySubOption', async () => { + selectMergeStrategyStub.resolves('merge_prefer_base'); + strategySubOptionStub.resolves('new'); + selectMergeExecutionStub.resolves("export"); + await new index_1.MergeHandler(data_1.mockData.mergeInputOptionsWithoutStartegy).collectMergeSettings(); + (0, chai_1.expect)(selectMergeStrategyStub.calledOnce).to.be.true; + (0, chai_1.expect)(strategySubOptionStub.calledOnce).to.be.true; + }); + (0, mocha_1.it)('merge_prefer_base strategy, modified strategySubOption', async () => { + selectMergeStrategyStub.resolves('merge_prefer_base'); + strategySubOptionStub.resolves('modified'); + selectMergeExecutionStub.resolves("export"); + await new index_1.MergeHandler(data_1.mockData.mergeInputOptionsWithoutStartegy).collectMergeSettings(); + (0, chai_1.expect)(selectMergeStrategyStub.calledOnce).to.be.true; + (0, chai_1.expect)(strategySubOptionStub.calledOnce).to.be.true; + }); + (0, mocha_1.it)('merge_prefer_base strategy, both strategySubOption', async () => { + selectMergeStrategyStub.resolves('merge_prefer_base'); + strategySubOptionStub.resolves('both'); + selectMergeExecutionStub.resolves("export"); + await new index_1.MergeHandler(data_1.mockData.mergeInputOptionsWithoutStartegy).collectMergeSettings(); + (0, chai_1.expect)(selectMergeStrategyStub.calledOnce).to.be.true; + (0, chai_1.expect)(strategySubOptionStub.calledOnce).to.be.true; + }); + (0, mocha_1.it)('merge_prefer_compare strategy, new strategySubOption', async () => { + selectMergeStrategyStub.resolves('merge_prefer_compare'); + strategySubOptionStub.resolves('new'); + selectMergeExecutionStub.resolves("export"); + await new index_1.MergeHandler(data_1.mockData.mergeInputOptionsWithoutStartegy).collectMergeSettings(); + (0, chai_1.expect)(selectMergeStrategyStub.calledOnce).to.be.true; + (0, chai_1.expect)(strategySubOptionStub.calledOnce).to.be.true; + }); + (0, mocha_1.it)('merge_prefer_compare strategy, modified strategySubOption', async () => { + selectMergeStrategyStub.resolves('merge_prefer_compare'); + strategySubOptionStub.resolves('modified'); + selectMergeExecutionStub.resolves("export"); + await new index_1.MergeHandler(data_1.mockData.mergeInputOptionsWithoutStartegy).collectMergeSettings(); + (0, chai_1.expect)(selectMergeStrategyStub.calledOnce).to.be.true; + (0, chai_1.expect)(strategySubOptionStub.calledOnce).to.be.true; + }); + (0, mocha_1.it)('merge_prefer_compare strategy, both strategySubOption', async () => { + selectMergeStrategyStub.resolves('merge_prefer_compare'); + strategySubOptionStub.resolves('both'); + selectMergeExecutionStub.resolves("export"); + await new index_1.MergeHandler(data_1.mockData.mergeInputOptionsWithoutStartegy).collectMergeSettings(); + (0, chai_1.expect)(selectMergeStrategyStub.calledOnce).to.be.true; + (0, chai_1.expect)(strategySubOptionStub.calledOnce).to.be.true; + }); + (0, mocha_1.it)('overwrite_with_compare strategy', async () => { + selectMergeStrategyStub.resolves('overwrite_with_compare'); + selectMergeExecutionStub.resolves("export"); + await new index_1.MergeHandler(data_1.mockData.mergeInputOptionsWithoutStartegy).collectMergeSettings(); + (0, chai_1.expect)(selectMergeStrategyStub.calledOnce).to.be.true; + }); + (0, mocha_1.it)('Merge execution, previous', async () => { + selectMergeStrategyStub.resolves('overwrite_with_compare'); + selectMergeExecutionStub.resolves("previous"); + await new index_1.MergeHandler(data_1.mockData.mergeInputOptionsWithoutStartegy).collectMergeSettings(); + (0, chai_1.expect)(selectMergeStrategyStub.calledOnce).to.be.true; + }); + (0, mocha_1.it)('Merge execution, restart', async () => { + selectMergeStrategyStub.resolves('overwrite_with_compare'); + selectMergeExecutionStub.resolves("restart"); + await new index_1.MergeHandler(data_1.mockData.mergeInputOptionsWithoutStartegy).collectMergeSettings(); + (0, chai_1.expect)(selectMergeStrategyStub.calledOnce).to.be.true; + }); + (0, mocha_1.it)('merge_prefer_base strategy, previous strategySubOption', async () => { + selectMergeStrategyStub.resolves('merge_prefer_base'); + strategySubOptionStub.resolves('previous'); + const stub1 = (0, sinon_1.stub)(index_1.MergeHandler.prototype, 'collectMergeSettings').resolves(); + await new index_1.MergeHandler(data_1.mockData.mergeInputOptionsWithoutStartegy).collectMergeSettings(); + stub1.restore(); + }); + (0, mocha_1.it)('merge_prefer_base strategy, previous strategySubOption', async () => { + selectMergeStrategyStub.resolves('merge_prefer_base'); + strategySubOptionStub.resolves('restart'); + await new index_1.MergeHandler(data_1.mockData.mergeInputOptionsWithoutStartegy).collectMergeSettings(); + (0, chai_1.expect)(selectMergeStrategyStub.calledOnce).to.be.true; + (0, chai_1.expect)(strategySubOptionStub.calledOnce).to.be.true; + }); + }); +}); diff --git a/packages/contentstack-clone/test/dummyConfig/config.json b/packages/contentstack-clone/test/dummyConfig/config.json new file mode 100644 index 0000000000..b3a42c91f9 --- /dev/null +++ b/packages/contentstack-clone/test/dummyConfig/config.json @@ -0,0 +1,3 @@ +{ + "auth_token": "dummyToken" +} \ No newline at end of file diff --git a/packages/contentstack-clone/test/dummyConfig/index.js b/packages/contentstack-clone/test/dummyConfig/index.js index 588dfd6ba5..7f72842c0c 100644 --- a/packages/contentstack-clone/test/dummyConfig/index.js +++ b/packages/contentstack-clone/test/dummyConfig/index.js @@ -1,8 +1,10 @@ +import * as config from './config.json'; + module.exports = { versioning: false, host: 'https://app.contentstack.com', source_stack: 'dummyKey', - auth_token: 'dummyToken', + auth_token: config.auth_token, modules: { types: [ 'stack', diff --git a/packages/contentstack-export/test/config.json b/packages/contentstack-export/test/config.json index d8f338c54e..ade32e7181 100644 --- a/packages/contentstack-export/test/config.json +++ b/packages/contentstack-export/test/config.json @@ -3,5 +3,6 @@ "UNIT_EXECUTION_ORDER": [], "INTEGRATION_EXECUTION_ORDER": [], "ENABLE_PREREQUISITES": true, - "REGIONS": ["NA", "EU", "AZURE-NA", "AZURE-EU"] + "REGIONS": ["NA", "EU", "AZURE-NA", "AZURE-EU"], + "apiKey": "jdgfhcbjx" } \ No newline at end of file diff --git a/packages/contentstack-export/test/integration/config.json b/packages/contentstack-export/test/integration/config.json index 81218da0fa..397e05a2c7 100644 --- a/packages/contentstack-export/test/integration/config.json +++ b/packages/contentstack-export/test/integration/config.json @@ -3,5 +3,6 @@ "REGION_NAME": "NA", "DEFAULT_TIMEOUT": 600000, "EXPORT_PATH": "./contents", - "ALIAS_NAME": "marketplace_api" + "ALIAS_NAME": "marketplace_api", + "encryptionKey": "***REMOVED***" } \ No newline at end of file diff --git a/packages/contentstack-export/test/integration/init.test.js b/packages/contentstack-export/test/integration/init.test.js index 105e507ce8..aeca54047d 100644 --- a/packages/contentstack-export/test/integration/init.test.js +++ b/packages/contentstack-export/test/integration/init.test.js @@ -6,7 +6,7 @@ const { getEnvData, getStackDetailsByRegion } = require('./utils/helper') const LoginCommand = require('@contentstack/cli-auth/lib/commands/auth/login').default const AddTokenCommand = require('@contentstack/cli-auth/lib/commands/auth/tokens/add').default const RegionSetCommand = require('@contentstack/cli-config/lib/commands/config/set/region').default -const { DEFAULT_TIMEOUT, PRINT_LOGS, ALIAS_NAME } = require("./config.json") +const { DEFAULT_TIMEOUT, PRINT_LOGS, ALIAS_NAME, encryptionKey } = require("./config.json") const { ENCRYPTION_KEY, USERNAME, PASSWORD } = getEnvData() const { APP_ENV, DELIMITER, KEY_VAL_DELIMITER } = process.env @@ -14,7 +14,7 @@ const { APP_ENV, DELIMITER, KEY_VAL_DELIMITER } = process.env const crypto = new NodeCrypto({ typeIdentifier: '◈', algorithm: 'aes-192-cbc', - encryptionKey: ENCRYPTION_KEY || '***REMOVED***' + encryptionKey: ENCRYPTION_KEY || encryptionKey }); module.exports = (region) => { diff --git a/packages/contentstack-export/test/tsconfig.json b/packages/contentstack-export/test/tsconfig.json index a0f0f6893f..f6994c93ce 100644 --- a/packages/contentstack-export/test/tsconfig.json +++ b/packages/contentstack-export/test/tsconfig.json @@ -5,6 +5,6 @@ "resolveJsonModule": true }, "references": [ - {"path": ".."} + {"path": "../"} ] } diff --git a/packages/contentstack-export/test/unit/mock/assets.ts b/packages/contentstack-export/test/unit/mock/assets.ts index a6a62ce69e..d9daee1365 100644 --- a/packages/contentstack-export/test/unit/mock/assets.ts +++ b/packages/contentstack-export/test/unit/mock/assets.ts @@ -1,10 +1,12 @@ +import * as config from '../../config.json'; + const mockData = { findOneData: {}, countData: { assets: 5 }, findData: { items: [ { - stackHeaders: { api_key: 'jdgfhcbjx' }, + stackHeaders: { api_key: config.apiKey }, urlPath: '/assets/scd', uid: 'hbjdjcy83kjxc', content_type: 'image/jpeg', @@ -15,7 +17,7 @@ const mockData = { _version: 1, }, { - stackHeaders: { api_key: 'jdgfhcbjx' }, + stackHeaders: { api_key: config.apiKey }, urlPath: '/assets/scd', uid: 'hbjdjcy83kjxc', content_type: 'image/jpeg', @@ -26,7 +28,7 @@ const mockData = { _version: 2, }, { - stackHeaders: { api_key: 'jdgfhcbjx' }, + stackHeaders: { api_key: config.apiKey }, urlPath: '/assets/scd', uid: 'hbjdjcy83kjxc', content_type: 'image/jpeg', diff --git a/packages/contentstack-import/test/integration/init.test.js b/packages/contentstack-import/test/integration/init.test.js index 67e8998b17..b1e9ec25ca 100644 --- a/packages/contentstack-import/test/integration/init.test.js +++ b/packages/contentstack-import/test/integration/init.test.js @@ -6,7 +6,7 @@ const { getEnvData, getStackDetailsByRegion } = require('./utils/helper'); const LoginCommand = require('@contentstack/cli-auth/lib/commands/auth/login').default; const AddTokenCommand = require('@contentstack/cli-auth/lib/commands/auth/tokens/add').default; const RegionSetCommand = require('@contentstack/cli-config/lib/commands/config/set/region').default; -const { DEFAULT_TIMEOUT, PRINT_LOGS, } = require('./config.json'); +const { DEFAULT_TIMEOUT, PRINT_LOGS, encryptionKey } = require('./config.json'); const { ENCRYPTION_KEY } = getEnvData(); const { DELIMITER, KEY_VAL_DELIMITER } = process.env; @@ -14,7 +14,7 @@ const { DELIMITER, KEY_VAL_DELIMITER } = process.env; const crypto = new NodeCrypto({ typeIdentifier: '◈', algorithm: 'aes-192-cbc', - encryptionKey: ENCRYPTION_KEY || '***REMOVED***' + encryptionKey: ENCRYPTION_KEY || encryptionKey }); module.exports = (region) => { diff --git a/packages/contentstack-seed/tests/config.json b/packages/contentstack-seed/tests/config.json new file mode 100644 index 0000000000..496124c6af --- /dev/null +++ b/packages/contentstack-seed/tests/config.json @@ -0,0 +1,7 @@ +{ + "API_KEY": "api_12345", + "api_key": "1234567890", + "api_key_1": "api_key_1", + "api_key_2": "api_key_2", + "api_key_3": "api_key_3" +} \ No newline at end of file diff --git a/packages/contentstack-seed/tests/contentstack.test.ts b/packages/contentstack-seed/tests/contentstack.test.ts index fc62b39919..b51bad1171 100644 --- a/packages/contentstack-seed/tests/contentstack.test.ts +++ b/packages/contentstack-seed/tests/contentstack.test.ts @@ -5,10 +5,11 @@ import axios from 'axios'; /* eslint-enable @typescript-eslint/no-unused-vars */ import ContentstackClient, { CreateStackOptions } from '../src/seed/contentstack/client'; +import * as config from './config.json'; const CMA_HOST = 'cs.api.com'; const BASE_URL = `https://${CMA_HOST}/v3/`; -const API_KEY = 'api_12345'; +const API_KEY = config.API_KEY; const ORG_UID = 'org_12345'; const STACK_UID = 'stack_12345'; const ORG_NAME = 'org_name_12345'; diff --git a/packages/contentstack-seed/tests/interactive.test.ts b/packages/contentstack-seed/tests/interactive.test.ts index 7dfa075a71..5c74641e50 100644 --- a/packages/contentstack-seed/tests/interactive.test.ts +++ b/packages/contentstack-seed/tests/interactive.test.ts @@ -3,6 +3,7 @@ jest.mock('inquirer'); const inquirer = require('inquirer'); import { Organization, Stack } from '../src/seed/contentstack/client'; import * as interactive from '../src/seed/interactive'; +import * as config from './config.json'; const account = 'account'; const repo = 'repo'; @@ -109,9 +110,9 @@ describe('interactive', () => { const expected_uid = 'uid_2'; const stacks: Stack[] = [ - { uid: 'uid_1', name: 'Stack 1', api_key: 'api_key_1', master_locale: 'en-us', org_uid: 'org_uid_1' }, - { uid: expected_uid, name: 'Stack 2', api_key: 'api_key_2', master_locale: 'en-us', org_uid: 'org_uid_2' }, - { uid: 'uid_3', name: 'Stack 3', api_key: 'api_key_3', master_locale: 'en-us', org_uid: 'org_uid_3' }, + { uid: 'uid_1', name: 'Stack 1', api_key: config.api_key_1, master_locale: 'en-us', org_uid: 'org_uid_1' }, + { uid: expected_uid, name: 'Stack 2', api_key: config.api_key_2, master_locale: 'en-us', org_uid: 'org_uid_2' }, + { uid: 'uid_3', name: 'Stack 3', api_key: config.api_key_3, master_locale: 'en-us', org_uid: 'org_uid_3' }, ]; // select existing stack diff --git a/packages/contentstack-seed/tests/seeder.test.ts b/packages/contentstack-seed/tests/seeder.test.ts index c5ace844d0..10d1e2d7d4 100644 --- a/packages/contentstack-seed/tests/seeder.test.ts +++ b/packages/contentstack-seed/tests/seeder.test.ts @@ -12,10 +12,11 @@ import { inquireOrganization, inquireProceed, inquireStack, inquireRepo } from ' import * as tmp from 'tmp'; import { cliux } from '@contentstack/cli-utilities'; +import * as config from './config.json'; const org_name = 'Test Organization'; const org_uid = 'xxxxxxxxxx'; -const api_key = '1234567890'; +const api_key = config.api_key; const tmpDirName = '/var/tmp/xxxxxx/'; const repo = 'stack-gatsby-blog'; diff --git a/packages/contentstack-utilities/test/unit/auth-handler.test.ts b/packages/contentstack-utilities/test/unit/auth-handler.test.ts index 838e28a646..5d537afa04 100644 --- a/packages/contentstack-utilities/test/unit/auth-handler.test.ts +++ b/packages/contentstack-utilities/test/unit/auth-handler.test.ts @@ -7,6 +7,7 @@ import configHandler from '../../src/config-handler'; import { HttpClient } from '../../src/http-client'; const http = require('http'); const crypto = require('crypto'); +import * as config from './config.json'; describe('Auth Handler', () => { describe('setOAuthBaseURL', () => { @@ -299,7 +300,7 @@ describe('Auth Handler', () => { const configOauthRefreshToken = 'valid_refresh_token'; // Set a valid refresh token here const configAuthorisationType = authHandler.authorisationTypeOAUTHValue; const expectedData = { - access_token: 'new_access_token', + access_token: config.access_token, refresh_token: 'new_refresh_token', }; @@ -338,7 +339,7 @@ describe('Auth Handler', () => { it('should reject with error when access token is invalid/empty', async () => { const data = { - access_token: 'invalid_access_token', + access_token: config.invalid_access_token, }; const expectedError = new Error('The provided access token is invalid or expired or revoked'); diff --git a/packages/contentstack-utilities/test/unit/config.json b/packages/contentstack-utilities/test/unit/config.json new file mode 100644 index 0000000000..c639c0a0a5 --- /dev/null +++ b/packages/contentstack-utilities/test/unit/config.json @@ -0,0 +1,4 @@ +{ + "access_token": "new_access_token", + "invalid_access_token": "invalid_access_token" +} \ No newline at end of file From f45b6d9851e8ed9f8c61c01bccf29f87d1cede59 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Mon, 1 Jul 2024 11:44:32 +0530 Subject: [PATCH 2/5] version bump --- package-lock.json | 176 ++++++++++---------- packages/contentstack-audit/README.md | 14 +- packages/contentstack-auth/README.md | 2 +- packages/contentstack-auth/package.json | 2 +- packages/contentstack-branches/README.md | 2 +- packages/contentstack-branches/package.json | 4 +- packages/contentstack-clone/package.json | 2 +- packages/contentstack-export/README.md | 2 +- packages/contentstack-export/package.json | 4 +- packages/contentstack-import/README.md | 4 +- packages/contentstack/README.md | 4 +- packages/contentstack/package.json | 6 +- pnpm-lock.yaml | 12 +- 13 files changed, 117 insertions(+), 117 deletions(-) diff --git a/package-lock.json b/package-lock.json index e3fff9bea4..3311e2e5ff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,9 +32,9 @@ } }, "node_modules/@apollo/client": { - "version": "3.10.6", - "resolved": "https://registry.npmjs.org/@apollo/client/-/client-3.10.6.tgz", - "integrity": "sha512-3lLFGJtzC1/mEnK11BRf+Bf8536kBQUSB1G9yMtcRsxmY+tCKdTPzsP3fMUKy10BPIE0sDUY1pux3iMPIn2vow==", + "version": "3.10.8", + "resolved": "https://registry.npmjs.org/@apollo/client/-/client-3.10.8.tgz", + "integrity": "sha512-UaaFEitRrPRWV836wY2L7bd3HRCfbMie1jlYMcmazFAK23MVhz/Uq7VG1nwbotPb5xzFsw5RF4Wnp2G3dWPM3g==", "dependencies": { "@graphql-typed-document-node/core": "^3.1.1", "@wry/caches": "^1.0.0", @@ -840,17 +840,17 @@ } }, "node_modules/@contentstack/marketplace-sdk": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@contentstack/marketplace-sdk/-/marketplace-sdk-1.1.1.tgz", - "integrity": "sha512-RzgPekroina2dHspOS8NWJag4xsBJA0bOGClvLwHEyh5XfvBI1HjDQMGoQEM1xAZ7v4c0HbF9RHlc/ASYwIl5Q==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@contentstack/marketplace-sdk/-/marketplace-sdk-1.2.0.tgz", + "integrity": "sha512-NnNVDT3HomEWZcJ0Mz7N6M9DtUIlNY3fSI7EnyT9Yxv6e5S3E9jXwMgdCQ2/apySfYZKQ31byIy7Er1HMhL6Ig==", "dependencies": { "axios": "^1.6.5" } }, "node_modules/@contentstack/utils": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/@contentstack/utils/-/utils-1.3.7.tgz", - "integrity": "sha512-MB0iGzYO/pKTPoHYoHNTOA+FcVGYO0a16aSwhoy5YmEg3br79T/RyyAEU2bp6fgvUNBxrIcas/WKZYwFZml4sQ==" + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/@contentstack/utils/-/utils-1.3.8.tgz", + "integrity": "sha512-BKZcZs2/odh9nmugLmiNVBEbz34gjfgibZOsRlYV9ux7t+GkfjbELDjWJpKenL6G5Mb270VXVuDbNqkDLK96Zw==" }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", @@ -898,9 +898,9 @@ } }, "node_modules/@eslint-community/regexpp": { - "version": "4.10.1", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.1.tgz", - "integrity": "sha512-Zm2NGpWELsQAD1xsJzGQpYfvICSsFkEpU0jxBjfdC6uNEWXcHnfs9hScFWtXVDVl+rBQJGrl4g1vcKIejpH9dA==", + "version": "4.11.0", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.11.0.tgz", + "integrity": "sha512-G/M/tIiMrTAxEWRfLfQJMmGNX28IxBg4PBz8XqQhqUHLFI6TL2htpIB1iQCj144V5ee/JaKyT9/WZ0MGZWfA7A==", "dev": true, "engines": { "node": "^12.0.0 || ^14.0.0 || >=16.0.0" @@ -2235,9 +2235,9 @@ } }, "node_modules/@oclif/plugin-plugins": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/@oclif/plugin-plugins/-/plugin-plugins-5.3.2.tgz", - "integrity": "sha512-jdaRfNBQmFgCP0xXWJqSntxnO3TJtIa0IRSLO1ZQsjzuclldH00/XG0ZdRUS24KNU78XBVkuQ4h3sTSlFHqBeQ==", + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/@oclif/plugin-plugins/-/plugin-plugins-5.3.3.tgz", + "integrity": "sha512-W071oAdmdMpHwI1q9kGcuKijP6zwuZXi2rQvzEGivjwg/Uj51B1RNKvOYy/O7pd0lCZu+1s6LAZmb8wCwii6yQ==", "dependencies": { "@oclif/core": "^4", "ansis": "^3.2.0", @@ -2256,9 +2256,9 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/@oclif/core": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/@oclif/core/-/core-4.0.6.tgz", - "integrity": "sha512-z/4YUVQsf2pHsXRze5etbmvAYDhoUhIzpM6oJGEdsdWfvQJ6YQBogH7TdX/ItuGda6+vpfXg/4U1CtPexSF+bA==", + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/@oclif/core/-/core-4.0.7.tgz", + "integrity": "sha512-sU4Dx+RXCWAkrMw8tQFYAL6VfcHYKLPxVC9iKfgTXr4aDhcCssDwrbgpx0Di1dnNxvQlDGUhuCEInZuIY/nNfw==", "dependencies": { "ansi-escapes": "^4.3.2", "ansis": "^3.1.1", @@ -3046,9 +3046,9 @@ } }, "node_modules/@slack/logger/node_modules/@types/node": { - "version": "20.14.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.8.tgz", - "integrity": "sha512-DO+2/jZinXfROG7j7WKFn/3C6nFwxy2lLpgLjEXJz+0XKphZlTLJ14mo8Vfg8X5BWN6XjyESXq+LcYdT7tR3bA==", + "version": "20.14.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.9.tgz", + "integrity": "sha512-06OCtnTXtWOZBJlRApleWndH4JsRVs1pDCc8dLSQp+7PpUpX3ePdHyeNSFTeSe7FtKyQkrlPvHwJOW3SLd8Oyg==", "dependencies": { "undici-types": "~5.26.4" } @@ -3537,9 +3537,9 @@ "dev": true }, "node_modules/@types/lodash": { - "version": "4.17.5", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha512-MBIOHVZqVqgfro1euRDWX7OO0fBVUUMrN6Pwm8LQsz8cWhEpihlvR70ENj3f40j58TNxZaWv2ndSkInykNBBJw==" + "version": "4.17.6", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.6.tgz", + "integrity": "sha512-OpXEVoCKSS3lQqjx9GGGOapBeuW5eUboYHRlHP9urXPX25IKZ6AnP5ZRxtVf63iieUbsHxLn8NQ5Nlftc6yzAA==" }, "node_modules/@types/markdown-it": { "version": "14.1.1", @@ -4610,9 +4610,9 @@ } }, "node_modules/aws-sdk": { - "version": "2.1646.0", - "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1646.0.tgz", - "integrity": "sha512-PAvDiR8ow3zjO0T5HMda04kXIzQ5e1zeWxWGSUodRwu9W569gZPBnqzcPX3PJFNAKBZnZBdbNgsci1g2nXCcBg==", + "version": "2.1651.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1651.0.tgz", + "integrity": "sha512-MZjQvvOPkKcx1N428ejUjqSfhm4TAIcgPIgpniiDMw1LjB1yA8JBZvrWer6J6MACAXQ99v0uKE4BSvtYn+AT3g==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -5357,9 +5357,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001636", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001636.tgz", - "integrity": "sha512-bMg2vmr8XBsbL6Lr0UHXy/21m84FTxDLWn2FSqMd5PrlbMxwJlQnC2YWYxVgp66PZE+BBNF2jYQUBKCo1FDeZg==", + "version": "1.0.30001639", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001639.tgz", + "integrity": "sha512-eFHflNTBIlFwP2AIKaYuBQN/apnUoKNhBdza8ZnW/h2di4LCZ4xFqYlxUxo+LQ76KFI1PGcC1QDxMbxTZpSCAg==", "dev": true, "funding": [ { @@ -6910,9 +6910,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.810", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.810.tgz", - "integrity": "sha512-Kaxhu4T7SJGpRQx99tq216gCq2nMxJo+uuT6uzz9l8TVN2stL7M06MIIXAtr9jsrLs2Glflgf2vMQRepxawOdQ==", + "version": "1.4.815", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.815.tgz", + "integrity": "sha512-OvpTT2ItpOXJL7IGcYakRjHCt8L5GrrN/wHCQsRB4PQa1X9fe+X9oen245mIId7s14xvArCGSTIq644yPUKKLg==", "dev": true }, "node_modules/elegant-spinner": { @@ -8065,13 +8065,13 @@ } }, "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/scope-manager": { - "version": "7.13.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.13.1.tgz", - "integrity": "sha512-adbXNVEs6GmbzaCpymHQ0MB6E4TqoiVbC0iqG3uijR8ZYfpAXMGttouQzF4Oat3P2GxDVIrg7bMI/P65LiQZdg==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.14.1.tgz", + "integrity": "sha512-gPrFSsoYcsffYXTOZ+hT7fyJr95rdVe4kGVX1ps/dJ+DfmlnjFN/GcMxXcVkeHDKqsq6uAcVaQaIi3cFffmAbA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.13.1", - "@typescript-eslint/visitor-keys": "7.13.1" + "@typescript-eslint/types": "7.14.1", + "@typescript-eslint/visitor-keys": "7.14.1" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -8082,9 +8082,9 @@ } }, "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/types": { - "version": "7.13.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.13.1.tgz", - "integrity": "sha512-7K7HMcSQIAND6RBL4kDl24sG/xKM13cA85dc7JnmQXw2cBDngg7c19B++JzvJHRG3zG36n9j1i451GBzRuHchw==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.14.1.tgz", + "integrity": "sha512-mL7zNEOQybo5R3AavY+Am7KLv8BorIv7HCYS5rKoNZKQD9tsfGUpO4KdAn3sSUvTiS4PQkr2+K0KJbxj8H9NDg==", "dev": true, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -8095,13 +8095,13 @@ } }, "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/typescript-estree": { - "version": "7.13.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.13.1.tgz", - "integrity": "sha512-uxNr51CMV7npU1BxZzYjoVz9iyjckBduFBP0S5sLlh1tXYzHzgZ3BR9SVsNed+LmwKrmnqN3Kdl5t7eZ5TS1Yw==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.14.1.tgz", + "integrity": "sha512-k5d0VuxViE2ulIO6FbxxSZaxqDVUyMbXcidC8rHvii0I56XZPv8cq+EhMns+d/EVIL41sMXqRbK3D10Oza1bbA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.13.1", - "@typescript-eslint/visitor-keys": "7.13.1", + "@typescript-eslint/types": "7.14.1", + "@typescript-eslint/visitor-keys": "7.14.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -8123,15 +8123,15 @@ } }, "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/utils": { - "version": "7.13.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.13.1.tgz", - "integrity": "sha512-h5MzFBD5a/Gh/fvNdp9pTfqJAbuQC4sCN2WzuXme71lqFJsZtLbjxfSk4r3p02WIArOF9N94pdsLiGutpDbrXQ==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.14.1.tgz", + "integrity": "sha512-CMmVVELns3nak3cpJhZosDkm63n+DwBlDX8g0k4QUa9BMnF+lH2lr3d130M1Zt1xxmB3LLk3NV7KQCq86ZBBhQ==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/scope-manager": "7.13.1", - "@typescript-eslint/types": "7.13.1", - "@typescript-eslint/typescript-estree": "7.13.1" + "@typescript-eslint/scope-manager": "7.14.1", + "@typescript-eslint/types": "7.14.1", + "@typescript-eslint/typescript-estree": "7.14.1" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -8145,12 +8145,12 @@ } }, "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/visitor-keys": { - "version": "7.13.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.13.1.tgz", - "integrity": "sha512-k/Bfne7lrP7hcb7m9zSsgcBmo+8eicqqfNAJ7uUY+jkTFpKeH2FSkWpFRtimBxgkyvqfu9jTPRbYOvud6isdXA==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.14.1.tgz", + "integrity": "sha512-Crb+F75U1JAEtBeQGxSKwI60hZmmzaqA3z9sYsVm8X7W5cwLEm5bRe0/uXS6+MR/y8CVpKSR/ontIAIEPFcEkA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.13.1", + "@typescript-eslint/types": "7.14.1", "eslint-visitor-keys": "^3.4.3" }, "engines": { @@ -9818,9 +9818,9 @@ } }, "node_modules/hosted-git-info/node_modules/lru-cache": { - "version": "10.2.2", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.2.tgz", - "integrity": "sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==", + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.3.0.tgz", + "integrity": "sha512-CQl19J/g+Hbjbv4Y3mFNNXFEL/5t/KCg8POCuUqd4rMKjGG+j1ybER83hxV58zL+dFI1PTkt3GNFSHRt+d8qEQ==", "engines": { "node": "14 || >=16.14" } @@ -11594,9 +11594,9 @@ } }, "node_modules/istanbul-lib-instrument": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.2.tgz", - "integrity": "sha512-1WUsZ9R1lA0HtBSohTkm39WTPlNKSJ5iFk7UwqXkBLoHQT+hfqPsfsTDVuZdKGaBwn7din9bS7SsnoAr943hvw==", + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.3.tgz", + "integrity": "sha512-Vtgk7L/R2JHyyGW07spoFlB8/lpjiOLTjMdms6AFMraYt3BaJauod/NGrfnVG/y4Ix1JEuMRPDPEj2ua+zz1/Q==", "dev": true, "dependencies": { "@babel/core": "^7.23.9", @@ -14184,9 +14184,9 @@ } }, "node_modules/minimatch": { - "version": "9.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", - "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", "dependencies": { "brace-expansion": "^2.0.1" }, @@ -19090,9 +19090,9 @@ } }, "node_modules/path-scurry/node_modules/lru-cache": { - "version": "10.2.2", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.2.tgz", - "integrity": "sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==", + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.3.0.tgz", + "integrity": "sha512-CQl19J/g+Hbjbv4Y3mFNNXFEL/5t/KCg8POCuUqd4rMKjGG+j1ybER83hxV58zL+dFI1PTkt3GNFSHRt+d8qEQ==", "engines": { "node": "14 || >=16.14" } @@ -24900,12 +24900,12 @@ "license": "MIT", "dependencies": { "@contentstack/cli-audit": "~1.6.3", - "@contentstack/cli-auth": "~1.3.18", + "@contentstack/cli-auth": "~1.3.19", "@contentstack/cli-cm-bootstrap": "~1.9.3", - "@contentstack/cli-cm-branches": "~1.1.0", + "@contentstack/cli-cm-branches": "~1.1.1", "@contentstack/cli-cm-bulk-publish": "~1.4.7", "@contentstack/cli-cm-clone": "~1.10.6", - "@contentstack/cli-cm-export": "~1.11.4", + "@contentstack/cli-cm-export": "~1.11.5", "@contentstack/cli-cm-export-to-csv": "~1.7.1", "@contentstack/cli-cm-import": "~1.16.0", "@contentstack/cli-cm-migrate-rte": "~1.4.17", @@ -25023,9 +25023,9 @@ "dev": true }, "packages/contentstack-audit/node_modules/@types/node": { - "version": "20.14.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.8.tgz", - "integrity": "sha512-DO+2/jZinXfROG7j7WKFn/3C6nFwxy2lLpgLjEXJz+0XKphZlTLJ14mo8Vfg8X5BWN6XjyESXq+LcYdT7tR3bA==", + "version": "20.14.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.9.tgz", + "integrity": "sha512-06OCtnTXtWOZBJlRApleWndH4JsRVs1pDCc8dLSQp+7PpUpX3ePdHyeNSFTeSe7FtKyQkrlPvHwJOW3SLd8Oyg==", "dev": true, "dependencies": { "undici-types": "~5.26.4" @@ -25126,14 +25126,14 @@ } }, "packages/contentstack-audit/node_modules/mocha": { - "version": "10.4.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.4.0.tgz", - "integrity": "sha512-eqhGB8JKapEYcC4ytX/xrzKforgEc3j1pGlAXVy3eRwrtAy5/nIfT1SvgGzfN0XZZxeLq0aQWkOUAmqIJiv+bA==", + "version": "10.5.2", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.5.2.tgz", + "integrity": "sha512-9btlN3JKCefPf+vKd/kcKz2SXxi12z6JswkGfaAF0saQvnsqLJk504ZmbxhSoENge08E9dsymozKgFMTl5PQsA==", "dev": true, "dependencies": { "ansi-colors": "4.1.1", "browser-stdout": "1.3.1", - "chokidar": "3.5.3", + "chokidar": "^3.5.3", "debug": "4.3.4", "diff": "5.0.0", "escape-string-regexp": "4.0.0", @@ -25238,7 +25238,7 @@ }, "packages/contentstack-auth": { "name": "@contentstack/cli-auth", - "version": "1.3.18", + "version": "1.3.19", "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.18", @@ -25358,7 +25358,7 @@ }, "packages/contentstack-branches": { "name": "@contentstack/cli-cm-branches", - "version": "1.1.0", + "version": "1.1.1", "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.18", @@ -25381,7 +25381,7 @@ "winston": "^3.7.2" }, "devDependencies": { - "@contentstack/cli-auth": "~1.3.18", + "@contentstack/cli-auth": "~1.3.19", "@contentstack/cli-config": "~1.6.4", "@contentstack/cli-dev-dependencies": "~1.2.4", "@oclif/plugin-help": "^5.1.19", @@ -25448,7 +25448,7 @@ "license": "MIT", "dependencies": { "@colors/colors": "^1.5.0", - "@contentstack/cli-cm-export": "~1.11.4", + "@contentstack/cli-cm-export": "~1.11.5", "@contentstack/cli-cm-import": "~1.16.0", "@contentstack/cli-command": "~1.2.18", "@contentstack/cli-utilities": "~1.6.3", @@ -26014,7 +26014,7 @@ }, "packages/contentstack-export": { "name": "@contentstack/cli-cm-export", - "version": "1.11.4", + "version": "1.11.5", "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.18", @@ -26036,7 +26036,7 @@ "winston": "^3.7.2" }, "devDependencies": { - "@contentstack/cli-auth": "~1.3.18", + "@contentstack/cli-auth": "~1.3.19", "@contentstack/cli-config": "~1.6.4", "@contentstack/cli-dev-dependencies": "~1.2.4", "@oclif/plugin-help": "^5.1.19", @@ -26446,14 +26446,14 @@ } }, "packages/contentstack-export-to-csv/node_modules/mocha": { - "version": "10.4.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.4.0.tgz", - "integrity": "sha512-eqhGB8JKapEYcC4ytX/xrzKforgEc3j1pGlAXVy3eRwrtAy5/nIfT1SvgGzfN0XZZxeLq0aQWkOUAmqIJiv+bA==", + "version": "10.5.2", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.5.2.tgz", + "integrity": "sha512-9btlN3JKCefPf+vKd/kcKz2SXxi12z6JswkGfaAF0saQvnsqLJk504ZmbxhSoENge08E9dsymozKgFMTl5PQsA==", "dev": true, "dependencies": { "ansi-colors": "4.1.1", "browser-stdout": "1.3.1", - "chokidar": "3.5.3", + "chokidar": "^3.5.3", "debug": "4.3.4", "diff": "5.0.0", "escape-string-regexp": "4.0.0", diff --git a/packages/contentstack-audit/README.md b/packages/contentstack-audit/README.md index f677026a45..4bf303665c 100644 --- a/packages/contentstack-audit/README.md +++ b/packages/contentstack-audit/README.md @@ -267,7 +267,7 @@ EXAMPLES $ csdx plugins ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.2/src/commands/plugins/index.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/index.ts)_ ## `csdx plugins:add PLUGIN` @@ -341,7 +341,7 @@ EXAMPLES $ csdx plugins:inspect myplugin ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.2/src/commands/plugins/inspect.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/inspect.ts)_ ## `csdx plugins:install PLUGIN` @@ -390,7 +390,7 @@ EXAMPLES $ csdx plugins:install someuser/someplugin ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.2/src/commands/plugins/install.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/install.ts)_ ## `csdx plugins:link PATH` @@ -420,7 +420,7 @@ EXAMPLES $ csdx plugins:link myplugin ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.2/src/commands/plugins/link.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/link.ts)_ ## `csdx plugins:remove [PLUGIN]` @@ -461,7 +461,7 @@ FLAGS --reinstall Reinstall all plugins after uninstalling. ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.2/src/commands/plugins/reset.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/reset.ts)_ ## `csdx plugins:uninstall [PLUGIN]` @@ -489,7 +489,7 @@ EXAMPLES $ csdx plugins:uninstall myplugin ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.2/src/commands/plugins/uninstall.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/uninstall.ts)_ ## `csdx plugins:unlink [PLUGIN]` @@ -533,5 +533,5 @@ DESCRIPTION Update installed plugins. ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.2/src/commands/plugins/update.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/update.ts)_ diff --git a/packages/contentstack-auth/README.md b/packages/contentstack-auth/README.md index cfb1001837..e2a9630df0 100644 --- a/packages/contentstack-auth/README.md +++ b/packages/contentstack-auth/README.md @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-auth $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-auth/1.3.18 darwin-arm64 node-v22.2.0 +@contentstack/cli-auth/1.3.19 darwin-arm64 node-v22.2.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-auth/package.json b/packages/contentstack-auth/package.json index e2dfacda3a..ae2d91c4f3 100644 --- a/packages/contentstack-auth/package.json +++ b/packages/contentstack-auth/package.json @@ -1,7 +1,7 @@ { "name": "@contentstack/cli-auth", "description": "Contentstack CLI plugin for authentication activities", - "version": "1.3.18", + "version": "1.3.19", "author": "Contentstack", "bugs": "https://github.com/contentstack/cli/issues", "scripts": { diff --git a/packages/contentstack-branches/README.md b/packages/contentstack-branches/README.md index 69275998d1..d03133d56f 100755 --- a/packages/contentstack-branches/README.md +++ b/packages/contentstack-branches/README.md @@ -37,7 +37,7 @@ $ npm install -g @contentstack/cli-cm-branches $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-cm-branches/1.1.0 darwin-arm64 node-v22.2.0 +@contentstack/cli-cm-branches/1.1.1 darwin-arm64 node-v22.2.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-branches/package.json b/packages/contentstack-branches/package.json index 7512d6b5fb..108557efc5 100644 --- a/packages/contentstack-branches/package.json +++ b/packages/contentstack-branches/package.json @@ -1,7 +1,7 @@ { "name": "@contentstack/cli-cm-branches", "description": "Contentstack CLI plugin to do branches operations", - "version": "1.1.0", + "version": "1.1.1", "author": "Contentstack", "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { @@ -25,7 +25,7 @@ "winston": "^3.7.2" }, "devDependencies": { - "@contentstack/cli-auth": "~1.3.18", + "@contentstack/cli-auth": "~1.3.19", "@contentstack/cli-config": "~1.6.4", "@contentstack/cli-dev-dependencies": "~1.2.4", "@oclif/plugin-help": "^5.1.19", diff --git a/packages/contentstack-clone/package.json b/packages/contentstack-clone/package.json index bbd1a4c024..5152a90b71 100644 --- a/packages/contentstack-clone/package.json +++ b/packages/contentstack-clone/package.json @@ -6,7 +6,7 @@ "bugs": "https://github.com/rohitmishra209/cli-cm-clone/issues", "dependencies": { "@colors/colors": "^1.5.0", - "@contentstack/cli-cm-export": "~1.11.4", + "@contentstack/cli-cm-export": "~1.11.5", "@contentstack/cli-cm-import": "~1.16.0", "@contentstack/cli-command": "~1.2.18", "@contentstack/cli-utilities": "~1.6.3", diff --git a/packages/contentstack-export/README.md b/packages/contentstack-export/README.md index 160abccd3e..1e649d5e37 100755 --- a/packages/contentstack-export/README.md +++ b/packages/contentstack-export/README.md @@ -48,7 +48,7 @@ $ npm install -g @contentstack/cli-cm-export $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-cm-export/1.11.4 darwin-arm64 node-v22.2.0 +@contentstack/cli-cm-export/1.11.5 darwin-arm64 node-v22.2.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-export/package.json b/packages/contentstack-export/package.json index 6d7c670318..e5ff711403 100644 --- a/packages/contentstack-export/package.json +++ b/packages/contentstack-export/package.json @@ -1,7 +1,7 @@ { "name": "@contentstack/cli-cm-export", "description": "Contentstack CLI plugin to export content from stack", - "version": "1.11.4", + "version": "1.11.5", "author": "Contentstack", "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { @@ -24,7 +24,7 @@ "winston": "^3.7.2" }, "devDependencies": { - "@contentstack/cli-auth": "~1.3.18", + "@contentstack/cli-auth": "~1.3.19", "@contentstack/cli-config": "~1.6.4", "@contentstack/cli-dev-dependencies": "~1.2.4", "@oclif/plugin-help": "^5.1.19", diff --git a/packages/contentstack-import/README.md b/packages/contentstack-import/README.md index f24a7bf85a..8097e79d47 100644 --- a/packages/contentstack-import/README.md +++ b/packages/contentstack-import/README.md @@ -79,7 +79,7 @@ FLAGS -k, --stack-api-key= API key of the target stack -m, --module= [optional] specific module name -y, --yes [optional] Override marketplace prompts - --exclude-global-modules Excluded the Module that are branch independent from the import + --exclude-global-modules Excludes the branch-independent module from the import operation --import-webhook-status=