reset-framework-cli 1.1.4 → 1.2.0

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.
@@ -176,89 +176,6 @@ function App() {
176
176
  export default App
177
177
  `
178
178
 
179
- const rootFrontendRunner = `import { readFileSync } from 'node:fs'
180
- import path from 'node:path'
181
- import { spawn } from 'node:child_process'
182
-
183
- const script = process.argv[2]
184
- if (!script) {
185
- throw new Error('Missing frontend script name.')
186
- }
187
-
188
- const appRoot = process.cwd()
189
- const config = JSON.parse(readFileSync(path.join(appRoot, 'reset.config.json'), 'utf8'))
190
- const frontendDir =
191
- typeof config?.project?.frontendDir === 'string' && config.project.frontendDir.trim() !== ''
192
- ? path.resolve(appRoot, config.project.frontendDir)
193
- : path.join(appRoot, 'frontend')
194
-
195
- function shouldUseShell(command) {
196
- return process.platform === 'win32' && typeof command === 'string' && /\\.(cmd|bat)$/i.test(command)
197
- }
198
-
199
- function resolvePackageManagerCommand() {
200
- const packageJsonPath = path.join(appRoot, 'package.json')
201
- const manifest = JSON.parse(readFileSync(packageJsonPath, 'utf8'))
202
- const packageManager = typeof manifest.packageManager === 'string' ? manifest.packageManager.trim() : ''
203
- const name = packageManager.split('@')[0]
204
-
205
- if (name === 'bun') {
206
- return process.platform === 'win32' ? 'bun.exe' : 'bun'
207
- }
208
-
209
- if (name === 'pnpm') {
210
- return process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm'
211
- }
212
-
213
- if (name === 'yarn') {
214
- return process.platform === 'win32' ? 'yarn.cmd' : 'yarn'
215
- }
216
-
217
- if (name === 'npm') {
218
- return process.platform === 'win32' ? 'npm.cmd' : 'npm'
219
- }
220
-
221
- const candidates = [
222
- ['bun.lock', process.platform === 'win32' ? 'bun.exe' : 'bun'],
223
- ['bun.lockb', process.platform === 'win32' ? 'bun.exe' : 'bun'],
224
- ['pnpm-lock.yaml', process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm'],
225
- ['yarn.lock', process.platform === 'win32' ? 'yarn.cmd' : 'yarn'],
226
- ['package-lock.json', process.platform === 'win32' ? 'npm.cmd' : 'npm']
227
- ]
228
-
229
- for (const [fileName, command] of candidates) {
230
- try {
231
- readFileSync(path.join(appRoot, fileName), 'utf8')
232
- return command
233
- } catch {}
234
- }
235
-
236
- return process.platform === 'win32' ? 'npm.cmd' : 'npm'
237
- }
238
-
239
- const command = resolvePackageManagerCommand()
240
- const child = spawn(command, ['run', script, '--', ...process.argv.slice(3)], {
241
- cwd: frontendDir,
242
- stdio: 'inherit',
243
- env: process.env,
244
- shell: shouldUseShell(command)
245
- })
246
-
247
- child.once('error', (error) => {
248
- console.error(error)
249
- process.exit(1)
250
- })
251
-
252
- child.once('exit', (code, signal) => {
253
- if (signal) {
254
- process.kill(process.pid, signal)
255
- return
256
- }
257
-
258
- process.exit(code ?? 1)
259
- })
260
- `
261
-
262
179
  export const description = "Scaffold a starter app with an interactive project setup"
263
180
 
264
181
  function listTemplates(templatesDir) {
@@ -387,6 +304,28 @@ function describeInstallCommand(packageManager) {
387
304
  return [packageManager, ...getInstallCommandArgs(packageManager)].join(" ")
388
305
  }
389
306
 
307
+ function createFrontendScriptCommand(packageManager, frontendDir, scriptName) {
308
+ const frontendPath = JSON.stringify(frontendDir.replace(/\\/g, "/"))
309
+
310
+ if (packageManager === "npm") {
311
+ return `npm --workspace ${frontendPath} run ${scriptName} --`
312
+ }
313
+
314
+ if (packageManager === "pnpm") {
315
+ return `pnpm --dir ${frontendPath} run ${scriptName} --`
316
+ }
317
+
318
+ if (packageManager === "yarn") {
319
+ return `yarn --cwd ${frontendPath} run ${scriptName}`
320
+ }
321
+
322
+ if (packageManager === "bun") {
323
+ return `bun --cwd ${frontendPath} run ${scriptName}`
324
+ }
325
+
326
+ throw new Error(`Unsupported package manager: ${packageManager}`)
327
+ }
328
+
390
329
  async function ensureWritableTarget(targetDir, force) {
391
330
  if (!existsSync(targetDir)) {
392
331
  return
@@ -493,10 +432,10 @@ function createRootPackageJson(options) {
493
432
 
494
433
  if (options.frontendDir !== ".") {
495
434
  base.workspaces = [options.frontendDir]
496
- base.scripts["dev:web"] = "node ./scripts/run-frontend.mjs dev"
497
- base.scripts["build:web"] = "node ./scripts/run-frontend.mjs build"
498
- base.scripts["lint:web"] = "node ./scripts/run-frontend.mjs lint"
499
- base.scripts["preview:web"] = "node ./scripts/run-frontend.mjs preview"
435
+ base.scripts["dev:web"] = createFrontendScriptCommand(options.packageManager, options.frontendDir, "dev")
436
+ base.scripts["build:web"] = createFrontendScriptCommand(options.packageManager, options.frontendDir, "build")
437
+ base.scripts["lint:web"] = createFrontendScriptCommand(options.packageManager, options.frontendDir, "lint")
438
+ base.scripts["preview:web"] = createFrontendScriptCommand(options.packageManager, options.frontendDir, "preview")
500
439
  }
501
440
 
502
441
  return base
@@ -544,10 +483,6 @@ async function writeRootPackageFiles(options) {
544
483
  JSON.stringify(createRootPackageJson(options), null, 2) + "\n",
545
484
  "utf8"
546
485
  )
547
-
548
- const scriptsDir = path.join(options.targetDir, "scripts")
549
- await mkdir(scriptsDir, { recursive: true })
550
- await writeFile(path.join(scriptsDir, "run-frontend.mjs"), rootFrontendRunner, "utf8")
551
486
  }
552
487
  }
553
488
 
@@ -846,11 +781,6 @@ export async function run(context) {
846
781
  ["plan", "Write Vite config", path.join(targetFrontendDir, "vite.config.ts")],
847
782
  ["plan", "Write TS config", path.join(targetFrontendDir, "tsconfig.app.json")]
848
783
  ])
849
- if (options.frontendDir !== ".") {
850
- printStatusTable([
851
- ["plan", "Write frontend runner", path.join(options.targetDir, "scripts", "run-frontend.mjs")]
852
- ])
853
- }
854
784
  if (options.styling === "tailwindcss") {
855
785
  printStatusTable([
856
786
  ["plan", "Patch package.json", path.join(targetFrontendDir, "package.json")],
@@ -1,9 +1,9 @@
1
- import { existsSync } from "node:fs"
2
-
3
- import { createMacOSZipArchive, createWindowsZipArchive } from "../lib/output.js"
4
- import {
5
- assertAppProject,
6
- loadResetConfig,
1
+ import { existsSync } from "node:fs"
2
+
3
+ import { createMacOSZipArchive, createWindowsZipArchive } from "../lib/output.js"
4
+ import {
5
+ assertAppProject,
6
+ loadResetConfig,
7
7
  resolveAppOutputPaths,
8
8
  resolveAppPaths
9
9
  } from "../lib/project.js"
@@ -15,17 +15,17 @@ import {
15
15
  printStatusTable
16
16
  } from "../lib/ui.js"
17
17
 
18
- export const description = "Package the built desktop app into a distributable archive"
19
-
20
- export async function run(context) {
21
- const dryRun = Boolean(context.flags["dry-run"])
22
- const isWindows = process.platform === "win32"
23
- const archiveBuilder = isWindows ? createWindowsZipArchive : createMacOSZipArchive
24
- const archiveDescription = isWindows
25
- ? "Create a Windows zip package from the built app folder"
26
- : "Create a macOS zip package from the built app bundle"
27
- const appPaths = resolveAppPaths(context.projectRoot)
28
- assertAppProject(appPaths)
18
+ export const description = "Package the built desktop app into a distributable archive"
19
+
20
+ export async function run(context) {
21
+ const dryRun = Boolean(context.flags["dry-run"])
22
+ const isWindows = process.platform === "win32"
23
+ const archiveBuilder = isWindows ? createWindowsZipArchive : createMacOSZipArchive
24
+ const archiveDescription = isWindows
25
+ ? "Create a Windows zip package from the built app folder"
26
+ : "Create a macOS zip package from the built app bundle"
27
+ const appPaths = resolveAppPaths(context.projectRoot)
28
+ assertAppProject(appPaths)
29
29
 
30
30
  const config = loadResetConfig(appPaths)
31
31
  assertAppProject(appPaths, config)
@@ -38,11 +38,11 @@ export async function run(context) {
38
38
  ["Archive", outputPaths.zipPath]
39
39
  ])
40
40
  console.log("")
41
-
42
- printSection("Plan")
43
- printStatusTable([
44
- ["ready", "Archive", archiveDescription]
45
- ])
41
+
42
+ printSection("Plan")
43
+ printStatusTable([
44
+ ["ready", "Archive", archiveDescription]
45
+ ])
46
46
 
47
47
  if (!existsSync(outputPaths.appBundlePath) && !dryRun) {
48
48
  throw new Error(
@@ -56,11 +56,11 @@ export async function run(context) {
56
56
  printStatusTable([["plan", "Package", "No archive will be written"]])
57
57
  return
58
58
  }
59
-
60
- console.log("")
61
- const progress = createProgress(1, "Package")
62
- await archiveBuilder(outputPaths, { dryRun })
63
- progress.tick("Archive created")
59
+
60
+ console.log("")
61
+ const progress = createProgress(1, "Package")
62
+ await archiveBuilder(outputPaths, { dryRun })
63
+ progress.tick("Archive created")
64
64
 
65
65
  console.log("")
66
66
  printSection("Result")
package/src/index.js CHANGED
@@ -16,15 +16,16 @@ import {
16
16
  } from "./lib/ui.js"
17
17
 
18
18
  const commands = {
19
- build: {
20
- description: buildDescription,
21
- usage: "reset-framework-cli build [--skip-frontend] [--skip-runtime] [--skip-stage] [--dry-run]",
22
- options: [
23
- ["--skip-frontend", "Skip the frontend build step"],
24
- ["--skip-runtime", "Skip the release runtime build"],
25
- ["--skip-stage", "Skip assembling the final .app bundle"],
26
- ["--dry-run", "Print the build plan without running commands"]
27
- ],
19
+ build: {
20
+ description: buildDescription,
21
+ usage: "reset-framework-cli build [--skip-frontend] [--skip-runtime] [--skip-stage] [--runtime-source] [--dry-run]",
22
+ options: [
23
+ ["--skip-frontend", "Skip the frontend build step"],
24
+ ["--skip-runtime", "Skip the release runtime build"],
25
+ ["--skip-stage", "Skip assembling the final .app bundle"],
26
+ ["--runtime-source", "Build the runtime from @reset-framework/native instead of using a bundled runtime package"],
27
+ ["--dry-run", "Print the build plan without running commands"]
28
+ ],
28
29
  examples: [
29
30
  "reset-framework-cli build",
30
31
  "reset-framework-cli build --dry-run"
@@ -56,15 +57,16 @@ const commands = {
56
57
  ],
57
58
  run: runCreateApp
58
59
  },
59
- dev: {
60
- description: devDescription,
61
- usage: "reset-framework-cli dev [--skip-frontend] [--skip-runtime] [--no-open] [--dry-run]",
62
- options: [
63
- ["--skip-frontend", "Reuse an already running frontend dev server"],
64
- ["--skip-runtime", "Reuse an existing native dev build"],
65
- ["--no-open", "Do not launch the desktop window after startup"],
66
- ["--dry-run", "Print the dev plan without starting processes"]
67
- ],
60
+ dev: {
61
+ description: devDescription,
62
+ usage: "reset-framework-cli dev [--skip-frontend] [--skip-runtime] [--no-open] [--runtime-source] [--dry-run]",
63
+ options: [
64
+ ["--skip-frontend", "Reuse an already running frontend dev server"],
65
+ ["--skip-runtime", "Reuse an existing native dev build"],
66
+ ["--no-open", "Do not launch the desktop window after startup"],
67
+ ["--runtime-source", "Build the runtime from @reset-framework/native instead of using a bundled runtime package"],
68
+ ["--dry-run", "Print the dev plan without starting processes"]
69
+ ],
68
70
  examples: [
69
71
  "reset-framework-cli dev",
70
72
  "reset-framework-cli dev --skip-runtime"
@@ -3,7 +3,8 @@ 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 { captureCommandOutput, runCommand } from "./process.js"
6
+ import { assertFrameworkSourceInstall, resolveFrameworkRuntimeStrategy } from "./project.js"
7
+ import { runCommand } from "./process.js"
7
8
  import { ensureVcpkgToolchain } from "./toolchain.js"
8
9
 
9
10
  function getBuildDirectory(frameworkBuildPaths, mode) {
@@ -16,6 +17,11 @@ 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
- try {
35
- const version = await captureCommandOutput(vswherePath, [
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
- "catalog_productLineVersion"
43
- ])
101
+ "installationPath"
102
+ ]).catch(() => "")
44
103
 
45
- const normalized = String(version).trim()
46
- if (normalized === "2022") {
47
- return "Visual Studio 17 2022"
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
- if (normalized === "2019") {
51
- return "Visual Studio 16 2019"
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 "Visual Studio 17 2022"
127
+ return null
58
128
  }
59
129
 
60
130
  async function resolveCmakeGenerator() {
@@ -62,35 +132,36 @@ async function resolveCmakeGenerator() {
62
132
  typeof process.env.CMAKE_GENERATOR === "string" && process.env.CMAKE_GENERATOR.trim() !== ""
63
133
  ? process.env.CMAKE_GENERATOR.trim()
64
134
  : null
65
-
66
- if (envGenerator) {
67
- return {
68
- name: envGenerator,
69
- configureArgs: process.platform === "win32" &&
70
- !process.env.CMAKE_GENERATOR_PLATFORM &&
71
- envGenerator.startsWith("Visual Studio ")
72
- ? ["-G", envGenerator, "-A", "x64"]
73
- : ["-G", envGenerator],
74
- buildArgs: envGenerator.startsWith("Visual Studio ")
75
- ? ["--config"]
76
- : [],
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
+ : [],
77
147
  multiConfig: envGenerator.startsWith("Visual Studio ")
78
148
  }
79
149
  }
80
150
 
81
151
  if (process.platform === "win32") {
82
- const generator = await findVisualStudioGenerator()
83
- if (!generator) {
84
- throw new Error(
85
- "Could not find a supported Visual Studio C++ installation. Install Visual Studio Build Tools or set CMAKE_GENERATOR manually."
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
- return {
90
- name: generator,
91
- configureArgs: ["-G", generator, "-A", "x64"],
92
- buildArgs: ["--config"],
93
- multiConfig: true
159
+ return {
160
+ name: visualStudio.generator,
161
+ configureArgs,
162
+ buildArgs: ["--config"],
163
+ multiConfig: true
164
+ }
94
165
  }
95
166
  }
96
167
 
@@ -99,79 +170,95 @@ async function resolveCmakeGenerator() {
99
170
  configureArgs: ["-G", "Ninja"],
100
171
  buildArgs: [],
101
172
  multiConfig: false
102
- }
103
- }
104
-
105
- async function ensureMatchingCmakeSource(buildDir, frameworkRoot) {
173
+ }
174
+ }
175
+
176
+ async function ensureCompatibleCmakeBuild(buildDir, frameworkRoot, generatorName) {
106
177
  const cachePath = path.join(buildDir, "CMakeCache.txt")
107
178
  if (!existsSync(cachePath)) {
108
179
  return
109
180
  }
110
-
111
- let cache
112
- try {
113
- cache = await readFile(cachePath, "utf8")
114
- } catch {
115
- return
116
- }
117
-
118
- const match = cache.match(/^CMAKE_HOME_DIRECTORY:INTERNAL=(.+)$/m)
119
- if (!match) {
181
+
182
+ let cache
183
+ try {
184
+ cache = await readFile(cachePath, "utf8")
185
+ } catch {
186
+ return
187
+ }
188
+
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(match[1].trim())
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 ensureMatchingCmakeSource(buildDir, frameworkPaths.frameworkRoot)
213
+ await ensureCompatibleCmakeBuild(buildDir, frameworkPaths.frameworkRoot, generator.name)
138
214
  }
139
- const configureArgs = [
140
- "-S",
141
- frameworkPaths.frameworkRoot,
142
- "-B",
143
- buildDir,
144
- ...generator.configureArgs,
145
- `-DCMAKE_BUILD_TYPE=${getBuildType(mode)}`,
146
- "-DCMAKE_CXX_STANDARD=20",
147
- "-DCMAKE_CXX_STANDARD_REQUIRED=ON",
148
- "-DCMAKE_CXX_EXTENSIONS=OFF",
149
- "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
150
- `-DCMAKE_TOOLCHAIN_FILE=${toolchainFile}`
151
- ]
152
-
153
- try {
154
- await runCommand("cmake", configureArgs, {
155
- cwd,
156
- dryRun
157
- })
158
- } catch (error) {
159
- 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
160
236
  }
161
237
  }
162
-
163
- export async function buildFrameworkRuntime(frameworkPaths, frameworkBuildPaths, mode, options = {}) {
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()
167
-
168
- await configureFrameworkBuild(frameworkPaths, frameworkBuildPaths, mode, {
169
- cwd,
170
- dryRun
171
- })
243
+
244
+ await configureFrameworkBuild(frameworkPaths, frameworkBuildPaths, mode, {
245
+ cwd,
246
+ dryRun
247
+ })
172
248
 
173
249
  await runCommand("cmake", ["--build", buildDir, ...generator.buildArgs, ...(generator.multiConfig ? [getBuildType(mode)] : [])], {
174
250
  cwd,
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
+ }