@dexhq/canvas 0.13.0 → 0.15.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/CHANGELOG.md +53 -0
- package/README.md +21 -18
- package/app/canvas/activity.tsx +8 -15
- package/app/canvas/anchoring.ts +3 -5
- package/app/canvas/canvas-input.ts +151 -14
- package/app/canvas/canvas-keys.ts +9 -0
- package/app/canvas/canvas-model.ts +5 -42
- package/app/canvas/canvas-panels.ts +1 -17
- package/app/canvas/canvas-scene.ts +7 -3
- package/app/canvas/canvas-ui.ts +2 -1
- package/app/canvas/canvas.css +61 -26
- package/app/canvas/change-notice.tsx +10 -1
- package/app/canvas/comment-layer.tsx +2 -1
- package/app/canvas/comments.tsx +204 -82
- package/app/canvas/element-picker.ts +200 -27
- package/app/canvas/engine/canvas-gestures.ts +72 -17
- package/app/canvas/engine/canvas-store.ts +17 -1
- package/app/canvas/engine/engine.css +6 -3
- package/app/canvas/find-bar.tsx +817 -0
- package/app/canvas/find-model.ts +135 -0
- package/app/canvas/flow-canvas.tsx +18 -2
- package/app/canvas/follow-pin.ts +26 -6
- package/app/canvas/frame-node.tsx +43 -26
- package/app/canvas/imported-reviews.tsx +12 -22
- package/app/canvas/layout.ts +27 -0
- package/app/canvas/live-page.ts +142 -19
- package/app/canvas/page-find.ts +220 -0
- package/app/canvas/page-style.ts +23 -0
- package/app/canvas/section-node.tsx +2 -0
- package/app/canvas/spec-threads.ts +24 -23
- package/app/canvas/thread-focus.tsx +14 -12
- package/app/canvas/tool-cursors.ts +16 -16
- package/app/canvas/use-activity.ts +0 -8
- package/app/canvas/use-agent-changes.tsx +34 -40
- package/app/canvas/use-canvas-clipboard.tsx +11 -14
- package/app/canvas/xray.ts +3 -12
- package/app/frame.tsx +5 -0
- package/app/i18n/locales/en/messages.po +114 -12
- package/app/i18n/locales/en/messages.ts +1 -1
- package/app/i18n/locales/pseudo/messages.po +114 -12
- package/app/i18n/locales/pseudo/messages.ts +1 -1
- package/app/icons/{sets/lucide.tsx → glyphs.tsx} +7 -5
- package/app/icons/index.tsx +3 -3
- package/app/icons/types.ts +3 -10
- package/app/index.html +3 -3
- package/app/main.tsx +3 -0
- package/app/pages/canvas-settings.tsx +35 -0
- package/app/pages/canvas.tsx +27 -8
- package/app/pages/commands-settings.tsx +16 -2
- package/app/shell/about.tsx +5 -4
- package/app/shell/feedback-details.ts +0 -3
- package/app/shell/feedback-form.tsx +10 -21
- package/app/shell/feedback-link.tsx +2 -1
- package/app/shell/instructions-editor.tsx +1 -1
- package/app/shell/presence-style.ts +59 -0
- package/app/shell/presence.tsx +6 -3
- package/app/shell/scaled-frame.tsx +21 -9
- package/app/shell/settings-sections.ts +12 -0
- package/app/shell/sidebar.tsx +1 -1
- package/app/studio-ui.d.ts +0 -9
- package/app/types.ts +21 -205
- package/app/ui/file-drop.ts +128 -0
- package/app/ui/prompt-editor.tsx +1 -1
- package/app/ui/shadcn/input-group.tsx +2 -2
- package/dist/cli/banner.d.mts +4 -2
- package/dist/cli/banner.mjs +34 -11
- package/dist/cli/commands/app.mjs +19 -11
- package/dist/cli/commands/create.d.mts +26 -14
- package/dist/cli/commands/create.mjs +13 -7
- package/dist/cli/commands/dev.mjs +2 -3
- package/dist/cli/commands/hook.mjs +2 -1
- package/dist/cli/commands/init.d.mts +11 -6
- package/dist/cli/help.d.mts +1 -1
- package/dist/cli/help.mjs +3 -3
- package/dist/cli/main.d.mts +22 -12
- package/dist/config/index.d.mts +6 -5
- package/dist/config/project-files.d.mts +6 -3
- package/dist/config/project-files.mjs +14 -5
- package/dist/config/renamed.d.mts +0 -2
- package/dist/config/renamed.mjs +1 -3
- package/dist/config/schema.d.mts +0 -5
- package/dist/config/schema.mjs +0 -5
- package/dist/content/capture.d.mts +2 -2
- package/dist/content/capture.mjs +2 -2
- package/dist/content/content.d.mts +3 -141
- package/dist/content/content.mjs +7 -65
- package/dist/content/flow-specs.mjs +1 -1
- package/dist/content/prototype-summary.d.mts +3 -39
- package/dist/content/prototype-summary.mjs +2 -3
- package/dist/content/prototypes.mjs +1 -1
- package/dist/content/snapshot-client.mjs +1 -1
- package/dist/content/text-replace.d.mts +30 -0
- package/dist/content/text-replace.mjs +309 -0
- package/dist/content/thread-module.mjs +1 -1
- package/dist/content/threads.mjs +1 -1
- package/dist/paths.d.mts +0 -2
- package/dist/paths.mjs +1 -3
- package/dist/server/agent-env.d.mts +5 -1
- package/dist/server/agent-env.mjs +7 -2
- package/dist/server/agent-session.d.mts +14 -1
- package/dist/server/agent-session.mjs +84 -19
- package/dist/server/brief.mjs +3 -3
- package/dist/server/build-pictures.mjs +1 -1
- package/dist/server/channel.d.mts +19 -24
- package/dist/server/channel.mjs +70 -37
- package/dist/server/claimed-presence.d.mts +18 -0
- package/dist/server/claimed-presence.mjs +58 -0
- package/dist/server/close-check.mjs +2 -2
- package/dist/server/comments/actions.d.mts +153 -0
- package/dist/server/comments/actions.mjs +154 -0
- package/dist/server/comments/routes.d.mts +25 -0
- package/dist/server/comments/routes.mjs +88 -0
- package/dist/server/comments/tools.d.mts +6 -0
- package/dist/server/comments/tools.mjs +154 -0
- package/dist/server/dev-server.mjs +36 -13
- package/dist/server/file-errors.d.mts +7 -2
- package/dist/server/file-errors.mjs +31 -8
- package/dist/server/file-lock.d.mts +2 -2
- package/dist/server/file-lock.mjs +130 -36
- package/dist/server/mcp.d.mts +0 -2
- package/dist/server/mcp.mjs +7 -8
- package/dist/server/me.d.mts +1 -1
- package/dist/server/open-page.d.mts +22 -0
- package/dist/server/open-page.mjs +20 -2
- package/dist/server/outcome.d.mts +22 -0
- package/dist/server/outcome.mjs +8 -0
- package/dist/server/own-copies.mjs +2 -2
- package/dist/server/people.d.mts +1 -1
- package/dist/server/port.d.mts +12 -0
- package/dist/server/port.mjs +66 -14
- package/dist/server/presence.d.mts +4 -1
- package/dist/server/presence.mjs +2 -2
- package/dist/server/requests.d.mts +5 -1
- package/dist/server/requests.mjs +32 -47
- package/dist/server/studio-for.d.mts +5 -0
- package/dist/server/studio-for.mjs +18 -4
- package/dist/server/sync-install.d.mts +8 -12
- package/dist/server/sync-install.mjs +12 -30
- package/dist/server/thread-source.mjs +2 -2
- package/dist/server/tools/describe.d.mts +1 -1
- package/dist/server/tools/describe.mjs +1 -1
- package/dist/server/tools/feedback.d.mts +1 -1
- package/dist/server/tools/reading.mjs +13 -4
- package/dist/server/tools/show.d.mts +1 -1
- package/dist/server/tools/snapshot.d.mts +1 -1
- package/dist/server/tools/thread-list.mjs +1 -1
- package/dist/server/tools/watch.mjs +5 -3
- package/dist/server/vite.mjs +28 -31
- package/dist/server/web-app.mjs +7 -10
- package/dist/server/work-groups.mjs +1 -1
- package/dist/setup/apply.mjs +8 -14
- package/dist/setup/create.d.mts +4 -2
- package/dist/setup/create.mjs +118 -36
- package/dist/setup/design-system-checks.mjs +3 -12
- package/dist/setup/desktop-app-script.mjs +4 -3
- package/dist/setup/desktop-app-start.d.mts +8 -2
- package/dist/setup/desktop-app-start.mjs +64 -29
- package/dist/setup/desktop-app.d.mts +8 -0
- package/dist/setup/desktop-app.mjs +20 -4
- package/dist/setup/detect.d.mts +14 -7
- package/dist/setup/detect.mjs +56 -10
- package/dist/setup/doctor.mjs +2 -4
- package/dist/setup/existing-setup.d.mts +1 -3
- package/dist/setup/existing-setup.mjs +10 -11
- package/dist/setup/migrate/row-titles.mjs +1 -1
- package/dist/setup/own-app.d.mts +1 -2
- package/dist/setup/own-app.mjs +4 -5
- package/dist/setup/plan.d.mts +8 -6
- package/dist/setup/plan.mjs +64 -48
- package/dist/setup/project.d.mts +6 -17
- package/dist/setup/project.mjs +17 -61
- package/dist/setup/prompts.d.mts +5 -5
- package/dist/setup/prompts.mjs +28 -61
- package/dist/setup/questions.d.mts +12 -4
- package/dist/setup/questions.mjs +10 -25
- package/dist/setup/starters.d.mts +2 -0
- package/dist/setup/starters.mjs +26 -9
- package/dist/setup/workspace-setup.d.mts +1 -2
- package/dist/setup/workspace-setup.mjs +4 -6
- package/dist/setup/write.d.mts +15 -5
- package/dist/setup/write.mjs +35 -9
- package/dist/shared/annotations-core.mjs +1 -1
- package/dist/shared/canvas-core.mjs +1 -1
- package/dist/shared/canvas-file.d.mts +201 -0
- package/dist/shared/canvas-file.mjs +1 -0
- package/dist/shared/comments/routes.d.mts +53 -0
- package/dist/shared/comments/routes.mjs +37 -0
- package/dist/shared/feedback.d.mts +8 -0
- package/dist/shared/feedback.mjs +10 -2
- package/dist/shared/page-review.d.mts +2 -11
- package/dist/shared/page-review.mjs +4 -13
- package/dist/shared/presence-core.d.mts +11 -0
- package/dist/shared/presence-core.mjs +11 -2
- package/dist/shared/review-file.d.mts +5 -0
- package/dist/shared/review-file.mjs +23 -13
- package/dist/shared/server-page.mjs +7 -1
- package/dist/shared/signup.d.mts +2 -5
- package/dist/shared/signup.mjs +2 -35
- package/dist/shared/studio-events.d.mts +0 -6
- package/dist/shared/studio-events.mjs +1 -5
- package/dist/shared/studio-files.d.mts +12 -0
- package/dist/shared/studio-files.mjs +6 -1
- package/dist/shared/studio-routes.d.mts +16 -62
- package/dist/shared/studio-routes.mjs +1 -69
- package/dist/shared/threads-core.d.mts +2 -2
- package/dist/shared/threads-core.mjs +1 -1
- package/extension/dist/feedback.js +148 -138
- package/extension/dist/manifest.json +1 -1
- package/extension/dist/picker.js +146 -136
- package/package.json +3 -20
- package/src/cli/banner.ts +45 -11
- package/src/cli/commands/app.ts +23 -8
- package/src/cli/commands/create.ts +17 -9
- package/src/cli/commands/dev.ts +0 -3
- package/src/cli/commands/hook.ts +4 -1
- package/src/cli/help.ts +3 -3
- package/src/config/index.ts +6 -5
- package/src/config/project-files.ts +21 -11
- package/src/config/renamed.ts +0 -3
- package/src/config/schema.ts +0 -1
- package/src/content/capture.ts +6 -12
- package/src/content/content.ts +7 -244
- package/src/content/flow-specs.ts +2 -1
- package/src/content/prototype-summary.ts +4 -44
- package/src/content/review-pages.ts +2 -1
- package/src/content/snapshot-client.ts +1 -1
- package/src/content/text-replace.ts +449 -0
- package/src/paths.ts +0 -8
- package/src/server/agent-env.ts +12 -2
- package/src/server/agent-session.ts +124 -34
- package/src/server/brief.ts +8 -3
- package/src/server/channel.ts +121 -52
- package/src/server/claimed-presence.ts +93 -0
- package/src/server/comments/actions.ts +352 -0
- package/src/server/comments/routes.ts +176 -0
- package/src/server/comments/tools.ts +317 -0
- package/src/server/dev-server.ts +49 -15
- package/src/server/file-errors.ts +47 -13
- package/src/server/file-lock.ts +205 -54
- package/src/server/mcp.ts +13 -14
- package/src/server/me.ts +2 -5
- package/src/server/open-page.ts +54 -4
- package/src/server/outcome.ts +26 -0
- package/src/server/people.ts +2 -1
- package/src/server/port.ts +94 -20
- package/src/server/presence.ts +11 -3
- package/src/server/requests.ts +60 -70
- package/src/server/studio-for.ts +27 -3
- package/src/server/sync-install.ts +35 -26
- package/src/server/thread-place.ts +2 -4
- package/src/server/tools/reading.ts +16 -3
- package/src/server/tools/watch.ts +7 -7
- package/src/server/vite.ts +37 -40
- package/src/server/web-app.ts +14 -12
- package/src/setup/apply.ts +10 -16
- package/src/setup/create.ts +143 -37
- package/src/setup/design-system-checks.ts +7 -15
- package/src/setup/desktop-app-script.ts +4 -3
- package/src/setup/desktop-app-start.ts +94 -26
- package/src/setup/desktop-app.ts +24 -3
- package/src/setup/detect.ts +56 -14
- package/src/setup/doctor.ts +4 -4
- package/src/setup/existing-setup.ts +10 -12
- package/src/setup/own-app.ts +2 -5
- package/src/setup/plan.ts +93 -84
- package/src/setup/project.ts +25 -118
- package/src/setup/prompts.ts +44 -127
- package/src/setup/questions.ts +27 -29
- package/src/setup/starters.ts +35 -10
- package/src/setup/workspace-setup.ts +8 -18
- package/src/setup/write.ts +52 -9
- package/src/shared/canvas-file.ts +205 -0
- package/src/shared/comments/routes.ts +79 -0
- package/src/shared/feedback.ts +14 -4
- package/src/shared/page-review.ts +11 -16
- package/src/shared/presence-core.ts +16 -2
- package/src/shared/review-file.ts +28 -12
- package/src/shared/server-page.ts +11 -1
- package/src/shared/signup.ts +4 -28
- package/src/shared/studio-events.ts +0 -13
- package/src/shared/studio-files.ts +14 -0
- package/src/shared/studio-routes.ts +21 -64
- package/src/shared/threads-core.ts +2 -2
- package/templates/methods/review.md +2 -2
- package/templates/rules/canvas-frames.md +104 -0
- package/templates/rules/canvas.md +8 -142
- package/templates/rules/prototypes.md +1 -1
- package/templates/rules/snapshots.md +52 -0
- package/templates/starters/standalone/README.md +7 -7
- package/templates/starters/standalone/components.json +1 -1
- package/templates/starters/standalone/package.json +1 -2
- package/templates/starters/turborepo/README.md +6 -6
- package/templates/starters/turborepo/apps/web/components.json +1 -1
- package/templates/starters/turborepo/apps/web/package.json +1 -2
- package/templates/starters/turborepo/apps/web/src/app.tsx +4 -5
- package/templates/starters/turborepo/packages/ui/components.json +1 -1
- package/templates/starters/turborepo/packages/ui/package.json +1 -2
- package/templates/starters/vite/README.md +7 -6
- package/templates/starters/vite/components.json +1 -1
- package/templates/starters/vite/package.json +1 -2
- package/templates/starters/vite/src/app.tsx +3 -4
- package/templates/starters/vite/src/components/ui/accordion.tsx +71 -0
- package/templates/starters/vite/src/components/ui/attachment.tsx +1 -1
- package/templates/starters/vite/src/components/ui/badge.tsx +2 -2
- package/templates/starters/vite/src/components/ui/button.tsx +17 -12
- package/templates/starters/vite/src/components/ui/card.tsx +1 -1
- package/templates/starters/vite/src/components/ui/checkbox.tsx +28 -0
- package/templates/starters/vite/src/components/ui/dialog.tsx +5 -5
- package/templates/starters/vite/src/components/ui/dropdown-menu.tsx +17 -14
- package/templates/starters/vite/src/components/ui/field.tsx +3 -1
- package/templates/starters/vite/src/components/ui/input-group.tsx +5 -3
- package/templates/starters/vite/src/components/ui/input.tsx +1 -1
- package/templates/starters/vite/src/components/ui/label.tsx +2 -0
- package/templates/starters/vite/src/components/ui/native-select.tsx +3 -4
- package/templates/starters/vite/src/components/ui/popover.tsx +1 -1
- package/templates/starters/vite/src/components/ui/separator.tsx +2 -0
- package/templates/starters/vite/src/components/ui/spinner.tsx +3 -7
- package/templates/starters/vite/src/components/ui/switch.tsx +1 -1
- package/templates/starters/vite/src/components/ui/textarea.tsx +1 -1
- package/templates/starters/vite/src/components/ui/toggle.tsx +4 -2
- package/templates/starters/vite/src/index.css +533 -111
- package/app/icons/sets/hugeicons.tsx +0 -259
- package/app/icons/sets/phosphor.tsx +0 -251
- package/dist/server/icon-set.d.mts +0 -15
- package/dist/server/icon-set.mjs +0 -31
- package/dist/server/tools/close-reply.d.mts +0 -6
- package/dist/server/tools/close-reply.mjs +0 -138
- package/dist/server/tools/comment.d.mts +0 -6
- package/dist/server/tools/comment.mjs +0 -49
- package/dist/shared/icon-sets.d.mts +0 -9
- package/dist/shared/icon-sets.mjs +0 -21
- package/src/server/icon-set.ts +0 -56
- package/src/server/tools/close-reply.ts +0 -271
- package/src/server/tools/comment.ts +0 -96
- package/src/shared/icon-sets.ts +0 -23
- /package/app/public/{sudio-192.png → dex-192.png} +0 -0
- /package/app/public/{sudio-512.png → dex-512.png} +0 -0
- /package/app/public/{apple-touch-icon.png → dex-apple-touch-icon.png} +0 -0
- /package/app/public/{favicon-32.png → dex-icon-32.png} +0 -0
- /package/app/public/{favicon.svg → dex-icon.svg} +0 -0
- /package/app/public/{sudio-maskable-512.png → dex-maskable-512.png} +0 -0
package/src/setup/prompts.ts
CHANGED
|
@@ -14,11 +14,6 @@ import { isPath, providerModule } from "../config/design-system.ts";
|
|
|
14
14
|
import { dependenciesOf, packageFolder } from "../config/project-files.ts";
|
|
15
15
|
import { isDirectory, isFile } from "../paths.ts";
|
|
16
16
|
import { checkAgents } from "../server/agents.ts";
|
|
17
|
-
import {
|
|
18
|
-
ICON_SET_NAMES,
|
|
19
|
-
INTERFACE_ICONS,
|
|
20
|
-
type InterfaceIcons,
|
|
21
|
-
} from "../shared/icon-sets.ts";
|
|
22
17
|
import { STUDIO_FILES } from "../shared/studio-files.ts";
|
|
23
18
|
import type { FoundDesignMd } from "./design-md.ts";
|
|
24
19
|
import {
|
|
@@ -42,7 +37,6 @@ import {
|
|
|
42
37
|
type ComponentsChoice,
|
|
43
38
|
type ComponentsFinding,
|
|
44
39
|
componentsAt,
|
|
45
|
-
iconsFinding,
|
|
46
40
|
type PackageManagerChoice,
|
|
47
41
|
type PackageManagerName,
|
|
48
42
|
type ProjectFindings,
|
|
@@ -59,12 +53,16 @@ import {
|
|
|
59
53
|
QUESTION,
|
|
60
54
|
QUESTIONS,
|
|
61
55
|
type SetupDecisions,
|
|
56
|
+
type ShadcnInit,
|
|
57
|
+
shadcnInitFlags,
|
|
62
58
|
} from "./questions.ts";
|
|
63
59
|
|
|
64
60
|
/** Every flag of `dex create` that answers a question or sets a fact. */
|
|
65
61
|
export interface SetupFlags {
|
|
66
62
|
/** The agents to connect: "claude,codex", or "none". */
|
|
67
63
|
agent?: string;
|
|
64
|
+
/** shadcn's component library for `shadcn init`. Sets up shadcn. */
|
|
65
|
+
base?: string;
|
|
68
66
|
/** The components' folder, or "none". */
|
|
69
67
|
components?: string;
|
|
70
68
|
/** How DESIGN.md starts: "draft", "none", a file to link or import, or a URL. */
|
|
@@ -73,14 +71,14 @@ export interface SetupFlags {
|
|
|
73
71
|
dir?: string;
|
|
74
72
|
/** Say what it would do, and do nothing. */
|
|
75
73
|
dryRun?: boolean;
|
|
76
|
-
/** The icon set the interface draws with: "lucide", "phosphor" or "hugeicons". */
|
|
77
|
-
icons?: string;
|
|
78
74
|
/** How prototypes import the components, when it cannot be derived. */
|
|
79
75
|
import?: string;
|
|
80
76
|
json?: boolean;
|
|
81
77
|
/** The package manager, instead of the detected one. */
|
|
82
78
|
pm?: string;
|
|
83
|
-
/**
|
|
79
|
+
/** shadcn's preset for `shadcn init`: a name or a code. Sets up shadcn. */
|
|
80
|
+
preset?: string;
|
|
81
|
+
/** Build the studio's interface from the components: off unless true. */
|
|
84
82
|
primitives?: boolean;
|
|
85
83
|
/** The module that wraps every prototype view, or "none". */
|
|
86
84
|
provider?: string;
|
|
@@ -315,6 +313,25 @@ const decidedComponents = (
|
|
|
315
313
|
...(open ? { open } : {}),
|
|
316
314
|
});
|
|
317
315
|
|
|
316
|
+
/** The component libraries `shadcn init --base` takes. */
|
|
317
|
+
const SHADCN_BASES = ["base", "radix", "aria"];
|
|
318
|
+
const PRESET_RE = /^[\w-]+$/;
|
|
319
|
+
|
|
320
|
+
/** `--preset` and `--base`, checked: what `shadcn init` is given. */
|
|
321
|
+
function shadcnInit({ preset, base }: SetupFlags): ShadcnInit {
|
|
322
|
+
if (base !== undefined && !SHADCN_BASES.includes(base)) {
|
|
323
|
+
throw new Error(
|
|
324
|
+
`Unknown --base "${base}". Choose ${SHADCN_BASES.join(", ")}.`
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
if (preset !== undefined && !PRESET_RE.test(preset)) {
|
|
328
|
+
throw new Error(
|
|
329
|
+
`--preset takes a preset's name (nova) or its code from https://ui.shadcn.com/create (b2fA), not "${preset}".`
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
return { ...(preset ? { preset } : {}), ...(base ? { base } : {}) };
|
|
333
|
+
}
|
|
334
|
+
|
|
318
335
|
/** The components, from a flag, a question or what was found. */
|
|
319
336
|
async function decideComponents(
|
|
320
337
|
findings: ProjectFindings,
|
|
@@ -322,8 +339,11 @@ async function decideComponents(
|
|
|
322
339
|
ui: Reporter,
|
|
323
340
|
ask: boolean
|
|
324
341
|
): Promise<Decided<ComponentsDecision>> {
|
|
325
|
-
if (flags.shadcn) {
|
|
326
|
-
return decidedComponents(
|
|
342
|
+
if (flags.shadcn || flags.preset || flags.base) {
|
|
343
|
+
return decidedComponents(
|
|
344
|
+
{ kind: "shadcn", ...shadcnInit(flags) },
|
|
345
|
+
flags.shadcn ? "--shadcn" : shadcnInitFlags(shadcnInit(flags)).join(" ")
|
|
346
|
+
);
|
|
327
347
|
}
|
|
328
348
|
if (flags.components === "none") {
|
|
329
349
|
return decidedComponents({ kind: "none" }, "--components none");
|
|
@@ -575,15 +595,11 @@ async function decideStyles(
|
|
|
575
595
|
|
|
576
596
|
// --- Primitives ---------------------------------------------------------------
|
|
577
597
|
|
|
578
|
-
|
|
579
|
-
findings: ProjectFindings,
|
|
598
|
+
function decidePrimitives(
|
|
580
599
|
components: ComponentsDecision,
|
|
581
|
-
flags: SetupFlags
|
|
582
|
-
|
|
583
|
-
ask: boolean
|
|
584
|
-
): Promise<Decided<boolean>> {
|
|
600
|
+
flags: SetupFlags
|
|
601
|
+
): Decided<boolean> {
|
|
585
602
|
const choice = components.kind === "folder" ? components.choice : undefined;
|
|
586
|
-
const fits = Boolean(choice?.baseUi && choice.import);
|
|
587
603
|
const decided = (value: boolean, source: string, warning?: string) => ({
|
|
588
604
|
key: "primitives",
|
|
589
605
|
value,
|
|
@@ -592,105 +608,17 @@ async function decidePrimitives(
|
|
|
592
608
|
shown: value ? `yes, from ${choice?.import}` : "no, the studio's own",
|
|
593
609
|
...(warning ? { warning } : {}),
|
|
594
610
|
});
|
|
595
|
-
if (flags.primitives
|
|
596
|
-
return decided(false, "--
|
|
611
|
+
if (flags.primitives !== true) {
|
|
612
|
+
return decided(false, "Dex's own, unless --primitives");
|
|
597
613
|
}
|
|
598
|
-
if (
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
"--primitives needs components with an import path, so the studio keeps its own"
|
|
604
|
-
);
|
|
605
|
-
}
|
|
606
|
-
return decided(true, "--primitives");
|
|
607
|
-
}
|
|
608
|
-
if (!fits) {
|
|
609
|
-
return decided(false, findings.primitives.evidence);
|
|
610
|
-
}
|
|
611
|
-
if (!ask) {
|
|
612
|
-
return decided(true, `${findings.primitives.evidence}, so they fit`);
|
|
613
|
-
}
|
|
614
|
-
const yes = answered(
|
|
615
|
-
await ui.confirm(
|
|
616
|
-
[
|
|
617
|
-
`Build the studio's own buttons, menus and dialogs from ${choice?.import}?`,
|
|
618
|
-
" Your components use shadcn's Base UI API, so they fit.",
|
|
619
|
-
` (${QUESTION.primitives.flag})`,
|
|
620
|
-
].join("\n")
|
|
621
|
-
)
|
|
622
|
-
);
|
|
623
|
-
return decided(yes, ANSWERED);
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
// --- Icon set -------------------------------------------------------------------
|
|
627
|
-
|
|
628
|
-
export function iconSet(flag: string): InterfaceIcons {
|
|
629
|
-
const set = INTERFACE_ICONS.find((each) => each === flag.trim());
|
|
630
|
-
if (!set) {
|
|
631
|
-
throw new Error(
|
|
632
|
-
`Unknown icon set "${flag}". Choose ${INTERFACE_ICONS.join(", ")}.`
|
|
614
|
+
if (!choice?.import) {
|
|
615
|
+
return decided(
|
|
616
|
+
false,
|
|
617
|
+
"--primitives",
|
|
618
|
+
"--primitives needs components with an import path, so the studio keeps its own"
|
|
633
619
|
);
|
|
634
620
|
}
|
|
635
|
-
return
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
/** Components chosen instead of those found bring their own. */
|
|
639
|
-
async function decideIcons(
|
|
640
|
-
findings: ProjectFindings,
|
|
641
|
-
components: ComponentsDecision,
|
|
642
|
-
flags: SetupFlags,
|
|
643
|
-
ui: Reporter,
|
|
644
|
-
ask: boolean
|
|
645
|
-
): Promise<Decided<InterfaceIcons>> {
|
|
646
|
-
const decided = (value: InterfaceIcons, source: string) => ({
|
|
647
|
-
key: "icons",
|
|
648
|
-
value,
|
|
649
|
-
source,
|
|
650
|
-
flag: QUESTION.icons.flag,
|
|
651
|
-
shown: ICON_SET_NAMES[value],
|
|
652
|
-
});
|
|
653
|
-
if (flags.icons !== undefined) {
|
|
654
|
-
return decided(iconSet(flags.icons), "--icons");
|
|
655
|
-
}
|
|
656
|
-
const choice = components.kind === "folder" ? components.choice : undefined;
|
|
657
|
-
const finding =
|
|
658
|
-
choice && choice.dir !== findings.components.value?.dir
|
|
659
|
-
? iconsFinding(findings.root, choice, "its components.json")
|
|
660
|
-
: findings.icons;
|
|
661
|
-
if (!ask) {
|
|
662
|
-
// More than one set installed: the one taken is a guess.
|
|
663
|
-
const others = finding.alternatives.map((set) => ICON_SET_NAMES[set]);
|
|
664
|
-
return finding.confidence === "guess"
|
|
665
|
-
? {
|
|
666
|
-
...decided(finding.value, finding.evidence),
|
|
667
|
-
warning: `${ICON_SET_NAMES[finding.value]}, though ${others.join(" and ")} ${others.length === 1 ? "is" : "are"} installed too: check it, or choose with --icons`,
|
|
668
|
-
open: {
|
|
669
|
-
candidates: [finding.value, ...finding.alternatives].map((set) => ({
|
|
670
|
-
value: set,
|
|
671
|
-
})),
|
|
672
|
-
safe: true,
|
|
673
|
-
},
|
|
674
|
-
}
|
|
675
|
-
: decided(finding.value, finding.evidence);
|
|
676
|
-
}
|
|
677
|
-
const answer = answered(
|
|
678
|
-
await ui.choose<InterfaceIcons>(
|
|
679
|
-
[
|
|
680
|
-
"Icon set: what Dex's interface draws its icons with",
|
|
681
|
-
` ${ICON_SET_NAMES[finding.value]} (${finding.evidence})`,
|
|
682
|
-
` (${QUESTION.icons.flag})`,
|
|
683
|
-
].join("\n"),
|
|
684
|
-
[
|
|
685
|
-
finding.value,
|
|
686
|
-
...INTERFACE_ICONS.filter((set) => set !== finding.value),
|
|
687
|
-
].map((set) => ({ value: set, label: ICON_SET_NAMES[set] }))
|
|
688
|
-
)
|
|
689
|
-
);
|
|
690
|
-
return decided(
|
|
691
|
-
answer,
|
|
692
|
-
answer === finding.value ? finding.evidence : ANSWERED
|
|
693
|
-
);
|
|
621
|
+
return decided(true, "--primitives");
|
|
694
622
|
}
|
|
695
623
|
|
|
696
624
|
// --- Provider -------------------------------------------------------------------
|
|
@@ -1225,23 +1153,13 @@ export async function decide(
|
|
|
1225
1153
|
): Promise<SetupDecisions> {
|
|
1226
1154
|
const dir = decideDir(flags);
|
|
1227
1155
|
const packageManager = decidePackageManager(findings, flags);
|
|
1228
|
-
// Unknown agents
|
|
1156
|
+
// Unknown agents stop setup before any question.
|
|
1229
1157
|
if (flags.agent !== undefined) {
|
|
1230
1158
|
parseAgents(flags.agent);
|
|
1231
1159
|
}
|
|
1232
|
-
if (flags.icons !== undefined) {
|
|
1233
|
-
iconSet(flags.icons);
|
|
1234
|
-
}
|
|
1235
1160
|
const components = await decideComponents(findings, flags, ui, ask);
|
|
1236
1161
|
const styles = await decideStyles(findings, components.value, flags, ui, ask);
|
|
1237
|
-
const primitives =
|
|
1238
|
-
findings,
|
|
1239
|
-
components.value,
|
|
1240
|
-
flags,
|
|
1241
|
-
ui,
|
|
1242
|
-
ask
|
|
1243
|
-
);
|
|
1244
|
-
const icons = await decideIcons(findings, components.value, flags, ui, ask);
|
|
1162
|
+
const primitives = decidePrimitives(components.value, flags);
|
|
1245
1163
|
const designMd = await decideDesignMd(
|
|
1246
1164
|
findings,
|
|
1247
1165
|
{ components: components.value, dir: dir.value, styles: styles.value },
|
|
@@ -1257,7 +1175,6 @@ export async function decide(
|
|
|
1257
1175
|
components,
|
|
1258
1176
|
styles,
|
|
1259
1177
|
primitives,
|
|
1260
|
-
icons,
|
|
1261
1178
|
...(provider ? { provider } : {}),
|
|
1262
1179
|
designMd,
|
|
1263
1180
|
agents,
|
package/src/setup/questions.ts
CHANGED
|
@@ -5,19 +5,33 @@
|
|
|
5
5
|
|
|
6
6
|
import { relative } from "node:path";
|
|
7
7
|
import { posix } from "../paths.ts";
|
|
8
|
-
import { ICON_SET_NAMES, type InterfaceIcons } from "../shared/icon-sets.ts";
|
|
9
8
|
import { type DesignMdDecision, fromProject } from "./design-md-setup.ts";
|
|
10
9
|
import type { Placement } from "./detect/workspace.ts";
|
|
11
10
|
import type { AgentId } from "./detect.ts";
|
|
12
11
|
import type { ComponentsChoice, PackageManagerChoice } from "./project.ts";
|
|
13
12
|
import type { ProviderNeed } from "./provider.ts";
|
|
14
13
|
|
|
14
|
+
/**
|
|
15
|
+
* How `shadcn init` sets the project up, as its own flags say it: a preset
|
|
16
|
+
* (a name, or a code from ui.shadcn.com/create) and the component library.
|
|
17
|
+
*/
|
|
18
|
+
export interface ShadcnInit {
|
|
19
|
+
base?: string;
|
|
20
|
+
preset?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
15
23
|
/** What to build prototypes with. */
|
|
16
24
|
export type ComponentsDecision =
|
|
17
25
|
| { kind: "folder"; choice: ComponentsChoice }
|
|
18
|
-
| { kind: "shadcn" }
|
|
26
|
+
| ({ kind: "shadcn" } & ShadcnInit)
|
|
19
27
|
| { kind: "none" };
|
|
20
28
|
|
|
29
|
+
/** `--preset` and `--base` as setup passes them on to `shadcn init`. */
|
|
30
|
+
export const shadcnInitFlags = ({ preset, base }: ShadcnInit): string[] => [
|
|
31
|
+
...(preset ? ["--preset", preset] : []),
|
|
32
|
+
...(base ? ["--base", base] : []),
|
|
33
|
+
];
|
|
34
|
+
|
|
21
35
|
/**
|
|
22
36
|
* What wraps every prototype view (`designSystem.provider`): a module of the
|
|
23
37
|
* project's (a path from where setup looked, or a package's module), the
|
|
@@ -66,7 +80,6 @@ export interface SetupDecisions {
|
|
|
66
80
|
components: Decided<ComponentsDecision>;
|
|
67
81
|
designMd: Decided<DesignMdDecision>;
|
|
68
82
|
dir: Decided<string>;
|
|
69
|
-
icons: Decided<InterfaceIcons>;
|
|
70
83
|
packageManager: Decided<PackageManagerChoice>;
|
|
71
84
|
primitives: Decided<boolean>;
|
|
72
85
|
/**
|
|
@@ -227,7 +240,11 @@ export const QUESTION: {
|
|
|
227
240
|
: decision.kind,
|
|
228
241
|
asFlags: (decision, { cwd }) => {
|
|
229
242
|
if (decision.kind === "shadcn") {
|
|
230
|
-
return [
|
|
243
|
+
return [
|
|
244
|
+
"--shadcn",
|
|
245
|
+
...(decision.preset ? [`--preset ${decision.preset}`] : []),
|
|
246
|
+
...(decision.base ? [`--base ${decision.base}`] : []),
|
|
247
|
+
];
|
|
231
248
|
}
|
|
232
249
|
if (decision.kind === "none") {
|
|
233
250
|
return ["--components none"];
|
|
@@ -259,31 +276,13 @@ export const QUESTION: {
|
|
|
259
276
|
primitives: {
|
|
260
277
|
key: "primitives",
|
|
261
278
|
label: "Primitives",
|
|
262
|
-
flag: "--primitives
|
|
279
|
+
flag: "--primitives",
|
|
263
280
|
asJson: (primitives) => primitives,
|
|
264
|
-
//
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
}
|
|
270
|
-
const { baseUi, import: specifier } = components.choice;
|
|
271
|
-
if (primitives) {
|
|
272
|
-
return specifier ? ["--primitives"] : [];
|
|
273
|
-
}
|
|
274
|
-
return baseUi ? ["--no-primitives"] : [];
|
|
275
|
-
},
|
|
276
|
-
},
|
|
277
|
-
icons: {
|
|
278
|
-
key: "icons",
|
|
279
|
-
label: "Icon set",
|
|
280
|
-
flag: "--icons lucide|phosphor|hugeicons",
|
|
281
|
-
asked: {
|
|
282
|
-
question: "Which icon set should Dex's interface draw with?",
|
|
283
|
-
choice: (icons) => ({ value: icons, label: ICON_SET_NAMES[icons] }),
|
|
284
|
-
},
|
|
285
|
-
asJson: (icons) => icons,
|
|
286
|
-
asFlags: (icons) => [`--icons ${icons}`],
|
|
281
|
+
// Off unless asked for: --primitives, for components with an import path.
|
|
282
|
+
asFlags: (primitives, { components }) =>
|
|
283
|
+
primitives && components.kind === "folder" && components.choice.import
|
|
284
|
+
? ["--primitives"]
|
|
285
|
+
: [],
|
|
287
286
|
},
|
|
288
287
|
provider: {
|
|
289
288
|
key: "provider",
|
|
@@ -353,7 +352,6 @@ export const QUESTIONS: readonly AnyQuestion[] = [
|
|
|
353
352
|
QUESTION.components,
|
|
354
353
|
QUESTION.styles,
|
|
355
354
|
QUESTION.primitives,
|
|
356
|
-
QUESTION.icons,
|
|
357
355
|
QUESTION.provider,
|
|
358
356
|
QUESTION.designMd,
|
|
359
357
|
QUESTION.agents,
|
package/src/setup/starters.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// The projects `dex create` starts in
|
|
1
|
+
// The projects `dex create` starts in a folder with no project (`--template`), as
|
|
2
2
|
// docs/planning/starters.md has them. Each is a folder in templates/starters,
|
|
3
3
|
// copied with the project's name, title and package manager filled in. The
|
|
4
4
|
// shadcn components are written once, in the vite starter; the others take
|
|
@@ -10,6 +10,7 @@ import { TEMPLATES_DIR } from "../paths.ts";
|
|
|
10
10
|
import type { Exec } from "./apply.ts";
|
|
11
11
|
import { type PackageManagerName, USER_AGENT_RE } from "./project.ts";
|
|
12
12
|
import { packageManagerName } from "./prompts.ts";
|
|
13
|
+
import { withEsbuildBuilds } from "./write.ts";
|
|
13
14
|
|
|
14
15
|
export const STARTERS_DIR = join(TEMPLATES_DIR, "starters");
|
|
15
16
|
|
|
@@ -68,7 +69,7 @@ export const STARTERS: Record<StarterName, Starter> = {
|
|
|
68
69
|
workspace: false,
|
|
69
70
|
shared: [],
|
|
70
71
|
next: [
|
|
71
|
-
{ script: "
|
|
72
|
+
{ script: "dex", what: "Dex, with a first file" },
|
|
72
73
|
{ script: "dev", what: "your app" },
|
|
73
74
|
],
|
|
74
75
|
},
|
|
@@ -80,7 +81,7 @@ export const STARTERS: Record<StarterName, Starter> = {
|
|
|
80
81
|
packageManager: "npm",
|
|
81
82
|
workspace: false,
|
|
82
83
|
shared: [COMPONENTS, LIB, STYLES],
|
|
83
|
-
next: [{ script: "
|
|
84
|
+
next: [{ script: "dex", what: "Dex, with a first file" }],
|
|
84
85
|
},
|
|
85
86
|
turborepo: {
|
|
86
87
|
name: "turborepo",
|
|
@@ -102,8 +103,8 @@ export const STARTERS: Record<StarterName, Starter> = {
|
|
|
102
103
|
{ from: "vite/src/index.css", to: "packages/ui/src/styles/globals.css" },
|
|
103
104
|
],
|
|
104
105
|
next: [
|
|
105
|
-
{ script: "
|
|
106
|
-
{ script: "dev", what: "every app: apps/web and
|
|
106
|
+
{ script: "dex", what: "Dex, with a first file" },
|
|
107
|
+
{ script: "dev", what: "every app: apps/web and Dex" },
|
|
107
108
|
],
|
|
108
109
|
},
|
|
109
110
|
};
|
|
@@ -179,6 +180,13 @@ export interface StarterValues {
|
|
|
179
180
|
// npm leaves .gitignore files out of packages, so the starters' are renamed.
|
|
180
181
|
const RENAMED: Record<string, string> = { gitignore: ".gitignore" };
|
|
181
182
|
|
|
183
|
+
/** What a starter writes at the project's root: "package.json", "src". */
|
|
184
|
+
export async function starterRootNames(starter: Starter): Promise<string[]> {
|
|
185
|
+
const own = await readdir(join(STARTERS_DIR, starter.name));
|
|
186
|
+
const shared = starter.shared.map(({ to }) => to.split("/")[0] ?? to);
|
|
187
|
+
return [...new Set([...own.map((name) => RENAMED[name] ?? name), ...shared])];
|
|
188
|
+
}
|
|
189
|
+
|
|
182
190
|
/** Copy a file or a folder, filling in the values and making the changes. */
|
|
183
191
|
async function copyTree(
|
|
184
192
|
from: string,
|
|
@@ -229,14 +237,29 @@ async function fitPackageManager(
|
|
|
229
237
|
manifest.workspaces = undefined;
|
|
230
238
|
}
|
|
231
239
|
await writeFile(file, `${JSON.stringify(manifest, null, 2)}\n`);
|
|
232
|
-
if (values.pm === "pnpm"
|
|
233
|
-
await
|
|
234
|
-
join(root, "pnpm-workspace.yaml"),
|
|
235
|
-
`packages:\n${workspaces.map((glob) => ` - "${glob}"`).join("\n")}\n`
|
|
236
|
-
);
|
|
240
|
+
if (values.pm === "pnpm") {
|
|
241
|
+
await writePnpmWorkspace(root, workspaces);
|
|
237
242
|
}
|
|
238
243
|
}
|
|
239
244
|
|
|
245
|
+
/**
|
|
246
|
+
* pnpm's settings file: the workspaces, in a workspace, and what to do with
|
|
247
|
+
* esbuild's install script. Vite brings esbuild, and pnpm 11 stops the
|
|
248
|
+
* install on a script nobody decided on (write.ts, withEsbuildBuilds).
|
|
249
|
+
*/
|
|
250
|
+
async function writePnpmWorkspace(
|
|
251
|
+
root: string,
|
|
252
|
+
workspaces: unknown
|
|
253
|
+
): Promise<void> {
|
|
254
|
+
const packages = Array.isArray(workspaces)
|
|
255
|
+
? `packages:\n${workspaces.map((glob) => ` - "${glob}"`).join("\n")}\n`
|
|
256
|
+
: "";
|
|
257
|
+
await writeFile(
|
|
258
|
+
join(root, "pnpm-workspace.yaml"),
|
|
259
|
+
withEsbuildBuilds(packages) ?? packages
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
|
|
240
263
|
/**
|
|
241
264
|
* Copy `starter` into `root`, which is empty: its own files, then the files
|
|
242
265
|
* it shares with another, with the name, title and package manager filled in.
|
|
@@ -268,5 +291,7 @@ export async function copyStarter(
|
|
|
268
291
|
}
|
|
269
292
|
if (starter.workspace) {
|
|
270
293
|
await fitPackageManager(root, values);
|
|
294
|
+
} else if (values.pm === "pnpm") {
|
|
295
|
+
await writePnpmWorkspace(root, undefined);
|
|
271
296
|
}
|
|
272
297
|
}
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
import { existsSync, readFileSync } from "node:fs";
|
|
9
9
|
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
10
|
-
import { pmCommand } from "../config/package-manager.ts";
|
|
11
10
|
import { PACKAGE_NAME, posix, studioVersion } from "../paths.ts";
|
|
12
11
|
import { designMdFinding } from "./design-md-setup.ts";
|
|
13
12
|
import {
|
|
@@ -22,8 +21,12 @@ import {
|
|
|
22
21
|
ownAppFacts,
|
|
23
22
|
rootStudioScript,
|
|
24
23
|
} from "./own-app.ts";
|
|
25
|
-
import
|
|
26
|
-
|
|
24
|
+
import {
|
|
25
|
+
installCommand,
|
|
26
|
+
type StudioTarget,
|
|
27
|
+
type WorkspaceSetup,
|
|
28
|
+
} from "./plan.ts";
|
|
29
|
+
import { findProject, type ProjectFindings } from "./project.ts";
|
|
27
30
|
import type { SetupFlags } from "./prompts.ts";
|
|
28
31
|
import type { SetupDecisions } from "./questions.ts";
|
|
29
32
|
|
|
@@ -124,14 +127,6 @@ export async function findingsFor(
|
|
|
124
127
|
evidence: `${library.folder} is a shared package`,
|
|
125
128
|
alternatives: candidates.filter((choice) => choice !== shared),
|
|
126
129
|
},
|
|
127
|
-
icons:
|
|
128
|
-
shared === value
|
|
129
|
-
? findings.icons
|
|
130
|
-
: iconsFinding(
|
|
131
|
-
findings.root,
|
|
132
|
-
shared,
|
|
133
|
-
`${library.folder}'s components.json`
|
|
134
|
-
),
|
|
135
130
|
designSystem: { ...findings.designSystem, name: library.name },
|
|
136
131
|
};
|
|
137
132
|
}
|
|
@@ -207,11 +202,7 @@ export function workspaceSetup(
|
|
|
207
202
|
placement: Placement,
|
|
208
203
|
findings: ProjectFindings,
|
|
209
204
|
decisions: SetupDecisions,
|
|
210
|
-
{
|
|
211
|
-
flags,
|
|
212
|
-
cwd,
|
|
213
|
-
iconPackages,
|
|
214
|
-
}: { flags: SetupFlags; cwd: string; iconPackages: Record<string, string> }
|
|
205
|
+
{ flags, cwd }: { flags: SetupFlags; cwd: string }
|
|
215
206
|
): WorkspaceSetup {
|
|
216
207
|
const manager = decisions.packageManager.value;
|
|
217
208
|
const studioSpec = studioSpecFor(findings, placement, flags, {
|
|
@@ -224,13 +215,12 @@ export function workspaceSetup(
|
|
|
224
215
|
? ownAppFacts(workspace, placement, {
|
|
225
216
|
componentsDir:
|
|
226
217
|
components.kind === "folder" ? components.choice.dir : undefined,
|
|
227
|
-
iconPackages,
|
|
228
218
|
studioSpec: studioSpec ?? versionSpec(),
|
|
229
219
|
})
|
|
230
220
|
: undefined;
|
|
231
221
|
return {
|
|
232
222
|
app,
|
|
233
|
-
install:
|
|
223
|
+
install: installCommand(manager.agent),
|
|
234
224
|
rootScripts: recordAt(readManifest(workspace.root), "scripts"),
|
|
235
225
|
studioScript: rootStudioScript(workspace, manager, placement),
|
|
236
226
|
studioSpec,
|
package/src/setup/write.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { isAbsolute, relative, resolve } from "node:path";
|
|
5
5
|
import { componentName } from "../config/design-system.ts";
|
|
6
|
-
import type { DesignSystemConfig
|
|
6
|
+
import type { DesignSystemConfig } from "../config/index.ts";
|
|
7
7
|
import { PACKAGE_NAME, posix } from "../paths.ts";
|
|
8
8
|
import { stateIgnoreLine } from "../server/state.ts";
|
|
9
9
|
import type { StylingApproach } from "../shared/design-system.ts";
|
|
@@ -101,20 +101,17 @@ export function designSystemConfig(
|
|
|
101
101
|
/**
|
|
102
102
|
* dex.config.ts for a new studio: the choices made, and nothing the
|
|
103
103
|
* project's files or the defaults say. `studio` is "studio", or "." for an
|
|
104
|
-
* app of its own.
|
|
105
|
-
* choice the team made, and what the install brought in.
|
|
104
|
+
* app of its own.
|
|
106
105
|
*/
|
|
107
106
|
export function configSource(
|
|
108
107
|
designSystem: DesignSystemConfig | undefined,
|
|
109
108
|
{
|
|
110
109
|
studio,
|
|
111
110
|
primitives,
|
|
112
|
-
icons,
|
|
113
111
|
next,
|
|
114
112
|
}: {
|
|
115
113
|
studio: string;
|
|
116
114
|
primitives: boolean;
|
|
117
|
-
icons: NonNullable<StudioInterface["icons"]>;
|
|
118
115
|
next?: boolean;
|
|
119
116
|
}
|
|
120
117
|
): string {
|
|
@@ -137,9 +134,9 @@ export default defineConfig({${content}});
|
|
|
137
134
|
designSystem: designSystem as unknown as ConfigValue | undefined,
|
|
138
135
|
plugins: next ? [{ code: "next()" }] : undefined,
|
|
139
136
|
},
|
|
140
|
-
// With primitives, the studio's interface uses the
|
|
141
|
-
// buttons, menus and dialogs rather than
|
|
142
|
-
|
|
137
|
+
// With primitives (--primitives), the studio's interface uses the
|
|
138
|
+
// project's own buttons, menus and dialogs rather than its own.
|
|
139
|
+
...(primitives ? { ui: { primitives: true } } : {}),
|
|
143
140
|
});
|
|
144
141
|
}
|
|
145
142
|
|
|
@@ -252,11 +249,12 @@ export const fromStudio = (content: string, file: string): string => {
|
|
|
252
249
|
* the project's own file changes by a dependency and a line.
|
|
253
250
|
*/
|
|
254
251
|
export const STUDIO_SCRIPTS: Record<string, string> = {
|
|
255
|
-
|
|
252
|
+
dex: "dex dev",
|
|
256
253
|
};
|
|
257
254
|
|
|
258
255
|
/** A later setup leaves these, as anything of the project's own: as Dex wrote them, or Sudio. */
|
|
259
256
|
export const OLD_SCRIPTS: Record<string, string[]> = {
|
|
257
|
+
studio: ["dex dev", "sudio dev"],
|
|
260
258
|
"studio:build": ["dex build", "sudio build"],
|
|
261
259
|
"studio:claude": ["dex claude", "sudio claude"],
|
|
262
260
|
};
|
|
@@ -309,6 +307,51 @@ export const withIgnoreLines = (
|
|
|
309
307
|
? gitignore
|
|
310
308
|
: `${gitignore.trimEnd() ? `${gitignore.trimEnd()}\n\n` : ""}# Dex\n${missing.join("\n")}\n`;
|
|
311
309
|
|
|
310
|
+
// --- pnpm's build scripts -----------------------------------------------------
|
|
311
|
+
//
|
|
312
|
+
// The studio's Vite brings esbuild, whose install script pnpm runs only when
|
|
313
|
+
// the project allows it. pnpm 11 stops the install on a script nobody
|
|
314
|
+
// decided on (ERR_PNPM_IGNORED_BUILDS), and then every later install too;
|
|
315
|
+
// pnpm 10 warned. esbuild runs without its script (it only checks the
|
|
316
|
+
// binary its platform package brings), so setup says so for the project:
|
|
317
|
+
// `allowBuilds: { esbuild: false }`, which pnpm 10 reads as well.
|
|
318
|
+
|
|
319
|
+
const ESBUILD_DECIDED_RE = /^\s*-?\s*["']?esbuild["']?\s*(:|$)/m;
|
|
320
|
+
const ALL_BUILDS_RE =
|
|
321
|
+
/^(dangerouslyAllowAllBuilds:\s*true|strictDepBuilds:\s*false)\s*$/m;
|
|
322
|
+
const ALLOW_BUILDS_RE = /^allowBuilds:[ \t]*\n((?:[ \t]+.*\n?)*)/m;
|
|
323
|
+
const ALLOW_BUILDS_KEY_RE = /^allowBuilds:/m;
|
|
324
|
+
const INDENT_RE = /^([ \t]+)\S/;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Whether pnpm-workspace.yaml settles esbuild's install script already:
|
|
328
|
+
* names it in any list or map (allowBuilds, onlyBuiltDependencies...), or
|
|
329
|
+
* allows every script.
|
|
330
|
+
*/
|
|
331
|
+
export const pnpmDecidesEsbuild = (yaml: string): boolean =>
|
|
332
|
+
ESBUILD_DECIDED_RE.test(yaml) || ALL_BUILDS_RE.test(yaml);
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* pnpm-workspace.yaml with `esbuild: false` under `allowBuilds`, keeping
|
|
336
|
+
* everything else; undefined when its `allowBuilds` is written some way
|
|
337
|
+
* this can't add to (`allowBuilds: {}`).
|
|
338
|
+
*/
|
|
339
|
+
export function withEsbuildBuilds(yaml: string): string | undefined {
|
|
340
|
+
const block = ALLOW_BUILDS_RE.exec(yaml);
|
|
341
|
+
if (block) {
|
|
342
|
+
const indent = INDENT_RE.exec(block[1] ?? "")?.[1] ?? " ";
|
|
343
|
+
const end = block.index + block[0].length;
|
|
344
|
+
const before = yaml.slice(0, end);
|
|
345
|
+
const line = `${indent}esbuild: false\n`;
|
|
346
|
+
return `${before}${before.endsWith("\n") ? "" : "\n"}${line}${yaml.slice(end)}`;
|
|
347
|
+
}
|
|
348
|
+
if (ALLOW_BUILDS_KEY_RE.test(yaml)) {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
const kept = yaml.trimEnd();
|
|
352
|
+
return `${kept ? `${kept}\n` : ""}allowBuilds:\n esbuild: false\n`;
|
|
353
|
+
}
|
|
354
|
+
|
|
312
355
|
/**
|
|
313
356
|
* The pointer setup adds to the root's AGENTS.md or CLAUDE.md, so an agent
|
|
314
357
|
* started at the root reads the studio's brief before studio work.
|