depfresh 0.9.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.
@@ -0,0 +1,204 @@
1
+ type ProvenanceLevel = 'trusted' | 'attested' | 'none';
2
+ interface PackageData {
3
+ name: string;
4
+ versions: string[];
5
+ distTags: Record<string, string>;
6
+ time?: Record<string, string>;
7
+ deprecated?: Record<string, string>;
8
+ description?: string;
9
+ homepage?: string;
10
+ repository?: string;
11
+ provenance?: Record<string, ProvenanceLevel>;
12
+ engines?: Record<string, string>;
13
+ }
14
+ interface RegistryConfig {
15
+ url: string;
16
+ token?: string;
17
+ authType?: 'bearer' | 'basic';
18
+ scope?: string;
19
+ }
20
+ interface NpmrcConfig {
21
+ registries: Map<string, RegistryConfig>;
22
+ defaultRegistry: string;
23
+ proxy?: string;
24
+ httpsProxy?: string;
25
+ strictSsl: boolean;
26
+ cafile?: string;
27
+ }
28
+
29
+ type RangeMode = 'default' | 'major' | 'minor' | 'patch' | 'latest' | 'newest' | 'next' | 'ignore';
30
+ type DiffType = 'major' | 'minor' | 'patch' | 'none' | 'error';
31
+ type SortOption = 'diff-asc' | 'diff-desc' | 'time-asc' | 'time-desc' | 'name-asc' | 'name-desc';
32
+ type DepFieldType = 'dependencies' | 'devDependencies' | 'peerDependencies' | 'optionalDependencies' | 'overrides' | 'resolutions' | 'packageManager' | 'pnpm.overrides' | 'catalog';
33
+ interface RawDep {
34
+ name: string;
35
+ currentVersion: string;
36
+ source: DepFieldType;
37
+ update: boolean;
38
+ parents: string[];
39
+ aliasName?: string;
40
+ protocol?: string;
41
+ }
42
+ interface UpdateScore {
43
+ confidence: number;
44
+ maturity: number;
45
+ adoption: number;
46
+ breaking: boolean;
47
+ }
48
+ interface ResolvedDepChange extends RawDep {
49
+ targetVersion: string;
50
+ diff: DiffType;
51
+ pkgData: PackageData;
52
+ resolvedUrl?: string;
53
+ deprecated?: string | boolean;
54
+ latestVersion?: string;
55
+ publishedAt?: string;
56
+ currentVersionTime?: string;
57
+ score?: UpdateScore;
58
+ provenance?: ProvenanceLevel;
59
+ currentProvenance?: ProvenanceLevel;
60
+ nodeCompat?: string;
61
+ nodeCompatible?: boolean;
62
+ }
63
+
64
+ type PackageManagerName = 'npm' | 'pnpm' | 'yarn' | 'bun';
65
+ type OutputFormat = 'table' | 'json' | 'sarif';
66
+ interface PackageManagerField {
67
+ name: PackageManagerName;
68
+ version: string;
69
+ hash?: string;
70
+ raw: string;
71
+ }
72
+ interface CatalogSource {
73
+ type: 'pnpm' | 'bun' | 'yarn';
74
+ name: string;
75
+ filepath: string;
76
+ deps: RawDep[];
77
+ raw: unknown;
78
+ indent: string;
79
+ }
80
+ type PackageType = 'package.json' | 'package.yaml' | 'pnpm-workspace' | 'bun-workspace' | 'yarn-workspace' | 'global';
81
+ interface PackageMeta {
82
+ name: string;
83
+ type: PackageType;
84
+ filepath: string;
85
+ deps: RawDep[];
86
+ resolved: ResolvedDepChange[];
87
+ raw: unknown;
88
+ indent: string;
89
+ catalogs?: CatalogSource[];
90
+ packageManager?: PackageManagerField;
91
+ }
92
+
93
+ interface DepzyOptions {
94
+ cwd: string;
95
+ recursive: boolean;
96
+ mode: RangeMode;
97
+ write: boolean;
98
+ interactive: boolean;
99
+ force: boolean;
100
+ includeLocked: boolean;
101
+ includeWorkspace: boolean;
102
+ include?: string[];
103
+ exclude?: string[];
104
+ depFields?: Partial<Record<DepFieldType, boolean>>;
105
+ packageMode?: Record<string, RangeMode>;
106
+ concurrency: number;
107
+ timeout: number;
108
+ retries: number;
109
+ cacheTTL: number;
110
+ output: OutputFormat;
111
+ loglevel: 'silent' | 'info' | 'debug';
112
+ peer: boolean;
113
+ global: boolean;
114
+ ignorePaths: string[];
115
+ ignoreOtherWorkspaces: boolean;
116
+ all: boolean;
117
+ group: boolean;
118
+ sort: SortOption;
119
+ timediff: boolean;
120
+ cooldown: number;
121
+ nodecompat: boolean;
122
+ long: boolean;
123
+ explain: boolean;
124
+ failOnOutdated: boolean;
125
+ install: boolean;
126
+ update: boolean;
127
+ execute?: string;
128
+ verifyCommand?: string;
129
+ beforePackageStart?: (pkg: PackageMeta) => void | Promise<void>;
130
+ onDependencyResolved?: (pkg: PackageMeta, dep: ResolvedDepChange) => void | Promise<void>;
131
+ beforePackageWrite?: (pkg: PackageMeta) => boolean | Promise<boolean>;
132
+ afterPackageWrite?: (pkg: PackageMeta) => void | Promise<void>;
133
+ afterPackagesLoaded?: (pkgs: PackageMeta[]) => void | Promise<void>;
134
+ afterPackageEnd?: (pkg: PackageMeta) => void | Promise<void>;
135
+ afterPackagesEnd?: (pkgs: PackageMeta[]) => void | Promise<void>;
136
+ }
137
+ declare const DEFAULT_OPTIONS: Partial<DepzyOptions>;
138
+
139
+ declare function check(options: DepzyOptions): Promise<number>;
140
+
141
+ declare function resolveConfig(overrides?: Partial<DepzyOptions>): Promise<DepzyOptions>;
142
+
143
+ interface DepzyErrorOptions {
144
+ cause?: unknown;
145
+ }
146
+ /**
147
+ * Base error class for all depzy runtime errors.
148
+ * Allows API users to reliably branch on `instanceof DepzyError` and `code`.
149
+ */
150
+ declare class DepzyError extends Error {
151
+ readonly code: string;
152
+ readonly cause?: unknown;
153
+ constructor(message: string, code: string, options?: DepzyErrorOptions);
154
+ }
155
+ declare class RegistryError extends DepzyError {
156
+ readonly status: number;
157
+ readonly url: string;
158
+ constructor(message: string, status: number, url: string, options?: DepzyErrorOptions);
159
+ }
160
+ declare class CacheError extends DepzyError {
161
+ constructor(message: string, options?: DepzyErrorOptions);
162
+ }
163
+ declare class ConfigError extends DepzyError {
164
+ constructor(message: string, options?: DepzyErrorOptions);
165
+ }
166
+ declare class WriteError extends DepzyError {
167
+ constructor(message: string, options?: DepzyErrorOptions);
168
+ }
169
+ declare class ResolveError extends DepzyError {
170
+ constructor(message: string, options?: DepzyErrorOptions);
171
+ }
172
+
173
+ declare function parseDependencies(raw: Record<string, unknown>, options: DepzyOptions): RawDep[];
174
+
175
+ declare function loadGlobalPackages(pm?: string): PackageMeta[];
176
+ declare function writeGlobalPackage(pm: PackageManagerName, name: string, version: string): void;
177
+
178
+ declare function loadPackages(options: DepzyOptions): Promise<PackageMeta[]>;
179
+
180
+ interface Cache {
181
+ get(key: string): PackageData | undefined;
182
+ set(key: string, data: PackageData, ttl: number): void;
183
+ has(key: string): boolean;
184
+ clear(): void;
185
+ close(): void;
186
+ stats(): {
187
+ hits: number;
188
+ misses: number;
189
+ size: number;
190
+ };
191
+ }
192
+
193
+ declare function resolvePackage(pkg: PackageMeta, options: DepzyOptions, externalCache?: Cache, externalNpmrc?: NpmrcConfig, privatePackages?: Set<string>, onDependencyProcessed?: (pkg: PackageMeta, dep: RawDep) => void | Promise<void>): Promise<ResolvedDepChange[]>;
194
+
195
+ /**
196
+ * Single-writer architecture: reads once, applies all mutations, writes once.
197
+ * Never allow independent writers to clobber each other.
198
+ */
199
+ declare function writePackage(pkg: PackageMeta, changes: ResolvedDepChange[], loglevel?: 'silent' | 'info' | 'debug'): void;
200
+
201
+ declare function defineConfig(options: Partial<DepzyOptions>): Partial<DepzyOptions>;
202
+
203
+ export { CacheError, ConfigError, DEFAULT_OPTIONS, DepzyError, RegistryError, ResolveError, WriteError, check, defineConfig, loadGlobalPackages, loadPackages, parseDependencies, resolveConfig, resolvePackage, writeGlobalPackage, writePackage };
204
+ export type { CatalogSource, DepFieldType, DepzyOptions, DiffType, NpmrcConfig, OutputFormat, PackageData, PackageManagerField, PackageManagerName, PackageMeta, PackageType, ProvenanceLevel, RangeMode, RawDep, RegistryConfig, ResolvedDepChange, SortOption, UpdateScore };
package/dist/index.mjs ADDED
@@ -0,0 +1,21 @@
1
+ export { D as DEFAULT_OPTIONS, r as resolveConfig } from './chunks/config.mjs';
2
+ export { C as CacheError, a as ConfigError, D as DepzyError, R as RegistryError, b as ResolveError, W as WriteError } from './shared/depfresh.B1o7OHO_.mjs';
3
+ export { d as defineConfig, l as loadGlobalPackages, w as writeGlobalPackage } from './chunks/index3.mjs';
4
+ export { c as check, l as loadPackages, p as parseDependencies, r as resolvePackage, w as writePackage } from './shared/depfresh.ClIHCCxD.mjs';
5
+ import 'node:fs/promises';
6
+ import 'node:url';
7
+ import 'defu';
8
+ import 'pathe';
9
+ import 'ansis';
10
+ import 'node:child_process';
11
+ import 'node:fs';
12
+ import 'node:os';
13
+ import 'find-up-simple';
14
+ import 'ini';
15
+ import 'detect-indent';
16
+ import 'semver';
17
+ import 'pnpm-workspace-yaml';
18
+ import 'yaml';
19
+ import 'p-limit';
20
+ import 'better-sqlite3';
21
+ import 'tinyglobby';
@@ -0,0 +1,63 @@
1
+ import c from 'ansis';
2
+
3
+ class DepzyError extends Error {
4
+ code;
5
+ cause;
6
+ constructor(message, code, options = {}) {
7
+ super(message);
8
+ this.name = new.target.name;
9
+ this.code = code;
10
+ this.cause = options.cause;
11
+ }
12
+ }
13
+ class RegistryError extends DepzyError {
14
+ status;
15
+ url;
16
+ constructor(message, status, url, options = {}) {
17
+ super(message, "ERR_REGISTRY", options);
18
+ this.status = status;
19
+ this.url = url;
20
+ }
21
+ }
22
+ class CacheError extends DepzyError {
23
+ constructor(message, options = {}) {
24
+ super(message, "ERR_CACHE", options);
25
+ }
26
+ }
27
+ class ConfigError extends DepzyError {
28
+ constructor(message, options = {}) {
29
+ super(message, "ERR_CONFIG", options);
30
+ }
31
+ }
32
+ class WriteError extends DepzyError {
33
+ constructor(message, options = {}) {
34
+ super(message, "ERR_WRITE", options);
35
+ }
36
+ }
37
+ class ResolveError extends DepzyError {
38
+ constructor(message, options = {}) {
39
+ super(message, "ERR_RESOLVE", options);
40
+ }
41
+ }
42
+
43
+ function createLogger(level = "info") {
44
+ const noop = () => {
45
+ };
46
+ if (level === "silent") {
47
+ return { info: noop, warn: noop, error: noop, debug: noop, success: noop };
48
+ }
49
+ return {
50
+ // biome-ignore lint/suspicious/noConsole: logger is the intentional console wrapper
51
+ info: (...args) => console.log(c.blue("i"), ...args),
52
+ // biome-ignore lint/suspicious/noConsole: logger is the intentional console wrapper
53
+ warn: (...args) => console.warn(c.yellow("!"), ...args),
54
+ // biome-ignore lint/suspicious/noConsole: logger is the intentional console wrapper
55
+ error: (...args) => console.error(c.red("x"), ...args),
56
+ // biome-ignore lint/suspicious/noConsole: logger is the intentional console wrapper
57
+ debug: level === "debug" ? (...args) => console.log(c.gray("~"), ...args) : noop,
58
+ // biome-ignore lint/suspicious/noConsole: logger is the intentional console wrapper
59
+ success: (...args) => console.log(c.green("*"), ...args)
60
+ };
61
+ }
62
+
63
+ export { CacheError as C, DepzyError as D, RegistryError as R, WriteError as W, ConfigError as a, ResolveError as b, createLogger as c };