From f11a8b4c3808d0f4d937a6e7884f52618c0eb079 Mon Sep 17 00:00:00 2001 From: Maxwell Brown Date: Mon, 16 Sep 2024 11:09:19 -0400 Subject: [PATCH 1/6] fix basic template --- packages/create-effect-app/src/Cli.ts | 7 +++++++ templates/basic/package.json | 11 +++++++---- templates/basic/vitest.config.ts | 3 +-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/create-effect-app/src/Cli.ts b/packages/create-effect-app/src/Cli.ts index d178b6a..5263fc5 100644 --- a/packages/create-effect-app/src/Cli.ts +++ b/packages/create-effect-app/src/Cli.ts @@ -315,6 +315,13 @@ function createTemplate(config: TemplateConfig) { if (config.projectType.withChangesets) { filesToCheck.push(path.join(config.projectName, ".changeset", "config.json")) } + if (config.projectType.template === "monorepo") { + filesToCheck.push(path.join(config.projectName, "packages", "cli", "package.json")) + filesToCheck.push(path.join(config.projectName, "packages", "domain", "package.json")) + filesToCheck.push(path.join(config.projectName, "packages", "server", "package.json")) + } else { + filesToCheck.push(path.join(config.projectName, "package.json")) + } yield* Effect.logInfo(AnsiDoc.cats([ AnsiDoc.hsep([ diff --git a/templates/basic/package.json b/templates/basic/package.json index 4003b50..2a46945 100644 --- a/templates/basic/package.json +++ b/templates/basic/package.json @@ -3,12 +3,16 @@ "version": "0.0.0", "type": "module", "packageManager": "pnpm@9.10.0", + "license": "MIT", + "description": "A basic Effect package", + "repository": { + "type": "git", + "url": "" + }, "publishConfig": { "access": "public", "directory": "dist" }, - "description": "A basic Effect package", - "license": "MIT", "scripts": { "codegen": "build-utils prepare-v2", "build": "pnpm build-esm && pnpm build-annotate && pnpm build-cjs && build-utils pack-v2", @@ -34,10 +38,9 @@ "@changesets/changelog-github": "^0.5.0", "@changesets/cli": "^2.27.8", "@effect/build-utils": "^0.7.7", - "@effect/docgen": "^0.4.4", - "@effect/dtslint": "^0.1.0", "@effect/eslint-plugin": "^0.2.0", "@effect/language-service": "^0.1.0", + "@effect/vitest": "latest", "@eslint/compat": "1.1.1", "@eslint/eslintrc": "3.1.0", "@eslint/js": "9.10.0", diff --git a/templates/basic/vitest.config.ts b/templates/basic/vitest.config.ts index d8c9907..80810e3 100644 --- a/templates/basic/vitest.config.ts +++ b/templates/basic/vitest.config.ts @@ -1,6 +1,5 @@ -/// import path from "path" -import { defineConfig } from "vite" +import { defineConfig } from "vitest/config" export default defineConfig({ plugins: [], From 6c93c44295c4cc399ef6f34aba611c354befb833 Mon Sep 17 00:00:00 2001 From: Maxwell Brown Date: Mon, 16 Sep 2024 11:18:22 -0400 Subject: [PATCH 2/6] fix cli template --- templates/cli/package.json | 10 ++++++++-- templates/cli/tsconfig.scripts.json | 14 ++++++++++---- templates/cli/vitest.config.ts | 3 +-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/templates/cli/package.json b/templates/cli/package.json index 113f13d..d8ce460 100644 --- a/templates/cli/package.json +++ b/templates/cli/package.json @@ -3,12 +3,16 @@ "version": "0.0.0", "type": "module", "packageManager": "pnpm@9.10.0", + "license": "MIT", + "description": "A basic Effect CLI application", + "repository": { + "type": "git", + "url": "" + }, "publishConfig": { "access": "public", "directory": "dist" }, - "description": "An Effect CLI application", - "license": "MIT", "scripts": { "build": "tsup && pnpm copy-package-json", "build:ts": "tsup", @@ -30,6 +34,7 @@ "@effect/language-service": "^0.1.0", "@effect/platform": "latest", "@effect/platform-node": "latest", + "@effect/vitest": "latest", "@eslint/compat": "1.1.1", "@eslint/eslintrc": "3.1.0", "@eslint/js": "9.10.0", @@ -45,6 +50,7 @@ "eslint-plugin-simple-import-sort": "^12.1.1", "eslint-plugin-sort-destructure-keys": "^2.0.0", "tsup": "^8.2.4", + "tsx": "^4.19.1", "typescript": "^5.6.2", "vitest": "^2.0.5" }, diff --git a/templates/cli/tsconfig.scripts.json b/templates/cli/tsconfig.scripts.json index 5fc1c35..fe382b9 100644 --- a/templates/cli/tsconfig.scripts.json +++ b/templates/cli/tsconfig.scripts.json @@ -1,11 +1,17 @@ - { "extends": "./tsconfig.base.json", - "include": ["scripts", "eslint.config.mjs", "tsup.config.ts", "vitest.config.ts"], + "include": [ + "scripts", + "eslint.config.mjs", + "tsup.config.ts", + "vitest.config.ts" + ], "compilerOptions": { - "types": ["node"], + "types": [ + "node" + ], "tsBuildInfoFile": ".tsbuildinfo/scripts.tsbuildinfo", - "rootDir": "scripts", + "rootDir": ".", "noEmit": true } } diff --git a/templates/cli/vitest.config.ts b/templates/cli/vitest.config.ts index 14a9491..4131857 100644 --- a/templates/cli/vitest.config.ts +++ b/templates/cli/vitest.config.ts @@ -1,5 +1,4 @@ -/// -import { defineConfig } from "vite" +import { defineConfig } from "vitest/config" export default defineConfig({ test: { From 8b2cb80856346eda2a3707bf23dbbdaf1e5d3f32 Mon Sep 17 00:00:00 2001 From: Maxwell Brown Date: Mon, 16 Sep 2024 12:07:52 -0400 Subject: [PATCH 3/6] fix monorepo template --- templates/monorepo/package.json | 2 ++ templates/monorepo/packages/cli/LICENSE | 21 +++++++++++++++++++ templates/monorepo/packages/cli/package.json | 17 +++++++++++++++ templates/monorepo/packages/domain/LICENSE | 21 +++++++++++++++++++ .../monorepo/packages/domain/package.json | 12 ++++++++++- templates/monorepo/packages/server/LICENSE | 21 +++++++++++++++++++ .../monorepo/packages/server/package.json | 6 ++++++ 7 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 templates/monorepo/packages/cli/LICENSE create mode 100644 templates/monorepo/packages/domain/LICENSE create mode 100644 templates/monorepo/packages/server/LICENSE diff --git a/templates/monorepo/package.json b/templates/monorepo/package.json index 1f8c739..6796ceb 100644 --- a/templates/monorepo/package.json +++ b/templates/monorepo/package.json @@ -28,6 +28,7 @@ "@effect/build-utils": "^0.7.7", "@effect/eslint-plugin": "^0.2.0", "@effect/language-service": "^0.1.0", + "@effect/vitest": "latest", "@eslint/compat": "1.1.1", "@eslint/eslintrc": "3.1.0", "@eslint/js": "9.10.0", @@ -35,6 +36,7 @@ "@typescript-eslint/eslint-plugin": "^8.4.0", "@typescript-eslint/parser": "^8.4.0", "babel-plugin-annotate-pure-calls": "^0.4.0", + "effect": "latest", "eslint": "^9.10.0", "eslint-import-resolver-typescript": "^3.6.3", "eslint-plugin-codegen": "^0.28.0", diff --git a/templates/monorepo/packages/cli/LICENSE b/templates/monorepo/packages/cli/LICENSE new file mode 100644 index 0000000..6d3ea95 --- /dev/null +++ b/templates/monorepo/packages/cli/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024-present + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/templates/monorepo/packages/cli/package.json b/templates/monorepo/packages/cli/package.json index 499a6ec..85000a5 100644 --- a/templates/monorepo/packages/cli/package.json +++ b/templates/monorepo/packages/cli/package.json @@ -3,6 +3,16 @@ "version": "0.0.0", "type": "module", "license": "MIT", + "description": "The CLI template", + "repository": { + "type": "git", + "url": "", + "directory": "packages/cli" + }, + "publishConfig": { + "access": "public", + "directory": "dist" + }, "scripts": { "codegen": "build-utils prepare-v2", "build": "pnpm build-esm && pnpm build-annotate && pnpm build-cjs && build-utils pack-v2", @@ -20,6 +30,13 @@ "@template/domain": "workspace:^", "effect": "latest" }, + "devDependencies": { + "@effect/cli": "latest", + "@effect/platform": "latest", + "@effect/platform-node": "latest", + "@template/domain": "workspace:^", + "effect": "latest" + }, "effect": { "generateExports": { "include": [ diff --git a/templates/monorepo/packages/domain/LICENSE b/templates/monorepo/packages/domain/LICENSE new file mode 100644 index 0000000..6d3ea95 --- /dev/null +++ b/templates/monorepo/packages/domain/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024-present + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/templates/monorepo/packages/domain/package.json b/templates/monorepo/packages/domain/package.json index 866bd3e..216e9a5 100644 --- a/templates/monorepo/packages/domain/package.json +++ b/templates/monorepo/packages/domain/package.json @@ -3,6 +3,16 @@ "version": "0.0.0", "type": "module", "license": "MIT", + "description": "The domain template", + "repository": { + "type": "git", + "url": "", + "directory": "packages/domain" + }, + "publishConfig": { + "access": "public", + "directory": "dist" + }, "scripts": { "codegen": "build-utils prepare-v2", "build": "pnpm build-esm && pnpm build-annotate && pnpm build-cjs && build-utils pack-v2", @@ -14,7 +24,7 @@ "coverage": "vitest --coverage" }, "dependencies": { - "@effect/platform": "^0.64.0", + "@effect/platform": "latest", "@effect/schema": "latest", "@effect/sql": "latest", "effect": "latest" diff --git a/templates/monorepo/packages/server/LICENSE b/templates/monorepo/packages/server/LICENSE new file mode 100644 index 0000000..6d3ea95 --- /dev/null +++ b/templates/monorepo/packages/server/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024-present + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/templates/monorepo/packages/server/package.json b/templates/monorepo/packages/server/package.json index 32337fa..a67c744 100644 --- a/templates/monorepo/packages/server/package.json +++ b/templates/monorepo/packages/server/package.json @@ -3,6 +3,12 @@ "version": "0.0.0", "type": "module", "license": "MIT", + "description": "The server template", + "repository": { + "type": "git", + "url": "", + "directory": "packages/server" + }, "scripts": { "codegen": "build-utils prepare-v2", "build": "pnpm build-esm && pnpm build-annotate && pnpm build-cjs && build-utils pack-v2", From eb44b83df0143b5d1e798a783e168f997d110c40 Mon Sep 17 00:00:00 2001 From: Maxwell Brown Date: Mon, 16 Sep 2024 12:23:40 -0400 Subject: [PATCH 4/6] fix example --- examples/http-server/.env.example | 3 +++ examples/http-server/README.md | 5 +++++ examples/http-server/package.json | 2 +- examples/http-server/src/Accounts.ts | 1 + examples/http-server/src/People.ts | 2 +- examples/http-server/src/Sql.ts | 2 +- examples/http-server/src/Tracing.ts | 2 +- 7 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 examples/http-server/.env.example create mode 100644 examples/http-server/README.md diff --git a/examples/http-server/.env.example b/examples/http-server/.env.example new file mode 100644 index 0000000..b685d11 --- /dev/null +++ b/examples/http-server/.env.example @@ -0,0 +1,3 @@ +# HONEYCOMB_API_KEY= +# HONEYCOMB_DATASET= +# OTEL_EXPORTER_OTLP_ENDPOINT= diff --git a/examples/http-server/README.md b/examples/http-server/README.md new file mode 100644 index 0000000..4d8e38d --- /dev/null +++ b/examples/http-server/README.md @@ -0,0 +1,5 @@ +# Effect HTTP Server Example + +## Getting Started + +Make sure to create a `.env` file in the root of the repository based on the `.env.example` file. diff --git a/examples/http-server/package.json b/examples/http-server/package.json index b36cb07..3794712 100644 --- a/examples/http-server/package.json +++ b/examples/http-server/package.json @@ -9,7 +9,7 @@ }, "keywords": [], "author": "", - "packageManager": "pnpm@9.7.0", + "packageManager": "pnpm@9.10.0", "devDependencies": { "@effect/language-service": "^0.1.0", "@effect/vitest": "^0.9.1", diff --git a/examples/http-server/src/Accounts.ts b/examples/http-server/src/Accounts.ts index 10ac856..cae6c5b 100644 --- a/examples/http-server/src/Accounts.ts +++ b/examples/http-server/src/Accounts.ts @@ -3,6 +3,7 @@ import { SqlClient } from "@effect/sql" import { Effect, Layer, Option, pipe } from "effect" import { AccountsRepo } from "./Accounts/AccountsRepo.js" import { UsersRepo } from "./Accounts/UsersRepo.js" +import { security } from "./Api/Security.js" import type { AccessToken } from "./Domain/AccessToken.js" import { accessTokenFromRedacted, accessTokenFromString } from "./Domain/AccessToken.js" import { Account } from "./Domain/Account.js" diff --git a/examples/http-server/src/People.ts b/examples/http-server/src/People.ts index 9b06ced..460a0b8 100644 --- a/examples/http-server/src/People.ts +++ b/examples/http-server/src/People.ts @@ -4,7 +4,7 @@ import type { GroupId } from "./Domain/Group.js" import type { PersonId } from "./Domain/Person.js" import { Person, PersonNotFound } from "./Domain/Person.js" import { policyRequire } from "./Domain/Policy.js" -import type { PeopleRepo } from "./People/Repo.js" +import { PeopleRepo } from "./People/Repo.js" import { SqlLive } from "./Sql.js" const make = Effect.gen(function*() { diff --git a/examples/http-server/src/Sql.ts b/examples/http-server/src/Sql.ts index edea9ed..03f59ff 100644 --- a/examples/http-server/src/Sql.ts +++ b/examples/http-server/src/Sql.ts @@ -6,7 +6,7 @@ import { fileURLToPath } from "url" import { makeTestLayer } from "./lib/Layer.js" const ClientLive = SqliteClient.layer({ - filename: Config.succeed("data/db.sqlite") + filename: Config.succeed("db.sqlite") }) const MigratorLive = SqliteMigrator.layer({ diff --git a/examples/http-server/src/Tracing.ts b/examples/http-server/src/Tracing.ts index c7bb0e8..9dccb8d 100644 --- a/examples/http-server/src/Tracing.ts +++ b/examples/http-server/src/Tracing.ts @@ -8,7 +8,7 @@ export const TracingLive = Layer.unwrapEffect( const apiKey = yield* Config.option(Config.redacted("HONEYCOMB_API_KEY")) const dataset = yield* Config.withDefault( Config.string("HONEYCOMB_DATASET"), - "stremio-effect" + "my-effect-app" ) if (Option.isNone(apiKey)) { const endpoint = yield* Config.option( From a6f45ed3bdd1b168802b6c866fb74dcd91820173 Mon Sep 17 00:00:00 2001 From: Maxwell Brown Date: Mon, 16 Sep 2024 12:25:06 -0400 Subject: [PATCH 5/6] update cli output --- packages/create-effect-app/src/Cli.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/create-effect-app/src/Cli.ts b/packages/create-effect-app/src/Cli.ts index 5263fc5..c524cfa 100644 --- a/packages/create-effect-app/src/Cli.ts +++ b/packages/create-effect-app/src/Cli.ts @@ -311,7 +311,6 @@ function createTemplate(config: TemplateConfig) { ])) const filesToCheck = [] - filesToCheck.push(path.join(config.projectName, "LICENSE")) if (config.projectType.withChangesets) { filesToCheck.push(path.join(config.projectName, ".changeset", "config.json")) } @@ -319,8 +318,12 @@ function createTemplate(config: TemplateConfig) { filesToCheck.push(path.join(config.projectName, "packages", "cli", "package.json")) filesToCheck.push(path.join(config.projectName, "packages", "domain", "package.json")) filesToCheck.push(path.join(config.projectName, "packages", "server", "package.json")) + filesToCheck.push(path.join(config.projectName, "packages", "cli", "LICENSE")) + filesToCheck.push(path.join(config.projectName, "packages", "domain", "LICENSE")) + filesToCheck.push(path.join(config.projectName, "packages", "server", "LICENSE")) } else { filesToCheck.push(path.join(config.projectName, "package.json")) + filesToCheck.push(path.join(config.projectName, "LICENSE")) } yield* Effect.logInfo(AnsiDoc.cats([ From 11c67a4cdd1e5e5ed0694c9858285e5aaef4155e Mon Sep 17 00:00:00 2001 From: Maxwell Brown Date: Mon, 16 Sep 2024 12:25:30 -0400 Subject: [PATCH 6/6] add changeset --- .changeset/pink-cycles-rule.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/pink-cycles-rule.md diff --git a/.changeset/pink-cycles-rule.md b/.changeset/pink-cycles-rule.md new file mode 100644 index 0000000..8ab79ae --- /dev/null +++ b/.changeset/pink-cycles-rule.md @@ -0,0 +1,5 @@ +--- +"create-effect-app": patch +--- + +Fix errors with package.json scripts in templates and examples