@simplysm/sd-cli 13.0.68 → 13.0.70
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/README.md +10 -957
- package/dist/builders/BaseBuilder.d.ts +23 -23
- package/dist/builders/BaseBuilder.d.ts.map +1 -1
- package/dist/builders/BaseBuilder.js +15 -15
- package/dist/builders/DtsBuilder.d.ts +4 -4
- package/dist/builders/DtsBuilder.js +1 -1
- package/dist/builders/LibraryBuilder.d.ts +3 -3
- package/dist/builders/types.d.ts +10 -10
- package/dist/capacitor/capacitor.d.ts +36 -36
- package/dist/capacitor/capacitor.js +63 -63
- package/dist/capacitor/capacitor.js.map +1 -1
- package/dist/commands/add-client.d.ts +8 -8
- package/dist/commands/add-client.js +15 -15
- package/dist/commands/add-client.js.map +1 -1
- package/dist/commands/add-server.d.ts +9 -9
- package/dist/commands/add-server.js +13 -13
- package/dist/commands/add-server.js.map +1 -1
- package/dist/commands/build.d.ts +9 -9
- package/dist/commands/check.js +3 -3
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/dev.d.ts +9 -9
- package/dist/commands/device.d.ts +9 -9
- package/dist/commands/device.d.ts.map +1 -1
- package/dist/commands/device.js +17 -17
- package/dist/commands/device.js.map +1 -1
- package/dist/commands/init.d.ts +6 -6
- package/dist/commands/init.js +12 -12
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/lint.d.ts +23 -23
- package/dist/commands/lint.d.ts.map +1 -1
- package/dist/commands/lint.js +25 -25
- package/dist/commands/lint.js.map +1 -1
- package/dist/commands/publish.d.ts +13 -13
- package/dist/commands/publish.d.ts.map +1 -1
- package/dist/commands/publish.js +61 -61
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/replace-deps.d.ts +3 -3
- package/dist/commands/replace-deps.d.ts.map +1 -1
- package/dist/commands/replace-deps.js +1 -1
- package/dist/commands/replace-deps.js.map +1 -1
- package/dist/commands/typecheck.d.ts +20 -20
- package/dist/commands/typecheck.d.ts.map +1 -1
- package/dist/commands/typecheck.js +20 -20
- package/dist/commands/typecheck.js.map +1 -1
- package/dist/commands/watch.d.ts +7 -7
- package/dist/electron/electron.d.ts +27 -27
- package/dist/electron/electron.js +32 -32
- package/dist/electron/electron.js.map +1 -1
- package/dist/infra/ResultCollector.d.ts +9 -9
- package/dist/infra/ResultCollector.js +5 -5
- package/dist/infra/SignalHandler.d.ts +7 -7
- package/dist/infra/SignalHandler.js +4 -4
- package/dist/infra/WorkerManager.d.ts +14 -14
- package/dist/infra/WorkerManager.js +11 -11
- package/dist/orchestrators/BuildOrchestrator.d.ts +19 -19
- package/dist/orchestrators/BuildOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/BuildOrchestrator.js +26 -26
- package/dist/orchestrators/BuildOrchestrator.js.map +1 -1
- package/dist/orchestrators/DevOrchestrator.d.ts +25 -25
- package/dist/orchestrators/DevOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/DevOrchestrator.js +30 -30
- package/dist/orchestrators/DevOrchestrator.js.map +1 -1
- package/dist/orchestrators/WatchOrchestrator.d.ts +13 -13
- package/dist/orchestrators/WatchOrchestrator.js +17 -17
- package/dist/orchestrators/WatchOrchestrator.js.map +1 -1
- package/dist/sd-cli-entry.d.ts +2 -2
- package/dist/sd-cli-entry.js +38 -38
- package/dist/sd-cli-entry.js.map +1 -1
- package/dist/sd-cli.d.ts +2 -2
- package/dist/sd-cli.js +1 -1
- package/dist/sd-cli.js.map +1 -1
- package/dist/sd-config.types.d.ts +84 -84
- package/dist/sd-config.types.d.ts.map +1 -1
- package/dist/utils/build-env.d.ts +1 -1
- package/dist/utils/config-editor.d.ts +5 -5
- package/dist/utils/config-editor.js +2 -2
- package/dist/utils/config-editor.js.map +1 -1
- package/dist/utils/copy-public.d.ts +9 -9
- package/dist/utils/copy-src.d.ts +9 -9
- package/dist/utils/esbuild-config.d.ts +30 -30
- package/dist/utils/esbuild-config.d.ts.map +1 -1
- package/dist/utils/output-utils.d.ts +6 -6
- package/dist/utils/package-utils.d.ts +6 -6
- package/dist/utils/package-utils.js +1 -1
- package/dist/utils/package-utils.js.map +1 -1
- package/dist/utils/rebuild-manager.js +3 -3
- package/dist/utils/rebuild-manager.js.map +1 -1
- package/dist/utils/replace-deps.d.ts +25 -25
- package/dist/utils/replace-deps.js +3 -3
- package/dist/utils/replace-deps.js.map +1 -1
- package/dist/utils/sd-config.d.ts +3 -3
- package/dist/utils/sd-config.js +3 -3
- package/dist/utils/sd-config.js.map +1 -1
- package/dist/utils/tailwind-config-deps.d.ts +3 -3
- package/dist/utils/template.d.ts +8 -8
- package/dist/utils/tsconfig.d.ts +16 -16
- package/dist/utils/tsconfig.js +2 -2
- package/dist/utils/tsconfig.js.map +1 -1
- package/dist/utils/typecheck-serialization.d.ts +8 -8
- package/dist/utils/vite-config.d.ts +8 -8
- package/dist/utils/vite-config.d.ts.map +1 -1
- package/dist/utils/vite-config.js +3 -3
- package/dist/utils/worker-events.d.ts +12 -12
- package/dist/utils/worker-events.d.ts.map +1 -1
- package/dist/utils/worker-utils.d.ts +3 -3
- package/dist/utils/worker-utils.js +2 -2
- package/dist/utils/worker-utils.js.map +1 -1
- package/dist/workers/client.worker.d.ts +14 -14
- package/dist/workers/client.worker.d.ts.map +1 -1
- package/dist/workers/client.worker.js +1 -1
- package/dist/workers/client.worker.js.map +1 -1
- package/dist/workers/dts.worker.d.ts +13 -13
- package/dist/workers/dts.worker.d.ts.map +1 -1
- package/dist/workers/dts.worker.js +3 -3
- package/dist/workers/dts.worker.js.map +1 -1
- package/dist/workers/library.worker.d.ts +12 -12
- package/dist/workers/library.worker.js +1 -1
- package/dist/workers/library.worker.js.map +1 -1
- package/dist/workers/lint.worker.d.ts +1 -1
- package/dist/workers/server-runtime.worker.d.ts +6 -6
- package/dist/workers/server-runtime.worker.js +6 -6
- package/dist/workers/server-runtime.worker.js.map +1 -1
- package/dist/workers/server.worker.d.ts +20 -20
- package/dist/workers/server.worker.d.ts.map +1 -1
- package/dist/workers/server.worker.js +6 -6
- package/dist/workers/server.worker.js.map +1 -1
- package/package.json +8 -7
- package/src/builders/BaseBuilder.ts +33 -33
- package/src/builders/DtsBuilder.ts +5 -5
- package/src/builders/LibraryBuilder.ts +9 -9
- package/src/builders/types.ts +10 -10
- package/src/capacitor/capacitor.ts +119 -119
- package/src/commands/add-client.ts +31 -31
- package/src/commands/add-server.ts +34 -34
- package/src/commands/build.ts +9 -9
- package/src/commands/check.ts +5 -5
- package/src/commands/dev.ts +9 -9
- package/src/commands/device.ts +30 -30
- package/src/commands/init.ts +25 -25
- package/src/commands/lint.ts +64 -64
- package/src/commands/publish.ts +139 -139
- package/src/commands/replace-deps.ts +4 -4
- package/src/commands/typecheck.ts +74 -74
- package/src/commands/watch.ts +7 -7
- package/src/electron/electron.ts +51 -51
- package/src/infra/ResultCollector.ts +9 -9
- package/src/infra/SignalHandler.ts +7 -7
- package/src/infra/WorkerManager.ts +14 -14
- package/src/orchestrators/BuildOrchestrator.ts +76 -76
- package/src/orchestrators/DevOrchestrator.ts +88 -88
- package/src/orchestrators/WatchOrchestrator.ts +39 -39
- package/src/sd-cli-entry.ts +43 -43
- package/src/sd-cli.ts +15 -15
- package/src/sd-config.types.ts +85 -85
- package/src/utils/build-env.ts +1 -1
- package/src/utils/config-editor.ts +19 -19
- package/src/utils/copy-public.ts +17 -17
- package/src/utils/copy-src.ts +11 -11
- package/src/utils/esbuild-config.ts +33 -33
- package/src/utils/output-utils.ts +11 -11
- package/src/utils/package-utils.ts +12 -12
- package/src/utils/rebuild-manager.ts +3 -3
- package/src/utils/replace-deps.ts +361 -361
- package/src/utils/sd-config.ts +44 -44
- package/src/utils/tailwind-config-deps.ts +98 -98
- package/src/utils/template.ts +56 -56
- package/src/utils/tsconfig.ts +127 -127
- package/src/utils/typecheck-serialization.ts +86 -86
- package/src/utils/vite-config.ts +341 -341
- package/src/utils/worker-events.ts +16 -16
- package/src/utils/worker-utils.ts +45 -45
- package/src/workers/client.worker.ts +34 -34
- package/src/workers/dts.worker.ts +467 -467
- package/src/workers/library.worker.ts +314 -314
- package/src/workers/lint.worker.ts +16 -16
- package/src/workers/server-runtime.worker.ts +157 -157
- package/src/workers/server.worker.ts +572 -572
- package/templates/add-client/__CLIENT__/package.json.hbs +1 -1
- package/templates/add-server/__SERVER__/package.json.hbs +2 -2
- package/templates/init/package.json.hbs +3 -3
- package/tests/config-editor.spec.ts +160 -0
- package/tests/copy-src.spec.ts +50 -0
- package/tests/get-compiler-options-for-package.spec.ts +139 -0
- package/tests/get-package-source-files.spec.ts +181 -0
- package/tests/get-types-from-package-json.spec.ts +107 -0
- package/tests/infra/ResultCollector.spec.ts +39 -0
- package/tests/infra/SignalHandler.spec.ts +38 -0
- package/tests/infra/WorkerManager.spec.ts +97 -0
- package/tests/load-ignore-patterns.spec.ts +188 -0
- package/tests/load-sd-config.spec.ts +137 -0
- package/tests/package-utils.spec.ts +188 -0
- package/tests/parse-root-tsconfig.spec.ts +89 -0
- package/tests/replace-deps.spec.ts +308 -0
- package/tests/run-lint.spec.ts +415 -0
- package/tests/run-typecheck.spec.ts +653 -0
- package/tests/run-watch.spec.ts +75 -0
- package/tests/sd-cli.spec.ts +330 -0
- package/tests/tailwind-config-deps.spec.ts +30 -0
- package/tests/template.spec.ts +70 -0
- package/tests/utils/rebuild-manager.spec.ts +43 -0
- package/tests/write-changed-output-files.spec.ts +97 -0
package/src/sd-config.types.ts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* - node: Node.js
|
|
4
|
-
* - browser:
|
|
5
|
-
* - neutral: Node
|
|
2
|
+
* Build target type (built with esbuild)
|
|
3
|
+
* - node: Node.js only package
|
|
4
|
+
* - browser: browser only package
|
|
5
|
+
* - neutral: Node/browser shared package
|
|
6
6
|
*/
|
|
7
7
|
export type BuildTarget = "node" | "browser" | "neutral";
|
|
8
8
|
|
|
9
|
-
//#region Publish
|
|
9
|
+
//#region Publish configuration types
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
* - "npm": npm
|
|
14
|
-
* - SdLocalDirectoryPublishConfig:
|
|
15
|
-
* - SdStoragePublishConfig: FTP/FTPS/SFTP
|
|
12
|
+
* Package publish configuration
|
|
13
|
+
* - "npm": deploy to npm registry
|
|
14
|
+
* - SdLocalDirectoryPublishConfig: copy to local directory
|
|
15
|
+
* - SdStoragePublishConfig: upload to FTP/FTPS/SFTP server
|
|
16
16
|
*/
|
|
17
17
|
export type SdPublishConfig = "npm" | SdLocalDirectoryPublishConfig | SdStoragePublishConfig;
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* Local directory publish configuration
|
|
21
21
|
*/
|
|
22
22
|
export interface SdLocalDirectoryPublishConfig {
|
|
23
23
|
type: "local-directory";
|
|
24
|
-
/**
|
|
24
|
+
/** deployment target path (supports environment variable substitution: %VER%, %PROJECT%) */
|
|
25
25
|
path: string;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* Storage (FTP/FTPS/SFTP) publish configuration
|
|
30
30
|
*/
|
|
31
31
|
export interface SdStoragePublishConfig {
|
|
32
32
|
type: "ftp" | "ftps" | "sftp";
|
|
@@ -38,168 +38,168 @@ export interface SdStoragePublishConfig {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
-
* postPublish
|
|
41
|
+
* postPublish script configuration
|
|
42
42
|
*/
|
|
43
43
|
export interface SdPostPublishScriptConfig {
|
|
44
44
|
type: "script";
|
|
45
45
|
cmd: string;
|
|
46
|
-
/**
|
|
46
|
+
/** script arguments (supports environment variable substitution: %VER%, %PROJECT%) */
|
|
47
47
|
args: string[];
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
//#endregion
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
53
|
+
* Package configuration (node/browser/neutral)
|
|
54
54
|
*/
|
|
55
55
|
export interface SdBuildPackageConfig {
|
|
56
|
-
/**
|
|
56
|
+
/** build target */
|
|
57
57
|
target: BuildTarget;
|
|
58
|
-
/** publish
|
|
58
|
+
/** publish configuration */
|
|
59
59
|
publish?: SdPublishConfig;
|
|
60
|
-
/**
|
|
60
|
+
/** glob patterns for files to copy from src/ to dist/ (relative path based on src/) */
|
|
61
61
|
copySrc?: string[];
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
* Capacitor Android
|
|
65
|
+
* Capacitor Android sign configuration
|
|
66
66
|
*/
|
|
67
67
|
export interface SdCapacitorSignConfig {
|
|
68
|
-
/** keystore
|
|
68
|
+
/** keystore file path (relative path based on package directory) */
|
|
69
69
|
keystore: string;
|
|
70
|
-
/** keystore
|
|
70
|
+
/** keystore password */
|
|
71
71
|
storePassword: string;
|
|
72
|
-
/**
|
|
72
|
+
/** key alias */
|
|
73
73
|
alias: string;
|
|
74
|
-
/**
|
|
74
|
+
/** key password */
|
|
75
75
|
password: string;
|
|
76
|
-
/** keystore
|
|
76
|
+
/** keystore type (default: "jks") */
|
|
77
77
|
keystoreType?: string;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
|
-
* Capacitor Android
|
|
81
|
+
* Capacitor Android permission configuration
|
|
82
82
|
*/
|
|
83
83
|
export interface SdCapacitorPermission {
|
|
84
|
-
/**
|
|
84
|
+
/** permission name (e.g., "CAMERA", "WRITE_EXTERNAL_STORAGE") */
|
|
85
85
|
name: string;
|
|
86
|
-
/**
|
|
86
|
+
/** maximum SDK version */
|
|
87
87
|
maxSdkVersion?: number;
|
|
88
|
-
/** tools:ignore
|
|
88
|
+
/** tools:ignore attribute value */
|
|
89
89
|
ignore?: string;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
|
-
* Capacitor Android Intent Filter
|
|
93
|
+
* Capacitor Android Intent Filter configuration
|
|
94
94
|
*/
|
|
95
95
|
export interface SdCapacitorIntentFilter {
|
|
96
|
-
/** intent action (
|
|
96
|
+
/** intent action (e.g., "android.intent.action.VIEW") */
|
|
97
97
|
action?: string;
|
|
98
|
-
/** intent category (
|
|
98
|
+
/** intent category (e.g., "android.intent.category.DEFAULT") */
|
|
99
99
|
category?: string;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
/**
|
|
103
|
-
* Capacitor Android
|
|
103
|
+
* Capacitor Android platform configuration
|
|
104
104
|
*/
|
|
105
105
|
export interface SdCapacitorAndroidConfig {
|
|
106
|
-
/** AndroidManifest.xml application
|
|
106
|
+
/** AndroidManifest.xml application tag attributes (e.g., { requestLegacyExternalStorage: "true" }) */
|
|
107
107
|
config?: Record<string, string>;
|
|
108
|
-
/** AAB
|
|
108
|
+
/** AAB bundle build flag (false for APK) */
|
|
109
109
|
bundle?: boolean;
|
|
110
|
-
/** Intent Filter
|
|
110
|
+
/** Intent Filter configuration */
|
|
111
111
|
intentFilters?: SdCapacitorIntentFilter[];
|
|
112
|
-
/** APK/AAB
|
|
112
|
+
/** APK/AAB signing configuration */
|
|
113
113
|
sign?: SdCapacitorSignConfig;
|
|
114
|
-
/** Android SDK
|
|
114
|
+
/** Android SDK version (minSdk, targetSdk) */
|
|
115
115
|
sdkVersion?: number;
|
|
116
|
-
/**
|
|
116
|
+
/** additional permission configuration */
|
|
117
117
|
permissions?: SdCapacitorPermission[];
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
|
-
* Capacitor
|
|
121
|
+
* Capacitor configuration
|
|
122
122
|
*/
|
|
123
123
|
export interface SdCapacitorConfig {
|
|
124
|
-
/**
|
|
124
|
+
/** app ID (e.g., "com.example.app") */
|
|
125
125
|
appId: string;
|
|
126
|
-
/**
|
|
126
|
+
/** app name */
|
|
127
127
|
appName: string;
|
|
128
|
-
/** Capacitor
|
|
128
|
+
/** Capacitor plugin configuration (key: package name, value: true or plugin options) */
|
|
129
129
|
plugins?: Record<string, Record<string, unknown> | true>;
|
|
130
|
-
/**
|
|
130
|
+
/** app icon path (relative path based on package directory) */
|
|
131
131
|
icon?: string;
|
|
132
|
-
/**
|
|
132
|
+
/** debug build flag */
|
|
133
133
|
debug?: boolean;
|
|
134
|
-
/**
|
|
134
|
+
/** per-platform configuration */
|
|
135
135
|
platform?: {
|
|
136
136
|
android?: SdCapacitorAndroidConfig;
|
|
137
137
|
};
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
/**
|
|
141
|
-
* Electron
|
|
141
|
+
* Electron configuration
|
|
142
142
|
*/
|
|
143
143
|
export interface SdElectronConfig {
|
|
144
|
-
/** Electron
|
|
144
|
+
/** Electron app ID (e.g., "com.example.myapp") */
|
|
145
145
|
appId: string;
|
|
146
|
-
/** portable .exe (true)
|
|
146
|
+
/** portable .exe (true) or NSIS installer (false/unspecified) */
|
|
147
147
|
portable?: boolean;
|
|
148
|
-
/**
|
|
148
|
+
/** installer icon path (.ico, relative path based on package directory) */
|
|
149
149
|
installerIcon?: string;
|
|
150
|
-
/**
|
|
150
|
+
/** npm packages to include in Electron (native modules, etc.) */
|
|
151
151
|
reinstallDependencies?: string[];
|
|
152
|
-
/** npm postinstall
|
|
152
|
+
/** npm postinstall script */
|
|
153
153
|
postInstallScript?: string;
|
|
154
|
-
/** NSIS
|
|
154
|
+
/** NSIS options (when portable is false) */
|
|
155
155
|
nsisOptions?: Record<string, unknown>;
|
|
156
|
-
/**
|
|
156
|
+
/** environment variables (accessible via process.env in electron-main.ts) */
|
|
157
157
|
env?: Record<string, string>;
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
/**
|
|
161
|
-
*
|
|
161
|
+
* Client package configuration (Vite development server)
|
|
162
162
|
*/
|
|
163
163
|
export interface SdClientPackageConfig {
|
|
164
|
-
/**
|
|
164
|
+
/** build target */
|
|
165
165
|
target: "client";
|
|
166
166
|
/**
|
|
167
|
-
*
|
|
168
|
-
* - string:
|
|
169
|
-
* - number: Vite
|
|
167
|
+
* server configuration
|
|
168
|
+
* - string: server package name to connect to (e.g., "solid-demo-server")
|
|
169
|
+
* - number: use Vite port directly (backward compatibility)
|
|
170
170
|
*/
|
|
171
171
|
server: string | number;
|
|
172
|
-
/**
|
|
172
|
+
/** environment variables to substitute during build (replace process.env with object) */
|
|
173
173
|
env?: Record<string, string>;
|
|
174
|
-
/** publish
|
|
174
|
+
/** publish configuration */
|
|
175
175
|
publish?: SdPublishConfig;
|
|
176
|
-
/** Capacitor
|
|
176
|
+
/** Capacitor configuration */
|
|
177
177
|
capacitor?: SdCapacitorConfig;
|
|
178
|
-
/** Electron
|
|
178
|
+
/** Electron configuration */
|
|
179
179
|
electron?: SdElectronConfig;
|
|
180
180
|
/** runtime config (written to dist/.config.json during build) */
|
|
181
181
|
configs?: Record<string, unknown>;
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
/**
|
|
185
|
-
*
|
|
185
|
+
* Server package configuration (Fastify server)
|
|
186
186
|
*/
|
|
187
187
|
export interface SdServerPackageConfig {
|
|
188
|
-
/**
|
|
188
|
+
/** build target */
|
|
189
189
|
target: "server";
|
|
190
|
-
/**
|
|
190
|
+
/** environment variables to substitute during build (replace process.env.KEY with constant) */
|
|
191
191
|
env?: Record<string, string>;
|
|
192
|
-
/** publish
|
|
192
|
+
/** publish configuration */
|
|
193
193
|
publish?: SdPublishConfig;
|
|
194
194
|
/** runtime config (written to dist/.config.json during build) */
|
|
195
195
|
configs?: Record<string, unknown>;
|
|
196
|
-
/**
|
|
196
|
+
/** external modules not to include in esbuild bundle (in addition to automatic binding.gyp detection) */
|
|
197
197
|
externals?: string[];
|
|
198
|
-
/** PM2
|
|
198
|
+
/** PM2 configuration (generates dist/pm2.config.cjs when specified) */
|
|
199
199
|
pm2?: {
|
|
200
|
-
/** PM2
|
|
200
|
+
/** PM2 process name (generated from package.json name if unspecified) */
|
|
201
201
|
name?: string;
|
|
202
|
-
/** PM2 watch
|
|
202
|
+
/** paths to exclude from PM2 watch */
|
|
203
203
|
ignoreWatchPaths?: string[];
|
|
204
204
|
};
|
|
205
205
|
/** Package manager to use (affects mise.toml or volta settings generation) */
|
|
@@ -207,15 +207,15 @@ export interface SdServerPackageConfig {
|
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
/**
|
|
210
|
-
*
|
|
210
|
+
* Scripts-only package configuration (excluded from watch/typecheck)
|
|
211
211
|
*/
|
|
212
212
|
export interface SdScriptsPackageConfig {
|
|
213
|
-
/**
|
|
213
|
+
/** build target */
|
|
214
214
|
target: "scripts";
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
/**
|
|
218
|
-
*
|
|
218
|
+
* Package configuration
|
|
219
219
|
*/
|
|
220
220
|
export type SdPackageConfig =
|
|
221
221
|
| SdBuildPackageConfig
|
|
@@ -224,36 +224,36 @@ export type SdPackageConfig =
|
|
|
224
224
|
| SdScriptsPackageConfig;
|
|
225
225
|
|
|
226
226
|
/**
|
|
227
|
-
* sd.config.ts
|
|
227
|
+
* sd.config.ts configuration type
|
|
228
228
|
*/
|
|
229
229
|
export interface SdConfig {
|
|
230
|
-
/**
|
|
230
|
+
/** per-package configuration (key: subdirectory name under packages/, e.g., "core-common") */
|
|
231
231
|
packages: Record<string, SdPackageConfig | undefined>;
|
|
232
232
|
/**
|
|
233
|
-
*
|
|
234
|
-
* -
|
|
235
|
-
* -
|
|
236
|
-
* -
|
|
233
|
+
* dependency replacement configuration (replace node_modules packages with local sources via symlink)
|
|
234
|
+
* - key: package glob pattern to find in node_modules (e.g., "@simplysm/*")
|
|
235
|
+
* - value: source directory path (captured values from key's * are substituted into value's *)
|
|
236
|
+
* - example: { "@simplysm/*": "../simplysm/packages/*" }
|
|
237
237
|
*/
|
|
238
238
|
replaceDeps?: Record<string, string>;
|
|
239
|
-
/**
|
|
239
|
+
/** script to execute after deployment completes */
|
|
240
240
|
postPublish?: SdPostPublishScriptConfig[];
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
/**
|
|
244
|
-
* sd.config.ts
|
|
244
|
+
* parameters passed to sd.config.ts function
|
|
245
245
|
*/
|
|
246
246
|
export interface SdConfigParams {
|
|
247
|
-
/**
|
|
247
|
+
/** current working directory */
|
|
248
248
|
cwd: string;
|
|
249
|
-
/**
|
|
249
|
+
/** development mode flag */
|
|
250
250
|
dev: boolean;
|
|
251
|
-
/**
|
|
251
|
+
/** additional options (from CLI's -o flag) */
|
|
252
252
|
opt: string[];
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
/**
|
|
256
|
-
* sd.config.ts
|
|
256
|
+
* sd.config.ts must default export a function of the following form:
|
|
257
257
|
*
|
|
258
258
|
* ```typescript
|
|
259
259
|
* import type { SdConfig, SdConfigFn, SdConfigParams } from "@simplysm/sd-cli";
|
package/src/utils/build-env.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Project, SyntaxKind, type ObjectLiteralExpression } from "ts-morph";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* sd.config.ts
|
|
4
|
+
* Find packages object literal in sd.config.ts
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* Structure: const config: SdConfigFn = () => ({ packages: { ... } });
|
|
7
7
|
* -> ArrowFunction -> ParenthesizedExpression -> ObjectLiteral -> "packages" property -> ObjectLiteral
|
|
8
8
|
*/
|
|
9
9
|
function findPackagesObject(configPath: string): {
|
|
@@ -13,11 +13,11 @@ function findPackagesObject(configPath: string): {
|
|
|
13
13
|
const project = new Project();
|
|
14
14
|
const sourceFile = project.addSourceFileAtPath(configPath);
|
|
15
15
|
|
|
16
|
-
// "config"
|
|
16
|
+
// Find "config" variable declaration
|
|
17
17
|
const configVar = sourceFile.getVariableDeclarationOrThrow("config");
|
|
18
18
|
const arrowFn = configVar.getInitializerIfKindOrThrow(SyntaxKind.ArrowFunction);
|
|
19
19
|
|
|
20
|
-
//
|
|
20
|
+
// Find return object in arrow function body
|
|
21
21
|
const body = arrowFn.getBody();
|
|
22
22
|
let returnObj: ObjectLiteralExpression;
|
|
23
23
|
|
|
@@ -27,10 +27,10 @@ function findPackagesObject(configPath: string): {
|
|
|
27
27
|
const returnStmt = body.getFirstDescendantByKindOrThrow(SyntaxKind.ReturnStatement);
|
|
28
28
|
returnObj = returnStmt.getExpressionIfKindOrThrow(SyntaxKind.ObjectLiteralExpression);
|
|
29
29
|
} else {
|
|
30
|
-
throw new Error("sd.config.ts
|
|
30
|
+
throw new Error("Unable to recognize structure of sd.config.ts");
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
// "packages"
|
|
33
|
+
// Find "packages" property
|
|
34
34
|
const packagesProp = returnObj
|
|
35
35
|
.getPropertyOrThrow("packages")
|
|
36
36
|
.asKindOrThrow(SyntaxKind.PropertyAssignment);
|
|
@@ -40,9 +40,9 @@ function findPackagesObject(configPath: string): {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
43
|
+
* Add new package entry to packages object in sd.config.ts
|
|
44
44
|
*
|
|
45
|
-
* @returns true:
|
|
45
|
+
* @returns true: success, false: already exists
|
|
46
46
|
*/
|
|
47
47
|
export function addPackageToSdConfig(
|
|
48
48
|
configPath: string,
|
|
@@ -51,14 +51,14 @@ export function addPackageToSdConfig(
|
|
|
51
51
|
): boolean {
|
|
52
52
|
const { project, packagesObj } = findPackagesObject(configPath);
|
|
53
53
|
|
|
54
|
-
//
|
|
54
|
+
// Check if already exists (check both quoted and unquoted forms)
|
|
55
55
|
const existing =
|
|
56
56
|
packagesObj.getProperty(`"${packageName}"`) ?? packagesObj.getProperty(packageName);
|
|
57
57
|
if (existing) {
|
|
58
58
|
return false;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
//
|
|
61
|
+
// Add new property -- convert config object to ts-morph initializer string
|
|
62
62
|
const configStr = JSON.stringify(config)
|
|
63
63
|
.replace(/"([^"]+)":/g, "$1: ")
|
|
64
64
|
.replace(/"/g, '"');
|
|
@@ -73,7 +73,7 @@ export function addPackageToSdConfig(
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
|
-
* sd.config.ts
|
|
76
|
+
* Set server field for specific client in sd.config.ts
|
|
77
77
|
*/
|
|
78
78
|
export function setClientServerInSdConfig(
|
|
79
79
|
configPath: string,
|
|
@@ -85,19 +85,19 @@ export function setClientServerInSdConfig(
|
|
|
85
85
|
const clientPropNode =
|
|
86
86
|
packagesObj.getProperty(`"${clientName}"`) ?? packagesObj.getProperty(clientName);
|
|
87
87
|
if (clientPropNode == null) {
|
|
88
|
-
throw new Error(
|
|
88
|
+
throw new Error(`Client "${clientName}" not found in sd.config.ts`);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
const clientProp = clientPropNode.asKindOrThrow(SyntaxKind.PropertyAssignment);
|
|
92
92
|
const clientObj = clientProp.getInitializerIfKindOrThrow(SyntaxKind.ObjectLiteralExpression);
|
|
93
93
|
|
|
94
|
-
//
|
|
94
|
+
// Remove existing server property if present
|
|
95
95
|
const serverProp = clientObj.getProperty("server");
|
|
96
96
|
if (serverProp) {
|
|
97
97
|
serverProp.remove();
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
// server
|
|
100
|
+
// Add server property
|
|
101
101
|
clientObj.addPropertyAssignment({
|
|
102
102
|
name: "server",
|
|
103
103
|
initializer: `"${serverName}"`,
|
|
@@ -107,26 +107,26 @@ export function setClientServerInSdConfig(
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
|
-
* eslint.config.ts
|
|
110
|
+
* Add tailwindcss config block to eslint.config.ts
|
|
111
111
|
*
|
|
112
|
-
* @returns true:
|
|
112
|
+
* @returns true: added, false: already exists
|
|
113
113
|
*/
|
|
114
114
|
export function addTailwindToEslintConfig(configPath: string, clientName: string): boolean {
|
|
115
115
|
const project = new Project();
|
|
116
116
|
const sourceFile = project.addSourceFileAtPath(configPath);
|
|
117
117
|
|
|
118
|
-
// default export
|
|
118
|
+
// Find default export array
|
|
119
119
|
const defaultExport = sourceFile.getFirstDescendantByKindOrThrow(
|
|
120
120
|
SyntaxKind.ArrayLiteralExpression,
|
|
121
121
|
);
|
|
122
122
|
|
|
123
|
-
// tailwindcss
|
|
123
|
+
// Check if tailwindcss config already exists
|
|
124
124
|
const text = defaultExport.getText();
|
|
125
125
|
if (text.includes("tailwindcss")) {
|
|
126
126
|
return false;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
//
|
|
129
|
+
// Add new config object
|
|
130
130
|
defaultExport.addElement(`{
|
|
131
131
|
files: ["**/*.{ts,tsx}"],
|
|
132
132
|
settings: {
|
package/src/utils/copy-public.ts
CHANGED
|
@@ -10,17 +10,17 @@ import {
|
|
|
10
10
|
} from "@simplysm/core-node";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* public/
|
|
14
|
-
* public-dev
|
|
13
|
+
* Copy files from public/ and public-dev/ directories to dist/.
|
|
14
|
+
* public-dev/ takes priority over public/ (overlay).
|
|
15
15
|
*
|
|
16
|
-
* @param pkgDir
|
|
17
|
-
* @param includeDev public-dev/
|
|
16
|
+
* @param pkgDir Package root directory
|
|
17
|
+
* @param includeDev Whether to include public-dev/ (true only in dev mode)
|
|
18
18
|
*/
|
|
19
19
|
export async function copyPublicFiles(pkgDir: string, includeDev: boolean): Promise<void> {
|
|
20
20
|
const distDir = path.join(pkgDir, "dist");
|
|
21
21
|
await fsMkdir(distDir);
|
|
22
22
|
|
|
23
|
-
// public/
|
|
23
|
+
// Copy public/
|
|
24
24
|
const publicDir = path.join(pkgDir, "public");
|
|
25
25
|
if (await fsExists(publicDir)) {
|
|
26
26
|
const files = await fsGlob("**/*", { cwd: publicDir, absolute: true });
|
|
@@ -32,7 +32,7 @@ export async function copyPublicFiles(pkgDir: string, includeDev: boolean): Prom
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
// public-dev/
|
|
35
|
+
// Copy public-dev/ (overlay: overwrites public/)
|
|
36
36
|
if (includeDev) {
|
|
37
37
|
const publicDevDir = path.join(pkgDir, "public-dev");
|
|
38
38
|
if (await fsExists(publicDevDir)) {
|
|
@@ -48,12 +48,12 @@ export async function copyPublicFiles(pkgDir: string, includeDev: boolean): Prom
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
|
-
* public/
|
|
52
|
-
*
|
|
51
|
+
* Watch public/ and public-dev/ directories and copy files to dist/ in real-time.
|
|
52
|
+
* Automatically reflects changes/additions/deletions after initial copy.
|
|
53
53
|
*
|
|
54
|
-
* @param pkgDir
|
|
55
|
-
* @param includeDev public-dev/
|
|
56
|
-
* @returns FsWatcher
|
|
54
|
+
* @param pkgDir Package root directory
|
|
55
|
+
* @param includeDev Whether to include public-dev/ (true only in dev mode)
|
|
56
|
+
* @returns FsWatcher instance (must call close() on shutdown) or undefined if no watch targets
|
|
57
57
|
*/
|
|
58
58
|
export async function watchPublicFiles(
|
|
59
59
|
pkgDir: string,
|
|
@@ -63,10 +63,10 @@ export async function watchPublicFiles(
|
|
|
63
63
|
const publicDir = path.join(pkgDir, "public");
|
|
64
64
|
const publicDevDir = path.join(pkgDir, "public-dev");
|
|
65
65
|
|
|
66
|
-
//
|
|
66
|
+
// Initial copy
|
|
67
67
|
await copyPublicFiles(pkgDir, includeDev);
|
|
68
68
|
|
|
69
|
-
// watch
|
|
69
|
+
// Collect watch target paths
|
|
70
70
|
const watchPaths: string[] = [];
|
|
71
71
|
if (await fsExists(publicDir)) {
|
|
72
72
|
watchPaths.push(path.join(publicDir, "**/*"));
|
|
@@ -83,7 +83,7 @@ export async function watchPublicFiles(
|
|
|
83
83
|
|
|
84
84
|
watcher.onChange({ delay: 300 }, async (changes) => {
|
|
85
85
|
for (const { event, path: filePath } of changes) {
|
|
86
|
-
//
|
|
86
|
+
// Determine which source directory the change came from
|
|
87
87
|
let sourceDir: string;
|
|
88
88
|
if (pathIsChildPath(filePath, publicDevDir)) {
|
|
89
89
|
sourceDir = publicDevDir;
|
|
@@ -95,14 +95,14 @@ export async function watchPublicFiles(
|
|
|
95
95
|
const distPath = path.join(distDir, relPath);
|
|
96
96
|
|
|
97
97
|
if (event === "unlink") {
|
|
98
|
-
//
|
|
98
|
+
// If deleted from public, don't delete if same file exists in public-dev
|
|
99
99
|
if (sourceDir === publicDir && includeDev) {
|
|
100
100
|
const devOverride = path.join(publicDevDir, relPath);
|
|
101
101
|
if (await fsExists(devOverride)) {
|
|
102
102
|
continue;
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
// public-dev
|
|
105
|
+
// If deleted from public-dev, restore from public if it exists (fallback restore)
|
|
106
106
|
if (sourceDir === publicDevDir && includeDev) {
|
|
107
107
|
const publicFallback = path.join(publicDir, relPath);
|
|
108
108
|
if (await fsExists(publicFallback)) {
|
|
@@ -113,7 +113,7 @@ export async function watchPublicFiles(
|
|
|
113
113
|
}
|
|
114
114
|
await fsRm(distPath);
|
|
115
115
|
} else if (event === "add" || event === "change") {
|
|
116
|
-
// public
|
|
116
|
+
// If changed in public, skip if same file exists in public-dev (overlay takes priority)
|
|
117
117
|
if (sourceDir === publicDir && includeDev) {
|
|
118
118
|
const devOverride = path.join(publicDevDir, relPath);
|
|
119
119
|
if (await fsExists(devOverride)) {
|
package/src/utils/copy-src.ts
CHANGED
|
@@ -2,11 +2,11 @@ import path from "path";
|
|
|
2
2
|
import { fsGlob, fsCopy, fsMkdir, fsRm, FsWatcher } from "@simplysm/core-node";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Copy files matching glob patterns from src/ to dist/
|
|
6
|
+
* Relative paths are preserved: src/a/b.css → dist/a/b.css
|
|
7
7
|
*
|
|
8
|
-
* @param pkgDir
|
|
9
|
-
* @param patterns glob
|
|
8
|
+
* @param pkgDir Package root directory
|
|
9
|
+
* @param patterns Array of glob patterns (relative to src/)
|
|
10
10
|
*/
|
|
11
11
|
export async function copySrcFiles(pkgDir: string, patterns: string[]): Promise<void> {
|
|
12
12
|
const srcDir = path.join(pkgDir, "src");
|
|
@@ -24,21 +24,21 @@ export async function copySrcFiles(pkgDir: string, patterns: string[]): Promise<
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
27
|
+
* Watch and copy files matching glob patterns from src/ to dist/
|
|
28
|
+
* Automatically reflects changes, additions, and deletions after initial copy.
|
|
29
29
|
*
|
|
30
|
-
* @param pkgDir
|
|
31
|
-
* @param patterns glob
|
|
32
|
-
* @returns FsWatcher
|
|
30
|
+
* @param pkgDir Package root directory
|
|
31
|
+
* @param patterns Array of glob patterns (relative to src/)
|
|
32
|
+
* @returns FsWatcher instance (call close() on shutdown)
|
|
33
33
|
*/
|
|
34
34
|
export async function watchCopySrcFiles(pkgDir: string, patterns: string[]): Promise<FsWatcher> {
|
|
35
35
|
const srcDir = path.join(pkgDir, "src");
|
|
36
36
|
const distDir = path.join(pkgDir, "dist");
|
|
37
37
|
|
|
38
|
-
//
|
|
38
|
+
// Initial copy
|
|
39
39
|
await copySrcFiles(pkgDir, patterns);
|
|
40
40
|
|
|
41
|
-
// watch
|
|
41
|
+
// Start watch
|
|
42
42
|
const watchPaths = patterns.map((p) => path.join(srcDir, p));
|
|
43
43
|
const watcher = await FsWatcher.watch(watchPaths);
|
|
44
44
|
|