@willbooster/shared-lib-node 2.5.0 → 2.5.1
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/cjs/hash.cjs +1 -1
- package/dist/cjs/hash.cjs.map +1 -1
- package/dist/cjs/hash.d.cts +2 -2
- package/dist/esm/hash.d.ts +2 -2
- package/dist/esm/hash.js +1 -1
- package/dist/esm/hash.js.map +1 -1
- package/package.json +5 -5
package/dist/cjs/hash.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("node:crypto"),
|
|
1
|
+
"use strict";var e=require("node:crypto"),t=require("node:fs"),s=require("node:path");async function r(...r){const a=e.createHash("sha512");for(const e of r.sort()){const r=await t.promises.stat(e);if(r.isDirectory()){const r=await t.promises.readdir(e,{withFileTypes:!0,recursive:!0});for(const i of r.sort(((e,t)=>e.name.localeCompare(t.name))))i.isFile()&&a.update(await t.promises.readFile(s.join(e,i.name),"utf8"))}else r.isFile()&&a.update(await t.promises.readFile(e,"utf8"))}return a.digest("hex")}exports.calculateHashFromFiles=r,exports.updateHashFromFiles=async function(e,...s){let a="";try{a=await t.promises.readFile(e,"utf8")}catch{}const i=await r(...s);return a!==i&&(await t.promises.writeFile(e,i,"utf8"),!0)};
|
|
2
2
|
//# sourceMappingURL=hash.cjs.map
|
package/dist/cjs/hash.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.cjs","sources":["../../src/hash.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nexport async function calculateHashFromFiles(paths: string[]): Promise<string> {\n const hash = crypto.createHash('sha512');\n for (const fileOrDirPath of paths.sort()) {\n const stat = await fs.promises.stat(fileOrDirPath);\n if (stat.isDirectory()) {\n // Get all files in the directory\n const dirents = await fs.promises.readdir(fileOrDirPath, { withFileTypes: true, recursive: true });\n for (const dirent of dirents.sort((d1, d2) => d1.name.localeCompare(d2.name))) {\n if (dirent.isFile()) {\n hash.update(await fs.promises.readFile(path.join(fileOrDirPath, dirent.name), 'utf8'));\n }\n }\n } else if (stat.isFile()) {\n hash.update(await fs.promises.readFile(fileOrDirPath, 'utf8'));\n }\n }\n return hash.digest('hex');\n}\n\nexport async function updateHashFromFiles(hashFilePath: string, paths: string[]): Promise<boolean> {\n
|
|
1
|
+
{"version":3,"file":"hash.cjs","sources":["../../src/hash.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nexport async function calculateHashFromFiles(...paths: string[]): Promise<string> {\n const hash = crypto.createHash('sha512');\n for (const fileOrDirPath of paths.sort()) {\n const stat = await fs.promises.stat(fileOrDirPath);\n if (stat.isDirectory()) {\n // Get all files in the directory\n const dirents = await fs.promises.readdir(fileOrDirPath, { withFileTypes: true, recursive: true });\n for (const dirent of dirents.sort((d1, d2) => d1.name.localeCompare(d2.name))) {\n if (dirent.isFile()) {\n hash.update(await fs.promises.readFile(path.join(fileOrDirPath, dirent.name), 'utf8'));\n }\n }\n } else if (stat.isFile()) {\n hash.update(await fs.promises.readFile(fileOrDirPath, 'utf8'));\n }\n }\n return hash.digest('hex');\n}\n\nexport async function updateHashFromFiles(hashFilePath: string, ...paths: string[]): Promise<boolean> {\n let oldHash = '';\n try {\n oldHash = await fs.promises.readFile(hashFilePath, 'utf8');\n } catch {\n // do nothing\n }\n const newHash = await calculateHashFromFiles(...paths);\n if (oldHash === newHash) return false;\n\n await fs.promises.writeFile(hashFilePath, newHash, 'utf8');\n return true;\n}\n"],"names":["async","calculateHashFromFiles","paths","hash","crypto","createHash","fileOrDirPath","sort","stat","fs","promises","isDirectory","dirents","readdir","withFileTypes","recursive","dirent","d1","d2","name","localeCompare","isFile","update","readFile","path","join","digest","hashFilePath","oldHash","newHash","writeFile"],"mappings":"sFAIOA,eAAeC,KAA0BC,GAC9C,MAAMC,EAAOC,EAAOC,WAAW,UAC/B,IAAK,MAAMC,KAAiBJ,EAAMK,OAAQ,CACxC,MAAMC,QAAaC,EAAGC,SAASF,KAAKF,GACpC,GAAIE,EAAKG,cAAe,CAEtB,MAAMC,QAAgBH,EAAGC,SAASG,QAAQP,EAAe,CAAEQ,eAAe,EAAMC,WAAW,IAC3F,IAAK,MAAMC,KAAUJ,EAAQL,MAAK,CAACU,EAAIC,IAAOD,EAAGE,KAAKC,cAAcF,EAAGC,QACjEH,EAAOK,UACTlB,EAAKmB,aAAab,EAAGC,SAASa,SAASC,EAAKC,KAAKnB,EAAeU,EAAOG,MAAO,QAGpF,MAAWX,EAAKa,UACdlB,EAAKmB,aAAab,EAAGC,SAASa,SAASjB,EAAe,QAE1D,CACA,OAAOH,EAAKuB,OAAO,MACrB,8DAEO1B,eAAmC2B,KAAyBzB,GACjE,IAAI0B,EAAU,GACd,IACEA,QAAgBnB,EAAGC,SAASa,SAASI,EAAc,OACrD,CAAE,MACA,CAEF,MAAME,QAAgB5B,KAA0BC,GAChD,OAAI0B,IAAYC,UAEVpB,EAAGC,SAASoB,UAAUH,EAAcE,EAAS,SAC5C,EACT"}
|
package/dist/cjs/hash.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare function calculateHashFromFiles(paths: string[]): Promise<string>;
|
|
2
|
-
declare function updateHashFromFiles(hashFilePath: string, paths: string[]): Promise<boolean>;
|
|
1
|
+
declare function calculateHashFromFiles(...paths: string[]): Promise<string>;
|
|
2
|
+
declare function updateHashFromFiles(hashFilePath: string, ...paths: string[]): Promise<boolean>;
|
|
3
3
|
export { calculateHashFromFiles, updateHashFromFiles };
|
package/dist/esm/hash.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare function calculateHashFromFiles(paths: string[]): Promise<string>;
|
|
2
|
-
declare function updateHashFromFiles(hashFilePath: string, paths: string[]): Promise<boolean>;
|
|
1
|
+
declare function calculateHashFromFiles(...paths: string[]): Promise<string>;
|
|
2
|
+
declare function updateHashFromFiles(hashFilePath: string, ...paths: string[]): Promise<boolean>;
|
|
3
3
|
export { calculateHashFromFiles, updateHashFromFiles };
|
package/dist/esm/hash.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"node:crypto";import t from"node:fs";import i from"node:path";async function o(o){const r=e.createHash("sha512");for(const e of o.sort()){const o=await t.promises.stat(e);if(o.isDirectory()){const o=await t.promises.readdir(e,{withFileTypes:!0,recursive:!0});for(const
|
|
1
|
+
import e from"node:crypto";import t from"node:fs";import i from"node:path";async function o(...o){const r=e.createHash("sha512");for(const e of o.sort()){const o=await t.promises.stat(e);if(o.isDirectory()){const o=await t.promises.readdir(e,{withFileTypes:!0,recursive:!0});for(const a of o.sort(((e,t)=>e.name.localeCompare(t.name))))a.isFile()&&r.update(await t.promises.readFile(i.join(e,a.name),"utf8"))}else o.isFile()&&r.update(await t.promises.readFile(e,"utf8"))}return r.digest("hex")}async function r(e,...i){let r="";try{r=await t.promises.readFile(e,"utf8")}catch{}const a=await o(...i);return r!==a&&(await t.promises.writeFile(e,a,"utf8"),!0)}export{o as calculateHashFromFiles,r as updateHashFromFiles};
|
|
2
2
|
//# sourceMappingURL=hash.js.map
|
package/dist/esm/hash.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.js","sources":["../../src/hash.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nexport async function calculateHashFromFiles(paths: string[]): Promise<string> {\n const hash = crypto.createHash('sha512');\n for (const fileOrDirPath of paths.sort()) {\n const stat = await fs.promises.stat(fileOrDirPath);\n if (stat.isDirectory()) {\n // Get all files in the directory\n const dirents = await fs.promises.readdir(fileOrDirPath, { withFileTypes: true, recursive: true });\n for (const dirent of dirents.sort((d1, d2) => d1.name.localeCompare(d2.name))) {\n if (dirent.isFile()) {\n hash.update(await fs.promises.readFile(path.join(fileOrDirPath, dirent.name), 'utf8'));\n }\n }\n } else if (stat.isFile()) {\n hash.update(await fs.promises.readFile(fileOrDirPath, 'utf8'));\n }\n }\n return hash.digest('hex');\n}\n\nexport async function updateHashFromFiles(hashFilePath: string, paths: string[]): Promise<boolean> {\n
|
|
1
|
+
{"version":3,"file":"hash.js","sources":["../../src/hash.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nexport async function calculateHashFromFiles(...paths: string[]): Promise<string> {\n const hash = crypto.createHash('sha512');\n for (const fileOrDirPath of paths.sort()) {\n const stat = await fs.promises.stat(fileOrDirPath);\n if (stat.isDirectory()) {\n // Get all files in the directory\n const dirents = await fs.promises.readdir(fileOrDirPath, { withFileTypes: true, recursive: true });\n for (const dirent of dirents.sort((d1, d2) => d1.name.localeCompare(d2.name))) {\n if (dirent.isFile()) {\n hash.update(await fs.promises.readFile(path.join(fileOrDirPath, dirent.name), 'utf8'));\n }\n }\n } else if (stat.isFile()) {\n hash.update(await fs.promises.readFile(fileOrDirPath, 'utf8'));\n }\n }\n return hash.digest('hex');\n}\n\nexport async function updateHashFromFiles(hashFilePath: string, ...paths: string[]): Promise<boolean> {\n let oldHash = '';\n try {\n oldHash = await fs.promises.readFile(hashFilePath, 'utf8');\n } catch {\n // do nothing\n }\n const newHash = await calculateHashFromFiles(...paths);\n if (oldHash === newHash) return false;\n\n await fs.promises.writeFile(hashFilePath, newHash, 'utf8');\n return true;\n}\n"],"names":["async","calculateHashFromFiles","paths","hash","crypto","createHash","fileOrDirPath","sort","stat","fs","promises","isDirectory","dirents","readdir","withFileTypes","recursive","dirent","d1","d2","name","localeCompare","isFile","update","readFile","path","join","digest","updateHashFromFiles","hashFilePath","oldHash","newHash","writeFile"],"mappings":"2EAIOA,eAAeC,KAA0BC,GAC9C,MAAMC,EAAOC,EAAOC,WAAW,UAC/B,IAAK,MAAMC,KAAiBJ,EAAMK,OAAQ,CACxC,MAAMC,QAAaC,EAAGC,SAASF,KAAKF,GACpC,GAAIE,EAAKG,cAAe,CAEtB,MAAMC,QAAgBH,EAAGC,SAASG,QAAQP,EAAe,CAAEQ,eAAe,EAAMC,WAAW,IAC3F,IAAK,MAAMC,KAAUJ,EAAQL,MAAK,CAACU,EAAIC,IAAOD,EAAGE,KAAKC,cAAcF,EAAGC,QACjEH,EAAOK,UACTlB,EAAKmB,aAAab,EAAGC,SAASa,SAASC,EAAKC,KAAKnB,EAAeU,EAAOG,MAAO,QAGpF,MAAWX,EAAKa,UACdlB,EAAKmB,aAAab,EAAGC,SAASa,SAASjB,EAAe,QAE1D,CACA,OAAOH,EAAKuB,OAAO,MACrB,CAEO1B,eAAe2B,EAAoBC,KAAyB1B,GACjE,IAAI2B,EAAU,GACd,IACEA,QAAgBpB,EAAGC,SAASa,SAASK,EAAc,OACrD,CAAE,MACA,CAEF,MAAME,QAAgB7B,KAA0BC,GAChD,OAAI2B,IAAYC,UAEVrB,EAAGC,SAASqB,UAAUH,EAAcE,EAAS,SAC5C,EACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/shared-lib-node",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"author": "WillBooster Inc.",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"@types/eslint": "8.44.1",
|
|
44
44
|
"@types/micromatch": "4.0.2",
|
|
45
45
|
"@types/prettier": "2.7.3",
|
|
46
|
-
"@typescript-eslint/eslint-plugin": "6.2.
|
|
47
|
-
"@typescript-eslint/parser": "6.2.
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "6.2.1",
|
|
47
|
+
"@typescript-eslint/parser": "6.2.1",
|
|
48
48
|
"@willbooster/eslint-config-ts": "10.4.0",
|
|
49
49
|
"@willbooster/prettier-config": "9.1.1",
|
|
50
|
-
"build-ts": "
|
|
50
|
+
"build-ts": "8.1.0",
|
|
51
51
|
"eslint": "8.46.0",
|
|
52
52
|
"eslint-config-prettier": "8.9.0",
|
|
53
53
|
"eslint-import-resolver-typescript": "3.5.5",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"prettier": "3.0.0",
|
|
61
61
|
"sort-package-json": "2.5.1",
|
|
62
62
|
"typescript": "5.1.6",
|
|
63
|
-
"vitest": "0.
|
|
63
|
+
"vitest": "0.34.1"
|
|
64
64
|
},
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|