@superblocksteam/cli 1.8.0 → 1.9.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 +51 -9
- package/assets/custom-components/setup/package.json +1 -1
- package/dist/commands/commits.d.ts +18 -0
- package/dist/commands/commits.js +298 -0
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.js +18 -2
- package/dist/commands/migrate.js +1 -2
- package/dist/commands/pull.d.ts +2 -0
- package/dist/commands/pull.js +58 -31
- package/dist/commands/push.d.ts +1 -0
- package/dist/commands/push.js +82 -27
- package/dist/common/version-control.d.ts +2 -1
- package/dist/common/version-control.js +3 -34
- package/oclif.manifest.json +81 -3
- package/package.json +6 -6
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.
|
|
15
|
+
@superblocksteam/cli/1.9.0 linux-x64 node-v18.20.4
|
|
16
16
|
$ superblocks --help [COMMAND]
|
|
17
17
|
USAGE
|
|
18
18
|
$ superblocks COMMAND
|
|
@@ -21,6 +21,7 @@ USAGE
|
|
|
21
21
|
<!-- usagestop -->
|
|
22
22
|
# Commands
|
|
23
23
|
<!-- commands -->
|
|
24
|
+
* [`superblocks commits [RESOURCE_PATH]`](#superblocks-commits-resource_path)
|
|
24
25
|
* [`superblocks components create`](#superblocks-components-create)
|
|
25
26
|
* [`superblocks components register`](#superblocks-components-register)
|
|
26
27
|
* [`superblocks components upload`](#superblocks-components-upload)
|
|
@@ -34,6 +35,37 @@ USAGE
|
|
|
34
35
|
* [`superblocks push [RESOURCE_PATH]`](#superblocks-push-resource_path)
|
|
35
36
|
* [`superblocks rm [RESOURCE_PATH]`](#superblocks-rm-resource_path)
|
|
36
37
|
|
|
38
|
+
## `superblocks commits [RESOURCE_PATH]`
|
|
39
|
+
|
|
40
|
+
List Superblocks commits for a resource
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
USAGE
|
|
44
|
+
$ superblocks commits [RESOURCE_PATH] [-b <value>] [-l <value>] [-o <value>]
|
|
45
|
+
|
|
46
|
+
ARGUMENTS
|
|
47
|
+
RESOURCE_PATH Superblocks resource location to show commits for (i.e. apps/my-app)
|
|
48
|
+
|
|
49
|
+
FLAGS
|
|
50
|
+
-b, --branch=<value> Superblocks branch to show commits for, the current git branch will be used by default
|
|
51
|
+
-l, --limit=<value> [default: 10] Number of commits to be displayed, default is 10
|
|
52
|
+
-o, --offset=<value> Number of commits to be skipped before displaying by creation time, default is 0
|
|
53
|
+
|
|
54
|
+
DESCRIPTION
|
|
55
|
+
List Superblocks commits for a resource
|
|
56
|
+
|
|
57
|
+
EXAMPLES
|
|
58
|
+
$ superblocks commits
|
|
59
|
+
|
|
60
|
+
$ superblocks commits apps/my-app
|
|
61
|
+
|
|
62
|
+
$ superblocks commits apps/my-app -b feature-branch
|
|
63
|
+
|
|
64
|
+
$ superblocks commits --limit 20
|
|
65
|
+
|
|
66
|
+
$ superblocks commits --offset 10
|
|
67
|
+
```
|
|
68
|
+
|
|
37
69
|
## `superblocks components create`
|
|
38
70
|
|
|
39
71
|
Creates a new Superblocks component in the current application folder
|
|
@@ -144,15 +176,16 @@ Interactively configure the current directory as a Superblocks project or initia
|
|
|
144
176
|
|
|
145
177
|
```
|
|
146
178
|
USAGE
|
|
147
|
-
$ superblocks init [RESOURCE_URL] [-m latest-edits|most-recent-commit|deployed]
|
|
179
|
+
$ superblocks init [RESOURCE_URL] [-m latest-edits|most-recent-commit|deployed] [-s]
|
|
148
180
|
|
|
149
181
|
ARGUMENTS
|
|
150
182
|
RESOURCE_URL Superblocks resource URL (i.e. https://app.superblocks.com/applications/<application_id> or
|
|
151
183
|
https://app.superblocks.com/applications/edit/<application_id>)
|
|
152
184
|
|
|
153
185
|
FLAGS
|
|
154
|
-
-m, --mode=<option>
|
|
155
|
-
|
|
186
|
+
-m, --mode=<option> Pull mode
|
|
187
|
+
<options: latest-edits|most-recent-commit|deployed>
|
|
188
|
+
-s, --skip-signing-verification If true, signature verification for signing enabled organizations will be skipped.
|
|
156
189
|
|
|
157
190
|
DESCRIPTION
|
|
158
191
|
Interactively configure the current directory as a Superblocks project or initialize new services in an already
|
|
@@ -200,15 +233,18 @@ Download objects from Superblocks and save them locally
|
|
|
200
233
|
|
|
201
234
|
```
|
|
202
235
|
USAGE
|
|
203
|
-
$ superblocks pull [RESOURCE_PATH] [-m latest-edits|most-recent-commit|deployed] [-b <value>]
|
|
236
|
+
$ superblocks pull [RESOURCE_PATH] [-m latest-edits|most-recent-commit|deployed] [-b <value>] [-c
|
|
237
|
+
<value>] [-s]
|
|
204
238
|
|
|
205
239
|
ARGUMENTS
|
|
206
240
|
RESOURCE_PATH Superblocks resource location to pull (i.e. apps/my-app)
|
|
207
241
|
|
|
208
242
|
FLAGS
|
|
209
|
-
-b, --branch=<value>
|
|
210
|
-
-
|
|
211
|
-
|
|
243
|
+
-b, --branch=<value> Superblocks branch to pull from, the current git branch will be used by default
|
|
244
|
+
-c, --commit-id=<value> Superblocks commit id to pull, the live edit will be used by default
|
|
245
|
+
-m, --mode=<option> [default: latest-edits] Pull mode
|
|
246
|
+
<options: latest-edits|most-recent-commit|deployed>
|
|
247
|
+
-s, --skip-signing-verification If true, signature verification for signing enabled organizations will be skipped.
|
|
212
248
|
|
|
213
249
|
DESCRIPTION
|
|
214
250
|
Download objects from Superblocks and save them locally
|
|
@@ -219,6 +255,8 @@ EXAMPLES
|
|
|
219
255
|
$ superblocks pull apps/my-app
|
|
220
256
|
|
|
221
257
|
$ superblocks pull apps/my-app -b feature-branch
|
|
258
|
+
|
|
259
|
+
$ superblocks pull apps/my-app -c commit-id
|
|
222
260
|
```
|
|
223
261
|
|
|
224
262
|
## `superblocks push [RESOURCE_PATH]`
|
|
@@ -227,13 +265,15 @@ Import objects from local filesystem to Superblocks
|
|
|
227
265
|
|
|
228
266
|
```
|
|
229
267
|
USAGE
|
|
230
|
-
$ superblocks push [RESOURCE_PATH] [-b <value>]
|
|
268
|
+
$ superblocks push [RESOURCE_PATH] [-b <value>] [-s]
|
|
231
269
|
|
|
232
270
|
ARGUMENTS
|
|
233
271
|
RESOURCE_PATH Superblocks resource location to push (e.g. apps/my-app)
|
|
234
272
|
|
|
235
273
|
FLAGS
|
|
236
274
|
-b, --branch=<value> Superblocks branch to push to, the current git branch will be used by default
|
|
275
|
+
-s, --skip-commit If true, push command will only update live edit state along with signature without creating a
|
|
276
|
+
commit.
|
|
237
277
|
|
|
238
278
|
DESCRIPTION
|
|
239
279
|
Import objects from local filesystem to Superblocks
|
|
@@ -244,6 +284,8 @@ EXAMPLES
|
|
|
244
284
|
$ superblocks push apps/my-app
|
|
245
285
|
|
|
246
286
|
$ superblocks push apps/my-app -b feature-branch
|
|
287
|
+
|
|
288
|
+
$ superblocks push apps/my-app --skip-commit
|
|
247
289
|
```
|
|
248
290
|
|
|
249
291
|
## `superblocks rm [RESOURCE_PATH]`
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { GetCommitsResponseBody } from "@superblocksteam/sdk";
|
|
2
|
+
import { AuthenticatedCommand } from "../common/authenticated-command";
|
|
3
|
+
export default class Commits extends AuthenticatedCommand {
|
|
4
|
+
static description: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static flags: {
|
|
7
|
+
branch: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
|
+
limit: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
|
+
offset: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
|
+
};
|
|
11
|
+
static args: {
|
|
12
|
+
resource_path: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<void>;
|
|
15
|
+
private createTasks;
|
|
16
|
+
private getResourceIdToShowCommits;
|
|
17
|
+
printCommits(commits: GetCommitsResponseBody, branch?: string): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,298 @@
|
|
|
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 authenticated_command_1 = require("../common/authenticated-command");
|
|
9
|
+
const version_control_1 = require("../common/version-control");
|
|
10
|
+
class Commits extends authenticated_command_1.AuthenticatedCommand {
|
|
11
|
+
async run() {
|
|
12
|
+
const { flags, args } = await this.parse(Commits);
|
|
13
|
+
const tasks = this.createTasks(args.resource_path, flags.branch, flags.limit, flags.offset);
|
|
14
|
+
await tasks.run();
|
|
15
|
+
}
|
|
16
|
+
createTasks(resourcePath, branch, limit, offset) {
|
|
17
|
+
const tasks = new listr2_1.Listr([
|
|
18
|
+
{
|
|
19
|
+
title: "Checking for existing Superblocks project...",
|
|
20
|
+
task: async (ctx) => {
|
|
21
|
+
ctx.writtenResources = {};
|
|
22
|
+
ctx.removedResourceIds = [];
|
|
23
|
+
try {
|
|
24
|
+
[
|
|
25
|
+
ctx.existingSuperblocksRootConfig,
|
|
26
|
+
ctx.superblocksRootConfigPath,
|
|
27
|
+
] = await (0, util_1.getSuperblocksMonorepoConfigJson)(true);
|
|
28
|
+
ctx.existingSuperblocksResourceConfig =
|
|
29
|
+
await (0, util_1.getSuperblocksResourceConfigIfExists)();
|
|
30
|
+
ctx.superblocksRootPath = node_path_1.default.resolve(node_path_1.default.dirname(ctx.superblocksRootConfigPath), "..");
|
|
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
|
+
ctx.branchToShowCommitsFor = new Map();
|
|
42
|
+
try {
|
|
43
|
+
ctx.localBranchName =
|
|
44
|
+
branch || (await (0, version_control_1.getCurrentGitBranchIfGit)()) || version_control_1.DEFAULT_BRANCH;
|
|
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
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
title: "Checking for deleted Superblocks resources...",
|
|
53
|
+
task: async (ctx, task) => {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
try {
|
|
56
|
+
for (const [resourceId, resource] of Object.entries((_b = (_a = ctx.existingSuperblocksRootConfig) === null || _a === void 0 ? void 0 : _a.resources) !== null && _b !== void 0 ? _b : {})) {
|
|
57
|
+
switch (resource === null || resource === void 0 ? void 0 : resource.resourceType) {
|
|
58
|
+
case "APPLICATION": {
|
|
59
|
+
try {
|
|
60
|
+
await this.getSdk().fetchApplication({
|
|
61
|
+
applicationId: resourceId,
|
|
62
|
+
// signing check is not relevant to find deleted resources
|
|
63
|
+
skipSigningVerification: true,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
if (error instanceof util_1.NotFoundError) {
|
|
68
|
+
ctx.removedResourceIds.push(resourceId);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
case "BACKEND": {
|
|
77
|
+
try {
|
|
78
|
+
await this.getSdk().fetchApi({
|
|
79
|
+
apiId: resourceId,
|
|
80
|
+
// signing check is not relevant to find deleted resources
|
|
81
|
+
skipSigningVerification: true,
|
|
82
|
+
});
|
|
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
|
+
await (0, version_control_1.deleteResourcesAndUpdateRootConfig)(ctx.removedResourceIds, ctx.existingSuperblocksRootConfig, ctx.superblocksRootPath, ctx.superblocksRootConfigPath);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch (e) {
|
|
122
|
+
this.warn(`Could not check for deleted Superblocks resources. Continuing...: ${e.message}`);
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
task: async (ctx, task) => {
|
|
128
|
+
task.title = `Determining what resource to show commits for...`;
|
|
129
|
+
ctx.resourceIdToShowCommits = await this.getResourceIdToShowCommits(ctx, task, resourcePath);
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
task: async (ctx, task) => {
|
|
134
|
+
var _a, _b;
|
|
135
|
+
task.title = `Get commits for the resource from branch ${ctx.localBranchName}...`;
|
|
136
|
+
const subtasks = [];
|
|
137
|
+
const resourceId = ctx.resourceIdToShowCommits;
|
|
138
|
+
const resource = (_a = ctx.existingSuperblocksRootConfig) === null || _a === void 0 ? void 0 : _a.resources[resourceId];
|
|
139
|
+
const branchName = (_b = ctx.branchToShowCommitsFor.get(resourceId)) !== null && _b !== void 0 ? _b : ctx.localBranchName;
|
|
140
|
+
switch (resource === null || resource === void 0 ? void 0 : resource.resourceType) {
|
|
141
|
+
case "APPLICATION": {
|
|
142
|
+
subtasks.push({
|
|
143
|
+
title: `Fetching commits for application ${resource.location} from branch ${branchName}...`,
|
|
144
|
+
task: async (_ctx, task) => {
|
|
145
|
+
const headers = {
|
|
146
|
+
[util_1.COMPONENT_EVENT_HEADER]: util_1.ComponentEvent.COMMITS,
|
|
147
|
+
};
|
|
148
|
+
try {
|
|
149
|
+
task.title += `: fetched`;
|
|
150
|
+
const applicationCommits = (await this.getSdk().fetchApplicationCommits({
|
|
151
|
+
applicationId: resourceId,
|
|
152
|
+
branch: branchName,
|
|
153
|
+
headers,
|
|
154
|
+
limit,
|
|
155
|
+
offset,
|
|
156
|
+
}));
|
|
157
|
+
this.printCommits(applicationCommits, branchName);
|
|
158
|
+
task.title += `: done`;
|
|
159
|
+
}
|
|
160
|
+
catch (e) {
|
|
161
|
+
if (e instanceof util_1.NotFoundError) {
|
|
162
|
+
task.title += `: not found in this branch. skipped`;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
throw e;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
case "BACKEND": {
|
|
173
|
+
subtasks.push({
|
|
174
|
+
title: `Fetching commits for backend ${resource.location}...`,
|
|
175
|
+
task: async (_ctx, task) => {
|
|
176
|
+
const apiCommits = await this.getSdk().fetchApiCommits({
|
|
177
|
+
apiId: resourceId,
|
|
178
|
+
branch: branchName,
|
|
179
|
+
limit,
|
|
180
|
+
offset,
|
|
181
|
+
});
|
|
182
|
+
task.title += `: fetched`;
|
|
183
|
+
this.printCommits(apiCommits, branchName);
|
|
184
|
+
task.title += `: done`;
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
default: {
|
|
190
|
+
this.error(`Unsupported resource type, resource: ${JSON.stringify(resource)}
|
|
191
|
+
`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return task.newListr(subtasks, {
|
|
195
|
+
concurrent: true,
|
|
196
|
+
});
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
], {
|
|
200
|
+
concurrent: false,
|
|
201
|
+
});
|
|
202
|
+
return tasks;
|
|
203
|
+
}
|
|
204
|
+
async getResourceIdToShowCommits(ctx, task, resourcePath) {
|
|
205
|
+
var _a, _b, _c, _d, _e;
|
|
206
|
+
if (resourcePath) {
|
|
207
|
+
for (const [resourceId, resource] of Object.entries((_b = (_a = ctx.existingSuperblocksRootConfig) === null || _a === void 0 ? void 0 : _a.resources) !== null && _b !== void 0 ? _b : {})) {
|
|
208
|
+
if (resource.location === resourcePath) {
|
|
209
|
+
return resourceId;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
throw new Error(`No resource found with the given location: ${resourcePath}`);
|
|
213
|
+
}
|
|
214
|
+
const resourceConfig = await (0, util_1.getSuperblocksResourceConfigIfExists)();
|
|
215
|
+
if (resourceConfig) {
|
|
216
|
+
return resourceConfig.id;
|
|
217
|
+
}
|
|
218
|
+
const choices = [];
|
|
219
|
+
const initialSelections = [];
|
|
220
|
+
let counter = 0;
|
|
221
|
+
for (const [resourceId, resource] of Object.entries((_d = (_c = ctx.existingSuperblocksRootConfig) === null || _c === void 0 ? void 0 : _c.resources) !== null && _d !== void 0 ? _d : {})) {
|
|
222
|
+
if (ctx.removedResourceIds.includes(resourceId)) {
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
choices.push({
|
|
226
|
+
name: resourceId,
|
|
227
|
+
message: resource.location,
|
|
228
|
+
});
|
|
229
|
+
if (((_e = ctx.existingSuperblocksResourceConfig) === null || _e === void 0 ? void 0 : _e.id) === resourceId) {
|
|
230
|
+
initialSelections.push(counter);
|
|
231
|
+
}
|
|
232
|
+
counter++;
|
|
233
|
+
}
|
|
234
|
+
if (choices.length === 0) {
|
|
235
|
+
throw new Error("No resources found in the Superblocks project");
|
|
236
|
+
}
|
|
237
|
+
const resourceIdToShowCommitFor = choices.length === 1
|
|
238
|
+
? [choices[0].name]
|
|
239
|
+
: await task.prompt([
|
|
240
|
+
{
|
|
241
|
+
type: "Select",
|
|
242
|
+
name: "resourceIdToShowCommits",
|
|
243
|
+
message: `Select a resource to see commits (${version_control_1.SELECT_PROMPT_HELP})`,
|
|
244
|
+
choices: choices,
|
|
245
|
+
initial: initialSelections,
|
|
246
|
+
validate: version_control_1.atLeastOneSelection,
|
|
247
|
+
prefix: "▸",
|
|
248
|
+
indicator: "◉",
|
|
249
|
+
},
|
|
250
|
+
]);
|
|
251
|
+
return resourceIdToShowCommitFor;
|
|
252
|
+
}
|
|
253
|
+
printCommits(commits, branch) {
|
|
254
|
+
var _a;
|
|
255
|
+
if (commits.commits.length === 0) {
|
|
256
|
+
console.log("No commits have been created.");
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
for (const commit of commits.commits) {
|
|
260
|
+
console.log(`commit ${commit.commitId}`, branch ? `(${branch})` : "");
|
|
261
|
+
console.log(`Author: ${(_a = commit.committer.name) !== null && _a !== void 0 ? _a : ""} <${commit.committer.email}>`);
|
|
262
|
+
console.log(`Date: ${new Date(commit.commitDate).toLocaleString()}`);
|
|
263
|
+
console.log(`Message: ${commit.commitMessage}`);
|
|
264
|
+
console.log("---");
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
Commits.description = "List Superblocks commits for a resource";
|
|
269
|
+
Commits.examples = [
|
|
270
|
+
"<%= config.bin %> <%= command.id %>",
|
|
271
|
+
"<%= config.bin %> <%= command.id %> apps/my-app",
|
|
272
|
+
"<%= config.bin %> <%= command.id %> apps/my-app -b feature-branch",
|
|
273
|
+
"<%= config.bin %> <%= command.id %> --limit 20",
|
|
274
|
+
"<%= config.bin %> <%= command.id %> --offset 10",
|
|
275
|
+
];
|
|
276
|
+
Commits.flags = {
|
|
277
|
+
branch: core_1.Flags.string({
|
|
278
|
+
char: "b",
|
|
279
|
+
description: "Superblocks branch to show commits for, the current git branch will be used by default",
|
|
280
|
+
}),
|
|
281
|
+
limit: core_1.Flags.integer({
|
|
282
|
+
char: "l",
|
|
283
|
+
default: 10,
|
|
284
|
+
description: "Number of commits to be displayed, default is 10",
|
|
285
|
+
}),
|
|
286
|
+
offset: core_1.Flags.integer({
|
|
287
|
+
char: "o",
|
|
288
|
+
default: 0,
|
|
289
|
+
description: "Number of commits to be skipped before displaying by creation time, default is 0",
|
|
290
|
+
}),
|
|
291
|
+
};
|
|
292
|
+
Commits.args = {
|
|
293
|
+
resource_path: core_1.Args.string({
|
|
294
|
+
description: "Superblocks resource location to show commits for (i.e. apps/my-app)",
|
|
295
|
+
required: false,
|
|
296
|
+
}),
|
|
297
|
+
};
|
|
298
|
+
exports.default = Commits;
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export default class Initialize extends AuthenticatedCommand {
|
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
6
|
mode: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
"skip-signing-verification": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
7
8
|
};
|
|
8
9
|
static args: {
|
|
9
10
|
resource_url: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
|
package/dist/commands/init.js
CHANGED
|
@@ -21,6 +21,7 @@ class Initialize extends authenticated_command_1.AuthenticatedCommand {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
createTasks(flags, args) {
|
|
24
|
+
const skipSigningVerification = flags["skip-signing-verification"];
|
|
24
25
|
const tasks = new listr2_1.Listr([
|
|
25
26
|
{
|
|
26
27
|
title: "Checking for existing Superblocks project...",
|
|
@@ -86,6 +87,7 @@ class Initialize extends authenticated_command_1.AuthenticatedCommand {
|
|
|
86
87
|
applicationId: resourceId,
|
|
87
88
|
branch: version_control_1.DEFAULT_BRANCH,
|
|
88
89
|
headers,
|
|
90
|
+
skipSigningVerification,
|
|
89
91
|
});
|
|
90
92
|
if (!application) {
|
|
91
93
|
throw new util_1.NotFoundError(`Application ${resourceId} was not found`);
|
|
@@ -96,7 +98,10 @@ class Initialize extends authenticated_command_1.AuthenticatedCommand {
|
|
|
96
98
|
};
|
|
97
99
|
}
|
|
98
100
|
else if (resourceType === "BACKEND") {
|
|
99
|
-
const api = await this.getSdk().fetchApi(
|
|
101
|
+
const api = await this.getSdk().fetchApi({
|
|
102
|
+
apiId: resourceId,
|
|
103
|
+
skipSigningVerification,
|
|
104
|
+
});
|
|
100
105
|
ctx.fetchedResources[api.id] = {
|
|
101
106
|
resourceType,
|
|
102
107
|
name: (0, version_control_1.extractApiName)(api),
|
|
@@ -143,6 +148,7 @@ class Initialize extends authenticated_command_1.AuthenticatedCommand {
|
|
|
143
148
|
branch: version_control_1.DEFAULT_BRANCH,
|
|
144
149
|
viewMode: ctx.viewMode,
|
|
145
150
|
headers,
|
|
151
|
+
skipSigningVerification,
|
|
146
152
|
}));
|
|
147
153
|
task.title += `: fetched`;
|
|
148
154
|
if (application) {
|
|
@@ -158,7 +164,12 @@ class Initialize extends authenticated_command_1.AuthenticatedCommand {
|
|
|
158
164
|
subtasks.push({
|
|
159
165
|
title: `Fetching backend ${resource.name}...`,
|
|
160
166
|
task: async (_ctx, task) => {
|
|
161
|
-
const backend = await this.getSdk().fetchApi(
|
|
167
|
+
const backend = await this.getSdk().fetchApi({
|
|
168
|
+
apiId: resourceId,
|
|
169
|
+
viewMode: ctx.viewMode,
|
|
170
|
+
branch: version_control_1.DEFAULT_BRANCH,
|
|
171
|
+
skipSigningVerification,
|
|
172
|
+
});
|
|
162
173
|
task.title += `: fetched`;
|
|
163
174
|
ctx.writtenResources[resourceId] =
|
|
164
175
|
await (0, version_control_1.writeResourceToDisk)("BACKEND", resourceId, backend, process.cwd());
|
|
@@ -292,6 +303,11 @@ Initialize.flags = {
|
|
|
292
303
|
description: "Pull mode",
|
|
293
304
|
options: Object.keys(version_control_1.modeFlagValuesMap),
|
|
294
305
|
}),
|
|
306
|
+
"skip-signing-verification": core_1.Flags.boolean({
|
|
307
|
+
char: "s",
|
|
308
|
+
description: "If true, signature verification for signing enabled organizations will be skipped.",
|
|
309
|
+
default: false,
|
|
310
|
+
}),
|
|
295
311
|
};
|
|
296
312
|
Initialize.args = {
|
|
297
313
|
resource_url: core_1.Args.string({
|
package/dist/commands/migrate.js
CHANGED
|
@@ -121,8 +121,7 @@ class Migrate extends authenticated_command_1.AuthenticatedCommand {
|
|
|
121
121
|
}
|
|
122
122
|
async migrateSinglePageApplicationToMultiPage(applicationResource, superblocksRootPath) {
|
|
123
123
|
const fileStructure = await (0, version_control_1.getFileStructureType)(superblocksRootPath, applicationResource.location);
|
|
124
|
-
if (fileStructure == version_control_1.FileStructureType.SINGLE_PAGE
|
|
125
|
-
(await this.getSdk().fetchCurrentUser()).flagBootstrap["server.multipage.enabled"]) {
|
|
124
|
+
if (fileStructure == version_control_1.FileStructureType.SINGLE_PAGE) {
|
|
126
125
|
this.log(`Migrating single page application at ${applicationResource.location} to multi-page application...`);
|
|
127
126
|
const singlePageApplication = await (0, version_control_1.readApplicationFromDisk)(superblocksRootPath, applicationResource.location);
|
|
128
127
|
const multiPageApplication = {
|
package/dist/commands/pull.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export default class Pull extends AuthenticatedCommand {
|
|
|
5
5
|
static flags: {
|
|
6
6
|
mode: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
7
|
branch: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
|
+
"commit-id": import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
|
+
"skip-signing-verification": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
10
|
};
|
|
9
11
|
static args: {
|
|
10
12
|
resource_path: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
|
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.resource_path, flags.mode, flags.branch);
|
|
14
|
+
const tasks = this.createTasks(args.resource_path, flags.mode, flags.branch, flags["skip-signing-verification"], flags["commit-id"]);
|
|
15
15
|
await tasks.run();
|
|
16
16
|
}
|
|
17
|
-
createTasks(resourcePath, mode, branch) {
|
|
17
|
+
createTasks(resourcePath, mode, branch, skipSigningVerification = false, commitId) {
|
|
18
18
|
const tasks = new listr2_1.Listr([
|
|
19
19
|
{
|
|
20
20
|
title: "Checking for existing Superblocks project...",
|
|
@@ -60,6 +60,8 @@ class Pull extends authenticated_command_1.AuthenticatedCommand {
|
|
|
60
60
|
try {
|
|
61
61
|
await this.getSdk().fetchApplication({
|
|
62
62
|
applicationId: resourceId,
|
|
63
|
+
// signing check is not relevant to find deleted resources
|
|
64
|
+
skipSigningVerification: true,
|
|
63
65
|
});
|
|
64
66
|
}
|
|
65
67
|
catch (error) {
|
|
@@ -74,7 +76,11 @@ class Pull extends authenticated_command_1.AuthenticatedCommand {
|
|
|
74
76
|
}
|
|
75
77
|
case "BACKEND": {
|
|
76
78
|
try {
|
|
77
|
-
await this.getSdk().fetchApi(
|
|
79
|
+
await this.getSdk().fetchApi({
|
|
80
|
+
apiId: resourceId,
|
|
81
|
+
// signing check is not relevant to find deleted resources
|
|
82
|
+
skipSigningVerification: true,
|
|
83
|
+
});
|
|
78
84
|
}
|
|
79
85
|
catch (error) {
|
|
80
86
|
if (error instanceof util_1.NotFoundError) {
|
|
@@ -143,11 +149,11 @@ Would you like to also delete these resources from your filesystem?`,
|
|
|
143
149
|
catch (error) {
|
|
144
150
|
if ((0, version_control_1.isCI)() && error instanceof sdk_1.ValidateGitSetupError) {
|
|
145
151
|
this.log(`WARN: Failed to validate git setup for ${resourceTitle}. Skipping pull.\n\n${error.message}.`);
|
|
152
|
+
ctx.resourceIdsToSkip.add(resourceId);
|
|
146
153
|
}
|
|
147
154
|
else {
|
|
148
155
|
throw error;
|
|
149
156
|
}
|
|
150
|
-
ctx.resourceIdsToSkip.add(resourceId);
|
|
151
157
|
}
|
|
152
158
|
},
|
|
153
159
|
});
|
|
@@ -157,13 +163,31 @@ Would you like to also delete these resources from your filesystem?`,
|
|
|
157
163
|
});
|
|
158
164
|
},
|
|
159
165
|
},
|
|
166
|
+
{
|
|
167
|
+
task: async (ctx, task) => {
|
|
168
|
+
return task.newListr([
|
|
169
|
+
{
|
|
170
|
+
title: `Filtering out resources with git validation errors...`,
|
|
171
|
+
enabled: () => ctx.resourceIdsToSkip.size > 0,
|
|
172
|
+
task: () => {
|
|
173
|
+
// Remove resources to skip from list of resources to pull
|
|
174
|
+
ctx.resourceIdsToPull = ctx.resourceIdsToPull.filter((id) => !ctx.resourceIdsToSkip.has(id));
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
]);
|
|
178
|
+
},
|
|
179
|
+
},
|
|
160
180
|
{
|
|
161
181
|
task: async (ctx, task) => {
|
|
162
182
|
var _a, _b;
|
|
163
183
|
task.title = `Pulling resources from branch ${ctx.localBranchName}...`;
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
184
|
+
let viewMode;
|
|
185
|
+
if (commitId) {
|
|
186
|
+
viewMode = "export-commit";
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
viewMode = await (0, version_control_1.getMode)(task, mode);
|
|
190
|
+
}
|
|
167
191
|
const subtasks = [];
|
|
168
192
|
for (const resourceId of ctx.resourceIdsToPull) {
|
|
169
193
|
const resource = (_a = ctx.existingSuperblocksRootConfig) === null || _a === void 0 ? void 0 : _a.resources[resourceId];
|
|
@@ -180,22 +204,7 @@ Would you like to also delete these resources from your filesystem?`,
|
|
|
180
204
|
task.title += `: fetched`;
|
|
181
205
|
const fileStructureType = await (0, version_control_1.getFileStructureType)(ctx.superblocksRootPath, resource.location);
|
|
182
206
|
if (fileStructureType === version_control_1.FileStructureType.SINGLE_PAGE) {
|
|
183
|
-
|
|
184
|
-
if (multiPageEnabled) {
|
|
185
|
-
this.error(`Application files at ${resource.location} are in single page format, but the multi-page feature is enabled for your account. Please run superblocks migrate to convert your application to multi-page format and commit the changes before pulling.`);
|
|
186
|
-
}
|
|
187
|
-
const application = await this.getSdk().fetchApplicationWithComponents({
|
|
188
|
-
applicationId: resourceId,
|
|
189
|
-
branch: branchName,
|
|
190
|
-
viewMode,
|
|
191
|
-
headers,
|
|
192
|
-
fetchSinglePageApplication: true,
|
|
193
|
-
});
|
|
194
|
-
if (!application) {
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
ctx.writtenResources[resourceId] =
|
|
198
|
-
await (0, version_control_1.writeResourceToDisk)("APPLICATION", resourceId, application, ctx.superblocksRootPath, resource.location);
|
|
207
|
+
this.error(`Application files at ${resource.location} are in single page format, but the multi-page feature is enabled for your account. Please run superblocks migrate to convert your application to multi-page format and commit the changes before pulling.`);
|
|
199
208
|
}
|
|
200
209
|
else {
|
|
201
210
|
const application = (await this.getSdk().fetchApplicationWithComponents({
|
|
@@ -203,6 +212,8 @@ Would you like to also delete these resources from your filesystem?`,
|
|
|
203
212
|
branch: branchName,
|
|
204
213
|
viewMode,
|
|
205
214
|
headers,
|
|
215
|
+
commitId,
|
|
216
|
+
skipSigningVerification,
|
|
206
217
|
}));
|
|
207
218
|
if (!application) {
|
|
208
219
|
return;
|
|
@@ -230,7 +241,13 @@ Would you like to also delete these resources from your filesystem?`,
|
|
|
230
241
|
subtasks.push({
|
|
231
242
|
title: `Fetching backend ${resource.location}...`,
|
|
232
243
|
task: async (_ctx, task) => {
|
|
233
|
-
const backend = await this.getSdk().fetchApi(
|
|
244
|
+
const backend = await this.getSdk().fetchApi({
|
|
245
|
+
apiId: resourceId,
|
|
246
|
+
viewMode,
|
|
247
|
+
branch: branchName,
|
|
248
|
+
commitId,
|
|
249
|
+
skipSigningVerification,
|
|
250
|
+
});
|
|
234
251
|
task.title += `: fetched`;
|
|
235
252
|
ctx.writtenResources[resourceId] =
|
|
236
253
|
await (0, version_control_1.writeResourceToDisk)("BACKEND", resourceId, backend, ctx.superblocksRootPath, resource.location);
|
|
@@ -256,23 +273,23 @@ Would you like to also delete these resources from your filesystem?`,
|
|
|
256
273
|
return tasks;
|
|
257
274
|
}
|
|
258
275
|
async getResourceIdsToPull(ctx, task, resourcePath) {
|
|
259
|
-
var _a, _b, _c, _d, _e
|
|
276
|
+
var _a, _b, _c, _d, _e;
|
|
260
277
|
if (resourcePath) {
|
|
261
278
|
for (const [resourceId, resource] of Object.entries((_b = (_a = ctx.existingSuperblocksRootConfig) === null || _a === void 0 ? void 0 : _a.resources) !== null && _b !== void 0 ? _b : {})) {
|
|
262
279
|
if (resource.location === resourcePath) {
|
|
263
280
|
return [resourceId];
|
|
264
281
|
}
|
|
265
282
|
}
|
|
266
|
-
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);
|
|
267
|
-
if (resource) {
|
|
268
|
-
return [resource[0]];
|
|
269
|
-
}
|
|
270
283
|
throw new Error(`No resource found with the given location: ${resourcePath}`);
|
|
271
284
|
}
|
|
285
|
+
const resourceConfig = await (0, util_1.getSuperblocksResourceConfigIfExists)();
|
|
286
|
+
if (resourceConfig) {
|
|
287
|
+
return [resourceConfig.id];
|
|
288
|
+
}
|
|
272
289
|
const choices = [];
|
|
273
290
|
const initialSelections = [];
|
|
274
291
|
let counter = 0;
|
|
275
|
-
for (const [resourceId, resource] of Object.entries((
|
|
292
|
+
for (const [resourceId, resource] of Object.entries((_d = (_c = ctx.existingSuperblocksRootConfig) === null || _c === void 0 ? void 0 : _c.resources) !== null && _d !== void 0 ? _d : {})) {
|
|
276
293
|
if (ctx.removedResourceIds.includes(resourceId)) {
|
|
277
294
|
continue;
|
|
278
295
|
}
|
|
@@ -280,7 +297,7 @@ Would you like to also delete these resources from your filesystem?`,
|
|
|
280
297
|
name: resourceId,
|
|
281
298
|
message: resource.location,
|
|
282
299
|
});
|
|
283
|
-
if (((
|
|
300
|
+
if (((_e = ctx.existingSuperblocksResourceConfig) === null || _e === void 0 ? void 0 : _e.id) === resourceId) {
|
|
284
301
|
initialSelections.push(counter);
|
|
285
302
|
}
|
|
286
303
|
counter++;
|
|
@@ -307,6 +324,7 @@ Pull.examples = [
|
|
|
307
324
|
"<%= config.bin %> <%= command.id %>",
|
|
308
325
|
"<%= config.bin %> <%= command.id %> apps/my-app",
|
|
309
326
|
"<%= config.bin %> <%= command.id %> apps/my-app -b feature-branch",
|
|
327
|
+
"<%= config.bin %> <%= command.id %> apps/my-app -c commit-id",
|
|
310
328
|
];
|
|
311
329
|
Pull.flags = {
|
|
312
330
|
mode: core_1.Flags.string({
|
|
@@ -319,6 +337,15 @@ Pull.flags = {
|
|
|
319
337
|
char: "b",
|
|
320
338
|
description: "Superblocks branch to pull from, the current git branch will be used by default",
|
|
321
339
|
}),
|
|
340
|
+
"commit-id": core_1.Flags.string({
|
|
341
|
+
char: "c",
|
|
342
|
+
description: "Superblocks commit id to pull, the live edit will be used by default",
|
|
343
|
+
}),
|
|
344
|
+
"skip-signing-verification": core_1.Flags.boolean({
|
|
345
|
+
char: "s",
|
|
346
|
+
description: "If true, signature verification for signing enabled organizations will be skipped.",
|
|
347
|
+
default: false,
|
|
348
|
+
}),
|
|
322
349
|
};
|
|
323
350
|
Pull.args = {
|
|
324
351
|
resource_path: core_1.Args.string({
|
package/dist/commands/push.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export default class Push extends AuthenticatedCommand {
|
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
6
|
branch: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
"skip-commit": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
7
8
|
};
|
|
8
9
|
static args: {
|
|
9
10
|
resource_path: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
|
package/dist/commands/push.js
CHANGED
|
@@ -12,10 +12,10 @@ const version_control_1 = require("../common/version-control");
|
|
|
12
12
|
class Push extends authenticated_command_1.AuthenticatedCommand {
|
|
13
13
|
async run() {
|
|
14
14
|
const { flags, args } = await this.parse(Push);
|
|
15
|
-
const tasks = this.createTasks(args.resource_path, flags.branch);
|
|
15
|
+
const tasks = this.createTasks(args.resource_path, flags.branch, flags["skip-commit"]);
|
|
16
16
|
await tasks.run();
|
|
17
17
|
}
|
|
18
|
-
createTasks(resourceName, branch) {
|
|
18
|
+
createTasks(resourceName, branch, skipCommit) {
|
|
19
19
|
const tasks = new listr2_1.Listr([
|
|
20
20
|
{
|
|
21
21
|
title: "Checking for existing Superblocks project...",
|
|
@@ -41,16 +41,29 @@ class Push extends authenticated_command_1.AuthenticatedCommand {
|
|
|
41
41
|
title: "Checking for existing git repository...",
|
|
42
42
|
task: async (ctx) => {
|
|
43
43
|
ctx.branchToPushTo = new Map();
|
|
44
|
+
if (skipCommit) {
|
|
45
|
+
const repoState = await (0, version_control_1.getLocalGitRepoState)();
|
|
46
|
+
if (repoState.status === "NO_GIT") {
|
|
47
|
+
if (!branch) {
|
|
48
|
+
this.error(`No git repository found in the current folder hierarchy. Please make sure to pass branch name. E.g. superblocks push --branch feature-branch.
|
|
49
|
+
If resource is not connected to git repository, pass "main" as branch name.`);
|
|
50
|
+
}
|
|
51
|
+
ctx.localBranchName = branch || version_control_1.DEFAULT_BRANCH;
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
44
55
|
try {
|
|
45
56
|
ctx.localBranchName =
|
|
46
57
|
branch || (await (0, version_control_1.getCurrentGitBranchIfGit)()) || version_control_1.DEFAULT_BRANCH;
|
|
47
|
-
|
|
58
|
+
if (!skipCommit) {
|
|
59
|
+
[ctx.headCommitId, ctx.headCommitMessage] = await (0, version_control_1.getHeadCommit)(ctx.localBranchName);
|
|
60
|
+
}
|
|
48
61
|
}
|
|
49
62
|
catch (e) {
|
|
50
63
|
this.error(`Failed to check for existing git repository: ${e.message}. Please make sure to clone or initialize a git repository.`);
|
|
51
64
|
}
|
|
52
65
|
const isDirtyRepo = await (0, version_control_1.isGitRepoDirty)();
|
|
53
|
-
if (isDirtyRepo) {
|
|
66
|
+
if (isDirtyRepo && !skipCommit) {
|
|
54
67
|
this.error(`Your git repository is dirty. Please commit or stash your changes before pushing to Superblocks.`);
|
|
55
68
|
}
|
|
56
69
|
},
|
|
@@ -59,6 +72,10 @@ class Push extends authenticated_command_1.AuthenticatedCommand {
|
|
|
59
72
|
title: "Checking for deleted Superblocks resources...",
|
|
60
73
|
task: async (ctx, task) => {
|
|
61
74
|
var _a, _b;
|
|
75
|
+
if ((0, version_control_1.isCI)()) {
|
|
76
|
+
this.log("Skipping check for deleted Superblocks resources in CI environment.");
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
62
79
|
try {
|
|
63
80
|
for (const [resourceId, resource] of Object.entries((_b = (_a = ctx.existingSuperblocksRootConfig) === null || _a === void 0 ? void 0 : _a.resources) !== null && _b !== void 0 ? _b : {})) {
|
|
64
81
|
switch (resource === null || resource === void 0 ? void 0 : resource.resourceType) {
|
|
@@ -66,6 +83,8 @@ class Push extends authenticated_command_1.AuthenticatedCommand {
|
|
|
66
83
|
try {
|
|
67
84
|
await this.getSdk().fetchApplication({
|
|
68
85
|
applicationId: resourceId,
|
|
86
|
+
// signing check is not relevant to find deleted resources
|
|
87
|
+
skipSigningVerification: true,
|
|
69
88
|
});
|
|
70
89
|
}
|
|
71
90
|
catch (error) {
|
|
@@ -80,7 +99,11 @@ class Push extends authenticated_command_1.AuthenticatedCommand {
|
|
|
80
99
|
}
|
|
81
100
|
case "BACKEND": {
|
|
82
101
|
try {
|
|
83
|
-
await this.getSdk().fetchApi(
|
|
102
|
+
await this.getSdk().fetchApi({
|
|
103
|
+
apiId: resourceId,
|
|
104
|
+
// signing check is not relevant to find deleted resources
|
|
105
|
+
skipSigningVerification: true,
|
|
106
|
+
});
|
|
84
107
|
}
|
|
85
108
|
catch (error) {
|
|
86
109
|
if (error instanceof util_1.NotFoundError) {
|
|
@@ -133,6 +156,10 @@ Would you like to also delete these resources from your filesystem?`,
|
|
|
133
156
|
{
|
|
134
157
|
task: async (ctx, task) => {
|
|
135
158
|
var _a, _b;
|
|
159
|
+
if (skipCommit) {
|
|
160
|
+
this.log("Skipping git validation as --skip-commit flag is set");
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
136
163
|
task.title = `Validating git configuration...`;
|
|
137
164
|
const subtasks = [];
|
|
138
165
|
ctx.resourceIdsToSkip = new Set();
|
|
@@ -150,11 +177,11 @@ Would you like to also delete these resources from your filesystem?`,
|
|
|
150
177
|
catch (error) {
|
|
151
178
|
if ((0, version_control_1.isCI)() && error instanceof sdk_1.ValidateGitSetupError) {
|
|
152
179
|
this.log(`WARN: Failed to validate git setup for ${resourceTitle}. Skipping push.\n\n${error.message}.`);
|
|
180
|
+
ctx.resourceIdsToSkip.add(resourceId);
|
|
153
181
|
}
|
|
154
182
|
else {
|
|
155
183
|
throw error;
|
|
156
184
|
}
|
|
157
|
-
ctx.resourceIdsToSkip.add(resourceId);
|
|
158
185
|
}
|
|
159
186
|
},
|
|
160
187
|
});
|
|
@@ -164,6 +191,23 @@ Would you like to also delete these resources from your filesystem?`,
|
|
|
164
191
|
});
|
|
165
192
|
},
|
|
166
193
|
},
|
|
194
|
+
{
|
|
195
|
+
task: async (ctx, task) => {
|
|
196
|
+
if (skipCommit) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
return task.newListr([
|
|
200
|
+
{
|
|
201
|
+
title: `Filtering out resources with git validation errors...`,
|
|
202
|
+
enabled: () => ctx.resourceIdsToSkip.size > 0,
|
|
203
|
+
task: () => {
|
|
204
|
+
// Remove resources to skip from list of resources to push
|
|
205
|
+
ctx.resourceIdsToPush = ctx.resourceIdsToPush.filter((id) => !ctx.resourceIdsToSkip.has(id));
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
]);
|
|
209
|
+
},
|
|
210
|
+
},
|
|
167
211
|
{
|
|
168
212
|
task: async (ctx, task) => {
|
|
169
213
|
var _a, _b;
|
|
@@ -192,8 +236,6 @@ Would you like to also delete these resources from your filesystem?`,
|
|
|
192
236
|
task: async (ctx, task) => {
|
|
193
237
|
var _a;
|
|
194
238
|
task.title = `Pushing resources to branch ${ctx.localBranchName}...`;
|
|
195
|
-
// Remove resources to skip from list of resources to push
|
|
196
|
-
ctx.resourceIdsToPush = ctx.resourceIdsToPush.filter((id) => !ctx.resourceIdsToSkip.has(id));
|
|
197
239
|
const subtasks = [];
|
|
198
240
|
const superblocksRootPath = node_path_1.default.resolve(node_path_1.default.dirname(ctx.superblocksRootConfigPath), "..");
|
|
199
241
|
for (const resourceId of ctx.resourceIdsToPush) {
|
|
@@ -205,33 +247,30 @@ Would you like to also delete these resources from your filesystem?`,
|
|
|
205
247
|
task: async (_ctx, task) => {
|
|
206
248
|
var _a;
|
|
207
249
|
const fileStructureType = await (0, version_control_1.getFileStructureType)(superblocksRootPath, resource.location);
|
|
208
|
-
if (fileStructureType === version_control_1.FileStructureType.SINGLE_PAGE
|
|
209
|
-
|
|
210
|
-
this.error(`Application files at ${resource.location} are in single page format, but the multi-page feature is enabled for your account. Please run \`superblocks migrate\` to convert your application to multi-page format and commit the changes before pushing.`);
|
|
250
|
+
if (fileStructureType === version_control_1.FileStructureType.SINGLE_PAGE) {
|
|
251
|
+
this.error(`Application files at ${resource.location} are in single page format, but the multi-page feature is enabled for your account. To resolve this issue, you can make a commit to this branch from Superblocks to convert the file structure to multi-page format (See docs: https://docs.superblocks.com/applications/multi-page/converting-single-page-to-multi-page#handling-outstanding-branches-created-before-multi-page). Alternatively, you can run \`superblocks migrate\` to convert your file structure and commit the changes before pushing.`);
|
|
211
252
|
}
|
|
212
253
|
const localGitRepoState = await (0, version_control_1.getLocalGitRepoState)(ctx.localBranchName);
|
|
213
|
-
const applicationConfig =
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
: {
|
|
221
|
-
...(await (0, version_control_1.readMultiPageApplicationFromDisk)(superblocksRootPath, resource.location)),
|
|
222
|
-
commitId: ctx.headCommitId,
|
|
223
|
-
commitMessage: ctx.headCommitMessage,
|
|
224
|
-
gitState: localGitRepoState,
|
|
225
|
-
};
|
|
254
|
+
const applicationConfig = {
|
|
255
|
+
...(await (0, version_control_1.readMultiPageApplicationFromDisk)(superblocksRootPath, resource.location)),
|
|
256
|
+
commitId: ctx.headCommitId,
|
|
257
|
+
commitMessage: ctx.headCommitMessage,
|
|
258
|
+
gitState: localGitRepoState,
|
|
259
|
+
skipCommit,
|
|
260
|
+
};
|
|
226
261
|
task.title += `: read from disk`;
|
|
227
262
|
try {
|
|
228
263
|
const branch = (_a = ctx.branchToPushTo.get(resourceId)) !== null && _a !== void 0 ? _a : ctx.localBranchName;
|
|
229
|
-
|
|
264
|
+
if (skipCommit) {
|
|
265
|
+
task.title += `: going to push update live edits on branch ${branch}`;
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
task.title += `: going to push commit ${applicationConfig.commitId} to branch ${branch}`;
|
|
269
|
+
}
|
|
230
270
|
await this.getSdk().pushApplication({
|
|
231
271
|
applicationId: resourceId,
|
|
232
272
|
applicationConfig,
|
|
233
273
|
branch,
|
|
234
|
-
multiPage: fileStructureType === version_control_1.FileStructureType.MULTI_PAGE,
|
|
235
274
|
});
|
|
236
275
|
}
|
|
237
276
|
catch (error) {
|
|
@@ -262,11 +301,17 @@ Would you like to also delete these resources from your filesystem?`,
|
|
|
262
301
|
commitId: ctx.headCommitId,
|
|
263
302
|
commitMessage: ctx.headCommitMessage,
|
|
264
303
|
gitState: localGitRepoState,
|
|
304
|
+
skipCommit,
|
|
265
305
|
};
|
|
266
306
|
task.title += `: read from disk`;
|
|
267
307
|
try {
|
|
268
308
|
const branch = (_a = ctx.branchToPushTo.get(resourceId)) !== null && _a !== void 0 ? _a : ctx.localBranchName;
|
|
269
|
-
|
|
309
|
+
if (skipCommit) {
|
|
310
|
+
task.title += `: going to push update live edits on branch ${branch}`;
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
task.title += `: going to push commit ${apiConfig.commitId} to branch ${branch}`;
|
|
314
|
+
}
|
|
270
315
|
await this.getSdk().pushApi({
|
|
271
316
|
apiId: resourceId,
|
|
272
317
|
apiConfig,
|
|
@@ -323,6 +368,10 @@ Would you like to also delete these resources from your filesystem?`,
|
|
|
323
368
|
}
|
|
324
369
|
throw new Error(`No resource found with the given location: ${resourcePath}`);
|
|
325
370
|
}
|
|
371
|
+
const resourceConfig = await (0, util_1.getSuperblocksResourceConfigIfExists)();
|
|
372
|
+
if (resourceConfig) {
|
|
373
|
+
return [resourceConfig.id];
|
|
374
|
+
}
|
|
326
375
|
const choices = [];
|
|
327
376
|
const initialSelections = [];
|
|
328
377
|
let counter = 0;
|
|
@@ -359,12 +408,18 @@ Push.examples = [
|
|
|
359
408
|
"<%= config.bin %> <%= command.id %>",
|
|
360
409
|
"<%= config.bin %> <%= command.id %> apps/my-app",
|
|
361
410
|
"<%= config.bin %> <%= command.id %> apps/my-app -b feature-branch",
|
|
411
|
+
"<%= config.bin %> <%= command.id %> apps/my-app --skip-commit",
|
|
362
412
|
];
|
|
363
413
|
Push.flags = {
|
|
364
414
|
branch: core_1.Flags.string({
|
|
365
415
|
char: "b",
|
|
366
416
|
description: "Superblocks branch to push to, the current git branch will be used by default",
|
|
367
417
|
}),
|
|
418
|
+
"skip-commit": core_1.Flags.boolean({
|
|
419
|
+
char: "s",
|
|
420
|
+
default: false,
|
|
421
|
+
description: "If true, push command will only update live edit state along with signature without creating a commit.",
|
|
422
|
+
}),
|
|
368
423
|
};
|
|
369
424
|
Push.args = {
|
|
370
425
|
resource_path: core_1.Args.string({
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ApiWrapper, ApplicationWrapper, MultiPageApplicationWrapper
|
|
1
|
+
import { ApiWrapper, ApplicationWrapper, MultiPageApplicationWrapper } from "@superblocksteam/sdk";
|
|
2
|
+
import { ViewMode } from "@superblocksteam/sdk/dist/types";
|
|
2
3
|
import { LocalGitRepoState, SuperblocksMonorepoConfig } from "@superblocksteam/util";
|
|
3
4
|
import { VersionedResourceConfig } from "@superblocksteam/util";
|
|
4
5
|
export declare const LATEST_EDITS_MODE = "latest-edits";
|
|
@@ -604,22 +604,6 @@ function writeApi(api, originalApiName, appDirName) {
|
|
|
604
604
|
};
|
|
605
605
|
return handleApi();
|
|
606
606
|
}
|
|
607
|
-
function validateSinglePageApplication(applicationConfig, superblocksRootPath, location) {
|
|
608
|
-
// validate app level APIs
|
|
609
|
-
for (const apiName of Object.values(applicationConfig.apis)) {
|
|
610
|
-
const apiPath = node_path_1.default.resolve(superblocksRootPath, location, "apis", `${slugifyName(apiName)}.yaml`);
|
|
611
|
-
const validateApiError = validateYamlFile(apiPath);
|
|
612
|
-
if (validateApiError) {
|
|
613
|
-
return validateApiError;
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
// validate page
|
|
617
|
-
const pagePath = node_path_1.default.resolve(superblocksRootPath, location, "page.yaml");
|
|
618
|
-
const validatePageError = validateYamlFile(pagePath);
|
|
619
|
-
if (validatePageError) {
|
|
620
|
-
return validatePageError;
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
607
|
async function validateMultiPageApplication(applicationConfig, superblocksRootPath, location) {
|
|
624
608
|
var _a;
|
|
625
609
|
// validate app level APIs
|
|
@@ -656,7 +640,6 @@ async function validateLocalResource(superblocksRootPath, resource) {
|
|
|
656
640
|
if (!(await fs.pathExists(applicationConfigPath))) {
|
|
657
641
|
return `File ${relativeToCurrentDir(applicationConfigPath)} not found. Superblocks CLI commands cannot function without it.`;
|
|
658
642
|
}
|
|
659
|
-
let fileStructureType = undefined;
|
|
660
643
|
let applicationConfig = undefined;
|
|
661
644
|
try {
|
|
662
645
|
// make sure it's a well-formed application config
|
|
@@ -664,8 +647,6 @@ async function validateLocalResource(superblocksRootPath, resource) {
|
|
|
664
647
|
if (!applicationConfig) {
|
|
665
648
|
throw new Error();
|
|
666
649
|
}
|
|
667
|
-
fileStructureType =
|
|
668
|
-
getFileStructureTypeFromResourceConfig(applicationConfig);
|
|
669
650
|
}
|
|
670
651
|
catch {
|
|
671
652
|
return `File ${relativeToCurrentDir(applicationConfigPath)} is not a valid JSON file. Please be sure it's valid JSON and rerun the command.`;
|
|
@@ -678,21 +659,9 @@ async function validateLocalResource(superblocksRootPath, resource) {
|
|
|
678
659
|
catch {
|
|
679
660
|
return `File ${relativeToCurrentDir(applicationYamlPath)} is not a valid YAML file. Please be sure it's valid YAML and rerun the command.`;
|
|
680
661
|
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
break;
|
|
685
|
-
}
|
|
686
|
-
case FileStructureType.MULTI_PAGE: {
|
|
687
|
-
const validationError = validateMultiPageApplication(applicationConfig, superblocksRootPath, resource.location);
|
|
688
|
-
if (validationError) {
|
|
689
|
-
return validationError;
|
|
690
|
-
}
|
|
691
|
-
break;
|
|
692
|
-
}
|
|
693
|
-
default: {
|
|
694
|
-
return `Invalid file structure type ${fileStructureType}`;
|
|
695
|
-
}
|
|
662
|
+
const validationError = validateMultiPageApplication(applicationConfig, superblocksRootPath, resource.location);
|
|
663
|
+
if (validationError) {
|
|
664
|
+
return validationError;
|
|
696
665
|
}
|
|
697
666
|
break;
|
|
698
667
|
}
|
package/oclif.manifest.json
CHANGED
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.9.0",
|
|
3
3
|
"commands": {
|
|
4
|
+
"commits": {
|
|
5
|
+
"id": "commits",
|
|
6
|
+
"description": "List Superblocks commits for a resource",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"pluginName": "@superblocksteam/cli",
|
|
9
|
+
"pluginAlias": "@superblocksteam/cli",
|
|
10
|
+
"pluginType": "core",
|
|
11
|
+
"aliases": [],
|
|
12
|
+
"examples": [
|
|
13
|
+
"<%= config.bin %> <%= command.id %>",
|
|
14
|
+
"<%= config.bin %> <%= command.id %> apps/my-app",
|
|
15
|
+
"<%= config.bin %> <%= command.id %> apps/my-app -b feature-branch",
|
|
16
|
+
"<%= config.bin %> <%= command.id %> --limit 20",
|
|
17
|
+
"<%= config.bin %> <%= command.id %> --offset 10"
|
|
18
|
+
],
|
|
19
|
+
"flags": {
|
|
20
|
+
"branch": {
|
|
21
|
+
"name": "branch",
|
|
22
|
+
"type": "option",
|
|
23
|
+
"char": "b",
|
|
24
|
+
"description": "Superblocks branch to show commits for, the current git branch will be used by default",
|
|
25
|
+
"multiple": false
|
|
26
|
+
},
|
|
27
|
+
"limit": {
|
|
28
|
+
"name": "limit",
|
|
29
|
+
"type": "option",
|
|
30
|
+
"char": "l",
|
|
31
|
+
"description": "Number of commits to be displayed, default is 10",
|
|
32
|
+
"multiple": false,
|
|
33
|
+
"default": 10
|
|
34
|
+
},
|
|
35
|
+
"offset": {
|
|
36
|
+
"name": "offset",
|
|
37
|
+
"type": "option",
|
|
38
|
+
"char": "o",
|
|
39
|
+
"description": "Number of commits to be skipped before displaying by creation time, default is 0",
|
|
40
|
+
"multiple": false,
|
|
41
|
+
"default": 0
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"args": {
|
|
45
|
+
"resource_path": {
|
|
46
|
+
"name": "resource_path",
|
|
47
|
+
"description": "Superblocks resource location to show commits for (i.e. apps/my-app)",
|
|
48
|
+
"required": false
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
4
52
|
"init": {
|
|
5
53
|
"id": "init",
|
|
6
54
|
"description": "Interactively configure the current directory as a Superblocks project or initialize new services in an already configured Superblocks project directory",
|
|
@@ -25,6 +73,13 @@
|
|
|
25
73
|
"most-recent-commit",
|
|
26
74
|
"deployed"
|
|
27
75
|
]
|
|
76
|
+
},
|
|
77
|
+
"skip-signing-verification": {
|
|
78
|
+
"name": "skip-signing-verification",
|
|
79
|
+
"type": "boolean",
|
|
80
|
+
"char": "s",
|
|
81
|
+
"description": "If true, signature verification for signing enabled organizations will be skipped.",
|
|
82
|
+
"allowNo": false
|
|
28
83
|
}
|
|
29
84
|
},
|
|
30
85
|
"args": {
|
|
@@ -79,7 +134,8 @@
|
|
|
79
134
|
"examples": [
|
|
80
135
|
"<%= config.bin %> <%= command.id %>",
|
|
81
136
|
"<%= config.bin %> <%= command.id %> apps/my-app",
|
|
82
|
-
"<%= config.bin %> <%= command.id %> apps/my-app -b feature-branch"
|
|
137
|
+
"<%= config.bin %> <%= command.id %> apps/my-app -b feature-branch",
|
|
138
|
+
"<%= config.bin %> <%= command.id %> apps/my-app -c commit-id"
|
|
83
139
|
],
|
|
84
140
|
"flags": {
|
|
85
141
|
"mode": {
|
|
@@ -101,6 +157,20 @@
|
|
|
101
157
|
"char": "b",
|
|
102
158
|
"description": "Superblocks branch to pull from, the current git branch will be used by default",
|
|
103
159
|
"multiple": false
|
|
160
|
+
},
|
|
161
|
+
"commit-id": {
|
|
162
|
+
"name": "commit-id",
|
|
163
|
+
"type": "option",
|
|
164
|
+
"char": "c",
|
|
165
|
+
"description": "Superblocks commit id to pull, the live edit will be used by default",
|
|
166
|
+
"multiple": false
|
|
167
|
+
},
|
|
168
|
+
"skip-signing-verification": {
|
|
169
|
+
"name": "skip-signing-verification",
|
|
170
|
+
"type": "boolean",
|
|
171
|
+
"char": "s",
|
|
172
|
+
"description": "If true, signature verification for signing enabled organizations will be skipped.",
|
|
173
|
+
"allowNo": false
|
|
104
174
|
}
|
|
105
175
|
},
|
|
106
176
|
"args": {
|
|
@@ -122,7 +192,8 @@
|
|
|
122
192
|
"examples": [
|
|
123
193
|
"<%= config.bin %> <%= command.id %>",
|
|
124
194
|
"<%= config.bin %> <%= command.id %> apps/my-app",
|
|
125
|
-
"<%= config.bin %> <%= command.id %> apps/my-app -b feature-branch"
|
|
195
|
+
"<%= config.bin %> <%= command.id %> apps/my-app -b feature-branch",
|
|
196
|
+
"<%= config.bin %> <%= command.id %> apps/my-app --skip-commit"
|
|
126
197
|
],
|
|
127
198
|
"flags": {
|
|
128
199
|
"branch": {
|
|
@@ -131,6 +202,13 @@
|
|
|
131
202
|
"char": "b",
|
|
132
203
|
"description": "Superblocks branch to push to, the current git branch will be used by default",
|
|
133
204
|
"multiple": false
|
|
205
|
+
},
|
|
206
|
+
"skip-commit": {
|
|
207
|
+
"name": "skip-commit",
|
|
208
|
+
"type": "boolean",
|
|
209
|
+
"char": "s",
|
|
210
|
+
"description": "If true, push command will only update live edit state along with signature without creating a commit.",
|
|
211
|
+
"allowNo": false
|
|
134
212
|
}
|
|
135
213
|
},
|
|
136
214
|
"args": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superblocksteam/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.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.
|
|
22
|
-
"@superblocksteam/react-shim": "1.
|
|
23
|
-
"@superblocksteam/sdk": "1.
|
|
24
|
-
"@superblocksteam/util": "1.
|
|
25
|
-
"@superblocksteam/vite-custom-component-reload-plugin": "1.
|
|
21
|
+
"@superblocksteam/css-plugin": "1.9.0",
|
|
22
|
+
"@superblocksteam/react-shim": "1.9.0",
|
|
23
|
+
"@superblocksteam/sdk": "1.9.0",
|
|
24
|
+
"@superblocksteam/util": "1.9.0",
|
|
25
|
+
"@superblocksteam/vite-custom-component-reload-plugin": "1.9.0",
|
|
26
26
|
"@vitejs/plugin-react": "^4.1.0",
|
|
27
27
|
"colorette": "^2.0.19",
|
|
28
28
|
"enquirer": "^2.3.6",
|