stepzen 0.10.0-beta.4 → 0.11.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/commands/import.js +4 -3
- package/lib/hooks/prerun/check-upgrade.d.ts +6 -0
- package/lib/hooks/prerun/check-upgrade.js +71 -12
- package/lib/shared/constants.d.ts +1 -0
- package/lib/shared/constants.js +2 -1
- package/lib/shared/errors.d.ts +1 -0
- package/lib/shared/errors.js +5 -1
- package/lib/start/deploy.js +13 -8
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ $ npm install -g stepzen
|
|
|
29
29
|
$ stepzen COMMAND
|
|
30
30
|
running command...
|
|
31
31
|
$ stepzen (-v|--version|version)
|
|
32
|
-
stepzen/0.
|
|
32
|
+
stepzen/0.11.0-beta.0 darwin-x64 node-v14.18.3
|
|
33
33
|
$ stepzen --help [COMMAND]
|
|
34
34
|
USAGE
|
|
35
35
|
$ stepzen COMMAND
|
package/lib/commands/import.js
CHANGED
|
@@ -44,9 +44,10 @@ class Import extends command_1.Command {
|
|
|
44
44
|
throw new errors_1.CLIError('Please append the full cURL command, e.g. ' +
|
|
45
45
|
chalk.bold(`${this.config.name} import curl https://test.stepzen.net/version`));
|
|
46
46
|
}
|
|
47
|
-
this.log(chalk.yellow(`NOTE: ${chalk.bold('stepzen import curl')} is
|
|
48
|
-
this.log(chalk.yellow('If you
|
|
49
|
-
'latest version
|
|
47
|
+
this.log(chalk.yellow(`NOTE: ${chalk.bold('stepzen import curl')} is a ${chalk.bold('new')} feature.`));
|
|
48
|
+
this.log(chalk.yellow('If you have any issues, please check if they have been addressed ' +
|
|
49
|
+
'in the latest version, or reach out to StepZen on Discord: ' +
|
|
50
|
+
'https://discord.gg/9k2VdPn2FR'));
|
|
50
51
|
// LATER: introduce a generic graphqlize() API taking in schema as the first arg
|
|
51
52
|
argv.shift(); // remove 'curl' and pass everything else further
|
|
52
53
|
cli_ux_1.cli.action.start('Starting');
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { Hook } from '@oclif/config';
|
|
2
|
+
export declare const compareMajorVersions: (v1: string, v2: string) => number | string;
|
|
3
|
+
export declare const shouldCheckVersion: (version: string) => boolean;
|
|
4
|
+
export declare const checkUpgrade: (version: string) => Promise<{
|
|
5
|
+
message?: string;
|
|
6
|
+
isBlocking: boolean;
|
|
7
|
+
}>;
|
|
2
8
|
declare const hook: Hook<'prerun'>;
|
|
3
9
|
export default hook;
|
|
@@ -1,19 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.checkUpgrade = exports.shouldCheckVersion = exports.compareMajorVersions = void 0;
|
|
4
5
|
const chalk = require("chalk");
|
|
5
6
|
const compareVersions = require("compare-versions");
|
|
6
|
-
const
|
|
7
|
+
const fs = require("fs-extra");
|
|
8
|
+
const debug_1 = require("debug");
|
|
9
|
+
const node_fetch_1 = require("node-fetch");
|
|
10
|
+
const constants_1 = require("../../shared/constants");
|
|
11
|
+
const errors_1 = require("../../shared/errors");
|
|
7
12
|
const { version } = require('../../../package.json');
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
const majorRegexp = /\d+\./;
|
|
14
|
+
const timeoutBeta = 1000 * 60 * 60 * 24; // one day
|
|
15
|
+
const timeoutStable = 7 * timeoutBeta; // one week
|
|
16
|
+
exports.compareMajorVersions = (v1, v2) => {
|
|
17
|
+
const v1Major = v1.match(majorRegexp);
|
|
18
|
+
const v2Major = v2.match(majorRegexp);
|
|
19
|
+
if (!v1Major || !v2Major) {
|
|
20
|
+
return ('Cannot get the major from the version string ' +
|
|
21
|
+
`'${v1Major ? v2 : v1}'. Does it follow semver?`);
|
|
22
|
+
}
|
|
23
|
+
return parseInt(v1Major[0], 10) - parseInt(v2Major[0], 10);
|
|
24
|
+
};
|
|
25
|
+
exports.shouldCheckVersion = (version) => {
|
|
26
|
+
if (!fs.existsSync(constants_1.STEPZEN_LAST_UPDATE_CHECK_TIMESTAMP)) {
|
|
27
|
+
// always check for a new version if the file does not exist
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
const { mtime } = fs.statSync(constants_1.STEPZEN_LAST_UPDATE_CHECK_TIMESTAMP);
|
|
31
|
+
const threshold = version.includes('beta') ? timeoutBeta : timeoutStable;
|
|
32
|
+
return new Date().getTime() - mtime.getTime() > threshold;
|
|
33
|
+
};
|
|
34
|
+
exports.checkUpgrade = async (version) => {
|
|
35
|
+
if (!exports.shouldCheckVersion(version)) {
|
|
36
|
+
return { message: undefined, isBlocking: false };
|
|
37
|
+
}
|
|
38
|
+
let versions;
|
|
39
|
+
try {
|
|
40
|
+
const pkgmeta = await node_fetch_1.default('https://registry.npmjs.org/stepzen').then(r => r.json());
|
|
41
|
+
versions = pkgmeta['dist-tags'];
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
// cannot connect to npm -> proceed
|
|
45
|
+
debug_1.default('stepzen:check-upgrade')('failed to get the stepzen version info from npm', error);
|
|
46
|
+
return { message: undefined, isBlocking: false };
|
|
11
47
|
}
|
|
12
|
-
const npm = shell.exec('npm view stepzen dist-tags --json', { silent: true });
|
|
13
|
-
const versions = JSON.parse(npm);
|
|
14
48
|
let beta = false;
|
|
15
49
|
let latest = versions.latest;
|
|
16
|
-
|
|
50
|
+
const result = {
|
|
51
|
+
message: undefined,
|
|
52
|
+
isBlocking: false,
|
|
53
|
+
};
|
|
17
54
|
if (version.includes('beta')) {
|
|
18
55
|
beta = true;
|
|
19
56
|
latest = versions.beta;
|
|
@@ -22,23 +59,45 @@ const hook = async function () {
|
|
|
22
59
|
if (upgradeable === -1) {
|
|
23
60
|
const diff = `${chalk.grey(version)} => ${latest}`;
|
|
24
61
|
if (beta) {
|
|
25
|
-
|
|
62
|
+
result.message = `${chalk.yellow('An upgrade to the beta channel is available:')}
|
|
26
63
|
${diff}
|
|
27
64
|
${chalk.green('npm install -g stepzen@beta')}
|
|
28
65
|
`;
|
|
29
66
|
}
|
|
30
67
|
else {
|
|
31
|
-
|
|
68
|
+
result.message = `${chalk.yellow('An upgrade to StepZen CLI is available:')}
|
|
32
69
|
${diff}
|
|
33
70
|
${chalk.green('npm install -g stepzen')}
|
|
34
71
|
`;
|
|
35
72
|
}
|
|
73
|
+
const versionCmpLatest = exports.compareMajorVersions(version, latest);
|
|
74
|
+
if (typeof versionCmpLatest === 'string') {
|
|
75
|
+
debug_1.default('stepzen:check-upgrade')(versionCmpLatest);
|
|
76
|
+
result.message = errors_1.UPGRADE_CHECK_ERROR;
|
|
77
|
+
result.isBlocking = true;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
result.isBlocking = versionCmpLatest < 0;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
// update the modification time on the file
|
|
85
|
+
fs.writeFileSync(constants_1.STEPZEN_LAST_UPDATE_CHECK_TIMESTAMP, '');
|
|
86
|
+
}
|
|
87
|
+
catch (_a) {
|
|
88
|
+
// ignore
|
|
36
89
|
}
|
|
37
|
-
|
|
90
|
+
return result;
|
|
91
|
+
};
|
|
92
|
+
const hook = async function () {
|
|
93
|
+
const { message, isBlocking } = await exports.checkUpgrade(version);
|
|
94
|
+
if (message) {
|
|
38
95
|
this.log('');
|
|
39
|
-
this.log(
|
|
96
|
+
this.log(message.trim());
|
|
40
97
|
this.log('');
|
|
41
|
-
|
|
98
|
+
if (isBlocking) {
|
|
99
|
+
this.exit(1);
|
|
100
|
+
}
|
|
42
101
|
}
|
|
43
102
|
};
|
|
44
103
|
exports.default = hook;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const STEPZEN_CONFIG_DIRECTORY: string;
|
|
2
|
+
export declare const STEPZEN_LAST_UPDATE_CHECK_TIMESTAMP: string;
|
|
2
3
|
export declare const STEPZEN_CONFIG_FILE: string;
|
|
3
4
|
export declare const STEPZEN_DOMAIN: string;
|
|
4
5
|
export declare const STEPZEN_SERVER_URL: string;
|
package/lib/shared/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.STEPZEN_JSON2SDL_SERVER_URL = exports.ADMIN_VERIFY_URL = exports.ADMIN_UPLOAD_URL = exports.ADMIN_LIST_URL = exports.ADMIN_DEPLOY_URL = exports.STEPZEN_API_TEMPLATES_REPOSITORY = exports.STEPZEN_GENERATOR_ENGINES_ENDPOINT = exports.STEPZEN_GENERATOR_ENGINES_SCHEMA = exports.STEPZEN_SERVER_URL = exports.STEPZEN_DOMAIN = exports.STEPZEN_CONFIG_FILE = exports.STEPZEN_CONFIG_DIRECTORY = void 0;
|
|
4
|
+
exports.STEPZEN_JSON2SDL_SERVER_URL = exports.ADMIN_VERIFY_URL = exports.ADMIN_UPLOAD_URL = exports.ADMIN_LIST_URL = exports.ADMIN_DEPLOY_URL = exports.STEPZEN_API_TEMPLATES_REPOSITORY = exports.STEPZEN_GENERATOR_ENGINES_ENDPOINT = exports.STEPZEN_GENERATOR_ENGINES_SCHEMA = exports.STEPZEN_SERVER_URL = exports.STEPZEN_DOMAIN = exports.STEPZEN_CONFIG_FILE = exports.STEPZEN_LAST_UPDATE_CHECK_TIMESTAMP = exports.STEPZEN_CONFIG_DIRECTORY = void 0;
|
|
5
5
|
// This file contains constants and all magic strings
|
|
6
6
|
const dotenv = require("dotenv");
|
|
7
7
|
const os = require("os");
|
|
@@ -12,6 +12,7 @@ dotenv.config();
|
|
|
12
12
|
const { STEPZEN_CONFIG_FILE: ENV_VAR_STEPZEN_CONFIG_FILE, STEPZEN_DOMAIN: ENV_VAR_STEPZEN_DOMAIN, STEPZEN_GENERATOR_ENGINES_SCHEMA: ENV_VAR_STEPZEN_GENERATOR_ENGINES_SCHEMA, STEPZEN_SERVER_URL: ENV_VAR_STEPZEN_SERVER_URL, STEPZEN_JSON2SDL_SERVER_URL: ENV_VAR_STEPZEN_JSON2SDL_SERVER_URL, } = process.env;
|
|
13
13
|
// Where your authentication details are stored locally
|
|
14
14
|
exports.STEPZEN_CONFIG_DIRECTORY = path.join(os.homedir(), '.stepzen');
|
|
15
|
+
exports.STEPZEN_LAST_UPDATE_CHECK_TIMESTAMP = path.join(exports.STEPZEN_CONFIG_DIRECTORY, 'last_update_check.timestamp');
|
|
15
16
|
exports.STEPZEN_CONFIG_FILE = ENV_VAR_STEPZEN_CONFIG_FILE || 'stepzen-config.yaml';
|
|
16
17
|
// The zenctl domain. Override with the env var `STEPZEN_DOMAIN`
|
|
17
18
|
exports.STEPZEN_DOMAIN = ENV_VAR_STEPZEN_DOMAIN || 'stepzen.io';
|
package/lib/shared/errors.d.ts
CHANGED
package/lib/shared/errors.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.PERMANENT_STEPZEN_ERROR = exports.formatTemporaryErrorMessage = void 0;
|
|
4
|
+
exports.UPGRADE_CHECK_ERROR = exports.PERMANENT_STEPZEN_ERROR = exports.formatTemporaryErrorMessage = void 0;
|
|
5
5
|
exports.formatTemporaryErrorMessage = (errors) => `A problem occurred while processing your import${errors.length > 0 && errors[0].message ? `: "${errors[0].message}"` : ''}. Please try again.` +
|
|
6
6
|
` If the issue persists, make sure you are on the latest version of StepZen ` +
|
|
7
7
|
`CLI. And if the issue still persists contact support via the StepZen discord ` +
|
|
@@ -10,3 +10,7 @@ exports.PERMANENT_STEPZEN_ERROR = 'An unexpected problem occurred while processi
|
|
|
10
10
|
` If the issue persists, make sure you are on the latest version of StepZen ` +
|
|
11
11
|
`CLI. And if the issue still persists contact support via the StepZen discord ` +
|
|
12
12
|
`channel (https://discord.gg/9k2VdPn2FR).`;
|
|
13
|
+
exports.UPGRADE_CHECK_ERROR = 'An unexpected problem occurred while checking for new CLI versions.' +
|
|
14
|
+
` If the issue persists, make sure you are on the latest version of StepZen ` +
|
|
15
|
+
`CLI. And if the issue still persists contact support via the StepZen discord ` +
|
|
16
|
+
`channel (https://discord.gg/9k2VdPn2FR).`;
|
package/lib/start/deploy.js
CHANGED
|
@@ -106,12 +106,17 @@ exports.default = async (file, workspace, flags) => {
|
|
|
106
106
|
console.log();
|
|
107
107
|
console.log(chalk.grey(`Your API url is`, chalk.green(` ${endpoint}`)));
|
|
108
108
|
console.log();
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
+
}
|
|
117
122
|
};
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.
|
|
1
|
+
{"version":"0.11.0-beta.0","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},"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."}},"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},"apikey":{"name":"apikey","type":"boolean","allowNo":false},"adminkey":{"name":"adminkey","type":"boolean","allowNo":false}},"args":[]}}}
|