@superblocksteam/sdk 2.0.6-next.39 → 2.0.6-next.4
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/application-build.mjs +0 -4
- package/dist/application-build.mjs.map +1 -1
- package/dist/cli-replacement/automatic-upgrades.d.ts.map +1 -1
- package/dist/cli-replacement/automatic-upgrades.js +79 -142
- package/dist/cli-replacement/automatic-upgrades.js.map +1 -1
- package/dist/dev-utils/dev-server.d.mts.map +1 -1
- package/dist/dev-utils/dev-server.mjs +1 -5
- package/dist/dev-utils/dev-server.mjs.map +1 -1
- package/dist/dev-utils/vite-plugin-sb-cdn.d.mts.map +1 -1
- package/dist/dev-utils/vite-plugin-sb-cdn.mjs +3 -13
- package/dist/dev-utils/vite-plugin-sb-cdn.mjs.map +1 -1
- package/package.json +4 -6
- package/src/application-build.mts +2 -5
- package/src/cli-replacement/automatic-upgrades.ts +99 -165
- package/src/dev-utils/dev-server.mts +1 -7
- package/src/dev-utils/vite-plugin-sb-cdn.mts +3 -14
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/dev-utils/vite-plugin-build-manifest-stub.d.mts +0 -10
- package/dist/dev-utils/vite-plugin-build-manifest-stub.d.mts.map +0 -1
- package/dist/dev-utils/vite-plugin-build-manifest-stub.mjs +0 -27
- package/dist/dev-utils/vite-plugin-build-manifest-stub.mjs.map +0 -1
- package/dist/vite-plugin-generate-build-manifest.d.mts +0 -21
- package/dist/vite-plugin-generate-build-manifest.d.mts.map +0 -1
- package/dist/vite-plugin-generate-build-manifest.mjs +0 -131
- package/dist/vite-plugin-generate-build-manifest.mjs.map +0 -1
- package/src/dev-utils/vite-plugin-build-manifest-stub.mts +0 -30
- package/src/vite-plugin-generate-build-manifest.mts +0 -193
|
@@ -9,8 +9,8 @@ import { customComponentsPlugin } from "./dev-utils/custom-build.mjs";
|
|
|
9
9
|
import { getLogger } from "./dev-utils/dev-logger.mjs";
|
|
10
10
|
import { ddRumPlugin } from "./dev-utils/vite-plugin-dd-rum.mjs";
|
|
11
11
|
import { superblocksCdnPlugin } from "./dev-utils/vite-plugin-sb-cdn.mjs";
|
|
12
|
-
import { generateBuildManifestPlugin } from "./vite-plugin-generate-build-manifest.mjs";
|
|
13
12
|
import { injectSuperblocksIdsPlugin } from "./vite-plugin-inject-sb-ids-transform.mjs";
|
|
13
|
+
import type { Plugin } from "vite";
|
|
14
14
|
|
|
15
15
|
export async function buildApplication({
|
|
16
16
|
root,
|
|
@@ -133,7 +133,7 @@ async function buildWithVite({
|
|
|
133
133
|
logLevel: "info",
|
|
134
134
|
plugins: [
|
|
135
135
|
tsconfigPaths(),
|
|
136
|
-
injectIndexVitePlugin({ assetsCdnUrl, logger }),
|
|
136
|
+
injectIndexVitePlugin({ assetsCdnUrl, logger }) as Plugin,
|
|
137
137
|
customComponentsPlugin(),
|
|
138
138
|
injectSuperblocksIdsPlugin(root),
|
|
139
139
|
superblocksCdnPlugin({
|
|
@@ -142,15 +142,12 @@ async function buildWithVite({
|
|
|
142
142
|
"react/jsx-runtime": "https://esm.sh/react@18.2.0/jsx-runtime.mjs",
|
|
143
143
|
"react/jsx-dev-runtime":
|
|
144
144
|
"https://esm.sh/react@18.2.0/jsx-dev-runtime.mjs",
|
|
145
|
-
"./user-facing/build-manifest.js": "/assets/build-manifest.js",
|
|
146
|
-
"/assets/user-facing/build-manifest.js": "/assets/build-manifest.js",
|
|
147
145
|
},
|
|
148
146
|
cssImports: {
|
|
149
147
|
"@superblocksteam/library/index.css": `${libraryUrl}/index.css`,
|
|
150
148
|
},
|
|
151
149
|
}),
|
|
152
150
|
react(),
|
|
153
|
-
generateBuildManifestPlugin(root),
|
|
154
151
|
|
|
155
152
|
ddRumPlugin({
|
|
156
153
|
clientToken: ddClientToken ?? "",
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import * as child_process from "node:child_process";
|
|
2
2
|
import { promisify } from "node:util";
|
|
3
3
|
import { isNativeError } from "node:util/types";
|
|
4
|
-
import { traceFunction } from "@superblocksteam/shared";
|
|
5
4
|
import { resolveCommand, type DetectResult } from "package-manager-detector";
|
|
6
5
|
import { detect } from "package-manager-detector/detect";
|
|
7
6
|
import gt from "semver/functions/gt.js";
|
|
8
7
|
import valid from "semver/functions/valid.js";
|
|
9
8
|
import { getLogger } from "../dev-utils/dev-logger.mjs";
|
|
10
|
-
import tracer from "../dev-utils/dev-tracer.js";
|
|
11
9
|
import type { ResponseMeta } from "../socket/handlers.js";
|
|
12
10
|
import type { ApplicationConfig } from "../types/common.js";
|
|
13
11
|
import type { LockService } from "@superblocksteam/vite-plugin-file-sync/lock-service";
|
|
@@ -202,10 +200,10 @@ async function upgradeCliWithOclif(targetVersion: string): Promise<boolean> {
|
|
|
202
200
|
|
|
203
201
|
if (!superblocksPath) return false;
|
|
204
202
|
|
|
205
|
-
const { stdout: updateOutput
|
|
203
|
+
const { stdout: updateOutput } = await exec(
|
|
206
204
|
`${superblocksPath} update --version=${targetVersion}`,
|
|
207
205
|
);
|
|
208
|
-
return !
|
|
206
|
+
return !updateOutput.includes("not updatable");
|
|
209
207
|
} catch (error) {
|
|
210
208
|
if (isNativeError(error)) {
|
|
211
209
|
logger.error(`Error checking CLI updatability: ${error.message}`);
|
|
@@ -258,170 +256,106 @@ export async function checkVersionsAndUpgrade(
|
|
|
258
256
|
lockService: LockService,
|
|
259
257
|
config?: ApplicationConfig,
|
|
260
258
|
) {
|
|
261
|
-
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
const pm = await traceFunction({
|
|
271
|
-
name: "detectPackageManager",
|
|
272
|
-
tracer,
|
|
273
|
-
fn: async () => {
|
|
274
|
-
return await detect({
|
|
275
|
-
strategies: [
|
|
276
|
-
"packageManager-field",
|
|
277
|
-
"lockfile",
|
|
278
|
-
"install-metadata",
|
|
279
|
-
"devEngines-field",
|
|
280
|
-
],
|
|
281
|
-
cwd: process.cwd(),
|
|
282
|
-
});
|
|
283
|
-
},
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
if (!pm || !config?.id) return;
|
|
287
|
-
|
|
288
|
-
// Get current versions
|
|
289
|
-
const currentCliVersion = await traceFunction({
|
|
290
|
-
name: "getCurrentCliVersion",
|
|
291
|
-
tracer,
|
|
292
|
-
fn: async () => {
|
|
293
|
-
return await getCurrentCliVersion();
|
|
294
|
-
},
|
|
295
|
-
});
|
|
296
|
-
const currentLibraryInfo = await traceFunction({
|
|
297
|
-
name: "getCurrentLibraryVersion",
|
|
298
|
-
tracer,
|
|
299
|
-
fn: async () => {
|
|
300
|
-
return await getCurrentLibraryVersion(pm);
|
|
301
|
-
},
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
// Skip if we're in local development
|
|
305
|
-
if (
|
|
306
|
-
!currentCliVersion ||
|
|
307
|
-
!valid(currentCliVersion) ||
|
|
308
|
-
currentCliVersion.startsWith("file:") ||
|
|
309
|
-
currentCliVersion.startsWith("link:") ||
|
|
310
|
-
!currentLibraryInfo ||
|
|
311
|
-
!valid(currentLibraryInfo.version) ||
|
|
312
|
-
currentLibraryInfo.version.startsWith("file:") ||
|
|
313
|
-
currentLibraryInfo.version.startsWith("link:")
|
|
314
|
-
) {
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// Get target versions from server
|
|
319
|
-
const targetVersions = await traceFunction({
|
|
320
|
-
name: "getRemoteVersions",
|
|
321
|
-
tracer,
|
|
322
|
-
fn: async () => {
|
|
323
|
-
return await getRemoteVersions(config);
|
|
324
|
-
},
|
|
325
|
-
});
|
|
326
|
-
if (!targetVersions) return;
|
|
327
|
-
|
|
328
|
-
let cliNeedsUpgrade: boolean | string;
|
|
329
|
-
let libraryNeedsUpgrade: boolean | string;
|
|
330
|
-
try {
|
|
331
|
-
// If version is latest, then semver can throw an error
|
|
332
|
-
// Check if CLI needs upgrade
|
|
333
|
-
cliNeedsUpgrade =
|
|
334
|
-
targetVersions.cli && gt(targetVersions.cli, currentCliVersion);
|
|
335
|
-
|
|
336
|
-
// Check if library needs upgrade
|
|
337
|
-
libraryNeedsUpgrade =
|
|
338
|
-
targetVersions.library &&
|
|
339
|
-
gt(targetVersions.library, currentLibraryInfo.version);
|
|
340
|
-
} catch (error) {
|
|
341
|
-
console.warn(
|
|
342
|
-
"Error checking versions to upgrade, releasing lock and exiting",
|
|
343
|
-
error,
|
|
344
|
-
);
|
|
345
|
-
await traceFunction({
|
|
346
|
-
name: "shutdownLockService",
|
|
347
|
-
tracer,
|
|
348
|
-
fn: async () => {
|
|
349
|
-
await lockService.shutdown({
|
|
350
|
-
serverInitiated: false,
|
|
351
|
-
});
|
|
352
|
-
},
|
|
353
|
-
});
|
|
354
|
-
hasFailedToUpgrade = true;
|
|
355
|
-
return;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
if (!cliNeedsUpgrade && !libraryNeedsUpgrade) {
|
|
359
|
-
return; // Everything is up to date
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
let cliUpdated = false;
|
|
363
|
-
let libraryUpdated = false;
|
|
364
|
-
|
|
365
|
-
// Upgrade CLI if needed
|
|
366
|
-
if (cliNeedsUpgrade) {
|
|
367
|
-
const oclifUpgradeSucceeded = await traceFunction({
|
|
368
|
-
name: "upgradeCliWithOclif",
|
|
369
|
-
tracer,
|
|
370
|
-
fn: async () => {
|
|
371
|
-
return await upgradeCliWithOclif(targetVersions.cli);
|
|
372
|
-
},
|
|
373
|
-
});
|
|
374
|
-
if (!oclifUpgradeSucceeded) {
|
|
375
|
-
// Fall back to package manager upgrade
|
|
376
|
-
await traceFunction({
|
|
377
|
-
name: "upgradePackageWithPackageManager",
|
|
378
|
-
tracer,
|
|
379
|
-
fn: async () => {
|
|
380
|
-
await upgradePackageWithPackageManager(
|
|
381
|
-
pm,
|
|
382
|
-
"cli",
|
|
383
|
-
targetVersions.cli,
|
|
384
|
-
);
|
|
385
|
-
},
|
|
386
|
-
});
|
|
387
|
-
cliUpdated = true;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
// Upgrade library if needed
|
|
392
|
-
if (libraryNeedsUpgrade) {
|
|
393
|
-
await traceFunction({
|
|
394
|
-
name: "upgradePackageWithPackageManager",
|
|
395
|
-
tracer,
|
|
396
|
-
fn: async () => {
|
|
397
|
-
await upgradePackageWithPackageManager(
|
|
398
|
-
pm,
|
|
399
|
-
"library",
|
|
400
|
-
targetVersions.library,
|
|
401
|
-
currentLibraryInfo.alias,
|
|
402
|
-
);
|
|
403
|
-
},
|
|
404
|
-
});
|
|
405
|
-
libraryUpdated = true;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
// Log what was updated
|
|
409
|
-
if (cliUpdated && libraryUpdated) {
|
|
410
|
-
logger.info(
|
|
411
|
-
"@superblocksteam/cli and @superblocksteam/library have been updated.",
|
|
412
|
-
);
|
|
413
|
-
} else if (cliUpdated) {
|
|
414
|
-
logger.info("@superblocksteam/cli has been updated.");
|
|
415
|
-
} else if (libraryUpdated) {
|
|
416
|
-
logger.info("@superblocksteam/library has been updated.");
|
|
417
|
-
}
|
|
418
|
-
},
|
|
259
|
+
// Detect package manager
|
|
260
|
+
const pm = await detect({
|
|
261
|
+
strategies: [
|
|
262
|
+
"packageManager-field",
|
|
263
|
+
"lockfile",
|
|
264
|
+
"install-metadata",
|
|
265
|
+
"devEngines-field",
|
|
266
|
+
],
|
|
267
|
+
cwd: process.cwd(),
|
|
419
268
|
});
|
|
420
269
|
|
|
421
|
-
|
|
422
|
-
|
|
270
|
+
if (!pm || !config?.id) return;
|
|
271
|
+
|
|
272
|
+
// Get current versions
|
|
273
|
+
const currentCliVersion = await getCurrentCliVersion();
|
|
274
|
+
const currentLibraryInfo = await getCurrentLibraryVersion(pm);
|
|
275
|
+
|
|
276
|
+
// Skip if we're in local development
|
|
277
|
+
if (
|
|
278
|
+
!currentCliVersion ||
|
|
279
|
+
!valid(currentCliVersion) ||
|
|
280
|
+
currentCliVersion.startsWith("file:") ||
|
|
281
|
+
currentCliVersion.startsWith("link:") ||
|
|
282
|
+
!currentLibraryInfo ||
|
|
283
|
+
!valid(currentLibraryInfo.version) ||
|
|
284
|
+
currentLibraryInfo.version.startsWith("file:") ||
|
|
285
|
+
currentLibraryInfo.version.startsWith("link:")
|
|
286
|
+
) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// Get target versions from server
|
|
291
|
+
const targetVersions = await getRemoteVersions(config);
|
|
292
|
+
if (!targetVersions) return;
|
|
293
|
+
|
|
294
|
+
let cliNeedsUpgrade: boolean | string;
|
|
295
|
+
let libraryNeedsUpgrade: boolean | string;
|
|
296
|
+
try {
|
|
297
|
+
// If version is latest, then semver can throw an error
|
|
298
|
+
// Check if CLI needs upgrade
|
|
299
|
+
cliNeedsUpgrade =
|
|
300
|
+
targetVersions.cli && gt(targetVersions.cli, currentCliVersion);
|
|
301
|
+
|
|
302
|
+
// Check if library needs upgrade
|
|
303
|
+
libraryNeedsUpgrade =
|
|
304
|
+
targetVersions.library &&
|
|
305
|
+
gt(targetVersions.library, currentLibraryInfo.version);
|
|
306
|
+
} catch (error) {
|
|
307
|
+
console.warn(
|
|
308
|
+
"Error checking versions to upgrade, releasing lock and exiting",
|
|
309
|
+
error,
|
|
310
|
+
);
|
|
311
|
+
await lockService.shutdown({
|
|
312
|
+
serverInitiated: false,
|
|
313
|
+
});
|
|
423
314
|
process.exit(1);
|
|
424
|
-
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (!cliNeedsUpgrade && !libraryNeedsUpgrade) {
|
|
318
|
+
return; // Everything is up to date
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
let cliUpdated = false;
|
|
322
|
+
let libraryUpdated = false;
|
|
323
|
+
|
|
324
|
+
// Upgrade CLI if needed
|
|
325
|
+
if (cliNeedsUpgrade) {
|
|
326
|
+
const oclifUpgradeSucceeded = await upgradeCliWithOclif(targetVersions.cli);
|
|
327
|
+
|
|
328
|
+
if (!oclifUpgradeSucceeded) {
|
|
329
|
+
// Fall back to package manager upgrade
|
|
330
|
+
await upgradePackageWithPackageManager(pm, "cli", targetVersions.cli);
|
|
331
|
+
cliUpdated = true;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// Upgrade library if needed
|
|
336
|
+
if (libraryNeedsUpgrade) {
|
|
337
|
+
await upgradePackageWithPackageManager(
|
|
338
|
+
pm,
|
|
339
|
+
"library",
|
|
340
|
+
targetVersions.library,
|
|
341
|
+
currentLibraryInfo.alias,
|
|
342
|
+
);
|
|
343
|
+
libraryUpdated = true;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// Log what was updated
|
|
347
|
+
if (cliUpdated && libraryUpdated) {
|
|
348
|
+
logger.info(
|
|
349
|
+
"@superblocksteam/cli and @superblocksteam/library have been updated.",
|
|
350
|
+
);
|
|
351
|
+
} else if (cliUpdated) {
|
|
352
|
+
logger.info("@superblocksteam/cli has been updated.");
|
|
353
|
+
} else if (libraryUpdated) {
|
|
354
|
+
logger.info("@superblocksteam/library has been updated.");
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// Restart CLI if anything was updated
|
|
358
|
+
if (cliUpdated || libraryUpdated) {
|
|
425
359
|
logger.info("Restarting the CLI…");
|
|
426
360
|
await lockService.releaseLock();
|
|
427
361
|
process.exit(AUTO_UPGRADE_EXIT_CODE);
|
|
@@ -19,7 +19,6 @@ import {
|
|
|
19
19
|
isCustomComponentsEnabled,
|
|
20
20
|
} from "./custom-build.mjs";
|
|
21
21
|
import { getLogger } from "./dev-logger.mjs";
|
|
22
|
-
import { buildManifestStubPlugin } from "./vite-plugin-build-manifest-stub.mjs";
|
|
23
22
|
import { ddRumPlugin } from "./vite-plugin-dd-rum.mjs";
|
|
24
23
|
import { superblocksCdnPlugin } from "./vite-plugin-sb-cdn.mjs";
|
|
25
24
|
import type { AiService } from "@superblocksteam/vite-plugin-file-sync/ai-service";
|
|
@@ -277,8 +276,6 @@ async function startVite({
|
|
|
277
276
|
const isCustomBuildEnabled = await isCustomComponentsEnabled();
|
|
278
277
|
const customFolder = path.join(root, "custom");
|
|
279
278
|
|
|
280
|
-
const draftsFolder = path.join(root, ".superblocks");
|
|
281
|
-
|
|
282
279
|
const cdnUrl = process.env.SUPERBLOCKS_CDN_URL ?? "http://localhost:4040/cdn";
|
|
283
280
|
|
|
284
281
|
const env = loadEnv(mode, root, "");
|
|
@@ -316,7 +313,7 @@ async function startVite({
|
|
|
316
313
|
server: {
|
|
317
314
|
middlewareMode: true,
|
|
318
315
|
watch: {
|
|
319
|
-
ignored: [`${customFolder}
|
|
316
|
+
ignored: [`${customFolder}/**/*`],
|
|
320
317
|
},
|
|
321
318
|
hmr: hmrOptions,
|
|
322
319
|
cors: {
|
|
@@ -350,9 +347,6 @@ async function startVite({
|
|
|
350
347
|
{ isCustomBuildEnabled },
|
|
351
348
|
) as Plugin,
|
|
352
349
|
|
|
353
|
-
// Add a virtual "stub" module for the build manifest
|
|
354
|
-
buildManifestStubPlugin(),
|
|
355
|
-
|
|
356
350
|
// for now, only use the CDN locally
|
|
357
351
|
superblocksCdnPlugin({
|
|
358
352
|
imports: {
|
|
@@ -224,8 +224,8 @@ async function analyzeModuleGraph(
|
|
|
224
224
|
{ content: string; binary: ArrayBuffer }
|
|
225
225
|
> = new Map(),
|
|
226
226
|
): Promise<AnalysisResult> {
|
|
227
|
-
// Avoid circular dependencies
|
|
228
|
-
if (visited.has(url)
|
|
227
|
+
// Avoid circular dependencies
|
|
228
|
+
if (visited.has(url)) {
|
|
229
229
|
return {
|
|
230
230
|
dependencies: new Set(),
|
|
231
231
|
content: "",
|
|
@@ -474,13 +474,6 @@ const wellKnownPackages = new Map<string, string>([
|
|
|
474
474
|
["react-dom", "https://esm.sh/react-dom@18.2.0"],
|
|
475
475
|
["react/jsx-runtime", "https://esm.sh/react@18.2.0/jsx-runtime"],
|
|
476
476
|
["react/jsx-dev-runtime", "https://esm.sh/react@18.2.0/jsx-dev-runtime"],
|
|
477
|
-
["./user-facing/build-manifest.js", "/assets/build-manifest.js"],
|
|
478
|
-
["/assets/user-facing/build-manifest.js", "/assets/build-manifest.js"],
|
|
479
|
-
]);
|
|
480
|
-
|
|
481
|
-
const packagesToExcludeFromCdnRedirect = new Set<string>([
|
|
482
|
-
"./user-facing/build-manifest.js",
|
|
483
|
-
"/assets/user-facing/build-manifest.js",
|
|
484
477
|
]);
|
|
485
478
|
|
|
486
479
|
const react18CdnUrl = "https://esm.sh/react@18.2.0";
|
|
@@ -780,12 +773,8 @@ export async function superblocksCdnPlugin(
|
|
|
780
773
|
// Externalize modules specified in the import map
|
|
781
774
|
// The cdn: prefix ensures they're properly resolved to the CDN URL
|
|
782
775
|
if (imports.includes(id)) {
|
|
783
|
-
const shouldRedirectToCdn = !packagesToExcludeFromCdnRedirect.has(id);
|
|
784
776
|
debug(`Externalizing module for CDN resolution: ${id}`);
|
|
785
|
-
return {
|
|
786
|
-
id: `${shouldRedirectToCdn ? "cdn:" : ""}${id}`,
|
|
787
|
-
external: true,
|
|
788
|
-
};
|
|
777
|
+
return { id: `cdn:${id}`, external: true };
|
|
789
778
|
}
|
|
790
779
|
|
|
791
780
|
return null;
|