@nwutils/packager 0.4.0 → 0.6.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/README.md +130 -35
- package/package.json +15 -4
- package/src/appImage.js +307 -10
- package/src/index.js +13 -6
- package/src/nsis.js +563 -0
- package/src/util.js +202 -2
- package/types/appImage.d.ts +85 -14
- package/types/index.d.ts +21 -5
- package/types/nsis.d.ts +140 -0
- package/types/util.d.ts +102 -7
package/types/util.d.ts
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
declare namespace _default {
|
|
2
|
+
export { APPIMAGE_ARCH_KV };
|
|
3
|
+
export { desktopExecArg };
|
|
4
|
+
export { fileExists };
|
|
5
|
+
export { isWindowsFileName };
|
|
6
|
+
export { nsisEscape };
|
|
7
|
+
export { nsisPath };
|
|
8
|
+
export { parseDesktopEntry };
|
|
9
|
+
export { sha512 };
|
|
10
|
+
export { shellQuote };
|
|
11
|
+
export { stringifyDesktopEntry };
|
|
12
|
+
export { stringifyYaml };
|
|
13
|
+
export { updateInfoFileName };
|
|
14
|
+
export { windowsVersion };
|
|
15
|
+
}
|
|
16
|
+
export default _default;
|
|
17
|
+
/**
|
|
18
|
+
* Map nw-builder's architecture identifiers to the identifiers used in
|
|
19
|
+
* `appimagetool` release asset names and its `ARCH` environment variable.
|
|
20
|
+
* @type {Record<"ia32" | "x64" | "arm64", string>}
|
|
21
|
+
*/
|
|
22
|
+
declare const APPIMAGE_ARCH_KV: Record<"ia32" | "x64" | "arm64", string>;
|
|
23
|
+
/**
|
|
24
|
+
* Quote `value` as a single argument of a desktop entry's `Exec` key, per the
|
|
25
|
+
* Desktop Entry Specification: `%` is doubled so it isn't read as a field
|
|
26
|
+
* code, an argument with reserved characters is double quoted with `"`, `` ` ``,
|
|
27
|
+
* `$` and `\` backslash-escaped, and finally backslashes are escaped again as
|
|
28
|
+
* required for every string value.
|
|
29
|
+
* @param {string} value
|
|
30
|
+
* @returns {string}
|
|
31
|
+
*/
|
|
32
|
+
declare function desktopExecArg(value: string): string;
|
|
1
33
|
/**
|
|
2
34
|
* Check if a file or directory exists.
|
|
3
35
|
* @async
|
|
@@ -6,6 +38,35 @@
|
|
|
6
38
|
* @returns {Promise<boolean>}
|
|
7
39
|
*/
|
|
8
40
|
declare function fileExists(filePath: string): Promise<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* Check that `value` can be used as a single Windows file name: no path
|
|
43
|
+
* separators, characters Windows forbids in file names, control characters,
|
|
44
|
+
* trailing dots or spaces, or reserved device names.
|
|
45
|
+
* @param {string} value
|
|
46
|
+
* @returns {boolean}
|
|
47
|
+
*/
|
|
48
|
+
declare function isWindowsFileName(value: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Escape `value` for use inside a double quoted NSIS string. NSIS expands `$`
|
|
51
|
+
* variables and `$\` escapes there, so `$` is doubled and `"` is escaped.
|
|
52
|
+
* Line breaks are rejected rather than escaped: a raw one would end the
|
|
53
|
+
* command and let the value inject further script lines. The result is not
|
|
54
|
+
* quoted, so it can be joined with NSIS variables, eg. `"$INSTDIR\<value>"`.
|
|
55
|
+
* @param {string} value
|
|
56
|
+
* @returns {string}
|
|
57
|
+
*/
|
|
58
|
+
declare function nsisEscape(value: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Check a path on the host for use inside a double quoted NSIS string that
|
|
61
|
+
* `makensis` reads at compile time, eg. a `File` source or `OutFile`. Unlike
|
|
62
|
+
* runtime strings, those keep `$` literally, so nothing is escaped. Instead,
|
|
63
|
+
* the sequences `makensis` would still interpret are rejected: `${define}`
|
|
64
|
+
* expansions and `$\` escapes, and `"` - an escaped `$\"` doesn't survive
|
|
65
|
+
* being passed through a `!define`, as the icon and license paths are.
|
|
66
|
+
* @param {string} value
|
|
67
|
+
* @returns {string} `value`, unchanged.
|
|
68
|
+
*/
|
|
69
|
+
declare function nsisPath(value: string): string;
|
|
9
70
|
/**
|
|
10
71
|
* Parse a freedesktop.org desktop entry file's `[Desktop Entry]` group into
|
|
11
72
|
* a key/value map. Other groups (eg. `[Desktop Action ...]`) are ignored.
|
|
@@ -13,16 +74,50 @@ declare function fileExists(filePath: string): Promise<boolean>;
|
|
|
13
74
|
* @returns {Record<string, string>}
|
|
14
75
|
*/
|
|
15
76
|
declare function parseDesktopEntry(contents: string): Record<string, string>;
|
|
77
|
+
/**
|
|
78
|
+
* Compute the base64 encoded SHA-512 digest of the file at `filePath`, the
|
|
79
|
+
* same encoding electron-builder writes into its update info files.
|
|
80
|
+
* @async
|
|
81
|
+
* @function
|
|
82
|
+
* @param {string} filePath
|
|
83
|
+
* @returns {Promise<string>}
|
|
84
|
+
*/
|
|
85
|
+
declare function sha512(filePath: string): Promise<string>;
|
|
86
|
+
/**
|
|
87
|
+
* Quote `value` as a single POSIX shell word. Inside single quotes nothing is
|
|
88
|
+
* expanded, so only single quotes themselves need escaping.
|
|
89
|
+
* @param {string} value
|
|
90
|
+
* @returns {string}
|
|
91
|
+
*/
|
|
92
|
+
declare function shellQuote(value: string): string;
|
|
16
93
|
/**
|
|
17
94
|
* Serialise a `[Desktop Entry]` key/value map back into a desktop entry file.
|
|
18
95
|
* @param {Record<string, string | undefined>} entries
|
|
19
96
|
* @returns {string}
|
|
20
97
|
*/
|
|
21
98
|
declare function stringifyDesktopEntry(entries: Record<string, string | undefined>): string;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
99
|
+
/**
|
|
100
|
+
* Serialise a map of scalars, and lists of maps of scalars, as YAML. This is
|
|
101
|
+
* the only shape the update info and `app-update.yml` files use, so it avoids
|
|
102
|
+
* pulling in a YAML library for a handful of lines.
|
|
103
|
+
* @param {Record<string, string | number | boolean | Record<string, string | number | boolean>[] | undefined>} entries
|
|
104
|
+
* @returns {string}
|
|
105
|
+
*/
|
|
106
|
+
declare function stringifyYaml(entries: Record<string, string | number | boolean | Record<string, string | number | boolean>[] | undefined>): string;
|
|
107
|
+
/**
|
|
108
|
+
* Name of the update info file `@nwutils/updater` downloads to find the
|
|
109
|
+
* latest release, following electron-builder's naming: `x64` gets the bare
|
|
110
|
+
* `latest-linux.yml`, every other architecture gets an `-<arch>` suffix.
|
|
111
|
+
* @param {"ia32" | "x64" | "arm64"} arch
|
|
112
|
+
* @returns {string}
|
|
113
|
+
*/
|
|
114
|
+
declare function updateInfoFileName(arch: "ia32" | "x64" | "arm64"): string;
|
|
115
|
+
/**
|
|
116
|
+
* Convert a version such as `"1.2.3"` or `"1.2.3-beta.1"` into the
|
|
117
|
+
* `X.X.X.X` form Windows version resources (and NSIS' `VIProductVersion`)
|
|
118
|
+
* require. Up to four leading numeric parts are kept, missing ones are
|
|
119
|
+
* filled with `0`, and any prerelease or build suffix is dropped.
|
|
120
|
+
* @param {string} version
|
|
121
|
+
* @returns {string}
|
|
122
|
+
*/
|
|
123
|
+
declare function windowsVersion(version: string): string;
|