@superblocksteam/cli 1.1.2 → 1.2.1

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 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.1.2 linux-x64 node-v18.18.2
15
+ @superblocksteam/cli/1.2.1 linux-x64 node-v18.18.2
16
16
  $ superblocks --help [COMMAND]
17
17
  USAGE
18
18
  $ superblocks COMMAND
@@ -7,7 +7,7 @@
7
7
  "lint:fix": "npx eslint . --fix"
8
8
  },
9
9
  "dependencies": {
10
- "@superblocksteam/custom-components": "1.1.2",
10
+ "@superblocksteam/custom-components": "1.2.1",
11
11
  "react": "^18",
12
12
  "react-dom": "^18"
13
13
  },
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
5
5
  const core_1 = require("@oclif/core");
6
+ const sdk_1 = require("@superblocksteam/sdk");
6
7
  const util_1 = require("@superblocksteam/util");
7
8
  const listr2_1 = require("listr2");
8
9
  const lodash_1 = require("lodash");
@@ -146,11 +147,24 @@ Would you like to also delete these resources from your filesystem?`,
146
147
  commitMessage: ctx.headCommitMessage,
147
148
  };
148
149
  task.title += `: read from disk`;
149
- await this.getSdk().pushApplication({
150
- applicationId: resourceId,
151
- applicationConfig,
152
- branch: ctx.pushToBranchName,
153
- });
150
+ try {
151
+ await this.getSdk().pushApplication({
152
+ applicationId: resourceId,
153
+ applicationConfig,
154
+ branch: ctx.pushToBranchName,
155
+ });
156
+ }
157
+ catch (error) {
158
+ if (error instanceof sdk_1.BranchNotCheckedOutError) {
159
+ this.log(`WARN: Application ${applicationConfig.application.name} failed to push, please check branch out in the Superblocks UI first in order to check this branch out for this resource.`);
160
+ }
161
+ else if (error instanceof sdk_1.CommitAlreadyExistsError) {
162
+ this.log(`WARN: Application ${applicationConfig.application.name} failed to push as the commit already exists in Superblocks.`);
163
+ }
164
+ else {
165
+ throw error;
166
+ }
167
+ }
154
168
  task.title += `: pushed to Superblocks`;
155
169
  ctx.pushedResources[resourceId] = resource;
156
170
  },
@@ -6,6 +6,7 @@ const https = tslib_1.__importStar(require("https"));
6
6
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
7
7
  const path_1 = require("path");
8
8
  const util_1 = require("@superblocksteam/util");
9
+ const util_2 = require("@superblocksteam/util");
9
10
  const colorette_1 = require("colorette");
10
11
  const fs = tslib_1.__importStar(require("fs-extra"));
11
12
  const lodash_1 = require("lodash");
@@ -144,7 +145,7 @@ async function writeResourceToDisk(resourceType, resourceId, resource, rootPath,
144
145
  const apiPromises = [];
145
146
  const apisDirName = `${appDirName}/apis`;
146
147
  await fs.ensureDir(apisDirName);
147
- const applicationConfig = {
148
+ const newApplicationConfig = {
148
149
  configType: "APPLICATION",
149
150
  apis: {},
150
151
  defaultPageId: (_a = resource.page) === null || _a === void 0 ? void 0 : _a.id,
@@ -162,12 +163,23 @@ async function writeResourceToDisk(resourceType, resourceId, resource, rootPath,
162
163
  await fs.outputFile(`${apisDirName}/${apiName}.yaml`, apiContent);
163
164
  };
164
165
  apiPromises.push(handleApi());
165
- applicationConfig.apis[api.id] = originalApiName;
166
+ newApplicationConfig.apis[api.id] = originalApiName;
166
167
  }
167
168
  await Promise.all(apiPromises);
168
169
  }
169
- await fs.ensureDir(`${appDirName}/${util_1.SUPERBLOCKS_HOME_FOLDER_NAME}`);
170
- await fs.writeFile(`${appDirName}/${util_1.RESOURCE_CONFIG_PATH}`, JSON.stringify(sortByKey(applicationConfig), null, 2));
170
+ const existingApplicationConfig = await (0, util_1.getSuperblocksApplicationConfigIfExists)(appDirName);
171
+ // iterate through existing apis and remove from disk any that are no longer present
172
+ if (existingApplicationConfig === null || existingApplicationConfig === void 0 ? void 0 : existingApplicationConfig.apis) {
173
+ for (const existingApiId of Object.keys(existingApplicationConfig.apis)) {
174
+ const existingApiName = existingApplicationConfig.apis[existingApiId];
175
+ const existingApiPath = `${apisDirName}/${slugifyName(existingApiName)}.yaml`;
176
+ if (!(existingApiId in newApplicationConfig.apis)) {
177
+ await fs.remove(existingApiPath);
178
+ }
179
+ }
180
+ }
181
+ await fs.ensureDir(`${appDirName}/${util_2.SUPERBLOCKS_HOME_FOLDER_NAME}`);
182
+ await fs.writeFile(`${appDirName}/${util_2.RESOURCE_CONFIG_PATH}`, JSON.stringify(sortByKey(newApplicationConfig), null, 2));
171
183
  const createdFiles = await Promise.resolve(
172
184
  // Defensive check for when application settings are missing componentFiles
173
185
  (_c = (_b = resource.componentFiles) === null || _b === void 0 ? void 0 : _b.map((file) => downloadFile(appDirName, file.filename, file.url))) !== null && _c !== void 0 ? _c : []);
@@ -200,8 +212,8 @@ async function writeResourceToDisk(resourceType, resourceId, resource, rootPath,
200
212
  id: resourceId,
201
213
  configType: "BACKEND",
202
214
  };
203
- await fs.ensureDir(`${backendDirName}/${util_1.SUPERBLOCKS_HOME_FOLDER_NAME}`);
204
- await fs.writeFile(`${backendDirName}/${util_1.RESOURCE_CONFIG_PATH}`, JSON.stringify(sortByKey(backendConfig), null, 2));
215
+ await fs.ensureDir(`${backendDirName}/${util_2.SUPERBLOCKS_HOME_FOLDER_NAME}`);
216
+ await fs.writeFile(`${backendDirName}/${util_2.RESOURCE_CONFIG_PATH}`, JSON.stringify(sortByKey(backendConfig), null, 2));
205
217
  return {
206
218
  location: relativeLocation,
207
219
  resourceType: "BACKEND",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.1.2",
2
+ "version": "1.2.1",
3
3
  "commands": {
4
4
  "init": {
5
5
  "id": "init",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superblocksteam/cli",
3
- "version": "1.1.2",
3
+ "version": "1.2.1",
4
4
  "description": "Official Superblocks CLI",
5
5
  "bin": {
6
6
  "superblocks": "bin/run"
@@ -18,12 +18,12 @@
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.1.2",
22
- "@superblocksteam/react-shim": "1.1.2",
23
- "@superblocksteam/sdk": "1.1.2",
24
- "@superblocksteam/util": "1.1.2",
25
- "@superblocksteam/vite-custom-component-reload-plugin": "1.1.2",
26
- "@vitejs/plugin-react": "^4.0.4",
21
+ "@superblocksteam/css-plugin": "1.2.1",
22
+ "@superblocksteam/react-shim": "1.2.1",
23
+ "@superblocksteam/sdk": "1.2.1",
24
+ "@superblocksteam/util": "1.2.1",
25
+ "@superblocksteam/vite-custom-component-reload-plugin": "1.2.1",
26
+ "@vitejs/plugin-react": "^4.1.0",
27
27
  "colorette": "^2.0.19",
28
28
  "enquirer": "^2.3.6",
29
29
  "fs-extra": "^11.1.1",