@stryke/fs 0.25.0 → 0.27.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/dist/compress.cjs CHANGED
@@ -8,18 +8,19 @@ var _uint8ArrayToString = require("@stryke/convert/uint8-array-to-string");
8
8
  var _path = require("@stryke/path");
9
9
  var _joinPaths = require("@stryke/path/join-paths");
10
10
  var _nanotar = require("nanotar");
11
+ var _isFile = require("./is-file.cjs");
11
12
  var _listFiles = require("./list-files.cjs");
12
13
  var _readFile = require("./read-file.cjs");
13
14
  var _writeFile = require("./write-file.cjs");
14
15
  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)
16
+ const e = await (0, _listFiles.listFiles)((0, _isFile.isDirectory)(t) ? (0, _joinPaths.joinPaths)(t, "**/*") : t, i),
17
+ s = await (0, _nanotar.createTarGzip)(await Promise.all(e.map(async a => ({
18
+ name: a,
19
+ data: await (0, _readFile.readFileIfExisting)(a)
19
20
  }))), {
20
21
  attrs: {
21
22
  group: "storm-software"
22
23
  }
23
24
  });
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
+ return (0, _writeFile.writeFile)(i?.destination ? (0, _isFile.isDirectory)(i.destination) ? (0, _joinPaths.joinPaths)(i.destination, `${new Date().getTime()}.tar.gz`) : i.destination : (0, _isFile.isDirectory)(t) ? `${(0, _joinPaths.joinPaths)((0, _path.resolveParentPath)(t), (0, _path.findFolderName)(t))}.tar.gz` : t, (0, _uint8ArrayToString.uint8ArrayToString)(s));
25
26
  }
package/dist/compress.mjs CHANGED
@@ -1 +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))}
1
+ import{uint8ArrayToString as n}from"@stryke/convert/uint8-array-to-string";import{findFolderName as m,resolveParentPath as p}from"@stryke/path";import{joinPaths as r}from"@stryke/path/join-paths";import{createTarGzip as f}from"nanotar";import{isDirectory as o}from"./is-file";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(o(t)?r(t,"**/*"):t,i),s=await f(await Promise.all(e.map(async a=>({name:a,data:await g(a)}))),{attrs:{group:"storm-software"}});return w(i?.destination?o(i.destination)?r(i.destination,`${new Date().getTime()}.tar.gz`):i.destination:o(t)?`${r(p(t),m(t))}.tar.gz`:t,n(s))}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.exists = exists;
7
+ exports.existsSync = existsSync;
8
+ var _nodeFs = require("node:fs");
9
+ var _promises = require("node:fs/promises");
10
+ function existsSync(s) {
11
+ return (0, _nodeFs.existsSync)(s);
12
+ }
13
+ async function exists(s) {
14
+ return (0, _promises.access)(s, _promises.constants.F_OK).then(() => !0).catch(() => !1);
15
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Check if a file exists
3
+ *
4
+ * @param filePath - The file path to check
5
+ * @returns An indicator specifying if the file exists
6
+ */
7
+ export declare function existsSync(filePath: string): boolean;
8
+ /**
9
+ * Check if a file exists
10
+ *
11
+ * @param filePath - The file path to check
12
+ * @returns An indicator specifying if the file exists
13
+ */
14
+ export declare function exists(filePath: string): Promise<boolean>;
@@ -0,0 +1 @@
1
+ import{existsSync as t}from"node:fs";import{access as n,constants as e}from"node:fs/promises";export function existsSync(s){return t(s)}export async function exists(s){return n(s,e.F_OK).then(()=>!0).catch(()=>!1)}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.WORKSPACE_ROOT_CONTENT = exports.PROJECT_ROOT_CONTENT = void 0;
7
+ exports.getProjectRoot = getProjectRoot;
8
+ exports.getWorkspaceRoot = getWorkspaceRoot;
9
+ exports.isProjectRoot = isProjectRoot;
10
+ exports.isWorkspaceRoot = isWorkspaceRoot;
11
+ var _configTools = require("@storm-software/config-tools");
12
+ var _cwd = require("@stryke/path/cwd");
13
+ var _getParentPath = require("@stryke/path/get-parent-path");
14
+ var _isRootDir = require("@stryke/path/is-root-dir");
15
+ 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
+ PROJECT_ROOT_CONTENT = exports.PROJECT_ROOT_CONTENT = ["project.json", "package.json", ".storm"];
17
+ function getWorkspaceRoot(o = process.cwd()) {
18
+ 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
+ const t = (0, _configTools.findWorkspaceRootSafe)(o);
20
+ if (t) return t;
21
+ let r = (0, _getParentPath.getParentPath)(WORKSPACE_ROOT_CONTENT, o);
22
+ if (r) return r;
23
+ for (r = o; r && !(0, _isRootDir.isSystemRoot)(r);) if (r = (0, _getParentPath.getParentPath)("storm-workspace.json", r, {
24
+ skipCwd: !0
25
+ }), r) return r;
26
+ return o;
27
+ }
28
+ function isWorkspaceRoot(o = (0, _cwd.cwd)()) {
29
+ const t = getWorkspaceRoot(o);
30
+ return t ? t === o : !1;
31
+ }
32
+ function getProjectRoot(o = process.cwd()) {
33
+ const t = (0, _getParentPath.getParentPath)(PROJECT_ROOT_CONTENT, o);
34
+ return t || o;
35
+ }
36
+ function isProjectRoot(o = process.cwd()) {
37
+ const t = getProjectRoot(o);
38
+ return t ? t === o : !1;
39
+ }
@@ -0,0 +1,30 @@
1
+ export declare const WORKSPACE_ROOT_CONTENT: string[];
2
+ export declare const PROJECT_ROOT_CONTENT: string[];
3
+ /**
4
+ * Get the workspace root path
5
+ *
6
+ * @param dir - A directory to start the search from
7
+ * @returns The workspace root path
8
+ */
9
+ export declare function getWorkspaceRoot(dir?: string): any;
10
+ /**
11
+ * Check if the given directory is the workspace root
12
+ *
13
+ * @param dir - A directory to check
14
+ * @returns True if the directory is the workspace root, false otherwise
15
+ */
16
+ export declare function isWorkspaceRoot(dir?: string): boolean;
17
+ /**
18
+ * Get the project root path
19
+ *
20
+ * @param dir - A directory to start the search from
21
+ * @returns The project root path
22
+ */
23
+ export declare function getProjectRoot(dir?: string): any;
24
+ /**
25
+ * Check if the given directory is the project root
26
+ *
27
+ * @param dir - A directory to check
28
+ * @returns True if the directory is the project root, false otherwise
29
+ */
30
+ export declare function isProjectRoot(dir?: string): boolean;
@@ -0,0 +1 @@
1
+ import{findWorkspaceRootSafe as e}from"@storm-software/config-tools";import{cwd as n}from"@stryke/path/cwd";import{getParentPath as s}from"@stryke/path/get-parent-path";import{isSystemRoot as c}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=process.cwd()){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=e(o);if(t)return t;let r=s(WORKSPACE_ROOT_CONTENT,o);if(r)return r;for(r=o;r&&!c(r);)if(r=s("storm-workspace.json",r,{skipCwd:!0}),r)return r;return o}export function isWorkspaceRoot(o=n()){const t=getWorkspaceRoot(o);return t?t===o:!1}export function getProjectRoot(o=process.cwd()){const t=s(PROJECT_ROOT_CONTENT,o);return t||o}export function isProjectRoot(o=process.cwd()){const t=getProjectRoot(o);return t?t===o:!1}
package/dist/helpers.cjs CHANGED
@@ -9,10 +9,10 @@ exports.extractFileFromTar = extractFileFromTar;
9
9
  exports.extractFileFromTarGzip = extractFileFromTarGzip;
10
10
  exports.removeDirectory = removeDirectory;
11
11
  exports.removeDirectorySync = removeDirectorySync;
12
- var _exists = require("@stryke/path/exists");
13
12
  var _nanotar = require("nanotar");
14
13
  var _nodeFs = require("node:fs");
15
14
  var _promises = require("node:fs/promises");
15
+ var _exists = require("./exists.cjs");
16
16
  function createDirectorySync(r) {
17
17
  if (!(0, _exists.existsSync)(r)) return (0, _nodeFs.mkdirSync)(r, {
18
18
  recursive: !0
package/dist/helpers.mjs CHANGED
@@ -1 +1 @@
1
- import{exists as c,existsSync as s}from"@stryke/path/exists";import{parseTar as y,parseTarGzip as g}from"nanotar";import{createWriteStream as u,mkdirSync as p,rmSync as w}from"node:fs";import{mkdir as a,readFile as o,rm as x}from"node:fs/promises";export function createDirectorySync(r){if(!s(r))return p(r,{recursive:!0})}export async function createDirectory(r){if(!await c(r))return a(r,{recursive:!0})}export function removeDirectorySync(r){if(s(r))return w(r,{recursive:!0})}export async function removeDirectory(r){if(s(r))return x(r,{recursive:!0})}export async function extractFileFromTar(r,i,t){const e=y(await o(r)).find(n=>n.name===i);if(!e?.data)return;await c(t)||await a(t,{recursive:!0}),u(t).write(e.data)}export async function extractFileFromTarGzip(r,i,t){const e=(await g(await o(r))).find(n=>n.name===i);if(!e?.data)return;await c(t)||await a(t,{recursive:!0}),u(t).write(e.data)}
1
+ import{parseTar as y,parseTarGzip as g}from"nanotar";import{createWriteStream as u,mkdirSync as p,rmSync as w}from"node:fs";import{mkdir as c,readFile as o,rm as x}from"node:fs/promises";import{exists as s,existsSync as a}from"./exists";export function createDirectorySync(r){if(!a(r))return p(r,{recursive:!0})}export async function createDirectory(r){if(!await s(r))return c(r,{recursive:!0})}export function removeDirectorySync(r){if(a(r))return w(r,{recursive:!0})}export async function removeDirectory(r){if(a(r))return x(r,{recursive:!0})}export async function extractFileFromTar(r,i,t){const e=y(await o(r)).find(n=>n.name===i);if(!e?.data)return;await s(t)||await c(t,{recursive:!0}),u(t).write(e.data)}export async function extractFileFromTarGzip(r,i,t){const e=(await g(await o(r))).find(n=>n.name===i);if(!e?.data)return;await s(t)||await c(t,{recursive:!0}),u(t).write(e.data)}
package/dist/index.cjs CHANGED
@@ -69,6 +69,28 @@ Object.keys(_copyFile).forEach(function (key) {
69
69
  }
70
70
  });
71
71
  });
72
+ var _exists = require("./exists.cjs");
73
+ Object.keys(_exists).forEach(function (key) {
74
+ if (key === "default" || key === "__esModule") return;
75
+ if (key in exports && exports[key] === _exists[key]) return;
76
+ Object.defineProperty(exports, key, {
77
+ enumerable: true,
78
+ get: function () {
79
+ return _exists[key];
80
+ }
81
+ });
82
+ });
83
+ var _getWorkspaceRoot = require("./get-workspace-root.cjs");
84
+ Object.keys(_getWorkspaceRoot).forEach(function (key) {
85
+ if (key === "default" || key === "__esModule") return;
86
+ if (key in exports && exports[key] === _getWorkspaceRoot[key]) return;
87
+ Object.defineProperty(exports, key, {
88
+ enumerable: true,
89
+ get: function () {
90
+ return _getWorkspaceRoot[key];
91
+ }
92
+ });
93
+ });
72
94
  var _helpers = require("./helpers.cjs");
73
95
  Object.keys(_helpers).forEach(function (key) {
74
96
  if (key === "default" || key === "__esModule") return;
@@ -91,6 +113,17 @@ Object.keys(_install).forEach(function (key) {
91
113
  }
92
114
  });
93
115
  });
116
+ var _isFile = require("./is-file.cjs");
117
+ Object.keys(_isFile).forEach(function (key) {
118
+ if (key === "default" || key === "__esModule") return;
119
+ if (key in exports && exports[key] === _isFile[key]) return;
120
+ Object.defineProperty(exports, key, {
121
+ enumerable: true,
122
+ get: function () {
123
+ return _isFile[key];
124
+ }
125
+ });
126
+ });
94
127
  var _json = require("./json.cjs");
95
128
  Object.keys(_json).forEach(function (key) {
96
129
  if (key === "default" || key === "__esModule") return;
@@ -157,6 +190,17 @@ Object.keys(_removeFile).forEach(function (key) {
157
190
  }
158
191
  });
159
192
  });
193
+ var _resolve = require("./resolve.cjs");
194
+ Object.keys(_resolve).forEach(function (key) {
195
+ if (key === "default" || key === "__esModule") return;
196
+ if (key in exports && exports[key] === _resolve[key]) return;
197
+ Object.defineProperty(exports, key, {
198
+ enumerable: true,
199
+ get: function () {
200
+ return _resolve[key];
201
+ }
202
+ });
203
+ });
160
204
  var _semverFns = require("./semver-fns.cjs");
161
205
  Object.keys(_semverFns).forEach(function (key) {
162
206
  if (key === "default" || key === "__esModule") return;
package/dist/index.d.ts CHANGED
@@ -12,14 +12,18 @@ export * from "./command-exists";
12
12
  export * from "./compress";
13
13
  export * from "./constants";
14
14
  export * from "./copy-file";
15
+ export * from "./exists";
16
+ export * from "./get-workspace-root";
15
17
  export * from "./helpers";
16
18
  export * from "./install";
19
+ export * from "./is-file";
17
20
  export * from "./json";
18
21
  export * from "./list-files";
19
22
  export * from "./package-fns";
20
23
  export * from "./read-file";
21
24
  export * from "./registry";
22
25
  export * from "./remove-file";
26
+ export * from "./resolve";
23
27
  export * from "./semver-fns";
24
28
  export * from "./toml";
25
29
  export * from "./tsconfig";
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"./registry";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"./exists";export*from"./get-workspace-root";export*from"./helpers";export*from"./install";export*from"./is-file";export*from"./json";export*from"./list-files";export*from"./package-fns";export*from"./read-file";export*from"./registry";export*from"./remove-file";export*from"./resolve";export*from"./semver-fns";export*from"./toml";export*from"./tsconfig";export*from"./write-file";export*from"./yaml";
package/dist/install.cjs CHANGED
@@ -6,13 +6,14 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.install = install;
7
7
  exports.packageExists = void 0;
8
8
  var _installPkg = require("@antfu/install-pkg");
9
- var _resolve = require("@stryke/path/resolve");
9
+ var _cwd = require("@stryke/path/cwd");
10
10
  require("tinyexec");
11
+ var _resolve = require("./resolve.cjs");
11
12
  async function install(t, a) {
12
13
  return (0, _installPkg.installPackage)(t, a);
13
14
  }
14
15
  const packageExists = async (t, a) => {
15
- const s = await (0, _resolve.resolve)(a?.cwd || process.cwd());
16
+ const s = await (0, _resolve.resolve)(a?.cwd || (0, _cwd.cwd)());
16
17
  try {
17
18
  await (0, _resolve.resolve)(t, {
18
19
  paths: [s]
package/dist/install.mjs CHANGED
@@ -1 +1 @@
1
- import{installPackage as e}from"@antfu/install-pkg";import{resolve as n}from"@stryke/path/resolve";import"tinyexec";export async function install(t,a){return e(t,a)}export const packageExists=async(t,a)=>{const s=await n(a?.cwd||process.cwd());try{await n(t,{paths:[s]})}catch{await install(t,a)}};
1
+ import{installPackage as i}from"@antfu/install-pkg";import{cwd as e}from"@stryke/path/cwd";import"tinyexec";import{resolve as n}from"./resolve";export async function install(t,a){return i(t,a)}export const packageExists=async(t,a)=>{const s=await n(a?.cwd||e());try{await n(t,{paths:[s]})}catch{await install(t,a)}};
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isDirectory = isDirectory;
7
+ exports.isDirectorySymlink = void 0;
8
+ exports.isFile = isFile;
9
+ exports.isFileSymlink = void 0;
10
+ var _joinPaths = require("@stryke/path/join-paths");
11
+ var _nodeFs = require("node:fs");
12
+ function isFile(r, o) {
13
+ return !!(0, _nodeFs.statSync)(o ? (0, _joinPaths.joinPaths)(o, r) : r, {
14
+ throwIfNoEntry: !1
15
+ })?.isFile();
16
+ }
17
+ function isDirectory(r, o) {
18
+ return !!(0, _nodeFs.statSync)(o ? (0, _joinPaths.joinPaths)(o, r) : r, {
19
+ throwIfNoEntry: !1
20
+ })?.isDirectory();
21
+ }
22
+ const isFileSymlink = (r, o) => !!(0, _nodeFs.lstatSync)(o ? (0, _joinPaths.joinPaths)(o, r) : r, {
23
+ throwIfNoEntry: !1
24
+ })?.isFile(),
25
+ isDirectorySymlink = (r, o) => !!(0, _nodeFs.lstatSync)(o ? (0, _joinPaths.joinPaths)(o, r) : r, {
26
+ throwIfNoEntry: !1
27
+ })?.isDirectory();
28
+ exports.isDirectorySymlink = isDirectorySymlink;
29
+ exports.isFileSymlink = isFileSymlink;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Check if the given path is a file.
3
+ *
4
+ * @param path - The location to check
5
+ * @param additionalPath - An optional additional path to add to the start of the path
6
+ * @returns An indicator specifying if the path is a file
7
+ */
8
+ export declare function isFile(path: string, additionalPath?: string): boolean;
9
+ /**
10
+ * Check if the given path is a directory.
11
+ *
12
+ * @param path - The location to check
13
+ * @param additionalPath - An optional additional path to add to the start of the path
14
+ * @returns An indicator specifying if the path is a directory
15
+ */
16
+ export declare function isDirectory(path: string, additionalPath?: string): boolean;
17
+ /**
18
+ * Check if the given path is a file . Does not dereference symbolic links.
19
+ *
20
+ * @param path - The location to check
21
+ * @param additionalPath - An optional additional path to add to the start of the path
22
+ * @returns An indicator specifying if the path is a file
23
+ */
24
+ export declare const isFileSymlink: (path: string, additionalPath?: string) => boolean;
25
+ /**
26
+ * Check if the given path is a directory. Does not dereference symbolic links.
27
+ *
28
+ * @param path - The location to check
29
+ * @param additionalPath - An optional additional path to add to the start of the path
30
+ * @returns An indicator specifying if the path is a directory
31
+ */
32
+ export declare const isDirectorySymlink: (path: string, additionalPath?: string) => boolean;
@@ -0,0 +1 @@
1
+ import{joinPaths as n}from"@stryke/path/join-paths";import{lstatSync as e,statSync as t}from"node:fs";export function isFile(r,o){return!!t(o?n(o,r):r,{throwIfNoEntry:!1})?.isFile()}export function isDirectory(r,o){return!!t(o?n(o,r):r,{throwIfNoEntry:!1})?.isDirectory()}export const isFileSymlink=(r,o)=>!!e(o?n(o,r):r,{throwIfNoEntry:!1})?.isFile(),isDirectorySymlink=(r,o)=>!!e(o?n(o,r):r,{throwIfNoEntry:!1})?.isDirectory();
@@ -10,19 +10,21 @@ exports.getPackageManager = getPackageManager;
10
10
  exports.isPackageExists = isPackageExists;
11
11
  exports.isPackageListed = isPackageListed;
12
12
  exports.loadPackageJson = loadPackageJson;
13
- var _path = require("@stryke/path");
13
+ var _filePathFns = require("@stryke/path/file-path-fns");
14
14
  var _getParentPath = require("@stryke/path/get-parent-path");
15
- var _getWorkspaceRoot = require("@stryke/path/get-workspace-root");
16
- var _resolve = require("@stryke/path/resolve");
15
+ var _joinPaths = require("@stryke/path/join-paths");
17
16
  var _package = require("@stryke/string-format/package");
18
17
  var _isString = require("@stryke/type-checks/is-string");
19
18
  var _nodeFs = require("node:fs");
20
19
  var _semver = require("semver");
20
+ var _exists = require("./exists.cjs");
21
+ var _getWorkspaceRoot = require("./get-workspace-root.cjs");
21
22
  var _json = require("./json.cjs");
23
+ var _resolve = require("./resolve.cjs");
22
24
  function getPackageManager(t = (0, _getWorkspaceRoot.getWorkspaceRoot)()) {
23
25
  const e = (0, _getParentPath.getParentPath)(["package-lock.json", "yarn.lock", "pnpm-lock.yaml", "bun.lock"], t);
24
26
  if (!e) return "pnpm";
25
- switch ((0, _path.findFileName)(e)) {
27
+ switch ((0, _filePathFns.findFileName)(e)) {
26
28
  case "yarn.lock":
27
29
  return "yarn";
28
30
  case "pnpm-lock.yaml":
@@ -37,9 +39,9 @@ async function v(t) {
37
39
  let e;
38
40
  for (;;) {
39
41
  if (!t) return;
40
- const n = (0, _path.findFilePath)(t);
42
+ const n = (0, _filePathFns.findFilePath)(t);
41
43
  if (n === t) return;
42
- if (t = n, e = (0, _path.joinPaths)(t, "package.json"), await (0, _path.exists)(e)) break;
44
+ if (t = n, e = (0, _joinPaths.joinPaths)(t, "package.json"), await (0, _exists.exists)(e)) break;
43
45
  }
44
46
  return e;
45
47
  }
@@ -54,7 +56,7 @@ async function getPackageInfo(t, e = {}) {
54
56
  return {
55
57
  name: t,
56
58
  version: s.version,
57
- rootPath: (0, _path.findFilePath)(n),
59
+ rootPath: (0, _filePathFns.findFilePath)(n),
58
60
  packageJsonPath: n,
59
61
  packageJson: s
60
62
  };
@@ -1,7 +1,7 @@
1
- import type { PackageResolvingOptions } from "@stryke/path/resolve";
2
1
  import type { PackageJson } from "@stryke/types/package-json";
3
2
  import type { PackageManager } from "@stryke/types/package-manager";
4
3
  import type { Range } from "semver";
4
+ import type { PackageResolvingOptions } from "./resolve";
5
5
  /**
6
6
  * Get the package manager used in the project
7
7
  * @param dir - The path to the project
@@ -1 +1 @@
1
- import{exists as u,findFileName as m,findFilePath as r,joinPaths as P}from"@stryke/path";import{getParentPath as c}from"@stryke/path/get-parent-path";import{getWorkspaceRoot as p}from"@stryke/path/get-workspace-root";import{resolvePackage as g}from"@stryke/path/resolve";import{getPackageName as d}from"@stryke/string-format/package";import{isString as k}from"@stryke/type-checks/is-string";import{existsSync as l}from"node:fs";import{subset as y}from"semver";import{readJsonFile as f}from"./json";export function getPackageManager(t=p()){const e=c(["package-lock.json","yarn.lock","pnpm-lock.yaml","bun.lock"],t);if(!e)return"pnpm";switch(m(e)){case"yarn.lock":return"yarn";case"pnpm-lock.yaml":return"pnpm";case"bun.lock":return"bun";default:return"npm"}}async function v(t){let e;for(;;){if(!t)return;const n=r(t);if(n===t)return;if(t=n,e=P(t,"package.json"),await u(e))break}return e}async function x(t,e={}){const n=await g(t,e);if(n)return v(n)}export async function getPackageInfo(t,e={}){const n=await x(t,e);if(!n)return;const s=await f(n);return{name:t,version:s.version,rootPath:r(n),packageJsonPath:n,packageJson:s}}export async function loadPackageJson(t=p()){const e=c("package.json",t,{skipCwd:!1});return!e||!l(e)?null:f(e)}export async function isPackageListed(t,e){const n=d(t),s=k(e)?e:e?.cwd,a=await loadPackageJson(s);return a?!!(a.dependencies&&n in a.dependencies&&a.dependencies[n]||a.devDependencies&&n in a.devDependencies&&a.devDependencies[n]):!1}export async function getPackageListing(t,e){const n=d(t),s=k(e)?e:e?.cwd,a=await loadPackageJson(s);if(!a)return;const i=a.dependencies&&n in a.dependencies?a.dependencies[n]:a.devDependencies&&n in a.devDependencies?a.devDependencies[n]:void 0,o=(a.dependencies&&n in a.dependencies?"dependencies":a.devDependencies&&n in a.devDependencies?"devDependencies":void 0)||void 0;return i&&o?{version:i,type:o}:void 0}export async function doesPackageMatch(t,e,n){const s=await getPackageListing(t,{cwd:n});return s?s.version.startsWith("catalog:")||s.version.startsWith("workspace:")||y(s.version,e):!1}export function isPackageExists(t,e={}){return!!g(t,e)}
1
+ import{findFileName as m,findFilePath as r}from"@stryke/path/file-path-fns";import{getParentPath as c}from"@stryke/path/get-parent-path";import{joinPaths as u}from"@stryke/path/join-paths";import{getPackageName as p}from"@stryke/string-format/package";import{isString as g}from"@stryke/type-checks/is-string";import{existsSync as P}from"node:fs";import{subset as l}from"semver";import{exists as y}from"./exists";import{getWorkspaceRoot as d}from"./get-workspace-root";import{readJsonFile as k}from"./json";import{resolvePackage as f}from"./resolve";export function getPackageManager(t=d()){const e=c(["package-lock.json","yarn.lock","pnpm-lock.yaml","bun.lock"],t);if(!e)return"pnpm";switch(m(e)){case"yarn.lock":return"yarn";case"pnpm-lock.yaml":return"pnpm";case"bun.lock":return"bun";default:return"npm"}}async function v(t){let e;for(;;){if(!t)return;const n=r(t);if(n===t)return;if(t=n,e=u(t,"package.json"),await y(e))break}return e}async function x(t,e={}){const n=await f(t,e);if(n)return v(n)}export async function getPackageInfo(t,e={}){const n=await x(t,e);if(!n)return;const s=await k(n);return{name:t,version:s.version,rootPath:r(n),packageJsonPath:n,packageJson:s}}export async function loadPackageJson(t=d()){const e=c("package.json",t,{skipCwd:!1});return!e||!P(e)?null:k(e)}export async function isPackageListed(t,e){const n=p(t),s=g(e)?e:e?.cwd,a=await loadPackageJson(s);return a?!!(a.dependencies&&n in a.dependencies&&a.dependencies[n]||a.devDependencies&&n in a.devDependencies&&a.devDependencies[n]):!1}export async function getPackageListing(t,e){const n=p(t),s=g(e)?e:e?.cwd,a=await loadPackageJson(s);if(!a)return;const i=a.dependencies&&n in a.dependencies?a.dependencies[n]:a.devDependencies&&n in a.devDependencies?a.devDependencies[n]:void 0,o=(a.dependencies&&n in a.dependencies?"dependencies":a.devDependencies&&n in a.devDependencies?"devDependencies":void 0)||void 0;return i&&o?{version:i,type:o}:void 0}export async function doesPackageMatch(t,e,n){const s=await getPackageListing(t,{cwd:n});return s?s.version.startsWith("catalog:")||s.version.startsWith("workspace:")||l(s.version,e):!1}export function isPackageExists(t,e={}){return!!f(t,e)}
package/dist/registry.cjs CHANGED
@@ -9,9 +9,9 @@ exports.getParsedNodeOptionsWithoutInspect = getParsedNodeOptionsWithoutInspect;
9
9
  exports.getRegistry = getRegistry;
10
10
  exports.tokenizeArgs = void 0;
11
11
  var _installPkg = require("@antfu/install-pkg");
12
- var _getWorkspaceRoot = require("@stryke/path/get-workspace-root");
13
12
  var _nodeChild_process = require("node:child_process");
14
13
  var _nodeUtil = require("node:util");
14
+ var _getWorkspaceRoot = require("./get-workspace-root.cjs");
15
15
  const l = r => {
16
16
  const {
17
17
  values: e,
package/dist/registry.mjs CHANGED
@@ -1 +1 @@
1
- import{detectPackageManager as s}from"@antfu/install-pkg";import{getWorkspaceRoot as a}from"@stryke/path/get-workspace-root";import{execSync as c}from"node:child_process";import{parseArgs as g}from"node:util";const l=r=>{const{values:e,tokens:n}=g({args:r,strict:!1,tokens:!0});let o=null;for(let i=0;i<n.length;i++){const t=n[i];if(t.kind==="option-terminator")break;if(t.kind==="option"){o=typeof t.value>"u"?t:null;continue}if(t.kind!=="positional"){o=null;continue}o&&(o.name in e&&typeof e[o.name]=="string"?e[o.name]+=` ${t.value}`:e[o.name]=t.value)}return e};export const tokenizeArgs=r=>{const e=[];let n=!1,o=!0;for(let i=0;i<r.length;i++){let t=r[i];if(t==="\\"&&n){if(r.length===i+1)throw new Error("Invalid escape character at the end.");t=r[++i]}else if(t===" "&&!n){o=!0;continue}else if(t==='"'){n=!n;continue}o?(e.push(t),o=!1):e[e.length-1]+=t}if(n)throw new Error("Unterminated string");return e};const f=()=>process.env.NODE_OPTIONS?tokenizeArgs(process.env.NODE_OPTIONS):[];export function formatNodeOptions(r){return Object.entries(r).map(([e,n])=>n===!0?`--${e}`:n?`--${e}=${n.includes(" ")&&!n.startsWith('"')?JSON.stringify(n):n}`:null).filter(e=>e!==null).join(" ")}export function getParsedNodeOptionsWithoutInspect(){const r=f();if(r.length===0)return{};const e=l(r);return delete e.inspect,delete e["inspect-brk"],delete e.inspect_brk,e}export function getFormattedNodeOptionsWithoutInspect(){const r=getParsedNodeOptionsWithoutInspect();return Object.keys(r).length===0?"":formatNodeOptions(r)}export async function getRegistry(r){const e=a(r),n=await s(e),o=n==="npm"?"--no-workspaces":"";let i="https://registry.npmjs.org/";try{const t=c(`${n} config get registry ${o}`,{env:{...process.env,NODE_OPTIONS:getFormattedNodeOptionsWithoutInspect()}}).toString().trim();t.startsWith("http")&&(i=t.endsWith("/")?t:`${t}/`)}catch(t){throw new Error(`Failed to get registry from "${n}".`,{cause:t})}return i}
1
+ import{detectPackageManager as s}from"@antfu/install-pkg";import{execSync as a}from"node:child_process";import{parseArgs as c}from"node:util";import{getWorkspaceRoot as g}from"./get-workspace-root";const l=r=>{const{values:e,tokens:n}=c({args:r,strict:!1,tokens:!0});let o=null;for(let i=0;i<n.length;i++){const t=n[i];if(t.kind==="option-terminator")break;if(t.kind==="option"){o=typeof t.value>"u"?t:null;continue}if(t.kind!=="positional"){o=null;continue}o&&(o.name in e&&typeof e[o.name]=="string"?e[o.name]+=` ${t.value}`:e[o.name]=t.value)}return e};export const tokenizeArgs=r=>{const e=[];let n=!1,o=!0;for(let i=0;i<r.length;i++){let t=r[i];if(t==="\\"&&n){if(r.length===i+1)throw new Error("Invalid escape character at the end.");t=r[++i]}else if(t===" "&&!n){o=!0;continue}else if(t==='"'){n=!n;continue}o?(e.push(t),o=!1):e[e.length-1]+=t}if(n)throw new Error("Unterminated string");return e};const f=()=>process.env.NODE_OPTIONS?tokenizeArgs(process.env.NODE_OPTIONS):[];export function formatNodeOptions(r){return Object.entries(r).map(([e,n])=>n===!0?`--${e}`:n?`--${e}=${n.includes(" ")&&!n.startsWith('"')?JSON.stringify(n):n}`:null).filter(e=>e!==null).join(" ")}export function getParsedNodeOptionsWithoutInspect(){const r=f();if(r.length===0)return{};const e=l(r);return delete e.inspect,delete e["inspect-brk"],delete e.inspect_brk,e}export function getFormattedNodeOptionsWithoutInspect(){const r=getParsedNodeOptionsWithoutInspect();return Object.keys(r).length===0?"":formatNodeOptions(r)}export async function getRegistry(r){const e=g(r),n=await s(e),o=n==="npm"?"--no-workspaces":"";let i="https://registry.npmjs.org/";try{const t=a(`${n} config get registry ${o}`,{env:{...process.env,NODE_OPTIONS:getFormattedNodeOptionsWithoutInspect()}}).toString().trim();t.startsWith("http")&&(i=t.endsWith("/")?t:`${t}/`)}catch(t){throw new Error(`Failed to get registry from "${n}".`,{cause:t})}return i}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.importModule = importModule;
7
+ exports.resolve = resolve;
8
+ exports.resolvePackage = resolvePackage;
9
+ exports.resolvePackageSync = resolvePackageSync;
10
+ exports.resolveSafe = resolveSafe;
11
+ exports.resolveSafeSync = resolveSafeSync;
12
+ exports.resolveSync = resolveSync;
13
+ var _correctPath = require("@stryke/path/correct-path");
14
+ var _cwd = require("@stryke/path/cwd");
15
+ var _filePathFns = require("@stryke/path/file-path-fns");
16
+ var _joinPaths = require("@stryke/path/join-paths");
17
+ var _mlly = require("mlly");
18
+ var _getWorkspaceRoot = require("./get-workspace-root.cjs");
19
+ async function resolve(r, e = {}) {
20
+ const t = e.paths ?? [];
21
+ t.length === 0 && t.push((0, _cwd.cwd)());
22
+ const n = (0, _getWorkspaceRoot.getWorkspaceRoot)();
23
+ return t.includes(n) || t.push(n), (0, _correctPath.correctPath)(await (0, _mlly.resolvePath)(r, {
24
+ url: t
25
+ }));
26
+ }
27
+ function resolveSync(r, e = {}) {
28
+ const t = e.paths ?? [];
29
+ t.length === 0 && t.push(process.cwd());
30
+ const n = (0, _getWorkspaceRoot.getWorkspaceRoot)();
31
+ return t.includes(n) || t.push(n), (0, _correctPath.correctPath)((0, _mlly.resolvePathSync)(r, {
32
+ url: e.paths
33
+ }));
34
+ }
35
+ async function resolveSafe(r, e = {}) {
36
+ try {
37
+ return await resolve(r, e);
38
+ } catch {
39
+ return;
40
+ }
41
+ }
42
+ function resolveSafeSync(r, e = {}) {
43
+ try {
44
+ return resolveSync(r, e);
45
+ } catch {
46
+ return;
47
+ }
48
+ }
49
+ async function importModule(r) {
50
+ const e = await Promise.resolve(`${r}`).then(s => require(s));
51
+ return e && (0, _mlly.interopDefault)(e);
52
+ }
53
+ async function resolvePackage(r, e = {}) {
54
+ let t = await resolveSafe((0, _joinPaths.joinPaths)(r, "package.json"), e);
55
+ return t || (t = await resolveSafe((0, _joinPaths.joinPaths)(r, "index.js"), e), t || (t = await resolveSafe(r, e))), t ? (0, _filePathFns.findFilePath)(t) : void 0;
56
+ }
57
+ function resolvePackageSync(r, e = {}) {
58
+ let t = resolveSafeSync((0, _joinPaths.joinPaths)(r, "package.json"), e);
59
+ return t || (t = resolveSafeSync((0, _joinPaths.joinPaths)(r, "index.js"), e), t || (t = resolveSafeSync(r, e))), t ? (0, _filePathFns.findFilePath)(t) : void 0;
60
+ }
@@ -0,0 +1,71 @@
1
+ import type { Platform } from "@stryke/types/system";
2
+ export interface PackageResolvingOptions {
3
+ /**
4
+ * Paths to resolve the package from
5
+ */
6
+ paths?: string[];
7
+ /**
8
+ * Resolve path as linux (stand-in for unix/posix) or win32
9
+ */
10
+ platform?: Platform;
11
+ }
12
+ /**
13
+ * Resolve the path to a specified module
14
+ *
15
+ * @param path - The path to the module
16
+ * @param options - The options to use when resolving the module
17
+ * @returns A promise for the path to the module
18
+ */
19
+ export declare function resolve(path: string, options?: PackageResolvingOptions): Promise<any>;
20
+ /**
21
+ * Resolve the path to a specified module
22
+ *
23
+ * @param path - The path to the module
24
+ * @param options - The options to use when resolving the module
25
+ * @returns The path to the module or undefined
26
+ */
27
+ export declare function resolveSync(path: string, options?: PackageResolvingOptions): any;
28
+ /**
29
+ * Resolve the path to a specified module with error handling
30
+ *
31
+ * @param name - The name of the module
32
+ * @param options - The options to use when resolving the module
33
+ * @returns A promise for the path to the module
34
+ */
35
+ export declare function resolveSafe(name: string, options?: PackageResolvingOptions): Promise<any>;
36
+ /**
37
+ * Resolve the path to a specified module with error handling
38
+ *
39
+ * @param name - The name of the module
40
+ * @param options - The options to use when resolving the module
41
+ * @returns The path to the module or undefined
42
+ */
43
+ export declare function resolveSafeSync(name: string, options?: PackageResolvingOptions): any;
44
+ /**
45
+ * Import a module from a specified path
46
+ *
47
+ * @param path - The path to the module
48
+ * @returns The module
49
+ */
50
+ export declare function importModule<T = any>(path: string): Promise<T>;
51
+ /**
52
+ * Resolve the path to a specified package asynchronously
53
+ *
54
+ * @remarks
55
+ * This path points to the root of the package, which is usually the directory containing the `package.json` file. Please note: this path does not include the `package.json` file itself.
56
+ *
57
+ * @param name - The name of the module
58
+ * @returns A promise for the module or undefined
59
+ */
60
+ export declare function resolvePackage(name: string, options?: PackageResolvingOptions): Promise<any>;
61
+ /**
62
+ * Resolve the path to a specified package synchronously
63
+ *
64
+ * @remarks
65
+ * This path points to the root of the package, which is usually the directory containing the `package.json` file. Please note: this path does not include the `package.json` file itself.
66
+ *
67
+ * @param name - The name of the module
68
+ * @param options - The options to use when resolving the module
69
+ * @returns The module or undefined
70
+ */
71
+ export declare function resolvePackageSync(name: string, options?: PackageResolvingOptions): any;
@@ -0,0 +1 @@
1
+ import{correctPath as i}from"@stryke/path/correct-path";import{cwd as c}from"@stryke/path/cwd";import{findFilePath as s}from"@stryke/path/file-path-fns";import{joinPaths as o}from"@stryke/path/join-paths";import{interopDefault as p,resolvePath as f,resolvePathSync as u}from"mlly";import{getWorkspaceRoot as a}from"./get-workspace-root";export async function resolve(r,e={}){const t=e.paths??[];t.length===0&&t.push(c());const n=a();return t.includes(n)||t.push(n),i(await f(r,{url:t}))}export function resolveSync(r,e={}){const t=e.paths??[];t.length===0&&t.push(process.cwd());const n=a();return t.includes(n)||t.push(n),i(u(r,{url:e.paths}))}export async function resolveSafe(r,e={}){try{return await resolve(r,e)}catch{return}}export function resolveSafeSync(r,e={}){try{return resolveSync(r,e)}catch{return}}export async function importModule(r){const e=await import(r);return e&&p(e)}export async function resolvePackage(r,e={}){let t=await resolveSafe(o(r,"package.json"),e);return t||(t=await resolveSafe(o(r,"index.js"),e),t||(t=await resolveSafe(r,e))),t?s(t):void 0}export function resolvePackageSync(r,e={}){let t=resolveSafeSync(o(r,"package.json"),e);return t||(t=resolveSafeSync(o(r,"index.js"),e),t||(t=resolveSafeSync(r,e))),t?s(t):void 0}
package/dist/tsconfig.cjs CHANGED
@@ -4,23 +4,24 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.loadTsConfig = loadTsConfig;
7
- var _exists = require("@stryke/path/exists");
7
+ var _cwd = require("@stryke/path/cwd");
8
8
  var _filePathFns = require("@stryke/path/file-path-fns");
9
9
  var _joinPaths = require("@stryke/path/join-paths");
10
10
  var _defu = _interopRequireDefault(require("defu"));
11
11
  var _mlly = require("mlly");
12
+ var _exists = require("./exists.cjs");
12
13
  var _json = require("./json.cjs");
13
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
- async function loadTsConfig(e = process.cwd()) {
15
- let s = e.endsWith(".json") ? e : (0, _joinPaths.joinPaths)(e, "tsconfig.json");
16
- if (!(0, _exists.existsSync)(s) && (s = await (0, _mlly.resolvePath)(e, {
15
+ async function loadTsConfig(e = (0, _cwd.cwd)()) {
16
+ let t = e.endsWith(".json") ? e : (0, _joinPaths.joinPaths)(e, "tsconfig.json");
17
+ if (!(0, _exists.existsSync)(t) && (t = await (0, _mlly.resolvePath)(e, {
17
18
  url: require('url').pathToFileURL(__filename).toString()
18
- }), !(0, _exists.existsSync)(s))) throw new Error(`tsconfig.json not found at ${s}. Please ensure the file exists.`);
19
- let o = await (0, _json.readJsonFile)(s);
20
- if (o?.compilerOptions?.baseUrl && (o.compilerOptions.baseUrl = (0, _joinPaths.joinPaths)((0, _filePathFns.findFilePath)(s), o.compilerOptions.baseUrl)), o?.extends) {
19
+ }), !(0, _exists.existsSync)(t))) throw new Error(`tsconfig.json not found at ${t}. Please ensure the file exists.`);
20
+ let o = await (0, _json.readJsonFile)(t);
21
+ if (o?.compilerOptions?.baseUrl && (o.compilerOptions.baseUrl = (0, _joinPaths.joinPaths)((0, _filePathFns.findFilePath)(t), o.compilerOptions.baseUrl)), o?.extends) {
21
22
  const f = Array.isArray(o.extends) ? o.extends : [o.extends];
22
23
  for (const m of f) {
23
- const n = await loadTsConfig((0, _joinPaths.joinPaths)((0, _filePathFns.findFilePath)(s), m));
24
+ const n = await loadTsConfig((0, _joinPaths.joinPaths)((0, _filePathFns.findFilePath)(t), m));
24
25
  n && (o = (0, _defu.default)(o, n ?? {}));
25
26
  }
26
27
  }
package/dist/tsconfig.mjs CHANGED
@@ -1 +1 @@
1
- import{existsSync as i}from"@stryke/path/exists";import{findFilePath as r}from"@stryke/path/file-path-fns";import{joinPaths as t}from"@stryke/path/join-paths";import a from"defu";import{resolvePath as p}from"mlly";import{readJsonFile as c}from"./json";export async function loadTsConfig(e=process.cwd()){let s=e.endsWith(".json")?e:t(e,"tsconfig.json");if(!i(s)&&(s=await p(e,{url:import.meta.url}),!i(s)))throw new Error(`tsconfig.json not found at ${s}. Please ensure the file exists.`);let o=await c(s);if(o?.compilerOptions?.baseUrl&&(o.compilerOptions.baseUrl=t(r(s),o.compilerOptions.baseUrl)),o?.extends){const f=Array.isArray(o.extends)?o.extends:[o.extends];for(const m of f){const n=await loadTsConfig(t(r(s),m));n&&(o=a(o,n??{}))}}return o.extends=void 0,o}
1
+ import{cwd as a}from"@stryke/path/cwd";import{findFilePath as i}from"@stryke/path/file-path-fns";import{joinPaths as s}from"@stryke/path/join-paths";import p from"defu";import{resolvePath as d}from"mlly";import{existsSync as r}from"./exists";import{readJsonFile as c}from"./json";export async function loadTsConfig(e=a()){let t=e.endsWith(".json")?e:s(e,"tsconfig.json");if(!r(t)&&(t=await d(e,{url:import.meta.url}),!r(t)))throw new Error(`tsconfig.json not found at ${t}. Please ensure the file exists.`);let o=await c(t);if(o?.compilerOptions?.baseUrl&&(o.compilerOptions.baseUrl=s(i(t),o.compilerOptions.baseUrl)),o?.extends){const f=Array.isArray(o.extends)?o.extends:[o.extends];for(const m of f){const n=await loadTsConfig(s(i(t),m));n&&(o=p(o,n??{}))}}return o.extends=void 0,o}
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.writeFileSync = exports.writeFile = void 0;
7
7
  var _correctPath = require("@stryke/path/correct-path");
8
- var _exists = require("@stryke/path/exists");
9
8
  var _filePathFns = require("@stryke/path/file-path-fns");
10
9
  var _nodeFs = require("node:fs");
11
10
  var _promises = require("node:fs/promises");
11
+ var _exists = require("./exists.cjs");
12
12
  var _helpers = require("./helpers.cjs");
13
13
  const writeFileSync = (e, t = "", o = {}) => {
14
14
  if (!e) throw new Error("No file path provided to write data");
@@ -1 +1 @@
1
- import{correctPath as i}from"@stryke/path/correct-path";import{existsSync as n}from"@stryke/path/exists";import{findFilePath as c}from"@stryke/path/file-path-fns";import{writeFileSync as s}from"node:fs";import{writeFile as d}from"node:fs/promises";import{createDirectory as p,createDirectorySync as a}from"./helpers";export const writeFileSync=(e,t="",o={})=>{if(!e)throw new Error("No file path provided to write data");const r=c(i(e));if(!n(r))if(o.createDirectory!==!1)a(r);else throw new Error(`Directory ${r} does not exist`);s(e,t||"",o)},writeFile=async(e,t="",o={})=>{if(!e)throw new Error("No file path provided to read data");const r=c(i(e));if(!n(r))if(o.createDirectory!==!1)await p(r);else throw new Error(`Directory ${r} does not exist`);return d(e,t||"",o)};
1
+ import{correctPath as i}from"@stryke/path/correct-path";import{findFilePath as n}from"@stryke/path/file-path-fns";import{writeFileSync as s}from"node:fs";import{writeFile as d}from"node:fs/promises";import{existsSync as c}from"./exists";import{createDirectory as p,createDirectorySync as a}from"./helpers";export const writeFileSync=(e,t="",o={})=>{if(!e)throw new Error("No file path provided to write data");const r=n(i(e));if(!c(r))if(o.createDirectory!==!1)a(r);else throw new Error(`Directory ${r} does not exist`);s(e,t||"",o)},writeFile=async(e,t="",o={})=>{if(!e)throw new Error("No file path provided to read data");const r=n(i(e));if(!c(r))if(o.createDirectory!==!1)await p(r);else throw new Error(`Directory ${r} does not exist`);return d(e,t||"",o)};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/fs",
3
- "version": "0.25.0",
3
+ "version": "0.27.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,9 @@
14
14
  "dependencies": {
15
15
  "@antfu/install-pkg": "^1.0.0",
16
16
  "@ltd/j-toml": "^1.38.0",
17
+ "@storm-software/config-tools": "latest",
17
18
  "@stryke/convert": "^0.3.1",
18
- "@stryke/path": "^0.12.5",
19
+ "@stryke/path": "^0.13.1",
19
20
  "@stryke/string-format": "^0.10.0",
20
21
  "@zkochan/js-yaml": "^0.0.7",
21
22
  "chalk": "^5.4.1",
@@ -130,6 +131,20 @@
130
131
  "default": "./dist/semver-fns.mjs"
131
132
  }
132
133
  },
134
+ "./resolve": {
135
+ "import": {
136
+ "types": "./dist/resolve.d.ts",
137
+ "default": "./dist/resolve.mjs"
138
+ },
139
+ "require": {
140
+ "types": "./dist/resolve.d.ts",
141
+ "default": "./dist/resolve.cjs"
142
+ },
143
+ "default": {
144
+ "types": "./dist/resolve.d.ts",
145
+ "default": "./dist/resolve.mjs"
146
+ }
147
+ },
133
148
  "./remove-file": {
134
149
  "import": {
135
150
  "types": "./dist/remove-file.d.ts",
@@ -205,6 +220,20 @@
205
220
  "require": { "types": "./dist/json.d.ts", "default": "./dist/json.cjs" },
206
221
  "default": { "types": "./dist/json.d.ts", "default": "./dist/json.mjs" }
207
222
  },
223
+ "./is-file": {
224
+ "import": {
225
+ "types": "./dist/is-file.d.ts",
226
+ "default": "./dist/is-file.mjs"
227
+ },
228
+ "require": {
229
+ "types": "./dist/is-file.d.ts",
230
+ "default": "./dist/is-file.cjs"
231
+ },
232
+ "default": {
233
+ "types": "./dist/is-file.d.ts",
234
+ "default": "./dist/is-file.mjs"
235
+ }
236
+ },
208
237
  "./install": {
209
238
  "import": {
210
239
  "types": "./dist/install.d.ts",
@@ -241,6 +270,34 @@
241
270
  "default": "./dist/helpers.mjs"
242
271
  }
243
272
  },
273
+ "./get-workspace-root": {
274
+ "import": {
275
+ "types": "./dist/get-workspace-root.d.ts",
276
+ "default": "./dist/get-workspace-root.mjs"
277
+ },
278
+ "require": {
279
+ "types": "./dist/get-workspace-root.d.ts",
280
+ "default": "./dist/get-workspace-root.cjs"
281
+ },
282
+ "default": {
283
+ "types": "./dist/get-workspace-root.d.ts",
284
+ "default": "./dist/get-workspace-root.mjs"
285
+ }
286
+ },
287
+ "./exists": {
288
+ "import": {
289
+ "types": "./dist/exists.d.ts",
290
+ "default": "./dist/exists.mjs"
291
+ },
292
+ "require": {
293
+ "types": "./dist/exists.d.ts",
294
+ "default": "./dist/exists.cjs"
295
+ },
296
+ "default": {
297
+ "types": "./dist/exists.d.ts",
298
+ "default": "./dist/exists.mjs"
299
+ }
300
+ },
244
301
  "./copy-file": {
245
302
  "import": {
246
303
  "types": "./dist/copy-file.d.ts",
@@ -338,5 +395,5 @@
338
395
  "main": "./dist/index.cjs",
339
396
  "module": "./dist/index.mjs",
340
397
  "types": "./dist/index.d.ts",
341
- "gitHead": "a4337f9cb38835e8f5b60e857c08235552b7db77"
398
+ "gitHead": "7ec1f888f4eb3038ac5316409189322fda2e5aa6"
342
399
  }