Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6904947
Merge pull request #373 from contentstack/main
cs-raj Apr 29, 2025
5f26db2
used marketplaceSDK instead of managementSDK for app related operations
Jul 10, 2025
f5d45d0
used marketplaceSDK to update the app
Jul 15, 2025
f58d35b
fixed test cases, linter errors and added workflow for unit test cases
Jul 15, 2025
fe10afa
update imports
Jul 15, 2025
4a566e7
updated workflow file
Jul 15, 2025
2b4a0a4
updated workflow file
Jul 15, 2025
01327ab
updated workflow file
Jul 15, 2025
6bdf5e7
commented the GH action, as it needs to be setup
Jul 17, 2025
600e816
Update sca-scan.yml
aravindbuilt Jul 17, 2025
364bcf1
minor version bump
Jul 17, 2025
0733834
updated error logging based on comments
Jul 17, 2025
cc27c96
Merge pull request #377 from contentstack/enhancement/DX-416
naman-contentstack Jul 21, 2025
dc16108
updat testcases and add GH pipeline for it
Jul 24, 2025
76188a0
version bump
Jul 24, 2025
7332748
created a helper file for stubbing authentication
Jul 24, 2025
1614a2e
update eslintrc
Jul 24, 2025
3764c7e
Merge pull request #378 from contentstack/enhancement/DX-3285
naman-contentstack Jul 24, 2025
37e886c
revert version
Jul 24, 2025
74733e9
Merge pull request #379 from contentstack/revert_version
naman-contentstack Jul 24, 2025
b4a7f9c
Merge pull request #380 from contentstack/development
harshithad0703 Jul 24, 2025
d19ebc3
Merge branch 'staging' into fix/talismanrc-update
harshithad0703 Jul 24, 2025
b5a7539
update talisman
harshithad0703 Jul 24, 2025
ce5325f
Merge pull request #383 from contentstack/fix/talismanrc-update
aman19K Jul 24, 2025
a566a8c
update .talismanrc to include additional fileignoreconfig entries
harshithad0703 Jul 24, 2025
b49a74e
Merge pull request #384 from contentstack/fix/talismanrc-update
harshithad0703 Jul 24, 2025
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
4 changes: 2 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"id-match": "error",
"no-eval": "error",
"no-var": "error",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-require-imports": "warn",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-require-imports": "off",
"prefer-const": "error"
}
}
44 changes: 22 additions & 22 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
# name: Run Unit Tests
name: Run Unit Tests

# on:
# pull_request:
# types: [opened, synchronize, reopened]
on:
pull_request:
types: [opened, synchronize, reopened]

# jobs:
# run-tests:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

# - name: Set up Node.js
# uses: actions/setup-node@v4
# with:
# node-version: "22.x"
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22.x"

# - name: Install dependencies
# run: |
# npm install
# npm install -g @contentstack/cli
- name: Install dependencies
run: |
npm install
npm install -g @contentstack/cli

# - name: Configure Region
# run: csdx config:set:region AWS-NA
- name: Configure Region
run: csdx config:set:region AWS-NA

# - name: Run tests
# run: npm run test
- name: Run tests
run: npm run test
42 changes: 23 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,34 @@ $ csdx plugins:install @contentstack/apps-cli
This plugin requires you to be authenticated using [csdx auth:login](https://www.contentstack.com/docs/developers/cli/authenticate-with-the-cli/).

<!-- usage -->

```sh-session
$ npm install -g @contentstack/apps-cli
$ csdx COMMAND
running command...
$ csdx (--version|-v)
@contentstack/apps-cli/1.5.0 darwin-arm64 node-v22.13.1
@contentstack/apps-cli/1.6.1 darwin-arm64 node-v22.13.1
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
...
```

<!-- usagestop -->

# Commands

<!-- commands -->
* [`csdx app`](#csdx-app)
* [`csdx app:create`](#csdx-appcreate)
* [`csdx app:delete`](#csdx-appdelete)
* [`csdx app:deploy`](#csdx-appdeploy)
* [`csdx app:get`](#csdx-appget)
* [`csdx app:install`](#csdx-appinstall)
* [`csdx app:reinstall`](#csdx-appreinstall)
* [`csdx app:uninstall`](#csdx-appuninstall)
* [`csdx app:update`](#csdx-appupdate)

- [`csdx app`](#csdx-app)
- [`csdx app:create`](#csdx-appcreate)
- [`csdx app:delete`](#csdx-appdelete)
- [`csdx app:deploy`](#csdx-appdeploy)
- [`csdx app:get`](#csdx-appget)
- [`csdx app:install`](#csdx-appinstall)
- [`csdx app:reinstall`](#csdx-appreinstall)
- [`csdx app:uninstall`](#csdx-appuninstall)
- [`csdx app:update`](#csdx-appupdate)

## `csdx app`

Expand Down Expand Up @@ -71,7 +74,7 @@ EXAMPLES
$ csdx app:update
```

_See code: [src/commands/app/index.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/index.ts)_
_See code: [src/commands/app/index.ts](https://github.com/contentstack/apps-cli/blob/v1.6.0/src/commands/app/index.ts)_

## `csdx app:create`

Expand Down Expand Up @@ -111,7 +114,7 @@ EXAMPLES
$ csdx app:create --name App-4 --app-type organization --org <UID> --boilerplate <Ecommerce App Boilerplate>
```

_See code: [src/commands/app/create.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/create.ts)_
_See code: [src/commands/app/create.ts](https://github.com/contentstack/apps-cli/blob/v1.6.0/src/commands/app/create.ts)_

## `csdx app:delete`

Expand All @@ -136,7 +139,7 @@ EXAMPLES
$ csdx app:delete --app-uid <value> --org <value> -d ./boilerplate
```

_See code: [src/commands/app/delete.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/delete.ts)_
_See code: [src/commands/app/delete.ts](https://github.com/contentstack/apps-cli/blob/v1.6.0/src/commands/app/delete.ts)_

## `csdx app:deploy`

Expand Down Expand Up @@ -174,7 +177,7 @@ EXAMPLES
$ csdx app:deploy --org <UID> --app-uid <APP-UID-1> --hosting-type <hosting-with-launch> --launch-project <new> --config <config-path>
```

_See code: [src/commands/app/deploy.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/deploy.ts)_
_See code: [src/commands/app/deploy.ts](https://github.com/contentstack/apps-cli/blob/v1.6.0/src/commands/app/deploy.ts)_

## `csdx app:get`

Expand Down Expand Up @@ -204,7 +207,7 @@ EXAMPLES
$ csdx app:get --org <value> --app-uid <value> --app-type organization
```

_See code: [src/commands/app/get.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/get.ts)_
_See code: [src/commands/app/get.ts](https://github.com/contentstack/apps-cli/blob/v1.6.0/src/commands/app/get.ts)_

## `csdx app:install`

Expand All @@ -230,7 +233,7 @@ EXAMPLES
$ csdx app:install --org <UID> --app-uid <APP-UID-1> --stack-api-key <STACK-API-KEY-1>
```

_See code: [src/commands/app/install.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/install.ts)_
_See code: [src/commands/app/install.ts](https://github.com/contentstack/apps-cli/blob/v1.6.0/src/commands/app/install.ts)_

## `csdx app:reinstall`

Expand All @@ -256,7 +259,7 @@ EXAMPLES
$ csdx app:reinstall --org <UID> --app-uid <APP-UID-1> --stack-api-key <STACK-API-KEY-1>
```

_See code: [src/commands/app/reinstall.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/reinstall.ts)_
_See code: [src/commands/app/reinstall.ts](https://github.com/contentstack/apps-cli/blob/v1.6.0/src/commands/app/reinstall.ts)_

## `csdx app:uninstall`

Expand All @@ -283,7 +286,7 @@ EXAMPLES
$ csdx app:uninstall --org <UID> --app-uid <APP-UID-1> --installation-uid <INSTALLATION-UID-1>
```

_See code: [src/commands/app/uninstall.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/uninstall.ts)_
_See code: [src/commands/app/uninstall.ts](https://github.com/contentstack/apps-cli/blob/v1.6.0/src/commands/app/uninstall.ts)_

## `csdx app:update`

Expand All @@ -306,5 +309,6 @@ EXAMPLES
$ csdx app:update --app-manifest ./boilerplate/manifest.json
```

_See code: [src/commands/app/update.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/update.ts)_
_See code: [src/commands/app/update.ts](https://github.com/contentstack/apps-cli/blob/v1.6.0/src/commands/app/update.ts)_

<!-- commandsstop -->
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/apps-cli",
"version": "1.6.0",
"version": "1.6.1",
"description": "App ClI",
"author": "Contentstack CLI",
"homepage": "https://github.com/contentstack/contentstack-apps-cli",
Expand Down
4 changes: 4 additions & 0 deletions test/unit/commands/app/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ 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";

const { origin, pathname } = new URL(config.appBoilerplateGithubUrl);
const zipPath = join(process.cwd(), "test", "unit", "mock", "boilerplate.zip");
Expand All @@ -36,6 +37,9 @@ describe("app:create", () => {
sandbox = sinon.createSandbox();
axios.defaults.adapter = "http";

// Stub authentication using shared helper
stubAuthentication(sandbox);

writeStreamMock = new MockWriteStream();
sandbox.stub(fs, "renameSync").callsFake(() => {});
sandbox.stub(fs, "createWriteStream").callsFake(() => writeStreamMock);
Expand Down
5 changes: 5 additions & 0 deletions test/unit/commands/app/delete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ 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";

const region: { cma: string; name: string; cda: string } =
configHandler.get("region");
Expand All @@ -15,6 +16,10 @@ describe("app:delete", () => {
let sandbox: sinon.SinonSandbox;
beforeEach(() => {
sandbox = sinon.createSandbox();

// Stub authentication using shared helper
stubAuthentication(sandbox);

nock(region.cma)
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
.reply(200, { organizations: mock.organizations });
Expand Down
15 changes: 3 additions & 12 deletions test/unit/commands/app/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ 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";

const region = configHandler.get("region");
const developerHubBaseUrl = getDeveloperHubUrl();
Expand All @@ -16,18 +17,8 @@ describe("app:deploy", () => {
beforeEach(() => {
sandbox = sinon.createSandbox();

// Stub authentication
sandbox.stub(configHandler, "get").returns({
cma: "https://api.contentstack.io",
cda: "https://cdn.contentstack.io",
region: "us",
});
sandbox
.stub(
require("../../../../src/base-command").BaseCommand.prototype,
"validateRegionAndAuth"
)
.callsFake(() => {});
// Stub authentication using shared helper
stubAuthentication(sandbox);

sandbox.stub(cliux, "loader").callsFake(() => {});
sandbox.stub(cliux, "inquire").callsFake((prompt: any) => {
Expand Down
5 changes: 5 additions & 0 deletions test/unit/commands/app/get.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ 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";

const region = configHandler.get("region");
const developerHubBaseUrl = getDeveloperHubUrl();
Expand All @@ -20,6 +21,10 @@ describe("app:get", () => {

beforeEach(() => {
sandbox = sinon.createSandbox();

// Stub authentication using shared helper
stubAuthentication(sandbox);

sandbox.stub(cliux, "loader").callsFake(() => {});
sandbox.stub(fs, "writeFileSync").callsFake(() => {});
});
Expand Down
4 changes: 4 additions & 0 deletions test/unit/commands/app/install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ 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";

const region = configHandler.get("region");
const developerHubBaseUrl = getDeveloperHubUrl();
Expand All @@ -18,6 +19,9 @@ describe("app:install", () => {
sandbox = sinon.createSandbox();
axios.defaults.adapter = "http";

// Stub authentication using shared helper
stubAuthentication(sandbox);

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

nock(region.cma)
Expand Down
4 changes: 4 additions & 0 deletions test/unit/commands/app/reinstall.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { cliux, configHandler } 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";

const region = configHandler.get("region");
const developerHubBaseUrl = getDeveloperHubUrl();
Expand All @@ -16,6 +17,9 @@ describe("app:reinstall", () => {
beforeEach(() => {
sandbox = sinon.createSandbox();

// Stub authentication using shared helper
stubAuthentication(sandbox);

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

nock(region.cma)
Expand Down
5 changes: 5 additions & 0 deletions test/unit/commands/app/uninstall.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { cliux, configHandler } from "@contentstack/cli-utilities";
import messages, { $t } from "../../../../src/messages";
import { getDeveloperHubUrl } from "../../../../src/util/inquirer";
import * as mock from "../../mock/common.mock.json";
import { stubAuthentication } from "../../helpers/auth-stub-helper";

const region = configHandler.get("region");
const developerHubBaseUrl = getDeveloperHubUrl();
Expand All @@ -15,6 +16,10 @@ describe("app:uninstall", () => {

beforeEach(() => {
sandbox = sinon.createSandbox();

// Stub authentication using shared helper
stubAuthentication(sandbox);

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

nock(region.cma)
Expand Down
17 changes: 3 additions & 14 deletions test/unit/commands/app/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { getDeveloperHubUrl } from "../../../../src/util/inquirer";
import sinon from "sinon";
import nock from "nock";
import fs from "fs";
import { stubAuthentication } from "../../helpers/auth-stub-helper";

const region = configHandler.get("region");
const developerHubBaseUrl = getDeveloperHubUrl();
Expand All @@ -19,20 +20,8 @@ describe("app:update", () => {
beforeEach(() => {
sandbox = sinon.createSandbox();

// Stub authentication
sandbox.stub(configHandler, "get").returns({
cma: "https://api.contentstack.io",
cda: "https://cdn.contentstack.io",
region: "us",
});

// Stub the validateRegionAndAuth method to skip authentication check
sandbox
.stub(
require("../../../../src/base-command").BaseCommand.prototype,
"validateRegionAndAuth"
)
.callsFake(() => {});
// Stub authentication using shared helper
stubAuthentication(sandbox);

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