@nocobase/plugin-multi-portal 2.2.0-alpha.10
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.txt +107 -0
- package/README.md +14 -0
- package/client-v2.d.ts +2 -0
- package/client-v2.js +1 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/index.d.ts +9 -0
- package/dist/client/index.js +10 -0
- package/dist/client/locale.d.ts +10 -0
- package/dist/client/models/index.d.ts +11 -0
- package/dist/client/plugin.d.ts +13 -0
- package/dist/client-v2/354.ead3e96143164cd5.js +10 -0
- package/dist/client-v2/499.ef2ff0c022687485.js +10 -0
- package/dist/client-v2/778.23ba409a924ee34a.js +10 -0
- package/dist/client-v2/845.f2b0ce44ae4be707.js +10 -0
- package/dist/client-v2/entryActions/PortalEntryActionModel.d.ts +52 -0
- package/dist/client-v2/entryActions/portalEntryActionStore.d.ts +36 -0
- package/dist/client-v2/entryActions/registerPortalEntryActions.d.ts +10 -0
- package/dist/client-v2/entryActions/types.d.ts +41 -0
- package/dist/client-v2/entryActions/url.d.ts +10 -0
- package/dist/client-v2/index.d.ts +9 -0
- package/dist/client-v2/index.js +10 -0
- package/dist/client-v2/layoutRegistration.d.ts +38 -0
- package/dist/client-v2/locale.d.ts +13 -0
- package/dist/client-v2/models/MultiPortalBlockModel.d.ts +13 -0
- package/dist/client-v2/models/MultiPortalMobilePageModels.d.ts +34 -0
- package/dist/client-v2/pages/MultiPortalsPage.d.ts +80 -0
- package/dist/client-v2/permissions/MultiPortalPermissionsTab.d.ts +21 -0
- package/dist/client-v2/permissions/multiPortalPermissions.d.ts +12 -0
- package/dist/client-v2/plugin.d.ts +13 -0
- package/dist/client-v2/routeRepositoryScope.d.ts +11 -0
- package/dist/client-v2/routeUrl.d.ts +18 -0
- package/dist/externalVersion.js +25 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +48 -0
- package/dist/locale/en-US.json +82 -0
- package/dist/locale/zh-CN.json +82 -0
- package/dist/node_modules/tar/dist/commonjs/create.d.ts +3 -0
- package/dist/node_modules/tar/dist/commonjs/create.js +82 -0
- package/dist/node_modules/tar/dist/commonjs/cwd-error.d.ts +8 -0
- package/dist/node_modules/tar/dist/commonjs/cwd-error.js +18 -0
- package/dist/node_modules/tar/dist/commonjs/extract.d.ts +3 -0
- package/dist/node_modules/tar/dist/commonjs/extract.js +88 -0
- package/dist/node_modules/tar/dist/commonjs/get-write-flag.d.ts +2 -0
- package/dist/node_modules/tar/dist/commonjs/get-write-flag.js +32 -0
- package/dist/node_modules/tar/dist/commonjs/header.d.ts +53 -0
- package/dist/node_modules/tar/dist/commonjs/header.js +312 -0
- package/dist/node_modules/tar/dist/commonjs/index.d.ts +20 -0
- package/dist/node_modules/tar/dist/commonjs/index.js +64 -0
- package/dist/node_modules/tar/dist/commonjs/index.min.js +1 -0
- package/dist/node_modules/tar/dist/commonjs/large-numbers.d.ts +3 -0
- package/dist/node_modules/tar/dist/commonjs/large-numbers.js +99 -0
- package/dist/node_modules/tar/dist/commonjs/list.d.ts +7 -0
- package/dist/node_modules/tar/dist/commonjs/list.js +145 -0
- package/dist/node_modules/tar/dist/commonjs/make-command.d.ts +49 -0
- package/dist/node_modules/tar/dist/commonjs/make-command.js +52 -0
- package/dist/node_modules/tar/dist/commonjs/mkdir.d.ts +25 -0
- package/dist/node_modules/tar/dist/commonjs/mkdir.js +187 -0
- package/dist/node_modules/tar/dist/commonjs/mode-fix.d.ts +2 -0
- package/dist/node_modules/tar/dist/commonjs/mode-fix.js +29 -0
- package/dist/node_modules/tar/dist/commonjs/normalize-unicode.d.ts +2 -0
- package/dist/node_modules/tar/dist/commonjs/normalize-unicode.js +38 -0
- package/dist/node_modules/tar/dist/commonjs/normalize-windows-path.d.ts +2 -0
- package/dist/node_modules/tar/dist/commonjs/normalize-windows-path.js +12 -0
- package/dist/node_modules/tar/dist/commonjs/options.d.ts +596 -0
- package/dist/node_modules/tar/dist/commonjs/options.js +66 -0
- package/dist/node_modules/tar/dist/commonjs/pack.d.ts +105 -0
- package/dist/node_modules/tar/dist/commonjs/pack.js +545 -0
- package/dist/node_modules/tar/dist/commonjs/package.json +3 -0
- package/dist/node_modules/tar/dist/commonjs/parse.d.ts +85 -0
- package/dist/node_modules/tar/dist/commonjs/parse.js +610 -0
- package/dist/node_modules/tar/dist/commonjs/path-reservations.d.ts +11 -0
- package/dist/node_modules/tar/dist/commonjs/path-reservations.js +170 -0
- package/dist/node_modules/tar/dist/commonjs/pax.d.ts +26 -0
- package/dist/node_modules/tar/dist/commonjs/pax.js +158 -0
- package/dist/node_modules/tar/dist/commonjs/process-umask.d.ts +2 -0
- package/dist/node_modules/tar/dist/commonjs/process-umask.js +7 -0
- package/dist/node_modules/tar/dist/commonjs/read-entry.d.ts +36 -0
- package/dist/node_modules/tar/dist/commonjs/read-entry.js +136 -0
- package/dist/node_modules/tar/dist/commonjs/replace.d.ts +2 -0
- package/dist/node_modules/tar/dist/commonjs/replace.js +227 -0
- package/dist/node_modules/tar/dist/commonjs/strip-absolute-path.d.ts +2 -0
- package/dist/node_modules/tar/dist/commonjs/strip-absolute-path.js +29 -0
- package/dist/node_modules/tar/dist/commonjs/strip-trailing-slashes.d.ts +2 -0
- package/dist/node_modules/tar/dist/commonjs/strip-trailing-slashes.js +18 -0
- package/dist/node_modules/tar/dist/commonjs/symlink-error.d.ts +9 -0
- package/dist/node_modules/tar/dist/commonjs/symlink-error.js +19 -0
- package/dist/node_modules/tar/dist/commonjs/types.d.ts +7 -0
- package/dist/node_modules/tar/dist/commonjs/types.js +50 -0
- package/dist/node_modules/tar/dist/commonjs/unpack.d.ts +101 -0
- package/dist/node_modules/tar/dist/commonjs/unpack.js +932 -0
- package/dist/node_modules/tar/dist/commonjs/update.d.ts +2 -0
- package/dist/node_modules/tar/dist/commonjs/update.js +33 -0
- package/dist/node_modules/tar/dist/commonjs/warn-method.d.ts +24 -0
- package/dist/node_modules/tar/dist/commonjs/warn-method.js +31 -0
- package/dist/node_modules/tar/dist/commonjs/winchars.d.ts +3 -0
- package/dist/node_modules/tar/dist/commonjs/winchars.js +14 -0
- package/dist/node_modules/tar/dist/commonjs/write-entry.d.ts +129 -0
- package/dist/node_modules/tar/dist/commonjs/write-entry.js +698 -0
- package/dist/node_modules/tar/dist/esm/create.d.ts +3 -0
- package/dist/node_modules/tar/dist/esm/create.js +76 -0
- package/dist/node_modules/tar/dist/esm/cwd-error.d.ts +8 -0
- package/dist/node_modules/tar/dist/esm/cwd-error.js +14 -0
- package/dist/node_modules/tar/dist/esm/extract.d.ts +3 -0
- package/dist/node_modules/tar/dist/esm/extract.js +49 -0
- package/dist/node_modules/tar/dist/esm/get-write-flag.d.ts +2 -0
- package/dist/node_modules/tar/dist/esm/get-write-flag.js +26 -0
- package/dist/node_modules/tar/dist/esm/header.d.ts +53 -0
- package/dist/node_modules/tar/dist/esm/header.js +275 -0
- package/dist/node_modules/tar/dist/esm/index.d.ts +20 -0
- package/dist/node_modules/tar/dist/esm/index.js +20 -0
- package/dist/node_modules/tar/dist/esm/index.min.js +4 -0
- package/dist/node_modules/tar/dist/esm/large-numbers.d.ts +3 -0
- package/dist/node_modules/tar/dist/esm/large-numbers.js +94 -0
- package/dist/node_modules/tar/dist/esm/list.d.ts +7 -0
- package/dist/node_modules/tar/dist/esm/list.js +105 -0
- package/dist/node_modules/tar/dist/esm/make-command.d.ts +49 -0
- package/dist/node_modules/tar/dist/esm/make-command.js +48 -0
- package/dist/node_modules/tar/dist/esm/mkdir.d.ts +25 -0
- package/dist/node_modules/tar/dist/esm/mkdir.js +179 -0
- package/dist/node_modules/tar/dist/esm/mode-fix.d.ts +2 -0
- package/dist/node_modules/tar/dist/esm/mode-fix.js +25 -0
- package/dist/node_modules/tar/dist/esm/normalize-unicode.d.ts +2 -0
- package/dist/node_modules/tar/dist/esm/normalize-unicode.js +34 -0
- package/dist/node_modules/tar/dist/esm/normalize-windows-path.d.ts +2 -0
- package/dist/node_modules/tar/dist/esm/normalize-windows-path.js +9 -0
- package/dist/node_modules/tar/dist/esm/options.d.ts +596 -0
- package/dist/node_modules/tar/dist/esm/options.js +54 -0
- package/dist/node_modules/tar/dist/esm/pack.d.ts +105 -0
- package/dist/node_modules/tar/dist/esm/pack.js +503 -0
- package/dist/node_modules/tar/dist/esm/package.json +3 -0
- package/dist/node_modules/tar/dist/esm/parse.d.ts +85 -0
- package/dist/node_modules/tar/dist/esm/parse.js +606 -0
- package/dist/node_modules/tar/dist/esm/path-reservations.d.ts +11 -0
- package/dist/node_modules/tar/dist/esm/path-reservations.js +166 -0
- package/dist/node_modules/tar/dist/esm/pax.d.ts +26 -0
- package/dist/node_modules/tar/dist/esm/pax.js +154 -0
- package/dist/node_modules/tar/dist/esm/process-umask.d.ts +2 -0
- package/dist/node_modules/tar/dist/esm/process-umask.js +3 -0
- package/dist/node_modules/tar/dist/esm/read-entry.d.ts +36 -0
- package/dist/node_modules/tar/dist/esm/read-entry.js +132 -0
- package/dist/node_modules/tar/dist/esm/replace.d.ts +2 -0
- package/dist/node_modules/tar/dist/esm/replace.js +221 -0
- package/dist/node_modules/tar/dist/esm/strip-absolute-path.d.ts +2 -0
- package/dist/node_modules/tar/dist/esm/strip-absolute-path.js +25 -0
- package/dist/node_modules/tar/dist/esm/strip-trailing-slashes.d.ts +2 -0
- package/dist/node_modules/tar/dist/esm/strip-trailing-slashes.js +14 -0
- package/dist/node_modules/tar/dist/esm/symlink-error.d.ts +9 -0
- package/dist/node_modules/tar/dist/esm/symlink-error.js +15 -0
- package/dist/node_modules/tar/dist/esm/types.d.ts +7 -0
- package/dist/node_modules/tar/dist/esm/types.js +45 -0
- package/dist/node_modules/tar/dist/esm/unpack.d.ts +101 -0
- package/dist/node_modules/tar/dist/esm/unpack.js +891 -0
- package/dist/node_modules/tar/dist/esm/update.d.ts +2 -0
- package/dist/node_modules/tar/dist/esm/update.js +30 -0
- package/dist/node_modules/tar/dist/esm/warn-method.d.ts +24 -0
- package/dist/node_modules/tar/dist/esm/warn-method.js +27 -0
- package/dist/node_modules/tar/dist/esm/winchars.d.ts +3 -0
- package/dist/node_modules/tar/dist/esm/winchars.js +9 -0
- package/dist/node_modules/tar/dist/esm/write-entry.d.ts +129 -0
- package/dist/node_modules/tar/dist/esm/write-entry.js +656 -0
- package/dist/node_modules/tar/node_modules/chownr/dist/commonjs/index.d.ts +3 -0
- package/dist/node_modules/tar/node_modules/chownr/dist/commonjs/index.js +93 -0
- package/dist/node_modules/tar/node_modules/chownr/dist/commonjs/package.json +3 -0
- package/dist/node_modules/tar/node_modules/chownr/dist/esm/index.d.ts +3 -0
- package/dist/node_modules/tar/node_modules/chownr/dist/esm/index.js +85 -0
- package/dist/node_modules/tar/node_modules/chownr/dist/esm/package.json +3 -0
- package/dist/node_modules/tar/node_modules/chownr/package.json +69 -0
- package/dist/node_modules/tar/node_modules/minipass/dist/commonjs/index.d.ts +549 -0
- package/dist/node_modules/tar/node_modules/minipass/dist/commonjs/index.js +1028 -0
- package/dist/node_modules/tar/node_modules/minipass/dist/commonjs/package.json +3 -0
- package/dist/node_modules/tar/node_modules/minipass/dist/esm/index.d.ts +549 -0
- package/dist/node_modules/tar/node_modules/minipass/dist/esm/index.js +1018 -0
- package/dist/node_modules/tar/node_modules/minipass/dist/esm/package.json +3 -0
- package/dist/node_modules/tar/node_modules/minipass/package.json +82 -0
- package/dist/node_modules/tar/node_modules/minizlib/dist/commonjs/constants.d.ts +2 -0
- package/dist/node_modules/tar/node_modules/minizlib/dist/commonjs/constants.js +123 -0
- package/dist/node_modules/tar/node_modules/minizlib/dist/commonjs/index.d.ts +99 -0
- package/dist/node_modules/tar/node_modules/minizlib/dist/commonjs/index.js +416 -0
- package/dist/node_modules/tar/node_modules/minizlib/dist/commonjs/package.json +3 -0
- package/dist/node_modules/tar/node_modules/minizlib/dist/esm/constants.d.ts +2 -0
- package/dist/node_modules/tar/node_modules/minizlib/dist/esm/constants.js +117 -0
- package/dist/node_modules/tar/node_modules/minizlib/dist/esm/index.d.ts +99 -0
- package/dist/node_modules/tar/node_modules/minizlib/dist/esm/index.js +363 -0
- package/dist/node_modules/tar/node_modules/minizlib/dist/esm/package.json +3 -0
- package/dist/node_modules/tar/node_modules/minizlib/package.json +80 -0
- package/dist/node_modules/tar/node_modules/yallist/dist/commonjs/index.d.ts +39 -0
- package/dist/node_modules/tar/node_modules/yallist/dist/commonjs/index.js +384 -0
- package/dist/node_modules/tar/node_modules/yallist/dist/commonjs/package.json +3 -0
- package/dist/node_modules/tar/node_modules/yallist/dist/esm/index.d.ts +39 -0
- package/dist/node_modules/tar/node_modules/yallist/dist/esm/index.js +379 -0
- package/dist/node_modules/tar/node_modules/yallist/dist/esm/package.json +3 -0
- package/dist/node_modules/tar/node_modules/yallist/package.json +68 -0
- package/dist/node_modules/tar/package.json +1 -0
- package/dist/server/collections/desktopRoutes.d.ts +14 -0
- package/dist/server/collections/desktopRoutes.js +48 -0
- package/dist/server/collections/extendRoleField.d.ts +14 -0
- package/dist/server/collections/extendRoleField.js +51 -0
- package/dist/server/collections/multiPortals.d.ts +10 -0
- package/dist/server/collections/multiPortals.js +128 -0
- package/dist/server/collections/rolesMultiPortalDesktopRoutes.d.ts +10 -0
- package/dist/server/collections/rolesMultiPortalDesktopRoutes.js +76 -0
- package/dist/server/collections/rolesMultiPortalRoutePolicies.d.ts +10 -0
- package/dist/server/collections/rolesMultiPortalRoutePolicies.js +73 -0
- package/dist/server/collections/rolesMultiPortals.d.ts +10 -0
- package/dist/server/collections/rolesMultiPortals.js +68 -0
- package/dist/server/ensureDefaultRoleMultiPortalAccess.d.ts +11 -0
- package/dist/server/ensureDefaultRoleMultiPortalAccess.js +70 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +42 -0
- package/dist/server/migrations/20260723105200-drop-ui-layout-foreign-key-constraint.d.ts +13 -0
- package/dist/server/migrations/20260723105200-drop-ui-layout-foreign-key-constraint.js +104 -0
- package/dist/server/plugin.d.ts +63 -0
- package/dist/server/plugin.js +2130 -0
- package/package.json +34 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { WriteStream, WriteStreamSync } from '@isaacs/fs-minipass';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { list } from './list.js';
|
|
4
|
+
import { makeCommand } from './make-command.js';
|
|
5
|
+
import { Pack, PackSync } from './pack.js';
|
|
6
|
+
const createFileSync = (opt, files) => {
|
|
7
|
+
const p = new PackSync(opt);
|
|
8
|
+
const stream = new WriteStreamSync(opt.file, {
|
|
9
|
+
mode: opt.mode || 0o666,
|
|
10
|
+
});
|
|
11
|
+
p.pipe(stream);
|
|
12
|
+
addFilesSync(p, files);
|
|
13
|
+
};
|
|
14
|
+
const createFile = (opt, files) => {
|
|
15
|
+
const p = new Pack(opt);
|
|
16
|
+
const stream = new WriteStream(opt.file, {
|
|
17
|
+
mode: opt.mode || 0o666,
|
|
18
|
+
});
|
|
19
|
+
p.pipe(stream);
|
|
20
|
+
const promise = new Promise((res, rej) => {
|
|
21
|
+
stream.on('error', rej);
|
|
22
|
+
stream.on('close', res);
|
|
23
|
+
p.on('error', rej);
|
|
24
|
+
});
|
|
25
|
+
addFilesAsync(p, files).catch(er => p.emit('error', er));
|
|
26
|
+
return promise;
|
|
27
|
+
};
|
|
28
|
+
const addFilesSync = (p, files) => {
|
|
29
|
+
files.forEach(file => {
|
|
30
|
+
if (file.charAt(0) === '@') {
|
|
31
|
+
list({
|
|
32
|
+
file: path.resolve(p.cwd, file.slice(1)),
|
|
33
|
+
sync: true,
|
|
34
|
+
noResume: true,
|
|
35
|
+
onReadEntry: entry => p.add(entry),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
p.add(file);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
p.end();
|
|
43
|
+
};
|
|
44
|
+
const addFilesAsync = async (p, files) => {
|
|
45
|
+
for (const file of files) {
|
|
46
|
+
if (file.charAt(0) === '@') {
|
|
47
|
+
await list({
|
|
48
|
+
file: path.resolve(String(p.cwd), file.slice(1)),
|
|
49
|
+
noResume: true,
|
|
50
|
+
onReadEntry: entry => {
|
|
51
|
+
p.add(entry);
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
p.add(file);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
p.end();
|
|
60
|
+
};
|
|
61
|
+
const createSync = (opt, files) => {
|
|
62
|
+
const p = new PackSync(opt);
|
|
63
|
+
addFilesSync(p, files);
|
|
64
|
+
return p;
|
|
65
|
+
};
|
|
66
|
+
const createAsync = (opt, files) => {
|
|
67
|
+
const p = new Pack(opt);
|
|
68
|
+
addFilesAsync(p, files).catch(er => p.emit('error', er));
|
|
69
|
+
return p;
|
|
70
|
+
};
|
|
71
|
+
export const create = makeCommand(createFileSync, createFile, createSync, createAsync, (_opt, files) => {
|
|
72
|
+
if (!files?.length) {
|
|
73
|
+
throw new TypeError('no paths specified to add to archive');
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export class CwdError extends Error {
|
|
2
|
+
path;
|
|
3
|
+
code;
|
|
4
|
+
syscall = 'chdir';
|
|
5
|
+
constructor(path, code) {
|
|
6
|
+
super(`${code}: Cannot cd into '${path}'`);
|
|
7
|
+
this.path = path;
|
|
8
|
+
this.code = code;
|
|
9
|
+
}
|
|
10
|
+
get name() {
|
|
11
|
+
return 'CwdError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=cwd-error.js.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// tar -x
|
|
2
|
+
import * as fsm from '@isaacs/fs-minipass';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import { filesFilter } from './list.js';
|
|
5
|
+
import { makeCommand } from './make-command.js';
|
|
6
|
+
import { Unpack, UnpackSync } from './unpack.js';
|
|
7
|
+
const extractFileSync = (opt) => {
|
|
8
|
+
const u = new UnpackSync(opt);
|
|
9
|
+
const file = opt.file;
|
|
10
|
+
const stat = fs.statSync(file);
|
|
11
|
+
// This trades a zero-byte read() syscall for a stat
|
|
12
|
+
// However, it will usually result in less memory allocation
|
|
13
|
+
const readSize = opt.maxReadSize || 16 * 1024 * 1024;
|
|
14
|
+
const stream = new fsm.ReadStreamSync(file, {
|
|
15
|
+
readSize: readSize,
|
|
16
|
+
size: stat.size,
|
|
17
|
+
});
|
|
18
|
+
stream.pipe(u);
|
|
19
|
+
};
|
|
20
|
+
const extractFile = (opt, _) => {
|
|
21
|
+
const u = new Unpack(opt);
|
|
22
|
+
const readSize = opt.maxReadSize || 16 * 1024 * 1024;
|
|
23
|
+
const file = opt.file;
|
|
24
|
+
const p = new Promise((resolve, reject) => {
|
|
25
|
+
u.on('error', reject);
|
|
26
|
+
u.on('close', resolve);
|
|
27
|
+
// This trades a zero-byte read() syscall for a stat
|
|
28
|
+
// However, it will usually result in less memory allocation
|
|
29
|
+
fs.stat(file, (er, stat) => {
|
|
30
|
+
if (er) {
|
|
31
|
+
reject(er);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
const stream = new fsm.ReadStream(file, {
|
|
35
|
+
readSize: readSize,
|
|
36
|
+
size: stat.size,
|
|
37
|
+
});
|
|
38
|
+
stream.on('error', reject);
|
|
39
|
+
stream.pipe(u);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
return p;
|
|
44
|
+
};
|
|
45
|
+
export const extract = makeCommand(extractFileSync, extractFile, opt => new UnpackSync(opt), opt => new Unpack(opt), (opt, files) => {
|
|
46
|
+
if (files?.length)
|
|
47
|
+
filesFilter(opt, files);
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=extract.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Get the appropriate flag to use for creating files
|
|
2
|
+
// We use fmap on Windows platforms for files less than
|
|
3
|
+
// 512kb. This is a fairly low limit, but avoids making
|
|
4
|
+
// things slower in some cases. Since most of what this
|
|
5
|
+
// library is used for is extracting tarballs of many
|
|
6
|
+
// relatively small files in npm packages and the like,
|
|
7
|
+
// it can be a big boost on Windows platforms.
|
|
8
|
+
import fs from 'fs';
|
|
9
|
+
const platform = process.env.__FAKE_PLATFORM__ || process.platform;
|
|
10
|
+
const isWindows = platform === 'win32';
|
|
11
|
+
/* c8 ignore start */
|
|
12
|
+
const { O_CREAT, O_NOFOLLOW, O_TRUNC, O_WRONLY } = fs.constants;
|
|
13
|
+
const UV_FS_O_FILEMAP = Number(process.env.__FAKE_FS_O_FILENAME__) ||
|
|
14
|
+
fs.constants.UV_FS_O_FILEMAP ||
|
|
15
|
+
0;
|
|
16
|
+
/* c8 ignore stop */
|
|
17
|
+
const fMapEnabled = isWindows && !!UV_FS_O_FILEMAP;
|
|
18
|
+
const fMapLimit = 512 * 1024;
|
|
19
|
+
const fMapFlag = UV_FS_O_FILEMAP | O_TRUNC | O_CREAT | O_WRONLY;
|
|
20
|
+
const noFollowFlag = !isWindows && typeof O_NOFOLLOW === 'number' ?
|
|
21
|
+
O_NOFOLLOW | O_TRUNC | O_CREAT | O_WRONLY
|
|
22
|
+
: null;
|
|
23
|
+
export const getWriteFlag = noFollowFlag !== null ? () => noFollowFlag
|
|
24
|
+
: !fMapEnabled ? () => 'w'
|
|
25
|
+
: (size) => (size < fMapLimit ? fMapFlag : 'w');
|
|
26
|
+
//# sourceMappingURL=get-write-flag.js.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { EntryTypeCode, EntryTypeName } from './types.js';
|
|
2
|
+
export type HeaderData = {
|
|
3
|
+
path?: string;
|
|
4
|
+
mode?: number;
|
|
5
|
+
uid?: number;
|
|
6
|
+
gid?: number;
|
|
7
|
+
size?: number;
|
|
8
|
+
cksum?: number;
|
|
9
|
+
type?: EntryTypeName | 'Unsupported';
|
|
10
|
+
linkpath?: string;
|
|
11
|
+
uname?: string;
|
|
12
|
+
gname?: string;
|
|
13
|
+
devmaj?: number;
|
|
14
|
+
devmin?: number;
|
|
15
|
+
atime?: Date;
|
|
16
|
+
ctime?: Date;
|
|
17
|
+
mtime?: Date;
|
|
18
|
+
charset?: string;
|
|
19
|
+
comment?: string;
|
|
20
|
+
dev?: number;
|
|
21
|
+
ino?: number;
|
|
22
|
+
nlink?: number;
|
|
23
|
+
};
|
|
24
|
+
export declare class Header implements HeaderData {
|
|
25
|
+
#private;
|
|
26
|
+
cksumValid: boolean;
|
|
27
|
+
needPax: boolean;
|
|
28
|
+
nullBlock: boolean;
|
|
29
|
+
block?: Buffer;
|
|
30
|
+
path?: string;
|
|
31
|
+
mode?: number;
|
|
32
|
+
uid?: number;
|
|
33
|
+
gid?: number;
|
|
34
|
+
size?: number;
|
|
35
|
+
cksum?: number;
|
|
36
|
+
linkpath?: string;
|
|
37
|
+
uname?: string;
|
|
38
|
+
gname?: string;
|
|
39
|
+
devmaj: number;
|
|
40
|
+
devmin: number;
|
|
41
|
+
atime?: Date;
|
|
42
|
+
ctime?: Date;
|
|
43
|
+
mtime?: Date;
|
|
44
|
+
charset?: string;
|
|
45
|
+
comment?: string;
|
|
46
|
+
constructor(data?: Buffer | HeaderData, off?: number, ex?: HeaderData, gex?: HeaderData);
|
|
47
|
+
decode(buf: Buffer, off: number, ex?: HeaderData, gex?: HeaderData): void;
|
|
48
|
+
encode(buf?: Buffer, off?: number): boolean;
|
|
49
|
+
get type(): EntryTypeName;
|
|
50
|
+
get typeKey(): EntryTypeCode | 'Unsupported';
|
|
51
|
+
set type(type: EntryTypeCode | EntryTypeName | 'Unsupported');
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=header.d.ts.map
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
// parse a 512-byte header block to a data object, or vice-versa
|
|
2
|
+
// encode returns `true` if a pax extended header is needed, because
|
|
3
|
+
// the data could not be faithfully encoded in a simple header.
|
|
4
|
+
// (Also, check header.needPax to see if it needs a pax header.)
|
|
5
|
+
import { posix as pathModule } from 'node:path';
|
|
6
|
+
import * as large from './large-numbers.js';
|
|
7
|
+
import * as types from './types.js';
|
|
8
|
+
export class Header {
|
|
9
|
+
cksumValid = false;
|
|
10
|
+
needPax = false;
|
|
11
|
+
nullBlock = false;
|
|
12
|
+
block;
|
|
13
|
+
path;
|
|
14
|
+
mode;
|
|
15
|
+
uid;
|
|
16
|
+
gid;
|
|
17
|
+
size;
|
|
18
|
+
cksum;
|
|
19
|
+
#type = 'Unsupported';
|
|
20
|
+
linkpath;
|
|
21
|
+
uname;
|
|
22
|
+
gname;
|
|
23
|
+
devmaj = 0;
|
|
24
|
+
devmin = 0;
|
|
25
|
+
atime;
|
|
26
|
+
ctime;
|
|
27
|
+
mtime;
|
|
28
|
+
charset;
|
|
29
|
+
comment;
|
|
30
|
+
constructor(data, off = 0, ex, gex) {
|
|
31
|
+
if (Buffer.isBuffer(data)) {
|
|
32
|
+
this.decode(data, off || 0, ex, gex);
|
|
33
|
+
}
|
|
34
|
+
else if (data) {
|
|
35
|
+
this.#slurp(data);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
decode(buf, off, ex, gex) {
|
|
39
|
+
if (!off) {
|
|
40
|
+
off = 0;
|
|
41
|
+
}
|
|
42
|
+
if (!buf || !(buf.length >= off + 512)) {
|
|
43
|
+
throw new Error('need 512 bytes for header');
|
|
44
|
+
}
|
|
45
|
+
this.path = ex?.path ?? decString(buf, off, 100);
|
|
46
|
+
this.mode = ex?.mode ?? gex?.mode ?? decNumber(buf, off + 100, 8);
|
|
47
|
+
this.uid = ex?.uid ?? gex?.uid ?? decNumber(buf, off + 108, 8);
|
|
48
|
+
this.gid = ex?.gid ?? gex?.gid ?? decNumber(buf, off + 116, 8);
|
|
49
|
+
this.size = ex?.size ?? gex?.size ?? decNumber(buf, off + 124, 12);
|
|
50
|
+
this.mtime = ex?.mtime ?? gex?.mtime ?? decDate(buf, off + 136, 12);
|
|
51
|
+
this.cksum = decNumber(buf, off + 148, 12);
|
|
52
|
+
// if we have extended or global extended headers, apply them now
|
|
53
|
+
// See https://github.com/npm/node-tar/pull/187
|
|
54
|
+
// Apply global before local, so it overrides
|
|
55
|
+
if (gex)
|
|
56
|
+
this.#slurp(gex, true);
|
|
57
|
+
if (ex)
|
|
58
|
+
this.#slurp(ex);
|
|
59
|
+
// old tar versions marked dirs as a file with a trailing /
|
|
60
|
+
const t = decString(buf, off + 156, 1);
|
|
61
|
+
if (types.isCode(t)) {
|
|
62
|
+
this.#type = t || '0';
|
|
63
|
+
}
|
|
64
|
+
if (this.#type === '0' && this.path.slice(-1) === '/') {
|
|
65
|
+
this.#type = '5';
|
|
66
|
+
}
|
|
67
|
+
// tar implementations sometimes incorrectly put the stat(dir).size
|
|
68
|
+
// as the size in the tarball, even though Directory entries are
|
|
69
|
+
// not able to have any body at all. In the very rare chance that
|
|
70
|
+
// it actually DOES have a body, we weren't going to do anything with
|
|
71
|
+
// it anyway, and it'll just be a warning about an invalid header.
|
|
72
|
+
if (this.#type === '5') {
|
|
73
|
+
this.size = 0;
|
|
74
|
+
}
|
|
75
|
+
this.linkpath = decString(buf, off + 157, 100);
|
|
76
|
+
if (buf.subarray(off + 257, off + 265).toString() === 'ustar\u000000') {
|
|
77
|
+
/* c8 ignore start */
|
|
78
|
+
this.uname = ex?.uname ?? gex?.uname ?? decString(buf, off + 265, 32);
|
|
79
|
+
this.gname = ex?.gname ?? gex?.gname ?? decString(buf, off + 297, 32);
|
|
80
|
+
this.devmaj =
|
|
81
|
+
ex?.devmaj ?? gex?.devmaj ?? decNumber(buf, off + 329, 8) ?? 0;
|
|
82
|
+
this.devmin =
|
|
83
|
+
ex?.devmin ?? gex?.devmin ?? decNumber(buf, off + 337, 8) ?? 0;
|
|
84
|
+
/* c8 ignore stop */
|
|
85
|
+
if (buf[off + 475] !== 0) {
|
|
86
|
+
// definitely a prefix, definitely >130 chars.
|
|
87
|
+
const prefix = decString(buf, off + 345, 155);
|
|
88
|
+
this.path = prefix + '/' + this.path;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
const prefix = decString(buf, off + 345, 130);
|
|
92
|
+
if (prefix) {
|
|
93
|
+
this.path = prefix + '/' + this.path;
|
|
94
|
+
}
|
|
95
|
+
/* c8 ignore start */
|
|
96
|
+
this.atime = ex?.atime ?? gex?.atime ?? decDate(buf, off + 476, 12);
|
|
97
|
+
this.ctime = ex?.ctime ?? gex?.ctime ?? decDate(buf, off + 488, 12);
|
|
98
|
+
/* c8 ignore stop */
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
let sum = 8 * 0x20;
|
|
102
|
+
for (let i = off; i < off + 148; i++) {
|
|
103
|
+
sum += buf[i];
|
|
104
|
+
}
|
|
105
|
+
for (let i = off + 156; i < off + 512; i++) {
|
|
106
|
+
sum += buf[i];
|
|
107
|
+
}
|
|
108
|
+
this.cksumValid = sum === this.cksum;
|
|
109
|
+
if (this.cksum === undefined && sum === 8 * 0x20) {
|
|
110
|
+
this.nullBlock = true;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
#slurp(ex, gex = false) {
|
|
114
|
+
Object.assign(this, Object.fromEntries(Object.entries(ex).filter(([k, v]) => {
|
|
115
|
+
// we slurp in everything except for the path attribute in
|
|
116
|
+
// a global extended header, because that's weird. Also, any
|
|
117
|
+
// null/undefined values are ignored.
|
|
118
|
+
return !(v === null ||
|
|
119
|
+
v === undefined ||
|
|
120
|
+
(k === 'path' && gex) ||
|
|
121
|
+
(k === 'linkpath' && gex) ||
|
|
122
|
+
k === 'global');
|
|
123
|
+
})));
|
|
124
|
+
}
|
|
125
|
+
encode(buf, off = 0) {
|
|
126
|
+
if (!buf) {
|
|
127
|
+
buf = this.block = Buffer.alloc(512);
|
|
128
|
+
}
|
|
129
|
+
if (this.#type === 'Unsupported') {
|
|
130
|
+
this.#type = '0';
|
|
131
|
+
}
|
|
132
|
+
if (!(buf.length >= off + 512)) {
|
|
133
|
+
throw new Error('need 512 bytes for header');
|
|
134
|
+
}
|
|
135
|
+
const prefixSize = this.ctime || this.atime ? 130 : 155;
|
|
136
|
+
const split = splitPrefix(this.path || '', prefixSize);
|
|
137
|
+
const path = split[0];
|
|
138
|
+
const prefix = split[1];
|
|
139
|
+
this.needPax = !!split[2];
|
|
140
|
+
this.needPax = encString(buf, off, 100, path) || this.needPax;
|
|
141
|
+
this.needPax = encNumber(buf, off + 100, 8, this.mode) || this.needPax;
|
|
142
|
+
this.needPax = encNumber(buf, off + 108, 8, this.uid) || this.needPax;
|
|
143
|
+
this.needPax = encNumber(buf, off + 116, 8, this.gid) || this.needPax;
|
|
144
|
+
this.needPax = encNumber(buf, off + 124, 12, this.size) || this.needPax;
|
|
145
|
+
this.needPax = encDate(buf, off + 136, 12, this.mtime) || this.needPax;
|
|
146
|
+
buf[off + 156] = Number(this.#type.codePointAt(0));
|
|
147
|
+
this.needPax =
|
|
148
|
+
encString(buf, off + 157, 100, this.linkpath) || this.needPax;
|
|
149
|
+
buf.write('ustar\u000000', off + 257, 8);
|
|
150
|
+
this.needPax =
|
|
151
|
+
encString(buf, off + 265, 32, this.uname) || this.needPax;
|
|
152
|
+
this.needPax =
|
|
153
|
+
encString(buf, off + 297, 32, this.gname) || this.needPax;
|
|
154
|
+
this.needPax =
|
|
155
|
+
encNumber(buf, off + 329, 8, this.devmaj) || this.needPax;
|
|
156
|
+
this.needPax =
|
|
157
|
+
encNumber(buf, off + 337, 8, this.devmin) || this.needPax;
|
|
158
|
+
this.needPax =
|
|
159
|
+
encString(buf, off + 345, prefixSize, prefix) || this.needPax;
|
|
160
|
+
if (buf[off + 475] !== 0) {
|
|
161
|
+
this.needPax = encString(buf, off + 345, 155, prefix) || this.needPax;
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
this.needPax = encString(buf, off + 345, 130, prefix) || this.needPax;
|
|
165
|
+
this.needPax =
|
|
166
|
+
encDate(buf, off + 476, 12, this.atime) || this.needPax;
|
|
167
|
+
this.needPax =
|
|
168
|
+
encDate(buf, off + 488, 12, this.ctime) || this.needPax;
|
|
169
|
+
}
|
|
170
|
+
let sum = 8 * 0x20;
|
|
171
|
+
for (let i = off; i < off + 148; i++) {
|
|
172
|
+
sum += buf[i];
|
|
173
|
+
}
|
|
174
|
+
for (let i = off + 156; i < off + 512; i++) {
|
|
175
|
+
sum += buf[i];
|
|
176
|
+
}
|
|
177
|
+
this.cksum = sum;
|
|
178
|
+
encNumber(buf, off + 148, 8, this.cksum);
|
|
179
|
+
this.cksumValid = true;
|
|
180
|
+
return this.needPax;
|
|
181
|
+
}
|
|
182
|
+
get type() {
|
|
183
|
+
return (this.#type === 'Unsupported' ?
|
|
184
|
+
this.#type
|
|
185
|
+
: types.name.get(this.#type));
|
|
186
|
+
}
|
|
187
|
+
get typeKey() {
|
|
188
|
+
return this.#type;
|
|
189
|
+
}
|
|
190
|
+
set type(type) {
|
|
191
|
+
const c = String(types.code.get(type));
|
|
192
|
+
if (types.isCode(c) || c === 'Unsupported') {
|
|
193
|
+
this.#type = c;
|
|
194
|
+
}
|
|
195
|
+
else if (types.isCode(type)) {
|
|
196
|
+
this.#type = type;
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
throw new TypeError('invalid entry type: ' + type);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const splitPrefix = (p, prefixSize) => {
|
|
204
|
+
const pathSize = 100;
|
|
205
|
+
let pp = p;
|
|
206
|
+
let prefix = '';
|
|
207
|
+
let ret = undefined;
|
|
208
|
+
const root = pathModule.parse(p).root || '.';
|
|
209
|
+
if (Buffer.byteLength(pp) < pathSize) {
|
|
210
|
+
ret = [pp, prefix, false];
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
// first set prefix to the dir, and path to the base
|
|
214
|
+
prefix = pathModule.dirname(pp);
|
|
215
|
+
pp = pathModule.basename(pp);
|
|
216
|
+
do {
|
|
217
|
+
if (Buffer.byteLength(pp) <= pathSize &&
|
|
218
|
+
Buffer.byteLength(prefix) <= prefixSize) {
|
|
219
|
+
// both fit!
|
|
220
|
+
ret = [pp, prefix, false];
|
|
221
|
+
}
|
|
222
|
+
else if (Buffer.byteLength(pp) > pathSize &&
|
|
223
|
+
Buffer.byteLength(prefix) <= prefixSize) {
|
|
224
|
+
// prefix fits in prefix, but path doesn't fit in path
|
|
225
|
+
ret = [pp.slice(0, pathSize - 1), prefix, true];
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
// make path take a bit from prefix
|
|
229
|
+
pp = pathModule.join(pathModule.basename(prefix), pp);
|
|
230
|
+
prefix = pathModule.dirname(prefix);
|
|
231
|
+
}
|
|
232
|
+
} while (prefix !== root && ret === undefined);
|
|
233
|
+
// at this point, found no resolution, just truncate
|
|
234
|
+
if (!ret) {
|
|
235
|
+
ret = [p.slice(0, pathSize - 1), '', true];
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return ret;
|
|
239
|
+
};
|
|
240
|
+
const decString = (buf, off, size) => buf
|
|
241
|
+
.subarray(off, off + size)
|
|
242
|
+
.toString('utf8')
|
|
243
|
+
.replace(/\0.*/, '');
|
|
244
|
+
const decDate = (buf, off, size) => numToDate(decNumber(buf, off, size));
|
|
245
|
+
const numToDate = (num) => num === undefined ? undefined : new Date(num * 1000);
|
|
246
|
+
const decNumber = (buf, off, size) => Number(buf[off]) & 0x80 ?
|
|
247
|
+
large.parse(buf.subarray(off, off + size))
|
|
248
|
+
: decSmallNumber(buf, off, size);
|
|
249
|
+
const nanUndef = (value) => (isNaN(value) ? undefined : value);
|
|
250
|
+
const decSmallNumber = (buf, off, size) => nanUndef(parseInt(buf
|
|
251
|
+
.subarray(off, off + size)
|
|
252
|
+
.toString('utf8')
|
|
253
|
+
.replace(/\0.*$/, '')
|
|
254
|
+
.trim(), 8));
|
|
255
|
+
// the maximum encodable as a null-terminated octal, by field size
|
|
256
|
+
const MAXNUM = {
|
|
257
|
+
12: 0o77777777777,
|
|
258
|
+
8: 0o7777777,
|
|
259
|
+
};
|
|
260
|
+
const encNumber = (buf, off, size, num) => num === undefined ? false
|
|
261
|
+
: num > MAXNUM[size] || num < 0 ?
|
|
262
|
+
(large.encode(num, buf.subarray(off, off + size)), true)
|
|
263
|
+
: (encSmallNumber(buf, off, size, num), false);
|
|
264
|
+
const encSmallNumber = (buf, off, size, num) => buf.write(octalString(num, size), off, size, 'ascii');
|
|
265
|
+
const octalString = (num, size) => padOctal(Math.floor(num).toString(8), size);
|
|
266
|
+
const padOctal = (str, size) => (str.length === size - 1 ?
|
|
267
|
+
str
|
|
268
|
+
: new Array(size - str.length - 1).join('0') + str + ' ') + '\0';
|
|
269
|
+
const encDate = (buf, off, size, date) => date === undefined ? false : (encNumber(buf, off, size, date.getTime() / 1000));
|
|
270
|
+
// enough to fill the longest string we've got
|
|
271
|
+
const NULLS = new Array(156).join('\0');
|
|
272
|
+
// pad with nulls, return true if it's longer or non-ascii
|
|
273
|
+
const encString = (buf, off, size, str) => str === undefined ? false : ((buf.write(str + NULLS, off, size, 'utf8'),
|
|
274
|
+
str.length !== Buffer.byteLength(str) || str.length > size));
|
|
275
|
+
//# sourceMappingURL=header.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { type TarOptionsWithAliasesAsync, type TarOptionsWithAliasesAsyncFile, type TarOptionsWithAliasesAsyncNoFile, type TarOptionsWithAliasesSyncNoFile, type TarOptionsWithAliases, type TarOptionsWithAliasesFile, type TarOptionsWithAliasesSync, type TarOptionsWithAliasesSyncFile, } from './options.js';
|
|
2
|
+
export * from './create.js';
|
|
3
|
+
export { create as c } from './create.js';
|
|
4
|
+
export * from './extract.js';
|
|
5
|
+
export { extract as x } from './extract.js';
|
|
6
|
+
export * from './header.js';
|
|
7
|
+
export * from './list.js';
|
|
8
|
+
export { list as t } from './list.js';
|
|
9
|
+
export * from './pack.js';
|
|
10
|
+
export * from './parse.js';
|
|
11
|
+
export * from './pax.js';
|
|
12
|
+
export * from './read-entry.js';
|
|
13
|
+
export * from './replace.js';
|
|
14
|
+
export { replace as r } from './replace.js';
|
|
15
|
+
export * as types from './types.js';
|
|
16
|
+
export * from './unpack.js';
|
|
17
|
+
export * from './update.js';
|
|
18
|
+
export { update as u } from './update.js';
|
|
19
|
+
export * from './write-entry.js';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from './create.js';
|
|
2
|
+
export { create as c } from './create.js';
|
|
3
|
+
export * from './extract.js';
|
|
4
|
+
export { extract as x } from './extract.js';
|
|
5
|
+
export * from './header.js';
|
|
6
|
+
export * from './list.js';
|
|
7
|
+
export { list as t } from './list.js';
|
|
8
|
+
// classes
|
|
9
|
+
export * from './pack.js';
|
|
10
|
+
export * from './parse.js';
|
|
11
|
+
export * from './pax.js';
|
|
12
|
+
export * from './read-entry.js';
|
|
13
|
+
export * from './replace.js';
|
|
14
|
+
export { replace as r } from './replace.js';
|
|
15
|
+
export * as types from './types.js';
|
|
16
|
+
export * from './unpack.js';
|
|
17
|
+
export * from './update.js';
|
|
18
|
+
export { update as u } from './update.js';
|
|
19
|
+
export * from './write-entry.js';
|
|
20
|
+
//# sourceMappingURL=index.js.map
|