diff --git a/package.json b/package.json index d566f11a..c6dd77cb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "create-fast-app", - "version": "0.3.0", + "version": "0.3.1", "description": "A cli app to create a new project with a lot of templates", "type": "module", "main": "./lib/src/bin.js", diff --git a/templates/node-graphql-ts/package-lock.json b/templates/node-graphql-ts/package-lock.json index 03d580d8..0bd54d90 100644 --- a/templates/node-graphql-ts/package-lock.json +++ b/templates/node-graphql-ts/package-lock.json @@ -31,14 +31,14 @@ "@types/node": "^17.0.33", "@typescript-eslint/eslint-plugin": "^5.23.0", "@typescript-eslint/parser": "^5.23.0", - "bob-tsm": "^0.4.8", - "bob-watch": "^0.1.1", + "bob-ts": "^4.0.0", "concurrently": "^7.2.0", "cross-env": "^7.0.3", "esbuild": "0.14.39", "eslint": "^8.15.0", "eslint-config-prettier": "^8.5.0", "husky": "^8.0.1", + "is-ci": "^3.0.1", "prettier": "^2.6.2", "typescript": "^4.6.4" }, @@ -2025,6 +2025,19 @@ "resolved": "https://registry.npmjs.org/@repeaterjs/repeater/-/repeater-3.0.4.tgz", "integrity": "sha512-AW8PKd6iX3vAZ0vA43nOUOnbq/X5ihgU+mSXXqunMkeQADGiqw/PY0JNeYtD5sr0PAy51YPgAPbDoeapv9r8WA==" }, + "node_modules/@rollup/pluginutils": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.2.1.tgz", + "integrity": "sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==", + "dev": true, + "dependencies": { + "estree-walker": "^2.0.1", + "picomatch": "^2.2.2" + }, + "engines": { + "node": ">= 8.0.0" + } + }, "node_modules/@samverschueren/stream-to-observable": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.1.tgz", @@ -2677,40 +2690,55 @@ "readable-stream": "^3.4.0" } }, - "node_modules/bob-tsm": { - "version": "0.4.8", - "resolved": "https://registry.npmjs.org/bob-tsm/-/bob-tsm-0.4.8.tgz", - "integrity": "sha512-HctV79VMhh8xh5+plIJbkghL9H0pi+euZvLSjvhgqkm3uQ73ebPUh3k7u/bYyXkhiVC/O0gs/I0alw7WOkZ3kw==", + "node_modules/bob-esbuild-plugin": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/bob-esbuild-plugin/-/bob-esbuild-plugin-4.0.0.tgz", + "integrity": "sha512-Ymk0kEPc0JhL3eZQVnWpjT4/HMX8Hw7aD5CzqSvNAXeUgaR1+8m5O1RtkP/D42ZwNv+FPgD1wKM4pdoQ4ScmAQ==", "dev": true, - "bin": { - "bob-tsm": "bin.mjs" - }, - "engines": { - "node": "^12.20.0 || >=14.13.0" - }, - "optionalDependencies": { - "fsevents": "~2.3.2" + "dependencies": { + "@rollup/pluginutils": "^4.2.1" }, "peerDependencies": { - "esbuild": ">=0.14.13", - "typescript": ">=4.1.2" + "esbuild": ">=0.14.39", + "rollup": "*" }, "peerDependenciesMeta": { - "typescript": { + "esbuild": { + "optional": true + }, + "rollup": { "optional": true } } }, - "node_modules/bob-watch": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/bob-watch/-/bob-watch-0.1.1.tgz", - "integrity": "sha512-FnmJjv8pkZwrC+SeLXvhX+RIdU5ekCm59WZDSUKwumSWWP44jNMaiBTTCeekhrb62fwo4URjjKXPkbIc7EBbPA==", + "node_modules/bob-ts": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/bob-ts/-/bob-ts-4.0.0.tgz", + "integrity": "sha512-+8wb4kt7Y0yY5FyrPVn/oviGes859eglOx6Tm1usYponuzdBpih3D90IW06nQbMp7AWzQfOsV/82SrguJBeUxQ==", "dev": true, + "dependencies": { + "bob-esbuild-plugin": "^4.0.0", + "rollup": "^2.73.0" + }, "bin": { - "bob-watch": "bin.mjs" + "bob-ts": "bin/build.mjs", + "bob-ts-watch": "bin/watch.mjs" }, - "optionalDependencies": { - "fsevents": "~2.3.2" + "engines": { + "node": ">=14.13.1" + }, + "peerDependencies": { + "@types/node": "*", + "esbuild": ">=0.14.39", + "typescript": "*" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "typescript": { + "optional": true + } } }, "node_modules/brace-expansion": { @@ -3015,6 +3043,12 @@ "fsevents": "~2.3.2" } }, + "node_modules/ci-info": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.3.1.tgz", + "integrity": "sha512-SXgeMX9VwDe7iFFaEWkA5AstuER9YKqy4EhHqr4DVqkwmD9rpVimkMKWHdjn30Ja45txyjhSn63lVX69eVCckg==", + "dev": true + }, "node_modules/cli-cursor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", @@ -4254,6 +4288,12 @@ "node": ">=4.0" } }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true + }, "node_modules/esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", @@ -5231,6 +5271,18 @@ "node": ">=8" } }, + "node_modules/is-ci": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-3.0.1.tgz", + "integrity": "sha512-ZYvCgrefwqoQ6yTyYUbQu64HsITZ3NfKX1lzaEYdkTDcfKzzCI/wthRRYKkdjHKFVgNiXKAKm65Zo1pk2as/QQ==", + "dev": true, + "dependencies": { + "ci-info": "^3.2.0" + }, + "bin": { + "is-ci": "bin.js" + } + }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -7179,6 +7231,21 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/rollup": { + "version": "2.73.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.73.0.tgz", + "integrity": "sha512-h/UngC3S4Zt28mB3g0+2YCMegT5yoftnQplwzPqGZcKvlld5e+kT/QRmJiL+qxGyZKOYpgirWGdLyEO1b0dpLQ==", + "dev": true, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=10.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, "node_modules/run-async": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", @@ -9617,6 +9684,16 @@ "resolved": "https://registry.npmjs.org/@repeaterjs/repeater/-/repeater-3.0.4.tgz", "integrity": "sha512-AW8PKd6iX3vAZ0vA43nOUOnbq/X5ihgU+mSXXqunMkeQADGiqw/PY0JNeYtD5sr0PAy51YPgAPbDoeapv9r8WA==" }, + "@rollup/pluginutils": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.2.1.tgz", + "integrity": "sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==", + "dev": true, + "requires": { + "estree-walker": "^2.0.1", + "picomatch": "^2.2.2" + } + }, "@samverschueren/stream-to-observable": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.1.tgz", @@ -10073,22 +10150,23 @@ "readable-stream": "^3.4.0" } }, - "bob-tsm": { - "version": "0.4.8", - "resolved": "https://registry.npmjs.org/bob-tsm/-/bob-tsm-0.4.8.tgz", - "integrity": "sha512-HctV79VMhh8xh5+plIJbkghL9H0pi+euZvLSjvhgqkm3uQ73ebPUh3k7u/bYyXkhiVC/O0gs/I0alw7WOkZ3kw==", + "bob-esbuild-plugin": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/bob-esbuild-plugin/-/bob-esbuild-plugin-4.0.0.tgz", + "integrity": "sha512-Ymk0kEPc0JhL3eZQVnWpjT4/HMX8Hw7aD5CzqSvNAXeUgaR1+8m5O1RtkP/D42ZwNv+FPgD1wKM4pdoQ4ScmAQ==", "dev": true, "requires": { - "fsevents": "~2.3.2" + "@rollup/pluginutils": "^4.2.1" } }, - "bob-watch": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/bob-watch/-/bob-watch-0.1.1.tgz", - "integrity": "sha512-FnmJjv8pkZwrC+SeLXvhX+RIdU5ekCm59WZDSUKwumSWWP44jNMaiBTTCeekhrb62fwo4URjjKXPkbIc7EBbPA==", + "bob-ts": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/bob-ts/-/bob-ts-4.0.0.tgz", + "integrity": "sha512-+8wb4kt7Y0yY5FyrPVn/oviGes859eglOx6Tm1usYponuzdBpih3D90IW06nQbMp7AWzQfOsV/82SrguJBeUxQ==", "dev": true, "requires": { - "fsevents": "~2.3.2" + "bob-esbuild-plugin": "^4.0.0", + "rollup": "^2.73.0" } }, "brace-expansion": { @@ -10311,6 +10389,12 @@ "readdirp": "~3.6.0" } }, + "ci-info": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.3.1.tgz", + "integrity": "sha512-SXgeMX9VwDe7iFFaEWkA5AstuER9YKqy4EhHqr4DVqkwmD9rpVimkMKWHdjn30Ja45txyjhSn63lVX69eVCckg==", + "dev": true + }, "cli-cursor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", @@ -11159,6 +11243,12 @@ "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", "dev": true }, + "estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true + }, "esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", @@ -11911,6 +12001,15 @@ "binary-extensions": "^2.0.0" } }, + "is-ci": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-3.0.1.tgz", + "integrity": "sha512-ZYvCgrefwqoQ6yTyYUbQu64HsITZ3NfKX1lzaEYdkTDcfKzzCI/wthRRYKkdjHKFVgNiXKAKm65Zo1pk2as/QQ==", + "dev": true, + "requires": { + "ci-info": "^3.2.0" + } + }, "is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -13394,6 +13493,15 @@ "glob": "^7.1.3" } }, + "rollup": { + "version": "2.73.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.73.0.tgz", + "integrity": "sha512-h/UngC3S4Zt28mB3g0+2YCMegT5yoftnQplwzPqGZcKvlld5e+kT/QRmJiL+qxGyZKOYpgirWGdLyEO1b0dpLQ==", + "dev": true, + "requires": { + "fsevents": "~2.3.2" + } + }, "run-async": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", diff --git a/templates/node-graphql-ts/package.json b/templates/node-graphql-ts/package.json index 00aa42f9..e858feb0 100644 --- a/templates/node-graphql-ts/package.json +++ b/templates/node-graphql-ts/package.json @@ -4,20 +4,21 @@ "description": "Node.js (Fastify) + GraphQL Yoga + Prisma + Typescript application", "license": "MIT", "type": "module", - "main": "src/server.ts", - "types": "src/server.ts", + "main": "dist/server.js", "scripts": { - "check:format": "prettier --check \"**/*.{ts,gql,json,yml,yaml}\"", - "clean:install": "npx rimraf \"**/{node_modules}\" package-lock.json && npm i && npm run generate", - "dev:script": "cross-env NODE_ENV=development bob-watch -w src -c \"bob-tsm src/server.ts\"", - "dev": "concurrently -r npm:dev:script npm:tsc:watch", + "build:watch": "bob-ts-watch -i src -c \"npm run dev:script\"", + "build": "bob-ts -i src", + "check:format": "prettier --check \"**/*.{ts,graphql,json,yml,yaml}\"", + "clean:install": "npx rimraf \"**/{node_modules,dist}\" package-lock.json && npm i && npm run generate", + "dev:script": "cross-env NODE_ENV=development node dist/server.js", + "dev": "cross-env NODE_ENV=development concurrently -r npm:generate npm:tsc:watch npm:build:watch", "codegen": "graphql-codegen --watch", "generate": "prisma generate", + "husky:install": "husky install", "lint": "eslint . --ext .ts", - "predev": "npm run generate", - "prepare": "husky install", + "prepare": "is-ci || concurrently npm:husky:install npm:build npm:generate", "pretty:all": "prettier --write \"**/*.{ts,gql,json,yml,yaml}\"", - "start": "cross-env NODE_ENV=production bob-tsm src/server.ts", + "start": "cross-env NODE_ENV=production node dist/server.js", "tsc:watch": "tsc --watch", "tsc": "tsc" }, @@ -44,14 +45,14 @@ "@types/node": "^17.0.33", "@typescript-eslint/eslint-plugin": "^5.23.0", "@typescript-eslint/parser": "^5.23.0", - "bob-tsm": "^0.4.8", - "bob-watch": "^0.1.1", + "bob-ts": "^4.0.0", "concurrently": "^7.2.0", "cross-env": "^7.0.3", "esbuild": "0.14.39", "eslint": "^8.15.0", "eslint-config-prettier": "^8.5.0", "husky": "^8.0.1", + "is-ci": "^3.0.1", "prettier": "^2.6.2", "typescript": "^4.6.4" }, diff --git a/templates/node-graphql-ts/src/modules/index.ts b/templates/node-graphql-ts/src/modules/index.ts index 39c30798..59057101 100644 --- a/templates/node-graphql-ts/src/modules/index.ts +++ b/templates/node-graphql-ts/src/modules/index.ts @@ -3,5 +3,5 @@ import { makeExecutableSchema } from "@graphql-tools/schema"; export const schema = makeExecutableSchema({ typeDefs: await loadFiles("./**/schema.graphql"), - resolvers: await loadFiles("./**/{mutation,query,definition}/index.ts"), + resolvers: await loadFiles("./**/{mutation,query,resolvers}/index.js"), }); diff --git a/templates/node-graphql-ts/src/modules/users/mutation/create-user.ts b/templates/node-graphql-ts/src/modules/users/mutation/create-user.ts index 76536357..29383166 100644 --- a/templates/node-graphql-ts/src/modules/users/mutation/create-user.ts +++ b/templates/node-graphql-ts/src/modules/users/mutation/create-user.ts @@ -1,6 +1,6 @@ import { MutationResolvers } from "../../../types.generated"; -export const createUser: MutationResolvers["createUser"] = async ( +const createUser: MutationResolvers["createUser"] = async ( _parent, { input }, ctx, diff --git a/templates/node-graphql-ts/src/modules/users/mutation/delete-user.ts b/templates/node-graphql-ts/src/modules/users/mutation/delete-user.ts index 95cd1f9a..4739575b 100644 --- a/templates/node-graphql-ts/src/modules/users/mutation/delete-user.ts +++ b/templates/node-graphql-ts/src/modules/users/mutation/delete-user.ts @@ -1,6 +1,6 @@ import { MutationResolvers } from "../../../types.generated"; -export const deleteUser: MutationResolvers["deleteUser"] = async ( +const deleteUser: MutationResolvers["deleteUser"] = async ( _parent, { id }, ctx, diff --git a/templates/node-graphql-ts/src/modules/users/mutation/update-user.ts b/templates/node-graphql-ts/src/modules/users/mutation/update-user.ts index 590a3819..63662cee 100644 --- a/templates/node-graphql-ts/src/modules/users/mutation/update-user.ts +++ b/templates/node-graphql-ts/src/modules/users/mutation/update-user.ts @@ -1,6 +1,6 @@ import { MutationResolvers } from "../../../types.generated"; -export const updateUser: MutationResolvers["updateUser"] = async ( +const updateUser: MutationResolvers["updateUser"] = async ( _parent, { input }, ctx, diff --git a/templates/node-graphql-ts/src/modules/users/query/user.ts b/templates/node-graphql-ts/src/modules/users/query/user.ts index f144b0bb..b23901f9 100644 --- a/templates/node-graphql-ts/src/modules/users/query/user.ts +++ b/templates/node-graphql-ts/src/modules/users/query/user.ts @@ -1,6 +1,6 @@ import { QueryResolvers } from "../../../types.generated"; -export const user: QueryResolvers["user"] = async (_parent, { id }, ctx) => { +const user: QueryResolvers["user"] = async (_parent, { id }, ctx) => { return await ctx.prisma.user.findUnique({ where: { id, diff --git a/templates/node-graphql-ts/src/modules/users/query/users.ts b/templates/node-graphql-ts/src/modules/users/query/users.ts index 8ce50fe6..cfb37299 100644 --- a/templates/node-graphql-ts/src/modules/users/query/users.ts +++ b/templates/node-graphql-ts/src/modules/users/query/users.ts @@ -1,6 +1,6 @@ import { QueryResolvers } from "../../../types.generated"; -export const users: QueryResolvers["users"] = async (_parent, _args, ctx) => { +const users: QueryResolvers["users"] = async (_parent, _args, ctx) => { return await ctx.prisma.user.findMany({ orderBy: { id: "asc", diff --git a/templates/node-graphql-ts/tsconfig.json b/templates/node-graphql-ts/tsconfig.json index 1f597181..b1f5b1eb 100644 --- a/templates/node-graphql-ts/tsconfig.json +++ b/templates/node-graphql-ts/tsconfig.json @@ -1,8 +1,8 @@ { "compilerOptions": { "incremental": true, - "target": "es2020", - "module": "esnext", + "target": "ESNext", + "module": "ESNext", "noEmit": true, "strict": true, "noUnusedLocals": true, @@ -18,5 +18,5 @@ "importsNotUsedAsValues": "remove" }, "include": ["**/*.ts"], - "exclude": ["**/node_modules"] + "exclude": ["**/node_modules", "dist"] }