stepzen 0.13.0 → 0.15.0-beta.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 +5 -2
- package/lib/commands/import.js +3 -3
- package/lib/commands/login.d.ts +1 -0
- package/lib/commands/login.js +51 -26
- package/lib/commands/logout.js +1 -1
- package/lib/commands/start.js +3 -4
- package/lib/commands/whoami.js +2 -2
- package/lib/generate/helpers.js +24 -8
- package/lib/generate/index.js +5 -5
- package/lib/hooks/prerun/{ensure-api-key.d.ts → ensure-config-file.d.ts} +0 -0
- package/lib/hooks/prerun/ensure-config-file.js +28 -0
- package/lib/shared/actions.js +3 -3
- package/lib/shared/configuration.d.ts +24 -5
- package/lib/shared/configuration.js +92 -34
- package/lib/shared/constants.d.ts +1 -1
- package/lib/shared/constants.js +2 -2
- package/lib/shared/curl-parser.js +22 -8
- package/lib/shared/path-params-parser.js +17 -9
- package/lib/shared/stepzen-sdk.d.ts +14 -14
- package/lib/shared/stepzen-sdk.js +25 -17
- package/lib/shared/types.d.ts +14 -2
- package/lib/shared/utils.d.ts +0 -2
- package/lib/shared/utils.js +1 -50
- package/lib/shared/zen-command.d.ts +4 -4
- package/lib/shared/zen-command.js +8 -8
- package/lib/start/deploy.js +4 -4
- package/oclif.manifest.json +1 -1
- package/package.json +6 -6
- package/lib/hooks/prerun/ensure-api-key.js +0 -8
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.
|
|
32
|
+
stepzen/0.15.0-beta.0 darwin-x64 node-v14.19.1
|
|
33
33
|
$ stepzen --help [COMMAND]
|
|
34
34
|
USAGE
|
|
35
35
|
$ stepzen COMMAND
|
|
@@ -135,7 +135,7 @@ OPTIONS
|
|
|
135
135
|
|
|
136
136
|
## `stepzen login`
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
Log in to StepZen
|
|
139
139
|
|
|
140
140
|
```
|
|
141
141
|
USAGE
|
|
@@ -143,6 +143,9 @@ USAGE
|
|
|
143
143
|
|
|
144
144
|
OPTIONS
|
|
145
145
|
-h, --help show CLI help
|
|
146
|
+
|
|
147
|
+
--public Create a public anonymous StepZen account and use it. This is handy for trying StepZen out, but it not
|
|
148
|
+
suitable for handling private data as all endpoints created with a public account will be public.
|
|
146
149
|
```
|
|
147
150
|
|
|
148
151
|
## `stepzen logout`
|
package/lib/commands/import.js
CHANGED
|
@@ -6,7 +6,7 @@ const fs = require("fs-extra");
|
|
|
6
6
|
const command_1 = require("@oclif/command");
|
|
7
7
|
const errors_1 = require("@oclif/errors");
|
|
8
8
|
const transpiler_1 = require("@stepzen/transpiler");
|
|
9
|
-
const
|
|
9
|
+
const core_1 = require("@oclif/core");
|
|
10
10
|
const generate_1 = require("../generate");
|
|
11
11
|
const utils_1 = require("../shared/utils");
|
|
12
12
|
const helpers_1 = require("../generate/helpers");
|
|
@@ -88,9 +88,9 @@ class Import extends zen_command_1.default {
|
|
|
88
88
|
}
|
|
89
89
|
curl2sdlOptions = Object.assign(Object.assign(Object.assign({}, fixedOptions), editableOptions), { pathParams: parsedPathParamsOrError, curlArgs: argsOrError });
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
core_1.CliUx.ux.action.start('Starting');
|
|
92
92
|
const resultOrError = await curl2sdl_1.curl2sdl(curl2sdlOptions);
|
|
93
|
-
|
|
93
|
+
core_1.CliUx.ux.action.stop();
|
|
94
94
|
if ('error' in resultOrError) {
|
|
95
95
|
this.log('A problem occured while processing your import. ' +
|
|
96
96
|
'Please check that the given cURL command is valid.');
|
package/lib/commands/login.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export default class Login extends ZenCommand {
|
|
|
5
5
|
static flags: {
|
|
6
6
|
account: flags.IOptionFlag<string | undefined>;
|
|
7
7
|
adminkey: flags.IOptionFlag<string | undefined>;
|
|
8
|
+
public: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
8
9
|
config: flags.IOptionFlag<string | undefined>;
|
|
9
10
|
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
10
11
|
'non-interactive': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
package/lib/commands/login.js
CHANGED
|
@@ -5,45 +5,70 @@ 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
|
|
8
|
+
const core_1 = require("@oclif/core");
|
|
9
|
+
const chalk = require("chalk");
|
|
9
10
|
const configuration_1 = require("../shared/configuration");
|
|
10
11
|
const stepzen_sdk_1 = require("../shared/stepzen-sdk");
|
|
11
12
|
const zen_command_1 = require("../shared/zen-command");
|
|
12
13
|
class Login extends zen_command_1.default {
|
|
13
14
|
async run() {
|
|
14
15
|
const { flags } = this.parse(Login);
|
|
15
|
-
let
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const config = configuration_1.importConfiguration(flags.config);
|
|
20
|
-
account = config.account;
|
|
21
|
-
adminkey = config.adminkey;
|
|
16
|
+
let configuration;
|
|
17
|
+
if (flags.public) {
|
|
18
|
+
const { uuid } = await configuration_1.readConfiguration();
|
|
19
|
+
configuration = await stepzen_sdk_1.default.createAnonymousAccount(uuid);
|
|
22
20
|
}
|
|
23
21
|
else {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
let account;
|
|
23
|
+
let adminkey;
|
|
24
|
+
// If the --config flag is provided, try and log in using the details in the file
|
|
25
|
+
if (flags.config) {
|
|
26
|
+
const config = await configuration_1.importConfiguration(flags.config);
|
|
27
|
+
account = config.account;
|
|
28
|
+
adminkey = config.adminkey;
|
|
27
29
|
}
|
|
28
30
|
else {
|
|
29
|
-
account
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
adminkey
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
// Check if the --account flag is provided, and if not prompt the user for an account name
|
|
32
|
+
if (flags.account) {
|
|
33
|
+
account = flags.account;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
account = await core_1.CliUx.ux.prompt('What is your account name?');
|
|
37
|
+
}
|
|
38
|
+
// Check if the --adminkey flag is provided, and if not prompt the user for an admin key.
|
|
39
|
+
if (flags.adminkey === undefined) {
|
|
40
|
+
adminkey = await core_1.CliUx.ux.prompt('What is your admin key?', {
|
|
41
|
+
required: false,
|
|
42
|
+
type: 'hide',
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
adminkey = flags.adminkey;
|
|
47
|
+
}
|
|
39
48
|
}
|
|
49
|
+
configuration = await stepzen_sdk_1.default.login(adminkey, account);
|
|
40
50
|
}
|
|
41
|
-
const configuration = await stepzen_sdk_1.default.login(adminkey, account);
|
|
42
51
|
// Change the default account.
|
|
43
|
-
configuration_1.
|
|
44
|
-
this.log(
|
|
52
|
+
configuration_1.writeCredentialsToConfigFile(configuration);
|
|
53
|
+
this.log(`You have successfully logged in as ${chalk.bold(configuration.account)}.`);
|
|
45
54
|
}
|
|
46
55
|
}
|
|
47
56
|
exports.default = Login;
|
|
48
|
-
Login.description = '
|
|
49
|
-
Login.flags = Object.assign(Object.assign({}, zen_command_1.default.flags), { account: command_1.flags.string({
|
|
57
|
+
Login.description = 'Log in to StepZen';
|
|
58
|
+
Login.flags = Object.assign(Object.assign({}, zen_command_1.default.flags), { account: command_1.flags.string({
|
|
59
|
+
char: 'a',
|
|
60
|
+
exclusive: ['config', 'public'],
|
|
61
|
+
hidden: true,
|
|
62
|
+
}), adminkey: command_1.flags.string({
|
|
63
|
+
char: 'k',
|
|
64
|
+
exclusive: ['config', 'public'],
|
|
65
|
+
hidden: true,
|
|
66
|
+
}), public: command_1.flags.boolean({
|
|
67
|
+
description: 'Create a public anonymous StepZen account and use it. This is handy' +
|
|
68
|
+
' for trying StepZen out, but it not suitable for handling private' +
|
|
69
|
+
' data as all endpoints created with a public account will be public.',
|
|
70
|
+
exclusive: ['config', 'account', 'adminkey'],
|
|
71
|
+
}), config: command_1.flags.string({
|
|
72
|
+
exclusive: ['account', 'adminkey', 'public'],
|
|
73
|
+
hidden: true,
|
|
74
|
+
}), help: command_1.flags.help({ char: 'h' }) });
|
package/lib/commands/logout.js
CHANGED
|
@@ -9,7 +9,7 @@ const zen_command_1 = require("../shared/zen-command");
|
|
|
9
9
|
class Logout extends zen_command_1.default {
|
|
10
10
|
async run() {
|
|
11
11
|
// Remove the configuration from the login file.
|
|
12
|
-
configuration_1.
|
|
12
|
+
configuration_1.removeCredentialsFromConfigFile();
|
|
13
13
|
this.log('You have been logged out.');
|
|
14
14
|
}
|
|
15
15
|
}
|
package/lib/commands/start.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const chokidar = require("chokidar");
|
|
5
|
-
const
|
|
5
|
+
const core_1 = require("@oclif/core");
|
|
6
6
|
const command_1 = require("@oclif/command");
|
|
7
7
|
const errors_1 = require("@oclif/errors");
|
|
8
8
|
const throttle_debounce_1 = require("throttle-debounce");
|
|
@@ -56,7 +56,6 @@ class Start extends zen_command_1.default {
|
|
|
56
56
|
ignored: '**/*.js',
|
|
57
57
|
})
|
|
58
58
|
.on('change', throttle_debounce_1.debounce(500, async (path) => {
|
|
59
|
-
await utils_1.checkAuth();
|
|
60
59
|
utils_1.clearConsole();
|
|
61
60
|
await start_1.deploy(path, workspace, flags);
|
|
62
61
|
await start_1.console(workspace);
|
|
@@ -64,7 +63,7 @@ class Start extends zen_command_1.default {
|
|
|
64
63
|
}
|
|
65
64
|
// Start!
|
|
66
65
|
utils_1.clearConsole();
|
|
67
|
-
|
|
66
|
+
core_1.CliUx.ux.action.start('Starting...');
|
|
68
67
|
// Unless explicitly disabled, auto-init
|
|
69
68
|
if (!flags['no-init']) {
|
|
70
69
|
await start_1.deploy(null, workspace, flags);
|
|
@@ -94,7 +93,7 @@ class Start extends zen_command_1.default {
|
|
|
94
93
|
await ui.start();
|
|
95
94
|
}
|
|
96
95
|
// Done
|
|
97
|
-
|
|
96
|
+
core_1.CliUx.ux.action.stop();
|
|
98
97
|
}
|
|
99
98
|
}
|
|
100
99
|
exports.default = Start;
|
package/lib/commands/whoami.js
CHANGED
|
@@ -9,8 +9,8 @@ const zen_command_1 = require("../shared/zen-command");
|
|
|
9
9
|
class WhoAmI extends zen_command_1.default {
|
|
10
10
|
async run() {
|
|
11
11
|
const { flags } = this.parse(WhoAmI);
|
|
12
|
-
const configuration = configuration_1.readConfiguration();
|
|
13
|
-
if (!configuration) {
|
|
12
|
+
const configuration = await configuration_1.readConfiguration();
|
|
13
|
+
if (!('account' in configuration)) {
|
|
14
14
|
this.log('You are not logged in.');
|
|
15
15
|
this.exit();
|
|
16
16
|
}
|
package/lib/generate/helpers.js
CHANGED
|
@@ -18,6 +18,7 @@ const { version } = require('../../package.json');
|
|
|
18
18
|
exports.createGeneratorFiles = async (id, details) => {
|
|
19
19
|
const url = `${constants_1.STEPZEN_DIRECT_GENERATOR_ENGINES_URL}/create`;
|
|
20
20
|
debug('stepzen:generate')(`calling the generator engine ${id} via ${url}`);
|
|
21
|
+
const engineErrorMessageWrap = (msg) => `An error has occurred when creating the schema: ${msg}. Please check your parameters and try again.`;
|
|
21
22
|
try {
|
|
22
23
|
const response = await node_fetch_1.default(url, {
|
|
23
24
|
body: JSON.stringify({
|
|
@@ -30,18 +31,33 @@ exports.createGeneratorFiles = async (id, details) => {
|
|
|
30
31
|
},
|
|
31
32
|
method: 'POST',
|
|
32
33
|
});
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
const responseJson = await response.json();
|
|
35
|
+
if (responseJson.errors) {
|
|
36
|
+
// assuming a response of type { status: Int, errors: String }
|
|
37
|
+
throw new errors_1.CLIError(engineErrorMessageWrap(responseJson.errors));
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
// where errors is an error message if name === null.
|
|
41
|
+
const files = responseJson;
|
|
42
|
+
const tmp = path.join(os.tmpdir(), `stepzen-generated-schema-${Date.now()}`);
|
|
43
|
+
fs.ensureDirSync(tmp);
|
|
44
|
+
for (const file of files) {
|
|
45
|
+
if (file.errors) {
|
|
46
|
+
throw new errors_1.CLIError(engineErrorMessageWrap(file.errors));
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
const dir = path.join(tmp, file.name);
|
|
50
|
+
fs.writeFileSync(dir, file.content);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return tmp;
|
|
39
54
|
}
|
|
40
|
-
return tmp;
|
|
41
55
|
}
|
|
42
56
|
catch (error) {
|
|
43
57
|
debug('stepzen:generate')(error);
|
|
44
|
-
throw
|
|
58
|
+
throw error instanceof errors_1.CLIError
|
|
59
|
+
? error
|
|
60
|
+
: new errors_1.CLIError(errors_2.PERMANENT_STEPZEN_ERROR);
|
|
45
61
|
}
|
|
46
62
|
};
|
|
47
63
|
exports.getConfiguration = async (id, details = {}) => {
|
package/lib/generate/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const errors_1 = require("@oclif/errors");
|
|
6
|
-
const
|
|
6
|
+
const core_1 = require("@oclif/core");
|
|
7
7
|
const fs = require("fs-extra");
|
|
8
8
|
const lodash = require("lodash");
|
|
9
9
|
const os = require("os");
|
|
@@ -21,7 +21,7 @@ exports.default = async (schemas, name, source) => {
|
|
|
21
21
|
// Store the answers
|
|
22
22
|
let answers = {};
|
|
23
23
|
// Start downloading
|
|
24
|
-
|
|
24
|
+
core_1.CliUx.ux.action.start('Downloading from StepZen...');
|
|
25
25
|
try {
|
|
26
26
|
// Get all generators from...Generators
|
|
27
27
|
for (var _f = tslib_1.__asyncValues(Object.keys(generators)), _g; _g = await _f.next(), !_g.done;) {
|
|
@@ -68,7 +68,7 @@ exports.default = async (schemas, name, source) => {
|
|
|
68
68
|
finally { if (e_2) throw e_2.error; }
|
|
69
69
|
}
|
|
70
70
|
// Finished downloading
|
|
71
|
-
|
|
71
|
+
core_1.CliUx.ux.action.stop();
|
|
72
72
|
console.log();
|
|
73
73
|
// If you've tried to import non-existent templates, complain and exit
|
|
74
74
|
const notFound = Object.entries(generators)
|
|
@@ -109,7 +109,7 @@ exports.default = async (schemas, name, source) => {
|
|
|
109
109
|
fs.ensureDirSync(output);
|
|
110
110
|
fs.copySync(source, output);
|
|
111
111
|
console.log();
|
|
112
|
-
|
|
112
|
+
core_1.CliUx.ux.action.start('Generating schemas...');
|
|
113
113
|
try {
|
|
114
114
|
for (var _m = tslib_1.__asyncValues(Object.entries(generators)), _o; _o = await _m.next(), !_o.done;) {
|
|
115
115
|
const [id, generator] = _o.value;
|
|
@@ -149,7 +149,7 @@ exports.default = async (schemas, name, source) => {
|
|
|
149
149
|
finally { if (e_4) throw e_4.error; }
|
|
150
150
|
}
|
|
151
151
|
// Housekeeping
|
|
152
|
-
|
|
152
|
+
core_1.CliUx.ux.action.stop();
|
|
153
153
|
fs.removeSync(templates);
|
|
154
154
|
return output;
|
|
155
155
|
};
|
|
File without changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const debug = require("debug");
|
|
6
|
+
const configuration_1 = require("../../shared/configuration");
|
|
7
|
+
const constants_1 = require("../../shared/constants");
|
|
8
|
+
const hook = async function () {
|
|
9
|
+
// If the configuration is set through an env variable,
|
|
10
|
+
// skip all the config file checks.
|
|
11
|
+
if (process.env.STEPZEN_CONFIG_CONTENT) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const configFilePath = path.join(constants_1.STEPZEN_CONFIG_DIRECTORY, constants_1.STEPZEN_CONFIG_FILE);
|
|
15
|
+
let rawConfiguration;
|
|
16
|
+
try {
|
|
17
|
+
rawConfiguration = await configuration_1.importConfiguration(configFilePath);
|
|
18
|
+
}
|
|
19
|
+
catch (_a) {
|
|
20
|
+
rawConfiguration = null;
|
|
21
|
+
}
|
|
22
|
+
const { configuration, modified } = await configuration_1.ensureValidConfiguration(rawConfiguration);
|
|
23
|
+
if (modified) {
|
|
24
|
+
configuration_1.writeConfiguration(configuration);
|
|
25
|
+
debug('stepzen:configuration')(`Automatically updated the ${configFilePath} config file.`);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
exports.default = hook;
|
package/lib/shared/actions.js
CHANGED
|
@@ -6,7 +6,7 @@ const configuration_1 = require("./configuration");
|
|
|
6
6
|
const constants_1 = require("./constants");
|
|
7
7
|
const stepzen_sdk_1 = require("./stepzen-sdk");
|
|
8
8
|
exports.deploy = async (destination, configurationsets, schema) => {
|
|
9
|
-
const config = configuration_1.readConfiguration();
|
|
9
|
+
const config = (await configuration_1.readConfiguration());
|
|
10
10
|
const server = constants_1.STEPZEN_SERVER_URL.replace('{account}', config.account);
|
|
11
11
|
const client = await stepzen_sdk_1.default.client({
|
|
12
12
|
account: config.account,
|
|
@@ -21,7 +21,7 @@ exports.deploy = async (destination, configurationsets, schema) => {
|
|
|
21
21
|
return client.deploy(destination, payload);
|
|
22
22
|
};
|
|
23
23
|
exports.list = async (type) => {
|
|
24
|
-
const config = configuration_1.readConfiguration();
|
|
24
|
+
const config = (await configuration_1.readConfiguration());
|
|
25
25
|
const server = constants_1.STEPZEN_SERVER_URL.replace('{account}', config.account);
|
|
26
26
|
const client = await stepzen_sdk_1.default.client({
|
|
27
27
|
account: config.account,
|
|
@@ -32,7 +32,7 @@ exports.list = async (type) => {
|
|
|
32
32
|
return client.list[type]();
|
|
33
33
|
};
|
|
34
34
|
exports.upload = async (type, destination, source) => {
|
|
35
|
-
const config = configuration_1.readConfiguration();
|
|
35
|
+
const config = (await configuration_1.readConfiguration());
|
|
36
36
|
const server = constants_1.STEPZEN_SERVER_URL.replace('{account}', config.account);
|
|
37
37
|
const client = await stepzen_sdk_1.default.client({
|
|
38
38
|
account: config.account,
|
|
@@ -1,5 +1,24 @@
|
|
|
1
|
-
import { MachineConfiguration } from './types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { LoggedInMachineConfiguration, LoggedOutMachineConfiguration, MachineConfiguration, StepZenCredentials } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Ensure that the `stepzen-config.yaml` file exists and has valid content.
|
|
4
|
+
* Cover 3 cases:
|
|
5
|
+
* - file does not exist (this is the first time the CLI is run)
|
|
6
|
+
* -> initialize the config file and add a UUID into it
|
|
7
|
+
* - file exists but does not include a UUID (it was created by an earlier
|
|
8
|
+
* version of the CLI)
|
|
9
|
+
* -> add a UUID into the existing config file
|
|
10
|
+
* - file exists, has stepzen credentials, but does not include an API key
|
|
11
|
+
* (it was created by an earlier version of the CLI)
|
|
12
|
+
* -> either fetch the API key from StepZen or remove logged in credentials
|
|
13
|
+
*
|
|
14
|
+
* @param {*} maybeConfiguration raw contents of the configuration file
|
|
15
|
+
*/
|
|
16
|
+
export declare const ensureValidConfiguration: (maybeConfiguration: Record<string, any> | null) => Promise<{
|
|
17
|
+
configuration: MachineConfiguration;
|
|
18
|
+
modified: boolean;
|
|
19
|
+
}>;
|
|
20
|
+
export declare const importConfiguration: (filepath: string) => Promise<Record<string, any>>;
|
|
21
|
+
export declare const readConfiguration: () => Promise<MachineConfiguration>;
|
|
22
|
+
export declare const writeConfiguration: (configuration: MachineConfiguration) => Promise<MachineConfiguration>;
|
|
23
|
+
export declare const writeCredentialsToConfigFile: (credentials: StepZenCredentials) => Promise<LoggedInMachineConfiguration>;
|
|
24
|
+
export declare const removeCredentialsFromConfigFile: () => Promise<LoggedOutMachineConfiguration>;
|
|
@@ -1,61 +1,106 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
4
|
+
exports.removeCredentialsFromConfigFile = exports.writeCredentialsToConfigFile = exports.writeConfiguration = exports.readConfiguration = exports.importConfiguration = exports.ensureValidConfiguration = void 0;
|
|
5
5
|
// This file contains methods for managing configuration
|
|
6
6
|
const errors_1 = require("@oclif/errors");
|
|
7
7
|
const debug = require("debug");
|
|
8
8
|
const fs = require("fs");
|
|
9
|
+
const crypto = require("crypto");
|
|
9
10
|
const path = require("path");
|
|
10
11
|
const yaml = require("yaml");
|
|
12
|
+
const stepzen_sdk_1 = require("./stepzen-sdk");
|
|
11
13
|
const constants_1 = require("./constants");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
const configFilePath = path.join(constants_1.STEPZEN_CONFIG_DIRECTORY, constants_1.STEPZEN_CONFIG_FILE);
|
|
15
|
+
/**
|
|
16
|
+
* Ensure that the `stepzen-config.yaml` file exists and has valid content.
|
|
17
|
+
* Cover 3 cases:
|
|
18
|
+
* - file does not exist (this is the first time the CLI is run)
|
|
19
|
+
* -> initialize the config file and add a UUID into it
|
|
20
|
+
* - file exists but does not include a UUID (it was created by an earlier
|
|
21
|
+
* version of the CLI)
|
|
22
|
+
* -> add a UUID into the existing config file
|
|
23
|
+
* - file exists, has stepzen credentials, but does not include an API key
|
|
24
|
+
* (it was created by an earlier version of the CLI)
|
|
25
|
+
* -> either fetch the API key from StepZen or remove logged in credentials
|
|
26
|
+
*
|
|
27
|
+
* @param {*} maybeConfiguration raw contents of the configuration file
|
|
28
|
+
*/
|
|
29
|
+
exports.ensureValidConfiguration = async (maybeConfiguration) => {
|
|
30
|
+
let modified = false;
|
|
31
|
+
const configuration = Object.assign({}, maybeConfiguration);
|
|
32
|
+
// ensure configuration exists
|
|
33
|
+
if (!maybeConfiguration) {
|
|
34
|
+
modified = true;
|
|
35
|
+
}
|
|
36
|
+
// ensure configuration has a UUID
|
|
37
|
+
if (!configuration.uuid) {
|
|
38
|
+
configuration.uuid = crypto.randomUUID();
|
|
39
|
+
debug('stepzen:configuration')(`Generated a new machine UUID: ${configuration.uuid}`);
|
|
40
|
+
modified = true;
|
|
41
|
+
}
|
|
42
|
+
// ensure a logged-in configuration includes an API key
|
|
43
|
+
if (configuration.account && !configuration.apikey) {
|
|
44
|
+
try {
|
|
45
|
+
debug('stepzen:configuration')(`Fetching an API key for account ${configuration.account}`);
|
|
46
|
+
const credentials = await stepzen_sdk_1.default.login(configuration.adminkey, configuration.account);
|
|
47
|
+
configuration.apikey = credentials.apikey;
|
|
18
48
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
49
|
+
catch (error) {
|
|
50
|
+
if (error instanceof Error &&
|
|
51
|
+
error.message.includes('Your credentials are invalid')) {
|
|
52
|
+
debug('stepzen:configuration')(`Removing the stored account credentials because logging in failed. ${error}`);
|
|
53
|
+
delete configuration.account;
|
|
54
|
+
delete configuration.adminkey;
|
|
55
|
+
delete configuration.apikey;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
// ignore other errors
|
|
59
|
+
}
|
|
23
60
|
}
|
|
24
|
-
|
|
25
|
-
const parsed = yaml.parse(configuration);
|
|
26
|
-
debug('stepzen:configuration')(parsed);
|
|
27
|
-
return parsed;
|
|
28
|
-
}
|
|
29
|
-
catch (_a) {
|
|
30
|
-
return null;
|
|
61
|
+
modified = true;
|
|
31
62
|
}
|
|
63
|
+
return {
|
|
64
|
+
configuration: configuration,
|
|
65
|
+
modified,
|
|
66
|
+
};
|
|
32
67
|
};
|
|
33
|
-
exports.importConfiguration = (filepath) => {
|
|
68
|
+
exports.importConfiguration = async (filepath) => {
|
|
34
69
|
if (!fs.existsSync(filepath)) {
|
|
35
70
|
throw new errors_1.CLIError('Configuration file does not exist');
|
|
36
71
|
}
|
|
37
|
-
const
|
|
72
|
+
const content = fs.readFileSync(filepath, 'utf8');
|
|
38
73
|
try {
|
|
39
|
-
|
|
40
|
-
debug('stepzen:configuration')(parsed);
|
|
41
|
-
return parsed;
|
|
74
|
+
return yaml.parse(content);
|
|
42
75
|
}
|
|
43
76
|
catch (_a) {
|
|
44
77
|
throw new errors_1.CLIError('Configuration file is not valid yaml');
|
|
45
78
|
}
|
|
46
79
|
};
|
|
47
|
-
exports.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
80
|
+
exports.readConfiguration = async () => {
|
|
81
|
+
let maybeConfiguration = null;
|
|
82
|
+
// If the configuration comes from an env var, use it
|
|
83
|
+
if (process.env.STEPZEN_CONFIG_CONTENT) {
|
|
84
|
+
try {
|
|
85
|
+
maybeConfiguration = yaml.parse(process.env.STEPZEN_CONFIG_CONTENT);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
debug('stepzen:configuration')(`Could not parse the STEPZEN_CONFIG_CONTENT env var as YAML: ${error}`);
|
|
89
|
+
}
|
|
53
90
|
}
|
|
54
|
-
|
|
55
|
-
|
|
91
|
+
else {
|
|
92
|
+
try {
|
|
93
|
+
maybeConfiguration = await exports.importConfiguration(configFilePath);
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
debug('stepzen:configuration')(`Could not read the config file at ${configFilePath}: ${error}`);
|
|
97
|
+
}
|
|
56
98
|
}
|
|
99
|
+
const { configuration } = await exports.ensureValidConfiguration(maybeConfiguration);
|
|
100
|
+
debug('stepzen:configuration')(configuration);
|
|
101
|
+
return configuration;
|
|
57
102
|
};
|
|
58
|
-
exports.
|
|
103
|
+
exports.writeConfiguration = async (configuration) => {
|
|
59
104
|
// Generate YAML from the configuration
|
|
60
105
|
const content = yaml.stringify(configuration);
|
|
61
106
|
// Check that the configuration directory exists. If not, create it.
|
|
@@ -63,7 +108,20 @@ exports.writeConfigurationToLoginFile = (configuration) => {
|
|
|
63
108
|
fs.mkdirSync(constants_1.STEPZEN_CONFIG_DIRECTORY);
|
|
64
109
|
}
|
|
65
110
|
// Write the configuration file. Overwrites if it already exists.
|
|
66
|
-
|
|
67
|
-
|
|
111
|
+
fs.writeFileSync(configFilePath, content, { mode: '600' });
|
|
112
|
+
return exports.readConfiguration();
|
|
113
|
+
};
|
|
114
|
+
exports.writeCredentialsToConfigFile = async (credentials) => {
|
|
115
|
+
const oldConfig = await exports.readConfiguration();
|
|
116
|
+
const newConfig = Object.assign(Object.assign({}, oldConfig), credentials);
|
|
117
|
+
const writtenConfig = await exports.writeConfiguration(newConfig);
|
|
118
|
+
return Object.assign(Object.assign({}, newConfig), writtenConfig);
|
|
119
|
+
};
|
|
120
|
+
exports.removeCredentialsFromConfigFile = async () => {
|
|
121
|
+
const configuration = await exports.readConfiguration();
|
|
122
|
+
delete configuration.account;
|
|
123
|
+
delete configuration.apikey;
|
|
124
|
+
delete configuration.adminkey;
|
|
125
|
+
await exports.writeConfiguration(configuration);
|
|
68
126
|
return configuration;
|
|
69
127
|
};
|
|
@@ -10,6 +10,6 @@ export declare const STEPZEN_API_TEMPLATES_REPOSITORY = "https://github.com/step
|
|
|
10
10
|
export declare const ADMIN_DEPLOY_URL = "/cli/admin/deploy";
|
|
11
11
|
export declare const ADMIN_LIST_URL = "/cli/admin/list";
|
|
12
12
|
export declare const ADMIN_UPLOAD_URL = "/cli/admin/upload";
|
|
13
|
-
export declare const
|
|
13
|
+
export declare const ADMIN_ACCOUNT_URL = "/cli/admin/account";
|
|
14
14
|
export declare const STEPZEN_JSON2SDL_SERVER_URL: string;
|
|
15
15
|
export declare const STEPZEN_DISCORD_URL = "https://discord.gg/9k2VdPn2FR";
|
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.STEPZEN_DISCORD_URL = exports.STEPZEN_JSON2SDL_SERVER_URL = exports.
|
|
4
|
+
exports.STEPZEN_DISCORD_URL = exports.STEPZEN_JSON2SDL_SERVER_URL = exports.ADMIN_ACCOUNT_URL = exports.ADMIN_UPLOAD_URL = exports.ADMIN_LIST_URL = exports.ADMIN_DEPLOY_URL = exports.STEPZEN_API_TEMPLATES_REPOSITORY = exports.STEPZEN_DIRECT_GENERATOR_ENGINES_URL = exports.STEPZEN_GENERATOR_ENGINES_ENDPOINT = exports.STEPZEN_GENERATOR_ENGINES_SCHEMA = exports.STEPZEN_SERVER_URL = exports.STEPZEN_DOMAIN = exports.STEPZEN_CONFIG_FILE = exports.STEPZEN_LAST_UPDATE_CHECK_TIMESTAMP = exports.STEPZEN_CONFIG_DIRECTORY = void 0;
|
|
5
5
|
// This file contains constants and all magic strings
|
|
6
6
|
const dotenv = require("dotenv");
|
|
7
7
|
const os = require("os");
|
|
@@ -32,7 +32,7 @@ exports.STEPZEN_API_TEMPLATES_REPOSITORY = 'https://github.com/steprz/stepzen-sc
|
|
|
32
32
|
exports.ADMIN_DEPLOY_URL = '/cli/admin/deploy';
|
|
33
33
|
exports.ADMIN_LIST_URL = '/cli/admin/list';
|
|
34
34
|
exports.ADMIN_UPLOAD_URL = '/cli/admin/upload';
|
|
35
|
-
exports.
|
|
35
|
+
exports.ADMIN_ACCOUNT_URL = '/cli/admin/account';
|
|
36
36
|
exports.STEPZEN_JSON2SDL_SERVER_URL = ENV_VAR_STEPZEN_JSON2SDL_SERVER_URL ||
|
|
37
37
|
'https://jsonintrospection-ng-prod-xynkgeaaaa-uc.a.run.app';
|
|
38
38
|
exports.STEPZEN_DISCORD_URL = 'https://discord.gg/9k2VdPn2FR';
|
|
@@ -87,6 +87,17 @@ const parseMethodFlag = (value, partialCurlArgs) => {
|
|
|
87
87
|
result: Object.assign(Object.assign({}, partialCurlArgs), { method }),
|
|
88
88
|
};
|
|
89
89
|
};
|
|
90
|
+
const parseURLFlag = (value, partialCurlArgs) => {
|
|
91
|
+
if (partialCurlArgs.url) {
|
|
92
|
+
return {
|
|
93
|
+
error: `Multiple URLs are not currently supported by StepZen CLI (${value}).` +
|
|
94
|
+
` If this is a blocker for you, please let us know on Discord (${constants_1.STEPZEN_DISCORD_URL})`,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
result: Object.assign(Object.assign({}, partialCurlArgs), { url: value }),
|
|
99
|
+
};
|
|
100
|
+
};
|
|
90
101
|
const flags = [
|
|
91
102
|
{
|
|
92
103
|
matches: ['-H', '--header'],
|
|
@@ -100,6 +111,10 @@ const flags = [
|
|
|
100
111
|
matches: ['-X', '--request'],
|
|
101
112
|
parse: parseMethodFlag,
|
|
102
113
|
},
|
|
114
|
+
{
|
|
115
|
+
matches: ['--url'],
|
|
116
|
+
parse: parseURLFlag,
|
|
117
|
+
},
|
|
103
118
|
];
|
|
104
119
|
const tryMatchCurlFlag = (matches, argv, i) => {
|
|
105
120
|
for (const match of matches) {
|
|
@@ -155,7 +170,7 @@ exports.parseCurlArgv = (argv) => {
|
|
|
155
170
|
continue;
|
|
156
171
|
}
|
|
157
172
|
if ('error' in matcherResult) {
|
|
158
|
-
// flag matched but it
|
|
173
|
+
// flag matched but it requires a value which is missing
|
|
159
174
|
return matcherResult;
|
|
160
175
|
}
|
|
161
176
|
const parserResult = flag.parse(matcherResult.value, result, matcherResult.match);
|
|
@@ -174,14 +189,13 @@ exports.parseCurlArgv = (argv) => {
|
|
|
174
189
|
};
|
|
175
190
|
}
|
|
176
191
|
}
|
|
177
|
-
else if (result.url) {
|
|
178
|
-
return {
|
|
179
|
-
error: `Multiple URLs are not currently supported by StepZen CLI (${argv[i]}).` +
|
|
180
|
-
` If this is a blocker for you, please let us know on Discord (${constants_1.STEPZEN_DISCORD_URL})`,
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
192
|
else {
|
|
184
|
-
|
|
193
|
+
// The only curl argument that's not a flag is the URL
|
|
194
|
+
const resultOrError = parseURLFlag(argv[i], result, '');
|
|
195
|
+
if ('error' in resultOrError) {
|
|
196
|
+
return resultOrError;
|
|
197
|
+
}
|
|
198
|
+
result = resultOrError.result;
|
|
185
199
|
}
|
|
186
200
|
}
|
|
187
201
|
if (!result.url) {
|
|
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.parsePathParamsPattern = exports.formatPatternDiffWithPath = void 0;
|
|
5
5
|
const chalk = require("chalk");
|
|
6
6
|
const pathParamRegex = /^\$[_A-Za-z]\w*$/;
|
|
7
|
+
// in a literal segment, $ should be escaped as $$
|
|
8
|
+
const pathSegmentRegex = /^([^$]|\$\$)+$/;
|
|
7
9
|
exports.formatPatternDiffWithPath = (patternSegments, pathSegments) => {
|
|
8
10
|
let hasErrors = false;
|
|
9
11
|
const diff = [];
|
|
@@ -13,12 +15,9 @@ exports.formatPatternDiffWithPath = (patternSegments, pathSegments) => {
|
|
|
13
15
|
diff.push(chalk.red(`< ${patternSegment} >`));
|
|
14
16
|
hasErrors = true;
|
|
15
17
|
}
|
|
16
|
-
else if (
|
|
17
|
-
diff.push(patternSegment);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
18
|
+
else if (pathSegmentRegex.test(patternSegment)) {
|
|
20
19
|
const pathSegment = pathSegments[i];
|
|
21
|
-
if (pathSegment === patternSegment) {
|
|
20
|
+
if (pathSegment === patternSegment.replace(/\$\$/g, '$')) {
|
|
22
21
|
diff.push(pathSegment);
|
|
23
22
|
}
|
|
24
23
|
else {
|
|
@@ -26,6 +25,13 @@ exports.formatPatternDiffWithPath = (patternSegments, pathSegments) => {
|
|
|
26
25
|
hasErrors = true;
|
|
27
26
|
}
|
|
28
27
|
}
|
|
28
|
+
else {
|
|
29
|
+
// If the path segment contains some unescaped (single) $ chars,
|
|
30
|
+
// interpret it as a pattern for now. An error will be reported
|
|
31
|
+
// later (in parsePathParamsPattern) if it doesn't match
|
|
32
|
+
// pathParamRegex (starts with $)
|
|
33
|
+
diff.push(patternSegment);
|
|
34
|
+
}
|
|
29
35
|
}
|
|
30
36
|
for (let i = patternSegments.length; i < pathSegments.length; i++) {
|
|
31
37
|
diff.push(chalk.magenta(`< ${pathSegments[i]} >`));
|
|
@@ -52,22 +58,24 @@ exports.parsePathParamsPattern = (url, pathParamsPattern) => {
|
|
|
52
58
|
error: `Path parameters do not align with the URL path: /${maybeDiff}`,
|
|
53
59
|
};
|
|
54
60
|
}
|
|
55
|
-
const invalidParameterSegments = patternSegments.filter(segment =>
|
|
61
|
+
const invalidParameterSegments = patternSegments.filter(segment => !pathSegmentRegex.test(segment) && !pathParamRegex.test(segment));
|
|
56
62
|
if (invalidParameterSegments.length > 0) {
|
|
57
63
|
return {
|
|
58
64
|
error: `The path parameter name '${invalidParameterSegments[0]}' is not` +
|
|
59
65
|
` allowed. Path parameter names should be valid GraphQL identifiers` +
|
|
60
|
-
` prefixed with $ (dollar sign)
|
|
66
|
+
` prefixed with $ (dollar sign). $ in literal path segments must be` +
|
|
67
|
+
` escaped as $$.`,
|
|
61
68
|
};
|
|
62
69
|
}
|
|
63
|
-
|
|
70
|
+
const retval = patternSegments
|
|
64
71
|
.map((segment, index) => ({
|
|
65
72
|
index,
|
|
66
73
|
name: segment,
|
|
67
74
|
}))
|
|
68
|
-
.filter(({ name }) =>
|
|
75
|
+
.filter(({ name }) => pathParamRegex.test(name))
|
|
69
76
|
.map(({ index, name }) => ({
|
|
70
77
|
index,
|
|
71
78
|
name: name.slice(1),
|
|
72
79
|
}));
|
|
80
|
+
return retval;
|
|
73
81
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import { StepZenCredentials } from './types';
|
|
1
2
|
declare const stepzen: {
|
|
2
|
-
login: (adminkey: string, account?: string) => Promise<
|
|
3
|
-
|
|
4
|
-
adminkey: string;
|
|
5
|
-
}>;
|
|
6
|
-
createAnonymousAccount: () => {
|
|
7
|
-
account: string;
|
|
8
|
-
adminkey: string;
|
|
9
|
-
};
|
|
3
|
+
login: (adminkey: string, account?: string) => Promise<StepZenCredentials>;
|
|
4
|
+
createAnonymousAccount: (uuid: string) => Promise<StepZenCredentials>;
|
|
10
5
|
verify: (account: string, adminkey: string) => Promise<boolean>;
|
|
11
|
-
client: (options:
|
|
6
|
+
client: (options: import("@stepzen/sdk/lib/client").AnonymousClientOptions | import("@stepzen/sdk/lib/client").UserCredentialsClientOptions) => Promise<{
|
|
7
|
+
readonly credentials: {
|
|
8
|
+
account: string;
|
|
9
|
+
adminkey: string;
|
|
10
|
+
apikey: string;
|
|
11
|
+
};
|
|
12
12
|
account: () => Promise<{
|
|
13
13
|
account: string;
|
|
14
14
|
apikey: string;
|
|
@@ -19,14 +19,14 @@ declare const stepzen: {
|
|
|
19
19
|
deploy: (destination: string, properties: {
|
|
20
20
|
configurationsets?: string[] | undefined;
|
|
21
21
|
schema: string;
|
|
22
|
-
}) => Promise<import("@stepzen/sdk").ZenCtlResponse>;
|
|
22
|
+
}) => Promise<import("@stepzen/sdk/lib/client").ZenCtlResponse>;
|
|
23
23
|
list: {
|
|
24
|
-
configurationsets: () => Promise<import("@stepzen/sdk").ZenCtlResponse>;
|
|
25
|
-
schemas: () => Promise<import("@stepzen/sdk").ZenCtlResponse>;
|
|
24
|
+
configurationsets: () => Promise<import("@stepzen/sdk/lib/client").ZenCtlResponse>;
|
|
25
|
+
schemas: () => Promise<import("@stepzen/sdk/lib/client").ZenCtlResponse>;
|
|
26
26
|
};
|
|
27
27
|
upload: {
|
|
28
|
-
configurationset: (destination: string, file: string) => Promise<import("@stepzen/sdk").ZenCtlResponse>;
|
|
29
|
-
schema: (destination: string, directory: string) => Promise<import("@stepzen/sdk").ZenCtlResponse>;
|
|
28
|
+
configurationset: (destination: string, file: string) => Promise<import("@stepzen/sdk/lib/client").ZenCtlResponse>;
|
|
29
|
+
schema: (destination: string, directory: string) => Promise<import("@stepzen/sdk/lib/client").ZenCtlResponse>;
|
|
30
30
|
};
|
|
31
31
|
}>;
|
|
32
32
|
};
|
|
@@ -3,26 +3,34 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const errors_1 = require("@oclif/errors");
|
|
5
5
|
const sdk_1 = require("@stepzen/sdk");
|
|
6
|
+
const constants_1 = require("./constants");
|
|
6
7
|
const { version } = require('../../package.json');
|
|
7
8
|
const stepzen = Object.assign(Object.assign({}, sdk_1.init({ appName: `stepzen-cli/${version}` })), { login: async (adminkey, account = adminkey.split(':')[0]) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
try {
|
|
10
|
+
const client = await stepzen.client({
|
|
11
|
+
account,
|
|
12
|
+
adminkey,
|
|
13
|
+
domain: constants_1.STEPZEN_DOMAIN,
|
|
14
|
+
server: constants_1.STEPZEN_SERVER_URL,
|
|
15
|
+
});
|
|
16
|
+
return client.credentials;
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
12
19
|
// Exit, with error
|
|
13
|
-
throw new errors_1.CLIError('We are unable to verify your account details. Could you please check them?'
|
|
20
|
+
throw new errors_1.CLIError('We are unable to verify your account details. Could you please check them?' +
|
|
21
|
+
` (${error})`);
|
|
22
|
+
}
|
|
23
|
+
}, createAnonymousAccount: async (uuid) => {
|
|
24
|
+
try {
|
|
25
|
+
const client = await stepzen.client({
|
|
26
|
+
publicAccountToken: uuid,
|
|
27
|
+
domain: constants_1.STEPZEN_DOMAIN,
|
|
28
|
+
server: constants_1.STEPZEN_SERVER_URL,
|
|
29
|
+
});
|
|
30
|
+
return client.credentials;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
throw new errors_1.CLIError(`Could not create a public account (${error})`);
|
|
14
34
|
}
|
|
15
|
-
return {
|
|
16
|
-
account,
|
|
17
|
-
adminkey,
|
|
18
|
-
};
|
|
19
|
-
}, createAnonymousAccount: () => {
|
|
20
|
-
const anonAdminKey = process.env.STEPZEN_ANONYMOUS_ADMINKEY ||
|
|
21
|
-
// LATER: call the actual API (pending https://github.com/steprz/zen/issues/5545)
|
|
22
|
-
'test::steprz.io+666::test';
|
|
23
|
-
return {
|
|
24
|
-
account: anonAdminKey.split(':')[0],
|
|
25
|
-
adminkey: anonAdminKey,
|
|
26
|
-
};
|
|
27
35
|
} });
|
|
28
36
|
exports.default = stepzen;
|
package/lib/shared/types.d.ts
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface StepZenCredentials {
|
|
2
2
|
account: string;
|
|
3
3
|
adminkey: string;
|
|
4
|
-
apikey
|
|
4
|
+
apikey: string;
|
|
5
5
|
}
|
|
6
|
+
export interface LoggedOutMachineConfiguration {
|
|
7
|
+
uuid: string;
|
|
8
|
+
}
|
|
9
|
+
export declare type LoggedInMachineConfiguration = LoggedOutMachineConfiguration & StepZenCredentials;
|
|
10
|
+
/**
|
|
11
|
+
* In-memory representation of the `~/.stepzen/stepzen-config.yaml`
|
|
12
|
+
* configuration file.
|
|
13
|
+
*
|
|
14
|
+
* If the user is not logged in, it has only a UUID of the CLI installation.
|
|
15
|
+
* If the user is logged in, it has also has the StepZen account credentials.
|
|
16
|
+
*/
|
|
17
|
+
export declare type MachineConfiguration = LoggedInMachineConfiguration | LoggedOutMachineConfiguration;
|
|
6
18
|
/**
|
|
7
19
|
* On-disk representation of a workspace config file, `stepzen.config.json`
|
|
8
20
|
*/
|
package/lib/shared/utils.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
export declare const checkAuth: () => Promise<void>;
|
|
2
1
|
export declare const clearConsole: () => void;
|
|
3
|
-
export declare const ensureApiKey: () => Promise<void>;
|
|
4
2
|
export declare const getDirectory: (d?: string | undefined) => string;
|
|
5
3
|
export declare const getStepZenExtensions: () => Promise<string>;
|
|
6
4
|
export declare const validateEndpoint: (endpoint: string) => any;
|
package/lib/shared/utils.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.maskStepZenKey = exports.validateEndpoint = exports.getStepZenExtensions = exports.getDirectory = exports.
|
|
4
|
+
exports.maskStepZenKey = exports.validateEndpoint = exports.getStepZenExtensions = exports.getDirectory = exports.clearConsole = void 0;
|
|
5
5
|
const errors_1 = require("@oclif/errors");
|
|
6
|
-
const chalk = require("chalk");
|
|
7
6
|
const debug = require("debug");
|
|
8
7
|
const node_fetch_1 = require("node-fetch");
|
|
9
8
|
const fs = require("fs");
|
|
@@ -11,60 +10,12 @@ const os = require("os");
|
|
|
11
10
|
const path = require("path");
|
|
12
11
|
const prettier = require("prettier");
|
|
13
12
|
const constants_1 = require("./constants");
|
|
14
|
-
const configuration_1 = require("./configuration");
|
|
15
|
-
const stepzen_sdk_1 = require("./stepzen-sdk");
|
|
16
|
-
exports.checkAuth = async () => {
|
|
17
|
-
var _a;
|
|
18
|
-
const configuration = configuration_1.readConfiguration();
|
|
19
|
-
// If there is no configuration, you're not logged in
|
|
20
|
-
if (!configuration) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const details = configuration;
|
|
24
|
-
// If the account is called 'test', return. It's a test.
|
|
25
|
-
if (details.account === 'test') {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const isValidAccount = await stepzen_sdk_1.default.verify(details.account, details.adminkey);
|
|
29
|
-
if (!isValidAccount) {
|
|
30
|
-
if ((_a = details.account) === null || _a === void 0 ? void 0 : _a.endsWith('Playground')) {
|
|
31
|
-
console.log(chalk.yellow(`
|
|
32
|
-
╔════════════════════════════════════════╗
|
|
33
|
-
║ Your playground account has expired! ║
|
|
34
|
-
║ Sign up for a full account: ║
|
|
35
|
-
║ www.stepzen.com ║
|
|
36
|
-
╚════════════════════════════════════════╝
|
|
37
|
-
`));
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
console.log('Could not complete the request. Please check your authentication details are correct.');
|
|
41
|
-
}
|
|
42
|
-
// eslint-disable-next-line no-process-exit,unicorn/no-process-exit
|
|
43
|
-
process.exit(1);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
13
|
exports.clearConsole = () => {
|
|
47
14
|
process.stdout.write(
|
|
48
15
|
// Taken from create-react-app
|
|
49
16
|
// eslint-disable-next-line unicorn/no-hex-escape
|
|
50
17
|
process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H');
|
|
51
18
|
};
|
|
52
|
-
exports.ensureApiKey = async () => {
|
|
53
|
-
const configuration = configuration_1.readConfiguration();
|
|
54
|
-
const details = configuration;
|
|
55
|
-
if (details && !details.apikey) {
|
|
56
|
-
debug('stepzen:account')(`Fetching API key for account ${details.account}`);
|
|
57
|
-
try {
|
|
58
|
-
const client = await stepzen_sdk_1.default.client(details);
|
|
59
|
-
const response = await client.account();
|
|
60
|
-
if ('apikey' in response) {
|
|
61
|
-
details.apikey = response.apikey;
|
|
62
|
-
await configuration_1.writeConfigurationToLoginFile(details);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
catch (_a) { }
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
19
|
exports.getDirectory = (d = process.cwd()) => {
|
|
69
20
|
let directory = d;
|
|
70
21
|
// If it starts with `~`, expand this
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Command, flags } from '@oclif/command';
|
|
2
|
-
import { MachineConfiguration } from './types';
|
|
2
|
+
import { MachineConfiguration, StepZenCredentials } from './types';
|
|
3
3
|
export declare abstract class ZenCommand extends Command {
|
|
4
4
|
static flags: {
|
|
5
5
|
'non-interactive': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
6
6
|
'enable-login-prompt': flags.IOptionFlag<boolean | undefined>;
|
|
7
7
|
};
|
|
8
8
|
ensureStepZenAccount(): Promise<{
|
|
9
|
-
configuration:
|
|
9
|
+
configuration: import("./types").LoggedInMachineConfiguration;
|
|
10
10
|
}>;
|
|
11
|
-
promptUserToLogIn(): Promise<{
|
|
12
|
-
configuration: MachineConfiguration;
|
|
11
|
+
promptUserToLogIn(uuid: string): Promise<{
|
|
12
|
+
configuration: MachineConfiguration & StepZenCredentials;
|
|
13
13
|
}>;
|
|
14
14
|
}
|
|
15
15
|
export default ZenCommand;
|
|
@@ -10,8 +10,8 @@ const configuration_1 = require("./configuration");
|
|
|
10
10
|
const stepzen_sdk_1 = require("./stepzen-sdk");
|
|
11
11
|
class ZenCommand extends command_1.Command {
|
|
12
12
|
async ensureStepZenAccount() {
|
|
13
|
-
const configuration = configuration_1.readConfiguration();
|
|
14
|
-
if (
|
|
13
|
+
const configuration = await configuration_1.readConfiguration();
|
|
14
|
+
if ('account' in configuration) {
|
|
15
15
|
return {
|
|
16
16
|
configuration,
|
|
17
17
|
};
|
|
@@ -19,12 +19,12 @@ class ZenCommand extends command_1.Command {
|
|
|
19
19
|
const TheCommand = this.constructor;
|
|
20
20
|
const { flags } = this.parse(TheCommand);
|
|
21
21
|
if (flags['enable-login-prompt']) {
|
|
22
|
-
return this.promptUserToLogIn();
|
|
22
|
+
return this.promptUserToLogIn(configuration.uuid);
|
|
23
23
|
}
|
|
24
24
|
throw new errors_1.CLIError('Could not find StepZen account credentials.' +
|
|
25
25
|
' Please run `stepzen login` first.');
|
|
26
26
|
}
|
|
27
|
-
async promptUserToLogIn() {
|
|
27
|
+
async promptUserToLogIn(uuid) {
|
|
28
28
|
this.log(chalk.bold(chalk.cyan('Welcome to StepZen CLI!')));
|
|
29
29
|
this.log('');
|
|
30
30
|
this.log(`Please log in with your StepZen account to make your GraphQL API private.` +
|
|
@@ -60,14 +60,14 @@ class ZenCommand extends command_1.Command {
|
|
|
60
60
|
suffix: chalk.blue(` (available at ${chalk.bold('https://stepzen.com/account')})`),
|
|
61
61
|
},
|
|
62
62
|
]);
|
|
63
|
-
|
|
64
|
-
configuration_1.
|
|
63
|
+
const credentials = await stepzen_sdk_1.default.login(answers.adminkey);
|
|
64
|
+
configuration = await configuration_1.writeCredentialsToConfigFile(credentials);
|
|
65
65
|
this.log('You have successfully logged in.');
|
|
66
66
|
this.log('');
|
|
67
67
|
}
|
|
68
68
|
else {
|
|
69
|
-
|
|
70
|
-
configuration_1.
|
|
69
|
+
const credentials = await stepzen_sdk_1.default.createAnonymousAccount(uuid);
|
|
70
|
+
configuration = await configuration_1.writeCredentialsToConfigFile(credentials);
|
|
71
71
|
this.log(`We've created a temporary public account for you.\nAll endpoints` +
|
|
72
72
|
` deployed to this account will be automatically deleted after 24` +
|
|
73
73
|
` hours. You can log in with your regular StepZen account at any` +
|
package/lib/start/deploy.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
5
5
|
const chalk = require("chalk");
|
|
6
|
-
const
|
|
6
|
+
const core_1 = require("@oclif/core");
|
|
7
7
|
const fs = require("fs-extra");
|
|
8
8
|
const path = require("path");
|
|
9
9
|
const prettyMilliseconds = require("pretty-ms");
|
|
@@ -19,7 +19,7 @@ exports.default = async (file, workspace, flags) => {
|
|
|
19
19
|
if (file) {
|
|
20
20
|
console.log(`File changed: ${chalk.blue(file)}`);
|
|
21
21
|
}
|
|
22
|
-
const configuration = configuration_1.readConfiguration();
|
|
22
|
+
const configuration = (await configuration_1.readConfiguration());
|
|
23
23
|
if (!flags['no-validate']) {
|
|
24
24
|
try {
|
|
25
25
|
await validate_1.default.run([workspace.schema]);
|
|
@@ -32,7 +32,7 @@ exports.default = async (file, workspace, flags) => {
|
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
core_1.CliUx.ux.action.start(`Deploying ${chalk.yellow(workspace.endpoint)} to StepZen`);
|
|
36
36
|
const deployArgs = [workspace.endpoint, '--silent'];
|
|
37
37
|
const uploadCmds = [];
|
|
38
38
|
const configPath = path.join(workspace.schema, 'config.yaml');
|
|
@@ -100,7 +100,7 @@ exports.default = async (file, workspace, flags) => {
|
|
|
100
100
|
}
|
|
101
101
|
const deployEnd = new Date().getTime();
|
|
102
102
|
const deployTime = deployEnd - deployStart;
|
|
103
|
-
|
|
103
|
+
core_1.CliUx.ux.action.stop(`${chalk.grey('done in')} ${prettyMilliseconds(deployTime)} 🚀`);
|
|
104
104
|
const domain = constants_1.STEPZEN_DOMAIN.replace('.io', '.net');
|
|
105
105
|
const endpoint = `https://${configuration.account}.${domain}/${workspace.endpoint}/__graphql`;
|
|
106
106
|
console.log();
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.13.0","commands":{"deploy":{"id":"deploy","description":"deploy to stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"non-interactive":{"name":"non-interactive","type":"boolean","description":"disable all interactive prompts","hidden":true,"allowNo":false},"enable-login-prompt":{"name":"enable-login-prompt","type":"option","description":"An (internal) feature flag to enable the \"prompt user to log in\" feature for the users who run the CLI without being logged in. It is intentially hidden and not documented because in the future this feature will be enabled for all users and the flag will be removed.","hidden":true,"options":["true","false"],"default":false},"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 a schema for an external data source or a API endpoint to your GraphQL API.","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"non-interactive":{"name":"non-interactive","type":"boolean","description":"disable all interactive prompts","hidden":true,"allowNo":false},"enable-login-prompt":{"name":"enable-login-prompt","type":"option","description":"An (internal) feature flag to enable the \"prompt user to log in\" feature for the users who run the CLI without being logged in. It is intentially hidden and not documented because in the future this feature will be enabled for all users and the flag will be removed.","hidden":true,"options":["true","false"],"default":false},"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},"name":{"name":"name","type":"option","description":"subfolder inside the workspace folder to save the imported schema files, defaults to the imported schema name"},"prefix":{"name":"prefix","type":"option","description":"[curl] prefix to add every type in the generated schema."},"query-name":{"name":"query-name","type":"option","description":"[curl] property name to add to the Query type as a way to access the imported cURL endpoint."},"query-type":{"name":"query-type","type":"option","description":"[curl] name for the type returned by the cURL endpoint in the generated schema. The name specified by --query-type is not prefixed by --prefix if both flags are present."},"path-params":{"name":"path-params","type":"option","description":"[curl] specifies path parameters in the URL path. Can be formed by taking the original path and replacing the variable segments with $paramName placeholders.\n\nExample:\nstepzen import curl https://example.com/users/jane/posts/12 --path-params '/users/$userId/posts/$postId'"}},"args":[{"name":"schemas","required":true}]},"init":{"id":"init","description":"stepzen init","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"non-interactive":{"name":"non-interactive","type":"boolean","description":"disable all interactive prompts","hidden":true,"allowNo":false},"enable-login-prompt":{"name":"enable-login-prompt","type":"option","description":"An (internal) feature flag to enable the \"prompt user to log in\" feature for the users who run the CLI without being logged in. It is intentially hidden and not documented because in the future this feature will be enabled for all users and the flag will be removed.","hidden":true,"options":["true","false"],"default":false},"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":{"non-interactive":{"name":"non-interactive","type":"boolean","description":"disable all interactive prompts","hidden":true,"allowNo":false},"enable-login-prompt":{"name":"enable-login-prompt","type":"option","description":"An (internal) feature flag to enable the \"prompt user to log in\" feature for the users who run the CLI without being logged in. It is intentially hidden and not documented because in the future this feature will be enabled for all users and the flag will be removed.","hidden":true,"options":["true","false"],"default":false},"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":{"non-interactive":{"name":"non-interactive","type":"boolean","description":"disable all interactive prompts","hidden":true,"allowNo":false},"enable-login-prompt":{"name":"enable-login-prompt","type":"option","description":"An (internal) feature flag to enable the \"prompt user to log in\" feature for the users who run the CLI without being logged in. It is intentially hidden and not documented because in the future this feature will be enabled for all users and the flag will be removed.","hidden":true,"options":["true","false"],"default":false},"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":{"non-interactive":{"name":"non-interactive","type":"boolean","description":"disable all interactive prompts","hidden":true,"allowNo":false},"enable-login-prompt":{"name":"enable-login-prompt","type":"option","description":"An (internal) feature flag to enable the \"prompt user to log in\" feature for the users who run the CLI without being logged in. It is intentially hidden and not documented because in the future this feature will be enabled for all users and the flag will be removed.","hidden":true,"options":["true","false"],"default":false},"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":{"non-interactive":{"name":"non-interactive","type":"boolean","description":"disable all interactive prompts","hidden":true,"allowNo":false},"enable-login-prompt":{"name":"enable-login-prompt","type":"option","description":"An (internal) feature flag to enable the \"prompt user to log in\" feature for the users who run the CLI without being logged in. It is intentially hidden and not documented because in the future this feature will be enabled for all users and the flag will be removed.","hidden":true,"options":["true","false"],"default":false},"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":{"non-interactive":{"name":"non-interactive","type":"boolean","description":"disable all interactive prompts","hidden":true,"allowNo":false},"enable-login-prompt":{"name":"enable-login-prompt","type":"option","description":"An (internal) feature flag to enable the \"prompt user to log in\" feature for the users who run the CLI without being logged in. It is intentially hidden and not documented because in the future this feature will be enabled for all users and the flag will be removed.","hidden":true,"options":["true","false"],"default":false},"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":{"non-interactive":{"name":"non-interactive","type":"boolean","description":"disable all interactive prompts","hidden":true,"allowNo":false},"enable-login-prompt":{"name":"enable-login-prompt","type":"option","description":"An (internal) feature flag to enable the \"prompt user to log in\" feature for the users who run the CLI without being logged in. It is intentially hidden and not documented because in the future this feature will be enabled for all users and the flag will be removed.","hidden":true,"options":["true","false"],"default":false},"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":{"non-interactive":{"name":"non-interactive","type":"boolean","description":"disable all interactive prompts","hidden":true,"allowNo":false},"enable-login-prompt":{"name":"enable-login-prompt","type":"option","description":"An (internal) feature flag to enable the \"prompt user to log in\" feature for the users who run the CLI without being logged in. It is intentially hidden and not documented because in the future this feature will be enabled for all users and the flag will be removed.","hidden":true,"options":["true","false"],"default":false},"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":{"non-interactive":{"name":"non-interactive","type":"boolean","description":"disable all interactive prompts","hidden":true,"allowNo":false},"enable-login-prompt":{"name":"enable-login-prompt","type":"option","description":"An (internal) feature flag to enable the \"prompt user to log in\" feature for the users who run the CLI without being logged in. It is intentially hidden and not documented because in the future this feature will be enabled for all users and the flag will be removed.","hidden":true,"options":["true","false"],"default":false},"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":{"non-interactive":{"name":"non-interactive","type":"boolean","description":"disable all interactive prompts","hidden":true,"allowNo":false},"enable-login-prompt":{"name":"enable-login-prompt","type":"option","description":"An (internal) feature flag to enable the \"prompt user to log in\" feature for the users who run the CLI without being logged in. It is intentially hidden and not documented because in the future this feature will be enabled for all users and the flag will be removed.","hidden":true,"options":["true","false"],"default":false},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"showkeys":{"name":"showkeys","type":"boolean","allowNo":false},"apikey":{"name":"apikey","type":"boolean","allowNo":false},"adminkey":{"name":"adminkey","type":"boolean","allowNo":false}},"args":[]}}}
|
|
1
|
+
{"version":"0.15.0-beta.0","commands":{"deploy":{"id":"deploy","description":"deploy to stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"non-interactive":{"name":"non-interactive","type":"boolean","description":"disable all interactive prompts","hidden":true,"allowNo":false},"enable-login-prompt":{"name":"enable-login-prompt","type":"option","description":"An (internal) feature flag to enable the \"prompt user to log in\" feature for the users who run the CLI without being logged in. It is intentially hidden and not documented because in the future this feature will be enabled for all users and the flag will be removed.","hidden":true,"options":["true","false"],"default":false},"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 a schema for an external data source or a API endpoint to your GraphQL API.","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"non-interactive":{"name":"non-interactive","type":"boolean","description":"disable all interactive prompts","hidden":true,"allowNo":false},"enable-login-prompt":{"name":"enable-login-prompt","type":"option","description":"An (internal) feature flag to enable the \"prompt user to log in\" feature for the users who run the CLI without being logged in. It is intentially hidden and not documented because in the future this feature will be enabled for all users and the flag will be removed.","hidden":true,"options":["true","false"],"default":false},"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},"name":{"name":"name","type":"option","description":"subfolder inside the workspace folder to save the imported schema files, defaults to the imported schema name"},"prefix":{"name":"prefix","type":"option","description":"[curl] prefix to add every type in the generated schema."},"query-name":{"name":"query-name","type":"option","description":"[curl] property name to add to the Query type as a way to access the imported cURL endpoint."},"query-type":{"name":"query-type","type":"option","description":"[curl] name for the type returned by the cURL endpoint in the generated schema. The name specified by --query-type is not prefixed by --prefix if both flags are present."},"path-params":{"name":"path-params","type":"option","description":"[curl] specifies path parameters in the URL path. Can be formed by taking the original path and replacing the variable segments with $paramName placeholders.\n\nExample:\nstepzen import curl https://example.com/users/jane/posts/12 --path-params '/users/$userId/posts/$postId'"}},"args":[{"name":"schemas","required":true}]},"init":{"id":"init","description":"stepzen init","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"non-interactive":{"name":"non-interactive","type":"boolean","description":"disable all interactive prompts","hidden":true,"allowNo":false},"enable-login-prompt":{"name":"enable-login-prompt","type":"option","description":"An (internal) feature flag to enable the \"prompt user to log in\" feature for the users who run the CLI without being logged in. It is intentially hidden and not documented because in the future this feature will be enabled for all users and the flag will be removed.","hidden":true,"options":["true","false"],"default":false},"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":{"non-interactive":{"name":"non-interactive","type":"boolean","description":"disable all interactive prompts","hidden":true,"allowNo":false},"enable-login-prompt":{"name":"enable-login-prompt","type":"option","description":"An (internal) feature flag to enable the \"prompt user to log in\" feature for the users who run the CLI without being logged in. It is intentially hidden and not documented because in the future this feature will be enabled for all users and the flag will be removed.","hidden":true,"options":["true","false"],"default":false},"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":{"non-interactive":{"name":"non-interactive","type":"boolean","description":"disable all interactive prompts","hidden":true,"allowNo":false},"enable-login-prompt":{"name":"enable-login-prompt","type":"option","description":"An (internal) feature flag to enable the \"prompt user to log in\" feature for the users who run the CLI without being logged in. It is intentially hidden and not documented because in the future this feature will be enabled for all users and the flag will be removed.","hidden":true,"options":["true","false"],"default":false},"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":{"non-interactive":{"name":"non-interactive","type":"boolean","description":"disable all interactive prompts","hidden":true,"allowNo":false},"enable-login-prompt":{"name":"enable-login-prompt","type":"option","description":"An (internal) feature flag to enable the \"prompt user to log in\" feature for the users who run the CLI without being logged in. It is intentially hidden and not documented because in the future this feature will be enabled for all users and the flag will be removed.","hidden":true,"options":["true","false"],"default":false},"account":{"name":"account","type":"option","char":"a","hidden":true},"adminkey":{"name":"adminkey","type":"option","char":"k","hidden":true},"public":{"name":"public","type":"boolean","description":"Create a public anonymous StepZen account and use it. This is handy for trying StepZen out, but it not suitable for handling private data as all endpoints created with a public account will be public.","allowNo":false},"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":{"non-interactive":{"name":"non-interactive","type":"boolean","description":"disable all interactive prompts","hidden":true,"allowNo":false},"enable-login-prompt":{"name":"enable-login-prompt","type":"option","description":"An (internal) feature flag to enable the \"prompt user to log in\" feature for the users who run the CLI without being logged in. It is intentially hidden and not documented because in the future this feature will be enabled for all users and the flag will be removed.","hidden":true,"options":["true","false"],"default":false},"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":{"non-interactive":{"name":"non-interactive","type":"boolean","description":"disable all interactive prompts","hidden":true,"allowNo":false},"enable-login-prompt":{"name":"enable-login-prompt","type":"option","description":"An (internal) feature flag to enable the \"prompt user to log in\" feature for the users who run the CLI without being logged in. It is intentially hidden and not documented because in the future this feature will be enabled for all users and the flag will be removed.","hidden":true,"options":["true","false"],"default":false},"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":{"non-interactive":{"name":"non-interactive","type":"boolean","description":"disable all interactive prompts","hidden":true,"allowNo":false},"enable-login-prompt":{"name":"enable-login-prompt","type":"option","description":"An (internal) feature flag to enable the \"prompt user to log in\" feature for the users who run the CLI without being logged in. It is intentially hidden and not documented because in the future this feature will be enabled for all users and the flag will be removed.","hidden":true,"options":["true","false"],"default":false},"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":{"non-interactive":{"name":"non-interactive","type":"boolean","description":"disable all interactive prompts","hidden":true,"allowNo":false},"enable-login-prompt":{"name":"enable-login-prompt","type":"option","description":"An (internal) feature flag to enable the \"prompt user to log in\" feature for the users who run the CLI without being logged in. It is intentially hidden and not documented because in the future this feature will be enabled for all users and the flag will be removed.","hidden":true,"options":["true","false"],"default":false},"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":{"non-interactive":{"name":"non-interactive","type":"boolean","description":"disable all interactive prompts","hidden":true,"allowNo":false},"enable-login-prompt":{"name":"enable-login-prompt","type":"option","description":"An (internal) feature flag to enable the \"prompt user to log in\" feature for the users who run the CLI without being logged in. It is intentially hidden and not documented because in the future this feature will be enabled for all users and the flag will be removed.","hidden":true,"options":["true","false"],"default":false},"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":{"non-interactive":{"name":"non-interactive","type":"boolean","description":"disable all interactive prompts","hidden":true,"allowNo":false},"enable-login-prompt":{"name":"enable-login-prompt","type":"option","description":"An (internal) feature flag to enable the \"prompt user to log in\" feature for the users who run the CLI without being logged in. It is intentially hidden and not documented because in the future this feature will be enabled for all users and the flag will be removed.","hidden":true,"options":["true","false"],"default":false},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"showkeys":{"name":"showkeys","type":"boolean","allowNo":false},"apikey":{"name":"apikey","type":"boolean","allowNo":false},"adminkey":{"name":"adminkey","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.
|
|
4
|
+
"version": "0.15.0-beta.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Darren Waddell <darren@stepzen.com>",
|
|
7
7
|
"contributors": [
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"main": "lib/index.js",
|
|
15
15
|
"engines": {
|
|
16
|
-
"node": ">=14.0
|
|
16
|
+
"node": ">=14.17.0",
|
|
17
17
|
"npm": ">=6.14"
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@oclif/command": "^1.8.0",
|
|
30
30
|
"@oclif/config": "^1.18.3",
|
|
31
|
+
"@oclif/core": "1.6.3",
|
|
31
32
|
"@oclif/errors": "1.3.5",
|
|
32
33
|
"@oclif/plugin-help": "^5.1.12",
|
|
33
34
|
"@stepzen/dashboard": "0.1.37",
|
|
34
|
-
"@stepzen/sdk": "0.
|
|
35
|
+
"@stepzen/sdk": "0.11.0",
|
|
35
36
|
"@stepzen/transpiler": "0.0.38",
|
|
36
37
|
"chalk": "^4.1.1",
|
|
37
38
|
"chokidar": "^3.5.2",
|
|
38
|
-
"cli-ux": "^6.0.9",
|
|
39
39
|
"compare-versions": "^3.6.0",
|
|
40
40
|
"date-fns": "^2.26.0",
|
|
41
41
|
"debug": "^4.3.0",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"@types/minimist": "^1.2.1",
|
|
70
70
|
"@types/mocha": "^5.2.7",
|
|
71
71
|
"@types/mock-fs": "^4.13.0",
|
|
72
|
-
"@types/node": "^
|
|
72
|
+
"@types/node": "^14.18.13",
|
|
73
73
|
"@types/node-fetch": "^2.5.7",
|
|
74
74
|
"@types/prettier": "^2.1.6",
|
|
75
75
|
"@types/rimraf": "^3.0.0",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"hooks": {
|
|
108
108
|
"prerun": [
|
|
109
109
|
"./lib/hooks/prerun/check-upgrade",
|
|
110
|
-
"./lib/hooks/prerun/ensure-
|
|
110
|
+
"./lib/hooks/prerun/ensure-config-file",
|
|
111
111
|
"./lib/hooks/prerun/ensure-permissions"
|
|
112
112
|
]
|
|
113
113
|
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const utils_1 = require("../../shared/utils");
|
|
5
|
-
const hook = async function () {
|
|
6
|
-
await utils_1.ensureApiKey();
|
|
7
|
-
};
|
|
8
|
-
exports.default = hook;
|