@superblocksteam/cli 0.0.11 → 0.0.13
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 +6 -6
- package/assets/custom-components/package.json +6 -7
- package/assets/custom-components/tsconfig.json +1 -1
- package/dist/commands/components/create.js +97 -37
- package/dist/commands/components/upload.js +2 -8
- package/dist/commands/components/watch.js +2 -5
- package/dist/commands/init.js +12 -3
- package/dist/commands/login.js +1 -1
- package/dist/commands/pull.d.ts +1 -1
- package/dist/commands/pull.js +24 -15
- package/dist/common/defaults/create-component-defaults.js +14 -1
- package/dist/common/version-control.d.ts +6 -7
- package/dist/common/version-control.js +25 -21
- package/oclif.manifest.json +7 -6
- package/package.json +3 -3
- package/dist/util/prompt.d.ts +0 -7
- package/dist/util/prompt.js +0 -33
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ $ npm install -g @superblocksteam/cli
|
|
|
12
12
|
$ superblocks COMMAND
|
|
13
13
|
running command...
|
|
14
14
|
$ superblocks (--version)
|
|
15
|
-
@superblocksteam/cli/0.0.
|
|
15
|
+
@superblocksteam/cli/0.0.13 linux-x64 node-v18.17.0
|
|
16
16
|
$ superblocks --help [COMMAND]
|
|
17
17
|
USAGE
|
|
18
18
|
$ superblocks COMMAND
|
|
@@ -110,14 +110,14 @@ Interactively configure the current directory as a Superblocks project or initia
|
|
|
110
110
|
|
|
111
111
|
```
|
|
112
112
|
USAGE
|
|
113
|
-
$ superblocks init [RESOURCEURL] [-m
|
|
113
|
+
$ superblocks init [RESOURCEURL] [-m latest-edits|most-recent-commit|deployed]
|
|
114
114
|
|
|
115
115
|
ARGUMENTS
|
|
116
116
|
RESOURCEURL Superblocks resource URL (i.e. https://app.superblocks.com/applications/<application_id>/pages/<page_id>)
|
|
117
117
|
|
|
118
118
|
FLAGS
|
|
119
119
|
-m, --mode=<option> Pull mode
|
|
120
|
-
<options:
|
|
120
|
+
<options: latest-edits|most-recent-commit|deployed>
|
|
121
121
|
|
|
122
122
|
DESCRIPTION
|
|
123
123
|
Interactively configure the current directory as a Superblocks project or initialize new services in an already
|
|
@@ -151,14 +151,14 @@ Download objects from Superblocks and save them locally
|
|
|
151
151
|
|
|
152
152
|
```
|
|
153
153
|
USAGE
|
|
154
|
-
$ superblocks pull [ONLY] [-m
|
|
154
|
+
$ superblocks pull [ONLY] [-m latest-edits|most-recent-commit|deployed]
|
|
155
155
|
|
|
156
156
|
ARGUMENTS
|
|
157
157
|
ONLY Superblocks resource location to pull (i.e. apps/my-app or backends/my-workflow)
|
|
158
158
|
|
|
159
159
|
FLAGS
|
|
160
|
-
-m, --mode=<option> Pull mode
|
|
161
|
-
<options:
|
|
160
|
+
-m, --mode=<option> [default: latest-edits] Pull mode
|
|
161
|
+
<options: latest-edits|most-recent-commit|deployed>
|
|
162
162
|
|
|
163
163
|
DESCRIPTION
|
|
164
164
|
Download objects from Superblocks and save them locally
|
|
@@ -6,15 +6,14 @@
|
|
|
6
6
|
"lint": "npx eslint .",
|
|
7
7
|
"lint:fix": "npx eslint . --fix"
|
|
8
8
|
},
|
|
9
|
-
"dependencies": {
|
|
10
|
-
|
|
11
|
-
"react": "^
|
|
12
|
-
"react-dom": "^17"
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"react": "^18",
|
|
11
|
+
"react-dom": "^18"
|
|
13
12
|
},
|
|
14
13
|
"devDependencies": {
|
|
15
|
-
"@superblocksteam/cli": "0.0.
|
|
16
|
-
"@types/react": "^
|
|
17
|
-
"@types/react-dom": "^
|
|
14
|
+
"@superblocksteam/cli": "0.0.13",
|
|
15
|
+
"@types/react": "^18",
|
|
16
|
+
"@types/react-dom": "^18",
|
|
18
17
|
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
19
18
|
"eslint": "^8.45.0",
|
|
20
19
|
"eslint-config-prettier": "^8.8.0",
|
|
@@ -9,12 +9,12 @@ const node_util_1 = tslib_1.__importDefault(require("node:util"));
|
|
|
9
9
|
const core_1 = require("@oclif/core");
|
|
10
10
|
const util_1 = require("@superblocksteam/util");
|
|
11
11
|
const colorette_1 = require("colorette");
|
|
12
|
+
const enquirer_1 = require("enquirer");
|
|
12
13
|
const fs = tslib_1.__importStar(require("fs-extra"));
|
|
13
|
-
const
|
|
14
|
+
const lodash_1 = require("lodash");
|
|
14
15
|
const authenticated_command_1 = require("../../common/authenticated-command");
|
|
15
16
|
const create_component_defaults_1 = require("../../common/defaults/create-component-defaults");
|
|
16
17
|
const identifiers_1 = require("../../util/identifiers");
|
|
17
|
-
const prompt_1 = require("../../util/prompt");
|
|
18
18
|
const types_1 = require("../../util/types");
|
|
19
19
|
// eslint-disable-next-line unicorn/prefer-module
|
|
20
20
|
const rootDirectory = node_path_1.default.resolve(__dirname, "../../../");
|
|
@@ -28,65 +28,125 @@ const tsStringify = (obj) => {
|
|
|
28
28
|
};
|
|
29
29
|
class CreateComponent extends authenticated_command_1.AuthenticatedApplicationCommand {
|
|
30
30
|
async run() {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
const displayName = (await (0, enquirer_1.prompt)({
|
|
32
|
+
type: "input",
|
|
33
|
+
name: "displayName",
|
|
34
|
+
message: "What is the display name of the component you want to create? (e.g. Date Picker)",
|
|
35
|
+
validate: (response) => !(0, lodash_1.isEmpty)(response.trim()),
|
|
36
|
+
})).displayName;
|
|
37
|
+
const name = (await (0, enquirer_1.prompt)({
|
|
38
|
+
type: "input",
|
|
39
|
+
name: "name",
|
|
40
|
+
message: "What is the machine readable name of the component you want to create?",
|
|
41
|
+
validate: (response) => (0, identifiers_1.isValidIdentifier)(response) || "Invalid identifier",
|
|
42
|
+
initial: (0, identifiers_1.suggestIdentifier)(displayName, true) || "DatePicker",
|
|
43
|
+
})).name;
|
|
34
44
|
this.log();
|
|
35
|
-
|
|
45
|
+
this.log(`${(0, colorette_1.cyanBright)("ℹ")} A ${(0, colorette_1.bold)("stateful property")} determines what shows up in the properties panel of a custom component`);
|
|
46
|
+
this.log();
|
|
47
|
+
const hasStatefulProps = (await (0, enquirer_1.prompt)({
|
|
48
|
+
type: "confirm",
|
|
49
|
+
name: "hasStatefulProps",
|
|
50
|
+
message: `Does this component have ${(0, colorette_1.bold)("stateful properties")}?`,
|
|
51
|
+
initial: false,
|
|
52
|
+
})).hasStatefulProps;
|
|
36
53
|
const statefulProps = [];
|
|
37
54
|
if (hasStatefulProps) {
|
|
38
55
|
for (;;) {
|
|
39
|
-
const statefulPropName = await
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
const statefulPropName = (await (0, enquirer_1.prompt)({
|
|
57
|
+
type: "input",
|
|
58
|
+
name: "statefulPropName",
|
|
59
|
+
message: "What is the label of the stateful prop? (e.g. Selected Date)",
|
|
60
|
+
validate: (response) => !(0, lodash_1.isEmpty)(response.trim()),
|
|
61
|
+
})).statefulPropName.trim();
|
|
62
|
+
const statefulPropPath = (await (0, enquirer_1.prompt)({
|
|
63
|
+
type: "input",
|
|
64
|
+
name: "path",
|
|
65
|
+
initial: (0, identifiers_1.suggestIdentifier)(statefulPropName) || "selectedDate",
|
|
66
|
+
message: "What is the machine readable name of the stateful prop?",
|
|
67
|
+
validate: (response) => {
|
|
68
|
+
if (!(0, identifiers_1.isValidIdentifier)(response))
|
|
69
|
+
return "Invalid identifier";
|
|
70
|
+
if (statefulProps.some((v) => v.path === response))
|
|
71
|
+
return "Duplicate property name";
|
|
72
|
+
return true;
|
|
55
73
|
},
|
|
56
|
-
});
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
74
|
+
})).path;
|
|
75
|
+
const statefulPropType = (await (0, enquirer_1.prompt)({
|
|
76
|
+
type: "select",
|
|
77
|
+
name: "type",
|
|
78
|
+
message: `What input type should ${statefulPropName} be?`,
|
|
79
|
+
choices: Object.entries(types_1.inputTypeDefinions).map(([k, v]) => ({
|
|
80
|
+
name: k,
|
|
81
|
+
message: v.prompt,
|
|
82
|
+
value: k,
|
|
83
|
+
})),
|
|
84
|
+
initial: 0,
|
|
85
|
+
})).type;
|
|
86
|
+
const placeholderText = (await (0, enquirer_1.prompt)({
|
|
87
|
+
type: "input",
|
|
88
|
+
name: "value",
|
|
89
|
+
message: `What placeholder text should ${statefulPropName} have, if any?`,
|
|
90
|
+
required: false,
|
|
91
|
+
})).value;
|
|
60
92
|
statefulProps.push({
|
|
61
93
|
label: statefulPropName,
|
|
62
94
|
path: statefulPropPath,
|
|
63
95
|
inputType: statefulPropType,
|
|
64
96
|
placeholder: placeholderText || undefined,
|
|
65
97
|
});
|
|
66
|
-
const addAnotherStatefulProp = await
|
|
98
|
+
const addAnotherStatefulProp = (await (0, enquirer_1.prompt)({
|
|
99
|
+
type: "confirm",
|
|
100
|
+
name: "value",
|
|
101
|
+
message: "Do you want to add another stateful prop?",
|
|
102
|
+
initial: false,
|
|
103
|
+
})).value;
|
|
67
104
|
if (!addAnotherStatefulProp) {
|
|
68
105
|
break;
|
|
69
106
|
}
|
|
70
107
|
}
|
|
71
108
|
}
|
|
72
109
|
this.log();
|
|
73
|
-
|
|
110
|
+
this.log(`${(0, colorette_1.cyanBright)("ℹ")} ${(0, colorette_1.bold)("Event handlers")} represent the events your custom component can fire`);
|
|
111
|
+
this.log();
|
|
112
|
+
const hasEventHandlers = (await (0, enquirer_1.prompt)({
|
|
113
|
+
type: "confirm",
|
|
114
|
+
name: "value",
|
|
115
|
+
message: `Does this component have ${(0, colorette_1.bold)("event handlers")}? (e.g. a date picker component that has a On Change event handler)`,
|
|
116
|
+
initial: false,
|
|
117
|
+
})).value;
|
|
74
118
|
const eventHandlers = [];
|
|
75
119
|
if (hasEventHandlers) {
|
|
76
120
|
for (;;) {
|
|
77
|
-
const eventHandlerName = await
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
121
|
+
const eventHandlerName = (await (0, enquirer_1.prompt)({
|
|
122
|
+
name: "value",
|
|
123
|
+
type: "input",
|
|
124
|
+
message: "What is the label of the event handler? (e.g. On Change)",
|
|
125
|
+
validate: (response) => !(0, lodash_1.isEmpty)(response.trim()),
|
|
126
|
+
})).value.trim();
|
|
127
|
+
const eventHandlerPath = (await (0, enquirer_1.prompt)({
|
|
128
|
+
name: "value",
|
|
129
|
+
message: "What is the machine readable name of the event handler?",
|
|
130
|
+
type: "input",
|
|
131
|
+
initial: (0, identifiers_1.suggestIdentifier)(eventHandlerName) || "onChange",
|
|
132
|
+
validate: (response) => {
|
|
133
|
+
if (!(0, identifiers_1.isValidIdentifier)(response))
|
|
134
|
+
return "Invalid identifier";
|
|
135
|
+
if (eventHandlers.some((v) => v.path === response))
|
|
136
|
+
return "Duplicate property name";
|
|
137
|
+
return true;
|
|
138
|
+
},
|
|
139
|
+
})).value;
|
|
85
140
|
eventHandlers.push({
|
|
86
141
|
label: eventHandlerName,
|
|
87
142
|
path: eventHandlerPath,
|
|
88
143
|
});
|
|
89
|
-
const addAnotherEventHandler = await
|
|
144
|
+
const addAnotherEventHandler = (await (0, enquirer_1.prompt)({
|
|
145
|
+
name: "value",
|
|
146
|
+
type: "confirm",
|
|
147
|
+
message: "Do you want to add another event handler?",
|
|
148
|
+
initial: false,
|
|
149
|
+
})).value;
|
|
90
150
|
if (!addAnotherEventHandler) {
|
|
91
151
|
break;
|
|
92
152
|
}
|
|
@@ -4,12 +4,12 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const node_http_1 = tslib_1.__importDefault(require("node:http"));
|
|
5
5
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
6
|
const core_1 = require("@oclif/core");
|
|
7
|
+
const react_shim_1 = require("@superblocksteam/react-shim");
|
|
7
8
|
const util_1 = require("@superblocksteam/util");
|
|
8
9
|
const plugin_react_1 = tslib_1.__importDefault(require("@vitejs/plugin-react"));
|
|
9
10
|
const fs = tslib_1.__importStar(require("fs-extra"));
|
|
10
11
|
const serve_handler_1 = tslib_1.__importDefault(require("serve-handler"));
|
|
11
12
|
const vite_1 = require("vite");
|
|
12
|
-
const vite_plugin_externals_1 = require("vite-plugin-externals");
|
|
13
13
|
const authenticated_command_1 = require("../../common/authenticated-command");
|
|
14
14
|
class Upload extends authenticated_command_1.AuthenticatedApplicationCommand {
|
|
15
15
|
async run() {
|
|
@@ -63,13 +63,7 @@ class Upload extends authenticated_command_1.AuthenticatedApplicationCommand {
|
|
|
63
63
|
write: true,
|
|
64
64
|
},
|
|
65
65
|
customLogger: viteLogger,
|
|
66
|
-
plugins: [
|
|
67
|
-
(0, plugin_react_1.default)(),
|
|
68
|
-
(0, vite_plugin_externals_1.viteExternalsPlugin)({
|
|
69
|
-
react: "React",
|
|
70
|
-
"react-dom": "ReactDOM",
|
|
71
|
-
}),
|
|
72
|
-
],
|
|
66
|
+
plugins: [(0, plugin_react_1.default)(), (0, react_shim_1.injectReactVersionsPlugin)()],
|
|
73
67
|
});
|
|
74
68
|
})();
|
|
75
69
|
core_1.ux.action.stop();
|
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.healthEndpointMiddleware = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const core_1 = require("@oclif/core");
|
|
6
|
+
const react_shim_1 = require("@superblocksteam/react-shim");
|
|
6
7
|
const util_1 = require("@superblocksteam/util");
|
|
7
8
|
const vite_custom_component_reload_plugin_1 = require("@superblocksteam/vite-custom-component-reload-plugin");
|
|
8
9
|
const plugin_react_1 = tslib_1.__importDefault(require("@vitejs/plugin-react"));
|
|
9
10
|
const colorette_1 = require("colorette");
|
|
10
11
|
const vite_1 = require("vite");
|
|
11
|
-
const vite_plugin_externals_1 = require("vite-plugin-externals");
|
|
12
12
|
const authenticated_command_1 = require("../../common/authenticated-command");
|
|
13
13
|
function healthEndpointMiddleware() {
|
|
14
14
|
return {
|
|
@@ -80,11 +80,8 @@ class Watch extends authenticated_command_1.AuthenticatedApplicationCommand {
|
|
|
80
80
|
plugins: [
|
|
81
81
|
healthEndpointMiddleware(),
|
|
82
82
|
(0, plugin_react_1.default)(),
|
|
83
|
-
(0, vite_plugin_externals_1.viteExternalsPlugin)({
|
|
84
|
-
react: "React",
|
|
85
|
-
"react-dom": "ReactDOM",
|
|
86
|
-
}),
|
|
87
83
|
(0, vite_custom_component_reload_plugin_1.appendHotReloadEventPlugin)(),
|
|
84
|
+
(0, react_shim_1.injectReactVersionsPlugin)(),
|
|
88
85
|
],
|
|
89
86
|
});
|
|
90
87
|
await server.listen();
|
package/dist/commands/init.js
CHANGED
|
@@ -26,7 +26,7 @@ class Initialize extends authenticated_command_1.AuthenticatedCommand {
|
|
|
26
26
|
task: async (ctx) => {
|
|
27
27
|
ctx.fetchedResources = {};
|
|
28
28
|
ctx.writtenResources = {};
|
|
29
|
-
ctx.now = Date.
|
|
29
|
+
ctx.now = new Date().toISOString();
|
|
30
30
|
try {
|
|
31
31
|
ctx.existingSuperblocksConfig = (await (0, util_1.getSuperblocksMonorepoConfigJson)())[0];
|
|
32
32
|
}
|
|
@@ -73,7 +73,7 @@ class Initialize extends authenticated_command_1.AuthenticatedCommand {
|
|
|
73
73
|
title: "Writing resources to a disk...",
|
|
74
74
|
task: async (ctx, task) => {
|
|
75
75
|
const subtasks = [];
|
|
76
|
-
const now = Date.
|
|
76
|
+
const now = new Date().toISOString();
|
|
77
77
|
for (const resourceId of ctx.resourceIdsToInitialize) {
|
|
78
78
|
const resource = ctx.fetchedResources[resourceId];
|
|
79
79
|
switch (resource.resourceType) {
|
|
@@ -179,6 +179,9 @@ class Initialize extends authenticated_command_1.AuthenticatedCommand {
|
|
|
179
179
|
}
|
|
180
180
|
counter++;
|
|
181
181
|
}
|
|
182
|
+
if ((0, lodash_1.isEmpty)(choices)) {
|
|
183
|
+
this.error(`No resources found in your account. Please make sure you have access to at least one application, workflow or scheduled job.`);
|
|
184
|
+
}
|
|
182
185
|
const resourceIdsToInitialize = await task.prompt([
|
|
183
186
|
{
|
|
184
187
|
type: "AutoComplete",
|
|
@@ -228,7 +231,13 @@ Initialize.examples = [
|
|
|
228
231
|
"<%= config.bin %> <%= command.id %>",
|
|
229
232
|
"<%= config.bin %> <%= command.id %> https://app.superblocks.com/applications/11111111-1111-1111-1111-111111111111/pages/22222222-2222-2222-2222-222222222222",
|
|
230
233
|
];
|
|
231
|
-
Initialize.flags =
|
|
234
|
+
Initialize.flags = {
|
|
235
|
+
mode: core_1.Flags.string({
|
|
236
|
+
char: "m",
|
|
237
|
+
description: "Pull mode",
|
|
238
|
+
options: Object.keys(version_control_1.modeFlagValuesMap),
|
|
239
|
+
}),
|
|
240
|
+
};
|
|
232
241
|
Initialize.args = {
|
|
233
242
|
resourceUrl: core_1.Args.string({
|
|
234
243
|
description: "Superblocks resource URL (i.e. https://app.superblocks.com/applications/<application_id>/pages/<page_id>)",
|
package/dist/commands/login.js
CHANGED
|
@@ -30,7 +30,7 @@ class Login extends core_1.Command {
|
|
|
30
30
|
if (superblocksBaseUrl === customChoice) {
|
|
31
31
|
superblocksBaseUrl = await core_1.ux.prompt("Enter the Superblocks base URL (then press Enter)", { type: "normal" });
|
|
32
32
|
}
|
|
33
|
-
const tokenPageUrl = new URL("personal-settings#
|
|
33
|
+
const tokenPageUrl = new URL("personal-settings#apiKey", superblocksBaseUrl).href;
|
|
34
34
|
token = await core_1.ux.prompt(`Enter your Superblocks access token (then press Enter) which can be found at ${tokenPageUrl}`, { type: "mask" });
|
|
35
35
|
}
|
|
36
36
|
}
|
package/dist/commands/pull.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export default class Pull extends AuthenticatedCommand {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
-
mode: import("@oclif/core/lib/interfaces").OptionFlag<string
|
|
6
|
+
mode: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
7
|
};
|
|
8
8
|
static args: {
|
|
9
9
|
only: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
|
package/dist/commands/pull.js
CHANGED
|
@@ -20,7 +20,7 @@ class Pull extends authenticated_command_1.AuthenticatedCommand {
|
|
|
20
20
|
title: "Checking for existing Superblocks project...",
|
|
21
21
|
task: async (ctx) => {
|
|
22
22
|
ctx.writtenResources = {};
|
|
23
|
-
ctx.now = Date.
|
|
23
|
+
ctx.now = new Date().toISOString();
|
|
24
24
|
try {
|
|
25
25
|
[
|
|
26
26
|
ctx.existingSuperblocksRootConfig,
|
|
@@ -42,7 +42,7 @@ class Pull extends authenticated_command_1.AuthenticatedCommand {
|
|
|
42
42
|
const viewMode = await (0, version_control_1.getMode)(task, mode);
|
|
43
43
|
const resourceIdsToPull = await this.getResourceIdsToPull(ctx, task, only);
|
|
44
44
|
const subtasks = [];
|
|
45
|
-
const now = Date.
|
|
45
|
+
const now = new Date().toISOString();
|
|
46
46
|
const superblocksRootPath = node_path_1.default.resolve(node_path_1.default.dirname(ctx.superblocksRootConfigPath), "..");
|
|
47
47
|
for (const resourceId of resourceIdsToPull) {
|
|
48
48
|
const resource = (_a = ctx.existingSuperblocksRootConfig) === null || _a === void 0 ? void 0 : _a.resources[resourceId];
|
|
@@ -135,18 +135,20 @@ class Pull extends authenticated_command_1.AuthenticatedCommand {
|
|
|
135
135
|
}
|
|
136
136
|
counter++;
|
|
137
137
|
}
|
|
138
|
-
const resourceIdsToPull =
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
138
|
+
const resourceIdsToPull = choices.length === 1
|
|
139
|
+
? [choices[0].name]
|
|
140
|
+
: await task.prompt([
|
|
141
|
+
{
|
|
142
|
+
type: "MultiSelect",
|
|
143
|
+
name: "resourceIdsToPull",
|
|
144
|
+
message: `Select resources to pull (${version_control_1.MULTI_SELECT_PROMPT_HELP})`,
|
|
145
|
+
choices: choices,
|
|
146
|
+
initial: initialSelections,
|
|
147
|
+
validate: version_control_1.atLeastOneSelection,
|
|
148
|
+
prefix: "▸",
|
|
149
|
+
indicator: "◉",
|
|
150
|
+
},
|
|
151
|
+
]);
|
|
150
152
|
return resourceIdsToPull;
|
|
151
153
|
}
|
|
152
154
|
}
|
|
@@ -157,7 +159,14 @@ Pull.examples = [
|
|
|
157
159
|
"<%= config.bin %> <%= command.id %> backends/my-workflow",
|
|
158
160
|
"<%= config.bin %> <%= command.id %> backends/my-scheduled-job",
|
|
159
161
|
];
|
|
160
|
-
Pull.flags =
|
|
162
|
+
Pull.flags = {
|
|
163
|
+
mode: core_1.Flags.string({
|
|
164
|
+
char: "m",
|
|
165
|
+
description: "Pull mode",
|
|
166
|
+
options: Object.keys(version_control_1.modeFlagValuesMap),
|
|
167
|
+
default: version_control_1.LATEST_EDITS_MODE,
|
|
168
|
+
}),
|
|
169
|
+
};
|
|
161
170
|
Pull.args = {
|
|
162
171
|
only: core_1.Args.string({
|
|
163
172
|
description: "Superblocks resource location to pull (i.e. apps/my-app or backends/my-workflow)",
|
|
@@ -54,7 +54,20 @@ export default function Component({
|
|
|
54
54
|
? ",\n" + eventHandlers.map((v) => indent(v, 2)).join(",\n")
|
|
55
55
|
: ""}
|
|
56
56
|
}: Props) {
|
|
57
|
-
return
|
|
57
|
+
return (
|
|
58
|
+
<div
|
|
59
|
+
style={{
|
|
60
|
+
height: "100%",
|
|
61
|
+
width: "100%",
|
|
62
|
+
display: "flex",
|
|
63
|
+
alignItems: "center",
|
|
64
|
+
justifyContent: "center",
|
|
65
|
+
backgroundColor: "#a7aebe",
|
|
66
|
+
}}
|
|
67
|
+
>
|
|
68
|
+
<h1 style={{ color: "white" }}>{"<Insert Component Here>"}</h1>
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
58
71
|
}
|
|
59
72
|
`;
|
|
60
73
|
exports.getDefaultComponentTsx = getDefaultComponentTsx;
|
|
@@ -6,16 +6,15 @@ export type SuperblocksMetadata = {
|
|
|
6
6
|
lastUpdated: number;
|
|
7
7
|
created: number;
|
|
8
8
|
};
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const
|
|
9
|
+
export declare const LATEST_EDITS_MODE = "latest-edits";
|
|
10
|
+
export declare const MOST_RECENT_COMMIT_MODE = "most-recent-commit";
|
|
11
|
+
export declare const DEPLOYED_MODE = "deployed";
|
|
12
|
+
export declare const modeFlagValuesMap: Record<string, string>;
|
|
11
13
|
export declare function modeFlagToViewMode(modeFlag: ModeFlag): ViewMode;
|
|
12
|
-
export type ModeFlag = (typeof
|
|
13
|
-
export declare const commonFlags: {
|
|
14
|
-
mode: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
15
|
-
};
|
|
14
|
+
export type ModeFlag = (keyof typeof modeFlagValuesMap)[number];
|
|
16
15
|
export declare const SELECT_PROMPT_HELP = "Use \u2191/\u2193 arrow keys, Enter to confirm";
|
|
17
16
|
export declare const MULTI_SELECT_PROMPT_HELP = "Use \u2191/\u2193 arrow keys, Space to select, Enter to confirm";
|
|
18
17
|
export declare const atLeastOneSelection: (value: string[]) => string | true;
|
|
19
|
-
export declare function writeResourceToDisk(resourceType: string, resourceId: string, resource: any, now:
|
|
18
|
+
export declare function writeResourceToDisk(resourceType: string, resourceId: string, resource: any, now: string, rootPath: string, existingRelativeLocation?: string): Promise<VersionedResourceConfig>;
|
|
20
19
|
export declare function getMode(task: any, mode: ModeFlag): Promise<ViewMode>;
|
|
21
20
|
export declare function sortByKey(obj: unknown): unknown;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sortByKey = exports.getMode = exports.writeResourceToDisk = exports.atLeastOneSelection = exports.MULTI_SELECT_PROMPT_HELP = exports.SELECT_PROMPT_HELP = exports.
|
|
3
|
+
exports.sortByKey = exports.getMode = exports.writeResourceToDisk = exports.atLeastOneSelection = exports.MULTI_SELECT_PROMPT_HELP = exports.SELECT_PROMPT_HELP = exports.modeFlagToViewMode = exports.modeFlagValuesMap = exports.DEPLOYED_MODE = exports.MOST_RECENT_COMMIT_MODE = exports.LATEST_EDITS_MODE = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
6
|
-
const core_1 = require("@oclif/core");
|
|
7
6
|
const util_1 = require("@superblocksteam/util");
|
|
8
7
|
const colorette_1 = require("colorette");
|
|
9
8
|
const fs = tslib_1.__importStar(require("fs-extra"));
|
|
@@ -11,28 +10,27 @@ const lodash_1 = require("lodash");
|
|
|
11
10
|
const lodash_2 = tslib_1.__importDefault(require("lodash"));
|
|
12
11
|
const slugify_1 = tslib_1.__importDefault(require("slugify"));
|
|
13
12
|
const yaml_1 = require("yaml");
|
|
14
|
-
exports.
|
|
15
|
-
exports.
|
|
13
|
+
exports.LATEST_EDITS_MODE = "latest-edits";
|
|
14
|
+
exports.MOST_RECENT_COMMIT_MODE = "most-recent-commit";
|
|
15
|
+
exports.DEPLOYED_MODE = "deployed";
|
|
16
|
+
exports.modeFlagValuesMap = {
|
|
17
|
+
[exports.LATEST_EDITS_MODE]: "Latest edits",
|
|
18
|
+
[exports.MOST_RECENT_COMMIT_MODE]: "Most recent commit",
|
|
19
|
+
[exports.DEPLOYED_MODE]: "Deployed",
|
|
20
|
+
};
|
|
16
21
|
function modeFlagToViewMode(modeFlag) {
|
|
17
22
|
switch (modeFlag) {
|
|
18
|
-
case exports.
|
|
23
|
+
case exports.LATEST_EDITS_MODE:
|
|
19
24
|
return "export-live";
|
|
20
|
-
case
|
|
25
|
+
case exports.MOST_RECENT_COMMIT_MODE:
|
|
21
26
|
return "export-latest";
|
|
22
|
-
case
|
|
27
|
+
case exports.DEPLOYED_MODE:
|
|
23
28
|
return "export-deployed";
|
|
24
29
|
default:
|
|
25
30
|
throw new Error(`Unsupported mode flag: ${modeFlag}`);
|
|
26
31
|
}
|
|
27
32
|
}
|
|
28
33
|
exports.modeFlagToViewMode = modeFlagToViewMode;
|
|
29
|
-
exports.commonFlags = {
|
|
30
|
-
mode: core_1.Flags.string({
|
|
31
|
-
char: "m",
|
|
32
|
-
description: "Pull mode",
|
|
33
|
-
options: exports.modeFlagValues,
|
|
34
|
-
}),
|
|
35
|
-
};
|
|
36
34
|
exports.SELECT_PROMPT_HELP = "Use ↑/↓ arrow keys, Enter to confirm";
|
|
37
35
|
exports.MULTI_SELECT_PROMPT_HELP = "Use ↑/↓ arrow keys, Space to select, Enter to confirm";
|
|
38
36
|
const atLeastOneSelection = (value) => {
|
|
@@ -49,7 +47,7 @@ function slugifyName(originalName) {
|
|
|
49
47
|
});
|
|
50
48
|
}
|
|
51
49
|
async function writeResourceToDisk(resourceType, resourceId, resource, now, rootPath, existingRelativeLocation) {
|
|
52
|
-
var _a;
|
|
50
|
+
var _a, _b, _c;
|
|
53
51
|
switch (resourceType) {
|
|
54
52
|
case "APPLICATION": {
|
|
55
53
|
const parentDirName = "apps";
|
|
@@ -80,14 +78,17 @@ async function writeResourceToDisk(resourceType, resourceId, resource, now, root
|
|
|
80
78
|
};
|
|
81
79
|
if (resource.apis) {
|
|
82
80
|
for (const api of resource.apis) {
|
|
81
|
+
const apiName = slugifyName((_b = api.apiPb.metadata.name) !== null && _b !== void 0 ? _b : api.actions.name);
|
|
82
|
+
// server is still sending actions for a backwards compatibility
|
|
83
|
+
delete api.actions;
|
|
83
84
|
const apiContent = (0, yaml_1.stringify)(api, {
|
|
84
85
|
sortMapEntries: true,
|
|
85
86
|
});
|
|
86
87
|
const handleApi = async () => {
|
|
87
|
-
await fs.outputFile(`${apisDirName}/${
|
|
88
|
+
await fs.outputFile(`${apisDirName}/${apiName}.yaml`, apiContent);
|
|
88
89
|
};
|
|
89
90
|
apiPromises.push(handleApi());
|
|
90
|
-
applicationConfig.apis[api.id] =
|
|
91
|
+
applicationConfig.apis[api.id] = apiName;
|
|
91
92
|
}
|
|
92
93
|
await Promise.all(apiPromises);
|
|
93
94
|
}
|
|
@@ -101,7 +102,10 @@ async function writeResourceToDisk(resourceType, resourceId, resource, now, root
|
|
|
101
102
|
}
|
|
102
103
|
case "BACKEND": {
|
|
103
104
|
const parentDirName = "backends";
|
|
104
|
-
const
|
|
105
|
+
const apiName = slugifyName((_c = resource.apiPb.metadata.name) !== null && _c !== void 0 ? _c : resource.actions.name);
|
|
106
|
+
// server is still sending actions for a backwards compatibility
|
|
107
|
+
delete resource.actions;
|
|
108
|
+
const newRelativeLocation = `${parentDirName}/${apiName}`;
|
|
105
109
|
const relativeLocation = existingRelativeLocation !== null && existingRelativeLocation !== void 0 ? existingRelativeLocation : newRelativeLocation;
|
|
106
110
|
const backendDirName = node_path_1.default.resolve(rootPath, relativeLocation);
|
|
107
111
|
if (!(await fs.pathExists(backendDirName))) {
|
|
@@ -137,10 +141,10 @@ async function getMode(task, mode) {
|
|
|
137
141
|
{
|
|
138
142
|
type: "Select",
|
|
139
143
|
name: "mode",
|
|
140
|
-
message: `Select fetch
|
|
141
|
-
choices: exports.
|
|
144
|
+
message: `Select which version of a resource you would like to fetch (${exports.SELECT_PROMPT_HELP})`,
|
|
145
|
+
choices: Object.keys(exports.modeFlagValuesMap).map((mode) => ({
|
|
142
146
|
name: mode,
|
|
143
|
-
message: mode,
|
|
147
|
+
message: exports.modeFlagValuesMap[mode],
|
|
144
148
|
})),
|
|
145
149
|
initial: 0,
|
|
146
150
|
multiple: false,
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.
|
|
2
|
+
"version": "0.0.13",
|
|
3
3
|
"commands": {
|
|
4
4
|
"init": {
|
|
5
5
|
"id": "init",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"description": "Pull mode",
|
|
22
22
|
"multiple": false,
|
|
23
23
|
"options": [
|
|
24
|
-
"
|
|
25
|
-
"
|
|
24
|
+
"latest-edits",
|
|
25
|
+
"most-recent-commit",
|
|
26
26
|
"deployed"
|
|
27
27
|
]
|
|
28
28
|
}
|
|
@@ -83,10 +83,11 @@
|
|
|
83
83
|
"description": "Pull mode",
|
|
84
84
|
"multiple": false,
|
|
85
85
|
"options": [
|
|
86
|
-
"
|
|
87
|
-
"
|
|
86
|
+
"latest-edits",
|
|
87
|
+
"most-recent-commit",
|
|
88
88
|
"deployed"
|
|
89
|
-
]
|
|
89
|
+
],
|
|
90
|
+
"default": "latest-edits"
|
|
90
91
|
}
|
|
91
92
|
},
|
|
92
93
|
"args": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superblocksteam/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "Official Superblocks CLI",
|
|
5
5
|
"bin": {
|
|
6
6
|
"superblocks": "bin/run"
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"@oclif/plugin-help": "^5",
|
|
20
20
|
"@oclif/plugin-plugins": "^2.4.4",
|
|
21
21
|
"@superblocksteam/sdk": "*",
|
|
22
|
+
"@superblocksteam/react-shim": "*",
|
|
22
23
|
"@superblocksteam/util": "*",
|
|
23
24
|
"@superblocksteam/vite-custom-component-reload-plugin": "*",
|
|
24
25
|
"@vitejs/plugin-react": "^4.0.0",
|
|
@@ -30,7 +31,6 @@
|
|
|
30
31
|
"serve-handler": "^6.1.5",
|
|
31
32
|
"slugify": "^1.6.6",
|
|
32
33
|
"vite": "^4.3.9",
|
|
33
|
-
"vite-plugin-externals": "^0.6.2",
|
|
34
34
|
"vite-plugin-inspect": "^0.7.28",
|
|
35
35
|
"yaml": "2.3.1"
|
|
36
36
|
},
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"shx": "^0.3.3",
|
|
57
57
|
"ts-node": "^10.9.1",
|
|
58
58
|
"tslib": "^2.5.0",
|
|
59
|
-
"typescript": "^5.1.
|
|
59
|
+
"typescript": "^5.1.6"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "tsc --build",
|
package/dist/util/prompt.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { IPromptOptions } from "@oclif/core/lib/cli-ux";
|
|
2
|
-
type ValidatorFn = (input: string) => string | boolean;
|
|
3
|
-
/**
|
|
4
|
-
* A wrapper around `oclif`'s `ux.prompt` function that allows for validation of user responses.
|
|
5
|
-
*/
|
|
6
|
-
export declare function validatedPrompt(name: string, options: IPromptOptions | undefined, validator: ValidatorFn | RegExp): Promise<string>;
|
|
7
|
-
export {};
|
package/dist/util/prompt.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validatedPrompt = void 0;
|
|
4
|
-
const core_1 = require("@oclif/core");
|
|
5
|
-
/**
|
|
6
|
-
* A wrapper around `oclif`'s `ux.prompt` function that allows for validation of user responses.
|
|
7
|
-
*/
|
|
8
|
-
async function validatedPrompt(name, options, validator) {
|
|
9
|
-
let validatorFn;
|
|
10
|
-
if (validator === undefined) {
|
|
11
|
-
validatorFn = () => true;
|
|
12
|
-
}
|
|
13
|
-
else if (validator instanceof RegExp) {
|
|
14
|
-
validatorFn = (response) => validator.test(response);
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
validatorFn = validator;
|
|
18
|
-
}
|
|
19
|
-
for (;;) {
|
|
20
|
-
const response = await core_1.ux.prompt(name, options);
|
|
21
|
-
const validationResult = validatorFn(response);
|
|
22
|
-
if (typeof validationResult === "string") {
|
|
23
|
-
core_1.ux.log(`Error: ${validationResult}`);
|
|
24
|
-
}
|
|
25
|
-
else if (validationResult === false) {
|
|
26
|
-
core_1.ux.log("Error: Invalid response");
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
return response;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.validatedPrompt = validatedPrompt;
|