From 6325e0a27f2017d6dab23cfa397edcdca558f02a Mon Sep 17 00:00:00 2001 From: Ryan Skinner Date: Sun, 1 Dec 2024 12:34:57 -0500 Subject: [PATCH 01/22] ignore lexicons dir and temp file --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index b947077..dcffbe5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ +atproto.tar.gz node_modules/ dist/ +lexicons/ From 7fc335cba2b2ed3829c7efbf2fd1d1acf2ce5591 Mon Sep 17 00:00:00 2001 From: Ryan Skinner Date: Sun, 1 Dec 2024 12:35:03 -0500 Subject: [PATCH 02/22] adding ts support --- eslint.config.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/eslint.config.mjs b/eslint.config.mjs index a5e888f..3f35c56 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -2,6 +2,7 @@ import antfu from '@antfu/eslint-config'; export default antfu( { + typescript: true, stylistic: { semi: true, }, From 0e38ff932ded9419ccbe4a2654e03676e6ceb331 Mon Sep 17 00:00:00 2001 From: Ryan Skinner Date: Sun, 1 Dec 2024 12:35:16 -0500 Subject: [PATCH 03/22] types generation packages --- package.json | 78 ++++++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 36 deletions(-) diff --git a/package.json b/package.json index 186037b..e12e165 100644 --- a/package.json +++ b/package.json @@ -1,36 +1,42 @@ -{ - "name": "tsky-workspace", - "type": "module", - "version": "0.1.0", - "packageManager": "pnpm@9.14.2", - "license": "MIT", - "homepage": "https://tsky.dev/", - "repository": { - "type": "git", - "url": "git+https://github.com/tsky-dev/tsky.git" - }, - "scripts": { - "build": "pnpm run --filter tsky build", - "docs:dev": "pnpm run --filter tsky-docs dev", - "docs:build": "pnpm run --filter tsky-docs build", - "docs:preview": "pnpm run --filter tsky-docs preview", - "format": "biome check --write .", - "format:check": "biome check", - "lint": "eslint ./packages ./docs", - "lint:fix": "eslint . --fix" - }, - "devDependencies": { - "@antfu/eslint-config": "^3.11.2", - "@biomejs/biome": "^1.9.4", - "@eslint/js": "^9.15.0", - "eslint": "^8.57.1", - "eslint-plugin-import": "^2.25.2", - "eslint-plugin-n": "^15.0.0 || ^16.0.0 ", - "eslint-plugin-promise": "^6.0.0", - "nano-staged": "^0.8.0", - "typescript-eslint": "^8.16.0" - }, - "nano-staged": { - "*.{js,ts,cjs,mjs}": ["biome check --write --"] - } -} +{ + "name": "tsky-workspace", + "type": "module", + "version": "0.1.0", + "packageManager": "pnpm@9.14.2", + "license": "MIT", + "homepage": "https://tsky.dev/", + "repository": { + "type": "git", + "url": "git+https://github.com/tsky-dev/tsky.git" + }, + "scripts": { + "build": "pnpm run --filter tsky build", + "docs:dev": "pnpm run --filter tsky-docs dev", + "docs:build": "pnpm run --filter tsky-docs build", + "docs:preview": "pnpm run --filter tsky-docs preview", + "format": "biome check --write .", + "format:check": "biome check", + "lint": "eslint ./packages ./docs", + "lint:fix": "eslint . --fix" + }, + "devDependencies": { + "@antfu/eslint-config": "^3.11.2", + "@atproto/lex-cli": "^0.5.2", + "@biomejs/biome": "^1.9.4", + "@eslint/js": "^9.15.0", + "@types/node": "^22.10.1", + "eslint": "^8.57.1", + "eslint-plugin-import": "^2.25.2", + "eslint-plugin-n": "^15.0.0 || ^16.0.0 ", + "eslint-plugin-promise": "^6.0.0", + "nano-staged": "^0.8.0", + "tar": "^7.4.3", + "tsx": "^4.19.2", + "typescript-eslint": "^8.16.0" + }, + "nano-staged": { + "*.{js,ts,cjs,mjs}": [ + "biome check --write --" + ] + } +} From 3d773d88310f4961578392550ef149de2b5ad57e Mon Sep 17 00:00:00 2001 From: Ryan Skinner Date: Sun, 1 Dec 2024 12:35:23 -0500 Subject: [PATCH 04/22] lock update --- pnpm-lock.yaml | 202 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 181 insertions(+), 21 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4e5af1c..da4ddc9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,13 +10,19 @@ importers: devDependencies: '@antfu/eslint-config': specifier: ^3.11.2 - version: 3.11.2(@typescript-eslint/utils@8.16.0(eslint@8.57.1)(typescript@5.7.2))(@vue/compiler-sfc@3.5.13)(eslint@8.57.1)(typescript@5.7.2)(vitest@2.1.6) + version: 3.11.2(@typescript-eslint/utils@8.16.0(eslint@8.57.1)(typescript@5.7.2))(@vue/compiler-sfc@3.5.13)(eslint@8.57.1)(typescript@5.7.2)(vitest@2.1.6(@types/node@22.10.1)) + '@atproto/lex-cli': + specifier: ^0.5.2 + version: 0.5.2 '@biomejs/biome': specifier: ^1.9.4 version: 1.9.4 '@eslint/js': specifier: ^9.15.0 version: 9.15.0 + '@types/node': + specifier: ^22.10.1 + version: 22.10.1 eslint: specifier: ^8.57.1 version: 8.57.1 @@ -32,6 +38,12 @@ importers: nano-staged: specifier: ^0.8.0 version: 0.8.0 + tar: + specifier: ^7.4.3 + version: 7.4.3 + tsx: + specifier: ^4.19.2 + version: 4.19.2 typescript-eslint: specifier: ^8.16.0 version: 8.16.0(eslint@8.57.1)(typescript@5.7.2) @@ -40,7 +52,7 @@ importers: devDependencies: vitepress: specifier: ^1.5.0 - version: 1.5.0(@algolia/client-search@5.15.0)(postcss@8.4.49)(search-insights@2.17.3)(typescript@5.7.2) + version: 1.5.0(@algolia/client-search@5.15.0)(@types/node@22.10.1)(postcss@8.4.49)(search-insights@2.17.3)(typescript@5.7.2) packages/core: dependencies: @@ -62,7 +74,7 @@ importers: version: 5.7.2 vitest: specifier: ^2.1.6 - version: 2.1.6 + version: 2.1.6(@types/node@22.10.1) packages: @@ -196,6 +208,10 @@ packages: '@atproto/common-web@0.3.1': resolution: {integrity: sha512-N7wiTnus5vAr+lT//0y8m/FaHHLJ9LpGuEwkwDAeV3LCiPif4m/FS8x/QOYrx1PdZQwKso95RAPzCGWQBH5j6Q==} + '@atproto/lex-cli@0.5.2': + resolution: {integrity: sha512-fM/FR/FpOMUOpwir7odZNiJhY3at0gMDGZpkLJeWFDaYyChtwqCGd6x7J4S6w/mqtCDcx1bzGTrnsLkJjtuNfg==} + hasBin: true + '@atproto/lexicon@0.4.3': resolution: {integrity: sha512-lFVZXe1S1pJP0dcxvJuHP3r/a+EAIBwwU7jUK+r8iLhIja+ml6NmYv8KeFHmIJATh03spEQ9s02duDmFVdCoXg==} @@ -666,6 +682,10 @@ packages: resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==} engines: {node: '>=12'} + '@isaacs/fs-minipass@4.0.1': + resolution: {integrity: sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==} + engines: {node: '>=18.0.0'} + '@jridgewell/sourcemap-codec@1.5.0': resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==} @@ -869,6 +889,9 @@ packages: peerDependencies: eslint: '>=8.40.0' + '@ts-morph/common@0.17.0': + resolution: {integrity: sha512-RMSSvSfs9kb0VzkvQ2NWobwnj7TxCA9vI/IjR9bDHqgAyVbu2T0DN4wiKVqomyDWqO7dPr/tErSfq7urQ1Q37g==} + '@types/debug@4.1.12': resolution: {integrity: sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==} @@ -896,6 +919,9 @@ packages: '@types/ms@0.7.34': resolution: {integrity: sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==} + '@types/node@22.10.1': + resolution: {integrity: sha512-qKgsUwfHZV2WCWLAnVP1JqnpE6Im6h3Y0+fYgMTasNQ7V++CBX5OT1as0g0f+OyubbFqhf6XVNIsmN4IIhEgGQ==} + '@types/normalize-package-data@2.4.4': resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==} @@ -1255,6 +1281,10 @@ packages: resolution: {integrity: sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==} engines: {node: '>= 16'} + chownr@3.0.0: + resolution: {integrity: sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==} + engines: {node: '>=18'} + ci-info@4.1.0: resolution: {integrity: sha512-HutrvTNsF48wnxkzERIXOe5/mlcfFcbfCmwcg6CJnizbSue78AbDt+1cgl26zwn61WFxhcPykPfZrbqjGmBb4A==} engines: {node: '>=8'} @@ -1267,6 +1297,9 @@ packages: resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} engines: {node: '>=12'} + code-block-writer@11.0.3: + resolution: {integrity: sha512-NiujjUFB4SwScJq2bwbYUtXbZhBSlY6vYzm++3Q6oC+U+injTqfPYFK8wS9COOmb2lueqp0ZRB4nK1VYeHgNyw==} + color-convert@2.0.1: resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} engines: {node: '>=7.0.0'} @@ -1277,6 +1310,10 @@ packages: comma-separated-tokens@2.0.3: resolution: {integrity: sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==} + commander@9.5.0: + resolution: {integrity: sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==} + engines: {node: ^12.20.0 || >=14} + comment-parser@1.4.1: resolution: {integrity: sha512-buhp5kePrmda3vhc5B9t7pUQXAb2Tnd0qgpkIhPhkHXxJpiPJ11H0ZEU0oBpJ2QztSbzG/ZxMj/CHsYJqRHmyg==} engines: {node: '>= 12.0.0'} @@ -2233,6 +2270,10 @@ packages: minimatch@3.1.2: resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} + minimatch@5.1.6: + resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==} + engines: {node: '>=10'} + minimatch@9.0.5: resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==} engines: {node: '>=16 || 14 >=14.17'} @@ -2247,9 +2288,23 @@ packages: minisearch@7.1.1: resolution: {integrity: sha512-b3YZEYCEH4EdCAtYP7OlDyx7FdPwNzuNwLQ34SfJpM9dlbBZzeXndGavTrC+VCiRWomL21SWfMc6SCKO/U2ZNw==} + minizlib@3.0.1: + resolution: {integrity: sha512-umcy022ILvb5/3Djuu8LWeqUa8D68JaBzlttKeMWen48SjabqS3iY5w/vzeMzMUNhLDifyhbOwKDSznB1vvrwg==} + engines: {node: '>= 18'} + mitt@3.0.1: resolution: {integrity: sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==} + mkdirp@1.0.4: + resolution: {integrity: sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==} + engines: {node: '>=10'} + hasBin: true + + mkdirp@3.0.1: + resolution: {integrity: sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==} + engines: {node: '>=10'} + hasBin: true + mlly@1.7.3: resolution: {integrity: sha512-xUsx5n/mN0uQf4V548PKQ+YShA4/IW0KI1dZhrNrPCLG+xizETbHTkOa1f8/xut9JRPp8kQuMnz0oqwkTiLo/A==} @@ -2361,6 +2416,9 @@ packages: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} engines: {node: '>=8'} + path-browserify@1.0.1: + resolution: {integrity: sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==} + path-exists@4.0.0: resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} engines: {node: '>=8'} @@ -2437,6 +2495,11 @@ packages: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} + prettier@3.4.1: + resolution: {integrity: sha512-G+YdqtITVZmOJje6QkXQWzl3fSfMxFwm1tjTyo9exhkmWSqC4Yhd1+lug++IlR2mvRVAxEDDWYkQdeSztajqgg==} + engines: {node: '>=14'} + hasBin: true + property-information@6.5.0: resolution: {integrity: sha512-PgTgs/BlvHxOu8QuEN7wi5A0OmXaBcHpmCSTehcs6Uuu9IkDIEo13Hy7n898RHfrQ49vKCoGeWZSaAK01nwVig==} @@ -2515,6 +2578,10 @@ packages: deprecated: Rimraf versions prior to v4 are no longer supported hasBin: true + rimraf@5.0.10: + resolution: {integrity: sha512-l0OE8wL34P4nJH/H2ffoaniAokM2qSmrtXHmlpvYr5AVVX8msAyW0l8NVJFDxlSK4u3Uh/f41cQheDVdnYijwQ==} + hasBin: true + rollup@4.27.4: resolution: {integrity: sha512-RLKxqHEMjh/RGLsDxAEsaLO3mWgyoU6x9w6n1ikAzet4B3gI2/3yP6PWY2p9QzRTh6MfEIXB3MwsOY0Iv3vNrw==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} @@ -2691,6 +2758,10 @@ packages: resolution: {integrity: sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==} engines: {node: '>=6'} + tar@7.4.3: + resolution: {integrity: sha512-5S7Va8hKfV7W5U6g3aYxXmlPoZVAwUMy9AOKyF2fVuZa2UD3qZjg578OrLRt8PcNN1PleVaL/5/yYATNL0ICUw==} + engines: {node: '>=18'} + text-table@0.2.0: resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} @@ -2733,6 +2804,9 @@ packages: peerDependencies: typescript: '>=4.2.0' + ts-morph@16.0.0: + resolution: {integrity: sha512-jGNF0GVpFj0orFw55LTsQxVYEUOCWBAbR5Ls7fTYE5pQsbW18ssTb/6UXx/GYAEjS+DQTp8VoTw0vqYMiaaQuw==} + tsconfig-paths@3.15.0: resolution: {integrity: sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==} @@ -2800,6 +2874,9 @@ packages: unbox-primitive@1.0.2: resolution: {integrity: sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==} + undici-types@6.20.0: + resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==} + unist-util-is@6.0.0: resolution: {integrity: sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==} @@ -2982,6 +3059,10 @@ packages: resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} engines: {node: '>=10'} + yallist@5.0.0: + resolution: {integrity: sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==} + engines: {node: '>=18'} + yaml-eslint-parser@1.2.3: resolution: {integrity: sha512-4wZWvE398hCP7O8n3nXKu/vdq1HcH01ixYlCREaJL5NUMwQ0g3MaGFUBNSlmBtKmhbtVG/Cm6lyYmSVTEVil8A==} engines: {node: ^14.17.0 || >=16.0.0} @@ -2999,6 +3080,9 @@ packages: resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==} engines: {node: '>=12'} + yesno@0.4.0: + resolution: {integrity: sha512-tdBxmHvbXPBKYIg81bMCB7bVeDmHkRzk5rVJyYYXurwKkHq/MCd8rz4HSJUP7hW0H2NlXiq8IFiWvYKEHhlotA==} + yocto-queue@0.1.0: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} @@ -3116,7 +3200,7 @@ snapshots: dependencies: '@algolia/client-common': 5.15.0 - '@antfu/eslint-config@3.11.2(@typescript-eslint/utils@8.16.0(eslint@8.57.1)(typescript@5.7.2))(@vue/compiler-sfc@3.5.13)(eslint@8.57.1)(typescript@5.7.2)(vitest@2.1.6)': + '@antfu/eslint-config@3.11.2(@typescript-eslint/utils@8.16.0(eslint@8.57.1)(typescript@5.7.2))(@vue/compiler-sfc@3.5.13)(eslint@8.57.1)(typescript@5.7.2)(vitest@2.1.6(@types/node@22.10.1))': dependencies: '@antfu/install-pkg': 0.5.0 '@clack/prompts': 0.8.2 @@ -3125,7 +3209,7 @@ snapshots: '@stylistic/eslint-plugin': 2.11.0(eslint@8.57.1)(typescript@5.7.2) '@typescript-eslint/eslint-plugin': 8.16.0(@typescript-eslint/parser@8.16.0(eslint@8.57.1)(typescript@5.7.2))(eslint@8.57.1)(typescript@5.7.2) '@typescript-eslint/parser': 8.16.0(eslint@8.57.1)(typescript@5.7.2) - '@vitest/eslint-plugin': 1.1.12(@typescript-eslint/utils@8.16.0(eslint@8.57.1)(typescript@5.7.2))(eslint@8.57.1)(typescript@5.7.2)(vitest@2.1.6) + '@vitest/eslint-plugin': 1.1.12(@typescript-eslint/utils@8.16.0(eslint@8.57.1)(typescript@5.7.2))(eslint@8.57.1)(typescript@5.7.2)(vitest@2.1.6(@types/node@22.10.1)) eslint: 8.57.1 eslint-config-flat-gitignore: 0.3.0(eslint@8.57.1) eslint-flat-config-utils: 0.4.0 @@ -3187,6 +3271,17 @@ snapshots: uint8arrays: 3.0.0 zod: 3.23.8 + '@atproto/lex-cli@0.5.2': + dependencies: + '@atproto/lexicon': 0.4.3 + '@atproto/syntax': 0.3.1 + chalk: 4.1.2 + commander: 9.5.0 + prettier: 3.4.1 + ts-morph: 16.0.0 + yesno: 0.4.0 + zod: 3.23.8 + '@atproto/lexicon@0.4.3': dependencies: '@atproto/common-web': 0.3.1 @@ -3519,6 +3614,10 @@ snapshots: wrap-ansi: 8.1.0 wrap-ansi-cjs: wrap-ansi@7.0.0 + '@isaacs/fs-minipass@4.0.1': + dependencies: + minipass: 7.1.2 + '@jridgewell/sourcemap-codec@1.5.0': {} '@nodelib/fs.scandir@2.1.5': @@ -3691,6 +3790,13 @@ snapshots: - supports-color - typescript + '@ts-morph/common@0.17.0': + dependencies: + fast-glob: 3.3.2 + minimatch: 5.1.6 + mkdirp: 1.0.4 + path-browserify: 1.0.1 + '@types/debug@4.1.12': dependencies: '@types/ms': 0.7.34 @@ -3718,6 +3824,10 @@ snapshots: '@types/ms@0.7.34': {} + '@types/node@22.10.1': + dependencies: + undici-types: 6.20.0 + '@types/normalize-package-data@2.4.4': {} '@types/resolve@1.20.2': {} @@ -3810,18 +3920,18 @@ snapshots: '@ungap/structured-clone@1.2.0': {} - '@vitejs/plugin-vue@5.2.1(vite@5.4.11)(vue@3.5.13(typescript@5.7.2))': + '@vitejs/plugin-vue@5.2.1(vite@5.4.11(@types/node@22.10.1))(vue@3.5.13(typescript@5.7.2))': dependencies: - vite: 5.4.11 + vite: 5.4.11(@types/node@22.10.1) vue: 3.5.13(typescript@5.7.2) - '@vitest/eslint-plugin@1.1.12(@typescript-eslint/utils@8.16.0(eslint@8.57.1)(typescript@5.7.2))(eslint@8.57.1)(typescript@5.7.2)(vitest@2.1.6)': + '@vitest/eslint-plugin@1.1.12(@typescript-eslint/utils@8.16.0(eslint@8.57.1)(typescript@5.7.2))(eslint@8.57.1)(typescript@5.7.2)(vitest@2.1.6(@types/node@22.10.1))': dependencies: '@typescript-eslint/utils': 8.16.0(eslint@8.57.1)(typescript@5.7.2) eslint: 8.57.1 optionalDependencies: typescript: 5.7.2 - vitest: 2.1.6 + vitest: 2.1.6(@types/node@22.10.1) '@vitest/expect@2.1.6': dependencies: @@ -3830,13 +3940,13 @@ snapshots: chai: 5.1.2 tinyrainbow: 1.2.0 - '@vitest/mocker@2.1.6(vite@5.4.11)': + '@vitest/mocker@2.1.6(vite@5.4.11(@types/node@22.10.1))': dependencies: '@vitest/spy': 2.1.6 estree-walker: 3.0.3 magic-string: 0.30.14 optionalDependencies: - vite: 5.4.11 + vite: 5.4.11(@types/node@22.10.1) '@vitest/pretty-format@2.1.6': dependencies: @@ -4133,6 +4243,8 @@ snapshots: check-error@2.1.1: {} + chownr@3.0.0: {} + ci-info@4.1.0: {} clean-regexp@1.0.0: @@ -4145,6 +4257,8 @@ snapshots: strip-ansi: 6.0.1 wrap-ansi: 7.0.0 + code-block-writer@11.0.3: {} + color-convert@2.0.1: dependencies: color-name: 1.1.4 @@ -4153,6 +4267,8 @@ snapshots: comma-separated-tokens@2.0.3: {} + commander@9.5.0: {} + comment-parser@1.4.1: {} commondir@1.0.1: {} @@ -5465,6 +5581,10 @@ snapshots: dependencies: brace-expansion: 1.1.11 + minimatch@5.1.6: + dependencies: + brace-expansion: 2.0.1 + minimatch@9.0.5: dependencies: brace-expansion: 2.0.1 @@ -5475,8 +5595,17 @@ snapshots: minisearch@7.1.1: {} + minizlib@3.0.1: + dependencies: + minipass: 7.1.2 + rimraf: 5.0.10 + mitt@3.0.1: {} + mkdirp@1.0.4: {} + + mkdirp@3.0.1: {} + mlly@1.7.3: dependencies: acorn: 8.14.0 @@ -5600,6 +5729,8 @@ snapshots: json-parse-even-better-errors: 2.3.1 lines-and-columns: 1.2.4 + path-browserify@1.0.1: {} + path-exists@4.0.0: {} path-is-absolute@1.0.1: {} @@ -5665,6 +5796,8 @@ snapshots: prelude-ls@1.2.1: {} + prettier@3.4.1: {} + property-information@6.5.0: {} punycode@2.3.1: {} @@ -5746,6 +5879,10 @@ snapshots: dependencies: glob: 7.2.3 + rimraf@5.0.10: + dependencies: + glob: 10.4.5 + rollup@4.27.4: dependencies: '@types/estree': 1.0.6 @@ -5953,6 +6090,15 @@ snapshots: tapable@2.2.1: {} + tar@7.4.3: + dependencies: + '@isaacs/fs-minipass': 4.0.1 + chownr: 3.0.0 + minipass: 7.1.2 + minizlib: 3.0.1 + mkdirp: 3.0.1 + yallist: 5.0.0 + text-table@0.2.0: {} tinybench@2.9.0: {} @@ -5981,6 +6127,11 @@ snapshots: dependencies: typescript: 5.7.2 + ts-morph@16.0.0: + dependencies: + '@ts-morph/common': 0.17.0 + code-block-writer: 11.0.3 + tsconfig-paths@3.15.0: dependencies: '@types/json5': 0.0.29 @@ -6066,6 +6217,8 @@ snapshots: has-symbols: 1.0.3 which-boxed-primitive: 1.0.2 + undici-types@6.20.0: {} + unist-util-is@6.0.0: dependencies: '@types/unist': 3.0.3 @@ -6116,13 +6269,13 @@ snapshots: '@types/unist': 3.0.3 vfile-message: 4.0.2 - vite-node@2.1.6: + vite-node@2.1.6(@types/node@22.10.1): dependencies: cac: 6.7.14 debug: 4.3.7 es-module-lexer: 1.5.4 pathe: 1.1.2 - vite: 5.4.11 + vite: 5.4.11(@types/node@22.10.1) transitivePeerDependencies: - '@types/node' - less @@ -6134,15 +6287,16 @@ snapshots: - supports-color - terser - vite@5.4.11: + vite@5.4.11(@types/node@22.10.1): dependencies: esbuild: 0.21.5 postcss: 8.4.49 rollup: 4.27.4 optionalDependencies: + '@types/node': 22.10.1 fsevents: 2.3.3 - vitepress@1.5.0(@algolia/client-search@5.15.0)(postcss@8.4.49)(search-insights@2.17.3)(typescript@5.7.2): + vitepress@1.5.0(@algolia/client-search@5.15.0)(@types/node@22.10.1)(postcss@8.4.49)(search-insights@2.17.3)(typescript@5.7.2): dependencies: '@docsearch/css': 3.8.0 '@docsearch/js': 3.8.0(@algolia/client-search@5.15.0)(search-insights@2.17.3) @@ -6151,7 +6305,7 @@ snapshots: '@shikijs/transformers': 1.24.0 '@shikijs/types': 1.24.0 '@types/markdown-it': 14.1.2 - '@vitejs/plugin-vue': 5.2.1(vite@5.4.11)(vue@3.5.13(typescript@5.7.2)) + '@vitejs/plugin-vue': 5.2.1(vite@5.4.11(@types/node@22.10.1))(vue@3.5.13(typescript@5.7.2)) '@vue/devtools-api': 7.6.7 '@vue/shared': 3.5.13 '@vueuse/core': 11.3.0(vue@3.5.13(typescript@5.7.2)) @@ -6160,7 +6314,7 @@ snapshots: mark.js: 8.11.1 minisearch: 7.1.1 shiki: 1.24.0 - vite: 5.4.11 + vite: 5.4.11(@types/node@22.10.1) vue: 3.5.13(typescript@5.7.2) optionalDependencies: postcss: 8.4.49 @@ -6192,10 +6346,10 @@ snapshots: - typescript - universal-cookie - vitest@2.1.6: + vitest@2.1.6(@types/node@22.10.1): dependencies: '@vitest/expect': 2.1.6 - '@vitest/mocker': 2.1.6(vite@5.4.11) + '@vitest/mocker': 2.1.6(vite@5.4.11(@types/node@22.10.1)) '@vitest/pretty-format': 2.1.6 '@vitest/runner': 2.1.6 '@vitest/snapshot': 2.1.6 @@ -6211,9 +6365,11 @@ snapshots: tinyexec: 0.3.1 tinypool: 1.0.2 tinyrainbow: 1.2.0 - vite: 5.4.11 - vite-node: 2.1.6 + vite: 5.4.11(@types/node@22.10.1) + vite-node: 2.1.6(@types/node@22.10.1) why-is-node-running: 2.3.0 + optionalDependencies: + '@types/node': 22.10.1 transitivePeerDependencies: - less - lightningcss @@ -6320,6 +6476,8 @@ snapshots: y18n@5.0.8: {} + yallist@5.0.0: {} + yaml-eslint-parser@1.2.3: dependencies: eslint-visitor-keys: 3.4.3 @@ -6340,6 +6498,8 @@ snapshots: y18n: 5.0.8 yargs-parser: 21.1.1 + yesno@0.4.0: {} + yocto-queue@0.1.0: {} zod@3.23.8: {} From da22d64e2c1e5f0d2b9e7e1dc2d94536370fe79e Mon Sep 17 00:00:00 2001 From: Ryan Skinner Date: Sun, 1 Dec 2024 12:47:54 -0500 Subject: [PATCH 05/22] generating types from the lexicons --- scripts/generate-types.ts | 94 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 scripts/generate-types.ts diff --git a/scripts/generate-types.ts b/scripts/generate-types.ts new file mode 100644 index 0000000..027529d --- /dev/null +++ b/scripts/generate-types.ts @@ -0,0 +1,94 @@ +import { Buffer } from 'node:buffer'; +import { execSync } from 'node:child_process'; +import fs from 'node:fs/promises'; +import path from 'node:path'; +import process from 'node:process'; +import * as tar from 'tar'; + +const LEXICONS_DIR = 'lexicons'; +const TYPES_DIR = 'packages/core/src/lexicons'; +const REPO = 'bluesky-social/atproto'; + +async function findJsonFiles(dir: string): Promise { + const files: string[] = []; + const entries = await fs.readdir(dir, { withFileTypes: true }); + + for (const entry of entries) { + const fullPath = path.join(dir, entry.name); + if (entry.isDirectory()) { + files.push(...await findJsonFiles(fullPath)); + } + else if (entry.isFile() && entry.name.endsWith('.json')) { + files.push(fullPath); + } + } + + return files; +} + +async function main() { + try { + // Ensure directories exist + await fs.mkdir(LEXICONS_DIR, { recursive: true }); + await fs.mkdir(TYPES_DIR, { recursive: true }); + + // Get latest commit SHA for lexicons + console.log('Getting latest lexicon commit...'); + const shaResponse = await fetch(`https://api.github.com/repos/${REPO}/commits?path=lexicons/`); + if (!shaResponse.ok) { + throw new Error(`Failed to get commit SHA: ${shaResponse.statusText}`); + } + + const commits = await shaResponse.json(); + const sha = commits[0]?.sha; + if (!sha) { + throw new Error('No commits found for lexicons'); + } + + // Download specific commit's lexicons + console.log('Downloading lexicons from atproto...'); + const response = await fetch(`https://github.com/${REPO}/archive/${sha}.tar.gz`); + if (!response.ok) { + throw new Error(`Failed to download lexicons: ${response.statusText}`); + } + + // Create a temporary file for the tar download + const tarFile = 'atproto.tar.gz'; + await fs.writeFile(tarFile, Buffer.from(await response.arrayBuffer())); + + // Extract only lexicon files + await tar.x({ + file: tarFile, + cwd: LEXICONS_DIR, + filter: path => path.includes('/lexicons/'), + strip: 2, + }); + + // Clean up tar file + await fs.unlink(tarFile); + + // Find all lexicon JSON files + console.log('Finding lexicon files...'); + const lexiconFiles = await findJsonFiles(LEXICONS_DIR); + if (lexiconFiles.length === 0) { + throw new Error('No lexicon files found'); + } + + // Generate types using @atproto/lex-cli + console.log('Generating types...'); + execSync( + `pnpm lex gen-api ${TYPES_DIR} ${lexiconFiles.join(' ')}`, + { + stdio: 'inherit', + }, + ); + + console.log('Done! Types generated in', TYPES_DIR); + } + catch (error) { + console.error('Error:', error); + process.exit(1); + } +} + +main(); From cc7fd715acfbf413ec7fceb6730ccf4906eeeb4a Mon Sep 17 00:00:00 2001 From: Ryan Skinner Date: Sun, 1 Dec 2024 15:04:02 -0500 Subject: [PATCH 06/22] moving types to `packages/lexicons` --- .gitignore | 2 +- pnpm-lock.yaml | 17 +++++++++++++++++ scripts/generate-types.ts | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index dcffbe5..7d67cfc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ atproto.tar.gz node_modules/ dist/ -lexicons/ +/lexicons/ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index da4ddc9..d864862 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -76,6 +76,18 @@ importers: specifier: ^2.1.6 version: 2.1.6(@types/node@22.10.1) + packages/lexicons: + dependencies: + '@atproto/lexicon': + specifier: ^0.4.3 + version: 0.4.3 + '@atproto/xrpc': + specifier: ^0.6.4 + version: 0.6.4 + multiformats: + specifier: ^13.3.1 + version: 13.3.1 + packages: '@algolia/autocomplete-core@1.17.7': @@ -2311,6 +2323,9 @@ packages: ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} + multiformats@13.3.1: + resolution: {integrity: sha512-QxowxTNwJ3r5RMctoGA5p13w5RbRT2QDkoM+yFlqfLiioBp78nhDjnRLvmSBI9+KAqN4VdgOVWM9c0CHd86m3g==} + multiformats@9.9.0: resolution: {integrity: sha512-HoMUjhH9T8DDBNT+6xzkrd9ga/XiBI4xLr58LJACwK6G3HTOPeMz4nB4KJs33L2BelrIJa7P0VuNaVF3hMYfjg==} @@ -5615,6 +5630,8 @@ snapshots: ms@2.1.3: {} + multiformats@13.3.1: {} + multiformats@9.9.0: {} nano-staged@0.8.0: diff --git a/scripts/generate-types.ts b/scripts/generate-types.ts index 027529d..57b962e 100644 --- a/scripts/generate-types.ts +++ b/scripts/generate-types.ts @@ -6,7 +6,7 @@ import process from 'node:process'; import * as tar from 'tar'; const LEXICONS_DIR = 'lexicons'; -const TYPES_DIR = 'packages/core/src/lexicons'; +const TYPES_DIR = 'packages/lexicons'; const REPO = 'bluesky-social/atproto'; async function findJsonFiles(dir: string): Promise { From 355716f106b1c72df6f3b2a61176671ffc11e430 Mon Sep 17 00:00:00 2001 From: Ryan Skinner Date: Sun, 1 Dec 2024 15:04:18 -0500 Subject: [PATCH 07/22] adding dependencies for generated types --- packages/lexicons/package.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 packages/lexicons/package.json diff --git a/packages/lexicons/package.json b/packages/lexicons/package.json new file mode 100644 index 0000000..bb819bd --- /dev/null +++ b/packages/lexicons/package.json @@ -0,0 +1,11 @@ +{ + "name": "@tsky/lexicons", + "private": true, + "version": "0.0.1", + "type": "module", + "dependencies": { + "@atproto/lexicon": "^0.4.3", + "@atproto/xrpc": "^0.6.4", + "multiformats": "^13.3.1" + } +} From f8caf66cbf3b9cc01e389ab415c5a392cec51cd1 Mon Sep 17 00:00:00 2001 From: Ryan Skinner Date: Sun, 1 Dec 2024 15:06:11 -0500 Subject: [PATCH 08/22] remove private --- packages/lexicons/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/lexicons/package.json b/packages/lexicons/package.json index bb819bd..3d56a95 100644 --- a/packages/lexicons/package.json +++ b/packages/lexicons/package.json @@ -1,6 +1,5 @@ { "name": "@tsky/lexicons", - "private": true, "version": "0.0.1", "type": "module", "dependencies": { From 586ed016f820b6f6cf863968f9a7edc58faad241 Mon Sep 17 00:00:00 2001 From: Ryan Skinner Date: Sun, 1 Dec 2024 18:03:40 -0500 Subject: [PATCH 09/22] fixing object key order --- packages/lexicons/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/lexicons/package.json b/packages/lexicons/package.json index 3d56a95..1a52ca8 100644 --- a/packages/lexicons/package.json +++ b/packages/lexicons/package.json @@ -1,7 +1,7 @@ { "name": "@tsky/lexicons", - "version": "0.0.1", "type": "module", + "version": "0.0.1", "dependencies": { "@atproto/lexicon": "^0.4.3", "@atproto/xrpc": "^0.6.4", From d918fe40f575b0096baef97f55f2e2994b9acf38 Mon Sep 17 00:00:00 2001 From: Ryan Skinner Date: Sun, 1 Dec 2024 18:32:10 -0500 Subject: [PATCH 10/22] adding publishConfig --- packages/lexicons/package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/lexicons/package.json b/packages/lexicons/package.json index 1a52ca8..eee174b 100644 --- a/packages/lexicons/package.json +++ b/packages/lexicons/package.json @@ -2,6 +2,9 @@ "name": "@tsky/lexicons", "type": "module", "version": "0.0.1", + "publishConfig": { + "access": "public" + }, "dependencies": { "@atproto/lexicon": "^0.4.3", "@atproto/xrpc": "^0.6.4", From 5d3d07569c4a1848e72af4951d0e838162ca4146 Mon Sep 17 00:00:00 2001 From: Ryan Skinner Date: Mon, 2 Dec 2024 09:29:16 -0500 Subject: [PATCH 11/22] moving devDeps to @tsky/lexicons --- package.json | 4 ---- packages/lexicons/package.json | 7 +++++++ pnpm-lock.yaml | 28 ++++++++++++++++------------ 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index e12e165..b322555 100644 --- a/package.json +++ b/package.json @@ -21,17 +21,13 @@ }, "devDependencies": { "@antfu/eslint-config": "^3.11.2", - "@atproto/lex-cli": "^0.5.2", "@biomejs/biome": "^1.9.4", "@eslint/js": "^9.15.0", - "@types/node": "^22.10.1", "eslint": "^8.57.1", "eslint-plugin-import": "^2.25.2", "eslint-plugin-n": "^15.0.0 || ^16.0.0 ", "eslint-plugin-promise": "^6.0.0", "nano-staged": "^0.8.0", - "tar": "^7.4.3", - "tsx": "^4.19.2", "typescript-eslint": "^8.16.0" }, "nano-staged": { diff --git a/packages/lexicons/package.json b/packages/lexicons/package.json index eee174b..0cd532b 100644 --- a/packages/lexicons/package.json +++ b/packages/lexicons/package.json @@ -9,5 +9,12 @@ "@atproto/lexicon": "^0.4.3", "@atproto/xrpc": "^0.6.4", "multiformats": "^13.3.1" + }, + "devDependencies": { + "@atproto/lex-cli": "^0.5.2", + "@types/node": "^22.10.1", + "tar": "^7.4.3", + "tsx": "^4.19.2", + "typescript": "^5.7.2" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d864862..afe4e48 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,18 +11,12 @@ importers: '@antfu/eslint-config': specifier: ^3.11.2 version: 3.11.2(@typescript-eslint/utils@8.16.0(eslint@8.57.1)(typescript@5.7.2))(@vue/compiler-sfc@3.5.13)(eslint@8.57.1)(typescript@5.7.2)(vitest@2.1.6(@types/node@22.10.1)) - '@atproto/lex-cli': - specifier: ^0.5.2 - version: 0.5.2 '@biomejs/biome': specifier: ^1.9.4 version: 1.9.4 '@eslint/js': specifier: ^9.15.0 version: 9.15.0 - '@types/node': - specifier: ^22.10.1 - version: 22.10.1 eslint: specifier: ^8.57.1 version: 8.57.1 @@ -38,12 +32,6 @@ importers: nano-staged: specifier: ^0.8.0 version: 0.8.0 - tar: - specifier: ^7.4.3 - version: 7.4.3 - tsx: - specifier: ^4.19.2 - version: 4.19.2 typescript-eslint: specifier: ^8.16.0 version: 8.16.0(eslint@8.57.1)(typescript@5.7.2) @@ -87,6 +75,22 @@ importers: multiformats: specifier: ^13.3.1 version: 13.3.1 + devDependencies: + '@atproto/lex-cli': + specifier: ^0.5.2 + version: 0.5.2 + '@types/node': + specifier: ^22.10.1 + version: 22.10.1 + tar: + specifier: ^7.4.3 + version: 7.4.3 + tsx: + specifier: ^4.19.2 + version: 4.19.2 + typescript: + specifier: ^5.7.2 + version: 5.7.2 packages: From 837a56054d9cd73002d2056b4e7a925eb5dd3b20 Mon Sep 17 00:00:00 2001 From: Ryan Skinner Date: Mon, 2 Dec 2024 09:29:27 -0500 Subject: [PATCH 12/22] adding tsconfig --- packages/lexicons/tsconfig.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 packages/lexicons/tsconfig.json diff --git a/packages/lexicons/tsconfig.json b/packages/lexicons/tsconfig.json new file mode 100644 index 0000000..b25195c --- /dev/null +++ b/packages/lexicons/tsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "target": "ESNext", + "module": "ESNext", + "moduleResolution": "node", + "resolveJsonModule": true, + "strict": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "skipLibCheck": true + }, + "include": ["scripts/**/*"], + "exclude": ["node_modules"] +} From 85d37d6c899c73fc5f2167da3d5f378271149684 Mon Sep 17 00:00:00 2001 From: Ryan Skinner Date: Mon, 2 Dec 2024 11:43:20 -0500 Subject: [PATCH 13/22] updating gitignores --- .gitignore | 2 -- packages/lexicons/.gitignore | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 packages/lexicons/.gitignore diff --git a/.gitignore b/.gitignore index 7d67cfc..b947077 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,2 @@ -atproto.tar.gz node_modules/ dist/ -/lexicons/ diff --git a/packages/lexicons/.gitignore b/packages/lexicons/.gitignore new file mode 100644 index 0000000..7d67cfc --- /dev/null +++ b/packages/lexicons/.gitignore @@ -0,0 +1,4 @@ +atproto.tar.gz +node_modules/ +dist/ +/lexicons/ From 4dc007dc821ef504d38d9af6c2b0ad07a65641a1 Mon Sep 17 00:00:00 2001 From: Ryan Skinner Date: Mon, 2 Dec 2024 11:43:43 -0500 Subject: [PATCH 14/22] moving script to @tsky/lexicons --- .../lexicons/scripts}/generate-types.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) rename {scripts => packages/lexicons/scripts}/generate-types.ts (88%) diff --git a/scripts/generate-types.ts b/packages/lexicons/scripts/generate-types.ts similarity index 88% rename from scripts/generate-types.ts rename to packages/lexicons/scripts/generate-types.ts index 57b962e..10804f4 100644 --- a/scripts/generate-types.ts +++ b/packages/lexicons/scripts/generate-types.ts @@ -3,10 +3,14 @@ import { execSync } from 'node:child_process'; import fs from 'node:fs/promises'; import path from 'node:path'; import process from 'node:process'; +import { fileURLToPath } from 'node:url'; import * as tar from 'tar'; -const LEXICONS_DIR = 'lexicons'; -const TYPES_DIR = 'packages/lexicons'; +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +const LEXICONS_DIR = path.resolve(__dirname, '../lexicons'); +const TYPES_DIR = path.resolve(__dirname, '../src'); const REPO = 'bluesky-social/atproto'; async function findJsonFiles(dir: string): Promise { @@ -53,7 +57,7 @@ async function main() { } // Create a temporary file for the tar download - const tarFile = 'atproto.tar.gz'; + const tarFile = path.join(LEXICONS_DIR, 'atproto.tar.gz'); await fs.writeFile(tarFile, Buffer.from(await response.arrayBuffer())); // Extract only lexicon files @@ -80,6 +84,7 @@ async function main() { `pnpm lex gen-api ${TYPES_DIR} ${lexiconFiles.join(' ')}`, { stdio: 'inherit', + cwd: TYPES_DIR, }, ); From 9fbf07bdf9c61e95bd6979396582f4036f4772bd Mon Sep 17 00:00:00 2001 From: Ryan Skinner Date: Mon, 2 Dec 2024 14:28:13 -0500 Subject: [PATCH 15/22] Update packages/lexicons/package.json Co-authored-by: Anbraten <6918444+anbraten@users.noreply.github.com> --- packages/lexicons/package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/lexicons/package.json b/packages/lexicons/package.json index 0cd532b..01bc3c0 100644 --- a/packages/lexicons/package.json +++ b/packages/lexicons/package.json @@ -5,6 +5,9 @@ "publishConfig": { "access": "public" }, + "scripts": { + "build": "tsx ./scripts/generate-types.ts" + }, "dependencies": { "@atproto/lexicon": "^0.4.3", "@atproto/xrpc": "^0.6.4", From 224675eec05b3815a7e097c96908fb834110e42f Mon Sep 17 00:00:00 2001 From: Ryan Skinner Date: Mon, 2 Dec 2024 14:30:47 -0500 Subject: [PATCH 16/22] adding generated files --- packages/lexicons/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/lexicons/tsconfig.json b/packages/lexicons/tsconfig.json index b25195c..53d5d52 100644 --- a/packages/lexicons/tsconfig.json +++ b/packages/lexicons/tsconfig.json @@ -9,6 +9,6 @@ "forceConsistentCasingInFileNames": true, "skipLibCheck": true }, - "include": ["scripts/**/*"], + "include": ["scripts/**/*", "src/**/*"], "exclude": ["node_modules"] } From 2b10ecc778151831b1f3cc90947c9257f4a92b03 Mon Sep 17 00:00:00 2001 From: patak <583075+patak-dev@users.noreply.github.com> Date: Mon, 2 Dec 2024 06:51:04 +0100 Subject: [PATCH 17/22] chore: set casing for tsky, Tsky, Bluesky (#24) --- README.md | 14 +++++++------- docs/.vitepress/config.mts | 4 ++-- docs/index.md | 6 +++--- packages/core/src/tsky/tsky.ts | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index ec4cdc7..9af7adc 100644 --- a/README.md +++ b/README.md @@ -2,17 +2,17 @@

-

TSky

+

tsky

A lightweight, fast, universal and typed Bluesky API wrapper for Apps & Bots.

-## ⚠️ TSky is still in development and is not ready for production use. +## ⚠️ tsky is still in development and is not ready for production use. -TSksy is still in active development and is not ready for production use. If you want to contribute to the project, please read the [CONTRIBUTING.md](CONTRIBUTING.md) file or join our [Discord Server](https://discord.gg/KPD7XPUZn3). +tsky is still in active development and is not ready for production use. If you want to contribute to the project, please read the [CONTRIBUTING.md](CONTRIBUTING.md) file or join our [Discord Server](https://discord.gg/KPD7XPUZn3). -TSky is a lightweight, fast, universal and typed Bluesky API wrapper for Apps & Bots. It's designed to be easy to use, lightweight and straightforward to use. It's built with TypeScript and has full type support. +tsky is a lightweight, fast, universal and typed Bluesky API wrapper for Apps & Bots. It's designed to be easy to use, lightweight and straightforward to use. It's built with TypeScript and has full type support. It was primarily built for the [Nimbus Client](https://github.com/nimbus-town/nimbus) but can be used in any other project that requires Bluesky API integration. @@ -48,9 +48,9 @@ console.log(profile.handle); ## Links -- [📚 TSky Documentation](https://tsky.dev/) -- [🦋 TSky on Bluesky](https://bsky.app/profile/tsky.dev) -- [📣 TSky Discord Server](https://discord.gg/KPD7XPUZn3) +- [📚 tsky Documentation](https://tsky.dev/) +- [🦋 tsky on Bluesky](https://bsky.app/profile/tsky.dev) +- [📣 tsky Discord Server](https://discord.gg/KPD7XPUZn3) - [🦋 Nimbus on Bluesky](https://bsky.app/profile/nimbus.town) ## Contributing diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index d6a0c92..6606822 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -2,8 +2,8 @@ import { defineConfig } from 'vitepress'; // https://vitepress.dev/reference/site-config export default defineConfig({ - title: 'TSky', - description: 'A BlueSky API client for nimble apps and tools', + title: 'tsky', + description: 'A Bluesky API client for nimble apps and tools', themeConfig: { nav: [ { text: 'Home', link: '/' }, diff --git a/docs/index.md b/docs/index.md index bcbaa07..8d11a40 100644 --- a/docs/index.md +++ b/docs/index.md @@ -3,9 +3,9 @@ layout: home hero: - name: "TSky" - text: "A BlueSky API client for nimble apps and tools" - tagline: A BlueSky API client for nimble apps and tools + name: "tsky" + text: "A Bluesky API client for nimble apps and tools" + tagline: A Bluesky API client for nimble apps and tools actions: - theme: brand text: Get Started diff --git a/packages/core/src/tsky/tsky.ts b/packages/core/src/tsky/tsky.ts index 5c7fbb6..629ee01 100644 --- a/packages/core/src/tsky/tsky.ts +++ b/packages/core/src/tsky/tsky.ts @@ -8,7 +8,7 @@ import type { } from '@atproto/api'; import { Paginator } from './paginator'; -export class TSky { +export class Tsky { constructor(private instance: AppBskyNS) {} /** From 889e16dd51585426bdf7ffdd2dfb2603354c4908 Mon Sep 17 00:00:00 2001 From: Ryan Skinner Date: Mon, 2 Dec 2024 02:40:54 -0500 Subject: [PATCH 18/22] refactor: migrate to scoped package structure (@tsky/*) (#25) --- docs/package.json | 2 +- package.json | 11 ++++++----- packages/core/package.json | 5 ++++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/docs/package.json b/docs/package.json index 849b458..4f56f44 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,5 +1,5 @@ { - "name": "tsky-docs", + "name": "@tsky/docs", "version": "1.0.0", "private": true, "main": "index.js", diff --git a/package.json b/package.json index b322555..aa86578 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,8 @@ { - "name": "tsky-workspace", + "name": "tsky", "type": "module", "version": "0.1.0", + "private": true, "packageManager": "pnpm@9.14.2", "license": "MIT", "homepage": "https://tsky.dev/", @@ -10,10 +11,10 @@ "url": "git+https://github.com/tsky-dev/tsky.git" }, "scripts": { - "build": "pnpm run --filter tsky build", - "docs:dev": "pnpm run --filter tsky-docs dev", - "docs:build": "pnpm run --filter tsky-docs build", - "docs:preview": "pnpm run --filter tsky-docs preview", + "build": "pnpm run --filter @tsky/core build", + "docs:dev": "pnpm run --filter @tsky/docs dev", + "docs:build": "pnpm run --filter @tsky/docs build", + "docs:preview": "pnpm run --filter @tsky/docs preview", "format": "biome check --write .", "format:check": "biome check", "lint": "eslint ./packages ./docs", diff --git a/packages/core/package.json b/packages/core/package.json index 1699900..24c4dc3 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,8 +1,11 @@ { - "name": "tsky", + "name": "@tsky/core", "type": "module", "version": "0.0.1", "license": "MIT", + "publishConfig": { + "access": "public" + }, "exports": { ".": { "import": { From f57d7b5626923059eb266b7958cabc8ceb1500bd Mon Sep 17 00:00:00 2001 From: Ryan Skinner Date: Mon, 2 Dec 2024 14:28:13 -0500 Subject: [PATCH 19/22] Update packages/lexicons/package.json Co-authored-by: Anbraten <6918444+anbraten@users.noreply.github.com> --- packages/lexicons/package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/lexicons/package.json b/packages/lexicons/package.json index 0cd532b..01bc3c0 100644 --- a/packages/lexicons/package.json +++ b/packages/lexicons/package.json @@ -5,6 +5,9 @@ "publishConfig": { "access": "public" }, + "scripts": { + "build": "tsx ./scripts/generate-types.ts" + }, "dependencies": { "@atproto/lexicon": "^0.4.3", "@atproto/xrpc": "^0.6.4", From 611e72e571af30209b340632cd93ae80d9fb5783 Mon Sep 17 00:00:00 2001 From: Ryan Skinner Date: Mon, 2 Dec 2024 14:30:47 -0500 Subject: [PATCH 20/22] adding generated files --- packages/lexicons/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/lexicons/tsconfig.json b/packages/lexicons/tsconfig.json index b25195c..53d5d52 100644 --- a/packages/lexicons/tsconfig.json +++ b/packages/lexicons/tsconfig.json @@ -9,6 +9,6 @@ "forceConsistentCasingInFileNames": true, "skipLibCheck": true }, - "include": ["scripts/**/*"], + "include": ["scripts/**/*", "src/**/*"], "exclude": ["node_modules"] } From 8b372ffa37cd696292075331cdf7e7d3767ab957 Mon Sep 17 00:00:00 2001 From: Ryan Skinner Date: Wed, 4 Dec 2024 08:31:37 -0500 Subject: [PATCH 21/22] lockfile update --- pnpm-lock.yaml | 274 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 273 insertions(+), 1 deletion(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bbebdbd..27c4666 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -556,6 +556,18 @@ packages: '@jridgewell/sourcemap-codec@1.5.0': resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==} + '@nodelib/fs.scandir@2.1.5': + resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} + engines: {node: '>= 8'} + + '@nodelib/fs.stat@2.0.5': + resolution: {integrity: sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==} + engines: {node: '>= 8'} + + '@nodelib/fs.walk@1.2.8': + resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} + engines: {node: '>= 8'} + '@pkgjs/parseargs@0.11.0': resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} engines: {node: '>=14'} @@ -731,6 +743,9 @@ packages: '@shikijs/vscode-textmate@9.3.0': resolution: {integrity: sha512-jn7/7ky30idSkd/O5yDBfAnVt+JJpepofP/POZ1iMOxK59cOfqIgg/Dj0eFsjOTMw+4ycJN0uhZH/Eb0bs/EUA==} + '@ts-morph/common@0.17.0': + resolution: {integrity: sha512-RMSSvSfs9kb0VzkvQ2NWobwnj7TxCA9vI/IjR9bDHqgAyVbu2T0DN4wiKVqomyDWqO7dPr/tErSfq7urQ1Q37g==} + '@types/estree@1.0.6': resolution: {integrity: sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==} @@ -749,6 +764,9 @@ packages: '@types/mdurl@2.0.0': resolution: {integrity: sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg==} + '@types/node@22.10.1': + resolution: {integrity: sha512-qKgsUwfHZV2WCWLAnVP1JqnpE6Im6h3Y0+fYgMTasNQ7V++CBX5OT1as0g0f+OyubbFqhf6XVNIsmN4IIhEgGQ==} + '@types/resolve@1.20.2': resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} @@ -921,6 +939,10 @@ packages: brace-expansion@2.0.1: resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==} + braces@3.0.3: + resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} + engines: {node: '>=8'} + cac@6.7.14: resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} engines: {node: '>=8'} @@ -932,6 +954,10 @@ packages: resolution: {integrity: sha512-aGtmf24DW6MLHHG5gCx4zaI3uBq3KRtxeVs0DjFH6Z0rDNbsvTxFASFvdj79pxjxZ8/5u3PIiN3IwEIQkiiuPw==} engines: {node: '>=12'} + chalk@4.1.2: + resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} + engines: {node: '>=10'} + character-entities-html4@2.1.0: resolution: {integrity: sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA==} @@ -942,6 +968,13 @@ packages: resolution: {integrity: sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==} engines: {node: '>= 16'} + chownr@3.0.0: + resolution: {integrity: sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==} + engines: {node: '>=18'} + + code-block-writer@11.0.3: + resolution: {integrity: sha512-NiujjUFB4SwScJq2bwbYUtXbZhBSlY6vYzm++3Q6oC+U+injTqfPYFK8wS9COOmb2lueqp0ZRB4nK1VYeHgNyw==} + color-convert@2.0.1: resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} engines: {node: '>=7.0.0'} @@ -952,6 +985,10 @@ packages: comma-separated-tokens@2.0.3: resolution: {integrity: sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==} + commander@9.5.0: + resolution: {integrity: sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==} + engines: {node: ^12.20.0 || >=14} + commondir@1.0.1: resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==} @@ -1029,6 +1066,17 @@ packages: resolution: {integrity: sha512-bFi65yM+xZgk+u/KRIpekdSYkTB5W1pEf0Lt8Q8Msh7b+eQ7LXVtIB1Bkm4fvclDEL1b2CZkMhv2mOeF8tMdkA==} engines: {node: '>=12.0.0'} + fast-glob@3.3.2: + resolution: {integrity: sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==} + engines: {node: '>=8.6.0'} + + fastq@1.17.1: + resolution: {integrity: sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==} + + fill-range@7.1.1: + resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==} + engines: {node: '>=8'} + focus-trap@7.6.2: resolution: {integrity: sha512-9FhUxK1hVju2+AiQIDJ5Dd//9R2n2RAfJ0qfhF4IHGHgcoEUTMpbTeG/zbEuwaiYXfuAH6XE0/aCyxDdRM+W5w==} @@ -1047,6 +1095,10 @@ packages: get-tsconfig@4.8.1: resolution: {integrity: sha512-k9PN+cFBmaLWtVz29SkUoqU5O0slLuHJXt/2P+tMVFT+phsSGXGkp9t3rQIqdz0e+06EHNGs3oM6ZX1s2zHxRg==} + glob-parent@5.1.2: + resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} + engines: {node: '>= 6'} + glob@10.4.5: resolution: {integrity: sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==} hasBin: true @@ -1058,6 +1110,10 @@ packages: graphemer@1.4.0: resolution: {integrity: sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==} + has-flag@4.0.0: + resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} + engines: {node: '>=8'} + hasown@2.0.2: resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==} engines: {node: '>= 0.4'} @@ -1078,13 +1134,25 @@ packages: resolution: {integrity: sha512-z0vtXSwucUJtANQWldhbtbt7BnL0vxiFjIdDLAatwhDYty2bad6s+rijD6Ri4YuYJubLzIJLUidCh09e1djEVQ==} engines: {node: '>= 0.4'} + is-extglob@2.1.1: + resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} + engines: {node: '>=0.10.0'} + is-fullwidth-code-point@3.0.0: resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} engines: {node: '>=8'} + is-glob@4.0.3: + resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} + engines: {node: '>=0.10.0'} + is-module@1.0.0: resolution: {integrity: sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==} + is-number@7.0.0: + resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} + engines: {node: '>=0.12.0'} + is-reference@1.2.1: resolution: {integrity: sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==} @@ -1116,6 +1184,10 @@ packages: mdast-util-to-hast@13.2.0: resolution: {integrity: sha512-QGYKEuUsYT9ykKBCMOEDLsU5JRObWQusAolFMeko/tYPufNkRffBAQjIE+99jbA87xv6FgmjLtwjh9wBWajwAA==} + merge2@1.4.1: + resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} + engines: {node: '>= 8'} + micromark-util-character@2.1.1: resolution: {integrity: sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==} @@ -1131,6 +1203,14 @@ packages: micromark-util-types@2.0.1: resolution: {integrity: sha512-534m2WhVTddrcKVepwmVEVnUAmtrx9bfIjNoQHRqfnvdaHQiFytEhJoTgpWJvDEXCO5gLTQh3wYC1PgOJA4NSQ==} + micromatch@4.0.8: + resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==} + engines: {node: '>=8.6'} + + minimatch@5.1.6: + resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==} + engines: {node: '>=10'} + minimatch@9.0.5: resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==} engines: {node: '>=16 || 14 >=14.17'} @@ -1149,6 +1229,16 @@ packages: mitt@3.0.1: resolution: {integrity: sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==} + mkdirp@1.0.4: + resolution: {integrity: sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==} + engines: {node: '>=10'} + hasBin: true + + mkdirp@3.0.1: + resolution: {integrity: sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==} + engines: {node: '>=10'} + hasBin: true + ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} @@ -1174,6 +1264,9 @@ packages: package-json-from-dist@1.0.1: resolution: {integrity: sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==} + path-browserify@1.0.1: + resolution: {integrity: sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==} + path-key@3.1.1: resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} engines: {node: '>=8'} @@ -1198,6 +1291,10 @@ packages: picocolors@1.1.1: resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} + picomatch@2.3.1: + resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} + engines: {node: '>=8.6'} + picomatch@4.0.2: resolution: {integrity: sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==} engines: {node: '>=12'} @@ -1219,9 +1316,17 @@ packages: preact@10.25.0: resolution: {integrity: sha512-6bYnzlLxXV3OSpUxLdaxBmE7PMOu0aR3pG6lryK/0jmvcDFPlcXGQAt5DpK3RITWiDrfYZRI0druyaK/S9kYLg==} + prettier@3.4.2: + resolution: {integrity: sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ==} + engines: {node: '>=14'} + hasBin: true + property-information@6.5.0: resolution: {integrity: sha512-PgTgs/BlvHxOu8QuEN7wi5A0OmXaBcHpmCSTehcs6Uuu9IkDIEo13Hy7n898RHfrQ49vKCoGeWZSaAK01nwVig==} + queue-microtask@1.2.3: + resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} + regex-recursion@4.3.0: resolution: {integrity: sha512-5LcLnizwjcQ2ALfOj95MjcatxyqF5RPySx9yT+PaXu3Gox2vyAtLDjHB8NTJLtMGkvyau6nI3CfpwFCjPUIs/A==} @@ -1238,14 +1343,25 @@ packages: resolution: {integrity: sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==} hasBin: true + reusify@1.0.4: + resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} + engines: {iojs: '>=1.0.0', node: '>=0.10.0'} + rfdc@1.4.1: resolution: {integrity: sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==} + rimraf@5.0.10: + resolution: {integrity: sha512-l0OE8wL34P4nJH/H2ffoaniAokM2qSmrtXHmlpvYr5AVVX8msAyW0l8NVJFDxlSK4u3Uh/f41cQheDVdnYijwQ==} + hasBin: true + rollup@4.27.4: resolution: {integrity: sha512-RLKxqHEMjh/RGLsDxAEsaLO3mWgyoU6x9w6n1ikAzet4B3gI2/3yP6PWY2p9QzRTh6MfEIXB3MwsOY0Iv3vNrw==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true + run-parallel@1.2.0: + resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} + search-insights@2.17.3: resolution: {integrity: sha512-RQPdCYTa8A68uM2jwxoY842xDhvx3E5LFL1LxvxCNMev4o5mLuokczhzjAgGwUZBAmOKZknArSxLKmXtIi2AxQ==} @@ -1307,6 +1423,10 @@ packages: resolution: {integrity: sha512-8iGv75BYOa0xRJHK5vRLEjE2H/i4lulTjzpUXic3Eg8akftYjkmQDa8JARQ42rlczXyFR3IeRoeFCc7RxHsYZA==} engines: {node: '>=16'} + supports-color@7.2.0: + resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} + engines: {node: '>=8'} + supports-preserve-symlinks-flag@1.0.0: resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} engines: {node: '>= 0.4'} @@ -1314,6 +1434,10 @@ packages: tabbable@6.2.0: resolution: {integrity: sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew==} + tar@7.4.3: + resolution: {integrity: sha512-5S7Va8hKfV7W5U6g3aYxXmlPoZVAwUMy9AOKyF2fVuZa2UD3qZjg578OrLRt8PcNN1PleVaL/5/yYATNL0ICUw==} + engines: {node: '>=18'} + tinybench@2.9.0: resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==} @@ -1336,9 +1460,16 @@ packages: resolution: {integrity: sha512-tcwMRIioTcF/FcxLev8MJWxCp+GUALRhFEqbDoZrnowmKSGqPrl5pqS+Sut2m8BgJ6S4FExCSSpGffZ0Tks6Aw==} hasBin: true + to-regex-range@5.0.1: + resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} + engines: {node: '>=8.0'} + trim-lines@3.0.1: resolution: {integrity: sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==} + ts-morph@16.0.0: + resolution: {integrity: sha512-jGNF0GVpFj0orFw55LTsQxVYEUOCWBAbR5Ls7fTYE5pQsbW18ssTb/6UXx/GYAEjS+DQTp8VoTw0vqYMiaaQuw==} + tsx@4.19.2: resolution: {integrity: sha512-pOUl6Vo2LUq/bSa8S5q7b91cgNSjctn9ugq/+Mvow99qW6x/UZYwzxy/3NmqoT66eHYfCVvFvACC58UBPFf28g==} engines: {node: '>=18.0.0'} @@ -1352,6 +1483,9 @@ packages: uint8arrays@3.0.0: resolution: {integrity: sha512-HRCx0q6O9Bfbp+HHSfQQKD7wU70+lydKVt4EghkdOvlK/NlrF90z+eXV34mUd48rNvVJXwkrMSPpCATkct8fJA==} + undici-types@6.20.0: + resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==} + unist-util-is@6.0.0: resolution: {integrity: sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==} @@ -1483,6 +1617,13 @@ packages: resolution: {integrity: sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==} engines: {node: '>=12'} + yallist@5.0.0: + resolution: {integrity: sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==} + engines: {node: '>=18'} + + yesno@0.4.0: + resolution: {integrity: sha512-tdBxmHvbXPBKYIg81bMCB7bVeDmHkRzk5rVJyYYXurwKkHq/MCd8rz4HSJUP7hW0H2NlXiq8IFiWvYKEHhlotA==} + zod@3.23.8: resolution: {integrity: sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==} @@ -1620,7 +1761,7 @@ snapshots: '@atproto/syntax': 0.3.1 chalk: 4.1.2 commander: 9.5.0 - prettier: 3.4.1 + prettier: 3.4.2 ts-morph: 16.0.0 yesno: 0.4.0 zod: 3.23.8 @@ -1868,8 +2009,24 @@ snapshots: wrap-ansi: 8.1.0 wrap-ansi-cjs: wrap-ansi@7.0.0 + '@isaacs/fs-minipass@4.0.1': + dependencies: + minipass: 7.1.2 + '@jridgewell/sourcemap-codec@1.5.0': {} + '@nodelib/fs.scandir@2.1.5': + dependencies: + '@nodelib/fs.stat': 2.0.5 + run-parallel: 1.2.0 + + '@nodelib/fs.stat@2.0.5': {} + + '@nodelib/fs.walk@1.2.8': + dependencies: + '@nodelib/fs.scandir': 2.1.5 + fastq: 1.17.1 + '@pkgjs/parseargs@0.11.0': optional: true @@ -2012,6 +2169,13 @@ snapshots: '@shikijs/vscode-textmate@9.3.0': {} + '@ts-morph/common@0.17.0': + dependencies: + fast-glob: 3.3.2 + minimatch: 5.1.6 + mkdirp: 1.0.4 + path-browserify: 1.0.1 + '@types/estree@1.0.6': {} '@types/hast@3.0.4': @@ -2031,6 +2195,10 @@ snapshots: '@types/mdurl@2.0.0': {} + '@types/node@22.10.1': + dependencies: + undici-types: 6.20.0 + '@types/resolve@1.20.2': {} '@types/unist@3.0.3': {} @@ -2224,6 +2392,10 @@ snapshots: dependencies: balanced-match: 1.0.2 + braces@3.0.3: + dependencies: + fill-range: 7.1.1 + cac@6.7.14: {} ccount@2.0.1: {} @@ -2236,6 +2408,11 @@ snapshots: loupe: 3.1.2 pathval: 2.0.0 + chalk@4.1.2: + dependencies: + ansi-styles: 4.3.0 + supports-color: 7.2.0 + character-entities-html4@2.1.0: {} character-entities-legacy@3.0.0: {} @@ -2244,6 +2421,8 @@ snapshots: chownr@3.0.0: {} + code-block-writer@11.0.3: {} + color-convert@2.0.1: dependencies: color-name: 1.1.4 @@ -2252,6 +2431,8 @@ snapshots: comma-separated-tokens@2.0.3: {} + commander@9.5.0: {} + commondir@1.0.1: {} copy-anything@3.0.5: @@ -2353,6 +2534,22 @@ snapshots: expect-type@1.1.0: {} + fast-glob@3.3.2: + dependencies: + '@nodelib/fs.stat': 2.0.5 + '@nodelib/fs.walk': 1.2.8 + glob-parent: 5.1.2 + merge2: 1.4.1 + micromatch: 4.0.8 + + fastq@1.17.1: + dependencies: + reusify: 1.0.4 + + fill-range@7.1.1: + dependencies: + to-regex-range: 5.0.1 + focus-trap@7.6.2: dependencies: tabbable: 6.2.0 @@ -2371,6 +2568,10 @@ snapshots: dependencies: resolve-pkg-maps: 1.0.0 + glob-parent@5.1.2: + dependencies: + is-glob: 4.0.3 + glob@10.4.5: dependencies: foreground-child: 3.3.0 @@ -2384,6 +2585,8 @@ snapshots: graphemer@1.4.0: {} + has-flag@4.0.0: {} + hasown@2.0.2: dependencies: function-bind: 1.1.2 @@ -2414,10 +2617,18 @@ snapshots: dependencies: hasown: 2.0.2 + is-extglob@2.1.1: {} + is-fullwidth-code-point@3.0.0: {} + is-glob@4.0.3: + dependencies: + is-extglob: 2.1.1 + is-module@1.0.0: {} + is-number@7.0.0: {} + is-reference@1.2.1: dependencies: '@types/estree': 1.0.6 @@ -2456,6 +2667,8 @@ snapshots: unist-util-visit: 5.0.0 vfile: 6.0.3 + merge2@1.4.1: {} + micromark-util-character@2.1.1: dependencies: micromark-util-symbol: 2.0.1 @@ -2473,6 +2686,15 @@ snapshots: micromark-util-types@2.0.1: {} + micromatch@4.0.8: + dependencies: + braces: 3.0.3 + picomatch: 2.3.1 + + minimatch@5.1.6: + dependencies: + brace-expansion: 2.0.1 + minimatch@9.0.5: dependencies: brace-expansion: 2.0.1 @@ -2488,6 +2710,10 @@ snapshots: mitt@3.0.1: {} + mkdirp@1.0.4: {} + + mkdirp@3.0.1: {} + ms@2.1.3: {} multiformats@13.3.1: {} @@ -2508,6 +2734,8 @@ snapshots: package-json-from-dist@1.0.1: {} + path-browserify@1.0.1: {} + path-key@3.1.1: {} path-parse@1.0.7: {} @@ -2525,6 +2753,8 @@ snapshots: picocolors@1.1.1: {} + picomatch@2.3.1: {} + picomatch@4.0.2: {} pkgroll@2.5.1(typescript@5.7.2): @@ -2550,8 +2780,12 @@ snapshots: preact@10.25.0: {} + prettier@3.4.2: {} + property-information@6.5.0: {} + queue-microtask@1.2.3: {} + regex-recursion@4.3.0: dependencies: regex-utilities: 2.3.0 @@ -2570,8 +2804,14 @@ snapshots: path-parse: 1.0.7 supports-preserve-symlinks-flag: 1.0.0 + reusify@1.0.4: {} + rfdc@1.4.1: {} + rimraf@5.0.10: + dependencies: + glob: 10.4.5 + rollup@4.27.4: dependencies: '@types/estree': 1.0.6 @@ -2596,6 +2836,10 @@ snapshots: '@rollup/rollup-win32-x64-msvc': 4.27.4 fsevents: 2.3.3 + run-parallel@1.2.0: + dependencies: + queue-microtask: 1.2.3 + search-insights@2.17.3: {} shebang-command@2.0.0: @@ -2656,10 +2900,23 @@ snapshots: dependencies: copy-anything: 3.0.5 + supports-color@7.2.0: + dependencies: + has-flag: 4.0.0 + supports-preserve-symlinks-flag@1.0.0: {} tabbable@6.2.0: {} + tar@7.4.3: + dependencies: + '@isaacs/fs-minipass': 4.0.1 + chownr: 3.0.0 + minipass: 7.1.2 + minizlib: 3.0.1 + mkdirp: 3.0.1 + yallist: 5.0.0 + tinybench@2.9.0: {} tinyexec@0.3.1: {} @@ -2672,8 +2929,17 @@ snapshots: tlds@1.255.0: {} + to-regex-range@5.0.1: + dependencies: + is-number: 7.0.0 + trim-lines@3.0.1: {} + ts-morph@16.0.0: + dependencies: + '@ts-morph/common': 0.17.0 + code-block-writer: 11.0.3 + tsx@4.19.2: dependencies: esbuild: 0.23.1 @@ -2687,6 +2953,8 @@ snapshots: dependencies: multiformats: 9.9.0 + undici-types@6.20.0: {} + unist-util-is@6.0.0: dependencies: '@types/unist': 3.0.3 @@ -2867,6 +3135,10 @@ snapshots: string-width: 5.1.2 strip-ansi: 7.1.0 + yallist@5.0.0: {} + + yesno@0.4.0: {} + zod@3.23.8: {} zwitch@2.0.4: {} From b77f77b118c9cca4eb697fb7b172eb0c232ad364 Mon Sep 17 00:00:00 2001 From: Ryan Skinner Date: Wed, 4 Dec 2024 08:34:47 -0500 Subject: [PATCH 22/22] linting --- packages/lexicons/scripts/generate-types.ts | 197 ++++++++++---------- 1 file changed, 98 insertions(+), 99 deletions(-) diff --git a/packages/lexicons/scripts/generate-types.ts b/packages/lexicons/scripts/generate-types.ts index 10804f4..a27822d 100644 --- a/packages/lexicons/scripts/generate-types.ts +++ b/packages/lexicons/scripts/generate-types.ts @@ -1,99 +1,98 @@ -import { Buffer } from 'node:buffer'; -import { execSync } from 'node:child_process'; -import fs from 'node:fs/promises'; -import path from 'node:path'; -import process from 'node:process'; -import { fileURLToPath } from 'node:url'; -import * as tar from 'tar'; - -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); - -const LEXICONS_DIR = path.resolve(__dirname, '../lexicons'); -const TYPES_DIR = path.resolve(__dirname, '../src'); -const REPO = 'bluesky-social/atproto'; - -async function findJsonFiles(dir: string): Promise { - const files: string[] = []; - const entries = await fs.readdir(dir, { withFileTypes: true }); - - for (const entry of entries) { - const fullPath = path.join(dir, entry.name); - if (entry.isDirectory()) { - files.push(...await findJsonFiles(fullPath)); - } - else if (entry.isFile() && entry.name.endsWith('.json')) { - files.push(fullPath); - } - } - - return files; -} - -async function main() { - try { - // Ensure directories exist - await fs.mkdir(LEXICONS_DIR, { recursive: true }); - await fs.mkdir(TYPES_DIR, { recursive: true }); - - // Get latest commit SHA for lexicons - console.log('Getting latest lexicon commit...'); - const shaResponse = await fetch(`https://api.github.com/repos/${REPO}/commits?path=lexicons/`); - if (!shaResponse.ok) { - throw new Error(`Failed to get commit SHA: ${shaResponse.statusText}`); - } - - const commits = await shaResponse.json(); - const sha = commits[0]?.sha; - if (!sha) { - throw new Error('No commits found for lexicons'); - } - - // Download specific commit's lexicons - console.log('Downloading lexicons from atproto...'); - const response = await fetch(`https://github.com/${REPO}/archive/${sha}.tar.gz`); - if (!response.ok) { - throw new Error(`Failed to download lexicons: ${response.statusText}`); - } - - // Create a temporary file for the tar download - const tarFile = path.join(LEXICONS_DIR, 'atproto.tar.gz'); - await fs.writeFile(tarFile, Buffer.from(await response.arrayBuffer())); - - // Extract only lexicon files - await tar.x({ - file: tarFile, - cwd: LEXICONS_DIR, - filter: path => path.includes('/lexicons/'), - strip: 2, - }); - - // Clean up tar file - await fs.unlink(tarFile); - - // Find all lexicon JSON files - console.log('Finding lexicon files...'); - const lexiconFiles = await findJsonFiles(LEXICONS_DIR); - if (lexiconFiles.length === 0) { - throw new Error('No lexicon files found'); - } - - // Generate types using @atproto/lex-cli - console.log('Generating types...'); - execSync( - `pnpm lex gen-api ${TYPES_DIR} ${lexiconFiles.join(' ')}`, - { - stdio: 'inherit', - cwd: TYPES_DIR, - }, - ); - - console.log('Done! Types generated in', TYPES_DIR); - } - catch (error) { - console.error('Error:', error); - process.exit(1); - } -} - -main(); +import { Buffer } from 'node:buffer'; +import { execSync } from 'node:child_process'; +import fs from 'node:fs/promises'; +import path from 'node:path'; +import process from 'node:process'; +import { fileURLToPath } from 'node:url'; +import * as tar from 'tar'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +const LEXICONS_DIR = path.resolve(__dirname, '../lexicons'); +const TYPES_DIR = path.resolve(__dirname, '../src'); +const REPO = 'bluesky-social/atproto'; + +async function findJsonFiles(dir: string): Promise { + const files: string[] = []; + const entries = await fs.readdir(dir, { withFileTypes: true }); + + for (const entry of entries) { + const fullPath = path.join(dir, entry.name); + if (entry.isDirectory()) { + files.push(...(await findJsonFiles(fullPath))); + } else if (entry.isFile() && entry.name.endsWith('.json')) { + files.push(fullPath); + } + } + + return files; +} + +async function main() { + try { + // Ensure directories exist + await fs.mkdir(LEXICONS_DIR, { recursive: true }); + await fs.mkdir(TYPES_DIR, { recursive: true }); + + // Get latest commit SHA for lexicons + console.log('Getting latest lexicon commit...'); + const shaResponse = await fetch( + `https://api.github.com/repos/${REPO}/commits?path=lexicons/`, + ); + if (!shaResponse.ok) { + throw new Error(`Failed to get commit SHA: ${shaResponse.statusText}`); + } + + const commits = await shaResponse.json(); + const sha = commits[0]?.sha; + if (!sha) { + throw new Error('No commits found for lexicons'); + } + + // Download specific commit's lexicons + console.log('Downloading lexicons from atproto...'); + const response = await fetch( + `https://github.com/${REPO}/archive/${sha}.tar.gz`, + ); + if (!response.ok) { + throw new Error(`Failed to download lexicons: ${response.statusText}`); + } + + // Create a temporary file for the tar download + const tarFile = path.join(LEXICONS_DIR, 'atproto.tar.gz'); + await fs.writeFile(tarFile, Buffer.from(await response.arrayBuffer())); + + // Extract only lexicon files + await tar.x({ + file: tarFile, + cwd: LEXICONS_DIR, + filter: (path) => path.includes('/lexicons/'), + strip: 2, + }); + + // Clean up tar file + await fs.unlink(tarFile); + + // Find all lexicon JSON files + console.log('Finding lexicon files...'); + const lexiconFiles = await findJsonFiles(LEXICONS_DIR); + if (lexiconFiles.length === 0) { + throw new Error('No lexicon files found'); + } + + // Generate types using @atproto/lex-cli + console.log('Generating types...'); + execSync(`pnpm lex gen-api ${TYPES_DIR} ${lexiconFiles.join(' ')}`, { + stdio: 'inherit', + cwd: TYPES_DIR, + }); + + console.log('Done! Types generated in', TYPES_DIR); + } catch (error) { + console.error('Error:', error); + process.exit(1); + } +} + +main();