@superblocksteam/cli 0.0.15 → 0.0.17
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 +26 -4
- package/assets/custom-components/.eslintrc.js +1 -0
- package/assets/custom-components/package.json +2 -1
- package/dist/commands/components/create.js +2 -2
- package/dist/commands/components/upload.js +2 -1
- package/dist/commands/components/watch.js +1 -1
- package/dist/commands/config/set.d.ts +11 -0
- package/dist/commands/config/set.js +79 -0
- package/dist/commands/init.js +2 -3
- package/dist/commands/login.d.ts +1 -1
- package/dist/commands/login.js +20 -26
- package/dist/common/authenticated-command.js +10 -6
- package/dist/common/defaults/create-component-defaults.js +1 -24
- package/dist/common/types.d.ts +1 -1
- package/dist/common/version-control.d.ts +1 -1
- package/dist/common/version-control.js +4 -4
- package/oclif.manifest.json +31 -9
- package/package.json +6 -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.17 linux-x64 node-v18.17.0
|
|
16
16
|
$ superblocks --help [COMMAND]
|
|
17
17
|
USAGE
|
|
18
18
|
$ superblocks COMMAND
|
|
@@ -25,6 +25,7 @@ USAGE
|
|
|
25
25
|
* [`superblocks components register`](#superblocks-components-register)
|
|
26
26
|
* [`superblocks components upload`](#superblocks-components-upload)
|
|
27
27
|
* [`superblocks components watch`](#superblocks-components-watch)
|
|
28
|
+
* [`superblocks config set PROPERTY VALUE`](#superblocks-config-set-property-value)
|
|
28
29
|
* [`superblocks help [COMMANDS]`](#superblocks-help-commands)
|
|
29
30
|
* [`superblocks init [RESOURCEURL]`](#superblocks-init-resourceurl)
|
|
30
31
|
* [`superblocks login`](#superblocks-login)
|
|
@@ -84,6 +85,28 @@ DESCRIPTION
|
|
|
84
85
|
watch for changes to your custom components
|
|
85
86
|
```
|
|
86
87
|
|
|
88
|
+
## `superblocks config set PROPERTY VALUE`
|
|
89
|
+
|
|
90
|
+
Sets the specified property in your Superblocks configuration. A property governs the behavior of the Superblocks CLI, such as Superblocks region to interact with
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
USAGE
|
|
94
|
+
$ superblocks config set PROPERTY VALUE
|
|
95
|
+
|
|
96
|
+
ARGUMENTS
|
|
97
|
+
PROPERTY (domain) Superblocks config name, e.g. domain
|
|
98
|
+
VALUE Superblocks config value
|
|
99
|
+
|
|
100
|
+
DESCRIPTION
|
|
101
|
+
Sets the specified property in your Superblocks configuration. A property governs the behavior of the Superblocks CLI,
|
|
102
|
+
such as Superblocks region to interact with
|
|
103
|
+
|
|
104
|
+
EXAMPLES
|
|
105
|
+
$ superblocks config set domain eu.superblocks.com
|
|
106
|
+
|
|
107
|
+
$ superblocks config set domain app.superblocks.com
|
|
108
|
+
```
|
|
109
|
+
|
|
87
110
|
## `superblocks help [COMMANDS]`
|
|
88
111
|
|
|
89
112
|
Display help for superblocks.
|
|
@@ -135,11 +158,10 @@ Authenticates with Superblocks cloud
|
|
|
135
158
|
|
|
136
159
|
```
|
|
137
160
|
USAGE
|
|
138
|
-
$ superblocks login [-t <value>]
|
|
161
|
+
$ superblocks login [-t <value>]
|
|
139
162
|
|
|
140
163
|
FLAGS
|
|
141
|
-
-
|
|
142
|
-
-t, --token=<value> Superblocks user access token
|
|
164
|
+
-t, --token=<value> Superblocks user API key
|
|
143
165
|
|
|
144
166
|
DESCRIPTION
|
|
145
167
|
Authenticates with Superblocks cloud
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"react-dom": "^18"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@superblocksteam/cli": "0.0.
|
|
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",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"eslint-config-prettier": "^8.8.0",
|
|
20
20
|
"eslint-plugin-prettier": "^5.0.0",
|
|
21
21
|
"eslint-plugin-react": "^7.32.2",
|
|
22
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
22
23
|
"prettier": "3.0.0",
|
|
23
24
|
"typescript": "^5.1.6"
|
|
24
25
|
}
|
|
@@ -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();
|
|
@@ -69,7 +69,7 @@ class Watch extends authenticated_command_1.AuthenticatedApplicationCommand {
|
|
|
69
69
|
this.log((0, colorette_1.green)(`Local server started at port ${port}`));
|
|
70
70
|
this.log((0, colorette_1.green)(`Visit your application at:`));
|
|
71
71
|
this.log();
|
|
72
|
-
this.log((0, colorette_1.
|
|
72
|
+
this.log((0, colorette_1.bold)((0, colorette_1.magenta)(`${editModeUrl}?devMode=true`)));
|
|
73
73
|
this.log();
|
|
74
74
|
this.log((0, colorette_1.yellow)("Remember to refresh your already open Application page and turn on local development in Superblocks to connect to your local server!"));
|
|
75
75
|
})();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
export default class SetSuperblocksConfig extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
property: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
7
|
+
value: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
8
|
+
};
|
|
9
|
+
run(): Promise<void>;
|
|
10
|
+
validateDomain(domain: string): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const dns_1 = tslib_1.__importDefault(require("dns"));
|
|
5
|
+
const util_1 = require("util");
|
|
6
|
+
const core_1 = require("@oclif/core");
|
|
7
|
+
const util_2 = require("@superblocksteam/util");
|
|
8
|
+
class SetSuperblocksConfig extends core_1.Command {
|
|
9
|
+
async run() {
|
|
10
|
+
const { args } = await this.parse(SetSuperblocksConfig);
|
|
11
|
+
try {
|
|
12
|
+
switch (args.property) {
|
|
13
|
+
case "domain": {
|
|
14
|
+
const newDomain = args.value;
|
|
15
|
+
const newSuperblocksBaseUrl = `https://${newDomain}/`;
|
|
16
|
+
await this.validateDomain(newDomain);
|
|
17
|
+
const result = await (0, util_2.getLocalTokenWithUrlIfExists)();
|
|
18
|
+
if (result) {
|
|
19
|
+
if (!("token" in result)) {
|
|
20
|
+
// domain only, no token
|
|
21
|
+
await (0, util_2.saveApiToken)(newSuperblocksBaseUrl);
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
// existing token with domain
|
|
25
|
+
const { token, superblocksBaseUrl } = result;
|
|
26
|
+
const tokenToSave = newSuperblocksBaseUrl === superblocksBaseUrl ? token : undefined;
|
|
27
|
+
if (tokenToSave) {
|
|
28
|
+
await (0, util_2.saveApiToken)(newSuperblocksBaseUrl, tokenToSave);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
await (0, util_2.saveApiToken)(newSuperblocksBaseUrl);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// no existing token
|
|
36
|
+
await (0, util_2.saveApiToken)(newSuperblocksBaseUrl);
|
|
37
|
+
}
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
default:
|
|
41
|
+
throw new Error(`Unknown property ${args.property}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
this.error(`Failed to set ${args.property} to ${args.value}: ${error.message}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async validateDomain(domain) {
|
|
49
|
+
const domainRegex = /^((?!-)[A-Za-z0-9-]{1,63}(?<!-)\.)+[A-Za-z]{2,6}$/;
|
|
50
|
+
const errorMessage = `Domain ${domain} is not valid, please make sure it's correct. Example: eu.superblocks.com`;
|
|
51
|
+
if (!domainRegex.test(domain)) {
|
|
52
|
+
throw new Error(errorMessage);
|
|
53
|
+
}
|
|
54
|
+
const lookup = (0, util_1.promisify)(dns_1.default.lookup);
|
|
55
|
+
try {
|
|
56
|
+
await lookup(domain);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
throw new Error(errorMessage);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
SetSuperblocksConfig.description = "Sets the specified property in your Superblocks configuration. A property governs the behavior of the Superblocks CLI, such as Superblocks region to interact with";
|
|
64
|
+
SetSuperblocksConfig.examples = [
|
|
65
|
+
"<%= config.bin %> <%= command.id %> domain eu.superblocks.com",
|
|
66
|
+
"<%= config.bin %> <%= command.id %> domain app.superblocks.com",
|
|
67
|
+
];
|
|
68
|
+
SetSuperblocksConfig.args = {
|
|
69
|
+
property: core_1.Args.string({
|
|
70
|
+
description: "Superblocks config name, e.g. domain",
|
|
71
|
+
options: ["domain"],
|
|
72
|
+
required: true,
|
|
73
|
+
}),
|
|
74
|
+
value: core_1.Args.string({
|
|
75
|
+
description: "Superblocks config value",
|
|
76
|
+
required: true,
|
|
77
|
+
}),
|
|
78
|
+
};
|
|
79
|
+
exports.default = SetSuperblocksConfig;
|
package/dist/commands/init.js
CHANGED
|
@@ -83,10 +83,10 @@ class Initialize extends authenticated_command_1.AuthenticatedCommand {
|
|
|
83
83
|
{
|
|
84
84
|
title: "Selecting resources to initialize...",
|
|
85
85
|
task: async (ctx, task) => {
|
|
86
|
-
const viewMode = await (0, version_control_1.getMode)(task, flags.mode);
|
|
87
|
-
ctx.viewMode = viewMode;
|
|
88
86
|
const resourceIdsToInitialize = await this.getResourcesToInitialize(ctx, task, args);
|
|
89
87
|
ctx.resourceIdsToInitialize = resourceIdsToInitialize;
|
|
88
|
+
const viewMode = await (0, version_control_1.getMode)(task, flags.mode);
|
|
89
|
+
ctx.viewMode = viewMode;
|
|
90
90
|
},
|
|
91
91
|
},
|
|
92
92
|
{
|
|
@@ -145,7 +145,6 @@ class Initialize extends authenticated_command_1.AuthenticatedCommand {
|
|
|
145
145
|
resources: {},
|
|
146
146
|
metadata: {
|
|
147
147
|
cliVersion: this.config.version,
|
|
148
|
-
remote: this.getSdk().superblocksBaseUrl,
|
|
149
148
|
lastUpdated: ctx.now,
|
|
150
149
|
created: (_b = (_a = ctx.existingSuperblocksConfig) === null || _a === void 0 ? void 0 : _a.metadata.created) !== null && _b !== void 0 ? _b : ctx.now,
|
|
151
150
|
},
|
package/dist/commands/login.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export default class Login extends Command {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static flags: {
|
|
5
5
|
token: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
6
|
-
superblocksBaseUrl: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
6
|
};
|
|
7
|
+
DEFAULT_BASE_URL: string;
|
|
8
8
|
run(): Promise<void>;
|
|
9
9
|
}
|
package/dist/commands/login.js
CHANGED
|
@@ -4,41 +4,40 @@ const core_1 = require("@oclif/core");
|
|
|
4
4
|
const sdk_1 = require("@superblocksteam/sdk");
|
|
5
5
|
const util_1 = require("@superblocksteam/util");
|
|
6
6
|
const colorette_1 = require("colorette");
|
|
7
|
-
|
|
8
|
-
const
|
|
7
|
+
const enquirer_1 = require("enquirer");
|
|
8
|
+
const lodash_1 = require("lodash");
|
|
9
9
|
class Login extends core_1.Command {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.DEFAULT_BASE_URL = "https://app.superblocks.com/";
|
|
13
|
+
}
|
|
10
14
|
async run() {
|
|
15
|
+
var _a;
|
|
11
16
|
const { flags } = await this.parse(Login);
|
|
12
17
|
let token = flags.token;
|
|
13
|
-
let superblocksBaseUrl =
|
|
18
|
+
let superblocksBaseUrl = "";
|
|
14
19
|
if (!token) {
|
|
15
20
|
const result = await (0, util_1.getLocalTokenWithUrlIfExists)();
|
|
16
|
-
if (result) {
|
|
21
|
+
if (result && "token" in result) {
|
|
17
22
|
({ token, superblocksBaseUrl } = result);
|
|
18
23
|
}
|
|
19
24
|
else {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
message: "Select the Superblocks base URL",
|
|
23
|
-
choices: [
|
|
24
|
-
"https://app.superblocks.com/",
|
|
25
|
-
"https://eu.superblocks.com/",
|
|
26
|
-
customChoice,
|
|
27
|
-
],
|
|
28
|
-
});
|
|
29
|
-
superblocksBaseUrl = await selectPrompt.run();
|
|
30
|
-
if (superblocksBaseUrl === customChoice) {
|
|
31
|
-
superblocksBaseUrl = await core_1.ux.prompt("Enter the Superblocks base URL (then press Enter)", { type: "normal" });
|
|
32
|
-
}
|
|
25
|
+
superblocksBaseUrl =
|
|
26
|
+
(_a = result === null || result === void 0 ? void 0 : result.superblocksBaseUrl) !== null && _a !== void 0 ? _a : this.DEFAULT_BASE_URL;
|
|
33
27
|
const tokenPageUrl = new URL("personal-settings#apiKey", superblocksBaseUrl).href;
|
|
34
|
-
token = await
|
|
28
|
+
token = (await (0, enquirer_1.prompt)({
|
|
29
|
+
type: "password",
|
|
30
|
+
name: "token",
|
|
31
|
+
message: `Enter your Superblocks API key (then press Enter) which can be found at ${tokenPageUrl}`,
|
|
32
|
+
validate: (response) => !(0, lodash_1.isEmpty)(response.trim()),
|
|
33
|
+
})).token;
|
|
35
34
|
}
|
|
36
35
|
}
|
|
37
36
|
this.log();
|
|
38
37
|
try {
|
|
39
38
|
const sdk = new sdk_1.SuperblocksSdk(token, superblocksBaseUrl);
|
|
40
39
|
const user = await sdk.fetchCurrentUser();
|
|
41
|
-
await (0, util_1.saveApiToken)(
|
|
40
|
+
await (0, util_1.saveApiToken)(superblocksBaseUrl, token);
|
|
42
41
|
this.log((0, colorette_1.green)(`Welcome to the Superblocks 🐨 CLI ${user.name}!`));
|
|
43
42
|
}
|
|
44
43
|
catch (error) {
|
|
@@ -46,7 +45,7 @@ class Login extends core_1.Command {
|
|
|
46
45
|
this.log((0, colorette_1.red)("Could not save token, ensure the Superblocks CLI has access to create folders in your home directory."));
|
|
47
46
|
return;
|
|
48
47
|
}
|
|
49
|
-
this.log((0, colorette_1.red)(
|
|
48
|
+
this.log((0, colorette_1.red)(`Login failed. Ensure you've copied the correct token from ${superblocksBaseUrl}. If using a different domain, run "superblocks help config set" for configuration options.`));
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
51
|
}
|
|
@@ -55,12 +54,7 @@ Login.flags = {
|
|
|
55
54
|
// flag with a value (-t, --token=VALUE)
|
|
56
55
|
token: core_1.Flags.string({
|
|
57
56
|
char: "t",
|
|
58
|
-
description: "Superblocks user
|
|
59
|
-
}),
|
|
60
|
-
// flag with a value (-b, --superblocksBaseUrl=VALUE)
|
|
61
|
-
superblocksBaseUrl: core_1.Flags.string({
|
|
62
|
-
char: "b",
|
|
63
|
-
description: "Superblocks base URL",
|
|
57
|
+
description: "Superblocks user API key",
|
|
64
58
|
}),
|
|
65
59
|
};
|
|
66
60
|
exports.default = Login;
|
|
@@ -10,7 +10,11 @@ class AuthenticatedCommand extends core_1.Command {
|
|
|
10
10
|
async init() {
|
|
11
11
|
await super.init();
|
|
12
12
|
try {
|
|
13
|
-
const
|
|
13
|
+
const result = await (0, util_1.getLocalTokenWithUrl)();
|
|
14
|
+
if (!("token" in result)) {
|
|
15
|
+
throw new Error();
|
|
16
|
+
}
|
|
17
|
+
const { token, superblocksBaseUrl } = result;
|
|
14
18
|
this.sdk = new sdk_1.SuperblocksSdk(token, superblocksBaseUrl);
|
|
15
19
|
}
|
|
16
20
|
catch {
|
|
@@ -19,8 +23,8 @@ class AuthenticatedCommand extends core_1.Command {
|
|
|
19
23
|
}
|
|
20
24
|
async getBaseUrl() {
|
|
21
25
|
var _a;
|
|
22
|
-
const
|
|
23
|
-
return (_a =
|
|
26
|
+
const result = await (0, util_1.getLocalTokenWithUrlIfExists)();
|
|
27
|
+
return (_a = result === null || result === void 0 ? void 0 : result.superblocksBaseUrl) !== null && _a !== void 0 ? _a : "";
|
|
24
28
|
}
|
|
25
29
|
getSdk() {
|
|
26
30
|
if (!this.sdk) {
|
|
@@ -41,8 +45,8 @@ class AuthenticatedApplicationCommand extends AuthenticatedCommand {
|
|
|
41
45
|
};
|
|
42
46
|
}
|
|
43
47
|
async getEditModeUrl() {
|
|
44
|
-
const
|
|
45
|
-
const baseUrl =
|
|
48
|
+
const result = await (0, util_1.getLocalTokenWithUrlIfExists)();
|
|
49
|
+
const baseUrl = typeof result === "string" ? result : result === null || result === void 0 ? void 0 : result.superblocksBaseUrl;
|
|
46
50
|
return new URL(`/applications/${this.applicationConfig.id}/pages/${this.applicationConfig.defaultPageId}/edit`, baseUrl).toString();
|
|
47
51
|
}
|
|
48
52
|
async init() {
|
|
@@ -65,7 +69,7 @@ class AuthenticatedApplicationCommand extends AuthenticatedCommand {
|
|
|
65
69
|
exit: 1,
|
|
66
70
|
});
|
|
67
71
|
}
|
|
68
|
-
const { configs, hasError } = await (0, util_1.getComponentConfigs)();
|
|
72
|
+
const { configs, hasError } = await (0, util_1.getComponentConfigs)(true);
|
|
69
73
|
if (hasError) {
|
|
70
74
|
core_1.ux.action.stop();
|
|
71
75
|
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
|
@@ -13,7 +13,7 @@ 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
15
|
export declare const SELECT_PROMPT_HELP = "Use \u2191/\u2193 arrow keys, Enter to confirm";
|
|
16
|
-
export declare const MULTI_SELECT_PROMPT_HELP = "Use \u2191/\u2193 arrow keys, Space to select, Enter to confirm";
|
|
16
|
+
export declare const MULTI_SELECT_PROMPT_HELP = "Type to filter, Use \u2191/\u2193 arrow keys, Space to select, Enter to confirm";
|
|
17
17
|
export declare const atLeastOneSelection: (value: string[]) => string | true;
|
|
18
18
|
export declare function writeResourceToDisk(resourceType: string, resourceId: string, resource: any, now: string, rootPath: string, existingRelativeLocation?: string): Promise<VersionedResourceConfig>;
|
|
19
19
|
export declare function getMode(task: any, mode: ModeFlag): Promise<ViewMode>;
|
|
@@ -32,7 +32,7 @@ function modeFlagToViewMode(modeFlag) {
|
|
|
32
32
|
}
|
|
33
33
|
exports.modeFlagToViewMode = modeFlagToViewMode;
|
|
34
34
|
exports.SELECT_PROMPT_HELP = "Use ↑/↓ arrow keys, Enter to confirm";
|
|
35
|
-
exports.MULTI_SELECT_PROMPT_HELP = "Use ↑/↓ arrow keys, Space to select, Enter to confirm";
|
|
35
|
+
exports.MULTI_SELECT_PROMPT_HELP = "Type to filter, Use ↑/↓ arrow keys, Space to select, Enter to confirm";
|
|
36
36
|
const atLeastOneSelection = (value) => {
|
|
37
37
|
if ((0, lodash_1.isEmpty)(value)) {
|
|
38
38
|
return `Please select at least one item ${(0, colorette_1.bold)("by pressing space")}`;
|
|
@@ -47,7 +47,7 @@ function slugifyName(originalName) {
|
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
async function writeResourceToDisk(resourceType, resourceId, resource, now, rootPath, existingRelativeLocation) {
|
|
50
|
-
var _a, _b, _c;
|
|
50
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
51
51
|
switch (resourceType) {
|
|
52
52
|
case "APPLICATION": {
|
|
53
53
|
const parentDirName = "apps";
|
|
@@ -78,7 +78,7 @@ async function writeResourceToDisk(resourceType, resourceId, resource, now, root
|
|
|
78
78
|
};
|
|
79
79
|
if (resource.apis) {
|
|
80
80
|
for (const api of resource.apis) {
|
|
81
|
-
const apiName = slugifyName((_b = api.apiPb.metadata.name) !== null &&
|
|
81
|
+
const apiName = slugifyName((_d = (_c = (_b = api.apiPb) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : api.actions.name);
|
|
82
82
|
// server is still sending actions for a backwards compatibility
|
|
83
83
|
delete api.actions;
|
|
84
84
|
const apiContent = (0, yaml_1.stringify)(api, {
|
|
@@ -102,7 +102,7 @@ async function writeResourceToDisk(resourceType, resourceId, resource, now, root
|
|
|
102
102
|
}
|
|
103
103
|
case "BACKEND": {
|
|
104
104
|
const parentDirName = "backends";
|
|
105
|
-
const apiName = slugifyName((
|
|
105
|
+
const apiName = slugifyName((_g = (_f = (_e = resource.apiPb) === null || _e === void 0 ? void 0 : _e.metadata) === null || _f === void 0 ? void 0 : _f.name) !== null && _g !== void 0 ? _g : resource.actions.name);
|
|
106
106
|
// server is still sending actions for a backwards compatibility
|
|
107
107
|
delete resource.actions;
|
|
108
108
|
const newRelativeLocation = `${parentDirName}/${apiName}`;
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.
|
|
2
|
+
"version": "0.0.17",
|
|
3
3
|
"commands": {
|
|
4
4
|
"init": {
|
|
5
5
|
"id": "init",
|
|
@@ -48,14 +48,7 @@
|
|
|
48
48
|
"name": "token",
|
|
49
49
|
"type": "option",
|
|
50
50
|
"char": "t",
|
|
51
|
-
"description": "Superblocks user
|
|
52
|
-
"multiple": false
|
|
53
|
-
},
|
|
54
|
-
"superblocksBaseUrl": {
|
|
55
|
-
"name": "superblocksBaseUrl",
|
|
56
|
-
"type": "option",
|
|
57
|
-
"char": "b",
|
|
58
|
-
"description": "Superblocks base URL",
|
|
51
|
+
"description": "Superblocks user API key",
|
|
59
52
|
"multiple": false
|
|
60
53
|
}
|
|
61
54
|
},
|
|
@@ -147,6 +140,35 @@
|
|
|
147
140
|
"aliases": [],
|
|
148
141
|
"flags": {},
|
|
149
142
|
"args": {}
|
|
143
|
+
},
|
|
144
|
+
"config:set": {
|
|
145
|
+
"id": "config:set",
|
|
146
|
+
"description": "Sets the specified property in your Superblocks configuration. A property governs the behavior of the Superblocks CLI, such as Superblocks region to interact with",
|
|
147
|
+
"strict": true,
|
|
148
|
+
"pluginName": "@superblocksteam/cli",
|
|
149
|
+
"pluginAlias": "@superblocksteam/cli",
|
|
150
|
+
"pluginType": "core",
|
|
151
|
+
"aliases": [],
|
|
152
|
+
"examples": [
|
|
153
|
+
"<%= config.bin %> <%= command.id %> domain eu.superblocks.com",
|
|
154
|
+
"<%= config.bin %> <%= command.id %> domain app.superblocks.com"
|
|
155
|
+
],
|
|
156
|
+
"flags": {},
|
|
157
|
+
"args": {
|
|
158
|
+
"property": {
|
|
159
|
+
"name": "property",
|
|
160
|
+
"description": "Superblocks config name, e.g. domain",
|
|
161
|
+
"required": true,
|
|
162
|
+
"options": [
|
|
163
|
+
"domain"
|
|
164
|
+
]
|
|
165
|
+
},
|
|
166
|
+
"value": {
|
|
167
|
+
"name": "value",
|
|
168
|
+
"description": "Superblocks config value",
|
|
169
|
+
"required": true
|
|
170
|
+
}
|
|
171
|
+
}
|
|
150
172
|
}
|
|
151
173
|
}
|
|
152
174
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superblocksteam/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
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
|
},
|
|
@@ -91,6 +92,9 @@
|
|
|
91
92
|
"topics": {
|
|
92
93
|
"components": {
|
|
93
94
|
"description": "Manage Superblocks components"
|
|
95
|
+
},
|
|
96
|
+
"config": {
|
|
97
|
+
"description": "Manage Superblocks configuration"
|
|
94
98
|
}
|
|
95
99
|
}
|
|
96
100
|
}
|
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;
|