This repository has been archived by the owner on May 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
__run.js
55 lines (41 loc) · 1.67 KB
/
__run.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { tauriBuildScript, tauriDevScript } from "./stuff.js";
/** @type {import("../..").AdderRun<import("./__info.js").Options>} */
export const run = async ({ folderInfo, install, runCommand, updateJson }) => {
const appName = "My Tauri App";
const windowTitle = "Tauri App Window";
const port = 3000;
let distDir = "../dist";
// TODO: extract build directory from vite config
if (folderInfo.kit) {
// TODO: set adapter to static
// TODO: setdefault ssr to false
// TODO: setdefault prerender to false?
// TODO: setdefault fallback to index.html?
// TODO: extract build directory from options
distDir = "../build";
await install({ package: "@sveltejs/adapter-static" });
}
await runCommand({
command: ["cargo", "tauri", "init", "--app-name", appName, "--dist-dir", distDir, "--dev-path", `http://localhost:${port}`, "--window-title", windowTitle],
async interact() {},
});
await updateJson({
path: "/package.json",
async json({ obj }) {
const devScript = "dev";
const buildScript = "build";
let applicationFrameworkDevScript = "vite:dev";
let applicationFrameworkBuildScript = "vite:build";
const scripts = obj.scripts;
scripts[applicationFrameworkDevScript] = scripts[devScript];
scripts[applicationFrameworkBuildScript] = scripts[buildScript];
scripts[tauriDevScript] = "cargo tauri dev";
scripts[tauriBuildScript] = "cargo tauri build";
scripts[devScript] = `run-p ${applicationFrameworkDevScript} ${tauriDevScript}`;
scripts[buildScript] = `run-s ${applicationFrameworkBuildScript} ${tauriBuildScript}`;
return { obj };
},
});
await install({ package: "npm-run-all" });
await install({ package: "@tauri-apps/api" });
};