@preventive/deptree 1.5.1 → 1.5.3
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/bin/compare.js +10 -21
- package/bin/deptree.js +5 -10
- package/cargo.d.ts +139 -195
- package/cargo.js +0 -2
- package/cocoapods.d.ts +211 -381
- package/cocoapods.js +0 -2
- package/npm.d.ts +245 -369
- package/npm.js +4 -6
- package/package.json +2 -2
- package/pnpm.d.ts +258 -667
- package/pnpm.js +2 -4
- package/soldeer.d.ts +144 -215
- package/soldeer.js +0 -2
- package/src/cargo/crate.js +21 -46
- package/src/cargo/inputs.js +5 -8
- package/src/cargo/members.js +6 -12
- package/src/cargo/registry.js +5 -9
- package/src/cargo/tree.js +8 -13
- package/src/cargo/workspace.js +13 -26
- package/src/cocoapods/archive.js +19 -40
- package/src/cocoapods/clean.js +21 -45
- package/src/cocoapods/fnmatch.js +12 -27
- package/src/cocoapods/inputs.js +5 -11
- package/src/cocoapods/install.js +11 -24
- package/src/cocoapods/podspec.js +19 -40
- package/src/cocoapods/podtree.js +10 -19
- package/src/cocoapods/source.js +13 -30
- package/src/cocoapods/tree.js +17 -39
- package/src/cocoapods/unicode.js +3 -9
- package/src/github.js +12 -24
- package/src/glob.js +2 -4
- package/src/lazy.js +2 -4
- package/src/manifest.js +2 -4
- package/src/matcher.js +3 -5
- package/src/mount.js +7 -14
- package/src/npm/bins.js +3 -5
- package/src/npm/compat.js +3 -5
- package/src/npm/package.js +6 -12
- package/src/npm/ratio.js +3 -5
- package/src/npm/settings.js +3 -5
- package/src/npm/tree.js +6 -11
- package/src/npm/versions.js +3 -4
- package/src/npmrc.js +2 -4
- package/src/patch.js +8 -14
- package/src/pnpm/bins.js +16 -42
- package/src/pnpm/filename.js +2 -4
- package/src/pnpm/gitignore.js +2 -4
- package/src/pnpm/glob.js +3 -5
- package/src/pnpm/hoist.js +8 -16
- package/src/pnpm/hoisted.js +15 -44
- package/src/pnpm/hook.js +2 -4
- package/src/pnpm/install.js +5 -10
- package/src/pnpm/lazy.js +8 -23
- package/src/pnpm/local.js +2 -4
- package/src/pnpm/minimatch.js +8 -15
- package/src/pnpm/nm-hoist.js +5 -11
- package/src/pnpm/npm-packlist.js +3 -6
- package/src/pnpm/overrides.js +2 -4
- package/src/pnpm/package.js +10 -16
- package/src/pnpm/packlist.js +3 -7
- package/src/pnpm/patches.js +3 -4
- package/src/pnpm/production.js +9 -28
- package/src/pnpm/projects.js +2 -6
- package/src/pnpm/readers.js +2 -4
- package/src/pnpm/settings.js +2 -5
- package/src/pnpm/tree.js +14 -37
- package/src/pnpm/workspace.js +4 -7
- package/src/pnpm/write.js +1 -1
- package/src/soldeer/config.js +5 -9
- package/src/soldeer/tree.js +2 -4
- package/src/soldeer/zip.js +8 -17
- package/src/tarball.js +12 -29
- package/src/yarn1/compat.js +2 -4
- package/src/yarn1/hoist.js +3 -8
- package/src/yarn1/package.js +12 -23
- package/src/yarn1/resolve.js +6 -11
- package/src/yarn1/settings.js +5 -10
- package/src/yarn1/tree.js +9 -18
- package/yarn1.d.ts +203 -360
- package/yarn1.js +4 -6
package/src/cargo/members.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
// workspace.members, exclude and default-members as cargo reads them:
|
|
2
|
-
//
|
|
3
|
-
// a directory, one with a leading dot too; `**` and `[`, and a path that
|
|
4
|
-
// leads out of the root or depends on where it is, are refused.
|
|
1
|
+
// workspace.members, exclude and default-members as cargo reads them, through the glob crate: `*` and
|
|
2
|
+
// `?` take any name, a leading dot too; `**`, `[`, and a path out of the root or by where it is, are refused
|
|
5
3
|
|
|
6
4
|
import { compareNames, join } from '@preventive/vfs/path.js'
|
|
7
5
|
import { DeptreeError, quote } from '../error.js'
|
|
@@ -28,8 +26,7 @@ export function checkLists(workspace) {
|
|
|
28
26
|
}
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
// is_excluded: under an `exclude` path and no `members` one, each
|
|
32
|
-
// written, a glob's wildcards as names.
|
|
29
|
+
// is_excluded: under an `exclude` path and no `members` one, each as written, wildcards as names
|
|
33
30
|
export function isExcluded(workspace, path) {
|
|
34
31
|
const under = (list) => list.some((entry) => {
|
|
35
32
|
const prefix = parts(entry)
|
|
@@ -46,8 +43,7 @@ function literal(names, segment, folded, dir, where) {
|
|
|
46
43
|
return []
|
|
47
44
|
}
|
|
48
45
|
|
|
49
|
-
// Every path the glob takes, files among them
|
|
50
|
-
// link it reaches is refused, as glob() follows it.
|
|
46
|
+
// Every path the glob takes, files among them as glob() lists them; a link is refused, as glob() follows it
|
|
51
47
|
function expand(project, glob, folded, where) {
|
|
52
48
|
let found = ['.']
|
|
53
49
|
for (const segment of parts(glob)) {
|
|
@@ -67,8 +63,7 @@ function expand(project, glob, folded, where) {
|
|
|
67
63
|
return found.sort(compareNames)
|
|
68
64
|
}
|
|
69
65
|
|
|
70
|
-
// members_paths: the directories each glob takes
|
|
71
|
-
// nothing at all fails as cargo goes to read it.
|
|
66
|
+
// members_paths: the directories each glob takes; one taking nothing fails as cargo goes to read it
|
|
72
67
|
function pathsOf(project, globs, key, folded) {
|
|
73
68
|
return globs.flatMap((glob, index) => {
|
|
74
69
|
const where = `Cargo.toml: workspace.${key}[${index}]`
|
|
@@ -80,8 +75,7 @@ function pathsOf(project, globs, key, folded) {
|
|
|
80
75
|
|
|
81
76
|
export const explicitMembers = (project, workspace, folded) => pathsOf(project, workspace.members, 'members', folded)
|
|
82
77
|
|
|
83
|
-
//
|
|
84
|
-
// directory `members` takes, `listed`, that is excluded.
|
|
78
|
+
// Each default member has to be a member, or a directory `members` takes (`listed`) that is excluded
|
|
85
79
|
export function checkDefaultMembers(project, workspace, members, listed, folded) {
|
|
86
80
|
if (workspace.defaultMembers === undefined) return
|
|
87
81
|
for (const dir of pathsOf(project, workspace.defaultMembers, 'default-members', folded)) {
|
package/src/cargo/registry.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
// The packages `cargo vendor` copies into vendor
|
|
2
|
-
//
|
|
3
|
-
// already. Each is fetched from crates.io and unpacked as cargo unpacks it.
|
|
1
|
+
// The packages `cargo vendor` copies into vendor/: every one of the lockfile's but a path package, each
|
|
2
|
+
// fetched from crates.io and unpacked as cargo unpacks it
|
|
4
3
|
|
|
5
4
|
import { parseVersion } from '@preventive/lockfile/rust-semver.js'
|
|
6
5
|
import { getCrate } from '@preventive/upstream/cargo.js'
|
|
@@ -15,10 +14,8 @@ export const about = (key) => `packages[${quote(key)}]`
|
|
|
15
14
|
|
|
16
15
|
const sign = (a, b) => (a === b ? 0 : a < b ? -1 : 1)
|
|
17
16
|
|
|
18
|
-
// The semver crate's order
|
|
19
|
-
//
|
|
20
|
-
// pre-release before its release, its identifiers digits before others and
|
|
21
|
-
// digits by their value.
|
|
17
|
+
// The semver crate's order, but for build metadata, which crates.io parts no two versions by: a pre-release
|
|
18
|
+
// before its release, its identifiers digits before others and digits by their value
|
|
22
19
|
function compareVersions(a, b) {
|
|
23
20
|
const [x, y] = [parseVersion(a), parseVersion(b)]
|
|
24
21
|
for (const part of ['major', 'minor', 'patch']) if (x[part] !== y[part]) return sign(x[part], y[part])
|
|
@@ -34,8 +31,7 @@ function compareVersions(a, b) {
|
|
|
34
31
|
return sign(ids1.length, ids2.length)
|
|
35
32
|
}
|
|
36
33
|
|
|
37
|
-
// vendor.rs: the greatest version of a name has a directory of the name
|
|
38
|
-
// alone, and any other `<name>-<version>`.
|
|
34
|
+
// vendor.rs: the greatest version of a name has a directory of the name alone, any other `<name>-<version>`
|
|
39
35
|
export function vendoredPackages(lock) {
|
|
40
36
|
const crates = []
|
|
41
37
|
for (const [key, pkg] of Object.entries(lock.packages)) {
|
package/src/cargo/tree.js
CHANGED
|
@@ -13,9 +13,8 @@ import { fileOf, findWorkspace, parseAs } from './workspace.js'
|
|
|
13
13
|
|
|
14
14
|
const checkNoVendor = checkNoDir('vendor', 'a vendor directory')
|
|
15
15
|
|
|
16
|
-
// Of the config, [patch] is read, as cargo resolves with it; `paths`, which
|
|
17
|
-
//
|
|
18
|
-
// files, are refused; the rest bears on no package vendored.
|
|
16
|
+
// Of the config, [patch] is read, as cargo resolves with it; `paths` and `include`, which change where
|
|
17
|
+
// packages come from and what is read, are refused; the rest bears on no package vendored
|
|
19
18
|
function configOf({ text, file }) {
|
|
20
19
|
if (text === undefined) return { patch: parseCargoConfig([]).patch, file }
|
|
21
20
|
const doc = parseAs(file, () => parseToml(text))
|
|
@@ -23,8 +22,8 @@ function configOf({ text, file }) {
|
|
|
23
22
|
return { patch: parseAs(file, () => parseCargoConfig([text])).patch, file }
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
// Each path package by
|
|
27
|
-
//
|
|
25
|
+
// Each path package by its lockfile key, `name version`: every one of the lockfile's has to be one cargo
|
|
26
|
+
// reads, and every member there
|
|
28
27
|
function pathKeys(lock, packages) {
|
|
29
28
|
const keys = new Map()
|
|
30
29
|
const dirs = new Map()
|
|
@@ -42,8 +41,7 @@ function pathKeys(lock, packages) {
|
|
|
42
41
|
return keys
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
// linkCargo ties a path dependency to a
|
|
46
|
-
// it has to be the one in the directory the path leads to.
|
|
44
|
+
// linkCargo ties a path dependency to a package by name and version, which has to be the one its path leads to
|
|
47
45
|
function checkPaths(graph, packages, keys) {
|
|
48
46
|
for (const [dir, { links }] of packages) {
|
|
49
47
|
const linked = graph.packages[keys.get(dir)]
|
|
@@ -55,9 +53,7 @@ function checkPaths(graph, packages, keys) {
|
|
|
55
53
|
}
|
|
56
54
|
}
|
|
57
55
|
|
|
58
|
-
// `links` are the repository and homepage the Cargo.toml
|
|
59
|
-
// in [package], or [project] as cargo reads it too: strings, as
|
|
60
|
-
// parseCargoManifest holds them to, or undefined.
|
|
56
|
+
// `links` are the repository and homepage the packed Cargo.toml's [package] (or [project]) gives, or undefined
|
|
61
57
|
function manifestOf(crate, vendored) {
|
|
62
58
|
const where = `${about(crate.key)}: Cargo.toml`
|
|
63
59
|
const file = vendored.files.get('Cargo.toml')
|
|
@@ -69,9 +65,8 @@ function manifestOf(crate, vendored) {
|
|
|
69
65
|
return { text, manifest, links: { repository: own(pkg, 'repository'), homepage: own(pkg, 'homepage') } }
|
|
70
66
|
}
|
|
71
67
|
|
|
72
|
-
// The lockfile laid over every manifest
|
|
73
|
-
//
|
|
74
|
-
// Gives back each crate's links, by its key.
|
|
68
|
+
// The lockfile laid over every manifest by linkCargo, then the copies read back as cargo's directory
|
|
69
|
+
// source reads them; gives back each crate's links, by its key
|
|
75
70
|
function checkLock(lock, inputs, crates, vendored) {
|
|
76
71
|
const { keys } = inputs
|
|
77
72
|
const manifests = Object.create(null)
|
package/src/cargo/workspace.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
// The workspace as cargo finds it from the project's root,
|
|
2
|
-
//
|
|
3
|
-
// and not excluded a member too, and every other path package cargo reads,
|
|
4
|
-
// each manifest parsed as cargo reads it, inheriting from the root's
|
|
5
|
-
// [workspace] where cargo has it inherit.
|
|
1
|
+
// The workspace as cargo finds it from the project's root, taken to be its root: the members and every
|
|
2
|
+
// other path package cargo reads, each parsed as cargo reads it, inheriting where cargo has it inherit
|
|
6
3
|
|
|
7
4
|
import { LockfileError, parseCargoManifest } from '@preventive/lockfile/cargo.js'
|
|
8
5
|
import { TomlError, parseToml } from '@preventive/lockfile/toml.js'
|
|
@@ -14,13 +11,11 @@ import { checkDefaultMembers, checkLists, explicitMembers, isExcluded, parts } f
|
|
|
14
11
|
|
|
15
12
|
export const fileOf = (dir) => (dir === '.' ? 'Cargo.toml' : `${dir}/Cargo.toml`)
|
|
16
13
|
const manifestPath = (dir) => [...parts(dir), 'Cargo.toml']
|
|
17
|
-
// Whether the root
|
|
18
|
-
// not exclude it.
|
|
14
|
+
// Whether the root has a [workspace] that does not exclude `dir`
|
|
19
15
|
const inRoot = (workspace, dir) => workspace !== undefined && !isExcluded(workspace, manifestPath(dir))
|
|
20
16
|
|
|
21
|
-
// A path
|
|
22
|
-
//
|
|
23
|
-
// that cargo's normalize_path drops unread.
|
|
17
|
+
// A path from `base`, `..` only ahead of every name: else the filesystem would walk through a name that
|
|
18
|
+
// cargo's normalize_path drops unread
|
|
24
19
|
function resolvePath(base, path, where) {
|
|
25
20
|
if (path.startsWith('/') || UNSAFE.test(path) || /^[A-Za-z]:/u.test(path)) throw new DeptreeError(`${quote(path)} is not a relative path within the project, which is all that is read`, where)
|
|
26
21
|
const segments = parts(base)
|
|
@@ -59,8 +54,7 @@ const pointerOf = (doc) => (doc.package ?? doc.project)?.workspace
|
|
|
59
54
|
const DEP_KEYS = { normal: 'dependencies', dev: 'dev-dependencies', build: 'build-dependencies' }
|
|
60
55
|
const depWhere = (dir, dep) => `${fileOf(dir)}: ${dep.target === undefined ? '' : `target.${quote(dep.target)}.`}${DEP_KEYS[dep.kind]}.${dep.name}`
|
|
61
56
|
|
|
62
|
-
// The
|
|
63
|
-
// each Cargo.toml read, and each path package loaded.
|
|
57
|
+
// The root's manifest and [workspace], each Cargo.toml read, and each path package loaded
|
|
64
58
|
function contextOf(project, folded) {
|
|
65
59
|
const read = new Map()
|
|
66
60
|
const raw = (dir) => {
|
|
@@ -75,8 +69,7 @@ function contextOf(project, folded) {
|
|
|
75
69
|
return { project, folded, read, raw, root, workspace: root.workspace, packages: new Map() }
|
|
76
70
|
}
|
|
77
71
|
|
|
78
|
-
//
|
|
79
|
-
// its own [workspace], the root's, or none. A package.workspace pointing
|
|
72
|
+
// The workspace of the package in `dir`: its own, the root's, or none. A package.workspace pointing
|
|
80
73
|
// elsewhere than the root, and a [workspace] between the two, are refused.
|
|
81
74
|
function workspaceOf({ raw, workspace }, dir) {
|
|
82
75
|
if (raw(dir).doc.workspace !== undefined) return 'own'
|
|
@@ -93,10 +86,8 @@ function workspaceOf({ raw, workspace }, dir) {
|
|
|
93
86
|
return inRoot(workspace, dir) ? 'root' : 'none'
|
|
94
87
|
}
|
|
95
88
|
|
|
96
|
-
// A path package's manifest
|
|
97
|
-
//
|
|
98
|
-
// cargo resolves for members alone. An inherited dependency's path is from
|
|
99
|
-
// the root of the workspace it is inherited from.
|
|
89
|
+
// A path package's manifest and where its path dependencies lead, dev-dependencies a member's alone; an
|
|
90
|
+
// inherited one's path is from the root of the workspace it is inherited from
|
|
100
91
|
function load(context, dir, member, where) {
|
|
101
92
|
const { raw, root, packages } = context
|
|
102
93
|
if (raw(dir) === undefined) throw new DeptreeError(`${quote(fileOf(dir))} is not there, which cargo fails on`, where)
|
|
@@ -114,9 +105,8 @@ function load(context, dir, member, where) {
|
|
|
114
105
|
return links
|
|
115
106
|
}
|
|
116
107
|
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
// given back, for the packages that are not members.
|
|
108
|
+
// The root, those `members` takes, and each path dependency of one in the root and not excluded; what
|
|
109
|
+
// else they lead to is given back, for the packages that are not members
|
|
120
110
|
function loadMembers(context) {
|
|
121
111
|
const { project, folded, workspace } = context
|
|
122
112
|
const members = new Set()
|
|
@@ -144,8 +134,7 @@ function loadMembers(context) {
|
|
|
144
134
|
return others
|
|
145
135
|
}
|
|
146
136
|
|
|
147
|
-
// Each [patch] from a path, the
|
|
148
|
-
// the directory its .cargo is in, which is the root too.
|
|
137
|
+
// Each [patch] from a path, the config's from the directory its .cargo is in, which is the root too
|
|
149
138
|
function patchesOf(root, config) {
|
|
150
139
|
const files = [[root.patch, 'Cargo.toml'], [config.patch, config.file]]
|
|
151
140
|
return files.flatMap(([patch, file]) => Object.entries(patch).flatMap(([table, specs]) => Object.entries(specs).filter(([, spec]) => spec.source.type === 'path').map(([name, spec]) => {
|
|
@@ -154,9 +143,7 @@ function patchesOf(root, config) {
|
|
|
154
143
|
})))
|
|
155
144
|
}
|
|
156
145
|
|
|
157
|
-
// `config` is
|
|
158
|
-
// `read` is each Cargo.toml read, by its directory: undefined where there is
|
|
159
|
-
// none.
|
|
146
|
+
// `config` is parseCargoConfig's, with its `file`; `read` each Cargo.toml read by directory, undefined for none
|
|
160
147
|
export function findWorkspace(project, config, folded) {
|
|
161
148
|
const context = contextOf(project, folded)
|
|
162
149
|
const others = loadMembers(context)
|
package/src/cocoapods/archive.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
// An archive by :http as RemoteFile leaves it: saved as `file.<type
|
|
2
|
-
//
|
|
3
|
-
// 0o022, then flattened where that is asked and it holds one directory.
|
|
1
|
+
// An archive by :http as RemoteFile leaves it: saved as `file.<type>`, extracted by `tar xf` or `unzip -d`
|
|
2
|
+
// under a 0o022 umask, then flattened where that is asked and it holds one directory
|
|
4
3
|
|
|
5
4
|
import { decompress } from '@preventive/archive/compression.js'
|
|
6
5
|
import { ArchiveError, unpack } from '@preventive/archive/tar.js'
|
|
@@ -23,8 +22,7 @@ const OTHERS = [
|
|
|
23
22
|
const SPECIAL = 0o7000
|
|
24
23
|
const UMASK = 0o022
|
|
25
24
|
|
|
26
|
-
// The names at the archive's root, a directory's that only paths under it
|
|
27
|
-
// name among them.
|
|
25
|
+
// The names at the archive's root, a directory's that only paths under it name among them
|
|
28
26
|
const topsOf = ({ dirs, files, links }) => new Set([...dirs, ...files.keys(), ...links.keys()].map((path) => path.split('/')[0]))
|
|
29
27
|
|
|
30
28
|
const gitRefusal = (at) => new DeptreeError('a path with a .git in it, which CocoaPods 1.16 leaves out of its cache and those before keep', at)
|
|
@@ -39,17 +37,9 @@ async function tarOf(bytes, where) {
|
|
|
39
37
|
return bytes
|
|
40
38
|
}
|
|
41
39
|
|
|
42
|
-
// Each entry as tar writes it out
|
|
43
|
-
//
|
|
44
|
-
// a
|
|
45
|
-
// CocoaPods copies the download into its cache with, and FileUtils.cp_r
|
|
46
|
-
// copy one: a file of the same bytes and mode, or a link to the same
|
|
47
|
-
// target. What tar would make otherwise on one machine than on another is
|
|
48
|
-
// refused: a special bit; a directory its owner cannot list and write in,
|
|
49
|
-
// which the cleaner would leave files in; a file its owner cannot read,
|
|
50
|
-
// which the copy fails on; a name starting with `._`, which bsdtar on macOS
|
|
51
|
-
// makes an extended attribute of; a `.git`, which the copy into the cache
|
|
52
|
-
// leaves out from CocoaPods 1.16; a FIFO or a device.
|
|
40
|
+
// Each entry as tar writes it out, a hard link copied as rsync -a and FileUtils.cp_r copy one into the
|
|
41
|
+
// cache. What tar makes otherwise on one machine than another is refused, and so is what the cleaner or
|
|
42
|
+
// the copy would fail on, a `._` name bsdtar on macOS reads as attributes, and a `.git` 1.16 leaves out.
|
|
53
43
|
function entriesOf(entries, where) {
|
|
54
44
|
const dirs = new Set()
|
|
55
45
|
const files = new Map()
|
|
@@ -83,17 +73,18 @@ function entriesOf(entries, where) {
|
|
|
83
73
|
return { dirs, files, links }
|
|
84
74
|
}
|
|
85
75
|
|
|
86
|
-
async function
|
|
76
|
+
async function readable(read, where) {
|
|
87
77
|
try {
|
|
88
|
-
return
|
|
78
|
+
return await read()
|
|
89
79
|
} catch (error) {
|
|
90
80
|
if (error instanceof ArchiveError) throw new DeptreeError(`its archive cannot be read: ${error.message}`, where, { cause: error })
|
|
91
81
|
throw error
|
|
92
82
|
}
|
|
93
83
|
}
|
|
94
84
|
|
|
95
|
-
|
|
96
|
-
|
|
85
|
+
const untarred = (bytes, where) => readable(async () => entriesOf(unpack(await tarOf(bytes, where), { trailingGlobal: true }), where), where)
|
|
86
|
+
|
|
87
|
+
// What unzip 6.0 stops to ask about, which fails `pod install` with nothing on stdin
|
|
97
88
|
const PKZIP_VERSION = 45
|
|
98
89
|
const VMS = 2
|
|
99
90
|
|
|
@@ -103,10 +94,8 @@ function checkVersion({ version }, at) {
|
|
|
103
94
|
if (version >> 8 === VMS) throw new DeptreeError('marked as stored in VMS format, which unzip asks before extracting', at)
|
|
104
95
|
}
|
|
105
96
|
|
|
106
|
-
// A mode as unzip's mapattr() makes one: a Unix maker's as stored,
|
|
107
|
-
//
|
|
108
|
-
// agrees with them, as PKZip for Unix writes one; filtattr() then drops the
|
|
109
|
-
// special bits. A symlink is one by its mode, from a maker known to make them.
|
|
97
|
+
// A mode as unzip's mapattr() makes one: a Unix maker's as stored, another's from the DOS bits under the
|
|
98
|
+
// umask unless its Unix mode agrees with them. A symlink is one by its mode, from a maker known to make them.
|
|
110
99
|
const UNIX_HOSTS = new Set([2, 3, 5, 12, 13, 16, 17, 30])
|
|
111
100
|
const SYMLINK_HOSTS = new Set([2, 3, 5, 16, 30])
|
|
112
101
|
const LABEL_HOSTS = new Set([0, 5, 6, 11])
|
|
@@ -147,17 +136,10 @@ function checkName({ storedName, type }, at) {
|
|
|
147
136
|
if (VMS_VERSION.test(last)) throw new DeptreeError('a name ending in `;` and digits, which unzip takes for a VMS version and drops', at)
|
|
148
137
|
}
|
|
149
138
|
|
|
150
|
-
// Each entry as unzip writes it out, in the central directory's order: a
|
|
151
|
-
//
|
|
152
|
-
// makes the directory for it.
|
|
139
|
+
// Each entry as unzip writes it out, in the central directory's order: a volume label skipped, a directory
|
|
140
|
+
// entry's mode counted only where unzip makes the directory for it
|
|
153
141
|
async function unzipped(bytes, where) {
|
|
154
|
-
|
|
155
|
-
try {
|
|
156
|
-
entries = await unzip(bytes, { limit: MAX_BYTES })
|
|
157
|
-
} catch (error) {
|
|
158
|
-
if (error instanceof ArchiveError) throw new DeptreeError(`its archive cannot be read: ${error.message}`, where, { cause: error })
|
|
159
|
-
throw error
|
|
160
|
-
}
|
|
142
|
+
const entries = await readable(() => unzip(bytes, { limit: MAX_BYTES }), where)
|
|
161
143
|
if (entries.length === 0) throw new DeptreeError('an empty archive, which unzip warns of, and CocoaPods fails on the warning', where)
|
|
162
144
|
const dirs = new Set()
|
|
163
145
|
const files = new Map()
|
|
@@ -193,12 +175,9 @@ async function unzipped(bytes, where) {
|
|
|
193
175
|
return { dirs, files, links }
|
|
194
176
|
}
|
|
195
177
|
|
|
196
|
-
// RemoteFile#extract_with_type's flattening
|
|
197
|
-
//
|
|
198
|
-
//
|
|
199
|
-
// Pathname#directory? would follow, is refused, and so is a name the moves
|
|
200
|
-
// would meet: a name ending in `.`, which Pathname#sub_ext reads otherwise
|
|
201
|
-
// than it ends, or something in it of the name it is moved to.
|
|
178
|
+
// RemoteFile#extract_with_type's flattening of one directory, moved to its name and `.tmp` first. A link
|
|
179
|
+
// there, which Pathname#directory? follows, is refused, as is a name the moves would meet: one ending in
|
|
180
|
+
// `.`, which Pathname#sub_ext reads otherwise, or one in it of the name it is moved to.
|
|
202
181
|
function flattened(contents, where) {
|
|
203
182
|
const tops = topsOf(contents)
|
|
204
183
|
if (tops.size !== 1) return contents
|
package/src/cocoapods/clean.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// PathList of what is there and a FileAccessor per spec and platform; its
|
|
5
|
-
// lock_files! then takes the owner's write off each source file. Each is
|
|
6
|
-
// followed as CocoaPods 1.13 to 1.17 have it, in Ruby 2.6 to 3.4.
|
|
1
|
+
// PodDirCleaner, which removes all no spec uses, by a PathList of what is there and a FileAccessor per spec
|
|
2
|
+
// and platform, then lock_files!, which takes the owner's write off each source file; as CocoaPods 1.13 to
|
|
3
|
+
// 1.17 have them, in Ruby 2.6 to 3.4
|
|
7
4
|
|
|
8
5
|
import { DeptreeError, quote } from '../error.js'
|
|
9
6
|
import { expandBraces, matcher } from './fnmatch.js'
|
|
10
7
|
|
|
11
|
-
// FileAccessor::GLOB_PATTERNS
|
|
12
|
-
// header extensions after CocoaPods' own.
|
|
8
|
+
// FileAccessor::GLOB_PATTERNS; a source file's extensions, Xcodeproj's header ones after CocoaPods' own
|
|
13
9
|
const HEADERS = ['.h', '.hh', '.hpp', '.ipp', '.tpp', '.hxx', '.def', '.inl', '.inc']
|
|
14
10
|
const SOURCES = [...new Set(['.m', '.mm', '.i', '.c', '.cc', '.cxx', '.cpp', '.c++', '.swift', ...HEADERS])]
|
|
15
11
|
const SOURCE_FILES = `*{${SOURCES.join(',')}}`
|
|
@@ -17,13 +13,10 @@ const README = 'readme{*,.*}'
|
|
|
17
13
|
const LICENSE = 'licen{c,s}e{*,.*}'
|
|
18
14
|
// What PathList#relative_glob lays under a directory an exclusion names.
|
|
19
15
|
const EXCLUDED_DIR = '**/*'
|
|
20
|
-
//
|
|
21
|
-
// counted, past which a pod is refused rather than cleaned.
|
|
16
|
+
// Paths matched against a pattern's expansions, past which a pod is refused rather than cleaned
|
|
22
17
|
export const MAX_MATCHES = 200_000_000
|
|
23
18
|
|
|
24
|
-
// Ruby's String#downcase
|
|
25
|
-
// final sigma, which takes the letters around it into account and Ruby
|
|
26
|
-
// does not.
|
|
19
|
+
// Ruby's String#downcase: Unicode's mapping without the final sigma, which Ruby does not take into account
|
|
27
20
|
const downcase = (text) => text.replaceAll('\u03A3', '\u03C3').toLowerCase()
|
|
28
21
|
const encoder = new TextEncoder()
|
|
29
22
|
function compareBytes(a, b) {
|
|
@@ -33,10 +26,8 @@ function compareBytes(a, b) {
|
|
|
33
26
|
// Ruby's sort_by(&:upcase), which compares bytes.
|
|
34
27
|
const byUpcase = (paths) => paths.map((path) => [path, encoder.encode(path.toUpperCase())]).sort(([, a], [, b]) => compareBytes(a, b)).map(([path]) => path)
|
|
35
28
|
|
|
36
|
-
// Sandbox::PathList:
|
|
37
|
-
//
|
|
38
|
-
// so and a file where it does not, a directory whose path ends in `.`
|
|
39
|
-
// passed over; each list sorted by sort_by(&:upcase).
|
|
29
|
+
// Sandbox::PathList: `**/*` with FNM_DOTMATCH, entering no link, a directory where File.directory? says so
|
|
30
|
+
// (but where its path ends in `.`) and a file elsewhere, each list by sort_by(&:upcase)
|
|
40
31
|
class PathList {
|
|
41
32
|
constructor(tree, budget) {
|
|
42
33
|
this.tree = tree
|
|
@@ -58,12 +49,9 @@ class PathList {
|
|
|
58
49
|
return this.lowerDirs.has(downcase(pattern).replace(/\/$/u, ''))
|
|
59
50
|
}
|
|
60
51
|
|
|
61
|
-
// PathList#relative_glob:
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
// one of them matches. Those `exclude` matches, under a directory it
|
|
65
|
-
// names too, are taken out. Paths come back in the order of the list,
|
|
66
|
-
// pattern by pattern, the same path more than once where two match it.
|
|
52
|
+
// PathList#relative_glob: a pattern that is a path as it is, else with `dirPattern` under a directory it
|
|
53
|
+
// names, its braces expanded and matched; `exclude` taken out, under a directory it names too. In the
|
|
54
|
+
// list's order, pattern by pattern, a path again where two match it.
|
|
67
55
|
glob(patterns, { dirPattern, exclude = [], includeDirs = false } = {}) {
|
|
68
56
|
if (patterns.length === 0) return []
|
|
69
57
|
const key = JSON.stringify([patterns, dirPattern, exclude, includeDirs])
|
|
@@ -88,8 +76,7 @@ class PathList {
|
|
|
88
76
|
return found
|
|
89
77
|
}
|
|
90
78
|
|
|
91
|
-
// `glob([pattern]).first`,
|
|
92
|
-
// two that sort_by(&:upcase) leaves in no set order could be first.
|
|
79
|
+
// `glob([pattern]).first`, refused where sort_by(&:upcase) leaves two in no set order first
|
|
93
80
|
first(pattern) {
|
|
94
81
|
const [one, two] = this.glob([pattern])
|
|
95
82
|
if (two !== undefined && one.toUpperCase() === two.toUpperCase()) throw new DeptreeError(`${quote(one)} and ${quote(two)} differ in case alone, and CocoaPods takes either as the first ${pattern}`, this.tree.where)
|
|
@@ -97,13 +84,11 @@ class PathList {
|
|
|
97
84
|
}
|
|
98
85
|
}
|
|
99
86
|
|
|
100
|
-
// FileAccessor#source_files
|
|
101
|
-
// consumerOf.
|
|
87
|
+
// FileAccessor#source_files; `values` are consumerOf's
|
|
102
88
|
const sourceFiles = (list, values) => list.glob(values.source_files, { dirPattern: SOURCE_FILES, exclude: values.exclude_files })
|
|
103
89
|
|
|
104
|
-
// FileAccessor.all_files
|
|
105
|
-
//
|
|
106
|
-
// header's, the module map's and the license's as the podspec gives them.
|
|
90
|
+
// FileAccessor.all_files: what a spec uses on a platform, the prefix header, module map and license as
|
|
91
|
+
// the podspec gives them
|
|
107
92
|
function usedFiles(list, values, licenseFile) {
|
|
108
93
|
const exclude = values.exclude_files
|
|
109
94
|
const withDirs = (patterns) => list.glob(patterns, { exclude, includeDirs: true })
|
|
@@ -135,10 +120,8 @@ function firstFrom(sorted, text) {
|
|
|
135
120
|
return low
|
|
136
121
|
}
|
|
137
122
|
|
|
138
|
-
// Whether one of `sorted` starts with `text`, or `text` with one
|
|
139
|
-
//
|
|
140
|
-
// between the two: the last before it starts with that one too, so that
|
|
141
|
-
// where it is not one, the search goes on in what the two have in common.
|
|
123
|
+
// Whether one of `sorted` starts with `text`, or `text` with one: such a one is at or before it, and so is
|
|
124
|
+
// all between, so where the last before it is not one the search goes on in what the two share
|
|
142
125
|
function sharesStart(sorted, text) {
|
|
143
126
|
let at = firstFrom(sorted, text)
|
|
144
127
|
if (sorted[at]?.startsWith(text)) return true
|
|
@@ -158,14 +141,9 @@ function sharesStart(sorted, text) {
|
|
|
158
141
|
// Each set of values once, as specs and platforms often share one.
|
|
159
142
|
const uniqueOf = (accessors) => [...new Map(accessors.map((one) => [JSON.stringify(one), one])).values()]
|
|
160
143
|
|
|
161
|
-
// PodDirCleaner#clean
|
|
162
|
-
//
|
|
163
|
-
//
|
|
164
|
-
// path or one of whose paths is in the other, downcased, as `include?`
|
|
165
|
-
// finds one string in another. The pod's directory has its own path in
|
|
166
|
-
// front of each, and is taken not to come again within one, so that one
|
|
167
|
-
// is in the other where it is at its start. `budget` counts the matches
|
|
168
|
-
// made, across every clean of the pod.
|
|
144
|
+
// PodDirCleaner#clean!: every path removed but what ends in `.` and what, downcased, `include?` finds in a
|
|
145
|
+
// used file's or finds one in, which with the pod's path in front of both is one at the other's start.
|
|
146
|
+
// `budget` counts the matches across every clean of the pod.
|
|
169
147
|
export function clean(tree, accessors, licenseFile, budget) {
|
|
170
148
|
const list = new PathList(tree, budget)
|
|
171
149
|
const used = [...new Set(uniqueOf(accessors).flatMap((values) => usedFiles(list, values, licenseFile)).map(downcase))].sort()
|
|
@@ -173,9 +151,7 @@ export function clean(tree, accessors, licenseFile, budget) {
|
|
|
173
151
|
tree.removeAll(new Set(tree.paths.filter((one) => !kept(one))))
|
|
174
152
|
}
|
|
175
153
|
|
|
176
|
-
// lock_files
|
|
177
|
-
// that a link among them leads to, as chmod follows it. A link that leads
|
|
178
|
-
// to nothing CocoaPods fails on, as File.stat does.
|
|
154
|
+
// lock_files!, through a link to the file it leads to as chmod follows it; one to nothing fails File.stat
|
|
179
155
|
export function lock(tree, accessors, budget) {
|
|
180
156
|
const list = new PathList(tree, budget)
|
|
181
157
|
for (const path of new Set(uniqueOf(accessors).flatMap((values) => sourceFiles(list, values)))) {
|
package/src/cocoapods/fnmatch.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// has it in Ruby 2.6 to 3.4. Each is followed step for step, quirks and
|
|
5
|
-
// all: a `*` stops at a `/`; a leading `.` of a name is matched by a `.`
|
|
6
|
-
// alone, and `**/` enters no directory whose name starts with one; case
|
|
7
|
-
// is folded for ASCII letters alone; and in a bracket, a character that is
|
|
8
|
-
// not one of it byte for byte is folded against the one after it in the
|
|
9
|
-
// pattern, so that `[a]` does not take `A` where `[ba]` does.
|
|
1
|
+
// PathList's brace expansion, then File.fnmatch with FNM_CASEFOLD | FNM_PATHNAME, step for step as dir.c
|
|
2
|
+
// has it in Ruby 2.6 to 3.4, quirks and all: case folds for ASCII alone, and in a bracket against the
|
|
3
|
+
// character after, so `[a]` does not take `A` where `[ba]` does
|
|
10
4
|
|
|
11
5
|
const NOMATCH = 1
|
|
12
6
|
|
|
@@ -68,7 +62,6 @@ function helper(P, p0, S, s0) {
|
|
|
68
62
|
if (at(S, s) === '.' && at(P, unescape(p)) !== '.') return { r: NOMATCH, p, s }
|
|
69
63
|
for (;;) {
|
|
70
64
|
const char = at(P, p)
|
|
71
|
-
let failed = false
|
|
72
65
|
if (char === '*') {
|
|
73
66
|
do p++
|
|
74
67
|
while (at(P, p) === '*')
|
|
@@ -87,9 +80,7 @@ function helper(P, p0, S, s0) {
|
|
|
87
80
|
if (char === '[') {
|
|
88
81
|
if (end(S, s)) return { r: NOMATCH, p, s }
|
|
89
82
|
const t = bracket(P, p + 1, S, s)
|
|
90
|
-
if (t
|
|
91
|
-
failed = true
|
|
92
|
-
} else {
|
|
83
|
+
if (t !== -1) {
|
|
93
84
|
p = t
|
|
94
85
|
s++
|
|
95
86
|
continue
|
|
@@ -102,9 +93,9 @@ function helper(P, p0, S, s0) {
|
|
|
102
93
|
s++
|
|
103
94
|
continue
|
|
104
95
|
}
|
|
105
|
-
failed = true
|
|
106
96
|
}
|
|
107
|
-
|
|
97
|
+
// A failed match: back to the last `*`, a character further on
|
|
98
|
+
if (ptmp !== -1) {
|
|
108
99
|
p = ptmp
|
|
109
100
|
stmp++
|
|
110
101
|
s = stmp
|
|
@@ -161,27 +152,21 @@ function matches(P, S) {
|
|
|
161
152
|
}
|
|
162
153
|
}
|
|
163
154
|
|
|
164
|
-
// Ruby's String#split by ','
|
|
165
|
-
// `{}` and `{,}` stand for no pattern at all.
|
|
155
|
+
// Ruby's String#split by ',', which drops empty strings at the end, so `{}` and `{,}` are no pattern at all
|
|
166
156
|
function splitCommas(text) {
|
|
167
157
|
const values = text.split(',')
|
|
168
158
|
while (values.length > 0 && values.at(-1) === '') values.pop()
|
|
169
159
|
return values
|
|
170
160
|
}
|
|
171
161
|
|
|
172
|
-
// More
|
|
173
|
-
//
|
|
174
|
-
// find in proportion to its length squared.
|
|
162
|
+
// More patterns from one are refused, and so is one longer than MAX_PATTERN, as finding its braces
|
|
163
|
+
// takes time in its length squared
|
|
175
164
|
export const MAX_EXPANDED = 4096
|
|
176
165
|
const MAX_PATTERN = 4096
|
|
177
166
|
|
|
178
|
-
// dir_glob_equivalent_patterns: each `/**/` as `{/**/,/}`, then each
|
|
179
|
-
//
|
|
180
|
-
//
|
|
181
|
-
// one set after another in the order each is first found. Ruby's gsub reads
|
|
182
|
-
// a backslash in a value as the start of a reference to the match; a
|
|
183
|
-
// pattern with one there, and one that comes to more than MAX_EXPANDED,
|
|
184
|
-
// is undefined, for the caller to refuse, before it is expanded.
|
|
167
|
+
// dir_glob_equivalent_patterns: each `/**/` as `{/**/,/}`, then each `{...}` by its text replaced everywhere
|
|
168
|
+
// with each of its values, set after set. Undefined, for the caller to refuse, past MAX_EXPANDED or with a
|
|
169
|
+
// backslash in a value, which Ruby's gsub reads as a reference to the match.
|
|
185
170
|
export function expandBraces(pattern) {
|
|
186
171
|
if (pattern.length > MAX_PATTERN) return undefined
|
|
187
172
|
const rewritten = pattern.replaceAll('/**/', '{/**/,/}')
|
package/src/cocoapods/inputs.js
CHANGED
|
@@ -5,10 +5,7 @@ import { DeptreeError, quote } from '../error.js'
|
|
|
5
5
|
import { checkHostKeys, checkLeftOut, checkProject, readBytes, readText, typeOf } from '../project.js'
|
|
6
6
|
import { isObject } from './podspec.js'
|
|
7
7
|
|
|
8
|
-
//
|
|
9
|
-
// but for one thing, which tree.js follows: 1.16 on copy a download into
|
|
10
|
-
// their cache with rsync, which leaves the clone's .git out, where those
|
|
11
|
-
// before use FileUtils.cp_r, which copies it.
|
|
8
|
+
// 1.13 to 1.17 download, clean and lock a pod alike but for the clone's .git, which tree.js follows
|
|
12
9
|
const VERSION = /^1\.1[3-7]\.\d+$/u
|
|
13
10
|
|
|
14
11
|
export function checkHost(host) {
|
|
@@ -18,8 +15,7 @@ export function checkHost(host) {
|
|
|
18
15
|
return { cocoapods: host.cocoapods, os: host.os }
|
|
19
16
|
}
|
|
20
17
|
|
|
21
|
-
// What the Podfile's targets are for, as Platform names them, each once;
|
|
22
|
-
// undefined for any.
|
|
18
|
+
// What the Podfile's targets are for, as Platform names them, each once; undefined for any
|
|
23
19
|
const PLATFORMS = new Set(['ios', 'osx', 'tvos', 'visionos', 'watchos'])
|
|
24
20
|
const PLATFORMS_TYPE = 'platforms must be a non-empty list of ios, osx, tvos, visionos and watchos, each once, or left out'
|
|
25
21
|
export function platformsOf(platforms) {
|
|
@@ -34,8 +30,7 @@ export function flagsOf({ manifest = false, partial = false }) {
|
|
|
34
30
|
return { manifest, partial }
|
|
35
31
|
}
|
|
36
32
|
|
|
37
|
-
//
|
|
38
|
-
// pod there is.
|
|
33
|
+
// The names of the pods to download, each once; undefined for every pod
|
|
39
34
|
const ONLY = 'only must be a list of the names of pods, each once, or left out'
|
|
40
35
|
export function onlyOf(only) {
|
|
41
36
|
if (only === undefined) return undefined
|
|
@@ -48,9 +43,8 @@ const PODFILES = ['CocoaPods.podfile.yaml', 'CocoaPods.podfile', 'Podfile', 'Pod
|
|
|
48
43
|
|
|
49
44
|
const LOCKFILE = 'lockfile must be the Podfile.lock text, or left out where project is given'
|
|
50
45
|
|
|
51
|
-
// The podspecs of pods by :podspec,
|
|
52
|
-
//
|
|
53
|
-
// project's Pods/Local Podspecs; undefined for one neither has.
|
|
46
|
+
// The podspecs of pods by :podspec, by name: those given, or else the project's Pods/Local Podspecs;
|
|
47
|
+
// undefined for one neither has
|
|
54
48
|
const PODSPECS = 'podspecs must be an object of podspecs by name, each as text or bytes, or left out'
|
|
55
49
|
function podspecsOf(podspecs, project) {
|
|
56
50
|
if (podspecs !== undefined) {
|