@simplysm/sd-cli 13.0.69 → 13.0.71

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.
Files changed (201) hide show
  1. package/README.md +10 -957
  2. package/dist/builders/BaseBuilder.d.ts +23 -23
  3. package/dist/builders/BaseBuilder.d.ts.map +1 -1
  4. package/dist/builders/BaseBuilder.js +15 -15
  5. package/dist/builders/DtsBuilder.d.ts +4 -4
  6. package/dist/builders/DtsBuilder.js +1 -1
  7. package/dist/builders/LibraryBuilder.d.ts +3 -3
  8. package/dist/builders/types.d.ts +10 -10
  9. package/dist/capacitor/capacitor.d.ts +36 -36
  10. package/dist/capacitor/capacitor.js +63 -63
  11. package/dist/capacitor/capacitor.js.map +1 -1
  12. package/dist/commands/add-client.d.ts +8 -8
  13. package/dist/commands/add-client.js +15 -15
  14. package/dist/commands/add-client.js.map +1 -1
  15. package/dist/commands/add-server.d.ts +9 -9
  16. package/dist/commands/add-server.js +13 -13
  17. package/dist/commands/add-server.js.map +1 -1
  18. package/dist/commands/build.d.ts +9 -9
  19. package/dist/commands/check.js +3 -3
  20. package/dist/commands/check.js.map +1 -1
  21. package/dist/commands/dev.d.ts +9 -9
  22. package/dist/commands/device.d.ts +9 -9
  23. package/dist/commands/device.d.ts.map +1 -1
  24. package/dist/commands/device.js +17 -17
  25. package/dist/commands/device.js.map +1 -1
  26. package/dist/commands/init.d.ts +6 -6
  27. package/dist/commands/init.js +12 -12
  28. package/dist/commands/init.js.map +1 -1
  29. package/dist/commands/lint.d.ts +23 -23
  30. package/dist/commands/lint.d.ts.map +1 -1
  31. package/dist/commands/lint.js +25 -25
  32. package/dist/commands/lint.js.map +1 -1
  33. package/dist/commands/publish.d.ts +13 -13
  34. package/dist/commands/publish.d.ts.map +1 -1
  35. package/dist/commands/publish.js +61 -61
  36. package/dist/commands/publish.js.map +1 -1
  37. package/dist/commands/replace-deps.d.ts +3 -3
  38. package/dist/commands/replace-deps.d.ts.map +1 -1
  39. package/dist/commands/replace-deps.js +1 -1
  40. package/dist/commands/replace-deps.js.map +1 -1
  41. package/dist/commands/typecheck.d.ts +20 -20
  42. package/dist/commands/typecheck.d.ts.map +1 -1
  43. package/dist/commands/typecheck.js +20 -20
  44. package/dist/commands/typecheck.js.map +1 -1
  45. package/dist/commands/watch.d.ts +7 -7
  46. package/dist/electron/electron.d.ts +27 -27
  47. package/dist/electron/electron.js +32 -32
  48. package/dist/electron/electron.js.map +1 -1
  49. package/dist/infra/ResultCollector.d.ts +9 -9
  50. package/dist/infra/ResultCollector.js +5 -5
  51. package/dist/infra/SignalHandler.d.ts +7 -7
  52. package/dist/infra/SignalHandler.js +4 -4
  53. package/dist/infra/WorkerManager.d.ts +14 -14
  54. package/dist/infra/WorkerManager.js +11 -11
  55. package/dist/orchestrators/BuildOrchestrator.d.ts +19 -19
  56. package/dist/orchestrators/BuildOrchestrator.d.ts.map +1 -1
  57. package/dist/orchestrators/BuildOrchestrator.js +26 -26
  58. package/dist/orchestrators/BuildOrchestrator.js.map +1 -1
  59. package/dist/orchestrators/DevOrchestrator.d.ts +25 -25
  60. package/dist/orchestrators/DevOrchestrator.d.ts.map +1 -1
  61. package/dist/orchestrators/DevOrchestrator.js +30 -30
  62. package/dist/orchestrators/DevOrchestrator.js.map +1 -1
  63. package/dist/orchestrators/WatchOrchestrator.d.ts +13 -13
  64. package/dist/orchestrators/WatchOrchestrator.js +17 -17
  65. package/dist/orchestrators/WatchOrchestrator.js.map +1 -1
  66. package/dist/sd-cli-entry.d.ts +2 -2
  67. package/dist/sd-cli-entry.js +38 -38
  68. package/dist/sd-cli-entry.js.map +1 -1
  69. package/dist/sd-cli.d.ts +2 -2
  70. package/dist/sd-cli.js +1 -1
  71. package/dist/sd-cli.js.map +1 -1
  72. package/dist/sd-config.types.d.ts +84 -84
  73. package/dist/sd-config.types.d.ts.map +1 -1
  74. package/dist/utils/build-env.d.ts +1 -1
  75. package/dist/utils/config-editor.d.ts +5 -5
  76. package/dist/utils/config-editor.js +2 -2
  77. package/dist/utils/config-editor.js.map +1 -1
  78. package/dist/utils/copy-public.d.ts +9 -9
  79. package/dist/utils/copy-src.d.ts +9 -9
  80. package/dist/utils/esbuild-config.d.ts +30 -30
  81. package/dist/utils/esbuild-config.d.ts.map +1 -1
  82. package/dist/utils/output-utils.d.ts +6 -6
  83. package/dist/utils/package-utils.d.ts +6 -6
  84. package/dist/utils/package-utils.js +1 -1
  85. package/dist/utils/package-utils.js.map +1 -1
  86. package/dist/utils/rebuild-manager.js +3 -3
  87. package/dist/utils/rebuild-manager.js.map +1 -1
  88. package/dist/utils/replace-deps.d.ts +25 -25
  89. package/dist/utils/replace-deps.js +3 -3
  90. package/dist/utils/replace-deps.js.map +1 -1
  91. package/dist/utils/sd-config.d.ts +3 -3
  92. package/dist/utils/sd-config.js +3 -3
  93. package/dist/utils/sd-config.js.map +1 -1
  94. package/dist/utils/tailwind-config-deps.d.ts +3 -3
  95. package/dist/utils/template.d.ts +8 -8
  96. package/dist/utils/tsconfig.d.ts +16 -16
  97. package/dist/utils/tsconfig.js +2 -2
  98. package/dist/utils/tsconfig.js.map +1 -1
  99. package/dist/utils/typecheck-serialization.d.ts +8 -8
  100. package/dist/utils/vite-config.d.ts +8 -8
  101. package/dist/utils/vite-config.d.ts.map +1 -1
  102. package/dist/utils/vite-config.js +3 -3
  103. package/dist/utils/worker-events.d.ts +12 -12
  104. package/dist/utils/worker-events.d.ts.map +1 -1
  105. package/dist/utils/worker-utils.d.ts +3 -3
  106. package/dist/utils/worker-utils.js +2 -2
  107. package/dist/utils/worker-utils.js.map +1 -1
  108. package/dist/workers/client.worker.d.ts +14 -14
  109. package/dist/workers/client.worker.d.ts.map +1 -1
  110. package/dist/workers/client.worker.js +1 -1
  111. package/dist/workers/client.worker.js.map +1 -1
  112. package/dist/workers/dts.worker.d.ts +13 -13
  113. package/dist/workers/dts.worker.d.ts.map +1 -1
  114. package/dist/workers/dts.worker.js +3 -3
  115. package/dist/workers/dts.worker.js.map +1 -1
  116. package/dist/workers/library.worker.d.ts +12 -12
  117. package/dist/workers/library.worker.js +1 -1
  118. package/dist/workers/library.worker.js.map +1 -1
  119. package/dist/workers/lint.worker.d.ts +1 -1
  120. package/dist/workers/server-runtime.worker.d.ts +6 -6
  121. package/dist/workers/server-runtime.worker.js +6 -6
  122. package/dist/workers/server-runtime.worker.js.map +1 -1
  123. package/dist/workers/server.worker.d.ts +20 -20
  124. package/dist/workers/server.worker.d.ts.map +1 -1
  125. package/dist/workers/server.worker.js +6 -6
  126. package/dist/workers/server.worker.js.map +1 -1
  127. package/package.json +8 -7
  128. package/src/builders/BaseBuilder.ts +33 -33
  129. package/src/builders/DtsBuilder.ts +5 -5
  130. package/src/builders/LibraryBuilder.ts +9 -9
  131. package/src/builders/types.ts +10 -10
  132. package/src/capacitor/capacitor.ts +119 -119
  133. package/src/commands/add-client.ts +31 -31
  134. package/src/commands/add-server.ts +34 -34
  135. package/src/commands/build.ts +9 -9
  136. package/src/commands/check.ts +5 -5
  137. package/src/commands/dev.ts +9 -9
  138. package/src/commands/device.ts +30 -30
  139. package/src/commands/init.ts +25 -25
  140. package/src/commands/lint.ts +64 -64
  141. package/src/commands/publish.ts +139 -139
  142. package/src/commands/replace-deps.ts +4 -4
  143. package/src/commands/typecheck.ts +74 -74
  144. package/src/commands/watch.ts +7 -7
  145. package/src/electron/electron.ts +51 -51
  146. package/src/infra/ResultCollector.ts +9 -9
  147. package/src/infra/SignalHandler.ts +7 -7
  148. package/src/infra/WorkerManager.ts +14 -14
  149. package/src/orchestrators/BuildOrchestrator.ts +76 -76
  150. package/src/orchestrators/DevOrchestrator.ts +88 -88
  151. package/src/orchestrators/WatchOrchestrator.ts +39 -39
  152. package/src/sd-cli-entry.ts +43 -43
  153. package/src/sd-cli.ts +15 -15
  154. package/src/sd-config.types.ts +85 -85
  155. package/src/utils/build-env.ts +1 -1
  156. package/src/utils/config-editor.ts +19 -19
  157. package/src/utils/copy-public.ts +17 -17
  158. package/src/utils/copy-src.ts +11 -11
  159. package/src/utils/esbuild-config.ts +33 -33
  160. package/src/utils/output-utils.ts +11 -11
  161. package/src/utils/package-utils.ts +12 -12
  162. package/src/utils/rebuild-manager.ts +3 -3
  163. package/src/utils/replace-deps.ts +361 -361
  164. package/src/utils/sd-config.ts +44 -44
  165. package/src/utils/tailwind-config-deps.ts +98 -98
  166. package/src/utils/template.ts +56 -56
  167. package/src/utils/tsconfig.ts +127 -127
  168. package/src/utils/typecheck-serialization.ts +86 -86
  169. package/src/utils/vite-config.ts +341 -341
  170. package/src/utils/worker-events.ts +16 -16
  171. package/src/utils/worker-utils.ts +45 -45
  172. package/src/workers/client.worker.ts +34 -34
  173. package/src/workers/dts.worker.ts +467 -467
  174. package/src/workers/library.worker.ts +314 -314
  175. package/src/workers/lint.worker.ts +16 -16
  176. package/src/workers/server-runtime.worker.ts +157 -157
  177. package/src/workers/server.worker.ts +572 -572
  178. package/templates/add-client/__CLIENT__/package.json.hbs +1 -1
  179. package/templates/add-server/__SERVER__/package.json.hbs +2 -2
  180. package/templates/init/package.json.hbs +3 -3
  181. package/tests/config-editor.spec.ts +160 -0
  182. package/tests/copy-src.spec.ts +50 -0
  183. package/tests/get-compiler-options-for-package.spec.ts +139 -0
  184. package/tests/get-package-source-files.spec.ts +181 -0
  185. package/tests/get-types-from-package-json.spec.ts +107 -0
  186. package/tests/infra/ResultCollector.spec.ts +39 -0
  187. package/tests/infra/SignalHandler.spec.ts +38 -0
  188. package/tests/infra/WorkerManager.spec.ts +97 -0
  189. package/tests/load-ignore-patterns.spec.ts +188 -0
  190. package/tests/load-sd-config.spec.ts +137 -0
  191. package/tests/package-utils.spec.ts +188 -0
  192. package/tests/parse-root-tsconfig.spec.ts +89 -0
  193. package/tests/replace-deps.spec.ts +308 -0
  194. package/tests/run-lint.spec.ts +415 -0
  195. package/tests/run-typecheck.spec.ts +653 -0
  196. package/tests/run-watch.spec.ts +75 -0
  197. package/tests/sd-cli.spec.ts +330 -0
  198. package/tests/tailwind-config-deps.spec.ts +30 -0
  199. package/tests/template.spec.ts +70 -0
  200. package/tests/utils/rebuild-manager.spec.ts +43 -0
  201. package/tests/write-changed-output-files.spec.ts +97 -0
package/README.md CHANGED
@@ -1,974 +1,27 @@
1
1
  # @simplysm/sd-cli
2
2
 
3
- The CLI tool for the Simplysm framework. It provides project initialization, ESLint/Stylelint linting, TypeScript type-checking, combined check (typecheck + lint + test), library/client/server package builds, development mode, deployment, Android device execution, and Electron desktop app build capabilities.
3
+ CLI tool for the Simplysm framework. Provides project initialization, lint, typecheck, watch, dev server, build, publish, and device commands. Also exports configuration types and Vite utilities for use in `sd.config.ts` and `vite.config.ts` files.
4
4
 
5
5
  ## Installation
6
6
 
7
- ```bash
8
- npm install --save-dev @simplysm/sd-cli
9
- # or
10
- pnpm add -D @simplysm/sd-cli
11
7
  ```
12
-
13
- ## Main Commands
14
-
15
- The CLI binary name is `sd-cli`. All commands support the `--debug` option to output detailed logs.
16
-
17
- ### lint
18
-
19
- Runs ESLint and Stylelint. ESLint lints `.ts`/`.tsx`/`.js`/`.jsx` files; Stylelint lints `.css` files (only when a Stylelint config file is present). Extracts globalIgnores patterns from `eslint.config.ts`. Caches results in `.cache/eslint.cache` and `.cache/stylelint.cache`.
20
-
21
- ```bash
22
- # Lint all
23
- sd-cli lint
24
-
25
- # Lint specific path
26
- sd-cli lint packages/core-common
27
-
28
- # Lint multiple paths
29
- sd-cli lint packages/core-common tests/orm
30
-
31
- # Auto-fix
32
- sd-cli lint --fix
33
-
34
- # Output rule execution times
35
- sd-cli lint --timing
36
- ```
37
-
38
- **Options:**
39
-
40
- | Option | Description | Default |
41
- | ---------- | ---------------------------------------------------------- | ------- |
42
- | `--fix` | Auto-fix | `false` |
43
- | `--timing` | Output rule execution times (sets ESLint `TIMING` env var) | `false` |
44
- | `--debug` | Output debug logs | `false` |
45
-
46
- ### typecheck
47
-
48
- Runs TypeScript type-checking. It performs parallel type-checking per package environment (`node`/`browser`) based on `tsconfig.json` and `sd.config.ts`. Uses worker threads to run concurrently up to 7/8 of CPU cores.
49
-
50
- ```bash
51
- # Type-check all
52
- sd-cli typecheck
53
-
54
- # Type-check specific path
55
- sd-cli typecheck packages/core-common
56
-
57
- # Type-check multiple paths
58
- sd-cli typecheck packages/core-common tests/orm
59
-
60
- # Pass options to sd.config.ts
61
- sd-cli typecheck -o key=value
62
- ```
63
-
64
- **Options:**
65
-
66
- | Option | Description | Default |
67
- | ----------------- | ---------------------------------------------------------- | ------- |
68
- | `--options`, `-o` | Additional options to pass to sd.config.ts (multi-use) | `[]` |
69
- | `--debug` | Output debug logs | `false` |
70
-
71
- **Type-check environment by target:**
72
-
73
- | Target | Environment |
74
- | ------------------- | ----------------------- |
75
- | `node` | node environment once |
76
- | `browser`, `client` | browser environment once |
77
- | `neutral` | node + browser environment twice |
78
- | `scripts` | Excluded from type-check |
79
-
80
- ### check
81
-
82
- Runs typecheck, lint, and test in parallel and prints a consolidated summary. Lint auto-fix is always enabled when run via `check`. Exits with code `1` if any check fails.
83
-
84
- ```bash
85
- # Run all checks (typecheck + lint + test)
86
- sd-cli check
87
-
88
- # Run specific check types
89
- sd-cli check --type typecheck,lint
90
-
91
- # Filter paths
92
- sd-cli check packages/core-common
93
- ```
94
-
95
- **Options:**
96
-
97
- | Option | Description | Default |
98
- | ---------- | -------------------------------------------------------------------- | ------------------------ |
99
- | `--type` | Comma-separated list of check types to run: `typecheck`, `lint`, `test` | `typecheck,lint,test` |
100
- | `--debug` | Output debug logs | `false` |
101
-
102
- **Output format:**
103
-
104
- Each check type prints a section header followed by its result summary. A final `SUMMARY` section lists overall pass/fail status and total error/warning counts.
105
-
106
- ### watch
107
-
108
- Watches **library packages** (`node`/`browser`/`neutral` targets) in watch mode. Automatically rebuilds on file changes and generates `.d.ts` type definition files.
109
-
110
- > **Note**: Use the `dev` command for `client`/`server` targets.
111
-
112
- ```bash
113
- # Watch all library packages
114
- sd-cli watch
115
-
116
- # Watch specific package
117
- sd-cli watch solid
118
-
119
- # Watch multiple packages
120
- sd-cli watch solid core-common
121
- ```
122
-
123
- **Options:**
124
-
125
- | Option | Description | Default |
126
- | ----------------- | ---------------------------------------------------------- | ------- |
127
- | `--options`, `-o` | Additional options to pass to sd.config.ts (multi-use) | `[]` |
128
- | `--debug` | Output debug logs | `false` |
129
-
130
- ### dev
131
-
132
- Runs **Client and Server packages** in development mode. `client` targets run with Vite dev server, and `server` targets run with Server Build Worker + Server Runtime Worker. Supports Server-Client proxy connection and Capacitor initialization.
133
-
134
- ```bash
135
- # Run all client/server packages
136
- sd-cli dev
137
-
138
- # Run specific package
139
- sd-cli dev solid-demo
140
-
141
- # Run multiple packages
142
- sd-cli dev solid-demo my-server
143
- ```
144
-
145
- **Options:**
146
-
147
- | Option | Description | Default |
148
- | ----------------- | ---------------------------------------------------------- | ------- |
149
- | `--options`, `-o` | Additional options to pass to sd.config.ts (multi-use) | `[]` |
150
- | `--debug` | Output debug logs | `false` |
151
-
152
- **How it works:**
153
-
154
- - `client` target: Starts Vite dev server. If `server` config is a string (package name), connects proxy to that server
155
- - `server` target: Builds in esbuild watch mode, then runs server runtime in separate Worker. Auto-rebuilds and restarts server on file changes
156
- - Client packages with Capacitor config perform Capacitor initialization after build completes
157
- - Client packages with Electron config launch Electron in dev mode after build completes
158
- - Terminates on SIGINT/SIGTERM signals
159
-
160
- **Scope Package HMR:**
161
-
162
- When using `replaceDeps` to develop scope packages locally, the Vite dev server automatically watches scope package dist files and triggers HMR when they change. This allows changes to `@simplysm/*` packages to be reflected in the dev app without manual reload.
163
-
164
- ### build
165
-
166
- Runs production build. Performs lint, dist folder cleanup, and build sequentially.
167
-
168
- ```bash
169
- # Build all packages
170
- sd-cli build
171
-
172
- # Build specific packages
173
- sd-cli build solid core-common
174
- ```
175
-
176
- **Options:**
177
-
178
- | Option | Description | Default |
179
- | ----------------- | ---------------------------------------------------------- | ------- |
180
- | `--options`, `-o` | Additional options to pass to sd.config.ts (multi-use) | `[]` |
181
- | `--debug` | Output debug logs | `false` |
182
-
183
- **Build behavior by target:**
184
-
185
- | Target | JS build | .d.ts generation | Type-check | Note |
186
- | -------------------------- | --------------- | ---------------- | ---------- | ------------------------------------- |
187
- | `node`/`browser`/`neutral` | esbuild | O | O | Library package |
188
- | `client` | Vite production | X | O | Client app (+ Capacitor/Electron build) |
189
- | `server` | esbuild | X | X | Server app |
190
- | `scripts` | Excluded | Excluded | Excluded | - |
191
-
192
- **Public Files & Assets:**
193
-
194
- Both client and server packages support serving static files from a `public/` directory:
195
-
196
- - **Client packages** (`dev` mode): Vite serves `public/` at the configured base path (`/{name}/`)
197
- - **Server packages** (`dev` mode): Copies `public/` to `dist/`, watches for changes, and automatically rebuilds
198
- - **Server packages** (`build` mode): Copies `public/` to `dist/` (production deployment)
199
- - **Client packages** (`dev` mode only): Optional `public-dev/` directory files are served with priority over `public/` files, allowing dev-specific overrides without affecting production builds
200
-
201
- Directory structure:
202
- ```
203
- packages/my-server/
204
- ├── public/ # Static files (both dev and build)
205
- │ ├── index.html
206
- │ ├── style.css
207
- │ └── assets/
208
- └── public-dev/ # Dev-only overrides (dev mode only, ignored in build)
209
- └── index.html # Overrides public/index.html in dev
210
- ```
211
-
212
- **How it works:**
213
-
214
- - In `dev` mode, both `public/` and `public-dev/` are copied to `dist/`, with `public-dev/` changes taking priority
215
- - If a `public-dev/` file is deleted, the corresponding `public/` file is served as fallback
216
- - In `build` mode, only `public/` is copied to `dist/` (no `public-dev/`)
217
- - The copy operation preserves directory structure
218
-
219
- **Runtime Configuration File (.config.json):**
220
-
221
- If a `server` or `client` package defines a `configs` field in `sd.config.ts`, the build automatically generates `dist/.config.json` containing that configuration. This is useful for storing environment-specific settings (database config, API endpoints, etc.) that are read at runtime via `ctx.getConfig()` in `service-server`.
222
-
223
- **Server Build: Externals & Production Deployment Files:**
224
-
225
- Server builds (`target: "server"`) automatically detect modules that cannot be bundled by esbuild and mark them as external. Three sources of externals are combined:
226
-
227
- 1. **Uninstalled optional peer dependencies** — automatically detected via `peerDependenciesMeta`
228
- 2. **Native modules (node-gyp)** — automatically detected by scanning for `binding.gyp` files in the dependency tree
229
- 3. **Manual externals** — specified via `externals` in `sd.config.ts`
230
-
231
- During production build (`sd-cli build`), the following deployment files are generated in `dist/`:
232
-
233
- | File | Description |
234
- |------|-------------|
235
- | `package.json` | Minimal package.json with externalized dependencies (version `"*"`) for `npm install` on the deployment server |
236
- | `mise.toml` | Node.js version specification (read from root `mise.toml`) — only generated when `packageManager: "mise"` is set |
237
- | `openssl.cnf` | Legacy OpenSSL provider activation (required for MSSQL and other legacy TLS connections) |
238
- | `pm2.config.cjs` | PM2 process manager config (only generated when `pm2` is configured) |
239
-
240
- > **Note**: Production deployment files are only generated during `sd-cli build`, not during `sd-cli dev` (watch mode).
241
-
242
- ### publish
243
-
244
- Publishes packages. For safety, proceeds in the following order:
245
-
246
- 1. Pre-validation (npm authentication, Git uncommitted changes check)
247
- 2. Version upgrade (increment prerelease if prerelease, otherwise patch)
248
- 3. Build (Git rollback on failure)
249
- 4. Git commit/tag/push (Git rollback on failure)
250
- 5. npm/FTP/local deployment
251
- 6. postPublish script execution
252
-
253
- ```bash
254
- # Publish all packages with publish config
255
- sd-cli publish
256
-
257
- # Publish specific packages
258
- sd-cli publish solid core-common
259
-
260
- # Publish without build (dangerous)
261
- sd-cli publish --no-build
262
-
263
- # Simulate without actual deployment
264
- sd-cli publish --dry-run
265
- ```
266
-
267
- **Options:**
268
-
269
- | Option | Description | Default |
270
- | ------------------------ | ---------------------------------------------------------- | ------- |
271
- | `--build` / `--no-build` | Whether to run build (skip with `--no-build`) | `true` |
272
- | `--dry-run` | Simulate without actual deployment | `false` |
273
- | `--options`, `-o` | Additional options to pass to sd.config.ts (multi-use) | `[]` |
274
- | `--debug` | Output debug logs | `false` |
275
-
276
- ### init
277
-
278
- Initializes a new Simplysm project in the current directory. The directory must be empty and the directory name must be a valid npm scope name (lowercase, numbers, hyphens only).
279
-
280
- Creates a skeleton project with:
281
- - `sd.config.ts`, `tsconfig.json`, `eslint.config.ts`, `pnpm-workspace.yaml`
282
- - `.gitignore`, `.prettierrc.yaml`, `.prettierignore`, `mise.toml`
283
-
284
- After rendering templates, runs `pnpm install` automatically.
285
-
286
- ```bash
287
- # Create an empty directory and run init
288
- mkdir my-project && cd my-project
289
- sd-cli init
290
- ```
291
-
292
- After initialization, use `sd-cli add client` and `sd-cli add server` to add packages.
293
-
294
- > **Note**: Claude Code skills/agents are automatically installed via `@simplysm/sd-claude` postinstall.
295
-
296
- ### add client
297
-
298
- Adds a client package to an existing project. Must be run from the project root (where `sd.config.ts` exists).
299
-
300
- Runs an interactive prompt to collect:
301
- 1. Client package name suffix (creates `client-{suffix}` package)
302
- 2. Whether to use router
303
-
304
- After collecting inputs, it:
305
- 1. Renders client package from Handlebars templates into `packages/client-{suffix}/`
306
- 2. Adds the package entry to `sd.config.ts` (via ts-morph AST editing)
307
- 3. Adds tailwind CSS settings to `eslint.config.ts` (if first client)
308
- 4. Runs `pnpm install`
309
-
310
- ```bash
311
- sd-cli add client
312
- ```
313
-
314
- ### add server
315
-
316
- Adds a server package to an existing project. Must be run from the project root (where `sd.config.ts` exists).
317
-
318
- Runs an interactive prompt to collect:
319
- 1. Server name suffix (leave empty for just `server`, otherwise creates `server-{suffix}`)
320
- 2. Which existing client packages this server should serve (multi-select)
321
-
322
- After collecting inputs, it:
323
- 1. Renders server package from Handlebars templates into `packages/{server-name}/`
324
- 2. Adds the server package entry to `sd.config.ts`
325
- 3. Updates selected client packages' `server` field in `sd.config.ts`
326
- 4. Runs `pnpm install`
327
-
328
- ```bash
329
- sd-cli add server
330
- ```
331
-
332
- ### replace-deps
333
-
334
- Sets up local dependency replacement according to `replaceDeps` configuration in `sd.config.ts`. Useful for local development of dependent packages across separate repositories.
335
-
336
- ```bash
337
- # Set up replacements (symlink or copy mode based on config)
338
- sd-cli replace-deps
339
-
340
- # With additional options
341
- sd-cli replace-deps -o key=value
342
- ```
343
-
344
- **Options:**
345
-
346
- | Option | Description | Default |
347
- | ----------------- | ---------------------------------------------------------- | ------- |
348
- | `--options`, `-o` | Additional options to pass to sd.config.ts (multi-use) | `[]` |
349
- | `--debug` | Output debug logs | `false` |
350
-
351
- ### device
352
-
353
- Runs Capacitor app on Android device. Only available for `client` target packages with `capacitor` config in `sd.config.ts`.
354
-
355
- ```bash
356
- # Specify package (required)
357
- sd-cli device -p my-app
358
-
359
- # Specify dev server URL directly
360
- sd-cli device -p my-app -u http://192.168.0.10:3000
361
- ```
362
-
363
- **Options:**
364
-
365
- | Option | Description | Default |
366
- | ----------------- | ------------------------------------------------------------------------- | ------- |
367
- | `--package`, `-p` | Package name (required) | - |
368
- | `--url`, `-u` | Dev server URL (uses server port from sd.config.ts if not specified) | - |
369
- | `--options`, `-o` | Additional options to pass to sd.config.ts (multi-use) | `[]` |
370
- | `--debug` | Output debug logs | `false` |
371
-
372
- ## Exported Types and Utilities
373
-
374
- This package exports configuration types for `sd.config.ts` and Vite utilities. All are importable from `@simplysm/sd-cli`.
375
-
376
- ```typescript
377
- import type {
378
- SdConfigFn,
379
- SdConfigParams,
380
- SdConfig,
381
- SdPackageConfig,
382
- BuildTarget,
383
- SdBuildPackageConfig,
384
- SdClientPackageConfig,
385
- SdServerPackageConfig,
386
- SdScriptsPackageConfig,
387
- SdPublishConfig,
388
- SdLocalDirectoryPublishConfig,
389
- SdStoragePublishConfig,
390
- SdPostPublishScriptConfig,
391
- SdCapacitorConfig,
392
- SdCapacitorAndroidConfig,
393
- SdCapacitorSignConfig,
394
- SdCapacitorPermission,
395
- SdCapacitorIntentFilter,
396
- SdElectronConfig,
397
- ViteConfigOptions,
398
- } from "@simplysm/sd-cli";
399
- import { createViteConfig } from "@simplysm/sd-cli";
8
+ pnpm add @simplysm/sd-cli
400
9
  ```
401
10
 
402
- | Type | Description |
403
- |------|-------------|
404
- | `SdConfigFn` | Function type for `sd.config.ts` default export: `(params: SdConfigParams) => SdConfig \| Promise<SdConfig>` |
405
- | `SdConfigParams` | Parameters passed to the config function (`cwd`, `dev`, `opt`) |
406
- | `SdConfig` | Root configuration object (`packages`, `replaceDeps?`, `postPublish?`) |
407
- | `SdPackageConfig` | Union of all package config types |
408
- | `BuildTarget` | Library build target: `"node" \| "browser" \| "neutral"` |
409
- | `SdBuildPackageConfig` | Config for library packages (`node`/`browser`/`neutral` targets) |
410
- | `SdClientPackageConfig` | Config for client packages (`client` target) |
411
- | `SdServerPackageConfig` | Config for server packages (`server` target, with `externals` and `pm2` options) |
412
- | `SdScriptsPackageConfig` | Config for scripts-only packages (`scripts` target) |
413
- | `SdPublishConfig` | Deployment config: `"npm" \| SdLocalDirectoryPublishConfig \| SdStoragePublishConfig` |
414
- | `SdLocalDirectoryPublishConfig` | Local directory deployment config (`type: "local-directory"`, `path`) |
415
- | `SdStoragePublishConfig` | FTP/FTPS/SFTP deployment config (`type`, `host`, `port?`, `path?`, `user?`, `pass?`) |
416
- | `SdPostPublishScriptConfig` | Post-publish script config (`type: "script"`, `cmd`, `args`) |
417
- | `SdCapacitorConfig` | Capacitor config for Android app builds |
418
- | `SdCapacitorAndroidConfig` | Android platform-specific Capacitor config |
419
- | `SdCapacitorSignConfig` | APK/AAB signing config (`keystore`, `storePassword`, `alias`, `password`, `keystoreType?`) |
420
- | `SdCapacitorPermission` | Android permission entry (`name`, `maxSdkVersion?`, `ignore?`) |
421
- | `SdCapacitorIntentFilter` | Android intent filter entry (`action?`, `category?`) |
422
- | `SdElectronConfig` | Electron desktop app build config |
423
- | `ViteConfigOptions` | Options passed to `createViteConfig()` — see fields below |
11
+ ## Usage
424
12
 
425
- ## Vite Utilities
426
-
427
- ### createViteConfig
428
-
429
- Creates pre-configured Vite configuration for Simplysm client packages.
430
-
431
- ```typescript
432
- import { createViteConfig, type ViteConfigOptions } from "@simplysm/sd-cli";
433
-
434
- const options: ViteConfigOptions = {
435
- pkgDir: "/path/to/package",
436
- name: "my-app",
437
- tsconfigPath: "/path/to/tsconfig.json",
438
- compilerOptions: {},
439
- mode: "build",
440
- };
441
-
442
- export default createViteConfig(options);
443
- ```
444
-
445
- **`ViteConfigOptions` fields:**
446
-
447
- | Field | Type | Required | Description |
448
- |-------|------|----------|-------------|
449
- | `pkgDir` | `string` | Yes | Absolute path to the package directory |
450
- | `name` | `string` | Yes | Package name used as Vite base path (`/{name}/`) |
451
- | `tsconfigPath` | `string` | Yes | Absolute path to `tsconfig.json` |
452
- | `compilerOptions` | `Record<string, unknown>` | Yes | TypeScript compiler options passed to esbuild |
453
- | `env` | `Record<string, string>` | No | Environment variables to substitute for `process.env` at build time |
454
- | `mode` | `"build" \| "dev"` | Yes | Build mode: `"build"` for production, `"dev"` for development server |
455
- | `serverPort` | `number` | No | Dev server port (`0` for auto-assign). Only used in `"dev"` mode |
456
- | `watchScopes` | `string[]` | No | Scope package prefixes to watch for HMR (e.g., `["@simplysm"]`) |
457
- | `onScopeRebuild` | `() => void` | No | Callback invoked when a watched scope package dist file changes |
458
-
459
- The `createViteConfig()` function configures:
460
- - Development server configuration
461
- - Production build optimization
462
- - SolidJS + TailwindCSS plugin integration
463
- - PWA (service worker + web app manifest) generation
464
- - Environment variable substitution support
465
- - Scope package watch/HMR (automatically watches scope package dist files and triggers HMR on changes via `replaceDeps`)
466
-
467
- ## Configuration (sd.config.ts)
468
-
469
- Create an `sd.config.ts` file in the project root to define build targets and deployment settings per package. Used by `typecheck`, `watch`, `dev`, `build`, `publish`, and `device` commands.
470
-
471
- The `typecheck` command treats all packages as `neutral` target if no config file exists. The `watch`, `dev`, `build`, and `publish` commands require this file.
472
-
473
- ### Basic Example
474
-
475
- ```typescript
476
- import type { SdConfigFn } from "@simplysm/sd-cli";
477
-
478
- const config: SdConfigFn = () => ({
479
- packages: {
480
- "core-common": { target: "neutral" },
481
- "core-node": { target: "node" },
482
- "core-browser": { target: "browser" },
483
- "solid": { target: "browser", publish: "npm" },
484
- "solid-demo": { target: "client", server: "solid-demo-server" },
485
- "solid-demo-server": { target: "server" },
486
- "my-scripts": { target: "scripts" },
487
- },
488
- });
489
-
490
- export default config;
491
- ```
492
-
493
- ### Target Types
494
-
495
- | Target | Description | Type-check | watch | dev | build |
496
- | --------- | ------------------------------------------------------------------ | ------------------ | ----- | --- | ------------ |
497
- | `node` | Node.js-only package. Removes DOM lib, includes `@types/node` | O (node) | O | X | O (JS + dts) |
498
- | `browser` | Browser-only package. Keeps DOM lib, excludes `@types/node` | O (browser) | O | X | O (JS + dts) |
499
- | `neutral` | Node/browser common. Keeps DOM lib, includes `@types/node` | O (node + browser) | O | X | O (JS + dts) |
500
- | `client` | Vite dev server-based client app | O (browser) | X | O | O (Vite) |
501
- | `server` | Fastify-based server app | X | X | O | O (JS) |
502
- | `scripts` | Excluded from typecheck/watch/build | X | X | X | X |
503
-
504
- ### Function Parameters
505
-
506
- The `sd.config.ts` function receives a `SdConfigParams` object as an argument:
507
-
508
- ```typescript
509
- import type { SdConfigFn, SdConfigParams } from "@simplysm/sd-cli";
510
-
511
- const config: SdConfigFn = (params: SdConfigParams) => {
512
- // params.cwd - Current working directory
513
- // params.dev - Whether in dev mode (true for dev command, false for build/publish)
514
- // params.opt - Additional options array passed via CLI's -o flag
515
-
516
- return {
517
- packages: {
518
- "my-app": {
519
- target: "client",
520
- server: params.dev ? 3000 : "my-server",
521
- },
522
- },
523
- };
524
- };
525
-
526
- export default config;
527
- ```
528
-
529
- ### Package Configuration Types
530
-
531
- #### Library Package (SdBuildPackageConfig)
532
-
533
- ```typescript
534
- {
535
- target: "node" | "browser" | "neutral";
536
- publish?: SdPublishConfig; // Deployment config (optional)
537
- copySrc?: string[]; // Glob patterns for copying assets from src/ to dist/ (optional)
538
- }
539
- ```
540
-
541
- **Asset Copying (copySrc)**
542
-
543
- The `copySrc` option allows copying non-TypeScript files (CSS, images, etc.) from `src/` to `dist/` during build and watch mode:
544
-
545
- ```typescript
546
- "my-lib": {
547
- target: "browser",
548
- publish: "npm",
549
- copySrc: ["**/*.css", "**/*.png"], // Copy all CSS and PNG files
550
- }
551
- ```
552
-
553
- **How it works:**
554
- - Glob patterns are relative to `src/` directory
555
- - File directory structure is preserved during copy (e.g., `src/styles/theme.css` → `dist/styles/theme.css`)
556
- - Applied during both production build (`sd-cli build`) and watch mode (`sd-cli watch`)
557
- - Useful for including CSS files with component libraries when consuming apps may not bundle them automatically
558
-
559
- #### Client Package (SdClientPackageConfig)
560
-
561
- ```typescript
562
- {
563
- target: "client";
564
- server: string | number; // Server package name or direct port number
565
- env?: Record<string, string>; // Environment variables to replace during build
566
- publish?: SdPublishConfig; // Deployment config (optional)
567
- capacitor?: SdCapacitorConfig; // Capacitor config (optional)
568
- electron?: SdElectronConfig; // Electron config (optional)
569
- configs?: Record<string, unknown>; // Runtime config (written to dist/.config.json during build)
570
- }
571
- ```
572
-
573
- ##### Progressive Web App (PWA) Support
574
-
575
- All client packages automatically generate PWA files during build. No configuration is required to enable PWA.
576
-
577
- **Generated Files:**
578
-
579
- - `sw.js` - Service worker (handles offline caching and precache of all build assets)
580
- - `manifest.webmanifest` - Web app manifest (for app install/launch)
581
- - `registerSW.js` - Service worker registration script (injected automatically)
582
-
583
- **Key behaviors:**
584
-
585
- - **Build mode**: Service worker is fully enabled with offline support and asset precaching via Workbox
586
- - **Dev mode**: Service worker registration is disabled by default for safe development (no stale cache issues)
587
- - **Precache strategy**: All build assets (`*.js`, `*.css`, `*.html`, `*.ico`, `*.png`, `*.svg`, `*.woff2`) are precached for instant loading
588
- - **HTTPS requirement**: Service workers require HTTPS at runtime (localhost dev mode is exempt)
589
- - **Offline capability**: Once cached, the app works offline with all precached resources available
590
-
591
- Users can install the app on their home screen on supported browsers and devices. No additional code or dependencies are needed.
592
-
593
- #### Server Package (SdServerPackageConfig)
594
-
595
- ```typescript
596
- {
597
- target: "server";
598
- env?: Record<string, string>; // Environment variables to replace during build
599
- publish?: SdPublishConfig; // Deployment config (optional)
600
- configs?: Record<string, unknown>; // Runtime config (written to dist/.config.json during build)
601
- externals?: string[]; // Additional modules to exclude from bundle (optional)
602
- packageManager?: "volta" | "mise"; // Package manager for Node.js version management (optional)
603
- pm2?: { // PM2 config — generates dist/pm2.config.cjs (optional)
604
- name?: string; // PM2 process name (defaults to package name)
605
- ignoreWatchPaths?: string[]; // Paths to ignore in PM2 watch
606
- };
607
- }
608
- ```
609
-
610
- #### Scripts Package (SdScriptsPackageConfig)
611
-
612
- ```typescript
613
- {
614
- target: "scripts";
615
- }
616
- ```
617
-
618
- ### Deployment Configuration (SdPublishConfig)
619
-
620
- Three deployment methods are supported:
621
-
622
- | Method | Config Value | Description |
623
- | ---------------- | ----------------------------------------------------------------------- | ------------------------------------- |
624
- | npm | `"npm"` | Deploy to npm registry |
625
- | Local directory | `{ type: "local-directory", path: "..." }` | Copy dist to local path |
626
- | Storage | `{ type: "ftp" \| "ftps" \| "sftp", host, port?, path?, user?, pass? }` | Upload to FTP/FTPS/SFTP server |
627
-
628
- Environment variable substitution is supported in `path` for local directory and storage: `%VER%` (version), `%PROJECT%` (project path).
629
-
630
- ```typescript
631
- // npm deployment
632
- "core-common": { target: "neutral", publish: "npm" },
633
-
634
- // Local directory deployment
635
- "my-app": {
636
- target: "client",
637
- server: 3000,
638
- publish: { type: "local-directory", path: "/deploy/%VER%/my-app" },
639
- },
640
-
641
- // SFTP upload
642
- "my-server": {
643
- target: "server",
644
- publish: {
645
- type: "sftp",
646
- host: "deploy.example.com",
647
- port: 22,
648
- path: "/opt/app",
649
- user: "deploy",
650
- pass: "secret",
651
- },
652
- },
653
- ```
654
-
655
- ### Runtime Configuration (configs)
656
-
657
- Define runtime configuration for `server` or `client` packages using the `configs` field. This configuration is automatically written to `dist/.config.json` during build and can be read at runtime via `ctx.getConfig()` in the `service-server` package.
658
-
659
- ```typescript
660
- import type { SdConfigFn } from "@simplysm/sd-cli";
661
-
662
- const config: SdConfigFn = () => ({
663
- packages: {
664
- "my-server": {
665
- target: "server",
666
- configs: {
667
- // Runtime configuration sections
668
- orm: {
669
- default: {
670
- dialect: "mysql",
671
- host: process.env.DB_HOST || "localhost",
672
- port: 3306,
673
- database: "mydb",
674
- user: process.env.DB_USER || "root",
675
- password: process.env.DB_PASSWORD,
676
- },
677
- },
678
- smtp: {
679
- default: {
680
- host: "smtp.example.com",
681
- port: 587,
682
- secure: false,
683
- user: process.env.SMTP_USER,
684
- pass: process.env.SMTP_PASS,
685
- },
686
- },
687
- },
688
- },
689
- "my-app": {
690
- target: "client",
691
- server: "my-server",
692
- configs: {
693
- api: {
694
- baseUrl: process.env.API_URL || "http://localhost:3000",
695
- timeout: 30000,
696
- },
697
- },
698
- },
699
- },
700
- });
701
-
702
- export default config;
703
- ```
704
-
705
- At runtime, services access configuration sections:
706
-
707
- ```typescript
708
- // In a service class
709
- const ormConfig = await this.getConfig<Record<string, DbConfig>>("orm");
710
- const dbConfig = ormConfig.default; // Access specific DB config by name
711
- ```
712
-
713
- **Key points:**
714
-
715
- - Configuration sections can be nested objects with any structure
716
- - Environment variable substitution can be used in config values
717
- - Generated `dist/.config.json` files are not included in version control (add to `.gitignore`)
718
- - Client and server both support `configs`, but typically only servers expose configuration via `ctx.getConfig()`
719
-
720
- ### Dependency Replacement (replaceDeps)
721
-
722
- Replace `node_modules` packages with local source directories via symlinks. Useful for local development of dependent packages across separate repositories.
723
-
724
- The key is a glob pattern to match packages in `node_modules`, and the value is the local source directory path. The `*` wildcard in the key is substituted into the `*` in the value.
725
-
726
- ```typescript
727
- import type { SdConfigFn } from "@simplysm/sd-cli";
728
-
729
- const config: SdConfigFn = () => ({
730
- packages: {
731
- "my-app": { target: "client", server: "my-server" },
732
- },
733
- replaceDeps: {
734
- // Replaces @simplysm/* packages in node_modules
735
- // with symlinks to ../simplysm/packages/*/dist
736
- "@simplysm/*": "../simplysm/packages/*",
737
- },
738
- });
739
-
740
- export default config;
741
- ```
742
-
743
- ### postPublish Scripts
744
-
745
- You can define scripts to run after deployment completes. Supports environment variable substitution (`%VER%`, `%PROJECT%`). On script failure, only a warning is printed and execution continues.
746
-
747
- ```typescript
748
- import type { SdConfigFn } from "@simplysm/sd-cli";
749
-
750
- const config: SdConfigFn = () => ({
751
- packages: {
752
- /* ... */
753
- },
754
- postPublish: [
755
- {
756
- type: "script",
757
- cmd: "curl",
758
- args: ["-X", "POST", "https://hooks.example.com/deploy?version=%VER%"],
759
- },
760
- ],
761
- });
762
-
763
- export default config;
764
- ```
765
-
766
- ### Capacitor Configuration (SdCapacitorConfig)
767
-
768
- Capacitor configuration for Android app builds in `client` target packages.
769
-
770
- ```typescript
771
- "my-app": {
772
- target: "client",
773
- server: 3000,
774
- capacitor: {
775
- appId: "com.example.myapp",
776
- appName: "My App",
777
- icon: "resources/icon.png", // App icon (relative to package directory)
778
- debug: true, // Whether debug build
779
- plugins: { // Capacitor plugins
780
- "@capacitor/camera": true,
781
- "@capacitor/storage": { group: "myGroup" },
782
- },
783
- platform: {
784
- android: {
785
- config: { // AndroidManifest.xml application attributes
786
- requestLegacyExternalStorage: "true",
787
- },
788
- bundle: true, // AAB bundle build (APK if false)
789
- sdkVersion: 33, // Android SDK version
790
- permissions: [ // Additional permissions
791
- { name: "CAMERA" },
792
- { name: "WRITE_EXTERNAL_STORAGE", maxSdkVersion: 29 },
793
- ],
794
- intentFilters: [ // Intent Filters
795
- { action: "android.intent.action.VIEW", category: "android.intent.category.DEFAULT" },
796
- ],
797
- sign: { // APK/AAB signing
798
- keystore: "keystore.jks",
799
- storePassword: "password",
800
- alias: "key0",
801
- password: "password",
802
- keystoreType: "jks", // Keystore type (optional, defaults to "jks")
803
- },
804
- },
805
- },
806
- },
807
- },
808
13
  ```
809
-
810
- ### Electron Configuration (SdElectronConfig)
811
-
812
- Electron configuration for Windows desktop app builds in `client` target packages. Requires `src/electron-main.ts` entry point in the package directory.
813
-
814
- ```typescript
815
- "my-app": {
816
- target: "client",
817
- server: 3000,
818
- electron: {
819
- appId: "com.example.myapp", // Electron app ID (required)
820
- portable: false, // true: portable .exe, false: NSIS installer
821
- installerIcon: "resources/icon.ico", // Installer icon (.ico, relative to package directory)
822
- reinstallDependencies: ["better-sqlite3"], // npm packages to include (native modules etc.)
823
- postInstallScript: "node scripts/setup.js", // npm postinstall script
824
- nsisOptions: {}, // NSIS options (when portable is false)
825
- env: { // Environment variables (accessible via process.env in electron-main.ts)
826
- API_URL: "https://api.example.com",
827
- },
828
- },
829
- },
14
+ npx sd-cli <command> [options]
830
15
  ```
831
16
 
832
- **How it works:**
833
-
834
- - **Initialize**: Creates `.electron/src/package.json`, runs `npm install`, rebuilds native modules with `electron-rebuild`
835
- - **Build**: Bundles `electron-main.ts` with esbuild, copies web assets, runs `electron-builder` for Windows
836
- - **Dev mode**: Bundles `electron-main.ts`, launches Electron pointing to Vite dev server URL
837
-
838
- ### Server Externals & PM2 Configuration
839
-
840
- Server packages can configure external modules, package manager selection, and PM2 deployment settings.
841
-
842
- #### Externals
843
-
844
- Native modules (with `binding.gyp`) are automatically detected and externalized. You can also manually specify additional modules to exclude from the bundle:
845
-
846
- ```typescript
847
- "my-server": {
848
- target: "server",
849
- externals: ["cpu-features", "ssh2"], // Manually externalize these modules
850
- },
851
- ```
852
-
853
- #### Package Manager Selection
854
-
855
- The `packageManager` field controls which Node.js version management tool is used in production deployment:
856
-
857
- ```typescript
858
- "my-server": {
859
- target: "server",
860
- packageManager: "volta", // Use Volta for Node.js version management
861
- },
862
- ```
863
-
864
- **Supported package managers:**
865
-
866
- | Value | Behavior | Generated Files |
867
- |-------|----------|-----------------|
868
- | `"volta"` | Uses Volta for Node.js version management. PM2 config will execute `node` directly (Volta manages version via `package.json` engines field). | `package.json` includes `volta` field with Node.js version |
869
- | `"mise"` | Uses mise for Node.js version management. PM2 config will resolve interpreter path via `mise which node`. | `mise.toml` is copied to `dist/` with Node.js version from root `mise.toml` |
870
- | `undefined` | No version management tool. PM2 config will execute `node` directly from system PATH. | No additional version management files |
871
-
872
- **Examples:**
873
-
874
- ```typescript
875
- // Using Volta
876
- "my-server": {
877
- target: "server",
878
- packageManager: "volta",
879
- pm2: {
880
- name: "my-app-server",
881
- },
882
- },
883
-
884
- // Using mise
885
- "my-server": {
886
- target: "server",
887
- packageManager: "mise",
888
- pm2: {
889
- name: "my-app-server",
890
- },
891
- },
892
-
893
- // No package manager (use system PATH node)
894
- "my-server": {
895
- target: "server",
896
- pm2: {
897
- name: "my-app-server",
898
- },
899
- },
900
- ```
901
-
902
- #### PM2 Configuration
903
-
904
- When `pm2` is configured, `dist/pm2.config.cjs` is generated during production build for use with [PM2](https://pm2.keymetrics.io/) process manager:
905
-
906
- ```typescript
907
- "my-server": {
908
- target: "server",
909
- packageManager: "mise", // Optional: specify package manager
910
- env: {
911
- CUSTOM_VAR: "value",
912
- },
913
- pm2: {
914
- name: "my-app-server", // PM2 process name (optional)
915
- ignoreWatchPaths: ["uploads"], // Additional paths to ignore in PM2 watch (optional)
916
- },
917
- },
918
- ```
919
-
920
- **Generated `pm2.config.cjs` includes:**
921
-
922
- - Process name (from `pm2.name` or derived from package name)
923
- - Watch mode enabled with configurable ignore paths (`node_modules`, `www` + custom paths)
924
- - Node.js interpreter path (resolved via `mise which node` if `packageManager: "mise"`, otherwise `node` from PATH)
925
- - `--openssl-config=openssl.cnf` interpreter argument for legacy TLS support
926
- - Environment variables: `NODE_ENV=production`, `TZ=Asia/Seoul`, plus custom `env` values
927
-
928
- **Deployment workflow:**
929
-
930
- ```bash
931
- # 1. Build the server
932
- sd-cli build my-server
933
-
934
- # 2. Copy dist/ to deployment server
935
-
936
- # 3. On the deployment server:
937
- cd /path/to/my-server/dist
938
-
939
- # If using mise, install mise and activate
940
- mise install # Only needed if packageManager: "mise"
941
-
942
- # Install externalized dependencies
943
- npm install
944
-
945
- # Start with PM2
946
- pm2 start pm2.config.cjs
947
- ```
948
-
949
- ## Cache
950
-
951
- | Command | Cache Path | Description |
952
- | ------------- | ---------------------------------------------------- | ------------------------------------------------------------------ |
953
- | `lint` | `.cache/eslint.cache` | ESLint cache |
954
- | `lint` | `.cache/stylelint.cache` | Stylelint cache |
955
- | `typecheck` | `packages/{pkg}/.cache/typecheck-{env}.tsbuildinfo` | Incremental type-check info (`{env}` is `node` or `browser`) |
956
- | `watch` (dts) | `packages/{pkg}/.cache/dts.tsbuildinfo` | Incremental .d.ts build info |
957
-
958
- To reset cache, delete the `.cache` directory:
959
-
960
- ```bash
961
- # Delete all caches
962
- rm -rf .cache packages/*/.cache
963
- ```
17
+ Commands: `init`, `add client`, `add server`, `lint`, `typecheck`, `check`, `watch`, `dev`, `build`, `publish`, `replace-deps`, `device`
964
18
 
965
- ## Caveats
19
+ ## Source Index
966
20
 
967
- - `sd.config.ts` is required for `watch`, `dev`, `build`, `publish`, and `device` commands. `typecheck` and `lint` work without a config file.
968
- - The `publish` command automatically increments version and performs Git commit/tag/push. Execution is rejected if there are uncommitted changes.
969
- - `publish --no-build` deploys already-built artifacts as-is, so use with caution.
970
- - Before using the `device` command, run `sd-cli dev` or `sd-cli watch` first to initialize the Capacitor project.
971
- - During build, `VER` (project version) and `DEV` (`"true"` or `"false"`) environment variables are automatically set.
21
+ | Source | Exports | Description | Test |
22
+ |--------|---------|-------------|------|
23
+ | `src/sd-config.types.ts` | `BuildTarget`, `SdConfig`, `SdConfigFn`, `SdConfigParams`, `SdPackageConfig`, `SdBuildPackageConfig`, `SdClientPackageConfig`, `SdServerPackageConfig`, `SdScriptsPackageConfig`, `SdPublishConfig`, `SdLocalDirectoryPublishConfig`, `SdStoragePublishConfig`, `SdPostPublishScriptConfig`, `SdCapacitorConfig`, `SdCapacitorAndroidConfig`, `SdCapacitorSignConfig`, `SdCapacitorPermission`, `SdCapacitorIntentFilter`, `SdElectronConfig` | All TypeScript types for `sd.config.ts` (packages, publish, Capacitor, Electron) | - |
24
+ | `src/utils/vite-config.ts` | `ViteConfigOptions`, `createViteConfig` | Generates a Vite config for SolidJS + Tailwind CSS client packages | - |
972
25
 
973
26
  ## License
974
27