Skip to content

Commit 9d17a6f

Browse files
committed
migrated oclif v3 to v4, loader update
1 parent 6bb11e3 commit 9d17a6f

File tree

12 files changed

+12018
-14902
lines changed

12 files changed

+12018
-14902
lines changed

package-lock.json

Lines changed: 11978 additions & 14859 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@contentstack/apps-cli",
3-
"version": "1.4.0",
3+
"version": "1.5.0",
44
"description": "App ClI",
55
"author": "Contentstack CLI",
66
"homepage": "https://github.com/contentstack/contentstack-apps-cli",
@@ -21,9 +21,9 @@
2121
],
2222
"dependencies": {
2323
"@apollo/client": "^3.11.8",
24-
"@contentstack/cli-command": "^1.3.2",
25-
"@contentstack/cli-launch": "^1.2.3",
26-
"@contentstack/cli-utilities": "^1.8.0",
24+
"@contentstack/cli-command": "^1.4.0",
25+
"@contentstack/cli-launch": "^1.3.0",
26+
"@contentstack/cli-utilities": "^1.9.0",
2727
"adm-zip": "^0.5.16",
2828
"chai-as-promised": "^8.0.0",
2929
"chalk": "^4.1.2",

src/base-command.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
Flags,
77
FlagInput,
88
Interfaces,
9-
cliux as ux,
109
ContentstackClient,
1110
managementSDKClient,
1211
managementSDKInitiator,
@@ -70,7 +69,7 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
7069
this.flags = flags as Flags<T>;
7170
this.args = args as Args<T>;
7271

73-
ux.registerSearchPlugin();
72+
cliux.registerSearchPlugin();
7473
this.registerConfig();
7574
// Init logger
7675
const logger = new Logger(this.sharedConfig);

src/commands/app/create.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
createWriteStream,
1717
} from "fs";
1818
import {
19-
ux,
2019
cliux,
2120
flags,
2221
HttpClient,
@@ -145,9 +144,9 @@ export default class Create extends BaseCommand<typeof Create> {
145144
await this.registerTheAppOnDeveloperHub();
146145

147146
// NOTE Step 3: Install dependencies
148-
ux.action.start(this.messages.INSTALL_DEPENDENCIES);
147+
cliux.loader(this.messages.INSTALL_DEPENDENCIES);
149148
await this.installDependencies();
150-
ux.action.stop();
149+
cliux.loader("done");
151150
this.log(
152151
this.$t(this.messages.START_APP_COMMAND, {
153152
command: `cd "${this.sharedConfig.folderPath}" && npm run start`,
@@ -205,7 +204,7 @@ export default class Create extends BaseCommand<typeof Create> {
205204
* @memberof Create
206205
*/
207206
async cloneBoilerplate(): Promise<string> {
208-
ux.action.start(this.messages.CLONE_BOILERPLATE);
207+
cliux.loader(this.messages.CLONE_BOILERPLATE);
209208
const tmpObj = tmp.fileSync();
210209
const filePath = tmpObj.name;
211210

@@ -220,7 +219,7 @@ export default class Create extends BaseCommand<typeof Create> {
220219
writer
221220
.on("finish", function () {
222221
resolve(filePath);
223-
ux.action.stop();
222+
cliux.loader("done");
224223
})
225224
.on("error", () => {
226225
reject(this.messages.FILE_GENERATION_FAILURE);
@@ -259,9 +258,9 @@ export default class Create extends BaseCommand<typeof Create> {
259258
this.sharedConfig.folderPath = targetPath;
260259

261260
await new Promise<void>((resolve, reject) => {
262-
ux.action.start(this.messages.UNZIP);
261+
cliux.loader(this.messages.UNZIP);
263262
zip.extractAllToAsync(dataDir, true, false, (error) => {
264-
ux.action.stop();
263+
cliux.loader("done");
265264

266265
if (!error) {
267266
renameSync(sourcePath, targetPath);
@@ -306,7 +305,7 @@ export default class Create extends BaseCommand<typeof Create> {
306305
* @memberof Create
307306
*/
308307
async registerTheAppOnDeveloperHub(saveManifest: boolean = true, retry = 0) {
309-
ux.action.start(
308+
cliux.loader(
310309
this.$t(this.messages.REGISTER_THE_APP_ON_DEVELOPER_HUB, {
311310
appName: this.sharedConfig.appName,
312311
})
@@ -316,7 +315,7 @@ export default class Create extends BaseCommand<typeof Create> {
316315
.app()
317316
.create(this.appData as AppData)
318317
.then((response) => {
319-
ux.action.stop();
318+
cliux.loader("done");
320319

321320
if (this.sharedConfig.nameChanged) {
322321
renameSync(
@@ -356,7 +355,7 @@ export default class Create extends BaseCommand<typeof Create> {
356355
this.log(this.messages.APP_CREATION_SUCCESS, "info");
357356
})
358357
.catch(async (error) => {
359-
ux.action.stop("Failed");
358+
cliux.loader("Failed");
360359
switch (error.status) {
361360
case 400:
362361
this.log(this.messages.APP_CREATION_CONSTRAINT_FAILURE, "error");
@@ -399,13 +398,13 @@ export default class Create extends BaseCommand<typeof Create> {
399398
*/
400399
rollbackBoilerplate() {
401400
if (existsSync(this.sharedConfig.folderPath)) {
402-
ux.action.start(this.messages.ROLLBACK_BOILERPLATE);
401+
cliux.loader(this.messages.ROLLBACK_BOILERPLATE);
403402
rmSync(this.sharedConfig.folderPath, {
404403
force: true,
405404
recursive: true,
406405
maxRetries: 3,
407406
});
408-
ux.action.stop();
407+
cliux.loader("done");
409408
}
410409
}
411410

test/unit/commands/app/create.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import shelljs from "shelljs";
77
import { join, resolve } from "path";
88
import sinon from "sinon";
99
import { runCommand } from "@oclif/test";
10-
import { cliux, ux, configHandler } from "@contentstack/cli-utilities";
10+
import { cliux, configHandler } from "@contentstack/cli-utilities";
1111
import messages from "../../../../src/messages";
1212
import config from "../../../../src/config";
1313
import * as mock from "../../mock/common.mock.json";
@@ -61,8 +61,8 @@ describe("app:create", () => {
6161
.reply(200, {
6262
data: { ...manifestData, name: "test-app", version: 1 },
6363
});
64-
sandbox.stub(ux.action, "stop").callsFake(() => {});
65-
sandbox.stub(ux.action, "start").callsFake(() => {});
64+
sandbox.stub(cliux, "loader").callsFake(() => {});
65+
sandbox.stub(cliux, "loader").callsFake(() => {});
6666
sandbox.stub(fs, "writeFileSync").callsFake(() => {});
6767
sandbox.stub(cliux, "inquire").callsFake((prompt: any) => {
6868
const cases: Record<string, any> = {
@@ -271,8 +271,8 @@ describe("app:create", () => {
271271
sandbox = sinon.createSandbox();
272272
axios.defaults.adapter = "http";
273273

274-
sandbox.stub(ux.action, "stop").callsFake(() => {});
275-
sandbox.stub(ux.action, "start").callsFake(() => {});
274+
sandbox.stub(cliux, "loader").callsFake(() => {});
275+
sandbox.stub(cliux, "loader").callsFake(() => {});
276276
sandbox
277277
.stub(shelljs, "cd")
278278
.callsFake(() => ({ stdout: "", stderr: "", code: 0 } as any));

test/unit/commands/app/delete.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect } from "chai";
22
import { runCommand } from "@oclif/test";
3-
import { cliux, configHandler, ux } from "@contentstack/cli-utilities";
3+
import { cliux, configHandler } from "@contentstack/cli-utilities";
44
import sinon from "sinon";
55
import * as mock from "../../mock/common.mock.json";
66
import messages, { $t } from "../../../../src/messages";
@@ -77,8 +77,8 @@ describe("app:delete", () => {
7777

7878
describe("app:delete error handling", () => {
7979
beforeEach(() => {
80-
sandbox.stub(ux.action, "stop").callsFake(() => {});
81-
sandbox.stub(ux.action, "start").callsFake(() => {});
80+
sandbox.stub(cliux, "loader").callsFake(() => {});
81+
sandbox.stub(cliux, "loader").callsFake(() => {});
8282
sandbox.stub(cliux, "inquire").callsFake(async (prompt: any) => {
8383
const cases: Record<string, any> = {
8484
Organization: "test org 1",

test/unit/commands/app/deploy.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect } from "chai";
22
import nock from "nock";
33
import { runCommand } from "@oclif/test";
4-
import { cliux, ux, configHandler } from "@contentstack/cli-utilities";
4+
import { cliux, configHandler } from "@contentstack/cli-utilities";
55
import messages, { $t } from "../../../../src/messages";
66
import * as mock from "../../mock/common.mock.json";
77
import { getDeveloperHubUrl } from "../../../../src/util/inquirer";
@@ -15,8 +15,8 @@ describe("app:deploy", () => {
1515

1616
beforeEach(() => {
1717
sandbox = sinon.createSandbox();
18-
sandbox.stub(ux.action, "stop").callsFake(() => {});
19-
sandbox.stub(ux.action, "start").callsFake(() => {});
18+
sandbox.stub(cliux, "loader").callsFake(() => {});
19+
sandbox.stub(cliux, "loader").callsFake(() => {});
2020
sandbox.stub(cliux, "inquire").callsFake((prompt: any) => {
2121
const cases: Record<string, any> = {
2222
App: mock.apps[1].name,
@@ -98,6 +98,6 @@ describe("app:deploy", () => {
9898
expect(stdout).to.contain(
9999
$t(messages.APP_DEPLOYED, { app: mock.apps2[1].name })
100100
);
101-
})
101+
});
102102
});
103103
});

test/unit/commands/app/get.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ describe("app:get", () => {
2020

2121
beforeEach(() => {
2222
sandbox = sinon.createSandbox();
23-
sandbox.stub(ux.action, "stop").callsFake(() => {});
24-
sandbox.stub(ux.action, "start").callsFake(() => {});
23+
sandbox.stub(cliux, "loader").callsFake(() => {});
24+
sandbox.stub(cliux, "loader").callsFake(() => {});
2525
sandbox.stub(fs, "writeFileSync").callsFake(() => {});
2626
});
2727

test/unit/commands/app/install.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect } from "chai";
22
import nock from "nock";
33
import sinon from "sinon";
44
import { runCommand } from "@oclif/test";
5-
import { cliux, ux, configHandler } from "@contentstack/cli-utilities";
5+
import { cliux, configHandler } from "@contentstack/cli-utilities";
66
import messages from "../../../../src/messages";
77
import * as mock from "../../mock/common.mock.json";
88
import { getDeveloperHubUrl } from "../../../../src/util/inquirer";
@@ -18,8 +18,8 @@ describe("app:install", () => {
1818
sandbox = sinon.createSandbox();
1919
axios.defaults.adapter = "http";
2020

21-
sandbox.stub(ux.action, "stop").callsFake(() => {});
22-
sandbox.stub(ux.action, "start").callsFake(() => {});
21+
sandbox.stub(cliux, "loader").callsFake(() => {});
22+
sandbox.stub(cliux, "loader").callsFake(() => {});
2323

2424
nock(region.cma)
2525
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")

test/unit/commands/app/reinstall.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect } from "chai";
22
import nock from "nock";
33
import sinon from "sinon";
44
import { runCommand } from "@oclif/test";
5-
import { cliux, ux, configHandler } from "@contentstack/cli-utilities";
5+
import { cliux, configHandler } from "@contentstack/cli-utilities";
66
import messages, { $t } from "../../../../src/messages";
77
import * as mock from "../../mock/common.mock.json";
88
import { getDeveloperHubUrl } from "../../../../src/util/inquirer";
@@ -16,8 +16,8 @@ describe("app:reinstall", () => {
1616
beforeEach(() => {
1717
sandbox = sinon.createSandbox();
1818

19-
sandbox.stub(ux.action, "stop").callsFake(() => {});
20-
sandbox.stub(ux.action, "start").callsFake(() => {});
19+
sandbox.stub(cliux, "loader").callsFake(() => {});
20+
sandbox.stub(cliux, "loader").callsFake(() => {});
2121

2222
nock(region.cma)
2323
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
@@ -95,7 +95,6 @@ describe("app:reinstall", () => {
9595
).replace("{target}", mock.stacks[0].name)
9696
);
9797
});
98-
9998
});
10099

101100
describe("Stack API Key and App ID provided through flags", () => {

0 commit comments

Comments
 (0)