stepzen 0.16.0-beta.5 → 0.17.0-beta.1

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 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.5 darwin-x64 node-v14.19.1
32
+ stepzen/0.17.0-beta.1 darwin-x64 node-v14.19.1
33
33
  $ stepzen --help [COMMAND]
34
34
  USAGE
35
35
  $ stepzen COMMAND
@@ -123,7 +123,11 @@ OPTIONS
123
123
  --header-param 'Authorization: apikey $apikey'
124
124
 
125
125
  --name=name
126
- subfolder inside the workspace folder to save the imported schema files, defaults to the imported schema name
126
+ Subfolder inside the workspace folder to save the imported schema files to. Defaults to the name of the imported
127
+ schema.
128
+
129
+ --overwrite
130
+ Overwrite any existing schema with the same name. Cannot be used without also providing a --name flag.
127
131
 
128
132
  --path-params=path-params
129
133
  [curl] specifies path parameters in the URL path. Can be formed by taking the original path and replacing the
@@ -1,5 +1,6 @@
1
1
  import { flags } from '@oclif/command';
2
2
  import ZenCommand from '../shared/zen-command';
3
+ import { Workspace } from '../shared/types';
3
4
  export default class Import extends ZenCommand {
4
5
  static description: string;
5
6
  static curlFlags: {
@@ -56,6 +57,7 @@ export default class Import extends ZenCommand {
56
57
  help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
57
58
  silent: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
58
59
  name: flags.IOptionFlag<string | undefined>;
60
+ overwrite: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
59
61
  'non-interactive': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
60
62
  };
61
63
  static args: {
@@ -64,9 +66,10 @@ export default class Import extends ZenCommand {
64
66
  }[];
65
67
  static strict: boolean;
66
68
  run(): Promise<void>;
67
- warnAboutIgnoredFlags: (schema: string, usedFlags: {
69
+ ensureOnConflictBehavior(workspace: Workspace, schema: string, flags: ReturnType<Import['parseWorkaround']>['flags']): Promise<"overwrite" | "append">;
70
+ warnAboutIgnoredFlags(schema: string, usedFlags: {
68
71
  [key: string]: any;
69
- }) => void;
72
+ }): void;
70
73
  parseWorkaround(): import("@oclif/parser").Output<{
71
74
  'db-schema': string | undefined;
72
75
  'db-host': string | undefined;
@@ -82,6 +85,7 @@ export default class Import extends ZenCommand {
82
85
  help: void;
83
86
  silent: boolean;
84
87
  name: string | undefined;
88
+ overwrite: boolean;
85
89
  'non-interactive': boolean;
86
90
  }, {
87
91
  [name: string]: any;
@@ -3,6 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const chalk = require("chalk");
5
5
  const fs = require("fs-extra");
6
+ const path = require("path");
7
+ const inquirer = require("inquirer");
6
8
  const command_1 = require("@oclif/command");
7
9
  const errors_1 = require("@oclif/errors");
8
10
  const transpiler_1 = require("@stepzen/transpiler");
@@ -12,49 +14,19 @@ const utils_1 = require("../shared/utils");
12
14
  const helpers_1 = require("../generate/helpers");
13
15
  const curl2sdl_1 = require("../generate/curl2sdl");
14
16
  const curl_parser_1 = require("../shared/curl-parser");
15
- const workspace_1 = require("../shared/workspace");
16
17
  const zen_command_1 = require("../shared/zen-command");
17
- const init_1 = require("./init");
18
18
  const constants_1 = require("../shared/constants");
19
19
  const path_params_parser_1 = require("../shared/path-params-parser");
20
20
  const header_params_parser_1 = require("../shared/header-params-parser");
21
21
  class Import extends zen_command_1.default {
22
- constructor() {
23
- super(...arguments);
24
- // notify the user about any ignored flags
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
- });
37
- };
38
- }
39
22
  async run() {
40
23
  const { args, argv, flags } = this.parseWorkaround();
41
24
  // Get a list of schemas you're asking for
42
25
  const schema = helpers_1.getSchema(args.schema);
43
- // Get the working directory and workspace
44
- let workspace;
45
- const directory = utils_1.getDirectory(flags.dir);
46
- const maybeWorkspace = workspace_1.getWorkspace(directory);
47
- if (maybeWorkspace) {
48
- workspace = maybeWorkspace;
49
- }
50
- else {
51
- try {
52
- workspace = await init_1.default.run([directory]);
53
- }
54
- catch (error) {
55
- throw new errors_1.CLIError(`Could not create a StepZen workspace in the ${flags.dir ? directory : 'current'} directory.\n` + error.message);
56
- }
57
- }
26
+ // Get or create a StepZen workspace (possibly interactive)
27
+ const workspace = await this.ensureStepZenWorkspace({ directory: flags.dir });
28
+ // Define a sane onConflict behaviour (possibly interactive)
29
+ const onConflict = await this.ensureOnConflictBehavior(workspace, schema, flags);
58
30
  this.warnAboutIgnoredFlags(schema, flags);
59
31
  // Select an import execution flow:
60
32
  // - v1 with `stepzen/engines` and cloud function
@@ -71,6 +43,7 @@ class Import extends zen_command_1.default {
71
43
  const fixedOptions = {
72
44
  name: flags.name,
73
45
  source: workspace.schema,
46
+ onConflict,
74
47
  };
75
48
  const editableOptions = {
76
49
  queryName: flags['query-name'],
@@ -132,7 +105,13 @@ class Import extends zen_command_1.default {
132
105
  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
106
  }
134
107
  // Let's go!
135
- result = await generate_1.default(schema, flags.name, workspace.schema, preAnswered);
108
+ result = await generate_1.default({
109
+ schema,
110
+ name: flags.name,
111
+ onConflict,
112
+ source: workspace.schema,
113
+ preAnswered,
114
+ });
136
115
  // Validate
137
116
  await transpiler_1.validate(result, {
138
117
  extensions: await utils_1.getStepZenExtensions(),
@@ -144,6 +123,61 @@ class Import extends zen_command_1.default {
144
123
  // Nice message
145
124
  this.log(chalk.green(`Successfully imported schema ${chalk.bold(schema)} from StepZen`));
146
125
  }
126
+ async ensureOnConflictBehavior(workspace, schema, flags) {
127
+ const name = flags.name || schema;
128
+ const hasConflict = fs.existsSync(path.join(workspace.schema, name));
129
+ if (!hasConflict) {
130
+ return 'append';
131
+ }
132
+ // No `--name` is given (i.e. naming is automatic)
133
+ // Using the default name is going to lead to a conflict, and it should
134
+ // be resolved by inventing a new unique name for the new schema.
135
+ if (!flags.name) {
136
+ return 'append';
137
+ }
138
+ // `--name` is given and (i.e. naming is namaged by the user)
139
+ // There is a naming conflict.
140
+ // The user has explicitly asked to overwrite the existing schema.
141
+ if (flags.overwrite) {
142
+ return 'overwrite';
143
+ }
144
+ // `--name` is given and (i.e. naming is namaged by the user)
145
+ // There is a naming conflict.
146
+ // The user has NOT given an explicit permission to overwrite the existing
147
+ // schema.
148
+ // In an interactive mode the CLI asks them for a confirmation.
149
+ // In a non-interactive mode the CLI throws an error.
150
+ if (flags['non-interactive']) {
151
+ throw new errors_1.CLIError(`A schema named ${chalk.bold(flags.name)} already exists in this workspace. Add an ${chalk.bold('--overwrite')} flag to overwrite it.`);
152
+ }
153
+ this.log(`A schema named ${chalk.bold(flags.name)} already exists in this workspace. Would you like to overwrite it?`);
154
+ const answers = await inquirer.prompt([
155
+ {
156
+ name: 'overwrite',
157
+ type: 'confirm',
158
+ default: false,
159
+ message: `Overwrite ${flags.name}?`,
160
+ },
161
+ ]);
162
+ if (answers.overwrite) {
163
+ return 'overwrite';
164
+ }
165
+ this.exit();
166
+ }
167
+ // notify the user about any ignored flags
168
+ warnAboutIgnoredFlags(schema, usedFlags) {
169
+ Import.flagsForSchemas.forEach(({ flags, schemas }) => {
170
+ if (!schemas.includes(schema)) {
171
+ Object.keys(flags).forEach(flag => {
172
+ if (Object.prototype.hasOwnProperty.call(usedFlags, flag)) {
173
+ this.log(chalk.gray(`The ${chalk.bold(`--${flag}`)} flag only applies when importing ${schemas
174
+ .map(schema => chalk.bold(schema))
175
+ .join(', ')}. It will be ignored now.`));
176
+ }
177
+ });
178
+ }
179
+ });
180
+ }
147
181
  // Correct the value for the 'header-param' flag to work around the oclif's
148
182
  // parser issue with multi-value flags: https://github.com/oclif/oclif/issues/261
149
183
  parseWorkaround() {
@@ -242,8 +276,12 @@ Import.flagsForSchemas = [
242
276
  { flags: Import.postgresqlFlags, schemas: ['postgresql'] },
243
277
  ];
244
278
  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({
245
- description: 'subfolder inside the workspace folder to save the imported' +
246
- ' schema files, defaults to the imported schema name',
279
+ description: 'Subfolder inside the workspace folder to save the imported' +
280
+ ' schema files to. Defaults to the name of the imported schema.',
281
+ }), overwrite: command_1.flags.boolean({
282
+ description: 'Overwrite any existing schema with the same name. Cannot be used' +
283
+ ' without also providing a --name flag.',
284
+ dependsOn: ['name'],
247
285
  }) }), Import.curlFlags), Import.sqlFlags), Import.postgresqlFlags);
248
286
  Import.args = [
249
287
  {
@@ -1,8 +1,5 @@
1
1
  import { flags } from '@oclif/command';
2
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
3
  export default class Init extends ZenCommand {
7
4
  static description: string;
8
5
  static hidden: boolean;
@@ -1,120 +1,17 @@
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;
5
4
  const command_1 = require("@oclif/command");
6
- const errors_1 = require("@oclif/errors");
7
- const fs = require("fs");
8
- const glob = require("glob");
9
- const inquirer = require("inquirer");
10
- const os = require("os");
11
- const path = require("path");
12
- const utils_1 = require("../shared/utils");
13
- const moniker_1 = require("../shared/moniker");
14
5
  const workspace_1 = require("../shared/workspace");
15
6
  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
7
  class Init extends zen_command_1.default {
40
8
  async run() {
41
9
  const { args, flags } = this.parse(Init);
42
- // Get the correct directory
43
- let directory = utils_1.getDirectory(args.directory);
44
- // Make sure it is not already a workspace
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
67
- if (flags.endpoint) {
68
- const error = utils_1.validateEndpoint(flags.endpoint);
69
- if (typeof error === 'string') {
70
- throw new errors_1.CLIError(error);
71
- }
72
- }
73
- // Make a suggestion for the endpoint
74
- const endpoint = flags.endpoint || `api/${moniker_1.default()}`;
75
- // What questions will we ask?
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
- },
84
- {
85
- default: endpoint,
86
- message: 'What would you like your endpoint to be called?',
87
- name: 'endpoint',
88
- validate: utils_1.validateEndpoint,
89
- when: !flags.endpoint && !flags.yes,
90
- },
91
- {
92
- message: `We have detected a schema in this directory. Set the schema root to "${root}"?`,
93
- name: 'use-root',
94
- type: 'confirm',
95
- when: Boolean(root) && !flags.yes,
96
- },
97
- ];
98
- // Get the answers
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
- }
108
- // Create the workspace
109
- const workspace = { endpoint: answers.endpoint };
110
- if (root && answers['use-root'])
111
- workspace.root = root;
112
- // Write the file
113
- const file = path.join(directory, 'stepzen.config.json');
114
- fs.writeFileSync(file, JSON.stringify(workspace, null, ' '));
115
- // Fetch the newly created workspace
116
- const created = workspace_1.getWorkspace(directory);
117
- // Done!
10
+ const created = await workspace_1.initWorkspace({
11
+ directory: args.directory,
12
+ endpoint: flags.endpoint,
13
+ yes: flags.yes,
14
+ });
118
15
  this.log(`Created a StepZen workspace in ${created.directory}`);
119
16
  return created;
120
17
  }
@@ -9,7 +9,6 @@ export default class Start extends ZenCommand {
9
9
  'no-console': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
10
10
  'no-dashboard': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
11
11
  'no-init': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
12
- 'no-server': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
13
12
  'no-validate': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
14
13
  'no-watcher': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
15
14
  port: import("@oclif/parser/lib/flags").IOptionFlag<number>;
@@ -7,10 +7,7 @@ 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 utils_1 = require("../shared/utils");
11
10
  const start_1 = require("../start");
12
- const workspace_1 = require("../shared/workspace");
13
- const init_1 = require("./init");
14
11
  const constants_1 = require("../shared/constants");
15
12
  const zen_command_1 = require("../shared/zen-command");
16
13
  const dashboard = require('@stepzen/dashboard');
@@ -19,28 +16,13 @@ class Start extends zen_command_1.default {
19
16
  async run() {
20
17
  const { flags } = this.parse(Start);
21
18
  const { configuration } = await this.ensureStepZenAccount();
22
- // Get the working directory and workspace
23
- let workspace;
24
- const directory = utils_1.getDirectory(flags.dir);
25
- const maybeWorkspace = workspace_1.getWorkspace(directory);
26
- if (maybeWorkspace) {
27
- workspace = maybeWorkspace;
28
- }
29
- else {
30
- const initArgs = [directory];
31
- if (flags.endpoint) {
32
- initArgs.push('--endpoint', flags.endpoint);
33
- }
34
- try {
35
- workspace = await init_1.default.run(initArgs);
36
- }
37
- catch (error) {
38
- throw new errors_1.CLIError(`Could not create a StepZen workspace in the ${flags.dir ? directory : 'current'} directory.\n` + error.message);
39
- }
40
- }
41
- // If you have overridden the endpoint, set it
19
+ // Get or create a StepZen workspace (possibly interactive)
20
+ const workspace = await this.ensureStepZenWorkspace({
21
+ directory: flags.dir,
22
+ endpoint: flags.endpoint,
23
+ });
24
+ // If the user has overridden the endpoint, apply the override
42
25
  if (flags.endpoint) {
43
- // eslint-disable-next-line require-atomic-updates
44
26
  workspace.endpoint = flags.endpoint;
45
27
  }
46
28
  // Check the port is available
@@ -50,25 +32,25 @@ class Start extends zen_command_1.default {
50
32
  }
51
33
  // This is the file watcher
52
34
  if (!flags['no-watcher']) {
35
+ const redeploy = throttle_debounce_1.debounce(500, (path) => {
36
+ start_1.changed({ workspace, file: path });
37
+ start_1.deploy({ workspace, flags });
38
+ });
53
39
  chokidar
54
- .watch(workspace.schema, {
55
- ignored: '**/*.js',
40
+ .watch(['**/*.graphql', 'config.yaml'], {
41
+ cwd: workspace.schema,
42
+ ignored: 'node_modules/**',
43
+ ignoreInitial: true,
56
44
  })
57
- .on('change', throttle_debounce_1.debounce(500, async (path) => {
58
- utils_1.clearConsole();
59
- await start_1.deploy(path, workspace, flags);
60
- await start_1.console(workspace);
61
- }));
45
+ .on('change', redeploy)
46
+ .on('add', redeploy)
47
+ .on('unlink', redeploy);
62
48
  }
63
49
  // Start!
64
- utils_1.clearConsole();
65
50
  core_1.CliUx.ux.action.start('Starting...');
66
51
  // Unless explicitly disabled, auto-init
67
52
  if (!flags['no-init']) {
68
- await start_1.deploy(null, workspace, flags);
69
- }
70
- if (!flags['no-console']) {
71
- start_1.console(workspace);
53
+ await start_1.deploy({ workspace, flags });
72
54
  }
73
55
  // Create the dashboard
74
56
  if (!flags['no-dashboard']) {
@@ -92,9 +74,22 @@ class Start extends zen_command_1.default {
92
74
  }
93
75
  // Done
94
76
  core_1.CliUx.ux.action.stop();
77
+ if (!flags['no-console']) {
78
+ if (!flags['no-init']) {
79
+ start_1.success({
80
+ workspace,
81
+ account: configuration.account,
82
+ port: flags.port,
83
+ });
84
+ this.log();
85
+ }
86
+ if (!flags['no-watcher']) {
87
+ start_1.watching(workspace);
88
+ }
89
+ }
95
90
  }
96
91
  }
97
92
  exports.default = Start;
98
93
  Start.description = 'upload and deploy your schema';
99
- 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' }) });
94
+ 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-validate': command_1.flags.boolean({ hidden: true }), 'no-watcher': command_1.flags.boolean({ hidden: true }), port: command_1.flags.integer({ default: 5001, env: 'PORT' }) });
100
95
  Start.args = [];
@@ -28,6 +28,7 @@ export declare type Curl2SdlOptions = {
28
28
  typePrefix?: string;
29
29
  pathParams: readonly PathParam[];
30
30
  headers: readonly HeaderInput[];
31
+ onConflict: 'overwrite' | 'append';
31
32
  };
32
33
  export declare type EditableCurl2SdlOptions = Pick<Curl2SdlOptions, 'curlArgs' | 'queryName' | 'rootType' | 'typePrefix' | 'pathParams'>;
33
34
  export declare type CurlAnswers = {
@@ -65,7 +66,7 @@ export declare const compileParameterList: (headers: HeaderInput[], pathParams:
65
66
  */
66
67
  export declare const makeDuplicateParamsMessage: (headers: HeaderInput[], pathParams: PathParam[], url: string) => string | null;
67
68
  export declare const askCurlQuestions: (defaultAnswers?: Partial<CurlAnswers>) => Promise<EditableCurl2SdlOptions>;
68
- export declare const curl2sdl: ({ curlArgs, name, source, queryName, rootType, typePrefix, pathParams, headers, }: Curl2SdlOptions) => Promise<{
69
+ export declare const curl2sdl: ({ curlArgs, name, source, queryName, rootType, typePrefix, pathParams, headers, onConflict, }: Curl2SdlOptions) => Promise<{
69
70
  error: string;
70
71
  } | {
71
72
  outPath: string;
@@ -151,7 +151,7 @@ exports.askCurlQuestions = async (defaultAnswers = {}) => {
151
151
  pathParams: parsedPathParamsOrError,
152
152
  };
153
153
  };
154
- exports.curl2sdl = async ({ curlArgs, name, source, queryName, rootType, typePrefix, pathParams, headers, }) => {
154
+ exports.curl2sdl = async ({ curlArgs, name, source, queryName, rootType, typePrefix, pathParams, headers, onConflict, }) => {
155
155
  let json;
156
156
  try {
157
157
  const url = `${constants_1.STEPZEN_JSON2SDL_SERVER_URL}/api/graphql`;
@@ -252,6 +252,7 @@ exports.curl2sdl = async ({ curlArgs, name, source, queryName, rootType, typePre
252
252
  output: null,
253
253
  silent: true,
254
254
  mergeTypes: false,
255
+ onConflict,
255
256
  });
256
257
  return { outPath: result };
257
258
  };
@@ -11,4 +11,3 @@ 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>;
@@ -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.mergeFiles = exports.askTemplateQuestions = exports.askGeneratorQuestions = exports.getTemplates = exports.getSchema = exports.getConfiguration = exports.createGeneratorFiles = void 0;
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");
@@ -12,7 +12,6 @@ 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");
16
15
  const constants_1 = require("../shared/constants");
17
16
  const errors_2 = require("../shared/errors");
18
17
  const { version } = require('../../package.json');
@@ -93,7 +92,7 @@ exports.getSchema = (arg) => {
93
92
  const schema = arg.trim();
94
93
  // Now supports importing only one schema at a time:
95
94
  // https://github.com/steprz/stepzen-cli/issues/628
96
- if (schema.includes(',')) {
95
+ if (schema.includes(',') || schema.includes(' ')) {
97
96
  throw new errors_1.CLIError("Importing multiple schemas is no longer supported; please specify only one (e.g. 'stepzen import mysql')");
98
97
  }
99
98
  // support `postgres` as an alias to `postgresql`
@@ -160,14 +159,3 @@ exports.askTemplateQuestions = async (id, settings, state) => {
160
159
  const answers = await inquirer.prompt(questions);
161
160
  return Object.assign(Object.assign({}, state), answers);
162
161
  };
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
- };
@@ -1,4 +1,11 @@
1
- declare const _default: (schema: string, name: string | undefined, source: string, preAnswered?: {
2
- [question: string]: string;
3
- }) => Promise<string>;
1
+ export declare type GenerateOptions = {
2
+ schema: string;
3
+ name?: string;
4
+ onConflict: 'overwrite' | 'append';
5
+ source: string;
6
+ preAnswered?: {
7
+ [question: string]: string;
8
+ };
9
+ };
10
+ declare const _default: ({ schema, name, onConflict, source, preAnswered, }: GenerateOptions) => Promise<string>;
4
11
  export default _default;
@@ -6,8 +6,9 @@ const core_1 = require("@oclif/core");
6
6
  const fs = require("fs-extra");
7
7
  const lodash = require("lodash");
8
8
  const path = require("path");
9
+ const transpiler = require("@stepzen/transpiler");
9
10
  const helpers_1 = require("./helpers");
10
- exports.default = async (schema, name, source, preAnswered = {}) => {
11
+ exports.default = async ({ schema, name, onConflict, source, preAnswered = {}, }) => {
11
12
  var _a, _b;
12
13
  // Store the generator
13
14
  let generator;
@@ -82,7 +83,15 @@ exports.default = async (schema, name, source, preAnswered = {}) => {
82
83
  // if (generator.type === 'template')
83
84
  files = path.join(templates, schema);
84
85
  }
85
- const output = await helpers_1.mergeFiles(name || schema, source, files, answers);
86
+ const output = await transpiler.merge(source, {
87
+ name: name || schema,
88
+ source: files,
89
+ }, {
90
+ answers,
91
+ silent: true,
92
+ output: null,
93
+ onConflict,
94
+ });
86
95
  core_1.CliUx.ux.action.stop();
87
96
  // Housekeeping
88
97
  cleanUp();
@@ -1,5 +1,19 @@
1
- export declare const clearConsole: () => void;
2
1
  export declare const getDirectory: (d?: string | undefined) => string;
2
+ /**
3
+ * Replace the path prefix with `~` if it is inside the user's home directory.
4
+ *
5
+ * @param {*} absPath an absolute file or directory path
6
+ * @returns {*} the same path that possibly looks more friendly to users
7
+ */
8
+ export declare const homeRelative: (absPath: string) => string;
9
+ /**
10
+ * Replace the path prefix with `~` if it is inside the user's home directory.
11
+ *
12
+ * @param {*} absPath an absolute file or directory path
13
+ * @param {*} workspace an absolute file or the workspace root
14
+ * @returns {*} the same path that possibly looks more friendly to users
15
+ */
16
+ export declare const workspaceRelative: (absPath: string, workspace: string) => string;
3
17
  export declare const getStepZenExtensions: () => Promise<string>;
4
18
  export declare const validateEndpoint: (endpoint: string) => any;
5
19
  export declare const maskStepZenKey: (key: string) => string;
@@ -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.maskStepZenKey = exports.validateEndpoint = exports.getStepZenExtensions = exports.getDirectory = exports.clearConsole = void 0;
4
+ exports.maskStepZenKey = exports.validateEndpoint = exports.getStepZenExtensions = exports.workspaceRelative = exports.homeRelative = exports.getDirectory = void 0;
5
5
  const errors_1 = require("@oclif/errors");
6
6
  const debug = require("debug");
7
7
  const node_fetch_1 = require("node-fetch");
@@ -10,12 +10,6 @@ const os = require("os");
10
10
  const path = require("path");
11
11
  const prettier = require("prettier");
12
12
  const constants_1 = require("./constants");
13
- exports.clearConsole = () => {
14
- process.stdout.write(
15
- // Taken from create-react-app
16
- // eslint-disable-next-line unicorn/no-hex-escape
17
- process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H');
18
- };
19
13
  exports.getDirectory = (d = process.cwd()) => {
20
14
  let directory = d;
21
15
  // If it starts with `~`, expand this
@@ -31,6 +25,33 @@ exports.getDirectory = (d = process.cwd()) => {
31
25
  }
32
26
  return directory;
33
27
  };
28
+ /**
29
+ * Replace the path prefix with `~` if it is inside the user's home directory.
30
+ *
31
+ * @param {*} absPath an absolute file or directory path
32
+ * @returns {*} the same path that possibly looks more friendly to users
33
+ */
34
+ exports.homeRelative = (absPath) => {
35
+ let pretty = absPath;
36
+ if (absPath.startsWith(os.homedir())) {
37
+ pretty = '~' + absPath.substring(os.homedir().length);
38
+ }
39
+ return pretty;
40
+ };
41
+ /**
42
+ * Replace the path prefix with `~` if it is inside the user's home directory.
43
+ *
44
+ * @param {*} absPath an absolute file or directory path
45
+ * @param {*} workspace an absolute file or the workspace root
46
+ * @returns {*} the same path that possibly looks more friendly to users
47
+ */
48
+ exports.workspaceRelative = (absPath, workspace) => {
49
+ let pretty = absPath;
50
+ if (absPath.startsWith(workspace)) {
51
+ pretty = '.' + absPath.substring(workspace.length);
52
+ }
53
+ return pretty;
54
+ };
34
55
  exports.getStepZenExtensions = async () => {
35
56
  const domain = constants_1.STEPZEN_DOMAIN.replace('.io', '.net');
36
57
  const url = `https://www.${domain}/directives.graphql`;
@@ -1,2 +1,10 @@
1
1
  import { Workspace } from './types';
2
+ export declare const validateWorkspaceName: (directory: string, name: string) => boolean;
3
+ export declare const generateWorkspaceName: (directory: string) => string;
4
+ export declare const guessSchemaRoot: (directory: string) => string;
2
5
  export declare const getWorkspace: (directory: string) => Workspace | null;
6
+ export declare const initWorkspace: (args: {
7
+ directory?: string;
8
+ endpoint?: string;
9
+ yes?: boolean;
10
+ }) => Promise<Workspace>;
@@ -1,12 +1,38 @@
1
1
  "use strict";
2
2
  // Copyright (c) 2020,2021,2022, StepZen, Inc.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.getWorkspace = void 0;
4
+ exports.initWorkspace = exports.getWorkspace = exports.guessSchemaRoot = exports.generateWorkspaceName = exports.validateWorkspaceName = void 0;
5
5
  const errors_1 = require("@oclif/errors");
6
6
  const fs = require("fs");
7
+ const glob = require("glob");
8
+ const inquirer = require("inquirer");
7
9
  const os = require("os");
8
10
  const path = require("path");
11
+ const moniker_1 = require("../shared/moniker");
9
12
  const utils_1 = require("./utils");
13
+ exports.validateWorkspaceName = (directory, name) => {
14
+ return !fs.existsSync(path.join(directory, name));
15
+ };
16
+ exports.generateWorkspaceName = (directory) => {
17
+ let name = 'hello-stepzen';
18
+ while (!exports.validateWorkspaceName(directory, name)) {
19
+ name = `hello-${moniker_1.getRandomDescriptor()}-stepzen`;
20
+ }
21
+ return name;
22
+ };
23
+ exports.guessSchemaRoot = (directory) => {
24
+ const existing = [
25
+ ...glob.sync('*/**/config.yaml', {
26
+ cwd: directory,
27
+ ignore: '**/node_modules/**',
28
+ }),
29
+ ...glob.sync('*/**/index.graphql', {
30
+ cwd: directory,
31
+ ignore: '**/node_modules/**',
32
+ }),
33
+ ];
34
+ return existing.length > 0 ? path.dirname(existing[0]) : '';
35
+ };
10
36
  exports.getWorkspace = (directory) => {
11
37
  let workspaceRoot;
12
38
  const parts = path
@@ -54,3 +80,81 @@ exports.getWorkspace = (directory) => {
54
80
  schema: schema,
55
81
  };
56
82
  };
83
+ exports.initWorkspace = async (args) => {
84
+ // Get the correct directory
85
+ let directory = utils_1.getDirectory(args.directory);
86
+ // Make sure it is not already a workspace
87
+ if (exports.getWorkspace(directory)) {
88
+ throw new errors_1.CLIError(`This directory is already a StepZen workspace: ${directory}.` +
89
+ ' Please select a different directory.');
90
+ }
91
+ const isHomeDir = directory === os.homedir();
92
+ // Prevent init from running in the home directory if the directory was
93
+ // explicitly provided as an aargument to `stepzen init`.
94
+ // StepZen CLI sometimes would enumerate all files in the workspace folder
95
+ // doing so in the home directory is likely to fail.
96
+ if (args.directory && isHomeDir) {
97
+ throw new errors_1.CLIError('Using the home directory as a StepZen workspace is not supported.' +
98
+ ' Please select a different directory.');
99
+ }
100
+ // Make a suggestion for the workspace name (if running in the HOME
101
+ // directory)
102
+ const name = isHomeDir
103
+ ? exports.generateWorkspaceName(directory)
104
+ : path.basename(directory);
105
+ // See if we think there's a StepZen schema already
106
+ const root = isHomeDir ? '' : exports.guessSchemaRoot(directory);
107
+ // If you've passed an endpoint, validate it, and throw an error
108
+ // straight away if needed
109
+ if (args.endpoint) {
110
+ const error = utils_1.validateEndpoint(args.endpoint);
111
+ if (typeof error === 'string') {
112
+ throw new errors_1.CLIError(error);
113
+ }
114
+ }
115
+ // Make a suggestion for the endpoint
116
+ const endpoint = args.endpoint || `api/${moniker_1.default()}`;
117
+ // What questions will we ask?
118
+ const questions = [
119
+ {
120
+ default: name,
121
+ message: 'What would you like to call your workspace?',
122
+ name: 'name',
123
+ validate: (name) => exports.validateWorkspaceName(directory, name),
124
+ when: isHomeDir && !args.yes,
125
+ },
126
+ {
127
+ default: endpoint,
128
+ message: 'What would you like your endpoint to be called?',
129
+ name: 'endpoint',
130
+ validate: utils_1.validateEndpoint,
131
+ when: !args.endpoint && !args.yes,
132
+ },
133
+ {
134
+ message: `We have detected a schema in this directory. Set the schema root to "${root}"?`,
135
+ name: 'use-root',
136
+ type: 'confirm',
137
+ when: Boolean(root) && !args.yes,
138
+ },
139
+ ];
140
+ // Get the answers
141
+ const answers = Object.assign({ name,
142
+ endpoint, 'use-root': true }, (await inquirer.prompt(questions)));
143
+ // Append the suggested workspace name to the directory (if running
144
+ // in the HOME directory)
145
+ if (isHomeDir) {
146
+ // eslint-disable-next-line require-atomic-updates
147
+ directory = path.join(directory, answers.name);
148
+ fs.mkdirSync(directory);
149
+ }
150
+ // Create the workspace
151
+ const workspace = { endpoint: answers.endpoint };
152
+ if (root && answers['use-root'])
153
+ workspace.root = root;
154
+ // Write the file
155
+ const file = path.join(directory, 'stepzen.config.json');
156
+ fs.writeFileSync(file, JSON.stringify(workspace, null, ' '));
157
+ // Fetch the newly created workspace
158
+ const created = exports.getWorkspace(directory);
159
+ return created;
160
+ };
@@ -1,5 +1,5 @@
1
1
  import { Command } from '@oclif/command';
2
- import { MachineConfiguration, StepZenCredentials } from './types';
2
+ import { MachineConfiguration, StepZenCredentials, Workspace } from './types';
3
3
  export declare abstract class ZenCommand extends Command {
4
4
  static flags: {
5
5
  'non-interactive': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
@@ -7,6 +7,10 @@ export declare abstract class ZenCommand extends Command {
7
7
  ensureStepZenAccount(): Promise<{
8
8
  configuration: import("./types").LoggedInMachineConfiguration;
9
9
  }>;
10
+ ensureStepZenWorkspace(options?: {
11
+ directory?: string;
12
+ endpoint?: string;
13
+ }): Promise<Workspace>;
10
14
  promptUserToLogIn(uuid: string): Promise<{
11
15
  configuration: MachineConfiguration & StepZenCredentials;
12
16
  }>;
@@ -3,10 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.ZenCommand = void 0;
5
5
  const command_1 = require("@oclif/command");
6
+ const errors_1 = require("@oclif/errors");
6
7
  const inquirer = require("inquirer");
7
8
  const chalk = require("chalk");
9
+ const process = require("process");
8
10
  const configuration_1 = require("./configuration");
9
11
  const stepzen_sdk_1 = require("./stepzen-sdk");
12
+ const utils_1 = require("./utils");
13
+ const workspace_1 = require("./workspace");
10
14
  class ZenCommand extends command_1.Command {
11
15
  async ensureStepZenAccount() {
12
16
  const configuration = await configuration_1.readConfiguration();
@@ -17,6 +21,29 @@ class ZenCommand extends command_1.Command {
17
21
  }
18
22
  return this.promptUserToLogIn(configuration.uuid);
19
23
  }
24
+ async ensureStepZenWorkspace(options = {}) {
25
+ let workspace;
26
+ const directory = utils_1.getDirectory(options.directory);
27
+ const maybeWorkspace = workspace_1.getWorkspace(directory);
28
+ if (maybeWorkspace) {
29
+ workspace = maybeWorkspace;
30
+ }
31
+ else {
32
+ try {
33
+ workspace = await workspace_1.initWorkspace({ directory, endpoint: options.endpoint });
34
+ }
35
+ catch (error) {
36
+ throw new errors_1.CLIError(`Could not create a StepZen workspace in the ${options.directory ? directory : 'current'} directory.\n` + error.message);
37
+ }
38
+ }
39
+ // Emphasize that the workspace is not the _current_ directory.
40
+ if (workspace.directory !== process.cwd()) {
41
+ this.log();
42
+ this.log(` ⤴️ Using the StepZen workspace in ${chalk.blue(utils_1.homeRelative(workspace.directory))}`);
43
+ this.log();
44
+ }
45
+ return workspace;
46
+ }
20
47
  async promptUserToLogIn(uuid) {
21
48
  this.log(chalk.bold(chalk.cyan('Welcome to the StepZen CLI!')));
22
49
  this.log('');
@@ -1,2 +1,11 @@
1
- declare const _default: (workspace: any) => Promise<void>;
2
- export default _default;
1
+ import { Workspace } from '../shared/types';
2
+ export declare const watching: (workspace: Workspace) => void;
3
+ export declare const changed: ({ file, workspace, }: {
4
+ file: string;
5
+ workspace: Workspace;
6
+ }) => void;
7
+ export declare const success: ({ workspace, account, port, }: {
8
+ workspace: Workspace;
9
+ account: string;
10
+ port: number;
11
+ }) => void;
@@ -1,16 +1,33 @@
1
1
  "use strict";
2
2
  // Copyright (c) 2020,2021,2022, StepZen, Inc.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.success = exports.changed = exports.watching = void 0;
4
5
  const chalk = require("chalk");
5
- const fs = require("fs");
6
- const os = require("os");
7
- const path = require("path");
8
- exports.default = async (workspace) => {
9
- const cwd = workspace.schema.replace(os.homedir(), '~');
10
- const config = path.join(cwd, 'config.yaml');
6
+ const utils_1 = require("../shared/utils");
7
+ const constants_1 = require("../shared/constants");
8
+ exports.watching = (workspace) => {
9
+ console.log(`Watching ${chalk.blue(utils_1.homeRelative(workspace.schema))} for changes...`);
10
+ };
11
+ exports.changed = ({ file, workspace, }) => {
12
+ console.log(`File changed: ${chalk.blue(utils_1.workspaceRelative(file, workspace.directory))}`);
13
+ };
14
+ exports.success = ({ workspace, account, port, }) => {
15
+ const domain = constants_1.STEPZEN_DOMAIN.replace('.io', '.net');
16
+ const url = `https://${account}.${domain}/${workspace.endpoint}/__graphql`;
11
17
  console.log();
12
- if (fs.existsSync(config)) {
13
- console.log(`Watching ${chalk.blue(config)} for configuration changes...`);
18
+ console.log(chalk.grey(`Your API url is`, chalk.green(` ${url}`)));
19
+ console.log();
20
+ if (process.platform === 'win32') {
21
+ console.log(chalk.grey(`You can explore your hosted API with GraphiQL at `), chalk.green(` http://localhost:${port}/${workspace.endpoint}`));
22
+ }
23
+ else {
24
+ console.log(chalk.grey(`You can test your hosted API with cURL:`));
25
+ console.log();
26
+ console.log(`curl ${url} \\`);
27
+ console.log(` --header "Authorization: Apikey $(stepzen whoami --apikey)" \\`);
28
+ console.log(` --header "Content-Type: application/json" \\`);
29
+ console.log(` --data '{"query": "your graphql query"}'`);
30
+ console.log();
31
+ console.log(chalk.grey(`or explore it with GraphiQL at`), chalk.green(` http://localhost:${port}/${workspace.endpoint}`));
14
32
  }
15
- console.log(`Watching ${chalk.blue(cwd)} for GraphQL changes...`);
16
33
  };
@@ -1,2 +1,6 @@
1
- declare const _default: (file: string | null, workspace: any, flags: any) => Promise<void>;
1
+ import { Workspace } from '../shared/types';
2
+ declare const _default: ({ workspace, flags, }: {
3
+ workspace: Workspace;
4
+ flags: Record<string, any>;
5
+ }) => Promise<void>;
2
6
  export default _default;
@@ -8,18 +8,12 @@ const fs = require("fs-extra");
8
8
  const path = require("path");
9
9
  const prettyMilliseconds = require("pretty-ms");
10
10
  const deploy_1 = require("../commands/deploy");
11
- const configuration_1 = require("../shared/configuration");
12
- const constants_1 = require("../shared/constants");
13
11
  const upload_1 = require("../commands/upload");
14
12
  const validate_1 = require("../commands/validate");
15
13
  const dotenv = require('dotenv');
16
- exports.default = async (file, workspace, flags) => {
14
+ exports.default = async ({ workspace, flags, }) => {
17
15
  var e_1, _a;
18
16
  dotenv.config({ path: path.join(workspace.directory, '.env') });
19
- if (file) {
20
- console.log(`File changed: ${chalk.blue(file)}`);
21
- }
22
- const configuration = (await configuration_1.readConfiguration());
23
17
  if (!flags['no-validate']) {
24
18
  try {
25
19
  await validate_1.default.run([workspace.schema]);
@@ -101,22 +95,4 @@ exports.default = async (file, workspace, flags) => {
101
95
  const deployEnd = new Date().getTime();
102
96
  const deployTime = deployEnd - deployStart;
103
97
  core_1.CliUx.ux.action.stop(`${chalk.grey('done in')} ${prettyMilliseconds(deployTime)} 🚀`);
104
- const domain = constants_1.STEPZEN_DOMAIN.replace('.io', '.net');
105
- const endpoint = `https://${configuration.account}.${domain}/${workspace.endpoint}/__graphql`;
106
- console.log();
107
- console.log(chalk.grey(`Your API url is`, chalk.green(` ${endpoint}`)));
108
- console.log();
109
- if (process.platform === 'win32') {
110
- console.log(chalk.grey(`You can explore your hosted API with GraphiQL at `), chalk.green(` http://localhost:${flags.port}/${workspace.endpoint}`));
111
- }
112
- else {
113
- console.log(chalk.grey(`You can test your hosted API with cURL:`));
114
- console.log();
115
- console.log(`curl ${endpoint} \\`);
116
- console.log(` --header "Authorization: Apikey $(stepzen whoami --apikey)" \\`);
117
- console.log(` --header "Content-Type: application/json" \\`);
118
- console.log(` --data '{"query": "your graphql query"}'`);
119
- console.log();
120
- console.log(chalk.grey(`or explore it with GraphiQL at`), chalk.green(` http://localhost:${flags.port}/${workspace.endpoint}`));
121
- }
122
98
  };
@@ -1,3 +1,2 @@
1
- import console from './console';
2
- import deploy from './deploy';
3
- export { console, deploy };
1
+ export { default as deploy } from './deploy';
2
+ export { changed, success, watching } from './console';
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  // Copyright (c) 2020,2021,2022, StepZen, Inc.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.deploy = exports.console = void 0;
5
- const console_1 = require("./console");
6
- exports.console = console_1.default;
7
- const deploy_1 = require("./deploy");
8
- exports.deploy = deploy_1.default;
4
+ var deploy_1 = require("./deploy");
5
+ Object.defineProperty(exports, "deploy", { enumerable: true, get: function () { return deploy_1.default; } });
6
+ var console_1 = require("./console");
7
+ Object.defineProperty(exports, "changed", { enumerable: true, get: function () { return console_1.changed; } });
8
+ Object.defineProperty(exports, "success", { enumerable: true, get: function () { return console_1.success; } });
9
+ Object.defineProperty(exports, "watching", { enumerable: true, get: function () { return console_1.watching; } });
@@ -1 +1 @@
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":[]}}}
1
+ {"version":"0.17.0-beta.1","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 to. Defaults to the name of the imported schema."},"overwrite":{"name":"overwrite","type":"boolean","description":"Overwrite any existing schema with the same name. Cannot be used without also providing a --name flag.","allowNo":false},"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-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.5",
4
+ "version": "0.17.0-beta.1",
5
5
  "license": "MIT",
6
6
  "author": "Darren Waddell <darren@stepzen.com>",
7
7
  "contributors": [
@@ -32,8 +32,8 @@
32
32
  "@oclif/errors": "1.3.5",
33
33
  "@oclif/plugin-help": "^5.1.12",
34
34
  "@stepzen/dashboard": "0.2.0",
35
- "@stepzen/sdk": "0.11.2",
36
- "@stepzen/transpiler": "0.0.39",
35
+ "@stepzen/sdk": "0.11.3",
36
+ "@stepzen/transpiler": "0.2.0",
37
37
  "chalk": "^4.1.1",
38
38
  "chokidar": "^3.5.2",
39
39
  "compare-versions": "^3.6.0",