Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion .talismanrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fileignoreconfig:
- filename: package-lock.json
checksum: acd0c006f11dc01dcf578cc783843c64b2e002a8f6b654a8b5513362303a3590
checksum: 44b582fb5d952f027fdcb2c771b5b684a1677d1860f9a5ab928a14781d0a0186
- filename: pnpm-lock.yaml
checksum: 006cd155027af9b70649f4e9295e7a158a960d7c87a74fad0710443fb3b814bc
- filename: packages/contentstack-import-setup/test/unit/backup-handler.test.ts
Expand Down
18 changes: 9 additions & 9 deletions 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.14.0 darwin-x64 node-v22.17.0
@contentstack/cli-audit/1.14.0 darwin-arm64 node-v23.11.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down Expand Up @@ -282,7 +282,7 @@ DESCRIPTION
Display help for csdx.
```

_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.32/src/commands/help.ts)_
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.29/src/commands/help.ts)_

## `csdx plugins`

Expand All @@ -305,7 +305,7 @@ EXAMPLES
$ csdx plugins
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.46/src/commands/plugins/index.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.43/src/commands/plugins/index.ts)_

## `csdx plugins:add PLUGIN`

Expand Down Expand Up @@ -379,7 +379,7 @@ EXAMPLES
$ csdx plugins:inspect myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.46/src/commands/plugins/inspect.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.43/src/commands/plugins/inspect.ts)_

## `csdx plugins:install PLUGIN`

Expand Down Expand Up @@ -428,7 +428,7 @@ EXAMPLES
$ csdx plugins:install someuser/someplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.46/src/commands/plugins/install.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.43/src/commands/plugins/install.ts)_

## `csdx plugins:link PATH`

Expand Down Expand Up @@ -459,7 +459,7 @@ EXAMPLES
$ csdx plugins:link myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.46/src/commands/plugins/link.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.43/src/commands/plugins/link.ts)_

## `csdx plugins:remove [PLUGIN]`

Expand Down Expand Up @@ -500,7 +500,7 @@ FLAGS
--reinstall Reinstall all plugins after uninstalling.
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.46/src/commands/plugins/reset.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.43/src/commands/plugins/reset.ts)_

## `csdx plugins:uninstall [PLUGIN]`

Expand Down Expand Up @@ -528,7 +528,7 @@ EXAMPLES
$ csdx plugins:uninstall myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.46/src/commands/plugins/uninstall.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.43/src/commands/plugins/uninstall.ts)_

## `csdx plugins:unlink [PLUGIN]`

Expand Down Expand Up @@ -572,5 +572,5 @@ DESCRIPTION
Update installed plugins.
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.46/src/commands/plugins/update.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.43/src/commands/plugins/update.ts)_
<!-- commandsstop -->
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.6.0 darwin-arm64 node-v22.14.0
@contentstack/cli-auth/1.5.1 darwin-arm64 node-v22.13.1
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
15 changes: 9 additions & 6 deletions packages/contentstack-bootstrap/README.md
Original file line number Diff line number Diff line change
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."
}
52 changes: 51 additions & 1 deletion 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,20 +115,68 @@ 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));
}
Expand Down
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