stepzen 0.13.0-beta.1 → 0.13.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/commands/deploy.d.ts +10 -3
- package/lib/commands/deploy.js +5 -13
- package/lib/commands/import.d.ts +14 -3
- package/lib/commands/import.js +9 -17
- package/lib/commands/init.d.ts +9 -3
- package/lib/commands/init.js +3 -6
- package/lib/commands/lint.d.ts +8 -3
- package/lib/commands/lint.js +3 -5
- package/lib/commands/list.d.ts +6 -3
- package/lib/commands/list.js +4 -10
- package/lib/commands/login.d.ts +10 -3
- package/lib/commands/login.js +5 -19
- package/lib/commands/logout.d.ts +6 -3
- package/lib/commands/logout.js +3 -4
- package/lib/commands/start.d.ts +16 -3
- package/lib/commands/start.js +4 -19
- package/lib/commands/transpile.d.ts +13 -3
- package/lib/commands/transpile.js +3 -10
- package/lib/commands/upload.d.ts +10 -3
- package/lib/commands/upload.js +5 -14
- package/lib/commands/validate.d.ts +6 -3
- package/lib/commands/validate.js +3 -4
- package/lib/commands/whoami.d.ts +9 -3
- package/lib/commands/whoami.js +6 -10
- package/lib/generate/curl2sdl.d.ts +1 -1
- package/lib/generate/index.d.ts +1 -1
- package/lib/shared/configuration.d.ts +1 -1
- package/lib/shared/configuration.js +1 -1
- package/lib/shared/stepzen-sdk.d.ts +8 -0
- package/lib/shared/stepzen-sdk.js +22 -1
- package/lib/shared/utils.js +1 -1
- package/lib/shared/zen-command.d.ts +14 -0
- package/lib/shared/zen-command.js +80 -0
- package/oclif.manifest.json +1 -1
- package/package.json +1 -2
- package/lib/hooks/prerun/check-account.d.ts +0 -3
- package/lib/hooks/prerun/check-account.js +0 -12
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.13.0-beta.
|
|
32
|
+
stepzen/0.13.0-beta.2 darwin-x64 node-v14.19.1
|
|
33
33
|
$ stepzen --help [COMMAND]
|
|
34
34
|
USAGE
|
|
35
35
|
$ stepzen COMMAND
|
package/lib/commands/deploy.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { flags } from '@oclif/command';
|
|
2
|
+
import ZenCommand from '../shared/zen-command';
|
|
3
|
+
export default class Deploy extends ZenCommand {
|
|
3
4
|
static description: string;
|
|
4
|
-
static flags:
|
|
5
|
+
static flags: {
|
|
6
|
+
configurationsets: flags.IOptionFlag<string>;
|
|
7
|
+
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
8
|
+
schema: flags.IOptionFlag<string>;
|
|
9
|
+
silent: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
10
|
+
'non-interactive': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
11
|
+
};
|
|
5
12
|
static args: {
|
|
6
13
|
name: string;
|
|
7
14
|
description: string;
|
package/lib/commands/deploy.js
CHANGED
|
@@ -8,19 +8,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
8
8
|
const command_1 = require("@oclif/command");
|
|
9
9
|
const errors_1 = require("@oclif/errors");
|
|
10
10
|
const actions_1 = require("../shared/actions");
|
|
11
|
-
const
|
|
12
|
-
class Deploy extends
|
|
11
|
+
const zen_command_1 = require("../shared/zen-command");
|
|
12
|
+
class Deploy extends zen_command_1.default {
|
|
13
13
|
async run() {
|
|
14
14
|
const { args, flags } = this.parse(Deploy);
|
|
15
15
|
// Make sure that you definitely specify folder/name
|
|
16
16
|
if (args.destination.includes('/') === false) {
|
|
17
17
|
throw new errors_1.CLIError('You must specify the folder/name you want to use');
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
if (!configuration) {
|
|
21
|
-
// Configuration not found. Most likely because someone is not logged in. Exit with error.
|
|
22
|
-
throw new errors_1.CLIError('You are probably not logged in.');
|
|
23
|
-
}
|
|
19
|
+
await this.ensureStepZenAccount();
|
|
24
20
|
if (!flags.silent) {
|
|
25
21
|
this.log('Deploying...');
|
|
26
22
|
}
|
|
@@ -38,17 +34,13 @@ class Deploy extends command_1.Command {
|
|
|
38
34
|
}
|
|
39
35
|
exports.default = Deploy;
|
|
40
36
|
Deploy.description = 'deploy to stepzen';
|
|
41
|
-
Deploy.flags = {
|
|
37
|
+
Deploy.flags = Object.assign(Object.assign({}, zen_command_1.default.flags), {
|
|
42
38
|
// configurationsets is assumed to be a comma separated string naming uploaded configurationsets
|
|
43
39
|
// a special configuration 'stepzen/defaults' is recognized.
|
|
44
40
|
configurationsets: command_1.flags.string({
|
|
45
41
|
description: 'Configurationsets to use',
|
|
46
42
|
default: '',
|
|
47
|
-
}),
|
|
48
|
-
help: command_1.flags.help({ char: 'h' }),
|
|
49
|
-
schema: command_1.flags.string({ description: 'Schema to use', required: true }),
|
|
50
|
-
silent: command_1.flags.boolean(),
|
|
51
|
-
};
|
|
43
|
+
}), help: command_1.flags.help({ char: 'h' }), schema: command_1.flags.string({ description: 'Schema to use', required: true }), silent: command_1.flags.boolean() });
|
|
52
44
|
Deploy.args = [
|
|
53
45
|
{
|
|
54
46
|
name: 'destination',
|
package/lib/commands/import.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { flags } from '@oclif/command';
|
|
2
|
+
import ZenCommand from '../shared/zen-command';
|
|
3
|
+
export default class Import extends ZenCommand {
|
|
3
4
|
static description: string;
|
|
4
|
-
static flags:
|
|
5
|
+
static flags: {
|
|
6
|
+
dir: flags.IOptionFlag<string | undefined>;
|
|
7
|
+
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
8
|
+
silent: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
9
|
+
name: flags.IOptionFlag<string | undefined>;
|
|
10
|
+
prefix: flags.IOptionFlag<string | undefined>;
|
|
11
|
+
'query-name': flags.IOptionFlag<string | undefined>;
|
|
12
|
+
'query-type': flags.IOptionFlag<string | undefined>;
|
|
13
|
+
'path-params': flags.IOptionFlag<string | undefined>;
|
|
14
|
+
'non-interactive': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
15
|
+
};
|
|
5
16
|
static args: {
|
|
6
17
|
name: string;
|
|
7
18
|
required: boolean;
|
package/lib/commands/import.js
CHANGED
|
@@ -14,10 +14,11 @@ const helpers_1 = require("../generate/helpers");
|
|
|
14
14
|
const curl2sdl_1 = require("../generate/curl2sdl");
|
|
15
15
|
const curl_parser_1 = require("../shared/curl-parser");
|
|
16
16
|
const workspace_1 = require("../shared/workspace");
|
|
17
|
+
const zen_command_1 = require("../shared/zen-command");
|
|
17
18
|
const init_1 = require("./init");
|
|
18
19
|
const constants_1 = require("../shared/constants");
|
|
19
20
|
const path_params_parser_1 = require("../shared/path-params-parser");
|
|
20
|
-
class Import extends
|
|
21
|
+
class Import extends zen_command_1.default {
|
|
21
22
|
async run() {
|
|
22
23
|
const { args, argv, flags } = this.parse(Import);
|
|
23
24
|
// Get a list of schemas you're asking for
|
|
@@ -100,7 +101,7 @@ class Import extends command_1.Command {
|
|
|
100
101
|
result = resultOrError.outPath;
|
|
101
102
|
}
|
|
102
103
|
else {
|
|
103
|
-
;
|
|
104
|
+
await this.ensureStepZenAccount();
|
|
104
105
|
['prefix', 'query-type', 'query-name', 'path-params'].forEach(flag => {
|
|
105
106
|
if (flag in flags) {
|
|
106
107
|
this.log(chalk.gray(`The ${chalk.bold(`--${flag}`)} flag only applies when importing ${chalk.bold('curl')}. It will be ignored now.`));
|
|
@@ -130,26 +131,18 @@ class Import extends command_1.Command {
|
|
|
130
131
|
}
|
|
131
132
|
exports.default = Import;
|
|
132
133
|
Import.description = 'Import a schema for an external data source or a API endpoint to your GraphQL API.';
|
|
133
|
-
Import.flags = {
|
|
134
|
-
dir: command_1.flags.string({ description: 'working directory' }),
|
|
135
|
-
help: command_1.flags.help({ char: 'h' }),
|
|
136
|
-
silent: command_1.flags.boolean({ hidden: true }),
|
|
137
|
-
name: command_1.flags.string({
|
|
134
|
+
Import.flags = Object.assign(Object.assign({}, zen_command_1.default.flags), { dir: command_1.flags.string({ description: 'working directory' }), help: command_1.flags.help({ char: 'h' }), silent: command_1.flags.boolean({ hidden: true }), name: command_1.flags.string({
|
|
138
135
|
description: 'subfolder inside the workspace folder to save the imported' +
|
|
139
136
|
' schema files, defaults to the imported schema name',
|
|
140
|
-
}),
|
|
141
|
-
prefix: command_1.flags.string({
|
|
137
|
+
}), prefix: command_1.flags.string({
|
|
142
138
|
description: '[curl] prefix to add every type in the generated schema.',
|
|
143
|
-
}),
|
|
144
|
-
'query-name': command_1.flags.string({
|
|
139
|
+
}), 'query-name': command_1.flags.string({
|
|
145
140
|
description: '[curl] property name to add to the Query type as a way to' +
|
|
146
141
|
' access the imported cURL endpoint.',
|
|
147
|
-
}),
|
|
148
|
-
'query-type': command_1.flags.string({
|
|
142
|
+
}), 'query-type': command_1.flags.string({
|
|
149
143
|
description: '[curl] name for the type returned by the cURL endpoint in the ' +
|
|
150
144
|
`generated schema. The name specified by ${chalk.bold('--query-type')} is not prefixed by ${chalk.bold('--prefix')} if both flags are present.`,
|
|
151
|
-
}),
|
|
152
|
-
'path-params': command_1.flags.string({
|
|
145
|
+
}), 'path-params': command_1.flags.string({
|
|
153
146
|
description: `[curl] specifies path parameters in the URL path.` +
|
|
154
147
|
` Can be formed by taking the original path and replacing the` +
|
|
155
148
|
` variable segments with ${chalk.bold('$paramName')} placeholders.` +
|
|
@@ -158,8 +151,7 @@ Import.flags = {
|
|
|
158
151
|
`\nstepzen import curl https://example.com/users/jane/posts/12` +
|
|
159
152
|
` --path-params` +
|
|
160
153
|
` '/users/${chalk.bold('$userId')}/posts/${chalk.bold('$postId')}'`,
|
|
161
|
-
})
|
|
162
|
-
};
|
|
154
|
+
}) });
|
|
163
155
|
Import.args = [
|
|
164
156
|
{
|
|
165
157
|
name: 'schemas',
|
package/lib/commands/init.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { flags } from '@oclif/command';
|
|
2
|
+
import ZenCommand from '../shared/zen-command';
|
|
2
3
|
export declare const validateWorkspaceName: (directory: string, name: string) => boolean;
|
|
3
4
|
export declare const generateWorkspaceName: (directory: string) => string;
|
|
4
5
|
export declare const guessSchemaRoot: (directory: string) => string;
|
|
5
|
-
export default class Init extends
|
|
6
|
+
export default class Init extends ZenCommand {
|
|
6
7
|
static description: string;
|
|
7
8
|
static hidden: boolean;
|
|
8
|
-
static flags:
|
|
9
|
+
static flags: {
|
|
10
|
+
endpoint: flags.IOptionFlag<string | undefined>;
|
|
11
|
+
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
12
|
+
yes: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
13
|
+
'non-interactive': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
14
|
+
};
|
|
9
15
|
static args: {
|
|
10
16
|
hidden: boolean;
|
|
11
17
|
name: string;
|
package/lib/commands/init.js
CHANGED
|
@@ -12,6 +12,7 @@ const path = require("path");
|
|
|
12
12
|
const utils_1 = require("../shared/utils");
|
|
13
13
|
const moniker_1 = require("../shared/moniker");
|
|
14
14
|
const workspace_1 = require("../shared/workspace");
|
|
15
|
+
const zen_command_1 = require("../shared/zen-command");
|
|
15
16
|
exports.validateWorkspaceName = (directory, name) => {
|
|
16
17
|
return !fs.existsSync(path.join(directory, name));
|
|
17
18
|
};
|
|
@@ -35,7 +36,7 @@ exports.guessSchemaRoot = (directory) => {
|
|
|
35
36
|
];
|
|
36
37
|
return existing.length > 0 ? path.dirname(existing[0]) : '';
|
|
37
38
|
};
|
|
38
|
-
class Init extends
|
|
39
|
+
class Init extends zen_command_1.default {
|
|
39
40
|
async run() {
|
|
40
41
|
const { args, flags } = this.parse(Init);
|
|
41
42
|
// Get the correct directory
|
|
@@ -121,11 +122,7 @@ class Init extends command_1.Command {
|
|
|
121
122
|
exports.default = Init;
|
|
122
123
|
Init.description = 'stepzen init';
|
|
123
124
|
Init.hidden = true;
|
|
124
|
-
Init.flags = {
|
|
125
|
-
endpoint: command_1.flags.string({ hidden: true }),
|
|
126
|
-
help: command_1.flags.help({ char: 'h' }),
|
|
127
|
-
yes: command_1.flags.boolean({ default: false, hidden: true }),
|
|
128
|
-
};
|
|
125
|
+
Init.flags = Object.assign(Object.assign({}, zen_command_1.default.flags), { endpoint: command_1.flags.string({ hidden: true }), help: command_1.flags.help({ char: 'h' }), yes: command_1.flags.boolean({ default: false, hidden: true }) });
|
|
129
126
|
Init.args = [
|
|
130
127
|
{
|
|
131
128
|
hidden: true,
|
package/lib/commands/lint.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { flags } from '@oclif/command';
|
|
2
|
+
import ZenCommand from '../shared/zen-command';
|
|
3
|
+
export default class Init extends ZenCommand {
|
|
3
4
|
static description: string;
|
|
4
5
|
static hidden: boolean;
|
|
5
|
-
static flags:
|
|
6
|
+
static flags: {
|
|
7
|
+
dir: flags.IOptionFlag<string | undefined>;
|
|
8
|
+
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
9
|
+
'non-interactive': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
10
|
+
};
|
|
6
11
|
run(): Promise<void>;
|
|
7
12
|
}
|
package/lib/commands/lint.js
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const command_1 = require("@oclif/command");
|
|
5
5
|
const utils_1 = require("../shared/utils");
|
|
6
|
+
const zen_command_1 = require("../shared/zen-command");
|
|
6
7
|
const { lint } = require('@stepzen/transpiler');
|
|
7
|
-
class Init extends
|
|
8
|
+
class Init extends zen_command_1.default {
|
|
8
9
|
async run() {
|
|
9
10
|
const { flags } = this.parse(Init);
|
|
10
11
|
// Get the correct directory
|
|
@@ -23,7 +24,4 @@ class Init extends command_1.Command {
|
|
|
23
24
|
exports.default = Init;
|
|
24
25
|
Init.description = 'stepzen lint';
|
|
25
26
|
Init.hidden = true;
|
|
26
|
-
Init.flags = {
|
|
27
|
-
dir: command_1.flags.string({ hidden: true }),
|
|
28
|
-
help: command_1.flags.help({ char: 'h' }),
|
|
29
|
-
};
|
|
27
|
+
Init.flags = Object.assign(Object.assign({}, zen_command_1.default.flags), { dir: command_1.flags.string({ hidden: true }), help: command_1.flags.help({ char: 'h' }) });
|
package/lib/commands/list.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default class List extends
|
|
1
|
+
import ZenCommand from '../shared/zen-command';
|
|
2
|
+
export default class List extends ZenCommand {
|
|
3
3
|
static description: string;
|
|
4
|
-
static flags:
|
|
4
|
+
static flags: {
|
|
5
|
+
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
6
|
+
'non-interactive': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
7
|
+
};
|
|
5
8
|
static args: {
|
|
6
9
|
name: string;
|
|
7
10
|
required: boolean;
|
package/lib/commands/list.js
CHANGED
|
@@ -8,16 +8,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
8
8
|
const command_1 = require("@oclif/command");
|
|
9
9
|
const errors_1 = require("@oclif/errors");
|
|
10
10
|
const actions_1 = require("../shared/actions");
|
|
11
|
-
const
|
|
12
|
-
class List extends
|
|
11
|
+
const zen_command_1 = require("../shared/zen-command");
|
|
12
|
+
class List extends zen_command_1.default {
|
|
13
13
|
async run() {
|
|
14
14
|
var _a;
|
|
15
15
|
const { args } = this.parse(List);
|
|
16
|
-
|
|
17
|
-
if (!configuration) {
|
|
18
|
-
// Configuration not found. Most likely because someone is not logged in. Exit with error.
|
|
19
|
-
throw new errors_1.CLIError('You are probably not logged in.');
|
|
20
|
-
}
|
|
16
|
+
await this.ensureStepZenAccount();
|
|
21
17
|
const response = await actions_1.list(args.type);
|
|
22
18
|
if (response.success) {
|
|
23
19
|
if (((_a = response.results) === null || _a === void 0 ? void 0 : _a.length) === 0) {
|
|
@@ -37,9 +33,7 @@ class List extends command_1.Command {
|
|
|
37
33
|
}
|
|
38
34
|
exports.default = List;
|
|
39
35
|
List.description = 'list your items';
|
|
40
|
-
List.flags = {
|
|
41
|
-
help: command_1.flags.help({ char: 'h' }),
|
|
42
|
-
};
|
|
36
|
+
List.flags = Object.assign(Object.assign({}, zen_command_1.default.flags), { help: command_1.flags.help({ char: 'h' }) });
|
|
43
37
|
List.args = [
|
|
44
38
|
{
|
|
45
39
|
name: 'type',
|
package/lib/commands/login.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { flags } from '@oclif/command';
|
|
2
|
+
import ZenCommand from '../shared/zen-command';
|
|
3
|
+
export default class Login extends ZenCommand {
|
|
3
4
|
static description: string;
|
|
4
|
-
static flags:
|
|
5
|
+
static flags: {
|
|
6
|
+
account: flags.IOptionFlag<string | undefined>;
|
|
7
|
+
adminkey: flags.IOptionFlag<string | undefined>;
|
|
8
|
+
config: flags.IOptionFlag<string | undefined>;
|
|
9
|
+
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
10
|
+
'non-interactive': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
11
|
+
};
|
|
5
12
|
run(): Promise<void>;
|
|
6
13
|
}
|
package/lib/commands/login.js
CHANGED
|
@@ -5,11 +5,11 @@ 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");
|
|
9
8
|
const cli_ux_1 = require("cli-ux");
|
|
10
9
|
const configuration_1 = require("../shared/configuration");
|
|
11
10
|
const stepzen_sdk_1 = require("../shared/stepzen-sdk");
|
|
12
|
-
|
|
11
|
+
const zen_command_1 = require("../shared/zen-command");
|
|
12
|
+
class Login extends zen_command_1.default {
|
|
13
13
|
async run() {
|
|
14
14
|
const { flags } = this.parse(Login);
|
|
15
15
|
let account;
|
|
@@ -38,26 +38,12 @@ class Login extends command_1.Command {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
// the stepzen admin api.
|
|
43
|
-
const isValidConfiguration = await stepzen_sdk_1.default.verify(account, adminkey);
|
|
44
|
-
if (!isValidConfiguration) {
|
|
45
|
-
// Exit, with error
|
|
46
|
-
throw new errors_1.CLIError('We are unable to verify your account details. Could you please check them?');
|
|
47
|
-
}
|
|
41
|
+
const configuration = await stepzen_sdk_1.default.login(adminkey, account);
|
|
48
42
|
// Change the default account.
|
|
49
|
-
configuration_1.writeConfigurationToLoginFile(
|
|
50
|
-
account,
|
|
51
|
-
adminkey,
|
|
52
|
-
});
|
|
43
|
+
configuration_1.writeConfigurationToLoginFile(configuration);
|
|
53
44
|
this.log('You have successfully logged in.');
|
|
54
45
|
}
|
|
55
46
|
}
|
|
56
47
|
exports.default = Login;
|
|
57
48
|
Login.description = 'log in to stepzen';
|
|
58
|
-
Login.flags = {
|
|
59
|
-
account: command_1.flags.string({ char: 'a', exclusive: ['config'], hidden: true }),
|
|
60
|
-
adminkey: command_1.flags.string({ char: 'k', exclusive: ['config'], hidden: true }),
|
|
61
|
-
config: command_1.flags.string({ exclusive: ['account', 'adminkey'], hidden: true }),
|
|
62
|
-
help: command_1.flags.help({ char: 'h' }),
|
|
63
|
-
};
|
|
49
|
+
Login.flags = Object.assign(Object.assign({}, zen_command_1.default.flags), { account: command_1.flags.string({ char: 'a', exclusive: ['config'], hidden: true }), adminkey: command_1.flags.string({ char: 'k', exclusive: ['config'], hidden: true }), config: command_1.flags.string({ exclusive: ['account', 'adminkey'], hidden: true }), help: command_1.flags.help({ char: 'h' }) });
|
package/lib/commands/logout.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default class Logout extends
|
|
1
|
+
import ZenCommand from '../shared/zen-command';
|
|
2
|
+
export default class Logout extends ZenCommand {
|
|
3
3
|
static description: string;
|
|
4
|
-
static flags:
|
|
4
|
+
static flags: {
|
|
5
|
+
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
6
|
+
'non-interactive': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
7
|
+
};
|
|
5
8
|
run(): Promise<void>;
|
|
6
9
|
}
|
package/lib/commands/logout.js
CHANGED
|
@@ -5,7 +5,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
5
5
|
// The logout command removes the entry in the login file.
|
|
6
6
|
const command_1 = require("@oclif/command");
|
|
7
7
|
const configuration_1 = require("../shared/configuration");
|
|
8
|
-
|
|
8
|
+
const zen_command_1 = require("../shared/zen-command");
|
|
9
|
+
class Logout extends zen_command_1.default {
|
|
9
10
|
async run() {
|
|
10
11
|
// Remove the configuration from the login file.
|
|
11
12
|
configuration_1.removeConfigurationFromLoginFile();
|
|
@@ -14,6 +15,4 @@ class Logout extends command_1.Command {
|
|
|
14
15
|
}
|
|
15
16
|
exports.default = Logout;
|
|
16
17
|
Logout.description = 'log out of stepzen';
|
|
17
|
-
Logout.flags = {
|
|
18
|
-
help: command_1.flags.help({ char: 'h' }),
|
|
19
|
-
};
|
|
18
|
+
Logout.flags = Object.assign(Object.assign({}, zen_command_1.default.flags), { help: command_1.flags.help({ char: 'h' }) });
|
package/lib/commands/start.d.ts
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { flags } from '@oclif/command';
|
|
2
|
+
import ZenCommand from '../shared/zen-command';
|
|
3
|
+
export default class Start extends ZenCommand {
|
|
3
4
|
static description: string;
|
|
4
|
-
static flags:
|
|
5
|
+
static flags: {
|
|
6
|
+
dir: flags.IOptionFlag<string | undefined>;
|
|
7
|
+
endpoint: flags.IOptionFlag<string | undefined>;
|
|
8
|
+
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
9
|
+
'no-console': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
10
|
+
'no-dashboard': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
11
|
+
'no-init': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
12
|
+
'no-server': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
13
|
+
'no-validate': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
14
|
+
'no-watcher': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
15
|
+
port: import("@oclif/parser/lib/flags").IOptionFlag<number>;
|
|
16
|
+
'non-interactive': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
17
|
+
};
|
|
5
18
|
static args: never[];
|
|
6
19
|
run(): Promise<void>;
|
|
7
20
|
}
|
package/lib/commands/start.js
CHANGED
|
@@ -7,23 +7,19 @@ const command_1 = require("@oclif/command");
|
|
|
7
7
|
const errors_1 = require("@oclif/errors");
|
|
8
8
|
const throttle_debounce_1 = require("throttle-debounce");
|
|
9
9
|
const detect = require("detect-port");
|
|
10
|
-
const configuration_1 = require("../shared/configuration");
|
|
11
10
|
const utils_1 = require("../shared/utils");
|
|
12
11
|
const start_1 = require("../start");
|
|
13
12
|
const workspace_1 = require("../shared/workspace");
|
|
14
13
|
const init_1 = require("./init");
|
|
15
14
|
const dashboard_interface_1 = require("../generate/dashboard-interface");
|
|
16
15
|
const constants_1 = require("../shared/constants");
|
|
16
|
+
const zen_command_1 = require("../shared/zen-command");
|
|
17
17
|
const dashboard = require('@stepzen/dashboard');
|
|
18
18
|
const { version } = require('../../package.json');
|
|
19
|
-
class Start extends
|
|
19
|
+
class Start extends zen_command_1.default {
|
|
20
20
|
async run() {
|
|
21
21
|
const { flags } = this.parse(Start);
|
|
22
|
-
const configuration =
|
|
23
|
-
if (!configuration) {
|
|
24
|
-
// Configuration not found. Most likely because someone is not logged in. Exit with error.
|
|
25
|
-
throw new errors_1.CLIError('You are probably not logged in.');
|
|
26
|
-
}
|
|
22
|
+
const { configuration } = await this.ensureStepZenAccount();
|
|
27
23
|
// Get the working directory and workspace
|
|
28
24
|
let workspace;
|
|
29
25
|
const directory = utils_1.getDirectory(flags.dir);
|
|
@@ -103,16 +99,5 @@ class Start extends command_1.Command {
|
|
|
103
99
|
}
|
|
104
100
|
exports.default = Start;
|
|
105
101
|
Start.description = 'upload and deploy your schema';
|
|
106
|
-
Start.flags = {
|
|
107
|
-
dir: command_1.flags.string({ description: 'working directory' }),
|
|
108
|
-
endpoint: command_1.flags.string({ description: 'Override workspace endpoint' }),
|
|
109
|
-
help: command_1.flags.help({ char: 'h' }),
|
|
110
|
-
'no-console': command_1.flags.boolean({ hidden: true }),
|
|
111
|
-
'no-dashboard': command_1.flags.boolean({ hidden: true }),
|
|
112
|
-
'no-init': command_1.flags.boolean({ hidden: true }),
|
|
113
|
-
'no-server': command_1.flags.boolean({ hidden: true }),
|
|
114
|
-
'no-validate': command_1.flags.boolean({ hidden: true }),
|
|
115
|
-
'no-watcher': command_1.flags.boolean({ hidden: true }),
|
|
116
|
-
port: command_1.flags.integer({ default: 5001, env: 'PORT' }),
|
|
117
|
-
};
|
|
102
|
+
Start.flags = Object.assign(Object.assign({}, zen_command_1.default.flags), { dir: command_1.flags.string({ description: 'working directory' }), endpoint: command_1.flags.string({ description: 'Override workspace endpoint' }), help: command_1.flags.help({ char: 'h' }), 'no-console': command_1.flags.boolean({ hidden: true }), 'no-dashboard': command_1.flags.boolean({ hidden: true }), 'no-init': command_1.flags.boolean({ hidden: true }), 'no-server': command_1.flags.boolean({ hidden: true }), 'no-validate': command_1.flags.boolean({ hidden: true }), 'no-watcher': command_1.flags.boolean({ hidden: true }), port: command_1.flags.integer({ default: 5001, env: 'PORT' }) });
|
|
118
103
|
Start.args = [];
|
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { flags } from '@oclif/command';
|
|
2
|
+
import ZenCommand from '../shared/zen-command';
|
|
3
|
+
export default class Transpile extends ZenCommand {
|
|
3
4
|
static description: string;
|
|
4
5
|
static hidden: boolean;
|
|
5
|
-
static flags:
|
|
6
|
+
static flags: {
|
|
7
|
+
config: flags.IOptionFlag<string | undefined>;
|
|
8
|
+
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
9
|
+
'hide-output': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
10
|
+
inspect: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
11
|
+
'inspect-after': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
12
|
+
'output-configuration': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
13
|
+
silent: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
14
|
+
'non-interactive': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
15
|
+
};
|
|
6
16
|
static args: {
|
|
7
17
|
name: string;
|
|
8
18
|
required: boolean;
|
|
@@ -7,8 +7,9 @@ const errors_1 = require("@oclif/errors");
|
|
|
7
7
|
const fs = require("fs-extra");
|
|
8
8
|
const path = require("path");
|
|
9
9
|
const utils_1 = require("../shared/utils");
|
|
10
|
+
const zen_command_1 = require("../shared/zen-command");
|
|
10
11
|
const { configure, stitch, validate } = require('@stepzen/transpiler');
|
|
11
|
-
class Transpile extends
|
|
12
|
+
class Transpile extends zen_command_1.default {
|
|
12
13
|
async run() {
|
|
13
14
|
const { args, flags } = this.parse(Transpile);
|
|
14
15
|
const folder = utils_1.getDirectory(args.folder);
|
|
@@ -39,15 +40,7 @@ class Transpile extends command_1.Command {
|
|
|
39
40
|
exports.default = Transpile;
|
|
40
41
|
Transpile.description = 'transpile a graphql schema';
|
|
41
42
|
Transpile.hidden = true;
|
|
42
|
-
Transpile.flags = {
|
|
43
|
-
config: command_1.flags.string({ hidden: true }),
|
|
44
|
-
help: command_1.flags.help({ char: 'h' }),
|
|
45
|
-
'hide-output': command_1.flags.boolean({ hidden: true }),
|
|
46
|
-
inspect: command_1.flags.boolean({ char: 'i', hidden: true }),
|
|
47
|
-
'inspect-after': command_1.flags.boolean({ hidden: true }),
|
|
48
|
-
'output-configuration': command_1.flags.boolean(),
|
|
49
|
-
silent: command_1.flags.boolean(),
|
|
50
|
-
};
|
|
43
|
+
Transpile.flags = Object.assign(Object.assign({}, zen_command_1.default.flags), { config: command_1.flags.string({ hidden: true }), help: command_1.flags.help({ char: 'h' }), 'hide-output': command_1.flags.boolean({ hidden: true }), inspect: command_1.flags.boolean({ char: 'i', hidden: true }), 'inspect-after': command_1.flags.boolean({ hidden: true }), 'output-configuration': command_1.flags.boolean(), silent: command_1.flags.boolean() });
|
|
51
44
|
Transpile.args = [
|
|
52
45
|
{
|
|
53
46
|
name: 'folder',
|
package/lib/commands/upload.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { flags } from '@oclif/command';
|
|
2
|
+
import ZenCommand from '../shared/zen-command';
|
|
3
|
+
export default class Upload extends ZenCommand {
|
|
3
4
|
static description: string;
|
|
4
|
-
static flags:
|
|
5
|
+
static flags: {
|
|
6
|
+
dir: flags.IOptionFlag<string | undefined>;
|
|
7
|
+
file: flags.IOptionFlag<string | undefined>;
|
|
8
|
+
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
9
|
+
silent: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
10
|
+
'non-interactive': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
11
|
+
};
|
|
5
12
|
static args: ({
|
|
6
13
|
name: string;
|
|
7
14
|
required: boolean;
|
package/lib/commands/upload.js
CHANGED
|
@@ -11,20 +11,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
11
11
|
// provided by the user.
|
|
12
12
|
const command_1 = require("@oclif/command");
|
|
13
13
|
const errors_1 = require("@oclif/errors");
|
|
14
|
-
const configuration_1 = require("../shared/configuration");
|
|
15
14
|
const actions_1 = require("../shared/actions");
|
|
16
|
-
|
|
15
|
+
const zen_command_1 = require("../shared/zen-command");
|
|
16
|
+
class Upload extends zen_command_1.default {
|
|
17
17
|
async run() {
|
|
18
18
|
const { args, flags } = this.parse(Upload);
|
|
19
19
|
// Make sure that you definitely specify folder/name
|
|
20
20
|
if (args.destination.includes('/') === false) {
|
|
21
21
|
throw new errors_1.CLIError('You must specify the folder/name you want to use');
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
if (!configuration) {
|
|
25
|
-
// Configuration not found. Most likely because someone is not logged in. Exit with error.
|
|
26
|
-
throw new errors_1.CLIError('You are probably not logged in.');
|
|
27
|
-
}
|
|
23
|
+
await this.ensureStepZenAccount();
|
|
28
24
|
if (!flags.file && !flags.dir) {
|
|
29
25
|
// You need to specify a file or directory. Exit with error.
|
|
30
26
|
throw new errors_1.CLIError('You must specify a file or directory.');
|
|
@@ -48,15 +44,10 @@ exports.default = Upload;
|
|
|
48
44
|
Upload.description = 'upload to stepzen';
|
|
49
45
|
// The uploaded resource is either a directory or a file. In case it is the former,
|
|
50
46
|
// it will be packaged into a zip archive and transferred.
|
|
51
|
-
Upload.flags = {
|
|
52
|
-
dir: command_1.flags.string({
|
|
47
|
+
Upload.flags = Object.assign(Object.assign({}, zen_command_1.default.flags), { dir: command_1.flags.string({
|
|
53
48
|
description: 'A directory to upload',
|
|
54
49
|
exclusive: ['file'],
|
|
55
|
-
}),
|
|
56
|
-
file: command_1.flags.string({ description: 'A file to upload', exclusive: ['dir'] }),
|
|
57
|
-
help: command_1.flags.help({ char: 'h' }),
|
|
58
|
-
silent: command_1.flags.boolean(),
|
|
59
|
-
};
|
|
50
|
+
}), file: command_1.flags.string({ description: 'A file to upload', exclusive: ['dir'] }), help: command_1.flags.help({ char: 'h' }), silent: command_1.flags.boolean() });
|
|
60
51
|
// the type and name of the uploaded resource.
|
|
61
52
|
Upload.args = [
|
|
62
53
|
{
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default class Validate extends
|
|
1
|
+
import ZenCommand from '../shared/zen-command';
|
|
2
|
+
export default class Validate extends ZenCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static hidden: boolean;
|
|
5
|
-
static flags:
|
|
5
|
+
static flags: {
|
|
6
|
+
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
7
|
+
'non-interactive': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
8
|
+
};
|
|
6
9
|
static args: {
|
|
7
10
|
name: string;
|
|
8
11
|
required: boolean;
|
package/lib/commands/validate.js
CHANGED
|
@@ -5,8 +5,9 @@ const chalk = require("chalk");
|
|
|
5
5
|
const command_1 = require("@oclif/command");
|
|
6
6
|
const errors_1 = require("@oclif/errors");
|
|
7
7
|
const utils_1 = require("../shared/utils");
|
|
8
|
+
const zen_command_1 = require("../shared/zen-command");
|
|
8
9
|
const { stitch, validate } = require('@stepzen/transpiler');
|
|
9
|
-
class Validate extends
|
|
10
|
+
class Validate extends zen_command_1.default {
|
|
10
11
|
async run() {
|
|
11
12
|
const { args } = this.parse(Validate);
|
|
12
13
|
const folder = utils_1.getDirectory(args.folder);
|
|
@@ -24,9 +25,7 @@ class Validate extends command_1.Command {
|
|
|
24
25
|
exports.default = Validate;
|
|
25
26
|
Validate.description = 'validate a graphql schema';
|
|
26
27
|
Validate.hidden = true;
|
|
27
|
-
Validate.flags = {
|
|
28
|
-
help: command_1.flags.help({ char: 'h' }),
|
|
29
|
-
};
|
|
28
|
+
Validate.flags = Object.assign(Object.assign({}, zen_command_1.default.flags), { help: command_1.flags.help({ char: 'h' }) });
|
|
30
29
|
Validate.args = [
|
|
31
30
|
{
|
|
32
31
|
name: 'folder',
|
package/lib/commands/whoami.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default class WhoAmI extends
|
|
1
|
+
import ZenCommand from '../shared/zen-command';
|
|
2
|
+
export default class WhoAmI extends ZenCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static hidden: boolean;
|
|
5
|
-
static flags:
|
|
5
|
+
static flags: {
|
|
6
|
+
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
7
|
+
showkeys: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
8
|
+
apikey: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
9
|
+
adminkey: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
10
|
+
'non-interactive': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
11
|
+
};
|
|
6
12
|
static args: never[];
|
|
7
13
|
run(): Promise<void>;
|
|
8
14
|
}
|
package/lib/commands/whoami.js
CHANGED
|
@@ -5,7 +5,8 @@ const chalk = require("chalk");
|
|
|
5
5
|
const command_1 = require("@oclif/command");
|
|
6
6
|
const configuration_1 = require("../shared/configuration");
|
|
7
7
|
const utils_1 = require("../shared/utils");
|
|
8
|
-
|
|
8
|
+
const zen_command_1 = require("../shared/zen-command");
|
|
9
|
+
class WhoAmI extends zen_command_1.default {
|
|
9
10
|
async run() {
|
|
10
11
|
const { flags } = this.parse(WhoAmI);
|
|
11
12
|
const configuration = configuration_1.readConfiguration();
|
|
@@ -52,19 +53,14 @@ class WhoAmI extends command_1.Command {
|
|
|
52
53
|
exports.default = WhoAmI;
|
|
53
54
|
WhoAmI.description = 'stepzen whoami';
|
|
54
55
|
WhoAmI.hidden = true;
|
|
55
|
-
WhoAmI.flags = {
|
|
56
|
-
help: command_1.flags.help({ char: 'h' }),
|
|
57
|
-
showkeys: command_1.flags.boolean({
|
|
56
|
+
WhoAmI.flags = Object.assign(Object.assign({}, zen_command_1.default.flags), { help: command_1.flags.help({ char: 'h' }), showkeys: command_1.flags.boolean({
|
|
58
57
|
default: false,
|
|
59
58
|
exclusive: ['adminkey', 'apikey'],
|
|
60
|
-
}),
|
|
61
|
-
apikey: command_1.flags.boolean({
|
|
59
|
+
}), apikey: command_1.flags.boolean({
|
|
62
60
|
default: false,
|
|
63
61
|
exclusive: ['showkeys', 'adminkey'],
|
|
64
|
-
}),
|
|
65
|
-
adminkey: command_1.flags.boolean({
|
|
62
|
+
}), adminkey: command_1.flags.boolean({
|
|
66
63
|
default: false,
|
|
67
64
|
exclusive: ['showkeys', 'apikey'],
|
|
68
|
-
})
|
|
69
|
-
};
|
|
65
|
+
}) });
|
|
70
66
|
WhoAmI.args = [];
|
|
@@ -2,7 +2,7 @@ import { CurlArguments } from '../shared/curl-parser';
|
|
|
2
2
|
import { PathParam } from '../shared/path-params-parser';
|
|
3
3
|
export declare type Curl2SdlOptions = {
|
|
4
4
|
curlArgs: CurlArguments;
|
|
5
|
-
name
|
|
5
|
+
name?: string;
|
|
6
6
|
source: string;
|
|
7
7
|
queryName?: string;
|
|
8
8
|
rootType?: string;
|
package/lib/generate/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: (schemas: any, name: string, source: string) => Promise<string>;
|
|
1
|
+
declare const _default: (schemas: any, name: string | undefined, source: string) => Promise<string>;
|
|
2
2
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MachineConfiguration } from './types';
|
|
2
|
-
export declare const readConfiguration: () => MachineConfiguration |
|
|
2
|
+
export declare const readConfiguration: () => MachineConfiguration | null;
|
|
3
3
|
export declare const importConfiguration: (filepath: string) => MachineConfiguration;
|
|
4
4
|
export declare const removeConfigurationFromLoginFile: () => boolean;
|
|
5
5
|
export declare const writeConfigurationToLoginFile: (configuration: MachineConfiguration) => MachineConfiguration;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
declare const stepzen: {
|
|
2
|
+
login: (adminkey: string, account?: string) => Promise<{
|
|
3
|
+
account: string;
|
|
4
|
+
adminkey: string;
|
|
5
|
+
}>;
|
|
6
|
+
createAnonymousAccount: () => {
|
|
7
|
+
account: string;
|
|
8
|
+
adminkey: string;
|
|
9
|
+
};
|
|
2
10
|
verify: (account: string, adminkey: string) => Promise<boolean>;
|
|
3
11
|
client: (options: Pick<import("@stepzen/sdk").StepZenAccount, "account" | "adminkey"> & Partial<import("@stepzen/sdk").StepZenAccount>) => Promise<{
|
|
4
12
|
account: () => Promise<{
|
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const errors_1 = require("@oclif/errors");
|
|
4
5
|
const sdk_1 = require("@stepzen/sdk");
|
|
5
6
|
const { version } = require('../../package.json');
|
|
6
|
-
const stepzen = sdk_1.init({ appName: `stepzen-cli/${version}` })
|
|
7
|
+
const stepzen = Object.assign(Object.assign({}, sdk_1.init({ appName: `stepzen-cli/${version}` })), { login: async (adminkey, account = adminkey.split(':')[0]) => {
|
|
8
|
+
// Check whether the account and admin key exist and are correct by calling
|
|
9
|
+
// the stepzen admin api.
|
|
10
|
+
const isValidConfiguration = await stepzen.verify(account, adminkey);
|
|
11
|
+
if (!isValidConfiguration) {
|
|
12
|
+
// Exit, with error
|
|
13
|
+
throw new errors_1.CLIError('We are unable to verify your account details. Could you please check them?');
|
|
14
|
+
}
|
|
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
|
+
} });
|
|
7
28
|
exports.default = stepzen;
|
package/lib/shared/utils.js
CHANGED
|
@@ -52,7 +52,7 @@ exports.clearConsole = () => {
|
|
|
52
52
|
exports.ensureApiKey = async () => {
|
|
53
53
|
const configuration = configuration_1.readConfiguration();
|
|
54
54
|
const details = configuration;
|
|
55
|
-
if (!details.apikey) {
|
|
55
|
+
if (details && !details.apikey) {
|
|
56
56
|
debug('stepzen:account')(`Fetching API key for account ${details.account}`);
|
|
57
57
|
try {
|
|
58
58
|
const client = await stepzen_sdk_1.default.client(details);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Command } from '@oclif/command';
|
|
2
|
+
import { MachineConfiguration } from './types';
|
|
3
|
+
export declare abstract class ZenCommand extends Command {
|
|
4
|
+
static flags: {
|
|
5
|
+
'non-interactive': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
6
|
+
};
|
|
7
|
+
ensureStepZenAccount(): Promise<{
|
|
8
|
+
configuration: MachineConfiguration;
|
|
9
|
+
}>;
|
|
10
|
+
promptUserToLogIn(): Promise<{
|
|
11
|
+
configuration: MachineConfiguration;
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
14
|
+
export default ZenCommand;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ZenCommand = void 0;
|
|
5
|
+
const command_1 = require("@oclif/command");
|
|
6
|
+
const inquirer = require("inquirer");
|
|
7
|
+
const chalk = require("chalk");
|
|
8
|
+
const configuration_1 = require("./configuration");
|
|
9
|
+
const stepzen_sdk_1 = require("./stepzen-sdk");
|
|
10
|
+
class ZenCommand extends command_1.Command {
|
|
11
|
+
async ensureStepZenAccount() {
|
|
12
|
+
const configuration = configuration_1.readConfiguration();
|
|
13
|
+
if (configuration && configuration.account) {
|
|
14
|
+
return {
|
|
15
|
+
configuration,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return this.promptUserToLogIn();
|
|
19
|
+
}
|
|
20
|
+
async promptUserToLogIn() {
|
|
21
|
+
this.log(chalk.bold(chalk.cyan('Welcome to StepZen CLI!')));
|
|
22
|
+
this.log('');
|
|
23
|
+
this.log(`Please log in with your StepZen account to make your GraphQL API private.` +
|
|
24
|
+
` All APIs created without logging in will be public.`);
|
|
25
|
+
this.log('');
|
|
26
|
+
const answers = await inquirer.prompt([
|
|
27
|
+
{
|
|
28
|
+
message: 'How would you like to continue?',
|
|
29
|
+
name: 'loginPath',
|
|
30
|
+
type: 'list',
|
|
31
|
+
choices: [
|
|
32
|
+
'Log in via stepzen.com',
|
|
33
|
+
'Continue without logging in (make your API public)',
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
]);
|
|
37
|
+
let configuration = null;
|
|
38
|
+
if (answers.loginPath === 'Log in via stepzen.com') {
|
|
39
|
+
const answers = await inquirer.prompt([
|
|
40
|
+
{
|
|
41
|
+
message: 'What is your Admin Key?',
|
|
42
|
+
name: 'adminkey',
|
|
43
|
+
type: 'password',
|
|
44
|
+
validate: async (value) => {
|
|
45
|
+
try {
|
|
46
|
+
await stepzen_sdk_1.default.login(value);
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
return `${error}`;
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
suffix: chalk.blue(` (available at ${chalk.bold('https://stepzen.com/account')})`),
|
|
54
|
+
},
|
|
55
|
+
]);
|
|
56
|
+
configuration = await stepzen_sdk_1.default.login(answers.adminkey);
|
|
57
|
+
configuration_1.writeConfigurationToLoginFile(configuration);
|
|
58
|
+
this.log('You have successfully logged in.');
|
|
59
|
+
this.log('');
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
configuration = await stepzen_sdk_1.default.createAnonymousAccount();
|
|
63
|
+
configuration_1.writeConfigurationToLoginFile(configuration);
|
|
64
|
+
this.log(`We've created a temporary public account for you.\nAll endpoints` +
|
|
65
|
+
` deployed to this account will be automatically deleted after 24` +
|
|
66
|
+
` hours. You can log in with your regular StepZen account at any` +
|
|
67
|
+
` time by running ${chalk.bold('stepzen login')}.`);
|
|
68
|
+
this.log('');
|
|
69
|
+
}
|
|
70
|
+
return { configuration };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.ZenCommand = ZenCommand;
|
|
74
|
+
ZenCommand.flags = {
|
|
75
|
+
'non-interactive': command_1.flags.boolean({
|
|
76
|
+
description: 'disable all interactive prompts',
|
|
77
|
+
hidden: true,
|
|
78
|
+
}),
|
|
79
|
+
};
|
|
80
|
+
exports.default = ZenCommand;
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.13.0-beta.
|
|
1
|
+
{"version":"0.13.0-beta.2","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},"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},"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},"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},"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},"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},"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},"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},"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},"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},"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},"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},"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.13.0-beta.
|
|
4
|
+
"version": "0.13.0-beta.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Darren Waddell <darren@stepzen.com>",
|
|
7
7
|
"contributors": [
|
|
@@ -106,7 +106,6 @@
|
|
|
106
106
|
],
|
|
107
107
|
"hooks": {
|
|
108
108
|
"prerun": [
|
|
109
|
-
"./lib/hooks/prerun/check-account",
|
|
110
109
|
"./lib/hooks/prerun/check-upgrade",
|
|
111
110
|
"./lib/hooks/prerun/ensure-api-key",
|
|
112
111
|
"./lib/hooks/prerun/ensure-permissions"
|
|
@@ -1,12 +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 ({ Command: { id } }) {
|
|
6
|
-
const CHECK_COMMANDS = ['deploy', 'start', 'upload'];
|
|
7
|
-
if (CHECK_COMMANDS.includes(id) === false) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
await utils_1.checkAuth();
|
|
11
|
-
};
|
|
12
|
-
exports.default = hook;
|