Give the front end its version through the build environment
vite.config.js reads RUNESTONE_VERSION and falls back to package.json. The installer build sets RUNESTONE_VERSION and writes all four version files only after the installer exists. Before, it wrote package.json before the build and restored it after a failure. The installation guide and CLAUDE.md now say that setup replaces the installed app in place. The installer no longer shows a maintenance page.
This commit is contained in:
+11
-11
@@ -61,7 +61,9 @@ export async function planInstallerBuild(root, requestedVersion) {
|
||||
const updated = [JSON.stringify(packageJson, null, 2) + '\n', JSON.stringify(config, null, 2) + '\n', cargo, lock];
|
||||
// Tauri merges this override into tauri.conf.json for the build script, the app, and the bundler.
|
||||
const override = { version: next.toolchain };
|
||||
return { root, files, before, updated, current, next, override, releaseDir, artifacts };
|
||||
// vite.config.js gives this version to the front end, so package.json can wait until the build completes.
|
||||
const env = { RUNESTONE_VERSION: next.version };
|
||||
return { root, files, before, updated, current, next, override, env, releaseDir, artifacts };
|
||||
}
|
||||
|
||||
// The commands of a build, in order. overridePath is the file with plan.override.
|
||||
@@ -82,15 +84,15 @@ export function describePlan(plan, overridePath = '<attempt folder>/tauri.versio
|
||||
`Release version: ${plan.next.version} (current ${plan.current.version})`,
|
||||
`Toolchain version: ${plan.next.toolchain}. Windows version: ${plan.next.windows}.`,
|
||||
`Configuration override: ${JSON.stringify(plan.override)}`,
|
||||
`1. Write version ${plan.next.version} to package.json. The front-end build reads it. A failed build restores it.`,
|
||||
...buildCommands(plan, overridePath).map((entry, index) => `${index + 2}. ${entry.step}: ${[entry.command, ...entry.args].join(' ')}`),
|
||||
`5. Move the setup file to ${relative(plan.artifacts.release)} and write ${relative(plan.artifacts.metadata)}.`,
|
||||
`6. Write the new version to ${versionFiles.slice(1).join(', ')}.`,
|
||||
`Environment: ${Object.entries(plan.env).map(([key, value]) => `${key}=${value}`).join(' ')}`,
|
||||
...buildCommands(plan, overridePath).map((entry, index) => `${index + 1}. ${entry.step}: ${[entry.command, ...entry.args].join(' ')}`),
|
||||
`4. Move the setup file to ${relative(plan.artifacts.release)} and write ${relative(plan.artifacts.metadata)}.`,
|
||||
`5. Write the new version to ${versionFiles.join(', ')}.`,
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
// Runs the build. run(command, args) must reject when a command fails.
|
||||
// The tracked version files change only when the build completes, except package.json during the build.
|
||||
// The tracked version files change only when the build completes.
|
||||
export async function runInstallerBuild(plan, run, staging) {
|
||||
const { files, before, updated, artifacts } = plan;
|
||||
await fs.mkdir(staging, { recursive: true });
|
||||
@@ -99,8 +101,6 @@ export async function runInstallerBuild(plan, run, staging) {
|
||||
await fs.writeFile(overridePath, JSON.stringify(plan.override, null, 2) + '\n');
|
||||
let complete = false;
|
||||
try {
|
||||
// src/lib/layout/SettingsDialog.svelte imports the version from package.json.
|
||||
await fs.writeFile(files[0], updated[0]);
|
||||
for (const { command, args } of buildCommands(plan, overridePath)) await run(command, args);
|
||||
await fs.access(artifacts.bundled);
|
||||
if (artifacts.bundled !== artifacts.renamed) await fs.rename(artifacts.bundled, artifacts.renamed);
|
||||
@@ -111,7 +111,7 @@ export async function runInstallerBuild(plan, run, staging) {
|
||||
file: path.basename(artifacts.release), bytes: bytes.length, sha256: createHash('sha256').update(bytes).digest('hex') };
|
||||
await fs.writeFile(artifacts.metadata, JSON.stringify(metadata, null, 2) + '\n', { flag: 'wx' });
|
||||
await fs.unlink(artifacts.renamed);
|
||||
for (let i = 1; i < files.length; i++) await fs.writeFile(files[i], updated[i]);
|
||||
for (let i = 0; i < files.length; i++) await fs.writeFile(files[i], updated[i]);
|
||||
complete = true;
|
||||
return artifacts.release;
|
||||
} finally {
|
||||
@@ -136,8 +136,8 @@ async function main() {
|
||||
return;
|
||||
}
|
||||
if (process.platform !== 'win32') throw Error('Build the Windows installer on Windows.');
|
||||
const env = { ...process.env, GIT_CONFIG_COUNT: '1', GIT_CONFIG_KEY_0: 'safe.directory', GIT_CONFIG_VALUE_0: root.replaceAll('\\', '/') };
|
||||
// Ctrl+C also stops the child build. Keep this process alive so that package.json is restored.
|
||||
const env = { ...process.env, ...plan.env, GIT_CONFIG_COUNT: '1', GIT_CONFIG_KEY_0: 'safe.directory', GIT_CONFIG_VALUE_0: root.replaceAll('\\', '/') };
|
||||
// Ctrl+C also stops the child build. Keep this process alive so that the cleanup runs.
|
||||
let interrupted = false;
|
||||
for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) process.on(signal, () => { interrupted = true; process.exitCode = 130; });
|
||||
async function run(command, parameters) {
|
||||
|
||||
Reference in New Issue
Block a user