Skip to content

Commit

Permalink
build: add syncpack for linting dependency versions and package.jsons
Browse files Browse the repository at this point in the history
This way, all the versions of dependencies are the same for all
packages. Also, `package.json` files now follow the same format. In the
future, once all dependency versions are fixed, we can even add the
linting step to the pipeline.

Related to #83
  • Loading branch information
JoosepAlviste committed Jan 1, 2024
1 parent 9232b36 commit ef6567a
Show file tree
Hide file tree
Showing 13 changed files with 496 additions and 350 deletions.
31 changes: 31 additions & 0 deletions .syncpackrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "./node_modules/syncpack/dist/schema.json",
"versionGroups": [
{
"label": "Use workspace protocol for local packages",
"dependencies": ["$LOCAL"],
"dependencyTypes": ["dev", "prod"],
"pinVersion": "workspace:*"
}
],
"sortFirst": [
"name",
"description",
"version",
"private",
"license",
"author",
"repository",
"homepage",
"bugs",
"engines",
"type",
"main",
"types",
"exports",
"scripts",
"dependencies",
"peerDependencies",
"devDependencies"
]
}
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ The series are automatically imported from [The Movie Database (TMDB)](https://w

The goal of the tech stack is to be as fully statically typed as possible, all
the way from the database to the front-end, while being as simple as possible.
[`pnpm`](https://pnpm.io/) is used to manage the multiple workspaces.
[`pnpm`](https://pnpm.io/) and [`nx`](https://nx.dev/) are used to manage the
multiple workspaces.

The front-end is an SPA with server-side rendering:

Expand Down Expand Up @@ -94,6 +95,15 @@ are split into features. The `src` folders contain some general, "global" files,
while the `src/features` folders contain feature-specific code.


### Generating a new package

A new package can be generated with:

```sh
pnpm generate:package
```


## Production

The project is deployed to a DigitalOcean droplet and is continuously deployed
Expand Down
50 changes: 18 additions & 32 deletions apps/api/package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
{
"name": "@serieslist/api",
"version": "1.0.0",
"private": true,
"description": "A side project. Keep track of your seen series' episodes.",
"author": "Joosep Alviste <[email protected]> (https://joosep.xyz/)",
"type": "module",
"module": "src/main.ts",
"scripts": {
"build": "NODE_ENV=production rimraf dist && tsx bin/build.ts && resolve-tspaths",
"clear-test-db": "dotenv -e ../../.env.test tsx bin/clearDatabase.ts",
"codegen": "DOTENV_CONFIG_PATH='../../.env' graphql-codegen-esm -r dotenv/config",
"codegen:db": "tsx bin/kyselyCodegen.ts && eslint --fix src/generated/db.ts",
"codegen:watch": "pnpm codegen -- --watch",
"lint": "eslint src && madge --circular --extensions ts ./src",
"lint:fix": "eslint --fix src",
"migrate": "tsx src/bin/migrate.ts && pnpm codegen:db",
"migrate:prod": "dotenv -e ../../.env node dist/bin/migrate.js",
"migrate:test": "dotenv -e ../../.env.test tsx src/bin/migrate.ts",
"migration": "./bin/createMigration.sh",
"start": "NODE_ENV=development tsx watch --clear-screen=false src/main.ts",
"start:prod": "NODE_ENV=production node dist/main.js",
"start:e2e": "dotenv -e ../../.env.e2e -v NODE_ENV=test pnpm build && pnpm start:prod",
"start:tmdb": "tsx watch src/test/mockTMDBServer.ts",
"start:jobs": "NODE_ENV=development tsx watch --clear-screen=false src/mainJobs.ts",
"start:jobs:prod": "NODE_ENV=production node dist/mainJobs.js",
"tsc": "tsc --noEmit",
"lint": "eslint src && madge --circular --extensions ts ./src",
"lint:fix": "eslint --fix src",
"start:prod": "NODE_ENV=production node dist/main.js",
"start:tmdb": "tsx watch src/test/mockTMDBServer.ts",
"test": "dotenv -e ../../.env.test vitest",
"test:coverage": "dotenv -e ../../.env.test vitest run -- --coverage",
"codegen": "DOTENV_CONFIG_PATH='../../.env' graphql-codegen-esm -r dotenv/config",
"codegen:watch": "pnpm codegen -- --watch",
"codegen:db": "tsx bin/kyselyCodegen.ts && eslint --fix src/generated/db.ts",
"migration": "./bin/createMigration.sh",
"migrate": "tsx src/bin/migrate.ts && pnpm codegen:db",
"migrate:test": "dotenv -e ../../.env.test tsx src/bin/migrate.ts",
"migrate:prod": "dotenv -e ../../.env node dist/bin/migrate.js",
"clear-test-db": "dotenv -e ../../.env.test tsx bin/clearDatabase.ts"
"tsc": "tsc --noEmit"
},
"dependencies": {
"@bull-board/api": "^5.6.0",
Expand All @@ -45,14 +41,15 @@
"@sentry/node": "^7.56.0",
"@sentry/tracing": "^7.56.0",
"@serieslist/logger": "workspace:*",
"@serieslist/tmdb": "workspace:*",
"bcryptjs": "^2.4.3",
"bullmq": "^4.1.0",
"dataloader": "^2.2.2",
"date-fns": "^2.30.0",
"dotenv": "^16.0.3",
"dotenv-cli": "^7.1.0",
"dotenv-expand": "^10.0.0",
"fastify": "^4.17.0",
"fastify": "^4.18.0",
"fishery": "^2.2.2",
"graphql": "^16.8.1",
"graphql-scalars": "^1.22.0",
Expand Down Expand Up @@ -83,24 +80,13 @@
"@types/node": "^18.15.3",
"@types/pg": "^8.6.6",
"@vitest/coverage-c8": "^0.29.3",
"eslint": "^8.36.0",
"kysely-codegen": "^0.10.0",
"madge": "^6.0.0",
"nock": "^13.3.1",
"prettier": "^2.8.4",
"resolve-tspaths": "^0.8.8",
"resolve-tspaths": "^0.8.13",
"rimraf": "^4.4.0",
"tsx": "^3.14.0",
"typescript": "^4.9.5",
"vitest": "^0.29.3"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/JoosepAlviste/serieslist.git"
},
"bugs": {
"url": "https://github.com/JoosepAlviste/serieslist/issues"
},
"homepage": "https://github.com/JoosepAlviste/serieslist#readme"
"vitest": "^0.34.6"
}
}
19 changes: 8 additions & 11 deletions apps/webapp/package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
{
"name": "@serieslist/webapp",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"start": "tsx ./src/server/server.ts",
"start:e2e": "dotenv -e ../../.env.e2e pnpm build && pnpm start:prod",
"build": "rimraf dist && vite build && pnpm build:server",
"build:server": "tsx bin/build.ts && resolve-tspaths --out dist/prodServer",
"start:prod": "cross-env NODE_ENV=production node dist/prodServer/server.js",
"codegen": "graphql-codegen",
"lint": "eslint src && madge --circular --extensions ts,tsx ./src",
"lint:fix": "eslint --fix src",
"tsc": "tsc --noEmit",
"start": "tsx ./src/server/server.ts",
"start:e2e": "dotenv -e ../../.env.e2e pnpm build && pnpm start:prod",
"start:prod": "cross-env NODE_ENV=production node dist/prodServer/server.js",
"test": "vitest",
"test:coverage": "vitest run --coverage",
"codegen": "graphql-codegen"
"tsc": "tsc --noEmit"
},
"dependencies": {
"@apollo/client": "^3.7.10",
Expand Down Expand Up @@ -59,8 +58,8 @@
"zod": "^3.22.3"
},
"devDependencies": {
"@graphql-codegen/cli": "4.0.1",
"@graphql-codegen/client-preset": "4.0.1",
"@graphql-codegen/cli": "^4.0.1",
"@graphql-codegen/client-preset": "^4.0.1",
"@sentry/vite-plugin": "^2.8.0",
"@serieslist/esbuild": "workspace:*",
"@serieslist/eslint-config-react": "workspace:*",
Expand All @@ -70,19 +69,17 @@
"@testing-library/jest-dom": "^6.1.3",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.5.1",
"@types/node": "^18.11.9",
"@types/node": "^18.15.3",
"@types/react": "^18.0.8",
"@types/react-dom": "^18.0.3",
"@types/react-highlight-words": "^0.16.4",
"@types/react-transition-group": "^4.4.6",
"@vanilla-extract/vite-plugin": "^3.9.0",
"@vitest/coverage-v8": "^0.34.6",
"eslint": "8.36.0",
"jsdom": "^22.1.0",
"madge": "^6.0.0",
"mock-apollo-client": "^1.2.1",
"nanoid": "^4.0.2",
"prettier": "2.8.4",
"resolve-tspaths": "^0.8.13",
"rimraf": "^4.4.0",
"tsx": "^3.14.0",
Expand Down
26 changes: 15 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
{
"name": "serieslist",
"author": "Joosep Alviste",
"license": "MIT",
"private": true,
"version": "1.0.0",
"description": "Always know which episode to watch next. Keep track of your series and seen episodes.",
"version": "1.0.0",
"private": true,
"license": "MIT",
"author": "Joosep Alviste <[email protected]> (https://joosep.xyz/)",
"repository": "JoosepAlviste/serieslist.git",
"homepage": "https://github.com/JoosepAlviste/serieslist#readme",
"bugs": "https://github.com/JoosepAlviste/serieslist/issues",
"engines": {
"node": ">=16",
"pnpm": ">=8"
},
"scripts": {
"postinstall": "cp -n .env.example .env || exit 0",
"start": "nx run-many -t start,start:jobs",
"lint": "nx affected -t lint",
"tsc": "nx affected -t tsc",
"test:coverage": "dotenv -e .env.test -- nx affected -t test:coverage --verbose",
"build": "nx affected -t build",
"generate:package": "nx generate @serieslist/nx-plugin:package",
"lint": "nx affected -t lint",
"migrate": "pnpm -F api migrate",
"migrate:test": "dotenv -e .env.test -- pnpm -F api migrate:test",
"postinstall": "cp -n .env.example .env || exit 0",
"start": "nx run-many -t start,start:jobs",
"test:coverage": "dotenv -e .env.test -- nx affected -t test:coverage --verbose",
"test:e2e": "dotenv -e .env.e2e -- nx test:e2e @serieslist/e2e",
"generate:package": "nx generate @serieslist/nx-plugin:package"
"tsc": "nx affected -t tsc"
},
"devDependencies": {
"@nx/devkit": "17.2.8",
"@nx/plugin": "^17.2.8",
"dotenv-cli": "^7.1.0",
"nx": "17.2.8"
"nx": "17.2.8",
"syncpack": "^12.3.0"
}
}
4 changes: 2 additions & 2 deletions packages/esbuild/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"types": "./src/index.ts",
"exports": {
".": {
"import": "./src/index.ts",
"types": "./src/index.ts"
"types": "./src/index.ts",
"import": "./src/index.ts"
}
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"eslint-plugin-prettier": "^4.2.1"
},
"devDependencies": {
"@serieslist/prettier-config": "workspace:^"
"@serieslist/prettier-config": "workspace:*"
}
}
10 changes: 5 additions & 5 deletions packages/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
"main": "./src/createLogger.ts",
"exports": {
".": {
"require": "./src/createLogger.ts",
"types": "./src/createLogger.ts",
"import": "./src/createLogger.ts",
"types": "./src/createLogger.ts"
"require": "./src/createLogger.ts"
}
},
"scripts": {
"lint": "eslint src",
"tsc": "tsc --noEmit"
},
"dependencies": {
"pino": "^8.14.1"
},
"devDependencies": {
"@serieslist/eslint-config-base": "workspace:*",
"@serieslist/prettier-config": "workspace:*",
"@serieslist/typescript-config-base": "workspace:*",
"pino-pretty": "^10.0.0",
"typescript": "^4.9.4"
},
"dependencies": {
"pino": "^8.14.1"
}
}
6 changes: 3 additions & 3 deletions packages/nx-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"version": "0.0.1",
"type": "commonjs",
"main": "./src/index.ts",
"typings": "./src/index.ts",
"generators": "./generators.json",
"dependencies": {
"@nx/devkit": "17.2.8",
"tslib": "^2.3.0"
Expand All @@ -14,5 +12,7 @@
"@serieslist/prettier-config": "workspace:*",
"@serieslist/typescript-config-base": "workspace:*",
"typescript": "^4.9.4"
}
},
"generators": "./generators.json",
"typings": "./src/index.ts"
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const variable = "<%= name %>";
export const variable = '<%= name %>'
3 changes: 3 additions & 0 deletions packages/prettier-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
"scripts": {
"lint": "prettier --check .",
"lint:fix": "prettier --write ."
},
"dependencies": {
"prettier": "2.8.4"
}
}
4 changes: 2 additions & 2 deletions packages/type-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"main": "./src/type-utils.ts",
"exports": {
".": {
"import": "./src/type-utils.ts",
"types": "./src/type-utils.ts"
"types": "./src/type-utils.ts",
"import": "./src/type-utils.ts"
}
},
"scripts": {
Expand Down
Loading

0 comments on commit ef6567a

Please sign in to comment.