@stryke/fs 0.13.0 → 0.14.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/package-fns.cjs +38 -36
- package/dist/package-fns.mjs +1 -1
- package/package.json +2 -2
package/dist/package-fns.cjs
CHANGED
|
@@ -15,10 +15,10 @@ var _getParentPath = require("@stryke/path/get-parent-path");
|
|
|
15
15
|
var _getWorkspaceRoot = require("@stryke/path/get-workspace-root");
|
|
16
16
|
var _resolve = require("@stryke/path/resolve");
|
|
17
17
|
var _readFile = require("./read-file.cjs");
|
|
18
|
-
function getPackageManager(
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
21
|
-
switch ((0, _path.findFileName)(
|
|
18
|
+
function getPackageManager(e = (0, _getWorkspaceRoot.getWorkspaceRoot)()) {
|
|
19
|
+
const n = (0, _getParentPath.getParentPath)(["package-lock.json", "yarn.lock", "pnpm-lock.yaml", "bun.lock"], e);
|
|
20
|
+
if (!n) return "pnpm";
|
|
21
|
+
switch ((0, _path.findFileName)(n)) {
|
|
22
22
|
case "yarn.lock":
|
|
23
23
|
return "yarn";
|
|
24
24
|
case "pnpm-lock.yaml":
|
|
@@ -29,54 +29,56 @@ function getPackageManager(a = (0, _getWorkspaceRoot.getWorkspaceRoot)()) {
|
|
|
29
29
|
return "npm";
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
async function
|
|
33
|
-
let
|
|
32
|
+
async function u(e) {
|
|
33
|
+
let n;
|
|
34
34
|
for (;;) {
|
|
35
|
-
if (!
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
38
|
-
if (
|
|
35
|
+
if (!e) return;
|
|
36
|
+
const a = (0, _path.findFilePath)(e);
|
|
37
|
+
if (a === e) return;
|
|
38
|
+
if (e = a, n = (0, _path.joinPaths)(e, "package.json"), await (0, _path.exists)(n)) break;
|
|
39
39
|
}
|
|
40
|
-
return
|
|
40
|
+
return n;
|
|
41
41
|
}
|
|
42
|
-
async function k(
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
42
|
+
async function k(e, n = {}) {
|
|
43
|
+
const a = await (0, _resolve.resolvePackage)(e, n);
|
|
44
|
+
if (a) return u(a);
|
|
45
45
|
}
|
|
46
|
-
async function getPackageInfo(
|
|
47
|
-
const
|
|
48
|
-
if (!
|
|
49
|
-
const t = _stormJson.StormJSON.parse(await (0, _readFile.readFile)(
|
|
46
|
+
async function getPackageInfo(e, n = {}) {
|
|
47
|
+
const a = await k(e, n);
|
|
48
|
+
if (!a) return;
|
|
49
|
+
const t = _stormJson.StormJSON.parse(await (0, _readFile.readFile)(a));
|
|
50
50
|
return {
|
|
51
|
-
name:
|
|
51
|
+
name: e,
|
|
52
52
|
version: t.version,
|
|
53
|
-
rootPath: (0, _path.findFilePath)(
|
|
54
|
-
packageJsonPath:
|
|
53
|
+
rootPath: (0, _path.findFilePath)(a),
|
|
54
|
+
packageJsonPath: a,
|
|
55
55
|
packageJson: t
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
async function getPackageInfoSync(
|
|
59
|
-
const
|
|
60
|
-
if (!
|
|
61
|
-
const t = _stormJson.StormJSON.parse(await (0, _readFile.readFile)(
|
|
58
|
+
async function getPackageInfoSync(e, n = {}) {
|
|
59
|
+
const a = await k(e, n);
|
|
60
|
+
if (!a) return;
|
|
61
|
+
const t = _stormJson.StormJSON.parse(await (0, _readFile.readFile)(a));
|
|
62
62
|
return {
|
|
63
|
-
name:
|
|
63
|
+
name: e,
|
|
64
64
|
version: t.version,
|
|
65
|
-
rootPath: (0, _path.findFilePath)(
|
|
66
|
-
packageJsonPath:
|
|
65
|
+
rootPath: (0, _path.findFilePath)(a),
|
|
66
|
+
packageJsonPath: a,
|
|
67
67
|
packageJson: t
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
|
-
async function loadPackageJSON(
|
|
71
|
-
const
|
|
70
|
+
async function loadPackageJSON(e = (0, _getWorkspaceRoot.getWorkspaceRoot)()) {
|
|
71
|
+
const n = (0, _getParentPath.getParentPath)("package.json", e, {
|
|
72
72
|
skipCwd: !1
|
|
73
73
|
});
|
|
74
|
-
return !
|
|
74
|
+
return !n || !(await (0, _path.exists)(n)) ? null : _stormJson.StormJSON.parse(await (0, _readFile.readFile)(n));
|
|
75
75
|
}
|
|
76
|
-
async function isPackageListed(
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
async function isPackageListed(e, n) {
|
|
77
|
+
let a = e;
|
|
78
|
+
a.includes("@") && (a = !a.startsWith("@") || a.lastIndexOf("@") > 0 ? a.slice(0, a.lastIndexOf("@")) : a);
|
|
79
|
+
const t = (await loadPackageJSON(n)) ?? {};
|
|
80
|
+
return a in (t.dependencies ?? {}) || a in (t.devDependencies ?? {});
|
|
79
81
|
}
|
|
80
|
-
function isPackageExists(
|
|
81
|
-
return !!(0, _resolve.resolvePackage)(
|
|
82
|
+
function isPackageExists(e, n = {}) {
|
|
83
|
+
return !!(0, _resolve.resolvePackage)(e, n);
|
|
82
84
|
}
|
package/dist/package-fns.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{StormJSON as o}from"@stryke/json/storm-json";import{exists as i,findFileName as
|
|
1
|
+
import{StormJSON as o}from"@stryke/json/storm-json";import{exists as i,findFileName as l,findFilePath as r,joinPaths as f}from"@stryke/path";import{getParentPath as c}from"@stryke/path/get-parent-path";import{getWorkspaceRoot as g}from"@stryke/path/get-workspace-root";import{resolvePackage as p}from"@stryke/path/resolve";import{readFile as s}from"./read-file";export function getPackageManager(e=g()){const n=c(["package-lock.json","yarn.lock","pnpm-lock.yaml","bun.lock"],e);if(!n)return"pnpm";switch(l(n)){case"yarn.lock":return"yarn";case"pnpm-lock.yaml":return"pnpm";case"bun.lock":return"bun";default:return"npm"}}async function u(e){let n;for(;;){if(!e)return;const a=r(e);if(a===e)return;if(e=a,n=f(e,"package.json"),await i(n))break}return n}async function k(e,n={}){const a=await p(e,n);if(a)return u(a)}export async function getPackageInfo(e,n={}){const a=await k(e,n);if(!a)return;const t=o.parse(await s(a));return{name:e,version:t.version,rootPath:r(a),packageJsonPath:a,packageJson:t}}export async function getPackageInfoSync(e,n={}){const a=await k(e,n);if(!a)return;const t=o.parse(await s(a));return{name:e,version:t.version,rootPath:r(a),packageJsonPath:a,packageJson:t}}export async function loadPackageJSON(e=g()){const n=c("package.json",e,{skipCwd:!1});return!n||!await i(n)?null:o.parse(await s(n))}export async function isPackageListed(e,n){let a=e;a.includes("@")&&(a=!a.startsWith("@")||a.lastIndexOf("@")>0?a.slice(0,a.lastIndexOf("@")):a);const t=await loadPackageJSON(n)??{};return a in(t.dependencies??{})||a in(t.devDependencies??{})}export function isPackageExists(e,n={}){return!!p(e,n)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/fs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing various file system utilities that expand the functionality of NodeJs's built-in `fs` module.",
|
|
6
6
|
"repository": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@antfu/install-pkg": "^1.0.0",
|
|
16
16
|
"@ltd/j-toml": "^1.38.0",
|
|
17
17
|
"@stryke/convert": "^0.2.0",
|
|
18
|
-
"@stryke/path": "^0.
|
|
18
|
+
"@stryke/path": "^0.5.0",
|
|
19
19
|
"@zkochan/js-yaml": "^0.0.7",
|
|
20
20
|
"chalk": "^5.4.1",
|
|
21
21
|
"defu": "^6.1.4",
|