@puckeditor/cli 0.24.0-canary.fd916921 → 0.25.0-canary.a9fe1d00
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 +5 -1
- package/dist/bin.mjs +327 -137
- package/dist/docs/cli.md +39 -5
- package/dist/docs/cloud/ai/assembly-mode.md +271 -0
- package/dist/docs/cloud/ai/business-context.md +69 -0
- package/dist/docs/cloud/ai/custom-agents.md +133 -0
- package/dist/docs/cloud/ai/design-mode.md +235 -0
- package/dist/docs/cloud/ai/headless-generation.md +122 -0
- package/dist/docs/cloud/ai/localization.md +43 -0
- package/dist/docs/cloud/ai/model-configuration.md +113 -0
- package/dist/docs/cloud/ai/overview.md +35 -0
- package/dist/docs/cloud/ai/setup.md +65 -0
- package/dist/docs/cloud/ai/tools.md +99 -0
- package/dist/docs/cloud/api-reference/cloud-client/helpers/chat.md +515 -0
- package/dist/docs/cloud/api-reference/cloud-client/helpers/login-url.md +21 -0
- package/dist/docs/cloud/api-reference/cloud-client/helpers/tool.md +128 -0
- package/dist/docs/cloud/api-reference/cloud-client/puck-cloud.md +73 -0
- package/dist/docs/cloud/api-reference/cloud-client/puck-handler.md +434 -0
- package/dist/docs/cloud/api-reference/cloud-client/server-apis/ai-generate.md +523 -0
- package/dist/docs/cloud/api-reference/cloud-client/server-apis/auth-get-session.md +41 -0
- package/dist/docs/cloud/api-reference/cloud-client/server-apis/auth-sign-out.md +24 -0
- package/dist/docs/cloud/api-reference/cloud-client/server-apis/pages-create-version.md +50 -0
- package/dist/docs/cloud/api-reference/cloud-client/server-apis/pages-create.md +45 -0
- package/dist/docs/cloud/api-reference/cloud-client/server-apis/pages-delete.md +42 -0
- package/dist/docs/cloud/api-reference/cloud-client/server-apis/pages-get-by-path.md +34 -0
- package/dist/docs/cloud/api-reference/cloud-client/server-apis/pages-get-published.md +25 -0
- package/dist/docs/cloud/api-reference/cloud-client/server-apis/pages-get.md +34 -0
- package/dist/docs/cloud/api-reference/cloud-client/server-apis/pages-list-versions.md +49 -0
- package/dist/docs/cloud/api-reference/cloud-client/server-apis/pages-list.md +46 -0
- package/dist/docs/cloud/api-reference/cloud-client/server-apis/pages-publish.md +30 -0
- package/dist/docs/cloud/api-reference/cloud-client/server-apis/pages-unpublish.md +25 -0
- package/dist/docs/cloud/api-reference/cloud-client/server-apis/pages-update.md +38 -0
- package/dist/docs/cloud/api-reference/cloud-client/types/ai-generate-field-type.md +33 -0
- package/dist/docs/cloud/api-reference/cloud-client/types/page-list.md +41 -0
- package/dist/docs/cloud/api-reference/cloud-client/types/page.md +61 -0
- package/dist/docs/cloud/api-reference/cloud-client/types/puck-cloud-error.md +34 -0
- package/dist/docs/cloud/api-reference/cloud-client/types/puck-session.md +53 -0
- package/dist/docs/cloud/api-reference/plugin-ai/ai-configuration/components.md +72 -0
- package/dist/docs/cloud/api-reference/plugin-ai/ai-configuration/fields.md +231 -0
- package/dist/docs/cloud/api-reference/plugin-ai/ai-field-type.md +41 -0
- package/dist/docs/cloud/api-reference/plugin-ai/ai-part.md +90 -0
- package/dist/docs/cloud/api-reference/plugin-ai/create-ai-plugin.md +311 -0
- package/dist/docs/cloud/api-reference/plugin-ai/dictionary.md +77 -0
- package/dist/docs/cloud/api-reference/plugin-ai/use-puck-ai.md +175 -0
- package/dist/docs/cloud/api-reference/plugin-ai/with-dynamic-config.md +35 -0
- package/dist/docs/cloud/api-reference/plugin-auth/create-auth-plugin.md +43 -0
- package/dist/docs/cloud/api-reference/plugin-pages/create-pages-plugin.md +65 -0
- package/dist/docs/cloud/auth/overview.md +24 -0
- package/dist/docs/cloud/auth/setup.md +169 -0
- package/dist/docs/cloud/auth-and-identity.md +70 -0
- package/dist/docs/cloud/getting-started.md +47 -0
- package/dist/docs/cloud/overview.md +23 -0
- package/dist/docs/cloud/pages/overview.md +38 -0
- package/dist/docs/cloud/pages/setup.md +80 -0
- package/dist/docs/cloud/server-apis.md +58 -0
- package/dist/docs/cloud/setup-cloud-plugins.md +202 -0
- package/dist/docs/{api-reference → editor/api-reference}/actions.md +16 -16
- package/dist/docs/{api-reference → editor/api-reference}/components/action-bar-action.md +2 -2
- package/dist/docs/editor/api-reference/components/action-bar-drag-handle.md +33 -0
- package/dist/docs/{api-reference → editor/api-reference}/components/action-bar-group.md +2 -2
- package/dist/docs/{api-reference → editor/api-reference}/components/action-bar-label.md +1 -1
- package/dist/docs/{api-reference → editor/api-reference}/components/action-bar-separator.md +1 -1
- package/dist/docs/{api-reference → editor/api-reference}/components/action-bar.md +2 -2
- package/dist/docs/{api-reference → editor/api-reference}/components/auto-field.md +11 -11
- package/dist/docs/{api-reference → editor/api-reference}/components/drawer-item.md +2 -2
- package/dist/docs/{api-reference → editor/api-reference}/components/drawer.md +2 -2
- package/dist/docs/{api-reference → editor/api-reference}/components/drop-zone.md +5 -5
- package/dist/docs/editor/api-reference/components/field-group-item.md +40 -0
- package/dist/docs/editor/api-reference/components/field-group.md +87 -0
- package/dist/docs/{api-reference → editor/api-reference}/components/field-label.md +6 -1
- package/dist/docs/editor/api-reference/components/field-tab.md +56 -0
- package/dist/docs/{api-reference → editor/api-reference}/components/inline-text-field.md +6 -6
- package/dist/docs/{api-reference → editor/api-reference}/components/puck-components.md +1 -1
- package/dist/docs/{api-reference → editor/api-reference}/components/puck-fields.md +1 -1
- package/dist/docs/{api-reference → editor/api-reference}/components/puck-layout.md +1 -1
- package/dist/docs/{api-reference → editor/api-reference}/components/puck.md +52 -47
- package/dist/docs/editor/api-reference/components/render.md +114 -0
- package/dist/docs/{api-reference → editor/api-reference}/components/rich-text-menu-control.md +1 -1
- package/dist/docs/{api-reference → editor/api-reference}/components/rich-text-menu-group.md +2 -2
- package/dist/docs/editor/api-reference/components/rich-text-menu.md +99 -0
- package/dist/docs/editor/api-reference/components.md +36 -0
- package/dist/docs/{api-reference → editor/api-reference}/configuration/component-config.md +71 -28
- package/dist/docs/{api-reference → editor/api-reference}/configuration/config.md +7 -7
- package/dist/docs/editor/api-reference/configuration.md +4 -0
- package/dist/docs/{api-reference → editor/api-reference}/data-model/app-state.md +30 -16
- package/dist/docs/{api-reference → editor/api-reference}/data-model/component-data.md +3 -3
- package/dist/docs/{api-reference → editor/api-reference}/data-model/data.md +12 -12
- package/dist/docs/{api-reference → editor/api-reference}/data-model/item-selector.md +5 -5
- package/dist/docs/editor/api-reference/data-model/root-data.md +59 -0
- package/dist/docs/editor/api-reference/data-model.md +8 -0
- package/dist/docs/{api-reference → editor/api-reference}/dictionary.md +8 -7
- package/dist/docs/{api-reference → editor/api-reference}/field-transforms.md +13 -13
- package/dist/docs/{api-reference → editor/api-reference}/fields/array.md +1 -1
- package/dist/docs/editor/api-reference/fields/checkbox.md +87 -0
- package/dist/docs/{api-reference → editor/api-reference}/fields/custom.md +11 -11
- package/dist/docs/{api-reference → editor/api-reference}/fields/external.md +2 -2
- package/dist/docs/{api-reference → editor/api-reference}/fields/number.md +1 -1
- package/dist/docs/editor/api-reference/fields/object.md +100 -0
- package/dist/docs/{api-reference → editor/api-reference}/fields/radio.md +1 -1
- package/dist/docs/{api-reference → editor/api-reference}/fields/richtext.md +5 -5
- package/dist/docs/{api-reference → editor/api-reference}/fields/select.md +1 -1
- package/dist/docs/{api-reference → editor/api-reference}/fields/slot.md +2 -2
- package/dist/docs/{api-reference → editor/api-reference}/fields/text.md +3 -3
- package/dist/docs/{api-reference → editor/api-reference}/fields/textarea.md +3 -3
- package/dist/docs/editor/api-reference/fields.md +17 -0
- package/dist/docs/{api-reference → editor/api-reference}/functions/migrate.md +9 -9
- package/dist/docs/{api-reference → editor/api-reference}/functions/register-overlay-portal.md +2 -2
- package/dist/docs/editor/api-reference/functions/resolve-all-data.md +27 -0
- package/dist/docs/{api-reference → editor/api-reference}/functions/set-deep.md +4 -4
- package/dist/docs/editor/api-reference/functions/transform-props.md +51 -0
- package/dist/docs/{api-reference → editor/api-reference}/functions/use-get-puck.md +3 -3
- package/dist/docs/{api-reference → editor/api-reference}/functions/use-puck.md +2 -2
- package/dist/docs/{api-reference → editor/api-reference}/functions/walk-tree.md +16 -16
- package/dist/docs/editor/api-reference/functions.md +8 -0
- package/dist/docs/editor/api-reference/overrides/action-bar.md +51 -0
- package/dist/docs/{api-reference → editor/api-reference}/overrides/component-overlay.md +2 -2
- package/dist/docs/{api-reference → editor/api-reference}/overrides/field-label.md +1 -1
- package/dist/docs/{api-reference → editor/api-reference}/overrides/field-types.md +9 -9
- package/dist/docs/editor/api-reference/overrides/fields.md +45 -0
- package/dist/docs/{api-reference → editor/api-reference}/overrides/header.md +1 -1
- package/dist/docs/{api-reference → editor/api-reference}/overrides/puck.md +2 -2
- package/dist/docs/editor/api-reference/overrides.md +28 -0
- package/dist/docs/{api-reference → editor/api-reference}/permissions.md +5 -5
- package/dist/docs/{api-reference → editor/api-reference}/plugin.md +12 -12
- package/dist/docs/{api-reference → editor/api-reference}/puck-api.md +39 -38
- package/dist/docs/{api-reference → editor/api-reference}/theming/action-bar.md +1 -1
- package/dist/docs/{api-reference → editor/api-reference}/theming/button.md +1 -1
- package/dist/docs/{api-reference → editor/api-reference}/theming/canvas.md +1 -1
- package/dist/docs/{api-reference → editor/api-reference}/theming/computed-values.md +15 -0
- package/dist/docs/{api-reference → editor/api-reference}/theming/drawer.md +1 -1
- package/dist/docs/editor/api-reference/theming/field-tabs.md +28 -0
- package/dist/docs/{api-reference → editor/api-reference}/theming/fields.md +8 -1
- package/dist/docs/{api-reference → editor/api-reference}/theming/header.md +1 -1
- package/dist/docs/{api-reference → editor/api-reference}/theming/icon-button.md +1 -1
- package/dist/docs/{api-reference → editor/api-reference}/theming/outline.md +1 -1
- package/dist/docs/{api-reference → editor/api-reference}/theming/plugin-bar.md +1 -1
- package/dist/docs/{api-reference → editor/api-reference}/theming/sidebar.md +1 -1
- package/dist/docs/{api-reference → editor/api-reference}/theming/slot.md +1 -1
- package/dist/docs/{integrating-puck → editor/components-and-fields}/component-configuration.md +12 -12
- package/dist/docs/{extending-puck → editor/components-and-fields}/custom-fields.md +8 -8
- package/dist/docs/{integrating-puck → editor/components-and-fields}/dynamic-fields.md +6 -6
- package/dist/docs/editor/components-and-fields/field-grouping.md +151 -0
- package/dist/docs/{extending-puck → editor/components-and-fields}/field-transforms.md +21 -7
- package/dist/docs/{integrating-puck → editor/components-and-fields}/multi-column-layouts.md +11 -11
- package/dist/docs/{integrating-puck → editor/components-and-fields}/overlay-portals.md +2 -2
- package/dist/docs/{integrating-puck → editor/components-and-fields}/rich-text-editing.md +13 -13
- package/dist/docs/{integrating-puck → editor/components-and-fields}/root-configuration.md +5 -5
- package/dist/docs/{integrating-puck → editor/customize}/categories.md +3 -3
- package/dist/docs/editor/customize/composition.md +54 -0
- package/dist/docs/{integrating-puck → editor/customize}/feature-toggling.md +11 -11
- package/dist/docs/{extending-puck → editor/customize}/internal-puck-api.md +15 -14
- package/dist/docs/{integrating-puck → editor/customize}/localization.md +13 -13
- package/dist/docs/{extending-puck → editor/customize}/plugins.md +19 -17
- package/dist/docs/{integrating-puck → editor/customize}/styling.md +11 -11
- package/dist/docs/editor/customize/theming.md +89 -0
- package/dist/docs/{extending-puck → editor/customize}/ui-overrides.md +9 -9
- package/dist/docs/{integrating-puck → editor/customize}/viewports.md +5 -5
- package/dist/docs/{integrating-puck → editor/data-and-rendering}/dynamic-props.md +7 -7
- package/dist/docs/{integrating-puck → editor/data-and-rendering}/external-data-sources.md +10 -10
- package/dist/docs/editor/data-and-rendering/save-and-render-pages.md +82 -0
- package/dist/docs/{integrating-puck → editor/data-and-rendering}/server-components.md +4 -4
- package/dist/docs/{getting-started.md → editor/getting-started.md} +3 -1
- package/dist/docs/{integrating-puck → editor/migrations}/data-migration.md +6 -6
- package/dist/docs/{guides → editor}/migrations/dropzones-to-slots.md +8 -8
- package/dist/docs/editor/overview.md +27 -0
- package/dist/docs/index.json +381 -137
- package/dist/templates/next/app/puck/[...puckPath]/page.tsx +3 -2
- package/dist/templates/next/app/puck/page.tsx +0 -2
- package/dist/templates/next/package.json +1 -1
- package/dist/templates/next-ai/app/puck/[...puckPath]/page.tsx +3 -2
- package/dist/templates/next-ai/app/puck/page.tsx +0 -2
- package/dist/templates/next-ai/package.json +1 -1
- package/dist/templates/react-router/package.json +1 -1
- package/dist/templates/react-router-ai/package.json +1 -1
- package/dist/templates/vinext/app/puck/[...puckPath]/page.tsx +3 -2
- package/dist/templates/vinext/app/puck/page.tsx +0 -2
- package/dist/templates/vinext-ai/app/puck/[...puckPath]/page.tsx +3 -2
- package/dist/templates/vinext-ai/app/puck/page.tsx +0 -2
- package/package.json +1 -1
- package/dist/docs/api-reference/components/render.md +0 -94
- package/dist/docs/api-reference/components/rich-text-menu.md +0 -99
- package/dist/docs/api-reference/components.md +0 -32
- package/dist/docs/api-reference/configuration.md +0 -4
- package/dist/docs/api-reference/data-model/root-data.md +0 -59
- package/dist/docs/api-reference/data-model.md +0 -8
- package/dist/docs/api-reference/fields/object.md +0 -78
- package/dist/docs/api-reference/fields.md +0 -16
- package/dist/docs/api-reference/functions/resolve-all-data.md +0 -27
- package/dist/docs/api-reference/functions/transform-props.md +0 -51
- package/dist/docs/api-reference/functions.md +0 -8
- package/dist/docs/api-reference/overrides/action-bar.md +0 -35
- package/dist/docs/api-reference/overrides/fields.md +0 -19
- package/dist/docs/api-reference/overrides.md +0 -28
- package/dist/docs/extending-puck/composition.md +0 -54
- package/dist/docs/extending-puck/theming.md +0 -88
- package/dist/docs/index.md +0 -37
- /package/dist/docs/{api-reference → editor/api-reference}/components/puck-outline.md +0 -0
- /package/dist/docs/{api-reference → editor/api-reference}/components/puck-preview.md +0 -0
- /package/dist/docs/{api-reference → editor/api-reference}/fields/base.md +0 -0
- /package/dist/docs/{api-reference → editor/api-reference}/overrides/drawer-item.md +0 -0
- /package/dist/docs/{api-reference → editor/api-reference}/overrides/drawer.md +0 -0
- /package/dist/docs/{api-reference → editor/api-reference}/overrides/header-actions.md +0 -0
- /package/dist/docs/{api-reference → editor/api-reference}/overrides/iframe.md +0 -0
- /package/dist/docs/{api-reference → editor/api-reference}/overrides/outline.md +0 -0
- /package/dist/docs/{api-reference → editor/api-reference}/overrides/preview.md +0 -0
- /package/dist/docs/{api-reference → editor/api-reference}/plugins/blocks-plugin.md +0 -0
- /package/dist/docs/{api-reference → editor/api-reference}/plugins/fields-plugin.md +0 -0
- /package/dist/docs/{api-reference → editor/api-reference}/plugins/legacy-side-bar-plugin.md +0 -0
- /package/dist/docs/{api-reference → editor/api-reference}/plugins/outline-plugin.md +0 -0
- /package/dist/docs/{api-reference → editor/api-reference}/theming/global.md +0 -0
package/dist/bin.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/bin.ts
|
|
4
4
|
import os from "os";
|
|
5
|
-
import
|
|
5
|
+
import path35 from "path";
|
|
6
6
|
import fs8 from "fs";
|
|
7
7
|
import { fileURLToPath } from "url";
|
|
8
8
|
|
|
@@ -76,6 +76,7 @@ var DEFAULT_CLOUD_URL = "https://cloud.puckeditor.com";
|
|
|
76
76
|
var API_KEYS_PATH = "/api-keys";
|
|
77
77
|
var DOCS_URL = "https://puckeditor.com/docs/cli";
|
|
78
78
|
var MANUAL_INTEGRATION_DOCS_URL = "https://puckeditor.com/docs/getting-started";
|
|
79
|
+
var CLI_PACKAGE = "@puckeditor/cli";
|
|
79
80
|
var CORE_PACKAGE = "@puckeditor/core";
|
|
80
81
|
var LEGACY_CORE_PACKAGE = "@measured/puck";
|
|
81
82
|
var CLOUD_CLIENT_PACKAGE = "@puckeditor/cloud-client";
|
|
@@ -156,6 +157,19 @@ var findStringProperty = (code, filename, key) => {
|
|
|
156
157
|
});
|
|
157
158
|
return result;
|
|
158
159
|
};
|
|
160
|
+
var hasTrueProperty = (code, filename, key) => {
|
|
161
|
+
const ast = tryParseModule(code, filename);
|
|
162
|
+
let found = false;
|
|
163
|
+
if (ast) {
|
|
164
|
+
walk(ast.program, (node) => {
|
|
165
|
+
if (node.type !== "ObjectProperty" || node.computed) return;
|
|
166
|
+
const name = node.key.type === "Identifier" ? node.key.name : node.key.type === "StringLiteral" ? node.key.value : null;
|
|
167
|
+
if (name === key && node.value.type === "BooleanLiteral")
|
|
168
|
+
found ||= node.value.value;
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
return found;
|
|
172
|
+
};
|
|
159
173
|
|
|
160
174
|
// src/detect/package-json.ts
|
|
161
175
|
import path from "path";
|
|
@@ -337,6 +351,18 @@ var findViteConfig = (vfs, root) => firstExisting(
|
|
|
337
351
|
root,
|
|
338
352
|
CONFIG_EXTENSIONS.map((ext) => `vite.config.${ext}`)
|
|
339
353
|
);
|
|
354
|
+
var detectCacheComponents = (vfs, root) => {
|
|
355
|
+
const config = firstExisting(
|
|
356
|
+
vfs,
|
|
357
|
+
root,
|
|
358
|
+
CONFIG_EXTENSIONS.map((ext) => `next.config.${ext}`)
|
|
359
|
+
);
|
|
360
|
+
return config ? hasTrueProperty(
|
|
361
|
+
vfs.readText(path3.join(root, config)) ?? "",
|
|
362
|
+
config,
|
|
363
|
+
"cacheComponents"
|
|
364
|
+
) : false;
|
|
365
|
+
};
|
|
340
366
|
var normalizeDir = (dir) => path3.posix.normalize(dir).replace(/^\.\/?$/, "").replace(/\/+$/, "");
|
|
341
367
|
var dynamicConfig = (file, what) => ({
|
|
342
368
|
status: "unsupported",
|
|
@@ -393,7 +419,8 @@ var detectNext = (vfs, root, range) => {
|
|
|
393
419
|
version,
|
|
394
420
|
major: major2,
|
|
395
421
|
...layout,
|
|
396
|
-
proxyKind: major2 >= 16 ? "proxy" : "middleware"
|
|
422
|
+
proxyKind: major2 >= 16 ? "proxy" : "middleware",
|
|
423
|
+
cacheComponents: detectCacheComponents(vfs, root)
|
|
397
424
|
}
|
|
398
425
|
};
|
|
399
426
|
};
|
|
@@ -415,6 +442,7 @@ var detectVinext = (vfs, root, range) => {
|
|
|
415
442
|
major: majorOf(version) ?? majorOf(range),
|
|
416
443
|
...layout,
|
|
417
444
|
proxyKind: hasMiddleware ? "middleware" : "proxy",
|
|
445
|
+
cacheComponents: false,
|
|
418
446
|
viteConfig: findViteConfig(vfs, root)
|
|
419
447
|
}
|
|
420
448
|
};
|
|
@@ -780,6 +808,7 @@ var OPTIONS = {
|
|
|
780
808
|
config: { type: "string" },
|
|
781
809
|
"package-manager": { type: "string" },
|
|
782
810
|
wait: { type: "boolean" },
|
|
811
|
+
login: { type: "boolean" },
|
|
783
812
|
framework: { type: "string" },
|
|
784
813
|
name: { type: "string" },
|
|
785
814
|
offline: { type: "boolean" },
|
|
@@ -809,6 +838,7 @@ var MUTATING = [
|
|
|
809
838
|
"config",
|
|
810
839
|
"package-manager",
|
|
811
840
|
"wait",
|
|
841
|
+
"login",
|
|
812
842
|
"backend",
|
|
813
843
|
"backend-url"
|
|
814
844
|
];
|
|
@@ -850,6 +880,8 @@ var COMMANDS = [
|
|
|
850
880
|
"help"
|
|
851
881
|
];
|
|
852
882
|
var FRAMEWORKS = FRAMEWORK_IDS;
|
|
883
|
+
var NO_POSITIONALS = ["init", "status", "doctor"];
|
|
884
|
+
var PLACEHOLDER = /^(<.*>|\[.*\])$/;
|
|
853
885
|
var parseCliArgs = (argv) => {
|
|
854
886
|
let parsed;
|
|
855
887
|
try {
|
|
@@ -871,11 +903,19 @@ var parseCliArgs = (argv) => {
|
|
|
871
903
|
if (!COMMANDS.includes(first)) {
|
|
872
904
|
throw new CliError(
|
|
873
905
|
"PUCK-CLI-UNKNOWN-COMMAND",
|
|
874
|
-
`Unknown command "${first}". Run \`${CANONICAL_INVOCATION} --help\` to see available commands
|
|
906
|
+
`Unknown command "${first}". Run \`${CANONICAL_INVOCATION} --help\` to see available commands.`,
|
|
907
|
+
{ command: first }
|
|
875
908
|
);
|
|
876
909
|
}
|
|
877
910
|
command = first;
|
|
878
911
|
}
|
|
912
|
+
const placeholder = positionals.find((p) => PLACEHOLDER.test(p));
|
|
913
|
+
if (command && NO_POSITIONALS.includes(command) && placeholder) {
|
|
914
|
+
throw new CliError(
|
|
915
|
+
"PUCK-CLI-INVALID-ARGS",
|
|
916
|
+
`"${placeholder}" is a placeholder. Ask the developer to pick one of the action's choices, then pass that flag instead.`
|
|
917
|
+
);
|
|
918
|
+
}
|
|
879
919
|
const values = parsed.values;
|
|
880
920
|
const allowed = COMMAND_OPTIONS[command ?? "help"];
|
|
881
921
|
for (const key of Object.keys(values)) {
|
|
@@ -944,6 +984,7 @@ var parseCliArgs = (argv) => {
|
|
|
944
984
|
config: values.config,
|
|
945
985
|
packageManager: pm,
|
|
946
986
|
wait: Boolean(values.wait),
|
|
987
|
+
login: Boolean(values.login),
|
|
947
988
|
framework,
|
|
948
989
|
name: values.name,
|
|
949
990
|
offline: Boolean(values.offline),
|
|
@@ -1113,6 +1154,22 @@ var createCloudApi = (baseUrl, fetchImpl) => {
|
|
|
1113
1154
|
}
|
|
1114
1155
|
return body;
|
|
1115
1156
|
},
|
|
1157
|
+
async createClaimableProject(client) {
|
|
1158
|
+
const res = await request("api/claimable-projects", {
|
|
1159
|
+
method: "POST",
|
|
1160
|
+
headers: { "content-type": "application/json" },
|
|
1161
|
+
body: JSON.stringify(client)
|
|
1162
|
+
});
|
|
1163
|
+
if (res.status === 404 || res.status === 429) return null;
|
|
1164
|
+
const body = await json(res);
|
|
1165
|
+
if (!res.ok || typeof body.apiKey !== "string" || typeof body.claimUrl !== "string") {
|
|
1166
|
+
throw new CloudRequestError(
|
|
1167
|
+
`Puck Cloud returned an unexpected response (${res.status})`,
|
|
1168
|
+
"bad_response"
|
|
1169
|
+
);
|
|
1170
|
+
}
|
|
1171
|
+
return body;
|
|
1172
|
+
},
|
|
1116
1173
|
async pollConnect(deviceCode) {
|
|
1117
1174
|
const res = await request("api/cli/connect/token", {
|
|
1118
1175
|
method: "POST",
|
|
@@ -1176,6 +1233,9 @@ var createCloudApi = (baseUrl, fetchImpl) => {
|
|
|
1176
1233
|
};
|
|
1177
1234
|
};
|
|
1178
1235
|
|
|
1236
|
+
// src/context.ts
|
|
1237
|
+
import path5 from "path";
|
|
1238
|
+
|
|
1179
1239
|
// src/env/truthy.ts
|
|
1180
1240
|
var isTruthyEnv = (value) => value !== void 0 && value !== "" && value !== "0" && value.toLowerCase() !== "false";
|
|
1181
1241
|
|
|
@@ -1211,7 +1271,17 @@ var rerunCommand = (rc) => {
|
|
|
1211
1271
|
if (arg.startsWith("--api-key=")) continue;
|
|
1212
1272
|
args.push(/[\s"'$`]/.test(arg) ? JSON.stringify(arg) : arg);
|
|
1213
1273
|
}
|
|
1214
|
-
return [
|
|
1274
|
+
return [rc.deps.invocation ?? CANONICAL_INVOCATION, ...args].join(" ");
|
|
1275
|
+
};
|
|
1276
|
+
var localInvocation = (binPath, cwd, env2) => {
|
|
1277
|
+
for (let dir = cwd; ; dir = path5.dirname(dir)) {
|
|
1278
|
+
if (binPath.startsWith(path5.join(dir, "node_modules") + path5.sep)) break;
|
|
1279
|
+
if (path5.dirname(dir) === dir) return void 0;
|
|
1280
|
+
}
|
|
1281
|
+
const pm = env2.npm_config_user_agent?.split("/")[0];
|
|
1282
|
+
if (pm === "pnpm") return "pnpm exec puck";
|
|
1283
|
+
if (pm === "yarn") return "yarn puck";
|
|
1284
|
+
return "npm exec --no -- puck";
|
|
1215
1285
|
};
|
|
1216
1286
|
|
|
1217
1287
|
// src/result.ts
|
|
@@ -1303,6 +1373,8 @@ Flags:
|
|
|
1303
1373
|
add one, use one elsewhere, or none (editor only)
|
|
1304
1374
|
--backend-url <url> The server for --backend external, e.g. http://localhost:3000
|
|
1305
1375
|
--wait Wait for Puck Cloud login approval instead of returning
|
|
1376
|
+
--login Log in to Puck Cloud instead of starting on a project
|
|
1377
|
+
without an account (init, add)
|
|
1306
1378
|
--framework <name> Framework for new apps (init), one of:
|
|
1307
1379
|
${FRAMEWORK_IDS.join(", ")}
|
|
1308
1380
|
--name <name> Directory name for new apps (init)
|
|
@@ -1311,12 +1383,13 @@ Flags:
|
|
|
1311
1383
|
For agents:
|
|
1312
1384
|
Every command prints exactly one JSON document with --json. When "status" is
|
|
1313
1385
|
"action_required", surface each entry in "actions" to the developer (e.g. a
|
|
1314
|
-
browser_login URL and code), then run its "rerun" command.
|
|
1386
|
+
browser_login URL and code), then run its "rerun" command. Show a
|
|
1387
|
+
claim_project link to the developer even when "status" is "success". Exit codes:
|
|
1315
1388
|
0 success, 2 usage, 3 unsupported project, 4 file conflict, 5 package manager,
|
|
1316
1389
|
6 doctor found problems, 7 Puck Cloud unreachable, 10 action required, 11 partial.
|
|
1317
1390
|
|
|
1318
1391
|
The docs for this version ship with the CLI. Start with:
|
|
1319
|
-
${CANONICAL_INVOCATION} docs cat getting-started
|
|
1392
|
+
${CANONICAL_INVOCATION} docs cat editor/getting-started
|
|
1320
1393
|
|
|
1321
1394
|
Docs: ${DOCS_URL}
|
|
1322
1395
|
`;
|
|
@@ -1353,10 +1426,10 @@ var indentationAt = (code, offset) => {
|
|
|
1353
1426
|
|
|
1354
1427
|
// src/templates/source.ts
|
|
1355
1428
|
import fs from "fs";
|
|
1356
|
-
import
|
|
1429
|
+
import path8 from "path";
|
|
1357
1430
|
|
|
1358
1431
|
// src/env/gitignore.ts
|
|
1359
|
-
import
|
|
1432
|
+
import path6 from "path";
|
|
1360
1433
|
var globToRegex = (glob) => {
|
|
1361
1434
|
let out = "";
|
|
1362
1435
|
for (let i = 0; i < glob.length; i++) {
|
|
@@ -1384,19 +1457,19 @@ var matchesPattern = (pattern, relPath) => {
|
|
|
1384
1457
|
const anchored = p.startsWith("/") || p.slice(0, -1).includes("/");
|
|
1385
1458
|
p = p.replace(/^\//, "");
|
|
1386
1459
|
const regex = globToRegex(p);
|
|
1387
|
-
return anchored ? regex.test(relPath) : regex.test(
|
|
1460
|
+
return anchored ? regex.test(relPath) : regex.test(path6.posix.basename(relPath));
|
|
1388
1461
|
};
|
|
1389
1462
|
var isIgnored = (vfs, file, rootDir) => {
|
|
1390
1463
|
const dirs = [];
|
|
1391
|
-
for (let dir =
|
|
1464
|
+
for (let dir = path6.dirname(file); ; dir = path6.dirname(dir)) {
|
|
1392
1465
|
dirs.unshift(dir);
|
|
1393
|
-
if (dir === rootDir ||
|
|
1466
|
+
if (dir === rootDir || path6.dirname(dir) === dir) break;
|
|
1394
1467
|
}
|
|
1395
1468
|
let ignored = false;
|
|
1396
1469
|
for (const dir of dirs) {
|
|
1397
|
-
const text = vfs.readText(
|
|
1470
|
+
const text = vfs.readText(path6.join(dir, ".gitignore"));
|
|
1398
1471
|
if (text === null) continue;
|
|
1399
|
-
const rel =
|
|
1472
|
+
const rel = path6.relative(dir, file).split(path6.sep).join("/");
|
|
1400
1473
|
for (const raw of text.split(/\r?\n/)) {
|
|
1401
1474
|
const line = raw.trim();
|
|
1402
1475
|
if (!line || line.startsWith("#")) continue;
|
|
@@ -1410,10 +1483,10 @@ var isIgnored = (vfs, file, rootDir) => {
|
|
|
1410
1483
|
return ignored;
|
|
1411
1484
|
};
|
|
1412
1485
|
var planIgnore = (vfs, file, appRoot, gitRoot) => {
|
|
1413
|
-
const appGitignore =
|
|
1414
|
-
const rootGitignore = gitRoot ?
|
|
1486
|
+
const appGitignore = path6.join(appRoot, ".gitignore");
|
|
1487
|
+
const rootGitignore = gitRoot ? path6.join(gitRoot, ".gitignore") : null;
|
|
1415
1488
|
const gitignore = vfs.exists(appGitignore) ? appGitignore : rootGitignore && vfs.exists(rootGitignore) ? rootGitignore : appGitignore;
|
|
1416
|
-
const pattern =
|
|
1489
|
+
const pattern = path6.relative(path6.dirname(gitignore), file).split(path6.sep).join("/");
|
|
1417
1490
|
const existing = vfs.readText(gitignore);
|
|
1418
1491
|
const eol = existing?.includes("\r\n") ? "\r\n" : "\n";
|
|
1419
1492
|
const block = `# Puck Cloud API key${eol}${pattern}${eol}`;
|
|
@@ -1422,7 +1495,7 @@ var planIgnore = (vfs, file, appRoot, gitRoot) => {
|
|
|
1422
1495
|
};
|
|
1423
1496
|
|
|
1424
1497
|
// src/detect/scan.ts
|
|
1425
|
-
import
|
|
1498
|
+
import path7 from "path";
|
|
1426
1499
|
|
|
1427
1500
|
// src/ast/imports.ts
|
|
1428
1501
|
var specifierName = (node) => node.type === "Identifier" ? node.name : node.value;
|
|
@@ -1514,7 +1587,7 @@ var SOURCE_EXT = /\.(tsx?|jsx?|mjs|cjs|mts|cts)$/;
|
|
|
1514
1587
|
var MAX_FILES = 4e3;
|
|
1515
1588
|
var MAX_DEPTH = 10;
|
|
1516
1589
|
var MAX_BYTES = 512 * 1024;
|
|
1517
|
-
var toPosix = (p) => p.split(
|
|
1590
|
+
var toPosix = (p) => p.split(path7.sep).join("/");
|
|
1518
1591
|
var listSourceFiles = (vfs, root) => {
|
|
1519
1592
|
const files = [];
|
|
1520
1593
|
let truncated = false;
|
|
@@ -1525,12 +1598,12 @@ var listSourceFiles = (vfs, root) => {
|
|
|
1525
1598
|
truncated = true;
|
|
1526
1599
|
return;
|
|
1527
1600
|
}
|
|
1528
|
-
const full =
|
|
1601
|
+
const full = path7.join(dir, entry.name);
|
|
1529
1602
|
if (entry.isDir) {
|
|
1530
1603
|
if (SKIP_DIRS.has(entry.name)) continue;
|
|
1531
1604
|
if (entry.name.startsWith(".") && entry.name !== ".server" && entry.name !== ".client")
|
|
1532
1605
|
continue;
|
|
1533
|
-
if (depth > 0 && vfs.exists(
|
|
1606
|
+
if (depth > 0 && vfs.exists(path7.join(full, "package.json"))) continue;
|
|
1534
1607
|
visit(full, depth + 1);
|
|
1535
1608
|
} else if (SOURCE_EXT.test(entry.name) && !entry.name.endsWith(".d.ts")) {
|
|
1536
1609
|
files.push(full);
|
|
@@ -1562,7 +1635,7 @@ var scanSources = (vfs, root) => {
|
|
|
1562
1635
|
if (!code.includes("@puckeditor/")) continue;
|
|
1563
1636
|
const ast = tryParseModule(code, file);
|
|
1564
1637
|
if (!ast) continue;
|
|
1565
|
-
const rel = toPosix(
|
|
1638
|
+
const rel = toPosix(path7.relative(root, file));
|
|
1566
1639
|
for (const ref of getModuleReferences(ast, code)) {
|
|
1567
1640
|
const imports = (...names) => ref.kind === "import" && ref.specifiers.some((s) => names.includes(s.imported) && !s.typeOnly);
|
|
1568
1641
|
if (ref.source === CORE_PACKAGE && ref.kind === "import") {
|
|
@@ -1658,8 +1731,8 @@ var excludeMatchers = templates_default.exclude.map((pattern) => {
|
|
|
1658
1731
|
});
|
|
1659
1732
|
var isExcludedTemplateFile = (rel) => excludeMatchers.some((m) => m(rel));
|
|
1660
1733
|
var walk2 = (dir, base = dir) => fs.readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
|
|
1661
|
-
const full =
|
|
1662
|
-
return entry.isDirectory() ? walk2(full, base) : [toPosix(
|
|
1734
|
+
const full = path8.join(dir, entry.name);
|
|
1735
|
+
return entry.isDirectory() ? walk2(full, base) : [toPosix(path8.relative(base, full))];
|
|
1663
1736
|
});
|
|
1664
1737
|
var DirTemplateSource = class {
|
|
1665
1738
|
#dir;
|
|
@@ -1671,10 +1744,10 @@ var DirTemplateSource = class {
|
|
|
1671
1744
|
this.#manifest = opts.manifest;
|
|
1672
1745
|
}
|
|
1673
1746
|
list(recipe) {
|
|
1674
|
-
return walk2(
|
|
1747
|
+
return walk2(path8.join(this.#dir, recipe)).map((rel) => this.#fromStored(rel)).filter((rel) => !isExcludedTemplateFile(rel)).sort();
|
|
1675
1748
|
}
|
|
1676
1749
|
read(recipe, file) {
|
|
1677
|
-
return fs.readFileSync(
|
|
1750
|
+
return fs.readFileSync(path8.join(this.#dir, recipe, this.#toStored(file)));
|
|
1678
1751
|
}
|
|
1679
1752
|
manifest() {
|
|
1680
1753
|
return this.#manifest();
|
|
@@ -1771,8 +1844,8 @@ var findCloudRoute = (scan, appDir, expected) => {
|
|
|
1771
1844
|
};
|
|
1772
1845
|
|
|
1773
1846
|
// src/templates/relocate.ts
|
|
1774
|
-
import
|
|
1775
|
-
var posix =
|
|
1847
|
+
import path9 from "path";
|
|
1848
|
+
var posix = path9.posix;
|
|
1776
1849
|
var stripExtension = (file) => file.replace(/\.(tsx?|jsx?|mjs|cjs|mts|cts)$/, "");
|
|
1777
1850
|
var relativeSpecifier = (fromFile, toModule) => {
|
|
1778
1851
|
const rel = posix.relative(posix.dirname(fromFile), toModule);
|
|
@@ -1785,6 +1858,27 @@ var configImportClause = (shape, local) => {
|
|
|
1785
1858
|
if (shape.named.length === 1) return `{ ${shape.named[0]} as ${local} }`;
|
|
1786
1859
|
return null;
|
|
1787
1860
|
};
|
|
1861
|
+
var INSTANT = `// Cache Components: allow rendering on request, outside <Suspense>
|
|
1862
|
+
export const instant = false;`;
|
|
1863
|
+
var cacheComponentsEdits = (ast, code) => {
|
|
1864
|
+
const dynamic = ast.program.body.find(
|
|
1865
|
+
(s) => s.type === "ExportNamedDeclaration" && s.declaration?.type === "VariableDeclaration" && s.declaration.declarations.some(
|
|
1866
|
+
(d) => d.id.type === "Identifier" && d.id.name === "dynamic"
|
|
1867
|
+
)
|
|
1868
|
+
);
|
|
1869
|
+
if (!dynamic) {
|
|
1870
|
+
return [{ start: code.length, end: code.length, text: `
|
|
1871
|
+
${INSTANT}
|
|
1872
|
+
` }];
|
|
1873
|
+
}
|
|
1874
|
+
return [
|
|
1875
|
+
{
|
|
1876
|
+
start: dynamic.leadingComments?.[0]?.start ?? dynamic.start,
|
|
1877
|
+
end: dynamic.end,
|
|
1878
|
+
text: INSTANT
|
|
1879
|
+
}
|
|
1880
|
+
];
|
|
1881
|
+
};
|
|
1788
1882
|
var TYPE_FALLBACKS = {
|
|
1789
1883
|
UserData: 'import("@puckeditor/core").Data'
|
|
1790
1884
|
};
|
|
@@ -1877,6 +1971,9 @@ var relocateModule = (code, opts) => {
|
|
|
1877
1971
|
});
|
|
1878
1972
|
}
|
|
1879
1973
|
}
|
|
1974
|
+
if (opts.cacheComponents && /(^|\/)page\.[jt]sx?$/.test(opts.to)) {
|
|
1975
|
+
edits.push(...cacheComponentsEdits(ast, code));
|
|
1976
|
+
}
|
|
1880
1977
|
return { ok: true, code: applyEdits(code, edits) };
|
|
1881
1978
|
};
|
|
1882
1979
|
|
|
@@ -2463,6 +2560,7 @@ import "@puckeditor/core/puck.css";
|
|
|
2463
2560
|
${ai ? `import "@puckeditor/plugin-ai/styles.css";
|
|
2464
2561
|
` : ""}import "@puckeditor/plugin-pages/styles.css";
|
|
2465
2562
|
import { Metadata } from "next";
|
|
2563
|
+
import { connection } from "next/server";
|
|
2466
2564
|
import { Client } from "./client";${auth ? `
|
|
2467
2565
|
import { requirePuckSession } from "../../../lib/puck-auth";` : ""}
|
|
2468
2566
|
|
|
@@ -2477,15 +2575,18 @@ ${auth ? `export default async function Page({
|
|
|
2477
2575
|
}: {
|
|
2478
2576
|
searchParams: Promise<Record<string, string>>;
|
|
2479
2577
|
}) {
|
|
2578
|
+
// Puck renders in the browser, so the editor is rendered on every request
|
|
2579
|
+
await connection();
|
|
2480
2580
|
const query = new URLSearchParams(await searchParams).toString();
|
|
2481
2581
|
await requirePuckSession(\`/puck\${query ? \`?\${query}\` : ""}\`);
|
|
2482
2582
|
|
|
2483
2583
|
return <Client />;
|
|
2484
2584
|
}` : `export default async function Page() {
|
|
2585
|
+
// Puck renders in the browser, so the editor is rendered on every request
|
|
2586
|
+
await connection();
|
|
2587
|
+
|
|
2485
2588
|
return <Client />;
|
|
2486
2589
|
}`}
|
|
2487
|
-
|
|
2488
|
-
export const dynamic = "force-dynamic";
|
|
2489
2590
|
`;
|
|
2490
2591
|
var nextPagesRenderPage = (host) => `/**
|
|
2491
2592
|
* This file implements a catch-all route that renders the pages published in
|
|
@@ -3141,7 +3242,8 @@ var nextRelocation = (p, info) => {
|
|
|
3141
3242
|
"lib/puck-auth": `${lib}/puck-auth`,
|
|
3142
3243
|
"puck.config": configModuleTarget(p)
|
|
3143
3244
|
},
|
|
3144
|
-
config: configRelocation(p)
|
|
3245
|
+
config: configRelocation(p),
|
|
3246
|
+
cacheComponents: info.cacheComponents
|
|
3145
3247
|
};
|
|
3146
3248
|
};
|
|
3147
3249
|
var conflictingSegments = (p, appDir) => {
|
|
@@ -3374,8 +3476,8 @@ import { requirePuckSession } from "../../../lib/puck-auth";`
|
|
|
3374
3476
|
"NB this route is public, and you will need to add authentication",
|
|
3375
3477
|
"Editing requires signing in with a Puck Cloud account in your organization."
|
|
3376
3478
|
);
|
|
3377
|
-
const
|
|
3378
|
-
const at = code.indexOf(
|
|
3479
|
+
const path36 = 'const path = `/${puckPath.join("/")}`;';
|
|
3480
|
+
const at = code.indexOf(path36, code.indexOf("export default async function Page")) + path36.length;
|
|
3379
3481
|
return `${code.slice(0, at)}
|
|
3380
3482
|
await requirePuckSession(\`\${path.replace(/\\/$/, "")}/edit\`);${code.slice(
|
|
3381
3483
|
at
|
|
@@ -3681,7 +3783,7 @@ var vinextAdapter = {
|
|
|
3681
3783
|
};
|
|
3682
3784
|
|
|
3683
3785
|
// src/frameworks/react-router.ts
|
|
3684
|
-
import
|
|
3786
|
+
import path10 from "path";
|
|
3685
3787
|
|
|
3686
3788
|
// src/ast/react-router-routes.ts
|
|
3687
3789
|
var ROUTES_MODULE = "@react-router/dev/routes";
|
|
@@ -3730,10 +3832,10 @@ var analyzeRoutes = (code, filename) => {
|
|
|
3730
3832
|
const topLevel = new Set(exported.elements.filter(Boolean));
|
|
3731
3833
|
walk(exported, (node) => {
|
|
3732
3834
|
if (!isRouteCall(node, routeLocal)) return;
|
|
3733
|
-
const
|
|
3835
|
+
const path36 = stringArg(node, 0);
|
|
3734
3836
|
const isTop = topLevel.has(node);
|
|
3735
|
-
calls.push({ path:
|
|
3736
|
-
if (
|
|
3837
|
+
calls.push({ path: path36, file: stringArg(node, 1), topLevel: isTop });
|
|
3838
|
+
if (path36 === "*") {
|
|
3737
3839
|
if (isTop) splat = node;
|
|
3738
3840
|
else nestedSplat = true;
|
|
3739
3841
|
}
|
|
@@ -4091,7 +4193,7 @@ var planReactRouterCloudRoute = (p, info, withAi = false) => {
|
|
|
4091
4193
|
registerRoute(
|
|
4092
4194
|
p,
|
|
4093
4195
|
info,
|
|
4094
|
-
{ path: entry.path, file:
|
|
4196
|
+
{ path: entry.path, file: path10.posix.relative(info.appDir, routeFile) },
|
|
4095
4197
|
"cloud",
|
|
4096
4198
|
{ position: "before-splat" }
|
|
4097
4199
|
);
|
|
@@ -4368,10 +4470,10 @@ var reactRouterAdapter = {
|
|
|
4368
4470
|
const routeFile = findCloudRoute(scan, info.appDir, expectedRouteFile);
|
|
4369
4471
|
let routeRegistered = false;
|
|
4370
4472
|
if (info.routesFile) {
|
|
4371
|
-
const code = vfs.readText(
|
|
4473
|
+
const code = vfs.readText(path10.join(root, info.routesFile)) ?? "";
|
|
4372
4474
|
routeRegistered = hasRoute(code, info.routesFile, {
|
|
4373
4475
|
path: CLOUD_ROUTE_ENTRY.path,
|
|
4374
|
-
file: routeFile ?
|
|
4476
|
+
file: routeFile ? path10.posix.relative(info.appDir, routeFile) : CLOUD_ROUTE_ENTRY.file
|
|
4375
4477
|
});
|
|
4376
4478
|
}
|
|
4377
4479
|
return { expectedRouteFile, routeFile, routeRegistered };
|
|
@@ -4386,7 +4488,7 @@ var reactRouterAdapter = {
|
|
|
4386
4488
|
};
|
|
4387
4489
|
|
|
4388
4490
|
// src/frameworks/tanstack-start.ts
|
|
4389
|
-
import
|
|
4491
|
+
import path11 from "path";
|
|
4390
4492
|
var TANSTACK_START_CLOUD_ROUTE_FILE = (routesDir) => `${routesDir}/api/puck/$.ts`;
|
|
4391
4493
|
var TANSTACK_START_EDITOR_MAPPED = [
|
|
4392
4494
|
"database.json",
|
|
@@ -4443,7 +4545,7 @@ var planTanStackStartEditor = (p, info, withAi = false) => {
|
|
|
4443
4545
|
{ from: "database.json", to: "database.json", ifMissing: true }
|
|
4444
4546
|
];
|
|
4445
4547
|
const homeExists = INDEX_ROUTES.some(
|
|
4446
|
-
(f) => p.vfs.exists(p.abs(
|
|
4548
|
+
(f) => p.vfs.exists(p.abs(path11.posix.join(info.routesDir, f)))
|
|
4447
4549
|
);
|
|
4448
4550
|
if (homeExists) {
|
|
4449
4551
|
p.warn(
|
|
@@ -4753,7 +4855,7 @@ var tanstackStartAdapter = {
|
|
|
4753
4855
|
};
|
|
4754
4856
|
|
|
4755
4857
|
// src/frameworks/server.ts
|
|
4756
|
-
import
|
|
4858
|
+
import path12 from "path";
|
|
4757
4859
|
|
|
4758
4860
|
// src/ast/server-app.ts
|
|
4759
4861
|
var stripExtension2 = (source) => source.replace(/\.(m?[jt]sx?)$/, "");
|
|
@@ -4928,12 +5030,12 @@ var CLOUD = { from: "src/puck/cloud.ts", name: "puckCloud" };
|
|
|
4928
5030
|
var CLOUD_CLIENT_PEER = { name: "react", range: "^19.0.0" };
|
|
4929
5031
|
var puckDir = (vfs, root, info) => {
|
|
4930
5032
|
if (info.entry)
|
|
4931
|
-
return
|
|
4932
|
-
return vfs.isDir(
|
|
5033
|
+
return path12.posix.join(path12.posix.dirname(info.entry), "puck");
|
|
5034
|
+
return vfs.isDir(path12.join(root, "src")) ? "src/puck" : "puck";
|
|
4933
5035
|
};
|
|
4934
5036
|
var importSource = (info, file) => {
|
|
4935
|
-
const from =
|
|
4936
|
-
const rel =
|
|
5037
|
+
const from = path12.posix.dirname(info.entry ?? "index.ts");
|
|
5038
|
+
const rel = path12.posix.relative(from, file).replace(/\.ts$/, "");
|
|
4937
5039
|
return `${rel.startsWith(".") ? "" : "./"}${rel}${info.importExtension}`;
|
|
4938
5040
|
};
|
|
4939
5041
|
var mountSnippet = (info, name, file) => `import { ${name} } from "${importSource(info, file)}";
|
|
@@ -5130,13 +5232,13 @@ var serverPlanner = (id2) => {
|
|
|
5130
5232
|
kind: "server",
|
|
5131
5233
|
recipe: (withAi) => withAi ? aiRecipe : recipe,
|
|
5132
5234
|
recipeCloudRoute: CLOUD.from,
|
|
5133
|
-
appDir: (info) => info.entry ?
|
|
5235
|
+
appDir: (info) => info.entry ? path12.posix.dirname(info.entry).replace(/^\.$/, "") : "",
|
|
5134
5236
|
configDirs: () => [],
|
|
5135
5237
|
envDir: () => "",
|
|
5136
5238
|
detectCloudRoute: (info, vfs, root, scan) => {
|
|
5137
5239
|
const expectedRouteFile = `${puckDir(vfs, root, info)}/cloud.ts`;
|
|
5138
5240
|
const routeFile = findCloudRoute(scan, "", expectedRouteFile);
|
|
5139
|
-
const code = info.entry ? vfs.readText(
|
|
5241
|
+
const code = info.entry ? vfs.readText(path12.join(root, info.entry)) ?? "" : "";
|
|
5140
5242
|
return {
|
|
5141
5243
|
expectedRouteFile,
|
|
5142
5244
|
routeFile,
|
|
@@ -5147,8 +5249,8 @@ var serverPlanner = (id2) => {
|
|
|
5147
5249
|
},
|
|
5148
5250
|
detectPagesApi: (info, vfs, root) => {
|
|
5149
5251
|
const file = `${puckDir(vfs, root, info)}/pages.ts`;
|
|
5150
|
-
if (!vfs.exists(
|
|
5151
|
-
const code = info.entry ? vfs.readText(
|
|
5252
|
+
if (!vfs.exists(path12.join(root, file))) return null;
|
|
5253
|
+
const code = info.entry ? vfs.readText(path12.join(root, info.entry)) ?? "" : "";
|
|
5152
5254
|
return {
|
|
5153
5255
|
file,
|
|
5154
5256
|
mounted: Boolean(info.entry) && isMounted(code, info.entry, info.id, {
|
|
@@ -5175,7 +5277,7 @@ var expressAdapter = serverPlanner(
|
|
|
5175
5277
|
);
|
|
5176
5278
|
|
|
5177
5279
|
// src/frameworks/vite-app.ts
|
|
5178
|
-
import
|
|
5280
|
+
import path13 from "path";
|
|
5179
5281
|
|
|
5180
5282
|
// src/ast/react-root.ts
|
|
5181
5283
|
var isCreateRoot = (node) => node.type === "CallExpression" && (node.callee.type === "Identifier" && node.callee.name === "createRoot" || node.callee.type === "MemberExpression" && node.callee.property.type === "Identifier" && node.callee.property.name === "createRoot");
|
|
@@ -5304,7 +5406,7 @@ var SERVER_DEV_PACKAGES = [
|
|
|
5304
5406
|
{ name: "@hono/vite-dev-server", range: "^0.26.1" },
|
|
5305
5407
|
{ name: "tsx", range: "^4.23.0" }
|
|
5306
5408
|
];
|
|
5307
|
-
var locate2 = (info) => (from) => from.startsWith("src/") ?
|
|
5409
|
+
var locate2 = (info) => (from) => from.startsWith("src/") ? path13.posix.join(info.srcDir || ".", from.slice(4)) : from;
|
|
5308
5410
|
var viteRelocation = (p, info) => {
|
|
5309
5411
|
const to = locate2(info);
|
|
5310
5412
|
const moduleId = (id2) => to(`${id2}.ts`).replace(/\.ts$/, "");
|
|
@@ -5418,8 +5520,8 @@ var planViteEditor = (p, info, withAi = false) => {
|
|
|
5418
5520
|
);
|
|
5419
5521
|
}
|
|
5420
5522
|
const entry = info.entry;
|
|
5421
|
-
const rootModule =
|
|
5422
|
-
|
|
5523
|
+
const rootModule = path13.posix.relative(
|
|
5524
|
+
path13.posix.dirname(entry ?? "src/main.tsx"),
|
|
5423
5525
|
to("src/puck/root")
|
|
5424
5526
|
);
|
|
5425
5527
|
const source = rootModule.startsWith(".") ? rootModule : `./${rootModule}`;
|
|
@@ -5725,7 +5827,7 @@ var viteAdapter = {
|
|
|
5725
5827
|
}),
|
|
5726
5828
|
detectCloudRoute: (info, vfs, root, scan) => {
|
|
5727
5829
|
const routeFile = findCloudRoute(scan, "server", CLOUD_ROUTE);
|
|
5728
|
-
const index = vfs.readText(
|
|
5830
|
+
const index = vfs.readText(path13.join(root, SERVER_ENTRY)) ?? "";
|
|
5729
5831
|
return {
|
|
5730
5832
|
expectedRouteFile: CLOUD_ROUTE,
|
|
5731
5833
|
routeFile,
|
|
@@ -5745,14 +5847,14 @@ var viteAdapter = {
|
|
|
5745
5847
|
};
|
|
5746
5848
|
|
|
5747
5849
|
// src/plan/install.ts
|
|
5748
|
-
import
|
|
5850
|
+
import path14 from "path";
|
|
5749
5851
|
var addCommand = (ctx, packages, { dev = false } = {}) => {
|
|
5750
5852
|
const pm = ctx.packageManager.name;
|
|
5751
5853
|
const specs = dev ? [pm === "bun" ? "-d" : "-D", ...packages] : packages;
|
|
5752
5854
|
const ws = ctx.workspace && !ctx.workspace.isRoot ? ctx.workspace : null;
|
|
5753
5855
|
const name = ctx.packageJson?.name;
|
|
5754
5856
|
if (ws) {
|
|
5755
|
-
const relDir = toPosix(
|
|
5857
|
+
const relDir = toPosix(path14.relative(ws.root, ctx.root));
|
|
5756
5858
|
if (pm === "pnpm" && name)
|
|
5757
5859
|
return {
|
|
5758
5860
|
command: "pnpm",
|
|
@@ -6259,13 +6361,13 @@ var ADAPTERS = {
|
|
|
6259
6361
|
var adapterFor = (info) => ADAPTERS[info.id];
|
|
6260
6362
|
|
|
6261
6363
|
// src/output/summary.ts
|
|
6262
|
-
import
|
|
6364
|
+
import path17 from "path";
|
|
6263
6365
|
|
|
6264
6366
|
// src/detect/state.ts
|
|
6265
|
-
import
|
|
6367
|
+
import path16 from "path";
|
|
6266
6368
|
|
|
6267
6369
|
// src/env/files.ts
|
|
6268
|
-
import
|
|
6370
|
+
import path15 from "path";
|
|
6269
6371
|
|
|
6270
6372
|
// src/env/dotenv.ts
|
|
6271
6373
|
var LINE = /^(\s*)(export\s+)?([A-Za-z_][A-Za-z0-9_.-]*)\s*=\s*(.*)$/;
|
|
@@ -6329,7 +6431,7 @@ var findApiKey = (vfs, envDir, processEnv) => {
|
|
|
6329
6431
|
};
|
|
6330
6432
|
}
|
|
6331
6433
|
for (const name of DEV_ENV_FILES) {
|
|
6332
|
-
const file =
|
|
6434
|
+
const file = path15.join(envDir, name);
|
|
6333
6435
|
const text = vfs.readText(file);
|
|
6334
6436
|
if (text === null) continue;
|
|
6335
6437
|
const value = parseEnv(text)[ENV_KEY];
|
|
@@ -6346,25 +6448,25 @@ var CONFIG_CANDIDATES = ["tsx", "ts", "jsx", "js"].map(
|
|
|
6346
6448
|
);
|
|
6347
6449
|
var findConfig = (vfs, ctx, configFlag) => {
|
|
6348
6450
|
if (configFlag) {
|
|
6349
|
-
const abs =
|
|
6350
|
-
return vfs.exists(abs) ? toPosix(
|
|
6451
|
+
const abs = path16.resolve(ctx.cwd, configFlag);
|
|
6452
|
+
return vfs.exists(abs) ? toPosix(path16.relative(ctx.root, abs)) : null;
|
|
6351
6453
|
}
|
|
6352
6454
|
const dirs = ctx.framework ? adapterFor(ctx.framework).configDirs(ctx.framework) : ["", "src"];
|
|
6353
6455
|
for (const dir of dirs) {
|
|
6354
6456
|
for (const candidate of CONFIG_CANDIDATES) {
|
|
6355
6457
|
const rel = dir ? `${dir}/${candidate}` : candidate;
|
|
6356
|
-
if (vfs.exists(
|
|
6458
|
+
if (vfs.exists(path16.join(ctx.root, rel))) return rel;
|
|
6357
6459
|
}
|
|
6358
6460
|
}
|
|
6359
6461
|
return null;
|
|
6360
6462
|
};
|
|
6361
|
-
var envDirFor = (ctx) => ctx.framework ?
|
|
6463
|
+
var envDirFor = (ctx) => ctx.framework ? path16.join(ctx.root, adapterFor(ctx.framework).envDir(ctx.framework)) : ctx.root;
|
|
6362
6464
|
var detectState = (vfs, ctx, env2, opts = {}) => {
|
|
6363
6465
|
const scan = scanSources(vfs, ctx.root);
|
|
6364
6466
|
const configFile = findConfig(vfs, ctx, opts.configFlag);
|
|
6365
6467
|
let configExports = null;
|
|
6366
6468
|
if (configFile) {
|
|
6367
|
-
const code = vfs.readText(
|
|
6469
|
+
const code = vfs.readText(path16.join(ctx.root, configFile));
|
|
6368
6470
|
const ast = code ? tryParseModule(code, configFile) : null;
|
|
6369
6471
|
configExports = ast ? getExportShape(ast) : null;
|
|
6370
6472
|
}
|
|
@@ -6375,7 +6477,7 @@ var detectState = (vfs, ctx, env2, opts = {}) => {
|
|
|
6375
6477
|
ctx.root,
|
|
6376
6478
|
scan
|
|
6377
6479
|
) : null;
|
|
6378
|
-
const routeCode = route?.routeFile ? vfs.readText(
|
|
6480
|
+
const routeCode = route?.routeFile ? vfs.readText(path16.join(ctx.root, route.routeFile)) : null;
|
|
6379
6481
|
const envDir = envDirFor(ctx);
|
|
6380
6482
|
const apiKey = findApiKey(vfs, envDir, env2);
|
|
6381
6483
|
const gitignoreRoot2 = ctx.gitRoot ?? ctx.workspace?.root ?? ctx.root;
|
|
@@ -6478,7 +6580,7 @@ var capabilityStatus = (state) => {
|
|
|
6478
6580
|
|
|
6479
6581
|
// src/output/summary.ts
|
|
6480
6582
|
var displayPath = (base, abs) => {
|
|
6481
|
-
const rel = toPosix(
|
|
6583
|
+
const rel = toPosix(path17.relative(base, abs));
|
|
6482
6584
|
return rel === "" ? "." : rel;
|
|
6483
6585
|
};
|
|
6484
6586
|
var capabilityLabels = (server) => ({
|
|
@@ -6543,6 +6645,12 @@ var actionLines = (action) => {
|
|
|
6543
6645
|
` and confirm the code ${pc.bold(action.userCode)}`
|
|
6544
6646
|
);
|
|
6545
6647
|
break;
|
|
6648
|
+
case "claim_project":
|
|
6649
|
+
lines.push(
|
|
6650
|
+
` Open ${pc.cyan(action.url)}`,
|
|
6651
|
+
` before ${new Date(action.expiresAt).toLocaleString()}`
|
|
6652
|
+
);
|
|
6653
|
+
break;
|
|
6546
6654
|
case "provide_api_key":
|
|
6547
6655
|
lines.push(` ${action.instructions}`);
|
|
6548
6656
|
break;
|
|
@@ -6780,11 +6888,11 @@ var presentHuman = (out, result, secrets) => {
|
|
|
6780
6888
|
};
|
|
6781
6889
|
|
|
6782
6890
|
// src/commands/init.ts
|
|
6783
|
-
import
|
|
6891
|
+
import path29 from "path";
|
|
6784
6892
|
|
|
6785
6893
|
// src/io/vfs.ts
|
|
6786
6894
|
import fs2 from "fs";
|
|
6787
|
-
import
|
|
6895
|
+
import path18 from "path";
|
|
6788
6896
|
import { createHash } from "crypto";
|
|
6789
6897
|
var hashContent = (content) => createHash("sha256").update(content).digest("hex");
|
|
6790
6898
|
var readDisk = (p) => {
|
|
@@ -6834,10 +6942,10 @@ var Vfs = class {
|
|
|
6834
6942
|
}
|
|
6835
6943
|
} catch {
|
|
6836
6944
|
}
|
|
6837
|
-
const prefix = dir.endsWith(
|
|
6945
|
+
const prefix = dir.endsWith(path18.sep) ? dir : dir + path18.sep;
|
|
6838
6946
|
for (const p of this.#overlay.keys()) {
|
|
6839
6947
|
if (!p.startsWith(prefix)) continue;
|
|
6840
|
-
const [first, ...rest] = p.slice(prefix.length).split(
|
|
6948
|
+
const [first, ...rest] = p.slice(prefix.length).split(path18.sep);
|
|
6841
6949
|
entries.set(first, rest.length > 0 || entries.get(first) === true);
|
|
6842
6950
|
}
|
|
6843
6951
|
return [...entries.entries()].map(([name, isDir]) => ({ name, isDir })).sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -6868,7 +6976,7 @@ var Vfs = class {
|
|
|
6868
6976
|
);
|
|
6869
6977
|
}
|
|
6870
6978
|
#overlayHasDescendant(p) {
|
|
6871
|
-
const prefix = p.endsWith(
|
|
6979
|
+
const prefix = p.endsWith(path18.sep) ? p : p + path18.sep;
|
|
6872
6980
|
for (const key of this.#overlay.keys()) {
|
|
6873
6981
|
if (key.startsWith(prefix)) return true;
|
|
6874
6982
|
}
|
|
@@ -6877,14 +6985,14 @@ var Vfs = class {
|
|
|
6877
6985
|
};
|
|
6878
6986
|
|
|
6879
6987
|
// src/detect/project.ts
|
|
6880
|
-
import
|
|
6988
|
+
import path20 from "path";
|
|
6881
6989
|
|
|
6882
6990
|
// src/detect/workspace.ts
|
|
6883
|
-
import
|
|
6991
|
+
import path19 from "path";
|
|
6884
6992
|
import { globSync } from "tinyglobby";
|
|
6885
6993
|
import { parse as parseYaml } from "yaml";
|
|
6886
6994
|
var readGlobs = (vfs, dir) => {
|
|
6887
|
-
const yamlText = vfs.readText(
|
|
6995
|
+
const yamlText = vfs.readText(path19.join(dir, "pnpm-workspace.yaml"));
|
|
6888
6996
|
if (yamlText !== null) {
|
|
6889
6997
|
try {
|
|
6890
6998
|
const parsed = parseYaml(yamlText);
|
|
@@ -6919,7 +7027,7 @@ var expandWorkspace = (vfs, root, globs) => {
|
|
|
6919
7027
|
absolute: false
|
|
6920
7028
|
}
|
|
6921
7029
|
);
|
|
6922
|
-
return files.map((file) =>
|
|
7030
|
+
return files.map((file) => path19.join(root, path19.dirname(file))).filter((dir) => dir !== root).sort().map((dir) => {
|
|
6923
7031
|
const read = readPackageJson(vfs, dir);
|
|
6924
7032
|
return { dir, name: read.status === "ok" ? read.pkg.name ?? null : null };
|
|
6925
7033
|
});
|
|
@@ -6934,7 +7042,7 @@ var findWorkspace = (vfs, startDir, stopAt) => {
|
|
|
6934
7042
|
packages: expandWorkspace(vfs, dir, globs.globs)
|
|
6935
7043
|
};
|
|
6936
7044
|
}
|
|
6937
|
-
const parent =
|
|
7045
|
+
const parent = path19.dirname(dir);
|
|
6938
7046
|
if (dir === stopAt || parent === dir) return null;
|
|
6939
7047
|
dir = parent;
|
|
6940
7048
|
}
|
|
@@ -6954,8 +7062,8 @@ var IGNORABLE_ENTRIES = /* @__PURE__ */ new Set([
|
|
|
6954
7062
|
]);
|
|
6955
7063
|
var findGitRoot = (vfs, start) => {
|
|
6956
7064
|
for (let dir = start; ; ) {
|
|
6957
|
-
if (vfs.exists(
|
|
6958
|
-
const parent =
|
|
7065
|
+
if (vfs.exists(path20.join(dir, ".git"))) return dir;
|
|
7066
|
+
const parent = path20.dirname(dir);
|
|
6959
7067
|
if (parent === dir) return null;
|
|
6960
7068
|
dir = parent;
|
|
6961
7069
|
}
|
|
@@ -7013,7 +7121,7 @@ var detectProject = ({
|
|
|
7013
7121
|
packageManager,
|
|
7014
7122
|
framework,
|
|
7015
7123
|
frameworkError,
|
|
7016
|
-
typescript: vfs.exists(
|
|
7124
|
+
typescript: vfs.exists(path20.join(root, "tsconfig.json")),
|
|
7017
7125
|
gitRoot,
|
|
7018
7126
|
isEmptyDir: vfs.isDir(root) ? isEmptyDir(vfs, root) : true,
|
|
7019
7127
|
workspace,
|
|
@@ -7022,7 +7130,7 @@ var detectProject = ({
|
|
|
7022
7130
|
};
|
|
7023
7131
|
|
|
7024
7132
|
// src/plan/bootstrap.ts
|
|
7025
|
-
import
|
|
7133
|
+
import path21 from "path";
|
|
7026
7134
|
|
|
7027
7135
|
// src/templates/transform.ts
|
|
7028
7136
|
var WORKSPACE_PROTOCOL = /^workspace:/;
|
|
@@ -7106,7 +7214,7 @@ var scaffoldApp = (vfs, templates2, {
|
|
|
7106
7214
|
}) => {
|
|
7107
7215
|
const files = templates2.list(recipe);
|
|
7108
7216
|
for (const rel of files) {
|
|
7109
|
-
const target =
|
|
7217
|
+
const target = path21.join(dir, ...rel.split("/"));
|
|
7110
7218
|
const raw = templates2.read(recipe, rel);
|
|
7111
7219
|
const legacyFile = legacy?.files[rel];
|
|
7112
7220
|
if (legacyFile) {
|
|
@@ -7134,9 +7242,9 @@ var scaffoldApp = (vfs, templates2, {
|
|
|
7134
7242
|
|
|
7135
7243
|
// src/commands/target.ts
|
|
7136
7244
|
import fs3 from "fs";
|
|
7137
|
-
import
|
|
7245
|
+
import path22 from "path";
|
|
7138
7246
|
var baseDir = (rc) => {
|
|
7139
|
-
const dir =
|
|
7247
|
+
const dir = path22.resolve(rc.deps.cwd, rc.flags.cwd ?? ".");
|
|
7140
7248
|
if (!fs3.existsSync(dir) || !fs3.statSync(dir).isDirectory()) {
|
|
7141
7249
|
throw new CliError("PUCK-CLI-CWD-NOT-FOUND", `Directory not found: ${dir}`);
|
|
7142
7250
|
}
|
|
@@ -7195,7 +7303,7 @@ var resolveTarget = async (rc, opts = {}) => {
|
|
|
7195
7303
|
const wanted = rc.flags.workspace.replace(/\/+$/, "");
|
|
7196
7304
|
const apps2 = listWorkspaceApps(vfs, workspace);
|
|
7197
7305
|
const match = apps2.find(
|
|
7198
|
-
(a) => a.name === wanted || a.dir ===
|
|
7306
|
+
(a) => a.name === wanted || a.dir === path22.resolve(base, wanted) || a.dir === path22.resolve(workspace.root, wanted)
|
|
7199
7307
|
);
|
|
7200
7308
|
if (!match) {
|
|
7201
7309
|
throw new CliError(
|
|
@@ -7281,10 +7389,10 @@ var resolveTarget = async (rc, opts = {}) => {
|
|
|
7281
7389
|
};
|
|
7282
7390
|
|
|
7283
7391
|
// src/commands/mutate.ts
|
|
7284
|
-
import
|
|
7392
|
+
import path28 from "path";
|
|
7285
7393
|
|
|
7286
7394
|
// src/plan/planner.ts
|
|
7287
|
-
import
|
|
7395
|
+
import path23 from "path";
|
|
7288
7396
|
var normalizeEol2 = (text) => text.replace(/\r\n/g, "\n");
|
|
7289
7397
|
var Planner = class {
|
|
7290
7398
|
constructor(vfs, ctx, state, templates2, cliVersion) {
|
|
@@ -7312,10 +7420,10 @@ var Planner = class {
|
|
|
7312
7420
|
/** Exact versions to install instead, with --canary */
|
|
7313
7421
|
canary = {};
|
|
7314
7422
|
abs(rel) {
|
|
7315
|
-
return
|
|
7423
|
+
return path23.join(this.ctx.root, rel);
|
|
7316
7424
|
}
|
|
7317
7425
|
rel(abs) {
|
|
7318
|
-
return toPosix(
|
|
7426
|
+
return toPosix(path23.relative(this.ctx.root, abs));
|
|
7319
7427
|
}
|
|
7320
7428
|
createFile(rel, content, opts) {
|
|
7321
7429
|
const abs = this.abs(rel);
|
|
@@ -7392,6 +7500,12 @@ var Planner = class {
|
|
|
7392
7500
|
/** Turns collected dependencies into one install, or folds them into a scaffolded or edited package.json */
|
|
7393
7501
|
finalize() {
|
|
7394
7502
|
if (this.#dependencies.length === 0) return;
|
|
7503
|
+
if (!(CLI_PACKAGE in this.ctx.deps)) {
|
|
7504
|
+
const range = this.cliVersion.includes("-") ? this.cliVersion : `^${this.cliVersion}`;
|
|
7505
|
+
this.addDependency(CLI_PACKAGE, range, this.#dependencies[0].capability, {
|
|
7506
|
+
dev: true
|
|
7507
|
+
});
|
|
7508
|
+
}
|
|
7395
7509
|
const specs = this.#dependencies.map((d) => `${d.name}@${d.range}`);
|
|
7396
7510
|
const pkgPath = this.abs("package.json");
|
|
7397
7511
|
if (this.scaffolded) {
|
|
@@ -7616,7 +7730,7 @@ var planCapabilities = (p, capabilities) => {
|
|
|
7616
7730
|
};
|
|
7617
7731
|
|
|
7618
7732
|
// src/plan/env.ts
|
|
7619
|
-
import
|
|
7733
|
+
import path24 from "path";
|
|
7620
7734
|
var gitignoreRoot = (p) => p.ctx.gitRoot ?? p.ctx.workspace?.root ?? p.ctx.root;
|
|
7621
7735
|
var planGitignore = (p, envFile) => {
|
|
7622
7736
|
if (isIgnored(p.vfs, envFile, gitignoreRoot(p))) return;
|
|
@@ -7626,7 +7740,7 @@ var planGitignore = (p, envFile) => {
|
|
|
7626
7740
|
p.ctx.root,
|
|
7627
7741
|
p.ctx.gitRoot
|
|
7628
7742
|
);
|
|
7629
|
-
const pattern =
|
|
7743
|
+
const pattern = path24.relative(path24.dirname(gitignore), envFile).split(path24.sep).join("/");
|
|
7630
7744
|
p.vfs.write(gitignore, content);
|
|
7631
7745
|
p.steps.push({
|
|
7632
7746
|
id: `cloud:gitignore:${p.rel(gitignore)}`,
|
|
@@ -7641,7 +7755,7 @@ var planEnvWrite = (p, secret) => {
|
|
|
7641
7755
|
const location = p.state.cloud.apiKey;
|
|
7642
7756
|
const envDir = p.state.cloud.envDir;
|
|
7643
7757
|
const root = gitignoreRoot(p);
|
|
7644
|
-
const target = location.file && isLocalEnvFile(location.source) && isIgnored(p.vfs, location.file, root) ? location.file :
|
|
7758
|
+
const target = location.file && isLocalEnvFile(location.source) && isIgnored(p.vfs, location.file, root) ? location.file : path24.join(envDir, ".env.local");
|
|
7645
7759
|
if (isSharedEnvFile(location.source)) {
|
|
7646
7760
|
p.warn(
|
|
7647
7761
|
"PUCK-CLI-W-KEY-IN-SHARED-ENV",
|
|
@@ -7668,7 +7782,7 @@ var planEnvWrite = (p, secret) => {
|
|
|
7668
7782
|
};
|
|
7669
7783
|
|
|
7670
7784
|
// src/plan/pnpm-builds.ts
|
|
7671
|
-
import
|
|
7785
|
+
import path25 from "path";
|
|
7672
7786
|
import { Document, isMap, isSeq, parseDocument } from "yaml";
|
|
7673
7787
|
var LEGACY_LISTS = [
|
|
7674
7788
|
"onlyBuiltDependencies",
|
|
@@ -7710,7 +7824,7 @@ var planAllowedBuilds = (planner) => {
|
|
|
7710
7824
|
if (ctx.packageManager.name !== "pnpm") return;
|
|
7711
7825
|
const ws = ctx.workspace;
|
|
7712
7826
|
if (ws && ws.source !== "pnpm-workspace.yaml") return;
|
|
7713
|
-
const file =
|
|
7827
|
+
const file = path25.join(ws?.root ?? ctx.root, "pnpm-workspace.yaml");
|
|
7714
7828
|
const names = templates_default.allowBuilds;
|
|
7715
7829
|
const list = names.join(", ");
|
|
7716
7830
|
const next = withAllowedBuilds(vfs.readText(file), names);
|
|
@@ -7796,14 +7910,14 @@ var resolveBackend = async (rc, options, capabilities, planned) => {
|
|
|
7796
7910
|
|
|
7797
7911
|
// src/auth/session-store.ts
|
|
7798
7912
|
import fs4 from "fs";
|
|
7799
|
-
import
|
|
7913
|
+
import path26 from "path";
|
|
7800
7914
|
import { createHash as createHash2 } from "crypto";
|
|
7801
7915
|
var SessionStore = class {
|
|
7802
7916
|
#file;
|
|
7803
7917
|
constructor(cacheDir, projectRoot, baseUrl) {
|
|
7804
7918
|
const key = createHash2("sha256").update(`${projectRoot}
|
|
7805
7919
|
${baseUrl}`).digest("hex").slice(0, 32);
|
|
7806
|
-
this.#file =
|
|
7920
|
+
this.#file = path26.join(cacheDir, "puck", "connect", `${key}.json`);
|
|
7807
7921
|
}
|
|
7808
7922
|
get path() {
|
|
7809
7923
|
return this.#file;
|
|
@@ -7817,14 +7931,14 @@ ${baseUrl}`).digest("hex").slice(0, 32);
|
|
|
7817
7931
|
}
|
|
7818
7932
|
}
|
|
7819
7933
|
save(session) {
|
|
7820
|
-
fs4.mkdirSync(
|
|
7934
|
+
fs4.mkdirSync(path26.dirname(this.#file), { recursive: true, mode: 448 });
|
|
7821
7935
|
fs4.writeFileSync(this.#file, JSON.stringify(session), { mode: 384 });
|
|
7822
7936
|
}
|
|
7823
7937
|
clear() {
|
|
7824
7938
|
fs4.rmSync(this.#file, { force: true });
|
|
7825
7939
|
}
|
|
7826
7940
|
};
|
|
7827
|
-
var cacheDirFor = (env2, homedir) => env2.XDG_CACHE_HOME ||
|
|
7941
|
+
var cacheDirFor = (env2, homedir) => env2.XDG_CACHE_HOME || path26.join(homedir, ".cache");
|
|
7828
7942
|
|
|
7829
7943
|
// src/auth/credentials.ts
|
|
7830
7944
|
var apiKeysUrl = (rc) => new URL(API_KEYS_PATH, rc.cloud.baseUrl).toString();
|
|
@@ -7900,6 +8014,28 @@ var connectFallback = (rc, err) => {
|
|
|
7900
8014
|
warnings: []
|
|
7901
8015
|
};
|
|
7902
8016
|
};
|
|
8017
|
+
var startUnclaimed = async (rc, info) => {
|
|
8018
|
+
let created;
|
|
8019
|
+
try {
|
|
8020
|
+
created = await rc.cloud.createClaimableProject(clientPayload(rc, info));
|
|
8021
|
+
} catch (err) {
|
|
8022
|
+
return connectFallback(rc, err);
|
|
8023
|
+
}
|
|
8024
|
+
if (!created) return null;
|
|
8025
|
+
const secret = secretFrom(rc, created.apiKey, "Puck Cloud");
|
|
8026
|
+
rc.log(
|
|
8027
|
+
`\u2713 Created the Puck Cloud project "${created.project.name}" without an account (key "${created.keyName}")`
|
|
8028
|
+
);
|
|
8029
|
+
return {
|
|
8030
|
+
kind: "resolved",
|
|
8031
|
+
secret,
|
|
8032
|
+
source: "connect",
|
|
8033
|
+
needsWrite: true,
|
|
8034
|
+
verified: "valid",
|
|
8035
|
+
warnings: [],
|
|
8036
|
+
claim: { url: created.claimUrl, expiresAt: created.expiresAt }
|
|
8037
|
+
};
|
|
8038
|
+
};
|
|
7903
8039
|
var connectNonInteractive = async (rc, info, attempt = 0) => {
|
|
7904
8040
|
const store = new SessionStore(
|
|
7905
8041
|
cacheDirFor(rc.deps.env, rc.deps.homedir),
|
|
@@ -8118,10 +8254,22 @@ var resolveCredential = async (rc, state, info, { fresh = false } = {}) => {
|
|
|
8118
8254
|
"How do you want to connect to Puck Cloud?",
|
|
8119
8255
|
[
|
|
8120
8256
|
{ value: "login", name: "Log in with the browser (recommended)" },
|
|
8257
|
+
// `connect` replaces the key, often for a branch, so it always logs in
|
|
8258
|
+
...fresh ? [] : [
|
|
8259
|
+
{
|
|
8260
|
+
value: "unclaimed",
|
|
8261
|
+
name: "Start without an account (claim it within 72 hours)"
|
|
8262
|
+
}
|
|
8263
|
+
],
|
|
8121
8264
|
{ value: "paste", name: "Paste an existing API key" }
|
|
8122
8265
|
]
|
|
8123
8266
|
);
|
|
8124
|
-
if (method === "
|
|
8267
|
+
if (method === "unclaimed") {
|
|
8268
|
+
const started = await startUnclaimed(rc, info);
|
|
8269
|
+
if (started?.kind === "resolved") return { ...started, warnings };
|
|
8270
|
+
rc.log("Couldn't start without an account. Log in instead.");
|
|
8271
|
+
}
|
|
8272
|
+
if (method === "login" || method === "unclaimed") {
|
|
8125
8273
|
const connected = await connectInteractive(rc, info);
|
|
8126
8274
|
if (connected) return { ...connected, warnings };
|
|
8127
8275
|
rc.log("Falling back to pasting an API key.");
|
|
@@ -8143,13 +8291,18 @@ var resolveCredential = async (rc, state, info, { fresh = false } = {}) => {
|
|
|
8143
8291
|
}
|
|
8144
8292
|
};
|
|
8145
8293
|
}
|
|
8294
|
+
if (!fresh && !rc.flags.login) {
|
|
8295
|
+
const started = await startUnclaimed(rc, info);
|
|
8296
|
+
if (started)
|
|
8297
|
+
return { ...started, warnings: [...warnings, ...started.warnings] };
|
|
8298
|
+
}
|
|
8146
8299
|
const resolution = await connectNonInteractive(rc, info);
|
|
8147
8300
|
return { ...resolution, warnings: [...warnings, ...resolution.warnings] };
|
|
8148
8301
|
};
|
|
8149
8302
|
|
|
8150
8303
|
// src/apply/applier.ts
|
|
8151
8304
|
import fs5 from "fs";
|
|
8152
|
-
import
|
|
8305
|
+
import path27 from "path";
|
|
8153
8306
|
var tail = (text, lines = 20) => text.trim().split("\n").slice(-lines).join("\n");
|
|
8154
8307
|
var run = async (rc, spec) => {
|
|
8155
8308
|
rc.log(`$ ${formatCommand(spec)}`);
|
|
@@ -8179,14 +8332,14 @@ ${result.stderr}`))
|
|
|
8179
8332
|
}
|
|
8180
8333
|
};
|
|
8181
8334
|
var writeFile = (file, content, mode) => {
|
|
8182
|
-
fs5.mkdirSync(
|
|
8335
|
+
fs5.mkdirSync(path27.dirname(file), { recursive: true });
|
|
8183
8336
|
if (mode === void 0) {
|
|
8184
8337
|
fs5.writeFileSync(file, content);
|
|
8185
8338
|
return;
|
|
8186
8339
|
}
|
|
8187
|
-
const temp =
|
|
8188
|
-
|
|
8189
|
-
`.${
|
|
8340
|
+
const temp = path27.join(
|
|
8341
|
+
path27.dirname(file),
|
|
8342
|
+
`.${path27.basename(file)}.${process.pid}.tmp`
|
|
8190
8343
|
);
|
|
8191
8344
|
fs5.writeFileSync(temp, content, { mode });
|
|
8192
8345
|
fs5.chmodSync(temp, mode);
|
|
@@ -8320,7 +8473,7 @@ var runMutation = async (rc, input) => {
|
|
|
8320
8473
|
registryToken(
|
|
8321
8474
|
registry,
|
|
8322
8475
|
[base, deps.homedir].map(
|
|
8323
|
-
(dir) => vfs.readText(
|
|
8476
|
+
(dir) => vfs.readText(path28.join(dir, ".npmrc"))
|
|
8324
8477
|
),
|
|
8325
8478
|
deps.env
|
|
8326
8479
|
)
|
|
@@ -8453,7 +8606,7 @@ var runMutation = async (rc, input) => {
|
|
|
8453
8606
|
if (wantsCloud) {
|
|
8454
8607
|
credential = await resolveCredential(rc, state, {
|
|
8455
8608
|
projectRoot: root,
|
|
8456
|
-
projectName: bootstrap?.appName ?? ctx.packageJson?.name ??
|
|
8609
|
+
projectName: bootstrap?.appName ?? ctx.packageJson?.name ?? path28.basename(root),
|
|
8457
8610
|
framework: ctx.framework.id
|
|
8458
8611
|
});
|
|
8459
8612
|
for (const w of credential.warnings) planner.warn(w.code, w.message);
|
|
@@ -8464,6 +8617,24 @@ var runMutation = async (rc, input) => {
|
|
|
8464
8617
|
[credential.action]
|
|
8465
8618
|
);
|
|
8466
8619
|
}
|
|
8620
|
+
if (credential.kind === "resolved" && credential.claim) {
|
|
8621
|
+
const { url, expiresAt } = credential.claim;
|
|
8622
|
+
planner.manual({
|
|
8623
|
+
id: "cloud:claim",
|
|
8624
|
+
type: "claim_project",
|
|
8625
|
+
required: false,
|
|
8626
|
+
message: "Ask the developer to claim this Puck Cloud project before it expires, or it's deleted with its pages.",
|
|
8627
|
+
url,
|
|
8628
|
+
expiresAt,
|
|
8629
|
+
instructions: `Open ${url} and sign up or log in before ${expiresAt}. ${ENV_KEY} keeps working once it's claimed.`
|
|
8630
|
+
});
|
|
8631
|
+
if (capabilities.includes("ai") || state.ai.installed) {
|
|
8632
|
+
planner.warn(
|
|
8633
|
+
"PUCK-CLI-W-AI-UNCLAIMED",
|
|
8634
|
+
`Puck AI works once the project is claimed. Open ${url} to claim it.`
|
|
8635
|
+
);
|
|
8636
|
+
}
|
|
8637
|
+
}
|
|
8467
8638
|
if (credential.kind === "resolved" && credential.needsWrite) {
|
|
8468
8639
|
planEnvWrite(planner, credential.secret);
|
|
8469
8640
|
} else if (credential.kind === "resolved" && state.cloud.apiKey.file) {
|
|
@@ -8546,10 +8717,14 @@ var runMutation = async (rc, input) => {
|
|
|
8546
8717
|
);
|
|
8547
8718
|
result.message = blocked ? `Partially set up. ${unsatisfied.length ? `Still missing: ${unsatisfied.flatMap((c) => status[c].missing).join("; ")}.` : "Complete the required actions below."}` : result.changed ? `Set up ${done.map((c) => capabilityLabels(state.target === "server")[c]).join(", ").replace(/, ([^,]*)$/, " and $1")}.` : "Already set up. Nothing changed.";
|
|
8548
8719
|
const devCommand = `${verifiedCtx.packageManager.name} ${verifiedCtx.packageManager.name === "npm" ? "run " : ""}dev`;
|
|
8549
|
-
const
|
|
8720
|
+
const devSteps = [
|
|
8721
|
+
...root === base ? [] : [`cd ${displayPath(base, root)}`],
|
|
8722
|
+
devCommand
|
|
8723
|
+
];
|
|
8550
8724
|
result.nextSteps = [
|
|
8551
8725
|
...(input.notes ?? []).map((n) => `# ${n}`),
|
|
8552
|
-
|
|
8726
|
+
// Windows PowerShell 5.1 has no `&&`
|
|
8727
|
+
...rc.deps.platform === "win32" ? devSteps : [devSteps.join(" && ")],
|
|
8553
8728
|
`# then open ${adapterFor(verifiedCtx.framework ?? ctx.framework).devUrl}`
|
|
8554
8729
|
];
|
|
8555
8730
|
const usesCloud = ["ai", "pages"].some(
|
|
@@ -8698,14 +8873,14 @@ var runInit = async (rc) => {
|
|
|
8698
8873
|
{ globs: target.workspace.globs }
|
|
8699
8874
|
);
|
|
8700
8875
|
}
|
|
8701
|
-
parentDir =
|
|
8876
|
+
parentDir = path29.join(target.workspace.root, appsDir);
|
|
8702
8877
|
workspaceRoot = target.workspace.root;
|
|
8703
8878
|
for (const pkg of target.workspace.packages) {
|
|
8704
8879
|
if (pkg.name) existingNames.add(pkg.name);
|
|
8705
|
-
existingNames.add(
|
|
8880
|
+
existingNames.add(path29.basename(pkg.dir));
|
|
8706
8881
|
}
|
|
8707
8882
|
} else {
|
|
8708
|
-
if (vfs.exists(
|
|
8883
|
+
if (vfs.exists(path29.join(target.root, "package.json"))) {
|
|
8709
8884
|
const read = readPackageJson(vfs, target.root);
|
|
8710
8885
|
const deps = depsOf(read.status === "ok" ? read.pkg : null);
|
|
8711
8886
|
const detection = detectFramework(vfs, target.root, deps);
|
|
@@ -8799,7 +8974,7 @@ var runInit = async (rc) => {
|
|
|
8799
8974
|
`A workspace package named "${name}" already exists.`
|
|
8800
8975
|
);
|
|
8801
8976
|
}
|
|
8802
|
-
const dir = inPlace ? parentDir :
|
|
8977
|
+
const dir = inPlace ? parentDir : path29.join(parentDir, name);
|
|
8803
8978
|
if (!inPlace && vfs.exists(dir) && !isEmptyDir(vfs, dir)) {
|
|
8804
8979
|
throw new CliError(
|
|
8805
8980
|
"PUCK-CLI-TARGET-DIR-NOT-EMPTY",
|
|
@@ -8818,7 +8993,7 @@ var runInit = async (rc) => {
|
|
|
8818
8993
|
bootstrap: {
|
|
8819
8994
|
framework,
|
|
8820
8995
|
dir,
|
|
8821
|
-
appName: name ?? sanitizeAppName(
|
|
8996
|
+
appName: name ?? sanitizeAppName(path29.basename(dir)),
|
|
8822
8997
|
workspaceRoot
|
|
8823
8998
|
},
|
|
8824
8999
|
workspace: target.kind === "workspace-empty" ? target.summary : null
|
|
@@ -8871,7 +9046,7 @@ var runAdd = async (rc, positionals) => {
|
|
|
8871
9046
|
};
|
|
8872
9047
|
|
|
8873
9048
|
// src/commands/connect.ts
|
|
8874
|
-
import
|
|
9049
|
+
import path30 from "path";
|
|
8875
9050
|
var BRANCH_NAME = /^[A-Za-z0-9][A-Za-z0-9._/-]*$/;
|
|
8876
9051
|
var isValidBranchName = (name) => name.length <= 255 && BRANCH_NAME.test(name) && !name.includes("..") && !name.includes("//") && !name.endsWith("/") && !name.endsWith(".");
|
|
8877
9052
|
var runConnect = async (rc, positionals = []) => {
|
|
@@ -8957,7 +9132,7 @@ var runConnect = async (rc, positionals = []) => {
|
|
|
8957
9132
|
state,
|
|
8958
9133
|
{
|
|
8959
9134
|
projectRoot: root,
|
|
8960
|
-
projectName: ctx.packageJson?.name ??
|
|
9135
|
+
projectName: ctx.packageJson?.name ?? path30.basename(root),
|
|
8961
9136
|
framework: ctx.framework.id,
|
|
8962
9137
|
branch
|
|
8963
9138
|
},
|
|
@@ -9010,10 +9185,14 @@ var runConnect = async (rc, positionals = []) => {
|
|
|
9010
9185
|
result.filesCreated = outcome.created.map((f) => displayPath(base, f)).sort();
|
|
9011
9186
|
result.filesModified = [...outcome.created, ...outcome.modified].map((f) => displayPath(base, f)).sort();
|
|
9012
9187
|
const pm = verifiedCtx.packageManager.name;
|
|
9013
|
-
const
|
|
9188
|
+
const devSteps = [
|
|
9189
|
+
...root === base ? [] : [`cd ${displayPath(base, root)}`],
|
|
9190
|
+
`${pm} ${pm === "npm" ? "run " : ""}dev`
|
|
9191
|
+
];
|
|
9014
9192
|
result.nextSteps = cloudReady ? [
|
|
9015
9193
|
"# Restart the dev server so it picks up the new key",
|
|
9016
|
-
|
|
9194
|
+
// Windows PowerShell 5.1 has no `&&`
|
|
9195
|
+
...rc.deps.platform === "win32" ? devSteps : [devSteps.join(" && ")]
|
|
9017
9196
|
] : [`${CANONICAL_INVOCATION} add cloud${where}`];
|
|
9018
9197
|
return result;
|
|
9019
9198
|
};
|
|
@@ -9095,7 +9274,7 @@ var runStatus = async (rc) => {
|
|
|
9095
9274
|
};
|
|
9096
9275
|
|
|
9097
9276
|
// src/commands/doctor.ts
|
|
9098
|
-
import
|
|
9277
|
+
import path31 from "path";
|
|
9099
9278
|
var finding = (check, status, evidence, fix = null) => ({ check, status, evidence, fix });
|
|
9100
9279
|
var runDoctor = async (rc) => {
|
|
9101
9280
|
const base = baseDir(rc);
|
|
@@ -9180,7 +9359,7 @@ var runDoctor = async (rc) => {
|
|
|
9180
9359
|
finding(
|
|
9181
9360
|
"project.package_json",
|
|
9182
9361
|
"ok",
|
|
9183
|
-
displayPath(base,
|
|
9362
|
+
displayPath(base, path31.join(ctx.root, "package.json"))
|
|
9184
9363
|
)
|
|
9185
9364
|
);
|
|
9186
9365
|
result.project = projectSummary(ctx, target.workspace);
|
|
@@ -9569,8 +9748,8 @@ var grep = (source, pages, pattern) => {
|
|
|
9569
9748
|
var usage = (sub, arg) => new CliError(
|
|
9570
9749
|
"PUCK-CLI-INVALID-ARGS",
|
|
9571
9750
|
`Specify ${arg}. For example \`${CANONICAL_INVOCATION} docs ${sub} ${{
|
|
9572
|
-
ls: "api-reference",
|
|
9573
|
-
cat: "getting-started",
|
|
9751
|
+
ls: "editor/api-reference",
|
|
9752
|
+
cat: "editor/getting-started",
|
|
9574
9753
|
find: "dynamic fields",
|
|
9575
9754
|
grep: "resolveData"
|
|
9576
9755
|
}[sub]}\`.`
|
|
@@ -9667,7 +9846,7 @@ var runFrameworks = async (_rc, positionals) => {
|
|
|
9667
9846
|
};
|
|
9668
9847
|
|
|
9669
9848
|
// src/commands/pages.ts
|
|
9670
|
-
import
|
|
9849
|
+
import path32 from "path";
|
|
9671
9850
|
var USAGE = `Usage: \`${CANONICAL_INVOCATION} pages import <file.json>\`.`;
|
|
9672
9851
|
var runPages = async (rc, positionals) => {
|
|
9673
9852
|
const [sub, ...rest] = positionals;
|
|
@@ -9705,7 +9884,7 @@ var runPagesImport = async (rc, arg) => {
|
|
|
9705
9884
|
const { deps, flags } = rc;
|
|
9706
9885
|
const base = baseDir(rc);
|
|
9707
9886
|
const vfs = new Vfs();
|
|
9708
|
-
const file =
|
|
9887
|
+
const file = path32.resolve(base, arg);
|
|
9709
9888
|
const shown = displayPath(base, file);
|
|
9710
9889
|
const pages = readPages(vfs, file, shown);
|
|
9711
9890
|
const routes = Object.keys(pages);
|
|
@@ -9815,11 +9994,11 @@ import { randomUUID } from "crypto";
|
|
|
9815
9994
|
|
|
9816
9995
|
// src/telemetry/config.ts
|
|
9817
9996
|
import fs6 from "fs";
|
|
9818
|
-
import
|
|
9997
|
+
import path33 from "path";
|
|
9819
9998
|
var TelemetryConfigStore = class {
|
|
9820
9999
|
#file;
|
|
9821
10000
|
constructor(configDir) {
|
|
9822
|
-
this.#file =
|
|
10001
|
+
this.#file = path33.join(configDir, "puck", "telemetry.json");
|
|
9823
10002
|
}
|
|
9824
10003
|
get path() {
|
|
9825
10004
|
return this.#file;
|
|
@@ -9834,13 +10013,13 @@ var TelemetryConfigStore = class {
|
|
|
9834
10013
|
}
|
|
9835
10014
|
/** Throws if the config directory isn't writable */
|
|
9836
10015
|
save(config) {
|
|
9837
|
-
fs6.mkdirSync(
|
|
10016
|
+
fs6.mkdirSync(path33.dirname(this.#file), { recursive: true, mode: 448 });
|
|
9838
10017
|
fs6.writeFileSync(this.#file, JSON.stringify(config, null, 2) + "\n", {
|
|
9839
10018
|
mode: 384
|
|
9840
10019
|
});
|
|
9841
10020
|
}
|
|
9842
10021
|
};
|
|
9843
|
-
var configDirFor = (env2, homedir) => env2.XDG_CONFIG_HOME ||
|
|
10022
|
+
var configDirFor = (env2, homedir) => env2.XDG_CONFIG_HOME || path33.join(homedir, ".config");
|
|
9844
10023
|
|
|
9845
10024
|
// src/telemetry/consent.ts
|
|
9846
10025
|
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
@@ -9936,6 +10115,7 @@ var AGENTS = [
|
|
|
9936
10115
|
var detectAgent = (env2) => AGENTS.find(([key]) => env2[key] !== void 0 && env2[key] !== "")?.[1] ?? null;
|
|
9937
10116
|
var id = (value) => value && /^[A-Za-z0-9._@:-]{1,64}$/.test(value) ? value : null;
|
|
9938
10117
|
var ids = (values) => values.map(id).filter((v) => v !== null);
|
|
10118
|
+
var word = (value) => typeof value === "string" && /^[a-z][a-z0-9-]{0,31}$/.test(value) ? value : null;
|
|
9939
10119
|
var major = (version) => {
|
|
9940
10120
|
const match = version?.match(/\d+/);
|
|
9941
10121
|
return match ? Number(match[0]) : null;
|
|
@@ -9950,6 +10130,7 @@ var buildEvent = (input) => {
|
|
|
9950
10130
|
capabilities: input.command === "add" ? CAPABILITY_IDS.filter((c) => input.positionals.includes(c)) : [],
|
|
9951
10131
|
status: result.status,
|
|
9952
10132
|
errorCode: id(result.error?.code),
|
|
10133
|
+
unknownCommand: result.error?.code === "PUCK-CLI-UNKNOWN-COMMAND" ? word(result.error.details?.command) : null,
|
|
9953
10134
|
exitCode: input.exitCode,
|
|
9954
10135
|
durationMs: Math.max(0, Math.round(input.durationMs)),
|
|
9955
10136
|
dryRun: Boolean(flags.dryRun),
|
|
@@ -10137,6 +10318,10 @@ var runCli = async (argv, deps) => {
|
|
|
10137
10318
|
// src/io/runner.ts
|
|
10138
10319
|
import { spawn } from "child_process";
|
|
10139
10320
|
var MAX_CAPTURE = 64 * 1024;
|
|
10321
|
+
var CMD_SPECIAL = /[\s^&|<>()]/;
|
|
10322
|
+
var quoteForShell = (args, platform) => platform === "win32" ? args.map(
|
|
10323
|
+
(arg) => CMD_SPECIAL.test(arg) && !arg.includes('"') ? `"${arg}"` : arg
|
|
10324
|
+
) : args;
|
|
10140
10325
|
var append = (current, chunk) => {
|
|
10141
10326
|
const next = current + chunk.toString("utf8");
|
|
10142
10327
|
return next.length > MAX_CAPTURE ? next.slice(-MAX_CAPTURE) : next;
|
|
@@ -10146,7 +10331,7 @@ var createRunner = (baseEnv) => ({
|
|
|
10146
10331
|
return new Promise((resolve) => {
|
|
10147
10332
|
let stdout = "";
|
|
10148
10333
|
let stderr = "";
|
|
10149
|
-
const child = spawn(command, args, {
|
|
10334
|
+
const child = spawn(command, quoteForShell(args, process.platform), {
|
|
10150
10335
|
cwd,
|
|
10151
10336
|
stdio: ["ignore", "pipe", "pipe"],
|
|
10152
10337
|
// Package managers ship as .cmd shims on Windows
|
|
@@ -10222,7 +10407,7 @@ var runDevServer = (spec, onReady) => new Promise((resolve) => {
|
|
|
10222
10407
|
|
|
10223
10408
|
// src/docs/source.ts
|
|
10224
10409
|
import fs7 from "fs";
|
|
10225
|
-
import
|
|
10410
|
+
import path34 from "path";
|
|
10226
10411
|
var DirDocsSource = class {
|
|
10227
10412
|
#dir;
|
|
10228
10413
|
constructor(dir) {
|
|
@@ -10230,21 +10415,21 @@ var DirDocsSource = class {
|
|
|
10230
10415
|
}
|
|
10231
10416
|
list() {
|
|
10232
10417
|
return JSON.parse(
|
|
10233
|
-
fs7.readFileSync(
|
|
10418
|
+
fs7.readFileSync(path34.join(this.#dir, "index.json"), "utf8")
|
|
10234
10419
|
);
|
|
10235
10420
|
}
|
|
10236
10421
|
read(page) {
|
|
10237
|
-
return fs7.readFileSync(
|
|
10422
|
+
return fs7.readFileSync(path34.join(this.#dir, `${page}.md`), "utf8");
|
|
10238
10423
|
}
|
|
10239
10424
|
};
|
|
10240
10425
|
|
|
10241
10426
|
// src/bin.ts
|
|
10242
|
-
var distDir =
|
|
10243
|
-
var templatesDir =
|
|
10427
|
+
var distDir = path35.dirname(fileURLToPath(import.meta.url));
|
|
10428
|
+
var templatesDir = path35.join(distDir, "templates");
|
|
10244
10429
|
var templates = new DirTemplateSource(templatesDir, {
|
|
10245
10430
|
gitignoreName: "_gitignore",
|
|
10246
10431
|
manifest: () => JSON.parse(
|
|
10247
|
-
fs8.readFileSync(
|
|
10432
|
+
fs8.readFileSync(path35.join(templatesDir, "manifest.json"), "utf8")
|
|
10248
10433
|
)
|
|
10249
10434
|
});
|
|
10250
10435
|
var env = { ...process.env };
|
|
@@ -10254,14 +10439,19 @@ runCli(process.argv.slice(2), {
|
|
|
10254
10439
|
stdout: process.stdout,
|
|
10255
10440
|
stderr: process.stderr,
|
|
10256
10441
|
stdinIsTTY: Boolean(process.stdin.isTTY),
|
|
10257
|
-
cliVersion: "0.
|
|
10442
|
+
cliVersion: "0.25.0-canary.a9fe1d00",
|
|
10443
|
+
invocation: localInvocation(
|
|
10444
|
+
fs8.realpathSync(fileURLToPath(import.meta.url)),
|
|
10445
|
+
fs8.realpathSync(process.cwd()),
|
|
10446
|
+
env
|
|
10447
|
+
),
|
|
10258
10448
|
runner: createRunner(env),
|
|
10259
10449
|
fetch: globalThis.fetch,
|
|
10260
10450
|
openUrl,
|
|
10261
10451
|
runDevServer,
|
|
10262
10452
|
createPrompter: () => createInquirerPrompter(process.stderr),
|
|
10263
10453
|
templates,
|
|
10264
|
-
docs: new DirDocsSource(
|
|
10454
|
+
docs: new DirDocsSource(path35.join(distDir, "docs")),
|
|
10265
10455
|
homedir: os.homedir(),
|
|
10266
10456
|
hostname: os.hostname(),
|
|
10267
10457
|
platform: process.platform,
|