stepzen 0.9.37 → 0.9.38-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 +2 -2
- package/lib/commands/import.js +2 -2
- package/lib/commands/start.js +3 -3
- package/lib/generate/dashboard-interface.js +3 -3
- package/lib/generate/helpers.js +2 -2
- package/lib/hooks/prerun/ensure-permissions.d.ts +3 -0
- package/lib/hooks/prerun/ensure-permissions.js +20 -0
- package/lib/shared/configuration.js +1 -1
- package/lib/shared/constants.d.ts +2 -1
- package/lib/shared/constants.js +7 -4
- package/lib/start/console.js +1 -1
- package/lib/start/deploy.js +29 -2
- package/oclif.manifest.json +1 -1
- package/package.json +3 -2
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.
|
|
32
|
+
stepzen/0.9.38-beta.0 darwin-x64 node-v14.18.3
|
|
33
33
|
$ stepzen --help [COMMAND]
|
|
34
34
|
USAGE
|
|
35
35
|
$ stepzen COMMAND
|
|
@@ -136,7 +136,7 @@ OPTIONS
|
|
|
136
136
|
|
|
137
137
|
## `stepzen start`
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
upload and deploy your schema
|
|
140
140
|
|
|
141
141
|
```
|
|
142
142
|
USAGE
|
package/lib/commands/import.js
CHANGED
|
@@ -25,9 +25,9 @@ class Import extends command_1.Command {
|
|
|
25
25
|
}
|
|
26
26
|
// Make sure the user has latest Generator Schema
|
|
27
27
|
await deploy_1.default.run([
|
|
28
|
-
constants_1.
|
|
28
|
+
constants_1.STEPZEN_GENERATOR_ENGINES_ENDPOINT,
|
|
29
29
|
'--schema',
|
|
30
|
-
|
|
30
|
+
constants_1.STEPZEN_GENERATOR_ENGINES_SCHEMA,
|
|
31
31
|
'--silent',
|
|
32
32
|
]);
|
|
33
33
|
// Let's go!
|
package/lib/commands/start.js
CHANGED
|
@@ -65,7 +65,7 @@ class Start extends command_1.Command {
|
|
|
65
65
|
await start_1.deploy(null, workspace, flags);
|
|
66
66
|
}
|
|
67
67
|
// Create the dashboard
|
|
68
|
-
if (
|
|
68
|
+
if (flags['local-proxy']) {
|
|
69
69
|
const ui = await dashboard({
|
|
70
70
|
account: configuration.account,
|
|
71
71
|
adminkey: configuration.adminkey,
|
|
@@ -91,13 +91,13 @@ class Start extends command_1.Command {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
exports.default = Start;
|
|
94
|
-
Start.description = '
|
|
94
|
+
Start.description = 'upload and deploy your schema';
|
|
95
95
|
Start.flags = {
|
|
96
96
|
dir: command_1.flags.string({ description: 'working directory' }),
|
|
97
97
|
endpoint: command_1.flags.string({ description: 'Override workspace endpoint' }),
|
|
98
98
|
help: command_1.flags.help({ char: 'h' }),
|
|
99
99
|
'no-console': command_1.flags.boolean({ hidden: true }),
|
|
100
|
-
'
|
|
100
|
+
'local-proxy': command_1.flags.boolean({ hidden: true }),
|
|
101
101
|
'no-init': command_1.flags.boolean({ hidden: true }),
|
|
102
102
|
'no-server': command_1.flags.boolean({ hidden: true }),
|
|
103
103
|
'no-validate': command_1.flags.boolean({ hidden: true }),
|
|
@@ -9,12 +9,12 @@ const deploy_1 = require("../commands/deploy");
|
|
|
9
9
|
const constants_1 = require("../shared/constants");
|
|
10
10
|
const { merge } = require('@stepzen/transpiler');
|
|
11
11
|
exports.createDashboardInterface = (workspace) => ({
|
|
12
|
-
endpoint: constants_1.
|
|
12
|
+
endpoint: constants_1.STEPZEN_GENERATOR_ENGINES_ENDPOINT,
|
|
13
13
|
onStart: async () => {
|
|
14
14
|
await deploy_1.default.run([
|
|
15
|
-
constants_1.
|
|
15
|
+
constants_1.STEPZEN_GENERATOR_ENGINES_ENDPOINT,
|
|
16
16
|
'--schema',
|
|
17
|
-
|
|
17
|
+
constants_1.STEPZEN_GENERATOR_ENGINES_SCHEMA,
|
|
18
18
|
'--silent',
|
|
19
19
|
]);
|
|
20
20
|
},
|
package/lib/generate/helpers.js
CHANGED
|
@@ -15,7 +15,7 @@ const { version } = require('../../package.json');
|
|
|
15
15
|
exports.createGeneratorFiles = async (id, details) => {
|
|
16
16
|
const config = configuration_1.readConfiguration();
|
|
17
17
|
const domain = constants_1.STEPZEN_DOMAIN.replace('.io', '.net');
|
|
18
|
-
const url = `https://${config.account}.${domain}/${constants_1.
|
|
18
|
+
const url = `https://${config.account}.${domain}/${constants_1.STEPZEN_GENERATOR_ENGINES_ENDPOINT}/__graphql`;
|
|
19
19
|
const response = await node_fetch_1.default(url, {
|
|
20
20
|
body: JSON.stringify({
|
|
21
21
|
query: `
|
|
@@ -47,7 +47,7 @@ exports.createGeneratorFiles = async (id, details) => {
|
|
|
47
47
|
exports.getConfiguration = async (id, details = {}) => {
|
|
48
48
|
const config = configuration_1.readConfiguration();
|
|
49
49
|
const domain = constants_1.STEPZEN_DOMAIN.replace('.io', '.net');
|
|
50
|
-
const url = `https://${config.account}.${domain}/${constants_1.
|
|
50
|
+
const url = `https://${config.account}.${domain}/${constants_1.STEPZEN_GENERATOR_ENGINES_ENDPOINT}/__graphql`;
|
|
51
51
|
const response = await node_fetch_1.default(url, {
|
|
52
52
|
body: JSON.stringify({
|
|
53
53
|
query: `
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const constants_1 = require("../../shared/constants");
|
|
7
|
+
const constants_2 = require("../../shared/constants");
|
|
8
|
+
const hook = async function () {
|
|
9
|
+
// checking file existence and permissions (https://betterprogramming.pub/dbce0f2b373c)
|
|
10
|
+
const file = path.join(constants_2.STEPZEN_CONFIG_DIRECTORY, constants_1.STEPZEN_CONFIG_FILE);
|
|
11
|
+
try {
|
|
12
|
+
fs.accessSync(file, fs.constants.F_OK | fs.constants.R_OK | fs.constants.W_OK);
|
|
13
|
+
const mode = fs.statSync(file).mode;
|
|
14
|
+
// https://stackoverflow.com/questions/50839744/how-to-interpret-the-number-returned-from-statsync
|
|
15
|
+
if (mode & (fs.constants.S_IRWXG | fs.constants.S_IRWXG))
|
|
16
|
+
fs.chmodSync(file, fs.constants.S_IRWXU);
|
|
17
|
+
}
|
|
18
|
+
catch (error) { }
|
|
19
|
+
};
|
|
20
|
+
exports.default = hook;
|
|
@@ -85,6 +85,6 @@ exports.writeConfigurationToLoginFile = (configuration) => {
|
|
|
85
85
|
}
|
|
86
86
|
// Write the configuration file. Overwrites if it already exists.
|
|
87
87
|
const file = path.join(constants_1.STEPZEN_CONFIG_DIRECTORY, constants_1.STEPZEN_CONFIG_FILE);
|
|
88
|
-
fs.writeFileSync(file, content);
|
|
88
|
+
fs.writeFileSync(file, content, { mode: '600' });
|
|
89
89
|
return configuration;
|
|
90
90
|
};
|
|
@@ -3,7 +3,8 @@ export declare const STEPZEN_CONFIG_DIRECTORY: string;
|
|
|
3
3
|
export declare const STEPZEN_CONFIG_FILE: string;
|
|
4
4
|
export declare const STEPZEN_DOMAIN: string;
|
|
5
5
|
export declare const STEPZEN_SERVER_URL: string;
|
|
6
|
-
export declare const STEPZEN_GENERATOR_ENGINES_SCHEMA
|
|
6
|
+
export declare const STEPZEN_GENERATOR_ENGINES_SCHEMA: string;
|
|
7
|
+
export declare const STEPZEN_GENERATOR_ENGINES_ENDPOINT = "stepzen-generator/engines";
|
|
7
8
|
export declare const STEPZEN_API_TEMPLATES_REPOSITORY = "https://github.com/steprz/stepzen-schemas";
|
|
8
9
|
export declare const ADMIN_ACCOUNT_URL = "/cli/admin/account";
|
|
9
10
|
export declare const ADMIN_DEPLOY_URL = "/cli/admin/deploy";
|
package/lib/shared/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ADMIN_VERIFY_URL = exports.ADMIN_UPLOAD_URL = exports.ADMIN_LIST_URL = exports.ADMIN_DEPLOY_URL = exports.ADMIN_ACCOUNT_URL = exports.STEPZEN_API_TEMPLATES_REPOSITORY = exports.STEPZEN_GENERATOR_ENGINES_SCHEMA = exports.STEPZEN_SERVER_URL = exports.STEPZEN_DOMAIN = exports.STEPZEN_CONFIG_FILE = exports.STEPZEN_CONFIG_DIRECTORY = exports.STEPZEN_CONFIG_CONTENT = void 0;
|
|
4
|
+
exports.ADMIN_VERIFY_URL = exports.ADMIN_UPLOAD_URL = exports.ADMIN_LIST_URL = exports.ADMIN_DEPLOY_URL = exports.ADMIN_ACCOUNT_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 = exports.STEPZEN_CONFIG_CONTENT = void 0;
|
|
5
5
|
// This file contains constants and all magic strings
|
|
6
6
|
const dotenv = require("dotenv");
|
|
7
7
|
const os = require("os");
|
|
@@ -9,7 +9,7 @@ const path = require("path");
|
|
|
9
9
|
// This allows you to set environment variables in a `.env` file.
|
|
10
10
|
// This file needs to be in your working directory.
|
|
11
11
|
dotenv.config();
|
|
12
|
-
const { STEPZEN_CONFIG_CONTENT: ENV_VAR_STEPZEN_CONFIG_CONTENT, STEPZEN_CONFIG_FILE: ENV_VAR_STEPZEN_CONFIG_FILE, STEPZEN_DOMAIN: ENV_VAR_STEPZEN_DOMAIN, STEPZEN_SERVER_URL: ENV_VAR_STEPZEN_SERVER_URL, } = process.env;
|
|
12
|
+
const { STEPZEN_CONFIG_CONTENT: ENV_VAR_STEPZEN_CONFIG_CONTENT, 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, } = process.env;
|
|
13
13
|
// Where your authentication details are stored locally
|
|
14
14
|
exports.STEPZEN_CONFIG_CONTENT = ENV_VAR_STEPZEN_CONFIG_CONTENT;
|
|
15
15
|
exports.STEPZEN_CONFIG_DIRECTORY = path.join(os.homedir(), '.stepzen');
|
|
@@ -18,8 +18,11 @@ exports.STEPZEN_CONFIG_FILE = ENV_VAR_STEPZEN_CONFIG_FILE || 'stepzen-config.yam
|
|
|
18
18
|
exports.STEPZEN_DOMAIN = ENV_VAR_STEPZEN_DOMAIN || 'stepzen.io';
|
|
19
19
|
// The zenctl URL. Override with the env var `STEPZEN_SERVER_URL`
|
|
20
20
|
exports.STEPZEN_SERVER_URL = ENV_VAR_STEPZEN_SERVER_URL || 'https://{account}.stepzen.io';
|
|
21
|
-
// Generator Engines schema folder/name
|
|
22
|
-
|
|
21
|
+
// Generator Engines schema: folder/name
|
|
22
|
+
// Use 'stepzen/engines-dev' to test the dev instance of https://github.com/steprz/generator-engines
|
|
23
|
+
exports.STEPZEN_GENERATOR_ENGINES_SCHEMA = ENV_VAR_STEPZEN_GENERATOR_ENGINES_SCHEMA || 'stepzen/engines';
|
|
24
|
+
// Generator Engines schema: target API endpoint
|
|
25
|
+
exports.STEPZEN_GENERATOR_ENGINES_ENDPOINT = 'stepzen-generator/engines';
|
|
23
26
|
// API Templates repository
|
|
24
27
|
exports.STEPZEN_API_TEMPLATES_REPOSITORY = 'https://github.com/steprz/stepzen-schemas';
|
|
25
28
|
// Paths to the endpoints used
|
package/lib/start/console.js
CHANGED
|
@@ -16,7 +16,7 @@ exports.default = async (workspace, flags) => {
|
|
|
16
16
|
console.log(`Watching ${chalk.blue(config)} for configuration changes`);
|
|
17
17
|
}
|
|
18
18
|
console.log(`Watching ${chalk.blue(cwd)} for GraphQL changes`);
|
|
19
|
-
if (
|
|
19
|
+
if (flags['local-proxy']) {
|
|
20
20
|
console.log();
|
|
21
21
|
cli_ux_1.default.url(`Running StepZen at http://localhost:${flags.port}/${workspace.endpoint}`, `http://localhost:${flags.port}/${workspace.endpoint}`);
|
|
22
22
|
}
|
package/lib/start/deploy.js
CHANGED
|
@@ -105,6 +105,33 @@ exports.default = async (file, workspace, flags) => {
|
|
|
105
105
|
console.log(chalk.green(`Successfully deployed ${what} at ${when}`));
|
|
106
106
|
const domain = constants_1.STEPZEN_DOMAIN.replace('.io', '.net');
|
|
107
107
|
const endpoint = `https://${configuration.account}.${domain}/${workspace.endpoint}/__graphql`;
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
let firstProxyLine = '';
|
|
109
|
+
let secondProxyLine = '';
|
|
110
|
+
if (flags['local-proxy']) {
|
|
111
|
+
firstProxyLine = `Explore your deployed GraphQL endpoint at a local proxy with GraphiQL:`;
|
|
112
|
+
secondProxyLine = ` http://localhost:${flags.port}/${workspace.endpoint}`;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
firstProxyLine = '';
|
|
116
|
+
secondProxyLine = '';
|
|
117
|
+
}
|
|
118
|
+
if (configuration.apikey) {
|
|
119
|
+
const parts = configuration.apikey.split('::');
|
|
120
|
+
const key = parts[2];
|
|
121
|
+
const firstTwoChars = key.substring(0, 2);
|
|
122
|
+
const lastTwoChars = key.slice(-2);
|
|
123
|
+
const masked = `${firstTwoChars}***${lastTwoChars}`;
|
|
124
|
+
const masked_apikey = `${parts[0]}::${parts[1]}::${masked}`;
|
|
125
|
+
console.log();
|
|
126
|
+
console.log(chalk.grey(`Your GraphQL schema is deployed to`, chalk.green(` ${endpoint}`)));
|
|
127
|
+
console.log();
|
|
128
|
+
console.log(chalk.grey(`You can test your endpoint with cURL:`));
|
|
129
|
+
console.log();
|
|
130
|
+
console.log(`curl ${endpoint} \\`);
|
|
131
|
+
console.log(` --header "Authorization: Apikey ${masked_apikey}" \\`);
|
|
132
|
+
console.log(` --header "Content-Type: application/json" \\`);
|
|
133
|
+
console.log(` --data '{"query": "your graphql query"}' \\`);
|
|
134
|
+
console.log();
|
|
135
|
+
console.log(chalk.grey(firstProxyLine), chalk.green(secondProxyLine));
|
|
136
|
+
}
|
|
110
137
|
};
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.9.
|
|
1
|
+
{"version":"0.9.38-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}},"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},"local-proxy":{"name":"local-proxy","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.
|
|
4
|
+
"version": "0.9.38-beta.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Darren Waddell <darren@stepzen.com>",
|
|
7
7
|
"contributors": [
|
|
@@ -102,7 +102,8 @@
|
|
|
102
102
|
"prerun": [
|
|
103
103
|
"./lib/hooks/prerun/check-account",
|
|
104
104
|
"./lib/hooks/prerun/check-upgrade",
|
|
105
|
-
"./lib/hooks/prerun/ensure-api-key"
|
|
105
|
+
"./lib/hooks/prerun/ensure-api-key",
|
|
106
|
+
"./lib/hooks/prerun/ensure-permissions"
|
|
106
107
|
]
|
|
107
108
|
}
|
|
108
109
|
},
|