Skip to content
Merged
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
4 changes: 4 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ jobs:
- name: Run tests for Contentstack Export To CSV
working-directory: ./packages/contentstack-export-to-csv
run: npm run test:unit

- name: Run tests for Contentstack Bootstrap
working-directory: ./packages/contentstack-bootstrap
run: npm run test
# - name: Fetch latest references
# run: |
# git fetch --prune
Expand Down
8 changes: 6 additions & 2 deletions .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,16 @@ fileignoreconfig:
checksum: 8cbd32dbbd2989c7c082f8a0b7615916125d211bce25531e9a882b8ebd5674af
- filename: .husky/pre-commit
checksum: 7a12030ddfea18d6f85edc25f1721fb2009df00fdd42bab66b05de25ab3e32b2
- filename: packages/contentstack-bootstrap/src/bootstrap/utils.ts
checksum: 0b0af505ce1a74eb8df519f106291e319eb3ea74003ca63e03527f59a8821d39
- filename: packages/contentstack-bootstrap/test/bootstrap.test.js
checksum: 5f0355a5048183d61b605cbc160e6727a9de32832d9159e903fee49f9ab751d5
- filename: packages/contentstack/package.json
checksum: 9b0fdd100effcdbb5ee3809f7f102bfd11c88dd76e49db5103434f3aa29473dd
- filename: pnpm-lock.yaml
checksum: 2edf846869b73d6fd640d9f660f9fdd664e721946a891554dad5297c75a1bfba
checksum: 9af6cb44ebbfeee5c456e0518e7f4023c8fb70ce994b98fc2bf8967633205bac
- filename: package-lock.json
checksum: 0c00a0335d48791b0736aae44c900c3e729de728c0bb62489d0697c9a2ed4200
checksum: 9b24bc901be3b211661a46bbe72d03eda7ad9e6842e79d7419935da98600f11c
- filename: packages/contentstack-migrate-rte/test/commands/json-migration.test.js
checksum: 1f5ee5b39119667bd4830f9dbbbf757fb922f4ec3b7f6fad06bbfbf214fe7f73
version: '1.0'
19,828 changes: 11,218 additions & 8,610 deletions package-lock.json

Large diffs are not rendered by default.

36 changes: 32 additions & 4 deletions packages/contentstack-bootstrap/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,41 @@
{
"extends": [
"oclif",
"oclif-typescript"
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:mocha/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"mocha"
],
"rules": {
"unicorn/no-abusive-eslint-disable": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"indent": "off",
"object-curly-spacing": "off"
}
"object-curly-spacing": "off",
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"mocha/no-async-describe": "off",
"mocha/no-identical-title": "off",
"mocha/no-mocha-arrows": "off",
"mocha/no-setup-in-describe": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-var-requires": "off",
"prefer-const": "error",
"no-fallthrough": "error",
"no-prototype-builtins": "off"
},
"env": {
"node": true,
"mocha": true
},
"overrides": [
{
"files": ["*.d.ts"],
"rules": {
"@typescript-eslint/no-explicit-any": "off"
}
}
]
}
2 changes: 1 addition & 1 deletion packages/contentstack-bootstrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $ npm install -g @contentstack/cli-cm-bootstrap
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-cm-bootstrap/1.14.0 darwin-arm64 node-v22.14.0
@contentstack/cli-cm-bootstrap/1.14.1 darwin-arm64 node-v22.14.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-bootstrap/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-cm-bootstrap",
"description": "Bootstrap contentstack apps",
"version": "1.14.0",
"version": "1.14.1",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as path from 'path';
const inquirer = require('inquirer');
import { cliux, pathValidator } from '@contentstack/cli-utilities';

Expand Down Expand Up @@ -109,4 +108,4 @@ export async function continueBootstrapCommand() {
loop: false,
});
return shouldContinue;
}
}
87 changes: 43 additions & 44 deletions packages/contentstack-bootstrap/src/bootstrap/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,48 +36,46 @@ export const setupEnvironments = async (
.find();

//create management token if not present
if(!managementToken){
if (!managementToken) {
const managementBody = {
"token":{
"name":"sample app",
"description":"This is a sample management token.",
"scope":[
{
"module":"content_type",
"acl":{
"read":true,
"write":true
}
},
{
"module":"branch",
"branches":[
"main"
],
"acl":{
"read":true
}
}
],
"expires_on": "3000-01-01",
"is_email_notification_enabled":false
}
}
managementTokenResult = await managementAPIClient
.stack({ api_key: api_key })
.managementToken()
.create(managementBody);
if(!managementTokenResult.uid){
cliux.print(
`Info: Failed to generate a management token.\nNote: Management token is not available in your plan. Please contact the admin for support.`,
{
color: 'yellow',
token: {
name: 'sample app',
description: 'This is a sample management token.',
scope: [
{
module: 'content_type',
acl: {
read: true,
write: true,
},
},
{
module: 'branch',
branches: ['main'],
acl: {
read: true,
},
},
],
expires_on: '3000-01-01',
is_email_notification_enabled: false,
},
);
if ((await continueBootstrapCommand()) === 'no') {
return;
};
managementTokenResult = await managementAPIClient
.stack({ api_key: api_key })
.managementToken()
.create(managementBody);
if (!managementTokenResult.uid) {
cliux.print(
`Info: Failed to generate a management token.\nNote: Management token is not available in your plan. Please contact the admin for support.`,
{
color: 'yellow',
},
);
if ((await continueBootstrapCommand()) === 'no') {
return;
}
}
}
}
if (Array.isArray(environmentResult.items) && environmentResult.items.length > 0) {
for (const environment of environmentResult.items) {
Expand Down Expand Up @@ -184,13 +182,11 @@ const envFileHandler = async (
let filePath;
let fileName;
let customHost;
let previewHost: string;
let appHost: string;
const managementAPIHost = region?.cma?.substring('8');
const regionName = region && region.name && region.name.toLowerCase();
previewHost = region?.uiHost?.substring(8)?.replace('app', 'rest-preview');
const previewHost = region?.uiHost?.substring(8)?.replace('app', 'rest-preview');
const cdnHost = region?.cda?.substring('8');
appHost = region?.uiHost?.substring(8);
const appHost = region?.uiHost?.substring(8);
const isUSRegion = regionName === 'us' || regionName === 'na';
if (regionName !== 'eu' && !isUSRegion) {
customHost = region?.cma?.substring(8);
Expand Down Expand Up @@ -252,8 +248,11 @@ const envFileHandler = async (
customHost ? customHost : managementAPIHost
}${
!isUSRegion && !customHost ? '\nCONTENTSTACK_REGION=' + region.name : ''
}\nCONTENTSTACK_APP_HOST=${appHost}\nCONTENTSTACK_MANAGEMENT_TOKEN=${managementTokenResult.uid}\nCONTENTSTACK_HOST=${cdnHost}`;
}\nCONTENTSTACK_APP_HOST=${appHost}\nCONTENTSTACK_MANAGEMENT_TOKEN=${
managementTokenResult.uid
}\nCONTENTSTACK_HOST=${cdnHost}`;
result = await writeEnvFile(content, filePath);
break;
case 'gatsby':
case 'gatsby-starter':
fileName = `.env.${environmentVariables.environment}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export default class BootstrapCommand extends Command {

const appConfig: AppConfig = getAppLevelConfigByName(selectedAppName || selectedApp.configKey);

let master_locale = appConfig.master_locale || DEFAULT_MASTER_LOCALE;
const master_locale = appConfig.master_locale || DEFAULT_MASTER_LOCALE;

let cloneDirectory =
(bootstrapCommandFlags.directory as string) || (bootstrapCommandFlags['project-dir'] as string);
Expand Down
Loading
Loading