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 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( diff --git a/packages/create-effect-app/src/Cli.ts b/packages/create-effect-app/src/Cli.ts index d178b6a..c524cfa 100644 --- a/packages/create-effect-app/src/Cli.ts +++ b/packages/create-effect-app/src/Cli.ts @@ -311,10 +311,20 @@ 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")) } + 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")) + 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([ 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: [], 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: { 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",