@socketsecurity/lib 5.15.0 → 5.17.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/CHANGELOG.md +21 -0
- package/README.md +2 -2
- package/dist/abort.d.ts +13 -0
- package/dist/agent.d.ts +81 -0
- package/dist/ansi.d.ts +13 -0
- package/dist/archives.d.ts +31 -0
- package/dist/argv/flags.d.ts +91 -0
- package/dist/argv/parse.d.ts +31 -0
- package/dist/bin.d.ts +54 -0
- package/dist/cacache.d.ts +38 -0
- package/dist/cache-with-ttl.d.ts +7 -0
- package/dist/colors.d.ts +12 -0
- package/dist/cover/formatters.d.ts +18 -0
- package/dist/debug.d.ts +6 -0
- package/dist/dlx/binary.d.ts +84 -0
- package/dist/dlx/cache.d.ts +6 -0
- package/dist/dlx/detect.d.ts +33 -0
- package/dist/dlx/dir.d.ts +34 -0
- package/dist/dlx/manifest.d.ts +16 -0
- package/dist/dlx/package.d.ts +43 -0
- package/dist/dlx/packages.d.ts +36 -0
- package/dist/dlx/paths.d.ts +20 -0
- package/dist/dlx/paths.js +1 -1
- package/dist/effects/pulse-frames.d.ts +6 -0
- package/dist/effects/text-shimmer.d.ts +9 -0
- package/dist/effects/ultra.d.ts +6 -0
- package/dist/env/ci.d.ts +14 -0
- package/dist/env/debug.d.ts +13 -0
- package/dist/env/github.d.ts +80 -0
- package/dist/env/helpers.d.ts +45 -0
- package/dist/env/home.d.ts +13 -0
- package/dist/env/locale.d.ts +30 -0
- package/dist/env/node-auth-token.d.ts +13 -0
- package/dist/env/node-env.d.ts +13 -0
- package/dist/env/npm.d.ts +50 -0
- package/dist/env/path.d.ts +13 -0
- package/dist/env/pre-commit.d.ts +14 -0
- package/dist/env/rewire.d.ts +38 -0
- package/dist/env/shell.d.ts +13 -0
- package/dist/env/socket-cli-shadow.d.ts +43 -0
- package/dist/env/socket-cli.d.ts +116 -0
- package/dist/env/socket.d.ts +153 -0
- package/dist/env/temp-dir.d.ts +30 -0
- package/dist/env/term.d.ts +13 -0
- package/dist/env/test.d.ts +32 -0
- package/dist/env/windows.d.ts +40 -0
- package/dist/env/xdg.d.ts +30 -0
- package/dist/env.d.ts +40 -0
- package/dist/external/npm-pack.js +202 -291
- package/dist/external/tar-fs.js +27 -7
- package/dist/fs.d.ts +13 -0
- package/dist/functions.d.ts +30 -0
- package/dist/globs.d.ts +27 -0
- package/dist/http-request.d.ts +16 -0
- package/dist/json/format.d.ts +18 -0
- package/dist/memoization.d.ts +5 -0
- package/dist/packages/edit.d.ts +28 -0
- package/dist/packages/exports.d.ts +40 -0
- package/dist/packages/licenses.d.ts +59 -0
- package/dist/packages/manifest.d.ts +18 -0
- package/dist/packages/normalize.d.ts +22 -0
- package/dist/packages/operations.d.ts +51 -0
- package/dist/packages/provenance.d.ts +11 -0
- package/dist/packages/specs.d.ts +30 -0
- package/dist/packages/validation.d.ts +18 -0
- package/dist/paths/normalize.d.ts +81 -5
- package/dist/paths/normalize.js +29 -2
- package/dist/paths/rewire.js +12 -3
- package/dist/regexps.d.ts +7 -0
- package/dist/releases/github.d.ts +63 -0
- package/dist/releases/socket-btm.d.ts +31 -0
- package/dist/sea.d.ts +15 -0
- package/dist/shadow.d.ts +7 -0
- package/dist/signal-exit.d.ts +27 -0
- package/dist/sorts.d.ts +33 -0
- package/dist/spawn.d.ts +9 -0
- package/dist/stdio/mask.d.ts +26 -0
- package/dist/streams.d.ts +28 -0
- package/dist/suppress-warnings.d.ts +7 -0
- package/dist/temporary-executor.d.ts +7 -0
- package/dist/url.d.ts +59 -0
- package/dist/versions.d.ts +119 -0
- package/dist/words.d.ts +20 -0
- package/package.json +7 -57
package/dist/external/tar-fs.js
CHANGED
|
@@ -547,9 +547,9 @@ var require_text_decoder = __commonJS({
|
|
|
547
547
|
}
|
|
548
548
|
});
|
|
549
549
|
|
|
550
|
-
// node_modules/.pnpm/streamx@2.
|
|
550
|
+
// node_modules/.pnpm/streamx@2.25.0/node_modules/streamx/index.js
|
|
551
551
|
var require_streamx = __commonJS({
|
|
552
|
-
"node_modules/.pnpm/streamx@2.
|
|
552
|
+
"node_modules/.pnpm/streamx@2.25.0/node_modules/streamx/index.js"(exports2, module2) {
|
|
553
553
|
var { EventEmitter } = require_default();
|
|
554
554
|
var STREAM_DESTROYED = new Error("Stream was destroyed");
|
|
555
555
|
var PREMATURE_CLOSE = new Error("Premature close");
|
|
@@ -660,6 +660,9 @@ var require_streamx = __commonJS({
|
|
|
660
660
|
this.afterWrite = afterWrite.bind(this);
|
|
661
661
|
this.afterUpdateNextTick = updateWriteNT.bind(this);
|
|
662
662
|
}
|
|
663
|
+
get ending() {
|
|
664
|
+
return (this.stream._duplexState & WRITE_FINISHING) !== 0;
|
|
665
|
+
}
|
|
663
666
|
get ended() {
|
|
664
667
|
return (this.stream._duplexState & WRITE_DONE) !== 0;
|
|
665
668
|
}
|
|
@@ -761,6 +764,9 @@ var require_streamx = __commonJS({
|
|
|
761
764
|
this.afterRead = afterRead.bind(this);
|
|
762
765
|
this.afterUpdateNextTick = updateReadNT.bind(this);
|
|
763
766
|
}
|
|
767
|
+
get ending() {
|
|
768
|
+
return (this.stream._duplexState & READ_ENDING) !== 0;
|
|
769
|
+
}
|
|
764
770
|
get ended() {
|
|
765
771
|
return (this.stream._duplexState & READ_DONE) !== 0;
|
|
766
772
|
}
|
|
@@ -825,7 +831,8 @@ var require_streamx = __commonJS({
|
|
|
825
831
|
const stream = this.stream;
|
|
826
832
|
if ((stream._duplexState & READ_STATUS) === READ_QUEUED) {
|
|
827
833
|
const data = this.shift();
|
|
828
|
-
if (this.pipeTo !== null && this.pipeTo.write(data) === false)
|
|
834
|
+
if (this.pipeTo !== null && this.pipeTo.write(data) === false)
|
|
835
|
+
stream._duplexState &= READ_PIPE_NOT_DRAINED;
|
|
829
836
|
if ((stream._duplexState & READ_EMIT_DATA) !== 0) stream.emit("data", data);
|
|
830
837
|
return data;
|
|
831
838
|
}
|
|
@@ -839,7 +846,8 @@ var require_streamx = __commonJS({
|
|
|
839
846
|
const stream = this.stream;
|
|
840
847
|
while ((stream._duplexState & READ_STATUS) === READ_QUEUED && (stream._duplexState & READ_FLOWING) !== 0) {
|
|
841
848
|
const data = this.shift();
|
|
842
|
-
if (this.pipeTo !== null && this.pipeTo.write(data) === false)
|
|
849
|
+
if (this.pipeTo !== null && this.pipeTo.write(data) === false)
|
|
850
|
+
stream._duplexState &= READ_PIPE_NOT_DRAINED;
|
|
843
851
|
if ((stream._duplexState & READ_EMIT_DATA) !== 0) stream.emit("data", data);
|
|
844
852
|
}
|
|
845
853
|
}
|
|
@@ -1001,7 +1009,8 @@ var require_streamx = __commonJS({
|
|
|
1001
1009
|
function afterRead(err) {
|
|
1002
1010
|
if (err) this.stream.destroy(err);
|
|
1003
1011
|
this.stream._duplexState &= READ_NOT_ACTIVE;
|
|
1004
|
-
if (this.readAhead === false && (this.stream._duplexState & READ_RESUMED) === 0)
|
|
1012
|
+
if (this.readAhead === false && (this.stream._duplexState & READ_RESUMED) === 0)
|
|
1013
|
+
this.stream._duplexState &= READ_NO_READ_AHEAD;
|
|
1005
1014
|
this.updateCallback();
|
|
1006
1015
|
}
|
|
1007
1016
|
__name(afterRead, "afterRead");
|
|
@@ -1265,7 +1274,8 @@ var require_streamx = __commonJS({
|
|
|
1265
1274
|
function ondata(data) {
|
|
1266
1275
|
if (promiseReject === null) return;
|
|
1267
1276
|
if (error) promiseReject(error);
|
|
1268
|
-
else if (data === null && (stream._duplexState & READ_DONE) === 0)
|
|
1277
|
+
else if (data === null && (stream._duplexState & READ_DONE) === 0)
|
|
1278
|
+
promiseReject(STREAM_DESTROYED);
|
|
1269
1279
|
else promiseResolve({ value: data, done: data === null });
|
|
1270
1280
|
promiseReject = promiseResolve = null;
|
|
1271
1281
|
}
|
|
@@ -1512,10 +1522,18 @@ var require_streamx = __commonJS({
|
|
|
1512
1522
|
return typeof stream._duplexState === "number" && isStream(stream);
|
|
1513
1523
|
}
|
|
1514
1524
|
__name(isStreamx, "isStreamx");
|
|
1525
|
+
function isEnding(stream) {
|
|
1526
|
+
return !!stream._readableState && stream._readableState.ending;
|
|
1527
|
+
}
|
|
1528
|
+
__name(isEnding, "isEnding");
|
|
1515
1529
|
function isEnded(stream) {
|
|
1516
1530
|
return !!stream._readableState && stream._readableState.ended;
|
|
1517
1531
|
}
|
|
1518
1532
|
__name(isEnded, "isEnded");
|
|
1533
|
+
function isFinishing(stream) {
|
|
1534
|
+
return !!stream._writableState && stream._writableState.ending;
|
|
1535
|
+
}
|
|
1536
|
+
__name(isFinishing, "isFinishing");
|
|
1519
1537
|
function isFinished(stream) {
|
|
1520
1538
|
return !!stream._writableState && stream._writableState.ended;
|
|
1521
1539
|
}
|
|
@@ -1530,7 +1548,7 @@ var require_streamx = __commonJS({
|
|
|
1530
1548
|
}
|
|
1531
1549
|
__name(isReadStreamx, "isReadStreamx");
|
|
1532
1550
|
function isDisturbed(stream) {
|
|
1533
|
-
return (stream._duplexState & OPENING) !== OPENING || (stream._duplexState & ACTIVE_OR_TICKING) !== 0;
|
|
1551
|
+
return (stream._duplexState & OPENING) !== OPENING || (stream._duplexState & DESTROYING) === DESTROYING || (stream._duplexState & ACTIVE_OR_TICKING) !== 0;
|
|
1534
1552
|
}
|
|
1535
1553
|
__name(isDisturbed, "isDisturbed");
|
|
1536
1554
|
function isTypedArray(data) {
|
|
@@ -1557,7 +1575,9 @@ var require_streamx = __commonJS({
|
|
|
1557
1575
|
pipelinePromise,
|
|
1558
1576
|
isStream,
|
|
1559
1577
|
isStreamx,
|
|
1578
|
+
isEnding,
|
|
1560
1579
|
isEnded,
|
|
1580
|
+
isFinishing,
|
|
1561
1581
|
isFinished,
|
|
1562
1582
|
isDisturbed,
|
|
1563
1583
|
getStreamError,
|
package/dist/fs.d.ts
CHANGED
|
@@ -283,6 +283,12 @@ export declare function findUpSync(name: string | string[] | readonly string[],
|
|
|
283
283
|
* Called automatically by the paths/rewire module when paths are overridden in tests.
|
|
284
284
|
*
|
|
285
285
|
* @internal Used for test rewiring
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* ```typescript
|
|
289
|
+
* invalidatePathCache()
|
|
290
|
+
* // Cached allowed directories are now cleared
|
|
291
|
+
* ```
|
|
286
292
|
*/
|
|
287
293
|
export declare function invalidatePathCache(): void;
|
|
288
294
|
/**
|
|
@@ -382,6 +388,13 @@ export declare function normalizeEncoding(enc: BufferEncoding | string | null |
|
|
|
382
388
|
*
|
|
383
389
|
* @param enc - Encoding to normalize
|
|
384
390
|
* @returns Normalized encoding string, defaults to 'utf8' for unknown encodings
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* ```typescript
|
|
394
|
+
* normalizeEncodingSlow('ucs2') // 'utf16le'
|
|
395
|
+
* normalizeEncodingSlow('LATIN1') // 'latin1'
|
|
396
|
+
* normalizeEncodingSlow('binary') // 'latin1'
|
|
397
|
+
* ```
|
|
385
398
|
*/
|
|
386
399
|
/*@__NO_SIDE_EFFECTS__*/
|
|
387
400
|
export declare function normalizeEncodingSlow(enc: string): BufferEncoding;
|
package/dist/functions.d.ts
CHANGED
|
@@ -7,21 +7,51 @@ export type AsyncFunction<TArgs extends unknown[], TResult> = (...args: TArgs) =
|
|
|
7
7
|
export type AnyFunction = (...args: unknown[]) => unknown;
|
|
8
8
|
/**
|
|
9
9
|
* A no-op function that does nothing.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const callback = noop
|
|
14
|
+
* callback() // does nothing
|
|
15
|
+
* ```
|
|
10
16
|
*/
|
|
11
17
|
/*@__NO_SIDE_EFFECTS__*/
|
|
12
18
|
export declare function noop(): void;
|
|
13
19
|
/**
|
|
14
20
|
* Create a function that only executes once.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const init = once(() => Math.random())
|
|
25
|
+
* init() // 0.456 (random value)
|
|
26
|
+
* init() // 0.456 (same value, not recalculated)
|
|
27
|
+
* ```
|
|
15
28
|
*/
|
|
16
29
|
/*@__NO_SIDE_EFFECTS__*/
|
|
17
30
|
export declare function once<T extends AnyFunction>(fn: T): T;
|
|
18
31
|
/**
|
|
19
32
|
* Wrap an async function to silently catch and ignore errors.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const safeFetch = silentWrapAsync(async (url: string) => {
|
|
37
|
+
* const res = await fetch(url)
|
|
38
|
+
* return res.json()
|
|
39
|
+
* })
|
|
40
|
+
* await safeFetch('https://example.com') // result or undefined on error
|
|
41
|
+
* ```
|
|
20
42
|
*/
|
|
21
43
|
/*@__NO_SIDE_EFFECTS__*/
|
|
22
44
|
export declare function silentWrapAsync<TArgs extends unknown[], TResult>(fn: AsyncFunction<TArgs, TResult>): (...args: TArgs) => Promise<TResult | undefined>;
|
|
23
45
|
/**
|
|
24
46
|
* Execute a function with tail call optimization via trampoline.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const factorial = trampoline((n: number, acc = 1): any =>
|
|
51
|
+
* n <= 1 ? acc : () => factorial(n - 1, n * acc)
|
|
52
|
+
* )
|
|
53
|
+
* factorial(5) // 120
|
|
54
|
+
* ```
|
|
25
55
|
*/
|
|
26
56
|
/*@__NO_SIDE_EFFECTS__*/
|
|
27
57
|
export declare function trampoline<T extends AnyFunction>(fn: T): T;
|
package/dist/globs.d.ts
CHANGED
|
@@ -32,11 +32,26 @@ export type { Pattern, FastGlobOptions };
|
|
|
32
32
|
export declare const defaultIgnore: readonly string[];
|
|
33
33
|
/**
|
|
34
34
|
* Create a stream of license file paths matching glob patterns.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const stream = globStreamLicenses('/tmp/my-package')
|
|
39
|
+
* for await (const licensePath of stream) {
|
|
40
|
+
* console.log(licensePath)
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
35
43
|
*/
|
|
36
44
|
/*@__NO_SIDE_EFFECTS__*/
|
|
37
45
|
export declare function globStreamLicenses(dirname: string, options?: GlobOptions): NodeJS.ReadableStream;
|
|
38
46
|
/**
|
|
39
47
|
* Get a cached glob matcher function.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const isMatch = getGlobMatcher('*.ts')
|
|
52
|
+
* isMatch('index.ts') // true
|
|
53
|
+
* isMatch('index.js') // false
|
|
54
|
+
* ```
|
|
40
55
|
*/
|
|
41
56
|
/*@__NO_SIDE_EFFECTS__*/
|
|
42
57
|
export declare function getGlobMatcher(glob: Pattern | Pattern[], options?: {
|
|
@@ -47,12 +62,24 @@ export declare function getGlobMatcher(glob: Pattern | Pattern[], options?: {
|
|
|
47
62
|
/**
|
|
48
63
|
* Asynchronously find files matching glob patterns.
|
|
49
64
|
* Wrapper around fast-glob.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* const files = await glob('src/*.ts', { cwd: '/tmp/project' })
|
|
69
|
+
* console.log(files) // ['src/index.ts', 'src/utils.ts']
|
|
70
|
+
* ```
|
|
50
71
|
*/
|
|
51
72
|
/*@__NO_SIDE_EFFECTS__*/
|
|
52
73
|
export declare function glob(patterns: Pattern | Pattern[], options?: FastGlobOptions): Promise<string[]>;
|
|
53
74
|
/**
|
|
54
75
|
* Synchronously find files matching glob patterns.
|
|
55
76
|
* Wrapper around fast-glob.sync.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* const files = globSync('*.json', { cwd: '/tmp/project' })
|
|
81
|
+
* console.log(files) // ['package.json', 'tsconfig.json']
|
|
82
|
+
* ```
|
|
56
83
|
*/
|
|
57
84
|
/*@__NO_SIDE_EFFECTS__*/
|
|
58
85
|
export declare function globSync(patterns: Pattern | Pattern[], options?: FastGlobOptions): string[];
|
package/dist/http-request.d.ts
CHANGED
|
@@ -429,6 +429,13 @@ export interface HttpResponse {
|
|
|
429
429
|
* `httpRequest()` (e.g., multipart form-data uploads via `http.request()`,
|
|
430
430
|
* or responses from third-party HTTP libraries) and need to convert it
|
|
431
431
|
* into the standard HttpResponse interface.
|
|
432
|
+
*
|
|
433
|
+
* @example
|
|
434
|
+
* ```typescript
|
|
435
|
+
* const raw = await makeRawRequest('https://example.com/api')
|
|
436
|
+
* const response = await readIncomingResponse(raw)
|
|
437
|
+
* console.log(response.status, response.body.toString('utf8'))
|
|
438
|
+
* ```
|
|
432
439
|
*/
|
|
433
440
|
export declare function readIncomingResponse(msg: IncomingResponse): Promise<HttpResponse>;
|
|
434
441
|
/**
|
|
@@ -772,6 +779,15 @@ export declare function fetchChecksums(url: string, options?: FetchChecksumsOpti
|
|
|
772
779
|
/**
|
|
773
780
|
* Build an enriched error message based on the error code.
|
|
774
781
|
* Generic guidance (no product-specific branding).
|
|
782
|
+
*
|
|
783
|
+
* @example
|
|
784
|
+
* ```typescript
|
|
785
|
+
* try {
|
|
786
|
+
* await fetch('https://api.example.com')
|
|
787
|
+
* } catch (err) {
|
|
788
|
+
* console.error(enrichErrorMessage('https://api.example.com', 'GET', err))
|
|
789
|
+
* }
|
|
790
|
+
* ```
|
|
775
791
|
*/
|
|
776
792
|
export declare function enrichErrorMessage(url: string, method: string, error: NodeJS.ErrnoException): string;
|
|
777
793
|
/**
|
package/dist/json/format.d.ts
CHANGED
|
@@ -69,6 +69,12 @@ export declare function extractFormatting(json: string): JsonFormatting;
|
|
|
69
69
|
* Get default formatting for JSON files.
|
|
70
70
|
*
|
|
71
71
|
* @returns Default formatting (2 spaces, LF line endings)
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const fmt = getDefaultFormatting()
|
|
76
|
+
* // { indent: 2, newline: '\n' }
|
|
77
|
+
* ```
|
|
72
78
|
*/
|
|
73
79
|
export declare function getDefaultFormatting(): JsonFormatting;
|
|
74
80
|
/**
|
|
@@ -109,6 +115,12 @@ export declare function stringifyWithFormatting(content: Record<string, unknown>
|
|
|
109
115
|
*
|
|
110
116
|
* @param content - Content object with potential symbol properties
|
|
111
117
|
* @returns Object with symbols removed
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* const obj = { key: "value", [Symbol.for("indent")]: 2 }
|
|
122
|
+
* stripFormattingSymbols(obj) // { key: "value" }
|
|
123
|
+
* ```
|
|
112
124
|
*/
|
|
113
125
|
export declare function stripFormattingSymbols(content: Record<string | symbol, unknown>): Record<string, unknown>;
|
|
114
126
|
/**
|
|
@@ -116,6 +128,12 @@ export declare function stripFormattingSymbols(content: Record<string | symbol,
|
|
|
116
128
|
*
|
|
117
129
|
* @param content - Content object with Symbol.for('indent') and Symbol.for('newline')
|
|
118
130
|
* @returns Formatting metadata, or defaults if symbols not present
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```typescript
|
|
134
|
+
* const content = { [Symbol.for("indent")]: 4, [Symbol.for("newline")]: "\r\n" }
|
|
135
|
+
* getFormattingFromContent(content) // { indent: 4, newline: "\r\n" }
|
|
136
|
+
* ```
|
|
119
137
|
*/
|
|
120
138
|
export declare function getFormattingFromContent(content: Record<string | symbol, unknown>): JsonFormatting;
|
|
121
139
|
/**
|
package/dist/memoization.d.ts
CHANGED
|
@@ -79,6 +79,11 @@ export declare function Memoize(options?: MemoizeOptions<unknown[], unknown>): (
|
|
|
79
79
|
/**
|
|
80
80
|
* Clear all memoization caches.
|
|
81
81
|
* Useful for testing or when you need to force recomputation.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* clearAllMemoizationCaches()
|
|
86
|
+
* ```
|
|
82
87
|
*/
|
|
83
88
|
export declare function clearAllMemoizationCaches(): void;
|
|
84
89
|
/**
|
package/dist/packages/edit.d.ts
CHANGED
|
@@ -83,21 +83,49 @@ export interface EditablePackageJsonInstance {
|
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
85
|
* Get the EditablePackageJson class for package.json manipulation.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* const EditablePackageJson = getEditablePackageJsonClass()
|
|
90
|
+
* const pkg = await EditablePackageJson.load('/tmp/my-project')
|
|
91
|
+
* console.log(pkg.content.name)
|
|
92
|
+
* ```
|
|
86
93
|
*/
|
|
87
94
|
/*@__NO_SIDE_EFFECTS__*/
|
|
88
95
|
export declare function getEditablePackageJsonClass(): EditablePackageJsonConstructor;
|
|
89
96
|
/**
|
|
90
97
|
* Convert a package.json object to an editable instance.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* const editable = pkgJsonToEditable({ name: 'my-pkg', version: '1.0.0' })
|
|
102
|
+
* ```
|
|
91
103
|
*/
|
|
92
104
|
/*@__NO_SIDE_EFFECTS__*/
|
|
93
105
|
export declare function pkgJsonToEditable(pkgJson: PackageJson, options?: EditablePackageJsonOptions): unknown;
|
|
94
106
|
/**
|
|
95
107
|
* Convert package.json to editable instance with file persistence.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* const editable = await toEditablePackageJson(
|
|
112
|
+
* { name: 'my-pkg', version: '1.0.0' },
|
|
113
|
+
* { path: '/tmp/my-project' }
|
|
114
|
+
* )
|
|
115
|
+
* ```
|
|
96
116
|
*/
|
|
97
117
|
/*@__NO_SIDE_EFFECTS__*/
|
|
98
118
|
export declare function toEditablePackageJson(pkgJson: PackageJson, options?: EditablePackageJsonOptions): Promise<unknown>;
|
|
99
119
|
/**
|
|
100
120
|
* Convert package.json to editable instance with file persistence synchronously.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* const editable = toEditablePackageJsonSync(
|
|
125
|
+
* { name: 'my-pkg', version: '1.0.0' },
|
|
126
|
+
* { path: '/tmp/my-project' }
|
|
127
|
+
* )
|
|
128
|
+
* ```
|
|
101
129
|
*/
|
|
102
130
|
/*@__NO_SIDE_EFFECTS__*/
|
|
103
131
|
export declare function toEditablePackageJsonSync(pkgJson: PackageJson, options?: EditablePackageJsonOptions): unknown;
|
|
@@ -1,30 +1,70 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Find types definition for a specific subpath in package exports.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* const exports = { '.': { types: './dist/index.d.ts', import: './dist/index.js' } }
|
|
7
|
+
* const types = findTypesForSubpath(exports, './dist/index.js')
|
|
8
|
+
* // types === './dist/index.d.ts'
|
|
9
|
+
* ```
|
|
3
10
|
*/
|
|
4
11
|
/*@__NO_SIDE_EFFECTS__*/
|
|
5
12
|
export declare function findTypesForSubpath(entryExports: unknown, subpath: string): string | undefined;
|
|
6
13
|
/**
|
|
7
14
|
* Get subpaths from package exports.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const exports = { '.': './index.js', './utils': './utils.js' }
|
|
19
|
+
* getSubpaths(exports) // ['.', './utils']
|
|
20
|
+
* ```
|
|
8
21
|
*/
|
|
9
22
|
/*@__NO_SIDE_EFFECTS__*/
|
|
10
23
|
export declare function getSubpaths(entryExports: unknown): string[];
|
|
11
24
|
/**
|
|
12
25
|
* Get file paths from package exports.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const exports = { '.': './dist/index.js', './utils': './dist/utils.js' }
|
|
30
|
+
* getExportFilePaths(exports) // ['./dist/index.js', './dist/utils.js']
|
|
31
|
+
* ```
|
|
13
32
|
*/
|
|
14
33
|
/*@__NO_SIDE_EFFECTS__*/
|
|
15
34
|
export declare function getExportFilePaths(entryExports: unknown): string[];
|
|
16
35
|
/**
|
|
17
36
|
* Check if package exports use conditional patterns (e.g., import/require).
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* isConditionalExports({ import: './index.mjs', require: './index.cjs' }) // true
|
|
41
|
+
* isConditionalExports({ '.': './index.js' }) // false
|
|
42
|
+
* ```
|
|
18
43
|
*/
|
|
19
44
|
/*@__NO_SIDE_EFFECTS__*/
|
|
20
45
|
export declare function isConditionalExports(entryExports: unknown): boolean;
|
|
21
46
|
/**
|
|
22
47
|
* Check if package exports use subpath patterns (keys starting with '.').
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* isSubpathExports({ '.': './index.js', './utils': './utils.js' }) // true
|
|
52
|
+
* isSubpathExports({ import: './index.mjs' }) // false
|
|
53
|
+
* ```
|
|
23
54
|
*/
|
|
24
55
|
/*@__NO_SIDE_EFFECTS__*/
|
|
25
56
|
export declare function isSubpathExports(entryExports: unknown): boolean;
|
|
26
57
|
/**
|
|
27
58
|
* Normalize package.json exports field to canonical format.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* resolvePackageJsonEntryExports('./index.js')
|
|
63
|
+
* // { '.': './index.js' }
|
|
64
|
+
*
|
|
65
|
+
* resolvePackageJsonEntryExports({ '.': './index.js' })
|
|
66
|
+
* // { '.': './index.js' }
|
|
67
|
+
* ```
|
|
28
68
|
*/
|
|
29
69
|
/*@__NO_SIDE_EFFECTS__*/
|
|
30
70
|
export declare function resolvePackageJsonEntryExports(entryExports: unknown): unknown;
|
|
@@ -28,41 +28,100 @@ export interface LicenseVisitor {
|
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Collect licenses that are incompatible (copyleft).
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const nodes = [{ license: 'MIT' }, { license: 'GPL-3.0' }]
|
|
35
|
+
* const incompatible = collectIncompatibleLicenses(nodes)
|
|
36
|
+
* // incompatible contains only the GPL-3.0 node
|
|
37
|
+
* ```
|
|
31
38
|
*/
|
|
32
39
|
/*@__NO_SIDE_EFFECTS__*/
|
|
33
40
|
export declare function collectIncompatibleLicenses(licenseNodes: LicenseNode[]): LicenseNode[];
|
|
34
41
|
/**
|
|
35
42
|
* Collect warnings from license nodes.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const nodes = [{ license: 'UNLICENSED' }]
|
|
47
|
+
* collectLicenseWarnings(nodes) // ['Package is unlicensed']
|
|
48
|
+
* ```
|
|
36
49
|
*/
|
|
37
50
|
/*@__NO_SIDE_EFFECTS__*/
|
|
38
51
|
export declare function collectLicenseWarnings(licenseNodes: LicenseNode[]): string[];
|
|
39
52
|
/**
|
|
40
53
|
* Create an AST node from a raw node.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const raw = { license: 'MIT' }
|
|
58
|
+
* const node = createAstNode(raw)
|
|
59
|
+
* // node.type === 'License'
|
|
60
|
+
* ```
|
|
41
61
|
*/
|
|
42
62
|
/*@__NO_SIDE_EFFECTS__*/
|
|
43
63
|
export declare function createAstNode(rawNode: SpdxAstNode): InternalAstNode;
|
|
44
64
|
/**
|
|
45
65
|
* Create a binary operation AST node.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const raw = {
|
|
70
|
+
* left: { license: 'MIT' },
|
|
71
|
+
* conjunction: 'OR' as const,
|
|
72
|
+
* right: { license: 'Apache-2.0' }
|
|
73
|
+
* }
|
|
74
|
+
* const node = createBinaryOperationNode(raw)
|
|
75
|
+
* // node.type === 'BinaryOperation'
|
|
76
|
+
* ```
|
|
46
77
|
*/
|
|
47
78
|
/*@__NO_SIDE_EFFECTS__*/
|
|
48
79
|
export declare function createBinaryOperationNode(rawNodeParam: SpdxBinaryOperationNode): InternalBinaryOperationNode;
|
|
49
80
|
/**
|
|
50
81
|
* Create a license AST node.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const node = createLicenseNode({ license: 'MIT' })
|
|
86
|
+
* // node.type === 'License' && node.license === 'MIT'
|
|
87
|
+
* ```
|
|
51
88
|
*/
|
|
52
89
|
/*@__NO_SIDE_EFFECTS__*/
|
|
53
90
|
export declare function createLicenseNode(rawNode: SpdxLicenseNode): InternalLicenseNode;
|
|
54
91
|
/**
|
|
55
92
|
* Parse an SPDX license expression into an AST.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* const ast = parseSpdxExp('MIT OR Apache-2.0')
|
|
97
|
+
* // ast is a BinaryOperation node with MIT and Apache-2.0 leaves
|
|
98
|
+
* ```
|
|
56
99
|
*/
|
|
57
100
|
/*@__NO_SIDE_EFFECTS__*/
|
|
58
101
|
export declare function parseSpdxExp(spdxExp: string): SpdxAstNode | undefined;
|
|
59
102
|
/**
|
|
60
103
|
* Parse package license field into structured license nodes.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* const nodes = resolvePackageLicenses('MIT', '/tmp/my-project')
|
|
108
|
+
* // [{ license: 'MIT' }]
|
|
109
|
+
* ```
|
|
61
110
|
*/
|
|
62
111
|
/*@__NO_SIDE_EFFECTS__*/
|
|
63
112
|
export declare function resolvePackageLicenses(licenseFieldValue: string, where: string): LicenseNode[];
|
|
64
113
|
/**
|
|
65
114
|
* Traverse SPDX license AST and invoke visitor callbacks for each node.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* const ast = parseSpdxExp('MIT OR Apache-2.0')
|
|
119
|
+
* const licenses: string[] = []
|
|
120
|
+
* if (ast) {
|
|
121
|
+
* visitLicenses(ast, { License(node) { licenses.push(node.license) } })
|
|
122
|
+
* }
|
|
123
|
+
* // licenses === ['MIT', 'Apache-2.0']
|
|
124
|
+
* ```
|
|
66
125
|
*/
|
|
67
126
|
/*@__NO_SIDE_EFFECTS__*/
|
|
68
127
|
export declare function visitLicenses(ast: SpdxAstNode, visitor: LicenseVisitor): void;
|
|
@@ -1,16 +1,34 @@
|
|
|
1
1
|
import type { PackageJson, PacoteOptions } from '../packages';
|
|
2
2
|
/**
|
|
3
3
|
* Create a package.json object for a Socket registry package.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const pkgJson = createPackageJson('is-number', 'packages/npm/is-number', {
|
|
8
|
+
* version: '1.0.0',
|
|
9
|
+
* description: 'Check if a value is a number'
|
|
10
|
+
* })
|
|
11
|
+
* ```
|
|
4
12
|
*/
|
|
5
13
|
/*@__NO_SIDE_EFFECTS__*/
|
|
6
14
|
export declare function createPackageJson(sockRegPkgName: string, directory: string, options?: PackageJson | undefined): PackageJson;
|
|
7
15
|
/**
|
|
8
16
|
* Fetch the manifest for a package.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const manifest = await fetchPackageManifest('lodash@4.17.21')
|
|
21
|
+
* ```
|
|
9
22
|
*/
|
|
10
23
|
/*@__NO_SIDE_EFFECTS__*/
|
|
11
24
|
export declare function fetchPackageManifest(pkgNameOrId: string, options?: PacoteOptions): Promise<unknown>;
|
|
12
25
|
/**
|
|
13
26
|
* Fetch the packument (package document) for a package.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const packument = await fetchPackagePackument('lodash')
|
|
31
|
+
* ```
|
|
14
32
|
*/
|
|
15
33
|
/*@__NO_SIDE_EFFECTS__*/
|
|
16
34
|
export declare function fetchPackagePackument(pkgNameOrId: string, options?: PacoteOptions): Promise<unknown>;
|
|
@@ -1,21 +1,43 @@
|
|
|
1
1
|
import type { NormalizeOptions, PackageJson } from '../packages';
|
|
2
2
|
/**
|
|
3
3
|
* Normalize a package.json object with standard npm package normalization.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const pkgJson = { name: 'my-pkg', version: '1.0.0' }
|
|
8
|
+
* const normalized = normalizePackageJson(pkgJson)
|
|
9
|
+
* ```
|
|
4
10
|
*/
|
|
5
11
|
/*@__NO_SIDE_EFFECTS__*/
|
|
6
12
|
export declare function normalizePackageJson(pkgJson: PackageJson, options?: NormalizeOptions): PackageJson;
|
|
7
13
|
/**
|
|
8
14
|
* Extract escaped scope from a Socket registry package name.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* resolveEscapedScope('babel__core') // 'babel__'
|
|
19
|
+
* resolveEscapedScope('lodash') // undefined
|
|
20
|
+
* ```
|
|
9
21
|
*/
|
|
10
22
|
/*@__NO_SIDE_EFFECTS__*/
|
|
11
23
|
export declare function resolveEscapedScope(sockRegPkgName: string): string | undefined;
|
|
12
24
|
/**
|
|
13
25
|
* Resolve original package name from Socket registry package name.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* resolveOriginalPackageName('@socketregistry/is-number') // 'is-number'
|
|
30
|
+
* ```
|
|
14
31
|
*/
|
|
15
32
|
/*@__NO_SIDE_EFFECTS__*/
|
|
16
33
|
export declare function resolveOriginalPackageName(sockRegPkgName: string): string;
|
|
17
34
|
/**
|
|
18
35
|
* Convert escaped scope to standard npm scope format.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* unescapeScope('babel__') // '@babel'
|
|
40
|
+
* ```
|
|
19
41
|
*/
|
|
20
42
|
/*@__NO_SIDE_EFFECTS__*/
|
|
21
43
|
export declare function unescapeScope(escapedScope: string): string;
|