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.
- package/LICENSE +20 -20
- package/README.md +57 -47
- package/package.json +8 -4
- package/src/commands/build.js +125 -113
- package/src/commands/dev.js +156 -144
- package/src/commands/doctor.js +137 -89
- package/src/commands/init.js +822 -822
- package/src/commands/package.js +41 -41
- package/src/index.js +215 -213
- package/src/lib/context.js +66 -66
- package/src/lib/framework.js +126 -39
- package/src/lib/logger.js +11 -11
- package/src/lib/output.js +147 -147
- package/src/lib/process.js +148 -148
- package/src/lib/project.js +759 -468
- 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/lib/context.js
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import path from "node:path"
|
|
2
|
-
|
|
3
|
-
const shortFlagAliases = {
|
|
4
|
-
h: "help",
|
|
5
|
-
y: "yes"
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
function parseArgv(argv) {
|
|
9
|
-
const [command = "help", ...rest] = argv
|
|
10
|
-
const args = []
|
|
11
|
-
const flags = {}
|
|
12
|
-
|
|
13
|
-
for (let index = 0; index < rest.length; index += 1) {
|
|
14
|
-
const token = rest[index]
|
|
15
|
-
|
|
16
|
-
if (!token.startsWith("-")) {
|
|
17
|
-
args.push(token)
|
|
18
|
-
continue
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (token.startsWith("--")) {
|
|
22
|
-
const body = token.slice(2)
|
|
23
|
-
const separatorIndex = body.indexOf("=")
|
|
24
|
-
const key = separatorIndex === -1 ? body : body.slice(0, separatorIndex)
|
|
25
|
-
const inlineValue = separatorIndex === -1 ? undefined : body.slice(separatorIndex + 1)
|
|
26
|
-
const next = rest[index + 1]
|
|
27
|
-
|
|
28
|
-
if (inlineValue !== undefined) {
|
|
29
|
-
flags[key] = inlineValue
|
|
30
|
-
continue
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (!next || next.startsWith("-")) {
|
|
34
|
-
flags[key] = true
|
|
35
|
-
continue
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
flags[key] = next
|
|
39
|
-
index += 1
|
|
40
|
-
continue
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const shortFlags = token.slice(1).split("")
|
|
44
|
-
for (const flag of shortFlags) {
|
|
45
|
-
const alias = shortFlagAliases[flag]
|
|
46
|
-
if (!alias) {
|
|
47
|
-
flags[flag] = true
|
|
48
|
-
continue
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
flags[alias] = true
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return { command, args, flags }
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export function createCommandContext(argv, cwd = process.cwd()) {
|
|
59
|
-
const parsed = parseArgv(argv)
|
|
60
|
-
|
|
61
|
-
return {
|
|
62
|
-
...parsed,
|
|
63
|
-
cwd,
|
|
64
|
-
projectRoot: path.resolve(cwd)
|
|
65
|
-
}
|
|
66
|
-
}
|
|
1
|
+
import path from "node:path"
|
|
2
|
+
|
|
3
|
+
const shortFlagAliases = {
|
|
4
|
+
h: "help",
|
|
5
|
+
y: "yes"
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function parseArgv(argv) {
|
|
9
|
+
const [command = "help", ...rest] = argv
|
|
10
|
+
const args = []
|
|
11
|
+
const flags = {}
|
|
12
|
+
|
|
13
|
+
for (let index = 0; index < rest.length; index += 1) {
|
|
14
|
+
const token = rest[index]
|
|
15
|
+
|
|
16
|
+
if (!token.startsWith("-")) {
|
|
17
|
+
args.push(token)
|
|
18
|
+
continue
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (token.startsWith("--")) {
|
|
22
|
+
const body = token.slice(2)
|
|
23
|
+
const separatorIndex = body.indexOf("=")
|
|
24
|
+
const key = separatorIndex === -1 ? body : body.slice(0, separatorIndex)
|
|
25
|
+
const inlineValue = separatorIndex === -1 ? undefined : body.slice(separatorIndex + 1)
|
|
26
|
+
const next = rest[index + 1]
|
|
27
|
+
|
|
28
|
+
if (inlineValue !== undefined) {
|
|
29
|
+
flags[key] = inlineValue
|
|
30
|
+
continue
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (!next || next.startsWith("-")) {
|
|
34
|
+
flags[key] = true
|
|
35
|
+
continue
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
flags[key] = next
|
|
39
|
+
index += 1
|
|
40
|
+
continue
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const shortFlags = token.slice(1).split("")
|
|
44
|
+
for (const flag of shortFlags) {
|
|
45
|
+
const alias = shortFlagAliases[flag]
|
|
46
|
+
if (!alias) {
|
|
47
|
+
flags[flag] = true
|
|
48
|
+
continue
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
flags[alias] = true
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return { command, args, flags }
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function createCommandContext(argv, cwd = process.cwd()) {
|
|
59
|
+
const parsed = parseArgv(argv)
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
...parsed,
|
|
63
|
+
cwd,
|
|
64
|
+
projectRoot: path.resolve(cwd)
|
|
65
|
+
}
|
|
66
|
+
}
|
package/src/lib/framework.js
CHANGED
|
@@ -3,19 +3,25 @@ import { rm } from "node:fs/promises"
|
|
|
3
3
|
import { readFile } from "node:fs/promises"
|
|
4
4
|
import path from "node:path"
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { assertFrameworkSourceInstall, resolveFrameworkRuntimeStrategy } from "./project.js"
|
|
7
|
+
import { runCommand } from "./process.js"
|
|
7
8
|
import { ensureVcpkgToolchain } from "./toolchain.js"
|
|
8
|
-
|
|
9
|
-
function getBuildDirectory(frameworkBuildPaths, mode) {
|
|
10
|
-
return mode === "release"
|
|
11
|
-
? frameworkBuildPaths.releaseBuildDir
|
|
12
|
-
: frameworkBuildPaths.devBuildDir
|
|
13
|
-
}
|
|
14
|
-
|
|
9
|
+
|
|
10
|
+
function getBuildDirectory(frameworkBuildPaths, mode) {
|
|
11
|
+
return mode === "release"
|
|
12
|
+
? frameworkBuildPaths.releaseBuildDir
|
|
13
|
+
: frameworkBuildPaths.devBuildDir
|
|
14
|
+
}
|
|
15
|
+
|
|
15
16
|
function getBuildType(mode) {
|
|
16
17
|
return mode === "release" ? "Release" : "Debug"
|
|
17
18
|
}
|
|
18
19
|
|
|
20
|
+
function readCmakeCacheValue(cacheContents, key) {
|
|
21
|
+
const match = cacheContents.match(new RegExp(`^${key}:[^=]+=(.+)$`, "m"))
|
|
22
|
+
return match ? match[1].trim() : null
|
|
23
|
+
}
|
|
24
|
+
|
|
19
25
|
function getVsWherePath() {
|
|
20
26
|
const candidates = [
|
|
21
27
|
path.join(process.env["ProgramFiles(x86)"] ?? "", "Microsoft Visual Studio", "Installer", "vswhere.exe"),
|
|
@@ -25,36 +31,100 @@ function getVsWherePath() {
|
|
|
25
31
|
return candidates.find((candidate) => candidate && existsSync(candidate)) ?? null
|
|
26
32
|
}
|
|
27
33
|
|
|
34
|
+
function getVisualStudioInstanceCandidates() {
|
|
35
|
+
const roots = [
|
|
36
|
+
path.join(process.env.ProgramFiles ?? "", "Microsoft Visual Studio", "2022"),
|
|
37
|
+
path.join(process.env["ProgramFiles(x86)"] ?? "", "Microsoft Visual Studio", "2022"),
|
|
38
|
+
path.join(process.env.ProgramFiles ?? "", "Microsoft Visual Studio", "2019"),
|
|
39
|
+
path.join(process.env["ProgramFiles(x86)"] ?? "", "Microsoft Visual Studio", "2019")
|
|
40
|
+
]
|
|
41
|
+
const editions = ["BuildTools", "Community", "Professional", "Enterprise", "Preview"]
|
|
42
|
+
const candidates = []
|
|
43
|
+
|
|
44
|
+
for (const root of roots) {
|
|
45
|
+
if (!root || !existsSync(root)) {
|
|
46
|
+
continue
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
for (const edition of editions) {
|
|
50
|
+
const candidate = path.join(root, edition)
|
|
51
|
+
if (existsSync(candidate)) {
|
|
52
|
+
candidates.push(candidate)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return candidates
|
|
58
|
+
}
|
|
59
|
+
|
|
28
60
|
async function findVisualStudioGenerator() {
|
|
61
|
+
const instanceCandidates = getVisualStudioInstanceCandidates()
|
|
62
|
+
|
|
63
|
+
if (instanceCandidates.some((candidate) => candidate.includes(`${path.sep}2022${path.sep}`))) {
|
|
64
|
+
return {
|
|
65
|
+
generator: "Visual Studio 17 2022",
|
|
66
|
+
instance: instanceCandidates.find((candidate) => candidate.includes(`${path.sep}2022${path.sep}`))
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (instanceCandidates.some((candidate) => candidate.includes(`${path.sep}2019${path.sep}`))) {
|
|
71
|
+
return {
|
|
72
|
+
generator: "Visual Studio 16 2019",
|
|
73
|
+
instance: instanceCandidates.find((candidate) => candidate.includes(`${path.sep}2019${path.sep}`))
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
29
77
|
const vswherePath = getVsWherePath()
|
|
30
78
|
if (!vswherePath) {
|
|
31
79
|
return null
|
|
32
80
|
}
|
|
33
81
|
|
|
34
|
-
|
|
35
|
-
|
|
82
|
+
const { captureCommandOutput } = await import("./process.js")
|
|
83
|
+
const version = await captureCommandOutput(vswherePath, [
|
|
84
|
+
"-latest",
|
|
85
|
+
"-products",
|
|
86
|
+
"*",
|
|
87
|
+
"-requires",
|
|
88
|
+
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
|
|
89
|
+
"-property",
|
|
90
|
+
"catalog_productLineVersion"
|
|
91
|
+
]).catch(() => "")
|
|
92
|
+
|
|
93
|
+
if (version === "2022") {
|
|
94
|
+
const instance = await captureCommandOutput(vswherePath, [
|
|
36
95
|
"-latest",
|
|
37
96
|
"-products",
|
|
38
97
|
"*",
|
|
39
98
|
"-requires",
|
|
40
99
|
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
|
|
41
100
|
"-property",
|
|
42
|
-
"
|
|
43
|
-
])
|
|
101
|
+
"installationPath"
|
|
102
|
+
]).catch(() => "")
|
|
44
103
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
104
|
+
return {
|
|
105
|
+
generator: "Visual Studio 17 2022",
|
|
106
|
+
instance: instance || null
|
|
48
107
|
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (version === "2019") {
|
|
111
|
+
const instance = await captureCommandOutput(vswherePath, [
|
|
112
|
+
"-latest",
|
|
113
|
+
"-products",
|
|
114
|
+
"*",
|
|
115
|
+
"-requires",
|
|
116
|
+
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
|
|
117
|
+
"-property",
|
|
118
|
+
"installationPath"
|
|
119
|
+
]).catch(() => "")
|
|
49
120
|
|
|
50
|
-
|
|
51
|
-
|
|
121
|
+
return {
|
|
122
|
+
generator: "Visual Studio 16 2019",
|
|
123
|
+
instance: instance || null
|
|
52
124
|
}
|
|
53
|
-
} catch {
|
|
54
|
-
// Fall through to the default Windows generator if detection fails.
|
|
55
125
|
}
|
|
56
126
|
|
|
57
|
-
return
|
|
127
|
+
return null
|
|
58
128
|
}
|
|
59
129
|
|
|
60
130
|
async function resolveCmakeGenerator() {
|
|
@@ -79,18 +149,19 @@ async function resolveCmakeGenerator() {
|
|
|
79
149
|
}
|
|
80
150
|
|
|
81
151
|
if (process.platform === "win32") {
|
|
82
|
-
const
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
152
|
+
const visualStudio = await findVisualStudioGenerator()
|
|
153
|
+
if (visualStudio) {
|
|
154
|
+
const configureArgs = ["-G", visualStudio.generator, "-A", "x64"]
|
|
155
|
+
if (visualStudio.instance) {
|
|
156
|
+
configureArgs.push(`-DCMAKE_GENERATOR_INSTANCE=${visualStudio.instance}`)
|
|
157
|
+
}
|
|
88
158
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
159
|
+
return {
|
|
160
|
+
name: visualStudio.generator,
|
|
161
|
+
configureArgs,
|
|
162
|
+
buildArgs: ["--config"],
|
|
163
|
+
multiConfig: true
|
|
164
|
+
}
|
|
94
165
|
}
|
|
95
166
|
}
|
|
96
167
|
|
|
@@ -102,7 +173,7 @@ async function resolveCmakeGenerator() {
|
|
|
102
173
|
}
|
|
103
174
|
}
|
|
104
175
|
|
|
105
|
-
async function
|
|
176
|
+
async function ensureCompatibleCmakeBuild(buildDir, frameworkRoot, generatorName) {
|
|
106
177
|
const cachePath = path.join(buildDir, "CMakeCache.txt")
|
|
107
178
|
if (!existsSync(cachePath)) {
|
|
108
179
|
return
|
|
@@ -115,26 +186,31 @@ async function ensureMatchingCmakeSource(buildDir, frameworkRoot) {
|
|
|
115
186
|
return
|
|
116
187
|
}
|
|
117
188
|
|
|
118
|
-
const
|
|
119
|
-
|
|
189
|
+
const cachedRootValue = readCmakeCacheValue(cache, "CMAKE_HOME_DIRECTORY")
|
|
190
|
+
const cachedGenerator = readCmakeCacheValue(cache, "CMAKE_GENERATOR")
|
|
191
|
+
if (!cachedRootValue) {
|
|
120
192
|
return
|
|
121
193
|
}
|
|
122
194
|
|
|
123
|
-
const cachedRoot = path.resolve(
|
|
195
|
+
const cachedRoot = path.resolve(cachedRootValue)
|
|
124
196
|
const currentRoot = path.resolve(frameworkRoot)
|
|
197
|
+
const generatorChanged =
|
|
198
|
+
typeof cachedGenerator === "string" &&
|
|
199
|
+
cachedGenerator !== generatorName
|
|
125
200
|
|
|
126
|
-
if (cachedRoot !== currentRoot) {
|
|
201
|
+
if (cachedRoot !== currentRoot || generatorChanged) {
|
|
127
202
|
await rm(buildDir, { recursive: true, force: true })
|
|
128
203
|
}
|
|
129
204
|
}
|
|
130
205
|
|
|
131
206
|
export async function configureFrameworkBuild(frameworkPaths, frameworkBuildPaths, mode, options = {}) {
|
|
132
207
|
const { dryRun = false, cwd } = options
|
|
208
|
+
assertFrameworkSourceInstall(frameworkPaths)
|
|
133
209
|
const toolchainFile = await ensureVcpkgToolchain({ dryRun })
|
|
134
210
|
const buildDir = getBuildDirectory(frameworkBuildPaths, mode)
|
|
135
211
|
const generator = await resolveCmakeGenerator()
|
|
136
212
|
if (!dryRun) {
|
|
137
|
-
await
|
|
213
|
+
await ensureCompatibleCmakeBuild(buildDir, frameworkPaths.frameworkRoot, generator.name)
|
|
138
214
|
}
|
|
139
215
|
const configureArgs = [
|
|
140
216
|
"-S",
|
|
@@ -159,8 +235,8 @@ export async function configureFrameworkBuild(frameworkPaths, frameworkBuildPath
|
|
|
159
235
|
throw error
|
|
160
236
|
}
|
|
161
237
|
}
|
|
162
|
-
|
|
163
|
-
|
|
238
|
+
|
|
239
|
+
async function buildFrameworkRuntimeFromSource(frameworkPaths, frameworkBuildPaths, mode, options = {}) {
|
|
164
240
|
const { dryRun = false, cwd } = options
|
|
165
241
|
const buildDir = getBuildDirectory(frameworkBuildPaths, mode)
|
|
166
242
|
const generator = await resolveCmakeGenerator()
|
|
@@ -175,3 +251,14 @@ export async function buildFrameworkRuntime(frameworkPaths, frameworkBuildPaths,
|
|
|
175
251
|
dryRun
|
|
176
252
|
})
|
|
177
253
|
}
|
|
254
|
+
|
|
255
|
+
export async function prepareFrameworkRuntime(frameworkPaths, frameworkBuildPaths, mode, options = {}) {
|
|
256
|
+
const strategy = resolveFrameworkRuntimeStrategy(frameworkPaths, options)
|
|
257
|
+
|
|
258
|
+
if (strategy.kind === "prebuilt") {
|
|
259
|
+
return strategy
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
await buildFrameworkRuntimeFromSource(frameworkPaths, frameworkBuildPaths, mode, options)
|
|
263
|
+
return strategy
|
|
264
|
+
}
|
package/src/lib/logger.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export const logger = {
|
|
2
|
-
info(message) {
|
|
3
|
-
console.log(message)
|
|
4
|
-
},
|
|
5
|
-
warn(message) {
|
|
6
|
-
console.warn(message)
|
|
7
|
-
},
|
|
8
|
-
error(message) {
|
|
9
|
-
console.error(message)
|
|
10
|
-
}
|
|
11
|
-
}
|
|
1
|
+
export const logger = {
|
|
2
|
+
info(message) {
|
|
3
|
+
console.log(message)
|
|
4
|
+
},
|
|
5
|
+
warn(message) {
|
|
6
|
+
console.warn(message)
|
|
7
|
+
},
|
|
8
|
+
error(message) {
|
|
9
|
+
console.error(message)
|
|
10
|
+
}
|
|
11
|
+
}
|