Skip to content

Commit da4d135

Browse files
authored
Merge pull request #185 from contentstack/fix/external-plugin-migration
Fix external plugin migration pipeline issues
2 parents 5fb56ca + c6e75c6 commit da4d135

40 files changed

Lines changed: 406 additions & 882 deletions

File tree

.github/workflows/tsgen-integration-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
run: csdx plugins:link
4343

4444
- name: Run integration tests
45-
run: pnpm --filter contentstack-cli-tsgen run test:integration
45+
run: pnpm --filter contentstack-cli-tsgen run test
4646
env:
4747
TOKEN_ALIAS: ${{ secrets.TOKEN_ALIAS }}
4848

.github/workflows/unit-test.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,8 @@ jobs:
6969

7070
- name: Run tests for Contentstack Apps CLI
7171
working-directory: ./packages/contentstack-apps-cli
72-
run: npm run test:unit:report:json
72+
run: npm run test:unit:report
7373

74-
- name: Run tests for Contentstack Tsgen plugin
75-
working-directory: ./packages/contentstack-cli-tsgen
76-
run: npm run test
77-
7874
- name: Run tests for Contentstack Content Type plugin
7975
working-directory: ./packages/contentstack-content-type
8076
run: npm run test:unit

packages/contentstack-apps-cli/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@
4343
"@types/tmp": "^0.2.6",
4444
"@typescript-eslint/eslint-plugin": "^8.58.2",
4545
"@typescript-eslint/parser": "^8.58.2",
46-
"axios": "^1.15.0",
46+
"axios": "^1.16.1",
4747
"chai": "^4.5.0",
4848
"dotenv": "^16.6.1",
4949
"eslint": "^8.57.1",
5050
"eslint-config-oclif": "^6.0.157",
5151
"eslint-config-oclif-typescript": "^3.1.14",
5252
"mocha": "^10.8.2",
5353
"nyc": "^15.1.0",
54-
"oclif": "^4.23.0",
54+
"oclif": "^4.23.8",
5555
"shx": "^0.4.0",
5656
"ts-node": "^10.9.2",
5757
"tslib": "^2.8.1",

packages/contentstack-apps-cli/test/helpers/init.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,15 @@ process.env.NODE_ENV = 'development'
44

55
global.oclif = global.oclif || {}
66
global.oclif.columns = 80
7-
global.commonMock = require(path.join(__dirname, '../unit/mock/common.mock.json'))
7+
global.commonMock = require(path.join(__dirname, '../unit/mock/common.mock.json'))
8+
9+
// Set a mock region so tests that call configHandler.get('region') or
10+
// getDeveloperHubUrl() at module-load time don't throw in CI environments
11+
const { configHandler } = require('@contentstack/cli-utilities')
12+
if (!configHandler.get('region')) {
13+
configHandler.set('region', {
14+
name: 'NA',
15+
cma: 'https://api.contentstack.io',
16+
cda: 'https://cdn.contentstack.io',
17+
})
18+
}

packages/contentstack-apps-cli/test/unit/commands/app/deploy.test.ts

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,12 @@ import sinon from "sinon";
99
import { stubAuthentication } from "../../helpers/auth-stub-helper";
1010
import Deploy from "../../../../src/commands/app/deploy";
1111
import { BaseCommand } from "../../../../src/base-command";
12-
import { join } from "path";
12+
import * as libCommonUtils from "../../../../src/util/common-utils";
13+
import * as libInquirer from "../../../../src/util/inquirer";
1314

1415
const region = configHandler.get("region");
15-
// Commands run from lib/ (oclif.commands); stub the same classes/modules the running command uses
16-
let BaseCommandToStub: typeof BaseCommand;
17-
let LibDeploy: typeof Deploy;
18-
let libCommonUtils: any;
19-
let libInquirer: any;
20-
try {
21-
BaseCommandToStub = require(join(process.cwd(), "lib", "base-command")).BaseCommand;
22-
} catch {
23-
BaseCommandToStub = BaseCommand;
24-
}
25-
try {
26-
LibDeploy = require(join(process.cwd(), "lib", "commands", "app", "deploy")).default;
27-
} catch {
28-
LibDeploy = Deploy;
29-
}
30-
try {
31-
libCommonUtils = require(join(process.cwd(), "lib", "util", "common-utils"));
32-
} catch {
33-
libCommonUtils = require("../../../../src/util/common-utils");
34-
}
35-
try {
36-
libInquirer = require(join(process.cwd(), "lib", "util", "inquirer"));
37-
} catch {
38-
libInquirer = require("../../../../src/util/inquirer");
39-
}
16+
const BaseCommandToStub = BaseCommand;
17+
const LibDeploy = Deploy;
4018
const developerHubBaseUrl = getDeveloperHubUrl();
4119

4220
describe("app:deploy", () => {
@@ -76,7 +54,7 @@ describe("app:deploy", () => {
7654
sandbox.stub(libInquirer, "getAppUrl").resolves("https://example.com");
7755
sandbox.stub(libInquirer, "askProjectType").resolves("existing");
7856
sandbox.stub(libInquirer, "askConfirmation").resolves(false);
79-
sandbox.stub(libInquirer, "selectProject").resolves(null);
57+
sandbox.stub(libInquirer, "selectProject").resolves(undefined);
8058
sandbox.stub(libInquirer, "askProjectName").resolves("test-project");
8159

8260
// Stub Launch.run
@@ -355,14 +333,15 @@ describe("app:deploy", () => {
355333
sandbox.stub(libInquirer, "askProjectType").resolves("new");
356334
sandbox.stub(libInquirer, "askProjectName").resolves("new-project");
357335
sandbox.stub(libInquirer, "askConfirmation").resolves(false);
358-
sandbox.stub(libInquirer, "selectProject").resolves(null);
336+
sandbox.stub(libInquirer, "selectProject").resolves(undefined);
359337

360338
sandbox.stub(libCommonUtils, "getProjects").resolves([
361339
{
362340
name: "new-project",
363341
uid: "project-2",
364342
url: "https://new-project.com",
365343
environmentUid: "env-2",
344+
developerHubAppUid: null,
366345
},
367346
]);
368347
sandbox.stub(libCommonUtils, "setupConfig").returns({

packages/contentstack-apps-cli/test/unit/commands/app/update.test.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { join } from "path";
21
import { expect } from "chai";
32
import { cliux, configHandler } from "@contentstack/cli-utilities";
43
import { runCommand } from "@oclif/test";
@@ -8,25 +7,16 @@ import manifestData from "../../config/manifest.json";
87
import sinon from "sinon";
98
import nock from "nock";
109
import fs from "fs";
10+
import { join } from "path";
1111
import { stubAuthentication } from "../../helpers/auth-stub-helper";
1212
import Update from "../../../../src/commands/app/update";
1313
import { BaseCommand } from "../../../../src/base-command";
1414

1515
const region = configHandler.get("region");
1616

17-
// Commands run from lib/ (oclif); stub the same class the running command uses
18-
let BaseCommandToStub: typeof BaseCommand;
19-
let LibUpdate: typeof Update;
20-
try {
21-
BaseCommandToStub = require(join(process.cwd(), "lib", "base-command")).BaseCommand;
22-
} catch {
23-
BaseCommandToStub = BaseCommand;
24-
}
25-
try {
26-
LibUpdate = require(join(process.cwd(), "lib", "commands", "app", "update")).default;
27-
} catch {
28-
LibUpdate = Update;
29-
}
17+
// oclif loads commands from src/ (ts-node is registered), so stub the src classes directly
18+
const BaseCommandToStub = BaseCommand;
19+
const LibUpdate = Update;
3020

3121
/** Optional override: return a custom marketplace SDK mock for this test. */
3222
let marketplaceMockOverride: any = null;

packages/contentstack-asset-management/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"eslint-config-oclif": "^6.0.68",
5151
"mocha": "^10.8.2",
5252
"nyc": "^15.1.0",
53-
"oclif": "^4.17.46",
53+
"oclif": "^4.23.8",
5454
"sinon": "^17.0.1",
5555
"source-map-support": "^0.5.21",
5656
"ts-node": "^10.9.2",

packages/contentstack-audit/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"dependencies": {
2121
"@contentstack/cli-command": "~2.0.0-beta.7",
2222
"@contentstack/cli-utilities": "~2.0.0-beta.8",
23-
"@oclif/core": "^4.3.0",
23+
"@oclif/core": "^4.11.4",
2424
"chalk": "^5.6.2",
2525
"fast-csv": "^4.3.6",
2626
"fs-extra": "^11.3.0",
@@ -39,7 +39,7 @@
3939
"eslint-config-oclif-typescript": "^3.1.14",
4040
"mocha": "^10.8.2",
4141
"nyc": "^15.1.0",
42-
"oclif": "^4.17.46",
42+
"oclif": "^4.23.8",
4343
"shx": "^0.4.0",
4444
"sinon": "^21.0.1",
4545
"ts-node": "^10.9.2",

packages/contentstack-bootstrap/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
"@contentstack/cli-command": "~2.0.0-beta.7",
2121
"@contentstack/cli-utilities": "~2.0.0-beta.8",
2222
"@contentstack/cli-config": "~2.0.0-beta.10",
23-
"@oclif/core": "^4.3.0",
23+
"@oclif/core": "^4.11.4",
2424
"inquirer": "12.11.1",
2525
"mkdirp": "^2.1.6",
26-
"tar": "^7.5.11"
26+
"tar": "^7.5.15"
2727
},
2828
"devDependencies": {
2929
"@oclif/test": "^4.1.18",
@@ -35,7 +35,7 @@
3535
"eslint": "^9.26.0",
3636
"mocha": "10.8.2",
3737
"nyc": "^15.1.0",
38-
"oclif": "^4.17.46",
38+
"oclif": "^4.23.8",
3939
"tmp": "^0.2.5",
4040
"ts-node": "^8.10.2",
4141
"typescript": "^5.9.3"

packages/contentstack-branches/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"bugs": "https://github.com/contentstack/cli/issues",
77
"dependencies": {
88
"@contentstack/cli-command": "~2.0.0-beta.7",
9-
"@oclif/core": "^4.3.0",
9+
"@oclif/core": "^4.11.4",
1010
"@contentstack/cli-utilities": "~2.0.0-beta.8",
1111
"chalk": "^5.6.2",
1212
"just-diff": "^6.0.2",
@@ -20,7 +20,7 @@
2020
"eslint-config-oclif": "^6.0.62",
2121
"mocha": "10.8.2",
2222
"nyc": "^15.1.0",
23-
"oclif": "^4.17.46",
23+
"oclif": "^4.23.8",
2424
"sinon": "^21.0.1",
2525
"ts-node": "^10.9.2",
2626
"typescript": "^4.9.5"

0 commit comments

Comments
 (0)