@stacksjs/defaults 0.75.621 → 0.75.622
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/ai/skills/stacks-buddy/SKILL.md +70 -7
- package/ai/skills/stacks-dashboard/SKILL.md +32 -2
- package/ai/skills/stacks-development/SKILL.md +3 -0
- package/ai/skills/stacks-native/CATALOG.md +12 -12
- package/ai/skills/stacks-utils/SKILL.md +8 -3
- package/functions/projects.test.ts +38 -0
- package/functions/projects.ts +99 -0
- package/ide/vscode/package.json +1 -1
- package/package.json +7 -7
- package/resources/components/Dashboard/ProjectSwitcher.stx +302 -0
- package/resources/functions/dashboard/project-switcher.test.ts +14 -0
- package/resources/functions/dashboard/project-switcher.ts +28 -0
- package/resources/plugins/preloader.ts +33 -2
- package/views/dashboard/layouts/default.stx +17 -0
|
@@ -15,6 +15,9 @@ The complete CLI runtime for the Stacks framework, lazy-loaded for fast cold sta
|
|
|
15
15
|
- CLI entry point: `storage/framework/core/buddy/src/cli.ts`
|
|
16
16
|
- Commands directory: `storage/framework/core/buddy/src/commands/`
|
|
17
17
|
- Lazy command registry: `storage/framework/core/buddy/src/lazy-commands.ts`
|
|
18
|
+
- Launcher (which project, whose CLI): `storage/framework/core/buddy/src/launcher.ts`
|
|
19
|
+
- Machine project list and service records: `storage/framework/core/path/src/projects.ts`
|
|
20
|
+
- Background daemon: `storage/framework/core/actions/src/daemon/`
|
|
18
21
|
- Config system: `storage/framework/core/buddy/src/config.ts`
|
|
19
22
|
- Shell entry: `buddy` (shell script at project root that invokes `bun run ./storage/framework/core/buddy/src/cli.ts`)
|
|
20
23
|
- Application commands: `app/Commands/` (auto-discovered; no registration step)
|
|
@@ -25,6 +28,65 @@ The complete CLI runtime for the Stacks framework, lazy-loaded for fast cold sta
|
|
|
25
28
|
`./buddy`, `bud`, and `stacks` invoke the Stacks CLI. The `stx` binary belongs
|
|
26
29
|
to the STX template engine; use it for template and native screen compilation.
|
|
27
30
|
|
|
31
|
+
## One buddy for every project
|
|
32
|
+
|
|
33
|
+
Buddy is installed once (`bun add -g @stacksjs/buddy`) and serves every Stacks
|
|
34
|
+
project on the machine. Each invocation first settles two things in
|
|
35
|
+
`launcher.ts`, before any command module loads:
|
|
36
|
+
|
|
37
|
+
1. **Which project.** `--project <name|path>` when given (`-p` too, on the
|
|
38
|
+
built-in commands that declare it as the project), otherwise the nearest
|
|
39
|
+
ancestor of the working directory that `isProjectRoot` accepts. So
|
|
40
|
+
`buddy migrate` works from `app/Models`, and `buddy migrate --project shop`
|
|
41
|
+
works from anywhere. A name that matches no project, or more than one, is
|
|
42
|
+
refused rather than guessed.
|
|
43
|
+
2. **Whose code runs it.** A project that has its own `buddy` installed gets
|
|
44
|
+
the command handed to it (the process is replaced, not wrapped), so it runs
|
|
45
|
+
on the framework version that project pins. A project with nothing
|
|
46
|
+
installed is run by the buddy that was invoked.
|
|
47
|
+
|
|
48
|
+
The process that does the work always starts in the project root, because Bun
|
|
49
|
+
reads `bunfig.toml` and its preloads from the directory it starts in.
|
|
50
|
+
|
|
51
|
+
Machine-level commands are never handed to a project and run from any
|
|
52
|
+
directory: `new`, `create`, `projects`, `projects:*`, `cd`, `daemon`,
|
|
53
|
+
`daemon:*`, `dashboard`.
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
buddy projects # the projects on this machine, most recently used first
|
|
57
|
+
-q/--quiet # paths only, one per line
|
|
58
|
+
--json # the list as JSON
|
|
59
|
+
buddy projects:add [path] # add a project (the current one by default)
|
|
60
|
+
buddy projects:remove <name> # take one off the list (alias: projects:forget)
|
|
61
|
+
buddy projects:scan [dir] # find projects on disk and add them
|
|
62
|
+
buddy projects:prune # drop listed projects whose directory is gone
|
|
63
|
+
buddy cd <name> # print a project's path (--eval for a shell function)
|
|
64
|
+
|
|
65
|
+
buddy dashboard [project] # open a project's dashboard, started in the background if needed
|
|
66
|
+
--no-open # print the address without opening a browser
|
|
67
|
+
--stop # stop that project's background dashboard
|
|
68
|
+
|
|
69
|
+
buddy daemon # is buddy running in the background, and what is it running
|
|
70
|
+
buddy daemon:start # start it (nothing requires this; it starts on demand)
|
|
71
|
+
buddy daemon:stop # stop it and the dashboards it started
|
|
72
|
+
buddy daemon:restart
|
|
73
|
+
buddy daemon:logs # --lines <count>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
A project joins the list (`~/.stacks/projects/<id>.json`, one file each) the
|
|
77
|
+
first time buddy runs inside it. Read the list with `listProjects()` and
|
|
78
|
+
`findProject()` from `@stacksjs/path`; do not walk the filesystem for
|
|
79
|
+
projects. `findStacksProjects()` in `@stacksjs/utils` is the disk scan behind
|
|
80
|
+
`projects:scan` and nothing else should need it.
|
|
81
|
+
|
|
82
|
+
The daemon (`core/actions/src/daemon/`) starts a project's dashboard through
|
|
83
|
+
that project's own `./buddy dev:dashboard`, on a port reserved for that project
|
|
84
|
+
(3900 upwards, the same one every time), with no native window and an idle
|
|
85
|
+
limit. It listens on a unix socket in `~/.stacks/buddy/`, loads no project
|
|
86
|
+
code, polls nothing, and exits once it has no dashboards left. Reach it through
|
|
87
|
+
`openProjectDashboard()` / `daemonStatus()` in `@stacksjs/actions/daemon/client`,
|
|
88
|
+
which start it when it is not running.
|
|
89
|
+
|
|
28
90
|
## Architecture
|
|
29
91
|
|
|
30
92
|
### Lazy Loading System
|
|
@@ -650,11 +712,10 @@ buddy search # search engine operations
|
|
|
650
712
|
buddy configure # configure project
|
|
651
713
|
buddy create # create new project
|
|
652
714
|
buddy completion [shell] # shell completion (bash/zsh/fish)
|
|
653
|
-
buddy ports #
|
|
654
|
-
-
|
|
655
|
-
|
|
656
|
-
buddy ports:
|
|
657
|
-
buddy ports:check # check ports across all Stacks projects
|
|
715
|
+
buddy ports # the ports this project's servers use
|
|
716
|
+
-c/--check # which of them are free and which are in use
|
|
717
|
+
buddy ports:list # same list
|
|
718
|
+
buddy ports:check # which of this project's ports are free or in use
|
|
658
719
|
buddy setup # ensure project is set up correctly (alias: ensure)
|
|
659
720
|
--skip-aws # skip AWS configuration
|
|
660
721
|
--skip-keygen # skip APP_KEY generation
|
|
@@ -680,7 +741,7 @@ buddy auth # auth commands
|
|
|
680
741
|
buddy queue # queue management
|
|
681
742
|
buddy schedule # schedule management
|
|
682
743
|
buddy package # package management
|
|
683
|
-
buddy projects # project
|
|
744
|
+
buddy projects # the Stacks projects on this machine (see "One buddy for every project")
|
|
684
745
|
buddy prepublish # pre-publish checks
|
|
685
746
|
buddy stacks # Stacks framework commands (registered as 'stack' in lazy-commands)
|
|
686
747
|
```
|
|
@@ -767,7 +828,9 @@ export default {
|
|
|
767
828
|
|
|
768
829
|
## Gotchas
|
|
769
830
|
- Application commands go in `app/Commands/`, framework commands in `storage/framework/core/buddy/src/commands/`
|
|
770
|
-
- The `buddy` file at root is a shell script that
|
|
831
|
+
- The `buddy` file at root is a shell script that picks a usable Bun and runs the project's CLI entry: vendored `storage/framework/core/buddy/src/cli.ts` first, then `@stacksjs/buddy` from `node_modules`, then from `pantry`. `projectCliEntry()` in `@stacksjs/path` looks in the same places in the same order, and `buddy/tests/launcher.test.ts` fails when the two disagree
|
|
832
|
+
- `--project` is read by the launcher, before the command runs, and only for built-in commands. An application command's own `--project` is passed through untouched. `build`, `make`, `preview`, `serve`, `serve:api` and `share` use `-p` for something else, so only the long form selects a project there
|
|
833
|
+
- `buddy dev:dashboard` becomes the dashboard server (the CLI process is replaced) instead of waiting beside it
|
|
771
834
|
- Commands are lazy-loaded with a 5-second timeout per command to prevent startup hangs
|
|
772
835
|
- The `list` command loads ALL commands to display them
|
|
773
836
|
- When no command matches, the CLI loads only `version` for minimal overhead
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: stacks-dashboard
|
|
3
|
-
description: Use when building or customizing the Stacks admin dashboard, including dashboard pages, model management views, analytics widgets, commerce dashboards, content management, settings panels, deployment monitoring, job/queue management, or the
|
|
3
|
+
description: Use when building or customizing the Stacks admin dashboard, including dashboard pages, model management views, analytics widgets, commerce dashboards, content management, settings panels, deployment monitoring, job/queue management, or the 445 built-in dashboard components. Covers the dashboard system at storage/framework/defaults/.
|
|
4
4
|
license: MIT
|
|
5
5
|
compatibility: Bun >= 1.3.0, TypeScript
|
|
6
6
|
allowed-tools: Read Edit Write Bash Grep Glob
|
|
@@ -8,7 +8,7 @@ allowed-tools: Read Edit Write Bash Grep Glob
|
|
|
8
8
|
|
|
9
9
|
# Stacks Dashboard
|
|
10
10
|
|
|
11
|
-
The Stacks admin dashboard provides a full-featured admin panel with 100+ route views,
|
|
11
|
+
The Stacks admin dashboard provides a full-featured admin panel with 100+ route views, 445 components, and a multi-section layout.
|
|
12
12
|
|
|
13
13
|
## Key Paths
|
|
14
14
|
- Dashboard components: `storage/framework/defaults/resources/components/Dashboard/`
|
|
@@ -714,6 +714,36 @@ form, a console, the search palette) with what they are.
|
|
|
714
714
|
- A hidden label becomes `ariaLabel`. A visible word beside the dropdown
|
|
715
715
|
("Sort") stays, with the dropdown inside its label at `size="sm"`.
|
|
716
716
|
|
|
717
|
+
### The project switcher
|
|
718
|
+
|
|
719
|
+
The top of the sidebar names the project being served and opens a menu of
|
|
720
|
+
every Stacks project on the machine (`resources/components/Dashboard/ProjectSwitcher.stx`,
|
|
721
|
+
placed in the layout's `#header` slot under the window-controls strip).
|
|
722
|
+
|
|
723
|
+
A dashboard process serves exactly one project: its config, database
|
|
724
|
+
connection, routes and model globals are bound when it starts. Switching
|
|
725
|
+
therefore goes to the other project's dashboard, at that project's own
|
|
726
|
+
address, and never re-points the running one. Do not try to make a dashboard
|
|
727
|
+
page read another project's data.
|
|
728
|
+
|
|
729
|
+
- The button is rendered on the server with the project's name
|
|
730
|
+
(`dashboardProjectIdentity()` in `resources/functions/dashboard/project-switcher.ts`),
|
|
731
|
+
so the sidebar does not shift on hydration. The list is fetched in the
|
|
732
|
+
browser when the menu opens, because the layout is rendered once and kept.
|
|
733
|
+
- The client lives in `functions/projects.ts` and talks to the dev dashboard
|
|
734
|
+
server's `/__buddy/` routes. Picking a project whose dashboard is up goes
|
|
735
|
+
straight there; otherwise the server asks the background daemon to start it
|
|
736
|
+
and answers with the address once it is ready.
|
|
737
|
+
- It is drawn only on the developer's machine. The dev dashboard server sets
|
|
738
|
+
`STACKS_DASHBOARD_PROJECTS=1`; a deployed dashboard has one project and no
|
|
739
|
+
switcher.
|
|
740
|
+
- Each project has its own origin (a port reserved for it, the same every
|
|
741
|
+
time), so appearance settings, the sign-in token and kept state are per
|
|
742
|
+
project by construction.
|
|
743
|
+
- The sidebar's header and its scroll area are stacked at the same level, so
|
|
744
|
+
the layout lifts the header (`:has([data-project-switcher][data-open="true"])`)
|
|
745
|
+
while the menu is open. A new header control with a menu needs the same.
|
|
746
|
+
|
|
717
747
|
### Sidebar-aware overlays
|
|
718
748
|
|
|
719
749
|
The desktop sidebar is fixed and publishes its current width through
|
|
@@ -158,6 +158,9 @@ Uses `bun-plugin-stx` serve function with pattern-based view resolution:
|
|
|
158
158
|
- Leaves `resources/functions` to the STX client auto-import pipeline because browser helpers may depend on signals and other browser-only primitives
|
|
159
159
|
- Opens a Craft `createApp()` window when a supported SDK and native binary are available (1400x900, titlebar hidden)
|
|
160
160
|
- Builds the web sidebar from configured sections and discovered model dashboard metadata
|
|
161
|
+
- Records itself in `storage/framework/runtime/services/dashboard.json` (pid, port, address) once it is up, which is how `buddy dashboard`, the background daemon and every other dashboard's project switcher know this project already has one. Read it with `readProjectService(root, 'dashboard')` from `@stacksjs/path`; a record whose process has died reads as null
|
|
162
|
+
- Serves the project switcher's routes under `/__buddy/` (`dev/dashboard-projects.ts`): the machine's project list, opening another project's dashboard through the daemon, adding a project. They stay out of `/api/` because an application may well have its own `/api/projects`
|
|
163
|
+
- With `STACKS_DASHBOARD_IDLE_EXIT_MS` set (the daemon sets it), exits after that long without a request. An open page reports in on a timer, so a dashboard someone is reading stays up
|
|
161
164
|
|
|
162
165
|
### Docs Dev Server (docs.ts)
|
|
163
166
|
- Uses `@stacksjs/bunpress` with `{ watch: true, quiet: true }`
|
|
@@ -11,7 +11,7 @@ Browser runtime bindings are documented separately in `stacks-auto-imports`.
|
|
|
11
11
|
| Package | Task guidance | Source entry | Retained tests |
|
|
12
12
|
|---|---|---|---|
|
|
13
13
|
| `@stacksjs/action-runner` | [`stacks-actions`](../stacks-actions/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/action-runner/src/index.ts) | 1 |
|
|
14
|
-
| `@stacksjs/actions` | [`stacks-actions`](../stacks-actions/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/index.ts) |
|
|
14
|
+
| `@stacksjs/actions` | [`stacks-actions`](../stacks-actions/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/index.ts) | 127 |
|
|
15
15
|
| `@stacksjs/ai` | [`stacks-ai`](../stacks-ai/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/index.ts) | 24 |
|
|
16
16
|
| `@stacksjs/alias` | [`stacks-alias`](../stacks-alias/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/alias/src/index.ts) | 3 |
|
|
17
17
|
| `@stacksjs/analytics` | [`stacks-analytics`](../stacks-analytics/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/analytics/src/index.ts) | 7 |
|
|
@@ -21,7 +21,7 @@ Browser runtime bindings are documented separately in `stacks-auto-imports`.
|
|
|
21
21
|
| `@stacksjs/auth` | [`stacks-auth`](../stacks-auth/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/auth/src/index.ts) | 136 |
|
|
22
22
|
| `@stacksjs/browser` | [`stacks-browser`](../stacks-browser/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/browser/src/index.ts) | 10 |
|
|
23
23
|
| `@stacksjs/browser-extension` | [`stacks-browser-extension`](../stacks-browser-extension/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/browser-extension/src/index.ts) | 9 |
|
|
24
|
-
| `@stacksjs/buddy` | [`stacks-buddy`](../stacks-buddy/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/buddy/src/index.ts) |
|
|
24
|
+
| `@stacksjs/buddy` | [`stacks-buddy`](../stacks-buddy/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/buddy/src/index.ts) | 213 |
|
|
25
25
|
| `@stacksjs/build` | [`stacks-build`](../stacks-build/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/build/src/index.ts) | 7 |
|
|
26
26
|
| `@stacksjs/cache` | [`stacks-cache`](../stacks-cache/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/cache/src/index.ts) | 24 |
|
|
27
27
|
| `@stacksjs/calendar-api` | [`stacks-calendar`](../stacks-calendar/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/calendar-api/src/index.ts) | 5 |
|
|
@@ -58,7 +58,7 @@ Browser runtime bindings are documented separately in `stacks-auto-imports`.
|
|
|
58
58
|
| `@stacksjs/hq` | [`stacks-hq`](../stacks-hq/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/hq/src/index.ts) | 11 |
|
|
59
59
|
| `@stacksjs/http` | [`stacks-http`](../stacks-http/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/http/src/index.ts) | 4 |
|
|
60
60
|
| `@stacksjs/i18n` | [`stacks-i18n`](../stacks-i18n/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/i18n/src/index.ts) | 7 |
|
|
61
|
-
| `@stacksjs/image` | [`stacks-image`](../stacks-image/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/image/src/index.ts) |
|
|
61
|
+
| `@stacksjs/image` | [`stacks-image`](../stacks-image/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/image/src/index.ts) | 5 |
|
|
62
62
|
| `@stacksjs/lint` | [`stacks-lint`](../stacks-lint/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/lint/src/index.ts) | 3 |
|
|
63
63
|
| `@stacksjs/logging` | [`stacks-logging`](../stacks-logging/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/logging/src/index.ts) | 14 |
|
|
64
64
|
| `@stacksjs/mobile` | [`stacks-mobile`](../stacks-mobile/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/mobile/src/index.ts) | 23 |
|
|
@@ -68,7 +68,7 @@ Browser runtime bindings are documented separately in `stacks-auto-imports`.
|
|
|
68
68
|
| `@stacksjs/objects` | [`stacks-objects`](../stacks-objects/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/objects/src/index.ts) | 10 |
|
|
69
69
|
| `@stacksjs/orm` | [`stacks-orm`](../stacks-orm/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/index.ts) | 79 |
|
|
70
70
|
| `@stacksjs/pagination` | [`stacks-pagination`](../stacks-pagination/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/pagination/src/index.ts) | 1 |
|
|
71
|
-
| `@stacksjs/path` | [`stacks-path`](../stacks-path/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/path/src/index.ts) |
|
|
71
|
+
| `@stacksjs/path` | [`stacks-path`](../stacks-path/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/path/src/index.ts) | 14 |
|
|
72
72
|
| `@stacksjs/payments` | [`stacks-payments`](../stacks-payments/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/payments/src/index.ts) | 40 |
|
|
73
73
|
| `@stacksjs/push` | [`stacks-push`](../stacks-push/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/push/src/index.ts) | 8 |
|
|
74
74
|
| `@stacksjs/query-builder` | [`stacks-query-builder`](../stacks-query-builder/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/query-builder/src/index.ts) | 7 |
|
|
@@ -91,7 +91,7 @@ Browser runtime bindings are documented separately in `stacks-auto-imports`.
|
|
|
91
91
|
| `@stacksjs/strings` | [`stacks-strings`](../stacks-strings/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/strings/src/index.ts) | 12 |
|
|
92
92
|
| `@stacksjs/support` | [`stacks-support`](../stacks-support/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/support/src/index.ts) | 6 |
|
|
93
93
|
| `@stacksjs/telephony` | [`stacks-telephony`](../stacks-telephony/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/telephony/src/index.ts) | 5 |
|
|
94
|
-
| `@stacksjs/testing` | [`stacks-testing`](../stacks-testing/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/src/index.ts) |
|
|
94
|
+
| `@stacksjs/testing` | [`stacks-testing`](../stacks-testing/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/src/index.ts) | 25 |
|
|
95
95
|
| `@stacksjs/tinker` | [`stacks-repl`](../stacks-repl/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/tinker/src/index.ts) | 4 |
|
|
96
96
|
| `@stacksjs/tunnel` | [`stacks-tunnel`](../stacks-tunnel/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/tunnel/src/index.ts) | 1 |
|
|
97
97
|
| `@stacksjs/types` | [`stacks-types`](../stacks-types/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/index.ts) | 3 |
|
|
@@ -122,7 +122,7 @@ Declared runtime exports: `BlogAdminError`, `DEFAULT_IOS_DEPENDENCIES`, `DEFAULT
|
|
|
122
122
|
|
|
123
123
|
Local source modules: [src/action.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/action.ts), [src/add.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/add.ts), [src/blog-admin.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/blog-admin.ts), [src/build/ios-toolchain.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/build/ios-toolchain.ts), [src/build/macos-native.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/build/macos-native.ts), [src/commit.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/commit.ts), [src/dev/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/dev/index.ts), [src/discover-packages.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/discover-packages.ts), [src/generate/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/generate/index.ts), [src/github-release.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/github-release.ts), [src/helpers/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/helpers/index.ts), [src/library/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/library/index.ts), [src/lint/lint.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/lint/lint.ts), [src/lint/stx-gate.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/lint/stx-gate.ts), [src/make-command.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/make-command.ts), [src/make-job.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/make-job.ts), [src/make-policy.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/make-policy.ts), [src/make-resource.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/make-resource.ts), [src/make.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/make.ts), [src/publication-preflight.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/publication-preflight.ts), [src/release-evidence.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/release-evidence.ts), [src/reviewos-evidence.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/reviewos-evidence.ts), [src/reviewos-workflows.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/reviewos-workflows.ts), [src/scaffold-crud.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/scaffold-crud.ts), [src/setup/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/setup/index.ts), [src/stacks.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/stacks.ts), [src/stx-source.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/stx-source.ts), [src/upgrade/package-project.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/upgrade/package-project.ts), [src/upgrade/route-actions.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/upgrade/route-actions.ts).
|
|
124
124
|
|
|
125
|
-
Evidence directory: [
|
|
125
|
+
Evidence directory: [127 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
|
|
126
126
|
|
|
127
127
|
### @stacksjs/ai
|
|
128
128
|
|
|
@@ -222,7 +222,7 @@ Read the entrypoint and package export map for re-exported or type-only surfaces
|
|
|
222
222
|
|
|
223
223
|
Local source modules: [src/commands/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/buddy/src/commands/index.ts).
|
|
224
224
|
|
|
225
|
-
Evidence directory: [
|
|
225
|
+
Evidence directory: [213 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/buddy/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
|
|
226
226
|
|
|
227
227
|
### @stacksjs/build
|
|
228
228
|
|
|
@@ -580,7 +580,7 @@ Declared runtime exports: `ImageBuilder`, `image`, `imageResponseHeaders`, `nego
|
|
|
580
580
|
|
|
581
581
|
Local source modules: [src/app-icons.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/image/src/app-icons.ts), [src/app-store.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/image/src/app-store.ts), [src/fonts.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/image/src/fonts.ts), [src/generate.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/image/src/generate.ts), [src/social.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/image/src/social.ts), [src/splash.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/image/src/splash.ts), [src/theme.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/image/src/theme.ts), [src/upload.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/image/src/upload.ts).
|
|
582
582
|
|
|
583
|
-
Evidence directory: [
|
|
583
|
+
Evidence directory: [5 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/image/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
|
|
584
584
|
|
|
585
585
|
### @stacksjs/lint
|
|
586
586
|
|
|
@@ -668,11 +668,11 @@ Evidence directory: [1 retained tests](https://github.com/stacksjs/stacks/blob/m
|
|
|
668
668
|
|
|
669
669
|
Guidance: [`stacks-path`](../stacks-path/SKILL.md). Source: [storage/framework/core/path/src/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/path/src/index.ts).
|
|
670
670
|
|
|
671
|
-
Declared runtime exports: `DEFAULTS_SYNC_MARKER`, `actionRunnerPath`, `actionsPath`, `aiPath`, `aliasPath`, `analyticsPath`, `appPath`, `applyRuntimeDirectoryEnv`, `arraysPath`, `assetsPath`, `authPath`, `basename`, `browserPath`, `buddyPath`, `buildEnginePath`, `buildPath`, `builtUserActionsPath`, `cachePath`, `chartsPath`, `chatPath`, `cliPath`, `cloudPath`, `cloudStatePath`, `collectionsPath`, `commandsPath`, `componentsPath`, `configPath`, `coreApiPath`, `coreEnvPath`, `corePath`, `coreStoragePath`, `customElementsDataPath`, `databasePath`, `datetimePath`, `defaultsAppPath`, `defaultsPackagePath`, `defaultsPath`, `defaultsResourcesPath`, `delimiter`, `desktopPath`, `developmentPath`, `dirname`, `dnsPath`, `docsPath`, `emailPath`, `ensureRuntimeDirectories`, `enumsPath`, `errorHandlingPath`, `eslintPluginPath`, `eventsPath`, `examplesPath`, `extname`, `fakerPath`, `featureFlagsPath`, `featuresPath`, `findProjectPath`, `frameworkCloudPath`, `frameworkDefaultsRoot`, `frameworkPath`, `frameworkRuntimePath`, `functionsPath`, `gitPath`, `healthPath`, `homeDir`, `inspectDefaultsProvenance`, `installedDefaultsVersion`, `isAbsolute`, `isCompiledBinary`, `isInstalledDefaultsRoot`, `jobsPath`, `join`, `langPath`, `layoutsPath`, `libraryPackagePath`, `libsEntriesPath`, `libsPath`, `linkPackagedDefaults`, `lintPath`, `listenersPath`, `loggingPath`, `logsPath`, `mergeDirectoryInto`, `modelMetaPath`, `modelsPath`, `modulesPath`, `newsletterPath`, `normalize`, `notificationsPath`, `objectsPath`, `onboardingPath`, `ormPath`, `packagedDefaultsRoot`, `paginationPath`, `path`, `pathPath`, `paymentsPath`, `projectConfigPath`, `projectPath`, `publicPath`, `pushPath`, `queryBuilderPath`, `queuePath`, `realtimePath`, `relative`, `relativeActionsPath`, `replPath`, `resolve`, `resolveModulePath`, `resolveUserLibBase`, `resourcesPath`, `routerPath`, `routesPath`, `runtimeDirectoryEnv`, `runtimePath`, `schedulerPath`, `scriptsPath`, `searchEnginePath`, `securityPath`, `sep`, `serverPath`, `serverlessPath`, `settingsPath`, `shellPath`, `siteConfigPath`, `skillsPath`, `slugPath`, `smsPath`, `socialsPath`, `stacksBackupPath`, `stacksLockPath`, `stacksPath`, `storagePath`, `storesPath`, `stringsPath`, `stxPath`, `testingPath`, `testsPath`, `tinkerPath`, `toNamespacedPath`, `typesPath`, `uiPath`, `userActionsPath`, `userComponentsPath`, `userControllersPath`, `userDatabasePath`, `userEmailsPath`, `userEventsPath`, `userFunctionsPath`, `userJobsPath`, `userLibsPath`, `userListenersPath`, `userMailPath`, `userMiddlewarePath`, `userMigrationsPath`, `userModelsPath`, `userNotificationsPath`, `userServerPath`, `userViewsPath`, `usesVendoredDefaults`, `utilsPath`, `validationPath`, `viewsPath`.
|
|
671
|
+
Declared runtime exports: `DEFAULTS_SYNC_MARKER`, `actionRunnerPath`, `actionsPath`, `aiPath`, `aliasPath`, `analyticsPath`, `appPath`, `applyRuntimeDirectoryEnv`, `arraysPath`, `assetsPath`, `authPath`, `basename`, `browserPath`, `buddyPath`, `buildEnginePath`, `buildPath`, `builtUserActionsPath`, `cachePath`, `chartsPath`, `chatPath`, `clearProjectService`, `cliPath`, `cloudPath`, `cloudStatePath`, `collectionsPath`, `commandsPath`, `componentsPath`, `configPath`, `coreApiPath`, `coreEnvPath`, `corePath`, `coreStoragePath`, `customElementsDataPath`, `databasePath`, `datetimePath`, `defaultsAppPath`, `defaultsPackagePath`, `defaultsPath`, `defaultsResourcesPath`, `delimiter`, `desktopPath`, `developmentPath`, `dirname`, `dnsPath`, `docsPath`, `emailPath`, `ensureRuntimeDirectories`, `enumsPath`, `errorHandlingPath`, `eslintPluginPath`, `eventsPath`, `examplesPath`, `extname`, `fakerPath`, `featureFlagsPath`, `featuresPath`, `findProject`, `findProjectPath`, `findProjectRoot`, `forgetProject`, `frameworkCloudPath`, `frameworkDefaultsRoot`, `frameworkPath`, `frameworkRuntimePath`, `functionsPath`, `gitPath`, `healthPath`, `homeDir`, `inspectDefaultsProvenance`, `installedDefaultsVersion`, `isAbsolute`, `isCompiledBinary`, `isInstalledDefaultsRoot`, `isProcessAlive`, `isProjectRoot`, `isVisitingCli`, `jobsPath`, `join`, `langPath`, `layoutsPath`, `libraryPackagePath`, `libsEntriesPath`, `libsPath`, `linkPackagedDefaults`, `lintPath`, `listProjects`, `listenersPath`, `loggingPath`, `logsPath`, `mergeDirectoryInto`, `modelMetaPath`, `modelsPath`, `modulesPath`, `newsletterPath`, `normalize`, `notificationsPath`, `objectsPath`, `onboardingPath`, `ormPath`, `packagedDefaultsRoot`, `paginationPath`, `path`, `pathPath`, `paymentsPath`, `projectCliEntry`, `projectConfigPath`, `projectPath`, `pruneProjects`, `publicPath`, `pushPath`, `queryBuilderPath`, `queuePath`, `readProjectService`, `realtimePath`, `recordProjectService`, `registerProject`, `relative`, `relativeActionsPath`, `replPath`, `reserveProjectPort`, `resolve`, `resolveModulePath`, `resolveUserLibBase`, `resourcesPath`, `routerPath`, `routesPath`, `runtimeDirectoryEnv`, `runtimePath`, `schedulerPath`, `scriptsPath`, `searchEnginePath`, `securityPath`, `sep`, `serverPath`, `serverlessPath`, `settingsPath`, `shellPath`, `siteConfigPath`, `skillsPath`, `slugPath`, `smsPath`, `socialsPath`, `stacksBackupPath`, `stacksHome`, `stacksLockPath`, `stacksPath`, `storagePath`, `storesPath`, `stringsPath`, `stxPath`, `testingPath`, `testsPath`, `tinkerPath`, `toNamespacedPath`, `typesPath`, `uiPath`, `userActionsPath`, `userComponentsPath`, `userControllersPath`, `userDatabasePath`, `userEmailsPath`, `userEventsPath`, `userFunctionsPath`, `userJobsPath`, `userLibsPath`, `userListenersPath`, `userMailPath`, `userMiddlewarePath`, `userMigrationsPath`, `userModelsPath`, `userNotificationsPath`, `userServerPath`, `userViewsPath`, `usesVendoredDefaults`, `utilsPath`, `validationPath`, `viewsPath`.
|
|
672
672
|
|
|
673
|
-
Local source modules: [src/module-resolution.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/path/src/module-resolution.ts), [src/project.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/path/src/project.ts).
|
|
673
|
+
Local source modules: [src/module-resolution.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/path/src/module-resolution.ts), [src/project.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/path/src/project.ts), [src/projects.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/path/src/projects.ts).
|
|
674
674
|
|
|
675
|
-
Evidence directory: [
|
|
675
|
+
Evidence directory: [14 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/path/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
|
|
676
676
|
|
|
677
677
|
### @stacksjs/payments
|
|
678
678
|
|
|
@@ -896,7 +896,7 @@ Read the entrypoint and package export map for re-exported or type-only surfaces
|
|
|
896
896
|
|
|
897
897
|
Local source modules: [src/console.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/src/console.ts), [src/disposable-database.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/src/disposable-database.ts), [src/events.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/src/events.ts), [src/feature.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/src/feature.ts), [src/isolated.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/src/isolated.ts), [src/mail.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/src/mail.ts), [src/schema.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/src/schema.ts), [src/service.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/src/service.ts), [src/time.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/src/time.ts).
|
|
898
898
|
|
|
899
|
-
Evidence directory: [
|
|
899
|
+
Evidence directory: [25 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
|
|
900
900
|
|
|
901
901
|
### @stacksjs/tinker
|
|
902
902
|
|
|
@@ -402,9 +402,14 @@ isIpv6(address) // check if AddressInfo is IPv6 (handle
|
|
|
402
402
|
## Find Stacks Projects (`find.ts`)
|
|
403
403
|
|
|
404
404
|
```typescript
|
|
405
|
-
await findStacksProjects(dir?, options?) //
|
|
406
|
-
//
|
|
407
|
-
//
|
|
405
|
+
await findStacksProjects(dir?, options?) // walk a directory tree for Stacks projects ({ quiet, maxDepth })
|
|
406
|
+
// The disk scan behind `buddy projects:scan`. To ask which projects are on the
|
|
407
|
+
// machine, read the list instead: `listProjects()` / `findProject()` in `@stacksjs/path`.
|
|
408
|
+
// A Stacks project = whatever `isProjectRoot()` in `@stacksjs/path` accepts: a package.json
|
|
409
|
+
// beside `storage/framework`, or beside `config/app.ts`, or declaring a native app.
|
|
410
|
+
// Skips by directory NAME: node_modules, dist, out, vendor, pantry and dot-folders, and does not
|
|
411
|
+
// look inside a project it has found. With no `dir` it starts at the home directory and also
|
|
412
|
+
// skips ~/Documents, ~/Pictures, ~/Library, ~/Movies, ~/Music, ~/Applications.
|
|
408
413
|
```
|
|
409
414
|
|
|
410
415
|
## Git Utilities (`git.ts`)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { SwitcherProject } from './projects'
|
|
2
|
+
import { describe, expect, it } from 'bun:test'
|
|
3
|
+
import { filterProjects, projectLocation } from './projects'
|
|
4
|
+
|
|
5
|
+
function project(name: string, path: string): SwitcherProject {
|
|
6
|
+
return { id: name, name, path, current: false, running: false, url: null }
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const projects = [
|
|
10
|
+
project('shop', '~/Code/clients/acme/shop'),
|
|
11
|
+
project('shop-admin', '~/Code/clients/acme/shop-admin'),
|
|
12
|
+
project('blog', '~/Code/personal/blog'),
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
describe('finding a project in the switcher', () => {
|
|
16
|
+
it('shows everything until something is typed', () => {
|
|
17
|
+
expect(filterProjects(projects, '')).toEqual(projects)
|
|
18
|
+
expect(filterProjects(projects, ' ')).toEqual(projects)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('matches the name or the folder, in any case', () => {
|
|
22
|
+
expect(filterProjects(projects, 'BLOG').map(match => match.name)).toEqual(['blog'])
|
|
23
|
+
expect(filterProjects(projects, 'acme').map(match => match.name)).toEqual(['shop', 'shop-admin'])
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('narrows with every word typed', () => {
|
|
27
|
+
expect(filterProjects(projects, 'acme admin').map(match => match.name)).toEqual(['shop-admin'])
|
|
28
|
+
expect(filterProjects(projects, 'acme blog')).toEqual([])
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
describe('where a project lives', () => {
|
|
33
|
+
it('is the folder that holds it', () => {
|
|
34
|
+
expect(projectLocation('~/Code/clients/acme/shop')).toBe('~/Code/clients/acme')
|
|
35
|
+
expect(projectLocation('/srv/shop')).toBe('/srv')
|
|
36
|
+
expect(projectLocation('shop')).toBe('shop')
|
|
37
|
+
})
|
|
38
|
+
})
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { dashboardApi } from './dashboard-api'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The project switcher's client.
|
|
5
|
+
*
|
|
6
|
+
* A dashboard serves one project. The other projects on the machine each have
|
|
7
|
+
* a dashboard of their own, at their own address, and switching is going
|
|
8
|
+
* there. These calls reach the dev dashboard's own `/__buddy/` routes
|
|
9
|
+
* (`core/actions/src/dev/dashboard-projects.ts`), which know the machine's
|
|
10
|
+
* project list and can bring another project's dashboard up.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export interface SwitcherProject {
|
|
14
|
+
id: string
|
|
15
|
+
name: string
|
|
16
|
+
/** As a person would write it: `~/Code/shop`. */
|
|
17
|
+
path: string
|
|
18
|
+
current: boolean
|
|
19
|
+
/** Whether a dashboard for it is up right now. */
|
|
20
|
+
running: boolean
|
|
21
|
+
url: string | null
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface SwitcherListing {
|
|
25
|
+
current: SwitcherProject
|
|
26
|
+
projects: SwitcherProject[]
|
|
27
|
+
/** How often an open page should report in, or null when it need not. */
|
|
28
|
+
keepAliveMs: number | null
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function fetchProjects(signal?: AbortSignal): Promise<SwitcherListing> {
|
|
32
|
+
return dashboardApi<SwitcherListing>('/__buddy/projects', { signal })
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Bring a project's dashboard up and return its address. Resolves once it is
|
|
37
|
+
* answering, which takes a few seconds the first time.
|
|
38
|
+
*/
|
|
39
|
+
export async function openProject(id: string): Promise<string> {
|
|
40
|
+
const { url } = await dashboardApi<{ url: string }>('/__buddy/projects/open', { method: 'POST', body: { id } })
|
|
41
|
+
return url
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Put the project at `path` on the machine's list. */
|
|
45
|
+
export async function addProject(path: string): Promise<SwitcherProject> {
|
|
46
|
+
const { project } = await dashboardApi<{ project: Pick<SwitcherProject, 'id' | 'name' | 'path'> }>('/__buddy/projects/add', { method: 'POST', body: { path } })
|
|
47
|
+
return { ...project, current: false, running: false, url: null }
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Tell the server this page is still open. A dashboard started in the
|
|
52
|
+
* background stops itself when nothing has asked it for anything in a while,
|
|
53
|
+
* and a page that is only being read asks for nothing.
|
|
54
|
+
*/
|
|
55
|
+
function reportAlive(): void {
|
|
56
|
+
void fetch('/__buddy/alive', { credentials: 'same-origin' }).catch(() => {})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Go to another project's dashboard. Its home page, not the page the user is
|
|
61
|
+
* on: a record, a setting or a whole section here may not exist there.
|
|
62
|
+
*/
|
|
63
|
+
export function goToProject(url: string): void {
|
|
64
|
+
window.location.assign(new URL('/', url).href)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Report in every `everyMs` until the returned function is called. A no-op
|
|
69
|
+
* when the server does not ask for it.
|
|
70
|
+
*/
|
|
71
|
+
export function keepAlive(everyMs: number | null): () => void {
|
|
72
|
+
if (!everyMs || everyMs <= 0)
|
|
73
|
+
return () => {}
|
|
74
|
+
|
|
75
|
+
const timer = setInterval(reportAlive, everyMs)
|
|
76
|
+
return () => clearInterval(timer)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Where a project lives: the folder that holds it. Its own name is already on
|
|
81
|
+
* the line above, and in a narrow menu the end of a long path is what gets cut
|
|
82
|
+
* off, which is the only part that tells two projects apart.
|
|
83
|
+
*/
|
|
84
|
+
export function projectLocation(path: string): string {
|
|
85
|
+
const cut = path.lastIndexOf('/')
|
|
86
|
+
return cut > 0 ? path.slice(0, cut) : path
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** The projects whose name or path contains every word typed. */
|
|
90
|
+
export function filterProjects(projects: SwitcherProject[], query: string): SwitcherProject[] {
|
|
91
|
+
const words = query.toLowerCase().split(/\s+/).filter(Boolean)
|
|
92
|
+
if (words.length === 0)
|
|
93
|
+
return projects
|
|
94
|
+
|
|
95
|
+
return projects.filter((project) => {
|
|
96
|
+
const haystack = `${project.name} ${project.path}`.toLowerCase()
|
|
97
|
+
return words.every(word => haystack.includes(word))
|
|
98
|
+
})
|
|
99
|
+
}
|
package/ide/vscode/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"publisher": "Stacks",
|
|
3
3
|
"name": "vscode-stacks",
|
|
4
4
|
"displayName": "Stacks",
|
|
5
|
-
"version": "0.75.
|
|
5
|
+
"version": "0.75.622",
|
|
6
6
|
"description": "Stacks, built into VS Code: stx templates, pickier linting and formatting, encrypted env files, the dev server preview and every buddy command. No other extensions required.",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"funding": "https://github.com/sponsors/chrisbbreuer",
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/defaults",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.75.
|
|
5
|
+
"version": "0.75.622",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/stacksjs/stacks.git",
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@iconify-json/f7": "^1.2.2",
|
|
47
47
|
"@iconify-json/hugeicons": "^1.2.35",
|
|
48
|
-
"@stacksjs/mobile": "0.75.
|
|
49
|
-
"@stacksjs/sanitizer": "^0.2.
|
|
50
|
-
"@stacksjs/stx": "^0.2.
|
|
51
|
-
"@stacksjs/strings": "0.75.
|
|
48
|
+
"@stacksjs/mobile": "0.75.622",
|
|
49
|
+
"@stacksjs/sanitizer": "^0.2.908",
|
|
50
|
+
"@stacksjs/stx": "^0.2.908",
|
|
51
|
+
"@stacksjs/strings": "0.75.622",
|
|
52
52
|
"@xterm/addon-fit": "^0.11.0",
|
|
53
53
|
"@xterm/xterm": "^6.0.0",
|
|
54
54
|
"ts-qr-codes": "^0.1.8",
|
|
55
|
-
"@stacksjs/support": "0.75.
|
|
56
|
-
"@stacksjs/browser": "0.75.
|
|
55
|
+
"@stacksjs/support": "0.75.622",
|
|
56
|
+
"@stacksjs/browser": "0.75.622"
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
<script server>
|
|
2
|
+
// The project switcher at the top of the dashboard sidebar.
|
|
3
|
+
//
|
|
4
|
+
// Its button is drawn on the server with the project's name, so the sidebar
|
|
5
|
+
// does not shift when the page hydrates. The list is fetched in the browser,
|
|
6
|
+
// when the menu opens: which projects have a dashboard up changes from one
|
|
7
|
+
// minute to the next, and the layout this sits in is rendered once and kept.
|
|
8
|
+
const { name = '' } = defineProps<{ name?: string }>()
|
|
9
|
+
|
|
10
|
+
export const projectName = name
|
|
11
|
+
export const projectInitial = (name.trim()[0] || 'S').toUpperCase()
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<script client>
|
|
15
|
+
import type { SwitcherProject } from '../../../functions/projects'
|
|
16
|
+
import { addProject, fetchProjects, filterProjects, goToProject, keepAlive, openProject, projectLocation } from '../../../functions/projects'
|
|
17
|
+
|
|
18
|
+
const isOpen = state(false)
|
|
19
|
+
const projects = state<SwitcherProject[]>([])
|
|
20
|
+
const query = state('')
|
|
21
|
+
const selectedIndex = state(0)
|
|
22
|
+
const isLoading = state(false)
|
|
23
|
+
// The id of the project being opened, while its dashboard starts.
|
|
24
|
+
const opening = state('')
|
|
25
|
+
const error = state('')
|
|
26
|
+
const isAdding = state(false)
|
|
27
|
+
const addPath = state('')
|
|
28
|
+
const isSaving = state(false)
|
|
29
|
+
const root = useRef<HTMLElement>('projectSwitcher')
|
|
30
|
+
const trigger = useRef<HTMLButtonElement>('projectSwitcherTrigger')
|
|
31
|
+
const searchInput = useRef<HTMLInputElement>('projectSwitcherSearch')
|
|
32
|
+
const addInput = useRef<HTMLInputElement>('projectSwitcherAddPath')
|
|
33
|
+
let stopKeepAlive = () => {}
|
|
34
|
+
|
|
35
|
+
function visibleProjects(): SwitcherProject[] {
|
|
36
|
+
return filterProjects(projects(), query())
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function load(): Promise<void> {
|
|
40
|
+
isLoading.set(true)
|
|
41
|
+
try {
|
|
42
|
+
const listing = await fetchProjects()
|
|
43
|
+
projects.set(listing.projects)
|
|
44
|
+
stopKeepAlive()
|
|
45
|
+
stopKeepAlive = keepAlive(listing.keepAliveMs)
|
|
46
|
+
}
|
|
47
|
+
catch (reason) {
|
|
48
|
+
error.set(reason instanceof Error ? reason.message : 'The project list could not be loaded.')
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
isLoading.set(false)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function open(): void {
|
|
56
|
+
isOpen.set(true)
|
|
57
|
+
query.set('')
|
|
58
|
+
error.set('')
|
|
59
|
+
selectedIndex.set(0)
|
|
60
|
+
isAdding.set(false)
|
|
61
|
+
void load()
|
|
62
|
+
void nextTick(() => searchInput.current?.focus())
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function close(): void {
|
|
66
|
+
if (!isOpen()) return
|
|
67
|
+
isOpen.set(false)
|
|
68
|
+
// Opening a project that has to start can take a few seconds; closing the
|
|
69
|
+
// menu does not cancel it, it only stops showing it.
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function toggle(): void {
|
|
73
|
+
isOpen() ? close() : open()
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function choose(project: SwitcherProject): Promise<void> {
|
|
77
|
+
if (opening()) return
|
|
78
|
+
if (project.current) {
|
|
79
|
+
close()
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
error.set('')
|
|
84
|
+
// Up already: go straight there. Otherwise ask for it to be started and
|
|
85
|
+
// wait until it answers.
|
|
86
|
+
if (project.running && project.url) {
|
|
87
|
+
goToProject(project.url)
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
opening.set(project.id)
|
|
92
|
+
try {
|
|
93
|
+
goToProject(await openProject(project.id))
|
|
94
|
+
}
|
|
95
|
+
catch (reason) {
|
|
96
|
+
opening.set('')
|
|
97
|
+
error.set(reason instanceof Error ? reason.message : `${project.name} could not be opened.`)
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function startAdding(): void {
|
|
102
|
+
isAdding.set(true)
|
|
103
|
+
addPath.set('')
|
|
104
|
+
error.set('')
|
|
105
|
+
void nextTick(() => addInput.current?.focus())
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async function submitAdd(): Promise<void> {
|
|
109
|
+
const path = addPath().trim()
|
|
110
|
+
if (!path || isSaving()) return
|
|
111
|
+
|
|
112
|
+
isSaving.set(true)
|
|
113
|
+
error.set('')
|
|
114
|
+
try {
|
|
115
|
+
const added = await addProject(path)
|
|
116
|
+
isAdding.set(false)
|
|
117
|
+
query.set('')
|
|
118
|
+
await load()
|
|
119
|
+
const index = visibleProjects().findIndex(project => project.id === added.id)
|
|
120
|
+
selectedIndex.set(index === -1 ? 0 : index)
|
|
121
|
+
void nextTick(() => searchInput.current?.focus())
|
|
122
|
+
}
|
|
123
|
+
catch (reason) {
|
|
124
|
+
error.set(reason instanceof Error ? reason.message : 'That project could not be added.')
|
|
125
|
+
}
|
|
126
|
+
finally {
|
|
127
|
+
isSaving.set(false)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function handleSearchKeydown(event: KeyboardEvent): void {
|
|
132
|
+
const items = visibleProjects()
|
|
133
|
+
if (event.key === 'ArrowDown') {
|
|
134
|
+
event.preventDefault()
|
|
135
|
+
if (items.length > 0)
|
|
136
|
+
selectedIndex.set(selectedIndex() >= items.length - 1 ? 0 : selectedIndex() + 1)
|
|
137
|
+
}
|
|
138
|
+
else if (event.key === 'ArrowUp') {
|
|
139
|
+
event.preventDefault()
|
|
140
|
+
if (items.length > 0)
|
|
141
|
+
selectedIndex.set(selectedIndex() <= 0 ? items.length - 1 : selectedIndex() - 1)
|
|
142
|
+
}
|
|
143
|
+
else if (event.key === 'Enter') {
|
|
144
|
+
event.preventDefault()
|
|
145
|
+
const project = items[selectedIndex()]
|
|
146
|
+
if (project) void choose(project)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function handleAddKeydown(event: KeyboardEvent): void {
|
|
151
|
+
if (event.key === 'Enter') {
|
|
152
|
+
event.preventDefault()
|
|
153
|
+
void submitAdd()
|
|
154
|
+
}
|
|
155
|
+
else if (event.key === 'Escape') {
|
|
156
|
+
// Back to the list, not out of the menu.
|
|
157
|
+
event.preventDefault()
|
|
158
|
+
event.stopPropagation()
|
|
159
|
+
isAdding.set(false)
|
|
160
|
+
void nextTick(() => searchInput.current?.focus())
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function handleEscape(): void {
|
|
165
|
+
if (!isOpen()) return
|
|
166
|
+
close()
|
|
167
|
+
trigger.current?.focus()
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Complete class strings, because a `class` attribute is not reactive.
|
|
171
|
+
function rowClass(project: SwitcherProject, index: number): string {
|
|
172
|
+
const active = index === selectedIndex()
|
|
173
|
+
return `flex gap-2.5 items-center px-2 py-1.5 w-full text-left rounded-md ${active ? 'bg-black/8 dark:bg-white/12' : ''} ${opening() && opening() !== project.id ? 'opacity-50' : ''}`
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
useClickOutside(root, close)
|
|
177
|
+
|
|
178
|
+
onMount(() => {
|
|
179
|
+
// Learns whether the server wants to hear from this page, and has the list
|
|
180
|
+
// ready before the menu is first opened.
|
|
181
|
+
void load()
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
onDestroy(() => {
|
|
185
|
+
stopKeepAlive()
|
|
186
|
+
})
|
|
187
|
+
</script>
|
|
188
|
+
|
|
189
|
+
<div
|
|
190
|
+
ref="projectSwitcher"
|
|
191
|
+
data-project-switcher
|
|
192
|
+
:data-open="String(isOpen())"
|
|
193
|
+
class="relative pb-1.5 px-2 [-webkit-app-region:no-drag]"
|
|
194
|
+
@keydown.escape="handleEscape()"
|
|
195
|
+
>
|
|
196
|
+
<button
|
|
197
|
+
ref="projectSwitcherTrigger"
|
|
198
|
+
type="button"
|
|
199
|
+
aria-haspopup="dialog"
|
|
200
|
+
:aria-expanded="String(isOpen())"
|
|
201
|
+
aria-label="Switch project"
|
|
202
|
+
title="Switch project"
|
|
203
|
+
class="flex gap-2 items-center px-1.5 py-1.5 w-full text-left hover:bg-black/5 dark:hover:bg-white/10 rounded-lg focus-visible:outline-2 focus-visible:outline-blue-500 focus-visible:outline-offset-[-2px] transition-colors"
|
|
204
|
+
@click="toggle()"
|
|
205
|
+
>
|
|
206
|
+
<span aria-hidden="true" class="flex items-center justify-center shrink-0 h-6 w-6 font-semibold text-[11px] text-white dark:text-neutral-900 bg-neutral-800 dark:bg-neutral-100 rounded-md">{{ projectInitial }}</span>
|
|
207
|
+
<span class="flex-1 min-w-0 font-semibold text-[13px] truncate">{{ projectName }}</span>
|
|
208
|
+
<span aria-hidden="true" class="shrink-0 h-4 w-4 opacity-50 i-hugeicons-unfold-more"></span>
|
|
209
|
+
</button>
|
|
210
|
+
|
|
211
|
+
<div
|
|
212
|
+
:if="isOpen()"
|
|
213
|
+
role="dialog"
|
|
214
|
+
aria-label="Projects"
|
|
215
|
+
class="absolute left-2 overflow-hidden right-2 top-full z-50 text-neutral-800 dark:text-neutral-100 bg-white/95 dark:bg-neutral-800/95 border border-black/10 rounded-xl dark:border-white/10 shadow-black/15 shadow-xl dark:shadow-black/40 backdrop-blur-xl backdrop-saturate-150"
|
|
216
|
+
>
|
|
217
|
+
<div class="flex gap-2 items-center px-2.5 border-b border-black/10 dark:border-white/10">
|
|
218
|
+
<span aria-hidden="true" class="shrink-0 h-4 w-4 opacity-50 i-hugeicons-search-01"></span>
|
|
219
|
+
<input
|
|
220
|
+
ref="projectSwitcherSearch"
|
|
221
|
+
x-model="query"
|
|
222
|
+
type="text"
|
|
223
|
+
autocomplete="off"
|
|
224
|
+
spellcheck="false"
|
|
225
|
+
placeholder="Find a project"
|
|
226
|
+
aria-label="Find a project"
|
|
227
|
+
class="py-2 w-full text-[13px] placeholder:text-neutral-400 bg-transparent border-none focus:outline-none focus:ring-0"
|
|
228
|
+
@input="selectedIndex.set(0)"
|
|
229
|
+
@keydown="handleSearchKeydown"
|
|
230
|
+
/>
|
|
231
|
+
<span :if="isLoading()" aria-hidden="true" class="shrink-0 h-4 w-4 opacity-60 animate-spin i-hugeicons-loading-03"></span>
|
|
232
|
+
</div>
|
|
233
|
+
|
|
234
|
+
<div role="listbox" aria-label="Projects on this machine" class="overflow-y-auto p-1 max-h-72">
|
|
235
|
+
<button
|
|
236
|
+
:for="(project, index) in visibleProjects()"
|
|
237
|
+
type="button"
|
|
238
|
+
role="option"
|
|
239
|
+
:aria-selected="String(index === selectedIndex())"
|
|
240
|
+
:data-project-id="project.id"
|
|
241
|
+
:title="project.path"
|
|
242
|
+
:disabled="Boolean(opening())"
|
|
243
|
+
:class="rowClass(project, index)"
|
|
244
|
+
@mouseenter="selectedIndex.set(index)"
|
|
245
|
+
@click="choose(project)"
|
|
246
|
+
>
|
|
247
|
+
<span aria-hidden="true" class="flex items-center justify-center shrink-0 h-6 w-6 font-semibold text-[11px] text-neutral-700 dark:text-neutral-200 bg-black/8 dark:bg-white/12 rounded-md">{{ (project.name[0] || '?').toUpperCase() }}</span>
|
|
248
|
+
<span class="flex-1 min-w-0">
|
|
249
|
+
<span class="block font-medium text-[13px] truncate">{{ project.name }}</span>
|
|
250
|
+
<span class="block text-[11px] truncate opacity-60">{{ projectLocation(project.path) }}</span>
|
|
251
|
+
</span>
|
|
252
|
+
<span :if="opening() === project.id" role="status" aria-label="Starting" class="shrink-0 h-4 w-4 animate-spin i-hugeicons-loading-03"></span>
|
|
253
|
+
<span :if="project.current && opening() !== project.id" aria-label="Current project" class="shrink-0 h-4 w-4 text-blue-500 i-hugeicons-tick-02"></span>
|
|
254
|
+
<span :if="project.running && !project.current && opening() !== project.id" title="Dashboard running" aria-label="Dashboard running" class="shrink-0 h-2 w-2 bg-green-500 rounded-full"></span>
|
|
255
|
+
</button>
|
|
256
|
+
|
|
257
|
+
<p :if="!isLoading() && projects().length > 0 && visibleProjects().length === 0" class="px-2 py-4 text-[12px] text-center opacity-60">
|
|
258
|
+
No project matches "{{ query() }}".
|
|
259
|
+
</p>
|
|
260
|
+
</div>
|
|
261
|
+
|
|
262
|
+
<p :if="opening()" role="status" class="px-3 py-2 text-[12px] border-black/10 border-t dark:border-white/10 opacity-70">
|
|
263
|
+
Starting its dashboard. This takes a few seconds the first time.
|
|
264
|
+
</p>
|
|
265
|
+
<p :if="error()" role="alert" class="px-3 py-2 break-words text-[12px] text-red-600 whitespace-pre-line dark:text-red-400 border-black/10 border-t dark:border-white/10">{{ error() }}</p>
|
|
266
|
+
|
|
267
|
+
<div class="p-1 border-black/10 border-t dark:border-white/10">
|
|
268
|
+
<button
|
|
269
|
+
:if="!isAdding()"
|
|
270
|
+
type="button"
|
|
271
|
+
data-project-add
|
|
272
|
+
class="flex gap-2.5 items-center px-2 py-1.5 w-full text-[13px] text-left hover:bg-black/5 dark:hover:bg-white/10 rounded-md"
|
|
273
|
+
@click="startAdding()"
|
|
274
|
+
>
|
|
275
|
+
<span aria-hidden="true" class="shrink-0 mx-1 h-4 w-4 opacity-70 i-hugeicons-folder-add"></span>
|
|
276
|
+
Add a project
|
|
277
|
+
</button>
|
|
278
|
+
|
|
279
|
+
<div :if="isAdding()" class="flex gap-1.5 items-center px-1 py-1">
|
|
280
|
+
<input
|
|
281
|
+
ref="projectSwitcherAddPath"
|
|
282
|
+
x-model="addPath"
|
|
283
|
+
type="text"
|
|
284
|
+
autocomplete="off"
|
|
285
|
+
spellcheck="false"
|
|
286
|
+
placeholder="~/Code/my-app"
|
|
287
|
+
aria-label="Path of the project to add"
|
|
288
|
+
class="flex-1 px-2 py-1 min-w-0 text-[12px] placeholder:text-neutral-400 bg-black/5 dark:bg-white/10 border-none rounded-md focus:outline-none focus:ring-1 focus:ring-blue-500"
|
|
289
|
+
@keydown="handleAddKeydown"
|
|
290
|
+
/>
|
|
291
|
+
<Button
|
|
292
|
+
variant="primary"
|
|
293
|
+
size="xs"
|
|
294
|
+
:disabled="isSaving() || !addPath().trim()"
|
|
295
|
+
@click="submitAdd()"
|
|
296
|
+
>
|
|
297
|
+
Add
|
|
298
|
+
</Button>
|
|
299
|
+
</div>
|
|
300
|
+
</div>
|
|
301
|
+
</div>
|
|
302
|
+
</div>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test'
|
|
2
|
+
import { dashboardProjectIdentity } from './project-switcher'
|
|
3
|
+
|
|
4
|
+
describe('the project a dashboard names in its sidebar', () => {
|
|
5
|
+
it('is the directory it serves, with a switcher on the developer\'s machine', () => {
|
|
6
|
+
expect(dashboardProjectIdentity('/Users/dev/Code/shop', { STACKS_DASHBOARD_PROJECTS: '1' })).toEqual({ enabled: true, name: 'shop' })
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
it('has no switcher where the dev dashboard server did not ask for one', () => {
|
|
10
|
+
// A deployed dashboard: one project, and a release directory for a name.
|
|
11
|
+
expect(dashboardProjectIdentity('/var/www/shop/releases/42', {}).enabled).toBe(false)
|
|
12
|
+
expect(dashboardProjectIdentity('/var/www/shop', { STACKS_DASHBOARD_PROJECTS: '0' }).enabled).toBe(false)
|
|
13
|
+
})
|
|
14
|
+
})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { basename } from 'node:path'
|
|
2
|
+
import process from 'node:process'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* What the dashboard layout needs to draw the project switcher on the first
|
|
6
|
+
* paint: the name of the project being served, and whether there is a
|
|
7
|
+
* switcher at all.
|
|
8
|
+
*
|
|
9
|
+
* There is one only on the developer's machine, where `buddy` knows the other
|
|
10
|
+
* projects and can start their dashboards; the dev dashboard server says so
|
|
11
|
+
* by setting `STACKS_DASHBOARD_PROJECTS`. A deployed dashboard serves the one
|
|
12
|
+
* project it was deployed with, and draws nothing here.
|
|
13
|
+
*
|
|
14
|
+
* Node built-ins only: this runs in the layout's server script.
|
|
15
|
+
*/
|
|
16
|
+
export interface DashboardProjectIdentity {
|
|
17
|
+
enabled: boolean
|
|
18
|
+
name: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function dashboardProjectIdentity(root: string = process.cwd(), env: Record<string, string | undefined> = process.env): DashboardProjectIdentity {
|
|
22
|
+
return {
|
|
23
|
+
enabled: env.STACKS_DASHBOARD_PROJECTS === '1',
|
|
24
|
+
// The directory name is what a developer calls the project, and it is the
|
|
25
|
+
// name `buddy projects` and `--project` use for it.
|
|
26
|
+
name: basename(root),
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -96,7 +96,38 @@ const entrypoint = (process.argv[1] ?? '').replaceAll('\\', '/')
|
|
|
96
96
|
const repositoryAction = '(?:release|bump|generate/lib-entries)\\.[jt]s'
|
|
97
97
|
const isRepositoryAction = new RegExp(`(?:^|/)storage/framework/core/actions/src/${repositoryAction}$`).test(entrypoint)
|
|
98
98
|
|| new RegExp(`(?:^|/)(?:node_modules|pantry)/@stacksjs/actions/(?:src|dist(?:/src)?)/${repositoryAction}$`).test(entrypoint)
|
|
99
|
-
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* A `buddy` installed once for the whole machine, started in this project.
|
|
102
|
+
*
|
|
103
|
+
* It is only passing through: it finds the project and replaces itself with
|
|
104
|
+
* the project's own `buddy`, which runs this file again, for real. Everything
|
|
105
|
+
* below (the env files, the auto-import graph) would be loaded here, thrown
|
|
106
|
+
* away a moment later, and loaded again: about half a second on every command
|
|
107
|
+
* typed at a project root.
|
|
108
|
+
*
|
|
109
|
+
* Not when this process was itself handed the project (`STACKS_BUDDY_ROOT`):
|
|
110
|
+
* that one is the last, and does the work.
|
|
111
|
+
*/
|
|
112
|
+
async function isVisitingBuddy(): Promise<boolean> {
|
|
113
|
+
if (isPostinstall || !/(?:^|\/)buddy\/(?:src\/cli\.ts|dist\/cli\.js)$/.test(entrypoint))
|
|
114
|
+
return false
|
|
115
|
+
if (process.env.STACKS_BUDDY_ROOT)
|
|
116
|
+
return false
|
|
117
|
+
|
|
118
|
+
try {
|
|
119
|
+
const pathPackage = '@stacksjs/' + 'path'
|
|
120
|
+
const { isVisitingCli } = await import('../../../core/path/src/index.ts').catch(() => import(pathPackage))
|
|
121
|
+
// An installed @stacksjs/path that predates the helper: carry on as before.
|
|
122
|
+
return typeof isVisitingCli === 'function' && isVisitingCli(process.cwd(), entrypoint)
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
return false
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const isPassingThrough = await isVisitingBuddy()
|
|
130
|
+
const skipPreloader = isRepl || isPostinstall || isRepositoryAction || isPassingThrough || (args.length > 0 && fastCommands.some(cmd => args[0] === cmd || args[0].startsWith(`${cmd}:`)))
|
|
100
131
|
|
|
101
132
|
if (!skipPreloader) {
|
|
102
133
|
// Detect production/deployment commands and set environment accordingly BEFORE loading env files
|
|
@@ -137,7 +168,7 @@ if (!skipPreloader) {
|
|
|
137
168
|
// importing it there can fail (see the isPostinstall note above). The REPL keeps
|
|
138
169
|
// its original skip. The heavy auto-import graph below stays gated separately via
|
|
139
170
|
// `skipAutoImports`.
|
|
140
|
-
if (!isRepl && !isPostinstall) {
|
|
171
|
+
if (!isRepl && !isPostinstall && !isPassingThrough) {
|
|
141
172
|
// Resolve the vendored source first; the package fallback covers non-standard
|
|
142
173
|
// layouts where defaults is consumed outside the framework layout.
|
|
143
174
|
const envPackage = '@stacksjs/' + 'env'
|
|
@@ -16,10 +16,16 @@
|
|
|
16
16
|
// vendored or linked. `@stacksjs/defaults/*` is mapped onto the vendored tree in
|
|
17
17
|
// `storage/framework/tsconfig.app.json` and falls back to the installed
|
|
18
18
|
// package when there is none, so it resolves in both layouts.
|
|
19
|
+
import { dashboardProjectIdentity } from '@stacksjs/defaults/resources/functions/dashboard/project-switcher'
|
|
19
20
|
import { buildWebSidebarSections, webSidebarRoleMap } from '@stacksjs/defaults/resources/functions/dashboard/sidebar'
|
|
20
21
|
|
|
21
22
|
export const sidebarSections = buildWebSidebarSections()
|
|
22
23
|
|
|
24
|
+
// The project this dashboard serves, for the switcher at the top of the
|
|
25
|
+
// sidebar. Only its name: the list of other projects is fetched by the
|
|
26
|
+
// switcher itself, because this layout is rendered once and kept.
|
|
27
|
+
export const dashboardProject = dashboardProjectIdentity()
|
|
28
|
+
|
|
23
29
|
// Role gating (stacksjs/stacks#1843). Models can declare
|
|
24
30
|
// `dashboard.roles: ['admin', 'dev']`; rows for those models are hidden from
|
|
25
31
|
// viewers who hold none of them. Emitted as an id-keyed map rather than a
|
|
@@ -429,6 +435,14 @@ html[data-appearance="arc"] [data-sidebar-section] > div:first-child {
|
|
|
429
435
|
opacity: 0.55;
|
|
430
436
|
}
|
|
431
437
|
|
|
438
|
+
/* The project switcher's menu hangs below the sidebar header, over the rows.
|
|
439
|
+
The header and the scroll area are stacked at the same level and the scroll
|
|
440
|
+
area comes later, so it would paint over the menu: the header is lifted
|
|
441
|
+
while the menu is open. */
|
|
442
|
+
[data-stx-sidebar] > div:has([data-project-switcher][data-open="true"]) {
|
|
443
|
+
z-index: 30;
|
|
444
|
+
}
|
|
445
|
+
|
|
432
446
|
/* A viewer can hide navigation sections they never use. Kept as CSS on an
|
|
433
447
|
attribute rather than a DOM removal so the rows stay hydrated and a later
|
|
434
448
|
change re-shows them without a re-render - the same approach the role
|
|
@@ -758,6 +772,9 @@ onDestroy(() => {
|
|
|
758
772
|
region, and in a browser it is the same empty strip macOS sidebars
|
|
759
773
|
carry above their first row. -->
|
|
760
774
|
<SidebarHeader windowControls="native" />
|
|
775
|
+
@if(dashboardProject.enabled)
|
|
776
|
+
<ProjectSwitcher :name="dashboardProject.name" />
|
|
777
|
+
@endif
|
|
761
778
|
</template>
|
|
762
779
|
<template #footer>
|
|
763
780
|
<div class="px-3 py-2 text-neutral-600 text-xs dark:text-neutral-300" data-sidebar-order-controls>
|