Skip to content

Commit 9edbb33

Browse files
chore: update inquirer and node types across multiple packages, refactor interactive prompts to use new inquirer syntax
1 parent 255d0b4 commit 9edbb33

File tree

18 files changed

+352
-477
lines changed

18 files changed

+352
-477
lines changed

packages/contentstack-bootstrap/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@
1818
"dependencies": {
1919
"@contentstack/cli-cm-seed": "~2.0.0-beta.8",
2020
"@contentstack/cli-command": "~2.0.0-beta",
21-
"@contentstack/cli-utilities": "~2.0.0-beta",
2221
"@contentstack/cli-config": "~2.0.0-beta.1",
22+
"@contentstack/cli-utilities": "~2.0.0-beta",
2323
"@oclif/core": "^4.3.0",
2424
"@oclif/plugin-help": "^6.2.37",
25-
"inquirer": "8.2.7",
25+
"inquirer": "12.11.1",
2626
"mkdirp": "^1.0.4",
2727
"tar": "^7.5.7"
2828
},
2929
"devDependencies": {
3030
"@oclif/test": "^4.1.13",
3131
"@types/inquirer": "^9.0.8",
3232
"@types/mkdirp": "^1.0.2",
33-
"@types/node": "^14.18.63",
33+
"@types/node": "^18.11.9",
3434
"@types/tar": "^6.1.13",
3535
"chai": "^4.5.0",
3636
"eslint": "^8.57.1",
@@ -41,7 +41,7 @@
4141
"oclif": "^4.17.46",
4242
"tmp": "^0.2.5",
4343
"ts-node": "^8.10.2",
44-
"typescript": "^4.9.5"
44+
"typescript": "^5.9.3"
4545
},
4646
"engines": {
4747
"node": ">=14.0.0"
@@ -73,4 +73,4 @@
7373
}
7474
},
7575
"repository": "contentstack/cli"
76-
}
76+
}

packages/contentstack-bootstrap/src/bootstrap/interactive.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const inquirer = require('inquirer');
1+
import inquirer from 'inquirer';
22
import { cliux, pathValidator } from '@contentstack/cli-utilities';
33

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

5252
// Ask for the custom path
53-
let selectedCustomPath = await inquirer.prompt([
53+
const selectedCustomPath = await inquirer.prompt([
5454
{
55-
type: 'string',
55+
type: 'input',
5656
name: 'path',
5757
message: messageHandler.parse('CLI_BOOTSTRAP_APP_COPY_SOURCE_CODE_DESTINATION_ENQUIRY'),
5858
},
5959
]);
60-
selectedCustomPath = pathValidator(selectedCustomPath.path);
61-
return selectedCustomPath;
60+
return pathValidator(selectedCustomPath.path);
6261
}
6362

6463
export async function inquireGithubAccessToken(): Promise<any> {

packages/contentstack-bootstrap/test/interactive-dev-server.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { expect } = require('chai');
22
const sinon = require('sinon');
3-
const inquirer = require('inquirer');
3+
import inquirer from 'inquirer';
44
const { inquireRunDevServer } = require('../lib/bootstrap/interactive');
55
const messages = require('../messages/index.json');
66

packages/contentstack-bootstrap/test/interactive.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { expect } = require('chai');
22
const sinon = require('sinon');
3-
const inquirer = require('inquirer');
3+
import inquirer from 'inquirer';
44
const {
55
inquireApp,
66
inquireCloneDirectory,

packages/contentstack-clone/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@oclif/core": "^4.3.0",
1414
"@oclif/plugin-help": "^6.2.28",
1515
"chalk": "^4.1.2",
16-
"inquirer": "8.2.7",
16+
"inquirer": "12.11.1",
1717
"lodash": "^4.17.23",
1818
"merge": "^2.1.1",
1919
"ora": "^5.4.1",
@@ -24,7 +24,7 @@
2424
"@oclif/test": "^4.1.13",
2525
"@types/chai": "^4.3.0",
2626
"@types/mocha": "^10.0.0",
27-
"@types/node": "^14.18.63",
27+
"@types/node": "^18.11.9",
2828
"@types/sinon": "^10.0.0",
2929
"@typescript-eslint/eslint-plugin": "^5.62.0",
3030
"chai": "^4.5.0",
@@ -35,7 +35,7 @@
3535
"oclif": "^4.17.46",
3636
"sinon": "^21.0.1",
3737
"ts-node": "^10.9.2",
38-
"typescript": "^4.9.5"
38+
"typescript": "^5.9.3"
3939
},
4040
"engines": {
4141
"node": ">=14.0.0"
@@ -78,4 +78,4 @@
7878
"cm:stacks:clone": "CLN"
7979
}
8080
}
81-
}
81+
}

packages/contentstack-clone/src/core/util/clone-handler.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ export class CloneHandler {
170170
}
171171

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

177176
setBackKeyPressHandler(backKeyPressHandler: (...args: any[]) => void): void {

packages/contentstack-clone/test/lib/util/clone-handler.commands.test.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -399,11 +399,6 @@ describe('CloneHandler - Commands', () => {
399399
const configHandler = require('@contentstack/cli-utilities').configHandler;
400400
configHandlerGetStub = sandbox.stub(configHandler, 'get').returns(undefined);
401401

402-
// Stub inquirer.ui.BottomBar to prevent hanging in displayBackOptionMessage
403-
sandbox.stub(inquirer.ui, 'BottomBar').returns({
404-
updateBottomBar: sandbox.stub(),
405-
} as any);
406-
407402
// Stub ora spinner - following import plugin pattern
408403
const oraModule = require('ora');
409404
const mockSpinner = {

packages/contentstack-clone/test/lib/util/clone-handler.execution.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,6 @@ describe('CloneHandler - Execution', () => {
425425
stack: sandbox.stub(),
426426
};
427427
handler.setClient(mockClient);
428-
// Stub inquirer.ui.BottomBar to prevent hanging
429-
sandbox.stub(inquirer.ui, 'BottomBar').returns({
430-
updateBottomBar: sandbox.stub(),
431-
} as any);
432428
});
433429

434430
afterEach(() => {

packages/contentstack-clone/test/lib/util/clone-handler.helpers.test.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,11 @@ describe('CloneHandler - Helpers', () => {
2626
});
2727

2828
it('should display back option message', () => {
29-
const uiStub = {
30-
updateBottomBar: sandbox.stub(),
31-
};
32-
sandbox.stub(inquirer.ui, 'BottomBar').returns(uiStub as any);
33-
29+
const writeStub = sandbox.stub(process.stdout, 'write');
3430
handler.displayBackOptionMessage();
35-
36-
expect(uiStub.updateBottomBar.calledOnce).to.be.true;
31+
expect(writeStub.calledOnce).to.be.true;
32+
expect(writeStub.firstCall.args[0]).to.include('Press shift & left arrow together to undo');
33+
writeStub.restore();
3734
});
3835
});
3936

packages/contentstack-clone/test/lib/util/clone-handler.stack.test.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ describe('CloneHandler - Stack', () => {
2121
const configHandler = require('@contentstack/cli-utilities').configHandler;
2222
configHandlerGetStub = sandbox.stub(configHandler, 'get').returns(undefined);
2323

24-
// Stub inquirer.ui.BottomBar to prevent hanging in displayBackOptionMessage
25-
sandbox.stub(inquirer.ui, 'BottomBar').returns({
26-
updateBottomBar: sandbox.stub(),
27-
} as any);
28-
2924
const config: CloneConfig = {
3025
cloneContext: {
3126
command: 'test',

0 commit comments

Comments
 (0)