@nwutils/packager 0.5.0 → 0.7.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/types/util.d.ts CHANGED
@@ -1,3 +1,45 @@
1
+ declare namespace _default {
2
+ export { APPIMAGE_ARCH_KV };
3
+ export { appUpdateYaml };
4
+ export { desktopExecArg };
5
+ export { fileExists };
6
+ export { isWindowsFileName };
7
+ export { nsisEscape };
8
+ export { nsisPath };
9
+ export { parseDesktopEntry };
10
+ export { sha512 };
11
+ export { shellQuote };
12
+ export { stringifyDesktopEntry };
13
+ export { stringifyYaml };
14
+ export { updateInfoFileName };
15
+ export { validatePublish };
16
+ export { windowsVersion };
17
+ export { writeUpdateInfo };
18
+ }
19
+ export default _default;
20
+ /**
21
+ * Map nw-builder's architecture identifiers to the identifiers used in
22
+ * `appimagetool` release asset names and its `ARCH` environment variable.
23
+ * @type {Record<"ia32" | "x64" | "arm64", string>}
24
+ */
25
+ declare const APPIMAGE_ARCH_KV: Record<"ia32" | "x64" | "arm64", string>;
26
+ /**
27
+ * Contents of the `app-update.yml` file `@nwutils/updater` reads to find out
28
+ * where releases are published. It is shipped next to the NW.js executable.
29
+ * @param {import("./appImage.js").PublishOptions} publish
30
+ * @returns {string}
31
+ */
32
+ declare function appUpdateYaml(publish: import("./appImage.js").PublishOptions): string;
33
+ /**
34
+ * Quote `value` as a single argument of a desktop entry's `Exec` key, per the
35
+ * Desktop Entry Specification: `%` is doubled so it isn't read as a field
36
+ * code, an argument with reserved characters is double quoted with `"`, `` ` ``,
37
+ * `$` and `\` backslash-escaped, and finally backslashes are escaped again as
38
+ * required for every string value.
39
+ * @param {string} value
40
+ * @returns {string}
41
+ */
42
+ declare function desktopExecArg(value: string): string;
1
43
  /**
2
44
  * Check if a file or directory exists.
3
45
  * @async
@@ -6,6 +48,35 @@
6
48
  * @returns {Promise<boolean>}
7
49
  */
8
50
  declare function fileExists(filePath: string): Promise<boolean>;
51
+ /**
52
+ * Check that `value` can be used as a single Windows file name: no path
53
+ * separators, characters Windows forbids in file names, control characters,
54
+ * trailing dots or spaces, or reserved device names.
55
+ * @param {string} value
56
+ * @returns {boolean}
57
+ */
58
+ declare function isWindowsFileName(value: string): boolean;
59
+ /**
60
+ * Escape `value` for use inside a double quoted NSIS string. NSIS expands `$`
61
+ * variables and `$\` escapes there, so `$` is doubled and `"` is escaped.
62
+ * Line breaks are rejected rather than escaped: a raw one would end the
63
+ * command and let the value inject further script lines. The result is not
64
+ * quoted, so it can be joined with NSIS variables, eg. `"$INSTDIR\<value>"`.
65
+ * @param {string} value
66
+ * @returns {string}
67
+ */
68
+ declare function nsisEscape(value: string): string;
69
+ /**
70
+ * Check a path on the host for use inside a double quoted NSIS string that
71
+ * `makensis` reads at compile time, eg. a `File` source or `OutFile`. Unlike
72
+ * runtime strings, those keep `$` literally, so nothing is escaped. Instead,
73
+ * the sequences `makensis` would still interpret are rejected: `${define}`
74
+ * expansions and `$\` escapes, and `"` - an escaped `$\"` doesn't survive
75
+ * being passed through a `!define`, as the icon and license paths are.
76
+ * @param {string} value
77
+ * @returns {string} `value`, unchanged.
78
+ */
79
+ declare function nsisPath(value: string): string;
9
80
  /**
10
81
  * Parse a freedesktop.org desktop entry file's `[Desktop Entry]` group into
11
82
  * a key/value map. Other groups (eg. `[Desktop Action ...]`) are ignored.
@@ -14,11 +85,14 @@ declare function fileExists(filePath: string): Promise<boolean>;
14
85
  */
15
86
  declare function parseDesktopEntry(contents: string): Record<string, string>;
16
87
  /**
17
- * Serialise a `[Desktop Entry]` key/value map back into a desktop entry file.
18
- * @param {Record<string, string | undefined>} entries
19
- * @returns {string}
88
+ * Compute the base64 encoded SHA-512 digest of the file at `filePath`, the
89
+ * same encoding electron-builder writes into its update info files.
90
+ * @async
91
+ * @function
92
+ * @param {string} filePath
93
+ * @returns {Promise<string>}
20
94
  */
21
- declare function stringifyDesktopEntry(entries: Record<string, string | undefined>): string;
95
+ declare function sha512(filePath: string): Promise<string>;
22
96
  /**
23
97
  * Quote `value` as a single POSIX shell word. Inside single quotes nothing is
24
98
  * expanded, so only single quotes themselves need escaping.
@@ -27,23 +101,11 @@ declare function stringifyDesktopEntry(entries: Record<string, string | undefine
27
101
  */
28
102
  declare function shellQuote(value: string): string;
29
103
  /**
30
- * Quote `value` as a single argument of a desktop entry's `Exec` key, per the
31
- * Desktop Entry Specification: `%` is doubled so it isn't read as a field
32
- * code, an argument with reserved characters is double quoted with `"`, `` ` ``,
33
- * `$` and `\` backslash-escaped, and finally backslashes are escaped again as
34
- * required for every string value.
35
- * @param {string} value
36
- * @returns {string}
37
- */
38
- declare function desktopExecArg(value: string): string;
39
- /**
40
- * Name of the update info file `@nwutils/updater` downloads to find the
41
- * latest release, following electron-builder's naming: `x64` gets the bare
42
- * `latest-linux.yml`, every other architecture gets an `-<arch>` suffix.
43
- * @param {"ia32" | "x64" | "arm64"} arch
104
+ * Serialise a `[Desktop Entry]` key/value map back into a desktop entry file.
105
+ * @param {Record<string, string | undefined>} entries
44
106
  * @returns {string}
45
107
  */
46
- declare function updateInfoFileName(arch: "ia32" | "x64" | "arm64"): string;
108
+ declare function stringifyDesktopEntry(entries: Record<string, string | undefined>): string;
47
109
  /**
48
110
  * Serialise a map of scalars, and lists of maps of scalars, as YAML. This is
49
111
  * the only shape the update info and `app-update.yml` files use, so it avoids
@@ -53,23 +115,44 @@ declare function updateInfoFileName(arch: "ia32" | "x64" | "arm64"): string;
53
115
  */
54
116
  declare function stringifyYaml(entries: Record<string, string | number | boolean | Record<string, string | number | boolean>[] | undefined>): string;
55
117
  /**
56
- * Compute the base64 encoded SHA-512 digest of the file at `filePath`, the
57
- * same encoding electron-builder writes into its update info files.
118
+ * Name of the update info file `@nwutils/updater` downloads for `arch` on
119
+ * `platform`, matching electron-builder: `x64` gets the bare
120
+ * `latest-linux.yml` (Linux) or `latest.yml` (Windows), every other
121
+ * architecture gets an `-<arch>` suffix.
122
+ * @param {string} arch
123
+ * @param {"linux" | "win"} [platform="linux"]
124
+ * @returns {string}
125
+ */
126
+ declare function updateInfoFileName(arch: string, platform?: "linux" | "win"): string;
127
+ /**
128
+ * Throw if `publish` isn't a valid `PublishOptions` object.
129
+ * @param {unknown} publish
130
+ * @returns {void}
131
+ */
132
+ declare function validatePublish(publish: unknown): void;
133
+ /**
134
+ * Convert a version such as `"1.2.3"` or `"1.2.3-beta.1"` into the
135
+ * `X.X.X.X` form Windows version resources (and NSIS' `VIProductVersion`)
136
+ * require. Up to four leading numeric parts are kept, missing ones are
137
+ * filled with `0`, and any prerelease or build suffix is dropped.
138
+ * @param {string} version
139
+ * @returns {string}
140
+ */
141
+ declare function windowsVersion(version: string): string;
142
+ /**
143
+ * Write the update info file `@nwutils/updater` compares the running version
144
+ * against, describing the packaged artifact at `filePath`. It must be uploaded
145
+ * to every release next to the artifact.
58
146
  * @async
59
147
  * @function
60
- * @param {string} filePath
61
- * @returns {Promise<string>}
148
+ * @param {object} options
149
+ * @param {string} options.filePath Path to the packaged artifact, eg. the AppImage or installer.
150
+ * @param {string} options.updateInfoPath Path the update info file is written to.
151
+ * @param {string} options.version Version of the application.
152
+ * @returns {Promise<void>}
62
153
  */
63
- declare function sha512(filePath: string): Promise<string>;
64
- declare const _default: {
65
- APPIMAGE_ARCH_KV: Record<"arm64" | "ia32" | "x64", string>;
66
- desktopExecArg: typeof desktopExecArg;
67
- fileExists: typeof fileExists;
68
- parseDesktopEntry: typeof parseDesktopEntry;
69
- sha512: typeof sha512;
70
- shellQuote: typeof shellQuote;
71
- stringifyDesktopEntry: typeof stringifyDesktopEntry;
72
- stringifyYaml: typeof stringifyYaml;
73
- updateInfoFileName: typeof updateInfoFileName;
74
- };
75
- export default _default;
154
+ declare function writeUpdateInfo({ filePath, updateInfoPath, version }: {
155
+ filePath: string;
156
+ updateInfoPath: string;
157
+ version: string;
158
+ }): Promise<void>;