package-management 0.0.16 → 0.1.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/LICENSE +21 -0
- package/dist/index.cjs +382 -357
- package/dist/index.d.cts +148 -74
- package/dist/index.d.mts +148 -74
- package/dist/index.d.ts +148 -74
- package/dist/index.mjs +378 -357
- package/package.json +10 -13
package/dist/index.d.cts
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
|
-
import { Split } from 'string-ts';
|
|
2
1
|
import * as async_cache_fn from 'async-cache-fn';
|
|
3
2
|
import { AsyncCacheFn as AsyncCacheFn$1 } from 'async-cache-fn';
|
|
3
|
+
import { WriteFileOptions } from 'node:fs';
|
|
4
4
|
import { Options } from 'execa';
|
|
5
|
-
import { InstallPackageOptions as InstallPackageOptions$1 } from '@antfu/install-pkg';
|
|
6
5
|
import { ResolveOptions } from 'mlly';
|
|
7
6
|
import * as parse_gitignore from 'parse-gitignore';
|
|
8
|
-
import * as WST from 'workspace-tools';
|
|
9
7
|
import { ModificationOptions } from 'jsonc-parser';
|
|
10
8
|
import { StorageValue, TransactionOptions, Snapshot, Storage } from 'unstorage';
|
|
11
9
|
import { FSStorageOptions } from 'unstorage/drivers/fs-lite';
|
|
12
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Returns true if string input type is a literal
|
|
13
|
+
*/
|
|
14
|
+
type IsStringLiteral<T extends string> = [T] extends [string] ? [string] extends [T] ? false : Uppercase<T> extends Uppercase<Lowercase<T>> ? Lowercase<T> extends Lowercase<Uppercase<T>> ? true : false : false : false;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Splits a string into an array of substrings.
|
|
18
|
+
* T: The string to split.
|
|
19
|
+
* delimiter: The delimiter.
|
|
20
|
+
*/
|
|
21
|
+
type Split<T extends string, delimiter extends string = ''> = IsStringLiteral<T | delimiter> extends true ? T extends `${infer first}${delimiter}${infer rest}` ? [first, ...Split<rest, delimiter>] : T extends '' ? [] : [T] : string[];
|
|
22
|
+
|
|
13
23
|
type Equals<A1 extends any, A2 extends any> = (<A>() => A extends A2 ? 1 : 0) extends <A>() => A extends A1 ? 1 : 0 ? 1 : 0;
|
|
14
24
|
type Cast<A1 extends any, A2 extends any> = A1 extends A2 ? A1 : A2;
|
|
15
25
|
type __<T> = {
|
|
@@ -21,6 +31,7 @@ type Prettify<T> = {
|
|
|
21
31
|
type ValueOf<T> = T[keyof T];
|
|
22
32
|
type EnumToLiteral<T extends string | number> = T extends string ? `${T}` : `${T}` extends `${infer N extends number}` ? N : never;
|
|
23
33
|
type IsUnknown<t> = unknown extends t ? [t] extends [{}] ? false : true : false;
|
|
34
|
+
type IsNever<T> = [T] extends [never] ? true : false;
|
|
24
35
|
type AnyFunction = (...args: any[]) => any;
|
|
25
36
|
type StringLiteral<T extends string> = T | (string & {});
|
|
26
37
|
type Awaitable<T> = T | Promise<T>;
|
|
@@ -74,11 +85,43 @@ interface PathOptions {
|
|
|
74
85
|
type AsyncCacheFn<TReturn = unknown, TOption extends object | undefined = undefined, C extends "required" | "optional" = "optional"> = AsyncCacheFn$1<TReturn, C extends "optional" ? [TOption | undefined] | [] : [TOption]>;
|
|
75
86
|
type CheckResult<$data, $error = Error, $data_key extends string = "data", $error_key extends string = "error"> = Prettify<RequireExactlyOne<SingleProp<$data_key, $data> & SingleProp<$error_key, $error>>>;
|
|
76
87
|
|
|
77
|
-
interface
|
|
78
|
-
|
|
88
|
+
interface CallerLocationOptions {
|
|
89
|
+
/**
|
|
90
|
+
* The calling module's own URL — pass `import.meta.url`.
|
|
91
|
+
*
|
|
92
|
+
* This is the reliable answer and skips stack inspection entirely. A module
|
|
93
|
+
* can always name itself; nothing can ask the runtime who called it, which is
|
|
94
|
+
* why the fallback below has to exist at all.
|
|
95
|
+
*/
|
|
96
|
+
from?: string | URL;
|
|
97
|
+
/**
|
|
98
|
+
* Name of the public entry point whose caller is wanted, used only when
|
|
99
|
+
* `from` is absent.
|
|
100
|
+
*/
|
|
101
|
+
boundaryFunctionName?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Module URLs to treat as this library's own when walking the stack.
|
|
104
|
+
*
|
|
105
|
+
* In a published bundle every internal frame shares one script, so this is
|
|
106
|
+
* redundant there; unbundled, each internal module is its own script and has
|
|
107
|
+
* to say so.
|
|
108
|
+
*/
|
|
109
|
+
internalScripts?: string[];
|
|
79
110
|
}
|
|
80
|
-
|
|
81
|
-
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The calling file's absolute path.
|
|
114
|
+
*
|
|
115
|
+
* Pass `from: import.meta.url` wherever the caller can — that is exact in every
|
|
116
|
+
* runtime, while the stack fallback is Node-only.
|
|
117
|
+
*/
|
|
118
|
+
declare const _filename: (options?: CallerLocationOptions) => string | undefined;
|
|
119
|
+
/** The directory of the calling file. */
|
|
120
|
+
declare const _dirname: (options?: CallerLocationOptions) => string | undefined;
|
|
121
|
+
|
|
122
|
+
declare function createFile(filePath: string, data: string, options?: WriteFileOptions): void;
|
|
123
|
+
|
|
124
|
+
declare function isWritable(filename: string): boolean;
|
|
82
125
|
|
|
83
126
|
interface PackageManagerConfig<ID extends string = string> {
|
|
84
127
|
id: ID;
|
|
@@ -86,6 +129,14 @@ interface PackageManagerConfig<ID extends string = string> {
|
|
|
86
129
|
name: string;
|
|
87
130
|
meta: {
|
|
88
131
|
lockfile: string | string[];
|
|
132
|
+
/**
|
|
133
|
+
* Distinguishes package managers that share both a command and a lockfile
|
|
134
|
+
* name, where the lockfile alone cannot identify which one a project uses —
|
|
135
|
+
* Yarn Classic and Yarn Berry being the case this exists for.
|
|
136
|
+
*
|
|
137
|
+
* Omit when the lockfile is already unambiguous.
|
|
138
|
+
*/
|
|
139
|
+
matchesVersion?: (version: string) => boolean;
|
|
89
140
|
};
|
|
90
141
|
runner: string;
|
|
91
142
|
args: {
|
|
@@ -138,9 +189,12 @@ interface ImportPackageData<T = any> extends ImportModuleData<T> {
|
|
|
138
189
|
*/
|
|
139
190
|
dev?: boolean;
|
|
140
191
|
/**
|
|
141
|
-
*
|
|
192
|
+
* When enabled, a package already declared as a dependency is not installed
|
|
193
|
+
* again, so a satisfied import map costs no package manager invocations.
|
|
194
|
+
*
|
|
195
|
+
* @default true
|
|
142
196
|
*/
|
|
143
|
-
|
|
197
|
+
checkExists?: boolean;
|
|
144
198
|
}
|
|
145
199
|
type ImportOption<T = any> = Module | ImportCallback<T> | ImportModuleData<T> | ImportPackageData<T>;
|
|
146
200
|
type Module<T = any> = Promise<T>;
|
|
@@ -259,6 +313,11 @@ interface PackageManager<ID extends string = PackageManagerId> {
|
|
|
259
313
|
cwd?: string;
|
|
260
314
|
}>;
|
|
261
315
|
globalVersion: AsyncCacheFn<string | undefined, PackageManagerScriptOptions>;
|
|
316
|
+
/**
|
|
317
|
+
* Whether the installed version is the one this config describes. Always
|
|
318
|
+
* true for managers whose lockfile already identifies them unambiguously.
|
|
319
|
+
*/
|
|
320
|
+
matchesVersion: AsyncCacheFn<boolean, PackageManagerScriptOptions>;
|
|
262
321
|
definePackage: DefinePackageFn;
|
|
263
322
|
defineImportMap: <T extends ImportMap>(importMap: T, options?: {
|
|
264
323
|
/**
|
|
@@ -270,6 +329,9 @@ interface PackageManager<ID extends string = PackageManagerId> {
|
|
|
270
329
|
uninstallPackage: (packageNames: string | string[], options?: UninstallPackageOptions) => Promise<void>;
|
|
271
330
|
installPackage: (packageNames: string | string[], options?: PackageManagerScriptOptions<"install">) => Promise<void>;
|
|
272
331
|
}
|
|
332
|
+
declare function definePackageManager<ID extends string>(config: PackageManagerConfig<ID>, options?: {
|
|
333
|
+
cwd?: string;
|
|
334
|
+
}): PackageManager<ID>;
|
|
273
335
|
|
|
274
336
|
interface DetectPackageManagerOptions<$id extends string = PackageManagerId> {
|
|
275
337
|
/**
|
|
@@ -312,20 +374,24 @@ declare function mapPackageManagers<$result, $id extends string = PackageManager
|
|
|
312
374
|
declare function filterPackageManagers<$id extends string = PackageManagerId>(packageManagers: PackageManagers<$id>, filterFn: (packageManager: PackageManager<$id>) => Awaitable<boolean>, options?: DetectPackageManagerOptions<$id>): Promise<PackageManager<$id>[]>;
|
|
313
375
|
|
|
314
376
|
type PackageManagerId = (typeof packageManagerConfigs)[number]["id"];
|
|
315
|
-
declare const packageManagerConfigs: (PackageManagerConfig<"pnpm"> | PackageManagerConfig<"yarn"> | PackageManagerConfig<"bun"> | PackageManagerConfig<"npm">)[];
|
|
377
|
+
declare const packageManagerConfigs: (PackageManagerConfig<"pnpm"> | PackageManagerConfig<"yarn"> | PackageManagerConfig<"yarn-berry"> | PackageManagerConfig<"bun"> | PackageManagerConfig<"npm">)[];
|
|
316
378
|
declare function definePackageManagerClient(options: DetectPackageManagerOptions): {
|
|
317
|
-
configs: PackageManager<"pnpm" | "yarn" | "bun" | "npm">[];
|
|
318
|
-
findPackageManager: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">, [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "bun" | "npm"> | undefined]>;
|
|
319
|
-
findPackageManagerSafely: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm"> | undefined, [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "bun" | "npm"> | undefined]>;
|
|
320
|
-
detectPackageManagers: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "bun" | "npm"> | undefined]>;
|
|
321
|
-
detectLockfilePackageManagers: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "bun" | "npm"> | undefined]>;
|
|
322
|
-
detectGlobalPackageManagers: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "bun" | "npm"> | undefined]>;
|
|
323
|
-
globalVersions: async_cache_fn.AsyncCacheFn<Record<"pnpm" | "yarn" | "bun" | "npm", string | undefined>, [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "bun" | "npm"> | undefined]>;
|
|
324
|
-
filterPackageManagers: (filterFn: (packageManager: PackageManager) => Awaitable<boolean>, options?: DetectPackageManagerOptions) => Promise<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[]>;
|
|
379
|
+
configs: PackageManager<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm">[];
|
|
380
|
+
findPackageManager: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm">, [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm"> | undefined]>;
|
|
381
|
+
findPackageManagerSafely: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm"> | undefined, [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm"> | undefined]>;
|
|
382
|
+
detectPackageManagers: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm">[], [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm"> | undefined]>;
|
|
383
|
+
detectLockfilePackageManagers: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm">[], [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm"> | undefined]>;
|
|
384
|
+
detectGlobalPackageManagers: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm">[], [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm"> | undefined]>;
|
|
385
|
+
globalVersions: async_cache_fn.AsyncCacheFn<Record<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm", string | undefined>, [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm"> | undefined]>;
|
|
386
|
+
filterPackageManagers: (filterFn: (packageManager: PackageManager) => Awaitable<boolean>, options?: DetectPackageManagerOptions) => Promise<PackageManager<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm">[]>;
|
|
325
387
|
mapPackageManagers: <$result>(mapFn: (packageManager: PackageManager) => Awaitable<$result>, options?: DetectPackageManagerOptions) => Promise<Awaited<$result>[]>;
|
|
326
388
|
};
|
|
327
389
|
|
|
328
|
-
|
|
390
|
+
/**
|
|
391
|
+
* Whether every named package is declared in the nearest package.json,
|
|
392
|
+
* searching up from `cwd`.
|
|
393
|
+
*/
|
|
394
|
+
declare function isPackageDependency(packageName: string | string[], options?: PathOptions): boolean;
|
|
329
395
|
|
|
330
396
|
interface AliasDefinition {
|
|
331
397
|
resolve: ResolvePathAliasFn;
|
|
@@ -341,9 +407,20 @@ type AliasMap<TAliases extends AliasDefinitionMap = AliasDefinitionMap> = {
|
|
|
341
407
|
} & {
|
|
342
408
|
[K in keyof TAliases as `${Extract<K, string>}/${NonNullable<TAliases[K]["subpaths"]>[number]["to"]}`]: TAliases[K]["resolve"];
|
|
343
409
|
};
|
|
344
|
-
|
|
410
|
+
interface PathAliasResolveOptions {
|
|
345
411
|
cwd?: string;
|
|
346
|
-
|
|
412
|
+
/**
|
|
413
|
+
* The calling module's own URL — `import.meta.url`. Only the caller-relative
|
|
414
|
+
* aliases read it, and only they need it.
|
|
415
|
+
*/
|
|
416
|
+
from?: string | URL;
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* `undefined` is a real answer: an alias can name a location that does not
|
|
420
|
+
* exist in this context, and callers assert on it rather than receiving a
|
|
421
|
+
* path assembled from nothing.
|
|
422
|
+
*/
|
|
423
|
+
type ResolvePathAliasFn = (opts?: PathAliasResolveOptions) => string | undefined;
|
|
347
424
|
type StringKeyOf<T> = Extract<keyof T, string>;
|
|
348
425
|
declare function definePathAliases<const T extends AliasDefinitionMap>(aliasDefinitions: T): {
|
|
349
426
|
aliasDefinitions: T;
|
|
@@ -355,6 +432,14 @@ interface GetPathOptions<TAlias extends string, TValidate extends boolean = fals
|
|
|
355
432
|
to: PathTo<TAlias>;
|
|
356
433
|
startingFrom?: PathTo<TAlias>;
|
|
357
434
|
cwd?: string;
|
|
435
|
+
/**
|
|
436
|
+
* The calling module's own URL — `import.meta.url`.
|
|
437
|
+
*
|
|
438
|
+
* Required in any runtime without `node:util`'s call sites, and worth
|
|
439
|
+
* passing regardless: a module naming itself is exact, whereas inferring the
|
|
440
|
+
* caller from the stack is a best effort.
|
|
441
|
+
*/
|
|
442
|
+
from?: string | URL;
|
|
358
443
|
checkExistence?: TValidate;
|
|
359
444
|
glob?: TGlob;
|
|
360
445
|
}
|
|
@@ -415,9 +500,7 @@ type PickPathAlias<K extends PathAlias> = K;
|
|
|
415
500
|
type PredefinedPathAliases = typeof predefinedPathAliases;
|
|
416
501
|
declare const predefinedPathAliases: {
|
|
417
502
|
readonly "<workspace_folder>": {
|
|
418
|
-
readonly resolve: (opts:
|
|
419
|
-
cwd?: string;
|
|
420
|
-
} | undefined) => string;
|
|
503
|
+
readonly resolve: (opts: PathAliasResolveOptions | undefined) => string;
|
|
421
504
|
readonly subpaths: [{
|
|
422
505
|
readonly to: "node_modules";
|
|
423
506
|
}, {
|
|
@@ -425,9 +508,7 @@ declare const predefinedPathAliases: {
|
|
|
425
508
|
}];
|
|
426
509
|
};
|
|
427
510
|
readonly "<workspace_folder?>": {
|
|
428
|
-
readonly resolve: (opts:
|
|
429
|
-
cwd?: string;
|
|
430
|
-
} | undefined) => string;
|
|
511
|
+
readonly resolve: (opts: PathAliasResolveOptions | undefined) => string;
|
|
431
512
|
readonly subpaths: [{
|
|
432
513
|
readonly to: "node_modules";
|
|
433
514
|
}, {
|
|
@@ -435,9 +516,7 @@ declare const predefinedPathAliases: {
|
|
|
435
516
|
}];
|
|
436
517
|
};
|
|
437
518
|
readonly "<package_folder>": {
|
|
438
|
-
readonly resolve: (opts:
|
|
439
|
-
cwd?: string;
|
|
440
|
-
} | undefined) => string;
|
|
519
|
+
readonly resolve: (opts: PathAliasResolveOptions | undefined) => string | undefined;
|
|
441
520
|
readonly subpaths: [{
|
|
442
521
|
readonly to: "node_modules";
|
|
443
522
|
}, {
|
|
@@ -447,9 +526,7 @@ declare const predefinedPathAliases: {
|
|
|
447
526
|
}];
|
|
448
527
|
};
|
|
449
528
|
readonly "<gitroot_folder>": {
|
|
450
|
-
readonly resolve: (opts:
|
|
451
|
-
cwd?: string;
|
|
452
|
-
} | undefined) => string;
|
|
529
|
+
readonly resolve: (opts: PathAliasResolveOptions | undefined) => string;
|
|
453
530
|
readonly subpaths: [{
|
|
454
531
|
readonly to: "node_modules";
|
|
455
532
|
}, {
|
|
@@ -471,11 +548,11 @@ declare const predefinedPathAliases: {
|
|
|
471
548
|
readonly subpaths: any[];
|
|
472
549
|
};
|
|
473
550
|
readonly "<current_file>": {
|
|
474
|
-
readonly resolve: () => string;
|
|
551
|
+
readonly resolve: (opts: PathAliasResolveOptions | undefined) => string | undefined;
|
|
475
552
|
readonly subpaths: any[];
|
|
476
553
|
};
|
|
477
554
|
readonly "<current_folder>": {
|
|
478
|
-
readonly resolve: () => string;
|
|
555
|
+
readonly resolve: (opts: PathAliasResolveOptions | undefined) => string | undefined;
|
|
479
556
|
readonly subpaths: any[];
|
|
480
557
|
};
|
|
481
558
|
};
|
|
@@ -679,11 +756,11 @@ declare const project: (...args: ProjectParams) => {
|
|
|
679
756
|
packageJsonPath: string | undefined;
|
|
680
757
|
packageName: string | undefined;
|
|
681
758
|
projectDir: string | undefined;
|
|
682
|
-
findPackageManager: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">, [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "bun" | "npm"> | undefined]>;
|
|
683
|
-
detectPackageManagers: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "bun" | "npm"> | undefined]>;
|
|
684
|
-
detectGlobalPackageManagers: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "bun" | "npm"> | undefined]>;
|
|
685
|
-
detectLockfilePackageManagers: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "bun" | "npm"> | undefined]>;
|
|
686
|
-
globalVersions: async_cache_fn.AsyncCacheFn<Record<"pnpm" | "yarn" | "bun" | "npm", string | undefined>, [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "bun" | "npm"> | undefined]>;
|
|
759
|
+
findPackageManager: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm">, [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm"> | undefined]>;
|
|
760
|
+
detectPackageManagers: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm">[], [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm"> | undefined]>;
|
|
761
|
+
detectGlobalPackageManagers: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm">[], [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm"> | undefined]>;
|
|
762
|
+
detectLockfilePackageManagers: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm">[], [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm"> | undefined]>;
|
|
763
|
+
globalVersions: async_cache_fn.AsyncCacheFn<Record<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm", string | undefined>, [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm"> | undefined]>;
|
|
687
764
|
mapPackageManagers: <$result>(mapFn: (packageManager: PackageManager) => Awaitable<$result>, options?: DetectPackageManagerOptions) => Promise<Awaited<$result>[]>;
|
|
688
765
|
tsconfig: {
|
|
689
766
|
readonly paths: string[];
|
|
@@ -692,8 +769,8 @@ declare const project: (...args: ProjectParams) => {
|
|
|
692
769
|
readonly data: parse_gitignore.ParsedGitignoreObject;
|
|
693
770
|
readonly patterns: string[];
|
|
694
771
|
};
|
|
695
|
-
filterPackageManagers: (filterFn: (packageManager: PackageManager) => Awaitable<boolean>, options?: DetectPackageManagerOptions) => Promise<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[]>;
|
|
696
|
-
getPackageJson: () => PackageJson;
|
|
772
|
+
filterPackageManagers: (filterFn: (packageManager: PackageManager) => Awaitable<boolean>, options?: DetectPackageManagerOptions) => Promise<PackageManager<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm">[]>;
|
|
773
|
+
getPackageJson: () => PackageJson | undefined;
|
|
697
774
|
findDependencyInPackageJson: (options: string | FindDependencyInPackageJsonOptions) => {
|
|
698
775
|
firstMatch: PackageDependencyItem | undefined;
|
|
699
776
|
matches: PackageDependencyItem[];
|
|
@@ -719,7 +796,7 @@ declare function getGitRootFolder<$ThrowIfNotFound extends boolean = true>(optio
|
|
|
719
796
|
*/
|
|
720
797
|
declare function getPackageFolder(options?: {
|
|
721
798
|
cwd?: string;
|
|
722
|
-
}): string;
|
|
799
|
+
}): string | undefined;
|
|
723
800
|
|
|
724
801
|
interface GetWorkspaceFolderOptions<$Validate extends boolean = true> extends PathOptions {
|
|
725
802
|
/** @default true */
|
|
@@ -741,7 +818,7 @@ interface GetPackageInfoListOptions {
|
|
|
741
818
|
cwd?: string;
|
|
742
819
|
includeRoot?: boolean;
|
|
743
820
|
}
|
|
744
|
-
declare function getWorkspacePackageInfoList(options?: GetPackageInfoListOptions):
|
|
821
|
+
declare function getWorkspacePackageInfoList(options?: GetPackageInfoListOptions): PackageInfo[];
|
|
745
822
|
|
|
746
823
|
declare function getWorkspacePackageNames(options?: GetPackageInfoListOptions): string[];
|
|
747
824
|
|
|
@@ -755,11 +832,11 @@ declare const workspace: {
|
|
|
755
832
|
packageJsonPath: string | undefined;
|
|
756
833
|
packageName: string | undefined;
|
|
757
834
|
projectDir: string | undefined;
|
|
758
|
-
findPackageManager: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">, [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "bun" | "npm"> | undefined]>;
|
|
759
|
-
detectPackageManagers: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "bun" | "npm"> | undefined]>;
|
|
760
|
-
detectGlobalPackageManagers: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "bun" | "npm"> | undefined]>;
|
|
761
|
-
detectLockfilePackageManagers: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "bun" | "npm"> | undefined]>;
|
|
762
|
-
globalVersions: async_cache_fn.AsyncCacheFn<Record<"pnpm" | "yarn" | "bun" | "npm", string | undefined>, [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "bun" | "npm"> | undefined]>;
|
|
835
|
+
findPackageManager: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm">, [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm"> | undefined]>;
|
|
836
|
+
detectPackageManagers: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm">[], [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm"> | undefined]>;
|
|
837
|
+
detectGlobalPackageManagers: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm">[], [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm"> | undefined]>;
|
|
838
|
+
detectLockfilePackageManagers: async_cache_fn.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm">[], [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm"> | undefined]>;
|
|
839
|
+
globalVersions: async_cache_fn.AsyncCacheFn<Record<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm", string | undefined>, [options?: DetectPackageManagerOptions<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm"> | undefined]>;
|
|
763
840
|
mapPackageManagers: <$result>(mapFn: (packageManager: PackageManager) => Awaitable<$result>, options?: DetectPackageManagerOptions) => Promise<Awaited<$result>[]>;
|
|
764
841
|
tsconfig: {
|
|
765
842
|
readonly paths: string[];
|
|
@@ -768,8 +845,8 @@ declare const workspace: {
|
|
|
768
845
|
readonly data: parse_gitignore.ParsedGitignoreObject;
|
|
769
846
|
readonly patterns: string[];
|
|
770
847
|
};
|
|
771
|
-
filterPackageManagers: (filterFn: (packageManager: PackageManager) => Awaitable<boolean>, options?: DetectPackageManagerOptions) => Promise<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[]>;
|
|
772
|
-
getPackageJson: () => PackageJson;
|
|
848
|
+
filterPackageManagers: (filterFn: (packageManager: PackageManager) => Awaitable<boolean>, options?: DetectPackageManagerOptions) => Promise<PackageManager<"pnpm" | "yarn" | "yarn-berry" | "bun" | "npm">[]>;
|
|
849
|
+
getPackageJson: () => PackageJson | undefined;
|
|
773
850
|
findDependencyInPackageJson: (options: string | FindDependencyInPackageJsonOptions) => {
|
|
774
851
|
firstMatch: PackageDependencyItem | undefined;
|
|
775
852
|
matches: PackageDependencyItem[];
|
|
@@ -819,20 +896,14 @@ type ModifyJSONFileResult<$auto_commit extends boolean = true> = $auto_commit ex
|
|
|
819
896
|
declare function modifyJSONFile<$auto_commit extends boolean = true>(filepath: string, edits: JSONEdits, options?: MoodifyJSONFileOptions<$auto_commit>): ModifyJSONFileResult<$auto_commit>;
|
|
820
897
|
|
|
821
898
|
declare const storage: Storage<StorageValue>;
|
|
822
|
-
declare const tempFileSystem:
|
|
823
|
-
definition: {
|
|
824
|
-
readonly base: string;
|
|
825
|
-
};
|
|
826
|
-
initialize: () => Promise<FileSystemStorage<unknown, string & {}>>;
|
|
827
|
-
};
|
|
899
|
+
declare const tempFileSystem: FileSystemStorage<FileSystemEntriesDefinition<string>, FileSystemPathCompletion<FileSystemEntriesDefinition<string>>>;
|
|
828
900
|
type FileSystemEntriesDefinition<$filepath extends string = string> = {
|
|
829
|
-
[K in $filepath]: StorageValue | (
|
|
830
|
-
file: $file_data;
|
|
831
|
-
options?: TransactionOptions;
|
|
832
|
-
serialize?: (file_data: $file_data) => string;
|
|
833
|
-
deserialize?: (file_content: string) => $file_data;
|
|
834
|
-
});
|
|
901
|
+
[K in $filepath]: StorageValue | (() => FileSystemEntryDefinition);
|
|
835
902
|
};
|
|
903
|
+
interface FileSystemEntryDefinition<$file_data extends StorageValue = StorageValue> {
|
|
904
|
+
file: $file_data;
|
|
905
|
+
options?: TransactionOptions;
|
|
906
|
+
}
|
|
836
907
|
interface FileSystemEntry<$key extends string = string> {
|
|
837
908
|
key: $key;
|
|
838
909
|
value: string;
|
|
@@ -858,15 +929,21 @@ $path_completion extends FileSystemPathCompletion<$fs_def> = FileSystemPathCompl
|
|
|
858
929
|
getFile: (filepath: $path_completion) => Promise<{
|
|
859
930
|
key: string;
|
|
860
931
|
filepath: string;
|
|
861
|
-
data:
|
|
862
|
-
read: () => Promise<
|
|
932
|
+
data: StorageValue;
|
|
933
|
+
read: () => Promise<string | undefined>;
|
|
863
934
|
}>;
|
|
864
|
-
|
|
865
|
-
|
|
935
|
+
/** Resolves to `undefined` when the file does not exist. */
|
|
936
|
+
readFile: (filepath: $path_completion) => Promise<string | undefined>;
|
|
937
|
+
/** The location a key maps to on disk, whether or not anything is there. */
|
|
938
|
+
getFilePath: (key: $path_completion) => string;
|
|
939
|
+
/** `base` is a storage key prefix, not a filesystem path. */
|
|
866
940
|
restoreFs(snapshot: Snapshot, base?: string): Promise<void>;
|
|
941
|
+
/** `base` is a storage key prefix, not a filesystem path. */
|
|
867
942
|
snapshotFs: (base?: string) => Promise<Snapshot<string>>;
|
|
943
|
+
/** Replaces the entries this storage owns, leaving other files in place. */
|
|
868
944
|
initializeFs: (newInitial?: FileSystemEntriesDefinition) => Promise<void>;
|
|
869
|
-
removeAllFiles(
|
|
945
|
+
removeAllFiles(): Promise<void>;
|
|
946
|
+
/** Removes the base directory and everything under it. */
|
|
870
947
|
deleteFileSystem(): Promise<void>;
|
|
871
948
|
defineFileSystemEntries: typeof defineFileSystemEntries;
|
|
872
949
|
storage: Storage;
|
|
@@ -878,10 +955,7 @@ interface FileSystemEntriesData<T extends FileSystemEntriesDefinition | undefine
|
|
|
878
955
|
declare function defineFileSystemEntries<const $fs_def extends FileSystemEntriesDefinition>(definition: $fs_def): FileSystemEntriesData<$fs_def>;
|
|
879
956
|
type ExtractFsEntriesDef<$fs_def> = Cast<$fs_def, FileSystemEntriesDefinition>;
|
|
880
957
|
declare function defineFileSystemStorage<const $fs_storage_def extends DefineFileSystemOptions = DefineFileSystemOptions, // prettier-ignore
|
|
881
|
-
$fs_def extends $fs_storage_def['initial'] = $fs_storage_def['initial']>(options: $fs_storage_def):
|
|
882
|
-
definition: $fs_storage_def;
|
|
883
|
-
initialize: () => Promise<FileSystemStorage<$fs_def>>;
|
|
884
|
-
};
|
|
958
|
+
$fs_def extends $fs_storage_def['initial'] = $fs_storage_def['initial']>(options: $fs_storage_def): FileSystemStorage<ExtractFsEntriesDef<$fs_def>>;
|
|
885
959
|
|
|
886
|
-
export { _dirname, _filename, defineFileSystemEntries, defineFileSystemStorage, definePackage, definePackageManagerClient, definePathAliases, dependencyTypeMap, detectGlobalPackageManagers, detectLockfilePackageManagers, detectPackageManagers, filterPackageManagers, findDependencyInPackageJson, findPackageManager, findPackageManagerSafely, findResolvedModulePath, getAliasMap, getFolderByPackageName, getGitRootFolder, getGlobalVersions, getPackageFolder, getPath, getWorkspaceFolder, importMap, importer, isDependencyInPackageJson, isPackageDependency, isPackageModuleFound, mapPackageManagers, modifyJSON, modifyJSONFile, packageManagerConfigs, predefinedPathAliases, project, resolveModule, resolveModulePath, resolvePackageModulePath, storage, tempFileSystem, workspace };
|
|
887
|
-
export type { AliasDefinition, AliasDefinitionMap, AliasMap, AnyFunction, AsyncCacheFn, Awaitable, Cast, CheckResult, DefinePackageFn, DetectPackageManagerOptions, Entry, EntryOf, EnumToLiteral, Equals, ExtractImportOptionModule, FileSystemEntriesDefinition, FindDependencyInPackageJsonOptions, FromEntries, GetGitRootFolderOptions, GetPathOptions, GetWorkspaceFolderOptions, ImportCallback, ImportList, ImportMap, ImportMapFn, ImportMapOptions, ImportModuleData, ImportModuleFn, ImportOption, ImportOptionData, ImportPackageData, ImporterOptions, InstallPackageOptions, InstallerFn, IsExactBoolean, IsUnion, IsUnknown, JSONEditData, JSONEditMap, JSONEditOptions, JSONEdits, KeyOf, KnownPackageJson, MergeObject, ModifyJSONCDataOptions, Module, MoodifyJSONFileOptions, NoInfer, OmitByValue, OmitIndexSignature, OmitNever, PackageDependencyItem, PackageDependencyType, PackageInfo, PackageInfoList, PackageInfoMap, PackageJson, PackageJsonPerson, PackageManagerCommandName, PackageManagerCommandSpec, PackageManagerCommands, PackageManagerConfig, PackageManagerId, PackageManagerScriptOptions, PackageName, PathAlias, PathOptions, PathTo, PickByValue, PickKeyOf, PickPathAlias, PredefinedPathAliases, Prettify, ProjectParams, RequireExactlyOne, ResolveModulePathOptions, ResolvedImportList, ResolvedImportListPromise, ResolvedImportMap, ResolvedImportMapPromise, ResolvedImportOption, ResolvedPromise, Select, SelectionMap, SingleProp, StringLiteral, UninstallPackageOptions, ValueAtPath, ValueKeyOf, ValueKeyOfDeep, ValueOf, __ };
|
|
960
|
+
export { _dirname, _filename, createFile, defineFileSystemEntries, defineFileSystemStorage, definePackage, definePackageManager, definePackageManagerClient, definePathAliases, dependencyTypeMap, detectGlobalPackageManagers, detectLockfilePackageManagers, detectPackageManagers, filterPackageManagers, findDependencyInPackageJson, findPackageManager, findPackageManagerSafely, findResolvedModulePath, getAliasMap, getFolderByPackageName, getGitRootFolder, getGlobalVersions, getPackageFolder, getPath, getWorkspaceFolder, importMap, importer, isDependencyInPackageJson, isPackageDependency, isPackageModuleFound, isWritable, mapPackageManagers, modifyJSON, modifyJSONFile, packageManagerConfigs, predefinedPathAliases, project, resolveModule, resolveModulePath, resolvePackageModulePath, storage, tempFileSystem, workspace };
|
|
961
|
+
export type { AliasDefinition, AliasDefinitionMap, AliasMap, AnyFunction, AsyncCacheFn, Awaitable, CallerLocationOptions, Cast, CheckResult, DefinePackageFn, DetectPackageManagerOptions, Entry, EntryOf, EnumToLiteral, Equals, ExtractImportOptionModule, FileSystemEntriesDefinition, FindDependencyInPackageJsonOptions, FromEntries, GetGitRootFolderOptions, GetPathOptions, GetWorkspaceFolderOptions, ImportCallback, ImportList, ImportMap, ImportMapFn, ImportMapOptions, ImportModuleData, ImportModuleFn, ImportOption, ImportOptionData, ImportPackageData, ImporterOptions, InstallPackageOptions, InstallerFn, IsExactBoolean, IsNever, IsUnion, IsUnknown, JSONEditData, JSONEditMap, JSONEditOptions, JSONEdits, KeyOf, KnownPackageJson, MergeObject, ModifyJSONCDataOptions, Module, MoodifyJSONFileOptions, NoInfer, OmitByValue, OmitIndexSignature, OmitNever, PackageDependencyItem, PackageDependencyType, PackageInfo, PackageInfoList, PackageInfoMap, PackageJson, PackageJsonPerson, PackageManager, PackageManagerCommandName, PackageManagerCommandSpec, PackageManagerCommands, PackageManagerConfig, PackageManagerId, PackageManagerScriptOptions, PackageManagers, PackageName, PathAlias, PathAliasResolveOptions, PathOptions, PathTo, PickByValue, PickKeyOf, PickPathAlias, PredefinedPathAliases, Prettify, ProjectParams, RequireExactlyOne, ResolveModulePathOptions, ResolvedImportList, ResolvedImportListPromise, ResolvedImportMap, ResolvedImportMapPromise, ResolvedImportOption, ResolvedPromise, Select, SelectionMap, SingleProp, StringLiteral, UninstallPackageOptions, ValueAtPath, ValueKeyOf, ValueKeyOfDeep, ValueOf, __ };
|