@fugood/bricks-project 2.24.0-beta.2 → 2.24.0-beta.21
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/action-name-map.ts +14 -0
- package/compile/index.ts +377 -129
- package/package.json +8 -3
- package/skills/bricks-project/rules/architecture-patterns.md +7 -0
- package/skills/bricks-project/rules/automations.md +74 -28
- package/skills/bricks-project/rules/buttress.md +9 -6
- package/tools/deploy.ts +39 -10
- package/tools/mcp-server.ts +10 -877
- package/tools/mcp-tools/compile.ts +91 -0
- package/tools/mcp-tools/huggingface.ts +762 -0
- package/tools/mcp-tools/icons.ts +60 -0
- package/tools/mcp-tools/lottie.ts +102 -0
- package/tools/mcp-tools/media.ts +110 -0
- package/tools/postinstall.ts +121 -33
- package/tools/preview-main.mjs +12 -8
- package/tools/pull.ts +37 -19
- package/tsconfig.json +16 -0
- package/types/animation.ts +4 -0
- package/types/automation.ts +3 -0
- package/types/brick-base.ts +1 -1
- package/types/bricks/Camera.ts +34 -7
- package/types/bricks/Chart.ts +1 -1
- package/types/bricks/GenerativeMedia.ts +6 -6
- package/types/bricks/Icon.ts +3 -3
- package/types/bricks/Image.ts +4 -4
- package/types/bricks/Items.ts +7 -7
- package/types/bricks/Lottie.ts +4 -4
- package/types/bricks/Maps.ts +4 -4
- package/types/bricks/QrCode.ts +4 -4
- package/types/bricks/Rect.ts +4 -4
- package/types/bricks/RichText.ts +3 -3
- package/types/bricks/Rive.ts +1 -1
- package/types/bricks/Slideshow.ts +4 -4
- package/types/bricks/Svg.ts +3 -3
- package/types/bricks/Text.ts +4 -4
- package/types/bricks/TextInput.ts +11 -7
- package/types/bricks/Video.ts +4 -4
- package/types/bricks/VideoStreaming.ts +3 -3
- package/types/bricks/WebRtcStream.ts +1 -1
- package/types/bricks/WebView.ts +4 -4
- package/types/canvas.ts +4 -2
- package/types/common.ts +9 -4
- package/types/data-calc-command.ts +2 -0
- package/types/data-calc.ts +1 -0
- package/types/data.ts +2 -0
- package/types/generators/AlarmClock.ts +5 -5
- package/types/generators/Assistant.ts +57 -12
- package/types/generators/BleCentral.ts +12 -4
- package/types/generators/BlePeripheral.ts +5 -5
- package/types/generators/CanvasMap.ts +4 -4
- package/types/generators/CastlesPay.ts +3 -3
- package/types/generators/DataBank.ts +31 -4
- package/types/generators/File.ts +63 -14
- package/types/generators/GraphQl.ts +3 -3
- package/types/generators/Http.ts +27 -8
- package/types/generators/HttpServer.ts +9 -9
- package/types/generators/Information.ts +2 -2
- package/types/generators/Intent.ts +8 -2
- package/types/generators/Iterator.ts +6 -6
- package/types/generators/Keyboard.ts +18 -8
- package/types/generators/LlmAnthropicCompat.ts +12 -6
- package/types/generators/LlmAppleBuiltin.ts +6 -6
- package/types/generators/LlmGgml.ts +75 -25
- package/types/generators/LlmMlx.ts +210 -0
- package/types/generators/LlmOnnx.ts +18 -9
- package/types/generators/LlmOpenAiCompat.ts +22 -6
- package/types/generators/LlmQualcommAiEngine.ts +32 -8
- package/types/generators/Mcp.ts +332 -17
- package/types/generators/McpServer.ts +38 -11
- package/types/generators/MediaFlow.ts +26 -8
- package/types/generators/MqttBroker.ts +10 -4
- package/types/generators/MqttClient.ts +11 -5
- package/types/generators/Question.ts +6 -6
- package/types/generators/RealtimeTranscription.ts +70 -11
- package/types/generators/RerankerGgml.ts +23 -9
- package/types/generators/SerialPort.ts +6 -6
- package/types/generators/SoundPlayer.ts +2 -2
- package/types/generators/SoundRecorder.ts +5 -5
- package/types/generators/SpeechToTextGgml.ts +34 -14
- package/types/generators/SpeechToTextOnnx.ts +8 -8
- package/types/generators/SpeechToTextPlatform.ts +4 -4
- package/types/generators/SqLite.ts +10 -6
- package/types/generators/Step.ts +3 -3
- package/types/generators/SttAppleBuiltin.ts +6 -6
- package/types/generators/Tcp.ts +5 -5
- package/types/generators/TcpServer.ts +7 -7
- package/types/generators/TextToSpeechApple.ts +1 -1
- package/types/generators/TextToSpeechAppleBuiltin.ts +5 -5
- package/types/generators/TextToSpeechGgml.ts +8 -8
- package/types/generators/TextToSpeechOnnx.ts +9 -9
- package/types/generators/TextToSpeechOpenAiLike.ts +5 -5
- package/types/generators/ThermalPrinter.ts +6 -6
- package/types/generators/Tick.ts +3 -3
- package/types/generators/Udp.ts +9 -4
- package/types/generators/VadGgml.ts +39 -10
- package/types/generators/VadOnnx.ts +31 -8
- package/types/generators/VadTraditional.ts +15 -9
- package/types/generators/VectorStore.ts +26 -9
- package/types/generators/Watchdog.ts +11 -6
- package/types/generators/WebCrawler.ts +5 -5
- package/types/generators/WebRtc.ts +17 -11
- package/types/generators/WebSocket.ts +5 -5
- package/types/generators/index.ts +1 -0
- package/types/subspace.ts +1 -0
- package/types/system.ts +1 -1
- package/utils/calc.ts +12 -8
- package/utils/event-props.ts +104 -87
- package/utils/id.ts +4 -0
- package/api/index.ts +0 -1
- package/api/instance.ts +0 -213
package/package.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fugood/bricks-project",
|
|
3
|
-
"version": "2.24.0-beta.
|
|
3
|
+
"version": "2.24.0-beta.21",
|
|
4
4
|
"main": "index.ts",
|
|
5
5
|
"scripts": {
|
|
6
|
+
"typecheck": "tsc --noEmit",
|
|
6
7
|
"build": "bun scripts/build.js"
|
|
7
8
|
},
|
|
8
9
|
"dependencies": {
|
|
9
|
-
"@fugood/bricks-cli": "^2.24.0-beta.
|
|
10
|
+
"@fugood/bricks-cli": "^2.24.0-beta.21",
|
|
10
11
|
"@huggingface/gguf": "^0.3.2",
|
|
11
12
|
"@iarna/toml": "^3.0.0",
|
|
12
13
|
"@modelcontextprotocol/sdk": "^1.15.0",
|
|
13
14
|
"@toon-format/toon": "^2.1.0",
|
|
15
|
+
"@types/bun": "^1.3.9",
|
|
14
16
|
"@types/escodegen": "^0.0.10",
|
|
15
17
|
"@types/lodash": "^4.17.12",
|
|
16
18
|
"acorn": "^8.13.0",
|
|
@@ -19,5 +21,8 @@
|
|
|
19
21
|
"lodash": "^4.17.4",
|
|
20
22
|
"uuid": "^8.3.1"
|
|
21
23
|
},
|
|
22
|
-
"
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"oxfmt": "^0.36.0"
|
|
26
|
+
},
|
|
27
|
+
"gitHead": "589c6464a2e195961d5904f31e8b2b12c7aff9c7"
|
|
23
28
|
}
|
|
@@ -37,6 +37,13 @@ Built-in commands for direct state and UI changes.
|
|
|
37
37
|
### Data Calculation (Priority 4)
|
|
38
38
|
ONLY for deriving, formatting, or aggregating values from other data. Not for orchestration, side effects, or flow control.
|
|
39
39
|
|
|
40
|
+
## Entity Aliases
|
|
41
|
+
|
|
42
|
+
Set `alias` on entities to give them a stable, human-readable name:
|
|
43
|
+
- Code generation uses alias as the variable name (e.g., `alias: 'submitBtn'` → `export const submitBtn`)
|
|
44
|
+
- At runtime, devtools MCP tools accept alias instead of short ID and selectors can match by alias. Note: bricks-project does not directly interact with devtools MCP — aliases here primarily affect code generation
|
|
45
|
+
- Aliases must be unique across the application — duplicates are excluded from resolution
|
|
46
|
+
|
|
40
47
|
## Flow Decomposition
|
|
41
48
|
|
|
42
49
|
When the user describes a complex flow, decompose it BEFORE writing code:
|
|
@@ -4,15 +4,16 @@ E2E testing and scheduled execution for BRICKS applications. Simulates user beha
|
|
|
4
4
|
|
|
5
5
|
## Automation Types
|
|
6
6
|
|
|
7
|
-
| Type
|
|
8
|
-
|
|
9
|
-
| `launch`
|
|
10
|
-
| `anytime` | Execute anytime via manual trigger
|
|
11
|
-
| `cron`
|
|
7
|
+
| Type | Description |
|
|
8
|
+
| --------- | ---------------------------------------------------------- |
|
|
9
|
+
| `launch` | Run on application launch (restarts app when run manually) |
|
|
10
|
+
| `anytime` | Execute anytime via manual trigger |
|
|
11
|
+
| `cron` | Scheduled execution using crontab expressions |
|
|
12
12
|
|
|
13
13
|
## Simulation Actions
|
|
14
14
|
|
|
15
15
|
Automations can simulate:
|
|
16
|
+
|
|
16
17
|
- **Brick Press**: Tap/click on bricks
|
|
17
18
|
- **Key Events**: Key up/down for keyboard input
|
|
18
19
|
- **HTTP Request**: API calls
|
|
@@ -21,6 +22,7 @@ Automations can simulate:
|
|
|
21
22
|
## Assertions
|
|
22
23
|
|
|
23
24
|
Automations can validate:
|
|
25
|
+
|
|
24
26
|
- **Brick Exists**: Check if brick is rendered
|
|
25
27
|
- **Event Triggered**: Verify event from Brick/Generator/Canvas
|
|
26
28
|
- **Canvas Changed**: Confirm canvas navigation
|
|
@@ -33,14 +35,14 @@ Automations can validate:
|
|
|
33
35
|
```typescript
|
|
34
36
|
const testLoginFlow: AutomationTest = {
|
|
35
37
|
__typename: 'AutomationTest',
|
|
36
|
-
id: 'test
|
|
38
|
+
id: makeId('test'),
|
|
37
39
|
title: 'Test Login Flow',
|
|
38
40
|
timeout: 30000,
|
|
39
41
|
trigger_type: 'launch',
|
|
40
42
|
cases: [
|
|
41
43
|
{
|
|
42
44
|
__typename: 'TestCase',
|
|
43
|
-
id: '
|
|
45
|
+
id: makeId('test_case'),
|
|
44
46
|
name: 'Wait for login canvas',
|
|
45
47
|
run: ['wait_until_canvas_change', () => mainSubspace, () => loginCanvas, 5000],
|
|
46
48
|
exit_on_failed: true,
|
|
@@ -51,7 +53,7 @@ const testLoginFlow: AutomationTest = {
|
|
|
51
53
|
},
|
|
52
54
|
{
|
|
53
55
|
__typename: 'TestCase',
|
|
54
|
-
id: '
|
|
56
|
+
id: makeId('test_case'),
|
|
55
57
|
name: 'Press username input',
|
|
56
58
|
run: ['brick_press', () => mainSubspace, () => usernameInput],
|
|
57
59
|
exit_on_failed: true,
|
|
@@ -62,7 +64,7 @@ const testLoginFlow: AutomationTest = {
|
|
|
62
64
|
},
|
|
63
65
|
{
|
|
64
66
|
__typename: 'TestCase',
|
|
65
|
-
id: '
|
|
67
|
+
id: makeId('test_case'),
|
|
66
68
|
name: 'Assert username value',
|
|
67
69
|
run: ['assert_property', () => mainSubspace, () => usernameData, 'testuser'],
|
|
68
70
|
exit_on_failed: true,
|
|
@@ -73,7 +75,7 @@ const testLoginFlow: AutomationTest = {
|
|
|
73
75
|
},
|
|
74
76
|
{
|
|
75
77
|
__typename: 'TestCase',
|
|
76
|
-
id: '
|
|
78
|
+
id: makeId('test_case'),
|
|
77
79
|
name: 'Press login button',
|
|
78
80
|
run: ['brick_press', () => mainSubspace, () => loginButton],
|
|
79
81
|
exit_on_failed: true,
|
|
@@ -84,7 +86,7 @@ const testLoginFlow: AutomationTest = {
|
|
|
84
86
|
},
|
|
85
87
|
{
|
|
86
88
|
__typename: 'TestCase',
|
|
87
|
-
id: '
|
|
89
|
+
id: makeId('test_case'),
|
|
88
90
|
name: 'Wait for dashboard',
|
|
89
91
|
run: ['wait_until_canvas_change', () => mainSubspace, () => dashboardCanvas, 10000],
|
|
90
92
|
exit_on_failed: true,
|
|
@@ -100,25 +102,58 @@ const testLoginFlow: AutomationTest = {
|
|
|
100
102
|
|
|
101
103
|
## Test Methods
|
|
102
104
|
|
|
103
|
-
| Method
|
|
104
|
-
|
|
105
|
-
| `brick_press`
|
|
106
|
-
| `brick_exists`
|
|
107
|
-
| `wait_until_brick_exists`
|
|
108
|
-
| `wait_until_event_trigger`
|
|
109
|
-
| `wait_until_canvas_change`
|
|
110
|
-
| `keydown`
|
|
111
|
-
| `keyup`
|
|
112
|
-
| `http_request`
|
|
113
|
-
| `assert_property`
|
|
114
|
-
| `wait_until_property_change` | `[subspace, property, value, timeout?]`
|
|
115
|
-
| `execute_action`
|
|
116
|
-
| `match_screenshot`
|
|
117
|
-
| `delay`
|
|
105
|
+
| Method | Signature | Description |
|
|
106
|
+
| ---------------------------- | ------------------------------------------------ | -------------------- |
|
|
107
|
+
| `brick_press` | `[subspace, brick, options?]` | Simulate brick press |
|
|
108
|
+
| `brick_exists` | `[subspace, brick, frame?]` | Check brick exists |
|
|
109
|
+
| `wait_until_brick_exists` | `[subspace, brick, timeout?, frame?]` | Wait for brick |
|
|
110
|
+
| `wait_until_event_trigger` | `[subspace, sender, eventKey, timeout?]` | Wait for event |
|
|
111
|
+
| `wait_until_canvas_change` | `[subspace, canvas, timeout?]` | Wait for canvas |
|
|
112
|
+
| `keydown` | `[keyCode, pressedKey?, flags?]` | Key down event |
|
|
113
|
+
| `keyup` | `[keyCode, pressedKey?, flags?]` | Key up event |
|
|
114
|
+
| `http_request` | `[url, options?]` | HTTP request |
|
|
115
|
+
| `assert_property` | `[subspace, property, value]` | Assert data value |
|
|
116
|
+
| `wait_until_property_change` | `[subspace, property, value, timeout?]` | Wait for value |
|
|
117
|
+
| `execute_action` | `[subspace, handler, action, params?, options?]` | Execute action |
|
|
118
|
+
| `match_screenshot` | `[name, threshold?, maxRetry?]` | Screenshot compare |
|
|
119
|
+
| `delay` | `[subspace?, property?, defaultValue?]` | Delay execution |
|
|
120
|
+
|
|
121
|
+
### execute_action Params
|
|
122
|
+
|
|
123
|
+
The `params` object in `execute_action` uses **runtime event property keys** from `event-props.ts`, NOT the action config `input` names from type definitions.
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
// CORRECT — use runtime event property key
|
|
127
|
+
run: ['execute_action', () => subspace0, bricks.bInput.id, 'BRICK_TEXT_INPUT_SET_TEXT',
|
|
128
|
+
{ BRICK_TEXT_INPUT_TEXT: 'hello' }]
|
|
129
|
+
|
|
130
|
+
// WRONG — action config input name doesn't work in automation
|
|
131
|
+
run: ['execute_action', () => subspace0, bricks.bInput.id, 'BRICK_TEXT_INPUT_SET_TEXT',
|
|
132
|
+
{ text: 'hello' }]
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Reference `event-props.ts` for the correct runtime keys (e.g., `BRICK_TEXT_INPUT_TEXT`, `GENERATOR_MQTT_PAYLOAD`).
|
|
136
|
+
|
|
137
|
+
### Prefer UI Interactions Over Direct Generator Calls
|
|
138
|
+
|
|
139
|
+
For realistic E2E testing, prefer simulating user actions (set text input + press button) over calling generator actions directly:
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
// GOOD — simulates real user behavior
|
|
143
|
+
{ run: ['execute_action', () => sub, bricks.bInput.id, 'BRICK_TEXT_INPUT_SET_TEXT',
|
|
144
|
+
{ BRICK_TEXT_INPUT_TEXT: 'hello' }] },
|
|
145
|
+
{ run: ['brick_press', () => sub, () => bricks.bSendBtn] },
|
|
146
|
+
{ run: ['wait_until_property_change', () => sub, () => data.dPayload, 'hello', 10000] },
|
|
147
|
+
|
|
148
|
+
// AVOID — bypasses UI, doesn't test the full flow
|
|
149
|
+
{ run: ['execute_action', () => sub, generators.gClient.id, 'GENERATOR_MQTT_PUBLISH',
|
|
150
|
+
{ topic: 'test', payload: 'hello', qos: '0' }] },
|
|
151
|
+
```
|
|
118
152
|
|
|
119
153
|
## Recording Automations
|
|
120
154
|
|
|
121
155
|
In BRICKS Editor Preview mode:
|
|
156
|
+
|
|
122
157
|
1. Perform operations normally
|
|
123
158
|
2. Open menu (right-bottom corner)
|
|
124
159
|
3. Select "Record Events as Automation"
|
|
@@ -127,12 +162,15 @@ In BRICKS Editor Preview mode:
|
|
|
127
162
|
## Running Automations
|
|
128
163
|
|
|
129
164
|
### Manual Run
|
|
165
|
+
|
|
130
166
|
`Menu` → `Automations` → Select automation → `Run`
|
|
131
167
|
|
|
132
168
|
### On Launch
|
|
169
|
+
|
|
133
170
|
`Bind Device` → `Select Automation` (only `launch` or `cron` types)
|
|
134
171
|
|
|
135
172
|
### Scheduled (Cron)
|
|
173
|
+
|
|
136
174
|
`Bind Device` → `Cron Automation` (allows multi-select)
|
|
137
175
|
|
|
138
176
|
Use [crontab.guru](https://crontab.guru) to build cron expressions.
|
|
@@ -144,7 +182,7 @@ Visual regression testing with screenshot comparison:
|
|
|
144
182
|
```typescript
|
|
145
183
|
{
|
|
146
184
|
__typename: 'TestCase',
|
|
147
|
-
id: '
|
|
185
|
+
id: makeId('test_case'),
|
|
148
186
|
name: 'Match dashboard screenshot',
|
|
149
187
|
run: ['match_screenshot', 'dashboard-initial-state', 0.01, 3],
|
|
150
188
|
exit_on_failed: true,
|
|
@@ -156,6 +194,7 @@ Visual regression testing with screenshot comparison:
|
|
|
156
194
|
```
|
|
157
195
|
|
|
158
196
|
Screenshots can be stored:
|
|
197
|
+
|
|
159
198
|
- Local file system
|
|
160
199
|
- Media Flow workspace
|
|
161
200
|
|
|
@@ -165,11 +204,18 @@ First run captures baseline. Use "Run with Update" to update baseline.
|
|
|
165
204
|
|
|
166
205
|
Automations work with Modules. Use Manual Run in Preview mode for module testing.
|
|
167
206
|
|
|
207
|
+
## Important Notes
|
|
208
|
+
|
|
209
|
+
- **Automation map key**: Always use `'AUTOMATION_MAP_DEFAULT'` as the automation map ID (not `makeId()`). The preview test runner reads from `automationMap['AUTOMATION_MAP_DEFAULT']?.map`.
|
|
210
|
+
- **Valid makeId types**: Use `'test'` for AutomationTest, `'test_case'` for TestCase, `'test_var'` for TestVariable. Do NOT use `'automation_test'` or `'automation_test_map'`.
|
|
211
|
+
- **handler in execute_action**: Pass the entity's `.id` string (e.g., `bricks.bInput.id`), not a getter function.
|
|
212
|
+
|
|
168
213
|
## Best Practices
|
|
169
214
|
|
|
170
215
|
1. **Test culture**: Create automations for every significant flow
|
|
171
216
|
2. **CI/CD integration**: Use `launch` automations for deployment validation
|
|
172
|
-
3. **Incremental waits**: Use `
|
|
217
|
+
3. **Incremental waits**: Use `wait_until_property_change` with appropriate timeouts
|
|
173
218
|
4. **Visual testing**: Add screenshot comparisons for critical UI states
|
|
174
219
|
5. **Cron monitoring**: Schedule health checks for production displays
|
|
175
220
|
6. **Isolation**: Each automation should be independent and idempotent
|
|
221
|
+
7. **UI-first testing**: Simulate real user interactions (text input, button press) rather than calling generators directly
|
|
@@ -14,8 +14,9 @@ When mobile devices or embedded systems lack hardware for local AI inference (LL
|
|
|
14
14
|
|
|
15
15
|
## Supported Generators
|
|
16
16
|
|
|
17
|
-
-
|
|
18
|
-
-
|
|
17
|
+
- LLM (GGML) (LlmMlx.ts) - Local Large Language Model inference with GGML
|
|
18
|
+
- LLM (MLX) (LlmGgml.ts) - Local Large Language Model inference with MLX
|
|
19
|
+
- Speech-to-Text (GGML) (SpeechToTextGgml.ts) - Local Speech-to-Text inference with GGML
|
|
19
20
|
|
|
20
21
|
## Client Configuration
|
|
21
22
|
|
|
@@ -50,10 +51,12 @@ const llmGenerator: GeneratorLLM = {
|
|
|
50
51
|
property: {
|
|
51
52
|
modelUrl: 'https://huggingface.co/ggml-org/gemma-3-12b-it-qat-GGUF/resolve/main/gemma-3-12b-it-qat-q4_0.gguf',
|
|
52
53
|
contextSize: 8192,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
buttressConnectionSettings: {
|
|
55
|
+
enabled: true,
|
|
56
|
+
url: 'http://192.168.1.100:2080',
|
|
57
|
+
fallbackType: 'use-local',
|
|
58
|
+
strategy: 'prefer-best',
|
|
59
|
+
},
|
|
57
60
|
},
|
|
58
61
|
events: {},
|
|
59
62
|
switches: [],
|
package/tools/deploy.ts
CHANGED
|
@@ -4,29 +4,40 @@ import { parseArgs } from 'util'
|
|
|
4
4
|
const cwd = process.cwd()
|
|
5
5
|
|
|
6
6
|
const {
|
|
7
|
-
values: {
|
|
7
|
+
values: {
|
|
8
|
+
changelogs: changelogsArg,
|
|
9
|
+
'changelogs-file': changelogsFile,
|
|
10
|
+
'auto-commit': autoCommit,
|
|
11
|
+
yes,
|
|
12
|
+
help,
|
|
13
|
+
},
|
|
8
14
|
} = parseArgs({
|
|
9
15
|
args: Bun.argv.slice(2),
|
|
10
16
|
options: {
|
|
11
17
|
changelogs: { type: 'string' },
|
|
12
18
|
'changelogs-file': { type: 'string' },
|
|
19
|
+
'auto-commit': { type: 'boolean' },
|
|
13
20
|
yes: { type: 'boolean', short: 'y' },
|
|
21
|
+
help: { type: 'boolean', short: 'h' },
|
|
14
22
|
},
|
|
15
23
|
allowPositionals: true,
|
|
16
24
|
})
|
|
17
25
|
|
|
26
|
+
if (help) {
|
|
27
|
+
console.log(`Options:
|
|
28
|
+
--changelogs <text> Changelogs text for the release
|
|
29
|
+
--changelogs-file <path> Read changelogs from a file
|
|
30
|
+
--auto-commit Auto-commit unstaged changes before deploying
|
|
31
|
+
-y, --yes Skip all prompts
|
|
32
|
+
-h, --help Show this help message`)
|
|
33
|
+
process.exit(0)
|
|
34
|
+
}
|
|
35
|
+
|
|
18
36
|
// Check git status
|
|
19
|
-
const { exitCode } = await $`cd ${cwd} && git status`.nothrow()
|
|
37
|
+
const { exitCode } = await $`cd ${cwd} && git status`.quiet().nothrow()
|
|
20
38
|
const isGitRepo = exitCode === 0
|
|
21
39
|
|
|
22
|
-
|
|
23
|
-
if (isGitRepo) {
|
|
24
|
-
const unstagedChanges = await $`cd ${cwd} && git diff --name-only --diff-filter=ACMR`.text()
|
|
25
|
-
if (unstagedChanges)
|
|
26
|
-
throw new Error('Unstaged changes found, please commit or stash your changes before deploying')
|
|
27
|
-
|
|
28
|
-
commitId = (await $`cd ${cwd} && git rev-parse HEAD`.text()).trim()
|
|
29
|
-
} else if (!yes) {
|
|
40
|
+
if (!isGitRepo && !yes) {
|
|
30
41
|
const confirmContinue = prompt('No git repository found, continue? (y/n)')
|
|
31
42
|
if (confirmContinue !== 'y') throw new Error('Deployment cancelled')
|
|
32
43
|
}
|
|
@@ -53,6 +64,24 @@ if (changelogsArg) {
|
|
|
53
64
|
changelogs = prompt('Enter changelogs (optional, press Enter to skip):') || ''
|
|
54
65
|
}
|
|
55
66
|
|
|
67
|
+
// Handle unstaged changes
|
|
68
|
+
let commitId = ''
|
|
69
|
+
if (isGitRepo) {
|
|
70
|
+
const unstagedChanges = await $`cd ${cwd} && git diff --name-only --diff-filter=ACMR`.text()
|
|
71
|
+
if (unstagedChanges) {
|
|
72
|
+
if (autoCommit) {
|
|
73
|
+
const commitMsg = `chore: release ${version || 'new version'}`
|
|
74
|
+
const commitBody = changelogs || '[no changelogs]'
|
|
75
|
+
await $`cd ${cwd} && git add -A && git commit -m ${commitMsg} -m ${commitBody}`
|
|
76
|
+
} else {
|
|
77
|
+
throw new Error(
|
|
78
|
+
'Unstaged changes found, please commit or stash your changes before deploying',
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
commitId = (await $`cd ${cwd} && git rev-parse HEAD`.text()).trim()
|
|
83
|
+
}
|
|
84
|
+
|
|
56
85
|
// Ask for confirmation
|
|
57
86
|
if (!yes) {
|
|
58
87
|
const confirm = prompt('Are you sure you want to deploy? (y/n)')
|