cross-packer 0.1.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 +661 -0
- package/README.md +151 -0
- package/README.zh-CN.md +151 -0
- package/dist/archive/ar.d.ts +12 -0
- package/dist/archive/seven-za.d.ts +32 -0
- package/dist/archive/tar.d.ts +30 -0
- package/dist/archive/zip-reader.d.ts +17 -0
- package/dist/asar/dependency/collect.d.ts +2 -0
- package/dist/asar/dependency/detector.d.ts +8 -0
- package/dist/asar/dependency/hoister.d.ts +27 -0
- package/dist/asar/dependency/utils.d.ts +59 -0
- package/dist/asar/fileset/matcher.d.ts +12 -0
- package/dist/asar/fileset/platform-fileset.d.ts +36 -0
- package/dist/asar/fileset/transformer.d.ts +2 -0
- package/dist/asar/fileset/unpack-detector.d.ts +10 -0
- package/dist/asar/fileset/walker.d.ts +14 -0
- package/dist/asar/pack.d.ts +23 -0
- package/dist/asar/packer/app-collector.d.ts +2 -0
- package/dist/asar/packer/collector.d.ts +18 -0
- package/dist/asar/packer/concurrency.d.ts +1 -0
- package/dist/asar/packer/integrity.d.ts +8 -0
- package/dist/asar/packer/nm-collector.d.ts +7 -0
- package/dist/asar/packer/stream-builder.d.ts +18 -0
- package/dist/cli.d.ts +2 -0
- package/dist/config/index.d.ts +97 -0
- package/dist/electron/dist-zip.d.ts +18 -0
- package/dist/electron/download.d.ts +21 -0
- package/dist/index.d.ts +11 -0
- package/dist/packer/common/app-update-yml.d.ts +5 -0
- package/dist/packer/common/extra-resources.d.ts +39 -0
- package/dist/packer/common/staging.d.ts +3 -0
- package/dist/packer/common/template.d.ts +2 -0
- package/dist/packer/linux/linux.d.ts +2 -0
- package/dist/packer/mac/mac.d.ts +23 -0
- package/dist/packer/win/nsis.d.ts +24 -0
- package/dist/packer/win/resedit.d.ts +5 -0
- package/dist/packer/win/toolchain.d.ts +8 -0
- package/dist/packer/win/win.d.ts +12 -0
- package/dist/pipeline/pipeline.d.ts +41 -0
- package/dist/pipeline/targets.d.ts +28 -0
- package/dist/shared/hash.d.ts +2 -0
- package/dist/shared/logger.d.ts +39 -0
- package/dist/shared/platform.d.ts +26 -0
- package/dist/shared/types.d.ts +68 -0
- package/dist/update/blockmap.d.ts +13 -0
- package/dist/update/metadata.d.ts +20 -0
- package/dist/update/version.d.ts +7 -0
- package/package.json +71 -0
- package/src/archive/ar.ts +41 -0
- package/src/archive/seven-za.ts +160 -0
- package/src/archive/tar.ts +142 -0
- package/src/archive/zip-reader.ts +61 -0
- package/src/asar/dependency/collect.ts +437 -0
- package/src/asar/dependency/detector.ts +73 -0
- package/src/asar/dependency/hoister.ts +714 -0
- package/src/asar/dependency/utils.ts +225 -0
- package/src/asar/fileset/matcher.ts +101 -0
- package/src/asar/fileset/platform-fileset.ts +416 -0
- package/src/asar/fileset/transformer.ts +154 -0
- package/src/asar/fileset/unpack-detector.ts +38 -0
- package/src/asar/fileset/walker.ts +115 -0
- package/src/asar/pack.ts +186 -0
- package/src/asar/packer/app-collector.ts +74 -0
- package/src/asar/packer/collector.ts +134 -0
- package/src/asar/packer/concurrency.ts +24 -0
- package/src/asar/packer/integrity.ts +53 -0
- package/src/asar/packer/nm-collector.ts +194 -0
- package/src/asar/packer/stream-builder.ts +723 -0
- package/src/cli.ts +182 -0
- package/src/config/index.ts +365 -0
- package/src/electron/dist-zip.ts +65 -0
- package/src/electron/download.ts +121 -0
- package/src/index.ts +14 -0
- package/src/packer/common/app-update-yml.ts +21 -0
- package/src/packer/common/extra-resources.ts +83 -0
- package/src/packer/common/staging.ts +33 -0
- package/src/packer/common/template.ts +24 -0
- package/src/packer/linux/linux.ts +329 -0
- package/src/packer/mac/mac.ts +495 -0
- package/src/packer/win/nsis.ts +244 -0
- package/src/packer/win/resedit.ts +60 -0
- package/src/packer/win/toolchain.ts +63 -0
- package/src/packer/win/win.ts +421 -0
- package/src/pipeline/pipeline.ts +149 -0
- package/src/pipeline/targets.ts +67 -0
- package/src/shared/hash.ts +15 -0
- package/src/shared/logger.ts +91 -0
- package/src/shared/platform.ts +41 -0
- package/src/shared/types.ts +82 -0
- package/src/update/blockmap.ts +247 -0
- package/src/update/metadata.ts +97 -0
- package/src/update/version.ts +59 -0
- package/templates/linux/app.desktop +11 -0
- package/templates/linux/control +9 -0
- package/templates/linux/postinst +10 -0
- package/templates/linux/postrm +8 -0
- package/templates/linux/preinst +49 -0
- package/templates/linux/prerm +43 -0
- package/templates/mac/Info.plist +18 -0
- package/templates/mac/app-update.yml +4 -0
- package/templates/win/nsis/README.md +51 -0
- package/templates/win/nsis/THIRD-PARTY-NOTICES.md +20 -0
- package/templates/win/nsis/assistedInstaller.nsh +154 -0
- package/templates/win/nsis/assistedMessages.yml +368 -0
- package/templates/win/nsis/common.nsh +147 -0
- package/templates/win/nsis/empty-license.txt +1 -0
- package/templates/win/nsis/include/FileAssociation.nsh +123 -0
- package/templates/win/nsis/include/StdUtils.nsh +496 -0
- package/templates/win/nsis/include/StrContains.nsh +48 -0
- package/templates/win/nsis/include/UAC.nsh +299 -0
- package/templates/win/nsis/include/allowOnlyOneInstallerInstance.nsh +164 -0
- package/templates/win/nsis/include/extractAppPackage.nsh +138 -0
- package/templates/win/nsis/include/getProcessInfo.nsh +157 -0
- package/templates/win/nsis/include/installUtil.nsh +248 -0
- package/templates/win/nsis/include/installer.nsh +247 -0
- package/templates/win/nsis/include/nsProcess.nsh +28 -0
- package/templates/win/nsis/include/webPackage.nsh +64 -0
- package/templates/win/nsis/installSection.nsh +110 -0
- package/templates/win/nsis/installer.nsi +132 -0
- package/templates/win/nsis/messages.yml +240 -0
- package/templates/win/nsis/multiUser.nsh +134 -0
- package/templates/win/nsis/multiUserUi.nsh +230 -0
- package/templates/win/nsis/oneClick.nsh +19 -0
- package/templates/win/nsis/portable.nsi +91 -0
- package/templates/win/nsis/uninstaller.nsh +263 -0
- package/templates/win/nsis-header.nsh +57 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type FileFilter, type FileSet } from '../../shared/types.ts';
|
|
2
|
+
/** A fileSet plus transformed contents collected during packing. */
|
|
3
|
+
interface PackedFileSet extends FileSet {
|
|
4
|
+
transformedFiles?: Map<number, string>;
|
|
5
|
+
}
|
|
6
|
+
export interface PackAsarOptions {
|
|
7
|
+
outputPath: string;
|
|
8
|
+
unpackPattern?: FileFilter;
|
|
9
|
+
smartUnpack?: boolean;
|
|
10
|
+
unpackDirs?: string[];
|
|
11
|
+
defaultDestination?: string;
|
|
12
|
+
workspaceRoot?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function packAsarFromFileSets(fileSets: PackedFileSet[], options: PackAsarOptions): Promise<{
|
|
15
|
+
asarPath: string;
|
|
16
|
+
unpackedDir: string | undefined;
|
|
17
|
+
}>;
|
|
18
|
+
export {};
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { PrebuiltModuleRule } from '../asar/fileset/platform-fileset.ts';
|
|
2
|
+
import type { ExtraResourceEntry } from '../packer/common/extra-resources.ts';
|
|
3
|
+
import type { Arch, NodePlatform } from '../shared/platform.ts';
|
|
4
|
+
import type { FileVisitor, JsonObject } from '../shared/types.ts';
|
|
5
|
+
export declare const DEFAULT_CONFIG_FILENAME = "cross-packer.config.mjs";
|
|
6
|
+
export interface NormalizedConfig {
|
|
7
|
+
name: string;
|
|
8
|
+
productName: string;
|
|
9
|
+
artifactName: string;
|
|
10
|
+
appId: string;
|
|
11
|
+
version: string;
|
|
12
|
+
buildNumber?: number | string;
|
|
13
|
+
description: string;
|
|
14
|
+
author: string;
|
|
15
|
+
homepage: string;
|
|
16
|
+
electronVersion: string;
|
|
17
|
+
electronMirror: string;
|
|
18
|
+
copyright: string;
|
|
19
|
+
projectDir: string;
|
|
20
|
+
files?: JsonObject;
|
|
21
|
+
appDistDir: string;
|
|
22
|
+
asarUnpack: string[];
|
|
23
|
+
smartUnpack: boolean;
|
|
24
|
+
extraResources: Array<ExtraResourceEntry>;
|
|
25
|
+
extraMetadata?: Record<string, unknown>;
|
|
26
|
+
onNodeModuleFile?: FileVisitor;
|
|
27
|
+
disableDefaultIgnoredFiles: boolean;
|
|
28
|
+
asar: {
|
|
29
|
+
path?: string;
|
|
30
|
+
unpackedDir?: string;
|
|
31
|
+
};
|
|
32
|
+
nativeModules: {
|
|
33
|
+
prebuiltRules?: (platform: NodePlatform, arch: Arch) => ReadonlyArray<PrebuiltModuleRule> | null | undefined;
|
|
34
|
+
};
|
|
35
|
+
mac: {
|
|
36
|
+
bundleName: string;
|
|
37
|
+
category: string;
|
|
38
|
+
iconFile?: string;
|
|
39
|
+
minimumSystemVersion: string;
|
|
40
|
+
urlSchemes: string[];
|
|
41
|
+
/** Extra Info.plist entries merged on top of the generated keys. */
|
|
42
|
+
plist: Record<string, unknown>;
|
|
43
|
+
};
|
|
44
|
+
win: {
|
|
45
|
+
iconFile?: string;
|
|
46
|
+
compressionLevel: number;
|
|
47
|
+
nsisVersion: string;
|
|
48
|
+
nsisResourcesVersion: string;
|
|
49
|
+
nsisCacheDir: string;
|
|
50
|
+
shortcutName: string;
|
|
51
|
+
};
|
|
52
|
+
linux: {
|
|
53
|
+
installDir: string;
|
|
54
|
+
iconDir: string;
|
|
55
|
+
iconSizes: number[];
|
|
56
|
+
debDepends: string[];
|
|
57
|
+
debRecommends: string;
|
|
58
|
+
maintainer: string;
|
|
59
|
+
mimeType: string;
|
|
60
|
+
desktopExtraFile?: string;
|
|
61
|
+
};
|
|
62
|
+
update: {
|
|
63
|
+
channel: string;
|
|
64
|
+
generateMetadata: boolean;
|
|
65
|
+
url: string;
|
|
66
|
+
extraArtifacts?: string[];
|
|
67
|
+
};
|
|
68
|
+
sign: {
|
|
69
|
+
enabled: boolean;
|
|
70
|
+
win?: {
|
|
71
|
+
enabled?: boolean;
|
|
72
|
+
hook?: (target: string, ctx: {
|
|
73
|
+
config: NormalizedConfig;
|
|
74
|
+
arch: Arch;
|
|
75
|
+
outputDir: string;
|
|
76
|
+
singleFile?: boolean;
|
|
77
|
+
}) => Promise<void> | void;
|
|
78
|
+
};
|
|
79
|
+
mac?: {
|
|
80
|
+
enabled?: boolean;
|
|
81
|
+
hook?: (target: string, ctx: {
|
|
82
|
+
config: NormalizedConfig;
|
|
83
|
+
arch: Arch;
|
|
84
|
+
outputDir: string;
|
|
85
|
+
}) => Promise<string> | string;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/** Overrides applied on top of the raw config during normalization. */
|
|
90
|
+
export interface LoadConfigOverrides {
|
|
91
|
+
channel?: string;
|
|
92
|
+
signEnabled?: boolean;
|
|
93
|
+
}
|
|
94
|
+
/** Resolve the config path: an explicit path, or the first default candidate. */
|
|
95
|
+
export declare function resolveConfigPath(explicitPath?: string): string;
|
|
96
|
+
export declare function loadConfig(configPath: string, overrides?: LoadConfigOverrides): Promise<NormalizedConfig>;
|
|
97
|
+
export declare function normalizeConfig(raw: Record<string, unknown>, overrides?: LoadConfigOverrides): NormalizedConfig;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Arch, NodePlatform } from '../shared/platform.ts';
|
|
2
|
+
interface ElectronZipConfig {
|
|
3
|
+
electronVersion: string;
|
|
4
|
+
electronMirror?: string;
|
|
5
|
+
checksums?: Record<string, string>;
|
|
6
|
+
cacheDir?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Download (with cache) and read the Electron distribution zip for a target.
|
|
10
|
+
*
|
|
11
|
+
* Checksums are resolved from the electron package's checksums.json when
|
|
12
|
+
* present; otherwise the caller provides config.checksums keyed by archive name.
|
|
13
|
+
*/
|
|
14
|
+
export declare function downloadAndReadElectron(platform: NodePlatform, arch: Arch, config: ElectronZipConfig): Promise<{
|
|
15
|
+
zipPath: string;
|
|
16
|
+
entries: import("../archive/zip-reader.ts").ZipEntry[];
|
|
17
|
+
}>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Arch, type NodePlatform } from '../shared/platform.ts';
|
|
2
|
+
export interface DownloadElectronOptions {
|
|
3
|
+
version: string;
|
|
4
|
+
platform: NodePlatform;
|
|
5
|
+
arch: Arch;
|
|
6
|
+
mirror?: string;
|
|
7
|
+
cacheDir?: string;
|
|
8
|
+
expectedChecksum: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Compose the Electron distribution archive name for a target. The Electron
|
|
12
|
+
* release artifacts use "x64" rather than "amd64" for the x86-64 architecture,
|
|
13
|
+
* for example version "33.2.0" yields "electron-v33.2.0-win32-x64.zip".
|
|
14
|
+
*/
|
|
15
|
+
export declare function electronArchiveName(version: string, platform: NodePlatform, arch: Arch): string;
|
|
16
|
+
/** Streams a file through sha256 and compares against the expected hex digest. */
|
|
17
|
+
export declare function validateArchiveChecksum(archivePath: string, expectedChecksum: string): Promise<void>;
|
|
18
|
+
/** Download a file with cache support and return the cached archive path. */
|
|
19
|
+
export declare function downloadElectron({ version, platform, arch, mirror, cacheDir, expectedChecksum, }: DownloadElectronOptions): Promise<string>;
|
|
20
|
+
/** Download a file while following redirects. No external dependencies. */
|
|
21
|
+
export declare function downloadFile(url: string, destPath: string): Promise<void>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type { PrebuiltModuleRule } from './asar/fileset/platform-fileset.ts';
|
|
2
|
+
export { setPrebuiltDirResolver } from './asar/fileset/platform-fileset.ts';
|
|
3
|
+
export type { LoadConfigOverrides, NormalizedConfig, } from './config/index.ts';
|
|
4
|
+
export { loadConfig, normalizeConfig, resolveConfigPath } from './config/index.ts';
|
|
5
|
+
export type { ExtraResourceEntry } from './packer/common/extra-resources.ts';
|
|
6
|
+
export type { PackResult, PipelineOptions, TargetResult, TargetSpec } from './pipeline/pipeline.ts';
|
|
7
|
+
export { runPack } from './pipeline/pipeline.ts';
|
|
8
|
+
export { Arch, NodePlatform, nodeArchName, Platform } from './shared/platform.ts';
|
|
9
|
+
export { buildBlockMap } from './update/blockmap.ts';
|
|
10
|
+
export type { UpdateMetadataOptions } from './update/metadata.ts';
|
|
11
|
+
export { generateUpdateMetadata } from './update/metadata.ts';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { NormalizedConfig } from '../../config/index.ts';
|
|
2
|
+
/** Derive the electron-updater cache directory name for a config. */
|
|
3
|
+
export declare function getUpdaterCacheDirName(config: NormalizedConfig): string;
|
|
4
|
+
/** Render the shared app-update.yml template. */
|
|
5
|
+
export declare function renderAppUpdateYml(config: NormalizedConfig): Promise<string>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extra-resource entry filtering, shared by the win/mac/linux packers.
|
|
3
|
+
*/
|
|
4
|
+
import { type Stats } from 'node:fs';
|
|
5
|
+
import type { CollectDirectoryOptions } from '../../archive/tar.ts';
|
|
6
|
+
import type { NormalizedConfig } from '../../config/index.ts';
|
|
7
|
+
export interface ExtraResourceEntry {
|
|
8
|
+
from?: string;
|
|
9
|
+
to?: string;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
exclude?: string[];
|
|
12
|
+
collectOptions?: CollectDirectoryOptions;
|
|
13
|
+
}
|
|
14
|
+
/** A resolved extra resource: source path, stat, and in-archive destination. */
|
|
15
|
+
export interface ResolvedExtraResource {
|
|
16
|
+
res: ExtraResourceEntry;
|
|
17
|
+
srcPath: string;
|
|
18
|
+
srcStat: Stats;
|
|
19
|
+
destPath: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Resolve every configured extra resource into a source path plus stat.
|
|
23
|
+
* Missing optional sources are skipped; required sources throw via
|
|
24
|
+
* assertRequiredExtraResource.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveExtraResources(config: NormalizedConfig): Promise<ResolvedExtraResource[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Check whether a directory entry (relative to the resource root) matches
|
|
29
|
+
* the resource's exclude list. A matched path or any path under it is excluded.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isExtraResourcePathExcluded(resource: ExtraResourceEntry, relativePath: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Ensures required extra resources exist before packaging.
|
|
34
|
+
* The optional hint callback returns an appended instruction telling the
|
|
35
|
+
* user how to obtain the missing resource (e.g. a project-specific
|
|
36
|
+
* download command); returning undefined falls back to the plain message.
|
|
37
|
+
* @throws when a required resource path is missing
|
|
38
|
+
*/
|
|
39
|
+
export declare function assertRequiredExtraResource(projectDir: string, res: ExtraResourceEntry, missingHint?: (from: string) => string | undefined): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Archiver } from 'archiver';
|
|
2
|
+
import type { NormalizedConfig } from '../../config/index.ts';
|
|
3
|
+
import type { PackerContext } from '../../pipeline/targets.ts';
|
|
4
|
+
import { type ExtraResourceEntry } from '../common/extra-resources.ts';
|
|
5
|
+
interface MacBundleIdentity {
|
|
6
|
+
/** Bundle directory name, for example "MyApp.app". */
|
|
7
|
+
appName: string;
|
|
8
|
+
/** On-disk bundle base name. */
|
|
9
|
+
bundleName: string;
|
|
10
|
+
/** User-visible product name. */
|
|
11
|
+
displayName: string;
|
|
12
|
+
executableName: string;
|
|
13
|
+
helperName: string;
|
|
14
|
+
/** Helper name with unsafe characters removed. */
|
|
15
|
+
sanitizedHelperName: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function packMac({ config, arch, outputDir, asarPath, unpackedDir, }: PackerContext): Promise<string>;
|
|
18
|
+
/** Derive bundle identity (app name, executable, helper names) from config. */
|
|
19
|
+
export declare function resolveMacBundleIdentity(config: NormalizedConfig): MacBundleIdentity;
|
|
20
|
+
/** Normalize an archive entry mode to executable / regular file bits. */
|
|
21
|
+
export declare function normalizeMacArchiveFileMode(sourceMode: string | number): number;
|
|
22
|
+
export declare function addDirectoryToArchive(archive: Archiver, dirPath: string, archivePath: string, resource?: ExtraResourceEntry, relativePath?: string): void;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { NormalizedConfig } from '../../config/index.ts';
|
|
2
|
+
export declare function getNsisTemplatesDir(): string;
|
|
3
|
+
export declare function prepareNsisToolchain(projectDir: string, winConfig: NormalizedConfig['win']): Promise<{
|
|
4
|
+
nsisDir: string;
|
|
5
|
+
nsisResourcesDir: string;
|
|
6
|
+
}>;
|
|
7
|
+
/**
|
|
8
|
+
* Assemble the NSIS script header: include paths, plugin directories,
|
|
9
|
+
* and localized messages.
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildNsisScriptHeader({ nsisIncludeDir, nsisPluginsDir, pluginArch, nsisTemplatesDir, stagingDir, }: {
|
|
12
|
+
nsisIncludeDir: string;
|
|
13
|
+
nsisPluginsDir: string;
|
|
14
|
+
pluginArch: string;
|
|
15
|
+
nsisTemplatesDir: string;
|
|
16
|
+
stagingDir: string;
|
|
17
|
+
}): Promise<string>;
|
|
18
|
+
export declare function executeMakensis({ nsisDir, defines, commands, script, cwd, }: {
|
|
19
|
+
nsisDir: string;
|
|
20
|
+
defines: Record<string, string | null>;
|
|
21
|
+
commands: Record<string, unknown>;
|
|
22
|
+
script: string;
|
|
23
|
+
cwd: string;
|
|
24
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function downloadAndExtract7z({ url, sha512, name, cacheDir, targetDir, validateExtracted, }: {
|
|
2
|
+
url: string;
|
|
3
|
+
sha512: string;
|
|
4
|
+
name: string;
|
|
5
|
+
cacheDir: string;
|
|
6
|
+
targetDir: string;
|
|
7
|
+
validateExtracted: (dir: string) => boolean;
|
|
8
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { NormalizedConfig } from '../../config/index.ts';
|
|
2
|
+
import type { PackerContext } from '../../pipeline/targets.ts';
|
|
3
|
+
export declare function packWin({ config, arch, outputDir, asarPath, unpackedDir, }: PackerContext): Promise<string>;
|
|
4
|
+
/** Derive the installer .exe filename from the distribution naming contract. */
|
|
5
|
+
export declare function buildWindowsInstallerFilename(config: NormalizedConfig): string;
|
|
6
|
+
/** Derive the Windows package identity (install dir, shortcut, updater cache). */
|
|
7
|
+
export declare function resolveWindowsPackageIdentity(config: NormalizedConfig): {
|
|
8
|
+
appFilename: string;
|
|
9
|
+
productFilename: string;
|
|
10
|
+
shortcutName: string;
|
|
11
|
+
updaterCacheDirName: string;
|
|
12
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { NormalizedConfig } from '../config/index.ts';
|
|
2
|
+
import type { Arch, Platform } from '../shared/platform.ts';
|
|
3
|
+
import type { FileSet } from '../shared/types.ts';
|
|
4
|
+
import { type PackTarget } from './targets.ts';
|
|
5
|
+
export interface PackResult {
|
|
6
|
+
ok: boolean;
|
|
7
|
+
outputDir: string;
|
|
8
|
+
targets: TargetResult[];
|
|
9
|
+
}
|
|
10
|
+
export interface PipelineOptions {
|
|
11
|
+
platforms: Platform[];
|
|
12
|
+
arches: Arch[];
|
|
13
|
+
output: string;
|
|
14
|
+
dryRun: boolean;
|
|
15
|
+
onTargetComplete?: (result: TargetResult) => void;
|
|
16
|
+
}
|
|
17
|
+
export interface TargetResult {
|
|
18
|
+
platform: Platform;
|
|
19
|
+
arch: Arch;
|
|
20
|
+
output?: string;
|
|
21
|
+
error?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface TargetSpec {
|
|
24
|
+
platform: Platform;
|
|
25
|
+
arches?: Arch[];
|
|
26
|
+
config?: (config: NormalizedConfig) => NormalizedConfig;
|
|
27
|
+
}
|
|
28
|
+
interface CollectedProjectFiles {
|
|
29
|
+
appFileSet: FileSet;
|
|
30
|
+
nmFileSets: FileSet[];
|
|
31
|
+
transformer: (file: string) => Promise<string | null> | string | null;
|
|
32
|
+
}
|
|
33
|
+
interface SharedState {
|
|
34
|
+
collectPromise?: Promise<CollectedProjectFiles>;
|
|
35
|
+
}
|
|
36
|
+
export declare function resolveAsarForTarget(target: PackTarget, config: NormalizedConfig, outputDir: string, shared: SharedState): Promise<{
|
|
37
|
+
asarPath: string;
|
|
38
|
+
unpackedDir: string | undefined;
|
|
39
|
+
}>;
|
|
40
|
+
export declare function runPack(config: NormalizedConfig, options: PipelineOptions, targetSpecs?: TargetSpec[]): Promise<PackResult>;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Target resolution: maps (platform, arch) pairs to packer implementations.
|
|
3
|
+
*/
|
|
4
|
+
import type { NormalizedConfig } from '../config/index.ts';
|
|
5
|
+
import type { Arch, Platform } from '../shared/platform.ts';
|
|
6
|
+
import type { PipelineOptions, TargetSpec } from './pipeline.ts';
|
|
7
|
+
export interface PackerContext {
|
|
8
|
+
config: NormalizedConfig;
|
|
9
|
+
arch: Arch;
|
|
10
|
+
outputDir: string;
|
|
11
|
+
asarPath?: string;
|
|
12
|
+
unpackedDir?: string;
|
|
13
|
+
}
|
|
14
|
+
/** A single (platform, arch) packaging unit. */
|
|
15
|
+
export interface PackTarget {
|
|
16
|
+
platform: Platform;
|
|
17
|
+
arch: Arch;
|
|
18
|
+
run: (asar: {
|
|
19
|
+
asarPath?: string;
|
|
20
|
+
unpackedDir?: string;
|
|
21
|
+
}) => Promise<string>;
|
|
22
|
+
}
|
|
23
|
+
export declare function runPlatformPackers({ config, options, outputDir, targetSpecs, }: {
|
|
24
|
+
config: NormalizedConfig;
|
|
25
|
+
options: PipelineOptions;
|
|
26
|
+
outputDir: string;
|
|
27
|
+
targetSpecs?: TargetSpec[];
|
|
28
|
+
}): PackTarget[];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logging facade. All output is written through process.stdout.write or
|
|
3
|
+
* process.stderr.write; quiet mode suppresses every channel.
|
|
4
|
+
*/
|
|
5
|
+
import type { Arch, Platform } from './platform.ts';
|
|
6
|
+
interface LoggerOptions {
|
|
7
|
+
quiet?: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface BannerSummary {
|
|
10
|
+
platforms: Platform[];
|
|
11
|
+
arches: Arch[];
|
|
12
|
+
}
|
|
13
|
+
interface TargetResult {
|
|
14
|
+
platform: Platform;
|
|
15
|
+
arch: Arch;
|
|
16
|
+
output?: string;
|
|
17
|
+
error?: string;
|
|
18
|
+
}
|
|
19
|
+
interface SummaryResult {
|
|
20
|
+
targets: TargetResult[];
|
|
21
|
+
}
|
|
22
|
+
/** Project identity fields shown in the banner; any config object with these fields works. */
|
|
23
|
+
export interface BannerInput {
|
|
24
|
+
productName: string;
|
|
25
|
+
version: string;
|
|
26
|
+
electronVersion: string;
|
|
27
|
+
}
|
|
28
|
+
export interface Logger {
|
|
29
|
+
info: (message: string) => void;
|
|
30
|
+
warn: (message: string) => void;
|
|
31
|
+
error: (message: string) => void;
|
|
32
|
+
step: (label: string, message: string) => void;
|
|
33
|
+
banner: (project: BannerInput, summary: BannerSummary) => void;
|
|
34
|
+
summary: (result: SummaryResult) => void;
|
|
35
|
+
}
|
|
36
|
+
export declare function createLogger(options?: LoggerOptions): Logger;
|
|
37
|
+
/** Shared default logger instance, used by packer/collector/util modules. */
|
|
38
|
+
export declare const logger: Logger;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-layer platform vocabulary: target platforms, architectures, and
|
|
3
|
+
* Node.js host platforms. Zero project dependencies; both config and the
|
|
4
|
+
* asar domain consume these enums.
|
|
5
|
+
*/
|
|
6
|
+
export declare enum Platform {
|
|
7
|
+
WIN = "win",
|
|
8
|
+
MAC = "mac",
|
|
9
|
+
LINUX = "linux"
|
|
10
|
+
}
|
|
11
|
+
export declare enum Arch {
|
|
12
|
+
AMD64 = "amd64",
|
|
13
|
+
ARM64 = "arm64"
|
|
14
|
+
}
|
|
15
|
+
export declare enum NodePlatform {
|
|
16
|
+
WIN32 = "win32",
|
|
17
|
+
DARWIN = "darwin",
|
|
18
|
+
LINUX = "linux"
|
|
19
|
+
}
|
|
20
|
+
export declare function nodeArchName(arch: Arch): 'x64' | 'arm64';
|
|
21
|
+
/**
|
|
22
|
+
* Narrow the host's `process.platform` to NodePlatform.
|
|
23
|
+
* Throws on unsupported hosts (node_modules collection is only defined
|
|
24
|
+
* for win32 / darwin / linux).
|
|
25
|
+
*/
|
|
26
|
+
export declare function nodePlatformOf(host: NodeJS.Platform): NodePlatform;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zero-dependency shared types.
|
|
3
|
+
*
|
|
4
|
+
* This file may only import from `node:` builtins and external type
|
|
5
|
+
* packages — never from project modules. Every other layer depends on
|
|
6
|
+
* `shared/`, which keeps type-only dependencies acyclic at the module level.
|
|
7
|
+
*/
|
|
8
|
+
import type { Stats } from 'node:fs';
|
|
9
|
+
/** The kind of an asar-storable entry. */
|
|
10
|
+
export declare enum EntryKind {
|
|
11
|
+
FILE = "file",
|
|
12
|
+
DIRECTORY = "directory",
|
|
13
|
+
LINK = "link"
|
|
14
|
+
}
|
|
15
|
+
/** A plain JSON object: arbitrary string keys, JSON-compatible values. */
|
|
16
|
+
export type JsonObject = Record<string, unknown>;
|
|
17
|
+
/** A logical file set: an absolute source dir plus the collected files. */
|
|
18
|
+
export interface FileSet {
|
|
19
|
+
src: string;
|
|
20
|
+
destination: string;
|
|
21
|
+
files: string[];
|
|
22
|
+
metadata: Map<string, FileStat>;
|
|
23
|
+
}
|
|
24
|
+
/** File filter predicate used across collectors. */
|
|
25
|
+
export type FileFilter = (file: string, stat: FileStat) => boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Callback invoked for each collected node_modules file; returning true
|
|
28
|
+
* forces the file to be included even if it matches default exclusions.
|
|
29
|
+
*/
|
|
30
|
+
export type FileVisitor = (file: string) => boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Collected entry metadata: the entry kind plus the module metadata that
|
|
33
|
+
* the collectors attach. Pure data with no behavior.
|
|
34
|
+
*/
|
|
35
|
+
export interface FileStat {
|
|
36
|
+
type: EntryKind;
|
|
37
|
+
size: number;
|
|
38
|
+
mode: number;
|
|
39
|
+
/** Real on-disk source path when the packed file differs from the logical path. */
|
|
40
|
+
realFilePath?: string;
|
|
41
|
+
/** Name of the node module the file belongs to. */
|
|
42
|
+
moduleName?: string;
|
|
43
|
+
/** Root directory of the owning module. */
|
|
44
|
+
moduleRootPath?: string;
|
|
45
|
+
/** Full path relative to the module root. */
|
|
46
|
+
moduleFullFilePath?: string;
|
|
47
|
+
/** Symlink target relative to the module root. */
|
|
48
|
+
relativeLink?: string;
|
|
49
|
+
/** Symlink target relative to the link's directory. */
|
|
50
|
+
linkRelativeToFile?: string;
|
|
51
|
+
}
|
|
52
|
+
/** A resolved production dependency reported by the collector. */
|
|
53
|
+
export interface DependencyEntry {
|
|
54
|
+
name: string;
|
|
55
|
+
dir: string;
|
|
56
|
+
dependencies?: DependencyEntry[];
|
|
57
|
+
}
|
|
58
|
+
/** A parsed minimatch pattern (from the `minimatch` package). */
|
|
59
|
+
export interface MinimatchPattern {
|
|
60
|
+
match: (p: string, partial?: boolean) => boolean;
|
|
61
|
+
set: Array<Array<string | object | symbol>>;
|
|
62
|
+
negate: boolean;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Map an fs stat result to its entry kind, or null for special entries
|
|
66
|
+
* (sockets, FIFOs, devices) that the asar format cannot store.
|
|
67
|
+
*/
|
|
68
|
+
export declare function entryKind(stat: Stats): EntryKind | null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure-JavaScript blockmap generator using Rabin fingerprinting.
|
|
3
|
+
* Ported from electron-builder v26.15.2 (app-builder-lib/out/targets/blockmap/blockmap.js),
|
|
4
|
+
* which replaced the Go-based app-builder.exe blockmap command.
|
|
5
|
+
*
|
|
6
|
+
* The output format is identical (blockmap v2 JSON), so the generated
|
|
7
|
+
* .blockmap files are fully compatible with electron-updater.
|
|
8
|
+
*/
|
|
9
|
+
export declare function buildBlockMap(inFile: string, compressionFormat: string, outFile?: string | null): Promise<{
|
|
10
|
+
sha512: string;
|
|
11
|
+
size: number;
|
|
12
|
+
blockMapSize?: number;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { NodePlatform } from '../shared/platform.ts';
|
|
2
|
+
export interface UpdateMetadataOptions {
|
|
3
|
+
filePath: string;
|
|
4
|
+
version: string;
|
|
5
|
+
outputDir: string;
|
|
6
|
+
platform: NodePlatform;
|
|
7
|
+
blockMapSize?: number;
|
|
8
|
+
channel?: string;
|
|
9
|
+
extraFiles?: string[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Derive the update channel from a semver prerelease suffix
|
|
13
|
+
* (for example, 1.2.3-beta.1 yields "beta").
|
|
14
|
+
*/
|
|
15
|
+
export declare function getUpdateChannel(version: string, explicitChannel?: string, defaultChannel?: string): string;
|
|
16
|
+
export declare function getUpdateMetadataFileName(version: string, explicitChannel?: string, platform?: NodePlatform, defaultChannel?: string): string;
|
|
17
|
+
export declare function generateUpdateMetadata({ filePath, version, outputDir, platform, blockMapSize, channel, extraFiles, }: UpdateMetadataOptions): {
|
|
18
|
+
metadataPath: string;
|
|
19
|
+
metadataFileName: string;
|
|
20
|
+
} | null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a semver string into the four-part numeric build version.
|
|
3
|
+
* NSIS VIProductVersion and PE version resources require the X.X.X.X format.
|
|
4
|
+
* The fourth segment prefers: explicit buildNumber param > prerelease number
|
|
5
|
+
* in the version string > CI build number (only when CI=true).
|
|
6
|
+
*/
|
|
7
|
+
export declare function getBuildVersion(version: string, buildNumber?: number | string): string;
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cross-packer",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Cross-platform Electron app packager — assemble Windows (NSIS), macOS (.app/.zip) and Linux (.deb) artifacts on any host OS, without electron-builder.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"private": false,
|
|
7
|
+
"license": "AGPL-3.0-or-later",
|
|
8
|
+
"author": "SgDylan",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/Sg4Dylan/cross-packer.git"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/Sg4Dylan/cross-packer#readme",
|
|
14
|
+
"bugs": "https://github.com/Sg4Dylan/cross-packer/issues",
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=20"
|
|
17
|
+
},
|
|
18
|
+
"bin": {
|
|
19
|
+
"cross-packer": "src/cli.ts"
|
|
20
|
+
},
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./src/index.ts",
|
|
24
|
+
"default": "./src/index.ts"
|
|
25
|
+
},
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@noble/hashes": "^2.4.0",
|
|
30
|
+
"7zip-bin": "^5.2.0",
|
|
31
|
+
"archiver": "^8.0.0",
|
|
32
|
+
"chromium-pickle-js": "^0.2.0",
|
|
33
|
+
"fs-extra": "^11.4.0",
|
|
34
|
+
"js-yaml": "^5.4.2",
|
|
35
|
+
"jszip": "^3.10.2",
|
|
36
|
+
"minimatch": "^10.2.6",
|
|
37
|
+
"plist": "5.0.0",
|
|
38
|
+
"resedit": "^3.1.0",
|
|
39
|
+
"tar": "^7.5.22"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@biomejs/biome": "^2.5.13",
|
|
43
|
+
"@types/archiver": "^8.0.0",
|
|
44
|
+
"@types/fs-extra": "^11.0.4",
|
|
45
|
+
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
46
|
+
"electron": "42.7.1",
|
|
47
|
+
"tsx": "^4.23.13"
|
|
48
|
+
},
|
|
49
|
+
"files": [
|
|
50
|
+
"src",
|
|
51
|
+
"dist",
|
|
52
|
+
"templates",
|
|
53
|
+
"README.md",
|
|
54
|
+
"LICENSE"
|
|
55
|
+
],
|
|
56
|
+
"scripts": {
|
|
57
|
+
"test": "tsx --test \"test/*.test.ts\"",
|
|
58
|
+
"build": "tsgo -p tsconfig.build.json",
|
|
59
|
+
"lint": "biome check .",
|
|
60
|
+
"lint:fix": "biome check --write .",
|
|
61
|
+
"format": "biome format --write .",
|
|
62
|
+
"typecheck": "npx tsgo --noEmit"
|
|
63
|
+
},
|
|
64
|
+
"keywords": [
|
|
65
|
+
"electron",
|
|
66
|
+
"packaging",
|
|
67
|
+
"nsis",
|
|
68
|
+
"deb",
|
|
69
|
+
"cross-platform"
|
|
70
|
+
]
|
|
71
|
+
}
|