dependency-owners 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -2,9 +2,9 @@
2
2
  import { buildApplication, buildCommand, run, } from '@stricli/core';
3
3
  import { createRequire } from 'node:module';
4
4
  import path from 'node:path';
5
- import { dependencyOwners } from './index.js';
6
- import { getErrorMessage } from './utils/message.js';
7
- import { getUnownedDependencies } from './utils/owners.js';
5
+ import { dependencyOwners } from "./index.js";
6
+ import { getErrorMessage } from "./utils/message.js";
7
+ import { getUnownedDependencies } from "./utils/owners.js";
8
8
  const { name, version, description } = createRequire(import.meta.url)('../package.json');
9
9
  function cwdParser(rawInput) {
10
10
  return this.path.join(this.process.cwd(), rawInput);
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type DependencyLoader } from './utils/loader.js';
1
+ import { type DependencyLoader } from './utils/loader.ts';
2
2
  /**
3
3
  * Options for the dependency owners lookup.
4
4
  */
@@ -25,4 +25,4 @@ export interface DependencyOwnersOptions {
25
25
  * @param {Options} options - The options for the dependency owners lookup.
26
26
  * @returns {Promise<Record<string, string[]>>} A mapping of dependency owners for the specified dependencies.
27
27
  */
28
- export declare function dependencyOwners(options: DependencyOwnersOptions): Promise<Record<string, string[]>>;
28
+ export declare function dependencyOwners(options?: DependencyOwnersOptions): Promise<Record<string, string[]>>;
package/dist/index.js CHANGED
@@ -1,20 +1,22 @@
1
1
  import * as PackageJsonLoader from '@dependency-owners/package-json-loader';
2
2
  import path from 'node:path';
3
- import { getOwners, getOwnersMapping } from './utils/owners.js';
4
- import { resolveDependencyLoader, } from './utils/loader.js';
3
+ import { getOwners, getOwnersMapping } from "./utils/owners.js";
4
+ import { resolveDependencyLoader, } from "./utils/loader.js";
5
5
  /**
6
6
  * Get the owners of the specified dependencies.
7
7
  * @param {Options} options - The options for the dependency owners lookup.
8
8
  * @returns {Promise<Record<string, string[]>>} A mapping of dependency owners for the specified dependencies.
9
9
  */
10
10
  export async function dependencyOwners(options) {
11
- const { dependencies = [], loader = PackageJsonLoader, dependencyFile = path.join(process.cwd(), 'package.json'), configFile = path.join(process.cwd(), 'dependency-owners.json'), } = options;
11
+ const { dependencies = [], loader = PackageJsonLoader, dependencyFile = path.join(process.cwd(), 'package.json'), configFile = path.join(process.cwd(), 'dependency-owners.json'), } = options || {};
12
12
  const resolvedLoader = await resolveDependencyLoader(loader, dependencyFile);
13
13
  if (!resolvedLoader) {
14
14
  throw new Error(`No loader found for file: ${dependencyFile}`);
15
15
  }
16
16
  const ownersMapping = getOwnersMapping(configFile);
17
17
  const resolvedDependencies = await resolvedLoader.load(dependencyFile);
18
- const filteredDependencies = resolvedDependencies.filter((dep) => dependencies.length === 0 || dependencies.includes(dep));
18
+ const filteredDependencies = resolvedDependencies
19
+ .map((dep) => (typeof dep === 'string' ? dep : dep.name))
20
+ .filter((dep) => dependencies.length === 0 || dependencies.includes(dep));
19
21
  return getOwners(filteredDependencies, ownersMapping);
20
22
  }
package/dist/loader.d.ts CHANGED
@@ -1 +1 @@
1
- export type { DependencyLoader } from './utils/loader.js';
1
+ export type { DependencyLoader } from './utils/loader.ts';
@@ -1,3 +1,16 @@
1
+ /**
2
+ * Type representing a dependency.
3
+ */
4
+ export interface Dependency {
5
+ /**
6
+ * The name of the dependency.
7
+ */
8
+ name: string;
9
+ /**
10
+ * The version of the dependency.
11
+ */
12
+ version: string;
13
+ }
1
14
  /**
2
15
  * Interface for loading dependencies from various file types.
3
16
  */
@@ -11,9 +24,9 @@ export interface DependencyLoader {
11
24
  /**
12
25
  * Load the dependencies from the specified file.
13
26
  * @param {string} filePath The path to the file to load dependencies from.
14
- * @returns {string[]} The list of loaded dependencies.
27
+ * @returns {string[] | Dependency[]} The list of loaded dependencies.
15
28
  */
16
- load(filePath: string): Promise<string[]>;
29
+ load(filePath: string): Promise<string[] | Dependency[]>;
17
30
  }
18
31
  /**
19
32
  * Resolve a dependency loader for a specific file.
@@ -1,3 +1,11 @@
1
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
+ });
6
+ }
7
+ return path;
8
+ };
1
9
  import path from 'node:path';
2
10
  /**
3
11
  * Import a dependency loader by name.
@@ -8,14 +16,14 @@ async function importDependencyLoader(loaderName) {
8
16
  let loaderModule;
9
17
  // Try importing from an installed dependency/absolute path
10
18
  try {
11
- loaderModule = await import(loaderName);
19
+ loaderModule = await import(__rewriteRelativeImportExtension(loaderName));
12
20
  }
13
21
  catch {
14
22
  // no-op
15
23
  }
16
24
  // Try import from relative path
17
25
  try {
18
- loaderModule = await import(path.join(process.cwd(), loaderName));
26
+ loaderModule = await import(__rewriteRelativeImportExtension(path.join(process.cwd(), loaderName)));
19
27
  }
20
28
  catch {
21
29
  // no-op
package/dist/utils.d.ts CHANGED
@@ -1 +1 @@
1
- export { getUnownedDependencies } from './utils/owners.js';
1
+ export { getUnownedDependencies } from './utils/owners.ts';
package/dist/utils.js CHANGED
@@ -1 +1 @@
1
- export { getUnownedDependencies } from './utils/owners.js';
1
+ export { getUnownedDependencies } from "./utils/owners.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dependency-owners",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Determine ownership of dependencies in a project",
5
5
  "author": "Kirk Eaton <contact@kirkeaton.ca>",
6
6
  "bin": "./dist/cli.js",
@@ -10,13 +10,12 @@
10
10
  },
11
11
  "devDependencies": {
12
12
  "@kirkeaton/prettier-config": "1.0.5",
13
- "@kirkeaton/semantic-release-config": "1.0.4",
14
- "@kirkeaton/tsconfig": "1.0.3",
13
+ "@kirkeaton/semantic-release-config": "1.1.0",
14
+ "@kirkeaton/tsconfig": "2.1.0",
15
15
  "@types/node": "24.3.0",
16
16
  "fs-fixture": "2.8.1",
17
17
  "prettier": "3.6.2",
18
18
  "semantic-release": "24.2.7",
19
- "tsx": "4.20.4",
20
19
  "typescript": "5.9.2"
21
20
  },
22
21
  "engines": {
@@ -57,7 +56,7 @@
57
56
  "format": "prettier \"**/*.{js,json,md,ts}\" --write",
58
57
  "lint": "prettier \"**/*.{js,json,md,ts}\" --check",
59
58
  "prepublishOnly": "pnpm build",
60
- "test": "tsx --test",
59
+ "test": "node --test",
61
60
  "typecheck": "tsc --noEmit"
62
61
  },
63
62
  "type": "module"