webstudio 0.265.0 → 0.266.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/lib/cli.js +287 -150
- package/package.json +14 -12
- package/templates/defaults/package.json +7 -7
- package/templates/react-router/package.json +7 -7
- package/templates/ssg/package.json +6 -6
package/lib/cli.js
CHANGED
|
@@ -146,13 +146,6 @@ const loadJSONFile = async (filePath) => {
|
|
|
146
146
|
return null;
|
|
147
147
|
}
|
|
148
148
|
};
|
|
149
|
-
var loadProjectDataByBuildId = async (params) => {
|
|
150
|
-
const headers = "seviceToken" in params ? { Authorization: params.seviceToken } : { "x-auth-token": params.authToken };
|
|
151
|
-
return await createTrpcClient(params.origin, headers).query(
|
|
152
|
-
"build.loadProjectDataByBuildId",
|
|
153
|
-
{ buildId: params.buildId }
|
|
154
|
-
);
|
|
155
|
-
};
|
|
156
149
|
var createTrpcClient = (origin, headers) => {
|
|
157
150
|
const { sourceOrigin } = parseBuilderUrl(origin);
|
|
158
151
|
const url = new URL("/trpc", sourceOrigin);
|
|
@@ -165,8 +158,18 @@ var createTrpcClient = (origin, headers) => {
|
|
|
165
158
|
]
|
|
166
159
|
});
|
|
167
160
|
};
|
|
161
|
+
var loadProjectDataByBuildId = async (params) => {
|
|
162
|
+
const headers = "seviceToken" in params ? { Authorization: params.seviceToken } : { "x-auth-token": params.authToken };
|
|
163
|
+
return await createTrpcClient(params.origin, {
|
|
164
|
+
...params.headers,
|
|
165
|
+
...headers
|
|
166
|
+
}).query("build.loadProjectDataByBuildId", {
|
|
167
|
+
buildId: params.buildId
|
|
168
|
+
});
|
|
169
|
+
};
|
|
168
170
|
var loadProjectDataByProjectId = async (params) => {
|
|
169
171
|
return await createTrpcClient(params.origin, {
|
|
172
|
+
...params.headers,
|
|
170
173
|
"x-auth-token": params.authToken
|
|
171
174
|
}).query("build.loadProjectDataByProjectId", {
|
|
172
175
|
projectId: params.projectId
|
|
@@ -309,6 +312,128 @@ You can find your config at ${GLOBAL_CONFIG_FILE}`);
|
|
|
309
312
|
);
|
|
310
313
|
log.step("The project is linked successfully");
|
|
311
314
|
};
|
|
315
|
+
const apiCompatibilityErrorType = "webstudioApiCompatibilityError";
|
|
316
|
+
const apiClientHeader = "x-webstudio-client";
|
|
317
|
+
const apiClientVersionHeader = "x-webstudio-client-version";
|
|
318
|
+
const ApiCompatibilityTarget = z.enum(["browser", "cli"]);
|
|
319
|
+
z.enum(["browser", "cli", "service"]);
|
|
320
|
+
const ApiCompatibilityAction = z.discriminatedUnion("type", [
|
|
321
|
+
z.object({
|
|
322
|
+
type: z.literal("reloadBrowser")
|
|
323
|
+
}),
|
|
324
|
+
z.object({
|
|
325
|
+
type: z.literal("updateCli")
|
|
326
|
+
})
|
|
327
|
+
]);
|
|
328
|
+
const ApiCompatibilityPayload = z.object({
|
|
329
|
+
type: z.literal(apiCompatibilityErrorType),
|
|
330
|
+
reason: z.enum(["apiRouteNotFound", "apiProcedureNotFound"]),
|
|
331
|
+
target: ApiCompatibilityTarget,
|
|
332
|
+
message: z.string(),
|
|
333
|
+
action: ApiCompatibilityAction
|
|
334
|
+
});
|
|
335
|
+
const isObject = (value) => typeof value === "object" && value !== null;
|
|
336
|
+
const getApiCompatibilityPayload = (value) => {
|
|
337
|
+
const findPayload = (value2, seen) => {
|
|
338
|
+
const parsed = ApiCompatibilityPayload.safeParse(value2);
|
|
339
|
+
if (parsed.success) {
|
|
340
|
+
return parsed.data;
|
|
341
|
+
}
|
|
342
|
+
if (isObject(value2) === false) {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
if (seen.has(value2)) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
seen.add(value2);
|
|
349
|
+
if (Array.isArray(value2)) {
|
|
350
|
+
for (const item of value2) {
|
|
351
|
+
const payload = findPayload(item, seen);
|
|
352
|
+
if (payload !== void 0) {
|
|
353
|
+
return payload;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
const candidates = [
|
|
359
|
+
value2.payload,
|
|
360
|
+
value2.error,
|
|
361
|
+
value2.data,
|
|
362
|
+
isObject(value2.data) ? value2.data.apiCompatibility : void 0,
|
|
363
|
+
isObject(value2.shape) ? value2.shape.data : void 0,
|
|
364
|
+
isObject(value2.shape) && isObject(value2.shape.data) ? value2.shape.data.apiCompatibility : void 0,
|
|
365
|
+
value2.cause
|
|
366
|
+
];
|
|
367
|
+
for (const candidate of candidates) {
|
|
368
|
+
const payload = findPayload(candidate, seen);
|
|
369
|
+
if (payload !== void 0) {
|
|
370
|
+
return payload;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
return findPayload(value, /* @__PURE__ */ new WeakSet());
|
|
375
|
+
};
|
|
376
|
+
const name = "webstudio";
|
|
377
|
+
const version = "0.266.0";
|
|
378
|
+
const description = "Webstudio CLI";
|
|
379
|
+
const author = "Webstudio <github@webstudio.is>";
|
|
380
|
+
const homepage = "https://webstudio.is";
|
|
381
|
+
const type$1 = "module";
|
|
382
|
+
const bin = { "webstudio-cli": "./bin.js", "webstudio": "./bin.js" };
|
|
383
|
+
const imports = { "#cli": { "webstudio": "./src/cli.ts", "default": "./lib/cli.js" } };
|
|
384
|
+
const files = ["lib/*", "templates/*", "bin.js", "!*.{test,stories}.*"];
|
|
385
|
+
const scripts = { "typecheck": "tsgo --noEmit", "build": "rm -rf lib && vite build", "test": "vitest run" };
|
|
386
|
+
const license = "AGPL-3.0-or-later";
|
|
387
|
+
const engines = { "node": ">=22" };
|
|
388
|
+
const dependencies = { "@clack/prompts": "^0.10.0", "@emotion/hash": "^0.9.2", "@trpc/client": "^10.45.2", "@webstudio-is/project-migrations": "workspace:*", "@webstudio-is/trpc-interface": "workspace:*", "acorn": "^8.14.1", "acorn-walk": "^8.3.4", "change-case": "^5.4.4", "deepmerge": "^4.3.1", "env-paths": "^3.0.0", "nanoid": "^5.1.5", "p-limit": "^6.2.0", "parse5": "7.3.0", "picocolors": "^1.1.1", "reserved-identifiers": "^1.0.0", "tinyexec": "^0.3.2", "warn-once": "^0.1.1", "yargs": "^17.7.2", "zod": "^3.24.2" };
|
|
389
|
+
const devDependencies = { "@cloudflare/vite-plugin": "^1.1.0", "@netlify/vite-plugin-react-router": "^1.0.1", "@react-router/dev": "^7.5.3", "@react-router/fs-routes": "^7.5.3", "@remix-run/cloudflare": "^2.16.5", "@remix-run/cloudflare-pages": "^2.16.5", "@remix-run/dev": "^2.16.5", "@remix-run/node": "^2.16.5", "@remix-run/react": "^2.16.5", "@remix-run/server-runtime": "^2.16.5", "@types/react": "^18.2.70", "@types/react-dom": "^18.2.25", "@types/yargs": "^17.0.33", "@vercel/react-router": "^1.1.0", "@vitejs/plugin-react": "^4.4.1", "@webstudio-is/css-engine": "workspace:*", "@webstudio-is/http-client": "workspace:*", "@webstudio-is/image": "workspace:*", "@webstudio-is/react-sdk": "workspace:*", "@webstudio-is/sdk": "workspace:*", "@webstudio-is/sdk-components-animation": "workspace:*", "@webstudio-is/sdk-components-react": "workspace:*", "@webstudio-is/sdk-components-react-radix": "workspace:*", "@webstudio-is/sdk-components-react-remix": "workspace:*", "@webstudio-is/sdk-components-react-router": "workspace:*", "@webstudio-is/tsconfig": "workspace:*", "h3": "^1.15.1", "ipx": "^3.0.3", "isbot": "^5.1.25", "prettier": "3.5.3", "react": "18.3.0-canary-14898b6a9-20240318", "react-dom": "18.3.0-canary-14898b6a9-20240318", "react-router": "^7.5.3", "ts-expect": "^1.3.0", "vike": "^0.4.229", "vite": "^6.3.4", "vitest": "^3.1.2", "wrangler": "^3.63.2" };
|
|
390
|
+
const packageJson = {
|
|
391
|
+
name,
|
|
392
|
+
version,
|
|
393
|
+
description,
|
|
394
|
+
author,
|
|
395
|
+
homepage,
|
|
396
|
+
type: type$1,
|
|
397
|
+
bin,
|
|
398
|
+
imports,
|
|
399
|
+
files,
|
|
400
|
+
scripts,
|
|
401
|
+
license,
|
|
402
|
+
engines,
|
|
403
|
+
dependencies,
|
|
404
|
+
devDependencies
|
|
405
|
+
};
|
|
406
|
+
class HandledCliError extends Error {
|
|
407
|
+
constructor() {
|
|
408
|
+
super("Handled CLI error");
|
|
409
|
+
this.name = "HandledCliError";
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
const isHandledCliError = (error) => error instanceof HandledCliError;
|
|
413
|
+
const apiCompatibilityHeaders = {
|
|
414
|
+
[apiClientHeader]: "cli",
|
|
415
|
+
[apiClientVersionHeader]: packageJson.version
|
|
416
|
+
};
|
|
417
|
+
const updateCliCommand = "npm install -g webstudio@latest";
|
|
418
|
+
const getCliCompatibilityMessage = (error) => {
|
|
419
|
+
const payload = getApiCompatibilityPayload(error);
|
|
420
|
+
if ((payload == null ? void 0 : payload.action.type) !== "updateCli") {
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
return `${payload.message}
|
|
424
|
+
|
|
425
|
+
Update the CLI with:
|
|
426
|
+
${updateCliCommand}
|
|
427
|
+
|
|
428
|
+
Or run the latest version once with:
|
|
429
|
+
npx webstudio@latest sync`;
|
|
430
|
+
};
|
|
431
|
+
const stopSyncingWithError = (syncing, error) => {
|
|
432
|
+
const compatibilityMessage = getCliCompatibilityMessage(error);
|
|
433
|
+
const message = error instanceof Error ? error.message : "Unable to synchronize project data";
|
|
434
|
+
syncing.stop(compatibilityMessage ?? message, 2);
|
|
435
|
+
return compatibilityMessage;
|
|
436
|
+
};
|
|
312
437
|
const syncOptions = (yargs) => yargs.option("buildId", {
|
|
313
438
|
type: "string",
|
|
314
439
|
describe: "[Experimental] Project build id to sync"
|
|
@@ -325,12 +450,21 @@ const sync = async (options) => {
|
|
|
325
450
|
syncing.start(`Synchronizing project data`);
|
|
326
451
|
if (options.buildId !== void 0 && options.origin !== void 0 && options.authToken !== void 0) {
|
|
327
452
|
syncing.message(`Synchronizing project data from ${options.origin}`);
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
453
|
+
try {
|
|
454
|
+
project = await loadProjectDataByBuildId({
|
|
455
|
+
buildId: options.buildId,
|
|
456
|
+
seviceToken: options.authToken,
|
|
457
|
+
origin: options.origin,
|
|
458
|
+
headers: apiCompatibilityHeaders
|
|
459
|
+
});
|
|
460
|
+
project.origin = options.origin;
|
|
461
|
+
} catch (error) {
|
|
462
|
+
const compatibilityMessage = stopSyncingWithError(syncing, error);
|
|
463
|
+
if (compatibilityMessage !== void 0) {
|
|
464
|
+
throw new HandledCliError();
|
|
465
|
+
}
|
|
466
|
+
throw error;
|
|
467
|
+
}
|
|
334
468
|
} else {
|
|
335
469
|
const globalConfigText = await readFile(GLOBAL_CONFIG_FILE, "utf-8");
|
|
336
470
|
const globalConfig = jsonToGlobalConfig(JSON.parse(globalConfigText));
|
|
@@ -360,15 +494,20 @@ const sync = async (options) => {
|
|
|
360
494
|
project = options.buildId !== void 0 ? await loadProjectDataByBuildId({
|
|
361
495
|
buildId: options.buildId,
|
|
362
496
|
authToken: token,
|
|
363
|
-
origin
|
|
497
|
+
origin,
|
|
498
|
+
headers: apiCompatibilityHeaders
|
|
364
499
|
}) : await loadProjectDataByProjectId({
|
|
365
500
|
projectId: localConfig.projectId,
|
|
366
501
|
authToken: token,
|
|
367
|
-
origin
|
|
502
|
+
origin,
|
|
503
|
+
headers: apiCompatibilityHeaders
|
|
368
504
|
});
|
|
369
505
|
project.origin = origin;
|
|
370
506
|
} catch (error) {
|
|
371
|
-
syncing
|
|
507
|
+
const compatibilityMessage = stopSyncingWithError(syncing, error);
|
|
508
|
+
if (compatibilityMessage !== void 0) {
|
|
509
|
+
throw new HandledCliError();
|
|
510
|
+
}
|
|
372
511
|
throw error;
|
|
373
512
|
}
|
|
374
513
|
}
|
|
@@ -766,9 +905,9 @@ function multiply_v3_m3x3(input2, matrix, out = [0, 0, 0]) {
|
|
|
766
905
|
return out;
|
|
767
906
|
}
|
|
768
907
|
function isString(str) {
|
|
769
|
-
return type
|
|
908
|
+
return type(str) === "string";
|
|
770
909
|
}
|
|
771
|
-
function type
|
|
910
|
+
function type(o2) {
|
|
772
911
|
let str = Object.prototype.toString.call(o2);
|
|
773
912
|
return (str.match(/^\[object\s+(.*?)\]$/)[1] || "").toLowerCase();
|
|
774
913
|
}
|
|
@@ -1547,7 +1686,7 @@ const _ColorSpace = class _ColorSpace {
|
|
|
1547
1686
|
if (!space || isInstance(space, this)) {
|
|
1548
1687
|
return space;
|
|
1549
1688
|
}
|
|
1550
|
-
let argType = type
|
|
1689
|
+
let argType = type(space);
|
|
1551
1690
|
if (argType === "string") {
|
|
1552
1691
|
let ret = _ColorSpace.registry[space.toLowerCase()];
|
|
1553
1692
|
if (!ret) {
|
|
@@ -1604,7 +1743,7 @@ const _ColorSpace = class _ColorSpace {
|
|
|
1604
1743
|
*/
|
|
1605
1744
|
static resolveCoord(ref, workingSpace) {
|
|
1606
1745
|
var _a2;
|
|
1607
|
-
let coordType = type
|
|
1746
|
+
let coordType = type(ref);
|
|
1608
1747
|
let space, coord;
|
|
1609
1748
|
if (coordType === "string") {
|
|
1610
1749
|
if (ref.includes(".")) {
|
|
@@ -1627,7 +1766,7 @@ const _ColorSpace = class _ColorSpace {
|
|
|
1627
1766
|
`Cannot resolve coordinate reference ${ref}: No color space specified and relative references are not allowed here`
|
|
1628
1767
|
);
|
|
1629
1768
|
}
|
|
1630
|
-
coordType = type
|
|
1769
|
+
coordType = type(coord);
|
|
1631
1770
|
if (coordType === "number" || coordType === "string" && coord >= 0) {
|
|
1632
1771
|
let meta = Object.entries(space.coords)[coord];
|
|
1633
1772
|
if (meta) {
|
|
@@ -3760,7 +3899,7 @@ var CompilerSettings = z.object({
|
|
|
3760
3899
|
// All fields are optional to ensure consistency and allow for the addition of new fields without requiring migration
|
|
3761
3900
|
atomicStyles: z.boolean().optional()
|
|
3762
3901
|
});
|
|
3763
|
-
z.object({
|
|
3902
|
+
var Pages = z.object({
|
|
3764
3903
|
meta: ProjectMeta.optional(),
|
|
3765
3904
|
compiler: CompilerSettings.optional(),
|
|
3766
3905
|
redirects: z.array(PageRedirect).optional(),
|
|
@@ -5651,104 +5790,6 @@ var getStaticSiteMapXml = (pages, updatedAt) => {
|
|
|
5651
5790
|
lastModified: updatedAt.split("T")[0]
|
|
5652
5791
|
}));
|
|
5653
5792
|
};
|
|
5654
|
-
var toMap = (items, normalizeItem = (item) => item) => {
|
|
5655
|
-
if (items instanceof Map) {
|
|
5656
|
-
return new Map(
|
|
5657
|
-
Array.from(items, ([id, item]) => [id, normalizeItem(item)])
|
|
5658
|
-
);
|
|
5659
|
-
}
|
|
5660
|
-
const list = Array.isArray(items) ? items : Object.values(items);
|
|
5661
|
-
return new Map(list.map((item) => [item.id, normalizeItem(item)]));
|
|
5662
|
-
};
|
|
5663
|
-
var normalizePage = (page) => ({
|
|
5664
|
-
...page,
|
|
5665
|
-
meta: page.meta ?? {}
|
|
5666
|
-
});
|
|
5667
|
-
var isLegacyPages = (pages) => {
|
|
5668
|
-
if (typeof pages !== "object" || pages === null) {
|
|
5669
|
-
return false;
|
|
5670
|
-
}
|
|
5671
|
-
return "homePage" in pages && Array.isArray(pages.pages);
|
|
5672
|
-
};
|
|
5673
|
-
var isSerializedPages = (pages) => {
|
|
5674
|
-
if (typeof pages !== "object" || pages === null) {
|
|
5675
|
-
return false;
|
|
5676
|
-
}
|
|
5677
|
-
const candidate = pages;
|
|
5678
|
-
return typeof candidate.homePageId === "string" && typeof candidate.rootFolderId === "string" && candidate.pages !== void 0 && candidate.folders !== void 0;
|
|
5679
|
-
};
|
|
5680
|
-
var migratePages = (pages) => {
|
|
5681
|
-
var _a2;
|
|
5682
|
-
if (isSerializedPages(pages) && pages.pages instanceof Map && pages.folders instanceof Map) {
|
|
5683
|
-
return pages;
|
|
5684
|
-
}
|
|
5685
|
-
if (isSerializedPages(pages)) {
|
|
5686
|
-
return {
|
|
5687
|
-
meta: pages.meta,
|
|
5688
|
-
compiler: pages.compiler,
|
|
5689
|
-
redirects: pages.redirects,
|
|
5690
|
-
homePageId: pages.homePageId,
|
|
5691
|
-
rootFolderId: pages.rootFolderId,
|
|
5692
|
-
pages: toMap(pages.pages, normalizePage),
|
|
5693
|
-
folders: toMap(pages.folders)
|
|
5694
|
-
};
|
|
5695
|
-
}
|
|
5696
|
-
if (isLegacyPages(pages) === false) {
|
|
5697
|
-
throw new Error("Pages data has unsupported shape.");
|
|
5698
|
-
}
|
|
5699
|
-
const homePage = {
|
|
5700
|
-
...normalizePage(pages.homePage),
|
|
5701
|
-
path: ""
|
|
5702
|
-
};
|
|
5703
|
-
const nextPages = /* @__PURE__ */ new Map([[homePage.id, homePage]]);
|
|
5704
|
-
for (const page of pages.pages) {
|
|
5705
|
-
if (page.id === homePage.id) {
|
|
5706
|
-
continue;
|
|
5707
|
-
}
|
|
5708
|
-
nextPages.set(page.id, normalizePage(page));
|
|
5709
|
-
}
|
|
5710
|
-
const nextFolders = /* @__PURE__ */ new Map();
|
|
5711
|
-
for (const folder of pages.folders ?? []) {
|
|
5712
|
-
nextFolders.set(folder.id, { ...folder, children: [...folder.children] });
|
|
5713
|
-
}
|
|
5714
|
-
const rootFolder = Array.from(nextFolders.values()).find(isRootFolder) ?? ((_a2 = pages.folders) == null ? void 0 : _a2[0]) ?? {
|
|
5715
|
-
id: ROOT_FOLDER_ID,
|
|
5716
|
-
name: "Root",
|
|
5717
|
-
slug: "",
|
|
5718
|
-
children: []
|
|
5719
|
-
};
|
|
5720
|
-
if (nextFolders.has(rootFolder.id) === false) {
|
|
5721
|
-
nextFolders.set(rootFolder.id, { ...rootFolder, children: [] });
|
|
5722
|
-
}
|
|
5723
|
-
const nextRootFolder = nextFolders.get(rootFolder.id);
|
|
5724
|
-
if (nextRootFolder === void 0) {
|
|
5725
|
-
throw new Error("Pages must include a root folder.");
|
|
5726
|
-
}
|
|
5727
|
-
for (const folder of nextFolders.values()) {
|
|
5728
|
-
folder.children = folder.children.filter(
|
|
5729
|
-
(childId) => childId !== homePage.id
|
|
5730
|
-
);
|
|
5731
|
-
}
|
|
5732
|
-
nextRootFolder.children.unshift(homePage.id);
|
|
5733
|
-
const referencedIds = new Set(
|
|
5734
|
-
Array.from(nextFolders.values()).flatMap((folder) => folder.children)
|
|
5735
|
-
);
|
|
5736
|
-
for (const page of pages.pages) {
|
|
5737
|
-
if (page.id !== homePage.id && referencedIds.has(page.id) === false) {
|
|
5738
|
-
nextRootFolder.children.push(page.id);
|
|
5739
|
-
referencedIds.add(page.id);
|
|
5740
|
-
}
|
|
5741
|
-
}
|
|
5742
|
-
return {
|
|
5743
|
-
meta: pages.meta,
|
|
5744
|
-
compiler: pages.compiler,
|
|
5745
|
-
redirects: pages.redirects,
|
|
5746
|
-
homePageId: homePage.id,
|
|
5747
|
-
rootFolderId: rootFolder.id,
|
|
5748
|
-
pages: nextPages,
|
|
5749
|
-
folders: nextFolders
|
|
5750
|
-
};
|
|
5751
|
-
};
|
|
5752
5793
|
var identifiers = reservedIdentifiers({ includeGlobalProperties: true });
|
|
5753
5794
|
var isReserved = (identifier) => identifiers.has(identifier);
|
|
5754
5795
|
var normalizeJsName = (name2) => {
|
|
@@ -7023,6 +7064,129 @@ var generateWebstudioComponent = ({
|
|
|
7023
7064
|
`;
|
|
7024
7065
|
return generatedComponent;
|
|
7025
7066
|
};
|
|
7067
|
+
var toMap = (items, normalizeItem = (item) => item) => {
|
|
7068
|
+
if (items instanceof Map) {
|
|
7069
|
+
return new Map(
|
|
7070
|
+
Array.from(items, ([id, item]) => [id, normalizeItem(item)])
|
|
7071
|
+
);
|
|
7072
|
+
}
|
|
7073
|
+
const list = Array.isArray(items) ? items : Object.values(items);
|
|
7074
|
+
return new Map(list.map((item) => [item.id, normalizeItem(item)]));
|
|
7075
|
+
};
|
|
7076
|
+
var normalizePage = (page) => ({
|
|
7077
|
+
...page,
|
|
7078
|
+
meta: page.meta ?? {}
|
|
7079
|
+
});
|
|
7080
|
+
var isLegacyPages = (pages) => {
|
|
7081
|
+
if (typeof pages !== "object" || pages === null) {
|
|
7082
|
+
return false;
|
|
7083
|
+
}
|
|
7084
|
+
return "homePage" in pages && Array.isArray(pages.pages);
|
|
7085
|
+
};
|
|
7086
|
+
var isSerializedPages = (pages) => {
|
|
7087
|
+
if (typeof pages !== "object" || pages === null) {
|
|
7088
|
+
return false;
|
|
7089
|
+
}
|
|
7090
|
+
const candidate = pages;
|
|
7091
|
+
return typeof candidate.homePageId === "string" && typeof candidate.rootFolderId === "string" && candidate.pages !== void 0 && candidate.folders !== void 0;
|
|
7092
|
+
};
|
|
7093
|
+
var removeOrphanFolderChildren = (pages, folders) => {
|
|
7094
|
+
const nextFolders = /* @__PURE__ */ new Map();
|
|
7095
|
+
for (const [folderId, folder] of folders) {
|
|
7096
|
+
nextFolders.set(folderId, {
|
|
7097
|
+
...folder,
|
|
7098
|
+
children: folder.children.filter(
|
|
7099
|
+
(childId) => pages.has(childId) || folders.has(childId)
|
|
7100
|
+
)
|
|
7101
|
+
});
|
|
7102
|
+
}
|
|
7103
|
+
return nextFolders;
|
|
7104
|
+
};
|
|
7105
|
+
var migratePages = (pages) => {
|
|
7106
|
+
var _a2;
|
|
7107
|
+
if (isSerializedPages(pages) && pages.pages instanceof Map && pages.folders instanceof Map) {
|
|
7108
|
+
const currentPages = pages;
|
|
7109
|
+
const result = Pages.safeParse(currentPages);
|
|
7110
|
+
if (result.success) {
|
|
7111
|
+
return currentPages;
|
|
7112
|
+
}
|
|
7113
|
+
return {
|
|
7114
|
+
...currentPages,
|
|
7115
|
+
folders: removeOrphanFolderChildren(
|
|
7116
|
+
currentPages.pages,
|
|
7117
|
+
currentPages.folders
|
|
7118
|
+
)
|
|
7119
|
+
};
|
|
7120
|
+
}
|
|
7121
|
+
if (isSerializedPages(pages)) {
|
|
7122
|
+
const nextPages2 = toMap(pages.pages, normalizePage);
|
|
7123
|
+
const nextFolders2 = toMap(pages.folders);
|
|
7124
|
+
return {
|
|
7125
|
+
meta: pages.meta,
|
|
7126
|
+
compiler: pages.compiler,
|
|
7127
|
+
redirects: pages.redirects,
|
|
7128
|
+
homePageId: pages.homePageId,
|
|
7129
|
+
rootFolderId: pages.rootFolderId,
|
|
7130
|
+
pages: nextPages2,
|
|
7131
|
+
folders: removeOrphanFolderChildren(nextPages2, nextFolders2)
|
|
7132
|
+
};
|
|
7133
|
+
}
|
|
7134
|
+
if (isLegacyPages(pages) === false) {
|
|
7135
|
+
throw new Error("Pages data has unsupported shape.");
|
|
7136
|
+
}
|
|
7137
|
+
const homePage = {
|
|
7138
|
+
...normalizePage(pages.homePage),
|
|
7139
|
+
path: ""
|
|
7140
|
+
};
|
|
7141
|
+
const nextPages = /* @__PURE__ */ new Map([[homePage.id, homePage]]);
|
|
7142
|
+
for (const page of pages.pages) {
|
|
7143
|
+
if (page.id === homePage.id) {
|
|
7144
|
+
continue;
|
|
7145
|
+
}
|
|
7146
|
+
nextPages.set(page.id, normalizePage(page));
|
|
7147
|
+
}
|
|
7148
|
+
const nextFolders = /* @__PURE__ */ new Map();
|
|
7149
|
+
for (const folder of pages.folders ?? []) {
|
|
7150
|
+
nextFolders.set(folder.id, { ...folder, children: [...folder.children] });
|
|
7151
|
+
}
|
|
7152
|
+
const rootFolder = Array.from(nextFolders.values()).find(isRootFolder) ?? ((_a2 = pages.folders) == null ? void 0 : _a2[0]) ?? {
|
|
7153
|
+
id: ROOT_FOLDER_ID,
|
|
7154
|
+
name: "Root",
|
|
7155
|
+
slug: "",
|
|
7156
|
+
children: []
|
|
7157
|
+
};
|
|
7158
|
+
if (nextFolders.has(rootFolder.id) === false) {
|
|
7159
|
+
nextFolders.set(rootFolder.id, { ...rootFolder, children: [] });
|
|
7160
|
+
}
|
|
7161
|
+
const nextRootFolder = nextFolders.get(rootFolder.id);
|
|
7162
|
+
if (nextRootFolder === void 0) {
|
|
7163
|
+
throw new Error("Pages must include a root folder.");
|
|
7164
|
+
}
|
|
7165
|
+
for (const folder of nextFolders.values()) {
|
|
7166
|
+
folder.children = folder.children.filter(
|
|
7167
|
+
(childId) => childId !== homePage.id && (nextPages.has(childId) || nextFolders.has(childId))
|
|
7168
|
+
);
|
|
7169
|
+
}
|
|
7170
|
+
nextRootFolder.children.unshift(homePage.id);
|
|
7171
|
+
const referencedIds = new Set(
|
|
7172
|
+
Array.from(nextFolders.values()).flatMap((folder) => folder.children)
|
|
7173
|
+
);
|
|
7174
|
+
for (const page of pages.pages) {
|
|
7175
|
+
if (page.id !== homePage.id && referencedIds.has(page.id) === false) {
|
|
7176
|
+
nextRootFolder.children.push(page.id);
|
|
7177
|
+
referencedIds.add(page.id);
|
|
7178
|
+
}
|
|
7179
|
+
}
|
|
7180
|
+
return {
|
|
7181
|
+
meta: pages.meta,
|
|
7182
|
+
compiler: pages.compiler,
|
|
7183
|
+
redirects: pages.redirects,
|
|
7184
|
+
homePageId: homePage.id,
|
|
7185
|
+
rootFolderId: rootFolder.id,
|
|
7186
|
+
pages: nextPages,
|
|
7187
|
+
folders: nextFolders
|
|
7188
|
+
};
|
|
7189
|
+
};
|
|
7026
7190
|
const BOOLEAN_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
7027
7191
|
"async",
|
|
7028
7192
|
"autofocus",
|
|
@@ -11281,36 +11445,6 @@ const getDeploymentInstructions = (deployTarget) => {
|
|
|
11281
11445
|
].join("\n");
|
|
11282
11446
|
}
|
|
11283
11447
|
};
|
|
11284
|
-
const name = "webstudio";
|
|
11285
|
-
const version = "0.265.0";
|
|
11286
|
-
const description = "Webstudio CLI";
|
|
11287
|
-
const author = "Webstudio <github@webstudio.is>";
|
|
11288
|
-
const homepage = "https://webstudio.is";
|
|
11289
|
-
const type = "module";
|
|
11290
|
-
const bin = { "webstudio-cli": "./bin.js", "webstudio": "./bin.js" };
|
|
11291
|
-
const imports = { "#cli": { "webstudio": "./src/cli.ts", "default": "./lib/cli.js" } };
|
|
11292
|
-
const files = ["lib/*", "templates/*", "bin.js", "!*.{test,stories}.*"];
|
|
11293
|
-
const scripts = { "typecheck": "tsgo --noEmit", "build": "rm -rf lib && vite build", "test": "vitest run" };
|
|
11294
|
-
const license = "AGPL-3.0-or-later";
|
|
11295
|
-
const engines = { "node": ">=22" };
|
|
11296
|
-
const dependencies = { "@clack/prompts": "^0.10.0", "@emotion/hash": "^0.9.2", "@trpc/client": "^10.45.2", "acorn": "^8.14.1", "acorn-walk": "^8.3.4", "change-case": "^5.4.4", "deepmerge": "^4.3.1", "env-paths": "^3.0.0", "nanoid": "^5.1.5", "p-limit": "^6.2.0", "parse5": "7.3.0", "picocolors": "^1.1.1", "reserved-identifiers": "^1.0.0", "tinyexec": "^0.3.2", "warn-once": "^0.1.1", "yargs": "^17.7.2", "zod": "^3.24.2" };
|
|
11297
|
-
const devDependencies = { "@cloudflare/vite-plugin": "^1.1.0", "@netlify/vite-plugin-react-router": "^1.0.1", "@react-router/dev": "^7.5.3", "@react-router/fs-routes": "^7.5.3", "@remix-run/cloudflare": "^2.16.5", "@remix-run/cloudflare-pages": "^2.16.5", "@remix-run/dev": "^2.16.5", "@remix-run/node": "^2.16.5", "@remix-run/react": "^2.16.5", "@remix-run/server-runtime": "^2.16.5", "@types/react": "^18.2.70", "@types/react-dom": "^18.2.25", "@types/yargs": "^17.0.33", "@vercel/react-router": "^1.1.0", "@vitejs/plugin-react": "^4.4.1", "@webstudio-is/css-engine": "workspace:*", "@webstudio-is/http-client": "workspace:*", "@webstudio-is/image": "workspace:*", "@webstudio-is/react-sdk": "workspace:*", "@webstudio-is/sdk": "workspace:*", "@webstudio-is/sdk-components-animation": "workspace:*", "@webstudio-is/sdk-components-react": "workspace:*", "@webstudio-is/sdk-components-react-radix": "workspace:*", "@webstudio-is/sdk-components-react-remix": "workspace:*", "@webstudio-is/sdk-components-react-router": "workspace:*", "@webstudio-is/tsconfig": "workspace:*", "h3": "^1.15.1", "ipx": "^3.0.3", "isbot": "^5.1.25", "prettier": "3.5.3", "react": "18.3.0-canary-14898b6a9-20240318", "react-dom": "18.3.0-canary-14898b6a9-20240318", "react-router": "^7.5.3", "ts-expect": "^1.3.0", "vike": "^0.4.229", "vite": "^6.3.4", "vitest": "^3.1.2", "wrangler": "^3.63.2" };
|
|
11298
|
-
const packageJson = {
|
|
11299
|
-
name,
|
|
11300
|
-
version,
|
|
11301
|
-
description,
|
|
11302
|
-
author,
|
|
11303
|
-
homepage,
|
|
11304
|
-
type,
|
|
11305
|
-
bin,
|
|
11306
|
-
imports,
|
|
11307
|
-
files,
|
|
11308
|
-
scripts,
|
|
11309
|
-
license,
|
|
11310
|
-
engines,
|
|
11311
|
-
dependencies,
|
|
11312
|
-
devDependencies
|
|
11313
|
-
};
|
|
11314
11448
|
const main = async () => {
|
|
11315
11449
|
try {
|
|
11316
11450
|
await createFileIfNotExists(GLOBAL_CONFIG_FILE, "{}");
|
|
@@ -11348,6 +11482,9 @@ const main = async () => {
|
|
|
11348
11482
|
cmd.command(["$0", "init"], "Setup the project", buildOptions, initFlow);
|
|
11349
11483
|
await cmd.parse();
|
|
11350
11484
|
} catch (error) {
|
|
11485
|
+
if (isHandledCliError(error)) {
|
|
11486
|
+
exit(1);
|
|
11487
|
+
}
|
|
11351
11488
|
console.error(error);
|
|
11352
11489
|
exit(1);
|
|
11353
11490
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webstudio",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.266.0",
|
|
4
4
|
"description": "Webstudio CLI",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -42,7 +42,9 @@
|
|
|
42
42
|
"tinyexec": "^0.3.2",
|
|
43
43
|
"warn-once": "^0.1.1",
|
|
44
44
|
"yargs": "^17.7.2",
|
|
45
|
-
"zod": "^3.24.2"
|
|
45
|
+
"zod": "^3.24.2",
|
|
46
|
+
"@webstudio-is/project-migrations": "0.266.0",
|
|
47
|
+
"@webstudio-is/trpc-interface": "0.266.0"
|
|
46
48
|
},
|
|
47
49
|
"devDependencies": {
|
|
48
50
|
"@cloudflare/vite-plugin": "^1.1.0",
|
|
@@ -72,16 +74,16 @@
|
|
|
72
74
|
"vite": "^6.3.4",
|
|
73
75
|
"vitest": "^3.1.2",
|
|
74
76
|
"wrangler": "^3.63.2",
|
|
75
|
-
"@webstudio-is/css-engine": "0.
|
|
76
|
-
"@webstudio-is/
|
|
77
|
-
"@webstudio-is/image": "0.
|
|
78
|
-
"@webstudio-is/sdk": "0.
|
|
79
|
-
"@webstudio-is/sdk-components-animation": "0.
|
|
80
|
-
"@webstudio-is/sdk-components-react": "0.
|
|
81
|
-
"@webstudio-is/sdk-components-react
|
|
82
|
-
"@webstudio-is/
|
|
83
|
-
"@webstudio-is/
|
|
84
|
-
"@webstudio-is/sdk-components-react-router": "0.
|
|
77
|
+
"@webstudio-is/css-engine": "0.266.0",
|
|
78
|
+
"@webstudio-is/http-client": "0.266.0",
|
|
79
|
+
"@webstudio-is/image": "0.266.0",
|
|
80
|
+
"@webstudio-is/sdk": "0.266.0",
|
|
81
|
+
"@webstudio-is/sdk-components-animation": "0.266.0",
|
|
82
|
+
"@webstudio-is/sdk-components-react-radix": "0.266.0",
|
|
83
|
+
"@webstudio-is/sdk-components-react": "0.266.0",
|
|
84
|
+
"@webstudio-is/react-sdk": "0.266.0",
|
|
85
|
+
"@webstudio-is/sdk-components-react-remix": "0.266.0",
|
|
86
|
+
"@webstudio-is/sdk-components-react-router": "0.266.0",
|
|
85
87
|
"@webstudio-is/tsconfig": "1.0.7"
|
|
86
88
|
},
|
|
87
89
|
"scripts": {
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
"@remix-run/node": "2.16.5",
|
|
12
12
|
"@remix-run/react": "2.16.5",
|
|
13
13
|
"@remix-run/server-runtime": "2.16.5",
|
|
14
|
-
"@webstudio-is/image": "0.
|
|
15
|
-
"@webstudio-is/react-sdk": "0.
|
|
16
|
-
"@webstudio-is/sdk": "0.
|
|
17
|
-
"@webstudio-is/sdk-components-react": "0.
|
|
18
|
-
"@webstudio-is/sdk-components-animation": "0.
|
|
19
|
-
"@webstudio-is/sdk-components-react-radix": "0.
|
|
20
|
-
"@webstudio-is/sdk-components-react-remix": "0.
|
|
14
|
+
"@webstudio-is/image": "0.266.0",
|
|
15
|
+
"@webstudio-is/react-sdk": "0.266.0",
|
|
16
|
+
"@webstudio-is/sdk": "0.266.0",
|
|
17
|
+
"@webstudio-is/sdk-components-react": "0.266.0",
|
|
18
|
+
"@webstudio-is/sdk-components-animation": "0.266.0",
|
|
19
|
+
"@webstudio-is/sdk-components-react-radix": "0.266.0",
|
|
20
|
+
"@webstudio-is/sdk-components-react-remix": "0.266.0",
|
|
21
21
|
"isbot": "^5.1.25",
|
|
22
22
|
"react": "18.3.0-canary-14898b6a9-20240318",
|
|
23
23
|
"react-dom": "18.3.0-canary-14898b6a9-20240318"
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@react-router/dev": "^7.5.3",
|
|
12
12
|
"@react-router/fs-routes": "^7.5.3",
|
|
13
|
-
"@webstudio-is/image": "0.
|
|
14
|
-
"@webstudio-is/react-sdk": "0.
|
|
15
|
-
"@webstudio-is/sdk": "0.
|
|
16
|
-
"@webstudio-is/sdk-components-animation": "0.
|
|
17
|
-
"@webstudio-is/sdk-components-react-radix": "0.
|
|
18
|
-
"@webstudio-is/sdk-components-react-router": "0.
|
|
19
|
-
"@webstudio-is/sdk-components-react": "0.
|
|
13
|
+
"@webstudio-is/image": "0.266.0",
|
|
14
|
+
"@webstudio-is/react-sdk": "0.266.0",
|
|
15
|
+
"@webstudio-is/sdk": "0.266.0",
|
|
16
|
+
"@webstudio-is/sdk-components-animation": "0.266.0",
|
|
17
|
+
"@webstudio-is/sdk-components-react-radix": "0.266.0",
|
|
18
|
+
"@webstudio-is/sdk-components-react-router": "0.266.0",
|
|
19
|
+
"@webstudio-is/sdk-components-react": "0.266.0",
|
|
20
20
|
"isbot": "^5.1.25",
|
|
21
21
|
"react": "18.3.0-canary-14898b6a9-20240318",
|
|
22
22
|
"react-dom": "18.3.0-canary-14898b6a9-20240318",
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"typecheck": "tsgo --noEmit"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@webstudio-is/image": "0.
|
|
12
|
-
"@webstudio-is/react-sdk": "0.
|
|
13
|
-
"@webstudio-is/sdk": "0.
|
|
14
|
-
"@webstudio-is/sdk-components-react": "0.
|
|
15
|
-
"@webstudio-is/sdk-components-animation": "0.
|
|
16
|
-
"@webstudio-is/sdk-components-react-radix": "0.
|
|
11
|
+
"@webstudio-is/image": "0.266.0",
|
|
12
|
+
"@webstudio-is/react-sdk": "0.266.0",
|
|
13
|
+
"@webstudio-is/sdk": "0.266.0",
|
|
14
|
+
"@webstudio-is/sdk-components-react": "0.266.0",
|
|
15
|
+
"@webstudio-is/sdk-components-animation": "0.266.0",
|
|
16
|
+
"@webstudio-is/sdk-components-react-radix": "0.266.0",
|
|
17
17
|
"react": "18.3.0-canary-14898b6a9-20240318",
|
|
18
18
|
"react-dom": "18.3.0-canary-14898b6a9-20240318",
|
|
19
19
|
"vike": "^0.4.229"
|