@superblocksteam/cli 0.0.18 → 0.0.20
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/setup/package.json +2 -1
- package/dist/commands/components/upload.js +1 -32
- package/dist/commands/init.js +2 -5
- package/dist/commands/pull.js +3 -11
- package/dist/common/authenticated-command.js +3 -1
- package/dist/common/defaults/create-component-defaults.d.ts +1 -1
- package/dist/common/defaults/create-component-defaults.js +11 -9
- package/dist/common/version-control.d.ts +0 -6
- package/dist/common/version-control.js +48 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -2
- package/oclif.manifest.json +1 -1
- package/package.json +6 -8
- package/dist/common/types.d.ts +0 -7
- package/dist/common/types.js +0 -2
- package/dist/exportedTypes.d.ts +0 -20
- package/dist/exportedTypes.js +0 -2
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.20 linux-x64 node-v18.17.0
|
|
16
16
|
$ superblocks --help [COMMAND]
|
|
17
17
|
USAGE
|
|
18
18
|
$ superblocks COMMAND
|
|
@@ -125,7 +125,7 @@ DESCRIPTION
|
|
|
125
125
|
Display help for superblocks.
|
|
126
126
|
```
|
|
127
127
|
|
|
128
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.
|
|
128
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.16/src/commands/help.ts)_
|
|
129
129
|
|
|
130
130
|
## `superblocks init [RESOURCEURL]`
|
|
131
131
|
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
"lint:fix": "npx eslint . --fix"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
+
"@superblocksteam/custom-components": "0.0.20",
|
|
10
11
|
"react": "^18",
|
|
11
12
|
"react-dom": "^18"
|
|
12
13
|
},
|
|
13
14
|
"devDependencies": {
|
|
14
|
-
"@superblocksteam/cli": "0.0.17",
|
|
15
15
|
"@types/react": "^18",
|
|
16
16
|
"@types/react-dom": "^18",
|
|
17
17
|
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"eslint-plugin-prettier": "^5.0.0",
|
|
21
21
|
"eslint-plugin-react": "^7.32.2",
|
|
22
22
|
"prettier": "3.0.0",
|
|
23
|
+
"sass": "^1.64.2",
|
|
23
24
|
"typescript": "^5.1.6"
|
|
24
25
|
}
|
|
25
26
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const node_http_1 = tslib_1.__importDefault(require("node:http"));
|
|
5
4
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
5
|
const core_1 = require("@oclif/core");
|
|
7
6
|
const css_plugin_1 = require("@superblocksteam/css-plugin");
|
|
@@ -9,7 +8,6 @@ const react_shim_1 = require("@superblocksteam/react-shim");
|
|
|
9
8
|
const util_1 = require("@superblocksteam/util");
|
|
10
9
|
const plugin_react_1 = tslib_1.__importDefault(require("@vitejs/plugin-react"));
|
|
11
10
|
const fs = tslib_1.__importStar(require("fs-extra"));
|
|
12
|
-
const serve_handler_1 = tslib_1.__importDefault(require("serve-handler"));
|
|
13
11
|
const vite_1 = require("vite");
|
|
14
12
|
const authenticated_command_1 = require("../../common/authenticated-command");
|
|
15
13
|
class Upload extends authenticated_command_1.AuthenticatedApplicationCommand {
|
|
@@ -82,36 +80,7 @@ class Upload extends authenticated_command_1.AuthenticatedApplicationCommand {
|
|
|
82
80
|
this.log(e.message);
|
|
83
81
|
this.error("Failed to upload components", { exit: 1 });
|
|
84
82
|
}
|
|
85
|
-
this.log("
|
|
86
|
-
const server = node_http_1.default.createServer((request, response) => {
|
|
87
|
-
// You pass two more arguments for config and middleware
|
|
88
|
-
// More details here: https://github.com/vercel/serve-handler#options
|
|
89
|
-
return (0, serve_handler_1.default)(request, response, {
|
|
90
|
-
public: "./",
|
|
91
|
-
headers: [
|
|
92
|
-
{
|
|
93
|
-
source: "**/*",
|
|
94
|
-
headers: [
|
|
95
|
-
{
|
|
96
|
-
key: "Access-Control-Allow-Origin",
|
|
97
|
-
value: "*",
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
key: "Access-Control-Allow-Credentials",
|
|
101
|
-
value: "true",
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
key: "Access-Control-Allow-Private-Network",
|
|
105
|
-
value: "true",
|
|
106
|
-
},
|
|
107
|
-
],
|
|
108
|
-
},
|
|
109
|
-
],
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
server.listen(3030, () => {
|
|
113
|
-
console.log("Running asset server at http://localhost:3030");
|
|
114
|
-
});
|
|
83
|
+
this.log("You can now disable local dev mode and test your production assets");
|
|
115
84
|
}
|
|
116
85
|
}
|
|
117
86
|
Upload.description = "Upload creates a production-ready bundle and saves the files for use outside of Local Development mode.";
|
package/dist/commands/init.js
CHANGED
|
@@ -139,23 +139,20 @@ class Initialize extends authenticated_command_1.AuthenticatedCommand {
|
|
|
139
139
|
{
|
|
140
140
|
title: "Updating Superblocks project file...",
|
|
141
141
|
task: async (ctx) => {
|
|
142
|
-
var _a, _b
|
|
142
|
+
var _a, _b;
|
|
143
143
|
const superblocksConfig = {
|
|
144
144
|
configType: "ROOT",
|
|
145
145
|
resources: {},
|
|
146
146
|
metadata: {
|
|
147
147
|
cliVersion: this.config.version,
|
|
148
|
-
lastUpdated: ctx.now,
|
|
149
|
-
created: (_b = (_a = ctx.existingSuperblocksConfig) === null || _a === void 0 ? void 0 : _a.metadata.created) !== null && _b !== void 0 ? _b : ctx.now,
|
|
150
148
|
},
|
|
151
149
|
};
|
|
152
|
-
superblocksConfig.metadata.lastUpdated = ctx.now;
|
|
153
150
|
// new resources
|
|
154
151
|
for (const [resourceId, resource] of Object.entries(ctx.writtenResources)) {
|
|
155
152
|
superblocksConfig.resources[resourceId] = resource;
|
|
156
153
|
}
|
|
157
154
|
// existing resources
|
|
158
|
-
for (const [resourceId, resource] of Object.entries((
|
|
155
|
+
for (const [resourceId, resource] of Object.entries((_b = (_a = ctx.existingSuperblocksConfig) === null || _a === void 0 ? void 0 : _a.resources) !== null && _b !== void 0 ? _b : {})) {
|
|
159
156
|
superblocksConfig.resources[resourceId] = resource;
|
|
160
157
|
}
|
|
161
158
|
if (!(await fs.exists(util_1.SUPERBLOCKS_HOME_FOLDER_NAME))) {
|
package/dist/commands/pull.js
CHANGED
|
@@ -87,20 +87,12 @@ class Pull extends authenticated_command_1.AuthenticatedCommand {
|
|
|
87
87
|
{
|
|
88
88
|
title: "Updating Superblocks project file...",
|
|
89
89
|
task: async (ctx) => {
|
|
90
|
-
|
|
91
|
-
const superblocksRootConfig = {
|
|
92
|
-
configType: "ROOT",
|
|
93
|
-
resources: ctx.existingSuperblocksRootConfig.resources,
|
|
94
|
-
metadata: {
|
|
95
|
-
...(_a = ctx.existingSuperblocksRootConfig) === null || _a === void 0 ? void 0 : _a.metadata,
|
|
96
|
-
lastUpdated: ctx.now,
|
|
97
|
-
},
|
|
98
|
-
};
|
|
90
|
+
const [superblocksRootConfig, rootConfigPath] = await (0, util_1.getSuperblocksMonorepoConfigJson)(true);
|
|
99
91
|
for (const [resourceId, resource] of Object.entries(ctx.writtenResources)) {
|
|
100
92
|
superblocksRootConfig.resources[resourceId] = resource;
|
|
101
93
|
}
|
|
102
94
|
// update superblocks.json file
|
|
103
|
-
await fs.writeFile(
|
|
95
|
+
await fs.writeFile(rootConfigPath, JSON.stringify((0, version_control_1.sortByKey)(superblocksRootConfig), null, 2));
|
|
104
96
|
},
|
|
105
97
|
},
|
|
106
98
|
], {
|
|
@@ -128,7 +120,7 @@ class Pull extends authenticated_command_1.AuthenticatedCommand {
|
|
|
128
120
|
for (const [resourceId, resource] of Object.entries((_f = (_e = ctx.existingSuperblocksRootConfig) === null || _e === void 0 ? void 0 : _e.resources) !== null && _f !== void 0 ? _f : {})) {
|
|
129
121
|
choices.push({
|
|
130
122
|
name: resourceId,
|
|
131
|
-
message:
|
|
123
|
+
message: resource.location,
|
|
132
124
|
});
|
|
133
125
|
if (((_g = ctx.existingSuperblocksResourceConfig) === null || _g === void 0 ? void 0 : _g.id) === resourceId) {
|
|
134
126
|
initialSelections.push(counter);
|
|
@@ -16,8 +16,10 @@ class AuthenticatedCommand extends core_1.Command {
|
|
|
16
16
|
}
|
|
17
17
|
const { token, superblocksBaseUrl } = result;
|
|
18
18
|
this.sdk = new sdk_1.SuperblocksSdk(token, superblocksBaseUrl);
|
|
19
|
+
await (0, util_1.updatedMonorepoConfig)(this.config.version);
|
|
19
20
|
}
|
|
20
|
-
catch {
|
|
21
|
+
catch (e) {
|
|
22
|
+
console.log(e.message);
|
|
21
23
|
this.error("Please run 'superblocks login' first", { exit: 1 });
|
|
22
24
|
}
|
|
23
25
|
}
|
|
@@ -8,7 +8,7 @@ const indent = (str, spaces) => {
|
|
|
8
8
|
.map((line) => `${spacesString}${line}`)
|
|
9
9
|
.join("\n");
|
|
10
10
|
};
|
|
11
|
-
const getDefaultConfigTs = ({ id, name, displayName, statefulPropsRendered, eventHandlersRendered, }) => `import { type ComponentConfig } from "@superblocksteam/
|
|
11
|
+
const getDefaultConfigTs = ({ id, name, displayName, statefulPropsRendered, eventHandlersRendered, }) => `import { type ComponentConfig } from "@superblocksteam/custom-components";
|
|
12
12
|
|
|
13
13
|
export default {
|
|
14
14
|
// DO NOT CHANGE THE ID ONCE THE COMPONENT HAS BEEN REGISTERED!
|
|
@@ -22,15 +22,17 @@ export default {
|
|
|
22
22
|
`;
|
|
23
23
|
exports.getDefaultConfigTs = getDefaultConfigTs;
|
|
24
24
|
const getDefaultComponentTsx = (statefulProps, eventHandlers) => `import React from "react";
|
|
25
|
-
import {
|
|
25
|
+
import { useSuperblocksContext } from "@superblocksteam/custom-components";
|
|
26
|
+
import { type Props, type EventTriggers } from "./types";
|
|
27
|
+
|
|
28
|
+
export default function Component({${statefulProps.length === 0
|
|
29
|
+
? ""
|
|
30
|
+
: "\n" + statefulProps.map((v) => indent(v.path, 2) + ",\n").join("")}}: Props) {
|
|
31
|
+
const {
|
|
32
|
+
updateStatefulProperties,
|
|
33
|
+
events: {${"\n" + eventHandlers.map((v) => indent(v, 6) + ",\n").join("")} },
|
|
34
|
+
} = useSuperblocksContext<Props, EventTriggers>();
|
|
26
35
|
|
|
27
|
-
export default function Component({
|
|
28
|
-
updateStatefulProperties${statefulProps.length > 0
|
|
29
|
-
? ",\n" + statefulProps.map((v) => indent(v.path, 2)).join(",\n")
|
|
30
|
-
: ""}${eventHandlers.length > 0
|
|
31
|
-
? ",\n" + eventHandlers.map((v) => indent(v, 2)).join(",\n")
|
|
32
|
-
: ""}
|
|
33
|
-
}: Props) {
|
|
34
36
|
return (
|
|
35
37
|
<div
|
|
36
38
|
style={{
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { ViewMode } from "@superblocksteam/sdk";
|
|
2
2
|
import { VersionedResourceConfig } from "@superblocksteam/util";
|
|
3
|
-
export type SuperblocksMetadata = {
|
|
4
|
-
cliVersion: string;
|
|
5
|
-
remote: string;
|
|
6
|
-
lastUpdated: number;
|
|
7
|
-
created: number;
|
|
8
|
-
};
|
|
9
3
|
export declare const LATEST_EDITS_MODE = "latest-edits";
|
|
10
4
|
export declare const MOST_RECENT_COMMIT_MODE = "most-recent-commit";
|
|
11
5
|
export declare const DEPLOYED_MODE = "deployed";
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
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
|
+
const https = tslib_1.__importStar(require("https"));
|
|
5
6
|
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
7
|
+
const path_1 = require("path");
|
|
6
8
|
const util_1 = require("@superblocksteam/util");
|
|
7
9
|
const colorette_1 = require("colorette");
|
|
8
10
|
const fs = tslib_1.__importStar(require("fs-extra"));
|
|
@@ -46,6 +48,45 @@ function slugifyName(originalName) {
|
|
|
46
48
|
lower: true,
|
|
47
49
|
});
|
|
48
50
|
}
|
|
51
|
+
// resolves a true promise when download is complete. If there's an error, resolve false
|
|
52
|
+
async function downloadFile(rootDirectory, filepath, url) {
|
|
53
|
+
const fullPath = `${rootDirectory}/${filepath}`;
|
|
54
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
55
|
+
const result = await new Promise(async (resolve) => {
|
|
56
|
+
try {
|
|
57
|
+
// create directory path if it doesn't exist yet
|
|
58
|
+
if (!(await fs.pathExists(fullPath))) {
|
|
59
|
+
await fs.mkdir((0, path_1.dirname)(fullPath), { recursive: true });
|
|
60
|
+
}
|
|
61
|
+
const file = fs.createWriteStream(fullPath);
|
|
62
|
+
https.get(url, (resp) => {
|
|
63
|
+
resp.pipe(file);
|
|
64
|
+
file
|
|
65
|
+
.on("finish", () => {
|
|
66
|
+
file.end(() => resolve(true));
|
|
67
|
+
})
|
|
68
|
+
.on("error", () => {
|
|
69
|
+
fs.unlink(filepath);
|
|
70
|
+
resolve(false);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
return resolve(false);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
// failed to download correctly, attempt to clean up file
|
|
79
|
+
if (!result) {
|
|
80
|
+
try {
|
|
81
|
+
await fs.unlink(fullPath);
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
console.log("Failed to delete file", fullPath);
|
|
85
|
+
}
|
|
86
|
+
return Promise.resolve(fullPath);
|
|
87
|
+
}
|
|
88
|
+
return Promise.resolve("");
|
|
89
|
+
}
|
|
49
90
|
async function writeResourceToDisk(resourceType, resourceId, resource, now, rootPath, existingRelativeLocation) {
|
|
50
91
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
51
92
|
switch (resourceType) {
|
|
@@ -94,9 +135,15 @@ async function writeResourceToDisk(resourceType, resourceId, resource, now, root
|
|
|
94
135
|
}
|
|
95
136
|
await fs.ensureDir(`${appDirName}/${util_1.SUPERBLOCKS_HOME_FOLDER_NAME}`);
|
|
96
137
|
await fs.writeFile(`${appDirName}/${util_1.RESOURCE_CONFIG_PATH}`, JSON.stringify(sortByKey(applicationConfig), null, 2));
|
|
138
|
+
const createdFiles = await Promise.resolve(resource.componentFiles.map((file) => downloadFile(appDirName, file.filename, file.url)));
|
|
139
|
+
// print out failed downloads synchronously here
|
|
140
|
+
createdFiles
|
|
141
|
+
.filter((createdFiles) => createdFiles.length)
|
|
142
|
+
.forEach((createdFile) => {
|
|
143
|
+
console.log(`Unable to download ${createdFile}`);
|
|
144
|
+
});
|
|
97
145
|
return {
|
|
98
146
|
location: relativeLocation,
|
|
99
|
-
lastUpdated: now,
|
|
100
147
|
resourceType: "APPLICATION",
|
|
101
148
|
};
|
|
102
149
|
}
|
|
@@ -123,7 +170,6 @@ async function writeResourceToDisk(resourceType, resourceId, resource, now, root
|
|
|
123
170
|
await fs.writeFile(`${backendDirName}/${util_1.RESOURCE_CONFIG_PATH}`, JSON.stringify(sortByKey(backendConfig), null, 2));
|
|
124
171
|
return {
|
|
125
172
|
location: relativeLocation,
|
|
126
|
-
lastUpdated: now,
|
|
127
173
|
resourceType: "BACKEND",
|
|
128
174
|
};
|
|
129
175
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.run = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
var core_1 = require("@oclif/core");
|
|
6
5
|
Object.defineProperty(exports, "run", { enumerable: true, get: function () { return core_1.run; } });
|
|
7
|
-
tslib_1.__exportStar(require("./exportedTypes"), exports);
|
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.20",
|
|
4
4
|
"description": "Official Superblocks CLI",
|
|
5
5
|
"bin": {
|
|
6
6
|
"superblocks": "bin/run"
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"/oclif.manifest.json"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@oclif/core": "^2",
|
|
19
|
-
"@oclif/plugin-help": "^5",
|
|
20
|
-
"@oclif/plugin-plugins": "^
|
|
18
|
+
"@oclif/core": "^2.11.7",
|
|
19
|
+
"@oclif/plugin-help": "^5.2.16",
|
|
20
|
+
"@oclif/plugin-plugins": "^3.1.10",
|
|
21
21
|
"@superblocksteam/css-plugin": "*",
|
|
22
22
|
"@superblocksteam/react-shim": "*",
|
|
23
23
|
"@superblocksteam/sdk": "*",
|
|
@@ -29,20 +29,18 @@
|
|
|
29
29
|
"fs-extra": "^11.1.1",
|
|
30
30
|
"listr2": "6.6.0",
|
|
31
31
|
"lodash": "^4.17.21",
|
|
32
|
-
"serve-handler": "^6.1.5",
|
|
33
32
|
"slugify": "^1.6.6",
|
|
34
33
|
"vite": "^4.4.8",
|
|
35
34
|
"vite-plugin-inspect": "^0.7.28",
|
|
36
35
|
"yaml": "2.3.1"
|
|
37
36
|
},
|
|
38
37
|
"devDependencies": {
|
|
39
|
-
"@oclif/test": "^2.
|
|
38
|
+
"@oclif/test": "^2.4.4",
|
|
40
39
|
"@types/babel__core": "^7.20.0",
|
|
41
40
|
"@types/chai": "^4",
|
|
42
41
|
"@types/fs-extra": "^11.0.1",
|
|
43
42
|
"@types/mocha": "^9.0.0",
|
|
44
43
|
"@types/node": "^16.18.38",
|
|
45
|
-
"@types/serve-handler": "^6.1.1",
|
|
46
44
|
"@typescript-eslint/eslint-plugin": "^5.60.1",
|
|
47
45
|
"@typescript-eslint/parser": "^5.60.1",
|
|
48
46
|
"chai": "^4",
|
|
@@ -52,7 +50,7 @@
|
|
|
52
50
|
"eslint-plugin-prettier": "4.2.1",
|
|
53
51
|
"eslint-plugin-unicorn": "^47.0.0",
|
|
54
52
|
"mocha": "^9",
|
|
55
|
-
"oclif": "^3",
|
|
53
|
+
"oclif": "^3.11.3",
|
|
56
54
|
"prettier": "^2.8.8",
|
|
57
55
|
"shx": "^0.3.3",
|
|
58
56
|
"ts-node": "^10.9.1",
|
package/dist/common/types.d.ts
DELETED
package/dist/common/types.js
DELETED
package/dist/exportedTypes.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { type UUID } from "crypto";
|
|
3
|
-
import { type StatefulProperty } from "./common/types";
|
|
4
|
-
export interface ComponentConfig {
|
|
5
|
-
id: UUID;
|
|
6
|
-
name: string;
|
|
7
|
-
displayName: string;
|
|
8
|
-
componentPath: string;
|
|
9
|
-
statefulProperties: StatefulProperty[];
|
|
10
|
-
/**
|
|
11
|
-
* Example: [{
|
|
12
|
-
* label: "On Click",
|
|
13
|
-
* path: "onClick",
|
|
14
|
-
* }]
|
|
15
|
-
*/
|
|
16
|
-
eventHandlers: Array<{
|
|
17
|
-
label: string;
|
|
18
|
-
path: string;
|
|
19
|
-
}>;
|
|
20
|
-
}
|
package/dist/exportedTypes.js
DELETED