@depup/nexe 5.0.0-beta.4-depup.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 +20 -0
- package/README.md +40 -0
- package/changes.json +46 -0
- package/index.js +32 -0
- package/lib/compiler.d.ts +105 -0
- package/lib/compiler.js +289 -0
- package/lib/fs/README.md +40 -0
- package/lib/fs/SnapshotZipFS.d.ts +228 -0
- package/lib/fs/SnapshotZipFS.js +283 -0
- package/lib/fs/bootstrap.js +20 -0
- package/lib/fs/bundle.d.ts +17 -0
- package/lib/fs/bundle.js +51 -0
- package/lib/fs/package.json +15 -0
- package/lib/fs/patch.bundle.js +7823 -0
- package/lib/fs/patch.bundle.js.map +1 -0
- package/lib/fs/patch.d.ts +12 -0
- package/lib/fs/patch.js +122 -0
- package/lib/logger.d.ts +18 -0
- package/lib/logger.js +60 -0
- package/lib/nexe.d.ts +5 -0
- package/lib/nexe.js +53 -0
- package/lib/options.d.ts +56 -0
- package/lib/options.js +244 -0
- package/lib/patches/boot-nexe.d.ts +5 -0
- package/lib/patches/boot-nexe.js +38 -0
- package/lib/patches/build-fixes.d.ts +2 -0
- package/lib/patches/build-fixes.js +22 -0
- package/lib/patches/disable-node-cli.d.ts +2 -0
- package/lib/patches/disable-node-cli.js +48 -0
- package/lib/patches/flags.d.ts +2 -0
- package/lib/patches/flags.js +22 -0
- package/lib/patches/gyp.d.ts +2 -0
- package/lib/patches/gyp.js +25 -0
- package/lib/patches/ico.d.ts +2 -0
- package/lib/patches/ico.js +24 -0
- package/lib/patches/index.d.ts +3 -0
- package/lib/patches/index.js +15 -0
- package/lib/patches/node-rc.d.ts +2 -0
- package/lib/patches/node-rc.js +37 -0
- package/lib/patches/snapshot.d.ts +2 -0
- package/lib/patches/snapshot.js +25 -0
- package/lib/patches/third-party-main.d.ts +2 -0
- package/lib/patches/third-party-main.js +99 -0
- package/lib/releases.d.ts +15 -0
- package/lib/releases.js +57 -0
- package/lib/steps/artifacts.d.ts +11 -0
- package/lib/steps/artifacts.js +89 -0
- package/lib/steps/bundle.d.ts +2 -0
- package/lib/steps/bundle.js +104 -0
- package/lib/steps/clean.d.ts +2 -0
- package/lib/steps/clean.js +30 -0
- package/lib/steps/cli.d.ts +12 -0
- package/lib/steps/cli.js +55 -0
- package/lib/steps/download.d.ts +7 -0
- package/lib/steps/download.js +76 -0
- package/lib/steps/resource.d.ts +2 -0
- package/lib/steps/resource.js +38 -0
- package/lib/steps/shim.d.ts +2 -0
- package/lib/steps/shim.js +45 -0
- package/lib/target.d.ts +11 -0
- package/lib/target.js +82 -0
- package/lib/util.d.ts +29 -0
- package/lib/util.js +104 -0
- package/package.json +148 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
import { Libzip } from '@yarnpkg/libzip';
|
|
5
|
+
import { FakeFS, PortablePath, RmdirOptions, OpendirOptions, BasePortableFakeFS, Dirent, MkdirOptions, FSPath, Filename, CustomDir } from '@yarnpkg/fslib';
|
|
6
|
+
import { ZipFS } from '@yarnpkg/libzip';
|
|
7
|
+
export type SnapshotZipFSOptions = {
|
|
8
|
+
baseFs: FakeFS<PortablePath>;
|
|
9
|
+
libzip: Libzip | (() => Libzip);
|
|
10
|
+
zipFs: ZipFS;
|
|
11
|
+
root: string;
|
|
12
|
+
};
|
|
13
|
+
export declare class SnapshotZipFS extends BasePortableFakeFS {
|
|
14
|
+
zipFs: ZipFS;
|
|
15
|
+
baseFs: FakeFS<PortablePath>;
|
|
16
|
+
root: string;
|
|
17
|
+
magic: number;
|
|
18
|
+
constructor(opts: SnapshotZipFSOptions);
|
|
19
|
+
private readonly fdMap;
|
|
20
|
+
private nextFd;
|
|
21
|
+
makeCallPromise<T>(p: FSPath<PortablePath>, discard: () => Promise<T>, accept: (zipFS: ZipFS, zipInfo: {
|
|
22
|
+
subPath: PortablePath;
|
|
23
|
+
}) => Promise<T>, { requireSubpath }?: {
|
|
24
|
+
requireSubpath?: boolean;
|
|
25
|
+
}): Promise<T>;
|
|
26
|
+
makeCallSync<T>(p: FSPath<PortablePath>, discard: () => T, accept: (zipFS: ZipFS, zipInfo: {
|
|
27
|
+
subPath: PortablePath;
|
|
28
|
+
archivePath: string;
|
|
29
|
+
}) => T, { requireSubpath }?: {
|
|
30
|
+
requireSubpath?: boolean;
|
|
31
|
+
}): T;
|
|
32
|
+
realpathPromise(p: PortablePath): Promise<PortablePath>;
|
|
33
|
+
realpathSync(p: PortablePath): PortablePath;
|
|
34
|
+
findZip(p: PortablePath): {
|
|
35
|
+
subPath: PortablePath;
|
|
36
|
+
} | undefined;
|
|
37
|
+
copyFilePromise(sourceP: PortablePath, destP: PortablePath, flags?: number): Promise<void>;
|
|
38
|
+
copyFileSync(sourceP: PortablePath, destP: PortablePath, flags?: number): void;
|
|
39
|
+
readdirPromise(p: PortablePath): Promise<Array<Filename>>;
|
|
40
|
+
readdirPromise(p: PortablePath, opts: {
|
|
41
|
+
withFileTypes: false;
|
|
42
|
+
} | null): Promise<Array<Filename>>;
|
|
43
|
+
readdirPromise(p: PortablePath, opts: {
|
|
44
|
+
withFileTypes: true;
|
|
45
|
+
}): Promise<Array<Dirent>>;
|
|
46
|
+
readdirPromise(p: PortablePath, opts: {
|
|
47
|
+
withFileTypes: boolean;
|
|
48
|
+
}): Promise<Array<Filename> | Array<Dirent>>;
|
|
49
|
+
readdirSync(p: PortablePath): Array<Filename>;
|
|
50
|
+
readdirSync(p: PortablePath, opts: {
|
|
51
|
+
withFileTypes: false;
|
|
52
|
+
} | null): Array<Filename>;
|
|
53
|
+
readdirSync(p: PortablePath, opts: {
|
|
54
|
+
withFileTypes: true;
|
|
55
|
+
}): Array<Dirent>;
|
|
56
|
+
readdirSync(p: PortablePath, opts: {
|
|
57
|
+
withFileTypes: boolean;
|
|
58
|
+
}): Array<Filename> | Array<Dirent>;
|
|
59
|
+
mkdirPromise(p: PortablePath, opts?: MkdirOptions): Promise<string | undefined>;
|
|
60
|
+
mkdirSync(p: PortablePath, opts?: MkdirOptions): string | undefined;
|
|
61
|
+
rmdirPromise(p: PortablePath, opts?: RmdirOptions): Promise<void>;
|
|
62
|
+
rmdirSync(p: PortablePath, opts?: RmdirOptions): void;
|
|
63
|
+
opendirPromise(p: PortablePath, opts?: OpendirOptions): Promise<CustomDir<PortablePath>>;
|
|
64
|
+
opendirSync(p: PortablePath, opts?: OpendirOptions): CustomDir<PortablePath>;
|
|
65
|
+
accessPromise: (p: PortablePath, mode?: number | undefined) => Promise<void>;
|
|
66
|
+
accessSync: (p: PortablePath, mode?: number | undefined) => void;
|
|
67
|
+
appendFilePromise: (p: FSPath<PortablePath>, content: string | Uint8Array, opts?: import("@yarnpkg/fslib").WriteFileOptions | undefined) => Promise<void>;
|
|
68
|
+
appendFileSync: (p: FSPath<PortablePath>, content: string | Uint8Array, opts?: import("@yarnpkg/fslib").WriteFileOptions | undefined) => void;
|
|
69
|
+
chmodPromise: (p: PortablePath, mask: number) => Promise<void>;
|
|
70
|
+
chmodSync: (p: PortablePath, mask: number) => void;
|
|
71
|
+
fchmodPromise: (fd: number, mask: number) => Promise<void>;
|
|
72
|
+
fchmodSync: (fd: number, mask: number) => void;
|
|
73
|
+
chownPromise: (p: PortablePath, uid: number, gid: number) => Promise<void>;
|
|
74
|
+
chownSync: (p: PortablePath, uid: number, gid: number) => void;
|
|
75
|
+
fchownPromise: (fd: number, uid: number, gid: number) => Promise<void>;
|
|
76
|
+
fchownSync: (fd: number, uid: number, gid: number) => void;
|
|
77
|
+
closePromise: (fd: number) => Promise<void>;
|
|
78
|
+
closeSync: (fd: number) => void;
|
|
79
|
+
createReadStream: (p: PortablePath | null, opts?: Partial<{
|
|
80
|
+
encoding: BufferEncoding;
|
|
81
|
+
fd: number;
|
|
82
|
+
}> | undefined) => import("fs").ReadStream;
|
|
83
|
+
createWriteStream: (p: PortablePath | null, opts?: Partial<{
|
|
84
|
+
encoding: BufferEncoding;
|
|
85
|
+
fd: number;
|
|
86
|
+
flags: "a";
|
|
87
|
+
}> | undefined) => import("fs").WriteStream;
|
|
88
|
+
existsPromise: (p: PortablePath) => Promise<boolean>;
|
|
89
|
+
existsSync: (p: PortablePath) => boolean;
|
|
90
|
+
fstatPromise: {
|
|
91
|
+
(fd: number): Promise<import("fs").Stats>;
|
|
92
|
+
(fd: number, opts: {
|
|
93
|
+
bigint: true;
|
|
94
|
+
}): Promise<import("fs").BigIntStats>;
|
|
95
|
+
(fd: number, opts?: {
|
|
96
|
+
bigint: boolean;
|
|
97
|
+
} | undefined): Promise<import("fs").Stats | import("fs").BigIntStats>;
|
|
98
|
+
};
|
|
99
|
+
fstatSync: {
|
|
100
|
+
(fd: number): import("fs").Stats;
|
|
101
|
+
(fd: number, opts: {
|
|
102
|
+
bigint: true;
|
|
103
|
+
}): import("fs").BigIntStats;
|
|
104
|
+
(fd: number, opts?: {
|
|
105
|
+
bigint: boolean;
|
|
106
|
+
} | undefined): import("fs").Stats | import("fs").BigIntStats;
|
|
107
|
+
};
|
|
108
|
+
getExtractHint: (hints: import("@yarnpkg/fslib").ExtractHintOptions) => boolean;
|
|
109
|
+
getRealPath: () => PortablePath;
|
|
110
|
+
linkPromise: (existingP: PortablePath, newP: PortablePath) => Promise<void>;
|
|
111
|
+
linkSync: (existingP: PortablePath, newP: PortablePath) => void;
|
|
112
|
+
lstatPromise: {
|
|
113
|
+
(p: PortablePath): Promise<import("fs").Stats>;
|
|
114
|
+
(p: PortablePath, opts: (import("@yarnpkg/fslib").StatOptions & {
|
|
115
|
+
bigint?: false | undefined;
|
|
116
|
+
}) | undefined): Promise<import("fs").Stats>;
|
|
117
|
+
(p: PortablePath, opts: import("@yarnpkg/fslib").StatOptions & {
|
|
118
|
+
bigint: true;
|
|
119
|
+
}): Promise<import("fs").BigIntStats>;
|
|
120
|
+
};
|
|
121
|
+
lstatSync: {
|
|
122
|
+
(p: PortablePath): import("fs").Stats;
|
|
123
|
+
(p: PortablePath, opts?: (import("@yarnpkg/fslib").StatSyncOptions & {
|
|
124
|
+
bigint?: false | undefined;
|
|
125
|
+
throwIfNoEntry: false;
|
|
126
|
+
}) | undefined): import("fs").Stats | undefined;
|
|
127
|
+
(p: PortablePath, opts: import("@yarnpkg/fslib").StatSyncOptions & {
|
|
128
|
+
bigint: true;
|
|
129
|
+
throwIfNoEntry: false;
|
|
130
|
+
}): import("fs").BigIntStats | undefined;
|
|
131
|
+
(p: PortablePath, opts?: (import("@yarnpkg/fslib").StatSyncOptions & {
|
|
132
|
+
bigint?: false | undefined;
|
|
133
|
+
}) | undefined): import("fs").Stats;
|
|
134
|
+
(p: PortablePath, opts: import("@yarnpkg/fslib").StatSyncOptions & {
|
|
135
|
+
bigint: true;
|
|
136
|
+
}): import("fs").BigIntStats;
|
|
137
|
+
(p: PortablePath, opts: import("@yarnpkg/fslib").StatSyncOptions & {
|
|
138
|
+
bigint: boolean;
|
|
139
|
+
throwIfNoEntry?: false | undefined;
|
|
140
|
+
}): import("fs").Stats | import("fs").BigIntStats;
|
|
141
|
+
};
|
|
142
|
+
openPromise: (p: PortablePath, flags: string, mode?: number | undefined) => Promise<number>;
|
|
143
|
+
openSync: (p: PortablePath, flags: string, mode?: number | undefined) => number;
|
|
144
|
+
readFilePromise: {
|
|
145
|
+
(p: FSPath<PortablePath>, encoding?: null | undefined): Promise<Buffer>;
|
|
146
|
+
(p: FSPath<PortablePath>, encoding: BufferEncoding): Promise<string>;
|
|
147
|
+
(p: FSPath<PortablePath>, encoding?: BufferEncoding | null | undefined): Promise<string | Buffer>;
|
|
148
|
+
};
|
|
149
|
+
readFileSync: {
|
|
150
|
+
(p: FSPath<PortablePath>, encoding?: null | undefined): Buffer;
|
|
151
|
+
(p: FSPath<PortablePath>, encoding: BufferEncoding): string;
|
|
152
|
+
(p: FSPath<PortablePath>, encoding?: BufferEncoding | null | undefined): string | Buffer;
|
|
153
|
+
};
|
|
154
|
+
readlinkPromise: (p: PortablePath) => Promise<PortablePath>;
|
|
155
|
+
readlinkSync: (p: PortablePath) => PortablePath;
|
|
156
|
+
readPromise: (fd: number, buffer: Buffer, offset: number, length: number, position: number) => Promise<number>;
|
|
157
|
+
readSync: (fd: number, buffer: Buffer, offset: number, length: number, position: number) => number;
|
|
158
|
+
renamePromise: (oldP: PortablePath, newP: PortablePath) => Promise<void>;
|
|
159
|
+
renameSync: (oldP: PortablePath, newP: PortablePath) => void;
|
|
160
|
+
resolve: (p: PortablePath) => PortablePath;
|
|
161
|
+
statPromise: {
|
|
162
|
+
(p: PortablePath): Promise<import("fs").Stats>;
|
|
163
|
+
(p: PortablePath, opts: (import("@yarnpkg/fslib").StatOptions & {
|
|
164
|
+
bigint?: false | undefined;
|
|
165
|
+
}) | undefined): Promise<import("fs").Stats>;
|
|
166
|
+
(p: PortablePath, opts: import("@yarnpkg/fslib").StatOptions & {
|
|
167
|
+
bigint: true;
|
|
168
|
+
}): Promise<import("fs").BigIntStats>;
|
|
169
|
+
(p: PortablePath, opts?: import("@yarnpkg/fslib").StatOptions | undefined): Promise<import("fs").Stats | import("fs").BigIntStats>;
|
|
170
|
+
};
|
|
171
|
+
statSync: {
|
|
172
|
+
(p: PortablePath): import("fs").Stats;
|
|
173
|
+
(p: PortablePath, opts?: (import("@yarnpkg/fslib").StatSyncOptions & {
|
|
174
|
+
bigint?: false | undefined;
|
|
175
|
+
throwIfNoEntry: false;
|
|
176
|
+
}) | undefined): import("fs").Stats | undefined;
|
|
177
|
+
(p: PortablePath, opts: import("@yarnpkg/fslib").StatSyncOptions & {
|
|
178
|
+
bigint: true;
|
|
179
|
+
throwIfNoEntry: false;
|
|
180
|
+
}): import("fs").BigIntStats | undefined;
|
|
181
|
+
(p: PortablePath, opts?: (import("@yarnpkg/fslib").StatSyncOptions & {
|
|
182
|
+
bigint?: false | undefined;
|
|
183
|
+
}) | undefined): import("fs").Stats;
|
|
184
|
+
(p: PortablePath, opts: import("@yarnpkg/fslib").StatSyncOptions & {
|
|
185
|
+
bigint: true;
|
|
186
|
+
}): import("fs").BigIntStats;
|
|
187
|
+
(p: PortablePath, opts: import("@yarnpkg/fslib").StatSyncOptions & {
|
|
188
|
+
bigint: boolean;
|
|
189
|
+
throwIfNoEntry?: false | undefined;
|
|
190
|
+
}): import("fs").Stats | import("fs").BigIntStats;
|
|
191
|
+
};
|
|
192
|
+
symlinkPromise: (target: PortablePath, p: PortablePath, type?: import("@yarnpkg/fslib").SymlinkType | undefined) => Promise<void>;
|
|
193
|
+
symlinkSync: (target: PortablePath, p: PortablePath, type?: import("@yarnpkg/fslib").SymlinkType | undefined) => void;
|
|
194
|
+
truncatePromise: (p: PortablePath, len?: number | undefined) => Promise<void>;
|
|
195
|
+
truncateSync: (p: PortablePath, len?: number | undefined) => void;
|
|
196
|
+
ftruncatePromise: (fd: number, len?: number | undefined) => Promise<void>;
|
|
197
|
+
ftruncateSync: (fd: number, len?: number | undefined) => void;
|
|
198
|
+
unlinkPromise: (p: PortablePath) => Promise<void>;
|
|
199
|
+
unlinkSync: (p: PortablePath) => void;
|
|
200
|
+
unwatchFile: (p: PortablePath, cb?: import("@yarnpkg/fslib").WatchFileCallback | undefined) => void;
|
|
201
|
+
utimesPromise: (p: PortablePath, atime: string | number | Date, mtime: string | number | Date) => Promise<void>;
|
|
202
|
+
utimesSync: (p: PortablePath, atime: string | number | Date, mtime: string | number | Date) => void;
|
|
203
|
+
lutimesPromise: (p: PortablePath, atime: string | number | Date, mtime: string | number | Date) => Promise<void>;
|
|
204
|
+
lutimesSync: (p: PortablePath, atime: string | number | Date, mtime: string | number | Date) => void;
|
|
205
|
+
watch: {
|
|
206
|
+
(p: PortablePath, cb?: import("@yarnpkg/fslib").WatchCallback | undefined): import("@yarnpkg/fslib").Watcher;
|
|
207
|
+
(p: PortablePath, opts: import("@yarnpkg/fslib").WatchOptions, cb?: import("@yarnpkg/fslib").WatchCallback | undefined): import("@yarnpkg/fslib").Watcher;
|
|
208
|
+
};
|
|
209
|
+
watchFile: {
|
|
210
|
+
(p: PortablePath, cb: import("@yarnpkg/fslib").WatchFileCallback): import("@yarnpkg/fslib").StatWatcher;
|
|
211
|
+
(p: PortablePath, opts: Partial<{
|
|
212
|
+
bigint: boolean;
|
|
213
|
+
persistent: boolean;
|
|
214
|
+
interval: number;
|
|
215
|
+
}>, cb: import("@yarnpkg/fslib").WatchFileCallback): import("@yarnpkg/fslib").StatWatcher;
|
|
216
|
+
};
|
|
217
|
+
writeFilePromise: (p: FSPath<PortablePath>, content: string | NodeJS.ArrayBufferView, opts?: import("@yarnpkg/fslib").WriteFileOptions | undefined) => Promise<void>;
|
|
218
|
+
writeFileSync: (p: FSPath<PortablePath>, content: string | NodeJS.ArrayBufferView, opts?: import("@yarnpkg/fslib").WriteFileOptions | undefined) => void;
|
|
219
|
+
writePromise: {
|
|
220
|
+
(fd: number, buffer: Buffer, offset?: number | undefined, length?: number | undefined, position?: number | undefined): Promise<number>;
|
|
221
|
+
(fd: number, buffer: string, position?: number | undefined): Promise<number>;
|
|
222
|
+
};
|
|
223
|
+
writeSync: {
|
|
224
|
+
(fd: number, buffer: Buffer, offset?: number | undefined, length?: number | undefined, position?: number | undefined): number;
|
|
225
|
+
(fd: number, buffer: string, position?: number | undefined): number;
|
|
226
|
+
};
|
|
227
|
+
remapFd: any;
|
|
228
|
+
}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SnapshotZipFS = void 0;
|
|
13
|
+
const fslib_1 = require("@yarnpkg/fslib");
|
|
14
|
+
const libzip_1 = require("@yarnpkg/libzip");
|
|
15
|
+
const path_1 = require("path");
|
|
16
|
+
const fs_1 = require("fs");
|
|
17
|
+
const uniqBy = (arr, pick) => {
|
|
18
|
+
const seen = new Set();
|
|
19
|
+
return arr.filter((x) => {
|
|
20
|
+
const key = pick(x);
|
|
21
|
+
if (seen.has(key))
|
|
22
|
+
return false;
|
|
23
|
+
seen.add(key);
|
|
24
|
+
return true;
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
function uniqReaddir(arr) {
|
|
28
|
+
return uniqBy(arr, (s) => (typeof s === 'string' ? s : s.name));
|
|
29
|
+
}
|
|
30
|
+
class SnapshotZipFS extends fslib_1.BasePortableFakeFS {
|
|
31
|
+
constructor(opts) {
|
|
32
|
+
super();
|
|
33
|
+
this.fdMap = new Map();
|
|
34
|
+
this.nextFd = 3;
|
|
35
|
+
this.accessPromise = libzip_1.ZipOpenFS.prototype.accessPromise;
|
|
36
|
+
this.accessSync = libzip_1.ZipOpenFS.prototype.accessSync;
|
|
37
|
+
this.appendFilePromise = libzip_1.ZipOpenFS.prototype.appendFilePromise;
|
|
38
|
+
this.appendFileSync = libzip_1.ZipOpenFS.prototype.appendFileSync;
|
|
39
|
+
this.chmodPromise = libzip_1.ZipOpenFS.prototype.chmodPromise;
|
|
40
|
+
this.chmodSync = libzip_1.ZipOpenFS.prototype.chmodSync;
|
|
41
|
+
this.fchmodPromise = libzip_1.ZipOpenFS.prototype.fchmodPromise;
|
|
42
|
+
this.fchmodSync = libzip_1.ZipOpenFS.prototype.fchmodSync;
|
|
43
|
+
this.chownPromise = libzip_1.ZipOpenFS.prototype.chownPromise;
|
|
44
|
+
this.chownSync = libzip_1.ZipOpenFS.prototype.chownSync;
|
|
45
|
+
this.fchownPromise = libzip_1.ZipOpenFS.prototype.fchownPromise;
|
|
46
|
+
this.fchownSync = libzip_1.ZipOpenFS.prototype.fchownSync;
|
|
47
|
+
this.closePromise = libzip_1.ZipOpenFS.prototype.closePromise;
|
|
48
|
+
this.closeSync = libzip_1.ZipOpenFS.prototype.closeSync;
|
|
49
|
+
this.createReadStream = libzip_1.ZipOpenFS.prototype.createReadStream;
|
|
50
|
+
this.createWriteStream = libzip_1.ZipOpenFS.prototype.createWriteStream;
|
|
51
|
+
this.existsPromise = libzip_1.ZipOpenFS.prototype.existsPromise;
|
|
52
|
+
this.existsSync = libzip_1.ZipOpenFS.prototype.existsSync;
|
|
53
|
+
this.fstatPromise = libzip_1.ZipOpenFS.prototype.fstatPromise;
|
|
54
|
+
this.fstatSync = libzip_1.ZipOpenFS.prototype.fstatSync;
|
|
55
|
+
this.getExtractHint = libzip_1.ZipOpenFS.prototype.getExtractHint;
|
|
56
|
+
this.getRealPath = libzip_1.ZipOpenFS.prototype.getRealPath;
|
|
57
|
+
this.linkPromise = libzip_1.ZipOpenFS.prototype.linkPromise;
|
|
58
|
+
this.linkSync = libzip_1.ZipOpenFS.prototype.linkSync;
|
|
59
|
+
this.lstatPromise = libzip_1.ZipOpenFS.prototype.lstatPromise;
|
|
60
|
+
this.lstatSync = libzip_1.ZipOpenFS.prototype.lstatSync;
|
|
61
|
+
this.openPromise = libzip_1.ZipOpenFS.prototype.openPromise;
|
|
62
|
+
this.openSync = libzip_1.ZipOpenFS.prototype.openSync;
|
|
63
|
+
this.readFilePromise = libzip_1.ZipOpenFS.prototype.readFilePromise;
|
|
64
|
+
this.readFileSync = libzip_1.ZipOpenFS.prototype.readFileSync;
|
|
65
|
+
this.readlinkPromise = libzip_1.ZipOpenFS.prototype.readlinkPromise;
|
|
66
|
+
this.readlinkSync = libzip_1.ZipOpenFS.prototype.readlinkSync;
|
|
67
|
+
this.readPromise = libzip_1.ZipOpenFS.prototype.readPromise;
|
|
68
|
+
this.readSync = libzip_1.ZipOpenFS.prototype.readSync;
|
|
69
|
+
this.renamePromise = libzip_1.ZipOpenFS.prototype.renamePromise;
|
|
70
|
+
this.renameSync = libzip_1.ZipOpenFS.prototype.renameSync;
|
|
71
|
+
this.resolve = libzip_1.ZipOpenFS.prototype.resolve;
|
|
72
|
+
this.statPromise = libzip_1.ZipOpenFS.prototype.statPromise;
|
|
73
|
+
this.statSync = libzip_1.ZipOpenFS.prototype.statSync;
|
|
74
|
+
this.symlinkPromise = libzip_1.ZipOpenFS.prototype.symlinkPromise;
|
|
75
|
+
this.symlinkSync = libzip_1.ZipOpenFS.prototype.symlinkSync;
|
|
76
|
+
this.truncatePromise = libzip_1.ZipOpenFS.prototype.truncatePromise;
|
|
77
|
+
this.truncateSync = libzip_1.ZipOpenFS.prototype.truncateSync;
|
|
78
|
+
this.ftruncatePromise = libzip_1.ZipOpenFS.prototype.ftruncatePromise;
|
|
79
|
+
this.ftruncateSync = libzip_1.ZipOpenFS.prototype.ftruncateSync;
|
|
80
|
+
this.unlinkPromise = libzip_1.ZipOpenFS.prototype.unlinkPromise;
|
|
81
|
+
this.unlinkSync = libzip_1.ZipOpenFS.prototype.unlinkSync;
|
|
82
|
+
this.unwatchFile = libzip_1.ZipOpenFS.prototype.unwatchFile;
|
|
83
|
+
this.utimesPromise = libzip_1.ZipOpenFS.prototype.utimesPromise;
|
|
84
|
+
this.utimesSync = libzip_1.ZipOpenFS.prototype.utimesSync;
|
|
85
|
+
this.lutimesPromise = libzip_1.ZipOpenFS.prototype.utimesPromise;
|
|
86
|
+
this.lutimesSync = libzip_1.ZipOpenFS.prototype.utimesSync;
|
|
87
|
+
this.watch = libzip_1.ZipOpenFS.prototype.watch;
|
|
88
|
+
this.watchFile = libzip_1.ZipOpenFS.prototype.watchFile;
|
|
89
|
+
this.writeFilePromise = libzip_1.ZipOpenFS.prototype.writeFilePromise;
|
|
90
|
+
this.writeFileSync = libzip_1.ZipOpenFS.prototype.writeFileSync;
|
|
91
|
+
this.writePromise = libzip_1.ZipOpenFS.prototype.writePromise;
|
|
92
|
+
this.writeSync = libzip_1.ZipOpenFS.prototype.writeSync;
|
|
93
|
+
// @ts-ignore
|
|
94
|
+
this.remapFd = libzip_1.ZipOpenFS.prototype.remapFd;
|
|
95
|
+
this.zipFs = opts.zipFs;
|
|
96
|
+
this.baseFs = opts.baseFs;
|
|
97
|
+
this.root = opts.root;
|
|
98
|
+
this.magic = 0x2a << 24;
|
|
99
|
+
}
|
|
100
|
+
makeCallPromise(p, discard, accept, { requireSubpath = true } = {}) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
if (typeof p !== 'string')
|
|
103
|
+
return yield discard();
|
|
104
|
+
const normalizedP = this.resolve(p);
|
|
105
|
+
const zipInfo = this.findZip(normalizedP);
|
|
106
|
+
if (!zipInfo)
|
|
107
|
+
return yield discard();
|
|
108
|
+
if (requireSubpath && zipInfo.subPath === '/')
|
|
109
|
+
return yield discard();
|
|
110
|
+
return yield accept(this.zipFs, zipInfo);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
makeCallSync(p, discard, accept, { requireSubpath = true } = {}) {
|
|
114
|
+
if (typeof p !== 'string')
|
|
115
|
+
return discard();
|
|
116
|
+
const normalizedP = this.resolve(p);
|
|
117
|
+
const zipInfo = this.findZip(normalizedP);
|
|
118
|
+
if (!zipInfo)
|
|
119
|
+
return discard();
|
|
120
|
+
if (requireSubpath && zipInfo.subPath === '/')
|
|
121
|
+
return discard();
|
|
122
|
+
return accept(this.zipFs, Object.assign({ archivePath: '' }, zipInfo));
|
|
123
|
+
}
|
|
124
|
+
realpathPromise(p) {
|
|
125
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
return yield this.realpathSync(p);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
realpathSync(p) {
|
|
130
|
+
return this.makeCallSync(p, () => this.baseFs.realpathSync(p), (zipFs, { subPath }) => {
|
|
131
|
+
if (zipFs.lstatSync(subPath).isSymbolicLink()) {
|
|
132
|
+
return zipFs.realpathSync(subPath);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
// return the original path in case it wasn't under /snapshot, e.g. if it was for a node module - otherwise the node module parent path is the wrong one (and other things resolve relative to that)
|
|
136
|
+
return p;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
findZip(p) {
|
|
141
|
+
p = this.resolve(p);
|
|
142
|
+
const snapshotPP = fslib_1.npath.toPortablePath('/snapshot');
|
|
143
|
+
const pathsToTry = Array.from(new Set([
|
|
144
|
+
p,
|
|
145
|
+
(0, path_1.resolve)('/snapshot', p),
|
|
146
|
+
fslib_1.ppath.resolve(snapshotPP, fslib_1.npath.toPortablePath(fslib_1.npath.relative(fslib_1.npath.fromPortablePath(this.root), fslib_1.npath.fromPortablePath(p)))),
|
|
147
|
+
fslib_1.ppath.resolve(snapshotPP, fslib_1.npath.toPortablePath(fslib_1.npath.relative((0, path_1.toNamespacedPath)(fslib_1.npath.fromPortablePath(this.root)), (0, path_1.toNamespacedPath)(fslib_1.npath.fromPortablePath(p))))),
|
|
148
|
+
fslib_1.ppath.resolve(snapshotPP, fslib_1.npath.toPortablePath(fslib_1.npath.relative(fslib_1.npath.fromPortablePath(process.cwd()), fslib_1.npath.fromPortablePath(p)))),
|
|
149
|
+
fslib_1.ppath.resolve(snapshotPP, fslib_1.npath.toPortablePath(fslib_1.npath.relative((0, path_1.toNamespacedPath)(fslib_1.npath.fromPortablePath(process.cwd())), (0, path_1.toNamespacedPath)(fslib_1.npath.fromPortablePath(p))))),
|
|
150
|
+
]));
|
|
151
|
+
for (const path of pathsToTry) {
|
|
152
|
+
const portablePath = fslib_1.npath.toPortablePath(path);
|
|
153
|
+
if (this.zipFs.existsSync(portablePath)) {
|
|
154
|
+
return {
|
|
155
|
+
subPath: portablePath,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
copyFilePromise(sourceP, destP, flags = 0) {
|
|
161
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
162
|
+
const fallback = (sourceFs, sourceP, destFs, destP) => __awaiter(this, void 0, void 0, function* () {
|
|
163
|
+
if ((flags & fs_1.constants.COPYFILE_FICLONE_FORCE) !== 0)
|
|
164
|
+
throw Object.assign(new Error(`EXDEV: cross-device clone not permitted, copyfile '${sourceP}' -> ${destP}'`), { code: `EXDEV` });
|
|
165
|
+
if (flags & fs_1.constants.COPYFILE_EXCL && (yield this.existsPromise(sourceP)))
|
|
166
|
+
throw Object.assign(new Error(`EEXIST: file already exists, copyfile '${sourceP}' -> '${destP}'`), { code: `EEXIST` });
|
|
167
|
+
let content;
|
|
168
|
+
try {
|
|
169
|
+
content = yield sourceFs.readFilePromise(sourceP);
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
throw Object.assign(new Error(`EINVAL: invalid argument, copyfile '${sourceP}' -> '${destP}'`), { code: `EINVAL` });
|
|
173
|
+
}
|
|
174
|
+
yield destFs.writeFilePromise(destP, content);
|
|
175
|
+
});
|
|
176
|
+
return yield this.makeCallPromise(sourceP, () => __awaiter(this, void 0, void 0, function* () {
|
|
177
|
+
return yield this.baseFs.copyFilePromise(sourceP, destP, flags);
|
|
178
|
+
}), (zipFsS, { subPath: subPathS }) => __awaiter(this, void 0, void 0, function* () {
|
|
179
|
+
return yield fallback(zipFsS, subPathS, this.baseFs, destP);
|
|
180
|
+
}));
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
copyFileSync(sourceP, destP, flags = 0) {
|
|
184
|
+
const fallback = (sourceFs, sourceP, destFs, destP) => {
|
|
185
|
+
if ((flags & fs_1.constants.COPYFILE_FICLONE_FORCE) !== 0)
|
|
186
|
+
throw Object.assign(new Error(`EXDEV: cross-device clone not permitted, copyfile '${sourceP}' -> ${destP}'`), { code: `EXDEV` });
|
|
187
|
+
if (flags & fs_1.constants.COPYFILE_EXCL && this.existsSync(sourceP))
|
|
188
|
+
throw Object.assign(new Error(`EEXIST: file already exists, copyfile '${sourceP}' -> '${destP}'`), { code: `EEXIST` });
|
|
189
|
+
let content;
|
|
190
|
+
try {
|
|
191
|
+
content = sourceFs.readFileSync(sourceP);
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
throw Object.assign(new Error(`EINVAL: invalid argument, copyfile '${sourceP}' -> '${destP}'`), { code: `EINVAL` });
|
|
195
|
+
}
|
|
196
|
+
destFs.writeFileSync(destP, content);
|
|
197
|
+
};
|
|
198
|
+
return this.makeCallSync(sourceP, () => {
|
|
199
|
+
return this.baseFs.copyFileSync(sourceP, destP, flags);
|
|
200
|
+
}, (zipFsS, { subPath: subPathS }) => {
|
|
201
|
+
return fallback(zipFsS, subPathS, this.baseFs, destP);
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
readdirPromise(p, opts) {
|
|
205
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
206
|
+
const fallback = () => __awaiter(this, void 0, void 0, function* () {
|
|
207
|
+
return yield this.baseFs.readdirPromise(p, opts);
|
|
208
|
+
});
|
|
209
|
+
return yield this.makeCallPromise(p, fallback, (zipFs, { subPath }) => __awaiter(this, void 0, void 0, function* () {
|
|
210
|
+
const fallbackPaths = yield fallback().catch(() => []);
|
|
211
|
+
return Promise.resolve(uniqReaddir(fallbackPaths.concat(yield zipFs.readdirPromise(subPath, opts))));
|
|
212
|
+
}), {
|
|
213
|
+
requireSubpath: false,
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
readdirSync(p, opts) {
|
|
218
|
+
const fallback = () => {
|
|
219
|
+
return this.baseFs.readdirSync(p, opts);
|
|
220
|
+
};
|
|
221
|
+
return this.makeCallSync(p, fallback, (zipFs, { subPath }) => {
|
|
222
|
+
let fallbackPaths = [];
|
|
223
|
+
try {
|
|
224
|
+
fallbackPaths = fallback();
|
|
225
|
+
}
|
|
226
|
+
catch (e) { }
|
|
227
|
+
return fallbackPaths.concat(uniqReaddir(zipFs.readdirSync(subPath, opts)));
|
|
228
|
+
}, {
|
|
229
|
+
requireSubpath: false,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
mkdirPromise(p, opts) {
|
|
233
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
234
|
+
return yield this.baseFs.mkdirPromise(p, opts);
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
mkdirSync(p, opts) {
|
|
238
|
+
return this.baseFs.mkdirSync(p, opts);
|
|
239
|
+
}
|
|
240
|
+
rmdirPromise(p, opts) {
|
|
241
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
242
|
+
return yield this.baseFs.rmdirPromise(p, opts);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
rmdirSync(p, opts) {
|
|
246
|
+
return this.baseFs.rmdirSync(p, opts);
|
|
247
|
+
}
|
|
248
|
+
opendirPromise(p, opts) {
|
|
249
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
250
|
+
return this.opendirSync(p, opts);
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
opendirSync(p, opts) {
|
|
254
|
+
const zipInfo = this.findZip(p);
|
|
255
|
+
let zipFsDir = null;
|
|
256
|
+
if (zipInfo) {
|
|
257
|
+
zipFsDir = this.zipFs.opendirSync(zipInfo.subPath);
|
|
258
|
+
}
|
|
259
|
+
let realFsDir = null;
|
|
260
|
+
try {
|
|
261
|
+
realFsDir = this.baseFs.opendirSync(p);
|
|
262
|
+
}
|
|
263
|
+
catch (e) {
|
|
264
|
+
if (!zipFsDir)
|
|
265
|
+
throw e;
|
|
266
|
+
}
|
|
267
|
+
const seen = new Set();
|
|
268
|
+
const nextDirent = () => {
|
|
269
|
+
const entry = (realFsDir === null || realFsDir === void 0 ? void 0 : realFsDir.readSync()) || (zipFsDir === null || zipFsDir === void 0 ? void 0 : zipFsDir.readSync());
|
|
270
|
+
if (entry && !seen.has(entry.name)) {
|
|
271
|
+
seen.add(entry.name);
|
|
272
|
+
return entry;
|
|
273
|
+
}
|
|
274
|
+
return null;
|
|
275
|
+
};
|
|
276
|
+
const onClose = () => {
|
|
277
|
+
zipFsDir === null || zipFsDir === void 0 ? void 0 : zipFsDir.closeSync();
|
|
278
|
+
realFsDir === null || realFsDir === void 0 ? void 0 : realFsDir.closeSync();
|
|
279
|
+
};
|
|
280
|
+
return new fslib_1.CustomDir(p, nextDirent, { onClose });
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
exports.SnapshotZipFS = SnapshotZipFS;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
if (true) {
|
|
2
|
+
const __nexe_patches = (process.nexe = { patches: {} }).patches
|
|
3
|
+
const slice = [].slice
|
|
4
|
+
const __nexe_noop_patch = function (original) {
|
|
5
|
+
const args = slice.call(arguments, 1)
|
|
6
|
+
return original.apply(this, args)
|
|
7
|
+
}
|
|
8
|
+
const __nexe_patch = function (obj, method, patch) {
|
|
9
|
+
const original = obj[method]
|
|
10
|
+
if (!original) return
|
|
11
|
+
__nexe_patches[method] = patch
|
|
12
|
+
obj[method] = function() {
|
|
13
|
+
const args = [original].concat(slice.call(arguments))
|
|
14
|
+
return __nexe_patches[method].apply(this, args)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
__nexe_patch((process).binding('fs'), 'internalModuleReadFile', __nexe_noop_patch)
|
|
18
|
+
__nexe_patch((process).binding('fs'), 'internalModuleReadJSON', __nexe_noop_patch)
|
|
19
|
+
__nexe_patch((process).binding('fs'), 'internalModuleStat', __nexe_noop_patch)
|
|
20
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { Readable } from 'stream';
|
|
4
|
+
import { File } from 'resolve-dependencies';
|
|
5
|
+
export declare function toStream(content: Buffer | string): Readable;
|
|
6
|
+
export declare class Bundle {
|
|
7
|
+
cwd: string;
|
|
8
|
+
files: Set<string>;
|
|
9
|
+
zip: any;
|
|
10
|
+
constructor({ cwd }?: {
|
|
11
|
+
cwd: string;
|
|
12
|
+
});
|
|
13
|
+
get list(): string[];
|
|
14
|
+
addResource(absoluteFileName: string, content?: File | Buffer | string): void;
|
|
15
|
+
finalize(): any;
|
|
16
|
+
toStream(): Readable;
|
|
17
|
+
}
|
package/lib/fs/bundle.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Bundle = exports.toStream = void 0;
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const stream_1 = require("stream");
|
|
9
|
+
const archiver_1 = __importDefault(require("archiver"));
|
|
10
|
+
function makeRelativeToZip(cwd, path) {
|
|
11
|
+
return '/snapshot/' + (0, path_1.relative)(cwd, path);
|
|
12
|
+
}
|
|
13
|
+
function toStream(content) {
|
|
14
|
+
const readable = new stream_1.Readable({
|
|
15
|
+
read() {
|
|
16
|
+
this.push(content);
|
|
17
|
+
this.push(null);
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
return readable;
|
|
21
|
+
}
|
|
22
|
+
exports.toStream = toStream;
|
|
23
|
+
class Bundle {
|
|
24
|
+
constructor({ cwd } = { cwd: process.cwd() }) {
|
|
25
|
+
this.files = new Set();
|
|
26
|
+
this.cwd = cwd;
|
|
27
|
+
this.zip = (0, archiver_1.default)('zip');
|
|
28
|
+
}
|
|
29
|
+
get list() {
|
|
30
|
+
return Array.from(this.files);
|
|
31
|
+
}
|
|
32
|
+
addResource(absoluteFileName, content) {
|
|
33
|
+
const destPath = makeRelativeToZip(this.cwd, absoluteFileName);
|
|
34
|
+
if (!this.files.has(destPath)) {
|
|
35
|
+
if (content == null) {
|
|
36
|
+
this.zip.file(absoluteFileName, { name: destPath });
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
this.zip.append(content, { name: destPath });
|
|
40
|
+
}
|
|
41
|
+
this.files.add(destPath);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
finalize() {
|
|
45
|
+
return this.zip.finalize();
|
|
46
|
+
}
|
|
47
|
+
toStream() {
|
|
48
|
+
return this.zip;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.Bundle = Bundle;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nexe-fs",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Virtual File System used by nexe",
|
|
5
|
+
"main": "bundle.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"*.d.ts",
|
|
8
|
+
"*.js"
|
|
9
|
+
],
|
|
10
|
+
"author": "Caleb Boyd",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"multistream": "^2.1.1"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT"
|
|
15
|
+
}
|