reset-framework-cli 1.2.1 → 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 +8 -6
- package/src/commands/build.js +144 -126
- package/src/commands/dev.js +195 -174
- package/src/commands/doctor.js +140 -133
- package/src/commands/init.js +946 -866
- package/src/commands/package.js +68 -68
- package/src/index.js +195 -195
- package/src/lib/backend.js +123 -0
- 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 -268
- package/src/lib/process.js +303 -303
- package/src/lib/project.js +897 -833
- 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
|
@@ -6,13 +6,13 @@ import path from "node:path"
|
|
|
6
6
|
import { assertFrameworkSourceInstall, resolveFrameworkRuntimeStrategy } from "./project.js"
|
|
7
7
|
import { runCommand } from "./process.js"
|
|
8
8
|
import { ensureVcpkgToolchain } from "./toolchain.js"
|
|
9
|
-
|
|
10
|
-
function getBuildDirectory(frameworkBuildPaths, mode) {
|
|
11
|
-
return mode === "release"
|
|
12
|
-
? frameworkBuildPaths.releaseBuildDir
|
|
13
|
-
: frameworkBuildPaths.devBuildDir
|
|
14
|
-
}
|
|
15
|
-
|
|
9
|
+
|
|
10
|
+
function getBuildDirectory(frameworkBuildPaths, mode) {
|
|
11
|
+
return mode === "release"
|
|
12
|
+
? frameworkBuildPaths.releaseBuildDir
|
|
13
|
+
: frameworkBuildPaths.devBuildDir
|
|
14
|
+
}
|
|
15
|
+
|
|
16
16
|
function getBuildType(mode) {
|
|
17
17
|
return mode === "release" ? "Release" : "Debug"
|
|
18
18
|
}
|
|
@@ -132,18 +132,18 @@ async function resolveCmakeGenerator() {
|
|
|
132
132
|
typeof process.env.CMAKE_GENERATOR === "string" && process.env.CMAKE_GENERATOR.trim() !== ""
|
|
133
133
|
? process.env.CMAKE_GENERATOR.trim()
|
|
134
134
|
: null
|
|
135
|
-
|
|
136
|
-
if (envGenerator) {
|
|
137
|
-
return {
|
|
138
|
-
name: envGenerator,
|
|
139
|
-
configureArgs: process.platform === "win32" &&
|
|
140
|
-
!process.env.CMAKE_GENERATOR_PLATFORM &&
|
|
141
|
-
envGenerator.startsWith("Visual Studio ")
|
|
142
|
-
? ["-G", envGenerator, "-A", "x64"]
|
|
143
|
-
: ["-G", envGenerator],
|
|
144
|
-
buildArgs: envGenerator.startsWith("Visual Studio ")
|
|
145
|
-
? ["--config"]
|
|
146
|
-
: [],
|
|
135
|
+
|
|
136
|
+
if (envGenerator) {
|
|
137
|
+
return {
|
|
138
|
+
name: envGenerator,
|
|
139
|
+
configureArgs: process.platform === "win32" &&
|
|
140
|
+
!process.env.CMAKE_GENERATOR_PLATFORM &&
|
|
141
|
+
envGenerator.startsWith("Visual Studio ")
|
|
142
|
+
? ["-G", envGenerator, "-A", "x64"]
|
|
143
|
+
: ["-G", envGenerator],
|
|
144
|
+
buildArgs: envGenerator.startsWith("Visual Studio ")
|
|
145
|
+
? ["--config"]
|
|
146
|
+
: [],
|
|
147
147
|
multiConfig: envGenerator.startsWith("Visual Studio ")
|
|
148
148
|
}
|
|
149
149
|
}
|
|
@@ -170,22 +170,22 @@ async function resolveCmakeGenerator() {
|
|
|
170
170
|
configureArgs: ["-G", "Ninja"],
|
|
171
171
|
buildArgs: [],
|
|
172
172
|
multiConfig: false
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
176
|
async function ensureCompatibleCmakeBuild(buildDir, frameworkRoot, generatorName) {
|
|
177
177
|
const cachePath = path.join(buildDir, "CMakeCache.txt")
|
|
178
178
|
if (!existsSync(cachePath)) {
|
|
179
179
|
return
|
|
180
180
|
}
|
|
181
|
-
|
|
182
|
-
let cache
|
|
183
|
-
try {
|
|
184
|
-
cache = await readFile(cachePath, "utf8")
|
|
185
|
-
} catch {
|
|
186
|
-
return
|
|
187
|
-
}
|
|
188
|
-
|
|
181
|
+
|
|
182
|
+
let cache
|
|
183
|
+
try {
|
|
184
|
+
cache = await readFile(cachePath, "utf8")
|
|
185
|
+
} catch {
|
|
186
|
+
return
|
|
187
|
+
}
|
|
188
|
+
|
|
189
189
|
const cachedRootValue = readCmakeCacheValue(cache, "CMAKE_HOME_DIRECTORY")
|
|
190
190
|
const cachedGenerator = readCmakeCacheValue(cache, "CMAKE_GENERATOR")
|
|
191
191
|
if (!cachedRootValue) {
|
|
@@ -202,7 +202,7 @@ async function ensureCompatibleCmakeBuild(buildDir, frameworkRoot, generatorName
|
|
|
202
202
|
await rm(buildDir, { recursive: true, force: true })
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
-
|
|
205
|
+
|
|
206
206
|
export async function configureFrameworkBuild(frameworkPaths, frameworkBuildPaths, mode, options = {}) {
|
|
207
207
|
const { dryRun = false, cwd } = options
|
|
208
208
|
assertFrameworkSourceInstall(frameworkPaths)
|
|
@@ -212,27 +212,27 @@ export async function configureFrameworkBuild(frameworkPaths, frameworkBuildPath
|
|
|
212
212
|
if (!dryRun) {
|
|
213
213
|
await ensureCompatibleCmakeBuild(buildDir, frameworkPaths.frameworkRoot, generator.name)
|
|
214
214
|
}
|
|
215
|
-
const configureArgs = [
|
|
216
|
-
"-S",
|
|
217
|
-
frameworkPaths.frameworkRoot,
|
|
218
|
-
"-B",
|
|
219
|
-
buildDir,
|
|
220
|
-
...generator.configureArgs,
|
|
221
|
-
`-DCMAKE_BUILD_TYPE=${getBuildType(mode)}`,
|
|
222
|
-
"-DCMAKE_CXX_STANDARD=20",
|
|
223
|
-
"-DCMAKE_CXX_STANDARD_REQUIRED=ON",
|
|
224
|
-
"-DCMAKE_CXX_EXTENSIONS=OFF",
|
|
225
|
-
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
|
|
226
|
-
`-DCMAKE_TOOLCHAIN_FILE=${toolchainFile}`
|
|
227
|
-
]
|
|
228
|
-
|
|
229
|
-
try {
|
|
230
|
-
await runCommand("cmake", configureArgs, {
|
|
231
|
-
cwd,
|
|
232
|
-
dryRun
|
|
233
|
-
})
|
|
234
|
-
} catch (error) {
|
|
235
|
-
throw error
|
|
215
|
+
const configureArgs = [
|
|
216
|
+
"-S",
|
|
217
|
+
frameworkPaths.frameworkRoot,
|
|
218
|
+
"-B",
|
|
219
|
+
buildDir,
|
|
220
|
+
...generator.configureArgs,
|
|
221
|
+
`-DCMAKE_BUILD_TYPE=${getBuildType(mode)}`,
|
|
222
|
+
"-DCMAKE_CXX_STANDARD=20",
|
|
223
|
+
"-DCMAKE_CXX_STANDARD_REQUIRED=ON",
|
|
224
|
+
"-DCMAKE_CXX_EXTENSIONS=OFF",
|
|
225
|
+
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
|
|
226
|
+
`-DCMAKE_TOOLCHAIN_FILE=${toolchainFile}`
|
|
227
|
+
]
|
|
228
|
+
|
|
229
|
+
try {
|
|
230
|
+
await runCommand("cmake", configureArgs, {
|
|
231
|
+
cwd,
|
|
232
|
+
dryRun
|
|
233
|
+
})
|
|
234
|
+
} catch (error) {
|
|
235
|
+
throw error
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
|
|
@@ -240,11 +240,11 @@ async function buildFrameworkRuntimeFromSource(frameworkPaths, frameworkBuildPat
|
|
|
240
240
|
const { dryRun = false, cwd } = options
|
|
241
241
|
const buildDir = getBuildDirectory(frameworkBuildPaths, mode)
|
|
242
242
|
const generator = await resolveCmakeGenerator()
|
|
243
|
-
|
|
244
|
-
await configureFrameworkBuild(frameworkPaths, frameworkBuildPaths, mode, {
|
|
245
|
-
cwd,
|
|
246
|
-
dryRun
|
|
247
|
-
})
|
|
243
|
+
|
|
244
|
+
await configureFrameworkBuild(frameworkPaths, frameworkBuildPaths, mode, {
|
|
245
|
+
cwd,
|
|
246
|
+
dryRun
|
|
247
|
+
})
|
|
248
248
|
|
|
249
249
|
await runCommand("cmake", ["--build", buildDir, ...generator.buildArgs, ...(generator.multiConfig ? [getBuildType(mode)] : [])], {
|
|
250
250
|
cwd,
|
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
|
+
}
|