@preventive/upstream 1.0.0-alpha.8 → 1.0.0-alpha.9
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/package.json +9 -2
- package/src/weak-edges.js +87 -0
- package/weak-edges.d.ts +36 -0
- package/weak-edges.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@preventive/upstream",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.9",
|
|
4
4
|
"description": "Minimal npm, crates.io and Soldeer registry clients, a GitHub client, and a git checkout reader: the calls we use, nothing more",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -39,6 +39,10 @@
|
|
|
39
39
|
"./soldeer.js": {
|
|
40
40
|
"types": "./soldeer.d.ts",
|
|
41
41
|
"default": "./soldeer.js"
|
|
42
|
+
},
|
|
43
|
+
"./weak-edges.js": {
|
|
44
|
+
"types": "./weak-edges.d.ts",
|
|
45
|
+
"default": "./weak-edges.js"
|
|
42
46
|
}
|
|
43
47
|
},
|
|
44
48
|
"files": [
|
|
@@ -62,6 +66,8 @@
|
|
|
62
66
|
"semver.js",
|
|
63
67
|
"soldeer.d.ts",
|
|
64
68
|
"soldeer.js",
|
|
69
|
+
"weak-edges.d.ts",
|
|
70
|
+
"weak-edges.js",
|
|
65
71
|
"src/advisories/common.js",
|
|
66
72
|
"src/advisories/github.js",
|
|
67
73
|
"src/advisories/index.js",
|
|
@@ -88,7 +94,8 @@
|
|
|
88
94
|
"src/semver-peer.cjs",
|
|
89
95
|
"src/semver.js",
|
|
90
96
|
"src/tree.js",
|
|
91
|
-
"src/soldeer.js"
|
|
97
|
+
"src/soldeer.js",
|
|
98
|
+
"src/weak-edges.js"
|
|
92
99
|
],
|
|
93
100
|
"engines": {
|
|
94
101
|
"node": ">=24.14.0"
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// Package-relative coordinates keep this inventory independent of installation
|
|
2
|
+
// roots, pnpm layouts, display-prefix stripping, and graph package grouping.
|
|
3
|
+
const babelConfig = { package: '@babel/core', path: /^lib\/config\//u }
|
|
4
|
+
const babelPlugins = { package: '@babel/core', path: /^lib\/config\/files\/(?:module-types|plugins)\.js$/u }
|
|
5
|
+
|
|
6
|
+
export const weakEdges = Object.freeze([
|
|
7
|
+
{
|
|
8
|
+
id: 'react-native-codegen-discovery',
|
|
9
|
+
reason: 'Codegen discovers package metadata and React Native configuration.',
|
|
10
|
+
from: { package: 'react-native', path: /^scripts\/codegen\/generate-artifacts-executor\.js$/u },
|
|
11
|
+
to: { path: /(?:^|\/)(?:package\.json|react-native\.config\.js)$/u },
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
id: 'react-native-release-version',
|
|
15
|
+
reason: 'The CLI release checker reads the installed React Native version.',
|
|
16
|
+
from: { package: '@react-native-community/cli-tools', path: /^build\/releaseChecker\/index\.js$/u },
|
|
17
|
+
to: { package: 'react-native', path: /^package\.json$/u },
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: 'react-native-platform-config',
|
|
21
|
+
reason: 'React Native configuration loads platform CLIs supplied by the host project.',
|
|
22
|
+
from: { package: 'react-native', path: /^react-native\.config\.js$/u },
|
|
23
|
+
to: { package: /^@react-native-community\/cli-platform-(?:android|ios)$/u, path: /^build\/index\.js$/u },
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: 'babel-project-config',
|
|
27
|
+
reason: 'Babel discovers project configuration.',
|
|
28
|
+
from: babelConfig,
|
|
29
|
+
to: { path: /(?:^|\/)babel\.config\.js$/u },
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: 'babel-typescript-preset',
|
|
33
|
+
reason: 'Babel configuration loads the TypeScript preset.',
|
|
34
|
+
from: babelConfig,
|
|
35
|
+
to: { package: '@babel/preset-typescript', path: /./u },
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: 'babel-react-native-preset',
|
|
39
|
+
reason: 'Babel config loaders load the configured React Native preset.',
|
|
40
|
+
from: babelPlugins,
|
|
41
|
+
to: { package: '@react-native/babel-preset', path: /^(?:src\/)?index\.js$/u },
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: 'babel-reanimated-plugin',
|
|
45
|
+
reason: 'Babel config loaders load the configured Reanimated plugin, including scoped copies.',
|
|
46
|
+
from: babelPlugins,
|
|
47
|
+
to: { package: /^(?:@[^/]+\/)?react-native-reanimated$/u, path: /^plugin\/index\.js$/u },
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: 'babel-transform-plugin',
|
|
51
|
+
reason: 'Babel config loaders load configured transform plugins.',
|
|
52
|
+
from: babelPlugins,
|
|
53
|
+
to: { package: /^@babel\/plugin-transform-[^/]+$/u, path: /^lib\/index\.js$/u },
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: 'cosmiconfig-config',
|
|
57
|
+
reason: 'Cosmiconfig loads discovered configuration, including dependency configuration.',
|
|
58
|
+
from: { package: 'cosmiconfig', path: /^dist\/loaders\.js$/u },
|
|
59
|
+
to: { path: /\.config\.js$/u },
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: 'import-fresh-own-config',
|
|
63
|
+
reason: 'import-fresh loads host-project configuration.',
|
|
64
|
+
from: { package: 'import-fresh', path: /./u },
|
|
65
|
+
to: { path: /\.config\.js$/u },
|
|
66
|
+
ownSourceOnly: true,
|
|
67
|
+
},
|
|
68
|
+
].map(rule => Object.freeze({ ...rule, from: Object.freeze(rule.from), to: Object.freeze(rule.to) })))
|
|
69
|
+
|
|
70
|
+
// Do not guess ownership from a partial or shortened path. A nested dependency
|
|
71
|
+
// must be passed as its own package, not as node_modules/... inside its parent.
|
|
72
|
+
function normalizedPath(path) {
|
|
73
|
+
return typeof path === 'string' && !path.includes('\\') && !path.includes(':')
|
|
74
|
+
&& path.split('/').every(part => part !== '' && part !== '.' && part !== '..' && part !== 'node_modules')
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function matches(selector, file) {
|
|
78
|
+
const pkg = selector.package
|
|
79
|
+
if (pkg !== undefined && file.ownSource === true) return false
|
|
80
|
+
return (pkg === undefined || (typeof pkg === 'string' ? pkg === file.package : pkg.test(file.package ?? '')))
|
|
81
|
+
&& selector.path.test(file.path)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function getWeakEdge(from, to) {
|
|
85
|
+
if (from?.ownSource === true || !normalizedPath(from?.path) || !normalizedPath(to?.path)) return undefined
|
|
86
|
+
return weakEdges.find(rule => (!rule.ownSourceOnly || to.ownSource === true) && matches(rule.from, from) && matches(rule.to, to))
|
|
87
|
+
}
|
package/weak-edges.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** A resolved file, identified by its owning package rather than a display path. */
|
|
2
|
+
export interface WeakEdgeFile {
|
|
3
|
+
/** Exact npm package name, including scope. May be absent for own source. */
|
|
4
|
+
package?: string
|
|
5
|
+
/** Normalized /-separated path relative to the owning package or own-source root. */
|
|
6
|
+
path: string
|
|
7
|
+
/** Authoritative project ownership, not inferred from a package name or path. */
|
|
8
|
+
ownSource?: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface WeakEdgeSelector {
|
|
12
|
+
/** Absent means any package or own source. Regular expressions match package names. */
|
|
13
|
+
readonly package?: string | RegExp
|
|
14
|
+
readonly path: RegExp
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface WeakEdgeRule {
|
|
18
|
+
readonly id: string
|
|
19
|
+
readonly reason: string
|
|
20
|
+
readonly from: WeakEdgeSelector
|
|
21
|
+
readonly to: WeakEdgeSelector
|
|
22
|
+
readonly ownSourceOnly?: boolean
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Curated weak loads: omit these file edges from cycles and default inclusion explanations. */
|
|
26
|
+
export const weakEdges: readonly WeakEdgeRule[]
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Returns the matching inventory rule, or undefined for an unrecognized edge.
|
|
30
|
+
* Own-source importers never match. import-fresh requires to.ownSource === true.
|
|
31
|
+
* Own-source targets only match selectors without a package constraint.
|
|
32
|
+
* Resolve nested installations to their actual owning package before calling;
|
|
33
|
+
* absolute, non-normalized, or nested node_modules paths do not match.
|
|
34
|
+
* Does not remove files, alter raw load records, or change runtime resolution.
|
|
35
|
+
*/
|
|
36
|
+
export function getWeakEdge(from: WeakEdgeFile, to: WeakEdgeFile): WeakEdgeRule | undefined
|
package/weak-edges.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getWeakEdge, weakEdges } from './src/weak-edges.js'
|