@vltpkg/output 1.0.0-rc.9 → 1.0.2
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/dist/{esm/error.d.ts → error.d.ts} +0 -1
- package/dist/{esm/error.js → error.js} +0 -1
- package/dist/{esm/index.d.ts → index.d.ts} +9 -2
- package/dist/{esm/index.js → index.js} +2 -3
- package/package.json +35 -39
- package/dist/esm/error.d.ts.map +0 -1
- package/dist/esm/error.js.map +0 -1
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/package.json +0 -3
|
@@ -2,12 +2,20 @@ export type Events = {
|
|
|
2
2
|
request: {
|
|
3
3
|
url: URL | string;
|
|
4
4
|
state: 'start' | 'complete' | '304' | 'cache' | 'stale';
|
|
5
|
+
/** HTTP method for the request, when known. */
|
|
6
|
+
method?: string;
|
|
7
|
+
/** HTTP status code, set on `complete`/`304` completion events. */
|
|
8
|
+
statusCode?: number;
|
|
9
|
+
/** Wall-clock duration of the request in ms, set on completion. */
|
|
10
|
+
durationMs?: number;
|
|
5
11
|
};
|
|
6
12
|
graphStep: {
|
|
7
13
|
step: 'build' | 'actual' | 'reify';
|
|
8
14
|
state: 'start' | 'stop';
|
|
9
15
|
};
|
|
10
16
|
};
|
|
17
|
+
/** Optional diagnostic details attached to a `request` event. */
|
|
18
|
+
export type RequestDetails = Omit<Events['request'], 'url' | 'state'>;
|
|
11
19
|
export declare class OutputEmitter {
|
|
12
20
|
private emitter;
|
|
13
21
|
emit<T extends keyof Events>(eventName: T, payload: Events[T]): void;
|
|
@@ -15,6 +23,5 @@ export declare class OutputEmitter {
|
|
|
15
23
|
off<T extends keyof Events>(eventName: T, handler: (payload: Events[T]) => void): void;
|
|
16
24
|
}
|
|
17
25
|
export declare const emitter: OutputEmitter;
|
|
18
|
-
export declare const logRequest: (url: URL | string, state: Events["request"]["state"]) => void;
|
|
26
|
+
export declare const logRequest: (url: URL | string, state: Events["request"]["state"], details?: RequestDetails) => void;
|
|
19
27
|
export declare const graphStep: (step: Events["graphStep"]["step"]) => () => void;
|
|
20
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -14,11 +14,10 @@ export class OutputEmitter {
|
|
|
14
14
|
// Exported event emitter to coordinate events.
|
|
15
15
|
// There must be one version of output across the entire CLI.
|
|
16
16
|
export const emitter = new OutputEmitter();
|
|
17
|
-
export const logRequest = (url, state) => {
|
|
18
|
-
emitter.emit('request', { url, state });
|
|
17
|
+
export const logRequest = (url, state, details = {}) => {
|
|
18
|
+
emitter.emit('request', { url, state, ...details });
|
|
19
19
|
};
|
|
20
20
|
export const graphStep = (step) => {
|
|
21
21
|
emitter.emit('graphStep', { step, state: 'start' });
|
|
22
22
|
return () => emitter.emit('graphStep', { step, state: 'stop' });
|
|
23
23
|
};
|
|
24
|
-
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,76 +1,72 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/output",
|
|
3
3
|
"description": "Generate output from the vlt CLI",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
8
8
|
"directory": "src/output"
|
|
9
9
|
},
|
|
10
|
-
"author":
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"dialects": [
|
|
15
|
-
"esm"
|
|
16
|
-
],
|
|
17
|
-
"exports": {
|
|
18
|
-
"./package.json": "./package.json",
|
|
19
|
-
".": "./src/index.ts",
|
|
20
|
-
"./error": "./src/error.ts"
|
|
21
|
-
}
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "vlt technology inc.",
|
|
12
|
+
"email": "support@vlt.sh",
|
|
13
|
+
"url": "http://vlt.sh"
|
|
22
14
|
},
|
|
23
15
|
"dependencies": {
|
|
24
|
-
"@vltpkg/types": "1.0.
|
|
16
|
+
"@vltpkg/types": "1.0.2"
|
|
25
17
|
},
|
|
26
18
|
"devDependencies": {
|
|
27
|
-
"@eslint/js": "^9.
|
|
28
|
-
"@types/node": "^22.
|
|
29
|
-
"eslint": "^9.
|
|
30
|
-
"prettier": "^3.
|
|
31
|
-
"tap": "^21.
|
|
32
|
-
"tshy": "^3.0.2",
|
|
19
|
+
"@eslint/js": "^9.39.1",
|
|
20
|
+
"@types/node": "^22.19.2",
|
|
21
|
+
"eslint": "^9.39.1",
|
|
22
|
+
"prettier": "^3.7.4",
|
|
23
|
+
"tap": "^21.5.0",
|
|
33
24
|
"typedoc": "~0.27.9",
|
|
34
25
|
"typescript": "5.7.3",
|
|
35
|
-
"typescript-eslint": "^8.
|
|
26
|
+
"typescript-eslint": "^8.49.0"
|
|
36
27
|
},
|
|
37
28
|
"license": "BSD-2-Clause-Patent",
|
|
38
29
|
"engines": {
|
|
39
|
-
"node": ">=22"
|
|
30
|
+
"node": ">=22.22.0"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"format": "prettier --write . --log-level warn --ignore-path ../../.prettierignore --cache",
|
|
34
|
+
"format:check": "prettier --check . --ignore-path ../../.prettierignore --cache",
|
|
35
|
+
"lint": "eslint . --fix",
|
|
36
|
+
"lint:check": "eslint .",
|
|
37
|
+
"prepack": "tsc -p tsconfig.publish.json && ../../scripts/update-dist-exports.ts",
|
|
38
|
+
"snap": "tap",
|
|
39
|
+
"test": "tap",
|
|
40
|
+
"posttest": "tsc --noEmit",
|
|
41
|
+
"typecheck": "tsc --noEmit"
|
|
40
42
|
},
|
|
41
43
|
"tap": {
|
|
42
44
|
"extends": "../../tap-config.yaml"
|
|
43
45
|
},
|
|
44
46
|
"prettier": "../../.prettierrc.js",
|
|
45
|
-
"module": "./dist/
|
|
47
|
+
"module": "./dist/index.js",
|
|
46
48
|
"type": "module",
|
|
47
49
|
"exports": {
|
|
48
50
|
"./package.json": "./package.json",
|
|
49
51
|
".": {
|
|
50
52
|
"import": {
|
|
51
|
-
"
|
|
52
|
-
"default": "./dist/esm/index.js"
|
|
53
|
+
"default": "./dist/index.js"
|
|
53
54
|
}
|
|
54
55
|
},
|
|
55
56
|
"./error": {
|
|
56
57
|
"import": {
|
|
57
|
-
"
|
|
58
|
-
"default": "./dist/esm/error.js"
|
|
58
|
+
"default": "./dist/error.js"
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
"files": [
|
|
63
63
|
"dist"
|
|
64
64
|
],
|
|
65
|
-
"
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
"tshy": "tshy",
|
|
74
|
-
"typecheck": "tsc --noEmit"
|
|
75
|
-
}
|
|
76
|
-
}
|
|
65
|
+
"bugs": [
|
|
66
|
+
{
|
|
67
|
+
"type": "link",
|
|
68
|
+
"url": "https://github.com/vltpkg/vltpkg/issues"
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
"homepage": "https://github.com/vltpkg/vltpkg/tree/main/src/output#readme"
|
|
72
|
+
}
|
package/dist/esm/error.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/error.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACjD,KAAK,CAAC,EAAE,UAAU,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,UAAU,GAAG,WAAW,CAAA;IAChC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,QAAS,OAAO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;IACH,CAAC;SAAM,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9B,GAAG,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IACnC,CAAC;IAED,OAAO,GAAkB,CAAA;AAC3B,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,CAAU,EACV,KAAyB,EACL,EAAE;IACtB,MAAM,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,CAAA;IACzB,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,IAAI,IAAI,GAAG,CAAC,KAAK,EAAE,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5D,IAAI;QACN,CAAC,CAAC,GAAG,CAAA;AACT,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,CAAU,EACV,KAAyB,EAEY,EAAE;IACvC,MAAM,GAAG,GAAG,aAAa,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;IACnC,IAAI,CAAC,GAAG;QAAE,MAAM,CAAC,CAAA;IACjB,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,IAAI,EAAE,CAAA;IAC3B,OAAO,GAC+B,CAAA;AACxC,CAAC,CAAA","sourcesContent":["import { isError, isObject } from '@vltpkg/types'\n\nexport type ErrorCause = Record<string, unknown> & {\n cause?: ErrorCause\n}\n\nexport type ParsedError = {\n name: string\n message: string\n stack?: string\n cause?: ErrorCause | ParsedError\n [key: string]: unknown\n}\n\n/**\n * Parse an unknown value into an error. Will also take enumerable properties\n * from legacy style Node errors and treat them as the cause.\n */\nexport const parseError = (err: unknown): null | ParsedError => {\n if (!isError(err)) {\n return null\n }\n\n // Assume that if the error has enumerable properties, then\n // it is a legacy error and does not also have a cause.\n const enumerable = Object.fromEntries(Object.entries(err))\n if (Object.keys(enumerable).length) {\n err.cause = enumerable\n return err as ParsedError\n }\n\n if (isObject(err.cause)) {\n if (isError(err.cause.cause)) {\n err.cause.cause = parseError(err.cause.cause)\n }\n } else if (isError(err.cause)) {\n err.cause = parseError(err.cause)\n }\n\n return err as ParsedError\n}\n\n/**\n * Find the root error from an unknown value, optionally matching a code.\n */\nexport const findRootError = (\n v: unknown,\n match?: { code?: string },\n): ParsedError | null => {\n const err = parseError(v)\n return !err || (match?.code && err.cause?.code !== match.code) ?\n null\n : err\n}\n\n/**\n * Find the root error from an unknown value and throw if one is not found.\n */\nexport const asRootError = (\n v: unknown,\n match?: { code?: string },\n): Omit<ParsedError, 'cause'> &\n Required<Pick<ParsedError, 'cause'>> => {\n const err = findRootError(v, match)\n if (!err) throw v\n err.cause = err.cause ?? {}\n return err as Omit<ParsedError, 'cause'> &\n Required<Pick<ParsedError, 'cause'>>\n}\n"]}
|
package/dist/esm/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,MAAM,GAAG;IACnB,OAAO,EAAE;QACP,GAAG,EAAE,GAAG,GAAG,MAAM,CAAA;QACjB,KAAK,EAAE,OAAO,GAAG,UAAU,GAAG,KAAK,GAAG,OAAO,GAAG,OAAO,CAAA;KACxD,CAAA;IACD,SAAS,EAAE;QACT,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAA;QAClC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAA;KACxB,CAAA;CACF,CAAA;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAAqB;IAEpC,IAAI,CAAC,CAAC,SAAS,MAAM,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IAI7D,EAAE,CAAC,CAAC,SAAS,MAAM,MAAM,EACvB,SAAS,EAAE,CAAC,EACZ,OAAO,EAAE,CAAC,OAAO,EAAE,MA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AAE,CAAC,CAAA;AACzC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAiC,EAAE,EAAE;IAC7D,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAA;IACnD,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;AACjE,CAAC,CAAA","sourcesContent":["import EventEmitter from 'node:events'\n\nexport type Events = {\n request: {\n url: URL | string\n state: 'start' | 'complete' | '304' | 'cache' | 'stale'\n }\n graphStep: {\n step: 'build' | 'actual' | 'reify'\n state: 'start' | 'stop'\n }\n}\n\nexport class OutputEmitter {\n private emitter = new EventEmitter()\n\n emit<T extends keyof Events>(eventName: T, payload: Events[T]) {\n this.emitter.emit(eventName, payload)\n }\n\n on<T extends keyof Events>(\n eventName: T,\n handler: (payload: Events[T]) => void,\n ) {\n this.emitter.on(eventName, handler)\n }\n\n off<T extends keyof Events>(\n eventName: T,\n handler: (payload: Events[T]) => void,\n ) {\n this.emitter.off(eventName, handler)\n }\n}\n\n// Exported event emitter to coordinate events.\n// There must be one version of output across the entire CLI.\nexport const emitter = new OutputEmitter()\n\nexport const logRequest = (\n url: URL | string,\n state: Events['request']['state'],\n) => {\n emitter.emit('request', { url, state })\n}\n\nexport const graphStep = (step: Events['graphStep']['step']) => {\n emitter.emit('graphStep', { step, state: 'start' })\n return () => emitter.emit('graphStep', { step, state: 'stop' })\n}\n"]}
|
package/dist/esm/package.json
DELETED