chore: update deps

This commit is contained in:
Rim
2025-03-29 15:51:03 -04:00
parent e1fab5e7ef
commit a9cac1605b
2120 changed files with 369757 additions and 880 deletions

View File

@ -0,0 +1,89 @@
/**
* Find the package.json file, either from a TypeScript file somewhere not
* in a 'dist' folder, or a built and/or installed 'dist' folder.
*
* Note: this *only* works if you build your code into `'./dist'`, and that the
* source path does not also contain `'dist'`! If you don't build into
* `'./dist'`, or if you have files at `./src/dist/dist.ts`, then this will
* not work properly!
*
* The default `pathFromSrc` option assumes that the calling code lives one
* folder below the root of the package. Otherwise, it must be specified.
*
* Example:
*
* ```ts
* // src/index.ts
* import { findPackageJson } from 'package-json-from-dist'
*
* const pj = findPackageJson(import.meta.url)
* console.log(`package.json found at ${pj}`)
* ```
*
* If the caller is deeper within the project source, then you must provide
* the appropriate fallback path:
*
* ```ts
* // src/components/something.ts
* import { findPackageJson } from 'package-json-from-dist'
*
* const pj = findPackageJson(import.meta.url, '../../package.json')
* console.log(`package.json found at ${pj}`)
* ```
*
* When running from CommmonJS, use `__filename` instead of `import.meta.url`
*
* ```ts
* // src/index.cts
* import { findPackageJson } from 'package-json-from-dist'
*
* const pj = findPackageJson(__filename)
* console.log(`package.json found at ${pj}`)
* ```
*/
export declare const findPackageJson: (from: string | URL, pathFromSrc?: string) => string;
/**
* Load the package.json file, either from a TypeScript file somewhere not
* in a 'dist' folder, or a built and/or installed 'dist' folder.
*
* Note: this *only* works if you build your code into `'./dist'`, and that the
* source path does not also contain `'dist'`! If you don't build into
* `'./dist'`, or if you have files at `./src/dist/dist.ts`, then this will
* not work properly!
*
* The default `pathFromSrc` option assumes that the calling code lives one
* folder below the root of the package. Otherwise, it must be specified.
*
* Example:
*
* ```ts
* // src/index.ts
* import { loadPackageJson } from 'package-json-from-dist'
*
* const pj = loadPackageJson(import.meta.url)
* console.log(`Hello from ${pj.name}@${pj.version}`)
* ```
*
* If the caller is deeper within the project source, then you must provide
* the appropriate fallback path:
*
* ```ts
* // src/components/something.ts
* import { loadPackageJson } from 'package-json-from-dist'
*
* const pj = loadPackageJson(import.meta.url, '../../package.json')
* console.log(`Hello from ${pj.name}@${pj.version}`)
* ```
*
* When running from CommmonJS, use `__filename` instead of `import.meta.url`
*
* ```ts
* // src/index.cts
* import { loadPackageJson } from 'package-json-from-dist'
*
* const pj = loadPackageJson(__filename)
* console.log(`Hello from ${pj.name}@${pj.version}`)
* ```
*/
export declare const loadPackageJson: (from: string | URL, pathFromSrc?: string) => any;
//# sourceMappingURL=index.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,eAAe,SACpB,MAAM,GAAG,GAAG,gBACL,MAAM,KAClB,MAsCF,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,eAAe,SACpB,MAAM,GAAG,GAAG,gBACL,MAAM,QAEiD,CAAA"}

View File

@ -0,0 +1,134 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadPackageJson = exports.findPackageJson = void 0;
const node_fs_1 = require("node:fs");
const node_path_1 = require("node:path");
const node_url_1 = require("node:url");
const NM = `${node_path_1.sep}node_modules${node_path_1.sep}`;
const STORE = `.store${node_path_1.sep}`;
const PKG = `${node_path_1.sep}package${node_path_1.sep}`;
const DIST = `${node_path_1.sep}dist${node_path_1.sep}`;
/**
* Find the package.json file, either from a TypeScript file somewhere not
* in a 'dist' folder, or a built and/or installed 'dist' folder.
*
* Note: this *only* works if you build your code into `'./dist'`, and that the
* source path does not also contain `'dist'`! If you don't build into
* `'./dist'`, or if you have files at `./src/dist/dist.ts`, then this will
* not work properly!
*
* The default `pathFromSrc` option assumes that the calling code lives one
* folder below the root of the package. Otherwise, it must be specified.
*
* Example:
*
* ```ts
* // src/index.ts
* import { findPackageJson } from 'package-json-from-dist'
*
* const pj = findPackageJson(import.meta.url)
* console.log(`package.json found at ${pj}`)
* ```
*
* If the caller is deeper within the project source, then you must provide
* the appropriate fallback path:
*
* ```ts
* // src/components/something.ts
* import { findPackageJson } from 'package-json-from-dist'
*
* const pj = findPackageJson(import.meta.url, '../../package.json')
* console.log(`package.json found at ${pj}`)
* ```
*
* When running from CommmonJS, use `__filename` instead of `import.meta.url`
*
* ```ts
* // src/index.cts
* import { findPackageJson } from 'package-json-from-dist'
*
* const pj = findPackageJson(__filename)
* console.log(`package.json found at ${pj}`)
* ```
*/
const findPackageJson = (from, pathFromSrc = '../package.json') => {
const f = typeof from === 'object' || from.startsWith('file://') ?
(0, node_url_1.fileURLToPath)(from)
: from;
const __dirname = (0, node_path_1.dirname)(f);
const nms = __dirname.lastIndexOf(NM);
if (nms !== -1) {
// inside of node_modules. find the dist directly under package name.
const nm = __dirname.substring(0, nms + NM.length);
const pkgDir = __dirname.substring(nms + NM.length);
// affordance for yarn berry, which puts package contents in
// '.../node_modules/.store/${id}-${hash}/package/...'
if (pkgDir.startsWith(STORE)) {
const pkg = pkgDir.indexOf(PKG, STORE.length);
if (pkg) {
return (0, node_path_1.resolve)(nm, pkgDir.substring(0, pkg + PKG.length), 'package.json');
}
}
const pkgName = pkgDir.startsWith('@') ?
pkgDir.split(node_path_1.sep, 2).join(node_path_1.sep)
: String(pkgDir.split(node_path_1.sep)[0]);
return (0, node_path_1.resolve)(nm, pkgName, 'package.json');
}
else {
// see if we are in a dist folder.
const d = __dirname.lastIndexOf(DIST);
if (d !== -1) {
return (0, node_path_1.resolve)(__dirname.substring(0, d), 'package.json');
}
else {
return (0, node_path_1.resolve)(__dirname, pathFromSrc);
}
}
};
exports.findPackageJson = findPackageJson;
/**
* Load the package.json file, either from a TypeScript file somewhere not
* in a 'dist' folder, or a built and/or installed 'dist' folder.
*
* Note: this *only* works if you build your code into `'./dist'`, and that the
* source path does not also contain `'dist'`! If you don't build into
* `'./dist'`, or if you have files at `./src/dist/dist.ts`, then this will
* not work properly!
*
* The default `pathFromSrc` option assumes that the calling code lives one
* folder below the root of the package. Otherwise, it must be specified.
*
* Example:
*
* ```ts
* // src/index.ts
* import { loadPackageJson } from 'package-json-from-dist'
*
* const pj = loadPackageJson(import.meta.url)
* console.log(`Hello from ${pj.name}@${pj.version}`)
* ```
*
* If the caller is deeper within the project source, then you must provide
* the appropriate fallback path:
*
* ```ts
* // src/components/something.ts
* import { loadPackageJson } from 'package-json-from-dist'
*
* const pj = loadPackageJson(import.meta.url, '../../package.json')
* console.log(`Hello from ${pj.name}@${pj.version}`)
* ```
*
* When running from CommmonJS, use `__filename` instead of `import.meta.url`
*
* ```ts
* // src/index.cts
* import { loadPackageJson } from 'package-json-from-dist'
*
* const pj = loadPackageJson(__filename)
* console.log(`Hello from ${pj.name}@${pj.version}`)
* ```
*/
const loadPackageJson = (from, pathFromSrc = '../package.json') => JSON.parse((0, node_fs_1.readFileSync)((0, exports.findPackageJson)(from, pathFromSrc), 'utf8'));
exports.loadPackageJson = loadPackageJson;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,3 @@
{
"type": "commonjs"
}

View File

@ -0,0 +1,89 @@
/**
* Find the package.json file, either from a TypeScript file somewhere not
* in a 'dist' folder, or a built and/or installed 'dist' folder.
*
* Note: this *only* works if you build your code into `'./dist'`, and that the
* source path does not also contain `'dist'`! If you don't build into
* `'./dist'`, or if you have files at `./src/dist/dist.ts`, then this will
* not work properly!
*
* The default `pathFromSrc` option assumes that the calling code lives one
* folder below the root of the package. Otherwise, it must be specified.
*
* Example:
*
* ```ts
* // src/index.ts
* import { findPackageJson } from 'package-json-from-dist'
*
* const pj = findPackageJson(import.meta.url)
* console.log(`package.json found at ${pj}`)
* ```
*
* If the caller is deeper within the project source, then you must provide
* the appropriate fallback path:
*
* ```ts
* // src/components/something.ts
* import { findPackageJson } from 'package-json-from-dist'
*
* const pj = findPackageJson(import.meta.url, '../../package.json')
* console.log(`package.json found at ${pj}`)
* ```
*
* When running from CommmonJS, use `__filename` instead of `import.meta.url`
*
* ```ts
* // src/index.cts
* import { findPackageJson } from 'package-json-from-dist'
*
* const pj = findPackageJson(__filename)
* console.log(`package.json found at ${pj}`)
* ```
*/
export declare const findPackageJson: (from: string | URL, pathFromSrc?: string) => string;
/**
* Load the package.json file, either from a TypeScript file somewhere not
* in a 'dist' folder, or a built and/or installed 'dist' folder.
*
* Note: this *only* works if you build your code into `'./dist'`, and that the
* source path does not also contain `'dist'`! If you don't build into
* `'./dist'`, or if you have files at `./src/dist/dist.ts`, then this will
* not work properly!
*
* The default `pathFromSrc` option assumes that the calling code lives one
* folder below the root of the package. Otherwise, it must be specified.
*
* Example:
*
* ```ts
* // src/index.ts
* import { loadPackageJson } from 'package-json-from-dist'
*
* const pj = loadPackageJson(import.meta.url)
* console.log(`Hello from ${pj.name}@${pj.version}`)
* ```
*
* If the caller is deeper within the project source, then you must provide
* the appropriate fallback path:
*
* ```ts
* // src/components/something.ts
* import { loadPackageJson } from 'package-json-from-dist'
*
* const pj = loadPackageJson(import.meta.url, '../../package.json')
* console.log(`Hello from ${pj.name}@${pj.version}`)
* ```
*
* When running from CommmonJS, use `__filename` instead of `import.meta.url`
*
* ```ts
* // src/index.cts
* import { loadPackageJson } from 'package-json-from-dist'
*
* const pj = loadPackageJson(__filename)
* console.log(`Hello from ${pj.name}@${pj.version}`)
* ```
*/
export declare const loadPackageJson: (from: string | URL, pathFromSrc?: string) => any;
//# sourceMappingURL=index.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,eAAe,SACpB,MAAM,GAAG,GAAG,gBACL,MAAM,KAClB,MAsCF,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,eAAe,SACpB,MAAM,GAAG,GAAG,gBACL,MAAM,QAEiD,CAAA"}

129
node_modules/package-json-from-dist/dist/esm/index.js generated vendored Normal file
View File

@ -0,0 +1,129 @@
import { readFileSync } from 'node:fs';
import { dirname, resolve, sep } from 'node:path';
import { fileURLToPath } from 'node:url';
const NM = `${sep}node_modules${sep}`;
const STORE = `.store${sep}`;
const PKG = `${sep}package${sep}`;
const DIST = `${sep}dist${sep}`;
/**
* Find the package.json file, either from a TypeScript file somewhere not
* in a 'dist' folder, or a built and/or installed 'dist' folder.
*
* Note: this *only* works if you build your code into `'./dist'`, and that the
* source path does not also contain `'dist'`! If you don't build into
* `'./dist'`, or if you have files at `./src/dist/dist.ts`, then this will
* not work properly!
*
* The default `pathFromSrc` option assumes that the calling code lives one
* folder below the root of the package. Otherwise, it must be specified.
*
* Example:
*
* ```ts
* // src/index.ts
* import { findPackageJson } from 'package-json-from-dist'
*
* const pj = findPackageJson(import.meta.url)
* console.log(`package.json found at ${pj}`)
* ```
*
* If the caller is deeper within the project source, then you must provide
* the appropriate fallback path:
*
* ```ts
* // src/components/something.ts
* import { findPackageJson } from 'package-json-from-dist'
*
* const pj = findPackageJson(import.meta.url, '../../package.json')
* console.log(`package.json found at ${pj}`)
* ```
*
* When running from CommmonJS, use `__filename` instead of `import.meta.url`
*
* ```ts
* // src/index.cts
* import { findPackageJson } from 'package-json-from-dist'
*
* const pj = findPackageJson(__filename)
* console.log(`package.json found at ${pj}`)
* ```
*/
export const findPackageJson = (from, pathFromSrc = '../package.json') => {
const f = typeof from === 'object' || from.startsWith('file://') ?
fileURLToPath(from)
: from;
const __dirname = dirname(f);
const nms = __dirname.lastIndexOf(NM);
if (nms !== -1) {
// inside of node_modules. find the dist directly under package name.
const nm = __dirname.substring(0, nms + NM.length);
const pkgDir = __dirname.substring(nms + NM.length);
// affordance for yarn berry, which puts package contents in
// '.../node_modules/.store/${id}-${hash}/package/...'
if (pkgDir.startsWith(STORE)) {
const pkg = pkgDir.indexOf(PKG, STORE.length);
if (pkg) {
return resolve(nm, pkgDir.substring(0, pkg + PKG.length), 'package.json');
}
}
const pkgName = pkgDir.startsWith('@') ?
pkgDir.split(sep, 2).join(sep)
: String(pkgDir.split(sep)[0]);
return resolve(nm, pkgName, 'package.json');
}
else {
// see if we are in a dist folder.
const d = __dirname.lastIndexOf(DIST);
if (d !== -1) {
return resolve(__dirname.substring(0, d), 'package.json');
}
else {
return resolve(__dirname, pathFromSrc);
}
}
};
/**
* Load the package.json file, either from a TypeScript file somewhere not
* in a 'dist' folder, or a built and/or installed 'dist' folder.
*
* Note: this *only* works if you build your code into `'./dist'`, and that the
* source path does not also contain `'dist'`! If you don't build into
* `'./dist'`, or if you have files at `./src/dist/dist.ts`, then this will
* not work properly!
*
* The default `pathFromSrc` option assumes that the calling code lives one
* folder below the root of the package. Otherwise, it must be specified.
*
* Example:
*
* ```ts
* // src/index.ts
* import { loadPackageJson } from 'package-json-from-dist'
*
* const pj = loadPackageJson(import.meta.url)
* console.log(`Hello from ${pj.name}@${pj.version}`)
* ```
*
* If the caller is deeper within the project source, then you must provide
* the appropriate fallback path:
*
* ```ts
* // src/components/something.ts
* import { loadPackageJson } from 'package-json-from-dist'
*
* const pj = loadPackageJson(import.meta.url, '../../package.json')
* console.log(`Hello from ${pj.name}@${pj.version}`)
* ```
*
* When running from CommmonJS, use `__filename` instead of `import.meta.url`
*
* ```ts
* // src/index.cts
* import { loadPackageJson } from 'package-json-from-dist'
*
* const pj = loadPackageJson(__filename)
* console.log(`Hello from ${pj.name}@${pj.version}`)
* ```
*/
export const loadPackageJson = (from, pathFromSrc = '../package.json') => JSON.parse(readFileSync(findPackageJson(from, pathFromSrc), 'utf8'));
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,3 @@
{
"type": "module"
}

68
node_modules/package-json-from-dist/package.json generated vendored Normal file
View File

@ -0,0 +1,68 @@
{
"name": "package-json-from-dist",
"version": "1.0.1",
"description": "Load the local package.json from either src or dist folder",
"main": "./dist/commonjs/index.js",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
}
},
"files": [
"dist"
],
"scripts": {
"preversion": "npm test",
"postversion": "npm publish",
"prepublishOnly": "git push origin --follow-tags",
"prepare": "tshy",
"pretest": "npm run prepare",
"presnap": "npm run prepare",
"test": "tap",
"snap": "tap",
"format": "prettier --write . --log-level warn",
"typedoc": "typedoc"
},
"author": "Isaac Z. Schlueter <i@izs.me> (https://izs.me)",
"license": "BlueOak-1.0.0",
"repository": {
"type": "git",
"url": "git+https://github.com/isaacs/package-json-from-dist.git"
},
"devDependencies": {
"@types/node": "^20.12.12",
"prettier": "^3.2.5",
"tap": "^18.5.3",
"typedoc": "^0.24.8",
"typescript": "^5.1.6",
"tshy": "^1.14.0"
},
"prettier": {
"semi": false,
"printWidth": 70,
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"jsxSingleQuote": false,
"bracketSameLine": true,
"arrowParens": "avoid",
"endOfLine": "lf",
"experimentalTernaries": true
},
"tshy": {
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
}
},
"types": "./dist/commonjs/index.d.ts",
"type": "module"
}