@contentstack/cli-cm-bootstrap 1.0.2 → 1.0.5
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 +2 -2
- package/lib/bootstrap/{error.js → bootstrap-error.js} +0 -0
- package/lib/bootstrap/github/client.js +2 -2
- package/lib/bootstrap/github/{error.js → github-error.js} +0 -0
- package/lib/bootstrap/index.js +9 -9
- package/lib/bootstrap/utils.js +12 -6
- package/lib/commands/cm/bootstrap.js +5 -5
- package/oclif.manifest.json +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ $ npm install -g @contentstack/cli-cm-bootstrap
|
|
|
13
13
|
$ csdx COMMAND
|
|
14
14
|
running command...
|
|
15
15
|
$ csdx (-v|--version|version)
|
|
16
|
-
@contentstack/cli-cm-bootstrap/1.0.
|
|
16
|
+
@contentstack/cli-cm-bootstrap/1.0.5 linux-x64 node-v12.22.7
|
|
17
17
|
$ csdx --help [COMMAND]
|
|
18
18
|
USAGE
|
|
19
19
|
$ csdx COMMAND
|
|
@@ -57,5 +57,5 @@ EXAMPLES
|
|
|
57
57
|
$ csdx cm:bootstrap -t <github access token>
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
_See code: [src/commands/cm/bootstrap.ts](https://github.com/contentstack/cli/blob/v1.0.
|
|
60
|
+
_See code: [src/commands/cm/bootstrap.ts](https://github.com/contentstack/cli/blob/v1.0.5/src/commands/cm/bootstrap.ts)_
|
|
61
61
|
<!-- commandsstop -->
|
|
File without changes
|
|
@@ -4,7 +4,7 @@ const axios_1 = require("axios");
|
|
|
4
4
|
const zlib = require("zlib");
|
|
5
5
|
const tar = require("tar");
|
|
6
6
|
const mkdirp = require("mkdirp");
|
|
7
|
-
const
|
|
7
|
+
const github_error_1 = require("./github-error");
|
|
8
8
|
const messages_1 = require("../../messages");
|
|
9
9
|
const DEFAULT_BRANCH = 'master';
|
|
10
10
|
class GitHubClient {
|
|
@@ -46,7 +46,7 @@ class GitHubClient {
|
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
49
|
-
throw new
|
|
49
|
+
throw new github_error_1.default(messages_1.default.parse('CLI_BOOTSTRAP_GITHUB_ACCESS_NOT_FOUND'), 1);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
const response = await axios_1.default.get(url, options);
|
|
File without changes
|
package/lib/bootstrap/index.js
CHANGED
|
@@ -5,10 +5,10 @@ const cli_ux_1 = require("cli-ux");
|
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const seed_1 = require("@contentstack/cli-cm-seed/lib/commands/cm/seed");
|
|
7
7
|
const client_1 = require("./github/client");
|
|
8
|
-
const
|
|
8
|
+
const github_error_1 = require("./github/github-error");
|
|
9
9
|
const utils_1 = require("./utils");
|
|
10
10
|
const messages_1 = require("../messages");
|
|
11
|
-
exports.ENGLISH_LOCALE =
|
|
11
|
+
exports.ENGLISH_LOCALE = "en-us";
|
|
12
12
|
/**
|
|
13
13
|
* @description Bootstraps the sample app
|
|
14
14
|
* Clone the repo
|
|
@@ -31,14 +31,14 @@ class Bootstrap {
|
|
|
31
31
|
this.options = options;
|
|
32
32
|
}
|
|
33
33
|
async run() {
|
|
34
|
-
cli_ux_1.default.action.start(messages_1.default.parse(
|
|
34
|
+
cli_ux_1.default.action.start(messages_1.default.parse("CLI_BOOTSTRAP_START_CLONE_APP"));
|
|
35
35
|
try {
|
|
36
36
|
await this.ghClient.getLatest(this.cloneDirectory);
|
|
37
37
|
}
|
|
38
38
|
catch (error) {
|
|
39
|
-
if (error instanceof
|
|
39
|
+
if (error instanceof github_error_1.default) {
|
|
40
40
|
if (error.status === 404) {
|
|
41
|
-
cli_ux_1.default.error(messages_1.default.parse(
|
|
41
|
+
cli_ux_1.default.error(messages_1.default.parse("CLI_BOOTSTRAP_REPO_NOT_FOUND", this.appConfig.source));
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
throw error;
|
|
@@ -48,17 +48,17 @@ class Bootstrap {
|
|
|
48
48
|
}
|
|
49
49
|
// seed plugin start
|
|
50
50
|
try {
|
|
51
|
-
const result = await seed_1.default.run([
|
|
51
|
+
const result = await seed_1.default.run(["-r", this.appConfig.stack]);
|
|
52
52
|
if (result.api_key) {
|
|
53
53
|
await utils_1.setupEnvironments(this.managementAPIClient, result.api_key, this.appConfig, this.cloneDirectory, this.region);
|
|
54
54
|
}
|
|
55
55
|
else {
|
|
56
|
-
throw new Error(messages_1.default.parse(
|
|
56
|
+
throw new Error(messages_1.default.parse("CLI_BOOTSTRAP_NO_API_KEY_FOUND"));
|
|
57
57
|
}
|
|
58
|
-
cli_ux_1.default.log(messages_1.default.parse(
|
|
58
|
+
cli_ux_1.default.log(messages_1.default.parse("CLI_BOOTSTRAP_SUCCESS"));
|
|
59
59
|
}
|
|
60
60
|
catch (error) {
|
|
61
|
-
cli_ux_1.default.error(messages_1.default.parse(
|
|
61
|
+
cli_ux_1.default.error(messages_1.default.parse("CLI_BOOTSTRAP_STACK_CREATION_FAILED", this.appConfig.stack));
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
}
|
package/lib/bootstrap/utils.js
CHANGED
|
@@ -20,14 +20,19 @@ exports.setupEnvironments = async (managementAPIClient, api_key, appConfig, clon
|
|
|
20
20
|
'token': {
|
|
21
21
|
'name': `Sample app ${environment.name}`,
|
|
22
22
|
'description': 'Sample app',
|
|
23
|
-
'scope': [
|
|
23
|
+
'scope': [
|
|
24
|
+
{
|
|
24
25
|
'module': 'environment',
|
|
25
26
|
'environments': [environment.name],
|
|
26
|
-
'acl': {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
'acl': { 'read': true }
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
module: "branch",
|
|
31
|
+
acl: { read: true },
|
|
32
|
+
branches: ["main"]
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
},
|
|
31
36
|
};
|
|
32
37
|
try {
|
|
33
38
|
const tokenResult = await managementAPIClient.stack({ api_key }).deliveryToken().create(body);
|
|
@@ -44,6 +49,7 @@ exports.setupEnvironments = async (managementAPIClient, api_key, appConfig, clon
|
|
|
44
49
|
}
|
|
45
50
|
}
|
|
46
51
|
catch (error) {
|
|
52
|
+
console.log("error", error);
|
|
47
53
|
cli_ux_1.default.log(messages_1.default.parse('CLI_BOOTSTRAP_APP_FAILED_TO_CREATE_ENV_FILE_FOR_ENV', environment.name));
|
|
48
54
|
}
|
|
49
55
|
}
|
|
@@ -12,17 +12,17 @@ class BootstrapCommand extends cli_command_1.Command {
|
|
|
12
12
|
return this._managementAPIClient;
|
|
13
13
|
}
|
|
14
14
|
async run() {
|
|
15
|
-
const
|
|
15
|
+
const bootstrapCommandFlags = this.parse(BootstrapCommand).flags;
|
|
16
16
|
try {
|
|
17
17
|
if (!this.authToken) {
|
|
18
18
|
this.error(messages_1.default.parse('CLI_BOOTSTRAP_LOGIN_FAILED'), { exit: 2, suggestions: ['https://www.contentstack.com/docs/developers/cli/authentication/'] });
|
|
19
19
|
}
|
|
20
20
|
// inquire user inputs
|
|
21
|
-
let appType =
|
|
21
|
+
let appType = bootstrapCommandFlags.appType || 'starterapp';
|
|
22
22
|
if (!appType) {
|
|
23
23
|
appType = await interactive_1.inquireAppType();
|
|
24
24
|
}
|
|
25
|
-
const selectedAppName =
|
|
25
|
+
const selectedAppName = bootstrapCommandFlags.appName;
|
|
26
26
|
let selectedApp;
|
|
27
27
|
if (!selectedAppName) {
|
|
28
28
|
if (appType === 'sampleapp') {
|
|
@@ -39,12 +39,12 @@ class BootstrapCommand extends cli_command_1.Command {
|
|
|
39
39
|
this.error(messages_1.default.parse('CLI_BOOTSTRAP_INVALID_APP_NAME'), { exit: 1 });
|
|
40
40
|
}
|
|
41
41
|
const appConfig = config_1.getAppLevelConfigByName(selectedAppName || selectedApp.configKey);
|
|
42
|
-
let cloneDirectory =
|
|
42
|
+
let cloneDirectory = bootstrapCommandFlags.directory;
|
|
43
43
|
if (!cloneDirectory) {
|
|
44
44
|
cloneDirectory = await interactive_1.inquireCloneDirectory();
|
|
45
45
|
}
|
|
46
46
|
// Check the access token
|
|
47
|
-
let accessToken =
|
|
47
|
+
let accessToken = bootstrapCommandFlags.accessToken;
|
|
48
48
|
if (appConfig.private && !accessToken) {
|
|
49
49
|
accessToken = await interactive_1.inquireGithubAccessToken();
|
|
50
50
|
}
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"1.0.
|
|
1
|
+
{"version":"1.0.5","commands":{"cm:bootstrap":{"id":"cm:bootstrap","description":"Bootstrap contentstack apps","pluginName":"@contentstack/cli-cm-bootstrap","pluginType":"core","aliases":[],"examples":["$ csdx cm:bootstrap","$ csdx cm:bootstrap -d <path/to/setup/the/app>","$ csdx cm:bootstrap -t <github access token>"],"flags":{"appName":{"name":"appName","type":"option","char":"a","description":"App name, reactjs-starter, nextjs-starter, gatsby-starter, angular-starter, nuxt-starter","required":false},"directory":{"name":"directory","type":"option","char":"d","description":"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","required":false},"accessToken":{"name":"accessToken","type":"option","char":"t","description":"Access token for private github repo","required":false},"appType":{"name":"appType","type":"option","char":"s","description":"Sample or Starter app","hidden":true,"required":false}},"args":[]}}}
|
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.0.
|
|
4
|
+
"version": "1.0.5",
|
|
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-command": "^0.1.1-beta.
|
|
21
|
-
"@contentstack/cli-cm-seed": "^1.0.
|
|
22
|
-
"@contentstack/management": "^1.
|
|
20
|
+
"@contentstack/cli-command": "^0.1.1-beta.6",
|
|
21
|
+
"@contentstack/cli-cm-seed": "^1.0.10",
|
|
22
|
+
"@contentstack/management": "^1.3.0",
|
|
23
23
|
"@oclif/command": "^1.8.0",
|
|
24
24
|
"@oclif/config": "^1.17.0",
|
|
25
25
|
"axios": "^0.21.1",
|