@superblocksteam/cli 0.0.15 → 0.0.16
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/assets/custom-components/.eslintrc.js +1 -0
- package/assets/custom-components/package.json +1 -1
- package/dist/commands/components/create.js +2 -2
- package/dist/commands/components/upload.js +2 -1
- package/dist/common/authenticated-command.js +1 -1
- package/dist/common/defaults/create-component-defaults.js +1 -24
- package/dist/common/types.d.ts +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +3 -2
- package/dist/util/types.d.ts +0 -9
- package/dist/util/types.js +0 -26
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.16 linux-x64 node-v18.17.0
|
|
16
16
|
$ superblocks --help [COMMAND]
|
|
17
17
|
USAGE
|
|
18
18
|
$ superblocks COMMAND
|
|
@@ -7,6 +7,7 @@ const node_crypto_1 = require("node:crypto");
|
|
|
7
7
|
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
8
8
|
const node_util_1 = tslib_1.__importDefault(require("node:util"));
|
|
9
9
|
const core_1 = require("@oclif/core");
|
|
10
|
+
const util_1 = require("@superblocksteam/util");
|
|
10
11
|
const colorette_1 = require("colorette");
|
|
11
12
|
const enquirer_1 = require("enquirer");
|
|
12
13
|
const fs = tslib_1.__importStar(require("fs-extra"));
|
|
@@ -14,7 +15,6 @@ 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 types_1 = require("../../util/types");
|
|
18
18
|
// eslint-disable-next-line unicorn/prefer-module
|
|
19
19
|
const rootDirectory = node_path_1.default.resolve(__dirname, "../../../");
|
|
20
20
|
const DEFAULT_PACKAGE_JSON_TEMPLATE_PATH = node_path_1.default.resolve(rootDirectory, "assets/custom-components");
|
|
@@ -75,7 +75,7 @@ class CreateComponent extends authenticated_command_1.AuthenticatedApplicationCo
|
|
|
75
75
|
type: "select",
|
|
76
76
|
name: "type",
|
|
77
77
|
message: `What input type should ${statefulPropName} be?`,
|
|
78
|
-
choices: Object.entries(
|
|
78
|
+
choices: Object.entries(util_1.inputTypeDefinions).map(([k, v]) => ({
|
|
79
79
|
name: k,
|
|
80
80
|
message: v.prompt,
|
|
81
81
|
value: k,
|
|
@@ -4,6 +4,7 @@ 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 css_plugin_1 = require("@superblocksteam/css-plugin");
|
|
7
8
|
const react_shim_1 = require("@superblocksteam/react-shim");
|
|
8
9
|
const util_1 = require("@superblocksteam/util");
|
|
9
10
|
const plugin_react_1 = tslib_1.__importDefault(require("@vitejs/plugin-react"));
|
|
@@ -50,7 +51,7 @@ class Upload extends authenticated_command_1.AuthenticatedApplicationCommand {
|
|
|
50
51
|
write: true,
|
|
51
52
|
},
|
|
52
53
|
customLogger: viteLogger,
|
|
53
|
-
plugins: [(0, plugin_react_1.default)(), (0, react_shim_1.injectReactVersionsPlugin)()],
|
|
54
|
+
plugins: [(0, plugin_react_1.default)(), (0, react_shim_1.injectReactVersionsPlugin)(), (0, css_plugin_1.productionCssPlugin)()],
|
|
54
55
|
});
|
|
55
56
|
})();
|
|
56
57
|
core_1.ux.action.stop();
|
|
@@ -65,7 +65,7 @@ class AuthenticatedApplicationCommand extends AuthenticatedCommand {
|
|
|
65
65
|
exit: 1,
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
-
const { configs, hasError } = await (0, util_1.getComponentConfigs)();
|
|
68
|
+
const { configs, hasError } = await (0, util_1.getComponentConfigs)(true);
|
|
69
69
|
if (hasError) {
|
|
70
70
|
core_1.ux.action.stop();
|
|
71
71
|
this.error("Failed to register components", { exit: 1 });
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getDefaultComponentTsx = exports.getDefaultConfigTs = void 0;
|
|
4
|
-
const types_1 = require("../../util/types");
|
|
5
4
|
const indent = (str, spaces) => {
|
|
6
5
|
const spacesString = " ".repeat(spaces);
|
|
7
6
|
return str
|
|
@@ -9,9 +8,6 @@ const indent = (str, spaces) => {
|
|
|
9
8
|
.map((line) => `${spacesString}${line}`)
|
|
10
9
|
.join("\n");
|
|
11
10
|
};
|
|
12
|
-
function renderInputTypeAsTS(name, type, trailingChars, indentSpaces) {
|
|
13
|
-
return indent(`${name}: ${types_1.inputTypeDefinions[type].tsType}${trailingChars}`, indentSpaces);
|
|
14
|
-
}
|
|
15
11
|
const getDefaultConfigTs = ({ id, name, displayName, statefulPropsRendered, eventHandlersRendered, }) => `import { type ComponentConfig } from "@superblocksteam/cli";
|
|
16
12
|
|
|
17
13
|
export default {
|
|
@@ -26,26 +22,7 @@ export default {
|
|
|
26
22
|
`;
|
|
27
23
|
exports.getDefaultConfigTs = getDefaultConfigTs;
|
|
28
24
|
const getDefaultComponentTsx = (statefulProps, eventHandlers) => `import React from "react";
|
|
29
|
-
|
|
30
|
-
// All stateful properties of your component are defined here.
|
|
31
|
-
// These are the properties which are surfaced in the Superblocks properties panel
|
|
32
|
-
// and can be referenced throughout your Superblocks Application
|
|
33
|
-
interface StatefulProperties {
|
|
34
|
-
${statefulProps
|
|
35
|
-
.map((v) => renderInputTypeAsTS(v.path, v.inputType, ";", 2) + "\n")
|
|
36
|
-
.join("")}}
|
|
37
|
-
|
|
38
|
-
interface Props extends StatefulProperties {
|
|
39
|
-
// Call updateStatefulProperties to update one (or more) of your component's stateful properties.
|
|
40
|
-
// This will cause the component to rerender, and will also notify any other components
|
|
41
|
-
// in your Application which depend on the updated properties, so they also rerender
|
|
42
|
-
updateStatefulProperties: (props: Partial<StatefulProperties>) => void;
|
|
43
|
-
|
|
44
|
-
// Call the subsequent function(s) to trigger event(s) in Superblocks from your component.
|
|
45
|
-
// These events can be wired up to event handlers in your Superblocks App
|
|
46
|
-
${eventHandlers.length === 0
|
|
47
|
-
? " // Note: no event handlers defined\n"
|
|
48
|
-
: eventHandlers.map((v) => indent(v, 2) + ": () => void;" + "\n").join("")}}
|
|
25
|
+
import { Props } from "./types";
|
|
49
26
|
|
|
50
27
|
export default function Component({
|
|
51
28
|
updateStatefulProperties${statefulProps.length > 0
|
package/dist/common/types.d.ts
CHANGED
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.16",
|
|
4
4
|
"description": "Official Superblocks CLI",
|
|
5
5
|
"bin": {
|
|
6
6
|
"superblocks": "bin/run"
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"@oclif/core": "^2",
|
|
19
19
|
"@oclif/plugin-help": "^5",
|
|
20
20
|
"@oclif/plugin-plugins": "^2.4.4",
|
|
21
|
+
"@superblocksteam/css-plugin": "*",
|
|
21
22
|
"@superblocksteam/react-shim": "*",
|
|
22
23
|
"@superblocksteam/sdk": "*",
|
|
23
24
|
"@superblocksteam/util": "*",
|
|
@@ -30,7 +31,7 @@
|
|
|
30
31
|
"lodash": "^4.17.21",
|
|
31
32
|
"serve-handler": "^6.1.5",
|
|
32
33
|
"slugify": "^1.6.6",
|
|
33
|
-
"vite": "^4.
|
|
34
|
+
"vite": "^4.4.8",
|
|
34
35
|
"vite-plugin-inspect": "^0.7.28",
|
|
35
36
|
"yaml": "2.3.1"
|
|
36
37
|
},
|
package/dist/util/types.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare const supportedInputTypes: readonly ["text", "number", "boolean", "js"];
|
|
2
|
-
export type InputType = (typeof supportedInputTypes)[number];
|
|
3
|
-
interface TypeInfo {
|
|
4
|
-
tsType: string;
|
|
5
|
-
prompt: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const inputTypeDefinions: Record<InputType, TypeInfo>;
|
|
8
|
-
export declare function isValidInputType(input: string): input is InputType;
|
|
9
|
-
export {};
|
package/dist/util/types.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isValidInputType = exports.inputTypeDefinions = exports.supportedInputTypes = void 0;
|
|
4
|
-
exports.supportedInputTypes = ["text", "number", "boolean", "js"];
|
|
5
|
-
exports.inputTypeDefinions = {
|
|
6
|
-
text: {
|
|
7
|
-
tsType: "string",
|
|
8
|
-
prompt: "text",
|
|
9
|
-
},
|
|
10
|
-
number: {
|
|
11
|
-
tsType: "number",
|
|
12
|
-
prompt: "number",
|
|
13
|
-
},
|
|
14
|
-
boolean: {
|
|
15
|
-
tsType: "boolean",
|
|
16
|
-
prompt: "boolean",
|
|
17
|
-
},
|
|
18
|
-
js: {
|
|
19
|
-
tsType: "any",
|
|
20
|
-
prompt: "any (raw js expression)",
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
function isValidInputType(input) {
|
|
24
|
-
return Object.prototype.hasOwnProperty.call(exports.inputTypeDefinions, input);
|
|
25
|
-
}
|
|
26
|
-
exports.isValidInputType = isValidInputType;
|