@layerzerolabs/common-node-utils 0.0.31

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,26 @@
1
+
2
+ > @layerzerolabs/common-node-utils@0.0.0 build /home/runner/work/monorepo-internal/monorepo-internal/packages/common/common-node-utils
3
+ > tsup
4
+
5
+ CLI Building entry: src/files.ts, src/index.ts
6
+ CLI Using tsconfig: tsconfig.json
7
+ CLI tsup v8.4.0
8
+ CLI Using tsup config: /home/runner/work/monorepo-internal/monorepo-internal/packages/common/common-node-utils/tsup.config.ts
9
+ CLI Target: es2022
10
+ CLI Cleaning output folder
11
+ CJS Build start
12
+ ESM Build start
13
+ ESM dist/index.js 1.06 KB
14
+ ESM dist/PXUGBXL3.js 1.00 KB
15
+ ESM dist/files.js 129.00 B
16
+ ESM dist/index.js.map 2.04 KB
17
+ ESM dist/PXUGBXL3.js.map 1.98 KB
18
+ ESM dist/files.js.map 69.00 B
19
+ ESM ⚡️ Build success in 98ms
20
+ CJS dist/files.cjs 295.00 B
21
+ CJS dist/index.cjs 1.87 KB
22
+ CJS dist/ORVETYPP.cjs 789.00 B
23
+ CJS dist/files.cjs.map 70.00 B
24
+ CJS dist/index.cjs.map 2.08 KB
25
+ CJS dist/ORVETYPP.cjs.map 1.23 KB
26
+ CJS ⚡️ Build success in 98ms
@@ -0,0 +1,8 @@
1
+
2
+ > @layerzerolabs/common-node-utils@0.0.0 checkdeps /home/runner/work/monorepo-internal/monorepo-internal/packages/common/common-node-utils
3
+ > pnpm --filter @layerzerolabs/depcheck run depcheck validate --catalog --missing-dependencies --only $npm_package_name
4
+
5
+
6
+ > @layerzerolabs/depcheck@1.0.1 depcheck /home/runner/work/monorepo-internal/monorepo-internal/tools/repo/depcheck
7
+ > tsx ./src/index.ts "validate" "--catalog" "--missing-dependencies" "--only" "@layerzerolabs/common-node-utils"
8
+
@@ -0,0 +1,4 @@
1
+
2
+ > @layerzerolabs/common-node-utils@0.0.0 lint /home/runner/work/monorepo-internal/monorepo-internal/packages/common/common-node-utils
3
+ > eslint . --max-warnings 0 || (eslint . --fix --max-warnings 0 && false)
4
+
@@ -0,0 +1,12 @@
1
+
2
+ > @layerzerolabs/common-node-utils@0.0.0 test /home/runner/work/monorepo-internal/monorepo-internal/packages/common/common-node-utils
3
+ > vitest --run --pass-with-no-tests
4
+
5
+
6
+  RUN  v3.2.3 /home/runner/work/monorepo-internal/monorepo-internal/packages/common/common-node-utils
7
+
8
+ No test files found, exiting with code 0
9
+
10
+ include: **/*.{test,spec}.?(c|m)[jt]s?(x)
11
+ exclude: **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*
12
+
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ var promises = require('fs/promises');
4
+ var path = require('path');
5
+
6
+ var __defProp = Object.defineProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var dirCache = /* @__PURE__ */ new Map();
9
+ var writeFileAndCreateDirsCached = /* @__PURE__ */ __name(async (path$1, data) => {
10
+ const dir = path.dirname(path$1);
11
+ if (!dirCache.has(dir)) {
12
+ dirCache.set(dir, promises.mkdir(dir, {
13
+ recursive: true
14
+ }));
15
+ }
16
+ await dirCache.get(dir)?.then(() => promises.writeFile(path$1, data, {
17
+ encoding: "utf-8"
18
+ }));
19
+ }, "writeFileAndCreateDirsCached");
20
+
21
+ exports.__name = __name;
22
+ exports.writeFileAndCreateDirsCached = writeFileAndCreateDirsCached;
23
+ //# sourceMappingURL=ORVETYPP.cjs.map
24
+ //# sourceMappingURL=ORVETYPP.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/files.ts"],"names":["dirCache","Map","writeFileAndCreateDirsCached","path","data","dir","dirname","has","set","mkdir","recursive","get","then","writeFile","encoding"],"mappings":";;;;;;;AAGA,IAAMA,QAAAA,uBAAeC,GAAAA,EAAAA;AAEd,IAAMC,4BAAAA,mBAA+B,MAAA,CAAA,OAAOC,MAAAA,EAAcC,IAAAA,KAAAA;AAC7D,EAAA,MAAMC,GAAAA,GAAMC,aAAQH,MAAAA,CAAAA;AAEpB,EAAA,IAAI,CAACH,QAAAA,CAASO,GAAAA,CAAIF,GAAAA,CAAAA,EAAM;AACpBL,IAAAA,QAAAA,CAASQ,GAAAA,CAAIH,GAAAA,EAAKI,cAAAA,CAAMJ,GAAAA,EAAK;MAAEK,SAAAA,EAAW;AAAK,KAAA,CAAA,CAAA;AACnD,EAAA;AACA,EAAA,MAAMV,QAAAA,CAASW,IAAIN,GAAAA,CAAAA,EAAMO,KAAK,MAAMC,kBAAAA,CAAUV,QAAMC,IAAAA,EAAM;IAAEU,QAAAA,EAAU;AAAQ,GAAA,CAAA,CAAA;AAClF,CAAA,EAP4C,8BAAA","file":"ORVETYPP.cjs","sourcesContent":["import { mkdir, writeFile } from 'node:fs/promises';\nimport { dirname } from 'node:path';\n\nconst dirCache = new Map<string, Promise<string | undefined>>();\n\nexport const writeFileAndCreateDirsCached = async (path: string, data: string) => {\n const dir = dirname(path);\n // Deduplicate concurrent mkdir calls\n if (!dirCache.has(dir)) {\n dirCache.set(dir, mkdir(dir, { recursive: true }));\n }\n await dirCache.get(dir)?.then(() => writeFile(path, data, { encoding: 'utf-8' }));\n};\n"]}
@@ -0,0 +1,26 @@
1
+ import { fileURLToPath } from 'url';
2
+ import path from 'path';
3
+ import { mkdir, writeFile } from 'node:fs/promises';
4
+ import { dirname } from 'node:path';
5
+
6
+ var __defProp = Object.defineProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var getFilename = /* @__PURE__ */ __name(() => fileURLToPath(import.meta.url), "getFilename");
9
+ var getDirname = /* @__PURE__ */ __name(() => path.dirname(getFilename()), "getDirname");
10
+ var __dirname = /* @__PURE__ */ getDirname();
11
+ var dirCache = /* @__PURE__ */ new Map();
12
+ var writeFileAndCreateDirsCached = /* @__PURE__ */ __name(async (path2, data) => {
13
+ const dir = dirname(path2);
14
+ if (!dirCache.has(dir)) {
15
+ dirCache.set(dir, mkdir(dir, {
16
+ recursive: true
17
+ }));
18
+ }
19
+ await dirCache.get(dir)?.then(() => writeFile(path2, data, {
20
+ encoding: "utf-8"
21
+ }));
22
+ }, "writeFileAndCreateDirsCached");
23
+
24
+ export { __dirname, __name, writeFileAndCreateDirsCached };
25
+ //# sourceMappingURL=PXUGBXL3.js.map
26
+ //# sourceMappingURL=PXUGBXL3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../node_modules/.pnpm/tsup@8.4.0_@swc+core@1.12.5_@swc+helpers@0.5.17__postcss@8.5.3_tsx@4.20.4_typescript@5.8.2_yaml@2.8.0/node_modules/tsup/assets/esm_shims.js","../src/files.ts"],"names":["getFilename","fileURLToPath","url","getDirname","path","dirname","__dirname","dirCache","Map","writeFileAndCreateDirsCached","data","dir","has","set","mkdir","recursive","get","then","writeFile","encoding"],"mappings":";;;;;;;AAIA,IAAMA,WAAAA,mBAAc,MAAA,CAAA,MAAMC,aAAAA,CAAc,MAAA,CAAA,IAAA,CAAYC,GAAG,CAAA,EAAnC,aAAA,CAAA;AACpB,IAAMC,6BAAa,MAAA,CAAA,MAAMC,IAAAA,CAAKC,OAAAA,CAAQL,WAAAA,EAAAA,CAAAA,EAAnB,YAAA,CAAA;AAEZ,IAAMM,4BAA4BH,UAAAA;ACJzC,IAAMI,QAAAA,uBAAeC,GAAAA,EAAAA;AAEd,IAAMC,4BAAAA,mBAA+B,MAAA,CAAA,OAAOL,KAAAA,EAAcM,IAAAA,KAAAA;AAC7D,EAAA,MAAMC,GAAAA,GAAMN,QAAQD,KAAAA,CAAAA;AAEpB,EAAA,IAAI,CAACG,QAAAA,CAASK,GAAAA,CAAID,GAAAA,CAAAA,EAAM;AACpBJ,IAAAA,QAAAA,CAASM,GAAAA,CAAIF,GAAAA,EAAKG,KAAAA,CAAMH,GAAAA,EAAK;MAAEI,SAAAA,EAAW;AAAK,KAAA,CAAA,CAAA;AACnD,EAAA;AACA,EAAA,MAAMR,QAAAA,CAASS,IAAIL,GAAAA,CAAAA,EAAMM,KAAK,MAAMC,SAAAA,CAAUd,OAAMM,IAAAA,EAAM;IAAES,QAAAA,EAAU;AAAQ,GAAA,CAAA,CAAA;AAClF,CAAA,EAP4C,8BAAA","file":"PXUGBXL3.js","sourcesContent":["// Shim globals in esm bundle\nimport { fileURLToPath } from 'url'\nimport path from 'path'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","import { mkdir, writeFile } from 'node:fs/promises';\nimport { dirname } from 'node:path';\n\nconst dirCache = new Map<string, Promise<string | undefined>>();\n\nexport const writeFileAndCreateDirsCached = async (path: string, data: string) => {\n const dir = dirname(path);\n // Deduplicate concurrent mkdir calls\n if (!dirCache.has(dir)) {\n dirCache.set(dir, mkdir(dir, { recursive: true }));\n }\n await dirCache.get(dir)?.then(() => writeFile(path, data, { encoding: 'utf-8' }));\n};\n"]}
package/dist/files.cjs ADDED
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ var ORVETYPP_cjs = require('./ORVETYPP.cjs');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, "writeFileAndCreateDirsCached", {
8
+ enumerable: true,
9
+ get: function () { return ORVETYPP_cjs.writeFileAndCreateDirsCached; }
10
+ });
11
+ //# sourceMappingURL=files.cjs.map
12
+ //# sourceMappingURL=files.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"files.cjs"}
@@ -0,0 +1,2 @@
1
+ export declare const writeFileAndCreateDirsCached: (path: string, data: string) => Promise<void>;
2
+ //# sourceMappingURL=files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,4BAA4B,GAAU,MAAM,MAAM,EAAE,MAAM,MAAM,kBAO5E,CAAC"}
package/dist/files.js ADDED
@@ -0,0 +1,3 @@
1
+ export { writeFileAndCreateDirsCached } from './PXUGBXL3.js';
2
+ //# sourceMappingURL=files.js.map
3
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"files.js"}
package/dist/index.cjs ADDED
@@ -0,0 +1,59 @@
1
+ 'use strict';
2
+
3
+ var ORVETYPP_cjs = require('./ORVETYPP.cjs');
4
+ var fs = require('fs/promises');
5
+ var path = require('path');
6
+
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
+
9
+ function _interopNamespace(e) {
10
+ if (e && e.__esModule) return e;
11
+ var n = Object.create(null);
12
+ if (e) {
13
+ Object.keys(e).forEach(function (k) {
14
+ if (k !== 'default') {
15
+ var d = Object.getOwnPropertyDescriptor(e, k);
16
+ Object.defineProperty(n, k, d.get ? d : {
17
+ enumerable: true,
18
+ get: function () { return e[k]; }
19
+ });
20
+ }
21
+ });
22
+ }
23
+ n.default = e;
24
+ return Object.freeze(n);
25
+ }
26
+
27
+ var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
28
+ var path__default = /*#__PURE__*/_interopDefault(path);
29
+
30
+ var _fullyQualifiedRepoRootPath = void 0;
31
+ var getFullyQualifiedRepoRootPath = /* @__PURE__ */ ORVETYPP_cjs.__name(() => {
32
+ if (!_fullyQualifiedRepoRootPath) {
33
+ _fullyQualifiedRepoRootPath = (async () => {
34
+ let currentDir = __dirname;
35
+ while (true) {
36
+ const candidate = path__default.default.join(currentDir, "pnpm-workspace.yaml");
37
+ try {
38
+ await fs__namespace.access(candidate);
39
+ return currentDir;
40
+ } catch {
41
+ const parent = path__default.default.dirname(currentDir);
42
+ if (parent === currentDir) {
43
+ throw new Error(`Could not locate root (pnpm-workspace.yaml not found)--started from ${__dirname}, ended at ${currentDir}`);
44
+ }
45
+ currentDir = parent;
46
+ }
47
+ }
48
+ })();
49
+ }
50
+ return _fullyQualifiedRepoRootPath;
51
+ }, "getFullyQualifiedRepoRootPath");
52
+
53
+ Object.defineProperty(exports, "writeFileAndCreateDirsCached", {
54
+ enumerable: true,
55
+ get: function () { return ORVETYPP_cjs.writeFileAndCreateDirsCached; }
56
+ });
57
+ exports.getFullyQualifiedRepoRootPath = getFullyQualifiedRepoRootPath;
58
+ //# sourceMappingURL=index.cjs.map
59
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":["_fullyQualifiedRepoRootPath","undefined","getFullyQualifiedRepoRootPath","__name","currentDir","__dirname","candidate","path","join","access","parent","dirname","Error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAIA,2BAAAA,GAA2DC,MAAAA;AACxD,IAAMC,gDAAgCC,mBAAA,CAAA,MAAA;AACzC,EAAA,IAAI,CAACH,2BAAAA,EAA6B;AAC9BA,IAAAA,2BAAAA,GAAAA,CAA+B,YAAA;AAC3B,MAAA,IAAII,UAAAA,GAAaC,SAAAA;AACjB,MAAA,OAAO,IAAA,EAAM;AACT,QAAA,MAAMC,SAAAA,GAAYC,qBAAAA,CAAKC,IAAAA,CAAKJ,UAAAA,EAAY,qBAAA,CAAA;AACxC,QAAA,IAAI;AACA,UAAA,MAASK,qBAAOH,SAAAA,CAAAA;AAChB,UAAA,OAAOF,UAAAA;QACX,CAAA,CAAA,MAAQ;AACJ,UAAA,MAAMM,MAAAA,GAASH,qBAAAA,CAAKI,OAAAA,CAAQP,UAAAA,CAAAA;AAC5B,UAAA,IAAIM,WAAWN,UAAAA,EAAY;AACvB,YAAA,MAAM,IAAIQ,KAAAA,CACN,CAAA,oEAAA,EAAuEP,SAAAA,CAAAA,WAAAA,EAAuBD,UAAAA,CAAAA,CAAY,CAAA;AAElH,UAAA;AACAA,UAAAA,UAAAA,GAAaM,MAAAA;AACjB,QAAA;AACJ,MAAA;IACJ,CAAA,GAAA;AACJ,EAAA;AAEA,EAAA,OAAOV,2BAAAA;AACX,CAAA,EAvB6C,+BAAA","file":"index.cjs","sourcesContent":["import * as fs from 'fs/promises';\nimport path from 'path';\n\nlet _fullyQualifiedRepoRootPath: Promise<string> | undefined = undefined;\nexport const getFullyQualifiedRepoRootPath = (): Promise<string> => {\n if (!_fullyQualifiedRepoRootPath) {\n _fullyQualifiedRepoRootPath = (async (): Promise<string> => {\n let currentDir = __dirname;\n while (true) {\n const candidate = path.join(currentDir, 'pnpm-workspace.yaml');\n try {\n await fs.access(candidate);\n return currentDir;\n } catch {\n const parent = path.dirname(currentDir);\n if (parent === currentDir) {\n throw new Error(\n `Could not locate root (pnpm-workspace.yaml not found)--started from ${__dirname}, ended at ${currentDir}`,\n );\n }\n currentDir = parent;\n }\n }\n })();\n }\n\n return _fullyQualifiedRepoRootPath;\n};\n\nexport * from './files';\n"]}
@@ -0,0 +1,3 @@
1
+ export declare const getFullyQualifiedRepoRootPath: () => Promise<string>;
2
+ export * from './files';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,6BAA6B,QAAO,OAAO,CAAC,MAAM,CAuB9D,CAAC;AAEF,cAAc,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,31 @@
1
+ import { __name, __dirname } from './PXUGBXL3.js';
2
+ export { writeFileAndCreateDirsCached } from './PXUGBXL3.js';
3
+ import * as fs from 'fs/promises';
4
+ import path from 'path';
5
+
6
+ var _fullyQualifiedRepoRootPath = void 0;
7
+ var getFullyQualifiedRepoRootPath = /* @__PURE__ */ __name(() => {
8
+ if (!_fullyQualifiedRepoRootPath) {
9
+ _fullyQualifiedRepoRootPath = (async () => {
10
+ let currentDir = __dirname;
11
+ while (true) {
12
+ const candidate = path.join(currentDir, "pnpm-workspace.yaml");
13
+ try {
14
+ await fs.access(candidate);
15
+ return currentDir;
16
+ } catch {
17
+ const parent = path.dirname(currentDir);
18
+ if (parent === currentDir) {
19
+ throw new Error(`Could not locate root (pnpm-workspace.yaml not found)--started from ${__dirname}, ended at ${currentDir}`);
20
+ }
21
+ currentDir = parent;
22
+ }
23
+ }
24
+ })();
25
+ }
26
+ return _fullyQualifiedRepoRootPath;
27
+ }, "getFullyQualifiedRepoRootPath");
28
+
29
+ export { getFullyQualifiedRepoRootPath };
30
+ //# sourceMappingURL=index.js.map
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":["_fullyQualifiedRepoRootPath","undefined","getFullyQualifiedRepoRootPath","currentDir","__dirname","candidate","path","join","access","parent","dirname","Error"],"mappings":";;;;;AAGA,IAAIA,2BAAAA,GAA2DC,MAAAA;AACxD,IAAMC,gDAAgC,MAAA,CAAA,MAAA;AACzC,EAAA,IAAI,CAACF,2BAAAA,EAA6B;AAC9BA,IAAAA,2BAAAA,GAAAA,CAA+B,YAAA;AAC3B,MAAA,IAAIG,UAAAA,GAAaC,SAAAA;AACjB,MAAA,OAAO,IAAA,EAAM;AACT,QAAA,MAAMC,SAAAA,GAAYC,IAAAA,CAAKC,IAAAA,CAAKJ,UAAAA,EAAY,qBAAA,CAAA;AACxC,QAAA,IAAI;AACA,UAAA,MAASK,UAAOH,SAAAA,CAAAA;AAChB,UAAA,OAAOF,UAAAA;QACX,CAAA,CAAA,MAAQ;AACJ,UAAA,MAAMM,MAAAA,GAASH,IAAAA,CAAKI,OAAAA,CAAQP,UAAAA,CAAAA;AAC5B,UAAA,IAAIM,WAAWN,UAAAA,EAAY;AACvB,YAAA,MAAM,IAAIQ,KAAAA,CACN,CAAA,oEAAA,EAAuEP,SAAAA,CAAAA,WAAAA,EAAuBD,UAAAA,CAAAA,CAAY,CAAA;AAElH,UAAA;AACAA,UAAAA,UAAAA,GAAaM,MAAAA;AACjB,QAAA;AACJ,MAAA;IACJ,CAAA,GAAA;AACJ,EAAA;AAEA,EAAA,OAAOT,2BAAAA;AACX,CAAA,EAvB6C,+BAAA","file":"index.js","sourcesContent":["import * as fs from 'fs/promises';\nimport path from 'path';\n\nlet _fullyQualifiedRepoRootPath: Promise<string> | undefined = undefined;\nexport const getFullyQualifiedRepoRootPath = (): Promise<string> => {\n if (!_fullyQualifiedRepoRootPath) {\n _fullyQualifiedRepoRootPath = (async (): Promise<string> => {\n let currentDir = __dirname;\n while (true) {\n const candidate = path.join(currentDir, 'pnpm-workspace.yaml');\n try {\n await fs.access(candidate);\n return currentDir;\n } catch {\n const parent = path.dirname(currentDir);\n if (parent === currentDir) {\n throw new Error(\n `Could not locate root (pnpm-workspace.yaml not found)--started from ${__dirname}, ended at ${currentDir}`,\n );\n }\n currentDir = parent;\n }\n }\n })();\n }\n\n return _fullyQualifiedRepoRootPath;\n};\n\nexport * from './files';\n"]}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@layerzerolabs/common-node-utils",
3
+ "version": "0.0.31",
4
+ "private": false,
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "exports": {
8
+ "types": "./dist/index.d.ts",
9
+ "require": "./dist/index.cjs",
10
+ "import": "./dist/index.js",
11
+ "default": "./dist/index.cjs"
12
+ },
13
+ "main": "./dist/index.cjs",
14
+ "module": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "devDependencies": {
17
+ "@types/ms": "^2.1.0",
18
+ "bs58": "^5.0.0",
19
+ "tsup": "^8.4.0",
20
+ "vitest": "^3.2.3",
21
+ "@layerzerolabs/tsup-configuration": "0.0.31",
22
+ "@layerzerolabs/typescript-configuration": "0.0.31"
23
+ },
24
+ "publishConfig": {
25
+ "access": "restricted",
26
+ "registry": "https://registry.npmjs.org/"
27
+ },
28
+ "scripts": {
29
+ "build": "tsup",
30
+ "checkdeps": "pnpm --filter @layerzerolabs/depcheck run depcheck validate --catalog --missing-dependencies --only $npm_package_name",
31
+ "clean": "rm -rf ./node_modules .turbo ./dist",
32
+ "dev": "tsup --watch",
33
+ "lint": "eslint . --max-warnings 0 || (eslint . --fix --max-warnings 0 && false)",
34
+ "test": "vitest --run --pass-with-no-tests"
35
+ }
36
+ }
package/src/files.ts ADDED
@@ -0,0 +1,13 @@
1
+ import { mkdir, writeFile } from 'node:fs/promises';
2
+ import { dirname } from 'node:path';
3
+
4
+ const dirCache = new Map<string, Promise<string | undefined>>();
5
+
6
+ export const writeFileAndCreateDirsCached = async (path: string, data: string) => {
7
+ const dir = dirname(path);
8
+ // Deduplicate concurrent mkdir calls
9
+ if (!dirCache.has(dir)) {
10
+ dirCache.set(dir, mkdir(dir, { recursive: true }));
11
+ }
12
+ await dirCache.get(dir)?.then(() => writeFile(path, data, { encoding: 'utf-8' }));
13
+ };
package/src/index.ts ADDED
@@ -0,0 +1,30 @@
1
+ import * as fs from 'fs/promises';
2
+ import path from 'path';
3
+
4
+ let _fullyQualifiedRepoRootPath: Promise<string> | undefined = undefined;
5
+ export const getFullyQualifiedRepoRootPath = (): Promise<string> => {
6
+ if (!_fullyQualifiedRepoRootPath) {
7
+ _fullyQualifiedRepoRootPath = (async (): Promise<string> => {
8
+ let currentDir = __dirname;
9
+ while (true) {
10
+ const candidate = path.join(currentDir, 'pnpm-workspace.yaml');
11
+ try {
12
+ await fs.access(candidate);
13
+ return currentDir;
14
+ } catch {
15
+ const parent = path.dirname(currentDir);
16
+ if (parent === currentDir) {
17
+ throw new Error(
18
+ `Could not locate root (pnpm-workspace.yaml not found)--started from ${__dirname}, ended at ${currentDir}`,
19
+ );
20
+ }
21
+ currentDir = parent;
22
+ }
23
+ }
24
+ })();
25
+ }
26
+
27
+ return _fullyQualifiedRepoRootPath;
28
+ };
29
+
30
+ export * from './files';
package/tsconfig.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "extends": "@layerzerolabs/typescript-configuration/tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "rootDir": "./src",
5
+ "outDir": "./dist",
6
+ "strictPropertyInitialization": false,
7
+ "noUnusedLocals": false,
8
+ "noUnusedParameters": false,
9
+ "jsx": "react-jsx"
10
+ },
11
+ "exclude": [
12
+ "node_modules",
13
+ "**/__mocks__/*",
14
+ "**/__tests__/*",
15
+ "**/*.spec.ts",
16
+ "**/*.test.ts",
17
+ "dist"
18
+ ],
19
+ "include": ["src/**/*"]
20
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from 'tsup';
2
+
3
+ import { createPackageTsupConfig } from '@layerzerolabs/tsup-configuration';
4
+
5
+ export default defineConfig(({ watch }) => ({
6
+ ...createPackageTsupConfig(),
7
+ clean: !watch,
8
+ }));