@contentstack/cli-cm-bootstrap 1.9.3 → 1.10.0
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/README.md +1 -1
- package/lib/bootstrap/index.d.ts +1 -0
- package/lib/bootstrap/index.js +3 -0
- package/lib/bootstrap/utils.d.ts +0 -6
- package/lib/bootstrap/utils.js +53 -3
- package/lib/commands/cm/bootstrap.d.ts +1 -0
- package/lib/commands/cm/bootstrap.js +4 -0
- package/lib/config.d.ts +1 -0
- package/lib/config.js +6 -0
- package/oclif.manifest.json +1 -1
- package/package.json +4 -4
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/1.
|
|
18
|
+
@contentstack/cli-cm-bootstrap/1.10.0 linux-x64 node-v18.20.4
|
|
19
19
|
$ csdx --help [COMMAND]
|
|
20
20
|
USAGE
|
|
21
21
|
$ csdx COMMAND
|
package/lib/bootstrap/index.d.ts
CHANGED
package/lib/bootstrap/index.js
CHANGED
|
@@ -64,6 +64,9 @@ class Bootstrap {
|
|
|
64
64
|
if (this.options.seedParams.managementTokenAlias) {
|
|
65
65
|
cmd.push('--alias', this.options.seedParams.managementTokenAlias);
|
|
66
66
|
}
|
|
67
|
+
if (this.options.master_locale) {
|
|
68
|
+
cmd.push('--locale', this.options.master_locale);
|
|
69
|
+
}
|
|
67
70
|
const result = await seed_1.default.run(cmd);
|
|
68
71
|
if (result && result.api_key) {
|
|
69
72
|
await (0, utils_1.setupEnvironments)(this.managementAPIClient, result.api_key, this.appConfig, this.cloneDirectory, this.region, this.options.livePreviewEnabled, this.options.seedParams.managementToken);
|
package/lib/bootstrap/utils.d.ts
CHANGED
|
@@ -1,8 +1,2 @@
|
|
|
1
1
|
import { AppConfig } from '../config';
|
|
2
|
-
/**
|
|
3
|
-
* @description Setup the environment for a given app for each environment
|
|
4
|
-
* Loads the environments for a given stack
|
|
5
|
-
* Create delivery token
|
|
6
|
-
* Create enviroment
|
|
7
|
-
*/
|
|
8
2
|
export declare const setupEnvironments: (managementAPIClient: any, api_key: string, appConfig: AppConfig, clonedDirectory: string, region: any, livePreviewEnabled: boolean, managementToken?: string) => Promise<void>;
|
package/lib/bootstrap/utils.js
CHANGED
|
@@ -12,6 +12,7 @@ const messages_1 = require("../messages");
|
|
|
12
12
|
* Create delivery token
|
|
13
13
|
* Create enviroment
|
|
14
14
|
*/
|
|
15
|
+
let managementTokenResult;
|
|
15
16
|
const setupEnvironments = async (managementAPIClient, api_key, appConfig, clonedDirectory, region, livePreviewEnabled, managementToken) => {
|
|
16
17
|
var _a, _b;
|
|
17
18
|
const environmentResult = await managementAPIClient
|
|
@@ -19,6 +20,47 @@ const setupEnvironments = async (managementAPIClient, api_key, appConfig, cloned
|
|
|
19
20
|
.environment()
|
|
20
21
|
.query()
|
|
21
22
|
.find();
|
|
23
|
+
//create management token if not present
|
|
24
|
+
if (!managementToken) {
|
|
25
|
+
const managementBody = {
|
|
26
|
+
"token": {
|
|
27
|
+
"name": "sample app",
|
|
28
|
+
"description": "This is a sample management token.",
|
|
29
|
+
"scope": [
|
|
30
|
+
{
|
|
31
|
+
"module": "content_type",
|
|
32
|
+
"acl": {
|
|
33
|
+
"read": true,
|
|
34
|
+
"write": true
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"module": "branch",
|
|
39
|
+
"branches": [
|
|
40
|
+
"main"
|
|
41
|
+
],
|
|
42
|
+
"acl": {
|
|
43
|
+
"read": true
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"expires_on": "3000-01-01",
|
|
48
|
+
"is_email_notification_enabled": false
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
managementTokenResult = await managementAPIClient
|
|
52
|
+
.stack({ api_key: api_key })
|
|
53
|
+
.managementToken()
|
|
54
|
+
.create(managementBody);
|
|
55
|
+
if (!managementTokenResult.uid) {
|
|
56
|
+
cli_utilities_1.cliux.print(`Info: Failed to generate a management token.\nNote: Management token is not available in your plan. Please contact the admin for support.`, {
|
|
57
|
+
color: 'yellow',
|
|
58
|
+
});
|
|
59
|
+
if ((await (0, interactive_1.continueBootstrapCommand)()) === 'no') {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
22
64
|
if (Array.isArray(environmentResult.items) && environmentResult.items.length > 0) {
|
|
23
65
|
for (const environment of environmentResult.items) {
|
|
24
66
|
if (environment.name) {
|
|
@@ -104,7 +146,7 @@ const writeEnvFile = (content, fileName) => {
|
|
|
104
146
|
* TBD: moving the content to config file
|
|
105
147
|
*/
|
|
106
148
|
const envFileHandler = async (appConfigKey, environmentVariables, clonedDirectory, region, livePreviewEnabled) => {
|
|
107
|
-
var _a, _b, _c, _d, _e;
|
|
149
|
+
var _a, _b, _c, _d, _e, _f;
|
|
108
150
|
if (!appConfigKey || !environmentVariables) {
|
|
109
151
|
return;
|
|
110
152
|
}
|
|
@@ -118,10 +160,11 @@ const envFileHandler = async (appConfigKey, environmentVariables, clonedDirector
|
|
|
118
160
|
const managementAPIHost = (_a = region === null || region === void 0 ? void 0 : region.cma) === null || _a === void 0 ? void 0 : _a.substring('8');
|
|
119
161
|
const regionName = region && region.name && region.name.toLowerCase();
|
|
120
162
|
previewHost = (_c = (_b = region === null || region === void 0 ? void 0 : region.uiHost) === null || _b === void 0 ? void 0 : _b.substring(8)) === null || _c === void 0 ? void 0 : _c.replace('app', 'rest-preview');
|
|
121
|
-
|
|
163
|
+
const cdnHost = (_d = region === null || region === void 0 ? void 0 : region.cda) === null || _d === void 0 ? void 0 : _d.substring('8');
|
|
164
|
+
appHost = (_e = region === null || region === void 0 ? void 0 : region.uiHost) === null || _e === void 0 ? void 0 : _e.substring(8);
|
|
122
165
|
const isUSRegion = regionName === 'us' || regionName === 'na';
|
|
123
166
|
if (regionName !== 'eu' && !isUSRegion) {
|
|
124
|
-
customHost = (
|
|
167
|
+
customHost = (_f = region === null || region === void 0 ? void 0 : region.cma) === null || _f === void 0 ? void 0 : _f.substring(8);
|
|
125
168
|
}
|
|
126
169
|
const production = environmentVariables.environment === 'production' ? true : false;
|
|
127
170
|
switch (appConfigKey) {
|
|
@@ -143,6 +186,13 @@ const envFileHandler = async (appConfigKey, environmentVariables, clonedDirector
|
|
|
143
186
|
: '\n'}CONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}\nCONTENTSTACK_API_HOST=${customHost ? customHost : managementAPIHost}${!isUSRegion && !customHost ? '\nCONTENTSTACK_REGION=' + region.name : ''}\nCONTENTSTACK_LIVE_PREVIEW=${livePreviewEnabled}\nCONTENTSTACK_LIVE_EDIT_TAGS=false`;
|
|
144
187
|
result = await writeEnvFile(content, filePath);
|
|
145
188
|
break;
|
|
189
|
+
case 'compass-app':
|
|
190
|
+
fileName = '.env';
|
|
191
|
+
filePath = (0, cli_utilities_1.pathValidator)(path.join((0, cli_utilities_1.sanitizePath)(clonedDirectory), (0, cli_utilities_1.sanitizePath)(fileName)));
|
|
192
|
+
content = `CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nCONTENTSTACK_DELIVERY_TOKEN=${environmentVariables.deliveryToken}\nCONTENTSTACK_BRANCH=main${livePreviewEnabled
|
|
193
|
+
? `\nCONTENTSTACK_PREVIEW_TOKEN=${environmentVariables.preview_token || `''`}\nCONTENTSTACK_PREVIEW_HOST=${previewHost}\n`
|
|
194
|
+
: '\n'}CONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}${!isUSRegion && !customHost ? '\nCONTENTSTACK_REGION=' + region.name : ''}\nCONTENTSTACK_LIVE_PREVIEW=${livePreviewEnabled}\nCONTENTSTACK_LIVE_EDIT_TAGS=false\nCONTENTSTACK_API_HOST=${customHost ? customHost : managementAPIHost}${!isUSRegion && !customHost ? '\nCONTENTSTACK_REGION=' + region.name : ''}\nCONTENTSTACK_APP_HOST=${appHost}\nCONTENTSTACK_MANAGEMENT_TOKEN=${managementTokenResult.uid}\nCONTENTSTACK_HOST=${cdnHost}`;
|
|
195
|
+
result = await writeEnvFile(content, filePath);
|
|
146
196
|
case 'gatsby':
|
|
147
197
|
case 'gatsby-starter':
|
|
148
198
|
fileName = `.env.${environmentVariables.environment}`;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Command } from '@contentstack/cli-command';
|
|
2
2
|
import { FlagInput } from '@contentstack/cli-utilities';
|
|
3
|
+
export declare const DEFAULT_MASTER_LOCALE = "en-us";
|
|
3
4
|
export default class BootstrapCommand extends Command {
|
|
4
5
|
private bootstrapManagementAPIClient;
|
|
5
6
|
static description: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_MASTER_LOCALE = void 0;
|
|
3
4
|
const cli_command_1 = require("@contentstack/cli-command");
|
|
4
5
|
const path_1 = require("path");
|
|
5
6
|
const bootstrap_1 = require("../../bootstrap");
|
|
@@ -7,6 +8,7 @@ const interactive_1 = require("../../bootstrap/interactive");
|
|
|
7
8
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
8
9
|
const config_1 = require("../../config");
|
|
9
10
|
const messages_1 = require("../../messages");
|
|
11
|
+
exports.DEFAULT_MASTER_LOCALE = 'en-us';
|
|
10
12
|
class BootstrapCommand extends cli_command_1.Command {
|
|
11
13
|
async run() {
|
|
12
14
|
const { flags: bootstrapCommandFlags } = await this.parse(BootstrapCommand);
|
|
@@ -46,6 +48,7 @@ class BootstrapCommand extends cli_command_1.Command {
|
|
|
46
48
|
}
|
|
47
49
|
const yes = bootstrapCommandFlags.yes;
|
|
48
50
|
const appConfig = (0, config_1.getAppLevelConfigByName)(selectedAppName || selectedApp.configKey);
|
|
51
|
+
let master_locale = appConfig.master_locale || exports.DEFAULT_MASTER_LOCALE;
|
|
49
52
|
let cloneDirectory = bootstrapCommandFlags.directory || bootstrapCommandFlags['project-dir'];
|
|
50
53
|
if (!cloneDirectory) {
|
|
51
54
|
cloneDirectory = await (0, interactive_1.inquireCloneDirectory)();
|
|
@@ -79,6 +82,7 @@ class BootstrapCommand extends cli_command_1.Command {
|
|
|
79
82
|
region: this.region,
|
|
80
83
|
appType,
|
|
81
84
|
livePreviewEnabled,
|
|
85
|
+
master_locale,
|
|
82
86
|
};
|
|
83
87
|
const bootstrap = new bootstrap_1.default(options);
|
|
84
88
|
await bootstrap.run();
|
package/lib/config.d.ts
CHANGED
package/lib/config.js
CHANGED
|
@@ -18,6 +18,7 @@ const config = {
|
|
|
18
18
|
{ displayName: 'Vue JS', configKey: 'vue-starter' },
|
|
19
19
|
{ displayName: 'Stencil', configKey: 'stencil-starter' },
|
|
20
20
|
{ displayName: 'Nuxt3', configKey: 'nuxt3-starter' },
|
|
21
|
+
// { displayName: 'Compass App', configKey: 'compass-app' }
|
|
21
22
|
],
|
|
22
23
|
appLevelConfig: {
|
|
23
24
|
nextjs: {
|
|
@@ -36,6 +37,11 @@ const config = {
|
|
|
36
37
|
source: 'contentstack/contentstack-angular-modularblock-example',
|
|
37
38
|
stack: 'contentstack/stack-contentstack-angular-modularblock-example',
|
|
38
39
|
},
|
|
40
|
+
'compass-app': {
|
|
41
|
+
source: 'contentstack/contentstack-universal-demo',
|
|
42
|
+
stack: 'contentstack/stack-contentstack-universal-demo',
|
|
43
|
+
master_locale: 'en',
|
|
44
|
+
},
|
|
39
45
|
'nuxtjs-disabled': {
|
|
40
46
|
source: 'contentstack/contentstack-nuxtjs-vue-universal-demo',
|
|
41
47
|
stack: 'shafeeqd959/stack-contentstack-nuxtjs-vue-universal-demo',
|
package/oclif.manifest.json
CHANGED
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": "1.
|
|
4
|
+
"version": "1.10.0",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"scripts": {
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"test:report": "nyc --reporter=lcov mocha \"test/**/*.test.js\""
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@contentstack/cli-cm-seed": "~1.7.
|
|
21
|
-
"@contentstack/cli-command": "~1.2.
|
|
22
|
-
"@contentstack/cli-utilities": "~1.
|
|
20
|
+
"@contentstack/cli-cm-seed": "~1.7.6",
|
|
21
|
+
"@contentstack/cli-command": "~1.2.19",
|
|
22
|
+
"@contentstack/cli-utilities": "~1.7.1",
|
|
23
23
|
"inquirer": "8.2.4",
|
|
24
24
|
"mkdirp": "^1.0.4",
|
|
25
25
|
"tar": "^6.2.1 "
|