@pkgr/core 0.2.5 → 0.3.1
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/lib/helpers.d.ts +18 -2
- package/lib/helpers.js +65 -23
- package/lib/helpers.js.map +1 -1
- package/lib/index.cjs +68 -25
- package/package.json +2 -2
package/lib/helpers.d.ts
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
|
+
import { type Stats } from 'node:fs';
|
|
1
2
|
export declare const tryPkg: (pkg: string) => string | undefined;
|
|
2
3
|
export declare const isPkgAvailable: (pkg: string) => boolean;
|
|
3
|
-
export
|
|
4
|
+
export type FileTypeBase = 'blockDevice' | 'characterDevice' | 'directory' | 'FIFO' | 'file' | 'socket' | 'symbolicLink';
|
|
5
|
+
export type FileType = Capitalize<FileTypeBase> | FileTypeBase;
|
|
6
|
+
export type FileTypes = FileType | FileType[] | boolean | 'any';
|
|
7
|
+
export declare const tryFileStats: (filename?: string[] | string, type?: FileTypes, base?: string) => {
|
|
8
|
+
filepath: string;
|
|
9
|
+
stats: Stats;
|
|
10
|
+
} | undefined;
|
|
11
|
+
export declare const tryFile: (filename?: string[] | string, type?: FileTypes, base?: string) => string;
|
|
4
12
|
export declare const tryExtensions: (filepath: string, extensions?: string[]) => string;
|
|
5
|
-
export
|
|
13
|
+
export interface FindUpOptions {
|
|
14
|
+
entry?: string;
|
|
15
|
+
search?: string[] | string;
|
|
16
|
+
type?: FileTypes;
|
|
17
|
+
stop?: string;
|
|
18
|
+
throwOnStopNotFound?: boolean;
|
|
19
|
+
throwOnInvalidStop?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare const findUp: (entryOrOptions?: FindUpOptions | string, options?: FindUpOptions) => string;
|
package/lib/helpers.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
1
|
+
import fs, {} from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { CWD, EXTENSIONS, cjsRequire } from './constants.js';
|
|
4
4
|
export const tryPkg = (pkg) => {
|
|
@@ -7,45 +7,87 @@ export const tryPkg = (pkg) => {
|
|
|
7
7
|
}
|
|
8
8
|
catch { }
|
|
9
9
|
};
|
|
10
|
-
export const isPkgAvailable = (pkg) =>
|
|
11
|
-
|
|
10
|
+
export const isPkgAvailable = (pkg) => Boolean(tryPkg(pkg));
|
|
11
|
+
const ANY_FILE_TYPES = new Set(['any', true]);
|
|
12
|
+
const isAnyFileType = (type) => ANY_FILE_TYPES.has(type);
|
|
13
|
+
export const tryFileStats = (filename, type = 'file', base = CWD) => {
|
|
14
|
+
if (!type) {
|
|
15
|
+
type = 'file';
|
|
16
|
+
}
|
|
12
17
|
if (typeof filename === 'string') {
|
|
13
18
|
const filepath = path.resolve(base, filename);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
const stats = fs.statSync(filepath, { throwIfNoEntry: false });
|
|
20
|
+
return stats &&
|
|
21
|
+
(isAnyFileType(type) ||
|
|
22
|
+
(Array.isArray(type) ? type : [type]).some(type => stats[`is${type[0].toUpperCase()}${type.slice(1)}`]()))
|
|
23
|
+
? { filepath, stats }
|
|
24
|
+
: undefined;
|
|
18
25
|
}
|
|
19
26
|
for (const file of filename ?? []) {
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
return
|
|
27
|
+
const result = tryFileStats(file, type, base);
|
|
28
|
+
if (result) {
|
|
29
|
+
return result;
|
|
23
30
|
}
|
|
24
31
|
}
|
|
25
|
-
return '';
|
|
26
32
|
};
|
|
33
|
+
export const tryFile = (filename, type = 'file', base) => tryFileStats(filename, type, base)?.filepath ?? '';
|
|
27
34
|
export const tryExtensions = (filepath, extensions = EXTENSIONS) => {
|
|
28
35
|
const ext = [...extensions, ''].find(ext => tryFile(filepath + ext));
|
|
29
36
|
return ext == null ? '' : filepath + ext;
|
|
30
37
|
};
|
|
31
|
-
export const findUp = (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
export const findUp = (entryOrOptions, options) => {
|
|
39
|
+
if (typeof entryOrOptions === 'string') {
|
|
40
|
+
options = {
|
|
41
|
+
entry: entryOrOptions,
|
|
42
|
+
...options,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
let { entry = CWD, search = 'package.json', type, stop, throwOnStopNotFound, throwOnInvalidStop, } = options ?? {};
|
|
46
|
+
search = Array.isArray(search) ? search : [search];
|
|
47
|
+
if (stop) {
|
|
48
|
+
const stopStats = tryFileStats(stop, ['file', 'directory']);
|
|
49
|
+
if (!stopStats) {
|
|
50
|
+
const message = `Cannot find stop path: ${stop}`;
|
|
51
|
+
if (throwOnStopNotFound) {
|
|
52
|
+
throw new Error(message);
|
|
53
|
+
}
|
|
54
|
+
else if (throwOnStopNotFound !== false) {
|
|
55
|
+
console.warn(message);
|
|
56
|
+
}
|
|
57
|
+
return '';
|
|
58
|
+
}
|
|
59
|
+
stop = stopStats.stats.isDirectory()
|
|
60
|
+
? stopStats.filepath
|
|
61
|
+
: path.dirname(stopStats.filepath);
|
|
62
|
+
if (entry !== stop && !entry.startsWith(stop + path.sep)) {
|
|
63
|
+
const message = `Invalid stop path: ${stop} is not a parent of ${entry}`;
|
|
64
|
+
if (throwOnInvalidStop) {
|
|
65
|
+
throw new Error(message);
|
|
66
|
+
}
|
|
67
|
+
else if (throwOnInvalidStop !== false) {
|
|
68
|
+
console.warn(message);
|
|
69
|
+
}
|
|
70
|
+
return '';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const entryStats = tryFileStats(entry, ['file', 'directory']);
|
|
74
|
+
if (!entryStats) {
|
|
35
75
|
return '';
|
|
36
76
|
}
|
|
37
|
-
|
|
38
|
-
?
|
|
39
|
-
: path.
|
|
40
|
-
const isSearchFile = typeof searchFileOrIncludeDir === 'string';
|
|
41
|
-
const searchFile = isSearchFile ? searchFileOrIncludeDir : 'package.json';
|
|
77
|
+
entry = entryStats.stats.isDirectory()
|
|
78
|
+
? entryStats.filepath
|
|
79
|
+
: path.dirname(entryStats.filepath);
|
|
42
80
|
do {
|
|
43
|
-
const searched = tryFile(
|
|
81
|
+
const searched = tryFile(search, type, entry);
|
|
44
82
|
if (searched) {
|
|
45
83
|
return searched;
|
|
46
84
|
}
|
|
47
|
-
|
|
48
|
-
|
|
85
|
+
const lastEntry = entry;
|
|
86
|
+
entry = path.dirname(entry);
|
|
87
|
+
if (entry === lastEntry) {
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
} while (!stop || entry !== stop);
|
|
49
91
|
return '';
|
|
50
92
|
};
|
|
51
93
|
//# sourceMappingURL=helpers.js.map
|
package/lib/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAc,MAAM,SAAS,CAAA;AACxC,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE5D,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,EAAE;IACpC,IAAI,CAAC;QACH,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAChC,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;AACZ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;AAenE,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAA;AAE7C,MAAM,aAAa,GAAG,CAAC,IAAe,EAAwB,EAA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AA;QACvB,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAC3B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,MAAK;QACP,CAAC;IACH,CAAC,QAAQ,CAAC,IAAI,IAAI,KAAK,KAAK,IAAI,EAAC;IAEjC,OAAO,EAAE,CAAA;AACX,CAAC,CAAA"}
|
package/lib/index.cjs
CHANGED
|
@@ -4,9 +4,9 @@ var node_module = require('node:module');
|
|
|
4
4
|
var fs = require('node:fs');
|
|
5
5
|
var path = require('node:path');
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
8
8
|
const CWD = process.cwd();
|
|
9
|
-
const importMetaUrl =
|
|
9
|
+
const importMetaUrl = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href));
|
|
10
10
|
const cjsRequire = importMetaUrl ? node_module.createRequire(importMetaUrl) : require;
|
|
11
11
|
const EVAL_FILENAMES = /* @__PURE__ */ new Set(["[eval]", "[worker eval]"]);
|
|
12
12
|
const EXTENSIONS = [".ts", ".tsx", ...Object.keys(cjsRequire.extensions)];
|
|
@@ -14,47 +14,89 @@ const EXTENSIONS = [".ts", ".tsx", ...Object.keys(cjsRequire.extensions)];
|
|
|
14
14
|
const tryPkg = (pkg) => {
|
|
15
15
|
try {
|
|
16
16
|
return cjsRequire.resolve(pkg);
|
|
17
|
-
} catch
|
|
17
|
+
} catch {
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
|
-
const isPkgAvailable = (pkg) =>
|
|
21
|
-
const
|
|
20
|
+
const isPkgAvailable = (pkg) => Boolean(tryPkg(pkg));
|
|
21
|
+
const ANY_FILE_TYPES = /* @__PURE__ */ new Set(["any", true]);
|
|
22
|
+
const isAnyFileType = (type) => ANY_FILE_TYPES.has(type);
|
|
23
|
+
const tryFileStats = (filename, type = "file", base = CWD) => {
|
|
24
|
+
if (!type) {
|
|
25
|
+
type = "file";
|
|
26
|
+
}
|
|
22
27
|
if (typeof filename === "string") {
|
|
23
28
|
const filepath = path.resolve(base, filename);
|
|
24
|
-
|
|
29
|
+
const stats = fs.statSync(filepath, { throwIfNoEntry: false });
|
|
30
|
+
return stats && (isAnyFileType(type) || (Array.isArray(type) ? type : [type]).some(
|
|
31
|
+
(type2) => stats[`is${type2[0].toUpperCase()}${type2.slice(1)}`]()
|
|
32
|
+
)) ? { filepath, stats } : void 0;
|
|
25
33
|
}
|
|
26
|
-
for (const file of filename
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
29
|
-
return
|
|
34
|
+
for (const file of filename ?? []) {
|
|
35
|
+
const result = tryFileStats(file, type, base);
|
|
36
|
+
if (result) {
|
|
37
|
+
return result;
|
|
30
38
|
}
|
|
31
39
|
}
|
|
32
|
-
return "";
|
|
33
40
|
};
|
|
41
|
+
const tryFile = (filename, type = "file", base) => tryFileStats(filename, type, base)?.filepath ?? "";
|
|
34
42
|
const tryExtensions = (filepath, extensions = EXTENSIONS) => {
|
|
35
43
|
const ext = [...extensions, ""].find((ext2) => tryFile(filepath + ext2));
|
|
36
44
|
return ext == null ? "" : filepath + ext;
|
|
37
45
|
};
|
|
38
|
-
const findUp = (
|
|
39
|
-
|
|
40
|
-
|
|
46
|
+
const findUp = (entryOrOptions, options) => {
|
|
47
|
+
if (typeof entryOrOptions === "string") {
|
|
48
|
+
options = {
|
|
49
|
+
entry: entryOrOptions,
|
|
50
|
+
...options
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
let {
|
|
54
|
+
entry = CWD,
|
|
55
|
+
search = "package.json",
|
|
56
|
+
type,
|
|
57
|
+
stop,
|
|
58
|
+
throwOnStopNotFound,
|
|
59
|
+
throwOnInvalidStop
|
|
60
|
+
} = options ?? {};
|
|
61
|
+
search = Array.isArray(search) ? search : [search];
|
|
62
|
+
if (stop) {
|
|
63
|
+
const stopStats = tryFileStats(stop, ["file", "directory"]);
|
|
64
|
+
if (!stopStats) {
|
|
65
|
+
const message = `Cannot find stop path: ${stop}`;
|
|
66
|
+
if (throwOnStopNotFound) {
|
|
67
|
+
throw new Error(message);
|
|
68
|
+
} else if (throwOnStopNotFound !== false) {
|
|
69
|
+
console.warn(message);
|
|
70
|
+
}
|
|
71
|
+
return "";
|
|
72
|
+
}
|
|
73
|
+
stop = stopStats.stats.isDirectory() ? stopStats.filepath : path.dirname(stopStats.filepath);
|
|
74
|
+
if (entry !== stop && !entry.startsWith(stop + path.sep)) {
|
|
75
|
+
const message = `Invalid stop path: ${stop} is not a parent of ${entry}`;
|
|
76
|
+
if (throwOnInvalidStop) {
|
|
77
|
+
throw new Error(message);
|
|
78
|
+
} else if (throwOnInvalidStop !== false) {
|
|
79
|
+
console.warn(message);
|
|
80
|
+
}
|
|
81
|
+
return "";
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const entryStats = tryFileStats(entry, ["file", "directory"]);
|
|
85
|
+
if (!entryStats) {
|
|
41
86
|
return "";
|
|
42
87
|
}
|
|
43
|
-
|
|
44
|
-
fs.statSync(searchEntry).isDirectory() ? searchEntry : path.resolve(searchEntry, "..")
|
|
45
|
-
);
|
|
46
|
-
const isSearchFile = typeof searchFileOrIncludeDir === "string";
|
|
47
|
-
const searchFile = isSearchFile ? searchFileOrIncludeDir : "package.json";
|
|
88
|
+
entry = entryStats.stats.isDirectory() ? entryStats.filepath : path.dirname(entryStats.filepath);
|
|
48
89
|
do {
|
|
49
|
-
const searched = tryFile(
|
|
50
|
-
path.resolve(searchEntry, searchFile),
|
|
51
|
-
isSearchFile && includeDir
|
|
52
|
-
);
|
|
90
|
+
const searched = tryFile(search, type, entry);
|
|
53
91
|
if (searched) {
|
|
54
92
|
return searched;
|
|
55
93
|
}
|
|
56
|
-
|
|
57
|
-
|
|
94
|
+
const lastEntry = entry;
|
|
95
|
+
entry = path.dirname(entry);
|
|
96
|
+
if (entry === lastEntry) {
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
} while (!stop || entry !== stop);
|
|
58
100
|
return "";
|
|
59
101
|
};
|
|
60
102
|
|
|
@@ -66,4 +108,5 @@ exports.findUp = findUp;
|
|
|
66
108
|
exports.isPkgAvailable = isPkgAvailable;
|
|
67
109
|
exports.tryExtensions = tryExtensions;
|
|
68
110
|
exports.tryFile = tryFile;
|
|
111
|
+
exports.tryFileStats = tryFileStats;
|
|
69
112
|
exports.tryPkg = tryPkg;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pkgr/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Shared core module for `@pkgr` packages or any package else",
|
|
6
6
|
"repository": "git+https://github.com/un-ts/pkgr.git",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"funding": "https://opencollective.com/pkgr",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"engines": {
|
|
12
|
-
"node": "^
|
|
12
|
+
"node": "^14.18.0 || >=16.0.0"
|
|
13
13
|
},
|
|
14
14
|
"main": "./lib/index.cjs",
|
|
15
15
|
"types": "./index.d.cts",
|