Skip to content

Chore/add kickstarts to bootstrap #1980

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: development
Choose a base branch
from
Draft
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
27 changes: 15 additions & 12 deletions .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -111,28 +111,31 @@ fileignoreconfig:
- filename: .husky/pre-commit
checksum: 7a12030ddfea18d6f85edc25f1721fb2009df00fdd42bab66b05de25ab3e32b2
- filename: packages/contentstack-bootstrap/src/bootstrap/utils.ts
checksum: 0b0af505ce1a74eb8df519f106291e319eb3ea74003ca63e03527f59a8821d39
checksum: 2845a5fc50cbe46591868c64d2105f9befbddfb27a547a8a68ada93071845df4
- filename: packages/contentstack-bootstrap/test/bootstrap.test.js
checksum: 5f0355a5048183d61b605cbc160e6727a9de32832d9159e903fee49f9ab751d5
checksum: c19fb9af02f858f92f66408d54343fcb84140b1050c492570f53fc9406f416f4
- filename: packages/contentstack/package.json
checksum: 9b0fdd100effcdbb5ee3809f7f102bfd11c88dd76e49db5103434f3aa29473dd
- filename: pnpm-lock.yaml
checksum: cb5c86b02ad84cbd3f0d0bd8ca2acd40ce3f87c59450331ab204f8fba5043a0d
- filename: packages/contentstack-audit/src/audit-base-command.ts
checksum: bd99d269c0b6694577f4751fa96b3d85856e41bbef624b4ec1196630d6c1d168
- filename: packages/contentstack-migrate-rte/test/commands/json-migration.test.js
checksum: 1f5ee5b39119667bd4830f9dbbbf757fb922f4ec3b7f6fad06bbfbf214fe7f73
- filename: packages/contentstack-bootstrap/src/bootstrap/utils.ts
checksum: 0b0af505ce1a74eb8df519f106291e319eb3ea74003ca63e03527f59a8821d39
- filename: packages/contentstack-bootstrap/test/bootstrap.test.js
checksum: 5f0355a5048183d61b605cbc160e6727a9de32832d9159e903fee49f9ab751d5
- filename: package-lock.json
checksum: 791af8308bb250145dd7328852d20f0ee8cb2f4b8085ab9c79e382e729f81697
- filename: packages/contentstack-utilities/test/unit/logger.test.ts
checksum: c773181ea55c49d91363adacf0424b84c927e3cffd6bef1444ec2559ddf1b3b0
- filename: packages/contentstack-utilities/src/logger/cliErrorHandler.ts
checksum: 023cf08f215cd0778599fb8478c94419373d4687f04421c4eb99d87de86a4a3e
- filename: packages/contentstack-utilities/src/logger/logger.ts
checksum: 09f3b73dd995bafc253265c676f06308513e6b1842d9bc01d39e6b6945a54c7d

version: "1.0"
- filename: packages/contentstack-export/src/export/modules/assets.ts
checksum: c7f19e6c4a212329d981cebce9a9a8393923dd7c85feb762ddcdca678f7a9349
- filename: packages/contentstack-bootstrap/messages/index.json
checksum: c435ceaa709a7504da303a6ea674e07a89030d8ad4152e7917cd17e7f3e58052
- filename: packages/contentstack-bootstrap/src/config.ts
checksum: 65d300dc729fb84f5446c0b14921555db01fe5c90be3d297e3d0418a37b3696a
- filename: package.json
checksum: 7194335baf75abb3d3b40d2545a96d8e8e95ac9c159db45232d487a8289c2e19
- filename: pnpm-lock.yaml
checksum: 908576623359f13e5ee834a6a936ee1cf48d3bfee3453673a442b3125521cd0b
- filename: package-lock.json
checksum: 505d0c38700fa2dc20d8ee766a5cdd8a4e4b4e0bbd15870e19e9c3e154505d44
version: '1.0'
1,451 changes: 719 additions & 732 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"license": "MIT",
"workspaces": [
"packages/*"
]
],
"packageManager": "pnpm@9.12.3+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee"
}
2 changes: 1 addition & 1 deletion packages/contentstack-audit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $ npm install -g @contentstack/cli-audit
$ csdx COMMAND
running command...
$ csdx (--version|-v)
@contentstack/cli-audit/1.13.0 darwin-arm64 node-v22.14.0
@contentstack/cli-audit/1.13.0 darwin-arm64 node-v22.13.1
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-auth
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-auth/1.4.1 darwin-arm64 node-v22.14.0
@contentstack/cli-auth/1.4.1 darwin-arm64 node-v22.13.1
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
17 changes: 10 additions & 7 deletions 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.1 darwin-arm64 node-v22.14.0
@contentstack/cli-cm-bootstrap/1.14.1 darwin-arm64 node-v22.13.1
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down Expand Up @@ -45,18 +45,19 @@ Bootstrap contentstack apps
```
USAGE
$ csdx cm:bootstrap [--app-name <value>] [--project-dir <value>] [-k <value> | --org <value> | -n <value>] [-y
<value>] [-a <value>]
<value>] [--run-dev-server] [-a <value>]

FLAGS
-a, --alias=<value> Alias of the management token
-k, --stack-api-key=<value> Provide stack API key to seed content
-n, --stack-name=<value> Name of the new stack that will be created.
-y, --yes=<value> [Optional] Skip stack confirmation
--app-name=<value> App name, reactjs-starter, nextjs-starter, gatsby-starter, angular-starter, nuxt-starter,
vue-starter, stencil-starter
--app-name=<value> App name, kickstart-next, kickstart-next-ssr, kickstart-next-ssg, kickstart-next-graphql,
kickstart-next-middleware, kickstart-nuxt, kickstart-nuxt-ssr
--org=<value> Provide organization UID to create a new stack
--project-dir=<value> Directory to setup the project. If directory name has a space then provide the path as a
string or escap the space using back slash eg: "../../test space" or ../../test\ space
--run-dev-server Automatically start the development server after setup

DESCRIPTION
Bootstrap contentstack apps
Expand All @@ -66,11 +67,13 @@ EXAMPLES

$ csdx cm:bootstrap --project-dir <path/to/setup/the/app>

$ csdx cm:bootstrap --app-name "reactjs-starter" --project-dir <path/to/setup/the/app>
$ csdx cm:bootstrap --app-name "kickstart-next" --project-dir <path/to/setup/the/app>

$ csdx cm:bootstrap --app-name "reactjs-starter" --project-dir <path/to/setup/the/app> --stack-api-key "stack-api-key"
$ csdx cm:bootstrap --app-name "kickstart-next" --project-dir <path/to/setup/the/app> --stack-api-key "stack-api-key"

$ csdx cm:bootstrap --app-name "reactjs-starter" --project-dir <path/to/setup/the/app> --org "your-org-uid" --stack-name "stack-name"
$ csdx cm:bootstrap --app-name "kickstart-next" --project-dir <path/to/setup/the/app> --org "your-org-uid" --stack-name "stack-name"

$ csdx cm:bootstrap --app-name "kickstart-next" --project-dir <path/to/setup/the/app> --run-dev-server
```

_See code: [src/commands/cm/bootstrap.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-bootstrap/src/commands/cm/bootstrap.ts)_
Expand Down
42 changes: 25 additions & 17 deletions packages/contentstack-bootstrap/messages/index.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
{
"CLI_BOOTSTRAP_INVALID_APP_NAME": "Invalid app name received, use cm:bootstrap see the list of apps supported",
"CLI_BOOTSTRAP_LOGIN_FAILED": "You need to login, first. See: auth:login --help",
"CLI_BOOTSTRAP_GITHUB_ACCESS_NOT_FOUND": "No Github access token found",
"CLI_BOOTSTRAP_START_CLONE_APP": "Cloning the selected app",
"CLI_BOOTSTRAP_REPO_NOT_FOUND": "Unable to find a repo for \"%s\"",
"CLI_BOOTSTRAP_NO_API_KEY_FOUND": "No API key generated for the stack",
"CLI_BOOTSTRAP_STACK_CREATION_FAILED": "Unable to create stack for content \"%s\"",
"CLI_BOOTSTRAP_APP_SELECTION_ENQUIRY": "Select an App",
"CLI_BOOTSTRAP_APP_COPY_SOURCE_CODE_DESTINATION_TYPE_ENQUIRY": "Choose the location where you want to copy the source code",
"CLI_BOOTSTRAP_APP_COPY_SOURCE_CODE_DESTINATION_ENQUIRY": "Enter destination path",
"CLI_BOOTSTRAP_NO_ACCESS_TOKEN_CREATED": "Note: Access token not created already, check out this link https://github.com/settings/tokens \n Provide github access token",
"CLI_BOOTSTRAP_TYPE_OF_APP_ENQUIRY": "Choose the type of app you want to clone",
"CLI_BOOTSTRAP_APP_FAILED_TO_CREATE_TOKEN_FOR_ENV": "Failed to create delivery token for env \"%s\"",
"CLI_BOOTSTRAP_APP_FAILED_TO_CREATE_ENV_FILE_FOR_ENV": "Failed to setup env file for \"%s\"",
"CLI_BOOTSTRAP_APP_ENV_NOT_FOUND_FOR_THE_STACK": "No environments found for the stack",
"CLI_BOOTSTRAP_SUCCESS": "Project setup is successful!"
}
"CLI_BOOTSTRAP_INVALID_APP_NAME": "Invalid app name received, use cm:bootstrap see the list of apps supported",
"CLI_BOOTSTRAP_LOGIN_FAILED": "You need to login, first. See: auth:login --help",
"CLI_BOOTSTRAP_GITHUB_ACCESS_NOT_FOUND": "No Github access token found",
"CLI_BOOTSTRAP_START_CLONE_APP": "Cloning the selected app",
"CLI_BOOTSTRAP_REPO_NOT_FOUND": "Unable to find a repo for \"%s\"",
"CLI_BOOTSTRAP_NO_API_KEY_FOUND": "No API key generated for the stack",
"CLI_BOOTSTRAP_STACK_CREATION_FAILED": "Unable to create stack for content \"%s\"",
"CLI_BOOTSTRAP_APP_SELECTION_ENQUIRY": "Select an App",
"CLI_BOOTSTRAP_APP_COPY_SOURCE_CODE_DESTINATION_TYPE_ENQUIRY": "Choose the location where you want to copy the source code",
"CLI_BOOTSTRAP_APP_COPY_SOURCE_CODE_DESTINATION_ENQUIRY": "Enter destination path",
"CLI_BOOTSTRAP_NO_ACCESS_TOKEN_CREATED": "Note: Access token not created already, check out this link https://github.com/settings/tokens \n Provide github access token",
"CLI_BOOTSTRAP_TYPE_OF_APP_ENQUIRY": "Choose the type of app you want to clone",
"CLI_BOOTSTRAP_APP_FAILED_TO_CREATE_TOKEN_FOR_ENV": "Failed to create delivery token for env \"%s\"",
"CLI_BOOTSTRAP_APP_FAILED_TO_CREATE_ENV_FILE_FOR_ENV": "Failed to setup env file for \"%s\"",
"CLI_BOOTSTRAP_APP_ENV_NOT_FOUND_FOR_THE_STACK": "No environments found for the stack",
"CLI_BOOTSTRAP_SUCCESS": "Project setup is successful!",
"CLI_BOOTSTRAP_SUCCESS_LIVE_PREVIEW_NOTE": "Note: Before running the app, please turn on Live Preview in the CMS: Stack Settings > Live Preview > Enable Live Preview",
"CLI_BOOTSTRAP_INSTALLING_DEPENDENCIES": "Installing local dependencies with NPM",
"CLI_BOOTSTRAP_DEPENDENCIES_INSTALLED": "NPM dependencies installed successfully!",
"CLI_BOOTSTRAP_DEPENDENCIES_INSTALL_FAILED": "Failed to install NPM dependencies.",
"CLI_BOOTSTRAP_RUN_DEV_SERVER_ENQUIRY": "Do you want to install dependencies and run the app locally (npm install && npm run dev)?",
"CLI_BOOTSTRAP_STARTING_DEV_SERVER": "Starting development server...",
"CLI_BOOTSTRAP_DEV_SERVER_STARTED": "Development server started successfully! Check your terminal for more details.",
"CLI_BOOTSTRAP_DEV_SERVER_FAILED": "Failed to start development server. You can start it manually with 'npm run dev' in the project directory."
}
54 changes: 52 additions & 2 deletions packages/contentstack-bootstrap/src/bootstrap/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as path from 'path';
import { execSync, spawn } from 'child_process';
import { cliux, sanitizePath } from '@contentstack/cli-utilities';
import { default as ContentStackSeed } from '@contentstack/cli-cm-seed/lib/commands/cm/stacks/seed';

Expand All @@ -19,6 +20,7 @@ export interface BootstrapOptions {
accessToken?: string;
appType: string;
livePreviewEnabled?: boolean;
runDevServer?: boolean;
master_locale: any;
}

Expand Down Expand Up @@ -113,22 +115,70 @@ export default class Bootstrap {
this.options.livePreviewEnabled as boolean,
this.options.seedParams.managementToken as string,
);

} else {
throw new Error(messageHandler.parse('CLI_BOOTSTRAP_NO_API_KEY_FOUND'));
}

if (this.options.livePreviewEnabled) {
cliux.print(
'Note: Before running the app, please configure a preview token, preview host, and app host in the environment file',
messageHandler.parse('CLI_BOOTSTRAP_SUCCESS_LIVE_PREVIEW_NOTE'),
{
color: 'yellow',
},
);
}

cliux.print(messageHandler.parse('CLI_BOOTSTRAP_SUCCESS'));

// Install dependencies and start development server if requested (after all other operations)
if (this.options.runDevServer) {
// Install project dependencies
cliux.loader(messageHandler.parse('CLI_BOOTSTRAP_INSTALLING_DEPENDENCIES'));
try {
execSync('npm install', {
cwd: this.cloneDirectory,
stdio: 'inherit'
});
cliux.loader();
cliux.print(messageHandler.parse('CLI_BOOTSTRAP_DEPENDENCIES_INSTALLED'));

// Start development server
cliux.print(messageHandler.parse('CLI_BOOTSTRAP_STARTING_DEV_SERVER'));
cliux.print(messageHandler.parse('CLI_BOOTSTRAP_DEV_SERVER_STARTED'));
cliux.print('You can now access your application. Check the output above for the local URL.');

// Run npm run dev using spawn for long-running process
const devProcess = spawn('npm', ['run', 'dev'], {
cwd: this.cloneDirectory,
stdio: 'inherit',
shell: true
});

devProcess.on('error', (error) => {
cliux.print(messageHandler.parse('CLI_BOOTSTRAP_DEV_SERVER_FAILED'), {
color: 'yellow',
});
console.error('Failed to start dev server:', error);
});

// Handle process exit
devProcess.on('exit', (code) => {
if (code !== 0 && code !== null) {
cliux.print(messageHandler.parse('CLI_BOOTSTRAP_DEV_SERVER_FAILED'), {
color: 'yellow',
});
}
});
} catch (installError: any) {
cliux.loader();
cliux.print(messageHandler.parse('CLI_BOOTSTRAP_DEPENDENCIES_INSTALL_FAILED'), {
color: 'yellow',
});
}
}
} catch (error) {
cliux.error(messageHandler.parse('CLI_BOOTSTRAP_STACK_CREATION_FAILED', this.appConfig.stack));
}
}
}
}
10 changes: 10 additions & 0 deletions packages/contentstack-bootstrap/src/bootstrap/interactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ export async function inquireLivePreviewSupport() {
return livePreviewEnabled;
}

export async function inquireRunDevServer() {
const { runDevServer } = await inquirer.prompt({
type: 'confirm',
name: 'runDevServer',
message: messageHandler.parse('CLI_BOOTSTRAP_RUN_DEV_SERVER_ENQUIRY'),
default: true,
});
return runDevServer;
}

export async function continueBootstrapCommand() {
const { shouldContinue } = await inquirer.prompt({
type: 'list',
Expand Down
Loading
Loading