reset-framework-cli 1.2.2 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -20
- package/README.md +25 -25
- package/package.json +7 -7
- package/src/commands/build.js +144 -144
- package/src/commands/dev.js +195 -195
- package/src/commands/doctor.js +140 -140
- package/src/commands/init.js +946 -946
- package/src/commands/package.js +68 -68
- package/src/index.js +195 -195
- package/src/lib/backend.js +123 -123
- package/src/lib/context.js +66 -66
- package/src/lib/framework.js +57 -57
- package/src/lib/logger.js +11 -11
- package/src/lib/output.js +283 -283
- package/src/lib/process.js +303 -303
- package/src/lib/project.js +893 -866
- package/src/lib/toolchain.js +62 -62
- package/src/lib/ui.js +244 -244
- package/templates/basic/README.md +15 -15
- package/templates/basic/frontend/README.md +73 -73
- package/templates/basic/frontend/eslint.config.js +23 -23
- package/templates/basic/frontend/index.html +13 -13
- package/templates/basic/frontend/package.json +31 -31
- package/templates/basic/frontend/public/icons.svg +24 -24
- package/templates/basic/frontend/src/App.css +216 -216
- package/templates/basic/frontend/src/App.tsx +77 -77
- package/templates/basic/frontend/src/assets/vite.svg +1 -1
- package/templates/basic/frontend/src/index.css +111 -111
- package/templates/basic/frontend/src/lib/reset.ts +1 -1
- package/templates/basic/frontend/src/main.tsx +10 -10
- package/templates/basic/frontend/tsconfig.app.json +28 -28
- package/templates/basic/frontend/tsconfig.json +7 -7
- package/templates/basic/frontend/tsconfig.node.json +26 -26
- package/templates/basic/frontend/vite.config.ts +16 -16
- package/templates/basic/reset.config.json +58 -58
package/src/commands/dev.js
CHANGED
|
@@ -1,200 +1,200 @@
|
|
|
1
|
-
import { prepareFrameworkRuntime } from "../lib/framework.js"
|
|
2
|
-
import { prepareAppBackend } from "../lib/backend.js"
|
|
3
|
-
import {
|
|
4
|
-
registerChildCleanup,
|
|
5
|
-
resolvePackageManagerCommand,
|
|
6
|
-
spawnCommand,
|
|
7
|
-
waitForProcessExit,
|
|
8
|
-
waitForUrl
|
|
9
|
-
} from "../lib/process.js"
|
|
10
|
-
import {
|
|
11
|
-
assertAppProject,
|
|
12
|
-
assertFrameworkInstall,
|
|
13
|
-
loadResetConfig,
|
|
14
|
-
resolveAppPaths,
|
|
15
|
-
resolveAppPackageManager,
|
|
16
|
-
resolveConfigPath,
|
|
17
|
-
resolveDevServerOptions,
|
|
18
|
-
resolveFrontendDir,
|
|
19
|
-
resolveFrameworkBuildPaths,
|
|
20
|
-
resolveFrameworkRuntimeBinary,
|
|
21
|
-
resolveFrameworkRuntimeStrategy,
|
|
22
|
-
resolveFrameworkPaths,
|
|
23
|
-
resolveOptionalBackendEntry
|
|
24
|
-
} from "../lib/project.js"
|
|
25
|
-
import {
|
|
26
|
-
createProgress,
|
|
27
|
-
printBanner,
|
|
28
|
-
printKeyValueTable,
|
|
29
|
-
printSection,
|
|
30
|
-
printStatusTable
|
|
31
|
-
} from "../lib/ui.js"
|
|
32
|
-
|
|
33
|
-
export const description = "Run the frontend dev server and native host"
|
|
34
|
-
|
|
35
|
-
export async function run(context) {
|
|
36
|
-
const dryRun = Boolean(context.flags["dry-run"])
|
|
37
|
-
const skipFrontend = Boolean(context.flags["skip-frontend"])
|
|
38
|
-
const skipRuntime = Boolean(context.flags["skip-runtime"])
|
|
39
|
-
const noOpen = Boolean(context.flags["no-open"])
|
|
1
|
+
import { prepareFrameworkRuntime } from "../lib/framework.js"
|
|
2
|
+
import { prepareAppBackend } from "../lib/backend.js"
|
|
3
|
+
import {
|
|
4
|
+
registerChildCleanup,
|
|
5
|
+
resolvePackageManagerCommand,
|
|
6
|
+
spawnCommand,
|
|
7
|
+
waitForProcessExit,
|
|
8
|
+
waitForUrl
|
|
9
|
+
} from "../lib/process.js"
|
|
10
|
+
import {
|
|
11
|
+
assertAppProject,
|
|
12
|
+
assertFrameworkInstall,
|
|
13
|
+
loadResetConfig,
|
|
14
|
+
resolveAppPaths,
|
|
15
|
+
resolveAppPackageManager,
|
|
16
|
+
resolveConfigPath,
|
|
17
|
+
resolveDevServerOptions,
|
|
18
|
+
resolveFrontendDir,
|
|
19
|
+
resolveFrameworkBuildPaths,
|
|
20
|
+
resolveFrameworkRuntimeBinary,
|
|
21
|
+
resolveFrameworkRuntimeStrategy,
|
|
22
|
+
resolveFrameworkPaths,
|
|
23
|
+
resolveOptionalBackendEntry
|
|
24
|
+
} from "../lib/project.js"
|
|
25
|
+
import {
|
|
26
|
+
createProgress,
|
|
27
|
+
printBanner,
|
|
28
|
+
printKeyValueTable,
|
|
29
|
+
printSection,
|
|
30
|
+
printStatusTable
|
|
31
|
+
} from "../lib/ui.js"
|
|
32
|
+
|
|
33
|
+
export const description = "Run the frontend dev server and native host"
|
|
34
|
+
|
|
35
|
+
export async function run(context) {
|
|
36
|
+
const dryRun = Boolean(context.flags["dry-run"])
|
|
37
|
+
const skipFrontend = Boolean(context.flags["skip-frontend"])
|
|
38
|
+
const skipRuntime = Boolean(context.flags["skip-runtime"])
|
|
39
|
+
const noOpen = Boolean(context.flags["no-open"])
|
|
40
40
|
const preferSource = Boolean(context.flags["runtime-source"])
|
|
41
41
|
|
|
42
42
|
const appPaths = resolveAppPaths(context.projectRoot)
|
|
43
|
-
const frameworkPaths = resolveFrameworkPaths()
|
|
43
|
+
const frameworkPaths = resolveFrameworkPaths({ appRoot: context.projectRoot })
|
|
44
44
|
assertAppProject(appPaths)
|
|
45
45
|
assertFrameworkInstall(frameworkPaths)
|
|
46
|
-
const config = loadResetConfig(appPaths)
|
|
47
|
-
assertAppProject(appPaths, config)
|
|
48
|
-
const packageManager = resolveAppPackageManager(appPaths, config)
|
|
49
|
-
const devServer = resolveDevServerOptions(config)
|
|
50
|
-
const configPath = resolveConfigPath(appPaths)
|
|
51
|
-
const frontendDir = resolveFrontendDir(appPaths, config)
|
|
52
|
-
const backendEntry = resolveOptionalBackendEntry(appPaths)
|
|
53
|
-
const frameworkBuildPaths = resolveFrameworkBuildPaths(appPaths)
|
|
54
|
-
const runtimeStrategy = resolveFrameworkRuntimeStrategy(frameworkPaths, { preferSource })
|
|
55
|
-
const steps = [
|
|
56
|
-
!skipRuntime ? "Prepare runtime" : null,
|
|
57
|
-
backendEntry ? "Bundle backend sidecar" : null,
|
|
58
|
-
!skipFrontend ? "Start frontend dev server" : null,
|
|
59
|
-
!noOpen ? "Launch desktop window" : null
|
|
60
|
-
].filter(Boolean)
|
|
61
|
-
|
|
62
|
-
printBanner("reset-framework-cli dev", description)
|
|
63
|
-
printSection("Project")
|
|
64
|
-
printKeyValueTable([
|
|
65
|
-
["Config", configPath],
|
|
66
|
-
["Frontend", frontendDir],
|
|
67
|
-
["Backend", backendEntry ?? "not configured"],
|
|
68
|
-
["Package manager", packageManager],
|
|
69
|
-
["Dev URL", config.frontend.devUrl],
|
|
70
|
-
["Runtime", `${runtimeStrategy.kind === "prebuilt" ? "bundled" : "source"} (${runtimeStrategy.label})`]
|
|
71
|
-
])
|
|
72
|
-
console.log("")
|
|
73
|
-
|
|
74
|
-
printSection("Plan")
|
|
75
|
-
printStatusTable([
|
|
76
|
-
[
|
|
77
|
-
skipRuntime ? "skip" : "ready",
|
|
78
|
-
"Runtime",
|
|
79
|
-
skipRuntime
|
|
80
|
-
? (runtimeStrategy.kind === "prebuilt" ? "Reuse the bundled runtime package" : "Reuse the existing source runtime build")
|
|
81
|
-
: (runtimeStrategy.kind === "prebuilt" ? "Use the bundled runtime package" : "Configure and build the runtime from source")
|
|
82
|
-
],
|
|
83
|
-
[backendEntry ? "ready" : "skip", "Backend", backendEntry ? "Bundle the optional TypeScript sidecar backend" : "No backend entry was found under backend/"],
|
|
84
|
-
[skipFrontend ? "skip" : "ready", "Frontend", skipFrontend ? "Expecting an already running dev server" : "Start the frontend dev server and wait for readiness"],
|
|
85
|
-
[noOpen ? "skip" : "ready", "Window", noOpen ? "Do not launch the desktop window" : "Start the native host with the active project config"]
|
|
86
|
-
])
|
|
87
|
-
|
|
88
|
-
if (dryRun) {
|
|
89
|
-
console.log("")
|
|
90
|
-
printSection("Dry run")
|
|
91
|
-
printStatusTable(
|
|
92
|
-
steps.length > 0
|
|
93
|
-
? steps.map((step) => ["plan", step, "No processes will be started"])
|
|
94
|
-
: [["warn", "Nothing to do", "All dev phases were skipped"]]
|
|
95
|
-
)
|
|
96
|
-
return
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (steps.length === 0) {
|
|
100
|
-
console.log("")
|
|
101
|
-
printSection("Result")
|
|
102
|
-
printStatusTable([["warn", "Nothing to do", "All dev phases were skipped"]])
|
|
103
|
-
return
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
console.log("")
|
|
107
|
-
const progress = createProgress(steps.length, "Dev")
|
|
108
|
-
|
|
109
|
-
if (!skipRuntime) {
|
|
110
|
-
const preparedRuntime = await prepareFrameworkRuntime(frameworkPaths, frameworkBuildPaths, "dev", {
|
|
111
|
-
cwd: appPaths.appRoot,
|
|
112
|
-
dryRun,
|
|
113
|
-
preferSource
|
|
114
|
-
})
|
|
115
|
-
progress.tick(preparedRuntime.kind === "prebuilt" ? "Bundled runtime ready" : "Native runtime built")
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const children = []
|
|
119
|
-
let backendArtifact = null
|
|
120
|
-
|
|
121
|
-
if (backendEntry) {
|
|
122
|
-
backendArtifact = await prepareAppBackend(frameworkPaths, appPaths, "dev")
|
|
123
|
-
progress.tick("Backend sidecar bundled")
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (!skipFrontend) {
|
|
127
|
-
const frontendProcess = spawnCommand(resolvePackageManagerCommand(packageManager), [
|
|
128
|
-
"run",
|
|
129
|
-
"dev",
|
|
130
|
-
"--",
|
|
131
|
-
"--host",
|
|
132
|
-
devServer.host,
|
|
133
|
-
"--port",
|
|
134
|
-
devServer.port,
|
|
135
|
-
"--strictPort"
|
|
136
|
-
], {
|
|
137
|
-
cwd: frontendDir,
|
|
138
|
-
dryRun
|
|
139
|
-
})
|
|
140
|
-
|
|
141
|
-
if (frontendProcess) {
|
|
142
|
-
children.push(frontendProcess)
|
|
143
|
-
await waitForUrl(config.frontend.devUrl)
|
|
144
|
-
progress.tick("Frontend dev server is reachable")
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (!noOpen) {
|
|
149
|
-
const appBinary = resolveFrameworkRuntimeBinary(frameworkPaths, frameworkBuildPaths, "dev", {
|
|
150
|
-
mustExist: !dryRun,
|
|
151
|
-
strategy: runtimeStrategy
|
|
152
|
-
})
|
|
153
|
-
const appProcess = spawnCommand(appBinary, [], {
|
|
154
|
-
cwd: appPaths.appRoot,
|
|
155
|
-
env: {
|
|
156
|
-
RESET_CONFIG_PATH: configPath,
|
|
157
|
-
RESET_FRONTEND_DEV_URL: config.frontend.devUrl,
|
|
158
|
-
...(backendArtifact
|
|
159
|
-
? {
|
|
160
|
-
RESET_BACKEND_EXECUTABLE: backendArtifact.runtimeExecutablePath,
|
|
161
|
-
RESET_BACKEND_RUNNER: backendArtifact.runnerPath,
|
|
162
|
-
RESET_BACKEND_ENTRY: backendArtifact.bundleEntryPath,
|
|
163
|
-
RESET_BACKEND_WORKING_DIRECTORY: backendArtifact.workingDirectory
|
|
164
|
-
}
|
|
165
|
-
: {})
|
|
166
|
-
},
|
|
167
|
-
dryRun
|
|
168
|
-
})
|
|
169
|
-
|
|
170
|
-
if (appProcess) {
|
|
171
|
-
children.push(appProcess)
|
|
172
|
-
progress.tick("Desktop window launched")
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if (children.length === 0) {
|
|
177
|
-
return
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
console.log("")
|
|
181
|
-
printSection("Runtime")
|
|
182
|
-
printStatusTable([
|
|
183
|
-
["done", "Frontend", config.frontend.devUrl],
|
|
184
|
-
["done", "Config", configPath],
|
|
185
|
-
["done", "Backend", backendArtifact ? backendArtifact.bundleEntryPath : "disabled"]
|
|
186
|
-
])
|
|
187
|
-
console.log(" Press Ctrl+C to stop")
|
|
188
|
-
|
|
189
|
-
const cleanup = registerChildCleanup(children)
|
|
190
|
-
|
|
191
|
-
try {
|
|
192
|
-
await Promise.race([
|
|
193
|
-
...children.map((child, index) =>
|
|
194
|
-
waitForProcessExit(child, index === 0 ? "dev process" : "native host")
|
|
195
|
-
)
|
|
196
|
-
])
|
|
197
|
-
} finally {
|
|
198
|
-
await cleanup()
|
|
199
|
-
}
|
|
200
|
-
}
|
|
46
|
+
const config = loadResetConfig(appPaths)
|
|
47
|
+
assertAppProject(appPaths, config)
|
|
48
|
+
const packageManager = resolveAppPackageManager(appPaths, config)
|
|
49
|
+
const devServer = resolveDevServerOptions(config)
|
|
50
|
+
const configPath = resolveConfigPath(appPaths)
|
|
51
|
+
const frontendDir = resolveFrontendDir(appPaths, config)
|
|
52
|
+
const backendEntry = resolveOptionalBackendEntry(appPaths)
|
|
53
|
+
const frameworkBuildPaths = resolveFrameworkBuildPaths(appPaths)
|
|
54
|
+
const runtimeStrategy = resolveFrameworkRuntimeStrategy(frameworkPaths, { preferSource })
|
|
55
|
+
const steps = [
|
|
56
|
+
!skipRuntime ? "Prepare runtime" : null,
|
|
57
|
+
backendEntry ? "Bundle backend sidecar" : null,
|
|
58
|
+
!skipFrontend ? "Start frontend dev server" : null,
|
|
59
|
+
!noOpen ? "Launch desktop window" : null
|
|
60
|
+
].filter(Boolean)
|
|
61
|
+
|
|
62
|
+
printBanner("reset-framework-cli dev", description)
|
|
63
|
+
printSection("Project")
|
|
64
|
+
printKeyValueTable([
|
|
65
|
+
["Config", configPath],
|
|
66
|
+
["Frontend", frontendDir],
|
|
67
|
+
["Backend", backendEntry ?? "not configured"],
|
|
68
|
+
["Package manager", packageManager],
|
|
69
|
+
["Dev URL", config.frontend.devUrl],
|
|
70
|
+
["Runtime", `${runtimeStrategy.kind === "prebuilt" ? "bundled" : "source"} (${runtimeStrategy.label})`]
|
|
71
|
+
])
|
|
72
|
+
console.log("")
|
|
73
|
+
|
|
74
|
+
printSection("Plan")
|
|
75
|
+
printStatusTable([
|
|
76
|
+
[
|
|
77
|
+
skipRuntime ? "skip" : "ready",
|
|
78
|
+
"Runtime",
|
|
79
|
+
skipRuntime
|
|
80
|
+
? (runtimeStrategy.kind === "prebuilt" ? "Reuse the bundled runtime package" : "Reuse the existing source runtime build")
|
|
81
|
+
: (runtimeStrategy.kind === "prebuilt" ? "Use the bundled runtime package" : "Configure and build the runtime from source")
|
|
82
|
+
],
|
|
83
|
+
[backendEntry ? "ready" : "skip", "Backend", backendEntry ? "Bundle the optional TypeScript sidecar backend" : "No backend entry was found under backend/"],
|
|
84
|
+
[skipFrontend ? "skip" : "ready", "Frontend", skipFrontend ? "Expecting an already running dev server" : "Start the frontend dev server and wait for readiness"],
|
|
85
|
+
[noOpen ? "skip" : "ready", "Window", noOpen ? "Do not launch the desktop window" : "Start the native host with the active project config"]
|
|
86
|
+
])
|
|
87
|
+
|
|
88
|
+
if (dryRun) {
|
|
89
|
+
console.log("")
|
|
90
|
+
printSection("Dry run")
|
|
91
|
+
printStatusTable(
|
|
92
|
+
steps.length > 0
|
|
93
|
+
? steps.map((step) => ["plan", step, "No processes will be started"])
|
|
94
|
+
: [["warn", "Nothing to do", "All dev phases were skipped"]]
|
|
95
|
+
)
|
|
96
|
+
return
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (steps.length === 0) {
|
|
100
|
+
console.log("")
|
|
101
|
+
printSection("Result")
|
|
102
|
+
printStatusTable([["warn", "Nothing to do", "All dev phases were skipped"]])
|
|
103
|
+
return
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
console.log("")
|
|
107
|
+
const progress = createProgress(steps.length, "Dev")
|
|
108
|
+
|
|
109
|
+
if (!skipRuntime) {
|
|
110
|
+
const preparedRuntime = await prepareFrameworkRuntime(frameworkPaths, frameworkBuildPaths, "dev", {
|
|
111
|
+
cwd: appPaths.appRoot,
|
|
112
|
+
dryRun,
|
|
113
|
+
preferSource
|
|
114
|
+
})
|
|
115
|
+
progress.tick(preparedRuntime.kind === "prebuilt" ? "Bundled runtime ready" : "Native runtime built")
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const children = []
|
|
119
|
+
let backendArtifact = null
|
|
120
|
+
|
|
121
|
+
if (backendEntry) {
|
|
122
|
+
backendArtifact = await prepareAppBackend(frameworkPaths, appPaths, "dev")
|
|
123
|
+
progress.tick("Backend sidecar bundled")
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (!skipFrontend) {
|
|
127
|
+
const frontendProcess = spawnCommand(resolvePackageManagerCommand(packageManager), [
|
|
128
|
+
"run",
|
|
129
|
+
"dev",
|
|
130
|
+
"--",
|
|
131
|
+
"--host",
|
|
132
|
+
devServer.host,
|
|
133
|
+
"--port",
|
|
134
|
+
devServer.port,
|
|
135
|
+
"--strictPort"
|
|
136
|
+
], {
|
|
137
|
+
cwd: frontendDir,
|
|
138
|
+
dryRun
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
if (frontendProcess) {
|
|
142
|
+
children.push(frontendProcess)
|
|
143
|
+
await waitForUrl(config.frontend.devUrl)
|
|
144
|
+
progress.tick("Frontend dev server is reachable")
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (!noOpen) {
|
|
149
|
+
const appBinary = resolveFrameworkRuntimeBinary(frameworkPaths, frameworkBuildPaths, "dev", {
|
|
150
|
+
mustExist: !dryRun,
|
|
151
|
+
strategy: runtimeStrategy
|
|
152
|
+
})
|
|
153
|
+
const appProcess = spawnCommand(appBinary, [], {
|
|
154
|
+
cwd: appPaths.appRoot,
|
|
155
|
+
env: {
|
|
156
|
+
RESET_CONFIG_PATH: configPath,
|
|
157
|
+
RESET_FRONTEND_DEV_URL: config.frontend.devUrl,
|
|
158
|
+
...(backendArtifact
|
|
159
|
+
? {
|
|
160
|
+
RESET_BACKEND_EXECUTABLE: backendArtifact.runtimeExecutablePath,
|
|
161
|
+
RESET_BACKEND_RUNNER: backendArtifact.runnerPath,
|
|
162
|
+
RESET_BACKEND_ENTRY: backendArtifact.bundleEntryPath,
|
|
163
|
+
RESET_BACKEND_WORKING_DIRECTORY: backendArtifact.workingDirectory
|
|
164
|
+
}
|
|
165
|
+
: {})
|
|
166
|
+
},
|
|
167
|
+
dryRun
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
if (appProcess) {
|
|
171
|
+
children.push(appProcess)
|
|
172
|
+
progress.tick("Desktop window launched")
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (children.length === 0) {
|
|
177
|
+
return
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
console.log("")
|
|
181
|
+
printSection("Runtime")
|
|
182
|
+
printStatusTable([
|
|
183
|
+
["done", "Frontend", config.frontend.devUrl],
|
|
184
|
+
["done", "Config", configPath],
|
|
185
|
+
["done", "Backend", backendArtifact ? backendArtifact.bundleEntryPath : "disabled"]
|
|
186
|
+
])
|
|
187
|
+
console.log(" Press Ctrl+C to stop")
|
|
188
|
+
|
|
189
|
+
const cleanup = registerChildCleanup(children)
|
|
190
|
+
|
|
191
|
+
try {
|
|
192
|
+
await Promise.race([
|
|
193
|
+
...children.map((child, index) =>
|
|
194
|
+
waitForProcessExit(child, index === 0 ? "dev process" : "native host")
|
|
195
|
+
)
|
|
196
|
+
])
|
|
197
|
+
} finally {
|
|
198
|
+
await cleanup()
|
|
199
|
+
}
|
|
200
|
+
}
|