+185
-185
@@ -1,8 +0,8 @@ | ||
| import { createRequire as __WEBPACK_EXTERNAL_createRequire } from "module"; | ||
| var __webpack_require__ = {}; | ||
| import { createRequire as w } from "module"; | ||
| var m = {}; | ||
| (() => { | ||
| __webpack_require__.d = (exports, definition) => { | ||
| for (var key in definition) { | ||
| if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { | ||
| Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); | ||
| m.d = (e, t) => { | ||
| for (var i in t) { | ||
| if (m.o(t, i) && !m.o(e, i)) { | ||
| Object.defineProperty(e, i, { enumerable: true, get: t[i] }); | ||
| } | ||
@@ -13,266 +13,266 @@ } | ||
| (() => { | ||
| __webpack_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop); | ||
| m.o = (e, t) => Object.prototype.hasOwnProperty.call(e, t); | ||
| })(); | ||
| var __webpack_exports__ = {}; | ||
| __webpack_require__.d(__webpack_exports__, { | ||
| Z: () => ( | ||
| var F = {}; | ||
| m.d(F, { | ||
| A: () => ( | ||
| /* binding */ | ||
| fs | ||
| N | ||
| ) | ||
| }); | ||
| ; | ||
| const external_node_path_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:path"); | ||
| const $ = w(import.meta.url)("node:path"); | ||
| ; | ||
| const external_node_fs_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:fs"); | ||
| const n = w(import.meta.url)("node:fs"); | ||
| ; | ||
| const rmfile = async (path, rootpath, sep) => { | ||
| if (!external_node_fs_namespaceObject.existsSync(path)) { | ||
| throw Error(`[${path}] \u6587\u4EF6\u6216\u6587\u4EF6\u5939\u4E0D\u5B58\u5728!`); | ||
| const d = async (e, t, i) => { | ||
| if (!n.existsSync(e)) { | ||
| throw Error(`[${e}] \u6587\u4EF6\u6216\u6587\u4EF6\u5939\u4E0D\u5B58\u5728!`); | ||
| } | ||
| if (path === rootpath) { | ||
| if (e === t) { | ||
| throw Error(`\u8BE5\u6587\u4EF6\u5939\u4E0D\u80FD\u88AB\u5220\u9664!`); | ||
| } | ||
| const stats = await external_node_fs_namespaceObject.statSync(path); | ||
| if (stats.isFile()) { | ||
| await external_node_fs_namespaceObject.unlinkSync(path); | ||
| return path; | ||
| const r = await n.statSync(e); | ||
| if (r.isFile()) { | ||
| await n.unlinkSync(e); | ||
| return e; | ||
| } | ||
| if (stats.isDirectory()) { | ||
| const files = await external_node_fs_namespaceObject.readdirSync(path); | ||
| for (let i = 0, l = files.length; i < l; i++) { | ||
| await rmfile(`${path}${sep}${files[i]}`, rootpath, sep); | ||
| if (r.isDirectory()) { | ||
| const s = await n.readdirSync(e); | ||
| for (let u = 0, o = s.length; u < o; u++) { | ||
| await d(`${e}${i}${s[u]}`, t, i); | ||
| } | ||
| await external_node_fs_namespaceObject.rmdirSync(path); | ||
| return path; | ||
| await n.rmdirSync(e); | ||
| return e; | ||
| } | ||
| }; | ||
| const fs_rmfile = rmfile; | ||
| const y = d; | ||
| ; | ||
| const getExt = (filename) => { | ||
| const arr = filename.split("."); | ||
| if (arr.filter(Boolean).length < 2) { | ||
| const O = (e) => { | ||
| const t = e.split("."); | ||
| if (t.filter(Boolean).length < 2) { | ||
| return; | ||
| } | ||
| const name = arr.slice(0, -1).join("."); | ||
| const [ext] = arr.slice(-1); | ||
| return [name, ext]; | ||
| const i = t.slice(0, -1).join("."); | ||
| const [r] = t.slice(-1); | ||
| return [i, r]; | ||
| }; | ||
| const getFilename = (path = "/", sep) => { | ||
| const pathArr = path.split(sep); | ||
| const dir = pathArr.slice(0, -1).join(sep) || "/"; | ||
| const [filename] = pathArr.slice(-1); | ||
| return [filename, dir]; | ||
| const _ = (e = "/", t) => { | ||
| const i = e.split(t); | ||
| const r = i.slice(0, -1).join(t) || "/"; | ||
| const [s] = i.slice(-1); | ||
| return [s, r]; | ||
| }; | ||
| ; | ||
| const copyfile_copyfile = async (src, dst, sep) => { | ||
| if (!external_node_fs_namespaceObject.existsSync(src)) { | ||
| throw Error(`[${src}] \u6587\u4EF6\u6216\u6587\u4EF6\u5939\u4E0D\u5B58\u5728!`); | ||
| const E = async (e, t, i) => { | ||
| if (!n.existsSync(e)) { | ||
| throw Error(`[${e}] \u6587\u4EF6\u6216\u6587\u4EF6\u5939\u4E0D\u5B58\u5728!`); | ||
| } | ||
| const stats = await external_node_fs_namespaceObject.statSync(src); | ||
| if (stats.isFile()) { | ||
| const filename = src.split(sep).slice(-1)[0]; | ||
| let dstfile = `${dst}${sep}${filename}`; | ||
| if (external_node_fs_namespaceObject.existsSync(dstfile)) { | ||
| const extname = getExt(filename); | ||
| if (!extname) { | ||
| dstfile = `${dstfile}_copy_${+/* @__PURE__ */ new Date()}`; | ||
| const r = await n.statSync(e); | ||
| if (r.isFile()) { | ||
| const s = e.split(i).slice(-1)[0]; | ||
| let u = `${t}${i}${s}`; | ||
| if (n.existsSync(u)) { | ||
| const o = O(s); | ||
| if (!o) { | ||
| u = `${u}_copy_${+/* @__PURE__ */ new Date()}`; | ||
| } else { | ||
| const [name, ext] = extname; | ||
| dstfile = `${dst}${sep}${name}_copy_${+/* @__PURE__ */ new Date()}.${ext}`; | ||
| const [l, f] = o; | ||
| u = `${t}${i}${l}_copy_${+/* @__PURE__ */ new Date()}.${f}`; | ||
| } | ||
| } | ||
| await external_node_fs_namespaceObject.copyFileSync(src, dstfile); | ||
| return dstfile; | ||
| await n.copyFileSync(e, u); | ||
| return u; | ||
| } | ||
| if (stats.isDirectory()) { | ||
| const filename = src.split(sep).slice(-1)[0]; | ||
| let dstfile = `${dst}${sep}${filename}`; | ||
| if (external_node_fs_namespaceObject.existsSync(dstfile)) { | ||
| dstfile = `${dstfile}_copy_${+/* @__PURE__ */ new Date()}`; | ||
| if (r.isDirectory()) { | ||
| const s = e.split(i).slice(-1)[0]; | ||
| let u = `${t}${i}${s}`; | ||
| if (n.existsSync(u)) { | ||
| u = `${u}_copy_${+/* @__PURE__ */ new Date()}`; | ||
| } | ||
| await external_node_fs_namespaceObject.mkdirSync(dstfile); | ||
| const files = await external_node_fs_namespaceObject.readdirSync(src); | ||
| for (let i = 0, l = files.length; i < l; i++) { | ||
| await copyfile_copyfile(`${src}${sep}${files[i]}`, dstfile, sep); | ||
| await n.mkdirSync(u); | ||
| const o = await n.readdirSync(e); | ||
| for (let l = 0, f = o.length; l < f; l++) { | ||
| await E(`${e}${i}${o[l]}`, u, i); | ||
| } | ||
| return dstfile; | ||
| return u; | ||
| } | ||
| }; | ||
| const copyfile_movefile = async (src, dst, rootpath, sep) => { | ||
| if (src === dst) { | ||
| const v = async (e, t, i, r) => { | ||
| if (e === t) { | ||
| return; | ||
| } | ||
| await copyfile_copyfile(src, dst, sep); | ||
| await fs_rmfile(src, rootpath, sep); | ||
| await E(e, t, r); | ||
| await y(e, i, r); | ||
| }; | ||
| ; | ||
| const createfile_mkdir = async (path, override = false, rootpath, sep) => { | ||
| if (external_node_fs_namespaceObject.existsSync(path)) { | ||
| if (!override) { | ||
| throw Error(`[${path}] \u6587\u4EF6\u5939\u5DF2\u5B58\u5728!`); | ||
| const j = async (e, t = false, i, r) => { | ||
| if (n.existsSync(e)) { | ||
| if (!t) { | ||
| throw Error(`[${e}] \u6587\u4EF6\u5939\u5DF2\u5B58\u5728!`); | ||
| } | ||
| await fs_rmfile(path, rootpath, sep); | ||
| await y(e, i, r); | ||
| } | ||
| await external_node_fs_namespaceObject.mkdirSync(path); | ||
| return path; | ||
| await n.mkdirSync(e); | ||
| return e; | ||
| }; | ||
| const createfile_touch = async (path, override = false, data = "", rootpath, sep) => { | ||
| if (external_node_fs_namespaceObject.existsSync(path)) { | ||
| if (data) { | ||
| await external_node_fs_namespaceObject.writeFileSync(path, data); | ||
| const k = async (e, t = false, i = "", r, s) => { | ||
| if (n.existsSync(e)) { | ||
| if (i) { | ||
| await n.writeFileSync(e, i); | ||
| return; | ||
| } | ||
| if (!override) { | ||
| throw Error(`[${path}] \u6587\u4EF6\u5DF2\u5B58\u5728!`); | ||
| if (!t) { | ||
| throw Error(`[${e}] \u6587\u4EF6\u5DF2\u5B58\u5728!`); | ||
| } | ||
| await fs_rmfile(path, rootpath, sep); | ||
| await y(e, r, s); | ||
| } | ||
| await external_node_fs_namespaceObject.writeFileSync(path, data); | ||
| return path; | ||
| await n.writeFileSync(e, i); | ||
| return e; | ||
| }; | ||
| ; | ||
| const readfile_openfile = async (path, sep) => { | ||
| if (!external_node_fs_namespaceObject.existsSync(path)) { | ||
| throw Error(`[${path}] \u6587\u4EF6\u6216\u6587\u4EF6\u5939\u4E0D\u5B58\u5728!`); | ||
| const R = async (e, t) => { | ||
| if (!n.existsSync(e)) { | ||
| throw Error(`[${e}] \u6587\u4EF6\u6216\u6587\u4EF6\u5939\u4E0D\u5B58\u5728!`); | ||
| } | ||
| const stats = await external_node_fs_namespaceObject.statSync(path); | ||
| if (!stats.isFile()) { | ||
| throw Error(`[${path}] \u4E0D\u662F\u4E00\u4E2A\u6587\u4EF6!`); | ||
| const i = await n.statSync(e); | ||
| if (!i.isFile()) { | ||
| throw Error(`[${e}] \u4E0D\u662F\u4E00\u4E2A\u6587\u4EF6!`); | ||
| } | ||
| const data = await external_node_fs_namespaceObject.readFileSync(path); | ||
| const [filename, dir] = getFilename(path, sep); | ||
| const r = await n.readFileSync(e); | ||
| const [s, u] = _(e, t); | ||
| return { | ||
| dir, | ||
| filename, | ||
| type: filename.split(".").slice(-1)[0], | ||
| size: stats.size, | ||
| mtime: stats.mtime, | ||
| birthtime: stats.birthtime, | ||
| data: data.toString() | ||
| dir: u, | ||
| filename: s, | ||
| type: s.split(".").slice(-1)[0], | ||
| size: i.size, | ||
| mtime: i.mtime, | ||
| birthtime: i.birthtime, | ||
| data: r.toString() | ||
| }; | ||
| }; | ||
| const readfile_readfile = async (path, sep) => { | ||
| if (!external_node_fs_namespaceObject.existsSync(path)) { | ||
| throw Error(`[${path}] \u6587\u4EF6\u6216\u6587\u4EF6\u5939\u4E0D\u5B58\u5728!`); | ||
| const S = async (e, t) => { | ||
| if (!n.existsSync(e)) { | ||
| throw Error(`[${e}] \u6587\u4EF6\u6216\u6587\u4EF6\u5939\u4E0D\u5B58\u5728!`); | ||
| } | ||
| const stats = await external_node_fs_namespaceObject.statSync(path); | ||
| const [filename, dir] = getFilename(path, sep); | ||
| if (stats.isFile()) { | ||
| const i = await n.statSync(e); | ||
| const [r, s] = _(e, t); | ||
| if (i.isFile()) { | ||
| return { | ||
| dir, | ||
| filename, | ||
| type: filename.split(".").slice(-1)[0], | ||
| size: stats.size, | ||
| mtime: stats.mtime, | ||
| birthtime: stats.birthtime | ||
| dir: s, | ||
| filename: r, | ||
| type: r.split(".").slice(-1)[0], | ||
| size: i.size, | ||
| mtime: i.mtime, | ||
| birthtime: i.birthtime | ||
| }; | ||
| } else if (stats.isDirectory()) { | ||
| } else if (i.isDirectory()) { | ||
| return { | ||
| dir, | ||
| filename, | ||
| dir: s, | ||
| filename: r, | ||
| type: "dir", | ||
| size: stats.size, | ||
| mtime: stats.ctime, | ||
| birthtime: stats.birthtime | ||
| size: i.size, | ||
| mtime: i.ctime, | ||
| birthtime: i.birthtime | ||
| }; | ||
| } | ||
| }; | ||
| const readfile_readdir = async (path, sep) => { | ||
| if (!external_node_fs_namespaceObject.existsSync(path)) { | ||
| throw Error(`[${path}] \u6587\u4EF6\u5939\u4E0D\u5B58\u5728!`); | ||
| const h = async (e, t) => { | ||
| if (!n.existsSync(e)) { | ||
| throw Error(`[${e}] \u6587\u4EF6\u5939\u4E0D\u5B58\u5728!`); | ||
| } | ||
| const files = await external_node_fs_namespaceObject.readdirSync(path); | ||
| const result = []; | ||
| for (let i = 0, l = files.length; i < l; i++) { | ||
| const i = await n.readdirSync(e); | ||
| const r = []; | ||
| for (let s = 0, u = i.length; s < u; s++) { | ||
| try { | ||
| const fileInfo = await readfile_readfile(`${path}${sep}${files[i]}`, sep); | ||
| result.push(fileInfo); | ||
| } catch (err) { | ||
| const o = await S(`${e}${t}${i[s]}`, t); | ||
| r.push(o); | ||
| } catch (o) { | ||
| continue; | ||
| } | ||
| } | ||
| return result; | ||
| return r; | ||
| }; | ||
| const readfile_readAllFile = async (path = "", sep) => { | ||
| if (!external_node_fs_namespaceObject.existsSync(path)) { | ||
| throw Error(`[${path}] \u6587\u4EF6\u5939\u4E0D\u5B58\u5728!`); | ||
| const x = async (e = "", t) => { | ||
| if (!n.existsSync(e)) { | ||
| throw Error(`[${e}] \u6587\u4EF6\u5939\u4E0D\u5B58\u5728!`); | ||
| } | ||
| const files = await external_node_fs_namespaceObject.readdirSync(path); | ||
| const result = []; | ||
| for (let i = 0, l = files.length; i < l; i++) { | ||
| const fullname = `${path}${sep}${files[i]}`; | ||
| const stats = await external_node_fs_namespaceObject.statSync(fullname); | ||
| if (stats.isFile()) { | ||
| result.push({ | ||
| fullname, | ||
| type: fullname.split(".").slice(-1)[0], | ||
| size: stats.size, | ||
| mtime: stats.mtime, | ||
| birthtime: stats.birthtime | ||
| const i = await n.readdirSync(e); | ||
| const r = []; | ||
| for (let s = 0, u = i.length; s < u; s++) { | ||
| const o = `${e}${t}${i[s]}`; | ||
| const l = await n.statSync(o); | ||
| if (l.isFile()) { | ||
| r.push({ | ||
| fullname: o, | ||
| type: o.split(".").slice(-1)[0], | ||
| size: l.size, | ||
| mtime: l.mtime, | ||
| birthtime: l.birthtime | ||
| }); | ||
| } else if (stats.isDirectory()) { | ||
| result.push({ | ||
| fullname, | ||
| } else if (l.isDirectory()) { | ||
| r.push({ | ||
| fullname: o, | ||
| type: "dir", | ||
| size: stats.size, | ||
| mtime: stats.mtime, | ||
| birthtime: stats.birthtime | ||
| size: l.size, | ||
| mtime: l.mtime, | ||
| birthtime: l.birthtime | ||
| }); | ||
| const children = await readfile_readAllFile(fullname, sep); | ||
| result.push(...children); | ||
| const f = await x(o, t); | ||
| r.push(...f); | ||
| } | ||
| } | ||
| return result; | ||
| return r; | ||
| }; | ||
| ; | ||
| const rnfile = async (path, newpath, rootpath) => { | ||
| if (path === newpath) { | ||
| const q = async (e, t, i) => { | ||
| if (e === t) { | ||
| return; | ||
| } | ||
| if (!external_node_fs_namespaceObject.existsSync(path)) { | ||
| throw Error(`[${path}] \u6587\u4EF6\u6216\u6587\u4EF6\u5939\u4E0D\u5B58\u5728!`); | ||
| if (!n.existsSync(e)) { | ||
| throw Error(`[${e}] \u6587\u4EF6\u6216\u6587\u4EF6\u5939\u4E0D\u5B58\u5728!`); | ||
| } | ||
| if (external_node_fs_namespaceObject.existsSync(newpath)) { | ||
| throw Error(`[${newpath}] \u6587\u4EF6\u6216\u6587\u4EF6\u5939\u5DF2\u5B58\u5728!`); | ||
| if (n.existsSync(t)) { | ||
| throw Error(`[${t}] \u6587\u4EF6\u6216\u6587\u4EF6\u5939\u5DF2\u5B58\u5728!`); | ||
| } | ||
| if (path === rootpath) { | ||
| if (e === i) { | ||
| throw Error(`\u8BE5\u6587\u4EF6\u5939\u4E0D\u80FD\u88AB\u91CD\u65B0\u547D\u540D!`); | ||
| } | ||
| await external_node_fs_namespaceObject.renameSync(path, newpath); | ||
| await n.renameSync(e, t); | ||
| }; | ||
| const fs_rnfile = rnfile; | ||
| const P = q; | ||
| ; | ||
| ; | ||
| const fixRoute = (path2, sep) => path2 ? path2.charAt(path2.length - 1) === sep ? path2.slice(0, -1) : path2 : ""; | ||
| const fixpath = (route = "", rootpath = "/", sep) => { | ||
| if (route.indexOf(`${rootpath}${sep}`) === 0) { | ||
| return fixRoute(route, sep); | ||
| const C = (e, t) => e ? e.charAt(e.length - 1) === t ? e.slice(0, -1) : e : ""; | ||
| const I = (e = "", t = "/", i) => { | ||
| if (e.indexOf(`${t}${i}`) === 0) { | ||
| return C(e, i); | ||
| } | ||
| if (route.indexOf(`..${sep}`) !== -1) { | ||
| if (e.indexOf(`..${i}`) !== -1) { | ||
| throw Error("\u4E0D\u652F\u6301\u76F8\u5BF9\u8DEF\u5F84\uFF01"); | ||
| } | ||
| return external_node_path_namespaceObject.resolve(rootpath, `${route.indexOf(sep) === 0 ? "." : `.${sep}`}${route}`); | ||
| return $.resolve(t, `${e.indexOf(i) === 0 ? "." : `.${i}`}${e}`); | ||
| }; | ||
| const fs_fixpath = fixpath; | ||
| const K = I; | ||
| ; | ||
| const fss = (configs) => { | ||
| const sep = external_node_path_namespaceObject.sep; | ||
| const rootpath = configs?.rootpath ?? configs ?? "/"; | ||
| const fixedpath = (route) => fs_fixpath(route, rootpath, sep); | ||
| const copyfile = (src, dst) => copyfile_copyfile(fixedpath(src), fixedpath(dst), sep); | ||
| const movefile = (src, dst) => copyfile_movefile(fixedpath(src), fixedpath(dst), rootpath, sep); | ||
| const mkdir = (path2, override) => createfile_mkdir(fixedpath(path2), override, rootpath, sep); | ||
| const touch = (path2, override, data) => createfile_touch(fixedpath(path2), override, data, rootpath, sep); | ||
| const openfile = (path2) => readfile_openfile(fixedpath(path2), sep); | ||
| const readfile = (path2) => readfile_readfile(fixedpath(path2), sep); | ||
| const readdir = (path2) => readfile_readdir(fixedpath(path2), sep); | ||
| const readAllFile = (path2) => readfile_readAllFile(fixedpath(path2), sep); | ||
| const rmfile2 = (path2) => fs_rmfile(fixedpath(path2), rootpath, sep); | ||
| const rnfile2 = (path2, newpath) => fs_rnfile(fixedpath(path2), fixedpath(newpath), rootpath); | ||
| return { copyfile, movefile, mkdir, touch, openfile, readfile, readdir, readAllFile, rmfile: rmfile2, rnfile: rnfile2 }; | ||
| const L = (e) => { | ||
| const t = $.sep; | ||
| const i = e?.rootpath ?? e ?? "/"; | ||
| const r = (c) => K(c, i, t); | ||
| const s = (c, a) => E(r(c), r(a), t); | ||
| const u = (c, a) => v(r(c), r(a), i, t); | ||
| const o = (c, a) => j(r(c), a, i, t); | ||
| const l = (c, a, g) => k(r(c), a, g, i, t); | ||
| const f = (c) => R(r(c), t); | ||
| const D = (c) => S(r(c), t); | ||
| const b = (c) => h(r(c), t); | ||
| const B = (c) => x(r(c), t); | ||
| const A = (c) => y(r(c), i, t); | ||
| const z = (c, a) => P(r(c), r(a), i); | ||
| return { copyfile: s, movefile: u, mkdir: o, touch: l, openfile: f, readfile: D, readdir: b, readAllFile: B, rmfile: A, rnfile: z }; | ||
| }; | ||
| const fs = fss; | ||
| var __webpack_exports__default = __webpack_exports__.Z; | ||
| const N = L; | ||
| var T = F.A; | ||
| export { | ||
| __webpack_exports__default as default | ||
| T as default | ||
| }; |
+1
-1
| { | ||
| "name": "@huxy/fss", | ||
| "version": "0.0.3", | ||
| "version": "0.0.4", | ||
| "title": "fss", | ||
@@ -5,0 +5,0 @@ "feature": "0.0.1", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
866921
-0.38%1
Infinity%