reset-framework-cli 1.1.5 → 1.2.1

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 (34) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +57 -47
  3. package/package.json +8 -4
  4. package/src/commands/build.js +125 -113
  5. package/src/commands/dev.js +156 -144
  6. package/src/commands/doctor.js +137 -89
  7. package/src/commands/init.js +822 -822
  8. package/src/commands/package.js +41 -41
  9. package/src/index.js +215 -213
  10. package/src/lib/context.js +66 -66
  11. package/src/lib/framework.js +126 -39
  12. package/src/lib/logger.js +11 -11
  13. package/src/lib/output.js +147 -147
  14. package/src/lib/process.js +148 -148
  15. package/src/lib/project.js +759 -468
  16. package/src/lib/toolchain.js +62 -62
  17. package/src/lib/ui.js +244 -244
  18. package/templates/basic/README.md +15 -15
  19. package/templates/basic/frontend/README.md +73 -73
  20. package/templates/basic/frontend/eslint.config.js +23 -23
  21. package/templates/basic/frontend/index.html +13 -13
  22. package/templates/basic/frontend/package.json +31 -31
  23. package/templates/basic/frontend/public/icons.svg +24 -24
  24. package/templates/basic/frontend/src/App.css +216 -216
  25. package/templates/basic/frontend/src/App.tsx +77 -77
  26. package/templates/basic/frontend/src/assets/vite.svg +1 -1
  27. package/templates/basic/frontend/src/index.css +111 -111
  28. package/templates/basic/frontend/src/lib/reset.ts +1 -1
  29. package/templates/basic/frontend/src/main.tsx +10 -10
  30. package/templates/basic/frontend/tsconfig.app.json +28 -28
  31. package/templates/basic/frontend/tsconfig.json +7 -7
  32. package/templates/basic/frontend/tsconfig.node.json +26 -26
  33. package/templates/basic/frontend/vite.config.ts +16 -16
  34. package/templates/basic/reset.config.json +58 -58
@@ -1,160 +1,172 @@
1
- import { buildFrameworkRuntime } from "../lib/framework.js"
2
- import {
3
- registerChildCleanup,
4
- resolvePackageManagerCommand,
5
- spawnCommand,
6
- waitForProcessExit,
7
- waitForUrl
8
- } from "../lib/process.js"
9
- import {
10
- assertAppProject,
11
- assertFrameworkInstall,
12
- loadResetConfig,
13
- resolveAppPaths,
14
- resolveAppPackageManager,
1
+ import { prepareFrameworkRuntime } from "../lib/framework.js"
2
+ import {
3
+ registerChildCleanup,
4
+ resolvePackageManagerCommand,
5
+ spawnCommand,
6
+ waitForProcessExit,
7
+ waitForUrl
8
+ } from "../lib/process.js"
9
+ import {
10
+ assertAppProject,
11
+ assertFrameworkInstall,
12
+ loadResetConfig,
13
+ resolveAppPaths,
14
+ resolveAppPackageManager,
15
15
  resolveConfigPath,
16
16
  resolveDevServerOptions,
17
17
  resolveFrontendDir,
18
18
  resolveFrameworkBuildPaths,
19
19
  resolveFrameworkRuntimeBinary,
20
+ resolveFrameworkRuntimeStrategy,
20
21
  resolveFrameworkPaths
21
22
  } from "../lib/project.js"
22
- import {
23
- createProgress,
24
- printBanner,
25
- printKeyValueTable,
26
- printSection,
27
- printStatusTable
28
- } from "../lib/ui.js"
29
-
30
- export const description = "Run the frontend dev server and native host"
31
-
32
- export async function run(context) {
33
- const dryRun = Boolean(context.flags["dry-run"])
34
- const skipFrontend = Boolean(context.flags["skip-frontend"])
35
- const skipRuntime = Boolean(context.flags["skip-runtime"])
36
- const noOpen = Boolean(context.flags["no-open"])
37
-
38
- const appPaths = resolveAppPaths(context.projectRoot)
39
- const frameworkPaths = resolveFrameworkPaths()
40
- assertAppProject(appPaths)
41
- assertFrameworkInstall(frameworkPaths)
42
- const config = loadResetConfig(appPaths)
43
- assertAppProject(appPaths, config)
44
- const packageManager = resolveAppPackageManager(appPaths, config)
45
- const devServer = resolveDevServerOptions(config)
46
- const configPath = resolveConfigPath(appPaths)
47
- const frontendDir = resolveFrontendDir(appPaths, config)
48
- const frameworkBuildPaths = resolveFrameworkBuildPaths(appPaths)
49
- const steps = [
50
- !skipRuntime ? "Build native runtime" : null,
51
- !skipFrontend ? "Start frontend dev server" : null,
52
- !noOpen ? "Launch desktop window" : null
53
- ].filter(Boolean)
54
-
55
- printBanner("reset-framework-cli dev", description)
56
- printSection("Project")
57
- printKeyValueTable([
58
- ["Config", configPath],
59
- ["Frontend", frontendDir],
60
- ["Package manager", packageManager],
61
- ["Dev URL", config.frontend.devUrl]
62
- ])
63
- console.log("")
64
-
65
- printSection("Plan")
66
- printStatusTable([
67
- [skipRuntime ? "skip" : "ready", "Runtime", skipRuntime ? "Reusing existing native dev build" : "Configure and build the native runtime"],
68
- [skipFrontend ? "skip" : "ready", "Frontend", skipFrontend ? "Expecting an already running dev server" : "Start the frontend dev server and wait for readiness"],
69
- [noOpen ? "skip" : "ready", "Window", noOpen ? "Do not launch the desktop window" : "Start the native host with the active project config"]
70
- ])
71
-
72
- if (dryRun) {
73
- console.log("")
74
- printSection("Dry run")
75
- printStatusTable(
76
- steps.length > 0
77
- ? steps.map((step) => ["plan", step, "No processes will be started"])
78
- : [["warn", "Nothing to do", "All dev phases were skipped"]]
79
- )
80
- return
81
- }
82
-
83
- if (steps.length === 0) {
84
- console.log("")
85
- printSection("Result")
86
- printStatusTable([["warn", "Nothing to do", "All dev phases were skipped"]])
87
- return
88
- }
89
-
90
- console.log("")
91
- const progress = createProgress(steps.length, "Dev")
92
-
93
- if (!skipRuntime) {
94
- await buildFrameworkRuntime(frameworkPaths, frameworkBuildPaths, "dev", {
95
- cwd: appPaths.appRoot,
96
- dryRun
97
- })
98
- progress.tick("Native runtime built")
99
- }
100
-
101
- const children = []
102
-
103
- if (!skipFrontend) {
104
- const frontendProcess = spawnCommand(resolvePackageManagerCommand(packageManager), [
105
- "run",
106
- "dev",
107
- "--",
108
- "--host",
109
- devServer.host,
110
- "--port",
111
- devServer.port,
112
- "--strictPort"
113
- ], {
114
- cwd: frontendDir,
115
- dryRun
116
- })
117
-
118
- if (frontendProcess) {
119
- children.push(frontendProcess)
120
- await waitForUrl(config.frontend.devUrl)
121
- progress.tick("Frontend dev server is reachable")
122
- }
123
- }
124
-
23
+ import {
24
+ createProgress,
25
+ printBanner,
26
+ printKeyValueTable,
27
+ printSection,
28
+ printStatusTable
29
+ } from "../lib/ui.js"
30
+
31
+ export const description = "Run the frontend dev server and native host"
32
+
33
+ export async function run(context) {
34
+ const dryRun = Boolean(context.flags["dry-run"])
35
+ const skipFrontend = Boolean(context.flags["skip-frontend"])
36
+ const skipRuntime = Boolean(context.flags["skip-runtime"])
37
+ const noOpen = Boolean(context.flags["no-open"])
38
+ const preferSource = Boolean(context.flags["runtime-source"])
39
+
40
+ const appPaths = resolveAppPaths(context.projectRoot)
41
+ const frameworkPaths = resolveFrameworkPaths()
42
+ assertAppProject(appPaths)
43
+ assertFrameworkInstall(frameworkPaths)
44
+ const config = loadResetConfig(appPaths)
45
+ assertAppProject(appPaths, config)
46
+ const packageManager = resolveAppPackageManager(appPaths, config)
47
+ const devServer = resolveDevServerOptions(config)
48
+ const configPath = resolveConfigPath(appPaths)
49
+ const frontendDir = resolveFrontendDir(appPaths, config)
50
+ const frameworkBuildPaths = resolveFrameworkBuildPaths(appPaths)
51
+ const runtimeStrategy = resolveFrameworkRuntimeStrategy(frameworkPaths, { preferSource })
52
+ const steps = [
53
+ !skipRuntime ? "Prepare runtime" : null,
54
+ !skipFrontend ? "Start frontend dev server" : null,
55
+ !noOpen ? "Launch desktop window" : null
56
+ ].filter(Boolean)
57
+
58
+ printBanner("reset-framework-cli dev", description)
59
+ printSection("Project")
60
+ printKeyValueTable([
61
+ ["Config", configPath],
62
+ ["Frontend", frontendDir],
63
+ ["Package manager", packageManager],
64
+ ["Dev URL", config.frontend.devUrl],
65
+ ["Runtime", `${runtimeStrategy.kind === "prebuilt" ? "bundled" : "source"} (${runtimeStrategy.label})`]
66
+ ])
67
+ console.log("")
68
+
69
+ printSection("Plan")
70
+ printStatusTable([
71
+ [
72
+ skipRuntime ? "skip" : "ready",
73
+ "Runtime",
74
+ skipRuntime
75
+ ? (runtimeStrategy.kind === "prebuilt" ? "Reuse the bundled runtime package" : "Reuse the existing source runtime build")
76
+ : (runtimeStrategy.kind === "prebuilt" ? "Use the bundled runtime package" : "Configure and build the runtime from source")
77
+ ],
78
+ [skipFrontend ? "skip" : "ready", "Frontend", skipFrontend ? "Expecting an already running dev server" : "Start the frontend dev server and wait for readiness"],
79
+ [noOpen ? "skip" : "ready", "Window", noOpen ? "Do not launch the desktop window" : "Start the native host with the active project config"]
80
+ ])
81
+
82
+ if (dryRun) {
83
+ console.log("")
84
+ printSection("Dry run")
85
+ printStatusTable(
86
+ steps.length > 0
87
+ ? steps.map((step) => ["plan", step, "No processes will be started"])
88
+ : [["warn", "Nothing to do", "All dev phases were skipped"]]
89
+ )
90
+ return
91
+ }
92
+
93
+ if (steps.length === 0) {
94
+ console.log("")
95
+ printSection("Result")
96
+ printStatusTable([["warn", "Nothing to do", "All dev phases were skipped"]])
97
+ return
98
+ }
99
+
100
+ console.log("")
101
+ const progress = createProgress(steps.length, "Dev")
102
+
103
+ if (!skipRuntime) {
104
+ const preparedRuntime = await prepareFrameworkRuntime(frameworkPaths, frameworkBuildPaths, "dev", {
105
+ cwd: appPaths.appRoot,
106
+ dryRun,
107
+ preferSource
108
+ })
109
+ progress.tick(preparedRuntime.kind === "prebuilt" ? "Bundled runtime ready" : "Native runtime built")
110
+ }
111
+
112
+ const children = []
113
+
114
+ if (!skipFrontend) {
115
+ const frontendProcess = spawnCommand(resolvePackageManagerCommand(packageManager), [
116
+ "run",
117
+ "dev",
118
+ "--",
119
+ "--host",
120
+ devServer.host,
121
+ "--port",
122
+ devServer.port,
123
+ "--strictPort"
124
+ ], {
125
+ cwd: frontendDir,
126
+ dryRun
127
+ })
128
+
129
+ if (frontendProcess) {
130
+ children.push(frontendProcess)
131
+ await waitForUrl(config.frontend.devUrl)
132
+ progress.tick("Frontend dev server is reachable")
133
+ }
134
+ }
135
+
125
136
  if (!noOpen) {
126
- const appBinary = resolveFrameworkRuntimeBinary(frameworkBuildPaths, "dev", {
127
- mustExist: !dryRun
137
+ const appBinary = resolveFrameworkRuntimeBinary(frameworkPaths, frameworkBuildPaths, "dev", {
138
+ mustExist: !dryRun,
139
+ strategy: runtimeStrategy
128
140
  })
129
141
  const appProcess = spawnCommand(appBinary, [], {
130
142
  cwd: appPaths.appRoot,
131
143
  env: {
132
144
  RESET_CONFIG_PATH: configPath,
133
- RESET_FRONTEND_DEV_URL: config.frontend.devUrl
134
- },
135
- dryRun
136
- })
137
-
138
- if (appProcess) {
139
- children.push(appProcess)
140
- progress.tick("Desktop window launched")
141
- }
142
- }
143
-
144
- if (children.length === 0) {
145
- return
146
- }
147
-
148
- console.log("")
149
- printSection("Runtime")
150
- printStatusTable([
151
- ["done", "Frontend", config.frontend.devUrl],
152
- ["done", "Config", configPath]
153
- ])
154
- console.log(" Press Ctrl+C to stop")
155
-
156
- const cleanup = registerChildCleanup(children)
157
-
145
+ RESET_FRONTEND_DEV_URL: config.frontend.devUrl
146
+ },
147
+ dryRun
148
+ })
149
+
150
+ if (appProcess) {
151
+ children.push(appProcess)
152
+ progress.tick("Desktop window launched")
153
+ }
154
+ }
155
+
156
+ if (children.length === 0) {
157
+ return
158
+ }
159
+
160
+ console.log("")
161
+ printSection("Runtime")
162
+ printStatusTable([
163
+ ["done", "Frontend", config.frontend.devUrl],
164
+ ["done", "Config", configPath]
165
+ ])
166
+ console.log(" Press Ctrl+C to stop")
167
+
168
+ const cleanup = registerChildCleanup(children)
169
+
158
170
  try {
159
171
  await Promise.race([
160
172
  ...children.map((child, index) =>
@@ -1,89 +1,137 @@
1
- import { existsSync } from "node:fs"
2
-
3
- import {
4
- getAppChecks,
5
- getFrameworkChecks,
6
- loadResetConfig,
7
- resolveFrontendDir,
8
- resolveAppPaths,
9
- resolveConfigPath,
10
- resolveFrameworkPaths
11
- } from "../lib/project.js"
12
- import { findVcpkgToolchainFile } from "../lib/toolchain.js"
13
- import {
14
- printBanner,
15
- printKeyValueTable,
16
- printSection,
17
- printStatusTable
18
- } from "../lib/ui.js"
19
-
20
- export const description = "Inspect the current project layout"
21
-
22
- export async function run(context) {
23
- const appPaths = resolveAppPaths(context.projectRoot)
24
- const frameworkPaths = resolveFrameworkPaths()
25
-
26
- let config = null
27
-
28
- if (existsSync(resolveConfigPath(appPaths))) {
29
- config = loadResetConfig(appPaths)
30
- }
31
-
32
- printBanner("reset-framework-cli doctor", description)
33
-
34
- printSection("App project")
35
-
36
- const appChecks = [...getAppChecks(appPaths)]
37
- if (config) {
38
- appChecks.unshift(["frontend", resolveFrontendDir(appPaths, config)])
39
- }
40
-
41
- printStatusTable(
42
- appChecks.map(([label, filePath]) => [
43
- existsSync(filePath) ? "ok" : "missing",
44
- label,
45
- filePath
46
- ])
47
- )
48
-
49
- console.log("")
50
- printSection("Framework installation")
51
-
52
- printStatusTable(
53
- getFrameworkChecks(frameworkPaths).map(([label, filePath]) => [
54
- existsSync(filePath) ? "ok" : "missing",
55
- label,
56
- filePath
57
- ])
58
- )
59
-
60
- console.log("")
61
- printSection("Framework packages")
62
- printKeyValueTable([
63
- ["Native", `${frameworkPaths.frameworkPackage.packageName}@${frameworkPaths.frameworkPackage.version}`],
64
- ["SDK", `${frameworkPaths.sdkPackage.packageName}@${frameworkPaths.sdkPackage.version}`],
65
- ["Schema", `${frameworkPaths.schemaPackage.packageName}@${frameworkPaths.schemaPackage.version}`]
66
- ])
67
-
68
- console.log("")
69
- printSection("Native toolchain")
70
- const vcpkgToolchainFile = findVcpkgToolchainFile()
71
- printStatusTable([
72
- [vcpkgToolchainFile ? "ok" : "warn", "Framework source", frameworkPaths.frameworkRoot],
73
- [vcpkgToolchainFile ? "ok" : "warn", "vcpkg toolchain", vcpkgToolchainFile ?? "Will be bootstrapped on first native build"]
74
- ])
75
-
76
- if (config) {
77
- console.log("")
78
- printSection("Config")
79
- printKeyValueTable([
80
- ["Name", config.name],
81
- ["Product", config.productName],
82
- ["App ID", config.appId],
83
- ["Frontend", config.project.frontendDir],
84
- ["Styling", config.project.styling],
85
- ["Dev URL", config.frontend.devUrl],
86
- ["Output", config.build.outputDir]
87
- ])
88
- }
89
- }
1
+ import { existsSync } from "node:fs"
2
+
3
+ import {
4
+ getAppChecks,
5
+ getFrameworkChecks,
6
+ getFrameworkRuntimeChecks,
7
+ getFrameworkRuntimeModeSummary,
8
+ hasFrameworkSourcePackage,
9
+ loadResetConfig,
10
+ resolveFrontendDir,
11
+ resolveAppPaths,
12
+ resolveConfigPath,
13
+ resolveFrameworkPaths
14
+ } from "../lib/project.js"
15
+ import { findVcpkgToolchainFile } from "../lib/toolchain.js"
16
+ import {
17
+ printBanner,
18
+ printKeyValueTable,
19
+ printSection,
20
+ printStatusTable
21
+ } from "../lib/ui.js"
22
+
23
+ export const description = "Inspect the current project layout"
24
+
25
+ export async function run(context) {
26
+ const appPaths = resolveAppPaths(context.projectRoot)
27
+ const frameworkPaths = resolveFrameworkPaths()
28
+ let runtimeMode = null
29
+ let runtimeModeError = null
30
+
31
+ let config = null
32
+
33
+ if (existsSync(resolveConfigPath(appPaths))) {
34
+ config = loadResetConfig(appPaths)
35
+ }
36
+
37
+ try {
38
+ runtimeMode = getFrameworkRuntimeModeSummary(frameworkPaths)
39
+ } catch (error) {
40
+ runtimeModeError = error instanceof Error ? error.message : String(error)
41
+ }
42
+
43
+ printBanner("reset-framework-cli doctor", description)
44
+
45
+ printSection("App project")
46
+
47
+ const appChecks = [...getAppChecks(appPaths)]
48
+ if (config) {
49
+ appChecks.unshift(["frontend", resolveFrontendDir(appPaths, config)])
50
+ }
51
+
52
+ printStatusTable(
53
+ appChecks.map(([label, filePath]) => [
54
+ existsSync(filePath) ? "ok" : "missing",
55
+ label,
56
+ filePath
57
+ ])
58
+ )
59
+
60
+ console.log("")
61
+ printSection("Framework installation")
62
+
63
+ printStatusTable(
64
+ getFrameworkChecks(frameworkPaths).map(([label, filePath]) => [
65
+ existsSync(filePath) ? "ok" : "missing",
66
+ label,
67
+ filePath
68
+ ])
69
+ )
70
+
71
+ console.log("")
72
+ printSection("Runtime installation")
73
+
74
+ const runtimeChecks = getFrameworkRuntimeChecks(frameworkPaths)
75
+ printStatusTable(
76
+ runtimeChecks.length > 0
77
+ ? runtimeChecks.map(([label, filePath]) => [
78
+ existsSync(filePath) ? "ok" : "missing",
79
+ label,
80
+ filePath
81
+ ])
82
+ : [["warn", "runtime", `No packaged runtime registered for ${process.platform}-${process.arch}`]]
83
+ )
84
+
85
+ console.log("")
86
+ printSection("Framework packages")
87
+ printKeyValueTable([
88
+ [
89
+ "Runtime",
90
+ frameworkPaths.runtimePackage?.packageInfo
91
+ ? `${frameworkPaths.runtimePackage.packageInfo.packageName}@${frameworkPaths.runtimePackage.packageInfo.version}`
92
+ : `Not installed for ${process.platform}-${process.arch}`
93
+ ],
94
+ [
95
+ "Native source",
96
+ frameworkPaths.frameworkPackage
97
+ ? `${frameworkPaths.frameworkPackage.packageName}@${frameworkPaths.frameworkPackage.version}`
98
+ : "Not installed"
99
+ ],
100
+ ["SDK", `${frameworkPaths.sdkPackage.packageName}@${frameworkPaths.sdkPackage.version}`],
101
+ ["Schema", `${frameworkPaths.schemaPackage.packageName}@${frameworkPaths.schemaPackage.version}`]
102
+ ])
103
+
104
+ console.log("")
105
+ printSection("Runtime mode")
106
+ printStatusTable([
107
+ [
108
+ runtimeMode ? "ok" : "warn",
109
+ "Runtime mode",
110
+ runtimeMode ? `${runtimeMode.kind} (${runtimeMode.label})` : runtimeModeError
111
+ ]
112
+ ])
113
+
114
+ if (hasFrameworkSourcePackage(frameworkPaths)) {
115
+ console.log("")
116
+ printSection("Native toolchain")
117
+ const vcpkgToolchainFile = findVcpkgToolchainFile()
118
+ printStatusTable([
119
+ ["ok", "Framework source", frameworkPaths.frameworkRoot],
120
+ [vcpkgToolchainFile ? "ok" : "warn", "vcpkg toolchain", vcpkgToolchainFile ?? "Will be bootstrapped on first source build"]
121
+ ])
122
+ }
123
+
124
+ if (config) {
125
+ console.log("")
126
+ printSection("Config")
127
+ printKeyValueTable([
128
+ ["Name", config.name],
129
+ ["Product", config.productName],
130
+ ["App ID", config.appId],
131
+ ["Frontend", config.project.frontendDir],
132
+ ["Styling", config.project.styling],
133
+ ["Dev URL", config.frontend.devUrl],
134
+ ["Output", config.build.outputDir]
135
+ ])
136
+ }
137
+ }