@stryke/fs 0.32.1 → 0.32.2
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/get-parent-path.cjs
CHANGED
|
@@ -9,19 +9,20 @@ var _cwd = require("@stryke/path/cwd");
|
|
|
9
9
|
var _joinPaths = require("@stryke/path/join-paths");
|
|
10
10
|
var _resolveParentPath = require("@stryke/path/resolve-parent-path");
|
|
11
11
|
var _nodeFs = require("node:fs");
|
|
12
|
-
|
|
12
|
+
var _isFile = require("./is-file.cjs");
|
|
13
|
+
const getParentPath = (m, o = (0, _cwd.cwd)(), r = {}) => {
|
|
13
14
|
const f = r?.ignoreCase ?? !0,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
let e =
|
|
17
|
-
|
|
18
|
-
let n = (0, _toArray.toArray)(
|
|
15
|
+
l = r?.skipCwd ?? !1,
|
|
16
|
+
c = r?.includeNameInResults ?? !1;
|
|
17
|
+
let e = o;
|
|
18
|
+
l && (e = (0, _resolveParentPath.resolveParentPath)(o));
|
|
19
|
+
let n = (0, _toArray.toArray)(m);
|
|
19
20
|
for (f && (n = n.map(t => t.toLowerCase()));;) {
|
|
20
|
-
const t = n.find(
|
|
21
|
-
if (t) return
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
24
|
-
e =
|
|
21
|
+
const t = n.find(p => (0, _nodeFs.existsSync)((0, _joinPaths.joinPaths)(e, p)));
|
|
22
|
+
if (t) return c || (0, _isFile.isDirectory)((0, _joinPaths.joinPaths)(e, t)) ? (0, _joinPaths.joinPaths)(e, t) : e;
|
|
23
|
+
const s = (0, _resolveParentPath.resolveParentPath)(e);
|
|
24
|
+
if (s === e) return;
|
|
25
|
+
e = s;
|
|
25
26
|
}
|
|
26
27
|
};
|
|
27
28
|
exports.getParentPath = getParentPath;
|
package/dist/get-parent-path.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{toArray as
|
|
1
|
+
import{toArray as u}from"@stryke/convert/to-array";import{cwd as d}from"@stryke/path/cwd";import{joinPaths as i}from"@stryke/path/join-paths";import{resolveParentPath as a}from"@stryke/path/resolve-parent-path";import{existsSync as P}from"node:fs";import{isDirectory as g}from"./is-file";export const getParentPath=(m,o=d(),r={})=>{const f=r?.ignoreCase??!0,l=r?.skipCwd??!1,c=r?.includeNameInResults??!1;let e=o;l&&(e=a(o));let n=u(m);for(f&&(n=n.map(t=>t.toLowerCase()));;){const t=n.find(p=>P(i(e,p)));if(t)return c||g(i(e,t))?i(e,t):e;const s=a(e);if(s===e)return;e=s}};
|
|
@@ -24,7 +24,8 @@ function getWorkspaceRoot(o = (0, _cwd.cwd)()) {
|
|
|
24
24
|
let s = (0, _getParentPath.getParentPath)(WORKSPACE_ROOT_CONTENT, o);
|
|
25
25
|
if (s) return s;
|
|
26
26
|
for (s = o; s && !(0, _isRootDir.isSystemRoot)(s);) if (s = (0, _getParentPath.getParentPath)("storm-workspace.json", s, {
|
|
27
|
-
skipCwd: !0
|
|
27
|
+
skipCwd: !0,
|
|
28
|
+
includeNameInResults: !1
|
|
28
29
|
}), s) return s;
|
|
29
30
|
return o;
|
|
30
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{findWorkspaceRootSafe as c}from"@storm-software/config-tools";import{cwd as e}from"@stryke/path/cwd";import{relativePath as
|
|
1
|
+
import{findWorkspaceRootSafe as c}from"@storm-software/config-tools";import{cwd as e}from"@stryke/path/cwd";import{relativePath as t}from"@stryke/path/file-path-fns";import{isSystemRoot as p}from"@stryke/path/is-root-dir";import{getParentPath as n}from"./get-parent-path";export const WORKSPACE_ROOT_CONTENT=[".all-contributorsrc",".commitlintrc",".github",".git",".husky",".huskyrc",".lintstagedrc",".log4brains.yml",".npmrc",".nx",".storm-workspace.js",".storm-workspace.json",".storm-workspace.ts",".storm-workspace.yaml",".storm-workspace.yml",".vscode",".whitesource","bun.lock","bun.lockb","lefthook.yaml","lefthook.yml","lerna.json","npm-lock.json","npm-lock.yaml","npm-lock.yml","npm-workspace.json","npm-workspace.yaml","npm-workspace.yml","nx.json","package-lock.json","patches","pnpm-lock.json","pnpm-lock.yaml","pnpm-lock.yml","pnpm-workspace.json","pnpm-workspace.yaml","pnpm-workspace.yml","socket.yaml","storm-workspace.js","storm-workspace.json","storm-workspace.ts","storm-workspace.yaml","storm-workspace.yml","syncpack.config.js","syncpack.json","turbo.json","yarn-lock.json","yarn-lock.yaml","yarn-lock.yml","yarn-workspace.json","yarn-workspace.yaml","yarn-workspace.yml","yarn.lock"],PROJECT_ROOT_CONTENT=[".powerlines",".storm","package.json","powerlines.json","powerlines.yaml","powerlines.yml","powerlines.toml","powerlines.config.js","powerlines.config.ts","project.json"];export function getWorkspaceRoot(o=e()){if(process.env.STORM_WORKSPACE_ROOT||process.env.NX_WORKSPACE_ROOT_PATH)return process.env.STORM_WORKSPACE_ROOT||process.env.NX_WORKSPACE_ROOT_PATH;const r=c(o);if(r)return r;let s=n(WORKSPACE_ROOT_CONTENT,o);if(s)return s;for(s=o;s&&!p(s);)if(s=n("storm-workspace.json",s,{skipCwd:!0,includeNameInResults:!1}),s)return s;return o}export function isWorkspaceRoot(o=e()){const r=getWorkspaceRoot(o);return r?r===o:!1}export function getProjectRoot(o=e()){const r=n(PROJECT_ROOT_CONTENT,o);return r||o}export function isProjectRoot(o=e()){const r=getProjectRoot(o);return r?r===o:!1}export function relativeToWorkspaceRoot(o){return t(o,getWorkspaceRoot())}export function relativeToProjectRoot(o){return t(o,getProjectRoot())}
|
package/dist/package-fns.cjs
CHANGED
|
@@ -22,7 +22,9 @@ var _getWorkspaceRoot = require("./get-workspace-root.cjs");
|
|
|
22
22
|
var _json = require("./json.cjs");
|
|
23
23
|
var _resolve = require("./resolve.cjs");
|
|
24
24
|
function getPackageManager(t = (0, _getWorkspaceRoot.getWorkspaceRoot)()) {
|
|
25
|
-
const e = (0, _getParentPath.getParentPath)(["package-lock.json", "yarn.lock", "pnpm-lock.yaml", "bun.lock"], t
|
|
25
|
+
const e = (0, _getParentPath.getParentPath)(["package-lock.json", "yarn.lock", "pnpm-lock.yaml", "bun.lock"], t, {
|
|
26
|
+
includeNameInResults: !0
|
|
27
|
+
});
|
|
26
28
|
if (!e) return "pnpm";
|
|
27
29
|
switch ((0, _filePathFns.findFileName)(e)) {
|
|
28
30
|
case "yarn.lock":
|
|
@@ -63,7 +65,8 @@ async function getPackageInfo(t, e = {}) {
|
|
|
63
65
|
}
|
|
64
66
|
async function loadPackageJson(t = (0, _getWorkspaceRoot.getWorkspaceRoot)()) {
|
|
65
67
|
const e = (0, _getParentPath.getParentPath)("package.json", t, {
|
|
66
|
-
skipCwd: !1
|
|
68
|
+
skipCwd: !1,
|
|
69
|
+
includeNameInResults: !0
|
|
67
70
|
});
|
|
68
71
|
return !e || !(0, _nodeFs.existsSync)(e) ? null : (0, _json.readJsonFile)(e);
|
|
69
72
|
}
|
package/dist/package-fns.d.ts
CHANGED
package/dist/package-fns.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{findFileName as
|
|
1
|
+
import{findFileName as f,findFilePath as r}from"@stryke/path/file-path-fns";import{joinPaths as m}from"@stryke/path/join-paths";import{getPackageName as c}from"@stryke/string-format/package";import{isString as p}from"@stryke/type-checks/is-string";import{existsSync as P}from"node:fs";import{subset as l}from"semver";import{exists as y}from"./exists";import{getParentPath as g}from"./get-parent-path";import{getWorkspaceRoot as d}from"./get-workspace-root";import{readJsonFile as k}from"./json";import{resolvePackage as u}from"./resolve";export function getPackageManager(t=d()){const e=g(["package-lock.json","yarn.lock","pnpm-lock.yaml","bun.lock"],t,{includeNameInResults:!0});if(!e)return"pnpm";switch(f(e)){case"yarn.lock":return"yarn";case"pnpm-lock.yaml":return"pnpm";case"bun.lock":return"bun";default:return"npm"}}async function v(t){let e;for(;;){if(!t)return;const n=r(t);if(n===t)return;if(t=n,e=m(t,"package.json"),await y(e))break}return e}async function x(t,e={}){const n=await u(t,e);if(n)return v(n)}export async function getPackageInfo(t,e={}){const n=await x(t,e);if(!n)return;const s=await k(n);return{name:t,version:s.version,rootPath:r(n),packageJsonPath:n,packageJson:s}}export async function loadPackageJson(t=d()){const e=g("package.json",t,{skipCwd:!1,includeNameInResults:!0});return!e||!P(e)?null:k(e)}export async function isPackageListed(t,e){const n=c(t),s=p(e)?e:e?.cwd,a=await loadPackageJson(s);return a?!!(a.dependencies&&n in a.dependencies&&a.dependencies[n]||a.devDependencies&&n in a.devDependencies&&a.devDependencies[n]):!1}export async function getPackageListing(t,e){const n=c(t),s=p(e)?e:e?.cwd,a=await loadPackageJson(s);if(!a)return;const i=a.dependencies&&n in a.dependencies?a.dependencies[n]:a.devDependencies&&n in a.devDependencies?a.devDependencies[n]:void 0,o=(a.dependencies&&n in a.dependencies?"dependencies":a.devDependencies&&n in a.devDependencies?"devDependencies":void 0)||void 0;return i&&o?{version:i,type:o}:void 0}export async function doesPackageMatch(t,e,n){const s=await getPackageListing(t,{cwd:n});return s?s.version.startsWith("catalog:")||s.version.startsWith("workspace:")||l(s.version,e):!1}export function isPackageExists(t,e={}){return!!u(t,e)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/fs",
|
|
3
|
-
"version": "0.32.
|
|
3
|
+
"version": "0.32.2",
|
|
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": {
|
|
@@ -409,5 +409,5 @@
|
|
|
409
409
|
"main": "./dist/index.cjs",
|
|
410
410
|
"module": "./dist/index.mjs",
|
|
411
411
|
"types": "./dist/index.d.ts",
|
|
412
|
-
"gitHead": "
|
|
412
|
+
"gitHead": "3c5d0e3bc5105cfc665edf33e4a495b68d64fb42"
|
|
413
413
|
}
|