@fugood/bricks-project 2.24.2 → 2.24.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compile/index.ts +195 -13
- package/package.json +2 -2
- package/package.json.bak +2 -2
- package/skills/bricks-ctor/SKILL.md +3 -1
- package/skills/bricks-ctor/rules/animation.md +3 -2
- package/skills/bricks-ctor/rules/buttress.md +97 -8
- package/skills/bricks-ctor/rules/verification-toolchain.md +170 -0
- package/skills/bricks-design/SKILL.md +160 -45
- package/skills/bricks-design/references/architecture-truths.md +125 -0
- package/skills/bricks-design/references/avoiding-complexity.md +91 -0
- package/skills/bricks-design/references/design-critique.md +195 -0
- package/skills/bricks-design/references/design-languages.md +265 -0
- package/skills/bricks-design/references/performance.md +116 -0
- package/skills/bricks-design/references/presentation-and-slideshow.md +137 -0
- package/skills/bricks-design/references/translating-inputs.md +152 -0
- package/skills/bricks-design/references/variations-and-tweaks.md +124 -0
- package/skills/bricks-design/references/when-the-brief-is-branded.md +284 -0
- package/skills/bricks-design/references/when-the-brief-is-vague.md +85 -0
- package/skills/bricks-design/references/workflow.md +134 -0
- package/skills/bricks-ux/SKILL.md +120 -0
- package/skills/bricks-ux/references/accessibility.md +162 -0
- package/skills/bricks-ux/references/flow-states.md +175 -0
- package/skills/bricks-ux/references/interaction-archetypes.md +189 -0
- package/skills/bricks-ux/references/monitoring-screens.md +153 -0
- package/skills/bricks-ux/references/pressable-composition.md +126 -0
- package/skills/bricks-ux/references/user-journey.md +168 -0
- package/skills/bricks-ux/references/ux-critique.md +256 -0
- package/tools/_git-author.ts +10 -2
- package/tools/_last-pushed-commit.ts +28 -0
- package/tools/deploy.ts +15 -0
- package/tools/preview-main.mjs +18 -5
- package/tools/pull.ts +91 -16
- package/tools/update-config.ts +118 -0
- package/types/animation.ts +16 -5
- package/types/automation.ts +1 -0
- package/types/bricks/Image.ts +12 -0
- package/types/data-calc.ts +1 -0
- package/types/data.ts +1 -1
- package/types/generators/Assistant.ts +18 -0
- package/types/generators/LlmGgml.ts +1 -0
- package/types/generators/LlmMlx.ts +1 -0
- package/types/generators/SpeechToTextGgml.ts +1 -0
- package/types/subspace.ts +1 -1
- package/utils/data.ts +1 -1
- package/skills/bricks-design/LICENSE.txt +0 -180
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# UX Critique
|
|
2
|
+
|
|
3
|
+
Verification proves the flow *runs*. UX critique proves the flow is *usable*. Both are required before declaring done; neither substitutes for the other.
|
|
4
|
+
|
|
5
|
+
UX critique runs in parallel with visual-design critique (`bricks-design/design-critique.md`). A Canvas can fail one and pass the other; both block ship.
|
|
6
|
+
|
|
7
|
+
This file is tiered. The same UX problem (e.g., closure missing) is **CRITICAL** on a payment kiosk and **MEDIUM** on a museum signage loop. Critique fails ship when CRITICAL or HIGH items go unaddressed in their applicable tiers.
|
|
8
|
+
|
|
9
|
+
## How to run the pass
|
|
10
|
+
|
|
11
|
+
1. **Open the journey.** Walk every interaction step-by-step using `user-journey.md` as the spine.
|
|
12
|
+
2. **For each Canvas / Brick group, classify by deployment risk** (table below). The classification determines which tier of checks apply.
|
|
13
|
+
3. **Run the checks in the applicable tier(s).** CRITICAL items always run; HIGH applies broadly; MEDIUM and LOW depend on classification.
|
|
14
|
+
4. **Fix every CRITICAL miss and every HIGH miss.** Surface MEDIUM and LOW misses in the trade-off note if not addressed.
|
|
15
|
+
5. **Re-verify after fixes.** Don't accumulate fix debt.
|
|
16
|
+
|
|
17
|
+
## Risk classification by deployment shape
|
|
18
|
+
|
|
19
|
+
| Deployment shape | Risk profile | Tier weighting |
|
|
20
|
+
|---|---|---|
|
|
21
|
+
| Payment / identity capture / safety-critical | CRITICAL-dense — every transact discipline must pass | CRITICAL + HIGH + MEDIUM all apply |
|
|
22
|
+
| Self-service interactive (ordering, check-in, configuration) | HIGH-dense — journey completeness, idle reset, recovery paths | CRITICAL + HIGH apply; MEDIUM where relevant |
|
|
23
|
+
| Monitoring / dashboard / control room | HIGH-dense — alarm hierarchy, stale-data trust, calm/detect/demand | CRITICAL + HIGH apply for alarm states |
|
|
24
|
+
| Browse / wayfinding / menu board | MEDIUM-dense — legibility, comparison clarity, sparse states | HIGH legibility, MEDIUM elsewhere |
|
|
25
|
+
| Glanceable signage / dwell / ambient loop | LOW-dense — main checks are legibility and rhythm | HIGH legibility, LOW elsewhere |
|
|
26
|
+
|
|
27
|
+
## CRITICAL — blocks ship
|
|
28
|
+
|
|
29
|
+
Failure on any of these is sufficient grounds to declare the work mid-iteration.
|
|
30
|
+
|
|
31
|
+
### CR-1. The user-journey spine is whole
|
|
32
|
+
|
|
33
|
+
Every interaction must have all seven steps present (or deliberately compressed; see `user-journey.md` § "When the seven steps compress"). Most-common holes:
|
|
34
|
+
|
|
35
|
+
- **Immediate feedback missing** (step 3). User taps, nothing visible, taps again.
|
|
36
|
+
- **In-flight visibility missing** (step 4). Action triggered, screen frozen, user re-triggers.
|
|
37
|
+
- **Recovery as dead-end** (step 6). Error Canvas with no path forward.
|
|
38
|
+
- **Closure ambiguous or missing** (step 7). Success state transient or unclear.
|
|
39
|
+
|
|
40
|
+
**Must Have:** every interaction has a designed and verified affordance, instruction, feedback, in-flight state, continuation, recovery, closure — or deliberate documented collapse.
|
|
41
|
+
**Anti-Pattern:** journey skipping any step on the assumption "it's fast enough not to need".
|
|
42
|
+
|
|
43
|
+
### CR-2. Transact has its intensification
|
|
44
|
+
|
|
45
|
+
For payment / identity / safety-critical flows, the seven steps must be tightened (`user-journey.md` § "When the seven steps intensify"):
|
|
46
|
+
|
|
47
|
+
- Confirmation step before commit.
|
|
48
|
+
- In-flight visibility non-skippable.
|
|
49
|
+
- Recovery categorised (declined / network / cancelled / timeout).
|
|
50
|
+
- Closure with weight and hold time.
|
|
51
|
+
|
|
52
|
+
**Must Have:** transact closure holds ≥ 5 seconds, success unmistakable, peripheral state visible.
|
|
53
|
+
**Anti-Pattern:** "Process payment in one tap" with no confirmation; closure that auto-advances in < 2s.
|
|
54
|
+
|
|
55
|
+
### CR-3. Monitoring has demand discipline
|
|
56
|
+
|
|
57
|
+
For dashboards / monitor screens with alarm capability:
|
|
58
|
+
|
|
59
|
+
- Calm / detect / demand are three distinct designed states.
|
|
60
|
+
- Demand state stands out unambiguously; not a slight colour change.
|
|
61
|
+
- Multiple concurrent demand states have priority ordering already designed.
|
|
62
|
+
- Stale-data is visibly declared per source.
|
|
63
|
+
- Color is never the only encoding of severity.
|
|
64
|
+
|
|
65
|
+
**Must Have:** alarm-state preview captured and reviewed; squint-test passes (alarm visible from peripheral vision); monochrome preview still distinguishes severity tiers.
|
|
66
|
+
**Anti-Pattern:** alarm styled identically to detect-state; "stale" indicator at 8pt in corner; severity by colour alone.
|
|
67
|
+
|
|
68
|
+
### CR-4. Accessibility floors met for the audience
|
|
69
|
+
|
|
70
|
+
The seven accessibility disciplines (`accessibility.md`) apply at deployment-relative floors. CRITICAL when the audience includes:
|
|
71
|
+
|
|
72
|
+
- Reduced-vision users (contrast, scale, color-not-only).
|
|
73
|
+
- Reduced-motor users (touch targets, no precise gestures, no time-pressure auto-cancels).
|
|
74
|
+
- Sensitive-to-motion users (reduced-motion path available).
|
|
75
|
+
- Multilingual audience (strings via Data; type scale accommodates longest translation).
|
|
76
|
+
|
|
77
|
+
**Must Have:** contrast verified under deployment-actual lighting; touch targets verified with real-finger / real-hardware testing; severity / status encoded by shape + color + label.
|
|
78
|
+
**Anti-Pattern:** WCAG-compliance-on-desktop-monitor as the audit (deployment is sunlit signage at 4m); time-pressure UI on a venue that includes slow / hesitant users.
|
|
79
|
+
|
|
80
|
+
### CR-5. Idle reset is clean
|
|
81
|
+
|
|
82
|
+
For self-service interactive deployments:
|
|
83
|
+
|
|
84
|
+
- Idle timeout exists and is calibrated to the use pattern.
|
|
85
|
+
- Idle reset clears flow state — no half-built order persists; no name on screen; no half-confirmed action.
|
|
86
|
+
- Reset returns to a designed idle / attractor state, not to "whatever Canvas was loaded".
|
|
87
|
+
|
|
88
|
+
**Must Have:** verified idle reset behaviour via Automation or live test; verified that no leaked state persists to next session.
|
|
89
|
+
**Anti-Pattern:** idle = last interact Canvas; idle that requires operator to manually reset.
|
|
90
|
+
|
|
91
|
+
## HIGH — must fix before launch
|
|
92
|
+
|
|
93
|
+
### H-1. Affordance is unambiguous
|
|
94
|
+
|
|
95
|
+
Every pressable Brick declares "press me" visually — contrast, weight, motion, or icon. Affordance vocabulary is consistent across the deployment.
|
|
96
|
+
|
|
97
|
+
**Must Have:** pressable tiles visually distinct from non-pressable; squint test confirms which Bricks are interactive.
|
|
98
|
+
**Anti-Pattern:** identical-looking tiles where some are pressable and some aren't; pressable Bricks with no visual distinction from background.
|
|
99
|
+
|
|
100
|
+
### H-2. Press feedback at registration
|
|
101
|
+
|
|
102
|
+
Every `on_press` produces a visible state change at the moment of registration — scale, opacity, color, or new Brick entry via Standby Transition. Not a fade-in.
|
|
103
|
+
|
|
104
|
+
**Must Have:** Brick under press visibly responds within 100ms (effectively snap, not fade).
|
|
105
|
+
**Anti-Pattern:** press registers, no visible change; press relies on Canvas-change-only feedback (user perceives lag).
|
|
106
|
+
|
|
107
|
+
### H-3. Flow states designed, not skipped
|
|
108
|
+
|
|
109
|
+
Idle / loading / empty / error / boot / maintenance (as applicable to the deployment) are designed states, each with verified preview.
|
|
110
|
+
|
|
111
|
+
**Must Have:** every applicable state's preview captured and reviewed; failure modes per state checked against `flow-states.md`.
|
|
112
|
+
**Anti-Pattern:** "empty state is fine, the list is always populated" without testing the empty case; error state in 8pt corner text; boot = loading spinner.
|
|
113
|
+
|
|
114
|
+
### H-4. Hero continuity across journey Canvases
|
|
115
|
+
|
|
116
|
+
For multi-Canvas flows, hero Bricks share ids across Canvases — chrome (logo, progress indicator, time, back action) carries via Truth #3 auto-tween.
|
|
117
|
+
|
|
118
|
+
**Must Have:** primary chrome elements identifiable in the same screen positions across the flow's Canvases.
|
|
119
|
+
**Anti-Pattern:** every Canvas remounts its full Brick set; user loses spatial mental model between steps.
|
|
120
|
+
|
|
121
|
+
### H-5. Error recovery has a path
|
|
122
|
+
|
|
123
|
+
Every error state offers retry, alternate method, abandon, or help — never a dead-end. Different error categories get distinguishable recovery treatments.
|
|
124
|
+
|
|
125
|
+
**Must Have:** each error path verified end-to-end via Automation or live test.
|
|
126
|
+
**Anti-Pattern:** "Error. Please try again." with no retry mechanism; generic recovery for all error types.
|
|
127
|
+
|
|
128
|
+
### H-6. Stale-data trust
|
|
129
|
+
|
|
130
|
+
For monitoring / live-data screens, every dynamic source has a visibly declared staleness state or a visible "last update" relative-time indicator.
|
|
131
|
+
|
|
132
|
+
**Must Have:** staleness visible in peripheral vision; stale value distinguishable from current value.
|
|
133
|
+
**Anti-Pattern:** dynamic value with no age indication; "last update" in 8pt absolute timestamp.
|
|
134
|
+
|
|
135
|
+
### H-7. Predictable navigation
|
|
136
|
+
|
|
137
|
+
Navigation affordances (back, next, home) sit consistently across Canvases. Idle returns to the same idle Canvas every time.
|
|
138
|
+
|
|
139
|
+
**Must Have:** back / next affordance positions verified across Canvases; idle reset produces identical idle Canvas every time.
|
|
140
|
+
**Anti-Pattern:** back button at top-left on Canvas 2, bottom-right on Canvas 3; idle rotates such that the "anchor" element moves.
|
|
141
|
+
|
|
142
|
+
## MEDIUM — impacts polish; prioritize by user impact
|
|
143
|
+
|
|
144
|
+
### M-1. Instruction matches user mental model
|
|
145
|
+
|
|
146
|
+
Action instructions ("Scan your code", "Tap to start", "Pay now") match the user's likely understanding; jargon avoided; language locale-matched.
|
|
147
|
+
|
|
148
|
+
**Must Have:** wording reviewed for the actual audience; jargon removed.
|
|
149
|
+
**Anti-Pattern:** "Initiate authentication sequence" on a public kiosk; English-only instruction on a multilingual venue.
|
|
150
|
+
|
|
151
|
+
### M-2. Continuation is non-surprising
|
|
152
|
+
|
|
153
|
+
The Canvas the user lands on after an action matches their expectation. Big jumps in journey context happen only with explicit transition.
|
|
154
|
+
|
|
155
|
+
**Must Have:** continuation Canvas reviewed for context preservation; hero continuity in place.
|
|
156
|
+
**Anti-Pattern:** success on Canvas A jumps to Canvas D mid-flow; user loses context.
|
|
157
|
+
|
|
158
|
+
### M-3. Closure proportional to stakes
|
|
159
|
+
|
|
160
|
+
Success closure hold time and visual weight match the action's stakes. Routine completions get brief acknowledgement; transact completions get held visible.
|
|
161
|
+
|
|
162
|
+
**Must Have:** closure hold time tuned to action stakes; auto-advance only after enough time for the user to read.
|
|
163
|
+
**Anti-Pattern:** 1.5s closure for a transact flow; 8s closure for a "saved to favorites" toast.
|
|
164
|
+
|
|
165
|
+
### M-4. Density rhythm in browse / dwell
|
|
166
|
+
|
|
167
|
+
For browse / dwell deployments, content rotation has variation in density / framing / colour rhythm across Canvases or slides. Three identical-rhythm Canvases in a row is a tell. (Cross-reference: `bricks-design/design-critique.md` density-rhythm collapse.)
|
|
168
|
+
|
|
169
|
+
**Must Have:** rhythm variation across the sequence; no three identical-archetype Canvases in a row.
|
|
170
|
+
**Anti-Pattern:** ten Canvases that all read as "headline + bullet list".
|
|
171
|
+
|
|
172
|
+
### M-5. Audio cues calibrated (when hardware allows)
|
|
173
|
+
|
|
174
|
+
If the deployment uses audio, volume / timing / time-of-day awareness is intentional.
|
|
175
|
+
|
|
176
|
+
**Must Have:** audio volume / scheduling reviewed; success / alarm cues distinguishable from ambient.
|
|
177
|
+
**Anti-Pattern:** constant-volume cues regardless of time; audio-only confirmation (no visual pair).
|
|
178
|
+
|
|
179
|
+
### M-6. Reduced-motion path available (if relevant)
|
|
180
|
+
|
|
181
|
+
For deployments in clinical / safety / motion-sensitive contexts, a reduced-motion path exists.
|
|
182
|
+
|
|
183
|
+
**Must Have:** `reduceMotion` Data flag wired where applicable; verified reduced-motion preview.
|
|
184
|
+
**Anti-Pattern:** continuous-motion design with no reduction path for a clinical deployment.
|
|
185
|
+
|
|
186
|
+
## LOW — context-dependent
|
|
187
|
+
|
|
188
|
+
### L-1. Polish on idle / attractor presence
|
|
189
|
+
|
|
190
|
+
For deployments where idle dominates: idle is *inviting*, not just *running*.
|
|
191
|
+
|
|
192
|
+
**Must Have for high-traffic public deployments:** attractor sequence engages from peripheral vision.
|
|
193
|
+
**Anti-Pattern:** logo-only idle on a deployment whose purpose is to invite interaction.
|
|
194
|
+
|
|
195
|
+
### L-2. Maintenance state designed
|
|
196
|
+
|
|
197
|
+
If the deployment has scheduled downtime, a maintenance Canvas exists and distinguishes itself from error.
|
|
198
|
+
|
|
199
|
+
**Must Have for deployments with maintenance windows:** maintenance Canvas with return path.
|
|
200
|
+
**Anti-Pattern:** maintenance = black screen.
|
|
201
|
+
|
|
202
|
+
### L-3. Empty-state composition
|
|
203
|
+
|
|
204
|
+
Empty states explain the absence and suggest what populates.
|
|
205
|
+
|
|
206
|
+
**Must Have:** empty state designed rather than collapsed-whitespace.
|
|
207
|
+
**Anti-Pattern:** "—" or blank where content would be.
|
|
208
|
+
|
|
209
|
+
## Tier-by-tier checklist (running order)
|
|
210
|
+
|
|
211
|
+
Use this when running the pass:
|
|
212
|
+
|
|
213
|
+
**CRITICAL (always run):**
|
|
214
|
+
|
|
215
|
+
- [ ] User-journey spine whole (CR-1)
|
|
216
|
+
- [ ] Transact intensified if applicable (CR-2)
|
|
217
|
+
- [ ] Monitoring demand discipline if applicable (CR-3)
|
|
218
|
+
- [ ] Accessibility floors met (CR-4)
|
|
219
|
+
- [ ] Idle reset clean if applicable (CR-5)
|
|
220
|
+
|
|
221
|
+
**HIGH (always run except for glance / dwell loops):**
|
|
222
|
+
|
|
223
|
+
- [ ] Affordance unambiguous (H-1)
|
|
224
|
+
- [ ] Press feedback at registration (H-2)
|
|
225
|
+
- [ ] Flow states designed (H-3)
|
|
226
|
+
- [ ] Hero continuity across Canvases (H-4)
|
|
227
|
+
- [ ] Error recovery has a path (H-5)
|
|
228
|
+
- [ ] Stale-data trust if applicable (H-6)
|
|
229
|
+
- [ ] Predictable navigation (H-7)
|
|
230
|
+
|
|
231
|
+
**MEDIUM (run for interact / transact / browse):**
|
|
232
|
+
|
|
233
|
+
- [ ] Instruction matches mental model (M-1)
|
|
234
|
+
- [ ] Continuation non-surprising (M-2)
|
|
235
|
+
- [ ] Closure proportional (M-3)
|
|
236
|
+
- [ ] Density rhythm (M-4)
|
|
237
|
+
- [ ] Audio cues calibrated (M-5)
|
|
238
|
+
- [ ] Reduced-motion path (M-6)
|
|
239
|
+
|
|
240
|
+
**LOW (run for public-facing / high-dwell):**
|
|
241
|
+
|
|
242
|
+
- [ ] Idle / attractor polish (L-1)
|
|
243
|
+
- [ ] Maintenance state (L-2)
|
|
244
|
+
- [ ] Empty-state composition (L-3)
|
|
245
|
+
|
|
246
|
+
## Definition of UX done
|
|
247
|
+
|
|
248
|
+
A flow is UX-done when:
|
|
249
|
+
|
|
250
|
+
1. The CRITICAL tier passes — zero unaddressed CRITICAL items.
|
|
251
|
+
2. The HIGH tier passes — zero unaddressed HIGH items (or surfaced as accepted trade-off with rationale).
|
|
252
|
+
3. Applicable MEDIUM / LOW items either pass or are surfaced.
|
|
253
|
+
4. Every state (golden path + error categories + idle + empty if relevant) has been verified via preview screenshot or Automation, and reviewed.
|
|
254
|
+
5. Accessibility floors are met at the deployment-relative threshold, not at a desktop default.
|
|
255
|
+
|
|
256
|
+
If any item is unmet, the work is mid-iteration. Say so explicitly to the user; offer a precise list of what remains.
|
package/tools/_git-author.ts
CHANGED
|
@@ -15,7 +15,15 @@ async function hasGitIdentity(cwd: string): Promise<boolean> {
|
|
|
15
15
|
// If no identity is configured (typical for non-tech users), CTOR becomes the
|
|
16
16
|
// main author via per-command `-c user.name/-c user.email` overrides so the
|
|
17
17
|
// user's git config is left untouched.
|
|
18
|
-
|
|
18
|
+
//
|
|
19
|
+
// `extraFlags` are inserted between `commit` and the `-m` args (e.g.
|
|
20
|
+
// `['--no-verify']` to bypass pre-commit hooks for controlled cases like
|
|
21
|
+
// committing merge-conflict markers).
|
|
22
|
+
export async function buildCommitArgs(
|
|
23
|
+
cwd: string,
|
|
24
|
+
messages: string[],
|
|
25
|
+
extraFlags: string[] = [],
|
|
26
|
+
): Promise<string[]> {
|
|
19
27
|
const hasIdentity = await hasGitIdentity(cwd)
|
|
20
28
|
const prefix = hasIdentity
|
|
21
29
|
? []
|
|
@@ -23,7 +31,7 @@ export async function buildCommitArgs(cwd: string, messages: string[]): Promise<
|
|
|
23
31
|
const msgArgs: string[] = []
|
|
24
32
|
for (const m of messages) msgArgs.push('-m', m)
|
|
25
33
|
if (hasIdentity) msgArgs.push('-m', CTOR_COAUTHOR_TRAILER)
|
|
26
|
-
return [...prefix, 'commit', ...msgArgs]
|
|
34
|
+
return [...prefix, 'commit', ...extraFlags, ...msgArgs]
|
|
27
35
|
}
|
|
28
36
|
|
|
29
37
|
export { CTOR_NAME, CTOR_EMAIL, CTOR_COAUTHOR_TRAILER }
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises'
|
|
2
|
+
|
|
3
|
+
// Local sync marker: the git commit hash that was on HEAD when we last
|
|
4
|
+
// successfully pushed to the server (deploy or update-config) or pulled
|
|
5
|
+
// from it. Stored at the `.bricks/` top level (gitignored explicitly) — it's
|
|
6
|
+
// per-clone state, not a build artifact, so it doesn't belong under
|
|
7
|
+
// `.bricks/build/`.
|
|
8
|
+
//
|
|
9
|
+
// Why this exists: server's `bricks_project_last_commit_id` can be an opaque
|
|
10
|
+
// nanoid for content-only edits (config-editor saves), so it isn't a
|
|
11
|
+
// reliable git anchor for `git checkout` during pull. The local marker is
|
|
12
|
+
// always a real reachable commit hash from THIS clone.
|
|
13
|
+
const REL_PATH = '.bricks/.last-pushed-commit'
|
|
14
|
+
|
|
15
|
+
export async function readLastPushedCommit(cwd: string): Promise<string | null> {
|
|
16
|
+
try {
|
|
17
|
+
const content = await readFile(`${cwd}/${REL_PATH}`, 'utf8')
|
|
18
|
+
return content.trim() || null
|
|
19
|
+
} catch {
|
|
20
|
+
return null
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function writeLastPushedCommit(cwd: string, commitId: string): Promise<void> {
|
|
25
|
+
if (!commitId) return
|
|
26
|
+
await mkdir(`${cwd}/.bricks`, { recursive: true })
|
|
27
|
+
await writeFile(`${cwd}/${REL_PATH}`, commitId)
|
|
28
|
+
}
|
package/tools/deploy.ts
CHANGED
|
@@ -2,6 +2,11 @@ import { access, readFile, writeFile } from 'node:fs/promises'
|
|
|
2
2
|
import { parseArgs } from 'util'
|
|
3
3
|
import { sh } from './_shell'
|
|
4
4
|
import { buildCommitArgs } from './_git-author'
|
|
5
|
+
import { writeLastPushedCommit } from './_last-pushed-commit'
|
|
6
|
+
|
|
7
|
+
if (!process.env.BRICKS_RELEASE_SIGN) {
|
|
8
|
+
process.env.BRICKS_RELEASE_SIGN = 'CTOR'
|
|
9
|
+
}
|
|
5
10
|
|
|
6
11
|
const cwd = process.cwd()
|
|
7
12
|
|
|
@@ -141,6 +146,10 @@ await writeFile(configPath, JSON.stringify(releaseConfig))
|
|
|
141
146
|
|
|
142
147
|
const args = ['bricks', command, 'release', app.id, '-c', configPath, '--json']
|
|
143
148
|
|
|
149
|
+
if (app.name) {
|
|
150
|
+
args.push('--name', app.name)
|
|
151
|
+
}
|
|
152
|
+
|
|
144
153
|
if (version) {
|
|
145
154
|
args.push('--version', version)
|
|
146
155
|
}
|
|
@@ -162,4 +171,10 @@ if (result.exitCode !== 0) {
|
|
|
162
171
|
}
|
|
163
172
|
|
|
164
173
|
const output = JSON.parse(result.stdout.toString())
|
|
174
|
+
|
|
175
|
+
// Record the commit we just pushed from so a later pull can use it as the
|
|
176
|
+
// merge base regardless of what the server stores in
|
|
177
|
+
// bricks_project_last_commit_id.
|
|
178
|
+
if (commitId) await writeLastPushedCommit(cwd, commitId)
|
|
179
|
+
|
|
165
180
|
console.log(`${isModule ? 'Module' : 'App'} deployed: ${output.name}`)
|
package/tools/preview-main.mjs
CHANGED
|
@@ -6,6 +6,12 @@ import { createServer } from 'http'
|
|
|
6
6
|
import { parseArgs } from 'util'
|
|
7
7
|
import * as TOON from '@toon-format/toon'
|
|
8
8
|
|
|
9
|
+
for (const stream of [process.stdout, process.stderr]) {
|
|
10
|
+
stream.on('error', (err) => {
|
|
11
|
+
if (err.code !== 'EPIPE') throw err
|
|
12
|
+
})
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
const { values } = parseArgs({
|
|
10
16
|
args: process.argv,
|
|
11
17
|
options: {
|
|
@@ -224,16 +230,23 @@ app.on('ready', () => {
|
|
|
224
230
|
)
|
|
225
231
|
if (takeScreenshotConfig) {
|
|
226
232
|
const { delay, width, height, path } = takeScreenshotConfig
|
|
227
|
-
setTimeout(() => {
|
|
233
|
+
setTimeout(async () => {
|
|
234
|
+
let screenshotFailed = false
|
|
228
235
|
console.log('Taking screenshot')
|
|
229
|
-
|
|
236
|
+
try {
|
|
237
|
+
const image = await mainWindow.webContents.capturePage()
|
|
230
238
|
console.log('Writing screenshot to', path)
|
|
231
|
-
writeFile(path, image.resize({ width, height }).toJPEG(75))
|
|
239
|
+
await writeFile(path, image.resize({ width, height }).toJPEG(75))
|
|
240
|
+
} catch (err) {
|
|
241
|
+
screenshotFailed = true
|
|
242
|
+
console.error('Screenshot capture/write failed', err)
|
|
243
|
+
} finally {
|
|
232
244
|
if (noKeepOpen) {
|
|
233
245
|
console.log('Closing app')
|
|
234
|
-
app.
|
|
246
|
+
if (screenshotFailed) app.exit(1)
|
|
247
|
+
else app.quit()
|
|
235
248
|
}
|
|
236
|
-
}
|
|
249
|
+
}
|
|
237
250
|
}, delay)
|
|
238
251
|
}
|
|
239
252
|
}
|
package/tools/pull.ts
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
1
|
-
import { readFile, writeFile } from 'node:fs/promises'
|
|
1
|
+
import { readdir, readFile, unlink, writeFile } from 'node:fs/promises'
|
|
2
|
+
import { existsSync } from 'node:fs'
|
|
3
|
+
import { join, relative } from 'node:path'
|
|
2
4
|
import { format } from 'oxfmt'
|
|
3
5
|
import { sh } from './_shell'
|
|
4
6
|
import { buildCommitArgs } from './_git-author'
|
|
7
|
+
import { readLastPushedCommit, writeLastPushedCommit } from './_last-pushed-commit'
|
|
8
|
+
|
|
9
|
+
// Directories whose .ts contents are entirely owned by the generator.
|
|
10
|
+
// Anything under these dirs not present in the freshly pulled file list is an orphan.
|
|
11
|
+
const ownedTsDirs = ['subspaces', 'automation-tests']
|
|
12
|
+
|
|
13
|
+
async function walkTsFiles(dir: string, baseDir: string): Promise<string[]> {
|
|
14
|
+
if (!existsSync(dir)) return []
|
|
15
|
+
const result: string[] = []
|
|
16
|
+
const entries = await readdir(dir, { withFileTypes: true })
|
|
17
|
+
await Promise.all(
|
|
18
|
+
entries.map(async (entry) => {
|
|
19
|
+
const full = join(dir, entry.name)
|
|
20
|
+
if (entry.isDirectory()) {
|
|
21
|
+
result.push(...(await walkTsFiles(full, baseDir)))
|
|
22
|
+
} else if (entry.isFile() && entry.name.endsWith('.ts')) {
|
|
23
|
+
result.push(relative(baseDir, full))
|
|
24
|
+
}
|
|
25
|
+
}),
|
|
26
|
+
)
|
|
27
|
+
return result
|
|
28
|
+
}
|
|
5
29
|
|
|
6
30
|
const cwd = process.cwd()
|
|
7
31
|
const args = process.argv.slice(2)
|
|
@@ -52,30 +76,40 @@ if (result.exitCode !== 0) {
|
|
|
52
76
|
}
|
|
53
77
|
}
|
|
54
78
|
|
|
55
|
-
const { files, lastCommitId } = JSON.parse(result.stdout.toString())
|
|
79
|
+
const { files, lastCommitId: serverLastCommitId } = JSON.parse(result.stdout.toString())
|
|
80
|
+
|
|
81
|
+
// The locally-saved commit (recorded by deploy/update-config) is the
|
|
82
|
+
// authoritative merge base for THIS clone — the server's value can be an
|
|
83
|
+
// opaque nanoid (config-only updates) or point to a commit other clients
|
|
84
|
+
// produced. Fall back to the server's value only if we have no local
|
|
85
|
+
// record yet.
|
|
86
|
+
const savedLocalCommitId = await readLastPushedCommit(cwd)
|
|
87
|
+
const baseCommitId = savedLocalCommitId || serverLastCommitId
|
|
88
|
+
|
|
89
|
+
const branchName = isModule
|
|
90
|
+
? 'BRICKS_PROJECT_try-pull-module'
|
|
91
|
+
: 'BRICKS_PROJECT_try-pull-application'
|
|
56
92
|
|
|
57
|
-
let useMain = false
|
|
58
93
|
if (isGitRepo && !force) {
|
|
59
|
-
console.log(`Checking commit ${
|
|
60
|
-
const found = (await sh`cd ${cwd} && git rev-list -1 ${
|
|
94
|
+
console.log(`Checking commit ${baseCommitId}...`)
|
|
95
|
+
const found = (await sh`cd ${cwd} && git rev-list -1 ${baseCommitId}`.nothrow().text())
|
|
61
96
|
.trim()
|
|
62
97
|
.match(/^[\da-f]{40}$/)
|
|
63
98
|
|
|
64
|
-
const
|
|
99
|
+
const headCommitId = (await sh`cd ${cwd} && git rev-parse HEAD`.text()).trim()
|
|
65
100
|
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
const branchName = isModule
|
|
69
|
-
? 'BRICKS_PROJECT_try-pull-module'
|
|
70
|
-
: 'BRICKS_PROJECT_try-pull-application'
|
|
101
|
+
if (headCommitId === serverLastCommitId) throw new Error('Commit not changed')
|
|
71
102
|
|
|
72
103
|
await sh`cd ${cwd} && git branch -D ${branchName}`.nothrow()
|
|
73
104
|
|
|
105
|
+
// When the base commit isn't reachable in this clone (server stored a
|
|
106
|
+
// nanoid, or the commit was pruned), fall back to forking from current
|
|
107
|
+
// HEAD. The downstream merge into main collapses both paths into the
|
|
108
|
+
// same result, just with different merge bases.
|
|
74
109
|
if (found) {
|
|
75
|
-
await sh`cd ${cwd} && git checkout -b ${branchName} ${
|
|
110
|
+
await sh`cd ${cwd} && git checkout -b ${branchName} ${baseCommitId}`.nothrow()
|
|
76
111
|
} else {
|
|
77
112
|
await sh`cd ${cwd} && git checkout -b ${branchName}`
|
|
78
|
-
useMain = true
|
|
79
113
|
}
|
|
80
114
|
}
|
|
81
115
|
|
|
@@ -89,6 +123,23 @@ const oxfmtConfig = await readFile(`${cwd}/.oxfmtrc.json`, 'utf8')
|
|
|
89
123
|
printWidth: 100,
|
|
90
124
|
}))
|
|
91
125
|
|
|
126
|
+
const expectedFiles = new Set(files.map((file: { name: string }) => file.name))
|
|
127
|
+
|
|
128
|
+
// Remove orphan .ts files under generator-owned directories before writing.
|
|
129
|
+
// File paths are produced by buildApplicationFiles and use forward slashes,
|
|
130
|
+
// so normalise the walked paths the same way for comparison.
|
|
131
|
+
const orphans: string[] = []
|
|
132
|
+
await Promise.all(
|
|
133
|
+
ownedTsDirs.map(async (dir) => {
|
|
134
|
+
const existing = await walkTsFiles(join(cwd, dir), cwd)
|
|
135
|
+
for (const file of existing) {
|
|
136
|
+
const normalized = file.split(/[\\/]/).join('/')
|
|
137
|
+
if (!expectedFiles.has(normalized)) orphans.push(normalized)
|
|
138
|
+
}
|
|
139
|
+
}),
|
|
140
|
+
)
|
|
141
|
+
await Promise.all(orphans.map((name) => unlink(`${cwd}/${name}`)))
|
|
142
|
+
|
|
92
143
|
await Promise.all(
|
|
93
144
|
files.map(async (file: { name: string; input: string; formatable?: boolean }) => {
|
|
94
145
|
let content = file.input
|
|
@@ -112,11 +163,35 @@ if (isGitRepo) {
|
|
|
112
163
|
const commitArgs = await buildCommitArgs(cwd, [commitMsg])
|
|
113
164
|
await sh`cd ${cwd} && git ${commitArgs}`
|
|
114
165
|
}
|
|
115
|
-
if (!force
|
|
116
|
-
|
|
166
|
+
if (!force) {
|
|
167
|
+
// Land the pulled commits on main with a single 3-way merge using
|
|
168
|
+
// baseCommit as the merge base. The user doesn't have to manage a side
|
|
169
|
+
// branch, and conflicts (if any) land in the working tree on main where
|
|
170
|
+
// auto-compile surfaces them as typecheck errors to resolve in-place.
|
|
171
|
+
await sh`cd ${cwd} && git checkout main`
|
|
172
|
+
const mergeResult = await sh`cd ${cwd} && git merge ${branchName} --no-edit`.nothrow()
|
|
173
|
+
if (mergeResult.exitCode !== 0) {
|
|
174
|
+
// Conflict markers are in the working tree — commit them so the tree
|
|
175
|
+
// is clean for auto-compile to detect, leaving the resolution to the
|
|
176
|
+
// user. Pre-commit hooks would reject markers (lint/format fail on
|
|
177
|
+
// invalid syntax), so bypass them for this controlled case.
|
|
178
|
+
await sh`cd ${cwd} && git add .`
|
|
179
|
+
const conflictArgs = await buildCommitArgs(
|
|
180
|
+
cwd,
|
|
181
|
+
['chore(project): merge with conflicts (resolve in main)'],
|
|
182
|
+
['--no-verify'],
|
|
183
|
+
)
|
|
184
|
+
await sh`cd ${cwd} && git ${conflictArgs}`
|
|
185
|
+
}
|
|
186
|
+
// The try-pull branch served its purpose; delete it so `git branch`
|
|
187
|
+
// stays tidy. The next pull recreates it anyway (line 103).
|
|
188
|
+
await sh`cd ${cwd} && git branch -D ${branchName}`.nothrow()
|
|
117
189
|
}
|
|
190
|
+
// Record the new sync point so a follow-up pull starts from the right base.
|
|
191
|
+
const newHead = (await sh`cd ${cwd} && git rev-parse HEAD`.nothrow().text()).trim()
|
|
192
|
+
if (newHead) await writeLastPushedCommit(cwd, newHead)
|
|
118
193
|
}
|
|
119
194
|
|
|
120
195
|
console.log(
|
|
121
|
-
`${isModule ? 'Module' : 'App'} project pulled: ${files.length} files${force ? ' (force)' : ''}`,
|
|
196
|
+
`${isModule ? 'Module' : 'App'} project pulled: ${files.length} files${orphans.length ? `, removed ${orphans.length} orphan .ts file${orphans.length === 1 ? '' : 's'}` : ''}${force ? ' (force)' : ''}`,
|
|
122
197
|
)
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { readFile, writeFile } from 'node:fs/promises'
|
|
2
|
+
import { parseArgs } from 'util'
|
|
3
|
+
import { sh } from './_shell'
|
|
4
|
+
import { buildCommitArgs } from './_git-author'
|
|
5
|
+
import { writeLastPushedCommit } from './_last-pushed-commit'
|
|
6
|
+
|
|
7
|
+
const cwd = process.cwd()
|
|
8
|
+
|
|
9
|
+
const readJson = async (p: string) => JSON.parse(await readFile(p, 'utf8'))
|
|
10
|
+
|
|
11
|
+
const {
|
|
12
|
+
values: { 'auto-commit': autoCommit, 'no-check': noCheck, 'no-validate': noValidate, yes, help },
|
|
13
|
+
} = parseArgs({
|
|
14
|
+
args: process.argv.slice(2),
|
|
15
|
+
options: {
|
|
16
|
+
'auto-commit': { type: 'boolean' },
|
|
17
|
+
'no-check': { type: 'boolean' },
|
|
18
|
+
'no-validate': { type: 'boolean' },
|
|
19
|
+
yes: { type: 'boolean', short: 'y' },
|
|
20
|
+
help: { type: 'boolean', short: 'h' },
|
|
21
|
+
},
|
|
22
|
+
allowPositionals: true,
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
if (help) {
|
|
26
|
+
console.log(`Push compiled config to BRICKS without creating a release.
|
|
27
|
+
|
|
28
|
+
Options:
|
|
29
|
+
--auto-commit Auto-commit unstaged changes before pushing
|
|
30
|
+
--no-check Skip the conflict guard (don't pass --last-commit-id)
|
|
31
|
+
--no-validate Skip server-side config schema validation
|
|
32
|
+
-y, --yes Skip all prompts
|
|
33
|
+
-h, --help Show this help message`)
|
|
34
|
+
process.exit(0)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Detect git repo (mirrors deploy.ts)
|
|
38
|
+
const { exitCode } = await sh`cd ${cwd} && git status`.quiet().nothrow()
|
|
39
|
+
const isGitRepo = exitCode === 0
|
|
40
|
+
|
|
41
|
+
if (!isGitRepo && !yes) {
|
|
42
|
+
const confirmContinue = prompt('No git repository found, continue? (y/n)')
|
|
43
|
+
if (confirmContinue !== 'y') throw new Error('Update cancelled')
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Read application.json + compiled config
|
|
47
|
+
const app = await readJson(`${cwd}/application.json`)
|
|
48
|
+
const config = await readJson(`${cwd}/.bricks/build/application-config.json`)
|
|
49
|
+
|
|
50
|
+
// Handle unstaged changes the same way deploy.ts does.
|
|
51
|
+
let commitId = ''
|
|
52
|
+
let parentCommitId = ''
|
|
53
|
+
if (isGitRepo) {
|
|
54
|
+
const unstagedChanges = await sh`cd ${cwd} && git diff --name-only --diff-filter=ACMR`.text()
|
|
55
|
+
if (unstagedChanges) {
|
|
56
|
+
if (autoCommit) {
|
|
57
|
+
// Capture the pre-commit HEAD so we can use it as the conflict-check
|
|
58
|
+
// baseline (the server should still hold it from the prior deploy).
|
|
59
|
+
parentCommitId = (await sh`cd ${cwd} && git rev-parse HEAD`.nothrow().text()).trim()
|
|
60
|
+
await sh`cd ${cwd} && git add -A`
|
|
61
|
+
const commitArgs = await buildCommitArgs(cwd, ['chore: update bricks config'])
|
|
62
|
+
await sh`cd ${cwd} && git ${commitArgs}`
|
|
63
|
+
} else {
|
|
64
|
+
throw new Error('Unstaged changes found, please commit or stash your changes before updating')
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
commitId = (await sh`cd ${cwd} && git rev-parse HEAD`.text()).trim()
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Auto-derive --last-commit-id for the server-side conflict guard.
|
|
71
|
+
// - parent of the auto-commit (server still holds it from the prior deploy)
|
|
72
|
+
// - current HEAD (clean tree — server should be at the same commit too)
|
|
73
|
+
let lastCommitId: string | undefined
|
|
74
|
+
if (!noCheck) {
|
|
75
|
+
if (parentCommitId) lastCommitId = parentCommitId
|
|
76
|
+
else if (commitId) lastCommitId = commitId
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!yes) {
|
|
80
|
+
const confirm = prompt('Are you sure you want to push the new config? (y/n)')
|
|
81
|
+
if (confirm !== 'y') throw new Error('Update cancelled')
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const isModule = app.type === 'module'
|
|
85
|
+
const command = isModule ? 'module' : 'app'
|
|
86
|
+
|
|
87
|
+
const updateConfig = {
|
|
88
|
+
...config,
|
|
89
|
+
bricks_project_last_commit_id: commitId || undefined,
|
|
90
|
+
}
|
|
91
|
+
const configPath = `${cwd}/.bricks/build/update-config.json`
|
|
92
|
+
await writeFile(configPath, JSON.stringify(updateConfig))
|
|
93
|
+
|
|
94
|
+
const args = ['bricks', command, 'update', app.id, '-f', configPath, '--json']
|
|
95
|
+
if (noValidate) args.push('--no-validate')
|
|
96
|
+
if (lastCommitId) args.push('--last-commit-id', lastCommitId)
|
|
97
|
+
|
|
98
|
+
const result = await sh`${args}`.quiet().nothrow()
|
|
99
|
+
|
|
100
|
+
if (result.exitCode !== 0) {
|
|
101
|
+
const output = result.stderr.toString() || result.stdout.toString()
|
|
102
|
+
try {
|
|
103
|
+
const json = JSON.parse(output)
|
|
104
|
+
throw new Error(json.error?.message || json.error || 'Update failed')
|
|
105
|
+
} catch {
|
|
106
|
+
throw new Error(output || 'Update failed')
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const output = JSON.parse(result.stdout.toString())
|
|
111
|
+
|
|
112
|
+
// Record the commit we just pushed from so a later pull can use it as the
|
|
113
|
+
// merge base regardless of what the server stores in
|
|
114
|
+
// bricks_project_last_commit_id (which may be an opaque nanoid for
|
|
115
|
+
// content-only edits).
|
|
116
|
+
if (commitId) await writeLastPushedCommit(cwd, commitId)
|
|
117
|
+
|
|
118
|
+
console.log(`${isModule ? 'Module' : 'App'} config updated: ${output.target?.name || app.name}`)
|