stepzen 0.16.0-beta.2 → 0.16.0-beta.5
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 +4 -4
- package/lib/commands/import.d.ts +1 -1
- package/lib/commands/import.js +13 -27
- package/lib/generate/helpers.d.ts +2 -1
- package/lib/generate/helpers.js +25 -17
- package/lib/generate/index.d.ts +2 -4
- package/lib/generate/index.js +61 -130
- package/lib/hooks/prerun/check-upgrade.js +3 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
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.5 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
|
package/lib/commands/import.d.ts
CHANGED
|
@@ -64,7 +64,7 @@ export default class Import extends ZenCommand {
|
|
|
64
64
|
}[];
|
|
65
65
|
static strict: boolean;
|
|
66
66
|
run(): Promise<void>;
|
|
67
|
-
warnAboutIgnoredFlags: (
|
|
67
|
+
warnAboutIgnoredFlags: (schema: string, usedFlags: {
|
|
68
68
|
[key: string]: any;
|
|
69
69
|
}) => void;
|
|
70
70
|
parseWorkaround(): import("@oclif/parser").Output<{
|
package/lib/commands/import.js
CHANGED
|
@@ -22,9 +22,9 @@ 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 = (
|
|
25
|
+
this.warnAboutIgnoredFlags = (schema, usedFlags) => {
|
|
26
26
|
Import.flagsForSchemas.forEach(({ flags, schemas }) => {
|
|
27
|
-
if (!
|
|
27
|
+
if (!schemas.includes(schema)) {
|
|
28
28
|
Object.keys(flags).forEach(flag => {
|
|
29
29
|
if (Object.prototype.hasOwnProperty.call(usedFlags, flag)) {
|
|
30
30
|
this.log(chalk.gray(`The ${chalk.bold(`--${flag}`)} flag only applies when importing ${schemas
|
|
@@ -39,11 +39,7 @@ class Import extends zen_command_1.default {
|
|
|
39
39
|
async run() {
|
|
40
40
|
const { args, argv, flags } = this.parseWorkaround();
|
|
41
41
|
// Get a list of schemas you're asking for
|
|
42
|
-
const
|
|
43
|
-
if (schemas.length > 1 && flags.name) {
|
|
44
|
-
this.log('When importing several schemas the --name flag is ignored. ' +
|
|
45
|
-
'In order to use the --name flag please import each schema separately.');
|
|
46
|
-
}
|
|
42
|
+
const schema = helpers_1.getSchema(args.schema);
|
|
47
43
|
// Get the working directory and workspace
|
|
48
44
|
let workspace;
|
|
49
45
|
const directory = utils_1.getDirectory(flags.dir);
|
|
@@ -59,17 +55,14 @@ class Import extends zen_command_1.default {
|
|
|
59
55
|
throw new errors_1.CLIError(`Could not create a StepZen workspace in the ${flags.dir ? directory : 'current'} directory.\n` + error.message);
|
|
60
56
|
}
|
|
61
57
|
}
|
|
62
|
-
this.warnAboutIgnoredFlags(
|
|
58
|
+
this.warnAboutIgnoredFlags(schema, flags);
|
|
63
59
|
// Select an import execution flow:
|
|
64
60
|
// - v1 with `stepzen/engines` and cloud function
|
|
65
61
|
// - v2 with the graphqlize service
|
|
66
62
|
let result;
|
|
67
|
-
if (
|
|
63
|
+
if (schema === 'curl') {
|
|
68
64
|
// LATER: offload the check to the graphqlize service or fetch
|
|
69
65
|
// the list of supported data sources and compare agains it.
|
|
70
|
-
if (schemas.length > 1) {
|
|
71
|
-
throw new errors_1.CLIError('Please run cURL import separately from importing other schemas');
|
|
72
|
-
}
|
|
73
66
|
this.log(chalk.yellow(`NOTE: ${chalk.bold('stepzen import curl')} is a ${chalk.bold('new')} feature.`));
|
|
74
67
|
this.log(chalk.yellow('If you have any issues, please check if they have been addressed ' +
|
|
75
68
|
'in the latest version, or reach out to StepZen on Discord: ' +
|
|
@@ -133,19 +126,13 @@ class Import extends zen_command_1.default {
|
|
|
133
126
|
// If/when the number of property-to-answer mappings increase, create a dictionary
|
|
134
127
|
// { schema: { flag: field } } and build the below map based on this (a
|
|
135
128
|
// dictionary also enables a generic solution to the warning about ignored flags).
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
? {}
|
|
142
|
-
: { schema: flags['db-schema'] }));
|
|
143
|
-
const preAnswered = {
|
|
144
|
-
mysql: preAnsweredForDBs,
|
|
145
|
-
postgresql: preAnsweredForDBs,
|
|
146
|
-
};
|
|
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
|
+
}
|
|
147
134
|
// Let's go!
|
|
148
|
-
result = await generate_1.default(
|
|
135
|
+
result = await generate_1.default(schema, flags.name, workspace.schema, preAnswered);
|
|
149
136
|
// Validate
|
|
150
137
|
await transpiler_1.validate(result, {
|
|
151
138
|
extensions: await utils_1.getStepZenExtensions(),
|
|
@@ -155,8 +142,7 @@ class Import extends zen_command_1.default {
|
|
|
155
142
|
fs.copySync(result, workspace.schema);
|
|
156
143
|
fs.removeSync(result);
|
|
157
144
|
// Nice message
|
|
158
|
-
this;
|
|
159
|
-
this.log(chalk.green(`Successfully imported ${schemas.length} schemas from StepZen`));
|
|
145
|
+
this.log(chalk.green(`Successfully imported schema ${chalk.bold(schema)} from StepZen`));
|
|
160
146
|
}
|
|
161
147
|
// Correct the value for the 'header-param' flag to work around the oclif's
|
|
162
148
|
// parser issue with multi-value flags: https://github.com/oclif/oclif/issues/261
|
|
@@ -261,7 +247,7 @@ Import.flags = Object.assign(Object.assign(Object.assign(Object.assign(Object.as
|
|
|
261
247
|
}) }), Import.curlFlags), Import.sqlFlags), Import.postgresqlFlags);
|
|
262
248
|
Import.args = [
|
|
263
249
|
{
|
|
264
|
-
name: '
|
|
250
|
+
name: 'schema',
|
|
265
251
|
required: true,
|
|
266
252
|
},
|
|
267
253
|
];
|
|
@@ -7,7 +7,8 @@ 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>;
|
|
14
|
+
export declare const mergeFiles: (name: string, source: string, files: string, answers: any) => Promise<string>;
|
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.mergeFiles = 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");
|
|
@@ -12,6 +12,7 @@ const lodash_1 = require("lodash");
|
|
|
12
12
|
const os = require("os");
|
|
13
13
|
const path = require("path");
|
|
14
14
|
const shell = require("shelljs");
|
|
15
|
+
const transpiler = require("@stepzen/transpiler");
|
|
15
16
|
const constants_1 = require("../shared/constants");
|
|
16
17
|
const errors_2 = require("../shared/errors");
|
|
17
18
|
const { version } = require('../../package.json');
|
|
@@ -88,23 +89,19 @@ exports.getConfiguration = async (id, details = {}) => {
|
|
|
88
89
|
throw new errors_1.CLIError(errors_2.PERMANENT_STEPZEN_ERROR);
|
|
89
90
|
}
|
|
90
91
|
};
|
|
91
|
-
exports.
|
|
92
|
-
const
|
|
93
|
-
//
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
throw new errors_1.CLIError(`You are trying to import "${schema}" more than once`);
|
|
98
|
-
}
|
|
92
|
+
exports.getSchema = (arg) => {
|
|
93
|
+
const schema = arg.trim();
|
|
94
|
+
// Now supports importing only one schema at a time:
|
|
95
|
+
// https://github.com/steprz/stepzen-cli/issues/628
|
|
96
|
+
if (schema.includes(',')) {
|
|
97
|
+
throw new errors_1.CLIError("Importing multiple schemas is no longer supported; please specify only one (e.g. 'stepzen import mysql')");
|
|
99
98
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return schema;
|
|
107
|
-
});
|
|
99
|
+
// support `postgres` as an alias to `postgresql`
|
|
100
|
+
// https://github.com/steprz/stepzen-cli/issues/431
|
|
101
|
+
if (schema.toLowerCase() === 'postgres') {
|
|
102
|
+
return 'postgresql';
|
|
103
|
+
}
|
|
104
|
+
return schema;
|
|
108
105
|
};
|
|
109
106
|
exports.getTemplates = async () => {
|
|
110
107
|
const tmp = path.join(os.tmpdir(), `stepzen-api-templates-${Date.now()}`);
|
|
@@ -163,3 +160,14 @@ exports.askTemplateQuestions = async (id, settings, state) => {
|
|
|
163
160
|
const answers = await inquirer.prompt(questions);
|
|
164
161
|
return Object.assign(Object.assign({}, state), answers);
|
|
165
162
|
};
|
|
163
|
+
exports.mergeFiles = async (name, source, files, answers) => {
|
|
164
|
+
const output = await transpiler.merge(source, {
|
|
165
|
+
name: name,
|
|
166
|
+
source: files,
|
|
167
|
+
}, {
|
|
168
|
+
answers,
|
|
169
|
+
silent: true,
|
|
170
|
+
output: null,
|
|
171
|
+
});
|
|
172
|
+
return output;
|
|
173
|
+
};
|
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,90 @@
|
|
|
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
|
-
const transpiler_1 = require("@stepzen/transpiler");
|
|
12
9
|
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;
|
|
10
|
+
exports.default = async (schema, name, source, preAnswered = {}) => {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
// Store the generator
|
|
13
|
+
let generator;
|
|
14
|
+
// Initial answers from flags, keyed as <schema>_config
|
|
15
|
+
let answers = {
|
|
16
|
+
[`${schema}_config`]: preAnswered,
|
|
17
|
+
};
|
|
27
18
|
// Start downloading
|
|
28
19
|
core_1.CliUx.ux.action.start('Downloading from StepZen...');
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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; }
|
|
20
|
+
// Get the generator configuration
|
|
21
|
+
const configure = await helpers_1.getConfiguration(schema, answers);
|
|
22
|
+
if (((_a = configure === null || configure === void 0 ? void 0 : configure.questions) === null || _a === void 0 ? void 0 : _a.length) ||
|
|
23
|
+
((configure === null || configure === void 0 ? void 0 : configure.status) && configure.status >= 0)) {
|
|
24
|
+
generator = {
|
|
25
|
+
questions: configure.questions,
|
|
26
|
+
type: 'generator',
|
|
27
|
+
answers: undefined,
|
|
28
|
+
};
|
|
48
29
|
}
|
|
30
|
+
// For housekeeping
|
|
31
|
+
const tempFiles = [];
|
|
32
|
+
const cleanUp = async () => {
|
|
33
|
+
// Silently ignore temporary files that could not be deleted (error message would be
|
|
34
|
+
// useless and allows simpler mocking by not having to actually create files).
|
|
35
|
+
await Promise.all(tempFiles.map(file => fs
|
|
36
|
+
.access(file, fs.constants.W_OK)
|
|
37
|
+
.then(() => fs.remove(file))
|
|
38
|
+
.catch(() => undefined)));
|
|
39
|
+
};
|
|
49
40
|
// Get the API templates repository
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
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);
|
|
41
|
+
let templates;
|
|
42
|
+
if (generator === undefined) {
|
|
43
|
+
templates = await helpers_1.getTemplates();
|
|
44
|
+
if (fs.existsSync(`${templates}/${schema}`)) {
|
|
45
|
+
const file = path.join(templates, schema, 'stepzen.config.json');
|
|
46
|
+
const config = fs.readFileSync(file, 'utf8');
|
|
47
|
+
const json = JSON.parse(config);
|
|
48
|
+
generator = {
|
|
49
|
+
questions: ((_b = json === null || json === void 0 ? void 0 : json.config) === null || _b === void 0 ? void 0 : _b.questions) || [],
|
|
50
|
+
type: 'template',
|
|
51
|
+
answers: undefined,
|
|
52
|
+
};
|
|
53
|
+
tempFiles.push(templates);
|
|
71
54
|
}
|
|
72
|
-
finally { if (e_2) throw e_2.error; }
|
|
73
55
|
}
|
|
74
56
|
// Finished downloading
|
|
75
57
|
core_1.CliUx.ux.action.stop();
|
|
76
58
|
console.log();
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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]}`);
|
|
59
|
+
let result;
|
|
60
|
+
if (generator === undefined) {
|
|
61
|
+
// If you've tried to import non-existent templates, complain and exit
|
|
62
|
+
cleanUp();
|
|
63
|
+
throw new errors_1.CLIError(`Cannot find the schema ${schema}`);
|
|
88
64
|
}
|
|
89
|
-
|
|
90
|
-
|
|
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);
|
|
102
|
-
}
|
|
65
|
+
else if (generator.type === 'generator') {
|
|
66
|
+
result = await helpers_1.askGeneratorQuestions(schema, generator, answers);
|
|
103
67
|
}
|
|
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; }
|
|
68
|
+
else if (generator.type === 'template') {
|
|
69
|
+
result = await helpers_1.askTemplateQuestions(schema, generator, answers);
|
|
110
70
|
}
|
|
71
|
+
generator.answers = result;
|
|
72
|
+
answers = lodash.merge(answers, result);
|
|
111
73
|
// We now have all the answers! Generate schemas
|
|
112
|
-
const output = path.join(os.tmpdir(), `stepzen-generated-schema-${Date.now()}`);
|
|
113
|
-
fs.ensureDirSync(output);
|
|
114
|
-
fs.copySync(source, output);
|
|
115
74
|
console.log();
|
|
116
75
|
core_1.CliUx.ux.action.start('Generating schemas...');
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const files = await helpers_1.createGeneratorFiles(id, generator);
|
|
122
|
-
const tmp = await transpiler_1.merge(output, {
|
|
123
|
-
name: id,
|
|
124
|
-
source: files,
|
|
125
|
-
}, {
|
|
126
|
-
answers,
|
|
127
|
-
silent: true,
|
|
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
|
-
}
|
|
76
|
+
let files;
|
|
77
|
+
if (generator.type === 'generator') {
|
|
78
|
+
files = await helpers_1.createGeneratorFiles(schema, generator);
|
|
79
|
+
tempFiles.push(files);
|
|
147
80
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
if (_o && !_o.done && (_d = _m.return)) await _d.call(_m);
|
|
152
|
-
}
|
|
153
|
-
finally { if (e_4) throw e_4.error; }
|
|
81
|
+
else {
|
|
82
|
+
// if (generator.type === 'template')
|
|
83
|
+
files = path.join(templates, schema);
|
|
154
84
|
}
|
|
155
|
-
|
|
85
|
+
const output = await helpers_1.mergeFiles(name || schema, source, files, answers);
|
|
156
86
|
core_1.CliUx.ux.action.stop();
|
|
157
|
-
|
|
87
|
+
// Housekeeping
|
|
88
|
+
cleanUp();
|
|
158
89
|
return output;
|
|
159
90
|
};
|
|
@@ -93,7 +93,9 @@ const hook = async function (options) {
|
|
|
93
93
|
const { message, isBlocking } = await exports.checkUpgrade(this.config.version);
|
|
94
94
|
// parse the command line to get `flags['non-interactive']`
|
|
95
95
|
const TheCommand = options.Command;
|
|
96
|
-
const { flags } = parser_1.parse(options.argv, Object.assign({ context:
|
|
96
|
+
const { flags } = parser_1.parse(options.argv, Object.assign({ context: Object.assign(Object.assign({}, this), { _help: () => {
|
|
97
|
+
// workaround for https://github.com/steprz/stepzen-cli/issues/637
|
|
98
|
+
} }) }, TheCommand));
|
|
97
99
|
// In a non-interactive shell only print the upgrade nudge if the upgrade
|
|
98
100
|
// is blocking.
|
|
99
101
|
// For non-blocking upgrades we don't want to print the upgrade nudge when
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.16.0-beta.
|
|
1
|
+
{"version":"0.16.0-beta.5","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":[]}}}
|