@stryke/fs 0.12.1 â 0.13.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 +1 -1
- package/dist/compress.cjs +25 -0
- package/dist/compress.d.ts +11 -0
- package/dist/compress.mjs +1 -0
- package/dist/index.cjs +11 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +1 -1
- package/dist/read-file.cjs +27 -16
- package/dist/read-file.d.ts +54 -2
- package/dist/read-file.mjs +1 -1
- package/dist/write-file.cjs +41 -18
- package/dist/write-file.d.ts +27 -0
- package/dist/write-file.mjs +5 -3
- package/package.json +24 -8
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] This repository, and the apps, libraries, and tools contained
|
|
28
28
|
> within, is still in it's initial development phase. As a result, bugs and
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.compressDirectory = compressDirectory;
|
|
7
|
+
var _uint8ArrayToString = require("@stryke/convert/uint8-array-to-string");
|
|
8
|
+
var _path = require("@stryke/path");
|
|
9
|
+
var _joinPaths = require("@stryke/path/join-paths");
|
|
10
|
+
var _nanotar = require("nanotar");
|
|
11
|
+
var _listFiles = require("./list-files.cjs");
|
|
12
|
+
var _readFile = require("./read-file.cjs");
|
|
13
|
+
var _writeFile = require("./write-file.cjs");
|
|
14
|
+
async function compressDirectory(t, i) {
|
|
15
|
+
const e = await (0, _listFiles.listFiles)((0, _path.isDirectory)(t) ? (0, _joinPaths.joinPaths)(t, "**/*") : t, i),
|
|
16
|
+
s = await (0, _nanotar.createTarGzip)(await Promise.all(e.map(async o => ({
|
|
17
|
+
name: o,
|
|
18
|
+
data: await (0, _readFile.readFileIfExisting)(o)
|
|
19
|
+
}))), {
|
|
20
|
+
attrs: {
|
|
21
|
+
group: "storm-software"
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return (0, _writeFile.writeFile)(i?.destination ? (0, _path.isDirectory)(i.destination) ? (0, _joinPaths.joinPaths)(i.destination, `${new Date().getTime()}.tar.gz`) : i.destination : (0, _path.isDirectory)(t) ? `${(0, _joinPaths.joinPaths)((0, _path.resolveParentPath)(t), (0, _path.findFolderName)(t))}.tar.gz` : t, (0, _uint8ArrayToString.uint8ArrayToString)(s));
|
|
25
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { GlobOptions } from "glob";
|
|
2
|
+
export interface CompressDirectoryOptions extends GlobOptions {
|
|
3
|
+
destination?: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Compress a directory or file into a tar.gz archive.
|
|
7
|
+
*
|
|
8
|
+
* @param directory - The source directory or file/glob to compress.
|
|
9
|
+
* @param options - Options for the compression.
|
|
10
|
+
*/
|
|
11
|
+
export declare function compressDirectory(directory: string, options?: CompressDirectoryOptions): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{uint8ArrayToString as n}from"@stryke/convert/uint8-array-to-string";import{findFolderName as m,isDirectory as r,resolveParentPath as p}from"@stryke/path";import{joinPaths as a}from"@stryke/path/join-paths";import{createTarGzip as f}from"nanotar";import{listFiles as l}from"./list-files";import{readFileIfExisting as g}from"./read-file";import{writeFile as w}from"./write-file";export async function compressDirectory(t,i){const e=await l(r(t)?a(t,"**/*"):t,i),s=await f(await Promise.all(e.map(async o=>({name:o,data:await g(o)}))),{attrs:{group:"storm-software"}});return w(i?.destination?r(i.destination)?a(i.destination,`${new Date().getTime()}.tar.gz`):i.destination:r(t)?`${a(p(t),m(t))}.tar.gz`:t,n(s))}
|
package/dist/index.cjs
CHANGED
|
@@ -14,6 +14,17 @@ Object.keys(_chmodX).forEach(function (key) {
|
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
});
|
|
17
|
+
var _compress = require("./compress.cjs");
|
|
18
|
+
Object.keys(_compress).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _compress[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _compress[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
17
28
|
var _constants = require("./constants.cjs");
|
|
18
29
|
Object.keys(_constants).forEach(function (key) {
|
|
19
30
|
if (key === "default" || key === "__esModule") return;
|
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./chmod-x";export*from"./constants";export*from"./copy-file";export*from"./get-tsconfig";export*from"./helpers";export*from"./install";export*from"./list-files";export*from"./package-fns";export*from"./read-file";export*from"./remove-file";export*from"./semver-fns";export*from"./write-file";
|
|
1
|
+
export*from"./chmod-x";export*from"./compress";export*from"./constants";export*from"./copy-file";export*from"./get-tsconfig";export*from"./helpers";export*from"./install";export*from"./list-files";export*from"./package-fns";export*from"./read-file";export*from"./remove-file";export*from"./semver-fns";export*from"./write-file";
|
package/dist/read-file.cjs
CHANGED
|
@@ -9,8 +9,11 @@ exports.readFileIfExistingSync = readFileIfExistingSync;
|
|
|
9
9
|
exports.readFileSync = void 0;
|
|
10
10
|
exports.readJsonFile = readJsonFile;
|
|
11
11
|
exports.readJsonFileSync = readJsonFileSync;
|
|
12
|
+
exports.readTomlFile = readTomlFile;
|
|
13
|
+
exports.readTomlFileSync = readTomlFileSync;
|
|
12
14
|
exports.readYamlFile = readYamlFile;
|
|
13
15
|
exports.readYamlFileSync = readYamlFileSync;
|
|
16
|
+
var _jToml = require("@ltd/j-toml");
|
|
14
17
|
var _stormJson = require("@stryke/json/storm-json");
|
|
15
18
|
var _isError = require("@stryke/type-checks/is-error");
|
|
16
19
|
var _nodeFs = require("node:fs");
|
|
@@ -38,43 +41,51 @@ const readFileSync = e => {
|
|
|
38
41
|
exports.readFile = readFile;
|
|
39
42
|
exports.readFileSync = readFileSync;
|
|
40
43
|
function readJsonFileSync(e, n) {
|
|
41
|
-
const
|
|
42
|
-
n && (n.endsWithNewline =
|
|
44
|
+
const r = readFileSync(e);
|
|
45
|
+
n && (n.endsWithNewline = r.codePointAt(r.length - 1) === 10);
|
|
43
46
|
try {
|
|
44
|
-
return _stormJson.StormJSON.parseJson(
|
|
45
|
-
} catch (
|
|
46
|
-
throw (0, _isError.isError)(
|
|
47
|
+
return _stormJson.StormJSON.parseJson(r, n);
|
|
48
|
+
} catch (t) {
|
|
49
|
+
throw (0, _isError.isError)(t) ? (t.message = t.message.replace("JSON", e), t) : new Error(`Failed to parse JSON: ${e}`);
|
|
47
50
|
}
|
|
48
51
|
}
|
|
49
52
|
async function readJsonFile(e, n) {
|
|
50
|
-
const
|
|
51
|
-
n && (n.endsWithNewline =
|
|
53
|
+
const r = await readFile(e);
|
|
54
|
+
n && (n.endsWithNewline = r.codePointAt(r.length - 1) === 10);
|
|
52
55
|
try {
|
|
53
|
-
return _stormJson.StormJSON.parseJson(
|
|
54
|
-
} catch (
|
|
55
|
-
throw (0, _isError.isError)(
|
|
56
|
+
return _stormJson.StormJSON.parseJson(r, n);
|
|
57
|
+
} catch (t) {
|
|
58
|
+
throw (0, _isError.isError)(t) ? (t.message = t.message.replace("JSON", e), t) : new Error(`Failed to parse JSON: ${e}`);
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
61
|
function readYamlFileSync(e, n) {
|
|
59
|
-
const
|
|
62
|
+
const r = readFileSync(e),
|
|
60
63
|
{
|
|
61
|
-
load:
|
|
64
|
+
load: t
|
|
62
65
|
} = require("@zkochan/js-yaml");
|
|
63
|
-
return r
|
|
66
|
+
return t(r, {
|
|
64
67
|
...n,
|
|
65
68
|
filename: e
|
|
66
69
|
});
|
|
67
70
|
}
|
|
68
71
|
async function readYamlFile(e, n) {
|
|
69
|
-
const
|
|
72
|
+
const r = await readFile(e),
|
|
70
73
|
{
|
|
71
|
-
load:
|
|
74
|
+
load: t
|
|
72
75
|
} = require("@zkochan/js-yaml");
|
|
73
|
-
return r
|
|
76
|
+
return t(r, {
|
|
74
77
|
...n,
|
|
75
78
|
filename: e
|
|
76
79
|
});
|
|
77
80
|
}
|
|
81
|
+
function readTomlFileSync(e, n) {
|
|
82
|
+
const r = readFileSync(e);
|
|
83
|
+
return n?.specificationVersion ? (0, _jToml.parse)(r, n.specificationVersion, n?.multilineStringJoiner, n?.useBigInt, n?.xOptions) : (0, _jToml.parse)(r);
|
|
84
|
+
}
|
|
85
|
+
async function readTomlFile(e, n) {
|
|
86
|
+
const r = await readFile(e);
|
|
87
|
+
return n?.specificationVersion ? (0, _jToml.parse)(r, n.specificationVersion, n?.multilineStringJoiner, n?.useBigInt, n?.xOptions) : (0, _jToml.parse)(r);
|
|
88
|
+
}
|
|
78
89
|
function readFileIfExistingSync(e) {
|
|
79
90
|
return (0, _nodeFs.existsSync)(e) ? readFileSync(e) : "";
|
|
80
91
|
}
|
package/dist/read-file.d.ts
CHANGED
|
@@ -45,16 +45,68 @@ interface YamlReadOptions {
|
|
|
45
45
|
* Reads a YAML file and returns the object the YAML content represents.
|
|
46
46
|
*
|
|
47
47
|
* @param path - A path to a file.
|
|
48
|
-
* @
|
|
48
|
+
* @param options - YAML parse options
|
|
49
|
+
* @returns Object the YAML content of the file represents
|
|
49
50
|
*/
|
|
50
51
|
export declare function readYamlFileSync<T extends object = any>(path: string, options?: YamlReadOptions): T;
|
|
51
52
|
/**
|
|
52
53
|
* Reads a YAML file and returns the object the YAML content represents.
|
|
53
54
|
*
|
|
54
55
|
* @param path - A path to a file.
|
|
55
|
-
* @
|
|
56
|
+
* @param options - YAML parse options
|
|
57
|
+
* @returns Object the YAML content of the file represents
|
|
56
58
|
*/
|
|
57
59
|
export declare function readYamlFile<T extends object = any>(path: string, options?: YamlReadOptions): Promise<T>;
|
|
60
|
+
type XOptions = null | {
|
|
61
|
+
readonly keys?: null | RegExp;
|
|
62
|
+
readonly order?: boolean;
|
|
63
|
+
readonly exact?: boolean;
|
|
64
|
+
readonly multi?: boolean;
|
|
65
|
+
readonly longer?: boolean;
|
|
66
|
+
readonly string?: boolean;
|
|
67
|
+
readonly comment?: boolean;
|
|
68
|
+
readonly literal?: boolean;
|
|
69
|
+
readonly null?: boolean;
|
|
70
|
+
readonly tag?: null | (<Table extends object & {
|
|
71
|
+
[key: string | symbol]: any;
|
|
72
|
+
}, Key extends string | symbol, Array extends any[], Index extends number, Tag extends string>(this: void, each: {
|
|
73
|
+
table: Table;
|
|
74
|
+
key: Key;
|
|
75
|
+
tag: Tag;
|
|
76
|
+
} | {
|
|
77
|
+
array: Array;
|
|
78
|
+
index: Index;
|
|
79
|
+
tag: Tag;
|
|
80
|
+
} | {
|
|
81
|
+
table: Table;
|
|
82
|
+
key: Key;
|
|
83
|
+
array: Array;
|
|
84
|
+
index: Index;
|
|
85
|
+
tag: Tag;
|
|
86
|
+
}) => void);
|
|
87
|
+
};
|
|
88
|
+
interface TomlReadOptions {
|
|
89
|
+
specificationVersion?: 1.0 | 0.5 | 0.4 | 0.3 | 0.2 | 0.1;
|
|
90
|
+
multilineStringJoiner?: string;
|
|
91
|
+
useBigInt?: boolean | number;
|
|
92
|
+
xOptions?: XOptions;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Reads a TOML file and returns the object the TOML content represents.
|
|
96
|
+
*
|
|
97
|
+
* @param path - A path to a file.
|
|
98
|
+
* @param options - TOML parse options
|
|
99
|
+
* @returns Object the TOML content of the file represents
|
|
100
|
+
*/
|
|
101
|
+
export declare function readTomlFileSync<T extends object = any>(path: string, options?: TomlReadOptions): T;
|
|
102
|
+
/**
|
|
103
|
+
* Reads a TOML file and returns the object the TOML content represents.
|
|
104
|
+
*
|
|
105
|
+
* @param path - A path to a file.
|
|
106
|
+
* @param options - TOML parse options
|
|
107
|
+
* @returns Object the TOML content of the file represents
|
|
108
|
+
*/
|
|
109
|
+
export declare function readTomlFile<T extends object = any>(path: string, options?: TomlReadOptions): Promise<T>;
|
|
58
110
|
/**
|
|
59
111
|
* Reads a file if it exists, otherwise returns an empty string.
|
|
60
112
|
*
|
package/dist/read-file.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{parse as o}from"@ltd/j-toml";import{StormJSON as a}from"@stryke/json/storm-json";import{isError as i}from"@stryke/type-checks/is-error";import{existsSync as s,readFileSync as l}from"node:fs";import{readFile as c}from"node:fs/promises";export const readFileSync=e=>{try{if(!e)throw new Error("No file path provided to read data");return l(e,{encoding:"utf8"})}catch{throw new Error("An error occurred writing data to file")}},readFile=async e=>{try{if(!e)throw new Error("No file path provided to read data");return await c(e,{encoding:"utf8"})}catch{throw new Error("An error occurred writing data to file")}};export function readJsonFileSync(e,n){const r=readFileSync(e);n&&(n.endsWithNewline=r.codePointAt(r.length-1)===10);try{return a.parseJson(r,n)}catch(t){throw i(t)?(t.message=t.message.replace("JSON",e),t):new Error(`Failed to parse JSON: ${e}`)}}export async function readJsonFile(e,n){const r=await readFile(e);n&&(n.endsWithNewline=r.codePointAt(r.length-1)===10);try{return a.parseJson(r,n)}catch(t){throw i(t)?(t.message=t.message.replace("JSON",e),t):new Error(`Failed to parse JSON: ${e}`)}}export function readYamlFileSync(e,n){const r=readFileSync(e),{load:t}=require("@zkochan/js-yaml");return t(r,{...n,filename:e})}export async function readYamlFile(e,n){const r=await readFile(e),{load:t}=require("@zkochan/js-yaml");return t(r,{...n,filename:e})}export function readTomlFileSync(e,n){const r=readFileSync(e);return n?.specificationVersion?o(r,n.specificationVersion,n?.multilineStringJoiner,n?.useBigInt,n?.xOptions):o(r)}export async function readTomlFile(e,n){const r=await readFile(e);return n?.specificationVersion?o(r,n.specificationVersion,n?.multilineStringJoiner,n?.useBigInt,n?.xOptions):o(r)}export function readFileIfExistingSync(e){return s(e)?readFileSync(e):""}export async function readFileIfExisting(e){return s(e)?readFile(e):""}
|
package/dist/write-file.cjs
CHANGED
|
@@ -6,34 +6,57 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.writeFileSync = exports.writeFile = void 0;
|
|
7
7
|
exports.writeJsonFile = writeJsonFile;
|
|
8
8
|
exports.writeJsonFileSync = writeJsonFileSync;
|
|
9
|
+
exports.writeTomlFile = writeTomlFile;
|
|
10
|
+
exports.writeTomlFileSync = writeTomlFileSync;
|
|
11
|
+
var _jToml = require("@ltd/j-toml");
|
|
9
12
|
var _stormJson = require("@stryke/json/storm-json");
|
|
10
13
|
var _correctPath = require("@stryke/path/correct-path");
|
|
11
14
|
var _exists = require("@stryke/path/exists");
|
|
12
15
|
var _filePathFns = require("@stryke/path/file-path-fns");
|
|
16
|
+
var _defu = _interopRequireDefault(require("defu"));
|
|
13
17
|
var _nodeFs = require("node:fs");
|
|
14
18
|
var _promises = require("node:fs/promises");
|
|
15
19
|
var _helpers = require("./helpers.cjs");
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
(0,
|
|
20
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
|
+
const writeFileSync = (e, n = "", i = {}) => {
|
|
22
|
+
if (!e) throw new Error("No file path provided to write data");
|
|
23
|
+
const r = (0, _filePathFns.findFilePath)((0, _correctPath.correctPath)(e));
|
|
24
|
+
if (!(0, _exists.existsSync)(r)) if (i.createDirectory !== !1) (0, _helpers.createDirectorySync)(r);else throw new Error(`Directory ${r} does not exist`);
|
|
25
|
+
(0, _nodeFs.writeFileSync)(e, n || "", i);
|
|
21
26
|
},
|
|
22
|
-
writeFile = async (
|
|
23
|
-
if (!
|
|
24
|
-
const
|
|
25
|
-
if (!(0, _exists.existsSync)(
|
|
26
|
-
return (0, _promises.writeFile)(
|
|
27
|
+
writeFile = async (e, n = "", i = {}) => {
|
|
28
|
+
if (!e) throw new Error("No file path provided to read data");
|
|
29
|
+
const r = (0, _filePathFns.findFilePath)((0, _correctPath.correctPath)(e));
|
|
30
|
+
if (!(0, _exists.existsSync)(r)) if (i.createDirectory !== !1) await (0, _helpers.createDirectory)(r);else throw new Error(`Directory ${r} does not exist`);
|
|
31
|
+
return (0, _promises.writeFile)(e, n || "", i);
|
|
27
32
|
};
|
|
28
33
|
exports.writeFile = writeFile;
|
|
29
34
|
exports.writeFileSync = writeFileSync;
|
|
30
|
-
function writeJsonFileSync(
|
|
31
|
-
const
|
|
32
|
-
return writeFileSync(
|
|
33
|
-
` :
|
|
35
|
+
function writeJsonFileSync(e, n, i) {
|
|
36
|
+
const r = _stormJson.StormJSON.stringify(n, i);
|
|
37
|
+
return writeFileSync(e, i?.appendNewLine ? `${r}
|
|
38
|
+
` : r);
|
|
34
39
|
}
|
|
35
|
-
async function writeJsonFile(
|
|
36
|
-
const
|
|
37
|
-
return writeFile(
|
|
38
|
-
` :
|
|
40
|
+
async function writeJsonFile(e, n, i) {
|
|
41
|
+
const r = _stormJson.StormJSON.stringify(n);
|
|
42
|
+
return writeFile(e, i?.appendNewLine ? `${r}
|
|
43
|
+
` : r);
|
|
44
|
+
}
|
|
45
|
+
function writeTomlFileSync(e, n, i) {
|
|
46
|
+
return writeFileSync(e, (0, _jToml.stringify)(n, (0, _defu.default)(i ?? {}, {
|
|
47
|
+
newline: `
|
|
48
|
+
`,
|
|
49
|
+
newlineAround: "pairs",
|
|
50
|
+
indent: 4,
|
|
51
|
+
forceInlineArraySpacing: 1
|
|
52
|
+
})));
|
|
53
|
+
}
|
|
54
|
+
async function writeTomlFile(e, n, i) {
|
|
55
|
+
return writeFile(e, (0, _jToml.stringify)(n, (0, _defu.default)(i ?? {}, {
|
|
56
|
+
newline: `
|
|
57
|
+
`,
|
|
58
|
+
newlineAround: "pairs",
|
|
59
|
+
indent: 4,
|
|
60
|
+
forceInlineArraySpacing: 1
|
|
61
|
+
})));
|
|
39
62
|
}
|
package/dist/write-file.d.ts
CHANGED
|
@@ -53,3 +53,30 @@ export declare function writeJsonFileSync<T extends object = object>(path: strin
|
|
|
53
53
|
* @param options - JSON serialize options
|
|
54
54
|
*/
|
|
55
55
|
export declare function writeJsonFile<T extends object = object>(path: string, data: T, options?: JsonWriteOptions): Promise<void>;
|
|
56
|
+
export interface TomlWriteOptions {
|
|
57
|
+
integer?: number;
|
|
58
|
+
newline?: "\n" | "\r\n";
|
|
59
|
+
newlineAround?: "document" | "section" | "header" | "pairs" | "pair";
|
|
60
|
+
indent?: string | number;
|
|
61
|
+
T?: "T" | "t" | " ";
|
|
62
|
+
Z?: "Z" | "z";
|
|
63
|
+
xNull?: boolean;
|
|
64
|
+
xBeforeNewlineInMultilineTable?: "," | "";
|
|
65
|
+
forceInlineArraySpacing?: 0 | 1 | 2 | 3;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Reads a TOML file and returns the object the TOML content represents.
|
|
69
|
+
*
|
|
70
|
+
* @param path - A path to a file.
|
|
71
|
+
* @param data - data which should be serialized/formatted to TOML and written to the file
|
|
72
|
+
* @param options - TOML parse options
|
|
73
|
+
*/
|
|
74
|
+
export declare function writeTomlFileSync<T extends object = any>(path: string, data: T, options?: TomlWriteOptions): void;
|
|
75
|
+
/**
|
|
76
|
+
* Reads a TOML file and returns the object the TOML content represents.
|
|
77
|
+
*
|
|
78
|
+
* @param path - A path to a file.
|
|
79
|
+
* @param data - data which should be serialized/formatted to TOML and written to the file
|
|
80
|
+
* @param options - TOML parse options
|
|
81
|
+
*/
|
|
82
|
+
export declare function writeTomlFile<T extends object = any>(path: string, data: T, options?: TomlWriteOptions): Promise<void>;
|
package/dist/write-file.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import{StormJSON as
|
|
2
|
-
`:
|
|
3
|
-
`:e)}
|
|
1
|
+
import{stringify as t}from"@ltd/j-toml";import{StormJSON as o}from"@stryke/json/storm-json";import{correctPath as s}from"@stryke/path/correct-path";import{existsSync as p}from"@stryke/path/exists";import{findFilePath as c}from"@stryke/path/file-path-fns";import a from"defu";import{writeFileSync as d}from"node:fs";import{writeFile as l}from"node:fs/promises";import{createDirectory as f,createDirectorySync as m}from"./helpers";export const writeFileSync=(e,n="",i={})=>{if(!e)throw new Error("No file path provided to write data");const r=c(s(e));if(!p(r))if(i.createDirectory!==!1)m(r);else throw new Error(`Directory ${r} does not exist`);d(e,n||"",i)},writeFile=async(e,n="",i={})=>{if(!e)throw new Error("No file path provided to read data");const r=c(s(e));if(!p(r))if(i.createDirectory!==!1)await f(r);else throw new Error(`Directory ${r} does not exist`);return l(e,n||"",i)};export function writeJsonFileSync(e,n,i){const r=o.stringify(n,i);return writeFileSync(e,i?.appendNewLine?`${r}
|
|
2
|
+
`:r)}export async function writeJsonFile(e,n,i){const r=o.stringify(n);return writeFile(e,i?.appendNewLine?`${r}
|
|
3
|
+
`:r)}export function writeTomlFileSync(e,n,i){return writeFileSync(e,t(n,a(i??{},{newline:`
|
|
4
|
+
`,newlineAround:"pairs",indent:4,forceInlineArraySpacing:1})))}export async function writeTomlFile(e,n,i){return writeFile(e,t(n,a(i??{},{newline:`
|
|
5
|
+
`,newlineAround:"pairs",indent:4,forceInlineArraySpacing:1})))}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/fs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.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": {
|
|
@@ -9,25 +9,27 @@
|
|
|
9
9
|
"directory": "packages/fs"
|
|
10
10
|
},
|
|
11
11
|
"private": false,
|
|
12
|
-
"peerDependencies": { "nx": "^
|
|
12
|
+
"peerDependencies": { "nx": "^21.0.3" },
|
|
13
13
|
"peerDependenciesMeta": { "nx": { "optional": true } },
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@antfu/install-pkg": "^1.0.0",
|
|
16
|
+
"@ltd/j-toml": "^1.38.0",
|
|
17
|
+
"@stryke/convert": "^0.2.0",
|
|
18
|
+
"@stryke/path": "^0.4.14",
|
|
16
19
|
"@zkochan/js-yaml": "^0.0.7",
|
|
17
20
|
"chalk": "^5.4.1",
|
|
18
21
|
"defu": "^6.1.4",
|
|
19
22
|
"glob": "^11.0.1",
|
|
20
23
|
"nanotar": "^0.2.0",
|
|
21
24
|
"semver": "7.7.1",
|
|
22
|
-
"@stryke/json": "^0.
|
|
23
|
-
"@stryke/
|
|
24
|
-
"@stryke/
|
|
25
|
-
"@stryke/types": "^0.8.1"
|
|
25
|
+
"@stryke/json": "^0.8.2",
|
|
26
|
+
"@stryke/type-checks": "^0.3.3",
|
|
27
|
+
"@stryke/types": "^0.8.3"
|
|
26
28
|
},
|
|
27
29
|
"devDependencies": {
|
|
28
|
-
"@types/node": "^22.
|
|
30
|
+
"@types/node": "^22.14.0",
|
|
29
31
|
"@types/semver": "^7.5.8",
|
|
30
|
-
"nx": "^
|
|
32
|
+
"nx": "^21.0.3",
|
|
31
33
|
"tinyexec": "^0.3.2"
|
|
32
34
|
},
|
|
33
35
|
"publishConfig": { "access": "public" },
|
|
@@ -236,6 +238,20 @@
|
|
|
236
238
|
"default": "./dist/constants.mjs"
|
|
237
239
|
}
|
|
238
240
|
},
|
|
241
|
+
"./compress": {
|
|
242
|
+
"import": {
|
|
243
|
+
"types": "./dist/compress.d.ts",
|
|
244
|
+
"default": "./dist/compress.mjs"
|
|
245
|
+
},
|
|
246
|
+
"require": {
|
|
247
|
+
"types": "./dist/compress.d.ts",
|
|
248
|
+
"default": "./dist/compress.cjs"
|
|
249
|
+
},
|
|
250
|
+
"default": {
|
|
251
|
+
"types": "./dist/compress.d.ts",
|
|
252
|
+
"default": "./dist/compress.mjs"
|
|
253
|
+
}
|
|
254
|
+
},
|
|
239
255
|
"./chmod-x": {
|
|
240
256
|
"import": {
|
|
241
257
|
"types": "./dist/chmod-x.d.ts",
|