@guanghechen/path 1.0.0-alpha.9 → 1.0.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/CHANGELOG.md +70 -29
- package/lib/cjs/index.cjs +9 -2
- package/lib/esm/index.mjs +9 -2
- package/lib/types/index.d.ts +7 -4
- package/package.json +5 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,91 +1,132 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
3
|
+
All notable changes to this project will be documented in this file. See
|
|
4
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
## 1.0.0-alpha.18 (2024-09-18)
|
|
7
7
|
|
|
8
|
+
- :art: format codes ([177eb54](https://github.com/guanghechen/sora/commit/177eb54))
|
|
9
|
+
- :rotating_light: improve: fix lint ([3083212](https://github.com/guanghechen/sora/commit/3083212))
|
|
10
|
+
- :wrench: chore: upgrade devDependencies and fix configs
|
|
11
|
+
([230fb63](https://github.com/guanghechen/sora/commit/230fb63))
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
# Change Log
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
All notable changes to this project will be documented in this file. See
|
|
16
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
12
17
|
|
|
18
|
+
# [1.0.0-alpha.17](https://github.com/guanghechen/sora/compare/@guanghechen/path@1.0.0-alpha.16...@guanghechen/path@1.0.0-alpha.17) (2024-02-03)
|
|
13
19
|
|
|
20
|
+
### Performance Improvements
|
|
14
21
|
|
|
22
|
+
- 💄 fix lint
|
|
23
|
+
([2d5bb6f](https://github.com/guanghechen/sora/commit/2d5bb6f03d0312a42c1117d95181df8b69de827a))
|
|
24
|
+
- 🔧 fix nx scripts
|
|
25
|
+
([47bc4e6](https://github.com/guanghechen/sora/commit/47bc4e66df825cb37127219bccf60dc81d6a9b48))
|
|
26
|
+
- 🔧 update tsconfig
|
|
27
|
+
([98855bc](https://github.com/guanghechen/sora/commit/98855bcc245d98c61217c5bafc6a1b2506b7824d))
|
|
15
28
|
|
|
29
|
+
# Change Log
|
|
16
30
|
|
|
17
|
-
|
|
31
|
+
All notable changes to this project will be documented in this file. See
|
|
32
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
18
33
|
|
|
34
|
+
# [1.0.0-alpha.16](https://github.com/guanghechen/sora/compare/@guanghechen/path@1.0.0-alpha.15...@guanghechen/path@1.0.0-alpha.16) (2024-01-17)
|
|
19
35
|
|
|
20
36
|
### Performance Improvements
|
|
21
37
|
|
|
22
|
-
|
|
38
|
+
- ⬆️ fix dependencies & fix lint
|
|
39
|
+
([b94c1da](https://github.com/guanghechen/sora/commit/b94c1dab2352201f11022e7aa5820c9da149cbb7))
|
|
23
40
|
|
|
41
|
+
# [1.0.0-alpha.15](https://github.com/guanghechen/sora/compare/@guanghechen/path@1.0.0-alpha.14...@guanghechen/path@1.0.0-alpha.15) (2024-01-17)
|
|
24
42
|
|
|
43
|
+
### Performance Improvements
|
|
25
44
|
|
|
45
|
+
- 🎨 support preferSlash option
|
|
46
|
+
([cf67725](https://github.com/guanghechen/sora/commit/cf67725983902912d31033bdd652ea8dbb36dd3b))
|
|
26
47
|
|
|
48
|
+
# [1.0.0-alpha.14](https://github.com/guanghechen/sora/compare/@guanghechen/path@1.0.0-alpha.13...@guanghechen/path@1.0.0-alpha.14) (2023-12-04)
|
|
27
49
|
|
|
28
|
-
|
|
50
|
+
**Note:** Version bump only for package @guanghechen/path
|
|
29
51
|
|
|
52
|
+
# [1.0.0-alpha.13](https://github.com/guanghechen/sora/compare/@guanghechen/path@1.0.0-alpha.12...@guanghechen/path@1.0.0-alpha.13) (2023-12-02)
|
|
53
|
+
|
|
54
|
+
**Note:** Version bump only for package @guanghechen/path
|
|
55
|
+
|
|
56
|
+
# [1.0.0-alpha.12](https://github.com/guanghechen/sora/compare/@guanghechen/path@1.0.0-alpha.11...@guanghechen/path@1.0.0-alpha.12) (2023-11-29)
|
|
30
57
|
|
|
31
58
|
### Performance Improvements
|
|
32
59
|
|
|
33
|
-
|
|
60
|
+
- 🔧 no longer to require node engine version in packages
|
|
61
|
+
([6dc2014](https://github.com/guanghechen/sora/commit/6dc2014122dd44bcadc893e2ee98697265e7d61e))
|
|
34
62
|
|
|
63
|
+
# [1.0.0-alpha.11](https://github.com/guanghechen/sora/compare/@guanghechen/path@1.0.0-alpha.10...@guanghechen/path@1.0.0-alpha.11) (2023-11-18)
|
|
35
64
|
|
|
65
|
+
**Note:** Version bump only for package @guanghechen/path
|
|
36
66
|
|
|
67
|
+
# [1.0.0-alpha.10](https://github.com/guanghechen/sora/compare/@guanghechen/path@1.0.0-alpha.9...@guanghechen/path@1.0.0-alpha.10) (2023-11-18)
|
|
37
68
|
|
|
69
|
+
### Performance Improvements
|
|
38
70
|
|
|
39
|
-
|
|
71
|
+
- 🔧 upgrade engine version requirement from '>= 16.0.0' to '>= 18.0.0'
|
|
72
|
+
([ddb9521](https://github.com/guanghechen/sora/commit/ddb9521b529b2ca838554794339b9e27ac80b8aa))
|
|
40
73
|
|
|
74
|
+
# [1.0.0-alpha.9](https://github.com/guanghechen/sora/compare/@guanghechen/path@1.0.0-alpha.8...@guanghechen/path@1.0.0-alpha.9) (2023-11-07)
|
|
41
75
|
|
|
42
76
|
### Performance Improvements
|
|
43
77
|
|
|
44
|
-
|
|
78
|
+
- 🔧 make tsconfig.json tidy
|
|
79
|
+
([809f8cf](https://github.com/guanghechen/sora/commit/809f8cf6b18da2d8fbba1566a5f4a783b52683da))
|
|
45
80
|
|
|
81
|
+
# [1.0.0-alpha.8](https://github.com/guanghechen/sora/compare/@guanghechen/path@1.0.0-alpha.7...@guanghechen/path@1.0.0-alpha.8) (2023-10-25)
|
|
46
82
|
|
|
83
|
+
### Performance Improvements
|
|
47
84
|
|
|
85
|
+
- ⬆️ ugprade dependencies
|
|
86
|
+
([e8e7a92](https://github.com/guanghechen/sora/commit/e8e7a92f58fbeee3afbb04e1ef023a894249c0bc))
|
|
48
87
|
|
|
88
|
+
# [1.0.0-alpha.7](https://github.com/guanghechen/sora/compare/@guanghechen/path@1.0.0-alpha.6...@guanghechen/path@1.0.0-alpha.7) (2023-10-16)
|
|
49
89
|
|
|
50
|
-
|
|
90
|
+
### Performance Improvements
|
|
51
91
|
|
|
92
|
+
- 🎨 support 'preferSlash' option for 'relativexx' funcs
|
|
93
|
+
([e59d415](https://github.com/guanghechen/sora/commit/e59d415df8272f6a5b8afed1f57152e4b44c89b8))
|
|
52
94
|
|
|
53
|
-
|
|
95
|
+
# [1.0.0-alpha.6](https://github.com/guanghechen/sora/compare/@guanghechen/path@1.0.0-alpha.5...@guanghechen/path@1.0.0-alpha.6) (2023-10-16)
|
|
54
96
|
|
|
55
|
-
|
|
56
|
-
* 🔧 remove unnecessary devDependencies ([944f3ae](https://github.com/guanghechen/sora/commit/944f3aee64e68ce52ca30237c7d0240a82c9c58f))
|
|
97
|
+
### Performance Improvements
|
|
57
98
|
|
|
99
|
+
- :art: refactor @guanghechen/path
|
|
100
|
+
([8952da3](https://github.com/guanghechen/sora/commit/8952da3154a042a10e76b356da7461a1f8ad8582))
|
|
58
101
|
|
|
102
|
+
# [1.0.0-alpha.5](https://github.com/guanghechen/sora/compare/@guanghechen/path@1.0.0-alpha.4...@guanghechen/path@1.0.0-alpha.5) (2023-10-16)
|
|
59
103
|
|
|
104
|
+
### Performance Improvements
|
|
60
105
|
|
|
106
|
+
- :art: refactor @guanghechen/path and @guanghechen/filepath
|
|
107
|
+
([5952ac3](https://github.com/guanghechen/sora/commit/5952ac39fee92e807e3cccc8e4b4dfa1aba1fa34))
|
|
108
|
+
- 🔧 remove unnecessary devDependencies
|
|
109
|
+
([944f3ae](https://github.com/guanghechen/sora/commit/944f3aee64e68ce52ca30237c7d0240a82c9c58f))
|
|
61
110
|
|
|
62
111
|
# [1.0.0-alpha.4](https://github.com/guanghechen/sora/compare/@guanghechen/path@1.0.0-alpha.3...@guanghechen/path@1.0.0-alpha.4) (2023-10-10)
|
|
63
112
|
|
|
64
113
|
**Note:** Version bump only for package @guanghechen/path
|
|
65
114
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
115
|
# [1.0.0-alpha.3](https://github.com/guanghechen/sora/compare/@guanghechen/path@1.0.0-alpha.2...@guanghechen/path@1.0.0-alpha.3) (2023-10-09)
|
|
71
116
|
|
|
72
|
-
|
|
73
117
|
### Performance Improvements
|
|
74
118
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
119
|
+
- re-expose @guanghechen/path.types
|
|
120
|
+
([92f5299](https://github.com/guanghechen/sora/commit/92f5299a62093f5e4167dda1b57adda1a45a3c8d))
|
|
80
121
|
|
|
81
122
|
# 1.0.0-alpha.2 (2023-10-09)
|
|
82
123
|
|
|
83
|
-
|
|
84
124
|
### Features
|
|
85
125
|
|
|
86
|
-
|
|
87
|
-
|
|
126
|
+
- ✨ add @guanghechen/path
|
|
127
|
+
([cf68a08](https://github.com/guanghechen/sora/commit/cf68a08d661896d642254c58a5377b0556452cde))
|
|
88
128
|
|
|
89
129
|
### Performance Improvements
|
|
90
130
|
|
|
91
|
-
|
|
131
|
+
- ✅ update tests
|
|
132
|
+
([ad6cd01](https://github.com/guanghechen/sora/commit/ad6cd01188a9b3739dbe390053de9de3ea32770a))
|
package/lib/cjs/index.cjs
CHANGED
|
@@ -11,6 +11,10 @@ var path__default = /*#__PURE__*/_interopDefault(path);
|
|
|
11
11
|
|
|
12
12
|
const clazz$1 = 'PathResolver';
|
|
13
13
|
class PathResolver {
|
|
14
|
+
defaultPreferSlash;
|
|
15
|
+
constructor(params = {}) {
|
|
16
|
+
this.defaultPreferSlash = params.preferSlash ?? false;
|
|
17
|
+
}
|
|
14
18
|
basename(filepath) {
|
|
15
19
|
this.ensureAbsolute(filepath);
|
|
16
20
|
const p = this.normalize(filepath);
|
|
@@ -54,13 +58,15 @@ class PathResolver {
|
|
|
54
58
|
this.ensureAbsolute(filepath);
|
|
55
59
|
return this._internalNormalize(filepath);
|
|
56
60
|
}
|
|
57
|
-
relative(from, to,
|
|
61
|
+
relative(from, to, preferSlash_) {
|
|
62
|
+
const preferSlash = preferSlash_ ?? this.defaultPreferSlash;
|
|
58
63
|
this.ensureAbsolute(from, `[${clazz$1}.relative] from is not an absolute path: ${from}`);
|
|
59
64
|
this.ensureAbsolute(to, `[${clazz$1}.relative] to is not an absolute path: ${to}`);
|
|
60
65
|
const relativePath = this._internalRelative(from, to);
|
|
61
66
|
return preferSlash ? relativePath.replaceAll('\\', '/') : relativePath;
|
|
62
67
|
}
|
|
63
|
-
safeRelative(root, filepath,
|
|
68
|
+
safeRelative(root, filepath, preferSlash_) {
|
|
69
|
+
const preferSlash = preferSlash_ ?? this.defaultPreferSlash;
|
|
64
70
|
this.ensureSafeRelative(root, filepath);
|
|
65
71
|
const relativePath = this._internalSafeRelative(root, filepath);
|
|
66
72
|
return preferSlash ? relativePath.replaceAll('\\', '/') : relativePath;
|
|
@@ -268,3 +274,4 @@ Object.keys(path_types).forEach(function (k) {
|
|
|
268
274
|
get: function () { return path_types[k]; }
|
|
269
275
|
});
|
|
270
276
|
});
|
|
277
|
+
//# sourceMappingURL=index.cjs.map
|
package/lib/esm/index.mjs
CHANGED
|
@@ -5,6 +5,10 @@ export * from '@guanghechen/path.types';
|
|
|
5
5
|
|
|
6
6
|
const clazz$1 = 'PathResolver';
|
|
7
7
|
class PathResolver {
|
|
8
|
+
defaultPreferSlash;
|
|
9
|
+
constructor(params = {}) {
|
|
10
|
+
this.defaultPreferSlash = params.preferSlash ?? false;
|
|
11
|
+
}
|
|
8
12
|
basename(filepath) {
|
|
9
13
|
this.ensureAbsolute(filepath);
|
|
10
14
|
const p = this.normalize(filepath);
|
|
@@ -48,13 +52,15 @@ class PathResolver {
|
|
|
48
52
|
this.ensureAbsolute(filepath);
|
|
49
53
|
return this._internalNormalize(filepath);
|
|
50
54
|
}
|
|
51
|
-
relative(from, to,
|
|
55
|
+
relative(from, to, preferSlash_) {
|
|
56
|
+
const preferSlash = preferSlash_ ?? this.defaultPreferSlash;
|
|
52
57
|
this.ensureAbsolute(from, `[${clazz$1}.relative] from is not an absolute path: ${from}`);
|
|
53
58
|
this.ensureAbsolute(to, `[${clazz$1}.relative] to is not an absolute path: ${to}`);
|
|
54
59
|
const relativePath = this._internalRelative(from, to);
|
|
55
60
|
return preferSlash ? relativePath.replaceAll('\\', '/') : relativePath;
|
|
56
61
|
}
|
|
57
|
-
safeRelative(root, filepath,
|
|
62
|
+
safeRelative(root, filepath, preferSlash_) {
|
|
63
|
+
const preferSlash = preferSlash_ ?? this.defaultPreferSlash;
|
|
58
64
|
this.ensureSafeRelative(root, filepath);
|
|
59
65
|
const relativePath = this._internalSafeRelative(root, filepath);
|
|
60
66
|
return preferSlash ? relativePath.replaceAll('\\', '/') : relativePath;
|
|
@@ -250,3 +256,4 @@ const pathResolver = new PathResolver();
|
|
|
250
256
|
const urlPathResolver = new UrlPathResolver();
|
|
251
257
|
|
|
252
258
|
export { PathResolver, UrlPathResolver, WorkspacePathResolver, findNearestFilepath, locateNearestFilepath, pathResolver, urlPathResolver };
|
|
259
|
+
//# sourceMappingURL=index.mjs.map
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { IPathResolver, IWorkspacePathResolver } from '@guanghechen/path.types';
|
|
1
|
+
import { IPathResolver, IPathResolverParams, IWorkspacePathResolver } from '@guanghechen/path.types';
|
|
2
2
|
export * from '@guanghechen/path.types';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Locate a nearest filepath from the given `currentDir` which name included in the
|
|
5
|
+
* Locate a nearest filepath from the given `currentDir` which name included in the `filenames`.
|
|
6
6
|
*
|
|
7
7
|
* @param currentDir
|
|
8
8
|
* @param filenames
|
|
@@ -19,6 +19,8 @@ declare function locateNearestFilepath(currentDir: string, filenames: string | R
|
|
|
19
19
|
declare function findNearestFilepath(currentDir: string, predicate: (filepath: string) => boolean): string | null;
|
|
20
20
|
|
|
21
21
|
declare class PathResolver implements IPathResolver {
|
|
22
|
+
protected readonly defaultPreferSlash: boolean;
|
|
23
|
+
constructor(params?: IPathResolverParams);
|
|
22
24
|
basename(filepath: string): string;
|
|
23
25
|
ensureAbsolute(filepath: string, message?: string | undefined): void | never;
|
|
24
26
|
ensureSafeRelative(root: string, filepath: string, message?: string | undefined): void | never;
|
|
@@ -27,8 +29,8 @@ declare class PathResolver implements IPathResolver {
|
|
|
27
29
|
isSafeRelative(root: string, filepath: string): boolean;
|
|
28
30
|
join(filepath: string, ...pathPieces: string[]): string | never;
|
|
29
31
|
normalize(filepath: string): string | never;
|
|
30
|
-
relative(from: string, to: string,
|
|
31
|
-
safeRelative(root: string, filepath: string,
|
|
32
|
+
relative(from: string, to: string, preferSlash_?: boolean): string | never;
|
|
33
|
+
safeRelative(root: string, filepath: string, preferSlash_?: boolean): string;
|
|
32
34
|
safeResolve(root: string, filepath: string): string;
|
|
33
35
|
protected _internalNormalize(filepath: string): string;
|
|
34
36
|
protected _internalRelative(from_: string, to_: string): string;
|
|
@@ -69,3 +71,4 @@ declare const pathResolver: IPathResolver;
|
|
|
69
71
|
declare const urlPathResolver: IPathResolver;
|
|
70
72
|
|
|
71
73
|
export { PathResolver, UrlPathResolver, WorkspacePathResolver, findNearestFilepath, locateNearestFilepath, pathResolver, urlPathResolver };
|
|
74
|
+
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guanghechen/path",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Path utils.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "guanghechen",
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/guanghechen/sora/tree/@guanghechen/path@1.0.0
|
|
11
|
+
"url": "https://github.com/guanghechen/sora/tree/@guanghechen/path@1.0.0",
|
|
12
12
|
"directory": "packages/path"
|
|
13
13
|
},
|
|
14
|
-
"homepage": "https://github.com/guanghechen/sora/tree/@guanghechen/path@1.0.0
|
|
14
|
+
"homepage": "https://github.com/guanghechen/sora/tree/@guanghechen/path@1.0.0/packages/path#readme",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -26,9 +26,6 @@
|
|
|
26
26
|
"module": "./lib/esm/index.mjs",
|
|
27
27
|
"types": "./lib/types/index.d.ts",
|
|
28
28
|
"license": "MIT",
|
|
29
|
-
"engines": {
|
|
30
|
-
"node": ">= 16.0.0"
|
|
31
|
-
},
|
|
32
29
|
"files": [
|
|
33
30
|
"lib/",
|
|
34
31
|
"!lib/**/*.map",
|
|
@@ -37,13 +34,8 @@
|
|
|
37
34
|
"LICENSE",
|
|
38
35
|
"README.md"
|
|
39
36
|
],
|
|
40
|
-
"scripts": {
|
|
41
|
-
"build": "../../node_modules/.bin/rimraf lib/ && ../../node_modules/.bin/cross-env NODE_ENV=production ../../node_modules/.bin/rollup -c ../../rollup.config.mjs",
|
|
42
|
-
"prepublishOnly": "yarn build",
|
|
43
|
-
"test": "node --experimental-vm-modules ../../node_modules/.bin/jest --config ../../jest.config.mjs --rootDir ."
|
|
44
|
-
},
|
|
45
37
|
"dependencies": {
|
|
46
|
-
"@guanghechen/path.types": "^1.0.
|
|
38
|
+
"@guanghechen/path.types": "^1.0.1"
|
|
47
39
|
},
|
|
48
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "e4d3bb66f61d6bf0a771d6c805dc1eb1ea31361d"
|
|
49
41
|
}
|