package-management 0.0.1 → 0.0.3
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 +806 -115
- package/dist/index.d.cts +574 -121
- package/dist/index.d.mts +574 -121
- package/dist/index.d.ts +574 -121
- package/dist/index.mjs +771 -118
- package/package.json +30 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,55 +1,23 @@
|
|
|
1
|
-
import { InstallPackageOptions } from '@antfu/install-pkg';
|
|
2
1
|
import { AsyncCacheFn as AsyncCacheFn$1 } from 'async-cache-fn';
|
|
3
2
|
import { Options } from 'execa';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
name: string;
|
|
10
|
-
/**
|
|
11
|
-
* When enabled, the package will be installed if it is not found
|
|
12
|
-
* @default true
|
|
13
|
-
*/
|
|
14
|
-
install?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* The import statement for the package.
|
|
17
|
-
*/
|
|
18
|
-
import: () => ImportStatement<T>;
|
|
19
|
-
/**
|
|
20
|
-
* When enabled, the package will be installed as a dev dependency
|
|
21
|
-
*/
|
|
22
|
-
isDevDependency?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Additional installation options
|
|
25
|
-
*/
|
|
26
|
-
installOptions?: Omit<InstallPackageOptions, "dev">;
|
|
27
|
-
}
|
|
28
|
-
type ImportMap = Record<string, ImportOption>;
|
|
29
|
-
type ImportList = ImportOption[];
|
|
30
|
-
type ImportOption<T = any> = ImportStatement<T> | (() => ImportStatement<T>) | ImportPackageOption<T>;
|
|
31
|
-
type ImportStatement<T = any> = Promise<T>;
|
|
32
|
-
type ResolvedImportOption<T extends ImportOption> = ResolvedPromise<ExtractImportStatement<T>>;
|
|
33
|
-
type ResolvedImportMap<$Imports extends ImportMap> = {
|
|
34
|
-
[P in keyof $Imports]: ResolvedImportOption<$Imports[P]>;
|
|
35
|
-
};
|
|
36
|
-
type ResolvedImportMapPromise<T extends ImportMap> = Promise<ResolvedImportMap<T>>;
|
|
37
|
-
type ResolvedImportList<$Imports extends ImportList> = {
|
|
38
|
-
[P in keyof $Imports]: ResolvedImportOption<$Imports[P]>;
|
|
39
|
-
};
|
|
40
|
-
type ResolvedImportListPromise<T extends ImportList> = Promise<ResolvedImportList<T>>;
|
|
41
|
-
type ExtractImportStatement<T extends ImportOption> = ExtractImport<T> extends () => infer I ? I : T;
|
|
42
|
-
type ExtractImport<T extends ImportOption> = T extends {
|
|
43
|
-
import: infer I;
|
|
44
|
-
} ? I : T;
|
|
3
|
+
import * as async_cache_fn_index from 'async-cache-fn/index';
|
|
4
|
+
import { InstallPackageOptions as InstallPackageOptions$1 } from '@antfu/install-pkg';
|
|
5
|
+
import { ResolveOptions } from 'mlly';
|
|
6
|
+
import * as parse_gitignore from 'parse-gitignore';
|
|
7
|
+
import * as WST from 'workspace-tools';
|
|
45
8
|
|
|
46
9
|
type __<T> = {
|
|
47
10
|
[K in keyof T]: T[K];
|
|
48
11
|
} & {};
|
|
12
|
+
type ValueOf<T> = T[keyof T];
|
|
13
|
+
type EnumToLiteral<T extends string | number> = T extends string ? `${T}` : `${T}` extends `${infer N extends number}` ? N : never;
|
|
14
|
+
type Func = (...args: any[]) => any;
|
|
15
|
+
type StringLiteral<T extends string> = T | (string & {});
|
|
49
16
|
type Awaitable<T> = T | Promise<T>;
|
|
50
17
|
type ResolvedPromise<T> = T extends Promise<infer U> ? U : never;
|
|
51
18
|
type KeyOf<T, K> = K extends keyof T ? K : never;
|
|
52
19
|
type KeyOfValue<T, K> = T[KeyOf<T, K>];
|
|
20
|
+
type PickKeyOf<T, K extends keyof T> = K extends keyof T ? K : never;
|
|
53
21
|
type SelectionMap<T> = __<{
|
|
54
22
|
[K in keyof T]?: boolean;
|
|
55
23
|
}>;
|
|
@@ -70,15 +38,123 @@ type Select<T, TSelection extends SelectionMap<T>, TMode extends "pick" | "omit"
|
|
|
70
38
|
type IsExactBoolean<T> = true extends T ? false extends T ? true : false : false;
|
|
71
39
|
type IsUnion<T, U = T> = T extends U ? [U] extends [T] ? false : true : never;
|
|
72
40
|
type MergeObject<T extends object, O extends object | unknown = unknown> = __<T & (O extends object ? O : Record<never, never>)>;
|
|
41
|
+
type OmitIndexSignature<ObjectType> = {
|
|
42
|
+
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType];
|
|
43
|
+
};
|
|
44
|
+
type RequireExactlyOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = {
|
|
45
|
+
[Key in KeysType]: Required<Pick<ObjectType, Key>> & Partial<Record<Exclude<KeysType, Key>, never>>;
|
|
46
|
+
}[KeysType] & Omit<ObjectType, KeysType>;
|
|
47
|
+
type OmitNever<T> = Omit<T, {
|
|
48
|
+
[K in keyof T]: T[K] extends never ? K : never;
|
|
49
|
+
}[keyof T]> & {};
|
|
50
|
+
type OmitByValue<T, V> = OmitNever<{
|
|
51
|
+
[K in keyof T]: T[K] extends V ? never : T[K];
|
|
52
|
+
}>;
|
|
53
|
+
type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
54
|
+
|
|
55
|
+
interface PathOptions {
|
|
56
|
+
cwd?: string;
|
|
57
|
+
}
|
|
73
58
|
type AsyncCacheFn<TReturn = unknown, TOption extends object | undefined = undefined, C extends "required" | "optional" = "optional"> = AsyncCacheFn$1<TReturn, C extends "optional" ? [TOption | undefined] | [] : [TOption]>;
|
|
74
59
|
|
|
60
|
+
interface StackFrameOptions {
|
|
61
|
+
rootFunctionName?: string;
|
|
62
|
+
}
|
|
63
|
+
declare const _filename: (options?: StackFrameOptions) => string | undefined;
|
|
64
|
+
declare const _dirname: (options?: StackFrameOptions) => string | undefined;
|
|
65
|
+
|
|
66
|
+
interface PackageManagerConfig<ID extends string = string> {
|
|
67
|
+
id: ID;
|
|
68
|
+
command: string;
|
|
69
|
+
name: string;
|
|
70
|
+
meta: {
|
|
71
|
+
lockfile: string | string[];
|
|
72
|
+
};
|
|
73
|
+
runner: string;
|
|
74
|
+
args: {
|
|
75
|
+
install: {
|
|
76
|
+
command: string;
|
|
77
|
+
options: {
|
|
78
|
+
preferOffline: string;
|
|
79
|
+
dev: string;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
uninstall: {
|
|
83
|
+
command: string;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
options: {
|
|
87
|
+
version: string;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
type InstallPackageOptions = PackageManagerScriptOptions<"install">;
|
|
91
|
+
type UninstallPackageOptions = PackageManagerScriptOptions<"uninstall">;
|
|
92
|
+
type PackageManagerCommands = PackageManagerConfig["args"];
|
|
93
|
+
type PackageManagerCommandName = keyof PackageManagerCommands;
|
|
94
|
+
type PackageManagerCommandSpec<K> = KeyOfValue<PackageManagerCommands, K> extends {
|
|
95
|
+
options: infer O;
|
|
96
|
+
} ? SelectionMap<O> : Record<never, never>;
|
|
97
|
+
type PackageManagerScriptOptions<K extends PackageManagerCommandName | undefined = undefined> = __<{
|
|
98
|
+
cwd?: string;
|
|
99
|
+
silent?: boolean;
|
|
100
|
+
shellOptions?: Options;
|
|
101
|
+
} & PackageManagerCommandSpec<K>>;
|
|
102
|
+
|
|
103
|
+
interface ImportModuleData<T = any> {
|
|
104
|
+
/**
|
|
105
|
+
* The name of the package to import. This should match the name used in the import statement.
|
|
106
|
+
*/
|
|
107
|
+
name: string;
|
|
108
|
+
/**
|
|
109
|
+
* A callback which returns a module import statement
|
|
110
|
+
*/
|
|
111
|
+
import: ImportCallback<T>;
|
|
112
|
+
}
|
|
113
|
+
interface ImportPackageData<T = any> extends ImportModuleData<T> {
|
|
114
|
+
/**
|
|
115
|
+
* When enabled, the package will be installed if it is not found
|
|
116
|
+
* @default true
|
|
117
|
+
*/
|
|
118
|
+
install?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* When enabled, the package will be installed as a dev dependency
|
|
121
|
+
*/
|
|
122
|
+
dev?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Additional installation options
|
|
125
|
+
*/
|
|
126
|
+
installOptions?: Omit<InstallPackageOptions$1, "dev">;
|
|
127
|
+
}
|
|
128
|
+
type ImportOption<T = any> = Module | ImportCallback<T> | ImportModuleData<T> | ImportPackageData<T>;
|
|
129
|
+
type Module<T = any> = Promise<T>;
|
|
130
|
+
type ImportCallback<T = any> = () => Module<T>;
|
|
131
|
+
type ImportMap = Record<string, ImportOption>;
|
|
132
|
+
type ImportList = ImportOption[];
|
|
133
|
+
type ImportModuleFn = <T = any>(name: string) => ImportModuleData<T>;
|
|
134
|
+
type ImportOptionData<T extends ImportOption> = ResolvedPromise<ExtractImportOptionModule<T>>;
|
|
135
|
+
type ResolvedImportMap<$Imports extends ImportMap> = {
|
|
136
|
+
[P in keyof $Imports]: ImportOptionData<$Imports[P]>;
|
|
137
|
+
};
|
|
138
|
+
type ResolvedImportMapPromise<T extends ImportMap> = Promise<ResolvedImportMap<T>>;
|
|
139
|
+
type ResolvedImportList<$Imports extends ImportList> = {
|
|
140
|
+
[P in keyof $Imports]: ImportOptionData<$Imports[P]>;
|
|
141
|
+
};
|
|
142
|
+
type ResolvedImportListPromise<T extends ImportList> = Promise<ResolvedImportList<T>>;
|
|
143
|
+
type ResolvedImportOption<TOption extends ImportOption> = __<{
|
|
144
|
+
name?: string;
|
|
145
|
+
import: () => ExtractImportOptionModule<TOption>;
|
|
146
|
+
} & Partial<ImportPackageData>>;
|
|
147
|
+
type ExtractImportOptionModule<TOption> = Extract<TOption extends {
|
|
148
|
+
import: () => infer I;
|
|
149
|
+
} ? I : TOption extends () => infer I ? I : TOption extends Module ? TOption : never, Module>;
|
|
150
|
+
|
|
75
151
|
interface ImporterOptions {
|
|
76
152
|
/**
|
|
77
|
-
* When enabled, the default behavior is to install packages that are not found.
|
|
78
|
-
* The name of the package is inferred from the key of the import map.
|
|
153
|
+
* When enabled, the default behavior is to install packages that are not found if the name is provided.
|
|
79
154
|
* @default true
|
|
80
155
|
*/
|
|
81
156
|
install?: boolean;
|
|
157
|
+
installer?: InstallerFn;
|
|
82
158
|
}
|
|
83
159
|
/**
|
|
84
160
|
* Dynamically imports modules and returns their exports in a tuple.
|
|
@@ -101,7 +177,16 @@ interface ImporterOptions {
|
|
|
101
177
|
* @typeparam Imports An array type representing the dynamic imports.
|
|
102
178
|
*/
|
|
103
179
|
declare function importer<T extends ImportList>(imports: [...T], options?: ImporterOptions): Promise<ResolvedImportList<T>>;
|
|
180
|
+
type DefinePackageFn = <T = any>(options: __<string | Pick<ImportPackageData, "name" | "dev">>) => ImportPackageData<T>;
|
|
181
|
+
declare const definePackage: DefinePackageFn;
|
|
182
|
+
type InstallerFn = (packageName: string | string[], options?: {
|
|
183
|
+
dev?: boolean;
|
|
184
|
+
checkExists?: boolean;
|
|
185
|
+
}) => Promise<void>;
|
|
104
186
|
|
|
187
|
+
interface ImportMapOptions extends ImporterOptions {
|
|
188
|
+
}
|
|
189
|
+
type ImportMapFn = <T extends ImportMap>(importMap: T, options?: ImportMapOptions) => ResolvedImportMapPromise<T>;
|
|
105
190
|
/**
|
|
106
191
|
* Asynchronously imports modules from a record of dynamic import promises.
|
|
107
192
|
* Returns a promise that resolves to a record with the same keys, each mapped to the resolved import.
|
|
@@ -124,68 +209,21 @@ declare function importer<T extends ImportList>(imports: [...T], options?: Impor
|
|
|
124
209
|
* ```
|
|
125
210
|
*
|
|
126
211
|
*/
|
|
127
|
-
declare
|
|
212
|
+
declare const importMap: ImportMapFn;
|
|
128
213
|
|
|
129
|
-
declare function
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Asynchronously handles the resolution of a module, extracting its default export if available.
|
|
133
|
-
* If the module does not have a default export, it returns the module itself.
|
|
134
|
-
*
|
|
135
|
-
* @param m A promise representing a module import (either ES Module or CommonJS).
|
|
136
|
-
* @returns A promise that resolves to either the default export of the module or the module itself.
|
|
137
|
-
*
|
|
138
|
-
* @typeparam T The type of the module being imported.
|
|
139
|
-
*
|
|
140
|
-
* @example
|
|
141
|
-
* ```typescript
|
|
142
|
-
* // Usage example with dynamic import
|
|
143
|
-
* const module = await interopDefault(import('some-module'));
|
|
144
|
-
*
|
|
145
|
-
* // 'module' will be either the default export of 'some-module' or the module itself if no default export exists
|
|
146
|
-
* ```
|
|
147
|
-
*/
|
|
148
|
-
declare function resolveModule<T>(m: Awaitable<T>): Promise<T extends {
|
|
214
|
+
declare function resolveModule<T>(module: Awaitable<T>): Promise<T extends {
|
|
149
215
|
default: infer U;
|
|
150
216
|
} ? U : T>;
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
interface PackageManagerConfig<ID extends string = string> {
|
|
155
|
-
id: ID;
|
|
156
|
-
command: string;
|
|
157
|
-
name: string;
|
|
158
|
-
meta: {
|
|
159
|
-
lockfile: string | string[];
|
|
160
|
-
};
|
|
161
|
-
runner: string;
|
|
162
|
-
args: {
|
|
163
|
-
install: {
|
|
164
|
-
command: string;
|
|
165
|
-
options: {
|
|
166
|
-
preferOffline: string;
|
|
167
|
-
isDevDependency: string;
|
|
168
|
-
};
|
|
169
|
-
};
|
|
170
|
-
uninstall: {
|
|
171
|
-
command: string;
|
|
172
|
-
};
|
|
173
|
-
};
|
|
174
|
-
options: {
|
|
175
|
-
version: string;
|
|
176
|
-
};
|
|
217
|
+
interface ResolveModulePathOptions extends Omit<ResolveOptions, "url"> {
|
|
218
|
+
paths?: string | URL | (string | URL)[];
|
|
219
|
+
normalize?: ((path: string) => string) | boolean;
|
|
177
220
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
} ? SelectionMap<O> : Record<never, never>;
|
|
221
|
+
declare function isPackageModuleFound(name: string, options?: ResolveModulePathOptions): boolean;
|
|
222
|
+
declare function resolvePackageModulePath(name: string, options?: ResolveModulePathOptions): string | undefined;
|
|
223
|
+
declare function findResolvedModulePath(paths: string[], options?: ResolveModulePathOptions): string | undefined;
|
|
224
|
+
declare function resolveModulePath(modulePath: string, options?: ResolveModulePathOptions): string | undefined;
|
|
183
225
|
|
|
184
|
-
type
|
|
185
|
-
cwd?: string;
|
|
186
|
-
silent?: boolean;
|
|
187
|
-
shellOptions?: Options;
|
|
188
|
-
} & PackageManagerCommandSpec<K>>;
|
|
226
|
+
type PackageManagers = PackageManager<PackageManagerId>[];
|
|
189
227
|
interface PackageManager<ID extends string = PackageManagerId> {
|
|
190
228
|
id: ID;
|
|
191
229
|
config: PackageManagerConfig;
|
|
@@ -198,30 +236,445 @@ interface PackageManager<ID extends string = PackageManagerId> {
|
|
|
198
236
|
readLockfile: AsyncCacheFn<string | undefined, {
|
|
199
237
|
cwd?: string;
|
|
200
238
|
}>;
|
|
201
|
-
globalVersion: AsyncCacheFn<string | undefined,
|
|
202
|
-
|
|
203
|
-
|
|
239
|
+
globalVersion: AsyncCacheFn<string | undefined, PackageManagerScriptOptions>;
|
|
240
|
+
definePackage: DefinePackageFn;
|
|
241
|
+
defineImportMap: <T extends ImportMap>(importMap: T, options?: {
|
|
242
|
+
/**
|
|
243
|
+
* When enabled, the default behavior is to install packages that are not found.
|
|
244
|
+
* @default true
|
|
245
|
+
*/
|
|
246
|
+
install?: boolean;
|
|
247
|
+
}) => ResolvedImportMapPromise<T>;
|
|
248
|
+
uninstallPackage: (packageNames: string | string[], options?: UninstallPackageOptions) => Promise<void>;
|
|
249
|
+
installPackage: (packageNames: string | string[], options?: PackageManagerScriptOptions<"install">) => Promise<void>;
|
|
204
250
|
}
|
|
205
251
|
|
|
206
|
-
type PackageManagerId = keyof typeof packageManagers;
|
|
207
|
-
declare const packageManagers: {
|
|
208
|
-
pnpm: PackageManager<"pnpm"> | PackageManager<"yarn"> | PackageManager<"bun"> | PackageManager<"npm">;
|
|
209
|
-
yarn: PackageManager<"pnpm"> | PackageManager<"yarn"> | PackageManager<"bun"> | PackageManager<"npm">;
|
|
210
|
-
bun: PackageManager<"pnpm"> | PackageManager<"yarn"> | PackageManager<"bun"> | PackageManager<"npm">;
|
|
211
|
-
npm: PackageManager<"pnpm"> | PackageManager<"yarn"> | PackageManager<"bun"> | PackageManager<"npm">;
|
|
212
|
-
};
|
|
213
|
-
|
|
214
252
|
interface DetectPackageManagerOptions {
|
|
215
|
-
allowed?: SelectionMap<
|
|
253
|
+
allowed?: SelectionMap<Record<PackageManagerId, unknown>>;
|
|
216
254
|
cwd?: string;
|
|
217
255
|
}
|
|
218
|
-
declare function findPackageManager(options?: DetectPackageManagerOptions): Promise<PackageManager<"pnpm"
|
|
219
|
-
declare function findPackageManagerSafely<TAssert extends boolean = true>(options?: DetectPackageManagerOptions & {
|
|
256
|
+
declare function findPackageManager(packageManagers: PackageManagers, options?: DetectPackageManagerOptions): Promise<PackageManager<"pnpm" | "yarn" | "bun" | "npm">>;
|
|
257
|
+
declare function findPackageManagerSafely<TAssert extends boolean = true>(packageManagers: PackageManagers, options?: DetectPackageManagerOptions & {
|
|
220
258
|
assert?: TAssert;
|
|
221
|
-
}): Promise<PackageManager<"pnpm"
|
|
222
|
-
declare function detectPackageManagers(options?: DetectPackageManagerOptions): Promise<
|
|
223
|
-
declare function detectLockfilePackageManagers(options?: DetectPackageManagerOptions): Promise<
|
|
224
|
-
declare function detectGlobalPackageManagers(options?: DetectPackageManagerOptions): Promise<
|
|
225
|
-
declare function filterPackageManagers(filterFn: (packageManager: PackageManager) => Promise<
|
|
259
|
+
}): Promise<PackageManager<"pnpm" | "yarn" | "bun" | "npm"> | undefined>;
|
|
260
|
+
declare function detectPackageManagers(packageManagers: PackageManagers, options?: DetectPackageManagerOptions): Promise<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[]>;
|
|
261
|
+
declare function detectLockfilePackageManagers(packageManagers: PackageManagers, options?: DetectPackageManagerOptions): Promise<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[]>;
|
|
262
|
+
declare function detectGlobalPackageManagers(packageManagers: PackageManagers, options?: DetectPackageManagerOptions): Promise<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[]>;
|
|
263
|
+
declare function filterPackageManagers(packageManagers: PackageManagers, filterFn: (packageManager: PackageManager) => Promise<boolean> | boolean, options?: DetectPackageManagerOptions): Promise<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[]>;
|
|
264
|
+
|
|
265
|
+
type PackageManagerId = (typeof packageManagerConfigs)[number]["id"];
|
|
266
|
+
declare const packageManagerConfigs: (PackageManagerConfig<"pnpm"> | PackageManagerConfig<"yarn"> | PackageManagerConfig<"bun"> | PackageManagerConfig<"npm">)[];
|
|
267
|
+
declare function definePackageManagerClient(options: DetectPackageManagerOptions): {
|
|
268
|
+
configs: PackageManager<"pnpm" | "yarn" | "bun" | "npm">[];
|
|
269
|
+
findPackageManager: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">, [options?: DetectPackageManagerOptions | undefined]>;
|
|
270
|
+
findPackageManagerSafely: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm"> | undefined, [options?: DetectPackageManagerOptions | undefined]>;
|
|
271
|
+
detectPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions | undefined]>;
|
|
272
|
+
detectLockfilePackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions | undefined]>;
|
|
273
|
+
detectGlobalPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions | undefined]>;
|
|
274
|
+
filterPackageManagers: (filterFn: (packageManager: PackageManager) => Promise<boolean> | boolean, options?: DetectPackageManagerOptions) => Promise<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[]>;
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
declare function isPackageDependency(packageName: string | string[]): boolean;
|
|
278
|
+
|
|
279
|
+
interface AliasDefinition {
|
|
280
|
+
resolve: ResolvePathAliasFn;
|
|
281
|
+
subpaths?: Subpath[] | Readonly<Subpath[]>;
|
|
282
|
+
}
|
|
283
|
+
interface Subpath {
|
|
284
|
+
to: string;
|
|
285
|
+
description?: string;
|
|
286
|
+
}
|
|
287
|
+
type AliasDefinitionMap<TAlias extends string = string> = Record<TAlias, AliasDefinition>;
|
|
288
|
+
type AliasMap<TAliases extends AliasDefinitionMap = AliasDefinitionMap> = {
|
|
289
|
+
[K in keyof TAliases]: TAliases[K]["resolve"];
|
|
290
|
+
} & {
|
|
291
|
+
[K in keyof TAliases as `${Extract<K, string>}/${NonNullable<TAliases[K]["subpaths"]>[number]["to"]}`]: TAliases[K]["resolve"];
|
|
292
|
+
};
|
|
293
|
+
type ResolvePathAliasFn = (opts?: {
|
|
294
|
+
cwd?: string;
|
|
295
|
+
}) => string;
|
|
296
|
+
declare function definePathAliases<const T extends AliasDefinitionMap>(aliasDefinitions: T): {
|
|
297
|
+
aliasDefinitions: T;
|
|
298
|
+
aliasMap: AliasMap<T>;
|
|
299
|
+
getFilePath: <TValidate extends boolean = false, TGlob extends boolean = false>(options: PathTo<Extract<keyof T, string> | Extract<keyof { [K in keyof T as `${Extract<K, string>}/${NonNullable<T[K]["subpaths"]>[number]["to"]}`]: T[K]["resolve"]; }, string>> | GetPathOptions<Extract<keyof T, string> | Extract<keyof { [K in keyof T as `${Extract<K, string>}/${NonNullable<T[K]["subpaths"]>[number]["to"]}`]: T[K]["resolve"]; }, string>, TValidate, TGlob>, aliases?: Record<string, string>) => TValidate extends true ? string | undefined : TGlob extends true ? string | undefined : string;
|
|
300
|
+
};
|
|
301
|
+
type PathTo<TBaseDirAlias extends string = string> = string | [baseDir: TBaseDirAlias, subpath?: string];
|
|
302
|
+
interface GetPathOptions<TAlias extends string, TValidate extends boolean = false, TGlob extends boolean = false> {
|
|
303
|
+
to: PathTo<TAlias>;
|
|
304
|
+
startingFrom?: PathTo<TAlias>;
|
|
305
|
+
cwd?: string;
|
|
306
|
+
checkExistence?: TValidate;
|
|
307
|
+
glob?: TGlob;
|
|
308
|
+
}
|
|
309
|
+
declare function getAliasMap<const T extends AliasDefinitionMap>(aliasDefs: T): AliasMap<T>;
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* ### Path Aliases:
|
|
313
|
+
*
|
|
314
|
+
*
|
|
315
|
+
```jsx
|
|
316
|
+
Notation: <user_home>/Projects/<workspace_folder>/apps/<package_folder>/src/
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
* - **`<workspace_folder>`**:
|
|
320
|
+
* > Starting from `cwd`, searches up the directory hierarchy for the workspace root, falling back to the git root if no workspace is detected.
|
|
321
|
+
*
|
|
322
|
+
* - **`<workspace_folder?>`**:
|
|
323
|
+
* > Starting from `cwd`, searches up the directory hierarchy for the workspace root, unlike `<workspace_folder>` it will not fallback to the git root if no workspace is detected.
|
|
324
|
+
* > - *Note that the `?` seen in `<workspace_folder?>` indicates that it has no fallback.*
|
|
325
|
+
*
|
|
326
|
+
* - **`<workspace_folder>/node_modules`**:
|
|
327
|
+
* > Subpath for node modules in the workspace folder.
|
|
328
|
+
* > - Example: `<workspace_folder>/node_modules`
|
|
329
|
+
*
|
|
330
|
+
* - **`<package_folder>`**:
|
|
331
|
+
* > Starting from `cwd`, searches up the directory hierarchy for package.json.
|
|
332
|
+
* > - Example: `<workspace_folder>/apps/package-folder`
|
|
333
|
+
*
|
|
334
|
+
* - **`<package_folder>/node_modules`**:
|
|
335
|
+
* > Subpath for node modules in the package folder.
|
|
336
|
+
*
|
|
337
|
+
* - **`<package_folder>/node_modules/.bin`**:
|
|
338
|
+
* > Subpath for executable scripts in the package folder.
|
|
339
|
+
*
|
|
340
|
+
* - **`<user_home>`**:
|
|
341
|
+
* > Path to the current user's home directory.
|
|
342
|
+
* > - Example: `/Users/username`
|
|
343
|
+
*
|
|
344
|
+
* - **`<user_tmpdir>`**:
|
|
345
|
+
* > Path to the OS tmpdir folder.
|
|
346
|
+
* > - Example: `/var/folders/vb/62qmb9fj2qsxcwhr8tb16krrw0000gn/T`
|
|
347
|
+
*
|
|
348
|
+
* - **`<cwd>`**:
|
|
349
|
+
* > Path to the current working directory.
|
|
350
|
+
*
|
|
351
|
+
* - **`<current_file>`**:
|
|
352
|
+
* > Path to the current file.
|
|
353
|
+
* > - Example: `/Users/username/Projects/monorepo/package-folder/src/utils/getPath.ts`
|
|
354
|
+
*
|
|
355
|
+
* - **`<current-folder>`**:
|
|
356
|
+
* > Path to the current folder.
|
|
357
|
+
* > - Example: `/Users/username/Projects/monorepo/package-folder/src/utils`
|
|
358
|
+
*/
|
|
359
|
+
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> | undefined) => TValidate extends true ? string | undefined : TGlob extends true ? string | undefined : string;
|
|
360
|
+
|
|
361
|
+
type PathAlias = keyof PredefinedPathAliases;
|
|
362
|
+
type PickPathAlias<K extends PathAlias> = K;
|
|
363
|
+
type PredefinedPathAliases = typeof predefinedPathAliases;
|
|
364
|
+
declare const predefinedPathAliases: {
|
|
365
|
+
readonly "<workspace_folder>": {
|
|
366
|
+
readonly resolve: (opts: {
|
|
367
|
+
cwd?: string | undefined;
|
|
368
|
+
} | undefined) => string;
|
|
369
|
+
readonly subpaths: [{
|
|
370
|
+
readonly to: "node_modules";
|
|
371
|
+
}, {
|
|
372
|
+
readonly to: "node_modules/.bin";
|
|
373
|
+
}];
|
|
374
|
+
};
|
|
375
|
+
readonly "<workspace_folder?>": {
|
|
376
|
+
readonly resolve: (opts: {
|
|
377
|
+
cwd?: string | undefined;
|
|
378
|
+
} | undefined) => string;
|
|
379
|
+
readonly subpaths: [{
|
|
380
|
+
readonly to: "node_modules";
|
|
381
|
+
}, {
|
|
382
|
+
readonly to: "node_modules/.bin";
|
|
383
|
+
}];
|
|
384
|
+
};
|
|
385
|
+
readonly "<package_folder>": {
|
|
386
|
+
readonly resolve: (opts: {
|
|
387
|
+
cwd?: string | undefined;
|
|
388
|
+
} | undefined) => string;
|
|
389
|
+
readonly subpaths: [{
|
|
390
|
+
readonly to: "node_modules";
|
|
391
|
+
}, {
|
|
392
|
+
readonly to: "node_modules/.bin";
|
|
393
|
+
}, {
|
|
394
|
+
readonly to: "src";
|
|
395
|
+
}];
|
|
396
|
+
};
|
|
397
|
+
readonly "<gitroot_folder>": {
|
|
398
|
+
readonly resolve: (opts: {
|
|
399
|
+
cwd?: string | undefined;
|
|
400
|
+
} | undefined) => string;
|
|
401
|
+
readonly subpaths: [{
|
|
402
|
+
readonly to: "node_modules";
|
|
403
|
+
}, {
|
|
404
|
+
readonly to: "node_modules/.bin";
|
|
405
|
+
}, {
|
|
406
|
+
readonly to: ".vscode";
|
|
407
|
+
}];
|
|
408
|
+
};
|
|
409
|
+
readonly "<user_home>": {
|
|
410
|
+
readonly resolve: () => string;
|
|
411
|
+
readonly subpaths: any[];
|
|
412
|
+
};
|
|
413
|
+
readonly "<user_tmpdir>": {
|
|
414
|
+
readonly resolve: () => string;
|
|
415
|
+
readonly subpaths: any[];
|
|
416
|
+
};
|
|
417
|
+
readonly "<cwd>": {
|
|
418
|
+
readonly resolve: () => string;
|
|
419
|
+
readonly subpaths: any[];
|
|
420
|
+
};
|
|
421
|
+
readonly "<current_file>": {
|
|
422
|
+
readonly resolve: () => string;
|
|
423
|
+
readonly subpaths: any[];
|
|
424
|
+
};
|
|
425
|
+
readonly "<current_folder>": {
|
|
426
|
+
readonly resolve: () => string;
|
|
427
|
+
readonly subpaths: any[];
|
|
428
|
+
};
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
type PackageName = string;
|
|
432
|
+
interface PackageInfo {
|
|
433
|
+
name: PackageName;
|
|
434
|
+
dirpath: string;
|
|
435
|
+
path: string;
|
|
436
|
+
packageJson: PackageJson;
|
|
437
|
+
}
|
|
438
|
+
type PackageInfoMap = Record<PackageName, PackageInfo>;
|
|
439
|
+
interface PackageDependencyItem {
|
|
440
|
+
name: string;
|
|
441
|
+
type: PackageDependencyType;
|
|
442
|
+
version: string;
|
|
443
|
+
}
|
|
444
|
+
type PackageDependencyType = "dependency" | "devDependency" | "peerDependency" | "optionalDependency";
|
|
445
|
+
interface PackageJson {
|
|
446
|
+
/**
|
|
447
|
+
* The name is what your thing is called.
|
|
448
|
+
* Some rules:
|
|
449
|
+
|
|
450
|
+
- The name must be less than or equal to 214 characters. This includes the scope for scoped packages.
|
|
451
|
+
- The name can’t start with a dot or an underscore.
|
|
452
|
+
- New packages must not have uppercase letters in the name.
|
|
453
|
+
- The name ends up being part of a URL, an argument on the command line, and a folder name. Therefore, the name can’t contain any non-URL-safe characters.
|
|
454
|
+
|
|
455
|
+
*/
|
|
456
|
+
name: PackageName;
|
|
457
|
+
/**
|
|
458
|
+
* Version must be parseable by `node-semver`, which is bundled with npm as a dependency. (`npm install semver` to use it yourself.)
|
|
459
|
+
*/
|
|
460
|
+
version?: string;
|
|
461
|
+
/**
|
|
462
|
+
* Put a description in it. It’s a string. This helps people discover your package, as it’s listed in `npm search`.
|
|
463
|
+
*/
|
|
464
|
+
description?: string;
|
|
465
|
+
/**
|
|
466
|
+
* Put keywords in it. It’s an array of strings. This helps people discover your package as it’s listed in `npm search`.
|
|
467
|
+
*/
|
|
468
|
+
keywords?: string[];
|
|
469
|
+
/**
|
|
470
|
+
* The url to the project homepage.
|
|
471
|
+
*/
|
|
472
|
+
homepage?: string;
|
|
473
|
+
/**
|
|
474
|
+
* The url to your project’s issue tracker and / or the email address to which issues should be reported. These are helpful for people who encounter issues with your package.
|
|
475
|
+
*/
|
|
476
|
+
bugs?: string | {
|
|
477
|
+
url?: string;
|
|
478
|
+
email?: string;
|
|
479
|
+
};
|
|
480
|
+
/**
|
|
481
|
+
* You should specify a license for your package so that people know how they are permitted to use it, and any restrictions you’re placing on it.
|
|
482
|
+
*/
|
|
483
|
+
license?: string;
|
|
484
|
+
/**
|
|
485
|
+
* Specify the place where your code lives. This is helpful for people who want to contribute. If the git repo is on GitHub, then the `npm docs` command will be able to find you.
|
|
486
|
+
* For GitHub, GitHub gist, Bitbucket, or GitLab repositories you can use the same shortcut syntax you use for npm install:
|
|
487
|
+
*/
|
|
488
|
+
repository?: string | {
|
|
489
|
+
type: string;
|
|
490
|
+
url: string;
|
|
491
|
+
/**
|
|
492
|
+
* If the `package.json` for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives:
|
|
493
|
+
*/
|
|
494
|
+
directory?: string;
|
|
495
|
+
};
|
|
496
|
+
scripts?: Record<string, string>;
|
|
497
|
+
/**
|
|
498
|
+
* If you set `"private": true` in your package.json, then npm will refuse to publish it.
|
|
499
|
+
*/
|
|
500
|
+
private?: boolean;
|
|
501
|
+
/**
|
|
502
|
+
* The “author” is one person.
|
|
503
|
+
*/
|
|
504
|
+
author?: PackageJsonPerson;
|
|
505
|
+
/**
|
|
506
|
+
* “contributors” is an array of people.
|
|
507
|
+
*/
|
|
508
|
+
contributors?: PackageJsonPerson[];
|
|
509
|
+
/**
|
|
510
|
+
* The optional `files` field is an array of file patterns that describes the entries to be included when your package is installed as a dependency. File patterns follow a similar syntax to `.gitignore`, but reversed: including a file, directory, or glob pattern (`*`, `**\/*`, and such) will make it so that file is included in the tarball when it’s packed. Omitting the field will make it default to `["*"]`, which means it will include all files.
|
|
511
|
+
*/
|
|
512
|
+
files?: string[];
|
|
513
|
+
/**
|
|
514
|
+
* The main field is a module ID that is the primary entry point to your program. That is, if your package is named `foo`, and a user installs it, and then does `require("foo")`, then your main module’s exports object will be returned.
|
|
515
|
+
* This should be a module ID relative to the root of your package folder.
|
|
516
|
+
* For most modules, it makes the most sense to have a main script and often not much else.
|
|
517
|
+
*/
|
|
518
|
+
main?: string;
|
|
519
|
+
/**
|
|
520
|
+
* If your module is meant to be used client-side the browser field should be used instead of the main field. This is helpful to hint users that it might rely on primitives that aren’t available in Node.js modules. (e.g. window)
|
|
521
|
+
*/
|
|
522
|
+
browser?: string;
|
|
523
|
+
/**
|
|
524
|
+
* A map of command name to local file name. On install, npm will symlink that file into `prefix/bin` for global installs, or `./node_modules/.bin/` for local installs.
|
|
525
|
+
*/
|
|
526
|
+
bin?: string | Record<string, string>;
|
|
527
|
+
/**
|
|
528
|
+
* Specify either a single file or an array of filenames to put in place for the `man` program to find.
|
|
529
|
+
*/
|
|
530
|
+
man?: string | string[];
|
|
531
|
+
/**
|
|
532
|
+
* Dependencies are specified in a simple object that maps a package name to a version range. The version range is a string which has one or more space-separated descriptors. Dependencies can also be identified with a tarball or git URL.
|
|
533
|
+
*/
|
|
534
|
+
dependencies?: Record<string, string>;
|
|
535
|
+
/**
|
|
536
|
+
* If someone is planning on downloading and using your module in their program, then they probably don’t want or need to download and build the external test or documentation framework that you use.
|
|
537
|
+
* In this case, it’s best to map these additional items in a `devDependencies` object.
|
|
538
|
+
*/
|
|
539
|
+
devDependencies?: Record<string, string>;
|
|
540
|
+
/**
|
|
541
|
+
* If a dependency can be used, but you would like npm to proceed if it cannot be found or fails to install, then you may put it in the `optionalDependencies` object. This is a map of package name to version or url, just like the `dependencies` object. The difference is that build failures do not cause installation to fail.
|
|
542
|
+
*/
|
|
543
|
+
optionalDependencies?: Record<string, string>;
|
|
544
|
+
/**
|
|
545
|
+
* In some cases, you want to express the compatibility of your package with a host tool or library, while not necessarily doing a `require` of this host. This is usually referred to as a plugin. Notably, your module may be exposing a specific interface, expected and specified by the host documentation.
|
|
546
|
+
*/
|
|
547
|
+
peerDependencies?: Record<string, string>;
|
|
548
|
+
/**
|
|
549
|
+
* TypeScript typings, typically ending by .d.ts
|
|
550
|
+
*/
|
|
551
|
+
types?: string;
|
|
552
|
+
typings?: string;
|
|
553
|
+
/**
|
|
554
|
+
* Non-Standard Node.js alternate entry-point to main.
|
|
555
|
+
* An initial implementation for supporting CJS packages (from main), and use module for ESM modules.
|
|
556
|
+
*/
|
|
557
|
+
module?: string;
|
|
558
|
+
/**
|
|
559
|
+
* Make main entry-point be loaded as an ESM module, support "export" syntax instead of "require"
|
|
560
|
+
*
|
|
561
|
+
* Docs:
|
|
562
|
+
* - https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_package_json_type_field
|
|
563
|
+
*
|
|
564
|
+
* @default 'commonjs'
|
|
565
|
+
* @since Node.js v14
|
|
566
|
+
*/
|
|
567
|
+
type?: "module" | "commonjs";
|
|
568
|
+
/**
|
|
569
|
+
* Alternate and extensible alternative to "main" entry point.
|
|
570
|
+
*
|
|
571
|
+
* When using `{type: "module"}`, any ESM module file MUST end with `.mjs` extension.
|
|
572
|
+
*
|
|
573
|
+
* Docs:
|
|
574
|
+
* - https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_exports_sugar
|
|
575
|
+
*
|
|
576
|
+
* @default 'commonjs'
|
|
577
|
+
* @since Node.js v14
|
|
578
|
+
*/
|
|
579
|
+
exports?: string | Record<"import" | "require" | "." | "node" | "browser" | string, string | Record<"import" | "require" | string, string>>;
|
|
580
|
+
workspaces?: string[];
|
|
581
|
+
[key: string]: any;
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* A “person” is an object with a “name” field and optionally “url” and “email”. Or you can shorten that all into a single string, and npm will parse it for you.
|
|
585
|
+
*/
|
|
586
|
+
type PackageJsonPerson = string | {
|
|
587
|
+
name: string;
|
|
588
|
+
email?: string;
|
|
589
|
+
url?: string;
|
|
590
|
+
};
|
|
591
|
+
|
|
592
|
+
interface FindDependencyInPackageJsonOptions {
|
|
593
|
+
name: string;
|
|
594
|
+
type?: PackageDependencyType | AllowedDependencyTypesOption;
|
|
595
|
+
}
|
|
596
|
+
type AllowedDependencyTypesOption = SelectionMap<Record<PackageDependencyType, any>>;
|
|
597
|
+
|
|
598
|
+
type ProjectFolderTypeOption = WorkspaceFolderTypeOption | PackageFolderTypeOption | GitRootFolderTypeOption | PackageNameFolderTypeOption;
|
|
599
|
+
type PackageFolderTypeOption = PickPathAlias<"<package_folder>">;
|
|
600
|
+
type GitRootFolderTypeOption = PickPathAlias<"<gitroot_folder>">;
|
|
601
|
+
type PackageNameFolderTypeOption = RequireExactlyOne<{
|
|
602
|
+
packageName: PackageName;
|
|
603
|
+
}>;
|
|
604
|
+
type WorkspaceFolderTypeOption = PickPathAlias<"<workspace_folder>"> | RequireExactlyOne<{
|
|
605
|
+
"<workspace_folder>": Pick<GetWorkspaceFolderOptions, "fallbackToGitRoot" | "throwIfNotFound">;
|
|
606
|
+
}>;
|
|
607
|
+
|
|
608
|
+
declare function getFolderByPackageName(name: PackageName, options?: PathOptions): string | undefined;
|
|
609
|
+
|
|
610
|
+
declare function getGitRootFolder(options?: PathOptions): string | undefined;
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
*
|
|
614
|
+
* Finds the nearest `package.json` directory, starting from `cwd`
|
|
615
|
+
*
|
|
616
|
+
*/
|
|
617
|
+
declare function getPackageFolder(options?: {
|
|
618
|
+
cwd?: string;
|
|
619
|
+
}): string;
|
|
620
|
+
|
|
621
|
+
interface GetWorkspaceFolderOptions<$Validate extends boolean = true> extends PathOptions {
|
|
622
|
+
/** @default true */
|
|
623
|
+
fallbackToGitRoot?: boolean;
|
|
624
|
+
/** @default true */
|
|
625
|
+
throwIfNotFound?: $Validate;
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Starting from cwd, searches up the directory hierarchy for the workspace root,
|
|
629
|
+
* falling back to the git root if no workspace is detected.
|
|
630
|
+
*/
|
|
631
|
+
declare function getWorkspaceFolder<$ThrowIfNotFound extends boolean = true>(options?: GetWorkspaceFolderOptions<$ThrowIfNotFound>): $ThrowIfNotFound extends true ? string : string | undefined;
|
|
632
|
+
|
|
633
|
+
declare function getWorkspacePackageInfoMap(options?: PathOptions & {
|
|
634
|
+
includeRoot?: boolean;
|
|
635
|
+
}): PackageInfoMap;
|
|
636
|
+
|
|
637
|
+
interface GetPackageInfoListOptions {
|
|
638
|
+
cwd?: string;
|
|
639
|
+
includeRoot?: boolean;
|
|
640
|
+
}
|
|
641
|
+
declare function getWorkspacePackageInfoList(options?: GetPackageInfoListOptions): (PackageInfo | {
|
|
642
|
+
name: string;
|
|
643
|
+
path: string;
|
|
644
|
+
packageJson: WST.PackageInfo;
|
|
645
|
+
})[];
|
|
646
|
+
|
|
647
|
+
declare function getWorkspacePackageNames(options?: GetPackageInfoListOptions): string[];
|
|
648
|
+
|
|
649
|
+
declare const workspace: {
|
|
650
|
+
packageNames: typeof getWorkspacePackageNames;
|
|
651
|
+
packageGraph: typeof getWorkspacePackageInfoMap;
|
|
652
|
+
packageList: typeof getWorkspacePackageInfoList;
|
|
653
|
+
workspaceRootDir: typeof getWorkspaceFolder;
|
|
654
|
+
getProject: (source: ProjectFolderTypeOption, options?: PathOptions | undefined) => {
|
|
655
|
+
packageJson: PackageJson | undefined;
|
|
656
|
+
packageJsonPath: string | undefined;
|
|
657
|
+
packageName: string | undefined;
|
|
658
|
+
projectDir: string | undefined;
|
|
659
|
+
findPackageManager: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">, [options?: DetectPackageManagerOptions | undefined]>;
|
|
660
|
+
detectPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions | undefined]>;
|
|
661
|
+
detectGlobalPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions | undefined]>;
|
|
662
|
+
detectLockfilePackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions | undefined]>;
|
|
663
|
+
tsconfig: {
|
|
664
|
+
readonly paths: string[];
|
|
665
|
+
};
|
|
666
|
+
gitignore: {
|
|
667
|
+
readonly data: parse_gitignore.ParsedGitignoreObject;
|
|
668
|
+
readonly patterns: string[];
|
|
669
|
+
};
|
|
670
|
+
filterPackageManagers: (filterFn: (packageManager: PackageManager<"pnpm" | "yarn" | "bun" | "npm">) => boolean | Promise<boolean>, options?: DetectPackageManagerOptions | undefined) => Promise<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[]>;
|
|
671
|
+
getPackageJson: () => PackageJson;
|
|
672
|
+
findDependencyInPackageJson: (options: string | FindDependencyInPackageJsonOptions) => {
|
|
673
|
+
firstMatch: PackageDependencyItem | undefined;
|
|
674
|
+
matches: PackageDependencyItem[];
|
|
675
|
+
} | undefined;
|
|
676
|
+
isDependencyInPackageJson: (options: string | FindDependencyInPackageJsonOptions) => boolean;
|
|
677
|
+
};
|
|
678
|
+
};
|
|
226
679
|
|
|
227
|
-
export { type AsyncCacheFn, type Awaitable, type Entry, type EntryOf, type FromEntries, type ImportList, type ImportMap, type ImportOption, type
|
|
680
|
+
export { type AliasDefinition, type AliasDefinitionMap, type AliasMap, type AsyncCacheFn, type Awaitable, type DefinePackageFn, type DetectPackageManagerOptions, type Entry, type EntryOf, type EnumToLiteral, type ExtractImportOptionModule, type FromEntries, type Func, type GetPathOptions, type GetWorkspaceFolderOptions, type ImportCallback, type ImportList, type ImportMap, type ImportMapFn, type ImportMapOptions, type ImportModuleData, type ImportModuleFn, type ImportOption, type ImportOptionData, type ImportPackageData, type ImporterOptions, type InstallPackageOptions, type InstallerFn, type IsExactBoolean, type IsUnion, type KeyOf, type KeyOfValue, type MergeObject, type Module, type NoInfer, type OmitByValue, type OmitIndexSignature, type OmitNever, type PackageManagerCommandName, type PackageManagerCommandSpec, type PackageManagerCommands, type PackageManagerConfig, type PackageManagerId, type PackageManagerScriptOptions, type PathAlias, type PathOptions, type PathTo, type PickByValue, type PickKeyOf, type PickPathAlias, type PredefinedPathAliases, type RequireExactlyOne, type ResolveModulePathOptions, type ResolvedImportList, type ResolvedImportListPromise, type ResolvedImportMap, type ResolvedImportMapPromise, type ResolvedImportOption, type ResolvedPromise, type Select, type SelectionMap, type StringLiteral, type UninstallPackageOptions, type ValueOf, type __, _dirname, _filename, definePackage, definePackageManagerClient, definePathAliases, detectGlobalPackageManagers, detectLockfilePackageManagers, detectPackageManagers, filterPackageManagers, findPackageManager, findPackageManagerSafely, findResolvedModulePath, getAliasMap, getFolderByPackageName, getGitRootFolder, getPackageFolder, getPath, getWorkspaceFolder, importMap, importer, isPackageDependency, isPackageModuleFound, packageManagerConfigs, predefinedPathAliases, resolveModule, resolveModulePath, resolvePackageModulePath, workspace };
|