@vyriy/path 0.1.9
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/LICENSE +21 -0
- package/README.md +43 -0
- package/index.d.ts +2 -0
- package/index.js +1 -0
- package/package.json +36 -0
- package/path.d.ts +6 -0
- package/path.js +7 -0
- package/types.d.ts +6 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vyriy contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# @vyriy/path
|
|
2
|
+
|
|
3
|
+
Shared path utilities for Vyriy projects.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
This package provides a small filesystem-oriented API rooted at the current project directory. It resolves paths relative to `PROJECT_CWD` when that environment variable is set, and otherwise falls back to `process.cwd()`.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
With npm:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @vyriy/path
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
With Yarn:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
yarn add @vyriy/path
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { directory, isEmpty, mkdir, path, readdir } from '@vyriy/path';
|
|
27
|
+
|
|
28
|
+
const packageRoot = path('packages', 'path');
|
|
29
|
+
const packageName = directory('packages', 'path');
|
|
30
|
+
|
|
31
|
+
mkdir('tmp', 'artifacts');
|
|
32
|
+
|
|
33
|
+
const entries = readdir('packages');
|
|
34
|
+
const empty = isEmpty('tmp');
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## API
|
|
38
|
+
|
|
39
|
+
- `path(...segments)` resolves an absolute path from `PROJECT_CWD` or `process.cwd()`.
|
|
40
|
+
- `directory(...segments)` returns the final path segment name.
|
|
41
|
+
- `readdir(...segments)` returns directory entries from the resolved path.
|
|
42
|
+
- `isEmpty(...segments)` returns `true` when the directory contains only ignored entries: `README.md` and `.git`.
|
|
43
|
+
- `mkdir(...segments)` creates the resolved directory recursively.
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './path.js';
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vyriy/path",
|
|
3
|
+
"version": "0.1.9",
|
|
4
|
+
"description": "Shared path utilities for Vyriy projects",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./index.js",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"types": "./index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./index.d.ts",
|
|
12
|
+
"import": "./index.js",
|
|
13
|
+
"default": "./index.js"
|
|
14
|
+
},
|
|
15
|
+
"./index": {
|
|
16
|
+
"types": "./index.d.ts",
|
|
17
|
+
"import": "./index.js",
|
|
18
|
+
"default": "./index.js"
|
|
19
|
+
},
|
|
20
|
+
"./index.js": {
|
|
21
|
+
"types": "./index.d.ts",
|
|
22
|
+
"import": "./index.js",
|
|
23
|
+
"default": "./index.js"
|
|
24
|
+
},
|
|
25
|
+
"./path": {
|
|
26
|
+
"types": "./path.d.ts",
|
|
27
|
+
"import": "./path.js",
|
|
28
|
+
"default": "./path.js"
|
|
29
|
+
},
|
|
30
|
+
"./path.js": {
|
|
31
|
+
"types": "./path.d.ts",
|
|
32
|
+
"import": "./path.js",
|
|
33
|
+
"default": "./path.js"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
package/path.d.ts
ADDED
package/path.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { mkdirSync, readdirSync, realpathSync } from 'node:fs';
|
|
2
|
+
import { basename, resolve } from 'node:path';
|
|
3
|
+
export const path = (...pathSegments) => resolve(realpathSync(process.env.PROJECT_CWD || process.cwd()), ...pathSegments);
|
|
4
|
+
export const directory = (...pathSegments) => basename(path(...pathSegments));
|
|
5
|
+
export const readdir = (...pathSegments) => readdirSync(path(...pathSegments));
|
|
6
|
+
export const isEmpty = (...pathSegments) => !readdir(...pathSegments).filter((name) => !['README.md', '.git'].includes(name)).length;
|
|
7
|
+
export const mkdir = (...pathSegments) => mkdirSync(path(...pathSegments), { recursive: true });
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type PathSegments = readonly string[];
|
|
2
|
+
export type Path = (...pathSegments: PathSegments) => string;
|
|
3
|
+
export type Directory = (...pathSegments: PathSegments) => string;
|
|
4
|
+
export type Readdir = (...pathSegments: PathSegments) => string[];
|
|
5
|
+
export type IsEmpty = (...pathSegments: PathSegments) => boolean;
|
|
6
|
+
export type Mkdir = (...pathSegments: PathSegments) => void;
|