@stryke/fs 0.27.1 → 0.28.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.
|
@@ -8,13 +8,16 @@ exports.getProjectRoot = getProjectRoot;
|
|
|
8
8
|
exports.getWorkspaceRoot = getWorkspaceRoot;
|
|
9
9
|
exports.isProjectRoot = isProjectRoot;
|
|
10
10
|
exports.isWorkspaceRoot = isWorkspaceRoot;
|
|
11
|
+
exports.relativeToProjectRoot = relativeToProjectRoot;
|
|
12
|
+
exports.relativeToWorkspaceRoot = relativeToWorkspaceRoot;
|
|
11
13
|
var _configTools = require("@storm-software/config-tools");
|
|
12
14
|
var _cwd = require("@stryke/path/cwd");
|
|
15
|
+
var _filePathFns = require("@stryke/path/file-path-fns");
|
|
13
16
|
var _getParentPath = require("@stryke/path/get-parent-path");
|
|
14
17
|
var _isRootDir = require("@stryke/path/is-root-dir");
|
|
15
18
|
const WORKSPACE_ROOT_CONTENT = exports.WORKSPACE_ROOT_CONTENT = ["package-lock.json", "yarn.lock", "pnpm-lock.yaml", "bun.lock", "nx.json", "knip.json", "pnpm-workspace.yaml", "LICENSE", ".all-contributorsrc", ".whitesource", "syncpack.config.js", "syncpack.json", "socket.yaml", "lefthook.yaml", ".npmrc", ".log4brains.yml", ".huskyrc", ".husky", ".lintstagedrc", ".commitlintrc", "lefthook.yml", ".github", ".nx", ".vscode", "patches"],
|
|
16
19
|
PROJECT_ROOT_CONTENT = exports.PROJECT_ROOT_CONTENT = ["project.json", "package.json", ".storm"];
|
|
17
|
-
function getWorkspaceRoot(o =
|
|
20
|
+
function getWorkspaceRoot(o = (0, _cwd.cwd)()) {
|
|
18
21
|
if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) return process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH;
|
|
19
22
|
const t = (0, _configTools.findWorkspaceRootSafe)(o);
|
|
20
23
|
if (t) return t;
|
|
@@ -29,11 +32,17 @@ function isWorkspaceRoot(o = (0, _cwd.cwd)()) {
|
|
|
29
32
|
const t = getWorkspaceRoot(o);
|
|
30
33
|
return t ? t === o : !1;
|
|
31
34
|
}
|
|
32
|
-
function getProjectRoot(o =
|
|
35
|
+
function getProjectRoot(o = (0, _cwd.cwd)()) {
|
|
33
36
|
const t = (0, _getParentPath.getParentPath)(PROJECT_ROOT_CONTENT, o);
|
|
34
37
|
return t || o;
|
|
35
38
|
}
|
|
36
|
-
function isProjectRoot(o =
|
|
39
|
+
function isProjectRoot(o = (0, _cwd.cwd)()) {
|
|
37
40
|
const t = getProjectRoot(o);
|
|
38
41
|
return t ? t === o : !1;
|
|
42
|
+
}
|
|
43
|
+
function relativeToWorkspaceRoot(o) {
|
|
44
|
+
return (0, _filePathFns.relativePath)(o, getWorkspaceRoot());
|
|
45
|
+
}
|
|
46
|
+
function relativeToProjectRoot(o) {
|
|
47
|
+
return (0, _filePathFns.relativePath)(o, getProjectRoot());
|
|
39
48
|
}
|
|
@@ -6,25 +6,39 @@ export declare const PROJECT_ROOT_CONTENT: string[];
|
|
|
6
6
|
* @param dir - A directory to start the search from
|
|
7
7
|
* @returns The workspace root path
|
|
8
8
|
*/
|
|
9
|
-
export declare function getWorkspaceRoot(dir?:
|
|
9
|
+
export declare function getWorkspaceRoot(dir?: any): any;
|
|
10
10
|
/**
|
|
11
11
|
* Check if the given directory is the workspace root
|
|
12
12
|
*
|
|
13
13
|
* @param dir - A directory to check
|
|
14
14
|
* @returns True if the directory is the workspace root, false otherwise
|
|
15
15
|
*/
|
|
16
|
-
export declare function isWorkspaceRoot(dir?:
|
|
16
|
+
export declare function isWorkspaceRoot(dir?: any): boolean;
|
|
17
17
|
/**
|
|
18
18
|
* Get the project root path
|
|
19
19
|
*
|
|
20
20
|
* @param dir - A directory to start the search from
|
|
21
21
|
* @returns The project root path
|
|
22
22
|
*/
|
|
23
|
-
export declare function getProjectRoot(dir?:
|
|
23
|
+
export declare function getProjectRoot(dir?: any): any;
|
|
24
24
|
/**
|
|
25
25
|
* Check if the given directory is the project root
|
|
26
26
|
*
|
|
27
27
|
* @param dir - A directory to check
|
|
28
28
|
* @returns True if the directory is the project root, false otherwise
|
|
29
29
|
*/
|
|
30
|
-
export declare function isProjectRoot(dir?:
|
|
30
|
+
export declare function isProjectRoot(dir?: any): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Find the file path relative to the workspace root path.
|
|
33
|
+
*
|
|
34
|
+
* @param filePath - The file path to process
|
|
35
|
+
* @returns The file path relative to the workspace root
|
|
36
|
+
*/
|
|
37
|
+
export declare function relativeToWorkspaceRoot(filePath: string): any;
|
|
38
|
+
/**
|
|
39
|
+
* Find the file path relative to the project root path.
|
|
40
|
+
*
|
|
41
|
+
* @param filePath - The file path to process
|
|
42
|
+
* @returns The file path relative to the project root
|
|
43
|
+
*/
|
|
44
|
+
export declare function relativeToProjectRoot(filePath: string): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{findWorkspaceRootSafe as
|
|
1
|
+
import{findWorkspaceRootSafe as c}from"@storm-software/config-tools";import{cwd as e}from"@stryke/path/cwd";import{relativePath as s}from"@stryke/path/file-path-fns";import{getParentPath as n}from"@stryke/path/get-parent-path";import{isSystemRoot as p}from"@stryke/path/is-root-dir";export const WORKSPACE_ROOT_CONTENT=["package-lock.json","yarn.lock","pnpm-lock.yaml","bun.lock","nx.json","knip.json","pnpm-workspace.yaml","LICENSE",".all-contributorsrc",".whitesource","syncpack.config.js","syncpack.json","socket.yaml","lefthook.yaml",".npmrc",".log4brains.yml",".huskyrc",".husky",".lintstagedrc",".commitlintrc","lefthook.yml",".github",".nx",".vscode","patches"],PROJECT_ROOT_CONTENT=["project.json","package.json",".storm"];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 t=c(o);if(t)return t;let r=n(WORKSPACE_ROOT_CONTENT,o);if(r)return r;for(r=o;r&&!p(r);)if(r=n("storm-workspace.json",r,{skipCwd:!0}),r)return r;return o}export function isWorkspaceRoot(o=e()){const t=getWorkspaceRoot(o);return t?t===o:!1}export function getProjectRoot(o=e()){const t=n(PROJECT_ROOT_CONTENT,o);return t||o}export function isProjectRoot(o=e()){const t=getProjectRoot(o);return t?t===o:!1}export function relativeToWorkspaceRoot(o){return s(o,getWorkspaceRoot())}export function relativeToProjectRoot(o){return s(o,getProjectRoot())}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/fs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.1",
|
|
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,9 +15,9 @@
|
|
|
15
15
|
"@antfu/install-pkg": "^1.0.0",
|
|
16
16
|
"@ltd/j-toml": "^1.38.0",
|
|
17
17
|
"@storm-software/config-tools": "latest",
|
|
18
|
-
"@stryke/convert": "^0.
|
|
18
|
+
"@stryke/convert": "^0.5.0",
|
|
19
19
|
"@stryke/path": "^0.13.1",
|
|
20
|
-
"@stryke/string-format": "^0.
|
|
20
|
+
"@stryke/string-format": "^0.11.0",
|
|
21
21
|
"@zkochan/js-yaml": "^0.0.7",
|
|
22
22
|
"chalk": "^5.4.1",
|
|
23
23
|
"defu": "^6.1.4",
|
|
@@ -395,5 +395,5 @@
|
|
|
395
395
|
"main": "./dist/index.cjs",
|
|
396
396
|
"module": "./dist/index.mjs",
|
|
397
397
|
"types": "./dist/index.d.ts",
|
|
398
|
-
"gitHead": "
|
|
398
|
+
"gitHead": "42d98e1558382fc90bcd857b1d5d1d75c546c7c6"
|
|
399
399
|
}
|