@willbooster/shared-lib-node 2.4.1 → 2.5.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.
@@ -0,0 +1,2 @@
1
+ "use strict";var e=require("node:crypto"),s=require("node:fs"),t=require("node:path");async function i(i){const r=e.createHash("sha512");for(const e of i.sort()){const i=await s.promises.stat(e);if(i.isDirectory()){const i=await s.promises.readdir(e,{withFileTypes:!0,recursive:!0});for(const a of i.sort(((e,s)=>e.name.localeCompare(s.name))))a.isFile()&&r.update(await s.promises.readFile(t.join(e,a.name),"utf8"))}else i.isFile()&&r.update(await s.promises.readFile(e,"utf8"))}return r.digest("hex")}exports.calculateHashFromFiles=i,exports.updateHashFromFiles=async function(e,t){const r=await s.promises.readFile(e,"utf8"),a=await i(t);return r!==a&&(await s.promises.writeFile(e,a,"utf8"),!0)};
2
+ //# sourceMappingURL=hash.cjs.map
@@ -0,0 +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 const oldHash = await fs.promises.readFile(hashFilePath, 'utf8');\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,EAAuBC,GAC3C,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,EAAsBzB,GAC9D,MAAM0B,QAAgBnB,EAAGC,SAASa,SAASI,EAAc,QACnDE,QAAgB5B,EAAuBC,GAC7C,OAAI0B,IAAYC,UAEVpB,EAAGC,SAASoB,UAAUH,EAAcE,EAAS,SAC5C,EACT"}
@@ -0,0 +1,3 @@
1
+ declare function calculateHashFromFiles(paths: string[]): Promise<string>;
2
+ declare function updateHashFromFiles(hashFilePath: string, paths: string[]): Promise<boolean>;
3
+ export { calculateHashFromFiles, updateHashFromFiles };
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("./env.cjs"),s=require("./exists.cjs"),n=require("./spawn.cjs");exports.loadEnvironmentVariables=e.loadEnvironmentVariables,exports.removeNpmAndYarnEnvironmentVariables=e.removeNpmAndYarnEnvironmentVariables,exports.existsAsync=s.existsAsync,exports.spawnAsync=n.spawnAsync;
1
+ "use strict";var e=require("./env.cjs"),s=require("./exists.cjs"),r=require("./hash.cjs"),a=require("./spawn.cjs");exports.loadEnvironmentVariables=e.loadEnvironmentVariables,exports.removeNpmAndYarnEnvironmentVariables=e.removeNpmAndYarnEnvironmentVariables,exports.existsAsync=s.existsAsync,exports.calculateHashFromFiles=r.calculateHashFromFiles,exports.updateHashFromFiles=r.updateHashFromFiles,exports.spawnAsync=a.spawnAsync;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,3 +1,4 @@
1
1
  export { loadEnvironmentVariables, removeNpmAndYarnEnvironmentVariables } from "./env.js";
2
2
  export { existsAsync } from "./exists.js";
3
+ export { calculateHashFromFiles, updateHashFromFiles } from "./hash.js";
3
4
  export { spawnAsync } from "./spawn.js";
@@ -0,0 +1,3 @@
1
+ declare function calculateHashFromFiles(paths: string[]): Promise<string>;
2
+ declare function updateHashFromFiles(hashFilePath: string, paths: string[]): Promise<boolean>;
3
+ export { calculateHashFromFiles, updateHashFromFiles };
@@ -0,0 +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 s of o.sort(((e,t)=>e.name.localeCompare(t.name))))s.isFile()&&r.update(await t.promises.readFile(i.join(e,s.name),"utf8"))}else o.isFile()&&r.update(await t.promises.readFile(e,"utf8"))}return r.digest("hex")}async function r(e,i){const r=await t.promises.readFile(e,"utf8"),s=await o(i);return r!==s&&(await t.promises.writeFile(e,s,"utf8"),!0)}export{o as calculateHashFromFiles,r as updateHashFromFiles};
2
+ //# sourceMappingURL=hash.js.map
@@ -0,0 +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 const oldHash = await fs.promises.readFile(hashFilePath, 'utf8');\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,EAAuBC,GAC3C,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,EAAsB1B,GAC9D,MAAM2B,QAAgBpB,EAAGC,SAASa,SAASK,EAAc,QACnDE,QAAgB7B,EAAuBC,GAC7C,OAAI2B,IAAYC,UAEVrB,EAAGC,SAASqB,UAAUH,EAAcE,EAAS,SAC5C,EACT"}
@@ -1,3 +1,4 @@
1
1
  export { loadEnvironmentVariables, removeNpmAndYarnEnvironmentVariables } from "./env.js";
2
2
  export { existsAsync } from "./exists.js";
3
+ export { calculateHashFromFiles, updateHashFromFiles } from "./hash.js";
3
4
  export { spawnAsync } from "./spawn.js";
package/dist/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export{loadEnvironmentVariables,removeNpmAndYarnEnvironmentVariables}from"./env.js";export{existsAsync}from"./exists.js";export{spawnAsync}from"./spawn.js";
1
+ export{loadEnvironmentVariables,removeNpmAndYarnEnvironmentVariables}from"./env.js";export{existsAsync}from"./exists.js";export{calculateHashFromFiles,updateHashFromFiles}from"./hash.js";export{spawnAsync}from"./spawn.js";
2
2
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/shared-lib-node",
3
- "version": "2.4.1",
3
+ "version": "2.5.0",
4
4
  "license": "Apache-2.0",
5
5
  "author": "WillBooster Inc.",
6
6
  "sideEffects": false,
@@ -40,21 +40,21 @@
40
40
  "tree-kill": "1.2.2"
41
41
  },
42
42
  "devDependencies": {
43
- "@types/eslint": "8.44.0",
43
+ "@types/eslint": "8.44.1",
44
44
  "@types/micromatch": "4.0.2",
45
45
  "@types/prettier": "2.7.3",
46
46
  "@typescript-eslint/eslint-plugin": "6.2.0",
47
47
  "@typescript-eslint/parser": "6.2.0",
48
48
  "@willbooster/eslint-config-ts": "10.4.0",
49
49
  "@willbooster/prettier-config": "9.1.1",
50
- "build-ts": "7.0.1",
51
- "eslint": "8.45.0",
52
- "eslint-config-prettier": "8.8.0",
50
+ "build-ts": "7.0.2",
51
+ "eslint": "8.46.0",
52
+ "eslint-config-prettier": "8.9.0",
53
53
  "eslint-import-resolver-typescript": "3.5.5",
54
- "eslint-plugin-import": "2.27.5",
54
+ "eslint-plugin-import": "2.28.0",
55
55
  "eslint-plugin-sort-class-members": "1.18.0",
56
56
  "eslint-plugin-sort-destructure-keys": "1.5.0",
57
- "eslint-plugin-unicorn": "48.0.0",
57
+ "eslint-plugin-unicorn": "48.0.1",
58
58
  "lint-staged": "13.2.3",
59
59
  "micromatch": "4.0.5",
60
60
  "prettier": "3.0.0",