@willbooster/shared-lib-node 6.0.6 → 6.1.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/glob.cjs +2 -0
- package/dist/glob.cjs.map +1 -0
- package/dist/glob.d.ts +15 -0
- package/dist/glob.js +2 -0
- package/dist/glob.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/package.json +4 -3
package/dist/glob.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e=require("node:fs"),s=require("node:path");function n(e,n){return n?.some((n=>{const o=n.replaceAll("\\","/");return s.join(e.parentPath,e.name).replaceAll("\\","/").includes(o)}))}exports.glob=async function*(o,l){if(process.versions.bun){const e=new((await import("bun")).Glob)(o);for await(const o of e.scan({cwd:l.cwd,onlyFiles:l.onlyFiles})){const e=s.parse(o),r={name:e.base,parentPath:s.resolve(l.cwd??".",e.dir)};n(r,l.excludes)||(yield r)}}else for await(const s of e.promises.glob(o,{...l,withFileTypes:!0}))l.onlyFiles&&!s.isFile()||n(s,l.excludes)||(yield s)},exports.globSync=function(o,l){if(process.versions.bun){const e=new(require("bun").Glob)(o),r=[];for(const o of e.scanSync({cwd:l.cwd,onlyFiles:l.onlyFiles})){const e=s.parse(o),i={name:e.base,parentPath:s.resolve(l.cwd??".",e.dir)};n(i,l.excludes)||r.push(i)}return r}return e.globSync(o,{...l,withFileTypes:!0}).filter((e=>(!l.onlyFiles||e.isFile())&&!n(e,l.excludes)))};
|
|
2
|
+
//# sourceMappingURL=glob.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glob.cjs","sources":["../src/glob.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport type { Glob } from 'bun';\n\ntype NodeJsDirentLike = {\n name: string;\n parentPath: string;\n};\n\nexport async function* glob(\n pattern: string,\n options: { cwd?: string; excludes?: string[]; onlyFiles: boolean }\n): NodeJS.AsyncIterator<NodeJsDirentLike> {\n // cf. https://bun.sh/guides/util/detect-bun\n if (process.versions.bun) {\n const bun = await import('bun');\n const bunGlob = new bun.Glob(pattern);\n for await (const direntPath of bunGlob.scan({ cwd: options.cwd, onlyFiles: options.onlyFiles })) {\n const parsedDirentPath = path.parse(direntPath);\n const dirent = {\n name: parsedDirentPath.base,\n parentPath: path.resolve(options.cwd ?? '.', parsedDirentPath.dir),\n };\n if (isExcluded(dirent, options.excludes)) continue;\n\n yield dirent;\n }\n } else {\n for await (const dirent of fs.promises.glob(pattern, { ...options, withFileTypes: true })) {\n if (options.onlyFiles && !dirent.isFile()) continue;\n if (isExcluded(dirent, options.excludes)) continue;\n\n yield dirent;\n }\n }\n}\n\nexport function globSync(\n pattern: string,\n options: { cwd?: string; excludes?: string[]; onlyFiles: boolean }\n): NodeJsDirentLike[] {\n // cf. https://bun.sh/guides/util/detect-bun\n if (process.versions.bun) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports,unicorn/prefer-module\n const bun = require('bun');\n const bunGlob = new bun.Glob(pattern) as Glob;\n const dirents: NodeJsDirentLike[] = [];\n for (const direntPath of bunGlob.scanSync({ cwd: options.cwd, onlyFiles: options.onlyFiles })) {\n const parsedDirentPath = path.parse(direntPath);\n const dirent = {\n name: parsedDirentPath.base,\n parentPath: path.resolve(options.cwd ?? '.', parsedDirentPath.dir),\n };\n if (isExcluded(dirent, options.excludes)) continue;\n\n dirents.push(dirent);\n }\n return dirents;\n } else {\n return fs\n .globSync(pattern, { ...options, withFileTypes: true })\n .filter((dirent) => (!options.onlyFiles || dirent.isFile()) && !isExcluded(dirent, options.excludes));\n }\n}\n\nfunction isExcluded(dirent: NodeJsDirentLike, excludes?: string[]): boolean | undefined {\n return excludes?.some((exclude) => {\n const pattern = exclude.replaceAll('\\\\', '/');\n return path.join(dirent.parentPath, dirent.name).replaceAll('\\\\', '/').includes(pattern);\n });\n}\n"],"names":["isExcluded","dirent","excludes","some","exclude","pattern","replaceAll","path","join","parentPath","name","includes","async","options","process","versions","bun","bunGlob","import","Glob","direntPath","scan","cwd","onlyFiles","parsedDirentPath","parse","base","resolve","dir","fs","promises","glob","withFileTypes","isFile","require","dirents","scanSync","push","globSync","filter"],"mappings":"6DAkEA,SAASA,EAAWC,EAA0BC,GAC5C,OAAOA,GAAUC,MAAMC,IACrB,MAAMC,EAAUD,EAAQE,WAAW,KAAM,KACzC,OAAOC,EAAKC,KAAKP,EAAOQ,WAAYR,EAAOS,MAAMJ,WAAW,KAAM,KAAKK,SAASN,EAAQ,GAE5F,cA7DOO,gBACLP,EACAQ,GAGA,GAAIC,QAAQC,SAASC,IAAK,CACxB,MACMC,EAAU,WADEC,OAAO,QACDC,MAAKd,GAC7B,UAAW,MAAMe,KAAcH,EAAQI,KAAK,CAAEC,IAAKT,EAAQS,IAAKC,UAAWV,EAAQU,YAAc,CAC/F,MAAMC,EAAmBjB,EAAKkB,MAAML,GAC9BnB,EAAS,CACbS,KAAMc,EAAiBE,KACvBjB,WAAYF,EAAKoB,QAAQd,EAAQS,KAAO,IAAKE,EAAiBI,MAE5D5B,EAAWC,EAAQY,EAAQX,kBAEzBD,EACR,CACF,MACE,UAAW,MAAMA,KAAU4B,EAAGC,SAASC,KAAK1B,EAAS,IAAKQ,EAASmB,eAAe,IAC5EnB,EAAQU,YAActB,EAAOgC,UAC7BjC,EAAWC,EAAQY,EAAQX,kBAEzBD,EAGZ,mBAEO,SACLI,EACAQ,GAGA,GAAIC,QAAQC,SAASC,IAAK,CAExB,MACMC,EAAU,IADJiB,QAAQ,OACIf,MAAKd,GACvB8B,EAA8B,GACpC,IAAK,MAAMf,KAAcH,EAAQmB,SAAS,CAAEd,IAAKT,EAAQS,IAAKC,UAAWV,EAAQU,YAAc,CAC7F,MAAMC,EAAmBjB,EAAKkB,MAAML,GAC9BnB,EAAS,CACbS,KAAMc,EAAiBE,KACvBjB,WAAYF,EAAKoB,QAAQd,EAAQS,KAAO,IAAKE,EAAiBI,MAE5D5B,EAAWC,EAAQY,EAAQX,WAE/BiC,EAAQE,KAAKpC,EACf,CACA,OAAOkC,CACT,CACE,OAAON,EACJS,SAASjC,EAAS,IAAKQ,EAASmB,eAAe,IAC/CO,QAAQtC,KAAaY,EAAQU,WAAatB,EAAOgC,YAAcjC,EAAWC,EAAQY,EAAQX,WAEjG"}
|
package/dist/glob.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type NodeJsDirentLike = {
|
|
2
|
+
name: string;
|
|
3
|
+
parentPath: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function glob(pattern: string, options: {
|
|
6
|
+
cwd?: string;
|
|
7
|
+
excludes?: string[];
|
|
8
|
+
onlyFiles: boolean;
|
|
9
|
+
}): NodeJS.AsyncIterator<NodeJsDirentLike>;
|
|
10
|
+
export declare function globSync(pattern: string, options: {
|
|
11
|
+
cwd?: string;
|
|
12
|
+
excludes?: string[];
|
|
13
|
+
onlyFiles: boolean;
|
|
14
|
+
}): NodeJsDirentLike[];
|
|
15
|
+
export {};
|
package/dist/glob.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import e from"node:fs";import n from"node:path";async function*s(s,o){if(process.versions.bun){const e=new((await import("bun")).Glob)(s);for await(const s of e.scan({cwd:o.cwd,onlyFiles:o.onlyFiles})){const e=n.parse(s),i={name:e.base,parentPath:n.resolve(o.cwd??".",e.dir)};l(i,o.excludes)||(yield i)}}else for await(const n of e.promises.glob(s,{...o,withFileTypes:!0}))o.onlyFiles&&!n.isFile()||l(n,o.excludes)||(yield n)}function o(s,o){if(process.versions.bun){const e=new(require("bun").Glob)(s),i=[];for(const s of e.scanSync({cwd:o.cwd,onlyFiles:o.onlyFiles})){const e=n.parse(s),r={name:e.base,parentPath:n.resolve(o.cwd??".",e.dir)};l(r,o.excludes)||i.push(r)}return i}return e.globSync(s,{...o,withFileTypes:!0}).filter((e=>(!o.onlyFiles||e.isFile())&&!l(e,o.excludes)))}function l(e,s){return s?.some((s=>{const o=s.replaceAll("\\","/");return n.join(e.parentPath,e.name).replaceAll("\\","/").includes(o)}))}export{s as glob,o as globSync};
|
|
2
|
+
//# sourceMappingURL=glob.js.map
|
package/dist/glob.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glob.js","sources":["../src/glob.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport type { Glob } from 'bun';\n\ntype NodeJsDirentLike = {\n name: string;\n parentPath: string;\n};\n\nexport async function* glob(\n pattern: string,\n options: { cwd?: string; excludes?: string[]; onlyFiles: boolean }\n): NodeJS.AsyncIterator<NodeJsDirentLike> {\n // cf. https://bun.sh/guides/util/detect-bun\n if (process.versions.bun) {\n const bun = await import('bun');\n const bunGlob = new bun.Glob(pattern);\n for await (const direntPath of bunGlob.scan({ cwd: options.cwd, onlyFiles: options.onlyFiles })) {\n const parsedDirentPath = path.parse(direntPath);\n const dirent = {\n name: parsedDirentPath.base,\n parentPath: path.resolve(options.cwd ?? '.', parsedDirentPath.dir),\n };\n if (isExcluded(dirent, options.excludes)) continue;\n\n yield dirent;\n }\n } else {\n for await (const dirent of fs.promises.glob(pattern, { ...options, withFileTypes: true })) {\n if (options.onlyFiles && !dirent.isFile()) continue;\n if (isExcluded(dirent, options.excludes)) continue;\n\n yield dirent;\n }\n }\n}\n\nexport function globSync(\n pattern: string,\n options: { cwd?: string; excludes?: string[]; onlyFiles: boolean }\n): NodeJsDirentLike[] {\n // cf. https://bun.sh/guides/util/detect-bun\n if (process.versions.bun) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports,unicorn/prefer-module\n const bun = require('bun');\n const bunGlob = new bun.Glob(pattern) as Glob;\n const dirents: NodeJsDirentLike[] = [];\n for (const direntPath of bunGlob.scanSync({ cwd: options.cwd, onlyFiles: options.onlyFiles })) {\n const parsedDirentPath = path.parse(direntPath);\n const dirent = {\n name: parsedDirentPath.base,\n parentPath: path.resolve(options.cwd ?? '.', parsedDirentPath.dir),\n };\n if (isExcluded(dirent, options.excludes)) continue;\n\n dirents.push(dirent);\n }\n return dirents;\n } else {\n return fs\n .globSync(pattern, { ...options, withFileTypes: true })\n .filter((dirent) => (!options.onlyFiles || dirent.isFile()) && !isExcluded(dirent, options.excludes));\n }\n}\n\nfunction isExcluded(dirent: NodeJsDirentLike, excludes?: string[]): boolean | undefined {\n return excludes?.some((exclude) => {\n const pattern = exclude.replaceAll('\\\\', '/');\n return path.join(dirent.parentPath, dirent.name).replaceAll('\\\\', '/').includes(pattern);\n });\n}\n"],"names":["async","glob","pattern","options","process","versions","bun","bunGlob","import","Glob","direntPath","scan","cwd","onlyFiles","parsedDirentPath","path","parse","dirent","name","base","parentPath","resolve","dir","isExcluded","excludes","fs","promises","withFileTypes","isFile","globSync","require","dirents","scanSync","push","filter","some","exclude","replaceAll","join","includes"],"mappings":"gDAUOA,eAAgBC,EACrBC,EACAC,GAGA,GAAIC,QAAQC,SAASC,IAAK,CACxB,MACMC,EAAU,WADEC,OAAO,QACDC,MAAKP,GAC7B,UAAW,MAAMQ,KAAcH,EAAQI,KAAK,CAAEC,IAAKT,EAAQS,IAAKC,UAAWV,EAAQU,YAAc,CAC/F,MAAMC,EAAmBC,EAAKC,MAAMN,GAC9BO,EAAS,CACbC,KAAMJ,EAAiBK,KACvBC,WAAYL,EAAKM,QAAQlB,EAAQS,KAAO,IAAKE,EAAiBQ,MAE5DC,EAAWN,EAAQd,EAAQqB,kBAEzBP,EACR,CACF,MACE,UAAW,MAAMA,KAAUQ,EAAGC,SAASzB,KAAKC,EAAS,IAAKC,EAASwB,eAAe,IAC5ExB,EAAQU,YAAcI,EAAOW,UAC7BL,EAAWN,EAAQd,EAAQqB,kBAEzBP,EAGZ,CAEO,SAASY,EACd3B,EACAC,GAGA,GAAIC,QAAQC,SAASC,IAAK,CAExB,MACMC,EAAU,IADJuB,QAAQ,OACIrB,MAAKP,GACvB6B,EAA8B,GACpC,IAAK,MAAMrB,KAAcH,EAAQyB,SAAS,CAAEpB,IAAKT,EAAQS,IAAKC,UAAWV,EAAQU,YAAc,CAC7F,MAAMC,EAAmBC,EAAKC,MAAMN,GAC9BO,EAAS,CACbC,KAAMJ,EAAiBK,KACvBC,WAAYL,EAAKM,QAAQlB,EAAQS,KAAO,IAAKE,EAAiBQ,MAE5DC,EAAWN,EAAQd,EAAQqB,WAE/BO,EAAQE,KAAKhB,EACf,CACA,OAAOc,CACT,CACE,OAAON,EACJI,SAAS3B,EAAS,IAAKC,EAASwB,eAAe,IAC/CO,QAAQjB,KAAad,EAAQU,WAAaI,EAAOW,YAAcL,EAAWN,EAAQd,EAAQqB,WAEjG,CAEA,SAASD,EAAWN,EAA0BO,GAC5C,OAAOA,GAAUW,MAAMC,IACrB,MAAMlC,EAAUkC,EAAQC,WAAW,KAAM,KACzC,OAAOtB,EAAKuB,KAAKrB,EAAOG,WAAYH,EAAOC,MAAMmB,WAAW,KAAM,KAAKE,SAASrC,EAAQ,GAE5F"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("./env.cjs"),r=require("./exists.cjs"),s=require("./
|
|
1
|
+
"use strict";var e=require("./env.cjs"),r=require("./exists.cjs"),s=require("./glob.cjs"),n=require("./hash.cjs"),a=require("./spawn.cjs");exports.readAndApplyEnvironmentVariables=e.readAndApplyEnvironmentVariables,exports.readEnvironmentVariables=e.readEnvironmentVariables,exports.removeNpmAndYarnEnvironmentVariables=e.removeNpmAndYarnEnvironmentVariables,exports.yargsOptionsBuilderForEnv=e.yargsOptionsBuilderForEnv,exports.existsAsync=r.existsAsync,exports.glob=s.glob,exports.globSync=s.globSync,exports.calculateHashFromFiles=n.calculateHashFromFiles,exports.canSkipSeed=n.canSkipSeed,exports.updateHashFromFiles=n.updateHashFromFiles,exports.spawnAsync=a.spawnAsync;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { readEnvironmentVariables, readAndApplyEnvironmentVariables, removeNpmAndYarnEnvironmentVariables, yargsOptionsBuilderForEnv, } from './env.js';
|
|
2
2
|
export type { EnvReaderOptions } from './env.js';
|
|
3
3
|
export { existsAsync } from './exists.js';
|
|
4
|
+
export { glob, globSync } from './glob.js';
|
|
4
5
|
export { calculateHashFromFiles, canSkipSeed, updateHashFromFiles } from './hash.js';
|
|
5
6
|
export { spawnAsync } from './spawn.js';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{readAndApplyEnvironmentVariables,readEnvironmentVariables,removeNpmAndYarnEnvironmentVariables,yargsOptionsBuilderForEnv}from"./env.js";export{existsAsync}from"./exists.js";export{calculateHashFromFiles,canSkipSeed,updateHashFromFiles}from"./hash.js";export{spawnAsync}from"./spawn.js";
|
|
1
|
+
export{readAndApplyEnvironmentVariables,readEnvironmentVariables,removeNpmAndYarnEnvironmentVariables,yargsOptionsBuilderForEnv}from"./env.js";export{existsAsync}from"./exists.js";export{glob,globSync}from"./glob.js";export{calculateHashFromFiles,canSkipSeed,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": "6.0
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"author": "WillBooster Inc.",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -31,11 +31,12 @@
|
|
|
31
31
|
"lint": "eslint --color \"./{scripts,src,tests}/**/*.{cjs,cts,js,jsx,mjs,mts,ts,tsx}\"",
|
|
32
32
|
"lint-fix": "yarn lint --fix",
|
|
33
33
|
"prettify": "prettier --cache --color --write \"**/{.*/,}*.{cjs,css,cts,htm,html,js,json,json5,jsonc,jsx,md,mjs,mts,scss,ts,tsx,vue,yaml,yml}\" \"!**/test-fixtures/**\"",
|
|
34
|
-
"test": "vitest",
|
|
34
|
+
"test": "vitest tests/",
|
|
35
35
|
"typecheck": "tsc --noEmit --Pretty"
|
|
36
36
|
},
|
|
37
37
|
"prettier": "@willbooster/prettier-config",
|
|
38
38
|
"dependencies": {
|
|
39
|
+
"@types/bun": "1.1.17",
|
|
39
40
|
"dotenv": "16.4.7",
|
|
40
41
|
"tree-kill": "1.2.2"
|
|
41
42
|
},
|
|
@@ -47,7 +48,7 @@
|
|
|
47
48
|
"@typescript-eslint/parser": "8.20.0",
|
|
48
49
|
"@willbooster/eslint-config-ts": "10.6.1",
|
|
49
50
|
"@willbooster/prettier-config": "9.1.3",
|
|
50
|
-
"build-ts": "13.1.
|
|
51
|
+
"build-ts": "13.1.12",
|
|
51
52
|
"eslint": "8.57.0",
|
|
52
53
|
"eslint-config-prettier": "10.0.1",
|
|
53
54
|
"eslint-import-resolver-typescript": "3.7.0",
|