stepzen 0.12.0 → 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 +21 -20
- package/lib/commands/init.d.ts +13 -4
- package/lib/commands/init.js +72 -35
- 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 +18 -24
- 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/curl-parser.js +65 -27
- package/lib/shared/moniker.d.ts +2 -0
- package/lib/shared/moniker.js +4 -5
- package/lib/shared/stepzen-sdk.d.ts +8 -0
- package/lib/shared/stepzen-sdk.js +22 -1
- package/lib/shared/types.d.ts +11 -2
- package/lib/shared/utils.js +6 -5
- package/lib/shared/workspace.d.ts +2 -1
- package/lib/shared/workspace.js +39 -36
- 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
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
|
|
@@ -27,10 +28,19 @@ class Import extends command_1.Command {
|
|
|
27
28
|
'In order to use the --name flag please import each schema separately.');
|
|
28
29
|
}
|
|
29
30
|
// Get the working directory and workspace
|
|
31
|
+
let workspace;
|
|
30
32
|
const directory = utils_1.getDirectory(flags.dir);
|
|
31
|
-
|
|
32
|
-
if (
|
|
33
|
-
workspace =
|
|
33
|
+
const maybeWorkspace = workspace_1.getWorkspace(directory);
|
|
34
|
+
if (maybeWorkspace) {
|
|
35
|
+
workspace = maybeWorkspace;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
try {
|
|
39
|
+
workspace = await init_1.default.run([directory]);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
throw new errors_1.CLIError(`Could not create a StepZen workspace in the ${flags.dir ? directory : 'current'} directory.\n` + error.message);
|
|
43
|
+
}
|
|
34
44
|
}
|
|
35
45
|
// Select an import execution flow:
|
|
36
46
|
// - v1 with `stepzen/engines` and cloud function
|
|
@@ -91,7 +101,7 @@ class Import extends command_1.Command {
|
|
|
91
101
|
result = resultOrError.outPath;
|
|
92
102
|
}
|
|
93
103
|
else {
|
|
94
|
-
;
|
|
104
|
+
await this.ensureStepZenAccount();
|
|
95
105
|
['prefix', 'query-type', 'query-name', 'path-params'].forEach(flag => {
|
|
96
106
|
if (flag in flags) {
|
|
97
107
|
this.log(chalk.gray(`The ${chalk.bold(`--${flag}`)} flag only applies when importing ${chalk.bold('curl')}. It will be ignored now.`));
|
|
@@ -121,26 +131,18 @@ class Import extends command_1.Command {
|
|
|
121
131
|
}
|
|
122
132
|
exports.default = Import;
|
|
123
133
|
Import.description = 'Import a schema for an external data source or a API endpoint to your GraphQL API.';
|
|
124
|
-
Import.flags = {
|
|
125
|
-
dir: command_1.flags.string({ description: 'working directory' }),
|
|
126
|
-
help: command_1.flags.help({ char: 'h' }),
|
|
127
|
-
silent: command_1.flags.boolean({ hidden: true }),
|
|
128
|
-
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({
|
|
129
135
|
description: 'subfolder inside the workspace folder to save the imported' +
|
|
130
136
|
' schema files, defaults to the imported schema name',
|
|
131
|
-
}),
|
|
132
|
-
prefix: command_1.flags.string({
|
|
137
|
+
}), prefix: command_1.flags.string({
|
|
133
138
|
description: '[curl] prefix to add every type in the generated schema.',
|
|
134
|
-
}),
|
|
135
|
-
'query-name': command_1.flags.string({
|
|
139
|
+
}), 'query-name': command_1.flags.string({
|
|
136
140
|
description: '[curl] property name to add to the Query type as a way to' +
|
|
137
141
|
' access the imported cURL endpoint.',
|
|
138
|
-
}),
|
|
139
|
-
'query-type': command_1.flags.string({
|
|
142
|
+
}), 'query-type': command_1.flags.string({
|
|
140
143
|
description: '[curl] name for the type returned by the cURL endpoint in the ' +
|
|
141
144
|
`generated schema. The name specified by ${chalk.bold('--query-type')} is not prefixed by ${chalk.bold('--prefix')} if both flags are present.`,
|
|
142
|
-
}),
|
|
143
|
-
'path-params': command_1.flags.string({
|
|
145
|
+
}), 'path-params': command_1.flags.string({
|
|
144
146
|
description: `[curl] specifies path parameters in the URL path.` +
|
|
145
147
|
` Can be formed by taking the original path and replacing the` +
|
|
146
148
|
` variable segments with ${chalk.bold('$paramName')} placeholders.` +
|
|
@@ -149,8 +151,7 @@ Import.flags = {
|
|
|
149
151
|
`\nstepzen import curl https://example.com/users/jane/posts/12` +
|
|
150
152
|
` --path-params` +
|
|
151
153
|
` '/users/${chalk.bold('$userId')}/posts/${chalk.bold('$postId')}'`,
|
|
152
|
-
})
|
|
153
|
-
};
|
|
154
|
+
}) });
|
|
154
155
|
Import.args = [
|
|
155
156
|
{
|
|
156
157
|
name: 'schemas',
|
package/lib/commands/init.d.ts
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { flags } from '@oclif/command';
|
|
2
|
+
import ZenCommand from '../shared/zen-command';
|
|
3
|
+
export declare const validateWorkspaceName: (directory: string, name: string) => boolean;
|
|
4
|
+
export declare const generateWorkspaceName: (directory: string) => string;
|
|
5
|
+
export declare const guessSchemaRoot: (directory: string) => string;
|
|
6
|
+
export default class Init extends ZenCommand {
|
|
3
7
|
static description: string;
|
|
4
8
|
static hidden: boolean;
|
|
5
|
-
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
|
+
};
|
|
6
15
|
static args: {
|
|
7
16
|
hidden: boolean;
|
|
8
17
|
name: string;
|
|
9
18
|
}[];
|
|
10
|
-
run(): Promise<
|
|
19
|
+
run(): Promise<import("../shared/types").Workspace>;
|
|
11
20
|
}
|
package/lib/commands/init.js
CHANGED
|
@@ -1,53 +1,86 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.guessSchemaRoot = exports.generateWorkspaceName = exports.validateWorkspaceName = void 0;
|
|
4
5
|
const command_1 = require("@oclif/command");
|
|
5
6
|
const errors_1 = require("@oclif/errors");
|
|
6
7
|
const fs = require("fs");
|
|
7
8
|
const glob = require("glob");
|
|
8
9
|
const inquirer = require("inquirer");
|
|
10
|
+
const os = require("os");
|
|
9
11
|
const path = require("path");
|
|
10
12
|
const utils_1 = require("../shared/utils");
|
|
11
13
|
const moniker_1 = require("../shared/moniker");
|
|
12
14
|
const workspace_1 = require("../shared/workspace");
|
|
13
|
-
|
|
15
|
+
const zen_command_1 = require("../shared/zen-command");
|
|
16
|
+
exports.validateWorkspaceName = (directory, name) => {
|
|
17
|
+
return !fs.existsSync(path.join(directory, name));
|
|
18
|
+
};
|
|
19
|
+
exports.generateWorkspaceName = (directory) => {
|
|
20
|
+
let name = 'hello-stepzen';
|
|
21
|
+
while (!exports.validateWorkspaceName(directory, name)) {
|
|
22
|
+
name = `hello-${moniker_1.getRandomDescriptor()}-stepzen`;
|
|
23
|
+
}
|
|
24
|
+
return name;
|
|
25
|
+
};
|
|
26
|
+
exports.guessSchemaRoot = (directory) => {
|
|
27
|
+
const existing = [
|
|
28
|
+
...glob.sync('*/**/config.yaml', {
|
|
29
|
+
cwd: directory,
|
|
30
|
+
ignore: '**/node_modules/**',
|
|
31
|
+
}),
|
|
32
|
+
...glob.sync('*/**/index.graphql', {
|
|
33
|
+
cwd: directory,
|
|
34
|
+
ignore: '**/node_modules/**',
|
|
35
|
+
}),
|
|
36
|
+
];
|
|
37
|
+
return existing.length > 0 ? path.dirname(existing[0]) : '';
|
|
38
|
+
};
|
|
39
|
+
class Init extends zen_command_1.default {
|
|
14
40
|
async run() {
|
|
15
41
|
const { args, flags } = this.parse(Init);
|
|
16
42
|
// Get the correct directory
|
|
17
|
-
|
|
43
|
+
let directory = utils_1.getDirectory(args.directory);
|
|
18
44
|
// Make sure it is not already a workspace
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
45
|
+
if (workspace_1.getWorkspace(directory)) {
|
|
46
|
+
throw new errors_1.CLIError(`This directory is already a StepZen workspace: ${directory}.` +
|
|
47
|
+
' Please select a different directory.');
|
|
48
|
+
}
|
|
49
|
+
const isHomeDir = directory === os.homedir();
|
|
50
|
+
// Prevent init from running in the home directory if the directory was
|
|
51
|
+
// explicitly provided as an aargument to `stepzen init`.
|
|
52
|
+
// StepZen CLI sometimes would enumerate all files in the workspace folder
|
|
53
|
+
// doing so in the home directory is likely to fail.
|
|
54
|
+
if (args.directory && isHomeDir) {
|
|
55
|
+
throw new errors_1.CLIError('Using the home directory as a StepZen workspace is not supported.' +
|
|
56
|
+
' Please select a different directory.');
|
|
57
|
+
}
|
|
58
|
+
// Make a suggestion for the workspace name (if running in the HOME
|
|
59
|
+
// directory)
|
|
60
|
+
const name = isHomeDir
|
|
61
|
+
? exports.generateWorkspaceName(directory)
|
|
62
|
+
: path.basename(directory);
|
|
63
|
+
// See if we think there's a StepZen schema already
|
|
64
|
+
const root = isHomeDir ? '' : exports.guessSchemaRoot(directory);
|
|
65
|
+
// If you've passed an endpoint, validate it, and throw an error
|
|
66
|
+
// straight away if needed
|
|
23
67
|
if (flags.endpoint) {
|
|
24
68
|
const error = utils_1.validateEndpoint(flags.endpoint);
|
|
25
|
-
if (typeof error === 'string')
|
|
69
|
+
if (typeof error === 'string') {
|
|
26
70
|
throw new errors_1.CLIError(error);
|
|
71
|
+
}
|
|
27
72
|
}
|
|
28
73
|
// Make a suggestion for the endpoint
|
|
29
74
|
const endpoint = flags.endpoint || `api/${moniker_1.default()}`;
|
|
30
|
-
// See if we think there's a StepZen schema already
|
|
31
|
-
let root;
|
|
32
|
-
const existing = [
|
|
33
|
-
...glob.sync('*/**/config.yaml', {
|
|
34
|
-
cwd: directory,
|
|
35
|
-
ignore: '**/node_modules/**',
|
|
36
|
-
}),
|
|
37
|
-
...glob.sync('*/**/index.graphql', {
|
|
38
|
-
cwd: directory,
|
|
39
|
-
ignore: '**/node_modules/**',
|
|
40
|
-
}),
|
|
41
|
-
];
|
|
42
|
-
if (existing.length > 0) {
|
|
43
|
-
root = existing[0]
|
|
44
|
-
.replace('config.yaml', '')
|
|
45
|
-
.replace('index.graphql', '')
|
|
46
|
-
.replace(/\/*$/, '');
|
|
47
|
-
}
|
|
48
|
-
const hasRoot = existing.length > 0;
|
|
49
75
|
// What questions will we ask?
|
|
50
76
|
const questions = [
|
|
77
|
+
{
|
|
78
|
+
default: name,
|
|
79
|
+
message: 'What would you like to call your workspace?',
|
|
80
|
+
name: 'name',
|
|
81
|
+
validate: (name) => exports.validateWorkspaceName(directory, name),
|
|
82
|
+
when: isHomeDir && !flags.yes,
|
|
83
|
+
},
|
|
51
84
|
{
|
|
52
85
|
default: endpoint,
|
|
53
86
|
message: 'What would you like your endpoint to be called?',
|
|
@@ -59,14 +92,22 @@ class Init extends command_1.Command {
|
|
|
59
92
|
message: `We have detected a schema in this directory. Set the schema root to "${root}"?`,
|
|
60
93
|
name: 'use-root',
|
|
61
94
|
type: 'confirm',
|
|
62
|
-
when:
|
|
95
|
+
when: Boolean(root) && !flags.yes,
|
|
63
96
|
},
|
|
64
97
|
];
|
|
65
98
|
// Get the answers
|
|
66
|
-
const answers = Object.assign({
|
|
99
|
+
const answers = Object.assign({ name,
|
|
100
|
+
endpoint, 'use-root': true }, (await inquirer.prompt(questions)));
|
|
101
|
+
// Append the suggested workspace name to the directory (if running
|
|
102
|
+
// in the HOME directory)
|
|
103
|
+
if (isHomeDir) {
|
|
104
|
+
// eslint-disable-next-line require-atomic-updates
|
|
105
|
+
directory = path.join(directory, answers.name);
|
|
106
|
+
fs.mkdirSync(directory);
|
|
107
|
+
}
|
|
67
108
|
// Create the workspace
|
|
68
109
|
const workspace = { endpoint: answers.endpoint };
|
|
69
|
-
if (
|
|
110
|
+
if (root && answers['use-root'])
|
|
70
111
|
workspace.root = root;
|
|
71
112
|
// Write the file
|
|
72
113
|
const file = path.join(directory, 'stepzen.config.json');
|
|
@@ -74,18 +115,14 @@ class Init extends command_1.Command {
|
|
|
74
115
|
// Fetch the newly created workspace
|
|
75
116
|
const created = workspace_1.getWorkspace(directory);
|
|
76
117
|
// Done!
|
|
77
|
-
this.log(`Created ${
|
|
118
|
+
this.log(`Created a StepZen workspace in ${created.directory}`);
|
|
78
119
|
return created;
|
|
79
120
|
}
|
|
80
121
|
}
|
|
81
122
|
exports.default = Init;
|
|
82
123
|
Init.description = 'stepzen init';
|
|
83
124
|
Init.hidden = true;
|
|
84
|
-
Init.flags = {
|
|
85
|
-
endpoint: command_1.flags.string({ hidden: true }),
|
|
86
|
-
help: command_1.flags.help({ char: 'h' }),
|
|
87
|
-
yes: command_1.flags.boolean({ default: false, hidden: true }),
|
|
88
|
-
};
|
|
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 }) });
|
|
89
126
|
Init.args = [
|
|
90
127
|
{
|
|
91
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,32 +7,37 @@ 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
|
|
24
|
+
let workspace;
|
|
28
25
|
const directory = utils_1.getDirectory(flags.dir);
|
|
29
|
-
|
|
30
|
-
if (
|
|
26
|
+
const maybeWorkspace = workspace_1.getWorkspace(directory);
|
|
27
|
+
if (maybeWorkspace) {
|
|
28
|
+
workspace = maybeWorkspace;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
31
|
const initArgs = [directory];
|
|
32
|
-
if (flags.endpoint)
|
|
32
|
+
if (flags.endpoint) {
|
|
33
33
|
initArgs.push('--endpoint', flags.endpoint);
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
workspace = await init_1.default.run(initArgs);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
throw new errors_1.CLIError(`Could not create a StepZen workspace in the ${flags.dir ? directory : 'current'} directory.\n` + error.message);
|
|
40
|
+
}
|
|
36
41
|
}
|
|
37
42
|
// If you have overridden the endpoint, set it
|
|
38
43
|
if (flags.endpoint) {
|
|
@@ -94,16 +99,5 @@ class Start extends command_1.Command {
|
|
|
94
99
|
}
|
|
95
100
|
exports.default = Start;
|
|
96
101
|
Start.description = 'upload and deploy your schema';
|
|
97
|
-
Start.flags = {
|
|
98
|
-
dir: command_1.flags.string({ description: 'working directory' }),
|
|
99
|
-
endpoint: command_1.flags.string({ description: 'Override workspace endpoint' }),
|
|
100
|
-
help: command_1.flags.help({ char: 'h' }),
|
|
101
|
-
'no-console': command_1.flags.boolean({ hidden: true }),
|
|
102
|
-
'no-dashboard': command_1.flags.boolean({ hidden: true }),
|
|
103
|
-
'no-init': command_1.flags.boolean({ hidden: true }),
|
|
104
|
-
'no-server': command_1.flags.boolean({ hidden: true }),
|
|
105
|
-
'no-validate': command_1.flags.boolean({ hidden: true }),
|
|
106
|
-
'no-watcher': command_1.flags.boolean({ hidden: true }),
|
|
107
|
-
port: command_1.flags.integer({ default: 5001, env: 'PORT' }),
|
|
108
|
-
};
|
|
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' }) });
|
|
109
103
|
Start.args = [];
|