Commit a354b69

Anton Medvedev <anton@medv.io>
2024-11-29 14:39:19
Add megaera.mjs with zx
1 parent b6f25a5
scripts/megaera.mjs
@@ -0,0 +1,5 @@
+import 'zx/globals'
+
+await $`megaera --schema .github/schema.graphql ${await glob('src/**/*.graphql')}`.verbose()
+await $`prettier --write ${await glob('src/**/*.graphql.ts')}`
+echo(chalk.green('TypeScript files generated successfully.'))
package-lock.json
@@ -27,7 +27,8 @@
         "image-dimensions": "^2.3.0",
         "prettier": "^3.4.1",
         "ts-node": "^10.9.2",
-        "typescript": "^5.7.2"
+        "typescript": "^5.7.2",
+        "zx": "^8.2.4"
       }
     },
     "node_modules/@bcoe/v8-coverage": {
@@ -614,12 +615,35 @@
       "integrity": "sha512-4Dh3dk2TUcbdfHrX0Al90mNGJDvA9NBiTQPzbrjGi/dLxzKCGOYgT8YQ47jUKNFALkAJAadifq0pzyjIUlhVhg==",
       "license": "MIT"
     },
+    "node_modules/@types/fs-extra": {
+      "version": "11.0.4",
+      "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-11.0.4.tgz",
+      "integrity": "sha512-yTbItCNreRooED33qjunPthRcSjERP1r4MqCZc7wv0u2sUkzTFp45tgUfS5+r7FrZPdmCCNflLhVSP/o+SemsQ==",
+      "dev": true,
+      "license": "MIT",
+      "optional": true,
+      "dependencies": {
+        "@types/jsonfile": "*",
+        "@types/node": "*"
+      }
+    },
     "node_modules/@types/istanbul-lib-coverage": {
       "version": "2.0.4",
       "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz",
       "integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==",
       "dev": true
     },
+    "node_modules/@types/jsonfile": {
+      "version": "6.1.4",
+      "resolved": "https://registry.npmjs.org/@types/jsonfile/-/jsonfile-6.1.4.tgz",
+      "integrity": "sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ==",
+      "dev": true,
+      "license": "MIT",
+      "optional": true,
+      "dependencies": {
+        "@types/node": "*"
+      }
+    },
     "node_modules/@types/minimist": {
       "version": "1.2.5",
       "resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.5.tgz",
@@ -1860,6 +1884,23 @@
       "funding": {
         "url": "https://github.com/sponsors/sindresorhus"
       }
+    },
+    "node_modules/zx": {
+      "version": "8.2.4",
+      "resolved": "https://registry.npmjs.org/zx/-/zx-8.2.4.tgz",
+      "integrity": "sha512-g9wVU+5+M+zVen/3IyAZfsZFmeqb6vDfjqFggakviz5uLK7OAejOirX+jeTOkyvAh/OYRlCgw+SdqzN7F61QVQ==",
+      "dev": true,
+      "license": "Apache-2.0",
+      "bin": {
+        "zx": "build/cli.js"
+      },
+      "engines": {
+        "node": ">= 12.17.0"
+      },
+      "optionalDependencies": {
+        "@types/fs-extra": ">=11",
+        "@types/node": ">=20"
+      }
     }
   }
 }
package.json
@@ -19,7 +19,7 @@
     "build": "tsc",
     "check-images": "node scripts/check-images.mjs",
     "generate-gh-pages": "node scripts/generate-gh-pages.mjs",
-    "megaera": "megaera --schema .github/schema.graphql src/**/*.graphql && prettier --write src/**/*.graphql.ts",
+    "megaera": "zx scripts/megaera.mjs",
     "test": "npm run test:unit",
     "test:unit": "c8 -r lcov -r text -o coverage -x scripts -x test node --loader ts-node/esm --experimental-specifier-resolution=node scripts/test.mjs"
   },
@@ -39,7 +39,8 @@
     "image-dimensions": "^2.3.0",
     "prettier": "^3.4.1",
     "ts-node": "^10.9.2",
-    "typescript": "^5.7.2"
+    "typescript": "^5.7.2",
+    "zx": "^8.2.4"
   },
   "files": [
     "dist"