@stryke/fs 0.21.3 â 0.22.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/README.md +2 -1
- package/dist/index.cjs +11 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +1 -1
- package/dist/registry.cjs +95 -0
- package/dist/registry.d.ts +41 -0
- package/dist/registry.mjs +1 -0
- package/package.json +17 -3
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ This package is part of Storm Software's **đŠī¸ Stryke** monorepo. Stryke pac
|
|
|
22
22
|
|
|
23
23
|
<h3 align="center">đģ Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
|
|
24
24
|
|
|
25
|
-
[](https://prettier.io/) [](http://nx.dev/) [](https://nextjs.org/) [](http://commitizen.github.io/cz-cli/)  [](https://fumadocs.vercel.app/) 
|
|
26
26
|
|
|
27
27
|
> [!IMPORTANT] Important
|
|
28
28
|
> This repository, and the apps, libraries, and tools contained within, is still in it's initial development phase. As a result, bugs and issues are expected with it's usage. When the main development phase completes, a proper release will be performed, the packages will be available through NPM (and other distributions), and this message will be removed. However, in the meantime, please feel free to report any issues you may come across.
|
|
@@ -48,6 +48,7 @@ provides a more modern and functional approach to working with the file system.
|
|
|
48
48
|
|
|
49
49
|
<!-- START doctoc -->
|
|
50
50
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
51
|
+
|
|
51
52
|
## Table of Contents
|
|
52
53
|
|
|
53
54
|
- [Installing](#installing)
|
package/dist/index.cjs
CHANGED
|
@@ -135,6 +135,17 @@ Object.keys(_readFile).forEach(function (key) {
|
|
|
135
135
|
}
|
|
136
136
|
});
|
|
137
137
|
});
|
|
138
|
+
var _registry = require("./registry.cjs");
|
|
139
|
+
Object.keys(_registry).forEach(function (key) {
|
|
140
|
+
if (key === "default" || key === "__esModule") return;
|
|
141
|
+
if (key in exports && exports[key] === _registry[key]) return;
|
|
142
|
+
Object.defineProperty(exports, key, {
|
|
143
|
+
enumerable: true,
|
|
144
|
+
get: function () {
|
|
145
|
+
return _registry[key];
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
});
|
|
138
149
|
var _removeFile = require("./remove-file.cjs");
|
|
139
150
|
Object.keys(_removeFile).forEach(function (key) {
|
|
140
151
|
if (key === "default" || key === "__esModule") return;
|
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./buffer";export*from"./chmod-x";export*from"./command-exists";export*from"./compress";export*from"./constants";export*from"./copy-file";export*from"./helpers";export*from"./install";export*from"./json";export*from"./list-files";export*from"./package-fns";export*from"./read-file";export*from"./remove-file";export*from"./semver-fns";export*from"./toml";export*from"./tsconfig";export*from"./write-file";export*from"./yaml";
|
|
1
|
+
export*from"./buffer";export*from"./chmod-x";export*from"./command-exists";export*from"./compress";export*from"./constants";export*from"./copy-file";export*from"./helpers";export*from"./install";export*from"./json";export*from"./list-files";export*from"./package-fns";export*from"./read-file";export*from"./registry";export*from"./remove-file";export*from"./semver-fns";export*from"./toml";export*from"./tsconfig";export*from"./write-file";export*from"./yaml";
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.formatNodeOptions = formatNodeOptions;
|
|
7
|
+
exports.getFormattedNodeOptionsWithoutInspect = getFormattedNodeOptionsWithoutInspect;
|
|
8
|
+
exports.getParsedNodeOptionsWithoutInspect = getParsedNodeOptionsWithoutInspect;
|
|
9
|
+
exports.getRegistry = getRegistry;
|
|
10
|
+
exports.tokenizeArgs = void 0;
|
|
11
|
+
var _installPkg = require("@antfu/install-pkg");
|
|
12
|
+
var _getWorkspaceRoot = require("@stryke/path/get-workspace-root");
|
|
13
|
+
var _nodeChild_process = require("node:child_process");
|
|
14
|
+
var _nodeUtil = require("node:util");
|
|
15
|
+
const l = n => {
|
|
16
|
+
const {
|
|
17
|
+
values: t,
|
|
18
|
+
tokens: r
|
|
19
|
+
} = (0, _nodeUtil.parseArgs)({
|
|
20
|
+
args: n,
|
|
21
|
+
strict: !1,
|
|
22
|
+
tokens: !0
|
|
23
|
+
});
|
|
24
|
+
let o = null;
|
|
25
|
+
for (let s = 0; s < r.length; s++) {
|
|
26
|
+
const e = r[s];
|
|
27
|
+
if (e.kind === "option-terminator") break;
|
|
28
|
+
if (e.kind === "option") {
|
|
29
|
+
o = typeof e.value > "u" ? e : null;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (e.kind !== "positional") {
|
|
33
|
+
o = null;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
o && (o.name in t && typeof t[o.name] == "string" ? t[o.name] += ` ${e.value}` : t[o.name] = e.value);
|
|
37
|
+
}
|
|
38
|
+
return t;
|
|
39
|
+
};
|
|
40
|
+
const tokenizeArgs = n => {
|
|
41
|
+
const t = [];
|
|
42
|
+
let r = !1,
|
|
43
|
+
o = !0;
|
|
44
|
+
for (let s = 0; s < n.length; s++) {
|
|
45
|
+
let e = n[s];
|
|
46
|
+
if (e === "\\" && r) {
|
|
47
|
+
if (n.length === s + 1) throw new Error("Invalid escape character at the end.");
|
|
48
|
+
e = n[++s];
|
|
49
|
+
} else if (e === " " && !r) {
|
|
50
|
+
o = !0;
|
|
51
|
+
continue;
|
|
52
|
+
} else if (e === '"') {
|
|
53
|
+
r = !r;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
o ? (t.push(e), o = !1) : t[t.length - 1] += e;
|
|
57
|
+
}
|
|
58
|
+
if (r) throw new Error("Unterminated string");
|
|
59
|
+
return t;
|
|
60
|
+
};
|
|
61
|
+
exports.tokenizeArgs = tokenizeArgs;
|
|
62
|
+
const f = () => process.env.NODE_OPTIONS ? tokenizeArgs(process.env.NODE_OPTIONS) : [];
|
|
63
|
+
function formatNodeOptions(n) {
|
|
64
|
+
return Object.entries(n).map(([t, r]) => r === !0 ? `--${t}` : r ? `--${t}=${r.includes(" ") && !r.startsWith('"') ? JSON.stringify(r) : r}` : null).filter(t => t !== null).join(" ");
|
|
65
|
+
}
|
|
66
|
+
function getParsedNodeOptionsWithoutInspect() {
|
|
67
|
+
const n = f();
|
|
68
|
+
if (n.length === 0) return {};
|
|
69
|
+
const t = l(n);
|
|
70
|
+
return delete t.inspect, delete t["inspect-brk"], delete t.inspect_brk, t;
|
|
71
|
+
}
|
|
72
|
+
function getFormattedNodeOptionsWithoutInspect() {
|
|
73
|
+
const n = getParsedNodeOptionsWithoutInspect();
|
|
74
|
+
return Object.keys(n).length === 0 ? "" : formatNodeOptions(n);
|
|
75
|
+
}
|
|
76
|
+
async function getRegistry(n) {
|
|
77
|
+
const t = (0, _getWorkspaceRoot.getWorkspaceRoot)(n),
|
|
78
|
+
r = await (0, _installPkg.detectPackageManager)(t),
|
|
79
|
+
o = r === "npm" ? "--no-workspaces" : "";
|
|
80
|
+
let s = "https://registry.npmjs.org/";
|
|
81
|
+
try {
|
|
82
|
+
const e = (0, _nodeChild_process.execSync)(`${r} config get registry ${o}`, {
|
|
83
|
+
env: {
|
|
84
|
+
...process.env,
|
|
85
|
+
NODE_OPTIONS: getFormattedNodeOptionsWithoutInspect()
|
|
86
|
+
}
|
|
87
|
+
}).toString().trim();
|
|
88
|
+
e.startsWith("http") && (s = e.endsWith("/") ? e : `${e}/`);
|
|
89
|
+
} catch (e) {
|
|
90
|
+
throw new Error(`Failed to get registry from "${r}".`, {
|
|
91
|
+
cause: e
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return s;
|
|
95
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tokenizes the arguments string into an array of strings, supporting quoted
|
|
3
|
+
* values and escaped characters.
|
|
4
|
+
* Converted from: https://github.com/nodejs/node/blob/c29d53c5cfc63c5a876084e788d70c9e87bed880/src/node_options.cc#L1401
|
|
5
|
+
*
|
|
6
|
+
* @param input - The arguments string to be tokenized.
|
|
7
|
+
* @returns An array of strings with the tokenized arguments.
|
|
8
|
+
*/
|
|
9
|
+
export declare const tokenizeArgs: (input: string) => string[];
|
|
10
|
+
/**
|
|
11
|
+
* Stringify the arguments to be used in a command line. It will ignore any
|
|
12
|
+
* argument that has a value of `undefined`.
|
|
13
|
+
*
|
|
14
|
+
* @param args - The arguments to be stringified.
|
|
15
|
+
* @returns A string with the arguments.
|
|
16
|
+
*/
|
|
17
|
+
export declare function formatNodeOptions(args: Record<string, string | boolean | undefined>): string;
|
|
18
|
+
/**
|
|
19
|
+
* Get the node options from the `NODE_OPTIONS` environment variable and parse
|
|
20
|
+
* them into an object without the inspect options.
|
|
21
|
+
*
|
|
22
|
+
* @returns An object with the parsed node options.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getParsedNodeOptionsWithoutInspect(): {
|
|
25
|
+
[longOption: string]: string | boolean | undefined;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Get the node options from the `NODE_OPTIONS` environment variable and format
|
|
29
|
+
* them into a string without the inspect options.
|
|
30
|
+
*
|
|
31
|
+
* @returns A string with the formatted node options.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getFormattedNodeOptionsWithoutInspect(): string;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the package registry using the user's package manager. The URL will have a trailing slash.
|
|
36
|
+
*
|
|
37
|
+
* @param baseDir - The base directory to detect the package manager from.
|
|
38
|
+
* @returns The package registry URL with a trailing slash.
|
|
39
|
+
* @throws Will throw an error if the package manager cannot be detected or if the registry cannot be retrieved.
|
|
40
|
+
*/
|
|
41
|
+
export declare function getRegistry(baseDir?: string): Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{detectPackageManager as i}from"@antfu/install-pkg";import{getWorkspaceRoot as c}from"@stryke/path/get-workspace-root";import{execSync as a}from"node:child_process";import{parseArgs as g}from"node:util";const l=n=>{const{values:t,tokens:r}=g({args:n,strict:!1,tokens:!0});let o=null;for(let s=0;s<r.length;s++){const e=r[s];if(e.kind==="option-terminator")break;if(e.kind==="option"){o=typeof e.value>"u"?e:null;continue}if(e.kind!=="positional"){o=null;continue}o&&(o.name in t&&typeof t[o.name]=="string"?t[o.name]+=` ${e.value}`:t[o.name]=e.value)}return t};export const tokenizeArgs=n=>{const t=[];let r=!1,o=!0;for(let s=0;s<n.length;s++){let e=n[s];if(e==="\\"&&r){if(n.length===s+1)throw new Error("Invalid escape character at the end.");e=n[++s]}else if(e===" "&&!r){o=!0;continue}else if(e==='"'){r=!r;continue}o?(t.push(e),o=!1):t[t.length-1]+=e}if(r)throw new Error("Unterminated string");return t};const f=()=>process.env.NODE_OPTIONS?tokenizeArgs(process.env.NODE_OPTIONS):[];export function formatNodeOptions(n){return Object.entries(n).map(([t,r])=>r===!0?`--${t}`:r?`--${t}=${r.includes(" ")&&!r.startsWith('"')?JSON.stringify(r):r}`:null).filter(t=>t!==null).join(" ")}export function getParsedNodeOptionsWithoutInspect(){const n=f();if(n.length===0)return{};const t=l(n);return delete t.inspect,delete t["inspect-brk"],delete t.inspect_brk,t}export function getFormattedNodeOptionsWithoutInspect(){const n=getParsedNodeOptionsWithoutInspect();return Object.keys(n).length===0?"":formatNodeOptions(n)}export async function getRegistry(n){const t=c(n),r=await i(t),o=r==="npm"?"--no-workspaces":"";let s="https://registry.npmjs.org/";try{const e=a(`${r} config get registry ${o}`,{env:{...process.env,NODE_OPTIONS:getFormattedNodeOptionsWithoutInspect()}}).toString().trim();e.startsWith("http")&&(s=e.endsWith("/")?e:`${e}/`)}catch(e){throw new Error(`Failed to get registry from "${r}".`,{cause:e})}return s}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/fs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.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": {
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@antfu/install-pkg": "^1.0.0",
|
|
16
16
|
"@ltd/j-toml": "^1.38.0",
|
|
17
|
-
"@stryke/convert": "^0.2.
|
|
18
|
-
"@stryke/path": "^0.8.
|
|
17
|
+
"@stryke/convert": "^0.2.3",
|
|
18
|
+
"@stryke/path": "^0.8.1",
|
|
19
19
|
"@zkochan/js-yaml": "^0.0.7",
|
|
20
20
|
"chalk": "^5.4.1",
|
|
21
21
|
"defu": "^6.1.4",
|
|
@@ -143,6 +143,20 @@
|
|
|
143
143
|
"default": "./dist/remove-file.mjs"
|
|
144
144
|
}
|
|
145
145
|
},
|
|
146
|
+
"./registry": {
|
|
147
|
+
"import": {
|
|
148
|
+
"types": "./dist/registry.d.ts",
|
|
149
|
+
"default": "./dist/registry.mjs"
|
|
150
|
+
},
|
|
151
|
+
"require": {
|
|
152
|
+
"types": "./dist/registry.d.ts",
|
|
153
|
+
"default": "./dist/registry.cjs"
|
|
154
|
+
},
|
|
155
|
+
"default": {
|
|
156
|
+
"types": "./dist/registry.d.ts",
|
|
157
|
+
"default": "./dist/registry.mjs"
|
|
158
|
+
}
|
|
159
|
+
},
|
|
146
160
|
"./read-file": {
|
|
147
161
|
"import": {
|
|
148
162
|
"types": "./dist/read-file.d.ts",
|