Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ snyk_output.log
.cursor/rules/snyk_rules.mdc
**/migration-logs
**/migration-logs/**
*.logs
*.logs
tsconfig.tsbuildinfo
2,080 changes: 1,624 additions & 456 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions packages/contentstack-bootstrap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@
"postpack": "rm -f oclif.manifest.json",
"prepack": "pnpm compile && oclif manifest && oclif readme",
"version": "oclif readme && git add README.md",
"test": "npm run build && npm run test:e2e",
"test": "npm run compile && npm run test:e2e",
"test:e2e": "nyc mocha \"test/**/*.test.js\" || exit 0",
"test:report": "nyc --reporter=lcov mocha \"test/**/*.test.js\""
},
"dependencies": {
"@contentstack/cli-cm-seed": "~2.0.0-beta.8",
"@contentstack/cli-command": "~2.0.0-beta",
"@contentstack/cli-utilities": "~2.0.0-beta",
"@contentstack/cli-config": "~2.0.0-beta.1",
"@contentstack/cli-utilities": "~2.0.0-beta",
"@oclif/core": "^4.3.0",
"@oclif/plugin-help": "^6.2.37",
"inquirer": "8.2.7",
"inquirer": "12.11.1",
"mkdirp": "^1.0.4",
"tar": "^7.5.7"
},
"devDependencies": {
"@oclif/test": "^4.1.13",
"@types/inquirer": "^9.0.8",
"@types/mkdirp": "^1.0.2",
"@types/node": "^14.18.63",
"@types/node": "^18.11.9",
"@types/tar": "^6.1.13",
"chai": "^4.5.0",
"eslint": "^8.57.1",
Expand All @@ -41,7 +41,7 @@
"oclif": "^4.17.46",
"tmp": "^0.2.5",
"ts-node": "^8.10.2",
"typescript": "^4.9.5"
"typescript": "^5.9.3"
},
"engines": {
"node": ">=14.0.0"
Expand Down Expand Up @@ -73,4 +73,4 @@
}
},
"repository": "contentstack/cli"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const inquirer = require('inquirer');
import inquirer from 'inquirer';
import { cliux, pathValidator } from '@contentstack/cli-utilities';

import messageHandler from '../messages';
Expand Down Expand Up @@ -50,15 +50,14 @@ export async function inquireCloneDirectory(): Promise<string> {
}

// Ask for the custom path
let selectedCustomPath = await inquirer.prompt([
const selectedCustomPath = await inquirer.prompt([
{
type: 'string',
type: 'input',
name: 'path',
message: messageHandler.parse('CLI_BOOTSTRAP_APP_COPY_SOURCE_CODE_DESTINATION_ENQUIRY'),
},
]);
selectedCustomPath = pathValidator(selectedCustomPath.path);
return selectedCustomPath;
return pathValidator(selectedCustomPath.path);
}

export async function inquireGithubAccessToken(): Promise<any> {
Expand Down
11 changes: 8 additions & 3 deletions packages/contentstack-bootstrap/test/bootstrap.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ describe('Bootstrapping an app', () => {
sandbox.stub(interactive, 'inquireAppType').resolves('starterapp');
sandbox.stub(interactive, 'inquireApp').resolves(mock.appConfig);
sandbox.stub(interactive, 'inquireCloneDirectory').resolves('/test/path');
sandbox.stub(interactive, 'inquireLivePreviewSupport');
sandbox.stub(interactive, 'inquireRunDevServer');

// Mock config
const config = require('../lib/config');
Expand Down Expand Up @@ -471,6 +473,8 @@ describe('Bootstrapping an app', () => {
sandbox.stub(interactive, 'inquireAppType').resolves('starterapp');
sandbox.stub(interactive, 'inquireApp').resolves(mock.appConfig);
sandbox.stub(interactive, 'inquireCloneDirectory').resolves('/test/path');
sandbox.stub(interactive, 'inquireLivePreviewSupport');
sandbox.stub(interactive, 'inquireRunDevServer');

// Mock config
const config = require('../lib/config');
Expand Down Expand Up @@ -619,8 +623,8 @@ describe('Bootstrapping an app', () => {
// Verify that appType is set correctly
expect(bootstrapOptions).to.not.be.null;
expect(bootstrapOptions.appType).to.equal('sampleapp');
// Verify that inquireApp was called with sampleApps
expect(interactive.inquireApp.calledWith(config.sampleApps)).to.be.true;
// Verify that inquireApp was called with sampleApps (config.default in compiled CJS)
expect(interactive.inquireApp.calledWith(config.default.sampleApps)).to.be.true;
});

it('should handle app-name flag correctly', async () => {
Expand All @@ -631,9 +635,10 @@ describe('Bootstrapping an app', () => {
const BootstrapCommand = require('../lib/commands/cm/bootstrap').default;
const command = new BootstrapCommand([], {});

// Mock interactive functions
// Mock interactive functions (stub inquireApp so .called exists for assertion)
const interactive = require('../lib/bootstrap/interactive');
sandbox.stub(interactive, 'inquireAppType').resolves('starterapp');
sandbox.stub(interactive, 'inquireApp').resolves(mock.appConfig);
sandbox.stub(interactive, 'inquireCloneDirectory').resolves('/test/path');
sandbox.stub(interactive, 'inquireLivePreviewSupport').resolves(false);
sandbox.stub(interactive, 'inquireRunDevServer').resolves(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const { expect } = require('chai');
const sinon = require('sinon');
const inquirer = require('inquirer');
// Inquirer v12 CJS export is { default: { prompt, ... } }; use default so stubs apply to what lib uses
const inquirer = require('inquirer').default || require('inquirer');
const { inquireRunDevServer } = require('../lib/bootstrap/interactive');
const messages = require('../messages/index.json');

Expand Down
15 changes: 7 additions & 8 deletions packages/contentstack-bootstrap/test/interactive.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const { expect } = require('chai');
const sinon = require('sinon');
const inquirer = require('inquirer');
// Inquirer v12 CJS export is { default: { prompt, ... } }; use default so stubs apply to what lib uses
const inquirer = require('inquirer').default || require('inquirer');
const {
inquireApp,
inquireCloneDirectory,
Expand All @@ -11,6 +14,7 @@ const {
continueBootstrapCommand,
} = require('../lib/bootstrap/interactive');
const messages = require('../messages/index.json');
const { pathValidator } = require('@contentstack/cli-utilities');

describe('Interactive Functions Tests', () => {
let sandbox;
Expand Down Expand Up @@ -101,30 +105,25 @@ describe('Interactive Functions Tests', () => {
.resolves({ path: 'Other' })
.onSecondCall()
.resolves({ path: customPath });
const pathValidatorStub = sandbox.stub(require('@contentstack/cli-utilities'), 'pathValidator').returns(customPath);

const result = await inquireCloneDirectory();

expect(result).to.equal(customPath);
expect(result).to.equal(pathValidator(customPath));
expect(inquirer.prompt.calledTwice).to.be.true;
expect(pathValidatorStub.calledOnce).to.be.true;
});

it('should validate custom path using pathValidator', async () => {
const rawPath = '/some/path';
const validatedPath = '/validated/path';
sandbox
.stub(inquirer, 'prompt')
.onFirstCall()
.resolves({ path: 'Other' })
.onSecondCall()
.resolves({ path: rawPath });
const pathValidatorStub = sandbox.stub(require('@contentstack/cli-utilities'), 'pathValidator').returns(validatedPath);

const result = await inquireCloneDirectory();

expect(pathValidatorStub.calledWith(rawPath)).to.be.true;
expect(result).to.equal(validatedPath);
expect(result).to.equal(pathValidator(rawPath));
});
});

Expand Down
8 changes: 4 additions & 4 deletions packages/contentstack-clone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@oclif/core": "^4.3.0",
"@oclif/plugin-help": "^6.2.28",
"chalk": "^4.1.2",
"inquirer": "8.2.7",
"inquirer": "12.11.1",
"lodash": "^4.17.23",
"merge": "^2.1.1",
"ora": "^5.4.1",
Expand All @@ -24,7 +24,7 @@
"@oclif/test": "^4.1.13",
"@types/chai": "^4.3.0",
"@types/mocha": "^10.0.0",
"@types/node": "^14.18.63",
"@types/node": "^18.11.9",
"@types/sinon": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"chai": "^4.5.0",
Expand All @@ -35,7 +35,7 @@
"oclif": "^4.17.46",
"sinon": "^21.0.1",
"ts-node": "^10.9.2",
"typescript": "^4.9.5"
"typescript": "^5.9.3"
},
"engines": {
"node": ">=14.0.0"
Expand Down Expand Up @@ -78,4 +78,4 @@
"cm:stacks:clone": "CLN"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ export class CloneHandler {
}

displayBackOptionMessage(): void {
const ui = new inquirer.ui.BottomBar();
ui.updateBottomBar(chalk.cyan('\nPress shift & left arrow together to undo the operation\n'));
process.stdout.write(chalk.cyan('\nPress shift & left arrow together to undo the operation\n'));
}

setBackKeyPressHandler(backKeyPressHandler: (...args: any[]) => void): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,6 @@ describe('CloneHandler - Commands', () => {
const configHandler = require('@contentstack/cli-utilities').configHandler;
configHandlerGetStub = sandbox.stub(configHandler, 'get').returns(undefined);

// Stub inquirer.ui.BottomBar to prevent hanging in displayBackOptionMessage
sandbox.stub(inquirer.ui, 'BottomBar').returns({
updateBottomBar: sandbox.stub(),
} as any);

// Stub ora spinner - following import plugin pattern
const oraModule = require('ora');
const mockSpinner = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,6 @@ describe('CloneHandler - Execution', () => {
stack: sandbox.stub(),
};
handler.setClient(mockClient);
// Stub inquirer.ui.BottomBar to prevent hanging
sandbox.stub(inquirer.ui, 'BottomBar').returns({
updateBottomBar: sandbox.stub(),
} as any);
});

afterEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,11 @@ describe('CloneHandler - Helpers', () => {
});

it('should display back option message', () => {
const uiStub = {
updateBottomBar: sandbox.stub(),
};
sandbox.stub(inquirer.ui, 'BottomBar').returns(uiStub as any);

const writeStub = sandbox.stub(process.stdout, 'write');
handler.displayBackOptionMessage();

expect(uiStub.updateBottomBar.calledOnce).to.be.true;
expect(writeStub.calledOnce).to.be.true;
expect(writeStub.firstCall.args[0]).to.include('Press shift & left arrow together to undo');
writeStub.restore();
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ describe('CloneHandler - Stack', () => {
const configHandler = require('@contentstack/cli-utilities').configHandler;
configHandlerGetStub = sandbox.stub(configHandler, 'get').returns(undefined);

// Stub inquirer.ui.BottomBar to prevent hanging in displayBackOptionMessage
sandbox.stub(inquirer.ui, 'BottomBar').returns({
updateBottomBar: sandbox.stub(),
} as any);

const config: CloneConfig = {
cloneContext: {
command: 'test',
Expand Down
5 changes: 2 additions & 3 deletions packages/contentstack-export-to-csv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
"dependencies": {
"@contentstack/cli-command": "~2.0.0-beta",
"@contentstack/cli-utilities": "~2.0.0-beta",
"@inquirer/prompts": "^8.2.1",
"@oclif/core": "^4.8.0",
"@oclif/plugin-help": "^6.2.32",
"fast-csv": "^4.3.6",
"inquirer": "8.2.7",
"inquirer-checkbox-plus-prompt": "1.4.2"
"fast-csv": "^4.3.6"
},
"devDependencies": {
"@oclif/test": "^4.1.13",
Expand Down
Loading
Loading