@stryke/fs 0.9.1 → 0.10.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/copy-file.cjs +11 -0
- package/dist/{files/copy-files.d.ts → copy-file.d.ts} +1 -1
- package/dist/copy-file.mjs +1 -0
- package/dist/get-tsconfig.cjs +112 -0
- package/dist/get-tsconfig.mjs +4 -0
- package/dist/{files/helpers.cjs → helpers.cjs} +1 -1
- package/dist/helpers.mjs +1 -0
- package/dist/index.cjs +118 -8
- package/dist/index.d.ts +12 -2
- package/dist/index.mjs +1 -1
- package/dist/{package/install.cjs → install.cjs} +5 -5
- package/dist/{package/install.d.ts → install.d.ts} +1 -1
- package/dist/install.mjs +1 -0
- package/dist/{files/list-files.cjs → list-files.cjs} +2 -2
- package/dist/list-files.mjs +1 -0
- package/dist/{package/package-fns.cjs → package-fns.cjs} +17 -17
- package/dist/{package/package-fns.d.ts → package-fns.d.ts} +3 -3
- package/dist/package-fns.mjs +1 -0
- package/dist/{files/read-file.cjs → read-file.cjs} +1 -1
- package/dist/read-file.mjs +1 -0
- package/dist/{package/semver-fns.d.ts → semver-fns.d.ts} +2 -2
- package/dist/{files/write-file.cjs → write-file.cjs} +3 -3
- package/dist/write-file.mjs +3 -0
- package/package.json +95 -149
- package/dist/files/copy-files.cjs +0 -15
- package/dist/files/copy-files.mjs +0 -1
- package/dist/files/helpers.mjs +0 -1
- package/dist/files/index.cjs +0 -93
- package/dist/files/index.d.ts +0 -8
- package/dist/files/index.mjs +0 -1
- package/dist/files/list-files.mjs +0 -1
- package/dist/files/read-file.mjs +0 -1
- package/dist/files/write-file.mjs +0 -3
- package/dist/package/get-tsconfig.cjs +0 -110
- package/dist/package/get-tsconfig.mjs +0 -4
- package/dist/package/index.cjs +0 -49
- package/dist/package/index.d.ts +0 -4
- package/dist/package/index.mjs +0 -1
- package/dist/package/install.mjs +0 -1
- package/dist/package/package-fns.mjs +0 -1
- /package/dist/{files/chmod-x.cjs → chmod-x.cjs} +0 -0
- /package/dist/{files/chmod-x.d.ts → chmod-x.d.ts} +0 -0
- /package/dist/{files/chmod-x.mjs → chmod-x.mjs} +0 -0
- /package/dist/{files/constants.cjs → constants.cjs} +0 -0
- /package/dist/{files/constants.d.ts → constants.d.ts} +0 -0
- /package/dist/{files/constants.mjs → constants.mjs} +0 -0
- /package/dist/{package/get-tsconfig.d.ts → get-tsconfig.d.ts} +0 -0
- /package/dist/{files/helpers.d.ts → helpers.d.ts} +0 -0
- /package/dist/{files/list-files.d.ts → list-files.d.ts} +0 -0
- /package/dist/{files/read-file.d.ts → read-file.d.ts} +0 -0
- /package/dist/{files/remove-file.cjs → remove-file.cjs} +0 -0
- /package/dist/{files/remove-file.d.ts → remove-file.d.ts} +0 -0
- /package/dist/{files/remove-file.mjs → remove-file.mjs} +0 -0
- /package/dist/{package/semver-fns.cjs → semver-fns.cjs} +0 -0
- /package/dist/{package/semver-fns.mjs → semver-fns.mjs} +0 -0
- /package/dist/{files/write-file.d.ts → write-file.d.ts} +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.copyFiles = exports.copyFile = void 0;
|
|
7
|
+
var _nodeFs = require("node:fs");
|
|
8
|
+
const copyFiles = (n, o, t) => (0, _nodeFs.cpSync)(n, o, t),
|
|
9
|
+
copyFile = (n, o) => (0, _nodeFs.copyFileSync)(n, o, _nodeFs.constants.COPYFILE_FICLONE);
|
|
10
|
+
exports.copyFile = copyFile;
|
|
11
|
+
exports.copyFiles = copyFiles;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{constants as r,copyFileSync as p,cpSync as s}from"node:fs";export const copyFiles=(n,o,t)=>s(n,o,t),copyFile=(n,o)=>p(n,o,r.COPYFILE_FICLONE);
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.loadTsConfigFile = exports.loadTsConfig = void 0;
|
|
7
|
+
var _exists = require("@stryke/path/exists");
|
|
8
|
+
var _filePathFns = require("@stryke/path/file-path-fns");
|
|
9
|
+
var _joinPaths = require("@stryke/path/join-paths");
|
|
10
|
+
var _base = require("@stryke/types/base");
|
|
11
|
+
var _nodeModule = require("node:module");
|
|
12
|
+
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
13
|
+
var _readFile = require("./read-file.cjs");
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
const g = Symbol("singleComment"),
|
|
16
|
+
y = Symbol("multiComment"),
|
|
17
|
+
E = () => "",
|
|
18
|
+
w = (e, i, c) => e.slice(i, c).replace(/\S/g, " "),
|
|
19
|
+
I = (e, i) => {
|
|
20
|
+
let c = i - 1,
|
|
21
|
+
l = 0;
|
|
22
|
+
for (; e[c] === "\\";) c -= 1, l += 1;
|
|
23
|
+
return !!(l % 2);
|
|
24
|
+
},
|
|
25
|
+
A = (e, {
|
|
26
|
+
whitespace: i = !0,
|
|
27
|
+
trailingCommas: c = !1
|
|
28
|
+
} = {}) => {
|
|
29
|
+
if (typeof e != "string") throw new TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof e}\``);
|
|
30
|
+
const l = i ? w : E;
|
|
31
|
+
let f = !1,
|
|
32
|
+
o = !1,
|
|
33
|
+
n = 0,
|
|
34
|
+
s = "",
|
|
35
|
+
m = "",
|
|
36
|
+
a = -1;
|
|
37
|
+
for (let t = 0; t < e.length; t++) {
|
|
38
|
+
const r = e[t],
|
|
39
|
+
u = e[t + 1];
|
|
40
|
+
!o && r === '"' && (I(e, t) || (f = !f)), !f && (!o && r + (u ?? _base.EMPTY_STRING) === "//" ? (s += e.slice(n, t), n = t, o = g, t++) : o === g && r + (u ?? _base.EMPTY_STRING) === `\r
|
|
41
|
+
` ? (t++, o = !1, s += l(e, n, t), n = t) : o === g && r === `
|
|
42
|
+
` ? (o = !1, s += l(e, n, t), n = t) : !o && r + (u ?? _base.EMPTY_STRING) === "/*" ? (s += e.slice(n, t), n = t, o = y, t++) : o === y && r + (u ?? _base.EMPTY_STRING) === "*/" ? (t++, o = !1, s += l(e, n, t + 1), n = t + 1) : c && !o && (a !== -1 ? r === "}" || r === "]" ? (s += e.slice(n, t), m += l(s, 0, 1) + s.slice(1), s = "", n = t, a = -1) : r !== " " && r !== " " && r !== "\r" && r !== `
|
|
43
|
+
` && (s += e.slice(n, t), n = t, a = -1) : r === "," && (m += s + e.slice(n, t), s = "", n = t, a = t)));
|
|
44
|
+
}
|
|
45
|
+
return m + s + (o ? l(e.slice(n)) : e.slice(n));
|
|
46
|
+
},
|
|
47
|
+
P = e => {
|
|
48
|
+
try {
|
|
49
|
+
return new Function(`return ${A(e).trim()}`)();
|
|
50
|
+
} catch {
|
|
51
|
+
return {};
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
U = (0, _nodeModule.createRequire)(require('url').pathToFileURL(__filename).toString()),
|
|
55
|
+
C = (e, i, c = _nodePath.default.parse(i).root) => {
|
|
56
|
+
let l = i;
|
|
57
|
+
for (; l !== c;) {
|
|
58
|
+
const f = (0, _joinPaths.joinPaths)(l, e);
|
|
59
|
+
if ((0, _exists.existsSync)(f)) return f;
|
|
60
|
+
if (!f.endsWith(".json")) {
|
|
61
|
+
const o = `${f}.json`;
|
|
62
|
+
if ((0, _exists.existsSync)(o)) return o;
|
|
63
|
+
}
|
|
64
|
+
l = _nodePath.default.dirname(l);
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
},
|
|
68
|
+
_ = (e, i) => _nodePath.default.isAbsolute(i) ? (0, _exists.existsSync)(i) ? i : null : C(i, e),
|
|
69
|
+
$ = (e, i) => _nodePath.default.isAbsolute(i) ? (0, _exists.existsSync)(i) ? i : null : i.startsWith(".") ? C(i, e) : U.resolve(i, {
|
|
70
|
+
paths: [e]
|
|
71
|
+
}),
|
|
72
|
+
O = (e = process.cwd(), i = "tsconfig.json", c = !1) => {
|
|
73
|
+
let l, f;
|
|
74
|
+
const o = _nodePath.default.resolve(e),
|
|
75
|
+
n = c ? $(o, i) : _(o, i);
|
|
76
|
+
if (!n) return null;
|
|
77
|
+
const s = P((0, _readFile.readFileSync)(n)),
|
|
78
|
+
m = _nodePath.default.dirname(n);
|
|
79
|
+
(l = s.compilerOptions) !== null && l.baseUrl && (s.compilerOptions.baseUrl = (0, _joinPaths.joinPaths)(m, s.compilerOptions.baseUrl));
|
|
80
|
+
const a = [];
|
|
81
|
+
if (s.extends) {
|
|
82
|
+
const t = Array.isArray(s.extends) ? s.extends : [s.extends],
|
|
83
|
+
r = {};
|
|
84
|
+
for (const u of t) {
|
|
85
|
+
const p = O(m, u, !0);
|
|
86
|
+
p && (Object.assign(r, {
|
|
87
|
+
...(p === null ? void 0 : p.data),
|
|
88
|
+
compilerOptions: {
|
|
89
|
+
...r.compilerOptions,
|
|
90
|
+
...((f = p === null ? void 0 : p.data) === null ? void 0 : f.compilerOptions)
|
|
91
|
+
}
|
|
92
|
+
}), a.push(...p.files));
|
|
93
|
+
}
|
|
94
|
+
Object.assign(s, {
|
|
95
|
+
...r,
|
|
96
|
+
...s,
|
|
97
|
+
compilerOptions: {
|
|
98
|
+
...r.compilerOptions,
|
|
99
|
+
...s.compilerOptions
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return s.extends = void 0, {
|
|
104
|
+
path: n,
|
|
105
|
+
data: s,
|
|
106
|
+
files: [...a, n]
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
const loadTsConfig = (e, i = "tsconfig.json") => O(e, i),
|
|
110
|
+
loadTsConfigFile = e => loadTsConfig((0, _filePathFns.findFilePath)(e), (0, _filePathFns.findFileName)(e));
|
|
111
|
+
exports.loadTsConfigFile = loadTsConfigFile;
|
|
112
|
+
exports.loadTsConfig = loadTsConfig;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{existsSync as h}from"@stryke/path/exists";import{findFileName as F,findFilePath as v}from"@stryke/path/file-path-fns";import{joinPaths as x}from"@stryke/path/join-paths";import{EMPTY_STRING as b}from"@stryke/types/base";import{createRequire as T}from"node:module";import d from"node:path";import{readFileSync as W}from"./read-file";const g=Symbol("singleComment"),y=Symbol("multiComment"),E=()=>"",w=(e,i,c)=>e.slice(i,c).replace(/\S/g," "),I=(e,i)=>{let c=i-1,l=0;for(;e[c]==="\\";)c-=1,l+=1;return!!(l%2)},A=(e,{whitespace:i=!0,trailingCommas:c=!1}={})=>{if(typeof e!="string")throw new TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof e}\``);const l=i?w:E;let f=!1,o=!1,n=0,s="",m="",a=-1;for(let t=0;t<e.length;t++){const r=e[t],u=e[t+1];!o&&r==='"'&&(I(e,t)||(f=!f)),!f&&(!o&&r+(u??b)==="//"?(s+=e.slice(n,t),n=t,o=g,t++):o===g&&r+(u??b)===`\r
|
|
2
|
+
`?(t++,o=!1,s+=l(e,n,t),n=t):o===g&&r===`
|
|
3
|
+
`?(o=!1,s+=l(e,n,t),n=t):!o&&r+(u??b)==="/*"?(s+=e.slice(n,t),n=t,o=y,t++):o===y&&r+(u??b)==="*/"?(t++,o=!1,s+=l(e,n,t+1),n=t+1):c&&!o&&(a!==-1?r==="}"||r==="]"?(s+=e.slice(n,t),m+=l(s,0,1)+s.slice(1),s="",n=t,a=-1):r!==" "&&r!==" "&&r!=="\r"&&r!==`
|
|
4
|
+
`&&(s+=e.slice(n,t),n=t,a=-1):r===","&&(m+=s+e.slice(n,t),s="",n=t,a=t)))}return m+s+(o?l(e.slice(n)):e.slice(n))},P=e=>{try{return new Function(`return ${A(e).trim()}`)()}catch{return{}}},U=T(import.meta.url),C=(e,i,c=d.parse(i).root)=>{let l=i;for(;l!==c;){const f=x(l,e);if(h(f))return f;if(!f.endsWith(".json")){const o=`${f}.json`;if(h(o))return o}l=d.dirname(l)}return null},_=(e,i)=>d.isAbsolute(i)?h(i)?i:null:C(i,e),$=(e,i)=>d.isAbsolute(i)?h(i)?i:null:i.startsWith(".")?C(i,e):U.resolve(i,{paths:[e]}),O=(e=process.cwd(),i="tsconfig.json",c=!1)=>{let l,f;const o=d.resolve(e),n=c?$(o,i):_(o,i);if(!n)return null;const s=P(W(n)),m=d.dirname(n);(l=s.compilerOptions)!==null&&l.baseUrl&&(s.compilerOptions.baseUrl=x(m,s.compilerOptions.baseUrl));const a=[];if(s.extends){const t=Array.isArray(s.extends)?s.extends:[s.extends],r={};for(const u of t){const p=O(m,u,!0);p&&(Object.assign(r,{...p===null?void 0:p.data,compilerOptions:{...r.compilerOptions,...(f=p===null?void 0:p.data)===null?void 0:f.compilerOptions}}),a.push(...p.files))}Object.assign(s,{...r,...s,compilerOptions:{...r.compilerOptions,...s.compilerOptions}})}return s.extends=void 0,{path:n,data:s,files:[...a,n]}};export const loadTsConfig=(e,i="tsconfig.json")=>O(e,i),loadTsConfigFile=e=>loadTsConfig(v(e),F(e));
|
|
@@ -9,7 +9,7 @@ exports.extractFileFromTar = extractFileFromTar;
|
|
|
9
9
|
exports.extractFileFromTarGzip = extractFileFromTarGzip;
|
|
10
10
|
exports.removeDirectory = removeDirectory;
|
|
11
11
|
exports.removeDirectorySync = removeDirectorySync;
|
|
12
|
-
var _exists = require("@stryke/path/
|
|
12
|
+
var _exists = require("@stryke/path/exists");
|
|
13
13
|
var _nanotar = require("nanotar");
|
|
14
14
|
var _nodeFs = require("node:fs");
|
|
15
15
|
var _promises = require("node:fs/promises");
|
package/dist/helpers.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{exists as c,existsSync as s}from"@stryke/path/exists";import{parseTar as y,parseTarGzip as g}from"nanotar";import{createWriteStream as u,mkdirSync as p,rmSync as w}from"node:fs";import{mkdir as a,readFile as o,rm as x}from"node:fs/promises";export function createDirectorySync(r){if(!s(r))return p(r,{recursive:!0})}export async function createDirectory(r){if(!await c(r))return a(r,{recursive:!0})}export function removeDirectorySync(r){if(s(r))return w(r,{recursive:!0})}export async function removeDirectory(r){if(s(r))return x(r,{recursive:!0})}export async function extractFileFromTar(r,i,t){const e=y(await o(r)).find(n=>n.name===i);if(!e?.data)return;await c(t)||await a(t,{recursive:!0}),u(t).write(e.data)}export async function extractFileFromTarGzip(r,i,t){const e=(await g(await o(r))).find(n=>n.name===i);if(!e?.data)return;await c(t)||await a(t,{recursive:!0}),u(t).write(e.data)}
|
package/dist/index.cjs
CHANGED
|
@@ -3,25 +3,135 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
var
|
|
7
|
-
Object.keys(
|
|
6
|
+
var _chmodX = require("./chmod-x.cjs");
|
|
7
|
+
Object.keys(_chmodX).forEach(function (key) {
|
|
8
8
|
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] ===
|
|
9
|
+
if (key in exports && exports[key] === _chmodX[key]) return;
|
|
10
10
|
Object.defineProperty(exports, key, {
|
|
11
11
|
enumerable: true,
|
|
12
12
|
get: function () {
|
|
13
|
-
return
|
|
13
|
+
return _chmodX[key];
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
});
|
|
17
|
-
var
|
|
18
|
-
Object.keys(
|
|
17
|
+
var _constants = require("./constants.cjs");
|
|
18
|
+
Object.keys(_constants).forEach(function (key) {
|
|
19
19
|
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] ===
|
|
20
|
+
if (key in exports && exports[key] === _constants[key]) return;
|
|
21
21
|
Object.defineProperty(exports, key, {
|
|
22
22
|
enumerable: true,
|
|
23
23
|
get: function () {
|
|
24
|
-
return
|
|
24
|
+
return _constants[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _copyFile = require("./copy-file.cjs");
|
|
29
|
+
Object.keys(_copyFile).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _copyFile[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _copyFile[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _getTsconfig = require("./get-tsconfig.cjs");
|
|
40
|
+
Object.keys(_getTsconfig).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _getTsconfig[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _getTsconfig[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
var _helpers = require("./helpers.cjs");
|
|
51
|
+
Object.keys(_helpers).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _helpers[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _helpers[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
var _install = require("./install.cjs");
|
|
62
|
+
Object.keys(_install).forEach(function (key) {
|
|
63
|
+
if (key === "default" || key === "__esModule") return;
|
|
64
|
+
if (key in exports && exports[key] === _install[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return _install[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
var _listFiles = require("./list-files.cjs");
|
|
73
|
+
Object.keys(_listFiles).forEach(function (key) {
|
|
74
|
+
if (key === "default" || key === "__esModule") return;
|
|
75
|
+
if (key in exports && exports[key] === _listFiles[key]) return;
|
|
76
|
+
Object.defineProperty(exports, key, {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function () {
|
|
79
|
+
return _listFiles[key];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
var _packageFns = require("./package-fns.cjs");
|
|
84
|
+
Object.keys(_packageFns).forEach(function (key) {
|
|
85
|
+
if (key === "default" || key === "__esModule") return;
|
|
86
|
+
if (key in exports && exports[key] === _packageFns[key]) return;
|
|
87
|
+
Object.defineProperty(exports, key, {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return _packageFns[key];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
var _readFile = require("./read-file.cjs");
|
|
95
|
+
Object.keys(_readFile).forEach(function (key) {
|
|
96
|
+
if (key === "default" || key === "__esModule") return;
|
|
97
|
+
if (key in exports && exports[key] === _readFile[key]) return;
|
|
98
|
+
Object.defineProperty(exports, key, {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () {
|
|
101
|
+
return _readFile[key];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
var _removeFile = require("./remove-file.cjs");
|
|
106
|
+
Object.keys(_removeFile).forEach(function (key) {
|
|
107
|
+
if (key === "default" || key === "__esModule") return;
|
|
108
|
+
if (key in exports && exports[key] === _removeFile[key]) return;
|
|
109
|
+
Object.defineProperty(exports, key, {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function () {
|
|
112
|
+
return _removeFile[key];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
var _semverFns = require("./semver-fns.cjs");
|
|
117
|
+
Object.keys(_semverFns).forEach(function (key) {
|
|
118
|
+
if (key === "default" || key === "__esModule") return;
|
|
119
|
+
if (key in exports && exports[key] === _semverFns[key]) return;
|
|
120
|
+
Object.defineProperty(exports, key, {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function () {
|
|
123
|
+
return _semverFns[key];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
var _writeFile = require("./write-file.cjs");
|
|
128
|
+
Object.keys(_writeFile).forEach(function (key) {
|
|
129
|
+
if (key === "default" || key === "__esModule") return;
|
|
130
|
+
if (key in exports && exports[key] === _writeFile[key]) return;
|
|
131
|
+
Object.defineProperty(exports, key, {
|
|
132
|
+
enumerable: true,
|
|
133
|
+
get: function () {
|
|
134
|
+
return _writeFile[key];
|
|
25
135
|
}
|
|
26
136
|
});
|
|
27
137
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -6,5 +6,15 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
|
-
export * from "./
|
|
10
|
-
export * from "./
|
|
9
|
+
export * from "./chmod-x";
|
|
10
|
+
export * from "./constants";
|
|
11
|
+
export * from "./copy-file";
|
|
12
|
+
export * from "./get-tsconfig";
|
|
13
|
+
export * from "./helpers";
|
|
14
|
+
export * from "./install";
|
|
15
|
+
export * from "./list-files";
|
|
16
|
+
export * from "./package-fns";
|
|
17
|
+
export * from "./read-file";
|
|
18
|
+
export * from "./remove-file";
|
|
19
|
+
export * from "./semver-fns";
|
|
20
|
+
export * from "./write-file";
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./files";export*from"./package";
|
|
1
|
+
export*from"./chmod-x";export*from"./constants";export*from"./copy-file";export*from"./get-tsconfig";export*from"./helpers";export*from"./install";export*from"./list-files";export*from"./package-fns";export*from"./read-file";export*from"./remove-file";export*from"./semver-fns";export*from"./write-file";
|
|
@@ -5,17 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.packageExists = exports.install = void 0;
|
|
7
7
|
var _installPkg = require("@antfu/install-pkg");
|
|
8
|
-
var _resolve = require("@stryke/path/resolve
|
|
8
|
+
var _resolve = require("@stryke/path/resolve");
|
|
9
9
|
require("tinyexec");
|
|
10
|
-
const install = (t,
|
|
11
|
-
packageExists = async (t,
|
|
12
|
-
const r = await (0, _resolve.resolve)(
|
|
10
|
+
const install = async (t, a) => (0, _installPkg.installPackage)(t, a),
|
|
11
|
+
packageExists = async (t, a) => {
|
|
12
|
+
const r = await (0, _resolve.resolve)(a?.cwd || process.cwd());
|
|
13
13
|
try {
|
|
14
14
|
(0, _resolve.resolve)(t, {
|
|
15
15
|
paths: [r]
|
|
16
16
|
});
|
|
17
17
|
} catch {
|
|
18
|
-
install(t,
|
|
18
|
+
install(t, a);
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
exports.packageExists = packageExists;
|
package/dist/install.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{installPackage as n}from"@antfu/install-pkg";import{resolve as s}from"@stryke/path/resolve";import"tinyexec";export const install=async(t,a)=>n(t,a),packageExists=async(t,a)=>{const r=await s(a?.cwd||process.cwd());try{s(t,{paths:[r]})}catch{install(t,a)}};
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.listFiles = listFiles;
|
|
7
|
-
var _isFile = require("@stryke/path/
|
|
8
|
-
var _joinPaths = require("@stryke/path/
|
|
7
|
+
var _isFile = require("@stryke/path/is-file");
|
|
8
|
+
var _joinPaths = require("@stryke/path/join-paths");
|
|
9
9
|
var _promises = require("node:fs/promises");
|
|
10
10
|
var _picomatch = _interopRequireDefault(require("picomatch"));
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isDirectory as m}from"@stryke/path/is-file";import{joinPaths as l}from"@stryke/path/join-paths";import{readdir as p}from"node:fs/promises";import o from"picomatch";export async function listFiles(e,a={}){const{ignored:t=[]}=a,r=[],n=async s=>{if(!o(s,t)){const c=await p(s);await Promise.all(c.map(async f=>{const i=l(s,f);o(i,t)||(m(i)?await n(i):r.push(i))}))}};return await n(e),r}
|
|
@@ -10,16 +10,16 @@ exports.isPackageExists = isPackageExists;
|
|
|
10
10
|
exports.isPackageListed = isPackageListed;
|
|
11
11
|
exports.loadPackageJSON = loadPackageJSON;
|
|
12
12
|
var _stormJson = require("@stryke/json/storm-json");
|
|
13
|
+
var _path = require("@stryke/path");
|
|
14
|
+
var _getParentPath = require("@stryke/path/get-parent-path");
|
|
15
|
+
var _getWorkspaceRoot = require("@stryke/path/get-workspace-root");
|
|
13
16
|
var _resolve = require("@stryke/path/resolve");
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var _getWorkspaceRoot = require("@stryke/path/workspace/get-workspace-root");
|
|
17
|
-
var _packageManager = require("@stryke/types/utility-types/package-manager");
|
|
18
|
-
var _promises = require("node:fs/promises");
|
|
17
|
+
var _packageManager = require("@stryke/types/package-manager");
|
|
18
|
+
var _readFile = require("./read-file.cjs");
|
|
19
19
|
function getPackageManager(a = (0, _getWorkspaceRoot.getWorkspaceRoot)()) {
|
|
20
20
|
const e = (0, _getParentPath.getParentPath)([_packageManager.PackageManagerLockFiles.NPM, _packageManager.PackageManagerLockFiles.YARN, _packageManager.PackageManagerLockFiles.PNPM, _packageManager.PackageManagerLockFiles.BUN], a);
|
|
21
21
|
if (!e) return _packageManager.PackageManagers.PNPM;
|
|
22
|
-
switch ((0,
|
|
22
|
+
switch ((0, _path.findFileName)(e)) {
|
|
23
23
|
case _packageManager.PackageManagerLockFiles.YARN:
|
|
24
24
|
return _packageManager.PackageManagers.YARN;
|
|
25
25
|
case _packageManager.PackageManagerLockFiles.PNPM:
|
|
@@ -34,45 +34,45 @@ async function m(a) {
|
|
|
34
34
|
let e;
|
|
35
35
|
for (;;) {
|
|
36
36
|
if (!a) return;
|
|
37
|
-
const t = (0,
|
|
37
|
+
const t = (0, _path.findFilePath)(a);
|
|
38
38
|
if (t === a) return;
|
|
39
|
-
if (a = t, e = (0,
|
|
39
|
+
if (a = t, e = (0, _path.joinPaths)(a, "package.json"), await (0, _path.exists)(e)) break;
|
|
40
40
|
}
|
|
41
41
|
return e;
|
|
42
42
|
}
|
|
43
|
-
async function
|
|
43
|
+
async function f(a, e = {}) {
|
|
44
44
|
const t = await (0, _resolve.resolvePackage)(a, e);
|
|
45
45
|
if (t) return m(t);
|
|
46
46
|
}
|
|
47
47
|
async function getPackageInfo(a, e = {}) {
|
|
48
|
-
const t = await
|
|
48
|
+
const t = await f(a, e);
|
|
49
49
|
if (!t) return;
|
|
50
|
-
const r = _stormJson.StormJSON.parse(await (0,
|
|
50
|
+
const r = _stormJson.StormJSON.parse(await (0, _readFile.readFile)(t));
|
|
51
51
|
return {
|
|
52
52
|
name: a,
|
|
53
53
|
version: r.version,
|
|
54
|
-
rootPath: (0,
|
|
54
|
+
rootPath: (0, _path.findFilePath)(t),
|
|
55
55
|
packageJsonPath: t,
|
|
56
56
|
packageJson: r
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
async function getPackageInfoSync(a, e = {}) {
|
|
60
|
-
const t = await
|
|
60
|
+
const t = await f(a, e);
|
|
61
61
|
if (!t) return;
|
|
62
|
-
const r = _stormJson.StormJSON.parse(await (0,
|
|
62
|
+
const r = _stormJson.StormJSON.parse(await (0, _readFile.readFile)(t));
|
|
63
63
|
return {
|
|
64
64
|
name: a,
|
|
65
65
|
version: r.version,
|
|
66
|
-
rootPath: (0,
|
|
66
|
+
rootPath: (0, _path.findFilePath)(t),
|
|
67
67
|
packageJsonPath: t,
|
|
68
68
|
packageJson: r
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
async function loadPackageJSON(a = (0, _getWorkspaceRoot.getWorkspaceRoot)()) {
|
|
72
|
-
|
|
72
|
+
const e = (0, _getParentPath.getParentPath)("package.json", a, {
|
|
73
73
|
skipCwd: !1
|
|
74
74
|
});
|
|
75
|
-
return !e || !(await (0,
|
|
75
|
+
return !e || !(await (0, _path.exists)(e)) ? null : _stormJson.StormJSON.parse(await (0, _readFile.readFile)(e));
|
|
76
76
|
}
|
|
77
77
|
async function isPackageListed(a, e) {
|
|
78
78
|
const t = (await loadPackageJSON(e)) ?? {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { PackageJson } from "@stryke/types/
|
|
3
|
-
import { PackageManagers } from "@stryke/types/
|
|
1
|
+
import type { PackageResolvingOptions } from "@stryke/path/resolve";
|
|
2
|
+
import type { PackageJson } from "@stryke/types/package-json";
|
|
3
|
+
import { PackageManagers } from "@stryke/types/package-manager";
|
|
4
4
|
/**
|
|
5
5
|
* Get the package manager used in the project
|
|
6
6
|
* @param dir - The path to the project
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{StormJSON as s}from"@stryke/json/storm-json";import{exists as g,findFileName as u,findFilePath as i,joinPaths as l}from"@stryke/path";import{getParentPath as P}from"@stryke/path/get-parent-path";import{getWorkspaceRoot as p}from"@stryke/path/get-workspace-root";import{resolvePackage as k}from"@stryke/path/resolve";import{PackageManagerLockFiles as n,PackageManagers as o}from"@stryke/types/package-manager";import{readFile as c}from"./read-file";export function getPackageManager(a=p()){const e=P([n.NPM,n.YARN,n.PNPM,n.BUN],a);if(!e)return o.PNPM;switch(u(e)){case n.YARN:return o.YARN;case n.PNPM:return o.PNPM;case n.BUN:return o.BUN;default:return o.NPM}}async function m(a){let e;for(;;){if(!a)return;const t=i(a);if(t===a)return;if(a=t,e=l(a,"package.json"),await g(e))break}return e}async function f(a,e={}){const t=await k(a,e);if(t)return m(t)}export async function getPackageInfo(a,e={}){const t=await f(a,e);if(!t)return;const r=s.parse(await c(t));return{name:a,version:r.version,rootPath:i(t),packageJsonPath:t,packageJson:r}}export async function getPackageInfoSync(a,e={}){const t=await f(a,e);if(!t)return;const r=s.parse(await c(t));return{name:a,version:r.version,rootPath:i(t),packageJsonPath:t,packageJson:r}}export async function loadPackageJSON(a=p()){const e=P("package.json",a,{skipCwd:!1});return!e||!await g(e)?null:s.parse(await c(e))}export async function isPackageListed(a,e){const t=await loadPackageJSON(e)??{};return a in(t.dependencies??{})||a in(t.devDependencies??{})}export function isPackageExists(a,e={}){return!!k(a,e)}
|
|
@@ -12,7 +12,7 @@ exports.readJsonFileSync = readJsonFileSync;
|
|
|
12
12
|
exports.readYamlFile = readYamlFile;
|
|
13
13
|
exports.readYamlFileSync = readYamlFileSync;
|
|
14
14
|
var _stormJson = require("@stryke/json/storm-json");
|
|
15
|
-
var _isError = require("@stryke/
|
|
15
|
+
var _isError = require("@stryke/type-checks/is-error");
|
|
16
16
|
var _nodeFs = require("node:fs");
|
|
17
17
|
var _promises = require("node:fs/promises");
|
|
18
18
|
const readFileSync = e => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{StormJSON as o}from"@stryke/json/storm-json";import{isError as i}from"@stryke/type-checks/is-error";import{existsSync as s,readFileSync as a}from"node:fs";import{readFile as c}from"node:fs/promises";export const readFileSync=e=>{try{if(!e)throw new Error("No file path provided to read data");return a(e,{encoding:"utf8"})}catch{throw new Error("An error occurred writing data to file")}},readFile=async e=>{try{if(!e)throw new Error("No file path provided to read data");return await c(e,{encoding:"utf8"})}catch{throw new Error("An error occurred writing data to file")}};export function readJsonFileSync(e,n){const t=readFileSync(e);n&&(n.endsWithNewline=t.codePointAt(t.length-1)===10);try{return o.parseJson(t,n)}catch(r){throw i(r)?(r.message=r.message.replace("JSON",e),r):new Error(`Failed to parse JSON: ${e}`)}}export async function readJsonFile(e,n){const t=await readFile(e);n&&(n.endsWithNewline=t.codePointAt(t.length-1)===10);try{return o.parseJson(t,n)}catch(r){throw i(r)?(r.message=r.message.replace("JSON",e),r):new Error(`Failed to parse JSON: ${e}`)}}export function readYamlFileSync(e,n){const t=readFileSync(e),{load:r}=require("@zkochan/js-yaml");return r(t,{...n,filename:e})}export async function readYamlFile(e,n){const t=await readFile(e),{load:r}=require("@zkochan/js-yaml");return r(t,{...n,filename:e})}export function readFileIfExistingSync(e){return s(e)?readFileSync(e):""}export async function readFileIfExisting(e){return s(e)?readFile(e):""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const parseVersion: (semver: string) =>
|
|
1
|
+
import type { ReleaseType } from "semver";
|
|
2
|
+
export declare const parseVersion: (semver: string) => import("semver").SemVer | null;
|
|
3
3
|
export declare const isRelativeVersionKeyword: (val: string) => val is ReleaseType;
|
|
4
4
|
export declare const deriveNewSemverVersion: (currentSemverVersion: string, semverSpecifier: string, preid?: string) => string;
|
|
@@ -7,9 +7,9 @@ exports.writeFileSync = exports.writeFile = void 0;
|
|
|
7
7
|
exports.writeJsonFile = writeJsonFile;
|
|
8
8
|
exports.writeJsonFileSync = writeJsonFileSync;
|
|
9
9
|
var _stormJson = require("@stryke/json/storm-json");
|
|
10
|
-
var _exists = require("@stryke/path/
|
|
11
|
-
var _filePathFns = require("@stryke/path/
|
|
12
|
-
var _normalizePath = require("@stryke/path/
|
|
10
|
+
var _exists = require("@stryke/path/exists");
|
|
11
|
+
var _filePathFns = require("@stryke/path/file-path-fns");
|
|
12
|
+
var _normalizePath = require("@stryke/path/normalize-path");
|
|
13
13
|
var _nodeFs = require("node:fs");
|
|
14
14
|
var _promises = require("node:fs/promises");
|
|
15
15
|
var _helpers = require("./helpers.cjs");
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{StormJSON as i}from"@stryke/json/storm-json";import{existsSync as n}from"@stryke/path/exists";import{findFilePath as s}from"@stryke/path/file-path-fns";import{normalizePath as p}from"@stryke/path/normalize-path";import{writeFileSync as c}from"node:fs";import{writeFile as d}from"node:fs/promises";import{createDirectory as a,createDirectorySync as f}from"./helpers";export const writeFileSync=(r,o,t)=>{if(!r)throw new Error("No file path provided to write data");const e=s(p(r));if(!n(e))if(t?.createDirectory!==!1)f(e);else throw new Error(`Directory ${e} does not exist`);c(r,o||"",t)},writeFile=async(r,o,t)=>{if(!r)throw new Error("No file path provided to read data");const e=s(p(r));if(!n(e))if(t?.createDirectory!==!1)await a(e);else throw new Error(`Directory ${e} does not exist`);return d(r,o||"",t)};export function writeJsonFileSync(r,o,t){const e=i.stringify(o,t);return writeFileSync(r,t?.appendNewLine?`${e}
|
|
2
|
+
`:e)}export async function writeJsonFile(r,o,t){const e=i.stringify(o);return writeFile(r,t?.appendNewLine?`${e}
|
|
3
|
+
`:e)}
|