reset-framework-cli 1.1.2 → 1.1.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.
Files changed (34) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +47 -47
  3. package/package.json +4 -4
  4. package/src/commands/build.js +114 -113
  5. package/src/commands/dev.js +157 -153
  6. package/src/commands/doctor.js +89 -89
  7. package/src/commands/init.js +925 -920
  8. package/src/commands/package.js +49 -44
  9. package/src/index.js +213 -213
  10. package/src/lib/context.js +66 -66
  11. package/src/lib/framework.js +150 -28
  12. package/src/lib/logger.js +11 -11
  13. package/src/lib/output.js +214 -106
  14. package/src/lib/process.js +188 -181
  15. package/src/lib/project.js +559 -475
  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 -138
  25. package/templates/basic/frontend/src/App.tsx +77 -76
  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,163 +1,167 @@
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 { 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,
15
15
  resolveConfigPath,
16
16
  resolveDevServerOptions,
17
17
  resolveFrontendDir,
18
18
  resolveFrameworkBuildPaths,
19
+ resolveFrameworkRuntimeBinary,
19
20
  resolveFrameworkPaths
20
21
  } from "../lib/project.js"
21
- import {
22
- createProgress,
23
- printBanner,
24
- printKeyValueTable,
25
- printSection,
26
- printStatusTable
27
- } from "../lib/ui.js"
28
-
29
- export const description = "Run the frontend dev server and native host"
30
-
31
- export async function run(context) {
32
- const dryRun = Boolean(context.flags["dry-run"])
33
- const skipFrontend = Boolean(context.flags["skip-frontend"])
34
- const skipRuntime = Boolean(context.flags["skip-runtime"])
35
- const noOpen = Boolean(context.flags["no-open"])
36
-
37
- const appPaths = resolveAppPaths(context.projectRoot)
38
- const frameworkPaths = resolveFrameworkPaths()
39
- assertAppProject(appPaths)
40
- assertFrameworkInstall(frameworkPaths)
41
- const config = loadResetConfig(appPaths)
42
- assertAppProject(appPaths, config)
43
- const packageManager = resolveAppPackageManager(appPaths, config)
44
- const devServer = resolveDevServerOptions(config)
45
- const configPath = resolveConfigPath(appPaths)
46
- const frontendDir = resolveFrontendDir(appPaths, config)
47
- const frameworkBuildPaths = resolveFrameworkBuildPaths(appPaths)
48
- const steps = [
49
- !skipRuntime ? "Build native runtime" : null,
50
- !skipFrontend ? "Start frontend dev server" : null,
51
- !noOpen ? "Launch desktop window" : null
52
- ].filter(Boolean)
53
-
54
- printBanner("reset-framework-cli dev", description)
55
- printSection("Project")
56
- printKeyValueTable([
57
- ["Config", configPath],
58
- ["Frontend", frontendDir],
59
- ["Package manager", packageManager],
60
- ["Dev URL", config.frontend.devUrl]
61
- ])
62
- console.log("")
63
-
64
- printSection("Plan")
65
- printStatusTable([
66
- [skipRuntime ? "skip" : "ready", "Runtime", skipRuntime ? "Reusing existing native dev build" : "Configure and build the native runtime"],
67
- [skipFrontend ? "skip" : "ready", "Frontend", skipFrontend ? "Expecting an already running dev server" : "Start the frontend dev server and wait for readiness"],
68
- [noOpen ? "skip" : "ready", "Window", noOpen ? "Do not launch the desktop window" : "Start the native host with the active project config"]
69
- ])
70
-
71
- if (dryRun) {
72
- console.log("")
73
- printSection("Dry run")
74
- printStatusTable(
75
- steps.length > 0
76
- ? steps.map((step) => ["plan", step, "No processes will be started"])
77
- : [["warn", "Nothing to do", "All dev phases were skipped"]]
78
- )
79
- return
80
- }
81
-
82
- if (steps.length === 0) {
83
- console.log("")
84
- printSection("Result")
85
- printStatusTable([["warn", "Nothing to do", "All dev phases were skipped"]])
86
- return
87
- }
88
-
89
- console.log("")
90
- const progress = createProgress(steps.length, "Dev")
91
-
92
- if (!skipRuntime) {
93
- await buildFrameworkRuntime(frameworkPaths, frameworkBuildPaths, "dev", {
94
- cwd: appPaths.appRoot,
95
- dryRun
96
- })
97
- progress.tick("Native runtime built")
98
- }
99
-
100
- const children = []
101
-
102
- if (!skipFrontend) {
103
- const frontendProcess = spawnCommand(resolvePackageManagerCommand(packageManager), [
104
- "run",
105
- "dev",
106
- "--",
107
- "--host",
108
- devServer.host,
109
- "--port",
110
- devServer.port,
111
- "--strictPort"
112
- ], {
113
- cwd: frontendDir,
114
- dryRun
115
- })
116
-
117
- if (frontendProcess) {
118
- children.push(frontendProcess)
119
- await waitForUrl(config.frontend.devUrl)
120
- progress.tick("Frontend dev server is reachable")
121
- }
122
- }
123
-
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
+
124
125
  if (!noOpen) {
125
- const appProcess = spawnCommand(frameworkBuildPaths.devAppBinary, [], {
126
+ const appBinary = resolveFrameworkRuntimeBinary(frameworkBuildPaths, "dev", {
127
+ mustExist: !dryRun
128
+ })
129
+ const appProcess = spawnCommand(appBinary, [], {
126
130
  cwd: appPaths.appRoot,
127
131
  env: {
128
132
  RESET_CONFIG_PATH: configPath,
129
- RESET_FRONTEND_DEV_URL: config.frontend.devUrl
130
- },
131
- dryRun
132
- })
133
-
134
- if (appProcess) {
135
- children.push(appProcess)
136
- progress.tick("Desktop window launched")
137
- }
138
- }
139
-
140
- if (children.length === 0) {
141
- return
142
- }
143
-
144
- console.log("")
145
- printSection("Runtime")
146
- printStatusTable([
147
- ["done", "Frontend", config.frontend.devUrl],
148
- ["done", "Config", configPath]
149
- ])
150
- console.log(" Press Ctrl+C to stop")
151
-
152
- const cleanup = registerChildCleanup(children)
153
-
154
- try {
155
- await Promise.race([
156
- ...children.map((child, index) =>
157
- waitForProcessExit(child, index === 0 ? "dev process" : "native host")
158
- )
159
- ])
160
- } finally {
161
- cleanup()
162
- }
163
- }
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
+
158
+ try {
159
+ await Promise.race([
160
+ ...children.map((child, index) =>
161
+ waitForProcessExit(child, index === 0 ? "dev process" : "native host")
162
+ )
163
+ ])
164
+ } finally {
165
+ cleanup()
166
+ }
167
+ }
@@ -1,89 +1,89 @@
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
+ 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
+ }