@lakutata/builder 3.0.0-beta.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.
- package/LICENSE +23 -0
- package/README.md +27 -0
- package/dist/esm/index.js +13 -0
- package/dist/esm/lib/Archive.js +21 -0
- package/dist/esm/lib/Bundle.js +162 -0
- package/dist/esm/lib/Executable.js +221 -0
- package/dist/esm/lib/Icons.js +372 -0
- package/dist/esm/lib/Installer.js +158 -0
- package/dist/esm/lib/Native.js +533 -0
- package/dist/esm/lib/NativeRuntime.js +177 -0
- package/dist/esm/lib/Platform.js +9 -0
- package/dist/esm/lib/Processes.js +42 -0
- package/dist/esm/lib/Scripts.js +161 -0
- package/dist/esm/lib/Tools.js +109 -0
- package/dist/esm/lib/electron/Electron.js +366 -0
- package/dist/esm/lib/linux/Linux.js +361 -0
- package/dist/esm/lib/mac/Mac.js +270 -0
- package/dist/esm/lib/win/Windows.js +525 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/lib/Archive.d.ts +14 -0
- package/dist/types/lib/Bundle.d.ts +96 -0
- package/dist/types/lib/Executable.d.ts +50 -0
- package/dist/types/lib/Icons.d.ts +70 -0
- package/dist/types/lib/Installer.d.ts +242 -0
- package/dist/types/lib/Native.d.ts +196 -0
- package/dist/types/lib/NativeRuntime.d.ts +75 -0
- package/dist/types/lib/Platform.d.ts +4 -0
- package/dist/types/lib/Processes.d.ts +21 -0
- package/dist/types/lib/Scripts.d.ts +77 -0
- package/dist/types/lib/Tools.d.ts +32 -0
- package/dist/types/lib/electron/Electron.d.ts +13 -0
- package/dist/types/lib/linux/Linux.d.ts +29 -0
- package/dist/types/lib/mac/Mac.d.ts +19 -0
- package/dist/types/lib/win/Windows.d.ts +20 -0
- package/package.json +51 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The moments of the installers the scripts of the applications are run at, the same on every system: before and after
|
|
3
|
+
* the installation (and the upgrades), before and after the removal (not the one of an upgrade)
|
|
4
|
+
*/
|
|
5
|
+
export declare const INSTALLER_HOOKS: readonly ["preinstall", "postinstall", "preremove", "postremove"];
|
|
6
|
+
export type InstallerHook = typeof INSTALLER_HOOKS[number];
|
|
7
|
+
/**
|
|
8
|
+
* The scripts of an application run by its installers (files of its project): the ones of Linux and macOS are run by
|
|
9
|
+
* the interpreter of their first line (#!/bin/sh by default), the ones of Windows are scripts of PowerShell (.ps1). They
|
|
10
|
+
* are given what the installer does: install, upgrade (preinstall and postinstall) or remove (preremove and
|
|
11
|
+
* postremove), and the directory of the application (LAKUTATA_INSTALL_DIR)
|
|
12
|
+
*/
|
|
13
|
+
export type InstallerScripts = Partial<Record<InstallerHook, string>>;
|
|
14
|
+
/**
|
|
15
|
+
* The scripts of the packages of Linux, as nFPM runs them: the ones of each package, given its own arguments (the ones
|
|
16
|
+
* of dpkg, of rpm, of apk, of pacman); the upgrades of apk and pacman have their own ones
|
|
17
|
+
*/
|
|
18
|
+
export declare const NATIVE_HOOKS: readonly ["preinstall", "postinstall", "preremove", "postremove", "preupgrade", "postupgrade"];
|
|
19
|
+
export type NativeHook = typeof NATIVE_HOOKS[number];
|
|
20
|
+
export type NativeScripts = Partial<Record<NativeHook, string>>;
|
|
21
|
+
/**
|
|
22
|
+
* A script of the application, read from its project
|
|
23
|
+
*/
|
|
24
|
+
export type ScriptFile = {
|
|
25
|
+
/**
|
|
26
|
+
* Its path, from the project
|
|
27
|
+
*/
|
|
28
|
+
file: string;
|
|
29
|
+
content: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The scripts of an installer: the ones of the moments (the ones of its platform, the ones of the installer replacing
|
|
33
|
+
* them), the native ones of the packages of Linux, the file of NSIS it includes
|
|
34
|
+
*/
|
|
35
|
+
export type TargetScripts = {
|
|
36
|
+
hooks: Partial<Record<InstallerHook, ScriptFile>>;
|
|
37
|
+
native: Partial<Record<NativeHook, ScriptFile>>;
|
|
38
|
+
include?: ScriptFile;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* The scripts of the platform and of its installers, as configured (lakutata.installer.<platform>)
|
|
42
|
+
*/
|
|
43
|
+
export type PlatformScripts = {
|
|
44
|
+
scripts?: InstallerScripts;
|
|
45
|
+
[target: string]: unknown;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* The scripts of the installers made on a platform: the ones of the platform (lakutata.installer.<platform>.scripts),
|
|
49
|
+
* replaced by the ones of each installer (lakutata.installer.<platform>.<installer>.scripts), the native ones of the
|
|
50
|
+
* packages of Linux (nativeScripts), the file of NSIS included by its installer (win.nsis.include). The ones an
|
|
51
|
+
* installer does not run are told (warnings)
|
|
52
|
+
* @param project
|
|
53
|
+
* @param platform its name in the configuration: linux, mac or win
|
|
54
|
+
* @param config its configuration
|
|
55
|
+
* @param targets the installers made
|
|
56
|
+
* @param warnings
|
|
57
|
+
* @param hooks the moments each installer runs the scripts at (the installers of lakutata by default)
|
|
58
|
+
* @param native whether the packages of Linux run native scripts (the ones of lakutata)
|
|
59
|
+
*/
|
|
60
|
+
export declare function resolveScripts(project: string, platform: 'linux' | 'mac' | 'win', config: PlatformScripts | undefined, targets: string[], warnings: string[], hooks?: (target: string) => readonly InstallerHook[], native?: boolean): Record<string, TargetScripts>;
|
|
61
|
+
/**
|
|
62
|
+
* The lines of sh running a script embedded in them (the scripts run before the files of the application are installed,
|
|
63
|
+
* or after they are removed): written to a temporary file, run by the interpreter of its first line (a temporary file
|
|
64
|
+
* system may not run its files), its failure the one of the script running it
|
|
65
|
+
* @param script
|
|
66
|
+
* @param prefix the directory of the application (LAKUTATA_INSTALL_DIR)
|
|
67
|
+
* @param args the arguments given to it (sh)
|
|
68
|
+
*/
|
|
69
|
+
export declare function embeddedShell(script: ScriptFile, prefix: string, args: string): string[];
|
|
70
|
+
/**
|
|
71
|
+
* The lines of sh running a script encoded in them (base64): the scripts of the packages of electron-builder are
|
|
72
|
+
* templates, which replace their ${...}
|
|
73
|
+
* @param script
|
|
74
|
+
* @param prefix the directory of the application (LAKUTATA_INSTALL_DIR)
|
|
75
|
+
* @param args the arguments given to it (sh)
|
|
76
|
+
*/
|
|
77
|
+
export declare function encodedShell(script: ScriptFile, prefix: string, args: string): string[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tool the builder downloads (as electron-builder downloads its tools): its version, and the archives of its releases
|
|
3
|
+
* by platform with their sha256, written here (the checksums are not downloaded with the archives)
|
|
4
|
+
*/
|
|
5
|
+
type Tool = {
|
|
6
|
+
version: string;
|
|
7
|
+
/**
|
|
8
|
+
* The executable, in the archive (its path, "/" separated), or the file downloaded
|
|
9
|
+
*/
|
|
10
|
+
executable: string;
|
|
11
|
+
url: (archive: string) => string;
|
|
12
|
+
archives: Record<string, {
|
|
13
|
+
archive: string;
|
|
14
|
+
sha256: string;
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The tools of the builder
|
|
19
|
+
*/
|
|
20
|
+
declare const TOOLS: Record<'nfpm' | 'winsw' | 'nsis' | 'wix', Tool>;
|
|
21
|
+
/**
|
|
22
|
+
* The directory of the cache of lakutata (the one of its tool): LAKUTATA_CACHE_DIR, else ~/.cache/lakutata
|
|
23
|
+
*/
|
|
24
|
+
export declare function cacheDirectory(): string;
|
|
25
|
+
/**
|
|
26
|
+
* A tool of the builder: the one given by its environment variable (LAKUTATA_NFPM, LAKUTATA_WINSW, LAKUTATA_NSIS:
|
|
27
|
+
* makensis.exe, LAKUTATA_WIX: candle.exe, next to light.exe), else the version of the builder, downloaded once into the
|
|
28
|
+
* cache and checked with its sha256
|
|
29
|
+
* @param name
|
|
30
|
+
*/
|
|
31
|
+
export declare function ensureTool(name: keyof typeof TOOLS): Promise<string>;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { InstallerConfig, InstallerOptions, InstallerResult } from '../Installer.js';
|
|
2
|
+
/**
|
|
3
|
+
* Make the installers of an Electron application (lakutata.installer.runtime: electron) for the platform it is made on,
|
|
4
|
+
* by electron-builder: its main process bundled with its dependencies (lakutata package bundle), Electron left out; its native
|
|
5
|
+
* addons and its resources (lakutata.resources: its renderer, its preload script) next to its archive (app.asar), in the
|
|
6
|
+
* resources of Electron. The configuration of electron-builder is made from lakutata.installer, lakutata.installer.electron
|
|
7
|
+
* merged over it; the scripts of the application are run by its installers
|
|
8
|
+
* @param project
|
|
9
|
+
* @param manifest
|
|
10
|
+
* @param config
|
|
11
|
+
* @param options
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildElectronInstaller(project: string, manifest: Record<string, any>, config: InstallerConfig, options: InstallerOptions): Promise<InstallerResult>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { InstallerPlan } from '../Installer.js';
|
|
2
|
+
import { type NativeHook } from '../Scripts.js';
|
|
3
|
+
/**
|
|
4
|
+
* The packages of Linux: the ones of nFPM, and the archive of the directory of the executable
|
|
5
|
+
*/
|
|
6
|
+
export declare const LINUX_TARGETS: readonly ["deb", "rpm", "apk", "archlinux", "tar.gz"];
|
|
7
|
+
export type LinuxTarget = typeof LINUX_TARGETS[number];
|
|
8
|
+
/**
|
|
9
|
+
* What a script of a package does, as the scripts of the application are given it (lakutata_action: install, upgrade,
|
|
10
|
+
* remove, or none), from the arguments of its package manager: the upgrades of deb and rpm run their scripts of the
|
|
11
|
+
* installation (deb: preinst upgrade, postinst configure <version replaced>; rpm: $1 > 1) and their scripts of the
|
|
12
|
+
* removal of the version replaced (which run none); the ones of apk and pacman run their own scripts
|
|
13
|
+
* @param target
|
|
14
|
+
* @param hook
|
|
15
|
+
*/
|
|
16
|
+
export declare function scriptAction(target: Exclude<LinuxTarget, 'tar.gz'>, hook: NativeHook): string;
|
|
17
|
+
/**
|
|
18
|
+
* Make the packages of Linux of an application: nFPM makes the deb, rpm, apk and archlinux packages, the tar.gz archive
|
|
19
|
+
* is the directory of the executable
|
|
20
|
+
* @param plan
|
|
21
|
+
* @param targets
|
|
22
|
+
* @param work
|
|
23
|
+
* @param outdir
|
|
24
|
+
*/
|
|
25
|
+
export declare function buildLinuxPackages(plan: InstallerPlan, targets: LinuxTarget[], work: string, outdir: string): Promise<{
|
|
26
|
+
target: string;
|
|
27
|
+
file: string;
|
|
28
|
+
size: number;
|
|
29
|
+
}[]>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { InstallerPlan } from '../Installer.js';
|
|
2
|
+
/**
|
|
3
|
+
* The installers of macOS: the package of its installer, and the archive of the directory of the executable
|
|
4
|
+
*/
|
|
5
|
+
export declare const MAC_TARGETS: readonly ["pkg", "tar.gz"];
|
|
6
|
+
export type MacTarget = typeof MAC_TARGETS[number];
|
|
7
|
+
/**
|
|
8
|
+
* Make the installers of macOS of an application: the package installed by its installer (pkgbuild, productbuild), the
|
|
9
|
+
* tar.gz archive of the directory of the executable
|
|
10
|
+
* @param plan
|
|
11
|
+
* @param targets
|
|
12
|
+
* @param work
|
|
13
|
+
* @param outdir
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildMacPackages(plan: InstallerPlan, targets: MacTarget[], work: string, outdir: string): Promise<{
|
|
16
|
+
target: string;
|
|
17
|
+
file: string;
|
|
18
|
+
size: number;
|
|
19
|
+
}[]>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { InstallerPlan } from '../Installer.js';
|
|
2
|
+
/**
|
|
3
|
+
* The installers of Windows: the installer of NSIS (.exe), the package of Windows Installer (.msi), the zip archive of
|
|
4
|
+
* the directory of the executable
|
|
5
|
+
*/
|
|
6
|
+
export declare const WINDOWS_TARGETS: readonly ["nsis", "msi", "zip"];
|
|
7
|
+
export type WindowsTarget = typeof WINDOWS_TARGETS[number];
|
|
8
|
+
/**
|
|
9
|
+
* Make the installers of Windows of an application: the installer of NSIS, the package of Windows Installer (WiX), the
|
|
10
|
+
* zip archive of the directory of the executable; its service run by WinSW
|
|
11
|
+
* @param plan
|
|
12
|
+
* @param targets
|
|
13
|
+
* @param work
|
|
14
|
+
* @param outdir
|
|
15
|
+
*/
|
|
16
|
+
export declare function buildWindowsPackages(plan: InstallerPlan, targets: WindowsTarget[], work: string, outdir: string): Promise<{
|
|
17
|
+
target: string;
|
|
18
|
+
file: string;
|
|
19
|
+
size: number;
|
|
20
|
+
}[]>;
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lakutata/builder",
|
|
3
|
+
"version": "3.0.0-beta.0",
|
|
4
|
+
"description": "The builder of the applications of the lakutata framework: their bundles, their executables (Node.js, Bun) with their native addons and their resources.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/esm/index.js",
|
|
7
|
+
"types": "./dist/types/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/types/index.d.ts",
|
|
11
|
+
"default": "./dist/esm/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"clean": "node -e \"require('node:fs').rmSync('dist', {recursive: true, force: true})\"",
|
|
17
|
+
"build:js": "tsc -p tsconfig.esm.json",
|
|
18
|
+
"rebuild": "npm run clean && npm run build:js",
|
|
19
|
+
"compile": "npm run rebuild",
|
|
20
|
+
"test:unit": "npm run compile && node --test \"dist/esm/tests/*.spec.js\"",
|
|
21
|
+
"test:installer": "npm run compile && LAKUTATA_DOCKER=1 node --test dist/esm/tests/Installer.spec.js",
|
|
22
|
+
"test:installer:mac": "npm run compile && LAKUTATA_TART=1 node --test dist/esm/tests/InstallerMac.spec.js",
|
|
23
|
+
"test:installer:windows": "npm run compile && node --test dist/esm/tests/InstallerWindows.spec.js"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"esbuild": "^0.28.2",
|
|
27
|
+
"postject": "^1.0.0-alpha.6",
|
|
28
|
+
"resedit": "^1.7.2"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"electron-builder": ">=26.0.0"
|
|
32
|
+
},
|
|
33
|
+
"peerDependenciesMeta": {
|
|
34
|
+
"electron-builder": {
|
|
35
|
+
"optional": true
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=22.12"
|
|
40
|
+
},
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"files": [
|
|
43
|
+
"dist/esm",
|
|
44
|
+
"!dist/esm/tests",
|
|
45
|
+
"dist/types",
|
|
46
|
+
"!dist/types/tests",
|
|
47
|
+
"*.md",
|
|
48
|
+
"LICENSE",
|
|
49
|
+
"package.json"
|
|
50
|
+
]
|
|
51
|
+
}
|