stepzen 0.9.37 → 0.9.38-beta.3
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/commands/deploy.js +4 -3
- package/lib/commands/import.js +2 -2
- package/lib/commands/init.js +3 -2
- package/lib/commands/list.js +3 -2
- package/lib/commands/login.js +2 -1
- package/lib/commands/start.js +11 -9
- package/lib/commands/transpile.js +2 -1
- package/lib/commands/upload.js +5 -4
- package/lib/commands/validate.js +2 -1
- package/lib/generate/dashboard-interface.js +3 -3
- package/lib/generate/helpers.d.ts +8 -1
- package/lib/generate/helpers.js +71 -15
- package/lib/generate/index.js +4 -3
- package/lib/hooks/prerun/ensure-permissions.d.ts +3 -0
- package/lib/hooks/prerun/ensure-permissions.js +20 -0
- package/lib/shared/configuration.js +4 -3
- package/lib/shared/constants.d.ts +2 -1
- package/lib/shared/constants.js +7 -4
- package/lib/shared/errors.d.ts +4 -0
- package/lib/shared/errors.js +12 -0
- package/lib/shared/utils.js +2 -1
- package/lib/shared/validation.js +7 -6
- package/lib/shared/workspace.js +4 -3
- package/lib/start/console.d.ts +1 -1
- package/lib/start/console.js +4 -11
- package/lib/start/deploy.js +16 -9
- package/oclif.manifest.json +1 -1
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ $ npm install -g stepzen
|
|
|
29
29
|
$ stepzen COMMAND
|
|
30
30
|
running command...
|
|
31
31
|
$ stepzen (-v|--version|version)
|
|
32
|
-
stepzen/0.9.
|
|
32
|
+
stepzen/0.9.38-beta.3 darwin-x64 node-v14.18.3
|
|
33
33
|
$ stepzen --help [COMMAND]
|
|
34
34
|
USAGE
|
|
35
35
|
$ stepzen COMMAND
|
|
@@ -136,7 +136,7 @@ OPTIONS
|
|
|
136
136
|
|
|
137
137
|
## `stepzen start`
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
upload and deploy your schema
|
|
140
140
|
|
|
141
141
|
```
|
|
142
142
|
USAGE
|
package/lib/commands/deploy.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
// objects, a single schema, and a collection of configurationsets
|
|
7
7
|
// and uses them to produce an endpoint which serves a GraphQL API.
|
|
8
8
|
const command_1 = require("@oclif/command");
|
|
9
|
+
const errors_1 = require("@oclif/errors");
|
|
9
10
|
const actions_1 = require("../shared/actions");
|
|
10
11
|
const configuration_1 = require("../shared/configuration");
|
|
11
12
|
class Deploy extends command_1.Command {
|
|
@@ -13,12 +14,12 @@ class Deploy extends command_1.Command {
|
|
|
13
14
|
const { args, flags } = this.parse(Deploy);
|
|
14
15
|
// Make sure that you definitely specify folder/name
|
|
15
16
|
if (args.destination.includes('/') === false) {
|
|
16
|
-
|
|
17
|
+
throw new errors_1.CLIError('You must specify the folder/name you want to use');
|
|
17
18
|
}
|
|
18
19
|
const configuration = configuration_1.readConfiguration();
|
|
19
20
|
if (!configuration) {
|
|
20
21
|
// Configuration not found. Most likely because someone is not logged in. Exit with error.
|
|
21
|
-
|
|
22
|
+
throw new errors_1.CLIError('You are probably not logged in.');
|
|
22
23
|
}
|
|
23
24
|
if (!flags.silent) {
|
|
24
25
|
this.log('Deploying...');
|
|
@@ -31,7 +32,7 @@ class Deploy extends command_1.Command {
|
|
|
31
32
|
}
|
|
32
33
|
else {
|
|
33
34
|
// Errors. Exit, and output the server's error response
|
|
34
|
-
|
|
35
|
+
throw new errors_1.CLIError(JSON.stringify(response.errors) || 'An error occurred.');
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
}
|
package/lib/commands/import.js
CHANGED
|
@@ -25,9 +25,9 @@ class Import extends command_1.Command {
|
|
|
25
25
|
}
|
|
26
26
|
// Make sure the user has latest Generator Schema
|
|
27
27
|
await deploy_1.default.run([
|
|
28
|
-
constants_1.
|
|
28
|
+
constants_1.STEPZEN_GENERATOR_ENGINES_ENDPOINT,
|
|
29
29
|
'--schema',
|
|
30
|
-
|
|
30
|
+
constants_1.STEPZEN_GENERATOR_ENGINES_SCHEMA,
|
|
31
31
|
'--silent',
|
|
32
32
|
]);
|
|
33
33
|
// Let's go!
|
package/lib/commands/init.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const command_1 = require("@oclif/command");
|
|
5
|
+
const errors_1 = require("@oclif/errors");
|
|
5
6
|
const fs = require("fs");
|
|
6
7
|
const glob = require("glob");
|
|
7
8
|
const inquirer = require("inquirer");
|
|
@@ -17,12 +18,12 @@ class Init extends command_1.Command {
|
|
|
17
18
|
// Make sure it is not already a workspace
|
|
18
19
|
const w = workspace_1.getWorkspace(directory);
|
|
19
20
|
if (w)
|
|
20
|
-
|
|
21
|
+
throw new errors_1.CLIError('This is already a workspace, cannot init');
|
|
21
22
|
// If you've passed an endpoint, validate it, and throw an error straight away if needed
|
|
22
23
|
if (flags.endpoint) {
|
|
23
24
|
const error = utils_1.validateEndpoint(flags.endpoint);
|
|
24
25
|
if (typeof error === 'string')
|
|
25
|
-
|
|
26
|
+
throw new errors_1.CLIError(error);
|
|
26
27
|
}
|
|
27
28
|
// Make a suggestion for the endpoint
|
|
28
29
|
const endpoint = flags.endpoint || `api/${moniker_1.default()}`;
|
package/lib/commands/list.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
// of resources stored within a stepzen account.
|
|
7
7
|
// You can use list to retrieve configurationsets and schemas.
|
|
8
8
|
const command_1 = require("@oclif/command");
|
|
9
|
+
const errors_1 = require("@oclif/errors");
|
|
9
10
|
const actions_1 = require("../shared/actions");
|
|
10
11
|
const configuration_1 = require("../shared/configuration");
|
|
11
12
|
class List extends command_1.Command {
|
|
@@ -15,7 +16,7 @@ class List extends command_1.Command {
|
|
|
15
16
|
const configuration = configuration_1.readConfiguration();
|
|
16
17
|
if (!configuration) {
|
|
17
18
|
// Configuration not found. Most likely because someone is not logged in. Exit with error.
|
|
18
|
-
|
|
19
|
+
throw new errors_1.CLIError('You are probably not logged in.');
|
|
19
20
|
}
|
|
20
21
|
const response = await actions_1.list(args.type);
|
|
21
22
|
if (response.success) {
|
|
@@ -30,7 +31,7 @@ class List extends command_1.Command {
|
|
|
30
31
|
}
|
|
31
32
|
else {
|
|
32
33
|
// Error. Exit, and output the server's error response
|
|
33
|
-
|
|
34
|
+
throw new errors_1.CLIError(JSON.stringify(response.errors) || 'An error occurred.');
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
}
|
package/lib/commands/login.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
5
5
|
// Stepzen login checks that credentials presented are good and
|
|
6
6
|
// subsequently changes the identity of the logged in account.
|
|
7
7
|
const command_1 = require("@oclif/command");
|
|
8
|
+
const errors_1 = require("@oclif/errors");
|
|
8
9
|
const cli_ux_1 = require("cli-ux");
|
|
9
10
|
const configuration_1 = require("../shared/configuration");
|
|
10
11
|
class Login extends command_1.Command {
|
|
@@ -45,7 +46,7 @@ class Login extends command_1.Command {
|
|
|
45
46
|
const isValidConfiguration = await configuration_1.verifyConfiguration(configuration);
|
|
46
47
|
if (!isValidConfiguration) {
|
|
47
48
|
// Exit, with error
|
|
48
|
-
|
|
49
|
+
throw new errors_1.CLIError('We are unable to verify your account details. Could you please check them?');
|
|
49
50
|
}
|
|
50
51
|
// Change the default account.
|
|
51
52
|
configuration_1.writeConfigurationToLoginFile(configuration);
|
package/lib/commands/start.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
const chokidar = require("chokidar");
|
|
5
5
|
const cli_ux_1 = require("cli-ux");
|
|
6
6
|
const command_1 = require("@oclif/command");
|
|
7
|
+
const errors_1 = require("@oclif/errors");
|
|
7
8
|
const throttle_debounce_1 = require("throttle-debounce");
|
|
8
9
|
const detect = require("detect-port");
|
|
9
10
|
const configuration_1 = require("../shared/configuration");
|
|
@@ -21,7 +22,7 @@ class Start extends command_1.Command {
|
|
|
21
22
|
const configuration = configuration_1.readConfiguration();
|
|
22
23
|
if (!configuration) {
|
|
23
24
|
// Configuration not found. Most likely because someone is not logged in. Exit with error.
|
|
24
|
-
|
|
25
|
+
throw new errors_1.CLIError('You are probably not logged in.');
|
|
25
26
|
}
|
|
26
27
|
// Get the working directory and workspace
|
|
27
28
|
const directory = utils_1.getDirectory(flags.dir);
|
|
@@ -41,7 +42,7 @@ class Start extends command_1.Command {
|
|
|
41
42
|
// Check the port is available
|
|
42
43
|
const port = await detect(flags.port);
|
|
43
44
|
if (flags.port !== port) {
|
|
44
|
-
|
|
45
|
+
throw new errors_1.CLIError(`Could not start - port ${flags.port} is already in use`);
|
|
45
46
|
}
|
|
46
47
|
// This is the file watcher
|
|
47
48
|
if (!flags['no-watcher']) {
|
|
@@ -51,19 +52,21 @@ class Start extends command_1.Command {
|
|
|
51
52
|
})
|
|
52
53
|
.on('change', throttle_debounce_1.debounce(500, async (path) => {
|
|
53
54
|
await utils_1.checkAuth();
|
|
54
|
-
|
|
55
|
-
start_1.deploy(path, workspace, flags);
|
|
55
|
+
utils_1.clearConsole();
|
|
56
|
+
await start_1.deploy(path, workspace, flags);
|
|
57
|
+
await start_1.console(workspace);
|
|
56
58
|
}));
|
|
57
59
|
}
|
|
58
60
|
// Start!
|
|
61
|
+
utils_1.clearConsole();
|
|
59
62
|
cli_ux_1.default.action.start('Starting...');
|
|
60
|
-
if (!flags['no-console']) {
|
|
61
|
-
start_1.console(workspace, flags);
|
|
62
|
-
}
|
|
63
63
|
// Unless explicitly disabled, auto-init
|
|
64
64
|
if (!flags['no-init']) {
|
|
65
65
|
await start_1.deploy(null, workspace, flags);
|
|
66
66
|
}
|
|
67
|
+
if (!flags['no-console']) {
|
|
68
|
+
start_1.console(workspace);
|
|
69
|
+
}
|
|
67
70
|
// Create the dashboard
|
|
68
71
|
if (!flags['no-dashboard']) {
|
|
69
72
|
const ui = await dashboard({
|
|
@@ -84,14 +87,13 @@ class Start extends command_1.Command {
|
|
|
84
87
|
workspace,
|
|
85
88
|
});
|
|
86
89
|
await ui.start();
|
|
87
|
-
await ui.open();
|
|
88
90
|
}
|
|
89
91
|
// Done
|
|
90
92
|
cli_ux_1.default.action.stop();
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
95
|
exports.default = Start;
|
|
94
|
-
Start.description = '
|
|
96
|
+
Start.description = 'upload and deploy your schema';
|
|
95
97
|
Start.flags = {
|
|
96
98
|
dir: command_1.flags.string({ description: 'working directory' }),
|
|
97
99
|
endpoint: command_1.flags.string({ description: 'Override workspace endpoint' }),
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const chalk = require("chalk");
|
|
5
5
|
const command_1 = require("@oclif/command");
|
|
6
|
+
const errors_1 = require("@oclif/errors");
|
|
6
7
|
const fs = require("fs-extra");
|
|
7
8
|
const path = require("path");
|
|
8
9
|
const utils_1 = require("../shared/utils");
|
|
@@ -31,7 +32,7 @@ class Transpile extends command_1.Command {
|
|
|
31
32
|
this.log(stitched);
|
|
32
33
|
}
|
|
33
34
|
catch (error) {
|
|
34
|
-
|
|
35
|
+
throw new errors_1.CLIError(chalk.red(error));
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
}
|
package/lib/commands/upload.js
CHANGED
|
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
// When uploaded, each resource is stored and referenced using a name
|
|
11
11
|
// provided by the user.
|
|
12
12
|
const command_1 = require("@oclif/command");
|
|
13
|
+
const errors_1 = require("@oclif/errors");
|
|
13
14
|
const configuration_1 = require("../shared/configuration");
|
|
14
15
|
const actions_1 = require("../shared/actions");
|
|
15
16
|
class Upload extends command_1.Command {
|
|
@@ -17,16 +18,16 @@ class Upload extends command_1.Command {
|
|
|
17
18
|
const { args, flags } = this.parse(Upload);
|
|
18
19
|
// Make sure that you definitely specify folder/name
|
|
19
20
|
if (args.destination.includes('/') === false) {
|
|
20
|
-
|
|
21
|
+
throw new errors_1.CLIError('You must specify the folder/name you want to use');
|
|
21
22
|
}
|
|
22
23
|
const configuration = configuration_1.readConfiguration();
|
|
23
24
|
if (!configuration) {
|
|
24
25
|
// Configuration not found. Most likely because someone is not logged in. Exit with error.
|
|
25
|
-
|
|
26
|
+
throw new errors_1.CLIError('You are probably not logged in.');
|
|
26
27
|
}
|
|
27
28
|
if (!flags.file && !flags.dir) {
|
|
28
29
|
// You need to specify a file or directory. Exit with error.
|
|
29
|
-
|
|
30
|
+
throw new errors_1.CLIError('You must specify a file or directory.');
|
|
30
31
|
}
|
|
31
32
|
if (!flags.silent) {
|
|
32
33
|
this.log('Uploading...');
|
|
@@ -39,7 +40,7 @@ class Upload extends command_1.Command {
|
|
|
39
40
|
}
|
|
40
41
|
else {
|
|
41
42
|
// Errors. Exit, and output the server's error response
|
|
42
|
-
|
|
43
|
+
throw new errors_1.CLIError(JSON.stringify(response.errors) || 'An error occurred.');
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
}
|
package/lib/commands/validate.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const chalk = require("chalk");
|
|
5
5
|
const command_1 = require("@oclif/command");
|
|
6
|
+
const errors_1 = require("@oclif/errors");
|
|
6
7
|
const utils_1 = require("../shared/utils");
|
|
7
8
|
const { stitch, validate } = require('@stepzen/transpiler');
|
|
8
9
|
class Validate extends command_1.Command {
|
|
@@ -16,7 +17,7 @@ class Validate extends command_1.Command {
|
|
|
16
17
|
});
|
|
17
18
|
}
|
|
18
19
|
catch (error) {
|
|
19
|
-
|
|
20
|
+
throw new errors_1.CLIError(chalk.red(error));
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
}
|
|
@@ -9,12 +9,12 @@ const deploy_1 = require("../commands/deploy");
|
|
|
9
9
|
const constants_1 = require("../shared/constants");
|
|
10
10
|
const { merge } = require('@stepzen/transpiler');
|
|
11
11
|
exports.createDashboardInterface = (workspace) => ({
|
|
12
|
-
endpoint: constants_1.
|
|
12
|
+
endpoint: constants_1.STEPZEN_GENERATOR_ENGINES_ENDPOINT,
|
|
13
13
|
onStart: async () => {
|
|
14
14
|
await deploy_1.default.run([
|
|
15
|
-
constants_1.
|
|
15
|
+
constants_1.STEPZEN_GENERATOR_ENGINES_ENDPOINT,
|
|
16
16
|
'--schema',
|
|
17
|
-
|
|
17
|
+
constants_1.STEPZEN_GENERATOR_ENGINES_SCHEMA,
|
|
18
18
|
'--silent',
|
|
19
19
|
]);
|
|
20
20
|
},
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import type { QuestionCollection, Answers } from 'inquirer';
|
|
1
2
|
export declare const createGeneratorFiles: (id: string, details: any) => Promise<string>;
|
|
2
|
-
export declare
|
|
3
|
+
export declare type GeneratorConfiguration = {
|
|
4
|
+
questions: QuestionCollection;
|
|
5
|
+
answers: Answers;
|
|
6
|
+
errors: Record<string, any>;
|
|
7
|
+
status: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const getConfiguration: (id: string, details?: any) => Promise<GeneratorConfiguration | null>;
|
|
3
10
|
export declare const getSchemaList: (arg: string) => string[];
|
|
4
11
|
export declare const getTemplates: () => Promise<string>;
|
|
5
12
|
export declare const askGeneratorQuestions: (id: string, settings: any, state: any) => Promise<any>;
|
package/lib/generate/helpers.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.askTemplateQuestions = exports.askGeneratorQuestions = exports.getTemplates = exports.getSchemaList = exports.getConfiguration = exports.createGeneratorFiles = void 0;
|
|
5
|
+
const errors_1 = require("@oclif/errors");
|
|
6
|
+
const chalk = require("chalk");
|
|
7
|
+
const debug = require("debug");
|
|
5
8
|
const node_fetch_1 = require("node-fetch");
|
|
6
9
|
const fs = require("fs-extra");
|
|
7
10
|
const inquirer = require("inquirer");
|
|
@@ -11,11 +14,12 @@ const path = require("path");
|
|
|
11
14
|
const shell = require("shelljs");
|
|
12
15
|
const configuration_1 = require("../shared/configuration");
|
|
13
16
|
const constants_1 = require("../shared/constants");
|
|
17
|
+
const errors_2 = require("../shared/errors");
|
|
14
18
|
const { version } = require('../../package.json');
|
|
15
19
|
exports.createGeneratorFiles = async (id, details) => {
|
|
16
20
|
const config = configuration_1.readConfiguration();
|
|
17
21
|
const domain = constants_1.STEPZEN_DOMAIN.replace('.io', '.net');
|
|
18
|
-
const url = `https://${config.account}.${domain}/${constants_1.
|
|
22
|
+
const url = `https://${config.account}.${domain}/${constants_1.STEPZEN_GENERATOR_ENGINES_ENDPOINT}/__graphql`;
|
|
19
23
|
const response = await node_fetch_1.default(url, {
|
|
20
24
|
body: JSON.stringify({
|
|
21
25
|
query: `
|
|
@@ -35,10 +39,13 @@ exports.createGeneratorFiles = async (id, details) => {
|
|
|
35
39
|
},
|
|
36
40
|
method: 'POST',
|
|
37
41
|
});
|
|
38
|
-
const { data
|
|
42
|
+
const { data, errors } = await response.json();
|
|
43
|
+
if (errors) {
|
|
44
|
+
throw new errors_1.CLIError(errors_2.formatTemporaryErrorMessage(errors));
|
|
45
|
+
}
|
|
39
46
|
const tmp = path.join(os.tmpdir(), `stepzen-generated-schema-${Date.now()}`);
|
|
40
47
|
fs.ensureDirSync(tmp);
|
|
41
|
-
for (const file of create) {
|
|
48
|
+
for (const file of data.create) {
|
|
42
49
|
const dir = path.join(tmp, file.name);
|
|
43
50
|
fs.writeFileSync(dir, file.content);
|
|
44
51
|
}
|
|
@@ -47,7 +54,7 @@ exports.createGeneratorFiles = async (id, details) => {
|
|
|
47
54
|
exports.getConfiguration = async (id, details = {}) => {
|
|
48
55
|
const config = configuration_1.readConfiguration();
|
|
49
56
|
const domain = constants_1.STEPZEN_DOMAIN.replace('.io', '.net');
|
|
50
|
-
const url = `https://${config.account}.${domain}/${constants_1.
|
|
57
|
+
const url = `https://${config.account}.${domain}/${constants_1.STEPZEN_GENERATOR_ENGINES_ENDPOINT}/__graphql`;
|
|
51
58
|
const response = await node_fetch_1.default(url, {
|
|
52
59
|
body: JSON.stringify({
|
|
53
60
|
query: `
|
|
@@ -69,8 +76,29 @@ exports.getConfiguration = async (id, details = {}) => {
|
|
|
69
76
|
},
|
|
70
77
|
method: 'POST',
|
|
71
78
|
});
|
|
72
|
-
const { data } = await response.json();
|
|
73
|
-
|
|
79
|
+
const { data, errors } = await response.json();
|
|
80
|
+
if (errors) {
|
|
81
|
+
return {
|
|
82
|
+
questions: [],
|
|
83
|
+
answers: {},
|
|
84
|
+
status: -1,
|
|
85
|
+
errors: {
|
|
86
|
+
error: errors[0].message,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
if (data.configure) {
|
|
92
|
+
data.configure.answers = JSON.parse(data.configure.answers);
|
|
93
|
+
data.configure.errors = JSON.parse(data.configure.errors);
|
|
94
|
+
data.configure.questions = JSON.parse(data.configure.questions);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
debug('stepzen:response')(error);
|
|
99
|
+
throw new errors_1.CLIError(errors_2.PERMANENT_STEPZEN_ERROR);
|
|
100
|
+
}
|
|
101
|
+
return data.configure;
|
|
74
102
|
};
|
|
75
103
|
exports.getSchemaList = (arg) => {
|
|
76
104
|
const schemas = arg.split(',').map((schema) => schema.trim());
|
|
@@ -78,10 +106,17 @@ exports.getSchemaList = (arg) => {
|
|
|
78
106
|
for (const schema of schemas) {
|
|
79
107
|
const instances = schemas.filter((s) => s === schema);
|
|
80
108
|
if (instances.length > 1) {
|
|
81
|
-
throw new
|
|
109
|
+
throw new errors_1.CLIError(`You are trying to import "${schema}" more than once`);
|
|
82
110
|
}
|
|
83
111
|
}
|
|
84
|
-
return schemas
|
|
112
|
+
return schemas.map(schema => {
|
|
113
|
+
// support `postgres` as an alias to `postgresql`
|
|
114
|
+
// https://github.com/steprz/stepzen-cli/issues/431
|
|
115
|
+
if (schema.toLowerCase() === 'postgres') {
|
|
116
|
+
return 'postgresql';
|
|
117
|
+
}
|
|
118
|
+
return schema;
|
|
119
|
+
});
|
|
85
120
|
};
|
|
86
121
|
exports.getTemplates = async () => {
|
|
87
122
|
const tmp = path.join(os.tmpdir(), `stepzen-api-templates-${Date.now()}`);
|
|
@@ -90,23 +125,44 @@ exports.getTemplates = async () => {
|
|
|
90
125
|
const command = `git clone ${repository} ${tmp}`;
|
|
91
126
|
const result = shell.exec(command, { silent: true });
|
|
92
127
|
if (result.code !== 0) {
|
|
93
|
-
throw new
|
|
128
|
+
throw new errors_1.CLIError(result.stderr.trim());
|
|
94
129
|
}
|
|
95
130
|
return tmp;
|
|
96
131
|
};
|
|
97
132
|
exports.askGeneratorQuestions = async (id, settings, state) => {
|
|
133
|
+
var _a, _b;
|
|
98
134
|
let status = -1;
|
|
99
135
|
do {
|
|
100
|
-
|
|
136
|
+
if (settings.questions.length === 0) {
|
|
137
|
+
// would cause a hot loop, so it's an error
|
|
138
|
+
throw new errors_1.CLIError(errors_2.PERMANENT_STEPZEN_ERROR);
|
|
139
|
+
}
|
|
140
|
+
const questions = settings.questions.map((question) => (Object.assign(Object.assign({ type: 'password' }, question), {
|
|
141
|
+
// set the previous iteration's answer as the default value, except for password fields
|
|
142
|
+
default: question.type && question.type !== 'password'
|
|
143
|
+
? lodash_1.get(state, question.name)
|
|
144
|
+
: undefined })));
|
|
101
145
|
// eslint-disable-next-line no-await-in-loop
|
|
102
146
|
const answers = await inquirer.prompt(questions);
|
|
103
147
|
state = lodash_1.merge(state, answers);
|
|
104
148
|
// eslint-disable-next-line no-await-in-loop
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
149
|
+
const result = await exports.getConfiguration(id, state);
|
|
150
|
+
if (!result) {
|
|
151
|
+
// at this point the generator ${id} should have been validated
|
|
152
|
+
throw new errors_1.CLIError(errors_2.PERMANENT_STEPZEN_ERROR);
|
|
153
|
+
}
|
|
154
|
+
if (result.status === -1) {
|
|
155
|
+
console.log();
|
|
156
|
+
console.log(chalk.red(`A problem occurred when running a ${id} import${((_a = result.errors) === null || _a === void 0 ? void 0 : _a.error) ? `: "${(_b = result.errors) === null || _b === void 0 ? void 0 : _b.error}"` : '.'}`));
|
|
157
|
+
console.log('Please try again');
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
settings = {
|
|
161
|
+
questions: result.questions,
|
|
162
|
+
};
|
|
163
|
+
// eslint-disable-next-line require-atomic-updates
|
|
164
|
+
state = lodash_1.merge(state, result.answers);
|
|
165
|
+
}
|
|
110
166
|
status = result.status;
|
|
111
167
|
} while (status === -1);
|
|
112
168
|
return state;
|
package/lib/generate/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const errors_1 = require("@oclif/errors");
|
|
5
6
|
const cli_ux_1 = require("cli-ux");
|
|
6
7
|
const fs = require("fs-extra");
|
|
7
8
|
const lodash = require("lodash");
|
|
@@ -25,10 +26,10 @@ exports.default = async (schemas, source) => {
|
|
|
25
26
|
// Get all generators from...Generators
|
|
26
27
|
for (var _f = tslib_1.__asyncValues(Object.keys(generators)), _g; _g = await _f.next(), !_g.done;) {
|
|
27
28
|
const id = _g.value;
|
|
28
|
-
const
|
|
29
|
+
const configure = await helpers_1.getConfiguration(id, {});
|
|
29
30
|
if (configure) {
|
|
30
31
|
generators[id] = {
|
|
31
|
-
questions:
|
|
32
|
+
questions: configure.questions,
|
|
32
33
|
type: 'generator',
|
|
33
34
|
};
|
|
34
35
|
}
|
|
@@ -79,7 +80,7 @@ exports.default = async (schemas, source) => {
|
|
|
79
80
|
.filter(i => i);
|
|
80
81
|
if (notFound.length > 0) {
|
|
81
82
|
fs.removeSync(templates);
|
|
82
|
-
throw new
|
|
83
|
+
throw new errors_1.CLIError(`Cannot find the schema ${notFound[0]}`);
|
|
83
84
|
}
|
|
84
85
|
try {
|
|
85
86
|
// Ask all the questions
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const constants_1 = require("../../shared/constants");
|
|
7
|
+
const constants_2 = require("../../shared/constants");
|
|
8
|
+
const hook = async function () {
|
|
9
|
+
// checking file existence and permissions (https://betterprogramming.pub/dbce0f2b373c)
|
|
10
|
+
const file = path.join(constants_2.STEPZEN_CONFIG_DIRECTORY, constants_1.STEPZEN_CONFIG_FILE);
|
|
11
|
+
try {
|
|
12
|
+
fs.accessSync(file, fs.constants.F_OK | fs.constants.R_OK | fs.constants.W_OK);
|
|
13
|
+
const mode = fs.statSync(file).mode;
|
|
14
|
+
// https://stackoverflow.com/questions/50839744/how-to-interpret-the-number-returned-from-statsync
|
|
15
|
+
if (mode & (fs.constants.S_IRWXG | fs.constants.S_IRWXG))
|
|
16
|
+
fs.chmodSync(file, fs.constants.S_IRWXU);
|
|
17
|
+
}
|
|
18
|
+
catch (error) { }
|
|
19
|
+
};
|
|
20
|
+
exports.default = hook;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.writeConfigurationToLoginFile = exports.verifyConfiguration = exports.removeConfigurationFromLoginFile = exports.importConfiguration = exports.readConfiguration = void 0;
|
|
5
5
|
// This file contains methods for managing configuration
|
|
6
|
+
const errors_1 = require("@oclif/errors");
|
|
6
7
|
const debug = require("debug");
|
|
7
8
|
const node_fetch_1 = require("node-fetch");
|
|
8
9
|
const fs = require("fs");
|
|
@@ -32,7 +33,7 @@ exports.readConfiguration = () => {
|
|
|
32
33
|
};
|
|
33
34
|
exports.importConfiguration = (filepath) => {
|
|
34
35
|
if (!fs.existsSync(filepath)) {
|
|
35
|
-
throw new
|
|
36
|
+
throw new errors_1.CLIError('Configuration file does not exist');
|
|
36
37
|
}
|
|
37
38
|
const configuration = fs.readFileSync(filepath, 'utf8');
|
|
38
39
|
try {
|
|
@@ -41,7 +42,7 @@ exports.importConfiguration = (filepath) => {
|
|
|
41
42
|
return parsed;
|
|
42
43
|
}
|
|
43
44
|
catch (_a) {
|
|
44
|
-
throw new
|
|
45
|
+
throw new errors_1.CLIError('Configuration file is not valid yaml');
|
|
45
46
|
}
|
|
46
47
|
};
|
|
47
48
|
exports.removeConfigurationFromLoginFile = () => {
|
|
@@ -85,6 +86,6 @@ exports.writeConfigurationToLoginFile = (configuration) => {
|
|
|
85
86
|
}
|
|
86
87
|
// Write the configuration file. Overwrites if it already exists.
|
|
87
88
|
const file = path.join(constants_1.STEPZEN_CONFIG_DIRECTORY, constants_1.STEPZEN_CONFIG_FILE);
|
|
88
|
-
fs.writeFileSync(file, content);
|
|
89
|
+
fs.writeFileSync(file, content, { mode: '600' });
|
|
89
90
|
return configuration;
|
|
90
91
|
};
|
|
@@ -3,7 +3,8 @@ export declare const STEPZEN_CONFIG_DIRECTORY: string;
|
|
|
3
3
|
export declare const STEPZEN_CONFIG_FILE: string;
|
|
4
4
|
export declare const STEPZEN_DOMAIN: string;
|
|
5
5
|
export declare const STEPZEN_SERVER_URL: string;
|
|
6
|
-
export declare const STEPZEN_GENERATOR_ENGINES_SCHEMA
|
|
6
|
+
export declare const STEPZEN_GENERATOR_ENGINES_SCHEMA: string;
|
|
7
|
+
export declare const STEPZEN_GENERATOR_ENGINES_ENDPOINT = "stepzen-generator/engines";
|
|
7
8
|
export declare const STEPZEN_API_TEMPLATES_REPOSITORY = "https://github.com/steprz/stepzen-schemas";
|
|
8
9
|
export declare const ADMIN_ACCOUNT_URL = "/cli/admin/account";
|
|
9
10
|
export declare const ADMIN_DEPLOY_URL = "/cli/admin/deploy";
|
package/lib/shared/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ADMIN_VERIFY_URL = exports.ADMIN_UPLOAD_URL = exports.ADMIN_LIST_URL = exports.ADMIN_DEPLOY_URL = exports.ADMIN_ACCOUNT_URL = exports.STEPZEN_API_TEMPLATES_REPOSITORY = exports.STEPZEN_GENERATOR_ENGINES_SCHEMA = exports.STEPZEN_SERVER_URL = exports.STEPZEN_DOMAIN = exports.STEPZEN_CONFIG_FILE = exports.STEPZEN_CONFIG_DIRECTORY = exports.STEPZEN_CONFIG_CONTENT = void 0;
|
|
4
|
+
exports.ADMIN_VERIFY_URL = exports.ADMIN_UPLOAD_URL = exports.ADMIN_LIST_URL = exports.ADMIN_DEPLOY_URL = exports.ADMIN_ACCOUNT_URL = exports.STEPZEN_API_TEMPLATES_REPOSITORY = exports.STEPZEN_GENERATOR_ENGINES_ENDPOINT = exports.STEPZEN_GENERATOR_ENGINES_SCHEMA = exports.STEPZEN_SERVER_URL = exports.STEPZEN_DOMAIN = exports.STEPZEN_CONFIG_FILE = exports.STEPZEN_CONFIG_DIRECTORY = exports.STEPZEN_CONFIG_CONTENT = void 0;
|
|
5
5
|
// This file contains constants and all magic strings
|
|
6
6
|
const dotenv = require("dotenv");
|
|
7
7
|
const os = require("os");
|
|
@@ -9,7 +9,7 @@ const path = require("path");
|
|
|
9
9
|
// This allows you to set environment variables in a `.env` file.
|
|
10
10
|
// This file needs to be in your working directory.
|
|
11
11
|
dotenv.config();
|
|
12
|
-
const { STEPZEN_CONFIG_CONTENT: ENV_VAR_STEPZEN_CONFIG_CONTENT, STEPZEN_CONFIG_FILE: ENV_VAR_STEPZEN_CONFIG_FILE, STEPZEN_DOMAIN: ENV_VAR_STEPZEN_DOMAIN, STEPZEN_SERVER_URL: ENV_VAR_STEPZEN_SERVER_URL, } = process.env;
|
|
12
|
+
const { STEPZEN_CONFIG_CONTENT: ENV_VAR_STEPZEN_CONFIG_CONTENT, STEPZEN_CONFIG_FILE: ENV_VAR_STEPZEN_CONFIG_FILE, STEPZEN_DOMAIN: ENV_VAR_STEPZEN_DOMAIN, STEPZEN_GENERATOR_ENGINES_SCHEMA: ENV_VAR_STEPZEN_GENERATOR_ENGINES_SCHEMA, STEPZEN_SERVER_URL: ENV_VAR_STEPZEN_SERVER_URL, } = process.env;
|
|
13
13
|
// Where your authentication details are stored locally
|
|
14
14
|
exports.STEPZEN_CONFIG_CONTENT = ENV_VAR_STEPZEN_CONFIG_CONTENT;
|
|
15
15
|
exports.STEPZEN_CONFIG_DIRECTORY = path.join(os.homedir(), '.stepzen');
|
|
@@ -18,8 +18,11 @@ exports.STEPZEN_CONFIG_FILE = ENV_VAR_STEPZEN_CONFIG_FILE || 'stepzen-config.yam
|
|
|
18
18
|
exports.STEPZEN_DOMAIN = ENV_VAR_STEPZEN_DOMAIN || 'stepzen.io';
|
|
19
19
|
// The zenctl URL. Override with the env var `STEPZEN_SERVER_URL`
|
|
20
20
|
exports.STEPZEN_SERVER_URL = ENV_VAR_STEPZEN_SERVER_URL || 'https://{account}.stepzen.io';
|
|
21
|
-
// Generator Engines schema folder/name
|
|
22
|
-
|
|
21
|
+
// Generator Engines schema: folder/name
|
|
22
|
+
// Use 'stepzen/engines-dev' to test the dev instance of https://github.com/steprz/generator-engines
|
|
23
|
+
exports.STEPZEN_GENERATOR_ENGINES_SCHEMA = ENV_VAR_STEPZEN_GENERATOR_ENGINES_SCHEMA || 'stepzen/engines';
|
|
24
|
+
// Generator Engines schema: target API endpoint
|
|
25
|
+
exports.STEPZEN_GENERATOR_ENGINES_ENDPOINT = 'stepzen-generator/engines';
|
|
23
26
|
// API Templates repository
|
|
24
27
|
exports.STEPZEN_API_TEMPLATES_REPOSITORY = 'https://github.com/steprz/stepzen-schemas';
|
|
25
28
|
// Paths to the endpoints used
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.PERMANENT_STEPZEN_ERROR = exports.formatTemporaryErrorMessage = void 0;
|
|
5
|
+
exports.formatTemporaryErrorMessage = (errors) => `A problem occurred while processing your import${errors.length > 0 && errors[0].message ? `: "${errors[0].message}"` : ''}. Please try again.` +
|
|
6
|
+
` If the issue persists, make sure you are on the latest version of StepZen ` +
|
|
7
|
+
`CLI. And if the issue still persists contact support via the StepZen discord ` +
|
|
8
|
+
`channel (https://discord.gg/9k2VdPn2FR).`;
|
|
9
|
+
exports.PERMANENT_STEPZEN_ERROR = 'An unexpected problem occurred while processing your import.' +
|
|
10
|
+
` If the issue persists, make sure you are on the latest version of StepZen ` +
|
|
11
|
+
`CLI. And if the issue still persists contact support via the StepZen discord ` +
|
|
12
|
+
`channel (https://discord.gg/9k2VdPn2FR).`;
|
package/lib/shared/utils.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.validateEndpoint = exports.getStepZenExtensions = exports.getDirectory = exports.ensureApiKey = exports.clearConsole = exports.checkAuth = void 0;
|
|
5
|
+
const errors_1 = require("@oclif/errors");
|
|
5
6
|
const chalk = require("chalk");
|
|
6
7
|
const debug = require("debug");
|
|
7
8
|
const node_fetch_1 = require("node-fetch");
|
|
@@ -77,7 +78,7 @@ exports.getDirectory = (d = process.cwd()) => {
|
|
|
77
78
|
directory = path.resolve(directory);
|
|
78
79
|
// If the path does not exist, throw an error
|
|
79
80
|
if (!fs.existsSync(directory)) {
|
|
80
|
-
throw new
|
|
81
|
+
throw new errors_1.CLIError(`Cannot find ${directory}`);
|
|
81
82
|
}
|
|
82
83
|
return directory;
|
|
83
84
|
};
|
package/lib/shared/validation.js
CHANGED
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.validateSchema = exports.validateConfigurationset = void 0;
|
|
5
|
+
const errors_1 = require("@oclif/errors");
|
|
5
6
|
const fs = require("fs");
|
|
6
7
|
const glob = require("glob");
|
|
7
8
|
const yaml = require("yaml");
|
|
8
9
|
// Validate the Configurationset file
|
|
9
10
|
exports.validateConfigurationset = async (file) => {
|
|
10
11
|
if (!file) {
|
|
11
|
-
throw new
|
|
12
|
+
throw new errors_1.CLIError('You must provide a file path');
|
|
12
13
|
}
|
|
13
14
|
if (!fs.existsSync(file)) {
|
|
14
|
-
throw new
|
|
15
|
+
throw new errors_1.CLIError('The file does not exist');
|
|
15
16
|
}
|
|
16
17
|
const content = fs.readFileSync(file, 'utf8');
|
|
17
18
|
// Ensure the file is valid YAML
|
|
@@ -19,20 +20,20 @@ exports.validateConfigurationset = async (file) => {
|
|
|
19
20
|
yaml.parse(content);
|
|
20
21
|
}
|
|
21
22
|
catch (_a) {
|
|
22
|
-
throw new
|
|
23
|
+
throw new errors_1.CLIError('The file is not valid YAML');
|
|
23
24
|
}
|
|
24
25
|
};
|
|
25
26
|
// Validate the Schema directory
|
|
26
27
|
exports.validateSchema = async (directory) => {
|
|
27
28
|
if (!directory) {
|
|
28
|
-
throw new
|
|
29
|
+
throw new errors_1.CLIError('You must provide a directory path');
|
|
29
30
|
}
|
|
30
31
|
if (!fs.existsSync(directory)) {
|
|
31
|
-
throw new
|
|
32
|
+
throw new errors_1.CLIError('The directory does not exist');
|
|
32
33
|
}
|
|
33
34
|
// Ensure there's a root `index.graphql` file
|
|
34
35
|
const allSchemaFiles = glob.sync('index.graphql', { cwd: directory });
|
|
35
36
|
if (allSchemaFiles.length === 0) {
|
|
36
|
-
throw new
|
|
37
|
+
throw new errors_1.CLIError('Schemas must include an `index.graphql` file');
|
|
37
38
|
}
|
|
38
39
|
};
|
package/lib/shared/workspace.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.getWorkspace = void 0;
|
|
5
|
+
const errors_1 = require("@oclif/errors");
|
|
5
6
|
const fs = require("fs");
|
|
6
7
|
const path = require("path");
|
|
7
8
|
const utils_1 = require("./utils");
|
|
@@ -32,7 +33,7 @@ exports.getWorkspace = (directory) => {
|
|
|
32
33
|
workspace = Object.assign(Object.assign({}, workspace), config);
|
|
33
34
|
}
|
|
34
35
|
catch (_a) {
|
|
35
|
-
throw new
|
|
36
|
+
throw new errors_1.CLIError(`Cannot parse configuration from ${filepath}`);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
// Add the 'schema' property, which is the directory + the 'root'
|
|
@@ -41,10 +42,10 @@ exports.getWorkspace = (directory) => {
|
|
|
41
42
|
if (workspace.directory) {
|
|
42
43
|
const error = utils_1.validateEndpoint(workspace.endpoint);
|
|
43
44
|
if (typeof error === 'string')
|
|
44
|
-
throw new
|
|
45
|
+
throw new errors_1.CLIError(error);
|
|
45
46
|
const schemaExists = fs.existsSync(workspace.schema);
|
|
46
47
|
if (!schemaExists)
|
|
47
|
-
throw new
|
|
48
|
+
throw new errors_1.CLIError(`Cannot find workspace schema folder ${workspace.schema}`);
|
|
48
49
|
return workspace;
|
|
49
50
|
}
|
|
50
51
|
// This is not a workspace folder
|
package/lib/start/console.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: (workspace: any
|
|
1
|
+
declare const _default: (workspace: any) => Promise<void>;
|
|
2
2
|
export default _default;
|
package/lib/start/console.js
CHANGED
|
@@ -2,22 +2,15 @@
|
|
|
2
2
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const chalk = require("chalk");
|
|
5
|
-
const cli_ux_1 = require("cli-ux");
|
|
6
5
|
const fs = require("fs");
|
|
7
6
|
const os = require("os");
|
|
8
7
|
const path = require("path");
|
|
9
|
-
|
|
10
|
-
// eslint-disable-next-line max-params
|
|
11
|
-
exports.default = async (workspace, flags) => {
|
|
12
|
-
utils_1.clearConsole();
|
|
8
|
+
exports.default = async (workspace) => {
|
|
13
9
|
const cwd = workspace.schema.replace(os.homedir(), '~');
|
|
14
10
|
const config = path.join(cwd, 'config.yaml');
|
|
11
|
+
console.log();
|
|
15
12
|
if (fs.existsSync(config)) {
|
|
16
|
-
console.log(`Watching ${chalk.blue(config)} for configuration changes
|
|
17
|
-
}
|
|
18
|
-
console.log(`Watching ${chalk.blue(cwd)} for GraphQL changes`);
|
|
19
|
-
if (!flags['no-dashboard']) {
|
|
20
|
-
console.log();
|
|
21
|
-
cli_ux_1.default.url(`Running StepZen at http://localhost:${flags.port}/${workspace.endpoint}`, `http://localhost:${flags.port}/${workspace.endpoint}`);
|
|
13
|
+
console.log(`Watching ${chalk.blue(config)} for configuration changes...`);
|
|
22
14
|
}
|
|
15
|
+
console.log(`Watching ${chalk.blue(cwd)} for GraphQL changes...`);
|
|
23
16
|
};
|
package/lib/start/deploy.js
CHANGED
|
@@ -4,9 +4,9 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
5
5
|
const chalk = require("chalk");
|
|
6
6
|
const cli_ux_1 = require("cli-ux");
|
|
7
|
-
const date_fns_1 = require("date-fns");
|
|
8
7
|
const fs = require("fs-extra");
|
|
9
8
|
const path = require("path");
|
|
9
|
+
const prettyMilliseconds = require("pretty-ms");
|
|
10
10
|
const deploy_1 = require("../commands/deploy");
|
|
11
11
|
const configuration_1 = require("../shared/configuration");
|
|
12
12
|
const constants_1 = require("../shared/constants");
|
|
@@ -16,7 +16,6 @@ const dotenv = require('dotenv');
|
|
|
16
16
|
exports.default = async (file, workspace, flags) => {
|
|
17
17
|
var e_1, _a;
|
|
18
18
|
dotenv.config({ path: path.join(workspace.directory, '.env') });
|
|
19
|
-
console.log();
|
|
20
19
|
if (file) {
|
|
21
20
|
console.log(`File changed: ${chalk.blue(file)}`);
|
|
22
21
|
}
|
|
@@ -33,7 +32,7 @@ exports.default = async (file, workspace, flags) => {
|
|
|
33
32
|
return;
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
|
-
cli_ux_1.default.action.start(
|
|
35
|
+
cli_ux_1.default.action.start(`Deploying ${chalk.yellow(workspace.endpoint)} to StepZen`);
|
|
37
36
|
const deployArgs = [workspace.endpoint, '--silent'];
|
|
38
37
|
const uploadCmds = [];
|
|
39
38
|
const configPath = path.join(workspace.schema, 'config.yaml');
|
|
@@ -72,6 +71,7 @@ exports.default = async (file, workspace, flags) => {
|
|
|
72
71
|
console.log(chalk.red(error));
|
|
73
72
|
}
|
|
74
73
|
};
|
|
74
|
+
const deployStart = new Date().getTime();
|
|
75
75
|
try {
|
|
76
76
|
for (var uploadCmds_1 = tslib_1.__asyncValues(uploadCmds), uploadCmds_1_1; uploadCmds_1_1 = await uploadCmds_1.next(), !uploadCmds_1_1.done;) {
|
|
77
77
|
const cmd = uploadCmds_1_1.value;
|
|
@@ -98,13 +98,20 @@ exports.default = async (file, workspace, flags) => {
|
|
|
98
98
|
logError(error);
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
console.log();
|
|
105
|
-
console.log(chalk.green(`Successfully deployed ${what} at ${when}`));
|
|
101
|
+
const deployEnd = new Date().getTime();
|
|
102
|
+
const deployTime = deployEnd - deployStart;
|
|
103
|
+
cli_ux_1.default.action.stop(`${chalk.grey('done in')} ${prettyMilliseconds(deployTime)} 🚀`);
|
|
106
104
|
const domain = constants_1.STEPZEN_DOMAIN.replace('.io', '.net');
|
|
107
105
|
const endpoint = `https://${configuration.account}.${domain}/${workspace.endpoint}/__graphql`;
|
|
108
106
|
console.log();
|
|
109
|
-
console.log(chalk.grey(`Your
|
|
107
|
+
console.log(chalk.grey(`Your API url is`, chalk.green(` ${endpoint}`)));
|
|
108
|
+
console.log();
|
|
109
|
+
console.log(chalk.grey(`You can test your hosted API with cURL:`));
|
|
110
|
+
console.log();
|
|
111
|
+
console.log(`curl ${endpoint} \\`);
|
|
112
|
+
console.log(` --header "Authorization: Apikey {{insert yours from https://stepzen.com/account}}" \\`);
|
|
113
|
+
console.log(` --header "Content-Type: application/json" \\`);
|
|
114
|
+
console.log(` --data '{"query": "your graphql query"}'`);
|
|
115
|
+
console.log();
|
|
116
|
+
console.log(chalk.grey(`or explore it with GraphiQL at`), chalk.green(` http://localhost:${flags.port}/${workspace.endpoint}`));
|
|
110
117
|
};
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.9.
|
|
1
|
+
{"version":"0.9.38-beta.3","commands":{"deploy":{"id":"deploy","description":"deploy to stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"configurationsets":{"name":"configurationsets","type":"option","description":"Configurationsets to use","default":""},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"schema":{"name":"schema","type":"option","description":"Schema to use","required":true},"silent":{"name":"silent","type":"boolean","allowNo":false}},"args":[{"name":"destination","description":"destination","required":true}]},"import":{"id":"import","description":"import schemas from stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"dir":{"name":"dir","type":"option","description":"working directory"},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"silent":{"name":"silent","type":"boolean","hidden":true,"allowNo":false}},"args":[{"name":"schemas","required":true}]},"init":{"id":"init","description":"stepzen init","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"endpoint":{"name":"endpoint","type":"option","hidden":true},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"yes":{"name":"yes","type":"boolean","hidden":true,"allowNo":false}},"args":[{"name":"directory","hidden":true}]},"lint":{"id":"lint","description":"stepzen lint","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"dir":{"name":"dir","type":"option","hidden":true},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"list":{"id":"list","description":"list your items","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"type","description":"type","required":true,"options":["configurationsets","schemas"]}]},"login":{"id":"login","description":"log in to stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"account":{"name":"account","type":"option","char":"a","hidden":true},"adminkey":{"name":"adminkey","type":"option","char":"k","hidden":true},"config":{"name":"config","type":"option","hidden":true},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"logout":{"id":"logout","description":"log out of stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"start":{"id":"start","description":"upload and deploy your schema","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"dir":{"name":"dir","type":"option","description":"working directory"},"endpoint":{"name":"endpoint","type":"option","description":"Override workspace endpoint"},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"no-console":{"name":"no-console","type":"boolean","hidden":true,"allowNo":false},"no-dashboard":{"name":"no-dashboard","type":"boolean","hidden":true,"allowNo":false},"no-init":{"name":"no-init","type":"boolean","hidden":true,"allowNo":false},"no-server":{"name":"no-server","type":"boolean","hidden":true,"allowNo":false},"no-validate":{"name":"no-validate","type":"boolean","hidden":true,"allowNo":false},"no-watcher":{"name":"no-watcher","type":"boolean","hidden":true,"allowNo":false},"port":{"name":"port","type":"option","default":5001}},"args":[]},"transpile":{"id":"transpile","description":"transpile a graphql schema","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"config":{"name":"config","type":"option","hidden":true},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"hide-output":{"name":"hide-output","type":"boolean","hidden":true,"allowNo":false},"inspect":{"name":"inspect","type":"boolean","char":"i","hidden":true,"allowNo":false},"inspect-after":{"name":"inspect-after","type":"boolean","hidden":true,"allowNo":false},"output-configuration":{"name":"output-configuration","type":"boolean","allowNo":false},"silent":{"name":"silent","type":"boolean","allowNo":false}},"args":[{"name":"folder","required":true}]},"upload":{"id":"upload","description":"upload to stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"dir":{"name":"dir","type":"option","description":"A directory to upload"},"file":{"name":"file","type":"option","description":"A file to upload"},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"silent":{"name":"silent","type":"boolean","allowNo":false}},"args":[{"name":"type","description":"type","required":true,"options":["configurationset","schema"]},{"name":"destination","description":"destination","required":true}]},"validate":{"id":"validate","description":"validate a graphql schema","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"folder","required":true}]},"whoami":{"id":"whoami","description":"stepzen whoami","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"showkeys":{"name":"showkeys","type":"boolean","allowNo":false}},"args":[]}}}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stepzen",
|
|
3
3
|
"description": "The StepZen CLI",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.38-beta.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Darren Waddell <darren@stepzen.com>",
|
|
7
7
|
"contributors": [
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@oclif/command": "^1.8.0",
|
|
30
30
|
"@oclif/config": "^1.17.1",
|
|
31
|
+
"@oclif/errors": "1.3.5",
|
|
31
32
|
"@oclif/plugin-help": "^5.1.10",
|
|
32
33
|
"@stepzen/dashboard": "0.1.36",
|
|
33
34
|
"@stepzen/sdk": "0.9.42",
|
|
@@ -46,6 +47,7 @@
|
|
|
46
47
|
"lodash": "^4.17.21",
|
|
47
48
|
"node-fetch": "^2.6.6",
|
|
48
49
|
"prettier": "^2.4.1",
|
|
50
|
+
"pretty-ms": "^7.0.1",
|
|
49
51
|
"shelljs": "^0.8.5",
|
|
50
52
|
"throttle-debounce": "^3.0.1",
|
|
51
53
|
"yaml": "^1.10.0"
|
|
@@ -102,7 +104,8 @@
|
|
|
102
104
|
"prerun": [
|
|
103
105
|
"./lib/hooks/prerun/check-account",
|
|
104
106
|
"./lib/hooks/prerun/check-upgrade",
|
|
105
|
-
"./lib/hooks/prerun/ensure-api-key"
|
|
107
|
+
"./lib/hooks/prerun/ensure-api-key",
|
|
108
|
+
"./lib/hooks/prerun/ensure-permissions"
|
|
106
109
|
]
|
|
107
110
|
}
|
|
108
111
|
},
|