@superblocksteam/cli 0.0.12 → 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 +2 -2
- package/assets/custom-components/package.json +6 -7
- 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/version-control.d.ts +1 -4
- package/dist/common/version-control.js +11 -13
- package/oclif.manifest.json +3 -2
- package/package.json +3 -3
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
|
|
@@ -157,7 +157,7 @@ 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
|
|
160
|
+
-m, --mode=<option> [default: latest-edits] Pull mode
|
|
161
161
|
<options: latest-edits|most-recent-commit|deployed>
|
|
162
162
|
|
|
163
163
|
DESCRIPTION
|
|
@@ -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",
|
|
@@ -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)",
|
|
@@ -12,12 +12,9 @@ export declare const DEPLOYED_MODE = "deployed";
|
|
|
12
12
|
export declare const modeFlagValuesMap: Record<string, string>;
|
|
13
13
|
export declare function modeFlagToViewMode(modeFlag: ModeFlag): ViewMode;
|
|
14
14
|
export type ModeFlag = (keyof typeof modeFlagValuesMap)[number];
|
|
15
|
-
export declare const commonFlags: {
|
|
16
|
-
mode: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
17
|
-
};
|
|
18
15
|
export declare const SELECT_PROMPT_HELP = "Use \u2191/\u2193 arrow keys, Enter to confirm";
|
|
19
16
|
export declare const MULTI_SELECT_PROMPT_HELP = "Use \u2191/\u2193 arrow keys, Space to select, Enter to confirm";
|
|
20
17
|
export declare const atLeastOneSelection: (value: string[]) => string | true;
|
|
21
|
-
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>;
|
|
22
19
|
export declare function getMode(task: any, mode: ModeFlag): Promise<ViewMode>;
|
|
23
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"));
|
|
@@ -32,13 +31,6 @@ function modeFlagToViewMode(modeFlag) {
|
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
33
|
exports.modeFlagToViewMode = modeFlagToViewMode;
|
|
35
|
-
exports.commonFlags = {
|
|
36
|
-
mode: core_1.Flags.string({
|
|
37
|
-
char: "m",
|
|
38
|
-
description: "Pull mode",
|
|
39
|
-
options: Object.keys(exports.modeFlagValuesMap),
|
|
40
|
-
}),
|
|
41
|
-
};
|
|
42
34
|
exports.SELECT_PROMPT_HELP = "Use ↑/↓ arrow keys, Enter to confirm";
|
|
43
35
|
exports.MULTI_SELECT_PROMPT_HELP = "Use ↑/↓ arrow keys, Space to select, Enter to confirm";
|
|
44
36
|
const atLeastOneSelection = (value) => {
|
|
@@ -55,7 +47,7 @@ function slugifyName(originalName) {
|
|
|
55
47
|
});
|
|
56
48
|
}
|
|
57
49
|
async function writeResourceToDisk(resourceType, resourceId, resource, now, rootPath, existingRelativeLocation) {
|
|
58
|
-
var _a;
|
|
50
|
+
var _a, _b, _c;
|
|
59
51
|
switch (resourceType) {
|
|
60
52
|
case "APPLICATION": {
|
|
61
53
|
const parentDirName = "apps";
|
|
@@ -86,14 +78,17 @@ async function writeResourceToDisk(resourceType, resourceId, resource, now, root
|
|
|
86
78
|
};
|
|
87
79
|
if (resource.apis) {
|
|
88
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;
|
|
89
84
|
const apiContent = (0, yaml_1.stringify)(api, {
|
|
90
85
|
sortMapEntries: true,
|
|
91
86
|
});
|
|
92
87
|
const handleApi = async () => {
|
|
93
|
-
await fs.outputFile(`${apisDirName}/${
|
|
88
|
+
await fs.outputFile(`${apisDirName}/${apiName}.yaml`, apiContent);
|
|
94
89
|
};
|
|
95
90
|
apiPromises.push(handleApi());
|
|
96
|
-
applicationConfig.apis[api.id] =
|
|
91
|
+
applicationConfig.apis[api.id] = apiName;
|
|
97
92
|
}
|
|
98
93
|
await Promise.all(apiPromises);
|
|
99
94
|
}
|
|
@@ -107,7 +102,10 @@ async function writeResourceToDisk(resourceType, resourceId, resource, now, root
|
|
|
107
102
|
}
|
|
108
103
|
case "BACKEND": {
|
|
109
104
|
const parentDirName = "backends";
|
|
110
|
-
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}`;
|
|
111
109
|
const relativeLocation = existingRelativeLocation !== null && existingRelativeLocation !== void 0 ? existingRelativeLocation : newRelativeLocation;
|
|
112
110
|
const backendDirName = node_path_1.default.resolve(rootPath, relativeLocation);
|
|
113
111
|
if (!(await fs.pathExists(backendDirName))) {
|
package/oclif.manifest.json
CHANGED
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",
|