stepzen 0.16.0-beta.0 → 0.16.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/lib/commands/import.d.ts +45 -1
- package/lib/commands/import.js +66 -45
- package/lib/commands/lint.js +1 -1
- package/lib/commands/login.js +1 -1
- package/lib/commands/logout.js +1 -1
- package/lib/commands/start.js +0 -2
- package/lib/commands/upload.js +1 -1
- package/lib/commands/whoami.js +1 -1
- package/lib/generate/helpers.d.ts +1 -1
- package/lib/generate/helpers.js +13 -17
- package/lib/generate/index.d.ts +2 -4
- package/lib/generate/index.js +65 -128
- package/lib/shared/constants.d.ts +0 -2
- package/lib/shared/constants.js +2 -7
- package/oclif.manifest.json +1 -1
- package/package.json +4 -4
- package/lib/generate/dashboard-interface.d.ts +0 -7
- package/lib/generate/dashboard-interface.js +0 -42
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.16.0-beta.
|
|
32
|
+
stepzen/0.16.0-beta.3 darwin-x64 node-v14.19.1
|
|
33
33
|
$ stepzen --help [COMMAND]
|
|
34
34
|
USAGE
|
|
35
35
|
$ stepzen COMMAND
|
|
@@ -40,7 +40,7 @@ USAGE
|
|
|
40
40
|
<!-- commands -->
|
|
41
41
|
* [`stepzen deploy DESTINATION`](#stepzen-deploy-destination)
|
|
42
42
|
* [`stepzen help [COMMAND]`](#stepzen-help-command)
|
|
43
|
-
* [`stepzen import
|
|
43
|
+
* [`stepzen import SCHEMA`](#stepzen-import-schema)
|
|
44
44
|
* [`stepzen list TYPE`](#stepzen-list-type)
|
|
45
45
|
* [`stepzen login`](#stepzen-login)
|
|
46
46
|
* [`stepzen logout`](#stepzen-logout)
|
|
@@ -82,13 +82,13 @@ OPTIONS
|
|
|
82
82
|
|
|
83
83
|
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.1.12/src/commands/help.ts)_
|
|
84
84
|
|
|
85
|
-
## `stepzen import
|
|
85
|
+
## `stepzen import SCHEMA`
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
import a schema for an external data source or a API endpoint to your GraphQL API
|
|
88
88
|
|
|
89
89
|
```
|
|
90
90
|
USAGE
|
|
91
|
-
$ stepzen import
|
|
91
|
+
$ stepzen import SCHEMA
|
|
92
92
|
|
|
93
93
|
OPTIONS
|
|
94
94
|
-h, --help
|
|
@@ -160,7 +160,7 @@ OPTIONS
|
|
|
160
160
|
|
|
161
161
|
## `stepzen login`
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
log in to StepZen
|
|
164
164
|
|
|
165
165
|
```
|
|
166
166
|
USAGE
|
|
@@ -175,7 +175,7 @@ OPTIONS
|
|
|
175
175
|
|
|
176
176
|
## `stepzen logout`
|
|
177
177
|
|
|
178
|
-
log out of
|
|
178
|
+
log out of StepZen
|
|
179
179
|
|
|
180
180
|
```
|
|
181
181
|
USAGE
|
|
@@ -202,7 +202,7 @@ OPTIONS
|
|
|
202
202
|
|
|
203
203
|
## `stepzen upload TYPE DESTINATION`
|
|
204
204
|
|
|
205
|
-
upload to
|
|
205
|
+
upload to StepZen
|
|
206
206
|
|
|
207
207
|
```
|
|
208
208
|
USAGE
|
package/lib/commands/import.d.ts
CHANGED
|
@@ -18,6 +18,29 @@ export default class Import extends ZenCommand {
|
|
|
18
18
|
static postgresqlFlags: {
|
|
19
19
|
'db-schema': flags.IOptionFlag<string | undefined>;
|
|
20
20
|
};
|
|
21
|
+
static flagsForSchemas: ({
|
|
22
|
+
flags: {
|
|
23
|
+
prefix: flags.IOptionFlag<string | undefined>;
|
|
24
|
+
'query-name': flags.IOptionFlag<string | undefined>;
|
|
25
|
+
'query-type': flags.IOptionFlag<string | undefined>;
|
|
26
|
+
'path-params': flags.IOptionFlag<string | undefined>;
|
|
27
|
+
'header-param': flags.IOptionFlag<string[]>;
|
|
28
|
+
};
|
|
29
|
+
schemas: string[];
|
|
30
|
+
} | {
|
|
31
|
+
flags: {
|
|
32
|
+
'db-host': flags.IOptionFlag<string | undefined>;
|
|
33
|
+
'db-user': flags.IOptionFlag<string | undefined>;
|
|
34
|
+
'db-password': flags.IOptionFlag<string | undefined>;
|
|
35
|
+
'db-database': flags.IOptionFlag<string | undefined>;
|
|
36
|
+
};
|
|
37
|
+
schemas: string[];
|
|
38
|
+
} | {
|
|
39
|
+
flags: {
|
|
40
|
+
'db-schema': flags.IOptionFlag<string | undefined>;
|
|
41
|
+
};
|
|
42
|
+
schemas: string[];
|
|
43
|
+
})[];
|
|
21
44
|
static flags: {
|
|
22
45
|
'db-schema': flags.IOptionFlag<string | undefined>;
|
|
23
46
|
'db-host': flags.IOptionFlag<string | undefined>;
|
|
@@ -41,5 +64,26 @@ export default class Import extends ZenCommand {
|
|
|
41
64
|
}[];
|
|
42
65
|
static strict: boolean;
|
|
43
66
|
run(): Promise<void>;
|
|
44
|
-
warnAboutIgnoredFlags: (
|
|
67
|
+
warnAboutIgnoredFlags: (schema: string, usedFlags: {
|
|
68
|
+
[key: string]: any;
|
|
69
|
+
}) => void;
|
|
70
|
+
parseWorkaround(): import("@oclif/parser").Output<{
|
|
71
|
+
'db-schema': string | undefined;
|
|
72
|
+
'db-host': string | undefined;
|
|
73
|
+
'db-user': string | undefined;
|
|
74
|
+
'db-password': string | undefined;
|
|
75
|
+
'db-database': string | undefined;
|
|
76
|
+
prefix: string | undefined;
|
|
77
|
+
'query-name': string | undefined;
|
|
78
|
+
'query-type': string | undefined;
|
|
79
|
+
'path-params': string | undefined;
|
|
80
|
+
'header-param': string[];
|
|
81
|
+
dir: string | undefined;
|
|
82
|
+
help: void;
|
|
83
|
+
silent: boolean;
|
|
84
|
+
name: string | undefined;
|
|
85
|
+
'non-interactive': boolean;
|
|
86
|
+
}, {
|
|
87
|
+
[name: string]: any;
|
|
88
|
+
}>;
|
|
45
89
|
}
|
package/lib/commands/import.js
CHANGED
|
@@ -22,27 +22,24 @@ class Import extends zen_command_1.default {
|
|
|
22
22
|
constructor() {
|
|
23
23
|
super(...arguments);
|
|
24
24
|
// notify the user about any ignored flags
|
|
25
|
-
this.warnAboutIgnoredFlags = (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
this.warnAboutIgnoredFlags = (schema, usedFlags) => {
|
|
26
|
+
Import.flagsForSchemas.forEach(({ flags, schemas }) => {
|
|
27
|
+
if (!schemas.includes(schema)) {
|
|
28
|
+
Object.keys(flags).forEach(flag => {
|
|
29
|
+
if (Object.prototype.hasOwnProperty.call(usedFlags, flag)) {
|
|
30
|
+
this.log(chalk.gray(`The ${chalk.bold(`--${flag}`)} flag only applies when importing ${schemas
|
|
31
|
+
.map(schema => chalk.bold(schema))
|
|
32
|
+
.join(', ')}. It will be ignored now.`));
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
36
37
|
};
|
|
37
38
|
}
|
|
38
39
|
async run() {
|
|
39
|
-
const { args, argv, flags } = this.
|
|
40
|
+
const { args, argv, flags } = this.parseWorkaround();
|
|
40
41
|
// Get a list of schemas you're asking for
|
|
41
|
-
const
|
|
42
|
-
if (schemas.length > 1 && flags.name) {
|
|
43
|
-
this.log('When importing several schemas the --name flag is ignored. ' +
|
|
44
|
-
'In order to use the --name flag please import each schema separately.');
|
|
45
|
-
}
|
|
42
|
+
const schema = helpers_1.getSchema(args.schema);
|
|
46
43
|
// Get the working directory and workspace
|
|
47
44
|
let workspace;
|
|
48
45
|
const directory = utils_1.getDirectory(flags.dir);
|
|
@@ -58,24 +55,14 @@ class Import extends zen_command_1.default {
|
|
|
58
55
|
throw new errors_1.CLIError(`Could not create a StepZen workspace in the ${flags.dir ? directory : 'current'} directory.\n` + error.message);
|
|
59
56
|
}
|
|
60
57
|
}
|
|
61
|
-
this.warnAboutIgnoredFlags(
|
|
62
|
-
this.warnAboutIgnoredFlags(schemas, Object.keys(Import.sqlFlags), [
|
|
63
|
-
'mysql',
|
|
64
|
-
'postgresql',
|
|
65
|
-
]);
|
|
66
|
-
this.warnAboutIgnoredFlags(schemas, Object.keys(Import.postgresqlFlags), [
|
|
67
|
-
'postgresql',
|
|
68
|
-
]);
|
|
58
|
+
this.warnAboutIgnoredFlags(schema, flags);
|
|
69
59
|
// Select an import execution flow:
|
|
70
60
|
// - v1 with `stepzen/engines` and cloud function
|
|
71
61
|
// - v2 with the graphqlize service
|
|
72
62
|
let result;
|
|
73
|
-
if (
|
|
63
|
+
if (schema === 'curl') {
|
|
74
64
|
// LATER: offload the check to the graphqlize service or fetch
|
|
75
65
|
// the list of supported data sources and compare agains it.
|
|
76
|
-
if (schemas.length > 1) {
|
|
77
|
-
throw new errors_1.CLIError('Please run cURL import separately from importing other schemas');
|
|
78
|
-
}
|
|
79
66
|
this.log(chalk.yellow(`NOTE: ${chalk.bold('stepzen import curl')} is a ${chalk.bold('new')} feature.`));
|
|
80
67
|
this.log(chalk.yellow('If you have any issues, please check if they have been addressed ' +
|
|
81
68
|
'in the latest version, or reach out to StepZen on Discord: ' +
|
|
@@ -139,19 +126,13 @@ class Import extends zen_command_1.default {
|
|
|
139
126
|
// If/when the number of property-to-answer mappings increase, create a dictionary
|
|
140
127
|
// { schema: { flag: field } } and build the below map based on this (a
|
|
141
128
|
// dictionary also enables a generic solution to the warning about ignored flags).
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
? {}
|
|
148
|
-
: { schema: flags['db-schema'] }));
|
|
149
|
-
const preAnswered = {
|
|
150
|
-
mysql: preAnsweredForDBs,
|
|
151
|
-
postgresql: preAnsweredForDBs,
|
|
152
|
-
};
|
|
129
|
+
let preAnswered = {};
|
|
130
|
+
if (schema === 'mysql' || schema === 'postgresql') {
|
|
131
|
+
const asKeyValue = (key, flag) => flag === undefined ? {} : { [key]: flag };
|
|
132
|
+
preAnswered = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, asKeyValue('host', flags['db-host'])), asKeyValue('user', flags['db-user'])), asKeyValue('password', flags['db-password'])), asKeyValue('database', flags['db-database'])), asKeyValue('schema', flags['db-schema']));
|
|
133
|
+
}
|
|
153
134
|
// Let's go!
|
|
154
|
-
result = await generate_1.default(
|
|
135
|
+
result = await generate_1.default(schema, flags.name, workspace.schema, preAnswered);
|
|
155
136
|
// Validate
|
|
156
137
|
await transpiler_1.validate(result, {
|
|
157
138
|
extensions: await utils_1.getStepZenExtensions(),
|
|
@@ -161,12 +142,47 @@ class Import extends zen_command_1.default {
|
|
|
161
142
|
fs.copySync(result, workspace.schema);
|
|
162
143
|
fs.removeSync(result);
|
|
163
144
|
// Nice message
|
|
164
|
-
this;
|
|
165
|
-
|
|
145
|
+
this.log(chalk.green(`Successfully imported schema ${chalk.bold(schema)} from StepZen`));
|
|
146
|
+
}
|
|
147
|
+
// Correct the value for the 'header-param' flag to work around the oclif's
|
|
148
|
+
// parser issue with multi-value flags: https://github.com/oclif/oclif/issues/261
|
|
149
|
+
parseWorkaround() {
|
|
150
|
+
const argv = this.argv;
|
|
151
|
+
const parsed = this.parse(Import, argv);
|
|
152
|
+
if (!parsed.flags['header-param']) {
|
|
153
|
+
return parsed;
|
|
154
|
+
}
|
|
155
|
+
// Every ['--header-param', value] pair in the argv array should match
|
|
156
|
+
// only one value in the 'header-param' flag's value list.
|
|
157
|
+
const matchedIndices = new Set();
|
|
158
|
+
// For each value in the 'header-param' flag's value list, find the original
|
|
159
|
+
// ['--header-param', value] pair in the argv array.
|
|
160
|
+
for (let i = 0; i < parsed.flags['header-param'].length; i++) {
|
|
161
|
+
const value = parsed.flags['header-param'][i];
|
|
162
|
+
const flagIdx = argv.findIndex((arg, idx) => {
|
|
163
|
+
const spaceDelimMatch = arg === '--header-param' &&
|
|
164
|
+
idx < argv.length &&
|
|
165
|
+
argv[idx + 1] === value;
|
|
166
|
+
const eqlDelimMatch = arg === `--header-param=${value}`;
|
|
167
|
+
return (spaceDelimMatch || eqlDelimMatch) && !matchedIndices.has(idx);
|
|
168
|
+
});
|
|
169
|
+
// If not found, that means the given value was associated with the
|
|
170
|
+
// `--header-param` flag incorrectly. In that case, it's moved from
|
|
171
|
+
// `flags` to `argv` in the parsed output.
|
|
172
|
+
if (flagIdx === -1) {
|
|
173
|
+
parsed.flags['header-param'].splice(i, 1);
|
|
174
|
+
i -= 1; // compensate for the .splice() call above
|
|
175
|
+
parsed.argv.push(value);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
matchedIndices.add(flagIdx);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return parsed;
|
|
166
182
|
}
|
|
167
183
|
}
|
|
168
184
|
exports.default = Import;
|
|
169
|
-
Import.description = '
|
|
185
|
+
Import.description = 'import a schema for an external data source or a API endpoint to your GraphQL API';
|
|
170
186
|
Import.curlFlags = {
|
|
171
187
|
prefix: command_1.flags.string({
|
|
172
188
|
description: '[curl] prefix to add every type in the generated schema.',
|
|
@@ -220,13 +236,18 @@ Import.postgresqlFlags = {
|
|
|
220
236
|
description: '[postgresql] database schema',
|
|
221
237
|
}),
|
|
222
238
|
};
|
|
239
|
+
Import.flagsForSchemas = [
|
|
240
|
+
{ flags: Import.curlFlags, schemas: ['curl'] },
|
|
241
|
+
{ flags: Import.sqlFlags, schemas: ['mysql', 'postgresql'] },
|
|
242
|
+
{ flags: Import.postgresqlFlags, schemas: ['postgresql'] },
|
|
243
|
+
];
|
|
223
244
|
Import.flags = Object.assign(Object.assign(Object.assign(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({
|
|
224
245
|
description: 'subfolder inside the workspace folder to save the imported' +
|
|
225
246
|
' schema files, defaults to the imported schema name',
|
|
226
247
|
}) }), Import.curlFlags), Import.sqlFlags), Import.postgresqlFlags);
|
|
227
248
|
Import.args = [
|
|
228
249
|
{
|
|
229
|
-
name: '
|
|
250
|
+
name: 'schema',
|
|
230
251
|
required: true,
|
|
231
252
|
},
|
|
232
253
|
];
|
package/lib/commands/lint.js
CHANGED
|
@@ -22,6 +22,6 @@ class Init extends zen_command_1.default {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
exports.default = Init;
|
|
25
|
-
Init.description = '
|
|
25
|
+
Init.description = 'StepZen lint';
|
|
26
26
|
Init.hidden = true;
|
|
27
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/login.js
CHANGED
|
@@ -54,7 +54,7 @@ class Login extends zen_command_1.default {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
exports.default = Login;
|
|
57
|
-
Login.description = '
|
|
57
|
+
Login.description = 'log in to StepZen';
|
|
58
58
|
Login.flags = Object.assign(Object.assign({}, zen_command_1.default.flags), { account: command_1.flags.string({
|
|
59
59
|
char: 'a',
|
|
60
60
|
exclusive: ['config', 'public'],
|
package/lib/commands/logout.js
CHANGED
|
@@ -14,5 +14,5 @@ class Logout extends zen_command_1.default {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
exports.default = Logout;
|
|
17
|
-
Logout.description = 'log out of
|
|
17
|
+
Logout.description = 'log out of StepZen';
|
|
18
18
|
Logout.flags = Object.assign(Object.assign({}, zen_command_1.default.flags), { help: command_1.flags.help({ char: 'h' }) });
|
package/lib/commands/start.js
CHANGED
|
@@ -11,7 +11,6 @@ const utils_1 = require("../shared/utils");
|
|
|
11
11
|
const start_1 = require("../start");
|
|
12
12
|
const workspace_1 = require("../shared/workspace");
|
|
13
13
|
const init_1 = require("./init");
|
|
14
|
-
const dashboard_interface_1 = require("../generate/dashboard-interface");
|
|
15
14
|
const constants_1 = require("../shared/constants");
|
|
16
15
|
const zen_command_1 = require("../shared/zen-command");
|
|
17
16
|
const dashboard = require('@stepzen/dashboard');
|
|
@@ -81,7 +80,6 @@ class Start extends zen_command_1.default {
|
|
|
81
80
|
version,
|
|
82
81
|
},
|
|
83
82
|
domain: constants_1.STEPZEN_DOMAIN,
|
|
84
|
-
generators: dashboard_interface_1.createDashboardInterface(workspace),
|
|
85
83
|
predicates: {
|
|
86
84
|
available: true,
|
|
87
85
|
enabled: false,
|
package/lib/commands/upload.js
CHANGED
|
@@ -50,7 +50,7 @@ class Upload extends zen_command_1.default {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
exports.default = Upload;
|
|
53
|
-
Upload.description = 'upload to
|
|
53
|
+
Upload.description = 'upload to StepZen';
|
|
54
54
|
// The uploaded resource is either a directory or a file. In case it is the former,
|
|
55
55
|
// it will be packaged into a zip archive and transferred.
|
|
56
56
|
Upload.flags = Object.assign(Object.assign({}, zen_command_1.default.flags), { dir: command_1.flags.string({
|
package/lib/commands/whoami.js
CHANGED
|
@@ -51,7 +51,7 @@ class WhoAmI extends zen_command_1.default {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
exports.default = WhoAmI;
|
|
54
|
-
WhoAmI.description = '
|
|
54
|
+
WhoAmI.description = 'display your credentials with StepZen whoami';
|
|
55
55
|
WhoAmI.hidden = true;
|
|
56
56
|
WhoAmI.flags = Object.assign(Object.assign({}, zen_command_1.default.flags), { help: command_1.flags.help({ char: 'h' }), showkeys: command_1.flags.boolean({
|
|
57
57
|
default: false,
|
|
@@ -7,7 +7,7 @@ export declare type GeneratorConfiguration = {
|
|
|
7
7
|
status: number;
|
|
8
8
|
};
|
|
9
9
|
export declare const getConfiguration: (id: string, details?: any) => Promise<GeneratorConfiguration | null>;
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const getSchema: (arg: string) => string;
|
|
11
11
|
export declare const getTemplates: () => Promise<string>;
|
|
12
12
|
export declare const askGeneratorQuestions: (id: string, settings: any, state: any) => Promise<any>;
|
|
13
13
|
export declare const askTemplateQuestions: (id: string, settings: any, state: any) => Promise<any>;
|
package/lib/generate/helpers.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.askTemplateQuestions = exports.askGeneratorQuestions = exports.getTemplates = exports.
|
|
4
|
+
exports.askTemplateQuestions = exports.askGeneratorQuestions = exports.getTemplates = exports.getSchema = exports.getConfiguration = exports.createGeneratorFiles = void 0;
|
|
5
5
|
const errors_1 = require("@oclif/errors");
|
|
6
6
|
const chalk = require("chalk");
|
|
7
7
|
const debug = require("debug");
|
|
@@ -88,23 +88,19 @@ exports.getConfiguration = async (id, details = {}) => {
|
|
|
88
88
|
throw new errors_1.CLIError(errors_2.PERMANENT_STEPZEN_ERROR);
|
|
89
89
|
}
|
|
90
90
|
};
|
|
91
|
-
exports.
|
|
92
|
-
const
|
|
93
|
-
//
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
throw new errors_1.CLIError(`You are trying to import "${schema}" more than once`);
|
|
98
|
-
}
|
|
91
|
+
exports.getSchema = (arg) => {
|
|
92
|
+
const schema = arg.trim();
|
|
93
|
+
// Now supports importing only one schema at a time:
|
|
94
|
+
// https://github.com/steprz/stepzen-cli/issues/628
|
|
95
|
+
if (schema.includes(',')) {
|
|
96
|
+
throw new errors_1.CLIError("Importing multiple schemas is no longer supported; please specify only one (e.g. 'stepzen import mysql')");
|
|
99
97
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return schema;
|
|
107
|
-
});
|
|
98
|
+
// support `postgres` as an alias to `postgresql`
|
|
99
|
+
// https://github.com/steprz/stepzen-cli/issues/431
|
|
100
|
+
if (schema.toLowerCase() === 'postgres') {
|
|
101
|
+
return 'postgresql';
|
|
102
|
+
}
|
|
103
|
+
return schema;
|
|
108
104
|
};
|
|
109
105
|
exports.getTemplates = async () => {
|
|
110
106
|
const tmp = path.join(os.tmpdir(), `stepzen-api-templates-${Date.now()}`);
|
package/lib/generate/index.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
declare const _default: (
|
|
2
|
-
[
|
|
3
|
-
[question: string]: string;
|
|
4
|
-
};
|
|
1
|
+
declare const _default: (schema: string, name: string | undefined, source: string, preAnswered?: {
|
|
2
|
+
[question: string]: string;
|
|
5
3
|
}) => Promise<string>;
|
|
6
4
|
export default _default;
|
package/lib/generate/index.js
CHANGED
|
@@ -1,159 +1,96 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const errors_1 = require("@oclif/errors");
|
|
6
5
|
const core_1 = require("@oclif/core");
|
|
7
6
|
const fs = require("fs-extra");
|
|
8
7
|
const lodash = require("lodash");
|
|
9
|
-
const os = require("os");
|
|
10
8
|
const path = require("path");
|
|
11
9
|
const transpiler_1 = require("@stepzen/transpiler");
|
|
12
10
|
const helpers_1 = require("./helpers");
|
|
13
|
-
exports.default = async (
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
// Initial answers from flags. Assumption: <schema> -> <schema>_config
|
|
22
|
-
const initialAnswers = {};
|
|
23
|
-
Object.keys(generators).forEach(id => {
|
|
24
|
-
initialAnswers[`${id}_config`] = preAnswered[id] || {};
|
|
25
|
-
});
|
|
26
|
-
let answers = initialAnswers;
|
|
11
|
+
exports.default = async (schema, name, source, preAnswered = {}) => {
|
|
12
|
+
var _a;
|
|
13
|
+
// Store the generator
|
|
14
|
+
let generator;
|
|
15
|
+
// Initial answers from flags, keyed as <schema>_config
|
|
16
|
+
let answers = {
|
|
17
|
+
[`${schema}_config`]: preAnswered,
|
|
18
|
+
};
|
|
27
19
|
// Start downloading
|
|
28
20
|
core_1.CliUx.ux.action.start('Downloading from StepZen...');
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
type: 'generator',
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
43
|
-
finally {
|
|
44
|
-
try {
|
|
45
|
-
if (_g && !_g.done && (_a = _f.return)) await _a.call(_f);
|
|
46
|
-
}
|
|
47
|
-
finally { if (e_1) throw e_1.error; }
|
|
21
|
+
// Get the generator configuration
|
|
22
|
+
const configure = await helpers_1.getConfiguration(schema, answers);
|
|
23
|
+
if (configure === null || configure === void 0 ? void 0 : configure.questions.length) {
|
|
24
|
+
generator = {
|
|
25
|
+
questions: configure.questions,
|
|
26
|
+
type: 'generator',
|
|
27
|
+
answers: undefined,
|
|
28
|
+
};
|
|
48
29
|
}
|
|
49
30
|
// Get the API templates repository
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
31
|
+
let templates;
|
|
32
|
+
if (generator === undefined) {
|
|
33
|
+
templates = await helpers_1.getTemplates();
|
|
34
|
+
if (fs.existsSync(`${templates}/${schema}`)) {
|
|
35
|
+
const file = path.join(templates, schema, 'stepzen.config.json');
|
|
36
|
+
const config = fs.readFileSync(file, 'utf8');
|
|
37
|
+
const json = JSON.parse(config);
|
|
38
|
+
generator = {
|
|
39
|
+
questions: ((_a = json === null || json === void 0 ? void 0 : json.config) === null || _a === void 0 ? void 0 : _a.questions) || [],
|
|
40
|
+
type: 'template',
|
|
41
|
+
answers: undefined,
|
|
42
|
+
};
|
|
65
43
|
}
|
|
66
44
|
}
|
|
67
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
68
|
-
finally {
|
|
69
|
-
try {
|
|
70
|
-
if (_j && !_j.done && (_b = _h.return)) await _b.call(_h);
|
|
71
|
-
}
|
|
72
|
-
finally { if (e_2) throw e_2.error; }
|
|
73
|
-
}
|
|
74
45
|
// Finished downloading
|
|
75
46
|
core_1.CliUx.ux.action.stop();
|
|
76
47
|
console.log();
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
return null;
|
|
83
|
-
})
|
|
84
|
-
.filter(i => i);
|
|
85
|
-
if (notFound.length > 0) {
|
|
86
|
-
fs.removeSync(templates);
|
|
87
|
-
throw new errors_1.CLIError(`Cannot find the schema ${notFound[0]}`);
|
|
88
|
-
}
|
|
89
|
-
try {
|
|
90
|
-
// Ask all the questions
|
|
91
|
-
for (var _k = tslib_1.__asyncValues(Object.entries(generators)), _l; _l = await _k.next(), !_l.done;) {
|
|
92
|
-
const [id, generator] = _l.value;
|
|
93
|
-
let result = {};
|
|
94
|
-
if (generator.type === 'generator') {
|
|
95
|
-
result = await helpers_1.askGeneratorQuestions(id, generator, answers);
|
|
96
|
-
}
|
|
97
|
-
else if (generator.type === 'template') {
|
|
98
|
-
result = await helpers_1.askTemplateQuestions(id, generator, answers);
|
|
99
|
-
}
|
|
100
|
-
generators[id].answers = result;
|
|
101
|
-
answers = lodash.merge(answers, result);
|
|
48
|
+
let result;
|
|
49
|
+
if (generator === undefined) {
|
|
50
|
+
// If you've tried to import non-existent templates, complain and exit
|
|
51
|
+
if (templates) {
|
|
52
|
+
fs.removeSync(templates);
|
|
102
53
|
}
|
|
54
|
+
throw new errors_1.CLIError(`Cannot find the schema ${schema}`);
|
|
103
55
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
try {
|
|
107
|
-
if (_l && !_l.done && (_c = _k.return)) await _c.call(_k);
|
|
108
|
-
}
|
|
109
|
-
finally { if (e_3) throw e_3.error; }
|
|
56
|
+
else if (generator.type === 'generator') {
|
|
57
|
+
result = await helpers_1.askGeneratorQuestions(schema, generator, answers);
|
|
110
58
|
}
|
|
59
|
+
else if (generator.type === 'template') {
|
|
60
|
+
result = await helpers_1.askTemplateQuestions(schema, generator, answers);
|
|
61
|
+
}
|
|
62
|
+
generator.answers = result;
|
|
63
|
+
answers = lodash.merge(answers, result);
|
|
111
64
|
// We now have all the answers! Generate schemas
|
|
112
|
-
|
|
113
|
-
fs.ensureDirSync(output);
|
|
114
|
-
fs.copySync(source, output);
|
|
65
|
+
let output;
|
|
115
66
|
console.log();
|
|
116
67
|
core_1.CliUx.ux.action.start('Generating schemas...');
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
output: null,
|
|
129
|
-
});
|
|
130
|
-
fs.copySync(tmp, output);
|
|
131
|
-
fs.removeSync(files);
|
|
132
|
-
fs.removeSync(tmp);
|
|
133
|
-
}
|
|
134
|
-
if (generator.type === 'template') {
|
|
135
|
-
const tmp = await transpiler_1.merge(output, {
|
|
136
|
-
name: name || id,
|
|
137
|
-
source: path.join(templates, id),
|
|
138
|
-
}, {
|
|
139
|
-
answers,
|
|
140
|
-
silent: true,
|
|
141
|
-
output: null,
|
|
142
|
-
});
|
|
143
|
-
fs.copySync(tmp, output);
|
|
144
|
-
fs.removeSync(tmp);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
68
|
+
if (generator.type === 'generator') {
|
|
69
|
+
const files = await helpers_1.createGeneratorFiles(schema, generator);
|
|
70
|
+
output = await transpiler_1.merge(source, {
|
|
71
|
+
name: schema,
|
|
72
|
+
source: files,
|
|
73
|
+
}, {
|
|
74
|
+
answers,
|
|
75
|
+
silent: true,
|
|
76
|
+
output: null,
|
|
77
|
+
});
|
|
78
|
+
fs.removeSync(files);
|
|
147
79
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
80
|
+
if (generator.type === 'template') {
|
|
81
|
+
output = await transpiler_1.merge(source, {
|
|
82
|
+
name: name || schema,
|
|
83
|
+
source: path.join(templates, schema),
|
|
84
|
+
}, {
|
|
85
|
+
answers,
|
|
86
|
+
silent: true,
|
|
87
|
+
output: null,
|
|
88
|
+
});
|
|
154
89
|
}
|
|
155
90
|
// Housekeeping
|
|
156
91
|
core_1.CliUx.ux.action.stop();
|
|
157
|
-
|
|
92
|
+
if (templates) {
|
|
93
|
+
fs.removeSync(templates);
|
|
94
|
+
}
|
|
158
95
|
return output;
|
|
159
96
|
};
|
|
@@ -3,8 +3,6 @@ export declare const STEPZEN_LAST_UPDATE_CHECK_TIMESTAMP: string;
|
|
|
3
3
|
export declare const STEPZEN_CONFIG_FILE: string;
|
|
4
4
|
export declare const STEPZEN_DOMAIN: string;
|
|
5
5
|
export declare const STEPZEN_SERVER_URL: string;
|
|
6
|
-
export declare const STEPZEN_GENERATOR_ENGINES_SCHEMA: string;
|
|
7
|
-
export declare const STEPZEN_GENERATOR_ENGINES_ENDPOINT = "stepzen-generator/engines";
|
|
8
6
|
export declare const STEPZEN_DIRECT_GENERATOR_ENGINES_URL: string;
|
|
9
7
|
export declare const STEPZEN_API_TEMPLATES_REPOSITORY = "https://github.com/steprz/stepzen-schemas";
|
|
10
8
|
export declare const ADMIN_DEPLOY_URL = "/cli/admin/deploy";
|
package/lib/shared/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.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.
|
|
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_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");
|
|
@@ -9,7 +9,7 @@ const path = require("path");
|
|
|
9
9
|
// This allows you to set environment variables in a `.env` file.
|
|
10
10
|
// This file needs to be in your working directory.
|
|
11
11
|
dotenv.config();
|
|
12
|
-
const { STEPZEN_CONFIG_FILE: ENV_VAR_STEPZEN_CONFIG_FILE, STEPZEN_DOMAIN: ENV_VAR_STEPZEN_DOMAIN,
|
|
12
|
+
const { STEPZEN_CONFIG_FILE: ENV_VAR_STEPZEN_CONFIG_FILE, STEPZEN_DOMAIN: ENV_VAR_STEPZEN_DOMAIN, STEPZEN_SERVER_URL: ENV_VAR_STEPZEN_SERVER_URL, STEPZEN_JSON2SDL_SERVER_URL: ENV_VAR_STEPZEN_JSON2SDL_SERVER_URL, STEPZEN_DIRECT_GENERATOR_ENGINES_URL: ENV_VAR_STEPZEN_DIRECT_GENERATOR_ENGINES_URL, } = process.env;
|
|
13
13
|
// Where your authentication details are stored locally
|
|
14
14
|
exports.STEPZEN_CONFIG_DIRECTORY = path.join(os.homedir(), '.stepzen');
|
|
15
15
|
exports.STEPZEN_LAST_UPDATE_CHECK_TIMESTAMP = path.join(exports.STEPZEN_CONFIG_DIRECTORY, 'last_update_check.timestamp');
|
|
@@ -18,11 +18,6 @@ exports.STEPZEN_CONFIG_FILE = ENV_VAR_STEPZEN_CONFIG_FILE || 'stepzen-config.yam
|
|
|
18
18
|
exports.STEPZEN_DOMAIN = ENV_VAR_STEPZEN_DOMAIN || 'stepzen.io';
|
|
19
19
|
// The zenctl URL. Override with the env var `STEPZEN_SERVER_URL`
|
|
20
20
|
exports.STEPZEN_SERVER_URL = ENV_VAR_STEPZEN_SERVER_URL || 'https://{account}.stepzen.io';
|
|
21
|
-
// Generator Engines schema: folder/name
|
|
22
|
-
// Use 'stepzen/engines-dev' to test the dev instance of https://github.com/steprz/generator-engines
|
|
23
|
-
exports.STEPZEN_GENERATOR_ENGINES_SCHEMA = ENV_VAR_STEPZEN_GENERATOR_ENGINES_SCHEMA || 'stepzen/engines';
|
|
24
|
-
// Generator Engines schema: target API endpoint
|
|
25
|
-
exports.STEPZEN_GENERATOR_ENGINES_ENDPOINT = 'stepzen-generator/engines';
|
|
26
21
|
// If defined, call the generator engines cloud function directly, skipping zenctl
|
|
27
22
|
exports.STEPZEN_DIRECT_GENERATOR_ENGINES_URL = ENV_VAR_STEPZEN_DIRECT_GENERATOR_ENGINES_URL ||
|
|
28
23
|
'https://us-central1-stepzen-functions.cloudfunctions.net/generator-engine';
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.16.0-beta.
|
|
1
|
+
{"version":"0.16.0-beta.3","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'"},"header-param":{"name":"header-param","type":"option","description":"[curl] specifies a parameter in a header value. Can be formed by taking a -H, --header flag and replacing the variable part of the header value with a $paramName placeholder. Repeat this flag once for each header with a parameter.\n\nExample:\nstepzen import curl https://example.com/api/customers \\\n\t-H \"Authorization: apikey SecretAPIKeyValue\" \\\n\t--header-param 'Authorization: apikey $apikey'"},"db-host":{"name":"db-host","type":"option","description":"[mysql, postgresql] database host"},"db-user":{"name":"db-user","type":"option","description":"[mysql, postgresql] database user name"},"db-password":{"name":"db-password","type":"option","description":"[mysql, postgresql] database password"},"db-database":{"name":"db-database","type":"option","description":"[mysql, postgresql] name of database to import"},"db-schema":{"name":"db-schema","type":"option","description":"[postgresql] database schema"}},"args":[{"name":"schema","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},"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},"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":"display your credentials with 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.16.0-beta.
|
|
4
|
+
"version": "0.16.0-beta.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Darren Waddell <darren@stepzen.com>",
|
|
7
7
|
"contributors": [
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"@oclif/core": "1.7.0",
|
|
32
32
|
"@oclif/errors": "1.3.5",
|
|
33
33
|
"@oclif/plugin-help": "^5.1.12",
|
|
34
|
-
"@stepzen/dashboard": "0.
|
|
35
|
-
"@stepzen/sdk": "0.11.
|
|
36
|
-
"@stepzen/transpiler": "0.0.
|
|
34
|
+
"@stepzen/dashboard": "0.2.0",
|
|
35
|
+
"@stepzen/sdk": "0.11.2",
|
|
36
|
+
"@stepzen/transpiler": "0.0.39",
|
|
37
37
|
"chalk": "^4.1.1",
|
|
38
38
|
"chokidar": "^3.5.2",
|
|
39
39
|
"compare-versions": "^3.6.0",
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.createDashboardInterface = void 0;
|
|
5
|
-
const fs = require("fs-extra");
|
|
6
|
-
const os = require("os");
|
|
7
|
-
const path = require("path");
|
|
8
|
-
const deploy_1 = require("../commands/deploy");
|
|
9
|
-
const constants_1 = require("../shared/constants");
|
|
10
|
-
const { merge } = require('@stepzen/transpiler');
|
|
11
|
-
exports.createDashboardInterface = (workspace) => ({
|
|
12
|
-
endpoint: constants_1.STEPZEN_GENERATOR_ENGINES_ENDPOINT,
|
|
13
|
-
onStart: async () => {
|
|
14
|
-
await deploy_1.default.run([
|
|
15
|
-
constants_1.STEPZEN_GENERATOR_ENGINES_ENDPOINT,
|
|
16
|
-
'--schema',
|
|
17
|
-
constants_1.STEPZEN_GENERATOR_ENGINES_SCHEMA,
|
|
18
|
-
'--silent',
|
|
19
|
-
]);
|
|
20
|
-
},
|
|
21
|
-
onImport: async (id, files) => {
|
|
22
|
-
const tmp = path.join(os.tmpdir(), `stepzen-generated-schema-${Date.now()}`);
|
|
23
|
-
fs.ensureDirSync(tmp);
|
|
24
|
-
for (const file of files) {
|
|
25
|
-
const cleaned = file.name.replace(os.tmpdir(), '');
|
|
26
|
-
const dir = path.join(tmp, cleaned);
|
|
27
|
-
fs.writeFileSync(dir, file.content);
|
|
28
|
-
}
|
|
29
|
-
const built = await merge(workspace.schema, {
|
|
30
|
-
name: id,
|
|
31
|
-
source: tmp,
|
|
32
|
-
}, {
|
|
33
|
-
silent: true,
|
|
34
|
-
});
|
|
35
|
-
fs.copySync(built, workspace.schema);
|
|
36
|
-
fs.removeSync(built);
|
|
37
|
-
fs.removeSync(tmp);
|
|
38
|
-
return {
|
|
39
|
-
success: true,
|
|
40
|
-
};
|
|
41
|
-
},
|
|
42
|
-
});
|