@rowanmanning/package-json-github 2.0.0 → 3.0.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/README.md CHANGED
@@ -16,7 +16,7 @@ Load and parse `package.json` and `package-lock.json` files from GitHub reposito
16
16
 
17
17
  This library requires the following to run:
18
18
 
19
- * [Node.js](https://nodejs.org/) 20+
19
+ * [Node.js](https://nodejs.org/) 22+
20
20
 
21
21
 
22
22
  ## Usage
@@ -31,8 +31,6 @@ Load into your code with `import` or `require`:
31
31
 
32
32
  ```js
33
33
  import { packageJson, packageLock } from '@rowanmanning/package-json-github';
34
- // or
35
- const { packageJson, packageLock } = require('@rowanmanning/package-json-github');
36
34
  ```
37
35
 
38
36
  The following exports are available.
package/index.d.ts CHANGED
@@ -2,11 +2,11 @@ import type { AnyPackageLock, PackageJson } from '@rowanmanning/package-json';
2
2
 
3
3
  declare module '@rowanmanning/package-json-github' {
4
4
  export type {
5
+ AnyPackageLock,
5
6
  PackageJson,
6
7
  PackageLockV1,
7
8
  PackageLockV2,
8
- PackageLockV3,
9
- AnyPackageLock
9
+ PackageLockV3
10
10
  } from '@rowanmanning/package-json';
11
11
 
12
12
  export interface GitHubOptions {
package/index.js CHANGED
@@ -1,4 +1,2 @@
1
- 'use strict';
2
-
3
- exports.packageJson = require('./lib/package-json');
4
- exports.packageLock = require('./lib/package-lock-json');
1
+ export * as packageJson from './lib/package-json.js';
2
+ export * as packageLock from './lib/package-lock-json.js';
package/lib/github.js CHANGED
@@ -1,18 +1,16 @@
1
- 'use strict';
2
-
3
- const { name, version, homepage } = require('../package.json');
1
+ import packageJson from '../package.json' with { type: 'json' };
4
2
 
5
3
  /**
6
4
  * @import { GitHubOptions } from '@rowanmanning/package-json-github'
7
5
  */
8
6
 
9
- const userAgent = `${name}/${version} (${homepage})`;
7
+ const userAgent = `${packageJson.name}/${packageJson.version} (${packageJson.homepage})`;
10
8
 
11
9
  /**
12
10
  * @param {GitHubOptions & { path: string }} options
13
11
  * @returns {Promise<string>}
14
12
  */
15
- exports.getRepoContent = async function getRepoContent(options) {
13
+ export async function getRepoContent(options) {
16
14
  if (!options || typeof options !== 'object' || Array.isArray(options)) {
17
15
  throw new TypeError('Invalid argument: options must be an object');
18
16
  }
@@ -54,4 +52,4 @@ exports.getRepoContent = async function getRepoContent(options) {
54
52
  );
55
53
  }
56
54
  return await response.text();
57
- };
55
+ }
@@ -1,16 +1,12 @@
1
- 'use strict';
2
-
3
- const { getRepoContent } = require('./github');
4
- const {
5
- packageJson: { fromString }
6
- } = require('@rowanmanning/package-json');
1
+ import { packageJson } from '@rowanmanning/package-json';
2
+ import { getRepoContent } from './github.js';
7
3
 
8
4
  /**
9
- * @import { packageJson } from '@rowanmanning/package-json-github'
5
+ * @import { packageJson as packageJsonGitHub } from '@rowanmanning/package-json-github'
10
6
  */
11
7
 
12
- /** @type {packageJson['fromGitHubRepo']} */
13
- exports.fromGitHubRepo = async function fromGitHubRepo(options) {
8
+ /** @type {packageJsonGitHub['fromGitHubRepo']} */
9
+ export async function fromGitHubRepo(options) {
14
10
  const optionsWithPath = Object.assign({ path: 'package.json' }, options);
15
- return fromString(await getRepoContent(optionsWithPath));
16
- };
11
+ return packageJson.fromString(await getRepoContent(optionsWithPath));
12
+ }
@@ -1,16 +1,12 @@
1
- 'use strict';
2
-
3
- const { getRepoContent } = require('./github');
4
- const {
5
- packageLock: { fromString }
6
- } = require('@rowanmanning/package-json');
1
+ import { packageLock } from '@rowanmanning/package-json';
2
+ import { getRepoContent } from './github.js';
7
3
 
8
4
  /**
9
- * @import { packageLock } from '@rowanmanning/package-json-github'
5
+ * @import { packageLock as packageLockGitHub } from '@rowanmanning/package-json-github'
10
6
  */
11
7
 
12
- /** @type {packageLock['fromGitHubRepo']} */
13
- exports.fromGitHubRepo = async function fromGitHubRepo(options) {
8
+ /** @type {packageLockGitHub['fromGitHubRepo']} */
9
+ export async function fromGitHubRepo(options) {
14
10
  const optionsWithPath = Object.assign({ path: 'package-lock.json' }, options);
15
- return fromString(await getRepoContent(optionsWithPath));
16
- };
11
+ return packageLock.fromString(await getRepoContent(optionsWithPath));
12
+ }
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@rowanmanning/package-json-github",
3
- "version": "2.0.0",
3
+ "version": "3.0.0",
4
+ "type": "module",
4
5
  "description": "Load and parse package.json and package-lock.json files from GitHub repositories",
5
6
  "keywords": [],
6
7
  "author": "Rowan Manning (https://rowanmanning.com/)",
@@ -13,11 +14,22 @@
13
14
  "bugs": "https://github.com/rowanmanning/repo-tools/issues",
14
15
  "license": "MIT",
15
16
  "engines": {
16
- "node": "20.x || 22.x"
17
+ "node": "22.x || 24.x"
17
18
  },
18
- "main": "index.js",
19
- "types": "index.d.ts",
19
+ "scripts": {
20
+ "test": "npm run test:unit && npm run test:end-to-end",
21
+ "test:unit": "node --test --experimental-test-module-mocks --experimental-test-coverage --test-coverage-exclude '**/*.test.js' --test-coverage-branches=100 --test-coverage-functions=100 --test-coverage-lines=100 'test/unit/**/*.test.js'",
22
+ "test:end-to-end": "node --test 'test/end-to-end/**/*.test.js'"
23
+ },
24
+ "exports": {
25
+ ".": {
26
+ "types": "./index.d.ts",
27
+ "default": "./index.js"
28
+ }
29
+ },
30
+ "types": "./index.d.ts",
31
+ "main": "./index.js",
20
32
  "dependencies": {
21
- "@rowanmanning/package-json": "^2.0.0"
33
+ "@rowanmanning/package-json": "^3.0.0"
22
34
  }
23
35
  }