@superblocksteam/cli 1.0.2 → 1.1.0
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 +49 -18
- package/assets/custom-components/setup/package.json +1 -1
- package/dist/commands/components/upload.d.ts +3 -0
- package/dist/commands/components/upload.js +16 -2
- package/dist/commands/components/watch.js +20 -3
- package/dist/commands/init.d.ts +1 -1
- package/dist/commands/init.js +26 -15
- package/dist/commands/login.js +3 -5
- package/dist/commands/pull.d.ts +2 -1
- package/dist/commands/pull.js +53 -23
- package/dist/commands/push.d.ts +14 -0
- package/dist/commands/push.js +240 -0
- package/dist/commands/rm.d.ts +1 -1
- package/dist/commands/rm.js +4 -4
- package/dist/common/authenticated-command.js +2 -0
- package/dist/common/version-control.d.ts +13 -1
- package/dist/common/version-control.js +89 -5
- package/oclif.manifest.json +56 -12
- package/package.json +8 -7
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/1.0
|
|
15
|
+
@superblocksteam/cli/1.1.0 linux-x64 node-v18.18.0
|
|
16
16
|
$ superblocks --help [COMMAND]
|
|
17
17
|
USAGE
|
|
18
18
|
$ superblocks COMMAND
|
|
@@ -27,11 +27,12 @@ USAGE
|
|
|
27
27
|
* [`superblocks components watch`](#superblocks-components-watch)
|
|
28
28
|
* [`superblocks config set PROPERTY VALUE`](#superblocks-config-set-property-value)
|
|
29
29
|
* [`superblocks help [COMMANDS]`](#superblocks-help-commands)
|
|
30
|
-
* [`superblocks init [
|
|
30
|
+
* [`superblocks init [RESOURCE_URL]`](#superblocks-init-resource_url)
|
|
31
31
|
* [`superblocks login`](#superblocks-login)
|
|
32
32
|
* [`superblocks migrate`](#superblocks-migrate)
|
|
33
|
-
* [`superblocks pull [
|
|
34
|
-
* [`superblocks
|
|
33
|
+
* [`superblocks pull [RESOURCE_PATH]`](#superblocks-pull-resource_path)
|
|
34
|
+
* [`superblocks push [RESOURCE_PATH]`](#superblocks-push-resource_path)
|
|
35
|
+
* [`superblocks rm [RESOURCE_PATH]`](#superblocks-rm-resource_path)
|
|
35
36
|
|
|
36
37
|
## `superblocks components create`
|
|
37
38
|
|
|
@@ -69,13 +70,18 @@ Upload creates a production-ready bundle and saves the files for use outside of
|
|
|
69
70
|
|
|
70
71
|
```
|
|
71
72
|
USAGE
|
|
72
|
-
$ superblocks components upload
|
|
73
|
+
$ superblocks components upload [-b <value>]
|
|
74
|
+
|
|
75
|
+
FLAGS
|
|
76
|
+
-b, --branch=<value> Superblocks branch to push to, the current (local) git branch will be used by default
|
|
73
77
|
|
|
74
78
|
DESCRIPTION
|
|
75
79
|
Upload creates a production-ready bundle and saves the files for use outside of Local Development mode.
|
|
76
80
|
|
|
77
81
|
EXAMPLES
|
|
78
82
|
$ superblocks components upload
|
|
83
|
+
|
|
84
|
+
$ superblocks components upload -b feature-branch
|
|
79
85
|
```
|
|
80
86
|
|
|
81
87
|
## `superblocks components watch`
|
|
@@ -132,16 +138,17 @@ DESCRIPTION
|
|
|
132
138
|
|
|
133
139
|
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.16/src/commands/help.ts)_
|
|
134
140
|
|
|
135
|
-
## `superblocks init [
|
|
141
|
+
## `superblocks init [RESOURCE_URL]`
|
|
136
142
|
|
|
137
143
|
Interactively configure the current directory as a Superblocks project or initialize new services in an already configured Superblocks project directory
|
|
138
144
|
|
|
139
145
|
```
|
|
140
146
|
USAGE
|
|
141
|
-
$ superblocks init [
|
|
147
|
+
$ superblocks init [RESOURCE_URL] [-m latest-edits|most-recent-commit|deployed]
|
|
142
148
|
|
|
143
149
|
ARGUMENTS
|
|
144
|
-
|
|
150
|
+
RESOURCE_URL Superblocks resource URL (i.e.
|
|
151
|
+
https://app.superblocks.com/applications/<application_id>/pages/<page_id>)
|
|
145
152
|
|
|
146
153
|
FLAGS
|
|
147
154
|
-m, --mode=<option> Pull mode
|
|
@@ -187,20 +194,21 @@ EXAMPLES
|
|
|
187
194
|
$ superblocks migrate
|
|
188
195
|
```
|
|
189
196
|
|
|
190
|
-
## `superblocks pull [
|
|
197
|
+
## `superblocks pull [RESOURCE_PATH]`
|
|
191
198
|
|
|
192
199
|
Download objects from Superblocks and save them locally
|
|
193
200
|
|
|
194
201
|
```
|
|
195
202
|
USAGE
|
|
196
|
-
$ superblocks pull [
|
|
203
|
+
$ superblocks pull [RESOURCE_PATH] [-m latest-edits|most-recent-commit|deployed] [-b <value>]
|
|
197
204
|
|
|
198
205
|
ARGUMENTS
|
|
199
|
-
|
|
206
|
+
RESOURCE_PATH Superblocks resource location to pull (i.e. apps/my-app)
|
|
200
207
|
|
|
201
208
|
FLAGS
|
|
202
|
-
-
|
|
203
|
-
|
|
209
|
+
-b, --branch=<value> Superblocks branch to pull from, the current git branch will be used by default
|
|
210
|
+
-m, --mode=<option> [default: latest-edits] Pull mode
|
|
211
|
+
<options: latest-edits|most-recent-commit|deployed>
|
|
204
212
|
|
|
205
213
|
DESCRIPTION
|
|
206
214
|
Download objects from Superblocks and save them locally
|
|
@@ -210,21 +218,44 @@ EXAMPLES
|
|
|
210
218
|
|
|
211
219
|
$ superblocks pull apps/my-app
|
|
212
220
|
|
|
213
|
-
$ superblocks pull
|
|
221
|
+
$ superblocks pull apps/my-app -b feature-branch
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## `superblocks push [RESOURCE_PATH]`
|
|
225
|
+
|
|
226
|
+
Import objects from local filesystem to Superblocks
|
|
227
|
+
|
|
228
|
+
```
|
|
229
|
+
USAGE
|
|
230
|
+
$ superblocks push [RESOURCE_PATH] [-b <value>]
|
|
231
|
+
|
|
232
|
+
ARGUMENTS
|
|
233
|
+
RESOURCE_PATH Superblocks resource location to push (e.g. apps/my-app)
|
|
234
|
+
|
|
235
|
+
FLAGS
|
|
236
|
+
-b, --branch=<value> Superblocks branch to push to, the current git branch will be used by default
|
|
237
|
+
|
|
238
|
+
DESCRIPTION
|
|
239
|
+
Import objects from local filesystem to Superblocks
|
|
240
|
+
|
|
241
|
+
EXAMPLES
|
|
242
|
+
$ superblocks push
|
|
243
|
+
|
|
244
|
+
$ superblocks push apps/my-app
|
|
214
245
|
|
|
215
|
-
$ superblocks
|
|
246
|
+
$ superblocks push apps/my-app -b feature-branch
|
|
216
247
|
```
|
|
217
248
|
|
|
218
|
-
## `superblocks rm [
|
|
249
|
+
## `superblocks rm [RESOURCE_PATH]`
|
|
219
250
|
|
|
220
251
|
Remove a Superblocks resource from the local Superblocks project and delete the resource folder directory locally (if it exists)
|
|
221
252
|
|
|
222
253
|
```
|
|
223
254
|
USAGE
|
|
224
|
-
$ superblocks rm [
|
|
255
|
+
$ superblocks rm [RESOURCE_PATH]
|
|
225
256
|
|
|
226
257
|
ARGUMENTS
|
|
227
|
-
|
|
258
|
+
RESOURCE_PATH Superblocks resource location (i.e. apps/my-spectacular-app)
|
|
228
259
|
|
|
229
260
|
DESCRIPTION
|
|
230
261
|
Remove a Superblocks resource from the local Superblocks project and delete the resource folder directory locally (if
|
|
@@ -2,5 +2,8 @@ import { AuthenticatedApplicationCommand } from "../../common/authenticated-comm
|
|
|
2
2
|
export default class Upload extends AuthenticatedApplicationCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
branch: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
};
|
|
5
8
|
run(): Promise<void>;
|
|
6
9
|
}
|
|
@@ -7,11 +7,14 @@ const css_plugin_1 = require("@superblocksteam/css-plugin");
|
|
|
7
7
|
const react_shim_1 = require("@superblocksteam/react-shim");
|
|
8
8
|
const util_1 = require("@superblocksteam/util");
|
|
9
9
|
const plugin_react_1 = tslib_1.__importDefault(require("@vitejs/plugin-react"));
|
|
10
|
+
const colorette_1 = require("colorette");
|
|
10
11
|
const fs = tslib_1.__importStar(require("fs-extra"));
|
|
11
12
|
const vite_1 = require("vite");
|
|
12
13
|
const authenticated_command_1 = require("../../common/authenticated-command");
|
|
14
|
+
const version_control_1 = require("../../common/version-control");
|
|
13
15
|
class Upload extends authenticated_command_1.AuthenticatedApplicationCommand {
|
|
14
16
|
async run() {
|
|
17
|
+
const { flags } = await this.parse(Upload);
|
|
15
18
|
core_1.ux.action.start("Scanning for Superblocks components...");
|
|
16
19
|
const exists = await fs.pathExists(util_1.CUSTOM_COMPONENTS_PATH);
|
|
17
20
|
if (!exists) {
|
|
@@ -20,6 +23,7 @@ class Upload extends authenticated_command_1.AuthenticatedApplicationCommand {
|
|
|
20
23
|
exit: 1,
|
|
21
24
|
});
|
|
22
25
|
}
|
|
26
|
+
const branch = flags.branch || (await (0, version_control_1.getCurrentGitBranchIfGit)());
|
|
23
27
|
const headers = {
|
|
24
28
|
[util_1.COMPONENT_EVENT_HEADER]: util_1.ComponentEvent.REGISTER,
|
|
25
29
|
};
|
|
@@ -89,7 +93,7 @@ class Upload extends authenticated_command_1.AuthenticatedApplicationCommand {
|
|
|
89
93
|
];
|
|
90
94
|
await walkThroughDirectory(".", fileRelativePaths, excluded);
|
|
91
95
|
this.log(fileRelativePaths.join("\n"));
|
|
92
|
-
await this.getSdk().uploadComponents(this.applicationConfig.id, configs, fileRelativePaths);
|
|
96
|
+
await this.getSdk().uploadComponents(this.applicationConfig.id, configs, fileRelativePaths, branch);
|
|
93
97
|
core_1.ux.action.stop();
|
|
94
98
|
}
|
|
95
99
|
catch (e) {
|
|
@@ -97,10 +101,20 @@ class Upload extends authenticated_command_1.AuthenticatedApplicationCommand {
|
|
|
97
101
|
this.error(`Failed to upload components - ${e.message}`, { exit: 1 });
|
|
98
102
|
}
|
|
99
103
|
this.log("You can now disable local dev mode and test your production assets");
|
|
104
|
+
this.log((0, colorette_1.bold)((0, colorette_1.green)("Once you are done developing please remember to commit your changes in the Superblocks UI.")));
|
|
100
105
|
}
|
|
101
106
|
}
|
|
102
107
|
Upload.description = "Upload creates a production-ready bundle and saves the files for use outside of Local Development mode.";
|
|
103
|
-
Upload.examples = [
|
|
108
|
+
Upload.examples = [
|
|
109
|
+
"<%= config.bin %> components upload",
|
|
110
|
+
"<%= config.bin %> components upload -b feature-branch",
|
|
111
|
+
];
|
|
112
|
+
Upload.flags = {
|
|
113
|
+
branch: core_1.Flags.string({
|
|
114
|
+
char: "b",
|
|
115
|
+
description: "Superblocks branch to push to, the current (local) git branch will be used by default",
|
|
116
|
+
}),
|
|
117
|
+
};
|
|
104
118
|
exports.default = Upload;
|
|
105
119
|
async function walkThroughDirectory(directory, mutableFiles, excluded) {
|
|
106
120
|
const files = await fs.readdir(directory);
|
|
@@ -9,17 +9,29 @@ const plugin_react_1 = tslib_1.__importDefault(require("@vitejs/plugin-react"));
|
|
|
9
9
|
const colorette_1 = require("colorette");
|
|
10
10
|
const vite_1 = require("vite");
|
|
11
11
|
const authenticated_command_1 = require("../../common/authenticated-command");
|
|
12
|
+
const version_control_1 = require("../../common/version-control");
|
|
12
13
|
function healthEndpointMiddleware() {
|
|
13
14
|
return {
|
|
14
15
|
name: "health-endpoint-middleware",
|
|
15
16
|
configureServer: (server) => {
|
|
16
|
-
server.middlewares.use("/health", (req, res) => {
|
|
17
|
+
server.middlewares.use("/health", async (req, res) => {
|
|
18
|
+
let branch;
|
|
19
|
+
try {
|
|
20
|
+
branch = await (0, version_control_1.getCurrentGitBranchIfGit)();
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
branch = null;
|
|
24
|
+
}
|
|
25
|
+
const gitState = branch
|
|
26
|
+
? { active: true, branch }
|
|
27
|
+
: { active: false };
|
|
17
28
|
res.setHeader("Cache-Control", "no-cache");
|
|
18
29
|
res.setHeader("Content-Type", "application/json");
|
|
19
30
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
20
31
|
const response = {
|
|
21
32
|
status: "up",
|
|
22
33
|
uptime: Math.floor(process.uptime()),
|
|
34
|
+
git: gitState,
|
|
23
35
|
};
|
|
24
36
|
res.write(JSON.stringify(response) + "\n");
|
|
25
37
|
res.end();
|
|
@@ -36,8 +48,13 @@ class Watch extends authenticated_command_1.AuthenticatedApplicationCommand {
|
|
|
36
48
|
await this.registerComponents(headers);
|
|
37
49
|
this.log((0, colorette_1.yellow)("Remember to refresh your application to see any newly registered components."));
|
|
38
50
|
this.log();
|
|
51
|
+
const editModeUrl = new URL(await this.getEditModeUrl());
|
|
52
|
+
editModeUrl.searchParams.set("devMode", "true");
|
|
53
|
+
const branch = await (0, version_control_1.getCurrentGitBranchIfGit)();
|
|
54
|
+
if (branch) {
|
|
55
|
+
editModeUrl.searchParams.set("branch", branch);
|
|
56
|
+
}
|
|
39
57
|
const port = 3002;
|
|
40
|
-
const editModeUrl = await this.getEditModeUrl();
|
|
41
58
|
const viteLogger = (0, vite_1.createLogger)();
|
|
42
59
|
viteLogger.info = (message) => {
|
|
43
60
|
this.log(message);
|
|
@@ -75,7 +92,7 @@ class Watch extends authenticated_command_1.AuthenticatedApplicationCommand {
|
|
|
75
92
|
this.log((0, colorette_1.green)(`Local server started at port ${port}`));
|
|
76
93
|
this.log((0, colorette_1.green)(`Visit your application at:`));
|
|
77
94
|
this.log();
|
|
78
|
-
this.log((0, colorette_1.bold)((0, colorette_1.magenta)(
|
|
95
|
+
this.log((0, colorette_1.bold)((0, colorette_1.magenta)(editModeUrl.href)));
|
|
79
96
|
this.log();
|
|
80
97
|
this.log((0, colorette_1.yellow)(`Please ensure that Local Dev Mode is enabled in your Application so that the component is fetched from your local dev server. Learn more about Local Dev Mode here: ${(0, colorette_1.magenta)("https://docs.superblocks.com/applications/custom-components/development-lifecycle#local-development-mode")}`));
|
|
81
98
|
})();
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export default class Initialize extends AuthenticatedCommand {
|
|
|
6
6
|
mode: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
7
|
};
|
|
8
8
|
static args: {
|
|
9
|
-
|
|
9
|
+
resource_url: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
|
|
10
10
|
};
|
|
11
11
|
run(): Promise<void>;
|
|
12
12
|
private createTasks;
|
package/dist/commands/init.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
4
5
|
const core_1 = require("@oclif/core");
|
|
5
6
|
const util_1 = require("@superblocksteam/util");
|
|
6
7
|
const fs = tslib_1.__importStar(require("fs-extra"));
|
|
@@ -27,7 +28,10 @@ class Initialize extends authenticated_command_1.AuthenticatedCommand {
|
|
|
27
28
|
ctx.fetchedResources = {};
|
|
28
29
|
ctx.writtenResources = {};
|
|
29
30
|
try {
|
|
30
|
-
|
|
31
|
+
[
|
|
32
|
+
ctx.existingSuperblocksRootConfig,
|
|
33
|
+
ctx.superblocksRootConfigPath,
|
|
34
|
+
] = await (0, util_1.getSuperblocksMonorepoConfigJson)(true);
|
|
31
35
|
}
|
|
32
36
|
catch {
|
|
33
37
|
// no existing superblocks config
|
|
@@ -39,7 +43,7 @@ class Initialize extends authenticated_command_1.AuthenticatedCommand {
|
|
|
39
43
|
task: (ctx, task) => task.newListr([
|
|
40
44
|
{
|
|
41
45
|
title: "Fetching applications...",
|
|
42
|
-
enabled: () => !args.
|
|
46
|
+
enabled: () => !args.resource_url,
|
|
43
47
|
task: async (ctx, task) => {
|
|
44
48
|
// applications choices
|
|
45
49
|
const applications = await this.getSdk().fetchApplications();
|
|
@@ -56,15 +60,16 @@ class Initialize extends authenticated_command_1.AuthenticatedCommand {
|
|
|
56
60
|
},
|
|
57
61
|
{
|
|
58
62
|
title: "Fetching resource by resourceUrl...",
|
|
59
|
-
enabled: () => args.
|
|
63
|
+
enabled: () => !(0, lodash_1.isEmpty)(args.resource_url),
|
|
60
64
|
task: async (ctx, task) => {
|
|
61
|
-
const [resourceId, resourceType] = getResourceIdFromUrl(args.
|
|
65
|
+
const [resourceId, resourceType] = getResourceIdFromUrl(args.resource_url);
|
|
62
66
|
if (resourceType === "APPLICATION") {
|
|
63
67
|
const headers = {
|
|
64
68
|
[util_1.COMPONENT_EVENT_HEADER]: util_1.ComponentEvent.INIT,
|
|
65
69
|
};
|
|
66
70
|
const application = await this.getSdk().fetchApplicationWithComponents({
|
|
67
71
|
applicationId: resourceId,
|
|
72
|
+
branch: version_control_1.DEFAULT_BRANCH,
|
|
68
73
|
headers,
|
|
69
74
|
});
|
|
70
75
|
if (!application) {
|
|
@@ -100,6 +105,11 @@ class Initialize extends authenticated_command_1.AuthenticatedCommand {
|
|
|
100
105
|
title: "Writing resources to a disk...",
|
|
101
106
|
task: async (ctx, task) => {
|
|
102
107
|
const subtasks = [];
|
|
108
|
+
// if ctx.superblocksRootConfigPath is defined, we are initializing a new resource in an existing Superblocks project
|
|
109
|
+
// otherwise, we are initializing a new Superblocks project
|
|
110
|
+
const superblocksRootPath = ctx.superblocksRootConfigPath
|
|
111
|
+
? path_1.default.resolve(path_1.default.dirname(ctx.superblocksRootConfigPath), "..")
|
|
112
|
+
: undefined;
|
|
103
113
|
for (const resourceId of ctx.resourceIdsToInitialize) {
|
|
104
114
|
const resource = ctx.fetchedResources[resourceId];
|
|
105
115
|
if (!resource) {
|
|
@@ -115,12 +125,13 @@ class Initialize extends authenticated_command_1.AuthenticatedCommand {
|
|
|
115
125
|
};
|
|
116
126
|
const application = await this.getSdk().fetchApplicationWithComponents({
|
|
117
127
|
applicationId: resourceId,
|
|
128
|
+
branch: version_control_1.DEFAULT_BRANCH,
|
|
118
129
|
viewMode: ctx.viewMode,
|
|
119
130
|
headers,
|
|
120
131
|
});
|
|
121
132
|
task.title += `: fetched`;
|
|
122
133
|
ctx.writtenResources[resourceId] =
|
|
123
|
-
await (0, version_control_1.writeResourceToDisk)("APPLICATION", resourceId, application, process.cwd());
|
|
134
|
+
await (0, version_control_1.writeResourceToDisk)("APPLICATION", resourceId, application, superblocksRootPath !== null && superblocksRootPath !== void 0 ? superblocksRootPath : process.cwd());
|
|
124
135
|
task.title += `: done`;
|
|
125
136
|
},
|
|
126
137
|
});
|
|
@@ -152,7 +163,7 @@ class Initialize extends authenticated_command_1.AuthenticatedCommand {
|
|
|
152
163
|
{
|
|
153
164
|
title: "Updating Superblocks project file...",
|
|
154
165
|
task: async (ctx) => {
|
|
155
|
-
var _a, _b;
|
|
166
|
+
var _a, _b, _c;
|
|
156
167
|
const superblocksConfig = {
|
|
157
168
|
configType: "ROOT",
|
|
158
169
|
resources: {},
|
|
@@ -165,14 +176,14 @@ class Initialize extends authenticated_command_1.AuthenticatedCommand {
|
|
|
165
176
|
superblocksConfig.resources[resourceId] = resource;
|
|
166
177
|
}
|
|
167
178
|
// existing resources
|
|
168
|
-
for (const [resourceId, resource] of Object.entries((_b = (_a = ctx.
|
|
179
|
+
for (const [resourceId, resource] of Object.entries((_b = (_a = ctx.existingSuperblocksRootConfig) === null || _a === void 0 ? void 0 : _a.resources) !== null && _b !== void 0 ? _b : {})) {
|
|
169
180
|
superblocksConfig.resources[resourceId] = resource;
|
|
170
181
|
}
|
|
171
182
|
if (!(await fs.exists(util_1.SUPERBLOCKS_HOME_FOLDER_NAME))) {
|
|
172
183
|
await fs.mkdir(util_1.SUPERBLOCKS_HOME_FOLDER_NAME);
|
|
173
184
|
}
|
|
174
185
|
// create superblocks.json file
|
|
175
|
-
await fs.writeFile(util_1.RESOURCE_CONFIG_PATH, JSON.stringify((0, version_control_1.sortByKey)(superblocksConfig), null, 2));
|
|
186
|
+
await fs.writeFile((_c = ctx.superblocksRootConfigPath) !== null && _c !== void 0 ? _c : util_1.RESOURCE_CONFIG_PATH, JSON.stringify((0, version_control_1.sortByKey)(superblocksConfig), null, 2));
|
|
176
187
|
},
|
|
177
188
|
},
|
|
178
189
|
], {
|
|
@@ -182,13 +193,13 @@ class Initialize extends authenticated_command_1.AuthenticatedCommand {
|
|
|
182
193
|
}
|
|
183
194
|
async getResourcesToInitialize(ctx, task, args) {
|
|
184
195
|
var _a, _b;
|
|
185
|
-
if (args.
|
|
196
|
+
if (args.resource_url) {
|
|
186
197
|
try {
|
|
187
|
-
const [resourceId] = getResourceIdFromUrl(args.
|
|
198
|
+
const [resourceId] = getResourceIdFromUrl(args.resource_url);
|
|
188
199
|
return [resourceId];
|
|
189
200
|
}
|
|
190
201
|
catch {
|
|
191
|
-
throw new Error(`Invalid resource URL: ${args.
|
|
202
|
+
throw new Error(`Invalid resource URL: ${args.resource_url}`);
|
|
192
203
|
}
|
|
193
204
|
}
|
|
194
205
|
else {
|
|
@@ -199,9 +210,9 @@ class Initialize extends authenticated_command_1.AuthenticatedCommand {
|
|
|
199
210
|
choices.push({
|
|
200
211
|
name: resourceId,
|
|
201
212
|
message: `${resource.name} (${resource.resourceType})`,
|
|
202
|
-
disabled: (_a = ctx.
|
|
213
|
+
disabled: (_a = ctx.existingSuperblocksRootConfig) === null || _a === void 0 ? void 0 : _a.resources[resourceId],
|
|
203
214
|
});
|
|
204
|
-
if ((_b = ctx.
|
|
215
|
+
if ((_b = ctx.existingSuperblocksRootConfig) === null || _b === void 0 ? void 0 : _b.resources[resourceId]) {
|
|
205
216
|
initialSelections.push(counter);
|
|
206
217
|
}
|
|
207
218
|
counter++;
|
|
@@ -229,7 +240,7 @@ class Initialize extends authenticated_command_1.AuthenticatedCommand {
|
|
|
229
240
|
.join(", ")}. Please make sure to select unique resources or rename them so that they have unique names.`);
|
|
230
241
|
}
|
|
231
242
|
// filter out disabled resources
|
|
232
|
-
return resourceIdsToInitialize.filter((resourceId) => { var _a; return !((_a = ctx.
|
|
243
|
+
return resourceIdsToInitialize.filter((resourceId) => { var _a; return !((_a = ctx.existingSuperblocksRootConfig) === null || _a === void 0 ? void 0 : _a.resources[resourceId]); });
|
|
233
244
|
}
|
|
234
245
|
}
|
|
235
246
|
async findDuplicates(selectedResourcesIds, resources) {
|
|
@@ -266,7 +277,7 @@ Initialize.flags = {
|
|
|
266
277
|
}),
|
|
267
278
|
};
|
|
268
279
|
Initialize.args = {
|
|
269
|
-
|
|
280
|
+
resource_url: core_1.Args.string({
|
|
270
281
|
description: "Superblocks resource URL (i.e. https://app.superblocks.com/applications/<application_id>/pages/<page_id>)",
|
|
271
282
|
required: false,
|
|
272
283
|
}),
|
package/dist/commands/login.js
CHANGED
|
@@ -15,15 +15,13 @@ class Login extends core_1.Command {
|
|
|
15
15
|
var _a;
|
|
16
16
|
const { flags } = await this.parse(Login);
|
|
17
17
|
let token = flags.token;
|
|
18
|
-
|
|
18
|
+
const result = await (0, util_1.getLocalTokenWithUrlIfExists)();
|
|
19
|
+
const superblocksBaseUrl = (_a = result === null || result === void 0 ? void 0 : result.superblocksBaseUrl) !== null && _a !== void 0 ? _a : this.DEFAULT_BASE_URL;
|
|
19
20
|
if (!token) {
|
|
20
|
-
const result = await (0, util_1.getLocalTokenWithUrlIfExists)();
|
|
21
21
|
if (result && "token" in result) {
|
|
22
|
-
|
|
22
|
+
token = result.token;
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
25
|
-
superblocksBaseUrl =
|
|
26
|
-
(_a = result === null || result === void 0 ? void 0 : result.superblocksBaseUrl) !== null && _a !== void 0 ? _a : this.DEFAULT_BASE_URL;
|
|
27
25
|
const tokenPageUrl = new URL("personal-settings#apiKey", superblocksBaseUrl).href;
|
|
28
26
|
token = (await (0, enquirer_1.prompt)({
|
|
29
27
|
type: "password",
|
package/dist/commands/pull.d.ts
CHANGED
|
@@ -4,9 +4,10 @@ export default class Pull extends AuthenticatedCommand {
|
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
6
|
mode: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
branch: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
8
|
};
|
|
8
9
|
static args: {
|
|
9
|
-
|
|
10
|
+
resource_path: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
|
|
10
11
|
};
|
|
11
12
|
run(): Promise<void>;
|
|
12
13
|
private createTasks;
|
package/dist/commands/pull.js
CHANGED
|
@@ -11,10 +11,10 @@ const version_control_1 = require("../common/version-control");
|
|
|
11
11
|
class Pull extends authenticated_command_1.AuthenticatedCommand {
|
|
12
12
|
async run() {
|
|
13
13
|
const { flags, args } = await this.parse(Pull);
|
|
14
|
-
const tasks = this.createTasks(args.
|
|
14
|
+
const tasks = this.createTasks(args.resource_path, flags.mode, flags.branch);
|
|
15
15
|
await tasks.run();
|
|
16
16
|
}
|
|
17
|
-
createTasks(
|
|
17
|
+
createTasks(resourcePath, mode, branch) {
|
|
18
18
|
const tasks = new listr2_1.Listr([
|
|
19
19
|
{
|
|
20
20
|
title: "Checking for existing Superblocks project...",
|
|
@@ -35,6 +35,18 @@ class Pull extends authenticated_command_1.AuthenticatedCommand {
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
},
|
|
38
|
+
{
|
|
39
|
+
title: "Checking for existing git repository...",
|
|
40
|
+
task: async (ctx) => {
|
|
41
|
+
try {
|
|
42
|
+
ctx.pullFromBranchName =
|
|
43
|
+
branch || (await (0, version_control_1.getCurrentGitBranchIfGit)()) || version_control_1.DEFAULT_BRANCH;
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
this.error(`Failed to check for existing git repository: ${e.message}. Please make sure to clone or initialize a git repository.`);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
},
|
|
38
50
|
{
|
|
39
51
|
title: "Checking for deleted Superblocks resources...",
|
|
40
52
|
task: async (ctx, task) => {
|
|
@@ -46,6 +58,8 @@ class Pull extends authenticated_command_1.AuthenticatedCommand {
|
|
|
46
58
|
try {
|
|
47
59
|
await this.getSdk().fetchApplication({
|
|
48
60
|
applicationId: resourceId,
|
|
61
|
+
//NOTE(alex): using default branch since we assume that the resource is deleted if it's deleted from the default branch
|
|
62
|
+
branch: version_control_1.DEFAULT_BRANCH,
|
|
49
63
|
});
|
|
50
64
|
}
|
|
51
65
|
catch (error) {
|
|
@@ -108,11 +122,11 @@ Would you like to also delete these resources from your filesystem?`,
|
|
|
108
122
|
},
|
|
109
123
|
},
|
|
110
124
|
{
|
|
111
|
-
title: "Pulling resources...",
|
|
112
125
|
task: async (ctx, task) => {
|
|
113
126
|
var _a;
|
|
127
|
+
task.title = `Pulling resources from branch ${ctx.pullFromBranchName}...`;
|
|
114
128
|
const viewMode = await (0, version_control_1.getMode)(task, mode);
|
|
115
|
-
const resourceIdsToPull = await this.getResourceIdsToPull(ctx, task,
|
|
129
|
+
const resourceIdsToPull = await this.getResourceIdsToPull(ctx, task, resourcePath);
|
|
116
130
|
const subtasks = [];
|
|
117
131
|
const superblocksRootPath = node_path_1.default.resolve(node_path_1.default.dirname(ctx.superblocksRootConfigPath), "..");
|
|
118
132
|
for (const resourceId of resourceIdsToPull) {
|
|
@@ -120,20 +134,33 @@ Would you like to also delete these resources from your filesystem?`,
|
|
|
120
134
|
switch (resource === null || resource === void 0 ? void 0 : resource.resourceType) {
|
|
121
135
|
case "APPLICATION": {
|
|
122
136
|
subtasks.push({
|
|
123
|
-
title: `Pulling application ${resource.location}...`,
|
|
137
|
+
title: `Pulling application ${resource.location} from branch ${ctx.pullFromBranchName}...`,
|
|
124
138
|
task: async (_ctx, task) => {
|
|
125
139
|
const headers = {
|
|
126
140
|
[util_1.COMPONENT_EVENT_HEADER]: util_1.ComponentEvent.PULL,
|
|
127
141
|
};
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
142
|
+
try {
|
|
143
|
+
const application = await this.getSdk().fetchApplicationWithComponents({
|
|
144
|
+
applicationId: resourceId,
|
|
145
|
+
branch: ctx.pullFromBranchName,
|
|
146
|
+
viewMode,
|
|
147
|
+
headers,
|
|
148
|
+
});
|
|
149
|
+
task.title += `: fetched`;
|
|
150
|
+
ctx.writtenResources[resourceId] =
|
|
151
|
+
await (0, version_control_1.writeResourceToDisk)("APPLICATION", resourceId, application, superblocksRootPath, resource.location);
|
|
152
|
+
task.title += `: done`;
|
|
153
|
+
}
|
|
154
|
+
catch (e) {
|
|
155
|
+
if (e instanceof util_1.NotFoundError) {
|
|
156
|
+
//NOTE(alex): today, branches are not shared between applications, so we can't pull from a branch that doesn't exist in the current application
|
|
157
|
+
//once we have shared branches, we can remove this catch block
|
|
158
|
+
task.title += `: not found in this branch. skipped`;
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
throw e;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
137
164
|
},
|
|
138
165
|
});
|
|
139
166
|
break;
|
|
@@ -178,19 +205,19 @@ Would you like to also delete these resources from your filesystem?`,
|
|
|
178
205
|
});
|
|
179
206
|
return tasks;
|
|
180
207
|
}
|
|
181
|
-
async getResourceIdsToPull(ctx, task,
|
|
208
|
+
async getResourceIdsToPull(ctx, task, resourcePath) {
|
|
182
209
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
183
|
-
if (
|
|
210
|
+
if (resourcePath) {
|
|
184
211
|
for (const [resourceId, resource] of Object.entries((_b = (_a = ctx.existingSuperblocksRootConfig) === null || _a === void 0 ? void 0 : _a.resources) !== null && _b !== void 0 ? _b : {})) {
|
|
185
|
-
if (resource.location ===
|
|
212
|
+
if (resource.location === resourcePath) {
|
|
186
213
|
return [resourceId];
|
|
187
214
|
}
|
|
188
215
|
}
|
|
189
|
-
const resource = Object.entries((_d = (_c = ctx.existingSuperblocksRootConfig) === null || _c === void 0 ? void 0 : _c.resources) !== null && _d !== void 0 ? _d : {}).find(([, resource]) => resource.location ===
|
|
216
|
+
const resource = Object.entries((_d = (_c = ctx.existingSuperblocksRootConfig) === null || _c === void 0 ? void 0 : _c.resources) !== null && _d !== void 0 ? _d : {}).find(([, resource]) => resource.location === resourcePath);
|
|
190
217
|
if (resource) {
|
|
191
218
|
return [resource[0]];
|
|
192
219
|
}
|
|
193
|
-
throw new Error(`No resource found with the given location: ${
|
|
220
|
+
throw new Error(`No resource found with the given location: ${resourcePath}`);
|
|
194
221
|
}
|
|
195
222
|
const choices = [];
|
|
196
223
|
const initialSelections = [];
|
|
@@ -229,8 +256,7 @@ Pull.description = "Download objects from Superblocks and save them locally";
|
|
|
229
256
|
Pull.examples = [
|
|
230
257
|
"<%= config.bin %> <%= command.id %>",
|
|
231
258
|
"<%= config.bin %> <%= command.id %> apps/my-app",
|
|
232
|
-
"<%= config.bin %> <%= command.id %>
|
|
233
|
-
"<%= config.bin %> <%= command.id %> backends/my-scheduled-job",
|
|
259
|
+
"<%= config.bin %> <%= command.id %> apps/my-app -b feature-branch",
|
|
234
260
|
];
|
|
235
261
|
Pull.flags = {
|
|
236
262
|
mode: core_1.Flags.string({
|
|
@@ -239,10 +265,14 @@ Pull.flags = {
|
|
|
239
265
|
options: Object.keys(version_control_1.modeFlagValuesMap),
|
|
240
266
|
default: version_control_1.LATEST_EDITS_MODE,
|
|
241
267
|
}),
|
|
268
|
+
branch: core_1.Flags.string({
|
|
269
|
+
char: "b",
|
|
270
|
+
description: "Superblocks branch to pull from, the current git branch will be used by default",
|
|
271
|
+
}),
|
|
242
272
|
};
|
|
243
273
|
Pull.args = {
|
|
244
|
-
|
|
245
|
-
description: "Superblocks resource location to pull (i.e. apps/my-app
|
|
274
|
+
resource_path: core_1.Args.string({
|
|
275
|
+
description: "Superblocks resource location to pull (i.e. apps/my-app)",
|
|
246
276
|
required: false,
|
|
247
277
|
}),
|
|
248
278
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AuthenticatedCommand } from "../common/authenticated-command";
|
|
2
|
+
export default class Push extends AuthenticatedCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
branch: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
};
|
|
8
|
+
static args: {
|
|
9
|
+
resource_path: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
private createTasks;
|
|
13
|
+
private getResourceIdsToPush;
|
|
14
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
5
|
+
const core_1 = require("@oclif/core");
|
|
6
|
+
const util_1 = require("@superblocksteam/util");
|
|
7
|
+
const listr2_1 = require("listr2");
|
|
8
|
+
const lodash_1 = require("lodash");
|
|
9
|
+
const authenticated_command_1 = require("../common/authenticated-command");
|
|
10
|
+
const version_control_1 = require("../common/version-control");
|
|
11
|
+
class Push extends authenticated_command_1.AuthenticatedCommand {
|
|
12
|
+
async run() {
|
|
13
|
+
const { flags, args } = await this.parse(Push);
|
|
14
|
+
const tasks = this.createTasks(args.resource_path, flags.branch);
|
|
15
|
+
await tasks.run();
|
|
16
|
+
}
|
|
17
|
+
createTasks(resourceName, branch) {
|
|
18
|
+
const tasks = new listr2_1.Listr([
|
|
19
|
+
{
|
|
20
|
+
title: "Checking for existing Superblocks project...",
|
|
21
|
+
task: async (ctx) => {
|
|
22
|
+
ctx.pushedResources = {};
|
|
23
|
+
ctx.removedResourceIds = [];
|
|
24
|
+
try {
|
|
25
|
+
[
|
|
26
|
+
ctx.existingSuperblocksRootConfig,
|
|
27
|
+
ctx.superblocksRootConfigPath,
|
|
28
|
+
] = await (0, util_1.getSuperblocksMonorepoConfigJson)(true);
|
|
29
|
+
ctx.existingSuperblocksResourceConfig =
|
|
30
|
+
await (0, util_1.getSuperblocksResourceConfigIfExists)();
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// no existing superblocks config
|
|
34
|
+
this.error("No Superblocks project found in the current folder hierarchy. Run 'superblocks init' to initialize a new project.");
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
title: "Checking for existing git repository...",
|
|
40
|
+
task: async (ctx) => {
|
|
41
|
+
try {
|
|
42
|
+
ctx.pushToBranchName =
|
|
43
|
+
branch || (await (0, version_control_1.getCurrentGitBranchIfGit)()) || version_control_1.DEFAULT_BRANCH;
|
|
44
|
+
[ctx.headCommitId, ctx.headCommitMessage] = await (0, version_control_1.getHeadCommit)(ctx.pushToBranchName);
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
this.error(`Failed to check for existing git repository: ${e.message}. Please make sure to clone or initialize a git repository.`);
|
|
48
|
+
}
|
|
49
|
+
const isDirtyRepo = await (0, version_control_1.isGitRepoDirty)();
|
|
50
|
+
if (isDirtyRepo) {
|
|
51
|
+
this.error(`Your git repository is dirty. Please commit or stash your changes before pushing to Superblocks.`);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
title: "Checking for deleted Superblocks resources...",
|
|
57
|
+
task: async (ctx, task) => {
|
|
58
|
+
var _a, _b, _c;
|
|
59
|
+
try {
|
|
60
|
+
for (const [resourceId, resource] of Object.entries((_b = (_a = ctx.existingSuperblocksRootConfig) === null || _a === void 0 ? void 0 : _a.resources) !== null && _b !== void 0 ? _b : {})) {
|
|
61
|
+
switch (resource === null || resource === void 0 ? void 0 : resource.resourceType) {
|
|
62
|
+
case "APPLICATION": {
|
|
63
|
+
try {
|
|
64
|
+
await this.getSdk().fetchApplication({
|
|
65
|
+
applicationId: resourceId,
|
|
66
|
+
//NOTE(alex): using default branch since we assume that the resource is deleted if it's deleted from the default branch
|
|
67
|
+
branch: version_control_1.DEFAULT_BRANCH,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
if (error instanceof util_1.NotFoundError) {
|
|
72
|
+
ctx.removedResourceIds.push(resourceId);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
case "BACKEND": {
|
|
81
|
+
try {
|
|
82
|
+
await this.getSdk().fetchApi(resourceId);
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
if (error instanceof util_1.NotFoundError) {
|
|
86
|
+
ctx.removedResourceIds.push(resourceId);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
default: {
|
|
95
|
+
this.warn(`Unsupported resource type, resource: ${JSON.stringify(resource)}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (ctx.removedResourceIds.length === 0) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const listOfDeletedResources = ctx.removedResourceIds
|
|
103
|
+
.map((id) => `- ${ctx.existingSuperblocksRootConfig.resources[id].location}`)
|
|
104
|
+
.join("\n");
|
|
105
|
+
const removeResourcesFromDisk = await task.prompt([
|
|
106
|
+
{
|
|
107
|
+
name: "removeResourcesFromDisk",
|
|
108
|
+
type: "confirm",
|
|
109
|
+
message: `Warning: The following resources could not be found in Superblocks.
|
|
110
|
+
${listOfDeletedResources}
|
|
111
|
+
|
|
112
|
+
Automatically removing resources from your local Superblocks project.
|
|
113
|
+
|
|
114
|
+
Would you like to also delete these resources from your filesystem?`,
|
|
115
|
+
},
|
|
116
|
+
]);
|
|
117
|
+
if (removeResourcesFromDisk) {
|
|
118
|
+
for (const resourceId of ctx.removedResourceIds) {
|
|
119
|
+
const resource = (_c = ctx.existingSuperblocksRootConfig) === null || _c === void 0 ? void 0 : _c.resources[resourceId];
|
|
120
|
+
await (0, version_control_1.removeResourceFromDisk)(resource.location);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
catch (e) {
|
|
125
|
+
this.warn(`Could not check for deleted Superblocks resources. Continuing...: ${e.message}`);
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
task: async (ctx, task) => {
|
|
131
|
+
var _a;
|
|
132
|
+
task.title = `Pushing resources to branch ${ctx.pushToBranchName}...`;
|
|
133
|
+
const resourceIdsToPush = await this.getResourceIdsToPush(ctx, task, resourceName);
|
|
134
|
+
const subtasks = [];
|
|
135
|
+
const superblocksRootPath = node_path_1.default.resolve(node_path_1.default.dirname(ctx.superblocksRootConfigPath), "..");
|
|
136
|
+
for (const resourceId of resourceIdsToPush) {
|
|
137
|
+
const resource = (_a = ctx.existingSuperblocksRootConfig) === null || _a === void 0 ? void 0 : _a.resources[resourceId];
|
|
138
|
+
switch (resource === null || resource === void 0 ? void 0 : resource.resourceType) {
|
|
139
|
+
case "APPLICATION": {
|
|
140
|
+
subtasks.push({
|
|
141
|
+
title: `Pushing application ${resource.location}...`,
|
|
142
|
+
task: async (_ctx, task) => {
|
|
143
|
+
const applicationConfig = {
|
|
144
|
+
...(await (0, version_control_1.readApplicationFromDisk)(superblocksRootPath, resource.location)),
|
|
145
|
+
commitId: ctx.headCommitId,
|
|
146
|
+
commitMessage: ctx.headCommitMessage,
|
|
147
|
+
};
|
|
148
|
+
task.title += `: read from disk`;
|
|
149
|
+
await this.getSdk().pushApplication({
|
|
150
|
+
applicationId: resourceId,
|
|
151
|
+
applicationConfig,
|
|
152
|
+
branch: ctx.pushToBranchName,
|
|
153
|
+
});
|
|
154
|
+
task.title += `: pushed to Superblocks`;
|
|
155
|
+
ctx.pushedResources[resourceId] = resource;
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
default: {
|
|
161
|
+
this.error(`Unsupported resource type, resource: ${JSON.stringify(resource)}
|
|
162
|
+
`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return task.newListr(subtasks, {
|
|
167
|
+
concurrent: true,
|
|
168
|
+
});
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
], {
|
|
172
|
+
concurrent: false,
|
|
173
|
+
});
|
|
174
|
+
return tasks;
|
|
175
|
+
}
|
|
176
|
+
async getResourceIdsToPush(ctx, task, resourcePath, supportedResourceTypes = ["APPLICATION"]) {
|
|
177
|
+
var _a, _b, _c;
|
|
178
|
+
const resources = Object.entries((_b = (_a = ctx.existingSuperblocksRootConfig) === null || _a === void 0 ? void 0 : _a.resources) !== null && _b !== void 0 ? _b : {}).filter(([, resource]) => {
|
|
179
|
+
return supportedResourceTypes.includes(resource.resourceType);
|
|
180
|
+
});
|
|
181
|
+
// If there are no resources, or if the user has specified a resource name
|
|
182
|
+
// that doesn't exist, we should throw an error.
|
|
183
|
+
if ((0, lodash_1.isEmpty)(resources)) {
|
|
184
|
+
throw new Error("No resources found in the current project");
|
|
185
|
+
}
|
|
186
|
+
else if (!(0, lodash_1.isEmpty)(resourcePath)) {
|
|
187
|
+
const resource = resources.find(([, resource]) => resource.location === resourcePath);
|
|
188
|
+
if (resource) {
|
|
189
|
+
return [resource[0]];
|
|
190
|
+
}
|
|
191
|
+
throw new Error(`No resource found with the given location: ${resourcePath}`);
|
|
192
|
+
}
|
|
193
|
+
const choices = [];
|
|
194
|
+
const initialSelections = [];
|
|
195
|
+
let counter = 0;
|
|
196
|
+
for (const [resourceId, resource] of resources) {
|
|
197
|
+
choices.push({
|
|
198
|
+
name: resourceId,
|
|
199
|
+
message: resource.location,
|
|
200
|
+
});
|
|
201
|
+
if (((_c = ctx.existingSuperblocksResourceConfig) === null || _c === void 0 ? void 0 : _c.id) === resourceId) {
|
|
202
|
+
initialSelections.push(counter);
|
|
203
|
+
}
|
|
204
|
+
counter++;
|
|
205
|
+
}
|
|
206
|
+
const resourceIdsToPush = choices.length === 1
|
|
207
|
+
? [choices[0].name]
|
|
208
|
+
: await task.prompt([
|
|
209
|
+
{
|
|
210
|
+
type: "MultiSelect",
|
|
211
|
+
name: "resourceIdsToPush",
|
|
212
|
+
message: `Select resources to push (${version_control_1.MULTI_SELECT_PROMPT_HELP})`,
|
|
213
|
+
choices: choices,
|
|
214
|
+
initial: initialSelections,
|
|
215
|
+
validate: version_control_1.atLeastOneSelection,
|
|
216
|
+
prefix: "▸",
|
|
217
|
+
indicator: "◉",
|
|
218
|
+
},
|
|
219
|
+
]);
|
|
220
|
+
return resourceIdsToPush;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
Push.description = "Import objects from local filesystem to Superblocks";
|
|
224
|
+
Push.examples = [
|
|
225
|
+
"<%= config.bin %> <%= command.id %>",
|
|
226
|
+
"<%= config.bin %> <%= command.id %> apps/my-app",
|
|
227
|
+
"<%= config.bin %> <%= command.id %> apps/my-app -b feature-branch",
|
|
228
|
+
];
|
|
229
|
+
Push.flags = {
|
|
230
|
+
branch: core_1.Flags.string({
|
|
231
|
+
char: "b",
|
|
232
|
+
description: "Superblocks branch to push to, the current git branch will be used by default",
|
|
233
|
+
}),
|
|
234
|
+
};
|
|
235
|
+
Push.args = {
|
|
236
|
+
resource_path: core_1.Args.string({
|
|
237
|
+
description: "Superblocks resource location to push (e.g. apps/my-app)",
|
|
238
|
+
}),
|
|
239
|
+
};
|
|
240
|
+
exports.default = Push;
|
package/dist/commands/rm.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export default class Remove extends AuthenticatedCommand {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static args: {
|
|
6
|
-
|
|
6
|
+
resource_path: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
|
|
7
7
|
};
|
|
8
8
|
run(): Promise<void>;
|
|
9
9
|
private createTasks;
|
package/dist/commands/rm.js
CHANGED
|
@@ -40,7 +40,7 @@ class Remove extends authenticated_command_1.AuthenticatedCommand {
|
|
|
40
40
|
task: (ctx, task) => task.newListr([
|
|
41
41
|
{
|
|
42
42
|
title: "Fetching applications...",
|
|
43
|
-
enabled: () => !args.
|
|
43
|
+
enabled: () => !args.resource_path,
|
|
44
44
|
task: async (ctx, task) => {
|
|
45
45
|
// applications choices
|
|
46
46
|
const applications = await this.getSdk().fetchApplications();
|
|
@@ -104,8 +104,8 @@ class Remove extends authenticated_command_1.AuthenticatedCommand {
|
|
|
104
104
|
}
|
|
105
105
|
async getResourcesToRemove(ctx, task, args) {
|
|
106
106
|
var _a;
|
|
107
|
-
if (args.
|
|
108
|
-
const [resourceId] = getResourceIdFromLocation(ctx, args.
|
|
107
|
+
if (args.resource_path) {
|
|
108
|
+
const [resourceId] = getResourceIdFromLocation(ctx, args.resource_path);
|
|
109
109
|
return [resourceId];
|
|
110
110
|
}
|
|
111
111
|
else {
|
|
@@ -169,7 +169,7 @@ Remove.examples = [
|
|
|
169
169
|
"<%= config.bin %> <%= command.id %> apps/my-spectacular-app",
|
|
170
170
|
];
|
|
171
171
|
Remove.args = {
|
|
172
|
-
|
|
172
|
+
resource_path: core_1.Args.string({
|
|
173
173
|
description: "Superblocks resource location (i.e. apps/my-spectacular-app)",
|
|
174
174
|
}),
|
|
175
175
|
};
|
|
@@ -126,8 +126,10 @@ class AuthenticatedApplicationCommand extends AuthenticatedCommand {
|
|
|
126
126
|
}
|
|
127
127
|
core_1.ux.action.start("Checking application...");
|
|
128
128
|
try {
|
|
129
|
+
const branch = (await (0, version_control_1.getCurrentGitBranchIfGit)()) || version_control_1.DEFAULT_BRANCH;
|
|
129
130
|
const application = await this.getSdk().fetchApplication({
|
|
130
131
|
applicationId: this.applicationConfig.id,
|
|
132
|
+
branch: branch,
|
|
131
133
|
});
|
|
132
134
|
core_1.ux.action.stop();
|
|
133
135
|
if ((_b = (_a = application === null || application === void 0 ? void 0 : application.application) === null || _a === void 0 ? void 0 : _a.settings) === null || _b === void 0 ? void 0 : _b.cliVersion) {
|
|
@@ -1,15 +1,27 @@
|
|
|
1
|
-
import { ViewMode } from "@superblocksteam/sdk";
|
|
1
|
+
import { ApplicationWrapper, ViewMode } from "@superblocksteam/sdk";
|
|
2
2
|
import { VersionedResourceConfig } from "@superblocksteam/util";
|
|
3
3
|
export declare const LATEST_EDITS_MODE = "latest-edits";
|
|
4
4
|
export declare const MOST_RECENT_COMMIT_MODE = "most-recent-commit";
|
|
5
5
|
export declare const DEPLOYED_MODE = "deployed";
|
|
6
|
+
export declare const DEFAULT_BRANCH = "main";
|
|
6
7
|
export declare const modeFlagValuesMap: Record<string, string>;
|
|
7
8
|
export declare function modeFlagToViewMode(modeFlag: ModeFlag): ViewMode;
|
|
8
9
|
export type ModeFlag = (keyof typeof modeFlagValuesMap)[number];
|
|
9
10
|
export declare const SELECT_PROMPT_HELP = "Use \u2191/\u2193 arrow keys, Enter to confirm";
|
|
10
11
|
export declare const MULTI_SELECT_PROMPT_HELP = "Type to filter, Use \u2191/\u2193 arrow keys, Space to select, Enter to confirm";
|
|
11
12
|
export declare const atLeastOneSelection: (value: string[]) => string | true;
|
|
13
|
+
export declare function readApplicationFromDisk(rootPath: string, existingRelativeLocation: string): Promise<ApplicationWrapper>;
|
|
12
14
|
export declare function writeResourceToDisk(resourceType: string, resourceId: string, resource: any, rootPath: string, existingRelativeLocation?: string): Promise<VersionedResourceConfig>;
|
|
13
15
|
export declare function removeResourceFromDisk(resourceLocation: string): Promise<void>;
|
|
14
16
|
export declare function getMode(task: any, mode: ModeFlag): Promise<ViewMode>;
|
|
15
17
|
export declare function sortByKey(obj: unknown): unknown;
|
|
18
|
+
/**
|
|
19
|
+
* Returns the current git branch, or undefined if not in a git repo
|
|
20
|
+
*/
|
|
21
|
+
export declare function getCurrentGitBranchIfGit(): Promise<string | null>;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the current git branch, or throws if not in a git repo
|
|
24
|
+
*/
|
|
25
|
+
export declare function getCurrentGitBranch(): Promise<string>;
|
|
26
|
+
export declare function getHeadCommit(branch: string): Promise<[string, string]>;
|
|
27
|
+
export declare function isGitRepoDirty(): Promise<boolean>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sortByKey = exports.getMode = exports.removeResourceFromDisk = 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;
|
|
3
|
+
exports.isGitRepoDirty = exports.getHeadCommit = exports.getCurrentGitBranch = exports.getCurrentGitBranchIfGit = exports.sortByKey = exports.getMode = exports.removeResourceFromDisk = exports.writeResourceToDisk = exports.readApplicationFromDisk = exports.atLeastOneSelection = exports.MULTI_SELECT_PROMPT_HELP = exports.SELECT_PROMPT_HELP = exports.modeFlagToViewMode = exports.modeFlagValuesMap = exports.DEFAULT_BRANCH = exports.DEPLOYED_MODE = exports.MOST_RECENT_COMMIT_MODE = exports.LATEST_EDITS_MODE = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const https = tslib_1.__importStar(require("https"));
|
|
6
6
|
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
@@ -10,11 +10,13 @@ const colorette_1 = require("colorette");
|
|
|
10
10
|
const fs = tslib_1.__importStar(require("fs-extra"));
|
|
11
11
|
const lodash_1 = require("lodash");
|
|
12
12
|
const lodash_2 = tslib_1.__importDefault(require("lodash"));
|
|
13
|
+
const simple_git_1 = require("simple-git");
|
|
13
14
|
const slugify_1 = tslib_1.__importDefault(require("slugify"));
|
|
14
15
|
const yaml_1 = require("yaml");
|
|
15
16
|
exports.LATEST_EDITS_MODE = "latest-edits";
|
|
16
17
|
exports.MOST_RECENT_COMMIT_MODE = "most-recent-commit";
|
|
17
18
|
exports.DEPLOYED_MODE = "deployed";
|
|
19
|
+
exports.DEFAULT_BRANCH = "main";
|
|
18
20
|
exports.modeFlagValuesMap = {
|
|
19
21
|
[exports.LATEST_EDITS_MODE]: "Latest edits",
|
|
20
22
|
[exports.MOST_RECENT_COMMIT_MODE]: "Most recent commit",
|
|
@@ -87,8 +89,38 @@ async function downloadFile(rootDirectory, filepath, url) {
|
|
|
87
89
|
}
|
|
88
90
|
return Promise.resolve("");
|
|
89
91
|
}
|
|
92
|
+
async function readYamlFile(path) {
|
|
93
|
+
return (0, yaml_1.parse)(await fs.readFile(path, "utf8"));
|
|
94
|
+
}
|
|
95
|
+
// NOTE: If a change is made to how applications are read from disk, please update
|
|
96
|
+
// logic to write applications to disk in the "writeResourceToDisk" function accordingly.
|
|
97
|
+
async function readApplicationFromDisk(rootPath, existingRelativeLocation) {
|
|
98
|
+
const application = await readYamlFile(`${rootPath}/${existingRelativeLocation}/application.yaml`);
|
|
99
|
+
const page = await readYamlFile(`${rootPath}/${existingRelativeLocation}/page.yaml`);
|
|
100
|
+
const apisDirName = `${rootPath}/${existingRelativeLocation}/apis`;
|
|
101
|
+
const apis = [];
|
|
102
|
+
if (await fs.pathExists(apisDirName)) {
|
|
103
|
+
const apiFiles = await fs.readdir(apisDirName);
|
|
104
|
+
for (const apiFile of apiFiles) {
|
|
105
|
+
const apiContent = await readYamlFile(`${apisDirName}/${apiFile}`);
|
|
106
|
+
// This mimics the shape of the ApiV3Dto object
|
|
107
|
+
apis.push({
|
|
108
|
+
id: apiContent.metadata.id,
|
|
109
|
+
apiPb: apiContent,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
application,
|
|
115
|
+
apis,
|
|
116
|
+
page,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
exports.readApplicationFromDisk = readApplicationFromDisk;
|
|
120
|
+
// NOTE: If a change is made to how applications are written to disk, please update
|
|
121
|
+
// logic to read applications from disk in the "readApplicationFromDisk" function accordingly.
|
|
90
122
|
async function writeResourceToDisk(resourceType, resourceId, resource, rootPath, existingRelativeLocation) {
|
|
91
|
-
var _a, _b, _c, _d, _e, _f
|
|
123
|
+
var _a, _b, _c, _d, _e, _f;
|
|
92
124
|
switch (resourceType) {
|
|
93
125
|
case "APPLICATION": {
|
|
94
126
|
const parentDirName = "apps";
|
|
@@ -105,6 +137,7 @@ async function writeResourceToDisk(resourceType, resourceId, resource, rootPath,
|
|
|
105
137
|
if (resource.page) {
|
|
106
138
|
const pageContent = (0, yaml_1.stringify)(resource.page, {
|
|
107
139
|
sortMapEntries: true,
|
|
140
|
+
blockQuote: "literal",
|
|
108
141
|
});
|
|
109
142
|
await fs.outputFile(`${appDirName}/page.yaml`, pageContent);
|
|
110
143
|
}
|
|
@@ -119,10 +152,11 @@ async function writeResourceToDisk(resourceType, resourceId, resource, rootPath,
|
|
|
119
152
|
};
|
|
120
153
|
if (resource.apis) {
|
|
121
154
|
for (const api of resource.apis) {
|
|
122
|
-
const originalApiName =
|
|
155
|
+
const originalApiName = api.apiPb.metadata.name;
|
|
123
156
|
const apiName = slugifyName(originalApiName);
|
|
124
157
|
const apiContent = (0, yaml_1.stringify)(api.apiPb, {
|
|
125
158
|
sortMapEntries: true,
|
|
159
|
+
blockQuote: "literal",
|
|
126
160
|
});
|
|
127
161
|
const handleApi = async () => {
|
|
128
162
|
await fs.outputFile(`${apisDirName}/${apiName}.yaml`, apiContent);
|
|
@@ -136,7 +170,7 @@ async function writeResourceToDisk(resourceType, resourceId, resource, rootPath,
|
|
|
136
170
|
await fs.writeFile(`${appDirName}/${util_1.RESOURCE_CONFIG_PATH}`, JSON.stringify(sortByKey(applicationConfig), null, 2));
|
|
137
171
|
const createdFiles = await Promise.resolve(
|
|
138
172
|
// Defensive check for when application settings are missing componentFiles
|
|
139
|
-
(
|
|
173
|
+
(_c = (_b = resource.componentFiles) === null || _b === void 0 ? void 0 : _b.map((file) => downloadFile(appDirName, file.filename, file.url))) !== null && _c !== void 0 ? _c : []);
|
|
140
174
|
// print out failed downloads synchronously here
|
|
141
175
|
createdFiles
|
|
142
176
|
.filter((createdFiles) => createdFiles.length)
|
|
@@ -150,7 +184,7 @@ async function writeResourceToDisk(resourceType, resourceId, resource, rootPath,
|
|
|
150
184
|
}
|
|
151
185
|
case "BACKEND": {
|
|
152
186
|
const parentDirName = "backends";
|
|
153
|
-
const apiName = slugifyName((
|
|
187
|
+
const apiName = slugifyName((_f = (_e = (_d = resource.apiPb) === null || _d === void 0 ? void 0 : _d.metadata) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : resource.actions.name);
|
|
154
188
|
const newRelativeLocation = `${parentDirName}/${apiName}`;
|
|
155
189
|
const relativeLocation = existingRelativeLocation !== null && existingRelativeLocation !== void 0 ? existingRelativeLocation : newRelativeLocation;
|
|
156
190
|
const backendDirName = node_path_1.default.resolve(rootPath, relativeLocation);
|
|
@@ -159,6 +193,7 @@ async function writeResourceToDisk(resourceType, resourceId, resource, rootPath,
|
|
|
159
193
|
}
|
|
160
194
|
const backendContent = (0, yaml_1.stringify)(resource.apiPb, {
|
|
161
195
|
sortMapEntries: true,
|
|
196
|
+
blockQuote: "literal",
|
|
162
197
|
});
|
|
163
198
|
await fs.outputFile(`${backendDirName}/api.yaml`, backendContent);
|
|
164
199
|
const backendConfig = {
|
|
@@ -217,3 +252,52 @@ function sortByKey(obj) {
|
|
|
217
252
|
return obj;
|
|
218
253
|
}
|
|
219
254
|
exports.sortByKey = sortByKey;
|
|
255
|
+
/**
|
|
256
|
+
* Returns the current git branch, or undefined if not in a git repo
|
|
257
|
+
*/
|
|
258
|
+
async function getCurrentGitBranchIfGit() {
|
|
259
|
+
const git = (0, simple_git_1.simpleGit)();
|
|
260
|
+
try {
|
|
261
|
+
const status = await git.status();
|
|
262
|
+
const currentBranch = status.current;
|
|
263
|
+
return currentBranch;
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
// ignore
|
|
267
|
+
}
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
exports.getCurrentGitBranchIfGit = getCurrentGitBranchIfGit;
|
|
271
|
+
/**
|
|
272
|
+
* Returns the current git branch, or throws if not in a git repo
|
|
273
|
+
*/
|
|
274
|
+
async function getCurrentGitBranch() {
|
|
275
|
+
const currentBranch = await getCurrentGitBranchIfGit();
|
|
276
|
+
if (!currentBranch) {
|
|
277
|
+
throw new Error("No git repository found");
|
|
278
|
+
}
|
|
279
|
+
return currentBranch;
|
|
280
|
+
}
|
|
281
|
+
exports.getCurrentGitBranch = getCurrentGitBranch;
|
|
282
|
+
async function getHeadCommit(branch) {
|
|
283
|
+
const git = (0, simple_git_1.simpleGit)();
|
|
284
|
+
let headCommitId;
|
|
285
|
+
let headCommitMessage;
|
|
286
|
+
const logResponse = await git.show(["--no-patch", "--format=%H%n%s", branch]);
|
|
287
|
+
const logLines = logResponse.split("\n");
|
|
288
|
+
if (logLines.length > 1) {
|
|
289
|
+
headCommitId = logLines[0];
|
|
290
|
+
headCommitMessage = logLines[1];
|
|
291
|
+
}
|
|
292
|
+
if (!headCommitId || !headCommitMessage) {
|
|
293
|
+
throw new Error(`Failed to get head commit for branch '${branch}'`);
|
|
294
|
+
}
|
|
295
|
+
return [headCommitId, headCommitMessage];
|
|
296
|
+
}
|
|
297
|
+
exports.getHeadCommit = getHeadCommit;
|
|
298
|
+
async function isGitRepoDirty() {
|
|
299
|
+
const git = (0, simple_git_1.simpleGit)();
|
|
300
|
+
const status = await git.status();
|
|
301
|
+
return !status.isClean();
|
|
302
|
+
}
|
|
303
|
+
exports.isGitRepoDirty = isGitRepoDirty;
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0
|
|
2
|
+
"version": "1.1.0",
|
|
3
3
|
"commands": {
|
|
4
4
|
"init": {
|
|
5
5
|
"id": "init",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"args": {
|
|
31
|
-
"
|
|
32
|
-
"name": "
|
|
31
|
+
"resource_url": {
|
|
32
|
+
"name": "resource_url",
|
|
33
33
|
"description": "Superblocks resource URL (i.e. https://app.superblocks.com/applications/<application_id>/pages/<page_id>)",
|
|
34
34
|
"required": false
|
|
35
35
|
}
|
|
@@ -79,8 +79,7 @@
|
|
|
79
79
|
"examples": [
|
|
80
80
|
"<%= config.bin %> <%= command.id %>",
|
|
81
81
|
"<%= config.bin %> <%= command.id %> apps/my-app",
|
|
82
|
-
"<%= config.bin %> <%= command.id %>
|
|
83
|
-
"<%= config.bin %> <%= command.id %> backends/my-scheduled-job"
|
|
82
|
+
"<%= config.bin %> <%= command.id %> apps/my-app -b feature-branch"
|
|
84
83
|
],
|
|
85
84
|
"flags": {
|
|
86
85
|
"mode": {
|
|
@@ -95,16 +94,52 @@
|
|
|
95
94
|
"deployed"
|
|
96
95
|
],
|
|
97
96
|
"default": "latest-edits"
|
|
97
|
+
},
|
|
98
|
+
"branch": {
|
|
99
|
+
"name": "branch",
|
|
100
|
+
"type": "option",
|
|
101
|
+
"char": "b",
|
|
102
|
+
"description": "Superblocks branch to pull from, the current git branch will be used by default",
|
|
103
|
+
"multiple": false
|
|
98
104
|
}
|
|
99
105
|
},
|
|
100
106
|
"args": {
|
|
101
|
-
"
|
|
102
|
-
"name": "
|
|
103
|
-
"description": "Superblocks resource location to pull (i.e. apps/my-app
|
|
107
|
+
"resource_path": {
|
|
108
|
+
"name": "resource_path",
|
|
109
|
+
"description": "Superblocks resource location to pull (i.e. apps/my-app)",
|
|
104
110
|
"required": false
|
|
105
111
|
}
|
|
106
112
|
}
|
|
107
113
|
},
|
|
114
|
+
"push": {
|
|
115
|
+
"id": "push",
|
|
116
|
+
"description": "Import objects from local filesystem to Superblocks",
|
|
117
|
+
"strict": true,
|
|
118
|
+
"pluginName": "@superblocksteam/cli",
|
|
119
|
+
"pluginAlias": "@superblocksteam/cli",
|
|
120
|
+
"pluginType": "core",
|
|
121
|
+
"aliases": [],
|
|
122
|
+
"examples": [
|
|
123
|
+
"<%= config.bin %> <%= command.id %>",
|
|
124
|
+
"<%= config.bin %> <%= command.id %> apps/my-app",
|
|
125
|
+
"<%= config.bin %> <%= command.id %> apps/my-app -b feature-branch"
|
|
126
|
+
],
|
|
127
|
+
"flags": {
|
|
128
|
+
"branch": {
|
|
129
|
+
"name": "branch",
|
|
130
|
+
"type": "option",
|
|
131
|
+
"char": "b",
|
|
132
|
+
"description": "Superblocks branch to push to, the current git branch will be used by default",
|
|
133
|
+
"multiple": false
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
"args": {
|
|
137
|
+
"resource_path": {
|
|
138
|
+
"name": "resource_path",
|
|
139
|
+
"description": "Superblocks resource location to push (e.g. apps/my-app)"
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
},
|
|
108
143
|
"rm": {
|
|
109
144
|
"id": "rm",
|
|
110
145
|
"description": "Remove a Superblocks resource from the local Superblocks project and delete the resource folder directory locally (if it exists)",
|
|
@@ -119,8 +154,8 @@
|
|
|
119
154
|
],
|
|
120
155
|
"flags": {},
|
|
121
156
|
"args": {
|
|
122
|
-
"
|
|
123
|
-
"name": "
|
|
157
|
+
"resource_path": {
|
|
158
|
+
"name": "resource_path",
|
|
124
159
|
"description": "Superblocks resource location (i.e. apps/my-spectacular-app)"
|
|
125
160
|
}
|
|
126
161
|
}
|
|
@@ -166,9 +201,18 @@
|
|
|
166
201
|
"pluginType": "core",
|
|
167
202
|
"aliases": [],
|
|
168
203
|
"examples": [
|
|
169
|
-
"<%= config.bin %> components upload"
|
|
204
|
+
"<%= config.bin %> components upload",
|
|
205
|
+
"<%= config.bin %> components upload -b feature-branch"
|
|
170
206
|
],
|
|
171
|
-
"flags": {
|
|
207
|
+
"flags": {
|
|
208
|
+
"branch": {
|
|
209
|
+
"name": "branch",
|
|
210
|
+
"type": "option",
|
|
211
|
+
"char": "b",
|
|
212
|
+
"description": "Superblocks branch to push to, the current (local) git branch will be used by default",
|
|
213
|
+
"multiple": false
|
|
214
|
+
}
|
|
215
|
+
},
|
|
172
216
|
"args": {}
|
|
173
217
|
},
|
|
174
218
|
"components:watch": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superblocksteam/cli",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Official Superblocks CLI",
|
|
5
5
|
"bin": {
|
|
6
6
|
"superblocks": "bin/run"
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"@oclif/core": "^2.11.7",
|
|
19
19
|
"@oclif/plugin-help": "^5.2.16",
|
|
20
20
|
"@oclif/plugin-plugins": "^3.1.10",
|
|
21
|
-
"@superblocksteam/css-plugin": "1.0
|
|
22
|
-
"@superblocksteam/react-shim": "1.0
|
|
23
|
-
"@superblocksteam/sdk": "1.0
|
|
24
|
-
"@superblocksteam/util": "1.0
|
|
25
|
-
"@superblocksteam/vite-custom-component-reload-plugin": "1.0
|
|
21
|
+
"@superblocksteam/css-plugin": "1.1.0",
|
|
22
|
+
"@superblocksteam/react-shim": "1.1.0",
|
|
23
|
+
"@superblocksteam/sdk": "1.1.0",
|
|
24
|
+
"@superblocksteam/util": "1.1.0",
|
|
25
|
+
"@superblocksteam/vite-custom-component-reload-plugin": "1.1.0",
|
|
26
26
|
"@vitejs/plugin-react": "^4.0.4",
|
|
27
27
|
"colorette": "^2.0.19",
|
|
28
28
|
"enquirer": "^2.3.6",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"listr2": "6.6.0",
|
|
31
31
|
"lodash": "^4.17.21",
|
|
32
32
|
"semver": "^7.5.4",
|
|
33
|
+
"simple-git": "^3.20.0",
|
|
33
34
|
"slugify": "^1.6.6",
|
|
34
35
|
"vite": "^4.4.8",
|
|
35
36
|
"vite-plugin-inspect": "^0.7.28",
|
|
@@ -59,7 +60,7 @@
|
|
|
59
60
|
"typescript": "^5.1.6"
|
|
60
61
|
},
|
|
61
62
|
"scripts": {
|
|
62
|
-
"preinstall": "node -e
|
|
63
|
+
"preinstall": "node -e \"if (process.versions.node.split('.')[0] < 16) { console.error('Incompatible Node version: Please use Node.js v16 or higher'); process.exit(1);}\"",
|
|
63
64
|
"build": "tsc --build",
|
|
64
65
|
"clean": "npm run clean:build && rm -rf node_modules",
|
|
65
66
|
"clean:build": "tsc --build --clean && rm -rf dist tsconfig.tsbuildinfo",
|