package-management 0.0.4 → 0.0.7

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 CHANGED
@@ -300,14 +300,13 @@ function getWorkspaceFolder(options) {
300
300
  fallbackToGitRoot = true,
301
301
  throwIfNotFound = true
302
302
  } = options ?? {};
303
- const getFolder = fallbackToGitRoot ? WST__namespace.getWorkspaceRoot : WST__namespace.getWorkspaceRoot;
303
+ const getFolder = fallbackToGitRoot ? WST__namespace.findProjectRoot : WST__namespace.getWorkspaceRoot;
304
304
  const folder = getFolder(cwd);
305
305
  if (folder === void 0 && throwIfNotFound) {
306
306
  throw new Error(`Could not find workspace folder`);
307
307
  }
308
308
  return folder;
309
309
  }
310
- getWorkspaceFolder();
311
310
 
312
311
  function getPackageFolder(options) {
313
312
  return WST__namespace.findPackageRoot(options?.cwd ?? process__default.cwd());
@@ -955,7 +954,6 @@ const predefinedPathAliases = {
955
954
  };
956
955
 
957
956
  const getPath = definePathAliases(predefinedPathAliases).getFilePath;
958
- getPath(["<workspace_folder>/node_modules/.bin"]);
959
957
 
960
958
  function getFolderByPackageName(name, options) {
961
959
  const infoMap = getWorkspacePackageInfoMap({ ...options, includeRoot: true });
package/dist/index.d.cts CHANGED
@@ -253,25 +253,25 @@ interface DetectPackageManagerOptions {
253
253
  allowed?: SelectionMap<Record<PackageManagerId, unknown>>;
254
254
  cwd?: string;
255
255
  }
256
- declare function findPackageManager(packageManagers: PackageManagers, options?: DetectPackageManagerOptions): Promise<PackageManager<"pnpm" | "yarn" | "bun" | "npm">>;
256
+ declare function findPackageManager(packageManagers: PackageManagers, options?: DetectPackageManagerOptions): Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun">>;
257
257
  declare function findPackageManagerSafely<TAssert extends boolean = true>(packageManagers: PackageManagers, options?: DetectPackageManagerOptions & {
258
258
  assert?: TAssert;
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">[]>;
259
+ }): Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun"> | undefined>;
260
+ declare function detectPackageManagers(packageManagers: PackageManagers, options?: DetectPackageManagerOptions): Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[]>;
261
+ declare function detectLockfilePackageManagers(packageManagers: PackageManagers, options?: DetectPackageManagerOptions): Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[]>;
262
+ declare function detectGlobalPackageManagers(packageManagers: PackageManagers, options?: DetectPackageManagerOptions): Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[]>;
263
+ declare function filterPackageManagers(packageManagers: PackageManagers, filterFn: (packageManager: PackageManager) => Promise<boolean> | boolean, options?: DetectPackageManagerOptions): Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[]>;
264
264
 
265
265
  type PackageManagerId = (typeof packageManagerConfigs)[number]["id"];
266
266
  declare const packageManagerConfigs: (PackageManagerConfig<"pnpm"> | PackageManagerConfig<"yarn"> | PackageManagerConfig<"bun"> | PackageManagerConfig<"npm">)[];
267
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">[]>;
268
+ configs: PackageManager<"yarn" | "pnpm" | "npm" | "bun">[];
269
+ findPackageManager: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">, [options?: DetectPackageManagerOptions | undefined]>;
270
+ findPackageManagerSafely: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun"> | undefined, [options?: DetectPackageManagerOptions | undefined]>;
271
+ detectPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
272
+ detectLockfilePackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
273
+ detectGlobalPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
274
+ filterPackageManagers: (filterFn: (packageManager: PackageManager) => Promise<boolean> | boolean, options?: DetectPackageManagerOptions) => Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[]>;
275
275
  };
276
276
 
277
277
  declare function isPackageDependency(packageName: string | string[]): boolean;
@@ -627,10 +627,10 @@ declare const project: (source: ProjectFolderTypeOption, options?: PathOptions |
627
627
  packageJsonPath: string | undefined;
628
628
  packageName: string | undefined;
629
629
  projectDir: string | undefined;
630
- findPackageManager: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">, [options?: DetectPackageManagerOptions | undefined]>;
631
- detectPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions | undefined]>;
632
- detectGlobalPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions | undefined]>;
633
- detectLockfilePackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions | undefined]>;
630
+ findPackageManager: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">, [options?: DetectPackageManagerOptions | undefined]>;
631
+ detectPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
632
+ detectGlobalPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
633
+ detectLockfilePackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
634
634
  tsconfig: {
635
635
  readonly paths: string[];
636
636
  };
@@ -638,7 +638,7 @@ declare const project: (source: ProjectFolderTypeOption, options?: PathOptions |
638
638
  readonly data: parse_gitignore.ParsedGitignoreObject;
639
639
  readonly patterns: string[];
640
640
  };
641
- filterPackageManagers: (filterFn: (packageManager: PackageManager<"pnpm" | "yarn" | "bun" | "npm">) => boolean | Promise<boolean>, options?: DetectPackageManagerOptions | undefined) => Promise<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[]>;
641
+ filterPackageManagers: (filterFn: (packageManager: PackageManager<"yarn" | "pnpm" | "npm" | "bun">) => boolean | Promise<boolean>, options?: DetectPackageManagerOptions | undefined) => Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[]>;
642
642
  getPackageJson: () => PackageJson;
643
643
  findDependencyInPackageJson: (options: string | FindDependencyInPackageJsonOptions) => {
644
644
  firstMatch: PackageDependencyItem | undefined;
@@ -698,10 +698,10 @@ declare const workspace: {
698
698
  packageJsonPath: string | undefined;
699
699
  packageName: string | undefined;
700
700
  projectDir: string | undefined;
701
- findPackageManager: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">, [options?: DetectPackageManagerOptions | undefined]>;
702
- detectPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions | undefined]>;
703
- detectGlobalPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions | undefined]>;
704
- detectLockfilePackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions | undefined]>;
701
+ findPackageManager: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">, [options?: DetectPackageManagerOptions | undefined]>;
702
+ detectPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
703
+ detectGlobalPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
704
+ detectLockfilePackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
705
705
  tsconfig: {
706
706
  readonly paths: string[];
707
707
  };
@@ -709,7 +709,7 @@ declare const workspace: {
709
709
  readonly data: parse_gitignore.ParsedGitignoreObject;
710
710
  readonly patterns: string[];
711
711
  };
712
- filterPackageManagers: (filterFn: (packageManager: PackageManager<"pnpm" | "yarn" | "bun" | "npm">) => boolean | Promise<boolean>, options?: DetectPackageManagerOptions | undefined) => Promise<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[]>;
712
+ filterPackageManagers: (filterFn: (packageManager: PackageManager<"yarn" | "pnpm" | "npm" | "bun">) => boolean | Promise<boolean>, options?: DetectPackageManagerOptions | undefined) => Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[]>;
713
713
  getPackageJson: () => PackageJson;
714
714
  findDependencyInPackageJson: (options: string | FindDependencyInPackageJsonOptions) => {
715
715
  firstMatch: PackageDependencyItem | undefined;
package/dist/index.d.mts CHANGED
@@ -253,25 +253,25 @@ interface DetectPackageManagerOptions {
253
253
  allowed?: SelectionMap<Record<PackageManagerId, unknown>>;
254
254
  cwd?: string;
255
255
  }
256
- declare function findPackageManager(packageManagers: PackageManagers, options?: DetectPackageManagerOptions): Promise<PackageManager<"pnpm" | "yarn" | "bun" | "npm">>;
256
+ declare function findPackageManager(packageManagers: PackageManagers, options?: DetectPackageManagerOptions): Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun">>;
257
257
  declare function findPackageManagerSafely<TAssert extends boolean = true>(packageManagers: PackageManagers, options?: DetectPackageManagerOptions & {
258
258
  assert?: TAssert;
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">[]>;
259
+ }): Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun"> | undefined>;
260
+ declare function detectPackageManagers(packageManagers: PackageManagers, options?: DetectPackageManagerOptions): Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[]>;
261
+ declare function detectLockfilePackageManagers(packageManagers: PackageManagers, options?: DetectPackageManagerOptions): Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[]>;
262
+ declare function detectGlobalPackageManagers(packageManagers: PackageManagers, options?: DetectPackageManagerOptions): Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[]>;
263
+ declare function filterPackageManagers(packageManagers: PackageManagers, filterFn: (packageManager: PackageManager) => Promise<boolean> | boolean, options?: DetectPackageManagerOptions): Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[]>;
264
264
 
265
265
  type PackageManagerId = (typeof packageManagerConfigs)[number]["id"];
266
266
  declare const packageManagerConfigs: (PackageManagerConfig<"pnpm"> | PackageManagerConfig<"yarn"> | PackageManagerConfig<"bun"> | PackageManagerConfig<"npm">)[];
267
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">[]>;
268
+ configs: PackageManager<"yarn" | "pnpm" | "npm" | "bun">[];
269
+ findPackageManager: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">, [options?: DetectPackageManagerOptions | undefined]>;
270
+ findPackageManagerSafely: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun"> | undefined, [options?: DetectPackageManagerOptions | undefined]>;
271
+ detectPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
272
+ detectLockfilePackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
273
+ detectGlobalPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
274
+ filterPackageManagers: (filterFn: (packageManager: PackageManager) => Promise<boolean> | boolean, options?: DetectPackageManagerOptions) => Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[]>;
275
275
  };
276
276
 
277
277
  declare function isPackageDependency(packageName: string | string[]): boolean;
@@ -627,10 +627,10 @@ declare const project: (source: ProjectFolderTypeOption, options?: PathOptions |
627
627
  packageJsonPath: string | undefined;
628
628
  packageName: string | undefined;
629
629
  projectDir: string | undefined;
630
- findPackageManager: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">, [options?: DetectPackageManagerOptions | undefined]>;
631
- detectPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions | undefined]>;
632
- detectGlobalPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions | undefined]>;
633
- detectLockfilePackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions | undefined]>;
630
+ findPackageManager: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">, [options?: DetectPackageManagerOptions | undefined]>;
631
+ detectPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
632
+ detectGlobalPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
633
+ detectLockfilePackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
634
634
  tsconfig: {
635
635
  readonly paths: string[];
636
636
  };
@@ -638,7 +638,7 @@ declare const project: (source: ProjectFolderTypeOption, options?: PathOptions |
638
638
  readonly data: parse_gitignore.ParsedGitignoreObject;
639
639
  readonly patterns: string[];
640
640
  };
641
- filterPackageManagers: (filterFn: (packageManager: PackageManager<"pnpm" | "yarn" | "bun" | "npm">) => boolean | Promise<boolean>, options?: DetectPackageManagerOptions | undefined) => Promise<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[]>;
641
+ filterPackageManagers: (filterFn: (packageManager: PackageManager<"yarn" | "pnpm" | "npm" | "bun">) => boolean | Promise<boolean>, options?: DetectPackageManagerOptions | undefined) => Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[]>;
642
642
  getPackageJson: () => PackageJson;
643
643
  findDependencyInPackageJson: (options: string | FindDependencyInPackageJsonOptions) => {
644
644
  firstMatch: PackageDependencyItem | undefined;
@@ -698,10 +698,10 @@ declare const workspace: {
698
698
  packageJsonPath: string | undefined;
699
699
  packageName: string | undefined;
700
700
  projectDir: string | undefined;
701
- findPackageManager: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">, [options?: DetectPackageManagerOptions | undefined]>;
702
- detectPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions | undefined]>;
703
- detectGlobalPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions | undefined]>;
704
- detectLockfilePackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions | undefined]>;
701
+ findPackageManager: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">, [options?: DetectPackageManagerOptions | undefined]>;
702
+ detectPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
703
+ detectGlobalPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
704
+ detectLockfilePackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
705
705
  tsconfig: {
706
706
  readonly paths: string[];
707
707
  };
@@ -709,7 +709,7 @@ declare const workspace: {
709
709
  readonly data: parse_gitignore.ParsedGitignoreObject;
710
710
  readonly patterns: string[];
711
711
  };
712
- filterPackageManagers: (filterFn: (packageManager: PackageManager<"pnpm" | "yarn" | "bun" | "npm">) => boolean | Promise<boolean>, options?: DetectPackageManagerOptions | undefined) => Promise<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[]>;
712
+ filterPackageManagers: (filterFn: (packageManager: PackageManager<"yarn" | "pnpm" | "npm" | "bun">) => boolean | Promise<boolean>, options?: DetectPackageManagerOptions | undefined) => Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[]>;
713
713
  getPackageJson: () => PackageJson;
714
714
  findDependencyInPackageJson: (options: string | FindDependencyInPackageJsonOptions) => {
715
715
  firstMatch: PackageDependencyItem | undefined;
package/dist/index.d.ts CHANGED
@@ -253,25 +253,25 @@ interface DetectPackageManagerOptions {
253
253
  allowed?: SelectionMap<Record<PackageManagerId, unknown>>;
254
254
  cwd?: string;
255
255
  }
256
- declare function findPackageManager(packageManagers: PackageManagers, options?: DetectPackageManagerOptions): Promise<PackageManager<"pnpm" | "yarn" | "bun" | "npm">>;
256
+ declare function findPackageManager(packageManagers: PackageManagers, options?: DetectPackageManagerOptions): Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun">>;
257
257
  declare function findPackageManagerSafely<TAssert extends boolean = true>(packageManagers: PackageManagers, options?: DetectPackageManagerOptions & {
258
258
  assert?: TAssert;
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">[]>;
259
+ }): Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun"> | undefined>;
260
+ declare function detectPackageManagers(packageManagers: PackageManagers, options?: DetectPackageManagerOptions): Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[]>;
261
+ declare function detectLockfilePackageManagers(packageManagers: PackageManagers, options?: DetectPackageManagerOptions): Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[]>;
262
+ declare function detectGlobalPackageManagers(packageManagers: PackageManagers, options?: DetectPackageManagerOptions): Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[]>;
263
+ declare function filterPackageManagers(packageManagers: PackageManagers, filterFn: (packageManager: PackageManager) => Promise<boolean> | boolean, options?: DetectPackageManagerOptions): Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[]>;
264
264
 
265
265
  type PackageManagerId = (typeof packageManagerConfigs)[number]["id"];
266
266
  declare const packageManagerConfigs: (PackageManagerConfig<"pnpm"> | PackageManagerConfig<"yarn"> | PackageManagerConfig<"bun"> | PackageManagerConfig<"npm">)[];
267
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">[]>;
268
+ configs: PackageManager<"yarn" | "pnpm" | "npm" | "bun">[];
269
+ findPackageManager: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">, [options?: DetectPackageManagerOptions | undefined]>;
270
+ findPackageManagerSafely: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun"> | undefined, [options?: DetectPackageManagerOptions | undefined]>;
271
+ detectPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
272
+ detectLockfilePackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
273
+ detectGlobalPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
274
+ filterPackageManagers: (filterFn: (packageManager: PackageManager) => Promise<boolean> | boolean, options?: DetectPackageManagerOptions) => Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[]>;
275
275
  };
276
276
 
277
277
  declare function isPackageDependency(packageName: string | string[]): boolean;
@@ -627,10 +627,10 @@ declare const project: (source: ProjectFolderTypeOption, options?: PathOptions |
627
627
  packageJsonPath: string | undefined;
628
628
  packageName: string | undefined;
629
629
  projectDir: string | undefined;
630
- findPackageManager: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">, [options?: DetectPackageManagerOptions | undefined]>;
631
- detectPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions | undefined]>;
632
- detectGlobalPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions | undefined]>;
633
- detectLockfilePackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions | undefined]>;
630
+ findPackageManager: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">, [options?: DetectPackageManagerOptions | undefined]>;
631
+ detectPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
632
+ detectGlobalPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
633
+ detectLockfilePackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
634
634
  tsconfig: {
635
635
  readonly paths: string[];
636
636
  };
@@ -638,7 +638,7 @@ declare const project: (source: ProjectFolderTypeOption, options?: PathOptions |
638
638
  readonly data: parse_gitignore.ParsedGitignoreObject;
639
639
  readonly patterns: string[];
640
640
  };
641
- filterPackageManagers: (filterFn: (packageManager: PackageManager<"pnpm" | "yarn" | "bun" | "npm">) => boolean | Promise<boolean>, options?: DetectPackageManagerOptions | undefined) => Promise<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[]>;
641
+ filterPackageManagers: (filterFn: (packageManager: PackageManager<"yarn" | "pnpm" | "npm" | "bun">) => boolean | Promise<boolean>, options?: DetectPackageManagerOptions | undefined) => Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[]>;
642
642
  getPackageJson: () => PackageJson;
643
643
  findDependencyInPackageJson: (options: string | FindDependencyInPackageJsonOptions) => {
644
644
  firstMatch: PackageDependencyItem | undefined;
@@ -698,10 +698,10 @@ declare const workspace: {
698
698
  packageJsonPath: string | undefined;
699
699
  packageName: string | undefined;
700
700
  projectDir: string | undefined;
701
- findPackageManager: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">, [options?: DetectPackageManagerOptions | undefined]>;
702
- detectPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions | undefined]>;
703
- detectGlobalPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions | undefined]>;
704
- detectLockfilePackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[], [options?: DetectPackageManagerOptions | undefined]>;
701
+ findPackageManager: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">, [options?: DetectPackageManagerOptions | undefined]>;
702
+ detectPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
703
+ detectGlobalPackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
704
+ detectLockfilePackageManagers: async_cache_fn_index.AsyncCacheFn<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[], [options?: DetectPackageManagerOptions | undefined]>;
705
705
  tsconfig: {
706
706
  readonly paths: string[];
707
707
  };
@@ -709,7 +709,7 @@ declare const workspace: {
709
709
  readonly data: parse_gitignore.ParsedGitignoreObject;
710
710
  readonly patterns: string[];
711
711
  };
712
- filterPackageManagers: (filterFn: (packageManager: PackageManager<"pnpm" | "yarn" | "bun" | "npm">) => boolean | Promise<boolean>, options?: DetectPackageManagerOptions | undefined) => Promise<PackageManager<"pnpm" | "yarn" | "bun" | "npm">[]>;
712
+ filterPackageManagers: (filterFn: (packageManager: PackageManager<"yarn" | "pnpm" | "npm" | "bun">) => boolean | Promise<boolean>, options?: DetectPackageManagerOptions | undefined) => Promise<PackageManager<"yarn" | "pnpm" | "npm" | "bun">[]>;
713
713
  getPackageJson: () => PackageJson;
714
714
  findDependencyInPackageJson: (options: string | FindDependencyInPackageJsonOptions) => {
715
715
  firstMatch: PackageDependencyItem | undefined;
package/dist/index.mjs CHANGED
@@ -276,14 +276,13 @@ function getWorkspaceFolder(options) {
276
276
  fallbackToGitRoot = true,
277
277
  throwIfNotFound = true
278
278
  } = options ?? {};
279
- const getFolder = fallbackToGitRoot ? WST.getWorkspaceRoot : WST.getWorkspaceRoot;
279
+ const getFolder = fallbackToGitRoot ? WST.findProjectRoot : WST.getWorkspaceRoot;
280
280
  const folder = getFolder(cwd);
281
281
  if (folder === void 0 && throwIfNotFound) {
282
282
  throw new Error(`Could not find workspace folder`);
283
283
  }
284
284
  return folder;
285
285
  }
286
- getWorkspaceFolder();
287
286
 
288
287
  function getPackageFolder(options) {
289
288
  return WST.findPackageRoot(options?.cwd ?? process.cwd());
@@ -931,7 +930,6 @@ const predefinedPathAliases = {
931
930
  };
932
931
 
933
932
  const getPath = definePathAliases(predefinedPathAliases).getFilePath;
934
- getPath(["<workspace_folder>/node_modules/.bin"]);
935
933
 
936
934
  function getFolderByPackageName(name, options) {
937
935
  const infoMap = getWorkspacePackageInfoMap({ ...options, includeRoot: true });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "package-management",
3
3
  "description": "Simple type-safe utilities for programatically installing and importing packages",
4
- "version": "0.0.4",
4
+ "version": "0.0.7",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "files": [
@@ -50,6 +50,7 @@
50
50
  "find-up": "^7.0.0",
51
51
  "get-current-line": "^7.4.0",
52
52
  "globby": "^14.0.0",
53
+ "is-odd": "^3.0.1",
53
54
  "jsonc-parser": "^3.2.1",
54
55
  "local-pkg": "^0.5.0",
55
56
  "lru-cache": "^10.2.0",