From 00cd26dbd7cdf1eed667aba84f767d377fb39edf Mon Sep 17 00:00:00 2001 From: David Nalchevanidze Date: Sun, 21 Apr 2024 23:26:48 +0200 Subject: [PATCH] setup-examples (#858) --- examples/client/package.yaml | 23 +++--- examples/code-gen-docs/package.yaml | 20 +++-- examples/code-gen/package.yaml | 20 +++-- examples/scotty-fraxl/package.yaml | 22 +++--- examples/scotty-freer-simple/package.yaml | 24 +++--- examples/scotty-haxl/package.yaml | 24 +++--- examples/scotty/package.yaml | 36 +++++---- examples/servant/package.yaml | 30 ++++---- examples/yesod-pubsub/package.yaml | 89 ++++++++++------------ scripts/lib/check-packages/dependencies.ts | 8 +- scripts/lib/check-packages/index.ts | 30 ++++++-- scripts/lib/check-packages/types.ts | 1 + 12 files changed, 166 insertions(+), 161 deletions(-) diff --git a/examples/client/package.yaml b/examples/client/package.yaml index 6573ca0ebc..b2fd4439a8 100644 --- a/examples/client/package.yaml +++ b/examples/client/package.yaml @@ -1,27 +1,24 @@ name: morpheus-graphql-examples-client -version: 0.1.0 -github: "nalchevanidze/morpheus-graphql" +version: 0.27.3 +github: nalchevanidze/morpheus-graphql license: MIT -author: "Daviti Nalchevanidze" +author: Daviti Nalchevanidze category: web, graphql synopsis: examples -copyright: "(c) 2019 Daviti Nalchevanidze" +copyright: (c) 2019 Daviti Nalchevanidze description: examples of GraphQL APIs - dependencies: - - base >= 4.7 && < 5 - - bytestring >= 0.10.4 - - text >= 1.2.3.0 + - base >= 4.7.0 && < 5.0.0 + - bytestring >= 0.10.4 && < 0.15.0 + - file-embed >= 0.0.10 && < 1.0.0 - morpheus-graphql-client - - req >= 2.1.0 - - file-embed - + - req >= 3.0.0 && < 4.0.0 + - text >= 1.2.3 && < 3.0.0 data-files: - assets/**/*.gql - assets/**/*.json - executables: morpheus-client-example: main: Main.hs source-dirs: src - ghc-options: -Wall + ghc-options: '-Wall' diff --git a/examples/code-gen-docs/package.yaml b/examples/code-gen-docs/package.yaml index 3aa675b5b4..cebed4e56f 100644 --- a/examples/code-gen-docs/package.yaml +++ b/examples/code-gen-docs/package.yaml @@ -1,25 +1,23 @@ name: morpheus-graphql-examples-code-gen-docs -version: 0.1.0 -github: "nalchevanidze/morpheus-graphql" +version: 0.27.3 +github: nalchevanidze/morpheus-graphql license: MIT -author: "Daviti Nalchevanidze" +author: Daviti Nalchevanidze category: web, graphql , code-gen synopsis: examples -copyright: "(c) 2019 Daviti Nalchevanidze" +copyright: (c) 2019 Daviti Nalchevanidze description: examples of GraphQL APIs - dependencies: - - base >= 4.7 && < 5 - - bytestring >= 0.10.4 - - text >= 1.2.3.0 + - base >= 4.7.0 && < 5.0.0 + - bytestring >= 0.10.4 && < 0.15.0 + - containers >= 0.4.2.1 && < 0.7.0 - morpheus-graphql - morpheus-graphql-server - morpheus-graphql-client - scotty - - containers >= 0.4.2.1 - + - text >= 1.2.3 && < 3.0.0 executables: code-gen-docs-server: main: Main.hs source-dirs: src - ghc-options: -Wall + ghc-options: '-Wall' diff --git a/examples/code-gen/package.yaml b/examples/code-gen/package.yaml index 49fc6e1e14..80fc4d4286 100644 --- a/examples/code-gen/package.yaml +++ b/examples/code-gen/package.yaml @@ -1,25 +1,23 @@ name: morpheus-graphql-examples-code-gen -version: 0.1.0 -github: "nalchevanidze/morpheus-graphql" +version: 0.27.3 +github: nalchevanidze/morpheus-graphql license: MIT -author: "Daviti Nalchevanidze" +author: Daviti Nalchevanidze category: web, graphql , code-gen synopsis: examples -copyright: "(c) 2019 Daviti Nalchevanidze" +copyright: (c) 2019 Daviti Nalchevanidze description: examples of GraphQL APIs - dependencies: - - base >= 4.7 && < 5 - - bytestring >= 0.10.4 - - text >= 1.2.3.0 + - base >= 4.7.0 && < 5.0.0 + - bytestring >= 0.10.4 && < 0.15.0 + - containers >= 0.4.2.1 && < 0.7.0 - morpheus-graphql - morpheus-graphql-server - morpheus-graphql-client - scotty - - containers >= 0.4.2.1 - + - text >= 1.2.3 && < 3.0.0 executables: generated-server: main: Main.hs source-dirs: src - ghc-options: -Wall + ghc-options: '-Wall' diff --git a/examples/scotty-fraxl/package.yaml b/examples/scotty-fraxl/package.yaml index 6013562c3c..b0d34f0d74 100644 --- a/examples/scotty-fraxl/package.yaml +++ b/examples/scotty-fraxl/package.yaml @@ -1,24 +1,22 @@ name: morpheus-graphql-examples-scotty-fraxl -version: 0.1.0 -github: "nalchevanidze/morpheus-graphql" +version: 0.27.3 +github: nalchevanidze/morpheus-graphql license: MIT -author: "Daviti Nalchevanidze" +author: Daviti Nalchevanidze category: web, graphql synopsis: examples -copyright: "(c) 2019 Daviti Nalchevanidze" +copyright: (c) 2019 Daviti Nalchevanidze description: Fraxl example of GraphQL APIs - dependencies: - - base >= 4.7 && < 5 - - mtl >= 2.0 - - text >= 1.2.3.0 - - containers >= 0.4.2.1 + - base >= 4.7.0 && < 5.0.0 + - containers >= 0.4.2.1 && < 0.7.0 + - fraxl + - mtl >= 2.0.0 && < 3.0.0 - morpheus-graphql - scotty - - fraxl - + - text >= 1.2.3 && < 3.0.0 executables: scotty-server-fraxl: main: Main.hs source-dirs: src - ghc-options: -Wall + ghc-options: '-Wall' diff --git a/examples/scotty-freer-simple/package.yaml b/examples/scotty-freer-simple/package.yaml index 7ab53e416e..a4834ddc48 100644 --- a/examples/scotty-freer-simple/package.yaml +++ b/examples/scotty-freer-simple/package.yaml @@ -1,26 +1,24 @@ name: morpheus-graphql-examples-scotty-freer -version: 0.1.0.0 -github: "githubuser/morpheus-graphql-examples-scotty-freer-simple" +version: 0.27.3 +github: githubuser/morpheus-graphql-examples-scotty-freer-simple license: BSD3 -author: "Author name here" -maintainer: "example@example.com" -copyright: "2021 Author name here" +author: Author name here +maintainer: example@example.com +copyright: 2021 Author name here description: example of graphql apis with scotty and freer-simple - dependencies: - - base >= 4.7 && < 5 - - bytestring - - file-embed + - base >= 4.7.0 && < 5.0.0 + - bytestring >= 0.10.4 && < 0.15.0 + - file-embed >= 0.0.10 && < 1.0.0 - freer-simple - morpheus-graphql - scotty - - text - - transformers + - text >= 1.2.3 && < 3.0.0 + - transformers >= 0.3.0 && < 0.7.0 - wai - warp - executables: scotty-freer-server: main: Main.hs source-dirs: src - ghc-options: -Wall + ghc-options: '-Wall' diff --git a/examples/scotty-haxl/package.yaml b/examples/scotty-haxl/package.yaml index c0e6a7308d..56f246ea92 100644 --- a/examples/scotty-haxl/package.yaml +++ b/examples/scotty-haxl/package.yaml @@ -1,26 +1,24 @@ name: morpheus-graphql-examples-scotty-haxl -version: 0.1.0 -github: "nalchevanidze/morpheus-graphql" +version: 0.27.3 +github: nalchevanidze/morpheus-graphql license: MIT -author: "Daviti Nalchevanidze" +author: Daviti Nalchevanidze category: web, graphql synopsis: examples -copyright: "(c) 2019 Daviti Nalchevanidze" +copyright: (c) 2019 Daviti Nalchevanidze description: examples of GraphQL APIs - dependencies: - - base >= 4.7 && < 5 - - mtl >= 2.0 - - text >= 1.2.3.0 - - containers >= 0.4.2.1 + - base >= 4.7.0 && < 5.0.0 + - containers >= 0.4.2.1 && < 0.7.0 + - haxl + - hashable >= 1.0.0 && < 2.0.0 + - mtl >= 2.0.0 && < 3.0.0 - morpheus-graphql - morpheus-graphql-app - scotty - - haxl - - hashable - + - text >= 1.2.3 && < 3.0.0 executables: scotty-server-haxl: main: Main.hs source-dirs: src - ghc-options: -Wall + ghc-options: '-Wall' diff --git a/examples/scotty/package.yaml b/examples/scotty/package.yaml index 12f05792f4..f36b4bb0b2 100644 --- a/examples/scotty/package.yaml +++ b/examples/scotty/package.yaml @@ -1,35 +1,33 @@ name: morpheus-graphql-examples-scotty -version: 0.1.0 -github: "nalchevanidze/morpheus-graphql" +version: 0.27.3 +github: nalchevanidze/morpheus-graphql license: MIT -author: "Daviti Nalchevanidze" +author: Daviti Nalchevanidze category: web, graphql synopsis: examples -copyright: "(c) 2019 Daviti Nalchevanidze" +copyright: (c) 2019 Daviti Nalchevanidze description: examples of GraphQL APIs - dependencies: - - base >= 4.7 && < 5 - - aeson >= 1.4.4.0 - - bytestring >= 0.10.4 - - text >= 1.2.3.0 - - containers >= 0.4.2.1 - - mtl >= 2.0 - - websockets >= 0.11.0 - - wai-websockets >= 1.0 + - aeson >= 1.4.4 && < 3.0.0 + - base >= 4.7.0 && < 5.0.0 + - bytestring >= 0.10.4 && < 0.15.0 + - containers >= 0.4.2.1 && < 0.7.0 + - extra + - http-types + - mtl >= 2.0.0 && < 3.0.0 - morpheus-graphql - morpheus-graphql-core - morpheus-graphql-app - morpheus-graphql-subscriptions - scotty - - warp - - transformers - - extra - - http-types - stm - + - text >= 1.2.3 && < 3.0.0 + - transformers >= 0.3.0 && < 0.7.0 + - websockets >= 0.12.6.0 && < 1.0.0 + - wai-websockets + - warp executables: scotty-server: main: Main.hs source-dirs: src - ghc-options: -Wall + ghc-options: '-Wall' diff --git a/examples/servant/package.yaml b/examples/servant/package.yaml index c9e717a653..c337d62a15 100644 --- a/examples/servant/package.yaml +++ b/examples/servant/package.yaml @@ -1,29 +1,27 @@ name: morpheus-graphql-examples-servant -version: 0.1.0 -github: "nalchevanidze/morpheus-graphql" +version: 0.27.3 +github: nalchevanidze/morpheus-graphql license: MIT -author: "Daviti Nalchevanidze" +author: Daviti Nalchevanidze category: web, graphql synopsis: examples -copyright: "(c) 2019 Daviti Nalchevanidze" +copyright: (c) 2019 Daviti Nalchevanidze description: examples of GraphQL APIs - dependencies: - - base >= 4.7 && < 5 - - bytestring >= 0.10.4 - - text >= 1.2.3 - - mtl >= 2.0 + - base >= 4.7.0 && < 5.0.0 + - bytestring >= 0.10.4 && < 0.15.0 + - file-embed >= 0.0.10 && < 1.0.0 + - http-media + - mtl >= 2.0.0 && < 3.0.0 - morpheus-graphql - morpheus-graphql-subscriptions - - wai-websockets >= 1.0 - - websockets >= 0.11.0 - - warp - servant-server - - http-media - - file-embed - + - text >= 1.2.3 && < 3.0.0 + - wai-websockets + - websockets >= 0.12.6.0 && < 1.0.0 + - warp executables: servant-server: main: Main.hs source-dirs: src - ghc-options: -Wall + ghc-options: '-Wall' diff --git a/examples/yesod-pubsub/package.yaml b/examples/yesod-pubsub/package.yaml index 8d7e176dea..2a4fecd114 100644 --- a/examples/yesod-pubsub/package.yaml +++ b/examples/yesod-pubsub/package.yaml @@ -1,62 +1,57 @@ -name: morpheus-graphql-examples-yesod-pubsub -version: 0.1.0.0 -github: "nalchevanidze/morpheus-graphql" -license: BSD3 -author: "Josh Brown" -copyright: "2021 ROPWARE" +name: morpheus-graphql-examples-yesod-pubsub +version: 0.27.3 +github: nalchevanidze/morpheus-graphql +license: BSD3 +author: Josh Brown +copyright: 2021 ROPWARE category: web, graphql synopsis: examples of external pub-sub description: examples of a GraphQL server using postgresql/rabbitmq as a pusub - extra-source-files: -- README.md -- ChangeLog.md - + - ChangeLog.md + - README.md dependencies: -- base >= 4.7 && < 5 -- text -- extra -- hashable -- bytestring -- yesod -- yesod-core -- blaze-html -- shakespeare -- morpheus-graphql -- morpheus-graphql-server -- morpheus-graphql-core -- morpheus-graphql-subscriptions -- warp -- wai -- wai-cors -- wai-websockets -- websockets -- unliftio-core - + - base >= 4.7.0 && < 5.0.0 + - bytestring >= 0.10.4 && < 0.15.0 + - blaze-html + - extra + - hashable >= 1.0.0 && < 2.0.0 + - morpheus-graphql + - morpheus-graphql-server + - morpheus-graphql-core + - morpheus-graphql-subscriptions + - shakespeare + - text >= 1.2.3 && < 3.0.0 + - unliftio-core >= 0.0.1 && < 0.4.0 + - warp + - wai + - wai-cors + - wai-websockets + - websockets >= 0.12.6.0 && < 1.0.0 + - yesod + - yesod-core library: source-dirs: src - executables: yesod-gql-example: - main: Main.hs - source-dirs: app + main: Main.hs + source-dirs: app ghc-options: - - -threaded - - -rtsopts - - -Wdefault - - -Wwarn - - -Wmissing-fields - - -with-rtsopts=-N + - '-Wdefault' + - '-Wmissing-fields' + - '-Wwarn' + - '-rtsopts' + - '-threaded' + - '-with-rtsopts=-N' dependencies: - - morpheus-graphql-examples-yesod-pubsub - + - morpheus-graphql-examples-yesod-pubsub tests: yesod-gql-example-test: - main: Spec.hs - source-dirs: test + main: Spec.hs + source-dirs: test ghc-options: - - -threaded - - -rtsopts - - -with-rtsopts=-N + - '-rtsopts' + - '-threaded' + - '-with-rtsopts=-N' dependencies: - - morpheus-graphql-examples-yesod-pubsub + - morpheus-graphql-examples-yesod-pubsub diff --git a/scripts/lib/check-packages/dependencies.ts b/scripts/lib/check-packages/dependencies.ts index 951c21b0e7..a72311904a 100644 --- a/scripts/lib/check-packages/dependencies.ts +++ b/scripts/lib/check-packages/dependencies.ts @@ -1,3 +1,4 @@ +import { log } from "../utils/utils"; import { formatTable } from "./formating"; import { Config } from "./types"; @@ -13,7 +14,7 @@ const withRule = (name: string, [min, max]: [string, string]) => [ ]; const updateDependency = - ({ bounds, rules }: Config) => + ({ bounds, rules, allowUnknownLib }: Config) => ([name, ...args]: string[]): string[] => { if (name.startsWith(projectPefix)) { if (!args.length) { @@ -27,6 +28,11 @@ const updateDependency = return withRule(name, rule); } + if (allowUnknownLib) { + log(` - unknown dependency: ${name}\n`, "warning"); + return [name]; + } + throw new Error(`Unknown package: ${name}`); }; diff --git a/scripts/lib/check-packages/index.ts b/scripts/lib/check-packages/index.ts index 587fcaab80..bee2b9b177 100644 --- a/scripts/lib/check-packages/index.ts +++ b/scripts/lib/check-packages/index.ts @@ -5,11 +5,24 @@ import { getConfig, readYAML, writeConfig, writeYAML } from "../utils/file"; import { genVersion, parseVersion, VersionUpdate } from "../utils/version"; import { log } from "../utils/utils"; -const checkPackage = (config: Config) => async (name: string) => { - const url = path.join(name, "package.yaml"); +const checkPackage = async ( + config: Config, + isExample: boolean, + name: string +) => { + const url = path.join( + isExample ? path.join("examples", name) : name, + "package.yaml" + ); const pkg = await readYAML(url); - const fixedPackage = updateDeps(config, { ...pkg, version: config.version }); + const fixedPackage = updateDeps( + { ...config, allowUnknownLib: isExample }, + { + ...pkg, + version: config.version, + } + ); await writeYAML(url, fixedPackage); @@ -40,9 +53,16 @@ const updateConfig = async ({ export const checkPackages = async (change?: VersionUpdate) => { const config = await (change ? updateConfig(change) : getConfig()); - const versions = await Promise.all(config.packages.map(checkPackage(config))); + const examples = await Promise.all( + config.examples.map((name) => checkPackage(config, true, name)) + ); + + const libs = await Promise.all( + config.packages.map((name) => checkPackage(config, false, name)) + ); await writeConfig(config); log(` - package.yaml (v${config.version})\n`, "success"); - log(versions.join(""), "success"); + log(examples.join(""), "success"); + log(libs.join(""), "success"); }; diff --git a/scripts/lib/check-packages/types.ts b/scripts/lib/check-packages/types.ts index f5c28df1ad..f335734dd9 100644 --- a/scripts/lib/check-packages/types.ts +++ b/scripts/lib/check-packages/types.ts @@ -20,6 +20,7 @@ export type Config = { packages: PackageName[]; plan: Record; examples: string[]; + allowUnknownLib: boolean; }; export type Table = string[][];