@graphql-hive/federation-gateway-audit 0.0.0 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yaml +4 -4
- package/.github/workflows/release.yml +3 -3
- package/CHANGELOG.md +10 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +8 -4
- package/src/cli.ts +700 -0
- package/src/env.ts +13 -0
- package/src/index.ts +262 -0
- package/src/subgraph.ts +113 -0
- package/src/summary.ts +237 -0
- package/src/supergraph.ts +195 -0
- package/src/test-suites/abstract-types/agency.subgraph.ts +43 -0
- package/src/test-suites/abstract-types/books.subgraph.ts +47 -0
- package/src/test-suites/abstract-types/data.ts +120 -0
- package/src/test-suites/abstract-types/index.ts +23 -0
- package/src/test-suites/abstract-types/inventory.subgraph.ts +142 -0
- package/src/test-suites/abstract-types/magazines.subgraph.ts +47 -0
- package/src/test-suites/abstract-types/products.subgraph.ts +204 -0
- package/src/test-suites/abstract-types/reviews.subgraph.ts +159 -0
- package/src/test-suites/abstract-types/test.ts +1084 -0
- package/src/test-suites/abstract-types/users.subgraph.ts +31 -0
- package/src/test-suites/child-type-mismatch/a.subgraph.ts +27 -0
- package/src/test-suites/child-type-mismatch/b.subgraph.ts +51 -0
- package/src/test-suites/child-type-mismatch/data.ts +6 -0
- package/src/test-suites/child-type-mismatch/index.ts +6 -0
- package/{dist/index-Ca0FeU7u.js → src/test-suites/child-type-mismatch/test.ts} +79 -178
- package/src/test-suites/circular-reference-interface/a.subgraph.ts +55 -0
- package/src/test-suites/circular-reference-interface/b.subgraph.ts +35 -0
- package/src/test-suites/circular-reference-interface/data.ts +17 -0
- package/src/test-suites/circular-reference-interface/index.ts +6 -0
- package/src/test-suites/circular-reference-interface/test.ts +78 -0
- package/src/test-suites/complex-entity-call/data.ts +27 -0
- package/src/test-suites/complex-entity-call/index.ts +12 -0
- package/src/test-suites/complex-entity-call/link.subgraph.ts +36 -0
- package/src/test-suites/complex-entity-call/list.subgraph.ts +44 -0
- package/src/test-suites/complex-entity-call/price.subgraph.ts +107 -0
- package/src/test-suites/complex-entity-call/products.subgraph.ts +65 -0
- package/src/test-suites/complex-entity-call/test.ts +74 -0
- package/src/test-suites/corrupted-supergraph-node-id/a.subgraph.ts +112 -0
- package/src/test-suites/corrupted-supergraph-node-id/b.subgraph.ts +113 -0
- package/src/test-suites/corrupted-supergraph-node-id/data.ts +16 -0
- package/src/test-suites/corrupted-supergraph-node-id/index.ts +6 -0
- package/src/test-suites/corrupted-supergraph-node-id/test.ts +223 -0
- package/src/test-suites/enum-intersection/a.subgraph.ts +46 -0
- package/src/test-suites/enum-intersection/b.subgraph.ts +51 -0
- package/src/test-suites/enum-intersection/data.ts +10 -0
- package/src/test-suites/enum-intersection/index.ts +6 -0
- package/src/test-suites/enum-intersection/test.ts +108 -0
- package/src/test-suites/fed1-external-extends/a.subgraph.ts +51 -0
- package/src/test-suites/fed1-external-extends/b.subgraph.ts +48 -0
- package/src/test-suites/fed1-external-extends/data.ts +14 -0
- package/src/test-suites/fed1-external-extends/index.ts +6 -0
- package/src/test-suites/fed1-external-extends/test.ts +90 -0
- package/src/test-suites/fed1-external-extends-resolvable/a.subgraph.ts +40 -0
- package/src/test-suites/fed1-external-extends-resolvable/b.subgraph.ts +52 -0
- package/src/test-suites/fed1-external-extends-resolvable/data.ts +9 -0
- package/src/test-suites/fed1-external-extends-resolvable/index.ts +6 -0
- package/src/test-suites/fed1-external-extends-resolvable/test.ts +28 -0
- package/src/test-suites/fed1-external-extension/a.subgraph.ts +51 -0
- package/src/test-suites/fed1-external-extension/b.subgraph.ts +48 -0
- package/src/test-suites/fed1-external-extension/data.ts +14 -0
- package/src/test-suites/fed1-external-extension/index.ts +6 -0
- package/src/test-suites/fed1-external-extension/test.ts +90 -0
- package/src/test-suites/fed2-external-extends/a.subgraph.ts +57 -0
- package/src/test-suites/fed2-external-extends/b.subgraph.ts +54 -0
- package/src/test-suites/fed2-external-extends/data.ts +14 -0
- package/src/test-suites/fed2-external-extends/index.ts +6 -0
- package/src/test-suites/fed2-external-extends/test.ts +90 -0
- package/src/test-suites/fed2-external-extension/a.subgraph.ts +57 -0
- package/src/test-suites/fed2-external-extension/b.subgraph.ts +54 -0
- package/src/test-suites/fed2-external-extension/data.ts +14 -0
- package/src/test-suites/fed2-external-extension/index.ts +6 -0
- package/src/test-suites/fed2-external-extension/test.ts +90 -0
- package/src/test-suites/include-skip/a.subgraph.ts +42 -0
- package/src/test-suites/include-skip/b.subgraph.ts +47 -0
- package/src/test-suites/include-skip/c.subgraph.ts +65 -0
- package/src/test-suites/include-skip/data.ts +6 -0
- package/src/test-suites/include-skip/index.ts +7 -0
- package/src/test-suites/include-skip/test.ts +74 -0
- package/src/test-suites/input-object-intersection/a.subgraph.ts +47 -0
- package/src/test-suites/input-object-intersection/b.subgraph.ts +51 -0
- package/src/test-suites/input-object-intersection/data.ts +10 -0
- package/src/test-suites/input-object-intersection/index.ts +6 -0
- package/src/test-suites/input-object-intersection/test.ts +49 -0
- package/src/test-suites/interface-object-indirect-extension/author.subgraph.ts +39 -0
- package/src/test-suites/interface-object-indirect-extension/index.ts +11 -0
- package/src/test-suites/interface-object-indirect-extension/media.subgraph.ts +63 -0
- package/src/test-suites/interface-object-indirect-extension/playlist.subgraph.ts +48 -0
- package/src/test-suites/interface-object-indirect-extension/test.ts +57 -0
- package/src/test-suites/interface-object-with-requires/a.subgraph.ts +68 -0
- package/src/test-suites/interface-object-with-requires/b.subgraph.ts +61 -0
- package/src/test-suites/interface-object-with-requires/data.ts +14 -0
- package/src/test-suites/interface-object-with-requires/index.ts +6 -0
- package/src/test-suites/interface-object-with-requires/test.ts +206 -0
- package/src/test-suites/keys-mashup/a.subgraph.ts +46 -0
- package/src/test-suites/keys-mashup/b.subgraph.ts +118 -0
- package/src/test-suites/keys-mashup/data.ts +43 -0
- package/src/test-suites/keys-mashup/index.ts +6 -0
- package/src/test-suites/keys-mashup/test.ts +32 -0
- package/src/test-suites/mutations/a.subgraph.ts +136 -0
- package/src/test-suites/mutations/b.subgraph.ts +107 -0
- package/src/test-suites/mutations/c.subgraph.ts +26 -0
- package/src/test-suites/mutations/data.ts +91 -0
- package/src/test-suites/mutations/index.ts +7 -0
- package/src/test-suites/mutations/test.ts +94 -0
- package/src/test-suites/mysterious-external/data.ts +12 -0
- package/src/test-suites/mysterious-external/index.ts +6 -0
- package/src/test-suites/mysterious-external/price.subgraph.ts +55 -0
- package/src/test-suites/mysterious-external/product.subgraph.ts +45 -0
- package/src/test-suites/mysterious-external/test.ts +51 -0
- package/src/test-suites/nested-provides/all-products.subgraph.ts +37 -0
- package/src/test-suites/nested-provides/category.subgraph.ts +104 -0
- package/src/test-suites/nested-provides/data.ts +28 -0
- package/src/test-suites/nested-provides/index.ts +11 -0
- package/src/test-suites/nested-provides/subcategories.subgraph.ts +89 -0
- package/src/test-suites/nested-provides/test.ts +122 -0
- package/src/test-suites/node/data.ts +23 -0
- package/src/test-suites/node/index.ts +7 -0
- package/src/test-suites/node/node-two.ts +49 -0
- package/src/test-suites/node/node.subgraph.ts +68 -0
- package/src/test-suites/node/test.ts +28 -0
- package/src/test-suites/node/types.subgraph.ts +58 -0
- package/src/test-suites/non-resolvable-interface-object/a.subgraph.ts +40 -0
- package/src/test-suites/non-resolvable-interface-object/b.subgraph.ts +55 -0
- package/src/test-suites/non-resolvable-interface-object/data.ts +7 -0
- package/src/test-suites/non-resolvable-interface-object/index.ts +6 -0
- package/src/test-suites/non-resolvable-interface-object/test.ts +113 -0
- package/src/test-suites/null-keys/a.subgraph.ts +40 -0
- package/src/test-suites/null-keys/b.subgraph.ts +42 -0
- package/src/test-suites/null-keys/c.subgraph.ts +48 -0
- package/src/test-suites/null-keys/data.ts +32 -0
- package/src/test-suites/null-keys/index.ts +7 -0
- package/src/test-suites/null-keys/test.ts +46 -0
- package/src/test-suites/override-type-interface/a.subgraph.ts +47 -0
- package/src/test-suites/override-type-interface/b.subgraph.ts +73 -0
- package/src/test-suites/override-type-interface/data.ts +27 -0
- package/src/test-suites/override-type-interface/index.ts +6 -0
- package/src/test-suites/override-type-interface/test.ts +94 -0
- package/src/test-suites/override-with-requires/a.subgraph.ts +55 -0
- package/src/test-suites/override-with-requires/b.subgraph.ts +42 -0
- package/src/test-suites/override-with-requires/c.subgraph.ts +55 -0
- package/src/test-suites/override-with-requires/data.ts +14 -0
- package/src/test-suites/override-with-requires/index.ts +7 -0
- package/src/test-suites/override-with-requires/test.ts +98 -0
- package/src/test-suites/parent-entity-call/a.subgraph.ts +90 -0
- package/src/test-suites/parent-entity-call/b.subgraph.ts +68 -0
- package/src/test-suites/parent-entity-call/c.subgraph.ts +56 -0
- package/src/test-suites/parent-entity-call/data.ts +34 -0
- package/src/test-suites/parent-entity-call/index.ts +7 -0
- package/src/test-suites/parent-entity-call/test.ts +52 -0
- package/src/test-suites/parent-entity-call-complex/a.subgraph.ts +29 -0
- package/src/test-suites/parent-entity-call-complex/b.subgraph.ts +32 -0
- package/src/test-suites/parent-entity-call-complex/c.subgraph.ts +22 -0
- package/src/test-suites/parent-entity-call-complex/d.subgraph.ts +35 -0
- package/src/test-suites/parent-entity-call-complex/index.ts +8 -0
- package/src/test-suites/parent-entity-call-complex/test.ts +32 -0
- package/src/test-suites/provides-on-interface/a.subgraph.ts +95 -0
- package/src/test-suites/provides-on-interface/b.subgraph.ts +65 -0
- package/src/test-suites/provides-on-interface/c.subgraph.ts +119 -0
- package/src/test-suites/provides-on-interface/data.ts +24 -0
- package/src/test-suites/provides-on-interface/index.ts +7 -0
- package/src/test-suites/provides-on-interface/test.ts +68 -0
- package/src/test-suites/provides-on-union/a.subgraph.ts +41 -0
- package/src/test-suites/provides-on-union/b.subgraph.ts +47 -0
- package/src/test-suites/provides-on-union/c.subgraph.ts +59 -0
- package/src/test-suites/provides-on-union/data.ts +12 -0
- package/src/test-suites/provides-on-union/index.ts +7 -0
- package/src/test-suites/provides-on-union/test.ts +62 -0
- package/src/test-suites/requires-circular/a.subgraph.ts +72 -0
- package/src/test-suites/requires-circular/b.subgraph.ts +46 -0
- package/src/test-suites/requires-circular/data.ts +25 -0
- package/src/test-suites/requires-circular/index.ts +6 -0
- package/src/test-suites/requires-circular/test.ts +46 -0
- package/src/test-suites/requires-interface/a.subgraph.ts +92 -0
- package/src/test-suites/requires-interface/b.subgraph.ts +82 -0
- package/src/test-suites/requires-interface/data.ts +27 -0
- package/src/test-suites/requires-interface/index.ts +6 -0
- package/src/test-suites/requires-interface/test.ts +96 -0
- package/src/test-suites/requires-requires/a.subgraph.ts +33 -0
- package/src/test-suites/requires-requires/b.subgraph.ts +42 -0
- package/src/test-suites/requires-requires/c.subgraph.ts +65 -0
- package/src/test-suites/requires-requires/d.subgraph.ts +71 -0
- package/src/test-suites/requires-requires/data.ts +7 -0
- package/src/test-suites/requires-requires/index.ts +8 -0
- package/src/test-suites/requires-requires/test.ts +88 -0
- package/src/test-suites/requires-with-argument/a.subgraph.ts +68 -0
- package/src/test-suites/requires-with-argument/b.subgraph.ts +55 -0
- package/src/test-suites/requires-with-argument/c.subgraph.ts +71 -0
- package/src/test-suites/requires-with-argument/d.subgraph.ts +97 -0
- package/src/test-suites/requires-with-argument/data.ts +81 -0
- package/src/test-suites/requires-with-argument/index.ts +8 -0
- package/src/test-suites/requires-with-argument/test.ts +192 -0
- package/src/test-suites/requires-with-argument-conflict/a.subgraph.ts +79 -0
- package/src/test-suites/requires-with-argument-conflict/b.subgraph.ts +60 -0
- package/src/test-suites/requires-with-argument-conflict/data.ts +20 -0
- package/src/test-suites/requires-with-argument-conflict/index.ts +6 -0
- package/src/test-suites/requires-with-argument-conflict/test.ts +37 -0
- package/src/test-suites/requires-with-fragments/a.subgraph.ts +81 -0
- package/src/test-suites/requires-with-fragments/b.subgraph.ts +151 -0
- package/src/test-suites/requires-with-fragments/data.ts +30 -0
- package/src/test-suites/requires-with-fragments/index.ts +6 -0
- package/src/test-suites/requires-with-fragments/test.ts +138 -0
- package/src/test-suites/shared-root/category.subgraph.ts +45 -0
- package/src/test-suites/shared-root/data.ts +22 -0
- package/src/test-suites/shared-root/index.ts +7 -0
- package/src/test-suites/shared-root/name.subgraph.ts +46 -0
- package/src/test-suites/shared-root/price.subgraph.ts +46 -0
- package/src/test-suites/shared-root/test.ts +94 -0
- package/src/test-suites/simple-entity-call/data.ts +12 -0
- package/src/test-suites/simple-entity-call/email.subgraph.ts +42 -0
- package/src/test-suites/simple-entity-call/index.ts +6 -0
- package/src/test-suites/simple-entity-call/nickname.subgraph.ts +32 -0
- package/src/test-suites/simple-entity-call/test.ts +23 -0
- package/src/test-suites/simple-inaccessible/age.subgraph.ts +45 -0
- package/src/test-suites/simple-inaccessible/data.ts +12 -0
- package/src/test-suites/simple-inaccessible/friends.subgraph.ts +68 -0
- package/src/test-suites/simple-inaccessible/index.ts +6 -0
- package/src/test-suites/simple-inaccessible/test.ts +124 -0
- package/src/test-suites/simple-interface-object/a.subgraph.ts +163 -0
- package/src/test-suites/simple-interface-object/b.subgraph.ts +89 -0
- package/src/test-suites/simple-interface-object/c.subgraph.ts +48 -0
- package/src/test-suites/simple-interface-object/data.ts +38 -0
- package/src/test-suites/simple-interface-object/index.ts +7 -0
- package/src/test-suites/simple-interface-object/test.ts +367 -0
- package/src/test-suites/simple-override/a.subgraph.ts +49 -0
- package/src/test-suites/simple-override/b.subgraph.ts +46 -0
- package/src/test-suites/simple-override/data.ts +10 -0
- package/src/test-suites/simple-override/index.ts +6 -0
- package/src/test-suites/simple-override/test.ts +51 -0
- package/src/test-suites/simple-requires-provides/accounts.subgraph.ts +48 -0
- package/src/test-suites/simple-requires-provides/data.ts +44 -0
- package/src/test-suites/simple-requires-provides/index.ts +12 -0
- package/src/test-suites/simple-requires-provides/inventory.subgraph.ts +59 -0
- package/src/test-suites/simple-requires-provides/products.subgraph.ts +48 -0
- package/src/test-suites/simple-requires-provides/reviews.subgraph.ts +106 -0
- package/src/test-suites/simple-requires-provides/test.ts +372 -0
- package/src/test-suites/typename/a.subgraph.ts +76 -0
- package/src/test-suites/typename/b.subgraph.ts +50 -0
- package/src/test-suites/typename/data.ts +14 -0
- package/src/test-suites/typename/index.ts +6 -0
- package/src/test-suites/typename/test.ts +132 -0
- package/src/test-suites/unavailable-override/a.subgraph.ts +46 -0
- package/src/test-suites/unavailable-override/b.subgraph.ts +46 -0
- package/src/test-suites/unavailable-override/data.ts +10 -0
- package/src/test-suites/unavailable-override/index.ts +6 -0
- package/src/test-suites/unavailable-override/test.ts +51 -0
- package/src/test-suites/union-interface-distributed/a.subgraph.ts +126 -0
- package/src/test-suites/union-interface-distributed/b.subgraph.ts +39 -0
- package/src/test-suites/union-interface-distributed/data.ts +26 -0
- package/src/test-suites/union-interface-distributed/index.ts +6 -0
- package/src/test-suites/union-interface-distributed/test.ts +244 -0
- package/src/test-suites/union-intersection/README.md +3 -0
- package/src/test-suites/union-intersection/a.subgraph.ts +83 -0
- package/src/test-suites/union-intersection/b.subgraph.ts +79 -0
- package/src/test-suites/union-intersection/data.ts +7 -0
- package/src/test-suites/union-intersection/index.ts +6 -0
- package/{dist/index-Ytb942t9.js → src/test-suites/union-intersection/test.ts} +74 -260
- package/src/test.ts +98 -0
- package/src/testkit.ts +31 -0
- package/.changeset/@graphql-hive_federation-gateway-audit-293-dependencies.md +0 -5
- package/.changeset/funky-times-cry.md +0 -5
- package/dist/index--3rcSZqA.js +0 -227
- package/dist/index-0MDIXUzP.cjs +0 -589
- package/dist/index-2oy7cA9A.js +0 -225
- package/dist/index-3BM15w2Y.mjs +0 -234
- package/dist/index-3CyAnc7j.js +0 -234
- package/dist/index-4swHVe9x.cjs +0 -507
- package/dist/index-6qNpP2wc.mjs +0 -238
- package/dist/index-A2YbwKzc.mjs +0 -288
- package/dist/index-B0coRevy.mjs +0 -337
- package/dist/index-B1NAc0TI.cjs +0 -215
- package/dist/index-B1WvIzTg.js +0 -371
- package/dist/index-B55AdoQy.js +0 -273
- package/dist/index-B7cr8XE-.js +0 -194
- package/dist/index-B7zN3YzE.cjs +0 -683
- package/dist/index-B9T896rB.mjs +0 -163
- package/dist/index-BEMScD_X.cjs +0 -173
- package/dist/index-BGC0_vWj.cjs +0 -335
- package/dist/index-BGUm947D.cjs +0 -229
- package/dist/index-BKcwbRZx.cjs +0 -339
- package/dist/index-BKpVb_h9.cjs +0 -236
- package/dist/index-BPFol6Ww.mjs +0 -129
- package/dist/index-BPza8i2Q.mjs +0 -213
- package/dist/index-BS7JyQSU.js +0 -250
- package/dist/index-BSWSgZCO.cjs +0 -252
- package/dist/index-BSwOAvti.js +0 -288
- package/dist/index-BWO8QbMB.mjs +0 -587
- package/dist/index-B_u5Boud.js +0 -333
- package/dist/index-BaH3FI9i.cjs +0 -361
- package/dist/index-BaluTf1I.cjs +0 -707
- package/dist/index-BcoW0aPo.cjs +0 -165
- package/dist/index-BdNZKlDU.js +0 -284
- package/dist/index-Bf81cAA1.mjs +0 -444
- package/dist/index-Bg3H3fgZ.js +0 -259
- package/dist/index-Bgl_1Y6Q.mjs +0 -681
- package/dist/index-BgryMCqm.mjs +0 -213
- package/dist/index-BiTzMTFn.js +0 -304
- package/dist/index-BjbmOyBP.cjs +0 -215
- package/dist/index-Bm8hqSRd.cjs +0 -168
- package/dist/index-BmQrhPXB.cjs +0 -131
- package/dist/index-BndUB2KV.mjs +0 -381
- package/dist/index-BpJZCoVH.mjs +0 -250
- package/dist/index-Br-Y1qC_.cjs +0 -446
- package/dist/index-BrFtcRgi.mjs +0 -194
- package/dist/index-Bu8SXnTf.mjs +0 -227
- package/dist/index-Bwh8HVkw.cjs +0 -384
- package/dist/index-BxK3Y72_.js +0 -227
- package/dist/index-BxPUzymh.cjs +0 -208
- package/dist/index-ByZa9qm8.mjs +0 -273
- package/dist/index-Bz_LTy1A.mjs +0 -222
- package/dist/index-C1GgHOiD.js +0 -228
- package/dist/index-C4Pk-zTm.mjs +0 -227
- package/dist/index-C6nkQ480.js +0 -225
- package/dist/index-C8Mu4K9Q.cjs +0 -383
- package/dist/index-CAJ9YPxc.js +0 -681
- package/dist/index-CD03pVUt.cjs +0 -373
- package/dist/index-CD8GiuIg.js +0 -227
- package/dist/index-CHB_0VqK.mjs +0 -333
- package/dist/index-CNvZCDZa.js +0 -166
- package/dist/index-COGhiFjk.mjs +0 -284
- package/dist/index-COIlelpZ.mjs +0 -262
- package/dist/index-CPu_XkjY.mjs +0 -304
- package/dist/index-CUFKuE64.js +0 -550
- package/dist/index-CW8h3l6M.js +0 -262
- package/dist/index-CWrng7Hd.mjs +0 -550
- package/dist/index-CXviN8qZ.cjs +0 -224
- package/dist/index-C_qaNb-X.mjs +0 -225
- package/dist/index-Cb3ImEjd.cjs +0 -165
- package/dist/index-Cc3vrs6_.mjs +0 -228
- package/dist/index-CcIXvx40.mjs +0 -171
- package/dist/index-CdaeeF3f.cjs +0 -306
- package/dist/index-Cj2ocjXI.cjs +0 -227
- package/dist/index-CkWEXzTN.js +0 -129
- package/dist/index-Ckhb9QAu.cjs +0 -264
- package/dist/index-CklJfQlf.cjs +0 -220
- package/dist/index-Cn0ZJkAv.mjs +0 -280
- package/dist/index-Cuw9ylL-.mjs +0 -371
- package/dist/index-CwOULUAt.mjs +0 -382
- package/dist/index-D-1dDKiZ.mjs +0 -227
- package/dist/index-D1Ip6ro6.js +0 -458
- package/dist/index-D5tEp8IU.js +0 -337
- package/dist/index-D7WuGKYY.cjs +0 -227
- package/dist/index-D8Dp6TnQ.cjs +0 -1837
- package/dist/index-D9OKpqgG.js +0 -381
- package/dist/index-DBMI2EcB.cjs +0 -170
- package/dist/index-DBRUKV0U.mjs +0 -225
- package/dist/index-DHRqE92a.cjs +0 -290
- package/dist/index-DJ3ndv3i.mjs +0 -705
- package/dist/index-DJXP-Gmp.js +0 -218
- package/dist/index-DJlXDQOY.cjs +0 -200
- package/dist/index-DLW4GEJl.cjs +0 -229
- package/dist/index-DM4ddIL6.js +0 -382
- package/dist/index-DN-ScBql.mjs +0 -458
- package/dist/index-DS86eFsI.mjs +0 -1835
- package/dist/index-DZws2w4w.cjs +0 -229
- package/dist/index-Dbb-jnWf.js +0 -206
- package/dist/index-DdXy_-T9.js +0 -444
- package/dist/index-DiDq1sL6.cjs +0 -240
- package/dist/index-DiuJQ9Mq.js +0 -198
- package/dist/index-Dk0q-ENv.mjs +0 -166
- package/dist/index-DlFElztE.mjs +0 -163
- package/dist/index-DlkxQ-B5.mjs +0 -359
- package/dist/index-Du5MxO_2.mjs +0 -505
- package/dist/index-DxHMqS-W.js +0 -117
- package/dist/index-DyTApTHI.cjs +0 -282
- package/dist/index-DzAewrkw.js +0 -238
- package/dist/index-EuKHpnHv.mjs +0 -117
- package/dist/index-FP6hvgSw.cjs +0 -552
- package/dist/index-GDSrKnPp.mjs +0 -198
- package/dist/index-GMCZo-KH.js +0 -222
- package/dist/index-IawHHRZX.mjs +0 -206
- package/dist/index-Jk7MG7tE.cjs +0 -286
- package/dist/index-KAC20a9r.js +0 -359
- package/dist/index-Ls2fI7y4.js +0 -163
- package/dist/index-NIEZaRYg.cjs +0 -261
- package/dist/index-PyaLRKuk.mjs +0 -168
- package/dist/index-QXYDkAsQ.cjs +0 -119
- package/dist/index-SmEIf5jz.mjs +0 -259
- package/dist/index-UVyXzNlG.js +0 -705
- package/dist/index-VvuhRvnC.mjs +0 -218
- package/dist/index-XZiO6uje.cjs +0 -275
- package/dist/index-YOlsBREZ.cjs +0 -230
- package/dist/index-_2dg_MWu.cjs +0 -460
- package/dist/index-eFEW10em.js +0 -213
- package/dist/index-f7FiDQMk.js +0 -171
- package/dist/index-fdDnq3vQ.js +0 -163
- package/dist/index-l8e8ip4U.js +0 -168
- package/dist/index-rn-_7-wp.cjs +0 -196
- package/dist/index-s27DHpTG.js +0 -1835
- package/dist/index-sbc7nDv3.js +0 -213
- package/dist/index-vHngHSlz.js +0 -280
- package/dist/testkit-C920qivh.js +0 -281
- package/dist/testkit-C920qivh.mjs +0 -281
- package/dist/testkit-D0rTQ6MD.cjs +0 -286
package/src/cli.ts
ADDED
|
@@ -0,0 +1,700 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
process.removeAllListeners("warning");
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
writeFileSync,
|
|
7
|
+
createWriteStream,
|
|
8
|
+
mkdirSync,
|
|
9
|
+
existsSync,
|
|
10
|
+
readFileSync,
|
|
11
|
+
} from "node:fs";
|
|
12
|
+
import retry from "async-retry";
|
|
13
|
+
import yargs from "yargs";
|
|
14
|
+
import waitOn from "wait-on";
|
|
15
|
+
import getPort from "get-port";
|
|
16
|
+
import detectPort from "detect-port";
|
|
17
|
+
import { spawn } from "node:child_process";
|
|
18
|
+
import { hideBin } from "yargs/helpers";
|
|
19
|
+
import { run } from "node:test";
|
|
20
|
+
import { junit, tap } from "node:test/reporters";
|
|
21
|
+
import { styleText } from "node:util";
|
|
22
|
+
import { killPortProcess } from "kill-port-process";
|
|
23
|
+
import { dirname, extname, join } from "node:path";
|
|
24
|
+
import { fileURLToPath } from "node:url";
|
|
25
|
+
import { serve } from "./index.js";
|
|
26
|
+
|
|
27
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
28
|
+
const ext = extname(fileURLToPath(import.meta.url));
|
|
29
|
+
|
|
30
|
+
const defaultPort = 4200;
|
|
31
|
+
|
|
32
|
+
function readPort(address: string) {
|
|
33
|
+
return parseInt(new URL(address).port, 10);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function resolvePath(
|
|
37
|
+
argv: {
|
|
38
|
+
cwd: string;
|
|
39
|
+
},
|
|
40
|
+
path: string,
|
|
41
|
+
) {
|
|
42
|
+
if (path.startsWith("/")) {
|
|
43
|
+
return path;
|
|
44
|
+
}
|
|
45
|
+
return join(argv.cwd, path);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
yargs(hideBin(process.argv))
|
|
49
|
+
.scriptName("graphql-federation-audit")
|
|
50
|
+
.epilogue(
|
|
51
|
+
"for more information, find our manual at https://github.com/the-guild-org/federation-compatibility",
|
|
52
|
+
)
|
|
53
|
+
.version(readVersion() ?? "local")
|
|
54
|
+
.recommendCommands()
|
|
55
|
+
.option("cwd", {
|
|
56
|
+
describe: "Change the current working directory",
|
|
57
|
+
type: "string",
|
|
58
|
+
default: process.cwd(),
|
|
59
|
+
})
|
|
60
|
+
.command(
|
|
61
|
+
"serve",
|
|
62
|
+
"start the server",
|
|
63
|
+
(yargs) => {
|
|
64
|
+
return yargs.option("port", {
|
|
65
|
+
describe: "port to bind on",
|
|
66
|
+
default: defaultPort,
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
async (argv) => {
|
|
70
|
+
await serve(argv.port);
|
|
71
|
+
console.log("Server started on port", argv.port);
|
|
72
|
+
},
|
|
73
|
+
)
|
|
74
|
+
.command(
|
|
75
|
+
"supergraph",
|
|
76
|
+
"fetch a supergraph.graphql for a test group",
|
|
77
|
+
(yargs) => {
|
|
78
|
+
return yargs
|
|
79
|
+
.option("test", {
|
|
80
|
+
describe: "test group id",
|
|
81
|
+
type: "string",
|
|
82
|
+
})
|
|
83
|
+
.option("port", {
|
|
84
|
+
describe: "port to bind on",
|
|
85
|
+
default: defaultPort,
|
|
86
|
+
})
|
|
87
|
+
.demandOption("test");
|
|
88
|
+
},
|
|
89
|
+
async (argv) => {
|
|
90
|
+
const res = await fetch(
|
|
91
|
+
`http://localhost:${argv.port}/${argv.test}/supergraph`,
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
if (!res.ok) {
|
|
95
|
+
process.stderr.write("Failed to fetch supergraph");
|
|
96
|
+
process.stderr.write(`HTTP ${res.status} ${res.statusText}`);
|
|
97
|
+
process.stderr.write('Body: "' + (await res.text()) + '"');
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
writeFileSync(resolvePath(argv, "supergraph.graphql"), await res.text());
|
|
102
|
+
process.exit(0);
|
|
103
|
+
},
|
|
104
|
+
)
|
|
105
|
+
.command(
|
|
106
|
+
"subgraphs",
|
|
107
|
+
"fetch a subgraphs.json for a test group",
|
|
108
|
+
(yargs) => {
|
|
109
|
+
return yargs
|
|
110
|
+
.option("test", {
|
|
111
|
+
describe: "test group id",
|
|
112
|
+
type: "string",
|
|
113
|
+
})
|
|
114
|
+
.option("port", {
|
|
115
|
+
describe: "port to bind on",
|
|
116
|
+
default: defaultPort,
|
|
117
|
+
})
|
|
118
|
+
.demandOption("test");
|
|
119
|
+
},
|
|
120
|
+
async (argv) => {
|
|
121
|
+
const endpoint = `http://localhost:${argv.port}/${argv.test}/subgraphs`;
|
|
122
|
+
const res = await fetch(endpoint, {
|
|
123
|
+
headers: {
|
|
124
|
+
accept: "application/json",
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
if (!res.ok) {
|
|
129
|
+
process.stderr.write("Failed to fetch subgraphs: " + endpoint);
|
|
130
|
+
process.stderr.write(`HTTP ${res.status} ${res.statusText}`);
|
|
131
|
+
process.stderr.write('Body: "' + (await res.text()) + '"');
|
|
132
|
+
process.exit(1);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
writeFileSync(resolvePath(argv, "subgraphs.json"), await res.text());
|
|
136
|
+
process.exit(0);
|
|
137
|
+
},
|
|
138
|
+
)
|
|
139
|
+
.command(
|
|
140
|
+
"start",
|
|
141
|
+
"start a gateway for a requested test group",
|
|
142
|
+
(yargs) => {
|
|
143
|
+
return yargs
|
|
144
|
+
.option("test", {
|
|
145
|
+
describe: "Test group id",
|
|
146
|
+
type: "string",
|
|
147
|
+
})
|
|
148
|
+
.option("run-script", {
|
|
149
|
+
describe: "Path to a bash script to run before each test",
|
|
150
|
+
type: "string",
|
|
151
|
+
})
|
|
152
|
+
.option("graphql", {
|
|
153
|
+
describe: "GraphQL endpoint serving the supergraph",
|
|
154
|
+
type: "string",
|
|
155
|
+
})
|
|
156
|
+
.option("healthcheck", {
|
|
157
|
+
describe: "Health check endpoint",
|
|
158
|
+
type: "string",
|
|
159
|
+
})
|
|
160
|
+
.option("port", {
|
|
161
|
+
describe: "Port to bind on",
|
|
162
|
+
default: defaultPort,
|
|
163
|
+
})
|
|
164
|
+
.demandOption("test")
|
|
165
|
+
.demandOption("graphql")
|
|
166
|
+
.demandOption("healthcheck")
|
|
167
|
+
.demandOption("run-script");
|
|
168
|
+
},
|
|
169
|
+
async (argv) => {
|
|
170
|
+
const abortSignal = new AbortController();
|
|
171
|
+
process.once("SIGINT", () => {
|
|
172
|
+
if (!abortSignal.signal.aborted) {
|
|
173
|
+
abortSignal.abort();
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
process.once("SIGTERM", () => {
|
|
177
|
+
if (!abortSignal.signal.aborted) {
|
|
178
|
+
abortSignal.abort();
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
const port = argv.port ?? (await getPort());
|
|
183
|
+
await serve(port);
|
|
184
|
+
|
|
185
|
+
process.stdout.write("\n");
|
|
186
|
+
|
|
187
|
+
await killPortIfRunning(readPort(argv.graphql)).catch(() => {});
|
|
188
|
+
|
|
189
|
+
const gatewayExit = Promise.withResolvers<void>();
|
|
190
|
+
let gatewayExited = false;
|
|
191
|
+
const gateway = spawn("sh", [argv.runScript, argv.test], {
|
|
192
|
+
signal: abortSignal.signal,
|
|
193
|
+
stdio: "inherit",
|
|
194
|
+
cwd: dirname(resolvePath(argv, argv.runScript)),
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
gateway.on("error", (err) => {
|
|
198
|
+
if (err.message.includes("aborted")) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
process.stderr.write(err.message);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
gateway.once("exit", () => {
|
|
206
|
+
gatewayExited = true;
|
|
207
|
+
gatewayExit.resolve();
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
await gatewayExit.promise;
|
|
211
|
+
},
|
|
212
|
+
)
|
|
213
|
+
.command(
|
|
214
|
+
"test-suite",
|
|
215
|
+
"run a test group",
|
|
216
|
+
(yargs) => {
|
|
217
|
+
return yargs
|
|
218
|
+
.option("test", {
|
|
219
|
+
describe: "Test group id",
|
|
220
|
+
type: "string",
|
|
221
|
+
})
|
|
222
|
+
.option("run-script", {
|
|
223
|
+
describe: "Path to a bash script to run before each test",
|
|
224
|
+
type: "string",
|
|
225
|
+
})
|
|
226
|
+
.option("graphql", {
|
|
227
|
+
describe: "GraphQL endpoint serving the supergraph",
|
|
228
|
+
type: "string",
|
|
229
|
+
})
|
|
230
|
+
.option("healthcheck", {
|
|
231
|
+
describe: "Health check endpoint",
|
|
232
|
+
type: "string",
|
|
233
|
+
})
|
|
234
|
+
.option("port", {
|
|
235
|
+
describe: "Port to bind on",
|
|
236
|
+
default: defaultPort,
|
|
237
|
+
})
|
|
238
|
+
.option("no-server", {
|
|
239
|
+
describe: "Skip starting the server",
|
|
240
|
+
type: "boolean",
|
|
241
|
+
default: false,
|
|
242
|
+
})
|
|
243
|
+
.option("reporter", {
|
|
244
|
+
describe: "Choose a reporter",
|
|
245
|
+
choices: ["dot", "tap"],
|
|
246
|
+
default: "tap",
|
|
247
|
+
})
|
|
248
|
+
.option("junit", {
|
|
249
|
+
describe: "Write test results to a JUnit XML file",
|
|
250
|
+
type: "boolean",
|
|
251
|
+
})
|
|
252
|
+
.demandOption("test")
|
|
253
|
+
.demandOption("graphql")
|
|
254
|
+
.demandOption("healthcheck")
|
|
255
|
+
.demandOption("run-script");
|
|
256
|
+
},
|
|
257
|
+
async (argv) => {
|
|
258
|
+
const abortSignal = new AbortController();
|
|
259
|
+
process.once("SIGINT", () => {
|
|
260
|
+
if (!abortSignal.signal.aborted) {
|
|
261
|
+
abortSignal.abort();
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
process.once("SIGTERM", () => {
|
|
265
|
+
if (!abortSignal.signal.aborted) {
|
|
266
|
+
abortSignal.abort();
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
const port = argv.port ?? (await getPort());
|
|
271
|
+
if (!argv["no-server"]) {
|
|
272
|
+
await serve(port);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
process.stdout.write("\n");
|
|
276
|
+
|
|
277
|
+
if (!existsSync(resolvePath(argv, "./logs"))) {
|
|
278
|
+
mkdirSync(resolvePath(argv, "./logs"));
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
await killPortIfRunning(readPort(argv.graphql)).catch(() => {});
|
|
282
|
+
const logStream = createWriteStream(
|
|
283
|
+
resolvePath(argv, `./logs/${argv.test}-gateway.log`),
|
|
284
|
+
{
|
|
285
|
+
flags: "w+",
|
|
286
|
+
},
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
const gatewayExit = Promise.withResolvers<void>();
|
|
290
|
+
let gatewayExited = false;
|
|
291
|
+
const gateway = spawn("sh", [argv.runScript, argv.test], {
|
|
292
|
+
signal: abortSignal.signal,
|
|
293
|
+
stdio: "pipe",
|
|
294
|
+
cwd: dirname(resolvePath(argv, argv.runScript)),
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
gateway.once("exit", () => {
|
|
298
|
+
gatewayExited = true;
|
|
299
|
+
gatewayExit.resolve();
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
gateway.stdout.pipe(logStream);
|
|
303
|
+
gateway.stderr.pipe(logStream);
|
|
304
|
+
|
|
305
|
+
const result = await runTest({
|
|
306
|
+
...argv,
|
|
307
|
+
reporter: argv.reporter === "tap" ? "tap" : "dot",
|
|
308
|
+
junit: argv.junit,
|
|
309
|
+
port,
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
if (!gatewayExited) {
|
|
313
|
+
gateway.kill();
|
|
314
|
+
}
|
|
315
|
+
await gatewayExit.promise;
|
|
316
|
+
process.stdout.write("\n");
|
|
317
|
+
|
|
318
|
+
if (result.includes("X")) {
|
|
319
|
+
process.exit(1);
|
|
320
|
+
} else {
|
|
321
|
+
process.exit(0);
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
)
|
|
325
|
+
.command(
|
|
326
|
+
"test",
|
|
327
|
+
"run all test groups in a sequence",
|
|
328
|
+
(yargs) => {
|
|
329
|
+
return yargs
|
|
330
|
+
.option("run-script", {
|
|
331
|
+
describe: "Path to a bash script to run before each test",
|
|
332
|
+
type: "string",
|
|
333
|
+
})
|
|
334
|
+
.option("no-server", {
|
|
335
|
+
describe: "Skip starting the server",
|
|
336
|
+
type: "boolean",
|
|
337
|
+
default: false,
|
|
338
|
+
})
|
|
339
|
+
.option("graphql", {
|
|
340
|
+
describe: "GraphQL endpoint serving the supergraph",
|
|
341
|
+
type: "string",
|
|
342
|
+
})
|
|
343
|
+
.option("healthcheck", {
|
|
344
|
+
describe: "Health check endpoint",
|
|
345
|
+
type: "string",
|
|
346
|
+
})
|
|
347
|
+
.option("port", {
|
|
348
|
+
describe: "Port to bind on",
|
|
349
|
+
default: defaultPort,
|
|
350
|
+
})
|
|
351
|
+
.option("reporter", {
|
|
352
|
+
describe: "Choose a reporter",
|
|
353
|
+
choices: ["dot", "tap"],
|
|
354
|
+
default: "dot",
|
|
355
|
+
})
|
|
356
|
+
.option("junit", {
|
|
357
|
+
describe: "Write test results to a JUnit XML file",
|
|
358
|
+
type: "boolean",
|
|
359
|
+
})
|
|
360
|
+
.option("write", {
|
|
361
|
+
describe: "Write test results to a file",
|
|
362
|
+
type: "string",
|
|
363
|
+
default: "results.txt",
|
|
364
|
+
})
|
|
365
|
+
.option("exit-on-fail", {
|
|
366
|
+
describe: "Exit with status 1 if any test fails",
|
|
367
|
+
type: "boolean",
|
|
368
|
+
default: false,
|
|
369
|
+
})
|
|
370
|
+
.demandOption("graphql")
|
|
371
|
+
.demandOption("healthcheck")
|
|
372
|
+
.demandOption("run-script");
|
|
373
|
+
},
|
|
374
|
+
async (argv) => {
|
|
375
|
+
const abortSignal = new AbortController();
|
|
376
|
+
process.once("SIGINT", () => {
|
|
377
|
+
if (!abortSignal.signal.aborted) {
|
|
378
|
+
abortSignal.abort();
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
process.once("SIGTERM", () => {
|
|
382
|
+
if (!abortSignal.signal.aborted) {
|
|
383
|
+
abortSignal.abort();
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
const port = argv.port ?? (await getPort());
|
|
388
|
+
|
|
389
|
+
if (!argv["no-server"]) {
|
|
390
|
+
await serve(port);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
const ids = await fetch(`http://localhost:${port}/ids`, {
|
|
394
|
+
signal: abortSignal.signal,
|
|
395
|
+
}).then((res) => res.json() as Promise<string[]>);
|
|
396
|
+
|
|
397
|
+
const results: Array<{
|
|
398
|
+
id: string;
|
|
399
|
+
result: Array<"." | "X">;
|
|
400
|
+
}> = [];
|
|
401
|
+
|
|
402
|
+
process.stdout.write("Running " + ids.length + " test suites\n");
|
|
403
|
+
|
|
404
|
+
if (!existsSync(resolvePath(argv, "./logs"))) {
|
|
405
|
+
mkdirSync(resolvePath(argv, "./logs"));
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
process.stdout.write("\n");
|
|
409
|
+
for await (const id of ids) {
|
|
410
|
+
await killPortIfRunning(readPort(argv.graphql)).catch(() => {});
|
|
411
|
+
const logStream = createWriteStream(
|
|
412
|
+
resolvePath(argv, `./logs/${id}-gateway.log`),
|
|
413
|
+
{
|
|
414
|
+
flags: "w+",
|
|
415
|
+
},
|
|
416
|
+
);
|
|
417
|
+
|
|
418
|
+
const gatewayExit = Promise.withResolvers<void>();
|
|
419
|
+
let gatewayExited = false;
|
|
420
|
+
const gateway = spawn("sh", [argv.runScript, id], {
|
|
421
|
+
signal: abortSignal.signal,
|
|
422
|
+
stdio: "pipe",
|
|
423
|
+
cwd: dirname(resolvePath(argv, argv.runScript)),
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
gateway.once("exit", () => {
|
|
427
|
+
gatewayExited = true;
|
|
428
|
+
gatewayExit.resolve();
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
gateway.stdout.pipe(logStream);
|
|
432
|
+
gateway.stderr.pipe(logStream);
|
|
433
|
+
|
|
434
|
+
const result = await runTest({
|
|
435
|
+
test: id,
|
|
436
|
+
graphql: argv.graphql,
|
|
437
|
+
healthcheck: argv.healthcheck,
|
|
438
|
+
port: argv.port,
|
|
439
|
+
reporter: argv.reporter === "tap" ? "tap" : "dot",
|
|
440
|
+
junit: argv.junit,
|
|
441
|
+
cwd: argv.cwd,
|
|
442
|
+
});
|
|
443
|
+
results.push({ id, result });
|
|
444
|
+
|
|
445
|
+
if (!gatewayExited) {
|
|
446
|
+
gateway.kill();
|
|
447
|
+
}
|
|
448
|
+
await gatewayExit.promise;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
let total = 0;
|
|
452
|
+
let passed = 0;
|
|
453
|
+
let failed = 0;
|
|
454
|
+
for (const { result } of results) {
|
|
455
|
+
for (const test of result) {
|
|
456
|
+
if (test === ".") {
|
|
457
|
+
total++;
|
|
458
|
+
passed++;
|
|
459
|
+
} else if (test === "X") {
|
|
460
|
+
total++;
|
|
461
|
+
failed++;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
process.stdout.write("\n\n\n");
|
|
467
|
+
|
|
468
|
+
process.stdout.write(styleText("bold", "Results") + "\n");
|
|
469
|
+
process.stdout.write("-----------\n");
|
|
470
|
+
process.stdout.write(`Total: ${total}\n`);
|
|
471
|
+
process.stdout.write(
|
|
472
|
+
`Passed: ${styleText("greenBright", passed + "")}\n`,
|
|
473
|
+
);
|
|
474
|
+
if (failed > 0) {
|
|
475
|
+
process.stdout.write(
|
|
476
|
+
`Failed: ${styleText("redBright", failed + "")}\n`,
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
process.stdout.write("\n");
|
|
480
|
+
|
|
481
|
+
if (failed > 0) {
|
|
482
|
+
process.stdout.write(
|
|
483
|
+
styleText("redBright", "Your gateway is not fully compatible\n"),
|
|
484
|
+
);
|
|
485
|
+
} else {
|
|
486
|
+
process.stdout.write(
|
|
487
|
+
styleText("greenBright", "Your gateway is fully compatible\n"),
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
writeFileSync(
|
|
492
|
+
resolvePath(argv, argv.write),
|
|
493
|
+
results
|
|
494
|
+
.flatMap((r) => [r.id, r.result.join("")])
|
|
495
|
+
.concat([
|
|
496
|
+
"",
|
|
497
|
+
"---",
|
|
498
|
+
`Total: ${total}`,
|
|
499
|
+
`Passed: ${passed}`,
|
|
500
|
+
`Failed: ${failed}`,
|
|
501
|
+
])
|
|
502
|
+
.join("\n"),
|
|
503
|
+
);
|
|
504
|
+
|
|
505
|
+
if (argv["exit-on-fail"] && failed > 0) {
|
|
506
|
+
process.exit(1);
|
|
507
|
+
}
|
|
508
|
+
process.exit(0);
|
|
509
|
+
},
|
|
510
|
+
)
|
|
511
|
+
.demandCommand(1)
|
|
512
|
+
.parse();
|
|
513
|
+
|
|
514
|
+
async function runTest(args: {
|
|
515
|
+
test: string;
|
|
516
|
+
graphql: string;
|
|
517
|
+
healthcheck?: string;
|
|
518
|
+
port: number;
|
|
519
|
+
reporter?: "dot" | "tap";
|
|
520
|
+
junit?: boolean;
|
|
521
|
+
cwd: string;
|
|
522
|
+
}): Promise<Array<"." | "X">> {
|
|
523
|
+
process.stdout.write(`${args.test}\n`);
|
|
524
|
+
process.env.TESTS_ENDPOINT = `http://localhost:${args.port}/${args.test}/tests`;
|
|
525
|
+
process.env.GRAPHQL_ENDPOINT = args.graphql;
|
|
526
|
+
process.env.TEST_SUITE = args.test;
|
|
527
|
+
|
|
528
|
+
const logStream = createWriteStream(
|
|
529
|
+
resolvePath({ cwd: args.cwd }, `./logs/${args.test}-tests.log`),
|
|
530
|
+
{
|
|
531
|
+
flags: "w+",
|
|
532
|
+
},
|
|
533
|
+
);
|
|
534
|
+
|
|
535
|
+
if (args.healthcheck) {
|
|
536
|
+
try {
|
|
537
|
+
await waitOnGraphQL({
|
|
538
|
+
healthcheck: args.healthcheck,
|
|
539
|
+
graphql: args.graphql,
|
|
540
|
+
});
|
|
541
|
+
} catch (err) {
|
|
542
|
+
logStream.write("\nHealth check failed\n");
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
const { resolve, promise } = Promise.withResolvers<Array<"." | "X">>();
|
|
547
|
+
const dotan = createDotReporter(resolve);
|
|
548
|
+
|
|
549
|
+
const testStream = run({
|
|
550
|
+
concurrency: 1,
|
|
551
|
+
files: [join(__dirname, `test${ext}`)],
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
testStream.compose(args.reporter === "tap" ? tap : dot).pipe(process.stdout);
|
|
555
|
+
testStream.compose(tap).pipe(logStream);
|
|
556
|
+
testStream.compose(dotan);
|
|
557
|
+
|
|
558
|
+
if (args.junit) {
|
|
559
|
+
const reportsDir = resolvePath({ cwd: args.cwd }, "reports");
|
|
560
|
+
if (!existsSync(reportsDir)) {
|
|
561
|
+
mkdirSync(reportsDir, { recursive: true });
|
|
562
|
+
}
|
|
563
|
+
const junitPath = join(reportsDir, `${args.test}.xml`);
|
|
564
|
+
const junitStream = createWriteStream(junitPath, {
|
|
565
|
+
flags: "w+",
|
|
566
|
+
});
|
|
567
|
+
testStream.compose(junit).pipe(junitStream);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
return promise;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
function createDotReporter(resolve: (value: Array<"." | "X">) => void) {
|
|
574
|
+
const report: Array<"." | "X"> = [];
|
|
575
|
+
return async function* dot(source: Parameters<typeof tap>[0]) {
|
|
576
|
+
for await (const { type, data } of source) {
|
|
577
|
+
if (data != null && "details" in data && data.details?.type === "suite") {
|
|
578
|
+
continue;
|
|
579
|
+
}
|
|
580
|
+
if (type === "test:pass") {
|
|
581
|
+
report.push(".");
|
|
582
|
+
}
|
|
583
|
+
if (type === "test:fail") {
|
|
584
|
+
report.push("X");
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
resolve(report);
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
async function* dot(source: Parameters<typeof tap>[0]) {
|
|
592
|
+
let count = 0;
|
|
593
|
+
let columns = getLineLength();
|
|
594
|
+
const failedTests = [];
|
|
595
|
+
for await (const { type, data } of source) {
|
|
596
|
+
if (data != null && "details" in data && data.details?.type === "suite") {
|
|
597
|
+
continue;
|
|
598
|
+
}
|
|
599
|
+
if (type === "test:pass") {
|
|
600
|
+
yield styleText("green", ".");
|
|
601
|
+
}
|
|
602
|
+
if (type === "test:fail") {
|
|
603
|
+
yield styleText("red", "X");
|
|
604
|
+
failedTests.push(data);
|
|
605
|
+
}
|
|
606
|
+
if ((type === "test:fail" || type === "test:pass") && ++count === columns) {
|
|
607
|
+
yield "\n";
|
|
608
|
+
// Getting again in case the terminal was resized.
|
|
609
|
+
columns = getLineLength();
|
|
610
|
+
count = 0;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
yield "\n";
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
function getLineLength() {
|
|
617
|
+
return Math.max(process.stdout.columns ?? 20, 20);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
function readVersion(): string | undefined {
|
|
621
|
+
try {
|
|
622
|
+
// src/cli.ts
|
|
623
|
+
return (
|
|
624
|
+
"v" +
|
|
625
|
+
JSON.parse(readFileSync(join(__dirname, "../package.json"), "utf-8"))
|
|
626
|
+
.version
|
|
627
|
+
);
|
|
628
|
+
} catch {
|
|
629
|
+
//
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
try {
|
|
633
|
+
// dist/cli.js
|
|
634
|
+
return (
|
|
635
|
+
"v" +
|
|
636
|
+
JSON.parse(readFileSync(join(__dirname, "./package.json"), "utf-8"))
|
|
637
|
+
.version
|
|
638
|
+
);
|
|
639
|
+
} catch {
|
|
640
|
+
//
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
async function waitOnGraphQL(endpoints: {
|
|
645
|
+
healthcheck: string;
|
|
646
|
+
graphql: string;
|
|
647
|
+
}) {
|
|
648
|
+
const timeout = process.env["GATEWAY_TIMEOUT"]
|
|
649
|
+
? parseInt(process.env["GATEWAY_TIMEOUT"])
|
|
650
|
+
: 5000;
|
|
651
|
+
await waitOn({
|
|
652
|
+
// Make sure the health check is a GET request
|
|
653
|
+
resources: [endpoints.healthcheck.replace("http://", "http-get://")],
|
|
654
|
+
timeout,
|
|
655
|
+
httpTimeout: 200,
|
|
656
|
+
log: false,
|
|
657
|
+
verbose: false,
|
|
658
|
+
});
|
|
659
|
+
|
|
660
|
+
await retry(fetchTypename, {
|
|
661
|
+
maxRetryTime: 2_000,
|
|
662
|
+
retries: 20,
|
|
663
|
+
maxTimeout: 500,
|
|
664
|
+
minTimeout: 100,
|
|
665
|
+
});
|
|
666
|
+
|
|
667
|
+
async function fetchTypename() {
|
|
668
|
+
const response = await fetch(endpoints.graphql, {
|
|
669
|
+
method: "POST",
|
|
670
|
+
headers: {
|
|
671
|
+
"Content-Type": "application/json",
|
|
672
|
+
accept: "application/json",
|
|
673
|
+
},
|
|
674
|
+
body: JSON.stringify({
|
|
675
|
+
operationName: "ping",
|
|
676
|
+
query: /* GraphQL */ `
|
|
677
|
+
query ping {
|
|
678
|
+
__typename
|
|
679
|
+
}
|
|
680
|
+
`,
|
|
681
|
+
}),
|
|
682
|
+
});
|
|
683
|
+
|
|
684
|
+
if (response.ok) {
|
|
685
|
+
const json = await response.json();
|
|
686
|
+
|
|
687
|
+
if (json.data.__typename === "Query") {
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
throw new Error("Failed to fetch __typename");
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
async function killPortIfRunning(port: number) {
|
|
697
|
+
if (await detectPort(port)) {
|
|
698
|
+
await killPortProcess(port);
|
|
699
|
+
}
|
|
700
|
+
}
|
package/src/env.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
let env_loaded = false;
|
|
2
|
+
|
|
3
|
+
export function shouldPunishForPoorPlans() {
|
|
4
|
+
if (!env_loaded) {
|
|
5
|
+
try {
|
|
6
|
+
process.loadEnvFile();
|
|
7
|
+
} catch (e) {
|
|
8
|
+
// Ignore if `.env` is not available
|
|
9
|
+
}
|
|
10
|
+
env_loaded = true;
|
|
11
|
+
}
|
|
12
|
+
return process.env.PUNISH_FOR_POOR_PLANS === "1";
|
|
13
|
+
}
|