package-management 0.0.9 → 0.0.11
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/index.cjs +388 -131
- package/dist/index.d.cts +208 -63
- package/dist/index.d.mts +208 -63
- package/dist/index.d.ts +208 -63
- package/dist/index.mjs +381 -133
- package/package.json +45 -38
package/dist/index.d.cts
CHANGED
|
@@ -1,23 +1,37 @@
|
|
|
1
|
+
import { Split } from 'string-ts';
|
|
2
|
+
import * as async_cache_fn from 'async-cache-fn';
|
|
1
3
|
import { AsyncCacheFn as AsyncCacheFn$1 } from 'async-cache-fn';
|
|
2
4
|
import { Options } from 'execa';
|
|
3
|
-
import * as async_cache_fn_index from 'async-cache-fn/index';
|
|
4
5
|
import { InstallPackageOptions as InstallPackageOptions$1 } from '@antfu/install-pkg';
|
|
5
6
|
import { ResolveOptions } from 'mlly';
|
|
6
7
|
import * as parse_gitignore from 'parse-gitignore';
|
|
7
8
|
import * as WST from 'workspace-tools';
|
|
8
|
-
import {
|
|
9
|
+
import { ModificationOptions } from 'jsonc-parser';
|
|
10
|
+
import { StorageValue, TransactionOptions, Snapshot, Storage } from 'unstorage';
|
|
11
|
+
import { FSStorageOptions } from 'unstorage/drivers/fs-lite';
|
|
9
12
|
|
|
13
|
+
type Equals<A1 extends any, A2 extends any> = (<A>() => A extends A2 ? 1 : 0) extends <A>() => A extends A1 ? 1 : 0 ? 1 : 0;
|
|
14
|
+
type Cast<A1 extends any, A2 extends any> = A1 extends A2 ? A1 : A2;
|
|
10
15
|
type __<T> = {
|
|
11
16
|
[K in keyof T]: T[K];
|
|
12
17
|
} & {};
|
|
18
|
+
type Prettify<T> = {
|
|
19
|
+
[K in keyof T]: T[K];
|
|
20
|
+
} & {};
|
|
13
21
|
type ValueOf<T> = T[keyof T];
|
|
14
22
|
type EnumToLiteral<T extends string | number> = T extends string ? `${T}` : `${T}` extends `${infer N extends number}` ? N : never;
|
|
15
|
-
type
|
|
23
|
+
type IsUnknown<t> = unknown extends t ? [t] extends [{}] ? false : true : false;
|
|
24
|
+
type AnyFunction = (...args: any[]) => any;
|
|
16
25
|
type StringLiteral<T extends string> = T | (string & {});
|
|
17
26
|
type Awaitable<T> = T | Promise<T>;
|
|
18
27
|
type ResolvedPromise<T> = T extends Promise<infer U> ? U : never;
|
|
19
28
|
type KeyOf<T, K> = K extends keyof T ? K : never;
|
|
20
|
-
type
|
|
29
|
+
type ValueKeyOf<T, K> = T[KeyOf<T, K>];
|
|
30
|
+
type ValueAtPath<T, $dot_path extends string> = ValueKeyOfDeep<Extract<T, object>, Split<$dot_path, ".">>;
|
|
31
|
+
type ValueKeyOfDeep<T, $path extends PropertyKey[]> = $path extends [
|
|
32
|
+
infer K,
|
|
33
|
+
...infer $Path
|
|
34
|
+
] ? ValueKeyOfDeep<ValueKeyOf<T, K>, Extract<$Path, PropertyKey[]>> : T;
|
|
21
35
|
type PickKeyOf<T, K extends keyof T> = K extends keyof T ? K : never;
|
|
22
36
|
type SelectionMap<T> = __<{
|
|
23
37
|
[K in keyof T]?: boolean;
|
|
@@ -32,11 +46,11 @@ type EntryOf<O> = {
|
|
|
32
46
|
type FromEntries<entries extends readonly Entry[]> = {
|
|
33
47
|
[entry in entries[number] as entry[0]]: entry[1];
|
|
34
48
|
};
|
|
49
|
+
type IsExactBoolean<T> = Equals<T, boolean> extends 1 ? true : false;
|
|
35
50
|
type UnionizedSelectionMap<T, TSelection extends SelectionMap<T>, V> = __<V & {
|
|
36
51
|
[K in keyof T as IsExactBoolean<TSelection[K]> extends true ? K : never]?: T[K];
|
|
37
52
|
}>;
|
|
38
|
-
type Select<T, TSelection extends SelectionMap<T>, TMode extends "pick" | "omit"> = __<UnionizedSelectionMap<T, TSelection, TMode extends "pick" ? Pick<T, KeyOf<T, keyof PickByValue<TSelection, true>>> : Omit<T, KeyOf<T, keyof PickByValue<TSelection, true>>>>>;
|
|
39
|
-
type IsExactBoolean<T> = true extends T ? false extends T ? true : false : false;
|
|
53
|
+
type Select<T, TSelection extends SelectionMap<T>, TMode extends "true:pick" | "true:omit"> = __<UnionizedSelectionMap<T, TSelection, TMode extends "true:pick" ? Pick<T, KeyOf<T, keyof PickByValue<TSelection, true>>> : Omit<T, KeyOf<T, keyof PickByValue<TSelection, true>>>>>;
|
|
40
54
|
type IsUnion<T, U = T> = T extends U ? [U] extends [T] ? false : true : never;
|
|
41
55
|
type MergeObject<T extends object, O extends object | unknown = unknown> = __<T & (O extends object ? O : Record<never, never>)>;
|
|
42
56
|
type OmitIndexSignature<ObjectType> = {
|
|
@@ -52,11 +66,13 @@ type OmitByValue<T, V> = OmitNever<{
|
|
|
52
66
|
[K in keyof T]: T[K] extends V ? never : T[K];
|
|
53
67
|
}>;
|
|
54
68
|
type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
69
|
+
type SingleProp<$key, $value> = Prettify<FromEntries<[[key: $key & PropertyKey, value: $value]]>>;
|
|
55
70
|
|
|
56
71
|
interface PathOptions {
|
|
57
72
|
cwd?: string;
|
|
58
73
|
}
|
|
59
74
|
type AsyncCacheFn<TReturn = unknown, TOption extends object | undefined = undefined, C extends "required" | "optional" = "optional"> = AsyncCacheFn$1<TReturn, C extends "optional" ? [TOption | undefined] | [] : [TOption]>;
|
|
75
|
+
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>>>;
|
|
60
76
|
|
|
61
77
|
interface StackFrameOptions {
|
|
62
78
|
rootFunctionName?: string;
|
|
@@ -92,7 +108,7 @@ type InstallPackageOptions = PackageManagerScriptOptions<"install">;
|
|
|
92
108
|
type UninstallPackageOptions = PackageManagerScriptOptions<"uninstall">;
|
|
93
109
|
type PackageManagerCommands = PackageManagerConfig["args"];
|
|
94
110
|
type PackageManagerCommandName = keyof PackageManagerCommands;
|
|
95
|
-
type PackageManagerCommandSpec<K> =
|
|
111
|
+
type PackageManagerCommandSpec<K> = ValueKeyOf<PackageManagerCommands, K> extends {
|
|
96
112
|
options: infer O;
|
|
97
113
|
} ? SelectionMap<O> : Record<never, never>;
|
|
98
114
|
type PackageManagerScriptOptions<K extends PackageManagerCommandName | undefined = undefined> = __<{
|
|
@@ -224,7 +240,12 @@ declare function resolvePackageModulePath(name: string, options?: ResolveModuleP
|
|
|
224
240
|
declare function findResolvedModulePath(paths: string[], options?: ResolveModulePathOptions): string | undefined;
|
|
225
241
|
declare function resolveModulePath(modulePath: string, options?: ResolveModulePathOptions): string | undefined;
|
|
226
242
|
|
|
227
|
-
|
|
243
|
+
/**
|
|
244
|
+
* A set of package managers. Generic over the id so that managers built with
|
|
245
|
+
* `definePackageManager` from a custom config are accepted everywhere the
|
|
246
|
+
* built-in ones are, without a cast.
|
|
247
|
+
*/
|
|
248
|
+
type PackageManagers<$id extends string = PackageManagerId> = PackageManager<$id>[];
|
|
228
249
|
interface PackageManager<ID extends string = PackageManagerId> {
|
|
229
250
|
id: ID;
|
|
230
251
|
config: PackageManagerConfig;
|
|
@@ -250,29 +271,58 @@ interface PackageManager<ID extends string = PackageManagerId> {
|
|
|
250
271
|
installPackage: (packageNames: string | string[], options?: PackageManagerScriptOptions<"install">) => Promise<void>;
|
|
251
272
|
}
|
|
252
273
|
|
|
253
|
-
interface DetectPackageManagerOptions {
|
|
254
|
-
|
|
274
|
+
interface DetectPackageManagerOptions<$id extends string = PackageManagerId> {
|
|
275
|
+
/**
|
|
276
|
+
* Restricts detection to the given package managers. Omit to consider all of
|
|
277
|
+
* them.
|
|
278
|
+
*/
|
|
279
|
+
allowed?: SelectionMap<Record<$id, unknown>>;
|
|
255
280
|
cwd?: string;
|
|
256
281
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
declare function
|
|
264
|
-
|
|
282
|
+
/**
|
|
283
|
+
* The package manager a project uses, preferring the one whose lockfile is
|
|
284
|
+
* present and falling back to whichever is installed globally.
|
|
285
|
+
*
|
|
286
|
+
* @throws when no package manager can be resolved.
|
|
287
|
+
*/
|
|
288
|
+
declare function findPackageManager<$id extends string = PackageManagerId>(packageManagers: PackageManagers<$id>, options?: DetectPackageManagerOptions<$id>): Promise<PackageManager<$id>>;
|
|
289
|
+
/**
|
|
290
|
+
* As {@link findPackageManager}, but resolves to `undefined` rather than
|
|
291
|
+
* throwing when nothing matches.
|
|
292
|
+
*/
|
|
293
|
+
declare function findPackageManagerSafely<$id extends string = PackageManagerId>(packageManagers: PackageManagers<$id>, options?: DetectPackageManagerOptions<$id>): Promise<PackageManager<$id> | undefined>;
|
|
294
|
+
declare function detectPackageManagers<$id extends string = PackageManagerId>(packageManagers: PackageManagers<$id>, options?: DetectPackageManagerOptions<$id>): Promise<PackageManager<$id>[]>;
|
|
295
|
+
declare function detectLockfilePackageManagers<$id extends string = PackageManagerId>(packageManagers: PackageManagers<$id>, options?: DetectPackageManagerOptions<$id>): Promise<PackageManager<$id>[]>;
|
|
296
|
+
declare function detectGlobalPackageManagers<$id extends string = PackageManagerId>(packageManagers: PackageManagers<$id>, options?: DetectPackageManagerOptions<$id>): Promise<PackageManager<$id>[]>;
|
|
297
|
+
/**
|
|
298
|
+
* Global versions of every allowed package manager, keyed by id, where
|
|
299
|
+
* `undefined` means the manager is not installed.
|
|
300
|
+
*
|
|
301
|
+
* Reading one version per manager is inherently concurrent; resolving that
|
|
302
|
+
* concurrency here is what keeps callers from assembling their own
|
|
303
|
+
* `Promise.all` over {@link PackageManager.globalVersion}.
|
|
304
|
+
*/
|
|
305
|
+
declare function getGlobalVersions<$id extends string = PackageManagerId>(packageManagers: PackageManagers<$id>, options?: DetectPackageManagerOptions<$id>): Promise<Record<$id, string | undefined>>;
|
|
306
|
+
/**
|
|
307
|
+
* Applies `mapFn` to every allowed package manager concurrently — the
|
|
308
|
+
* collection-level counterpart to the single-manager methods, and the shared
|
|
309
|
+
* base the filter and version helpers are built from.
|
|
310
|
+
*/
|
|
311
|
+
declare function mapPackageManagers<$result, $id extends string = PackageManagerId>(packageManagers: PackageManagers<$id>, mapFn: (packageManager: PackageManager<$id>) => Awaitable<$result>, options?: DetectPackageManagerOptions<$id>): Promise<(Awaited<$result> | Awaited<$result>)[]>;
|
|
312
|
+
declare function filterPackageManagers<$id extends string = PackageManagerId>(packageManagers: PackageManagers<$id>, filterFn: (packageManager: PackageManager<$id>) => Awaitable<boolean>, options?: DetectPackageManagerOptions<$id>): Promise<PackageManager<$id>[]>;
|
|
265
313
|
|
|
266
314
|
type PackageManagerId = (typeof packageManagerConfigs)[number]["id"];
|
|
267
315
|
declare const packageManagerConfigs: (PackageManagerConfig<"pnpm"> | PackageManagerConfig<"yarn"> | PackageManagerConfig<"bun"> | PackageManagerConfig<"npm">)[];
|
|
268
316
|
declare function definePackageManagerClient(options: DetectPackageManagerOptions): {
|
|
269
|
-
configs: PackageManager<"
|
|
270
|
-
findPackageManager:
|
|
271
|
-
findPackageManagerSafely:
|
|
272
|
-
detectPackageManagers:
|
|
273
|
-
detectLockfilePackageManagers:
|
|
274
|
-
detectGlobalPackageManagers:
|
|
275
|
-
|
|
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">[]>;
|
|
325
|
+
mapPackageManagers: <$result>(mapFn: (packageManager: PackageManager) => Awaitable<$result>, options?: DetectPackageManagerOptions) => Promise<Awaited<$result>[]>;
|
|
276
326
|
};
|
|
277
327
|
|
|
278
328
|
declare function isPackageDependency(packageName: string | string[]): boolean;
|
|
@@ -294,10 +344,11 @@ type AliasMap<TAliases extends AliasDefinitionMap = AliasDefinitionMap> = {
|
|
|
294
344
|
type ResolvePathAliasFn = (opts?: {
|
|
295
345
|
cwd?: string;
|
|
296
346
|
}) => string;
|
|
347
|
+
type StringKeyOf<T> = Extract<keyof T, string>;
|
|
297
348
|
declare function definePathAliases<const T extends AliasDefinitionMap>(aliasDefinitions: T): {
|
|
298
349
|
aliasDefinitions: T;
|
|
299
350
|
aliasMap: AliasMap<T>;
|
|
300
|
-
getFilePath: <TValidate extends boolean = false, TGlob extends boolean = false>(options: PathTo<
|
|
351
|
+
getFilePath: <TValidate extends boolean = false, TGlob extends boolean = false>(options: PathTo<StringKeyOf<AliasMap<T>>> | GetPathOptions<StringKeyOf<AliasMap<T>>, TValidate, TGlob>, aliases?: Record<string, string>) => TValidate extends true ? string | undefined : TGlob extends true ? string | undefined : string;
|
|
301
352
|
};
|
|
302
353
|
type PathTo<TBaseDirAlias extends string = string> = string | [baseDir: TBaseDirAlias, subpath?: string];
|
|
303
354
|
interface GetPathOptions<TAlias extends string, TValidate extends boolean = false, TGlob extends boolean = false> {
|
|
@@ -357,7 +408,7 @@ declare function getAliasMap<const T extends AliasDefinitionMap>(aliasDefs: T):
|
|
|
357
408
|
* > Path to the current folder.
|
|
358
409
|
* > - Example: `/Users/username/Projects/monorepo/package-folder/src/utils`
|
|
359
410
|
*/
|
|
360
|
-
declare const getPath: <TValidate extends boolean = false, TGlob extends boolean = false>(options: PathTo<"<workspace_folder>" | "<workspace_folder?>" | "<package_folder>" | "<gitroot_folder>" | "<user_home>" | "<user_tmpdir>" | "<cwd>" | "<current_file>" | "<current_folder>" | `<user_home>/${any}` | `<user_tmpdir>/${any}` | `<cwd>/${any}` | `<current_file>/${any}` | `<current_folder>/${any}` | "<workspace_folder>/node_modules" | "<workspace_folder>/node_modules/.bin" | "<workspace_folder?>/node_modules" | "<workspace_folder?>/node_modules/.bin" | "<package_folder>/node_modules" | "<package_folder>/node_modules/.bin" | "<package_folder>/src" | "<gitroot_folder>/node_modules" | "<gitroot_folder>/node_modules/.bin" | "<gitroot_folder>/.vscode"> | GetPathOptions<"<workspace_folder>" | "<workspace_folder?>" | "<package_folder>" | "<gitroot_folder>" | "<user_home>" | "<user_tmpdir>" | "<cwd>" | "<current_file>" | "<current_folder>" | `<user_home>/${any}` | `<user_tmpdir>/${any}` | `<cwd>/${any}` | `<current_file>/${any}` | `<current_folder>/${any}` | "<workspace_folder>/node_modules" | "<workspace_folder>/node_modules/.bin" | "<workspace_folder?>/node_modules" | "<workspace_folder?>/node_modules/.bin" | "<package_folder>/node_modules" | "<package_folder>/node_modules/.bin" | "<package_folder>/src" | "<gitroot_folder>/node_modules" | "<gitroot_folder>/node_modules/.bin" | "<gitroot_folder>/.vscode", TValidate, TGlob>, aliases?: Record<string, string>
|
|
411
|
+
declare const getPath: <TValidate extends boolean = false, TGlob extends boolean = false>(options: PathTo<"<workspace_folder>" | "<workspace_folder?>" | "<package_folder>" | "<gitroot_folder>" | "<user_home>" | "<user_tmpdir>" | "<cwd>" | "<current_file>" | "<current_folder>" | `<user_home>/${any}` | `<user_tmpdir>/${any}` | `<cwd>/${any}` | `<current_file>/${any}` | `<current_folder>/${any}` | "<workspace_folder>/node_modules" | "<workspace_folder>/node_modules/.bin" | "<workspace_folder?>/node_modules" | "<workspace_folder?>/node_modules/.bin" | "<package_folder>/node_modules" | "<package_folder>/node_modules/.bin" | "<package_folder>/src" | "<gitroot_folder>/node_modules" | "<gitroot_folder>/node_modules/.bin" | "<gitroot_folder>/.vscode"> | GetPathOptions<"<workspace_folder>" | "<workspace_folder?>" | "<package_folder>" | "<gitroot_folder>" | "<user_home>" | "<user_tmpdir>" | "<cwd>" | "<current_file>" | "<current_folder>" | `<user_home>/${any}` | `<user_tmpdir>/${any}` | `<cwd>/${any}` | `<current_file>/${any}` | `<current_folder>/${any}` | "<workspace_folder>/node_modules" | "<workspace_folder>/node_modules/.bin" | "<workspace_folder?>/node_modules" | "<workspace_folder?>/node_modules/.bin" | "<package_folder>/node_modules" | "<package_folder>/node_modules/.bin" | "<package_folder>/src" | "<gitroot_folder>/node_modules" | "<gitroot_folder>/node_modules/.bin" | "<gitroot_folder>/.vscode", TValidate, TGlob>, aliases?: Record<string, string>) => TValidate extends true ? string | undefined : TGlob extends true ? string | undefined : string;
|
|
361
412
|
|
|
362
413
|
type PathAlias = keyof PredefinedPathAliases;
|
|
363
414
|
type PickPathAlias<K extends PathAlias> = K;
|
|
@@ -365,7 +416,7 @@ type PredefinedPathAliases = typeof predefinedPathAliases;
|
|
|
365
416
|
declare const predefinedPathAliases: {
|
|
366
417
|
readonly "<workspace_folder>": {
|
|
367
418
|
readonly resolve: (opts: {
|
|
368
|
-
cwd?: string
|
|
419
|
+
cwd?: string;
|
|
369
420
|
} | undefined) => string;
|
|
370
421
|
readonly subpaths: [{
|
|
371
422
|
readonly to: "node_modules";
|
|
@@ -375,7 +426,7 @@ declare const predefinedPathAliases: {
|
|
|
375
426
|
};
|
|
376
427
|
readonly "<workspace_folder?>": {
|
|
377
428
|
readonly resolve: (opts: {
|
|
378
|
-
cwd?: string
|
|
429
|
+
cwd?: string;
|
|
379
430
|
} | undefined) => string;
|
|
380
431
|
readonly subpaths: [{
|
|
381
432
|
readonly to: "node_modules";
|
|
@@ -385,7 +436,7 @@ declare const predefinedPathAliases: {
|
|
|
385
436
|
};
|
|
386
437
|
readonly "<package_folder>": {
|
|
387
438
|
readonly resolve: (opts: {
|
|
388
|
-
cwd?: string
|
|
439
|
+
cwd?: string;
|
|
389
440
|
} | undefined) => string;
|
|
390
441
|
readonly subpaths: [{
|
|
391
442
|
readonly to: "node_modules";
|
|
@@ -397,7 +448,7 @@ declare const predefinedPathAliases: {
|
|
|
397
448
|
};
|
|
398
449
|
readonly "<gitroot_folder>": {
|
|
399
450
|
readonly resolve: (opts: {
|
|
400
|
-
cwd?: string
|
|
451
|
+
cwd?: string;
|
|
401
452
|
} | undefined) => string;
|
|
402
453
|
readonly subpaths: [{
|
|
403
454
|
readonly to: "node_modules";
|
|
@@ -623,15 +674,17 @@ type ProjectParams = [
|
|
|
623
674
|
source: ProjectFolderTypeOption,
|
|
624
675
|
options?: PathOptions
|
|
625
676
|
];
|
|
626
|
-
declare const project: (
|
|
677
|
+
declare const project: (...args: ProjectParams) => {
|
|
627
678
|
packageJson: PackageJson | undefined;
|
|
628
679
|
packageJsonPath: string | undefined;
|
|
629
680
|
packageName: string | undefined;
|
|
630
681
|
projectDir: string | undefined;
|
|
631
|
-
findPackageManager:
|
|
632
|
-
detectPackageManagers:
|
|
633
|
-
detectGlobalPackageManagers:
|
|
634
|
-
detectLockfilePackageManagers:
|
|
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]>;
|
|
687
|
+
mapPackageManagers: <$result>(mapFn: (packageManager: PackageManager) => Awaitable<$result>, options?: DetectPackageManagerOptions) => Promise<Awaited<$result>[]>;
|
|
635
688
|
tsconfig: {
|
|
636
689
|
readonly paths: string[];
|
|
637
690
|
};
|
|
@@ -639,7 +692,7 @@ declare const project: (source: ProjectFolderTypeOption, options?: PathOptions |
|
|
|
639
692
|
readonly data: parse_gitignore.ParsedGitignoreObject;
|
|
640
693
|
readonly patterns: string[];
|
|
641
694
|
};
|
|
642
|
-
filterPackageManagers: (filterFn: (packageManager: PackageManager
|
|
695
|
+
filterPackageManagers: (filterFn: (packageManager: PackageManager) => Awaitable<boolean>, options?: DetectPackageManagerOptions) => Promise<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[]>;
|
|
643
696
|
getPackageJson: () => PackageJson;
|
|
644
697
|
findDependencyInPackageJson: (options: string | FindDependencyInPackageJsonOptions) => {
|
|
645
698
|
firstMatch: PackageDependencyItem | undefined;
|
|
@@ -650,7 +703,14 @@ declare const project: (source: ProjectFolderTypeOption, options?: PathOptions |
|
|
|
650
703
|
|
|
651
704
|
declare function getFolderByPackageName(name: PackageName, options?: PathOptions): string | undefined;
|
|
652
705
|
|
|
653
|
-
|
|
706
|
+
interface GetGitRootFolderOptions<$Validate extends boolean = true> extends PathOptions {
|
|
707
|
+
/** @default true */
|
|
708
|
+
throwIfNotFound?: $Validate;
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* Starting from `cwd`, resolves the root of the enclosing git working tree.
|
|
712
|
+
*/
|
|
713
|
+
declare function getGitRootFolder<$ThrowIfNotFound extends boolean = true>(options?: GetGitRootFolderOptions<$ThrowIfNotFound>): $ThrowIfNotFound extends true ? string : string | undefined;
|
|
654
714
|
|
|
655
715
|
/**
|
|
656
716
|
*
|
|
@@ -681,11 +741,7 @@ interface GetPackageInfoListOptions {
|
|
|
681
741
|
cwd?: string;
|
|
682
742
|
includeRoot?: boolean;
|
|
683
743
|
}
|
|
684
|
-
declare function getWorkspacePackageInfoList(options?: GetPackageInfoListOptions): (PackageInfo |
|
|
685
|
-
name: string;
|
|
686
|
-
path: string;
|
|
687
|
-
packageJson: WST.PackageInfo;
|
|
688
|
-
})[];
|
|
744
|
+
declare function getWorkspacePackageInfoList(options?: GetPackageInfoListOptions): (PackageInfo | WST.WorkspacePackageInfo)[];
|
|
689
745
|
|
|
690
746
|
declare function getWorkspacePackageNames(options?: GetPackageInfoListOptions): string[];
|
|
691
747
|
|
|
@@ -699,10 +755,12 @@ declare const workspace: {
|
|
|
699
755
|
packageJsonPath: string | undefined;
|
|
700
756
|
packageName: string | undefined;
|
|
701
757
|
projectDir: string | undefined;
|
|
702
|
-
findPackageManager:
|
|
703
|
-
detectPackageManagers:
|
|
704
|
-
detectGlobalPackageManagers:
|
|
705
|
-
detectLockfilePackageManagers:
|
|
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]>;
|
|
763
|
+
mapPackageManagers: <$result>(mapFn: (packageManager: PackageManager) => Awaitable<$result>, options?: DetectPackageManagerOptions) => Promise<Awaited<$result>[]>;
|
|
706
764
|
tsconfig: {
|
|
707
765
|
readonly paths: string[];
|
|
708
766
|
};
|
|
@@ -710,7 +768,7 @@ declare const workspace: {
|
|
|
710
768
|
readonly data: parse_gitignore.ParsedGitignoreObject;
|
|
711
769
|
readonly patterns: string[];
|
|
712
770
|
};
|
|
713
|
-
filterPackageManagers: (filterFn: (packageManager: PackageManager
|
|
771
|
+
filterPackageManagers: (filterFn: (packageManager: PackageManager) => Awaitable<boolean>, options?: DetectPackageManagerOptions) => Promise<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[]>;
|
|
714
772
|
getPackageJson: () => PackageJson;
|
|
715
773
|
findDependencyInPackageJson: (options: string | FindDependencyInPackageJsonOptions) => {
|
|
716
774
|
firstMatch: PackageDependencyItem | undefined;
|
|
@@ -720,23 +778,110 @@ declare const workspace: {
|
|
|
720
778
|
};
|
|
721
779
|
};
|
|
722
780
|
|
|
723
|
-
interface
|
|
724
|
-
|
|
725
|
-
|
|
781
|
+
interface JsonSourceData<$json extends object = object> {
|
|
782
|
+
text: string;
|
|
783
|
+
data: $json;
|
|
784
|
+
}
|
|
785
|
+
type JsonSourceInput<data extends object = object> = Prettify<RequireExactlyOne<{
|
|
786
|
+
data?: data;
|
|
787
|
+
filepath?: string;
|
|
788
|
+
text?: string;
|
|
789
|
+
}>>;
|
|
790
|
+
|
|
791
|
+
interface JSONEditMap {
|
|
792
|
+
[$dot_path: string | number]: Omit<JSONEditData, "path">;
|
|
726
793
|
}
|
|
727
|
-
interface
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
794
|
+
interface JSONEditData {
|
|
795
|
+
path: (string | number)[] | string | number;
|
|
796
|
+
value: any;
|
|
797
|
+
options?: JSONEditOptions;
|
|
731
798
|
}
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
799
|
+
interface JSONEditOptions extends ModificationOptions {
|
|
800
|
+
/** @default "." */
|
|
801
|
+
pathSeparator?: string | false;
|
|
802
|
+
}
|
|
803
|
+
type JSONEdits = JSONEditMap | JSONEditData[];
|
|
804
|
+
interface ModifyJSONCDataOptions<$data extends object = object> {
|
|
805
|
+
json: JsonSourceInput<$data>;
|
|
806
|
+
edits: JSONEdits;
|
|
807
|
+
defaultEditOptions?: JSONEditOptions;
|
|
808
|
+
}
|
|
809
|
+
type ModifyJSONDataResult = CheckResult<JsonSourceData>;
|
|
810
|
+
declare function modifyJSON({ json, edits, defaultEditOptions, }: ModifyJSONCDataOptions): ModifyJSONDataResult;
|
|
811
|
+
interface MoodifyJSONFileOptions<$auto_commit extends boolean = boolean> {
|
|
812
|
+
autoCommit?: $auto_commit;
|
|
813
|
+
defaultEditOptions?: JSONEditOptions;
|
|
814
|
+
}
|
|
815
|
+
type ModifyJSONFileResult<$auto_commit extends boolean = true> = $auto_commit extends true ? CheckResult<JsonSourceData> : CheckResult<{
|
|
816
|
+
json: JsonSourceData;
|
|
817
|
+
commit: () => void;
|
|
818
|
+
}>;
|
|
819
|
+
declare function modifyJSONFile<$auto_commit extends boolean = true>(filepath: string, edits: JSONEdits, options?: MoodifyJSONFileOptions<$auto_commit>): ModifyJSONFileResult<$auto_commit>;
|
|
820
|
+
|
|
821
|
+
declare const storage: Storage<StorageValue>;
|
|
822
|
+
declare const tempFileSystem: {
|
|
823
|
+
definition: {
|
|
824
|
+
readonly base: string;
|
|
739
825
|
};
|
|
826
|
+
initialize: () => Promise<FileSystemStorage<unknown, string & {}>>;
|
|
827
|
+
};
|
|
828
|
+
type FileSystemEntriesDefinition<$filepath extends string = string> = {
|
|
829
|
+
[K in $filepath]: StorageValue | (<$file_data extends StorageValue>() => {
|
|
830
|
+
file: $file_data;
|
|
831
|
+
options?: TransactionOptions;
|
|
832
|
+
serialize?: (file_data: $file_data) => string;
|
|
833
|
+
deserialize?: (file_content: string) => $file_data;
|
|
834
|
+
});
|
|
835
|
+
};
|
|
836
|
+
interface FileSystemEntry<$key extends string = string> {
|
|
837
|
+
key: $key;
|
|
838
|
+
value: string;
|
|
839
|
+
options?: TransactionOptions;
|
|
840
|
+
}
|
|
841
|
+
type DefineFileSystemOptions<$filepath extends string = string> = {
|
|
842
|
+
base: string;
|
|
843
|
+
initial?: FileSystemEntriesDefinition<$filepath>;
|
|
844
|
+
} & Omit<FSStorageOptions, "base">;
|
|
845
|
+
type FileSystemPath<$fs_def> = Extract<keyof $fs_def, string>;
|
|
846
|
+
type FileSystemPathCompletion<$fs_def> = StringLiteral<FileSystemPath<$fs_def>>;
|
|
847
|
+
interface FileSystemStorage<$fs_def extends FileSystemEntriesDefinition | undefined = FileSystemEntriesDefinition, // prettier-ignore
|
|
848
|
+
$path_completion extends FileSystemPathCompletion<$fs_def> = FileSystemPathCompletion<$fs_def>> {
|
|
849
|
+
meta: {
|
|
850
|
+
fileEntriesData: FileSystemEntriesData<$fs_def>;
|
|
851
|
+
};
|
|
852
|
+
createFile: (key: string, data: string) => Promise<{
|
|
853
|
+
key: string;
|
|
854
|
+
filepath: string;
|
|
855
|
+
get: () => Promise<StorageValue>;
|
|
856
|
+
update: (data: string) => Promise<void>;
|
|
857
|
+
}>;
|
|
858
|
+
getFile: (filepath: $path_completion) => Promise<{
|
|
859
|
+
key: string;
|
|
860
|
+
filepath: string;
|
|
861
|
+
data: any;
|
|
862
|
+
read: () => Promise<any>;
|
|
863
|
+
}>;
|
|
864
|
+
readFile: (filepath: $path_completion) => Promise<string>;
|
|
865
|
+
getFilePath: <$filepath extends $path_completion>(key: $filepath) => Promise<string>;
|
|
866
|
+
restoreFs(snapshot: Snapshot, base?: string): Promise<void>;
|
|
867
|
+
snapshotFs: (base?: string) => Promise<Snapshot<string>>;
|
|
868
|
+
initializeFs: (newInitial?: FileSystemEntriesDefinition) => Promise<void>;
|
|
869
|
+
removeAllFiles(base?: string, opts?: TransactionOptions): Promise<void>;
|
|
870
|
+
deleteFileSystem(): Promise<void>;
|
|
871
|
+
defineFileSystemEntries: typeof defineFileSystemEntries;
|
|
872
|
+
storage: Storage;
|
|
873
|
+
}
|
|
874
|
+
interface FileSystemEntriesData<T extends FileSystemEntriesDefinition | undefined = undefined, $fs_def extends ExtractFsEntriesDef<T> = ExtractFsEntriesDef<T>> {
|
|
875
|
+
definition: $fs_def;
|
|
876
|
+
fileSystemEntries: FileSystemEntry<FileSystemPath<$fs_def>>[];
|
|
877
|
+
}
|
|
878
|
+
declare function defineFileSystemEntries<const $fs_def extends FileSystemEntriesDefinition>(definition: $fs_def): FileSystemEntriesData<$fs_def>;
|
|
879
|
+
type ExtractFsEntriesDef<$fs_def> = Cast<$fs_def, FileSystemEntriesDefinition>;
|
|
880
|
+
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): $fs_storage_def["initial"] extends undefined ? FileSystemStorage : {
|
|
882
|
+
definition: $fs_storage_def;
|
|
883
|
+
initialize: () => Promise<FileSystemStorage<$fs_def>>;
|
|
740
884
|
};
|
|
741
885
|
|
|
742
|
-
export {
|
|
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, __ };
|