@pipelab/plugin-tauri 1.0.0-beta.1 → 1.0.0-beta.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/package.json +8 -5
- package/CHANGELOG.md +0 -20
- package/src/configure.ts +0 -23
- package/src/declarations.d.ts +0 -1
- package/src/fixtures/build/index.html +0 -11
- package/src/index.ts +0 -68
- package/src/make.spec.ts +0 -57
- package/src/make.ts +0 -21
- package/src/package.ts +0 -43
- package/src/preview.ts +0 -51
- package/src/public/tauri.webp +0 -0
- package/src/tauri.ts +0 -842
- package/src/utils.ts +0 -27
- package/tsconfig.json +0 -10
- package/tsdown.config.ts +0 -15
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipelab/plugin-tauri",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.4",
|
|
4
4
|
"license": "FSL-1.1-MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/CynToolkit/pipelab.git",
|
|
8
8
|
"directory": "plugins/plugin-tauri"
|
|
9
9
|
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
10
13
|
"type": "module",
|
|
11
14
|
"main": "./dist/index.cjs",
|
|
12
15
|
"module": "./dist/index.mjs",
|
|
@@ -19,14 +22,14 @@
|
|
|
19
22
|
"electron": "32.1.2",
|
|
20
23
|
"execa": "9.4.1",
|
|
21
24
|
"ts-deepmerge": "7.0.1",
|
|
22
|
-
"@pipelab/constants": "1.0.0-beta.
|
|
23
|
-
"@pipelab/plugin-core": "1.0.0-beta.
|
|
24
|
-
"@pipelab/shared": "1.0.0-beta.
|
|
25
|
+
"@pipelab/constants": "1.0.0-beta.3",
|
|
26
|
+
"@pipelab/plugin-core": "1.0.0-beta.4",
|
|
27
|
+
"@pipelab/shared": "1.0.0-beta.2"
|
|
25
28
|
},
|
|
26
29
|
"devDependencies": {
|
|
27
30
|
"tsdown": "0.21.2",
|
|
28
31
|
"typescript": "5.9.3",
|
|
29
|
-
"@pipelab/tsconfig": "1.0.0-beta.
|
|
32
|
+
"@pipelab/tsconfig": "1.0.0-beta.2"
|
|
30
33
|
},
|
|
31
34
|
"scripts": {
|
|
32
35
|
"format": "oxfmt .",
|
package/CHANGELOG.md
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# @pipelab/plugin-tauri
|
|
2
|
-
|
|
3
|
-
## 1.0.0-beta.1
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- @pipelab/plugin-core@1.0.0-beta.1
|
|
8
|
-
|
|
9
|
-
## 1.0.0-beta.0
|
|
10
|
-
|
|
11
|
-
### Major Changes
|
|
12
|
-
|
|
13
|
-
- e1befbf: initial release
|
|
14
|
-
|
|
15
|
-
### Patch Changes
|
|
16
|
-
|
|
17
|
-
- Updated dependencies [e1befbf]
|
|
18
|
-
- @pipelab/plugin-core@1.0.0-beta.0
|
|
19
|
-
- @pipelab/constants@1.0.0-beta.0
|
|
20
|
-
- @pipelab/shared@1.0.0-beta.0
|
package/src/configure.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { createAction, createActionRunner } from "@pipelab/plugin-core";
|
|
2
|
-
import { configureParams } from "./tauri";
|
|
3
|
-
|
|
4
|
-
export const props = createAction({
|
|
5
|
-
id: "tauri:configure",
|
|
6
|
-
description: "Configure tauri",
|
|
7
|
-
displayString: "'Configure Tauri'",
|
|
8
|
-
icon: "",
|
|
9
|
-
meta: {},
|
|
10
|
-
name: "Configure Tauri",
|
|
11
|
-
advanced: true,
|
|
12
|
-
outputs: {
|
|
13
|
-
configuration: {
|
|
14
|
-
label: "Configuration",
|
|
15
|
-
value: {} as Partial<DesktopApp.Tauri>,
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
params: configureParams,
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
export const configureRunner = createActionRunner<typeof props>(async ({ setOutput, inputs }) => {
|
|
22
|
-
setOutput("configuration", inputs);
|
|
23
|
-
});
|
package/src/declarations.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
declare module "*.webp";
|
package/src/index.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { makeRunner } from "./make";
|
|
2
|
-
import { previewRunner } from "./preview";
|
|
3
|
-
|
|
4
|
-
import { createNodeDefinition } from "@pipelab/plugin-core";
|
|
5
|
-
const icon = new URL("./public/tauri.webp", import.meta.url).href;
|
|
6
|
-
import {
|
|
7
|
-
createMakeProps,
|
|
8
|
-
createPackageV2Props,
|
|
9
|
-
createPreviewProps,
|
|
10
|
-
IDMake,
|
|
11
|
-
IDPackageV2,
|
|
12
|
-
IDPreview,
|
|
13
|
-
} from "./tauri";
|
|
14
|
-
import { configureRunner, props } from "./configure";
|
|
15
|
-
import { packageV2Runner } from "./package";
|
|
16
|
-
|
|
17
|
-
export default createNodeDefinition({
|
|
18
|
-
description: "Tauri",
|
|
19
|
-
name: "Tauri",
|
|
20
|
-
id: "tauri",
|
|
21
|
-
icon: {
|
|
22
|
-
type: "image",
|
|
23
|
-
image: icon,
|
|
24
|
-
},
|
|
25
|
-
nodes: [
|
|
26
|
-
// make and package
|
|
27
|
-
{
|
|
28
|
-
node: createMakeProps(
|
|
29
|
-
IDMake,
|
|
30
|
-
"Create Installer",
|
|
31
|
-
"Create a distributable installer for your chosen platform",
|
|
32
|
-
"",
|
|
33
|
-
"`Build package for ${fmt.param(params['input-folder'], 'primary', 'Input folder not set')}`",
|
|
34
|
-
),
|
|
35
|
-
runner: makeRunner,
|
|
36
|
-
// disabled: platform === 'linux' ? 'Tauri is not supported on Linux' : undefined
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
node: createPackageV2Props(
|
|
40
|
-
IDPackageV2,
|
|
41
|
-
"Package app with configuration",
|
|
42
|
-
"Gather all necessary files and prepare your app for distribution, creating a platform-specific bundle.",
|
|
43
|
-
"",
|
|
44
|
-
"`Package app from ${fmt.param(params['input-folder'], 'primary', 'Input folder not set')}`",
|
|
45
|
-
false,
|
|
46
|
-
false,
|
|
47
|
-
undefined,
|
|
48
|
-
false,
|
|
49
|
-
false,
|
|
50
|
-
),
|
|
51
|
-
runner: packageV2Runner,
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
node: createPreviewProps(
|
|
55
|
-
IDPreview,
|
|
56
|
-
"Preview app",
|
|
57
|
-
"Package and preview your app from an URL",
|
|
58
|
-
"",
|
|
59
|
-
"`Preview app from ${fmt.param(params['input-url'], 'primary', 'Input folder not set')}`",
|
|
60
|
-
),
|
|
61
|
-
runner: previewRunner,
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
node: props,
|
|
65
|
-
runner: configureRunner,
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
});
|
package/src/make.spec.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { expect, test, vi } from "vitest";
|
|
2
|
-
import { makeRunner } from "./make.js";
|
|
3
|
-
import { tmpdir } from "node:os";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { type fs } from "memfs";
|
|
6
|
-
import { browserWindow } from "@pipelab/shared";
|
|
7
|
-
|
|
8
|
-
// ...
|
|
9
|
-
|
|
10
|
-
// vi.mock('node:fs/promises', async () => {
|
|
11
|
-
// const memfs: { fs: typeof fs } = await vi.importActual('memfs')
|
|
12
|
-
|
|
13
|
-
// return memfs.fs.promises
|
|
14
|
-
// })
|
|
15
|
-
|
|
16
|
-
test("adds 1 + 2 to equal 3", async () => {
|
|
17
|
-
const outputs: Record<string, unknown> = {};
|
|
18
|
-
|
|
19
|
-
const id = "ut-electron-build";
|
|
20
|
-
const tmpDir = join(tmpdir(), id);
|
|
21
|
-
|
|
22
|
-
console.log("tmpDir", tmpDir);
|
|
23
|
-
|
|
24
|
-
const inputFolder = join(process.cwd(), "fixtures", "build");
|
|
25
|
-
|
|
26
|
-
console.log("inputFolder", inputFolder);
|
|
27
|
-
|
|
28
|
-
// await makeRunner({
|
|
29
|
-
// inputs: {
|
|
30
|
-
// 'input-folder': inputFolder,
|
|
31
|
-
// configuration: {},
|
|
32
|
-
// arch: undefined,
|
|
33
|
-
// platform: undefined
|
|
34
|
-
// },
|
|
35
|
-
// log: (...args) => {
|
|
36
|
-
// console.log(...args)
|
|
37
|
-
// },
|
|
38
|
-
// setOutput: (key, value) => {
|
|
39
|
-
// outputs[key] = value
|
|
40
|
-
// },
|
|
41
|
-
// meta: {
|
|
42
|
-
// definition: ''
|
|
43
|
-
// },
|
|
44
|
-
// setMeta: () => {
|
|
45
|
-
// console.log('set meta defined here')
|
|
46
|
-
// },
|
|
47
|
-
// cwd: tmpDir,
|
|
48
|
-
// paths: {
|
|
49
|
-
// assets: '',
|
|
50
|
-
// unpack: ''
|
|
51
|
-
// },
|
|
52
|
-
// api: undefined,
|
|
53
|
-
// browserWindow
|
|
54
|
-
// })
|
|
55
|
-
console.log("outputs", outputs);
|
|
56
|
-
expect(true).toBe(true);
|
|
57
|
-
}, 120_000);
|
package/src/make.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { createActionRunner } from "@pipelab/plugin-core";
|
|
2
|
-
import { createMakeProps, tauri } from "./tauri";
|
|
3
|
-
import { merge } from "ts-deepmerge";
|
|
4
|
-
import { defaultTauriConfig } from "./utils";
|
|
5
|
-
|
|
6
|
-
export const makeRunner = createActionRunner<ReturnType<typeof createMakeProps>>(
|
|
7
|
-
async (options) => {
|
|
8
|
-
const appFolder = options.inputs["input-folder"];
|
|
9
|
-
|
|
10
|
-
if (!options.inputs.configuration) {
|
|
11
|
-
throw new Error("Missing tauri configuration");
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const completeConfiguration = merge(
|
|
15
|
-
defaultTauriConfig,
|
|
16
|
-
options.inputs.configuration,
|
|
17
|
-
) as DesktopApp.Tauri;
|
|
18
|
-
|
|
19
|
-
await tauri("make", appFolder, options, completeConfiguration);
|
|
20
|
-
},
|
|
21
|
-
);
|
package/src/package.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { createActionRunner } from "@pipelab/plugin-core";
|
|
2
|
-
import { createPackageV2Props, tauri } from "./tauri";
|
|
3
|
-
import { merge } from "ts-deepmerge";
|
|
4
|
-
import { defaultTauriConfig } from "./utils";
|
|
5
|
-
|
|
6
|
-
export const packageV2Runner = createActionRunner<ReturnType<typeof createPackageV2Props>>(
|
|
7
|
-
async (options) => {
|
|
8
|
-
const appFolder = options.inputs["input-folder"];
|
|
9
|
-
|
|
10
|
-
const completeConfiguration = merge(defaultTauriConfig, {
|
|
11
|
-
alwaysOnTop: options.inputs["alwaysOnTop"],
|
|
12
|
-
appBundleId: options.inputs["appBundleId"],
|
|
13
|
-
appCategoryType: options.inputs["appCategoryType"],
|
|
14
|
-
appCopyright: options.inputs["appCopyright"],
|
|
15
|
-
appVersion: options.inputs["appVersion"],
|
|
16
|
-
author: options.inputs["author"],
|
|
17
|
-
description: options.inputs["description"],
|
|
18
|
-
tauriVersion: options.inputs["tauriVersion"],
|
|
19
|
-
enableExtraLogging: options.inputs["enableExtraLogging"],
|
|
20
|
-
clearServiceWorkerOnBoot: options.inputs["clearServiceWorkerOnBoot"],
|
|
21
|
-
frame: options.inputs["frame"],
|
|
22
|
-
fullscreen: options.inputs["fullscreen"],
|
|
23
|
-
icon: options.inputs["icon"],
|
|
24
|
-
height: options.inputs["height"],
|
|
25
|
-
name: options.inputs["name"],
|
|
26
|
-
toolbar: options.inputs["toolbar"],
|
|
27
|
-
transparent: options.inputs["transparent"],
|
|
28
|
-
width: options.inputs["width"],
|
|
29
|
-
enableSteamSupport: options.inputs["enableSteamSupport"],
|
|
30
|
-
steamGameId: options.inputs["steamGameId"],
|
|
31
|
-
ignore: options.inputs["ignore"],
|
|
32
|
-
openDevtoolsOnStart: options.inputs["openDevtoolsOnStart"],
|
|
33
|
-
enableDiscordSupport: options.inputs["enableDiscordSupport"],
|
|
34
|
-
discordAppId: options.inputs["discordAppId"],
|
|
35
|
-
customPackages: options.inputs["customPackages"],
|
|
36
|
-
backgroundColor: options.inputs["backgroundColor"],
|
|
37
|
-
} satisfies DesktopApp.Tauri) as DesktopApp.Tauri;
|
|
38
|
-
|
|
39
|
-
console.log("completeConfiguration", completeConfiguration);
|
|
40
|
-
|
|
41
|
-
await tauri("package", appFolder, options, completeConfiguration);
|
|
42
|
-
},
|
|
43
|
-
);
|
package/src/preview.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { createActionRunner, runWithLiveLogs } from "@pipelab/plugin-core";
|
|
2
|
-
import { createPreviewProps, tauri } from "./tauri";
|
|
3
|
-
import { merge } from "ts-deepmerge";
|
|
4
|
-
import { defaultTauriConfig } from "./utils";
|
|
5
|
-
|
|
6
|
-
export const previewRunner = createActionRunner<ReturnType<typeof createPreviewProps>>(
|
|
7
|
-
async (options) => {
|
|
8
|
-
const url = options.inputs["input-url"];
|
|
9
|
-
if (url === "") {
|
|
10
|
-
throw new Error("URL can't be empty");
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (!options.inputs.configuration) {
|
|
14
|
-
throw new Error("Missing tauri configuration");
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const completeConfiguration = merge(defaultTauriConfig, {
|
|
18
|
-
alwaysOnTop: options.inputs.configuration["alwaysOnTop"],
|
|
19
|
-
appBundleId: options.inputs.configuration["appBundleId"],
|
|
20
|
-
appCategoryType: options.inputs.configuration["appCategoryType"],
|
|
21
|
-
appCopyright: options.inputs.configuration["appCopyright"],
|
|
22
|
-
appVersion: options.inputs.configuration["appVersion"],
|
|
23
|
-
author: options.inputs.configuration["author"],
|
|
24
|
-
description: options.inputs.configuration["description"],
|
|
25
|
-
tauriVersion: options.inputs.configuration["tauriVersion"],
|
|
26
|
-
enableExtraLogging: options.inputs.configuration["enableExtraLogging"],
|
|
27
|
-
clearServiceWorkerOnBoot: options.inputs.configuration["clearServiceWorkerOnBoot"],
|
|
28
|
-
frame: options.inputs.configuration["frame"],
|
|
29
|
-
fullscreen: options.inputs.configuration["fullscreen"],
|
|
30
|
-
icon: options.inputs.configuration["icon"],
|
|
31
|
-
height: options.inputs.configuration["height"],
|
|
32
|
-
name: options.inputs.configuration["name"],
|
|
33
|
-
toolbar: options.inputs.configuration["toolbar"],
|
|
34
|
-
transparent: options.inputs.configuration["transparent"],
|
|
35
|
-
width: options.inputs.configuration["width"],
|
|
36
|
-
enableSteamSupport: options.inputs.configuration["enableSteamSupport"],
|
|
37
|
-
steamGameId: options.inputs.configuration["steamGameId"],
|
|
38
|
-
ignore: options.inputs.configuration["ignore"],
|
|
39
|
-
openDevtoolsOnStart: options.inputs.configuration["openDevtoolsOnStart"],
|
|
40
|
-
enableDiscordSupport: options.inputs.configuration["enableDiscordSupport"],
|
|
41
|
-
discordAppId: options.inputs.configuration["discordAppId"],
|
|
42
|
-
customPackages: options.inputs.configuration["customPackages"],
|
|
43
|
-
backgroundColor: options.inputs.configuration["backgroundColor"],
|
|
44
|
-
} satisfies DesktopApp.Tauri) as DesktopApp.Tauri;
|
|
45
|
-
|
|
46
|
-
console.log("completeConfiguration", completeConfiguration);
|
|
47
|
-
|
|
48
|
-
await tauri("preview", url, options, completeConfiguration);
|
|
49
|
-
return;
|
|
50
|
-
},
|
|
51
|
-
);
|
package/src/public/tauri.webp
DELETED
|
Binary file
|
package/src/tauri.ts
DELETED
|
@@ -1,842 +0,0 @@
|
|
|
1
|
-
import { getBinName } from "@pipelab/constants";
|
|
2
|
-
import {
|
|
3
|
-
ActionRunnerData,
|
|
4
|
-
createAction,
|
|
5
|
-
createArray,
|
|
6
|
-
createBooleanParam,
|
|
7
|
-
createNumberParam,
|
|
8
|
-
createPathParam,
|
|
9
|
-
createStringParam,
|
|
10
|
-
detectRuntime,
|
|
11
|
-
InputsDefinition,
|
|
12
|
-
OutputsDefinition,
|
|
13
|
-
runPnpm,
|
|
14
|
-
runWithLiveLogs,
|
|
15
|
-
fetchPipelabAsset,
|
|
16
|
-
} from "@pipelab/plugin-core";
|
|
17
|
-
import { dirname, join, basename, delimiter } from "node:path";
|
|
18
|
-
import { existsSync, readFile, writeFile } from "node:fs";
|
|
19
|
-
import { cp, readFile as readFilePromise, writeFile as writeFilePromise } from "node:fs/promises";
|
|
20
|
-
import { homedir, platform as osPlatform, arch as osArch } from "node:os";
|
|
21
|
-
import { execa } from "execa";
|
|
22
|
-
import { kebabCase } from "change-case";
|
|
23
|
-
import { parseTOML, stringifyTOML } from "confbox";
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Searches for common cargo paths and resolves to a valid cargo executable path
|
|
27
|
-
* @returns The path to the cargo executable
|
|
28
|
-
* @throws Error if cargo cannot be found
|
|
29
|
-
*/
|
|
30
|
-
async function resolveCargoPath(): Promise<string> {
|
|
31
|
-
const cargoBinName = osPlatform() === "win32" ? "cargo.exe" : "cargo";
|
|
32
|
-
|
|
33
|
-
// Common cargo paths by platform
|
|
34
|
-
const commonPaths: string[] = [];
|
|
35
|
-
const currentPlatform = osPlatform();
|
|
36
|
-
|
|
37
|
-
// Helper function to add paths if they exist
|
|
38
|
-
const addIfExists = (path: string) => {
|
|
39
|
-
if (existsSync(path)) {
|
|
40
|
-
commonPaths.push(path);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const rustupHome = process.env.RUSTUP_HOME || join(homedir(), ".rustup");
|
|
45
|
-
const cargoHome = process.env.CARGO_HOME || join(homedir(), ".cargo");
|
|
46
|
-
|
|
47
|
-
if (currentPlatform === "win32") {
|
|
48
|
-
// Windows paths
|
|
49
|
-
addIfExists(
|
|
50
|
-
join(rustupHome, "toolchains", "stable-x86_64-pc-windows-msvc", "bin", cargoBinName),
|
|
51
|
-
);
|
|
52
|
-
addIfExists(
|
|
53
|
-
join(rustupHome, "toolchains", "nightly-x86_64-pc-windows-msvc", "bin", cargoBinName),
|
|
54
|
-
);
|
|
55
|
-
addIfExists(join(cargoHome, "bin", cargoBinName));
|
|
56
|
-
} else if (currentPlatform === "linux") {
|
|
57
|
-
// Linux paths
|
|
58
|
-
addIfExists(
|
|
59
|
-
join(rustupHome, "toolchains", "stable-x86_64-unknown-linux-gnu", "bin", cargoBinName),
|
|
60
|
-
);
|
|
61
|
-
addIfExists(
|
|
62
|
-
join(rustupHome, "toolchains", "nightly-x86_64-unknown-linux-gnu", "bin", cargoBinName),
|
|
63
|
-
);
|
|
64
|
-
addIfExists(join(cargoHome, "bin", cargoBinName));
|
|
65
|
-
addIfExists("/usr/bin/cargo");
|
|
66
|
-
addIfExists("/usr/local/bin/cargo");
|
|
67
|
-
} else if (currentPlatform === "darwin") {
|
|
68
|
-
// macOS paths
|
|
69
|
-
addIfExists(join(rustupHome, "toolchains", "stable-x86_64-apple-darwin", "bin", cargoBinName));
|
|
70
|
-
addIfExists(join(rustupHome, "toolchains", "nightly-x86_64-apple-darwin", "bin", cargoBinName));
|
|
71
|
-
addIfExists(join(cargoHome, "bin", cargoBinName));
|
|
72
|
-
addIfExists("/usr/local/bin/cargo");
|
|
73
|
-
addIfExists("/opt/homebrew/bin/cargo");
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Return first existing path found
|
|
77
|
-
if (commonPaths.length > 0) {
|
|
78
|
-
return commonPaths[0];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Fallback: try to find cargo using system tools on Unix systems
|
|
82
|
-
if (currentPlatform !== "win32") {
|
|
83
|
-
try {
|
|
84
|
-
const whichResult = await execa("which", ["cargo"]);
|
|
85
|
-
const cargoPath = whichResult.stdout.trim();
|
|
86
|
-
if (cargoPath && existsSync(cargoPath)) {
|
|
87
|
-
return cargoPath;
|
|
88
|
-
}
|
|
89
|
-
} catch {
|
|
90
|
-
// Ignore errors from which command
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
throw new Error("Cargo not found. Please install it first");
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// TODO: https://js.electronforge.io/modules/_electron_forge_core.html
|
|
98
|
-
|
|
99
|
-
export const IDMake = "tauri:make";
|
|
100
|
-
export const IDPackageV2 = "tauri:package:v2";
|
|
101
|
-
export const IDPreview = "tauri:preview";
|
|
102
|
-
|
|
103
|
-
const paramsInputFolder = {
|
|
104
|
-
"input-folder": createPathParam("", {
|
|
105
|
-
label: "Folder to package",
|
|
106
|
-
required: true,
|
|
107
|
-
control: {
|
|
108
|
-
type: "path",
|
|
109
|
-
options: {
|
|
110
|
-
properties: ["openDirectory"],
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
}),
|
|
114
|
-
} satisfies InputsDefinition;
|
|
115
|
-
|
|
116
|
-
const paramsInputURL = {
|
|
117
|
-
"input-url": createStringParam("", {
|
|
118
|
-
label: "URL to preview",
|
|
119
|
-
required: true,
|
|
120
|
-
}),
|
|
121
|
-
} satisfies InputsDefinition;
|
|
122
|
-
|
|
123
|
-
const params = {
|
|
124
|
-
arch: {
|
|
125
|
-
value: "" as NodeJS.Architecture | "", // MakeOptions['arch'],
|
|
126
|
-
label: "Architecture",
|
|
127
|
-
required: false,
|
|
128
|
-
control: {
|
|
129
|
-
type: "select",
|
|
130
|
-
options: {
|
|
131
|
-
placeholder: "Architecture",
|
|
132
|
-
options: [
|
|
133
|
-
{
|
|
134
|
-
label: "Older PCs (ia32)",
|
|
135
|
-
value: "ia32",
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
label: "Modern PCs (x64)",
|
|
139
|
-
value: "x64",
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
label: "Older Mobile/Pi (armv7l)",
|
|
143
|
-
value: "armv7l",
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
label: "New Mobile/Apple Silicon (arm64)",
|
|
147
|
-
value: "arm64",
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
label: "Mac Universal (universal)",
|
|
151
|
-
value: "universal",
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
label: "Special Systems (mips64el)",
|
|
155
|
-
value: "mips64el",
|
|
156
|
-
},
|
|
157
|
-
],
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
platform: {
|
|
162
|
-
value: "" as NodeJS.Platform | "", // MakeOptions['platform'],
|
|
163
|
-
label: "Platform",
|
|
164
|
-
required: false,
|
|
165
|
-
control: {
|
|
166
|
-
type: "select",
|
|
167
|
-
options: {
|
|
168
|
-
placeholder: "Platform",
|
|
169
|
-
options: [
|
|
170
|
-
{
|
|
171
|
-
label: "Windows (win32)",
|
|
172
|
-
value: "win32",
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
label: "macOS (darwin)",
|
|
176
|
-
value: "darwin",
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
label: "Linux (linux)",
|
|
180
|
-
value: "linux",
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
label: "Android",
|
|
184
|
-
value: "android",
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
label: "iOS",
|
|
188
|
-
value: "ios",
|
|
189
|
-
},
|
|
190
|
-
],
|
|
191
|
-
},
|
|
192
|
-
},
|
|
193
|
-
},
|
|
194
|
-
configuration: {
|
|
195
|
-
label: "Tauri configuration",
|
|
196
|
-
value: undefined as Partial<DesktopApp.Tauri> | undefined,
|
|
197
|
-
required: true,
|
|
198
|
-
control: {
|
|
199
|
-
type: "json",
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
} satisfies InputsDefinition;
|
|
203
|
-
|
|
204
|
-
export const configureParams = {
|
|
205
|
-
name: createStringParam("Pipelab", {
|
|
206
|
-
label: "Application name",
|
|
207
|
-
description: "The name of the application",
|
|
208
|
-
required: true,
|
|
209
|
-
}),
|
|
210
|
-
appBundleId: createStringParam("com.pipelab.app", {
|
|
211
|
-
label: "Application bundle ID",
|
|
212
|
-
description: "The bundle ID of the application",
|
|
213
|
-
required: true,
|
|
214
|
-
}),
|
|
215
|
-
appCopyright: createStringParam("Copyright © 2024 Pipelab", {
|
|
216
|
-
label: "Application copyright",
|
|
217
|
-
description: "The copyright of the application",
|
|
218
|
-
required: false,
|
|
219
|
-
}),
|
|
220
|
-
appVersion: createStringParam("1.0.0", {
|
|
221
|
-
label: "Application version",
|
|
222
|
-
description: "The version of the application",
|
|
223
|
-
required: true,
|
|
224
|
-
}),
|
|
225
|
-
icon: createPathParam("", {
|
|
226
|
-
label: "Application icon",
|
|
227
|
-
description: "The icon of the application. macOS: .icns. Windows: .ico",
|
|
228
|
-
required: false,
|
|
229
|
-
control: {
|
|
230
|
-
type: "path",
|
|
231
|
-
options: {
|
|
232
|
-
filters: [
|
|
233
|
-
{ name: "Image", extensions: ["png", "jpg", "jpeg", "gif", "bmp", "ico", "icns"] },
|
|
234
|
-
],
|
|
235
|
-
},
|
|
236
|
-
label: "Path to an image file",
|
|
237
|
-
},
|
|
238
|
-
}),
|
|
239
|
-
author: createStringParam("Pipelab", {
|
|
240
|
-
label: "Application author",
|
|
241
|
-
description: "The author of the application",
|
|
242
|
-
required: true,
|
|
243
|
-
}),
|
|
244
|
-
description: createStringParam("A simple Electron application", {
|
|
245
|
-
label: "Application description",
|
|
246
|
-
description: "The description of the application",
|
|
247
|
-
required: false,
|
|
248
|
-
}),
|
|
249
|
-
|
|
250
|
-
appCategoryType: createStringParam("public.app-category.developer-tools", {
|
|
251
|
-
platforms: ["darwin"],
|
|
252
|
-
label: "Application category type",
|
|
253
|
-
description: "The category type of the application",
|
|
254
|
-
required: false,
|
|
255
|
-
}),
|
|
256
|
-
|
|
257
|
-
// window
|
|
258
|
-
width: createNumberParam(800, {
|
|
259
|
-
label: "Window width",
|
|
260
|
-
description: "The width of the window",
|
|
261
|
-
required: false,
|
|
262
|
-
}),
|
|
263
|
-
height: createNumberParam(600, {
|
|
264
|
-
label: "Window height",
|
|
265
|
-
description: "The height of the window",
|
|
266
|
-
required: false,
|
|
267
|
-
}),
|
|
268
|
-
fullscreen: {
|
|
269
|
-
label: "Fullscreen",
|
|
270
|
-
value: false,
|
|
271
|
-
description: "Whether to start the application in fullscreen mode",
|
|
272
|
-
required: false,
|
|
273
|
-
control: {
|
|
274
|
-
type: "boolean",
|
|
275
|
-
},
|
|
276
|
-
},
|
|
277
|
-
frame: {
|
|
278
|
-
label: "Frame",
|
|
279
|
-
value: true,
|
|
280
|
-
description: "Whether to show the window frame",
|
|
281
|
-
required: false,
|
|
282
|
-
control: {
|
|
283
|
-
type: "boolean",
|
|
284
|
-
},
|
|
285
|
-
},
|
|
286
|
-
transparent: {
|
|
287
|
-
label: "Transparent",
|
|
288
|
-
value: false,
|
|
289
|
-
description: "Whether to make the window transparent",
|
|
290
|
-
required: false,
|
|
291
|
-
control: {
|
|
292
|
-
type: "boolean",
|
|
293
|
-
},
|
|
294
|
-
},
|
|
295
|
-
toolbar: {
|
|
296
|
-
label: "Toolbar",
|
|
297
|
-
value: true,
|
|
298
|
-
description: "Whether to show the toolbar",
|
|
299
|
-
required: false,
|
|
300
|
-
control: {
|
|
301
|
-
type: "boolean",
|
|
302
|
-
},
|
|
303
|
-
},
|
|
304
|
-
alwaysOnTop: {
|
|
305
|
-
label: "Always on top",
|
|
306
|
-
value: false,
|
|
307
|
-
description: "Whether to always keep the window on top",
|
|
308
|
-
required: false,
|
|
309
|
-
control: {
|
|
310
|
-
type: "boolean",
|
|
311
|
-
},
|
|
312
|
-
},
|
|
313
|
-
|
|
314
|
-
tauriVersion: createStringParam("", {
|
|
315
|
-
label: "Tauri version",
|
|
316
|
-
description:
|
|
317
|
-
"The version of Tauri to use. If no version specified, it will use the latest one.",
|
|
318
|
-
required: false,
|
|
319
|
-
}),
|
|
320
|
-
enableExtraLogging: {
|
|
321
|
-
required: false,
|
|
322
|
-
label: "Enable extra logging",
|
|
323
|
-
value: false,
|
|
324
|
-
control: {
|
|
325
|
-
type: "boolean",
|
|
326
|
-
},
|
|
327
|
-
description: "Whether to enable extra logging of internal tools while bundling",
|
|
328
|
-
},
|
|
329
|
-
openDevtoolsOnStart: createBooleanParam(false, {
|
|
330
|
-
label: "Open devtools on app start",
|
|
331
|
-
required: false,
|
|
332
|
-
description: "Whether to open devtools on app start",
|
|
333
|
-
}),
|
|
334
|
-
|
|
335
|
-
// websocket apis
|
|
336
|
-
websocketApi: {
|
|
337
|
-
required: false,
|
|
338
|
-
label: "WebSocket APIs to allow (empty = all)",
|
|
339
|
-
value: "[]",
|
|
340
|
-
control: {
|
|
341
|
-
type: "array",
|
|
342
|
-
options: {
|
|
343
|
-
kind: "text",
|
|
344
|
-
},
|
|
345
|
-
},
|
|
346
|
-
},
|
|
347
|
-
ignore: createArray<(string | RegExp)[]>(
|
|
348
|
-
`[
|
|
349
|
-
// use 'src/app/' as starting point
|
|
350
|
-
]`,
|
|
351
|
-
{
|
|
352
|
-
required: false,
|
|
353
|
-
label: "Folders to ignore",
|
|
354
|
-
description:
|
|
355
|
-
"An array of string or Regex that allow ignoring certain files or folders from being packaged",
|
|
356
|
-
control: {
|
|
357
|
-
type: "array",
|
|
358
|
-
options: {
|
|
359
|
-
kind: "text",
|
|
360
|
-
},
|
|
361
|
-
},
|
|
362
|
-
},
|
|
363
|
-
),
|
|
364
|
-
|
|
365
|
-
// integrations
|
|
366
|
-
|
|
367
|
-
enableSteamSupport: {
|
|
368
|
-
required: false,
|
|
369
|
-
label: "Enable steam support",
|
|
370
|
-
description: "Whether to enable Steam support",
|
|
371
|
-
value: false,
|
|
372
|
-
control: {
|
|
373
|
-
type: "boolean",
|
|
374
|
-
},
|
|
375
|
-
},
|
|
376
|
-
steamGameId: createNumberParam(480, {
|
|
377
|
-
required: false,
|
|
378
|
-
label: "Steam game ID",
|
|
379
|
-
description: "The Steam game ID",
|
|
380
|
-
}),
|
|
381
|
-
enableDiscordSupport: {
|
|
382
|
-
required: false,
|
|
383
|
-
label: "Enable Discord support",
|
|
384
|
-
description: "Whether to enable Discord support",
|
|
385
|
-
value: false,
|
|
386
|
-
control: {
|
|
387
|
-
type: "boolean",
|
|
388
|
-
},
|
|
389
|
-
},
|
|
390
|
-
discordAppId: createStringParam("", {
|
|
391
|
-
required: false,
|
|
392
|
-
label: "Discord application ID",
|
|
393
|
-
description: "The Discord application ID",
|
|
394
|
-
}),
|
|
395
|
-
} satisfies InputsDefinition;
|
|
396
|
-
|
|
397
|
-
const outputs = {
|
|
398
|
-
output: {
|
|
399
|
-
label: "Output",
|
|
400
|
-
value: "",
|
|
401
|
-
control: {
|
|
402
|
-
type: "path",
|
|
403
|
-
options: {
|
|
404
|
-
properties: ["openDirectory"],
|
|
405
|
-
},
|
|
406
|
-
},
|
|
407
|
-
},
|
|
408
|
-
binary: {
|
|
409
|
-
label: "Binary",
|
|
410
|
-
value: "",
|
|
411
|
-
control: {
|
|
412
|
-
type: "path",
|
|
413
|
-
options: {
|
|
414
|
-
properties: ["openFile"],
|
|
415
|
-
},
|
|
416
|
-
},
|
|
417
|
-
},
|
|
418
|
-
} satisfies OutputsDefinition;
|
|
419
|
-
|
|
420
|
-
// type Inputs = ParamsToInput<typeof params>
|
|
421
|
-
|
|
422
|
-
export const createMakeProps = (
|
|
423
|
-
id: string,
|
|
424
|
-
name: string,
|
|
425
|
-
description: string,
|
|
426
|
-
icon: string,
|
|
427
|
-
displayString: string,
|
|
428
|
-
) =>
|
|
429
|
-
createAction({
|
|
430
|
-
id,
|
|
431
|
-
name,
|
|
432
|
-
description,
|
|
433
|
-
icon,
|
|
434
|
-
displayString,
|
|
435
|
-
meta: {},
|
|
436
|
-
params: {
|
|
437
|
-
...params,
|
|
438
|
-
...paramsInputFolder,
|
|
439
|
-
},
|
|
440
|
-
outputs,
|
|
441
|
-
});
|
|
442
|
-
|
|
443
|
-
export const createPackageV2Props = (
|
|
444
|
-
id: string,
|
|
445
|
-
name: string,
|
|
446
|
-
description: string,
|
|
447
|
-
icon: string,
|
|
448
|
-
displayString: string,
|
|
449
|
-
advanced?: boolean,
|
|
450
|
-
deprecated?: boolean,
|
|
451
|
-
deprecatedMessage?: string,
|
|
452
|
-
disabled?: false,
|
|
453
|
-
updateAvailable?: boolean,
|
|
454
|
-
) => {
|
|
455
|
-
const { arch, platform } = params;
|
|
456
|
-
return createAction({
|
|
457
|
-
id,
|
|
458
|
-
name,
|
|
459
|
-
description,
|
|
460
|
-
icon,
|
|
461
|
-
displayString,
|
|
462
|
-
meta: {},
|
|
463
|
-
advanced,
|
|
464
|
-
deprecated,
|
|
465
|
-
deprecatedMessage,
|
|
466
|
-
disabled,
|
|
467
|
-
updateAvailable,
|
|
468
|
-
params: {
|
|
469
|
-
arch,
|
|
470
|
-
platform,
|
|
471
|
-
...paramsInputFolder,
|
|
472
|
-
...configureParams,
|
|
473
|
-
},
|
|
474
|
-
outputs: outputs,
|
|
475
|
-
});
|
|
476
|
-
};
|
|
477
|
-
|
|
478
|
-
export const createPreviewProps = (
|
|
479
|
-
id: string,
|
|
480
|
-
name: string,
|
|
481
|
-
description: string,
|
|
482
|
-
icon: string,
|
|
483
|
-
displayString: string,
|
|
484
|
-
) =>
|
|
485
|
-
createAction({
|
|
486
|
-
id,
|
|
487
|
-
name,
|
|
488
|
-
description,
|
|
489
|
-
icon,
|
|
490
|
-
displayString,
|
|
491
|
-
meta: {},
|
|
492
|
-
params: {
|
|
493
|
-
...params,
|
|
494
|
-
...paramsInputURL,
|
|
495
|
-
},
|
|
496
|
-
outputs: outputs,
|
|
497
|
-
});
|
|
498
|
-
|
|
499
|
-
export const tauri = async (
|
|
500
|
-
action: "make" | "package" | "preview",
|
|
501
|
-
appFolder: string | undefined,
|
|
502
|
-
{
|
|
503
|
-
cwd,
|
|
504
|
-
log,
|
|
505
|
-
inputs,
|
|
506
|
-
setOutput,
|
|
507
|
-
paths,
|
|
508
|
-
abortSignal,
|
|
509
|
-
context,
|
|
510
|
-
}: ActionRunnerData<ReturnType<typeof createPackageV2Props>>,
|
|
511
|
-
completeConfiguration: DesktopApp.Config,
|
|
512
|
-
): Promise<{ folder: string; binary: string | undefined } | undefined> => {
|
|
513
|
-
console.log("appFolder", appFolder);
|
|
514
|
-
|
|
515
|
-
log("Building tauri");
|
|
516
|
-
|
|
517
|
-
if (action !== "preview") {
|
|
518
|
-
await detectRuntime(appFolder);
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
const { modules, cache, node } = paths;
|
|
522
|
-
|
|
523
|
-
const destinationFolder = join(cwd, "build");
|
|
524
|
-
|
|
525
|
-
const rawAssetFolder = await fetchPipelabAsset("@pipelab/asset-tauri", "^1.0.0", { context });
|
|
526
|
-
const templateFolder = join(rawAssetFolder, "template");
|
|
527
|
-
|
|
528
|
-
// copy template to destination
|
|
529
|
-
await cp(templateFolder, destinationFolder, {
|
|
530
|
-
recursive: true,
|
|
531
|
-
filter: (src) => {
|
|
532
|
-
// log('src', src)
|
|
533
|
-
// log('dest', dest)
|
|
534
|
-
// TODO: support other oses
|
|
535
|
-
return (
|
|
536
|
-
basename(src) !== "node_modules" &&
|
|
537
|
-
!src.includes("src-tauri\\target") &&
|
|
538
|
-
!src.includes("src-tauri\\gen")
|
|
539
|
-
);
|
|
540
|
-
},
|
|
541
|
-
});
|
|
542
|
-
|
|
543
|
-
const placeAppFolder = join(destinationFolder, "src", "app");
|
|
544
|
-
|
|
545
|
-
// if input is folder, copy folder to destination
|
|
546
|
-
if (appFolder && action !== "preview") {
|
|
547
|
-
// copy app to template
|
|
548
|
-
await cp(appFolder, placeAppFolder, { recursive: true });
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
writeFilePromise(
|
|
552
|
-
join(destinationFolder, "config.cjs"),
|
|
553
|
-
`module.exports = ${JSON.stringify(completeConfiguration, undefined, 2)}`,
|
|
554
|
-
"utf8",
|
|
555
|
-
);
|
|
556
|
-
|
|
557
|
-
const sanitizedName = kebabCase(completeConfiguration.name);
|
|
558
|
-
|
|
559
|
-
// package.json update
|
|
560
|
-
log("Package.json update");
|
|
561
|
-
const pkgJSONPath = join(destinationFolder, "package.json");
|
|
562
|
-
const pkgJSONContent = await readFile(pkgJSONPath, "utf8");
|
|
563
|
-
const pkgJSON = JSON.parse(pkgJSONContent);
|
|
564
|
-
log("Setting name to", sanitizedName);
|
|
565
|
-
pkgJSON.name = sanitizedName;
|
|
566
|
-
log("Setting productName to", completeConfiguration.name);
|
|
567
|
-
pkgJSON.productName = completeConfiguration.name;
|
|
568
|
-
await writeFile(pkgJSONPath, JSON.stringify(pkgJSON, null, 2));
|
|
569
|
-
|
|
570
|
-
// Cargo.toml update
|
|
571
|
-
log("Cargo.toml update");
|
|
572
|
-
const cargoTomlPath = join(destinationFolder, "src-tauri", "Cargo.toml");
|
|
573
|
-
const cargoTomlContent = await readFilePromise(cargoTomlPath, "utf8");
|
|
574
|
-
const cargoToml = parseTOML(cargoTomlContent) as { name: string; version: string };
|
|
575
|
-
log("Setting name to", sanitizedName);
|
|
576
|
-
console.log("cargoToml", cargoToml);
|
|
577
|
-
cargoToml.name = sanitizedName;
|
|
578
|
-
log("Setting version to", completeConfiguration.appVersion);
|
|
579
|
-
cargoToml.version = completeConfiguration.appVersion;
|
|
580
|
-
console.log("cargoToml", stringifyTOML(cargoToml));
|
|
581
|
-
await writeFilePromise(cargoTomlPath, stringifyTOML(cargoToml));
|
|
582
|
-
|
|
583
|
-
// tauri.conf.json update
|
|
584
|
-
log("Tauri.conf.json update");
|
|
585
|
-
const tauriConfJSONPath = join(destinationFolder, "src-tauri", "tauri.conf.json");
|
|
586
|
-
const tauriConfJSONContent = await readFile(tauriConfJSONPath, "utf8");
|
|
587
|
-
const tauriConfJSON = JSON.parse(tauriConfJSONContent);
|
|
588
|
-
log("Setting productName to", completeConfiguration.name);
|
|
589
|
-
tauriConfJSON.productName = completeConfiguration.name;
|
|
590
|
-
log("Setting version to", completeConfiguration.appVersion);
|
|
591
|
-
tauriConfJSON.version = completeConfiguration.appVersion;
|
|
592
|
-
log("Setting identifier to", completeConfiguration.appBundleId);
|
|
593
|
-
tauriConfJSON.identifier = completeConfiguration.appBundleId;
|
|
594
|
-
if (action === "preview") {
|
|
595
|
-
log("Setting build.devUrl to", appFolder);
|
|
596
|
-
tauriConfJSON.build.devUrl = appFolder;
|
|
597
|
-
await writeFilePromise(tauriConfJSONPath, JSON.stringify(tauriConfJSON, null, 2));
|
|
598
|
-
}
|
|
599
|
-
/* else {
|
|
600
|
-
log('Setting build.frontendDist to', appFolder)
|
|
601
|
-
tauriConfJSON.build.frontendDist = appFolder
|
|
602
|
-
await writeFile(tauriConfJSONPath, JSON.stringify(tauriConfJSON, null, 2))
|
|
603
|
-
} */
|
|
604
|
-
|
|
605
|
-
log("Installing packages");
|
|
606
|
-
const { all } = await runPnpm(destinationFolder, {
|
|
607
|
-
signal: abortSignal,
|
|
608
|
-
context,
|
|
609
|
-
});
|
|
610
|
-
if (all) log(all);
|
|
611
|
-
|
|
612
|
-
// override tauri version
|
|
613
|
-
// if (completeConfiguration.electronVersion && completeConfiguration.electronVersion !== '') {
|
|
614
|
-
// log(`Installing tauri@${completeConfiguration.electronVersion}`)
|
|
615
|
-
// await runWithLiveLogs(
|
|
616
|
-
// process.execPath,
|
|
617
|
-
// [pnpm, 'install', `tauri@${completeConfiguration.electronVersion}`, '--prefer-offline'],
|
|
618
|
-
// {
|
|
619
|
-
// cwd: destinationFolder,
|
|
620
|
-
// env: {
|
|
621
|
-
// // DEBUG: '*',
|
|
622
|
-
// PATH: `${dirname(node)}${delimiter}${process.env.PATH}`,
|
|
623
|
-
// PNPM_HOME: pnpmHome
|
|
624
|
-
// },
|
|
625
|
-
// cancelSignal: abortSignal
|
|
626
|
-
// },
|
|
627
|
-
// log,
|
|
628
|
-
// {
|
|
629
|
-
// onStderr(data) {
|
|
630
|
-
// log(data)
|
|
631
|
-
// },
|
|
632
|
-
// onStdout(data) {
|
|
633
|
-
// log(data)
|
|
634
|
-
// }
|
|
635
|
-
// }
|
|
636
|
-
// )
|
|
637
|
-
// }
|
|
638
|
-
|
|
639
|
-
const inputPlatform = inputs.platform === "" ? undefined : inputs.platform;
|
|
640
|
-
const inputArch = inputs.arch === "" ? undefined : inputs.arch;
|
|
641
|
-
|
|
642
|
-
try {
|
|
643
|
-
log("typeof inputs.platform", typeof inputs.platform);
|
|
644
|
-
const finalPlatform: NodeJS.Platform = inputPlatform ?? osPlatform();
|
|
645
|
-
log("finalPlatform", finalPlatform);
|
|
646
|
-
const finalArch: NodeJS.Architecture = inputArch ?? (osArch() as NodeJS.Architecture);
|
|
647
|
-
log("finalArch", finalArch);
|
|
648
|
-
|
|
649
|
-
let tauriPlatform = "";
|
|
650
|
-
if (finalPlatform === "win32") {
|
|
651
|
-
tauriPlatform = "pc-windows-msvc";
|
|
652
|
-
} else if (finalPlatform === "linux") {
|
|
653
|
-
tauriPlatform = "unknown-linux-gnu";
|
|
654
|
-
} else {
|
|
655
|
-
throw new Error("Unsupported platform");
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
let tauriArch = "";
|
|
659
|
-
if (finalArch === "x64") {
|
|
660
|
-
tauriArch = "x86_64";
|
|
661
|
-
} else {
|
|
662
|
-
throw new Error("Unsupported arch");
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
const target = `${tauriArch}-${tauriPlatform}`;
|
|
666
|
-
|
|
667
|
-
// Resolve cargo path using the new function
|
|
668
|
-
const cargo = await resolveCargoPath();
|
|
669
|
-
const cargoBinDir = dirname(cargo);
|
|
670
|
-
|
|
671
|
-
log("cargoBinDir", cargoBinDir);
|
|
672
|
-
console.log("cargo", cargo);
|
|
673
|
-
|
|
674
|
-
log("destinationFolder", destinationFolder);
|
|
675
|
-
|
|
676
|
-
const cargoTargetDir = join(cache, "cargo", "target", completeConfiguration.appBundleId);
|
|
677
|
-
const cargoOutputPath = join(cargoTargetDir, target, "release");
|
|
678
|
-
|
|
679
|
-
log("cargoTargetDir", cargoTargetDir);
|
|
680
|
-
log("cargoOutputPath", cargoOutputPath);
|
|
681
|
-
|
|
682
|
-
log("Starting compiling");
|
|
683
|
-
|
|
684
|
-
// by default add the tauri cli
|
|
685
|
-
await runWithLiveLogs(
|
|
686
|
-
cargo,
|
|
687
|
-
["install", "tauri-cli", "--version", "^2.0.0", "--locked"],
|
|
688
|
-
{
|
|
689
|
-
cwd: join(destinationFolder, "src-tauri"),
|
|
690
|
-
env: {
|
|
691
|
-
...process.env,
|
|
692
|
-
DEBUG: completeConfiguration.enableExtraLogging ? "*" : "",
|
|
693
|
-
ELECTRON_NO_ASAR: "1",
|
|
694
|
-
CARGO_TARGET_DIR: cargoTargetDir,
|
|
695
|
-
PATH: `${cargoBinDir}${delimiter}${dirname(node)}${delimiter}${process.env.PATH}`,
|
|
696
|
-
},
|
|
697
|
-
cancelSignal: abortSignal,
|
|
698
|
-
},
|
|
699
|
-
log,
|
|
700
|
-
{
|
|
701
|
-
onStderr(data) {
|
|
702
|
-
// on ci, do not log
|
|
703
|
-
if (!process.env.CI) {
|
|
704
|
-
log(data);
|
|
705
|
-
}
|
|
706
|
-
},
|
|
707
|
-
onStdout(data) {
|
|
708
|
-
// on ci, do not log
|
|
709
|
-
if (!process.env.CI) {
|
|
710
|
-
log(data);
|
|
711
|
-
}
|
|
712
|
-
},
|
|
713
|
-
},
|
|
714
|
-
);
|
|
715
|
-
|
|
716
|
-
// if preview, run tauri dev
|
|
717
|
-
if (action === "preview") {
|
|
718
|
-
await runWithLiveLogs(
|
|
719
|
-
cargo,
|
|
720
|
-
["tauri", "dev", "--target", target],
|
|
721
|
-
{
|
|
722
|
-
cwd: join(destinationFolder, "src-tauri"),
|
|
723
|
-
env: {
|
|
724
|
-
...process.env,
|
|
725
|
-
DEBUG: completeConfiguration.enableExtraLogging ? "*" : "",
|
|
726
|
-
ELECTRON_NO_ASAR: "1",
|
|
727
|
-
CARGO_TARGET_DIR: cargoTargetDir,
|
|
728
|
-
PATH: `${cargoBinDir}${delimiter}${dirname(node)}${delimiter}${process.env.PATH}`,
|
|
729
|
-
},
|
|
730
|
-
cancelSignal: abortSignal,
|
|
731
|
-
},
|
|
732
|
-
log,
|
|
733
|
-
{
|
|
734
|
-
onStderr(data) {
|
|
735
|
-
log(data);
|
|
736
|
-
},
|
|
737
|
-
onStdout(data) {
|
|
738
|
-
log(data);
|
|
739
|
-
},
|
|
740
|
-
},
|
|
741
|
-
);
|
|
742
|
-
} else {
|
|
743
|
-
// otherwise build, but don't bundle
|
|
744
|
-
await runWithLiveLogs(
|
|
745
|
-
cargo,
|
|
746
|
-
["tauri", "build", "--target", target, "--no-bundle"],
|
|
747
|
-
{
|
|
748
|
-
cwd: join(destinationFolder, "src-tauri"),
|
|
749
|
-
env: {
|
|
750
|
-
...process.env,
|
|
751
|
-
DEBUG: completeConfiguration.enableExtraLogging ? "*" : "",
|
|
752
|
-
ELECTRON_NO_ASAR: "1",
|
|
753
|
-
CARGO_TARGET_DIR: cargoTargetDir,
|
|
754
|
-
PATH: `${cargoBinDir}${delimiter}${dirname(node)}${delimiter}${process.env.PATH}`,
|
|
755
|
-
},
|
|
756
|
-
cancelSignal: abortSignal,
|
|
757
|
-
},
|
|
758
|
-
log,
|
|
759
|
-
{
|
|
760
|
-
onStderr(data) {
|
|
761
|
-
// on ci, do not log
|
|
762
|
-
if (!process.env.CI) {
|
|
763
|
-
log(data);
|
|
764
|
-
}
|
|
765
|
-
},
|
|
766
|
-
onStdout(data) {
|
|
767
|
-
// on ci, do not log
|
|
768
|
-
if (!process.env.CI) {
|
|
769
|
-
log(data);
|
|
770
|
-
}
|
|
771
|
-
},
|
|
772
|
-
},
|
|
773
|
-
);
|
|
774
|
-
|
|
775
|
-
// if make, bundle
|
|
776
|
-
if (action === "make") {
|
|
777
|
-
await runWithLiveLogs(
|
|
778
|
-
cargo,
|
|
779
|
-
// TODO: https://v2.tauri.app/fr/distribute/#bundling
|
|
780
|
-
["tauri", "bundle", "--", "--bundles", "appimage"],
|
|
781
|
-
{
|
|
782
|
-
cwd: join(destinationFolder, "src-tauri"),
|
|
783
|
-
env: {
|
|
784
|
-
DEBUG: completeConfiguration.enableExtraLogging ? "*" : "",
|
|
785
|
-
ELECTRON_NO_ASAR: "1",
|
|
786
|
-
CARGO_TARGET_DIR: cargoTargetDir,
|
|
787
|
-
PATH: `${cargoBinDir}${delimiter}${dirname(node)}${delimiter}${process.env.PATH}`,
|
|
788
|
-
},
|
|
789
|
-
cancelSignal: abortSignal,
|
|
790
|
-
},
|
|
791
|
-
log,
|
|
792
|
-
{
|
|
793
|
-
onStderr(data) {
|
|
794
|
-
log(data);
|
|
795
|
-
},
|
|
796
|
-
onStdout(data) {
|
|
797
|
-
log(data);
|
|
798
|
-
},
|
|
799
|
-
},
|
|
800
|
-
);
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
if (action === "package") {
|
|
805
|
-
const binName = getBinName(sanitizedName);
|
|
806
|
-
|
|
807
|
-
log("cargoOutputPath", cargoOutputPath);
|
|
808
|
-
|
|
809
|
-
setOutput("output", cargoOutputPath);
|
|
810
|
-
setOutput("binary", join(cargoOutputPath, binName));
|
|
811
|
-
return {
|
|
812
|
-
folder: cargoOutputPath,
|
|
813
|
-
binary: join(cargoOutputPath, binName),
|
|
814
|
-
};
|
|
815
|
-
} else if (action === "make") {
|
|
816
|
-
// TODO:
|
|
817
|
-
throw new Error("Unsupported action");
|
|
818
|
-
} else if (action === "preview") {
|
|
819
|
-
// continue
|
|
820
|
-
} else {
|
|
821
|
-
throw new Error("Unsupported action");
|
|
822
|
-
// const output = join(destinationFolder, 'out', 'make')
|
|
823
|
-
// setOutput('output', output)
|
|
824
|
-
// return {
|
|
825
|
-
// folder: output,
|
|
826
|
-
// binary: undefined
|
|
827
|
-
// }
|
|
828
|
-
}
|
|
829
|
-
} catch (e) {
|
|
830
|
-
if (e instanceof Error) {
|
|
831
|
-
if (e.name === "RequestError") {
|
|
832
|
-
log("Request error");
|
|
833
|
-
}
|
|
834
|
-
if (e.name === "RequestError") {
|
|
835
|
-
log("Request error");
|
|
836
|
-
}
|
|
837
|
-
throw e;
|
|
838
|
-
}
|
|
839
|
-
log(e);
|
|
840
|
-
return undefined;
|
|
841
|
-
}
|
|
842
|
-
};
|
package/src/utils.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export const defaultTauriConfig = {
|
|
2
|
-
alwaysOnTop: false,
|
|
3
|
-
appBundleId: "com.pipelab.app",
|
|
4
|
-
appCategoryType: "",
|
|
5
|
-
appCopyright: "Copyright © 2024 Pipelab",
|
|
6
|
-
appVersion: "1.0.0",
|
|
7
|
-
author: "Pipelab",
|
|
8
|
-
description: "A simple Electron application",
|
|
9
|
-
tauriVersion: "",
|
|
10
|
-
enableExtraLogging: false,
|
|
11
|
-
clearServiceWorkerOnBoot: false,
|
|
12
|
-
frame: true,
|
|
13
|
-
fullscreen: false,
|
|
14
|
-
icon: "",
|
|
15
|
-
height: 600,
|
|
16
|
-
name: "Pipelab",
|
|
17
|
-
toolbar: true,
|
|
18
|
-
transparent: false,
|
|
19
|
-
width: 800,
|
|
20
|
-
enableSteamSupport: false,
|
|
21
|
-
steamGameId: 480,
|
|
22
|
-
enableDiscordSupport: false,
|
|
23
|
-
discordAppId: "",
|
|
24
|
-
ignore: [] as string[],
|
|
25
|
-
backgroundColor: "#FFF",
|
|
26
|
-
openDevtoolsOnStart: false,
|
|
27
|
-
} satisfies DesktopApp.Tauri;
|
package/tsconfig.json
DELETED
package/tsdown.config.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "tsdown";
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
entry: ["src/index.ts"],
|
|
5
|
-
format: ["esm", "cjs"],
|
|
6
|
-
dts: true,
|
|
7
|
-
clean: true,
|
|
8
|
-
loader: {
|
|
9
|
-
".webp": "dataurl",
|
|
10
|
-
".png": "dataurl",
|
|
11
|
-
".jpg": "dataurl",
|
|
12
|
-
".jpeg": "dataurl",
|
|
13
|
-
".svg": "dataurl",
|
|
14
|
-
},
|
|
15
|
-
});
|