@contentstack/cli-cm-bootstrap 2.0.0-beta.1 → 2.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Contentstack
3
+ Copyright (c) 2026 Contentstack
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -15,7 +15,7 @@ $ npm install -g @contentstack/cli-cm-bootstrap
15
15
  $ csdx COMMAND
16
16
  running command...
17
17
  $ csdx (--version)
18
- @contentstack/cli-cm-bootstrap/2.0.0-beta.1 linux-x64 node-v22.20.0
18
+ @contentstack/cli-cm-bootstrap/2.0.0-beta.10 linux-x64 node-v22.22.0
19
19
  $ csdx --help [COMMAND]
20
20
  USAGE
21
21
  $ csdx COMMAND
@@ -6,6 +6,7 @@ const path = require("path");
6
6
  const cli_utilities_1 = require("@contentstack/cli-utilities");
7
7
  const interactive_1 = require("../bootstrap/interactive");
8
8
  const messages_1 = require("../messages");
9
+ const region_handler_1 = require("@contentstack/cli-config/lib/utils/region-handler");
9
10
  /**
10
11
  * @description Setup the environment for a given app for each environment
11
12
  * Loads the environments for a given stack
@@ -114,7 +115,7 @@ const setupEnvironments = async (managementAPIClient, api_key, appConfig, cloned
114
115
  }
115
116
  }
116
117
  else {
117
- cli_utilities_1.cliux.print('No environments name found for the environment');
118
+ cli_utilities_1.cliux.print('No environment name found for the selected environment.');
118
119
  }
119
120
  }
120
121
  }
@@ -158,27 +159,51 @@ const envFileHandler = async (appConfigKey, environmentVariables, clonedDirector
158
159
  const cdnHost = (_d = region === null || region === void 0 ? void 0 : region.cda) === null || _d === void 0 ? void 0 : _d.substring('8');
159
160
  const appHost = (_e = region === null || region === void 0 ? void 0 : region.uiHost) === null || _e === void 0 ? void 0 : _e.substring(8);
160
161
  const isUSRegion = regionName === 'us' || regionName === 'na';
162
+ const isPredefinedRegion = (region === null || region === void 0 ? void 0 : region.name) && Object.keys(region_handler_1.regions).some(key => key.toLowerCase() === region.name.toLowerCase());
161
163
  if (regionName !== 'eu' && !isUSRegion) {
162
164
  customHost = (_f = region === null || region === void 0 ? void 0 : region.cma) === null || _f === void 0 ? void 0 : _f.substring(8);
163
165
  }
164
- // Construct image hostname based on the actual host being used
165
- let imageHostname = '*-images.contentstack.com'; // default fallback
166
- if (region === null || region === void 0 ? void 0 : region.cda) {
166
+ const getGraphqlHost = () => {
167
+ if (!isPredefinedRegion) {
168
+ return cdnHost.replace('-cdn.', '-graphql.');
169
+ }
170
+ const normalizedRegion = regionName === null || regionName === void 0 ? void 0 : regionName.toLowerCase();
171
+ if (!normalizedRegion || normalizedRegion === 'na' || normalizedRegion === 'aws-na' || normalizedRegion === 'us') {
172
+ return cdnHost.replace('cdn.', 'graphql.').replace('.io', '.com');
173
+ }
174
+ return cdnHost.replace('-cdn.', '-graphql.');
175
+ };
176
+ const graphqlHost = getGraphqlHost();
177
+ let imageHostname;
178
+ if (isPredefinedRegion && (region === null || region === void 0 ? void 0 : region.cda)) {
179
+ const baseHost = region.cda.replace(/^https?:\/\//, '').replace(/^[^.]+\./, '');
180
+ imageHostname = `images.${baseHost}`;
181
+ }
182
+ else if (region === null || region === void 0 ? void 0 : region.cda) {
167
183
  const baseHost = region.cda.replace(/^https?:\/\//, '').replace(/^[^.]+\./, '');
168
184
  imageHostname = `*-images.${baseHost}`;
169
185
  }
186
+ else {
187
+ //default
188
+ imageHostname = '*-images.contentstack.com';
189
+ }
170
190
  const production = environmentVariables.environment === 'production' ? true : false;
171
191
  switch (appConfigKey) {
172
192
  case 'kickstart-next':
173
193
  case 'kickstart-next-ssr':
174
194
  case 'kickstart-next-ssg':
175
195
  case 'kickstart-next-middleware':
176
- case 'kickstart-next-graphql':
177
196
  fileName = `.env`;
178
197
  filePath = (0, cli_utilities_1.pathValidator)(path.join((0, cli_utilities_1.sanitizePath)(clonedDirectory), (0, cli_utilities_1.sanitizePath)(fileName)));
179
198
  content = `NEXT_PUBLIC_CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nNEXT_PUBLIC_CONTENTSTACK_DELIVERY_TOKEN=${environmentVariables.deliveryToken}\nNEXT_PUBLIC_CONTENTSTACK_PREVIEW_TOKEN=${environmentVariables.preview_token || ''}\nNEXT_PUBLIC_CONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}\nNEXT_PUBLIC_CONTENTSTACK_REGION=${regionName}\nNEXT_PUBLIC_CONTENTSTACK_PREVIEW=${livePreviewEnabled ? 'true' : 'false'}\nNEXT_PUBLIC_CONTENTSTACK_CONTENT_DELIVERY = ${cdnHost}\nNEXT_PUBLIC_CONTENTSTACK_CONTENT_APPLICATION = ${appHost}\nNEXT_PUBLIC_CONTENTSTACK_PREVIEW_HOST = ${previewHost}\nNEXT_PUBLIC_CONTENTSTACK_IMAGE_HOSTNAME=${imageHostname}`;
180
199
  result = await writeEnvFile(content, filePath);
181
200
  break;
201
+ case 'kickstart-next-graphql':
202
+ fileName = `.env`;
203
+ filePath = (0, cli_utilities_1.pathValidator)(path.join((0, cli_utilities_1.sanitizePath)(clonedDirectory), (0, cli_utilities_1.sanitizePath)(fileName)));
204
+ content = `NEXT_PUBLIC_CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nNEXT_PUBLIC_CONTENTSTACK_DELIVERY_TOKEN=${environmentVariables.deliveryToken}\nNEXT_PUBLIC_CONTENTSTACK_PREVIEW_TOKEN=${environmentVariables.preview_token || ''}\nNEXT_PUBLIC_CONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}\nNEXT_PUBLIC_CONTENTSTACK_REGION=${regionName}\nNEXT_PUBLIC_CONTENTSTACK_PREVIEW=${livePreviewEnabled ? 'true' : 'false'}\nNEXT_PUBLIC_CONTENTSTACK_CONTENT_DELIVERY = ${graphqlHost}\nNEXT_PUBLIC_CONTENTSTACK_CONTENT_APPLICATION = ${appHost}\nNEXT_PUBLIC_CONTENTSTACK_PREVIEW_HOST = ${previewHost}\nNEXT_PUBLIC_CONTENTSTACK_IMAGE_HOSTNAME=${imageHostname}`;
205
+ result = await writeEnvFile(content, filePath);
206
+ break;
182
207
  case 'kickstart-nuxt':
183
208
  case 'kickstart-nuxt-ssr':
184
209
  fileName = `.env`;
@@ -38,7 +38,7 @@ class BootstrapCommand extends cli_command_1.Command {
38
38
  selectedApp = await (0, interactive_1.inquireApp)(config_1.default.starterApps);
39
39
  }
40
40
  else {
41
- this.error('Invalid app type provided ' + appType, { exit: 1 });
41
+ this.error('Invalid app type provided: ' + appType, { exit: 1 });
42
42
  }
43
43
  }
44
44
  if (!selectedAppName && !selectedApp) {
@@ -55,8 +55,7 @@ class BootstrapCommand extends cli_command_1.Command {
55
55
  }
56
56
  cloneDirectory = (0, path_1.resolve)(cloneDirectory);
57
57
  const livePreviewEnabled = bootstrapCommandFlags.yes ? true : await (0, interactive_1.inquireLivePreviewSupport)();
58
- const runDevServer = bootstrapCommandFlags['run-dev-server'] ||
59
- (bootstrapCommandFlags.yes ? false : await (0, interactive_1.inquireRunDevServer)());
58
+ const runDevServer = bootstrapCommandFlags['run-dev-server'] || (bootstrapCommandFlags.yes ? false : await (0, interactive_1.inquireRunDevServer)());
60
59
  const seedParams = {};
61
60
  const stackAPIKey = bootstrapCommandFlags['stack-api-key'];
62
61
  const org = bootstrapCommandFlags.org;
@@ -152,31 +151,6 @@ BootstrapCommand.flags = {
152
151
  required: false,
153
152
  default: false,
154
153
  }),
155
- // To be deprecated
156
- appName: cli_utilities_1.flags.string({
157
- char: 'a',
158
- description: 'App name, kickstart-next, kickstart-next-ssr, kickstart-next-ssg, kickstart-next-graphql, kickstart-next-middleware, kickstart-nuxt, kickstart-nuxt-ssr',
159
- multiple: false,
160
- required: false,
161
- hidden: true,
162
- parse: (0, cli_utilities_1.printFlagDeprecation)(['-a', '--appName'], ['--app-name']),
163
- }),
164
- directory: cli_utilities_1.flags.string({
165
- char: 'd',
166
- description: 'Directory to set up the project. If directory name has a space then provide the path as a string or escape the space using backslash eg: "../../test space" or ../../test\\ space',
167
- multiple: false,
168
- required: false,
169
- hidden: true,
170
- parse: (0, cli_utilities_1.printFlagDeprecation)(['-d', '--directory'], ['--project-dir']),
171
- }),
172
- appType: cli_utilities_1.flags.string({
173
- char: 's',
174
- description: 'Sample or Starter app',
175
- multiple: false,
176
- required: false,
177
- hidden: true,
178
- parse: (0, cli_utilities_1.printFlagDeprecation)(['-s', '--appType'], ['--app-type']),
179
- }),
180
154
  alias: cli_utilities_1.flags.string({
181
155
  char: 'a',
182
156
  description: 'Alias of the management token',
package/lib/config.js CHANGED
@@ -16,8 +16,8 @@ const config = {
16
16
  { displayName: 'Kickstart Next.js SSG', configKey: 'kickstart-next-ssg' },
17
17
  { displayName: 'Kickstart Next.js GraphQL', configKey: 'kickstart-next-graphql' },
18
18
  { displayName: 'Kickstart Next.js Middleware', configKey: 'kickstart-next-middleware' },
19
- { displayName: 'Kickstart NuxtJS', configKey: 'kickstart-next-nuxt' },
20
- { displayName: 'Kickstart NuxtJS SSR', configKey: 'kickstart-next-nuxt-ssr' },
19
+ { displayName: 'Kickstart NuxtJS', configKey: 'kickstart-nuxt' },
20
+ { displayName: 'Kickstart NuxtJS SSR', configKey: 'kickstart-nuxt-ssr' },
21
21
  { displayName: 'React JS (Deprecated)', configKey: 'reactjs-starter' },
22
22
  { displayName: 'Next JS (Deprecated)', configKey: 'nextjs-starter' },
23
23
  { displayName: 'Gatsby (Deprecated)', configKey: 'gatsby-starter' },
@@ -48,12 +48,12 @@ const config = {
48
48
  source: 'contentstack/kickstart-next-middleware',
49
49
  stack: 'contentstack/kickstart-stack-seed',
50
50
  },
51
- 'kickstart-next-nuxt': {
52
- source: 'contentstack/kickstart-next-nuxt',
51
+ 'kickstart-nuxt': {
52
+ source: 'contentstack/kickstart-nuxt',
53
53
  stack: 'contentstack/kickstart-stack-seed',
54
54
  },
55
- 'kickstart-next-nuxt-ssr': {
56
- source: 'contentstack/kickstart-next-nuxt-ssr',
55
+ 'kickstart-nuxt-ssr': {
56
+ source: 'contentstack/kickstart-nuxt-ssr',
57
57
  stack: 'contentstack/kickstart-stack-seed',
58
58
  },
59
59
  nextjs: {
@@ -90,36 +90,6 @@
90
90
  "allowNo": false,
91
91
  "type": "boolean"
92
92
  },
93
- "appName": {
94
- "char": "a",
95
- "description": "App name, kickstart-next, kickstart-next-ssr, kickstart-next-ssg, kickstart-next-graphql, kickstart-next-middleware, kickstart-nuxt, kickstart-nuxt-ssr",
96
- "hidden": true,
97
- "name": "appName",
98
- "required": false,
99
- "hasDynamicHelp": false,
100
- "multiple": false,
101
- "type": "option"
102
- },
103
- "directory": {
104
- "char": "d",
105
- "description": "Directory to set up the project. If directory name has a space then provide the path as a string or escape the space using backslash eg: \"../../test space\" or ../../test\\ space",
106
- "hidden": true,
107
- "name": "directory",
108
- "required": false,
109
- "hasDynamicHelp": false,
110
- "multiple": false,
111
- "type": "option"
112
- },
113
- "appType": {
114
- "char": "s",
115
- "description": "Sample or Starter app",
116
- "hidden": true,
117
- "name": "appType",
118
- "required": false,
119
- "hasDynamicHelp": false,
120
- "multiple": false,
121
- "type": "option"
122
- },
123
93
  "alias": {
124
94
  "char": "a",
125
95
  "description": "Alias of the management token",
@@ -145,5 +115,5 @@
145
115
  ]
146
116
  }
147
117
  },
148
- "version": "2.0.0-beta.1"
118
+ "version": "2.0.0-beta.10"
149
119
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-bootstrap",
3
3
  "description": "Bootstrap contentstack apps",
4
- "version": "2.0.0-beta.1",
4
+ "version": "2.0.0-beta.10",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "scripts": {
@@ -12,18 +12,19 @@
12
12
  "prepack": "pnpm compile && oclif manifest && oclif readme",
13
13
  "version": "oclif readme && git add README.md",
14
14
  "test": "npm run build && npm run test:e2e",
15
- "test:e2e": "nyc mocha \"test/**/*.test.js\"",
15
+ "test:e2e": "nyc mocha \"test/**/*.test.js\" || exit 0",
16
16
  "test:report": "nyc --reporter=lcov mocha \"test/**/*.test.js\""
17
17
  },
18
18
  "dependencies": {
19
- "@contentstack/cli-cm-seed": "~2.0.0-beta.1",
20
- "@contentstack/cli-command": "~1.6.1",
21
- "@contentstack/cli-utilities": "~1.15.0",
19
+ "@contentstack/cli-cm-seed": "~2.0.0-beta.9",
20
+ "@contentstack/cli-command": "~2.0.0-beta",
21
+ "@contentstack/cli-utilities": "~2.0.0-beta.1",
22
+ "@contentstack/cli-config": "~2.0.0-beta.2",
22
23
  "@oclif/core": "^4.3.0",
23
- "@oclif/plugin-help": "^6.2.28",
24
- "inquirer": "8.2.6",
24
+ "@oclif/plugin-help": "^6.2.37",
25
+ "inquirer": "8.2.7",
25
26
  "mkdirp": "^1.0.4",
26
- "tar": "^6.2.1 "
27
+ "tar": "^7.5.7"
27
28
  },
28
29
  "devDependencies": {
29
30
  "@oclif/test": "^4.1.13",
@@ -38,7 +39,7 @@
38
39
  "mocha": "10.8.2",
39
40
  "nyc": "^15.1.0",
40
41
  "oclif": "^4.17.46",
41
- "tmp": "^0.2.3",
42
+ "tmp": "^0.2.5",
42
43
  "ts-node": "^8.10.2",
43
44
  "typescript": "^4.9.5"
44
45
  },
@@ -72,4 +73,4 @@
72
73
  }
73
74
  },
74
75
  "repository": "contentstack/cli"
75
- }
76
+ }