@superblocksteam/cli 2.0.3-next.161 → 2.0.3-next.163

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/dist/index.js CHANGED
@@ -9,12 +9,11 @@ import {
9
9
  isEqual_default,
10
10
  isObject_default,
11
11
  isString_default,
12
- pickBy_default,
13
12
  require_constants,
14
13
  require_dist,
15
14
  require_lib,
16
15
  require_slugify
17
- } from "./chunk-LHELDOWV.js";
16
+ } from "./chunk-JOXVTBHC.js";
18
17
  import {
19
18
  __commonJS,
20
19
  __esm,
@@ -96096,11 +96095,11 @@ var require_api_files = __commonJS({
96096
96095
  exports2.writeApiFiles = writeApiFiles3;
96097
96096
  exports2.readAppApiYamlFile = readAppApiYamlFile4;
96098
96097
  async function writeApiFiles3(...args) {
96099
- const esmFunction = await import("./api-CNGTM444.js");
96098
+ const esmFunction = await import("./api-CHKMPXFE.js");
96100
96099
  return esmFunction.writeApiFiles(...args);
96101
96100
  }
96102
96101
  async function readAppApiYamlFile4(...args) {
96103
- const esmFunction = await import("./api-CNGTM444.js");
96102
+ const esmFunction = await import("./api-CHKMPXFE.js");
96104
96103
  return esmFunction.readAppApiYamlFile(...args);
96105
96104
  }
96106
96105
  }
@@ -331437,7 +331436,7 @@ var import_dd_trace = __toESM(require_dd_trace2(), 1);
331437
331436
  // ../sdk/package.json
331438
331437
  var package_default = {
331439
331438
  name: "@superblocksteam/sdk",
331440
- version: "2.0.3-next.161",
331439
+ version: "2.0.3-next.163",
331441
331440
  type: "module",
331442
331441
  description: "Superblocks JS SDK",
331443
331442
  homepage: "https://www.superblocks.com",
@@ -331467,8 +331466,8 @@ var package_default = {
331467
331466
  "@rollup/wasm-node": "^4.35.0",
331468
331467
  "@superblocksteam/bucketeer-sdk": "0.4.1",
331469
331468
  "@superblocksteam/shared": "0.9120.0",
331470
- "@superblocksteam/util": "2.0.3-next.161",
331471
- "@superblocksteam/vite-plugin-file-sync": "2.0.3-next.161",
331469
+ "@superblocksteam/util": "2.0.3-next.163",
331470
+ "@superblocksteam/vite-plugin-file-sync": "2.0.3-next.163",
331472
331471
  "@vitejs/plugin-react": "^4.3.4",
331473
331472
  axios: "^1.4.0",
331474
331473
  chokidar: "^4.0.3",
@@ -331629,6 +331628,9 @@ function isComputedPropertyInfo(value2) {
331629
331628
  return isPropertyInfo(value2) && value2.type === "COMPUTED";
331630
331629
  }
331631
331630
 
331631
+ // ../../../library-shared/dist/utils/source-id.js
331632
+ init_cjs_shims();
331633
+
331632
331634
  // ../../../library-shared/dist/utils/strings.js
331633
331635
  init_cjs_shims();
331634
331636
  function containsStringInterpolation(value2) {
@@ -371195,6 +371197,7 @@ export default registerPage(Page, { name: "${name17}" });
371195
371197
  this.emit("setProperties", payload);
371196
371198
  };
371197
371199
  handleDeleteProperties = async (payload, writeFile8 = true) => {
371200
+ this.trackTransaction(payload.transaction?.id);
371198
371201
  await this.sourceTracker?.deleteProperties({
371199
371202
  source: payload.element.source,
371200
371203
  properties: payload.properties
@@ -371202,6 +371205,7 @@ export default registerPage(Page, { name: "${name17}" });
371202
371205
  if (writeFile8) {
371203
371206
  const changes = await this.sourceTracker?.getAndFlushChanges() ?? [];
371204
371207
  await this.writeChanges(changes ?? []);
371208
+ this.flushTransactions();
371205
371209
  }
371206
371210
  this.emit("deleteProperties", payload);
371207
371211
  };
@@ -371226,6 +371230,9 @@ export default registerPage(Page, { name: "${name17}" });
371226
371230
  case "editor:deleteProperties":
371227
371231
  returnValues.push(await this.handleDeleteProperties(update.payload, false));
371228
371232
  break;
371233
+ case "editor:deleteComponents":
371234
+ returnValues.push(await this.handleDeleteComponents(update.payload, false));
371235
+ break;
371229
371236
  }
371230
371237
  }
371231
371238
  const changes = await this.sourceTracker?.getAndFlushChanges() ?? [];
@@ -376161,7 +376168,7 @@ async function startVite({ app, httpServer: httpServer2, root: root2, mode, port
376161
376168
  };
376162
376169
  const isCustomBuildEnabled2 = await isCustomComponentsEnabled();
376163
376170
  const customFolder = path21.join(root2, "custom");
376164
- const cdnUrl = "https://assets-cdn.superblocks.com/library/2.0.3-next.161";
376171
+ const cdnUrl = "https://assets-cdn.superblocks.com/library/2.0.3-next.163";
376165
376172
  const env3 = loadEnv(mode, root2, "");
376166
376173
  const hmrPort = await getFreePort();
376167
376174
  const hmrOptions = {
@@ -392085,7 +392092,6 @@ async function readPackage({ cwd, normalize: normalize3 = true } = {}) {
392085
392092
 
392086
392093
  // ../sdk/dist/cli-replacement/automatic-upgrades.js
392087
392094
  init_cjs_shims();
392088
- init_lodash();
392089
392095
  import * as child_process from "node:child_process";
392090
392096
  import { promisify } from "node:util";
392091
392097
  import { isNativeError } from "node:util/types";
@@ -392093,14 +392099,12 @@ var import_gt = __toESM(require_gt(), 1);
392093
392099
  var import_valid = __toESM(require_valid(), 1);
392094
392100
  var exec3 = promisify(child_process.exec);
392095
392101
  var logger2 = getLogger2();
392096
- async function getRemoteCliLibraryVersions(config2) {
392102
+ async function getRemoteVersions(config2) {
392097
392103
  const { token: token2, superblocksBaseUrl, id: id2 } = config2;
392098
392104
  try {
392099
392105
  const response = await fetch(new URL(`api/v3/applications/${id2}/cli-library-versions`, superblocksBaseUrl), {
392100
392106
  method: "GET",
392101
- headers: {
392102
- Authorization: `Bearer ${token2}`
392103
- }
392107
+ headers: { Authorization: `Bearer ${token2}` }
392104
392108
  });
392105
392109
  if (response.ok) {
392106
392110
  const data = await response.json();
@@ -392117,38 +392121,15 @@ async function getRemoteCliLibraryVersions(config2) {
392117
392121
  }
392118
392122
  }
392119
392123
  }
392120
- async function installPackageVersions(pm, versions) {
392121
- const installCommand = resolveCommand(pm.agent, "install", Object.entries(versions).map(([pkg, version2]) => `@superblocksteam/${pkg}@${version2}`));
392122
- if (!installCommand) {
392123
- console.error("We could not determine how to upgrade your Superblocks packages.");
392124
- return;
392125
- }
392126
- const { command, args } = installCommand;
392127
- return await exec3(`${command} ${args.join(" ")}`);
392128
- }
392129
- async function findSuperblocksExecutable() {
392124
+ async function getCurrentCliVersion() {
392130
392125
  try {
392131
392126
  const command = process.platform === "win32" ? "where" : "which";
392132
392127
  const { stdout } = await exec3(`${command} superblocks`);
392133
- return stdout.trim();
392134
- } catch {
392135
- return void 0;
392136
- }
392137
- }
392138
- async function getLocalCliLibraryVersions(pm) {
392139
- return {
392140
- cli: await getLocalCliVersion(),
392141
- library: await getLocalPackageVersion(pm, "library")
392142
- };
392143
- }
392144
- async function getLocalCliVersion() {
392145
- try {
392146
- const superblocksPath = await findSuperblocksExecutable();
392147
- if (!superblocksPath) {
392128
+ const superblocksPath = stdout.trim();
392129
+ if (!superblocksPath)
392148
392130
  return void 0;
392149
- }
392150
- const { stdout } = await exec3(`${superblocksPath} version --json`);
392151
- const json2 = JSON.parse(stdout);
392131
+ const { stdout: versionOutput } = await exec3(`${superblocksPath} version --json`);
392132
+ const json2 = JSON.parse(versionOutput);
392152
392133
  return json2.cliVersion?.replace(/@superblocksteam\/cli(-ephemeral)?\//, "");
392153
392134
  } catch (error) {
392154
392135
  if (isNativeError(error)) {
@@ -392157,46 +392138,99 @@ async function getLocalCliVersion() {
392157
392138
  return void 0;
392158
392139
  }
392159
392140
  }
392160
- async function getLocalPackageVersion(pm, pkg, global2) {
392141
+ async function getCurrentLibraryVersion(pm) {
392161
392142
  try {
392162
392143
  switch (pm.agent) {
392163
- case "npm": {
392164
- const { stdout } = await exec3(`npm list ${global2 ? "--global" : ""} @superblocksteam/${pkg} --json`, {
392165
- cwd: process.cwd()
392166
- });
392167
- const parsed = JSON.parse(stdout);
392168
- return parsed.dependencies?.[`@superblocksteam/${pkg}`]?.version ?? parsed.devDependencies?.[`@superblocksteam/${pkg}`]?.version;
392169
- }
392170
- case "pnpm": {
392171
- const { stdout } = await exec3(`pnpm list ${global2 ? "--global" : ""} @superblocksteam/${pkg} --json`, { cwd: process.cwd() });
392172
- const parsed = JSON.parse(stdout);
392173
- return parsed[0]?.dependencies?.[`@superblocksteam/${pkg}`]?.version ?? parsed[0]?.devDependencies?.[`@superblocksteam/${pkg}`]?.version;
392174
- }
392144
+ case "npm":
392145
+ return await getNpmLibraryVersion();
392146
+ case "pnpm":
392147
+ return await getPnpmLibraryVersion();
392175
392148
  default:
392176
- console.error(`${pm.agent} is currently not supported. Your application will not be upgraded automatically.`);
392177
- return;
392149
+ console.error(`${pm.agent} is currently not supported for automatic upgrades.`);
392150
+ return void 0;
392151
+ }
392152
+ } catch (error) {
392153
+ console.error("Could not resolve current library version. Skipping automatic upgrade.");
392154
+ console.error(error);
392155
+ return void 0;
392156
+ }
392157
+ }
392158
+ async function getNpmLibraryVersion() {
392159
+ const { stdout } = await exec3("npm list @superblocksteam/library --json", {
392160
+ cwd: process.cwd()
392161
+ });
392162
+ const parsed = JSON.parse(stdout);
392163
+ const packageData = parsed.dependencies?.["@superblocksteam/library"] ?? parsed.devDependencies?.["@superblocksteam/library"];
392164
+ if (!packageData?.version)
392165
+ return void 0;
392166
+ const resolved = packageData.resolved;
392167
+ if (resolved && resolved.includes("@superblocksteam/")) {
392168
+ const aliasMatch = resolved.match(/@superblocksteam\/([^\/]+)/);
392169
+ if (aliasMatch && aliasMatch[1] !== "library") {
392170
+ return {
392171
+ version: packageData.version,
392172
+ alias: `@superblocksteam/${aliasMatch[1]}`
392173
+ };
392178
392174
  }
392179
- } catch (e) {
392180
- console.error("We couldn't resolve your current Superblocks package versions. Your application will not be upgraded automatically.");
392181
- console.error(e);
392182
- return;
392183
392175
  }
392176
+ return { version: packageData.version };
392184
392177
  }
392185
- async function tryCliUpdateCommand(version2) {
392178
+ async function getPnpmLibraryVersion() {
392179
+ let packageData;
392186
392180
  try {
392187
- const superblocksPath = await findSuperblocksExecutable();
392188
- if (!superblocksPath) {
392189
- return false;
392181
+ const result = await exec3("pnpm list @superblocksteam/library --json", {
392182
+ cwd: process.cwd()
392183
+ });
392184
+ const parsed = JSON.parse(result.stdout);
392185
+ packageData = parsed[0]?.dependencies?.["@superblocksteam/library"] ?? parsed[0]?.devDependencies?.["@superblocksteam/library"];
392186
+ } catch {
392187
+ }
392188
+ if (!packageData?.version) {
392189
+ try {
392190
+ const aliasResult = await exec3("pnpm list @superblocksteam/library-ephemeral --json", { cwd: process.cwd() });
392191
+ const aliasParsed = JSON.parse(aliasResult.stdout);
392192
+ packageData = aliasParsed[0]?.dependencies?.["@superblocksteam/library"] ?? aliasParsed[0]?.devDependencies?.["@superblocksteam/library"];
392193
+ } catch {
392194
+ return void 0;
392190
392195
  }
392191
- const { stdout } = await exec3(`${superblocksPath} update --version=${version2}`);
392192
- return !stdout.includes("not updatable");
392196
+ }
392197
+ if (!packageData?.version)
392198
+ return void 0;
392199
+ const from = packageData.from;
392200
+ if (from && from !== "@superblocksteam/library") {
392201
+ return {
392202
+ version: packageData.version,
392203
+ alias: from
392204
+ };
392205
+ }
392206
+ return { version: packageData.version };
392207
+ }
392208
+ async function upgradeCliWithOclif(targetVersion) {
392209
+ try {
392210
+ const command = process.platform === "win32" ? "where" : "which";
392211
+ const { stdout } = await exec3(`${command} superblocks`);
392212
+ const superblocksPath = stdout.trim();
392213
+ if (!superblocksPath)
392214
+ return false;
392215
+ const { stdout: updateOutput } = await exec3(`${superblocksPath} update --version=${targetVersion}`);
392216
+ return !updateOutput.includes("not updatable");
392193
392217
  } catch (error) {
392194
392218
  if (isNativeError(error)) {
392195
- logger2.error(`Error checking updatability: ${error.message}`);
392219
+ logger2.error(`Error checking CLI updatability: ${error.message}`);
392196
392220
  }
392197
392221
  return false;
392198
392222
  }
392199
392223
  }
392224
+ async function upgradePackageWithPackageManager(pm, packageName, targetVersion, alias) {
392225
+ const packageSpec = alias ? `@superblocksteam/${packageName}@npm:${alias}@${targetVersion}` : `@superblocksteam/${packageName}@${targetVersion}`;
392226
+ const installCommand = resolveCommand(pm.agent, "install", [packageSpec]);
392227
+ if (!installCommand) {
392228
+ console.error("Could not determine how to upgrade Superblocks packages.");
392229
+ return;
392230
+ }
392231
+ const { command, args } = installCommand;
392232
+ await exec3(`${command} ${args.join(" ")}`);
392233
+ }
392200
392234
  async function restartCli() {
392201
392235
  const args = process.argv.slice(1);
392202
392236
  const child = child_process.spawn(process.execPath, [...args], {
@@ -392217,49 +392251,32 @@ async function checkVersionsAndUpgrade(lockService, config2) {
392217
392251
  ],
392218
392252
  cwd: process.cwd()
392219
392253
  });
392220
- if (!pm)
392221
- return;
392222
- if (!config2?.id)
392254
+ if (!pm || !config2?.id)
392223
392255
  return;
392224
- const localVersions = await getLocalCliLibraryVersions(pm);
392225
- if (
392226
- // don't attempt upgrades in local development
392227
- Object.values(localVersions).some((x) => !x || !(0, import_valid.default)(x) || x.startsWith("file:") || x.startsWith("link:"))
392228
- ) {
392256
+ const currentCliVersion = await getCurrentCliVersion();
392257
+ const currentLibraryInfo = await getCurrentLibraryVersion(pm);
392258
+ if (!currentCliVersion || !(0, import_valid.default)(currentCliVersion) || currentCliVersion.startsWith("file:") || currentCliVersion.startsWith("link:") || !currentLibraryInfo || !(0, import_valid.default)(currentLibraryInfo.version) || currentLibraryInfo.version.startsWith("file:") || currentLibraryInfo.version.startsWith("link:")) {
392229
392259
  return;
392230
392260
  }
392231
- const serverVersions = await getRemoteCliLibraryVersions(config2);
392232
- if (
392233
- // server versions could not be fetched, or
392234
- !serverVersions || // we have a different # of libraries in server/local
392235
- Object.keys(localVersions).length !== Object.keys(serverVersions).length
392236
- ) {
392261
+ const targetVersions = await getRemoteVersions(config2);
392262
+ if (!targetVersions)
392237
392263
  return;
392238
- }
392239
- const isUpToDate = isEqual_default(localVersions, serverVersions);
392240
- if (isUpToDate)
392241
- return;
392242
- const packagesToUpdate = pickBy_default(localVersions, (_, key2) => {
392243
- try {
392244
- return (0, import_gt.default)(serverVersions[key2], localVersions[key2]);
392245
- } catch {
392246
- return false;
392247
- }
392248
- });
392249
- if (Object.keys(packagesToUpdate).length === 0) {
392264
+ const cliNeedsUpgrade = targetVersions.cli && (0, import_gt.default)(targetVersions.cli, currentCliVersion);
392265
+ const libraryNeedsUpgrade = targetVersions.library && (0, import_gt.default)(targetVersions.library, currentLibraryInfo.version);
392266
+ if (!cliNeedsUpgrade && !libraryNeedsUpgrade) {
392250
392267
  return;
392251
392268
  }
392252
392269
  let cliUpdated = false;
392253
392270
  let libraryUpdated = false;
392254
- if (packagesToUpdate.cli) {
392255
- const isUpdated = await tryCliUpdateCommand(serverVersions.cli);
392256
- if (!isUpdated) {
392257
- await installPackageVersions(pm, { cli: serverVersions.cli });
392271
+ if (cliNeedsUpgrade) {
392272
+ const oclifUpgradeSucceeded = await upgradeCliWithOclif(targetVersions.cli);
392273
+ if (!oclifUpgradeSucceeded) {
392274
+ await upgradePackageWithPackageManager(pm, "cli", targetVersions.cli);
392258
392275
  cliUpdated = true;
392259
392276
  }
392260
392277
  }
392261
- if (packagesToUpdate.library) {
392262
- await installPackageVersions(pm, { library: serverVersions.library });
392278
+ if (libraryNeedsUpgrade) {
392279
+ await upgradePackageWithPackageManager(pm, "library", targetVersions.library, currentLibraryInfo.alias);
392263
392280
  libraryUpdated = true;
392264
392281
  }
392265
392282
  if (cliUpdated && libraryUpdated) {
@@ -392269,9 +392286,11 @@ async function checkVersionsAndUpgrade(lockService, config2) {
392269
392286
  } else if (libraryUpdated) {
392270
392287
  logger2.info("@superblocksteam/library has been updated.");
392271
392288
  }
392272
- logger2.info("Restarting the CLI\u2026");
392273
- await lockService.releaseLock();
392274
- await restartCli();
392289
+ if (cliUpdated || libraryUpdated) {
392290
+ logger2.info("Restarting the CLI\u2026");
392291
+ await lockService.releaseLock();
392292
+ await restartCli();
392293
+ }
392275
392294
  }
392276
392295
 
392277
392296
  // ../sdk/dist/cli-replacement/dev.mjs
@@ -509,5 +509,5 @@
509
509
  "strict": true
510
510
  }
511
511
  },
512
- "version": "2.0.3-next.161"
512
+ "version": "2.0.3-next.163"
513
513
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superblocksteam/cli",
3
- "version": "2.0.3-next.161",
3
+ "version": "2.0.3-next.163",
4
4
  "type": "module",
5
5
  "description": "Official Superblocks CLI",
6
6
  "homepage": "https://www.superblocks.com",
@@ -42,9 +42,9 @@
42
42
  "devDependencies": {
43
43
  "@eslint/js": "^9.16.0",
44
44
  "@oclif/test": "^4.1.11",
45
- "@superblocksteam/sdk": "2.0.3-next.161",
45
+ "@superblocksteam/sdk": "2.0.3-next.163",
46
46
  "@superblocksteam/shared": "0.9120.0",
47
- "@superblocksteam/util": "2.0.3-next.161",
47
+ "@superblocksteam/util": "2.0.3-next.163",
48
48
  "@types/babel__core": "^7.20.0",
49
49
  "@types/chai": "^4",
50
50
  "@types/fs-extra": "^11.0.1",