Skip to content

Commit 8b8ce7a

Browse files
committedJun 27, 2024
deps: glob@10.4.2
1 parent 4646768 commit 8b8ce7a

File tree

12 files changed

+399
-11
lines changed

12 files changed

+399
-11
lines changed
 

‎DEPENDENCIES.md

+1
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ graph LR;
293293
glob-->jackspeak;
294294
glob-->minimatch;
295295
glob-->minipass;
296+
glob-->package-json-from-dist;
296297
glob-->path-scurry;
297298
hasown-->function-bind;
298299
hosted-git-info-->lru-cache;

‎node_modules/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@
155155
!/npm-registry-fetch
156156
!/npm-user-validate
157157
!/p-map
158+
!/package-json-from-dist
158159
!/pacote
159160
!/parse-conflict-json
160161
!/path-key

‎node_modules/glob/dist/esm/bin.mjs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
#!/usr/bin/env node
22
import { foregroundChild } from 'foreground-child';
33
import { existsSync } from 'fs';
4-
import { readFile } from 'fs/promises';
54
import { jack } from 'jackspeak';
5+
import { loadPackageJson } from 'package-json-from-dist';
66
import { join } from 'path';
7-
import { fileURLToPath } from 'url';
87
import { globStream } from './index.js';
9-
/* c8 ignore start */
10-
const { version } = JSON.parse(await readFile(fileURLToPath(new URL('../../package.json', import.meta.url)), 'utf8').catch(() => readFile(fileURLToPath(new URL('../../package.json', import.meta.url)), 'utf8')));
11-
/* c8 ignore stop */
8+
const { version } = loadPackageJson(import.meta.url, '../package.json');
129
const j = jack({
1310
usage: 'glob [options] [<pattern> [<pattern> ...]]',
1411
})

‎node_modules/glob/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author": "Isaac Z. Schlueter <i@izs.me> (https://blog.izs.me/)",
33
"name": "glob",
44
"description": "the most correct and second fastest glob implementation in JavaScript",
5-
"version": "10.4.1",
5+
"version": "10.4.2",
66
"type": "module",
77
"tshy": {
88
"main": true,
@@ -71,6 +71,7 @@
7171
"jackspeak": "^3.1.2",
7272
"minimatch": "^9.0.4",
7373
"minipass": "^7.1.2",
74+
"package-json-from-dist": "^1.0.0",
7475
"path-scurry": "^1.11.1"
7576
},
7677
"devDependencies": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
All packages under `src/` are licensed according to the terms in
2+
their respective `LICENSE` or `LICENSE.md` files.
3+
4+
The remainder of this project is licensed under the Blue Oak
5+
Model License, as follows:
6+
7+
-----
8+
9+
# Blue Oak Model License
10+
11+
Version 1.0.0
12+
13+
## Purpose
14+
15+
This license gives everyone as much permission to work with
16+
this software as possible, while protecting contributors
17+
from liability.
18+
19+
## Acceptance
20+
21+
In order to receive this license, you must agree to its
22+
rules. The rules of this license are both obligations
23+
under that agreement and conditions to your license.
24+
You must not do anything with this software that triggers
25+
a rule that you cannot or will not follow.
26+
27+
## Copyright
28+
29+
Each contributor licenses you to do everything with this
30+
software that would otherwise infringe that contributor's
31+
copyright in it.
32+
33+
## Notices
34+
35+
You must ensure that everyone who gets a copy of
36+
any part of this software from you, with or without
37+
changes, also gets the text of this license or a link to
38+
<https://blueoakcouncil.org/license/1.0.0>.
39+
40+
## Excuse
41+
42+
If anyone notifies you in writing that you have not
43+
complied with [Notices](#notices), you can keep your
44+
license by taking all practical steps to comply within 30
45+
days after the notice. If you do not do so, your license
46+
ends immediately.
47+
48+
## Patent
49+
50+
Each contributor licenses you to do everything with this
51+
software that would otherwise infringe any patent claims
52+
they can license or become able to license.
53+
54+
## Reliability
55+
56+
No contributor can revoke this license.
57+
58+
## No Liability
59+
60+
***As far as the law allows, this software comes as is,
61+
without any warranty or condition, and no contributor
62+
will be liable to anyone for any damages related to this
63+
software or this license, under any kind of legal claim.***
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.loadPackageJson = exports.findPackageJson = void 0;
4+
const node_fs_1 = require("node:fs");
5+
const node_path_1 = require("node:path");
6+
const node_url_1 = require("node:url");
7+
const NM = `${node_path_1.sep}node_modules${node_path_1.sep}`;
8+
const DIST = `${node_path_1.sep}dist${node_path_1.sep}`;
9+
/**
10+
* Find the package.json file, either from a TypeScript file somewhere not
11+
* in a 'dist' folder, or a built and/or installed 'dist' folder.
12+
*
13+
* Note: this *only* works if you build your code into `'./dist'`, and that the
14+
* source path does not also contain `'dist'`! If you don't build into
15+
* `'./dist'`, or if you have files at `./src/dist/dist.ts`, then this will
16+
* not work properly!
17+
*
18+
* The default `pathFromSrc` option assumes that the calling code lives one
19+
* folder below the root of the package. Otherwise, it must be specified.
20+
*
21+
* Example:
22+
*
23+
* ```ts
24+
* // src/index.ts
25+
* import { findPackageJson } from 'package-json-from-dist'
26+
*
27+
* const pj = findPackageJson(import.meta.url)
28+
* console.log(`package.json found at ${pj}`)
29+
* ```
30+
*
31+
* If the caller is deeper within the project source, then you must provide
32+
* the appropriate fallback path:
33+
*
34+
* ```ts
35+
* // src/components/something.ts
36+
* import { findPackageJson } from 'package-json-from-dist'
37+
*
38+
* const pj = findPackageJson(import.meta.url, '../../package.json')
39+
* console.log(`package.json found at ${pj}`)
40+
* ```
41+
*
42+
* When running from CommmonJS, use `__filename` instead of `import.meta.url`
43+
*
44+
* ```ts
45+
* // src/index.cts
46+
* import { findPackageJson } from 'package-json-from-dist'
47+
*
48+
* const pj = findPackageJson(__filename)
49+
* console.log(`package.json found at ${pj}`)
50+
* ```
51+
*/
52+
const findPackageJson = (from, pathFromSrc = '../package.json') => {
53+
const f = typeof from === 'object' || from.startsWith('file://') ?
54+
(0, node_url_1.fileURLToPath)(from)
55+
: from;
56+
const __dirname = (0, node_path_1.dirname)(f);
57+
const nms = __dirname.lastIndexOf(NM);
58+
if (nms !== -1) {
59+
// inside of node_modules. find the dist directly under package name.
60+
const nm = __dirname.substring(0, nms + NM.length);
61+
const pkgDir = __dirname.substring(nms + NM.length);
62+
const pkgName = pkgDir.startsWith('@') ?
63+
pkgDir.split(node_path_1.sep).slice(0, 2).join(node_path_1.sep)
64+
: String(pkgDir.split(node_path_1.sep)[0]);
65+
return (0, node_path_1.resolve)(nm, pkgName, 'package.json');
66+
}
67+
else {
68+
// see if we are in a dist folder.
69+
const d = __dirname.lastIndexOf(DIST);
70+
if (d !== -1) {
71+
return (0, node_path_1.resolve)(__dirname.substring(0, d), 'package.json');
72+
}
73+
else {
74+
return (0, node_path_1.resolve)(__dirname, pathFromSrc);
75+
}
76+
}
77+
};
78+
exports.findPackageJson = findPackageJson;
79+
/**
80+
* Load the package.json file, either from a TypeScript file somewhere not
81+
* in a 'dist' folder, or a built and/or installed 'dist' folder.
82+
*
83+
* Note: this *only* works if you build your code into `'./dist'`, and that the
84+
* source path does not also contain `'dist'`! If you don't build into
85+
* `'./dist'`, or if you have files at `./src/dist/dist.ts`, then this will
86+
* not work properly!
87+
*
88+
* The default `pathFromSrc` option assumes that the calling code lives one
89+
* folder below the root of the package. Otherwise, it must be specified.
90+
*
91+
* Example:
92+
*
93+
* ```ts
94+
* // src/index.ts
95+
* import { loadPackageJson } from 'package-json-from-dist'
96+
*
97+
* const pj = loadPackageJson(import.meta.url)
98+
* console.log(`Hello from ${pj.name}@${pj.version}`)
99+
* ```
100+
*
101+
* If the caller is deeper within the project source, then you must provide
102+
* the appropriate fallback path:
103+
*
104+
* ```ts
105+
* // src/components/something.ts
106+
* import { loadPackageJson } from 'package-json-from-dist'
107+
*
108+
* const pj = loadPackageJson(import.meta.url, '../../package.json')
109+
* console.log(`Hello from ${pj.name}@${pj.version}`)
110+
* ```
111+
*
112+
* When running from CommmonJS, use `__filename` instead of `import.meta.url`
113+
*
114+
* ```ts
115+
* // src/index.cts
116+
* import { loadPackageJson } from 'package-json-from-dist'
117+
*
118+
* const pj = loadPackageJson(__filename)
119+
* console.log(`Hello from ${pj.name}@${pj.version}`)
120+
* ```
121+
*/
122+
const loadPackageJson = (from, pathFromSrc = '../package.json') => JSON.parse((0, node_fs_1.readFileSync)((0, exports.findPackageJson)(from, pathFromSrc), 'utf8'));
123+
exports.loadPackageJson = loadPackageJson;
124+
//# sourceMappingURL=index.js.map
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
import { readFileSync } from 'node:fs';
2+
import { dirname, resolve, sep } from 'node:path';
3+
import { fileURLToPath } from 'node:url';
4+
const NM = `${sep}node_modules${sep}`;
5+
const DIST = `${sep}dist${sep}`;
6+
/**
7+
* Find the package.json file, either from a TypeScript file somewhere not
8+
* in a 'dist' folder, or a built and/or installed 'dist' folder.
9+
*
10+
* Note: this *only* works if you build your code into `'./dist'`, and that the
11+
* source path does not also contain `'dist'`! If you don't build into
12+
* `'./dist'`, or if you have files at `./src/dist/dist.ts`, then this will
13+
* not work properly!
14+
*
15+
* The default `pathFromSrc` option assumes that the calling code lives one
16+
* folder below the root of the package. Otherwise, it must be specified.
17+
*
18+
* Example:
19+
*
20+
* ```ts
21+
* // src/index.ts
22+
* import { findPackageJson } from 'package-json-from-dist'
23+
*
24+
* const pj = findPackageJson(import.meta.url)
25+
* console.log(`package.json found at ${pj}`)
26+
* ```
27+
*
28+
* If the caller is deeper within the project source, then you must provide
29+
* the appropriate fallback path:
30+
*
31+
* ```ts
32+
* // src/components/something.ts
33+
* import { findPackageJson } from 'package-json-from-dist'
34+
*
35+
* const pj = findPackageJson(import.meta.url, '../../package.json')
36+
* console.log(`package.json found at ${pj}`)
37+
* ```
38+
*
39+
* When running from CommmonJS, use `__filename` instead of `import.meta.url`
40+
*
41+
* ```ts
42+
* // src/index.cts
43+
* import { findPackageJson } from 'package-json-from-dist'
44+
*
45+
* const pj = findPackageJson(__filename)
46+
* console.log(`package.json found at ${pj}`)
47+
* ```
48+
*/
49+
export const findPackageJson = (from, pathFromSrc = '../package.json') => {
50+
const f = typeof from === 'object' || from.startsWith('file://') ?
51+
fileURLToPath(from)
52+
: from;
53+
const __dirname = dirname(f);
54+
const nms = __dirname.lastIndexOf(NM);
55+
if (nms !== -1) {
56+
// inside of node_modules. find the dist directly under package name.
57+
const nm = __dirname.substring(0, nms + NM.length);
58+
const pkgDir = __dirname.substring(nms + NM.length);
59+
const pkgName = pkgDir.startsWith('@') ?
60+
pkgDir.split(sep).slice(0, 2).join(sep)
61+
: String(pkgDir.split(sep)[0]);
62+
return resolve(nm, pkgName, 'package.json');
63+
}
64+
else {
65+
// see if we are in a dist folder.
66+
const d = __dirname.lastIndexOf(DIST);
67+
if (d !== -1) {
68+
return resolve(__dirname.substring(0, d), 'package.json');
69+
}
70+
else {
71+
return resolve(__dirname, pathFromSrc);
72+
}
73+
}
74+
};
75+
/**
76+
* Load the package.json file, either from a TypeScript file somewhere not
77+
* in a 'dist' folder, or a built and/or installed 'dist' folder.
78+
*
79+
* Note: this *only* works if you build your code into `'./dist'`, and that the
80+
* source path does not also contain `'dist'`! If you don't build into
81+
* `'./dist'`, or if you have files at `./src/dist/dist.ts`, then this will
82+
* not work properly!
83+
*
84+
* The default `pathFromSrc` option assumes that the calling code lives one
85+
* folder below the root of the package. Otherwise, it must be specified.
86+
*
87+
* Example:
88+
*
89+
* ```ts
90+
* // src/index.ts
91+
* import { loadPackageJson } from 'package-json-from-dist'
92+
*
93+
* const pj = loadPackageJson(import.meta.url)
94+
* console.log(`Hello from ${pj.name}@${pj.version}`)
95+
* ```
96+
*
97+
* If the caller is deeper within the project source, then you must provide
98+
* the appropriate fallback path:
99+
*
100+
* ```ts
101+
* // src/components/something.ts
102+
* import { loadPackageJson } from 'package-json-from-dist'
103+
*
104+
* const pj = loadPackageJson(import.meta.url, '../../package.json')
105+
* console.log(`Hello from ${pj.name}@${pj.version}`)
106+
* ```
107+
*
108+
* When running from CommmonJS, use `__filename` instead of `import.meta.url`
109+
*
110+
* ```ts
111+
* // src/index.cts
112+
* import { loadPackageJson } from 'package-json-from-dist'
113+
*
114+
* const pj = loadPackageJson(__filename)
115+
* console.log(`Hello from ${pj.name}@${pj.version}`)
116+
* ```
117+
*/
118+
export const loadPackageJson = (from, pathFromSrc = '../package.json') => JSON.parse(readFileSync(findPackageJson(from, pathFromSrc), 'utf8'));
119+
//# sourceMappingURL=index.js.map
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "module"
3+
}

‎node_modules/package-json-from-dist/package.json

+68
Original file line numberDiff line numberDiff line change

‎package-lock.json

+12-4
Original file line numberDiff line numberDiff line change

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"cli-columns": "^4.0.0",
7070
"fastest-levenshtein": "^1.0.16",
7171
"fs-minipass": "^3.0.3",
72-
"glob": "^10.4.1",
72+
"glob": "^10.4.2",
7373
"graceful-fs": "^4.2.11",
7474
"hosted-git-info": "^7.0.2",
7575
"ini": "^4.1.3",

0 commit comments

Comments
 (0)
Please sign in to comment.