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
103 changes: 103 additions & 0 deletions .github/workflows/unit-test-parallel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Run Unit Tests (Parallel)

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

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

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.28.0

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'
cache: 'pnpm'

- name: Prune pnpm store
run: pnpm store prune

- name: Install dependencies
run: pnpm install --no-frozen-lockfile

- name: Build all plugins
run: NODE_ENV=PREPACK_MODE pnpm -r --sort run build

- name: Upload workspace
uses: actions/upload-artifact@v4
with:
name: built-workspace-${{ github.sha }}
path: .
retention-days: 1
compression-level: 6

test:
needs: setup
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- package: contentstack-import
cmd: npm run test:unit
- package: contentstack-export
cmd: npm run test:unit
- package: contentstack-audit
cmd: npm run test:unit
- package: contentstack-migration
cmd: npm run test
- package: contentstack-export-to-csv
cmd: npm run test:unit
- package: contentstack-bootstrap
cmd: npm run test
- package: contentstack-import-setup
cmd: npm run test:unit
- package: contentstack-branches
cmd: npm run test:unit
- package: contentstack-query-export
cmd: npm run test:unit
- package: contentstack-apps-cli
cmd: npm run test:unit:report
- package: contentstack-content-type
cmd: npm run test:unit
- package: contentstack-cli-cm-regex-validate
cmd: npm run test:unit
- package: contentstack-migrate-rte
cmd: npm test
- package: contentstack-bulk-operations
cmd: npm test
- package: contentstack-variants
cmd: npm run test
- package: contentstack-asset-management
cmd: npm run test:unit
- package: contentstack-clone
cmd: npm run test:unit
# - package: contentstack-external-migrate # DX-9432: ESLint errors blocking CI — assigned to Netraj
# cmd: npm test
- package: contentstack-seed
cmd: npm test

steps:
- name: Download workspace
uses: actions/download-artifact@v4
with:
name: built-workspace-${{ github.sha }}
path: .

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

- name: Run tests — ${{ matrix.package }}
working-directory: ./packages/${{ matrix.package }}
run: ${{ matrix.cmd }}
22 changes: 17 additions & 5 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ jobs:
working-directory: ./packages/contentstack-bootstrap
run: npm run test

# - name: Run tests for Contentstack Import Setup
# working-directory: ./packages/contentstack-import-setup
# run: npm run test:unit

- name: Run tests for Contentstack Branches
working-directory: ./packages/contentstack-branches
run: npm run test:unit
Expand Down Expand Up @@ -86,7 +82,23 @@ jobs:
- name: Run tests for Contentstack Bulk Operations
working-directory: ./packages/contentstack-bulk-operations
run: npm test

- name: Run tests for Contentstack Variants
working-directory: ./packages/contentstack-variants
run: npm run test

- name: Run tests for Contentstack Asset Management
working-directory: ./packages/contentstack-asset-management
run: npm run test:unit

- name: Run tests for Contentstack Clone
working-directory: ./packages/contentstack-clone
run: npm run test:unit

# - name: Run tests for Contentstack External Migrate
# working-directory: ./packages/contentstack-external-migrate
# run: npm test

- name: Run tests for Contentstack Seed
working-directory: ./packages/contentstack-seed
run: npm test
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export default class Create extends BaseCommand<typeof Create> {

static flags: FlagInput = {
name: flags.string({
char: "n",
description: appCreate.NAME_DESCRIPTION,
}),
"app-type": flags.string({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default class Install extends AppCLIBaseCommand {
description: commonMsg.APP_UID,
}),
"stack-api-key": flags.string({
char: "k",
description: commonMsg.STACK_API_KEY,
}),
...AppCLIBaseCommand.baseFlags,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default class Reinstall extends AppCLIBaseCommand {
description: commonMsg.APP_UID,
}),
"stack-api-key": flags.string({
char: "k",
description: commonMsg.STACK_API_KEY,
}),
...AppCLIBaseCommand.baseFlags,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,24 @@ export default class ValidateRegex extends Command {
static examples = [
'$ csdx cm:stacks:validate-regex',
'$ csdx cm:stacks:validate-regex -a <management_token_alias>',
'$ csdx cm:stacks:validate-regex -c',
'$ csdx cm:stacks:validate-regex -g',
'$ csdx cm:stacks:validate-regex -f <path/to/the/directory>',
'$ csdx cm:stacks:validate-regex -a <management_token_alias> -c -g',
'$ csdx cm:stacks:validate-regex -a <management_token_alias> -c -g -f <path/to/the/directory>',
'$ csdx cm:stacks:validate-regex --contentType',
'$ csdx cm:stacks:validate-regex --globalField',
'$ csdx cm:stacks:validate-regex --filePath <path/to/the/directory>',
'$ csdx cm:stacks:validate-regex -a <management_token_alias> --contentType --globalField',
'$ csdx cm:stacks:validate-regex -a <management_token_alias> --contentType --globalField --filePath <path/to/the/directory>',
]
static flags: any = {
alias: flags.string({
char: 'a',
description: regexMessages.command.alias,
}),
contentType: flags.boolean({
char: 'c',
description: regexMessages.command.contentTypes,
}),
filePath: flags.string({
char: 'f',
description: regexMessages.command.filePath,
}),
globalField: flags.boolean({
char: 'g',
description: regexMessages.command.globalFields,
}),
}
Expand Down
19 changes: 8 additions & 11 deletions packages/contentstack-cli-tsgen/src/commands/tsgen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ export default class TypeScriptCodeGeneratorCommand extends Command {
static description = "Generate TypeScript typings from a Stack";

static examples = [
'$ csdx tsgen -a "delivery token alias" -o "contentstack/generated.d.ts"',
'$ csdx tsgen -a "delivery token alias" -o "contentstack/generated.d.ts" -p "I"',
'$ csdx tsgen -a "delivery token alias" -o "contentstack/generated.d.ts" --no-doc',
'$ csdx tsgen -a "delivery token alias" -o "contentstack/generated.d.ts" --include-referenced-entry',
'$ csdx tsgen -a "delivery token alias" -o "contentstack/generated.d.ts" --api-type graphql',
'$ csdx tsgen -a "delivery token alias" -o "contentstack/generated.d.ts" --api-type graphql --namespace "GraphQL" ',
'$ csdx tsgen -a "delivery token alias" --output "contentstack/generated.d.ts"',
'$ csdx tsgen -a "delivery token alias" --output "contentstack/generated.d.ts" --prefix "I"',
'$ csdx tsgen -a "delivery token alias" --output "contentstack/generated.d.ts" --no-doc',
'$ csdx tsgen -a "delivery token alias" --output "contentstack/generated.d.ts" --include-referenced-entry',
'$ csdx tsgen -a "delivery token alias" --output "contentstack/generated.d.ts" --api-type graphql',
'$ csdx tsgen -a "delivery token alias" --output "contentstack/generated.d.ts" --api-type graphql --namespace "GraphQL" ',
];

// Check if a region is a default Contentstack region
Expand All @@ -46,7 +46,7 @@ export default class TypeScriptCodeGeneratorCommand extends Command {
}

static flags: FlagInput = {
"token-alias": flags.string({
alias: flags.string({
char: "a",
description: "delivery token alias",
hidden: false,
Expand All @@ -55,15 +55,13 @@ export default class TypeScriptCodeGeneratorCommand extends Command {
}),
Comment on lines 48 to 55

output: flags.string({
char: "o",
description: "full path to output",
hidden: false,
multiple: false,
required: true,
}),

prefix: flags.string({
char: "p",
description: 'interface prefix, e.g. "I"',
hidden: false,
multiple: false,
Expand All @@ -72,7 +70,6 @@ export default class TypeScriptCodeGeneratorCommand extends Command {
}),

doc: flags.boolean({
char: "d",
description: "include documentation comments",
default: true,
allowNo: true,
Expand Down Expand Up @@ -118,7 +115,7 @@ export default class TypeScriptCodeGeneratorCommand extends Command {
try {
const { flags } = await this.parse(TypeScriptCodeGeneratorCommand);

const token = this.getToken(flags["token-alias"]);
const token = this.getToken(flags["alias"]);
const prefix = flags.prefix;
const includeDocumentation = flags.doc;
const filePath = flags.output;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("Integration Test for tsgen command", () => {
// Test case 1: Generate TypeScript types with default flags
it("should generate TypeScript types with the default flags", () => {
const cmd = "csdx";
const args = ["tsgen", "-a", tokenAlias!, "-o", outputFilePath];
const args = ["tsgen", "-a", tokenAlias!, "--output", outputFilePath];

const result = spawnSync(cmd, args, { encoding: "utf-8" });

Expand All @@ -44,9 +44,9 @@ describe("Integration Test for tsgen command", () => {
"tsgen",
"-a",
tokenAlias!,
"-o",
"--output",
outputFilePath,
"-p",
"--prefix",
prefix,
];

Expand All @@ -72,7 +72,7 @@ describe("Integration Test for tsgen command", () => {
// Test case 3: Generate TypeScript types without documentation comments
it("should generate TypeScript types without documentation", () => {
const cmd = "csdx";
const args = ["tsgen", "-a", tokenAlias!, "-o", outputFilePath, "--no-doc"];
const args = ["tsgen", "-a", tokenAlias!, "--output", outputFilePath, "--no-doc"];

const result = spawnSync(cmd, args, { encoding: "utf-8" });

Expand All @@ -90,7 +90,7 @@ describe("Integration Test for tsgen command", () => {
"tsgen",
"-a",
tokenAlias!,
"-o",
"--output",
outputFilePath,
"--include-system-fields",
];
Expand All @@ -108,7 +108,7 @@ describe("Integration Test for tsgen command", () => {
// Test case 5: Handling of invalid token alias
it("should fail with an invalid token alias", () => {
const cmd = "csdx";
const args = ["tsgen", "-a", "invalid_alias", "-o", outputFilePath];
const args = ["tsgen", "-a", "invalid_alias", "--output", outputFilePath];

const result = spawnSync(cmd, args, { encoding: "utf-8" });

Expand All @@ -124,7 +124,7 @@ describe("Integration Test for tsgen command", () => {
"tsgen",
"-a",
tokenAlias!,
"-o",
"--output",
outputFilePath,
"--api-type",
"graphql",
Expand All @@ -147,7 +147,7 @@ describe("Integration Test for tsgen command", () => {
"tsgen",
"-a",
tokenAlias!,
"-o",
"--output",
outputFilePath,
"--api-type",
"graphql",
Expand All @@ -171,7 +171,7 @@ describe("Integration Test for tsgen command", () => {
"tsgen",
"-a",
"invalid_alias",
"-o",
"--output",
outputFilePath,
"--api-type",
"graphql",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export default class MigrateConvert extends Command {
description: 'Destination master locale code',
}),
affix: flags.string({
char: 'a',
description: 'Content-type UID prefix',
default: '',
}),
Comment on lines 34 to 37
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ export default class MigrationCommand extends Command {

// To be deprecated
'api-key': flags.string({
char: 'k',
description: 'With this flag add the API key of your stack.',
// dependsOn: ['authtoken'],
exclusive: ['alias'],
Expand Down
Loading