Skip to content
Open
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
2,922 changes: 1,427 additions & 1,495 deletions package-lock.json

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/apps-cli",
"version": "1.6.3",
"version": "1.6.4",
"description": "App ClI",
"author": "Contentstack CLI",
"homepage": "https://github.com/contentstack/contentstack-apps-cli",
Expand All @@ -21,37 +21,37 @@
],
"dependencies": {
"@apollo/client": "^3.14.0",
"@contentstack/cli-command": "^1.7.0",
"@contentstack/cli-launch": "^1.9.4",
"@contentstack/cli-utilities": "^1.14.4",
"@contentstack/cli-command": "^1.7.2",
"@contentstack/cli-launch": "^1.9.5",
"@contentstack/cli-utilities": "^1.17.1",
"adm-zip": "^0.5.16",
"chalk": "^4.1.2",
"lodash": "^4.17.21",
"lodash": "^4.17.23",
"shelljs": "^0.10.0",
"tmp": "^0.2.5",
"winston": "^3.19.0"
},
"devDependencies": {
"@oclif/test": "^4.1.15",
"@oclif/test": "^4.1.16",
"@types/adm-zip": "^0.5.7",
"@types/chai": "^4.3.20",
"@types/lodash": "^4.17.21",
"@types/lodash": "^4.17.23",
"@types/mocha": "^10.0.10",
"@types/node": "^20.19.27",
"@types/shelljs": "^0.8.17",
"@types/node": "^20.19.33",
"@types/shelljs": "^0.10.0",
"@types/tmp": "^0.2.6",
"@typescript-eslint/eslint-plugin": "^8.50.1",
"@typescript-eslint/parser": "^8.50.1",
"axios": "^1.13.2",
"@typescript-eslint/eslint-plugin": "^8.54.0",
"@typescript-eslint/parser": "^8.54.0",
"axios": "^1.13.5",
"chai": "^4.5.0",
"dotenv": "^16.6.1",
"eslint": "^8.57.1",
"eslint-config-oclif": "^6.0.128",
"eslint-config-oclif": "^6.0.137",
"eslint-config-oclif-typescript": "^3.1.14",
"fancy-test": "3.0.16",
"mocha": "^10.8.2",
"nyc": "^15.1.0",
"oclif": "^4.22.61",
"oclif": "^4.22.77",
"shx": "^0.4.0",
"ts-node": "^10.9.2",
"tslib": "^2.8.1",
Expand Down
10 changes: 4 additions & 6 deletions test/unit/commands/app/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@ import shelljs from "shelljs";
import { join } from "path";
import sinon from "sinon";
import { runCommand } from "@oclif/test";
import { cliux, configHandler } from "@contentstack/cli-utilities";
import { cliux } from "@contentstack/cli-utilities";
import messages from "../../../../src/messages";
import config from "../../../../src/config";
import * as mock from "../../mock/common.mock.json";
import manifestData from "../../../../src/config/manifest.json";
import orgManifestData from "../../../unit/config/org_manifest.json";
import { getDeveloperHubUrl } from "../../../../src/util/inquirer";
import axios from "axios";
import { stubAuthentication } from "../../helpers/auth-stub-helper";
import { stubAuthentication, MOCK_CMA } from "../../helpers/auth-stub-helper";

const { origin, pathname } = new URL(config.appBoilerplateGithubUrl);
const zipPath = join(process.cwd(), "test", "unit", "mock", "boilerplate.zip");
const region: { cma: string; name: string; cda: string } =
configHandler.get("region");
const developerHubBaseUrl = getDeveloperHubUrl();

class MockWriteStream extends PassThrough implements fs.WriteStream {
Expand Down Expand Up @@ -49,7 +47,7 @@ describe("app:create", () => {
removeCallback: sandbox.stub(),
}));
nock(origin).get(pathname).reply(200, { data: "test-data" });
nock(region.cma)
nock(MOCK_CMA)
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
.reply(200, { organizations: mock.organizations });
});
Expand Down Expand Up @@ -434,7 +432,7 @@ describe("app:create", () => {

describe("App creation with organization UID instead of app UID", () => {
beforeEach(() => {
nock(region.cma)
nock(MOCK_CMA)
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
.reply(200, { organizations: mock.organizations });

Expand Down
8 changes: 3 additions & 5 deletions test/unit/commands/app/delete.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { expect } from "chai";
import { runCommand } from "@oclif/test";
import { cliux, configHandler } from "@contentstack/cli-utilities";
import { cliux } from "@contentstack/cli-utilities";
import sinon from "sinon";
import * as mock from "../../mock/common.mock.json";
import messages, { $t } from "../../../../src/messages";
import { getDeveloperHubUrl } from "../../../../src/util/inquirer";
import nock from "nock";
import { stubAuthentication } from "../../helpers/auth-stub-helper";
import { stubAuthentication, MOCK_CMA } from "../../helpers/auth-stub-helper";

const region: { cma: string; name: string; cda: string } =
configHandler.get("region");
const developerHubBaseUrl = getDeveloperHubUrl();

describe("app:delete", () => {
Expand All @@ -20,7 +18,7 @@
// Stub authentication using shared helper
stubAuthentication(sandbox);

nock(region.cma)
nock(MOCK_CMA)
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
.reply(200, { organizations: mock.organizations });
});
Expand Down Expand Up @@ -106,7 +104,7 @@

it("should throw an error while deleting the app", async () => {
const { stdout } = await runCommand(["app:delete"]);
expect(stdout).to.contain(messages.CONTACT_SUPPORT);

Check failure on line 107 in test/unit/commands/app/delete.test.ts

View workflow job for this annotation

GitHub Actions / Mocha Unit Test

test/unit/commands/app/delete.test.ts ► app:delete app:delete error handling ► should throw an error while deleting the app

Failed test found in: report.json Error: expected 'warn: Some error occurred while fetch…' to include 'Contact the support team for help.'
Raw output
AssertionError: expected 'warn: Some error occurred while fetch…' to include 'Contact the support team for help.'
    at Context.<anonymous> (test/unit/commands/app/delete.test.ts:107:25)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
});
});
});
11 changes: 5 additions & 6 deletions test/unit/commands/app/deploy.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { expect } from "chai";
import nock from "nock";
import { runCommand } from "@oclif/test";
import { cliux, configHandler } from "@contentstack/cli-utilities";
import { cliux } from "@contentstack/cli-utilities";
import messages, { $t } from "../../../../src/messages";
import * as mock from "../../mock/common.mock.json";
import { getDeveloperHubUrl } from "../../../../src/util/inquirer";
import sinon from "sinon";
import { stubAuthentication } from "../../helpers/auth-stub-helper";
import { stubAuthentication, MOCK_CMA } from "../../helpers/auth-stub-helper";

const region = configHandler.get("region");
const developerHubBaseUrl = getDeveloperHubUrl();

describe("app:deploy", () => {
Expand Down Expand Up @@ -76,7 +75,7 @@ describe("app:deploy", () => {
// Stub Launch.run
sandbox.stub(require("@contentstack/cli-launch").Launch, "run").resolves();

nock(region.cma)
nock(MOCK_CMA)
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
.reply(200, { organizations: mock.organizations });

Expand Down Expand Up @@ -173,7 +172,7 @@ describe("app:deploy", () => {
.stub(require("../../../../src/util/common-utils"), "updateApp")
.resolves();

nock(region.cma)
nock(MOCK_CMA)
.get(
"/v3/organizations?limit=100&asc=name&asc=name&include_count=true&skip=0"
)
Expand Down Expand Up @@ -233,7 +232,7 @@ describe("app:deploy", () => {
.stub(require("@contentstack/cli-launch").Launch, "run")
.resolves();

nock(region.cma)
nock(MOCK_CMA)
.get(
"/v3/organizations?limit=100&asc=name&asc=name&include_count=true&skip=0"
)
Expand Down
13 changes: 6 additions & 7 deletions test/unit/commands/app/get.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ import fs from "fs";
import { join } from "path";
import sinon from "sinon";
import { runCommand } from "@oclif/test";
import { cliux, configHandler } from "@contentstack/cli-utilities";
import { cliux } from "@contentstack/cli-utilities";
import messages, { $t } from "../../../../src/messages";
import * as commonUtils from "../../../../src/util/common-utils";
import * as mock from "../../mock/common.mock.json";
import manifestData from "../../../../src/config/manifest.json";
import { getDeveloperHubUrl } from "../../../../src/util/inquirer";
import config from "../../../../src/config";
import { stubAuthentication } from "../../helpers/auth-stub-helper";
import { stubAuthentication, MOCK_CMA } from "../../helpers/auth-stub-helper";

const region = configHandler.get("region");
const developerHubBaseUrl = getDeveloperHubUrl();

describe("app:get", () => {
Expand Down Expand Up @@ -46,7 +45,7 @@ describe("app:get", () => {
return cases[prompt.name];
});

nock(region.cma)
nock(MOCK_CMA)
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
.reply(200, { organizations: mock.organizations });

Expand Down Expand Up @@ -81,7 +80,7 @@ describe("app:get", () => {
sandbox.stub(fs, "readdirSync").returns([]);
sandbox.stub(cliux, "inquire").resolves("test org 1");

nock(region.cma)
nock(MOCK_CMA)
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
.reply(200, { organizations: mock.organizations });

Expand Down Expand Up @@ -121,7 +120,7 @@ describe("app:get", () => {
sandbox.stub(cliux, "confirm").resolves(false);
sandbox.stub(cliux, "inquire").resolves("test org 1");

nock(region.cma)
nock(MOCK_CMA)
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
.reply(200, { organizations: mock.organizations });

Expand Down Expand Up @@ -160,7 +159,7 @@ describe("app:get", () => {
sandbox.stub(cliux, "confirm").resolves(true);
sandbox.stub(cliux, "inquire").resolves("test org 1");

nock(region.cma)
nock(MOCK_CMA)
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
.reply(200, { organizations: mock.organizations });

Expand Down
11 changes: 5 additions & 6 deletions test/unit/commands/app/install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import { expect } from "chai";
import nock from "nock";
import sinon from "sinon";
import { runCommand } from "@oclif/test";
import { cliux, configHandler } from "@contentstack/cli-utilities";
import { cliux } from "@contentstack/cli-utilities";
import messages from "../../../../src/messages";
import * as mock from "../../mock/common.mock.json";
import { getDeveloperHubUrl } from "../../../../src/util/inquirer";
import axios from "axios";
import { stubAuthentication } from "../../helpers/auth-stub-helper";
import { stubAuthentication, MOCK_CMA } from "../../helpers/auth-stub-helper";

const region = configHandler.get("region");
const developerHubBaseUrl = getDeveloperHubUrl();

describe("app:install", () => {
Expand All @@ -24,7 +23,7 @@ describe("app:install", () => {

sandbox.stub(cliux, "loader").callsFake(() => {});

nock(region.cma)
nock(MOCK_CMA)
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
.reply(200, { organizations: mock.organizations });

Expand Down Expand Up @@ -75,7 +74,7 @@ describe("app:install", () => {
};
return cases[prompt.name];
});
nock(region.cma)
nock(MOCK_CMA)
.get(
`/v3/organizations/${mock.organizations[0].uid}/stacks?limit=100&asc=name&include_count=true&skip=0`
)
Expand Down Expand Up @@ -108,7 +107,7 @@ describe("app:install", () => {
};
return cases[prompt.name];
});
nock(region.cma).get(`/v3/stacks`).reply(200, { stack: mock.stacks[0] });
nock(MOCK_CMA).get(`/v3/stacks`).reply(200, { stack: mock.stacks[0] });
nock(`https://${developerHubBaseUrl}`)
.get(`/manifests/${mock.apps[0].uid}`)
.reply(200, {
Expand Down
17 changes: 8 additions & 9 deletions test/unit/commands/app/reinstall.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import { expect } from "chai";
import nock from "nock";
import sinon from "sinon";
import { runCommand } from "@oclif/test";
import { cliux, configHandler } from "@contentstack/cli-utilities";
import { cliux } from "@contentstack/cli-utilities";
import messages, { $t } from "../../../../src/messages";
import * as mock from "../../mock/common.mock.json";
import { getDeveloperHubUrl } from "../../../../src/util/inquirer";
import { stubAuthentication } from "../../helpers/auth-stub-helper";
import { stubAuthentication, MOCK_CMA } from "../../helpers/auth-stub-helper";

const region = configHandler.get("region");
const developerHubBaseUrl = getDeveloperHubUrl();

describe("app:reinstall", () => {
Expand All @@ -22,7 +21,7 @@ describe("app:reinstall", () => {

sandbox.stub(cliux, "loader").callsFake(() => {});

nock(region.cma)
nock(MOCK_CMA)
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
.reply(200, { organizations: mock.organizations });
});
Expand Down Expand Up @@ -67,7 +66,7 @@ describe("app:reinstall", () => {
nock(`https://${developerHubBaseUrl}`)
.get("/manifests?limit=50&asc=name&include_count=true&skip=0")
.reply(200, { data: mock.apps });
nock(region.cma)
nock(MOCK_CMA)
.get(
`/v3/organizations/${mock.organizations[0].uid}/stacks?limit=100&asc=name&include_count=true&skip=0`
)
Expand Down Expand Up @@ -108,7 +107,7 @@ describe("app:reinstall", () => {
};
return cases[prompt.name];
});
nock(region.cma).get(`/v3/stacks`).reply(200, { stack: mock.stacks[0] });
nock(MOCK_CMA).get(`/v3/stacks`).reply(200, { stack: mock.stacks[0] });
nock(`https://${developerHubBaseUrl}`)
.get(`/manifests/${mock.apps[0].uid}`)
.reply(200, {
Expand Down Expand Up @@ -150,11 +149,11 @@ describe("app:reinstall", () => {
return cases[prompt.name];
});

nock(region.cma)
nock(MOCK_CMA)
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
.reply(200, { organizations: mock.organizations });

nock(region.cma)
nock(MOCK_CMA)
.get(
`/v3/organizations/${mock.organizations[0].uid}/stacks?limit=100&asc=name&include_count=true&skip=0`
)
Expand Down Expand Up @@ -189,7 +188,7 @@ describe("app:reinstall", () => {
};
return (cases as Record<string, any>)[prompt.name];
});
nock(region.cma)
nock(MOCK_CMA)
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
.reply(200, { organizations: mock.organizations });

Expand Down
Loading
Loading