stepzen 0.9.38-beta.2 → 0.9.38-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md 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.9.38-beta.2 darwin-x64 node-v14.18.3
32
+ stepzen/0.9.38-beta.3 darwin-x64 node-v14.18.3
33
33
  $ stepzen --help [COMMAND]
34
34
  USAGE
35
35
  $ stepzen COMMAND
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  // objects, a single schema, and a collection of configurationsets
7
7
  // and uses them to produce an endpoint which serves a GraphQL API.
8
8
  const command_1 = require("@oclif/command");
9
+ const errors_1 = require("@oclif/errors");
9
10
  const actions_1 = require("../shared/actions");
10
11
  const configuration_1 = require("../shared/configuration");
11
12
  class Deploy extends command_1.Command {
@@ -13,12 +14,12 @@ class Deploy extends command_1.Command {
13
14
  const { args, flags } = this.parse(Deploy);
14
15
  // Make sure that you definitely specify folder/name
15
16
  if (args.destination.includes('/') === false) {
16
- this.error('You must specify the folder/name you want to use');
17
+ throw new errors_1.CLIError('You must specify the folder/name you want to use');
17
18
  }
18
19
  const configuration = configuration_1.readConfiguration();
19
20
  if (!configuration) {
20
21
  // Configuration not found. Most likely because someone is not logged in. Exit with error.
21
- this.error('You are probably not logged in.');
22
+ throw new errors_1.CLIError('You are probably not logged in.');
22
23
  }
23
24
  if (!flags.silent) {
24
25
  this.log('Deploying...');
@@ -31,7 +32,7 @@ class Deploy extends command_1.Command {
31
32
  }
32
33
  else {
33
34
  // Errors. Exit, and output the server's error response
34
- this.error(JSON.stringify(response.errors) || 'An error occurred.');
35
+ throw new errors_1.CLIError(JSON.stringify(response.errors) || 'An error occurred.');
35
36
  }
36
37
  }
37
38
  }
@@ -2,6 +2,7 @@
2
2
  // Copyright (c) 2020,2021,2022, StepZen, Inc.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const command_1 = require("@oclif/command");
5
+ const errors_1 = require("@oclif/errors");
5
6
  const fs = require("fs");
6
7
  const glob = require("glob");
7
8
  const inquirer = require("inquirer");
@@ -17,12 +18,12 @@ class Init extends command_1.Command {
17
18
  // Make sure it is not already a workspace
18
19
  const w = workspace_1.getWorkspace(directory);
19
20
  if (w)
20
- this.error('This is already a workspace, cannot init');
21
+ throw new errors_1.CLIError('This is already a workspace, cannot init');
21
22
  // If you've passed an endpoint, validate it, and throw an error straight away if needed
22
23
  if (flags.endpoint) {
23
24
  const error = utils_1.validateEndpoint(flags.endpoint);
24
25
  if (typeof error === 'string')
25
- this.error(error);
26
+ throw new errors_1.CLIError(error);
26
27
  }
27
28
  // Make a suggestion for the endpoint
28
29
  const endpoint = flags.endpoint || `api/${moniker_1.default()}`;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  // of resources stored within a stepzen account.
7
7
  // You can use list to retrieve configurationsets and schemas.
8
8
  const command_1 = require("@oclif/command");
9
+ const errors_1 = require("@oclif/errors");
9
10
  const actions_1 = require("../shared/actions");
10
11
  const configuration_1 = require("../shared/configuration");
11
12
  class List extends command_1.Command {
@@ -15,7 +16,7 @@ class List extends command_1.Command {
15
16
  const configuration = configuration_1.readConfiguration();
16
17
  if (!configuration) {
17
18
  // Configuration not found. Most likely because someone is not logged in. Exit with error.
18
- this.error('You are probably not logged in.');
19
+ throw new errors_1.CLIError('You are probably not logged in.');
19
20
  }
20
21
  const response = await actions_1.list(args.type);
21
22
  if (response.success) {
@@ -30,7 +31,7 @@ class List extends command_1.Command {
30
31
  }
31
32
  else {
32
33
  // Error. Exit, and output the server's error response
33
- this.error(JSON.stringify(response.errors) || 'An error occurred.');
34
+ throw new errors_1.CLIError(JSON.stringify(response.errors) || 'An error occurred.');
34
35
  }
35
36
  }
36
37
  }
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
5
5
  // Stepzen login checks that credentials presented are good and
6
6
  // subsequently changes the identity of the logged in account.
7
7
  const command_1 = require("@oclif/command");
8
+ const errors_1 = require("@oclif/errors");
8
9
  const cli_ux_1 = require("cli-ux");
9
10
  const configuration_1 = require("../shared/configuration");
10
11
  class Login extends command_1.Command {
@@ -45,7 +46,7 @@ class Login extends command_1.Command {
45
46
  const isValidConfiguration = await configuration_1.verifyConfiguration(configuration);
46
47
  if (!isValidConfiguration) {
47
48
  // Exit, with error
48
- this.error('We are unable to verify your account details. Could you please check them?');
49
+ throw new errors_1.CLIError('We are unable to verify your account details. Could you please check them?');
49
50
  }
50
51
  // Change the default account.
51
52
  configuration_1.writeConfigurationToLoginFile(configuration);
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const chokidar = require("chokidar");
5
5
  const cli_ux_1 = require("cli-ux");
6
6
  const command_1 = require("@oclif/command");
7
+ const errors_1 = require("@oclif/errors");
7
8
  const throttle_debounce_1 = require("throttle-debounce");
8
9
  const detect = require("detect-port");
9
10
  const configuration_1 = require("../shared/configuration");
@@ -21,7 +22,7 @@ class Start extends command_1.Command {
21
22
  const configuration = configuration_1.readConfiguration();
22
23
  if (!configuration) {
23
24
  // Configuration not found. Most likely because someone is not logged in. Exit with error.
24
- this.error('You are probably not logged in.');
25
+ throw new errors_1.CLIError('You are probably not logged in.');
25
26
  }
26
27
  // Get the working directory and workspace
27
28
  const directory = utils_1.getDirectory(flags.dir);
@@ -41,7 +42,7 @@ class Start extends command_1.Command {
41
42
  // Check the port is available
42
43
  const port = await detect(flags.port);
43
44
  if (flags.port !== port) {
44
- this.error(`Could not start - port ${flags.port} is already in use`);
45
+ throw new errors_1.CLIError(`Could not start - port ${flags.port} is already in use`);
45
46
  }
46
47
  // This is the file watcher
47
48
  if (!flags['no-watcher']) {
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const chalk = require("chalk");
5
5
  const command_1 = require("@oclif/command");
6
+ const errors_1 = require("@oclif/errors");
6
7
  const fs = require("fs-extra");
7
8
  const path = require("path");
8
9
  const utils_1 = require("../shared/utils");
@@ -31,7 +32,7 @@ class Transpile extends command_1.Command {
31
32
  this.log(stitched);
32
33
  }
33
34
  catch (error) {
34
- this.error(chalk.red(error));
35
+ throw new errors_1.CLIError(chalk.red(error));
35
36
  }
36
37
  }
37
38
  }
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  // When uploaded, each resource is stored and referenced using a name
11
11
  // provided by the user.
12
12
  const command_1 = require("@oclif/command");
13
+ const errors_1 = require("@oclif/errors");
13
14
  const configuration_1 = require("../shared/configuration");
14
15
  const actions_1 = require("../shared/actions");
15
16
  class Upload extends command_1.Command {
@@ -17,16 +18,16 @@ class Upload extends command_1.Command {
17
18
  const { args, flags } = this.parse(Upload);
18
19
  // Make sure that you definitely specify folder/name
19
20
  if (args.destination.includes('/') === false) {
20
- this.error('You must specify the folder/name you want to use');
21
+ throw new errors_1.CLIError('You must specify the folder/name you want to use');
21
22
  }
22
23
  const configuration = configuration_1.readConfiguration();
23
24
  if (!configuration) {
24
25
  // Configuration not found. Most likely because someone is not logged in. Exit with error.
25
- this.error('You are probably not logged in.');
26
+ throw new errors_1.CLIError('You are probably not logged in.');
26
27
  }
27
28
  if (!flags.file && !flags.dir) {
28
29
  // You need to specify a file or directory. Exit with error.
29
- this.error('You must specify a file or directory.');
30
+ throw new errors_1.CLIError('You must specify a file or directory.');
30
31
  }
31
32
  if (!flags.silent) {
32
33
  this.log('Uploading...');
@@ -39,7 +40,7 @@ class Upload extends command_1.Command {
39
40
  }
40
41
  else {
41
42
  // Errors. Exit, and output the server's error response
42
- this.error(JSON.stringify(response.errors) || 'An error occurred.');
43
+ throw new errors_1.CLIError(JSON.stringify(response.errors) || 'An error occurred.');
43
44
  }
44
45
  }
45
46
  }
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const chalk = require("chalk");
5
5
  const command_1 = require("@oclif/command");
6
+ const errors_1 = require("@oclif/errors");
6
7
  const utils_1 = require("../shared/utils");
7
8
  const { stitch, validate } = require('@stepzen/transpiler');
8
9
  class Validate extends command_1.Command {
@@ -16,7 +17,7 @@ class Validate extends command_1.Command {
16
17
  });
17
18
  }
18
19
  catch (error) {
19
- this.error(chalk.red(error));
20
+ throw new errors_1.CLIError(chalk.red(error));
20
21
  }
21
22
  }
22
23
  }
@@ -1,5 +1,12 @@
1
+ import type { QuestionCollection, Answers } from 'inquirer';
1
2
  export declare const createGeneratorFiles: (id: string, details: any) => Promise<string>;
2
- export declare const getConfiguration: (id: string, details?: any) => Promise<any>;
3
+ export declare type GeneratorConfiguration = {
4
+ questions: QuestionCollection;
5
+ answers: Answers;
6
+ errors: Record<string, any>;
7
+ status: number;
8
+ };
9
+ export declare const getConfiguration: (id: string, details?: any) => Promise<GeneratorConfiguration | null>;
3
10
  export declare const getSchemaList: (arg: string) => string[];
4
11
  export declare const getTemplates: () => Promise<string>;
5
12
  export declare const askGeneratorQuestions: (id: string, settings: any, state: any) => Promise<any>;
@@ -2,6 +2,9 @@
2
2
  // Copyright (c) 2020,2021,2022, StepZen, Inc.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.askTemplateQuestions = exports.askGeneratorQuestions = exports.getTemplates = exports.getSchemaList = exports.getConfiguration = exports.createGeneratorFiles = void 0;
5
+ const errors_1 = require("@oclif/errors");
6
+ const chalk = require("chalk");
7
+ const debug = require("debug");
5
8
  const node_fetch_1 = require("node-fetch");
6
9
  const fs = require("fs-extra");
7
10
  const inquirer = require("inquirer");
@@ -11,6 +14,7 @@ const path = require("path");
11
14
  const shell = require("shelljs");
12
15
  const configuration_1 = require("../shared/configuration");
13
16
  const constants_1 = require("../shared/constants");
17
+ const errors_2 = require("../shared/errors");
14
18
  const { version } = require('../../package.json');
15
19
  exports.createGeneratorFiles = async (id, details) => {
16
20
  const config = configuration_1.readConfiguration();
@@ -35,10 +39,13 @@ exports.createGeneratorFiles = async (id, details) => {
35
39
  },
36
40
  method: 'POST',
37
41
  });
38
- const { data: { create }, } = await response.json();
42
+ const { data, errors } = await response.json();
43
+ if (errors) {
44
+ throw new errors_1.CLIError(errors_2.formatTemporaryErrorMessage(errors));
45
+ }
39
46
  const tmp = path.join(os.tmpdir(), `stepzen-generated-schema-${Date.now()}`);
40
47
  fs.ensureDirSync(tmp);
41
- for (const file of create) {
48
+ for (const file of data.create) {
42
49
  const dir = path.join(tmp, file.name);
43
50
  fs.writeFileSync(dir, file.content);
44
51
  }
@@ -69,8 +76,29 @@ exports.getConfiguration = async (id, details = {}) => {
69
76
  },
70
77
  method: 'POST',
71
78
  });
72
- const { data } = await response.json();
73
- return data;
79
+ const { data, errors } = await response.json();
80
+ if (errors) {
81
+ return {
82
+ questions: [],
83
+ answers: {},
84
+ status: -1,
85
+ errors: {
86
+ error: errors[0].message,
87
+ },
88
+ };
89
+ }
90
+ try {
91
+ if (data.configure) {
92
+ data.configure.answers = JSON.parse(data.configure.answers);
93
+ data.configure.errors = JSON.parse(data.configure.errors);
94
+ data.configure.questions = JSON.parse(data.configure.questions);
95
+ }
96
+ }
97
+ catch (error) {
98
+ debug('stepzen:response')(error);
99
+ throw new errors_1.CLIError(errors_2.PERMANENT_STEPZEN_ERROR);
100
+ }
101
+ return data.configure;
74
102
  };
75
103
  exports.getSchemaList = (arg) => {
76
104
  const schemas = arg.split(',').map((schema) => schema.trim());
@@ -78,7 +106,7 @@ exports.getSchemaList = (arg) => {
78
106
  for (const schema of schemas) {
79
107
  const instances = schemas.filter((s) => s === schema);
80
108
  if (instances.length > 1) {
81
- throw new Error(`You are trying to import "${schema}" more than once`);
109
+ throw new errors_1.CLIError(`You are trying to import "${schema}" more than once`);
82
110
  }
83
111
  }
84
112
  return schemas.map(schema => {
@@ -97,23 +125,44 @@ exports.getTemplates = async () => {
97
125
  const command = `git clone ${repository} ${tmp}`;
98
126
  const result = shell.exec(command, { silent: true });
99
127
  if (result.code !== 0) {
100
- throw new Error(result.stderr.trim());
128
+ throw new errors_1.CLIError(result.stderr.trim());
101
129
  }
102
130
  return tmp;
103
131
  };
104
132
  exports.askGeneratorQuestions = async (id, settings, state) => {
133
+ var _a, _b;
105
134
  let status = -1;
106
135
  do {
107
- const questions = settings.questions.map((question) => (Object.assign({ type: 'password' }, question)));
136
+ if (settings.questions.length === 0) {
137
+ // would cause a hot loop, so it's an error
138
+ throw new errors_1.CLIError(errors_2.PERMANENT_STEPZEN_ERROR);
139
+ }
140
+ const questions = settings.questions.map((question) => (Object.assign(Object.assign({ type: 'password' }, question), {
141
+ // set the previous iteration's answer as the default value, except for password fields
142
+ default: question.type && question.type !== 'password'
143
+ ? lodash_1.get(state, question.name)
144
+ : undefined })));
108
145
  // eslint-disable-next-line no-await-in-loop
109
146
  const answers = await inquirer.prompt(questions);
110
147
  state = lodash_1.merge(state, answers);
111
148
  // eslint-disable-next-line no-await-in-loop
112
- const { configure: result } = await exports.getConfiguration(id, state);
113
- settings = {
114
- questions: JSON.parse(result.questions),
115
- };
116
- state = lodash_1.merge(state, JSON.parse(result.answers));
149
+ const result = await exports.getConfiguration(id, state);
150
+ if (!result) {
151
+ // at this point the generator ${id} should have been validated
152
+ throw new errors_1.CLIError(errors_2.PERMANENT_STEPZEN_ERROR);
153
+ }
154
+ if (result.status === -1) {
155
+ console.log();
156
+ console.log(chalk.red(`A problem occurred when running a ${id} import${((_a = result.errors) === null || _a === void 0 ? void 0 : _a.error) ? `: "${(_b = result.errors) === null || _b === void 0 ? void 0 : _b.error}"` : '.'}`));
157
+ console.log('Please try again');
158
+ }
159
+ else {
160
+ settings = {
161
+ questions: result.questions,
162
+ };
163
+ // eslint-disable-next-line require-atomic-updates
164
+ state = lodash_1.merge(state, result.answers);
165
+ }
117
166
  status = result.status;
118
167
  } while (status === -1);
119
168
  return state;
@@ -2,6 +2,7 @@
2
2
  // Copyright (c) 2020,2021,2022, StepZen, Inc.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const tslib_1 = require("tslib");
5
+ const errors_1 = require("@oclif/errors");
5
6
  const cli_ux_1 = require("cli-ux");
6
7
  const fs = require("fs-extra");
7
8
  const lodash = require("lodash");
@@ -25,10 +26,10 @@ exports.default = async (schemas, source) => {
25
26
  // Get all generators from...Generators
26
27
  for (var _f = tslib_1.__asyncValues(Object.keys(generators)), _g; _g = await _f.next(), !_g.done;) {
27
28
  const id = _g.value;
28
- const { configure } = await helpers_1.getConfiguration(id, {});
29
+ const configure = await helpers_1.getConfiguration(id, {});
29
30
  if (configure) {
30
31
  generators[id] = {
31
- questions: JSON.parse(configure.questions),
32
+ questions: configure.questions,
32
33
  type: 'generator',
33
34
  };
34
35
  }
@@ -79,7 +80,7 @@ exports.default = async (schemas, source) => {
79
80
  .filter(i => i);
80
81
  if (notFound.length > 0) {
81
82
  fs.removeSync(templates);
82
- throw new Error(`Cannot find the schema ${notFound[0]}`);
83
+ throw new errors_1.CLIError(`Cannot find the schema ${notFound[0]}`);
83
84
  }
84
85
  try {
85
86
  // Ask all the questions
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.writeConfigurationToLoginFile = exports.verifyConfiguration = exports.removeConfigurationFromLoginFile = exports.importConfiguration = exports.readConfiguration = void 0;
5
5
  // This file contains methods for managing configuration
6
+ const errors_1 = require("@oclif/errors");
6
7
  const debug = require("debug");
7
8
  const node_fetch_1 = require("node-fetch");
8
9
  const fs = require("fs");
@@ -32,7 +33,7 @@ exports.readConfiguration = () => {
32
33
  };
33
34
  exports.importConfiguration = (filepath) => {
34
35
  if (!fs.existsSync(filepath)) {
35
- throw new Error('Configuration file does not exist');
36
+ throw new errors_1.CLIError('Configuration file does not exist');
36
37
  }
37
38
  const configuration = fs.readFileSync(filepath, 'utf8');
38
39
  try {
@@ -41,7 +42,7 @@ exports.importConfiguration = (filepath) => {
41
42
  return parsed;
42
43
  }
43
44
  catch (_a) {
44
- throw new Error('Configuration file is not valid yaml');
45
+ throw new errors_1.CLIError('Configuration file is not valid yaml');
45
46
  }
46
47
  };
47
48
  exports.removeConfigurationFromLoginFile = () => {
@@ -0,0 +1,4 @@
1
+ export declare const formatTemporaryErrorMessage: (errors: ReadonlyArray<{
2
+ message?: string;
3
+ }>) => string;
4
+ export declare const PERMANENT_STEPZEN_ERROR: string;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ // Copyright (c) 2020,2021,2022, StepZen, Inc.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.PERMANENT_STEPZEN_ERROR = exports.formatTemporaryErrorMessage = void 0;
5
+ exports.formatTemporaryErrorMessage = (errors) => `A problem occurred while processing your import${errors.length > 0 && errors[0].message ? `: "${errors[0].message}"` : ''}. Please try again.` +
6
+ ` If the issue persists, make sure you are on the latest version of StepZen ` +
7
+ `CLI. And if the issue still persists contact support via the StepZen discord ` +
8
+ `channel (https://discord.gg/9k2VdPn2FR).`;
9
+ exports.PERMANENT_STEPZEN_ERROR = 'An unexpected problem occurred while processing your import.' +
10
+ ` If the issue persists, make sure you are on the latest version of StepZen ` +
11
+ `CLI. And if the issue still persists contact support via the StepZen discord ` +
12
+ `channel (https://discord.gg/9k2VdPn2FR).`;
@@ -2,6 +2,7 @@
2
2
  // Copyright (c) 2020,2021,2022, StepZen, Inc.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.validateEndpoint = exports.getStepZenExtensions = exports.getDirectory = exports.ensureApiKey = exports.clearConsole = exports.checkAuth = void 0;
5
+ const errors_1 = require("@oclif/errors");
5
6
  const chalk = require("chalk");
6
7
  const debug = require("debug");
7
8
  const node_fetch_1 = require("node-fetch");
@@ -77,7 +78,7 @@ exports.getDirectory = (d = process.cwd()) => {
77
78
  directory = path.resolve(directory);
78
79
  // If the path does not exist, throw an error
79
80
  if (!fs.existsSync(directory)) {
80
- throw new Error(`Cannot find ${directory}`);
81
+ throw new errors_1.CLIError(`Cannot find ${directory}`);
81
82
  }
82
83
  return directory;
83
84
  };
@@ -2,16 +2,17 @@
2
2
  // Copyright (c) 2020,2021,2022, StepZen, Inc.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.validateSchema = exports.validateConfigurationset = void 0;
5
+ const errors_1 = require("@oclif/errors");
5
6
  const fs = require("fs");
6
7
  const glob = require("glob");
7
8
  const yaml = require("yaml");
8
9
  // Validate the Configurationset file
9
10
  exports.validateConfigurationset = async (file) => {
10
11
  if (!file) {
11
- throw new Error('You must provide a file path');
12
+ throw new errors_1.CLIError('You must provide a file path');
12
13
  }
13
14
  if (!fs.existsSync(file)) {
14
- throw new Error('The file does not exist');
15
+ throw new errors_1.CLIError('The file does not exist');
15
16
  }
16
17
  const content = fs.readFileSync(file, 'utf8');
17
18
  // Ensure the file is valid YAML
@@ -19,20 +20,20 @@ exports.validateConfigurationset = async (file) => {
19
20
  yaml.parse(content);
20
21
  }
21
22
  catch (_a) {
22
- throw new Error('The file is not valid YAML');
23
+ throw new errors_1.CLIError('The file is not valid YAML');
23
24
  }
24
25
  };
25
26
  // Validate the Schema directory
26
27
  exports.validateSchema = async (directory) => {
27
28
  if (!directory) {
28
- throw new Error('You must provide a directory path');
29
+ throw new errors_1.CLIError('You must provide a directory path');
29
30
  }
30
31
  if (!fs.existsSync(directory)) {
31
- throw new Error('The directory does not exist');
32
+ throw new errors_1.CLIError('The directory does not exist');
32
33
  }
33
34
  // Ensure there's a root `index.graphql` file
34
35
  const allSchemaFiles = glob.sync('index.graphql', { cwd: directory });
35
36
  if (allSchemaFiles.length === 0) {
36
- throw new Error('Schemas must include an `index.graphql` file');
37
+ throw new errors_1.CLIError('Schemas must include an `index.graphql` file');
37
38
  }
38
39
  };
@@ -2,6 +2,7 @@
2
2
  // Copyright (c) 2020,2021,2022, StepZen, Inc.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.getWorkspace = void 0;
5
+ const errors_1 = require("@oclif/errors");
5
6
  const fs = require("fs");
6
7
  const path = require("path");
7
8
  const utils_1 = require("./utils");
@@ -32,7 +33,7 @@ exports.getWorkspace = (directory) => {
32
33
  workspace = Object.assign(Object.assign({}, workspace), config);
33
34
  }
34
35
  catch (_a) {
35
- throw new Error(`Cannot parse configuration from ${filepath}`);
36
+ throw new errors_1.CLIError(`Cannot parse configuration from ${filepath}`);
36
37
  }
37
38
  }
38
39
  // Add the 'schema' property, which is the directory + the 'root'
@@ -41,10 +42,10 @@ exports.getWorkspace = (directory) => {
41
42
  if (workspace.directory) {
42
43
  const error = utils_1.validateEndpoint(workspace.endpoint);
43
44
  if (typeof error === 'string')
44
- throw new Error(error);
45
+ throw new errors_1.CLIError(error);
45
46
  const schemaExists = fs.existsSync(workspace.schema);
46
47
  if (!schemaExists)
47
- throw new Error(`Cannot find workspace schema folder ${workspace.schema}`);
48
+ throw new errors_1.CLIError(`Cannot find workspace schema folder ${workspace.schema}`);
48
49
  return workspace;
49
50
  }
50
51
  // This is not a workspace folder
@@ -1 +1 @@
1
- {"version":"0.9.38-beta.2","commands":{"deploy":{"id":"deploy","description":"deploy to stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"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 schemas from stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"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}},"args":[{"name":"schemas","required":true}]},"init":{"id":"init","description":"stepzen init","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"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":{"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":{"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":{"account":{"name":"account","type":"option","char":"a","hidden":true},"adminkey":{"name":"adminkey","type":"option","char":"k","hidden":true},"config":{"name":"config","type":"option","hidden":true},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"logout":{"id":"logout","description":"log out of stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"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":{"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":{"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":{"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":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"folder","required":true}]},"whoami":{"id":"whoami","description":"stepzen whoami","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"showkeys":{"name":"showkeys","type":"boolean","allowNo":false}},"args":[]}}}
1
+ {"version":"0.9.38-beta.3","commands":{"deploy":{"id":"deploy","description":"deploy to stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"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 schemas from stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"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}},"args":[{"name":"schemas","required":true}]},"init":{"id":"init","description":"stepzen init","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"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":{"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":{"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":{"account":{"name":"account","type":"option","char":"a","hidden":true},"adminkey":{"name":"adminkey","type":"option","char":"k","hidden":true},"config":{"name":"config","type":"option","hidden":true},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"logout":{"id":"logout","description":"log out of stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"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":{"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":{"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":{"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":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"folder","required":true}]},"whoami":{"id":"whoami","description":"stepzen whoami","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"showkeys":{"name":"showkeys","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.9.38-beta.2",
4
+ "version": "0.9.38-beta.3",
5
5
  "license": "MIT",
6
6
  "author": "Darren Waddell <darren@stepzen.com>",
7
7
  "contributors": [
@@ -28,6 +28,7 @@
28
28
  "dependencies": {
29
29
  "@oclif/command": "^1.8.0",
30
30
  "@oclif/config": "^1.17.1",
31
+ "@oclif/errors": "1.3.5",
31
32
  "@oclif/plugin-help": "^5.1.10",
32
33
  "@stepzen/dashboard": "0.1.36",
33
34
  "@stepzen/sdk": "0.9.42",