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
19 changes: 14 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,20 @@ 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

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 @@ -8,7 +8,7 @@ export default class MigrateConvert extends Command {

static examples = [
'$ csdx migrate:convert --legacy contentful --input ./export.json --output ./contentstack-import',
'$ csdx migrate:convert -l contentful -i ../references/contentful-export-*.json -o ./contentstack-import -m en-US',
'$ csdx migrate:convert -l contentful -i ../references/contentful-export-*.json --output ./contentstack-import --master-locale en-US',
];
static hidden = true;
static flags: FlagInput = {
Expand All @@ -23,16 +23,13 @@ export default class MigrateConvert extends Command {
description: 'Path to legacy export JSON (e.g. Contentful export)',
}),
output: flags.string({
char: 'o',
description: 'Parent output directory; bundle written to <output>/bundle',
default: './contentstack-import',
}),
'master-locale': flags.string({
char: 'm',
description: 'Destination master locale code',
}),
affix: flags.string({
char: 'a',
description: 'Content-type UID prefix',
default: '',
}),
Comment on lines 32 to 35
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export default class MigrateExport extends Command {
description: 'Contentful CMA token (prefer CONTENTFUL_MANAGEMENT_TOKEN env)',
}),
output: flags.string({
char: 'o',
description: 'Migration workspace root (writes export.json here)',
default: './migration-workspace',
}),
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
5 changes: 5 additions & 0 deletions packages/contentstack-seed/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ module.exports = {
'^.+\\.(ts|tsx)$': ['ts-jest', {
tsconfig: 'tsconfig.test.json',
}],
'(node_modules/.pnpm/uuid@[^/]+/node_modules/uuid|node_modules/uuid)/.+\\.js$': [
'babel-jest',
{ presets: [['@babel/preset-env', { modules: 'commonjs' }]] },
],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
testEnvironment: 'node',
Expand All @@ -16,4 +20,5 @@ module.exports = {
'^@/(.*)$': '<rootDir>/src/$1',
},
testPathIgnorePatterns: ['/node_modules/', '/old_tests/'],
transformIgnorePatterns: ['/node_modules/(?!(.pnpm/uuid@[^/]+/node_modules/)?uuid/)'],
};
Loading