Skip to content

Commit

Permalink
setup(@daotl/myutil): use @nx/js:tsc to build and @nx/vite:test to test
Browse files Browse the repository at this point in the history
  • Loading branch information
NexZhu committed Dec 18, 2023
1 parent 1552a0b commit 63eab7d
Show file tree
Hide file tree
Showing 29 changed files with 3,204 additions and 171 deletions.
5 changes: 4 additions & 1 deletion .lefthook.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
extends:
- k8s/.lefthook.yml
- apps/web/.lefthook.yml
# FIXME: Biome "extends" overriding and "overrides" not working for now
# - apps/lib/.lefthook.yml
# - apps/web/.lefthook.yml
# - apps/desktop/.lefthook.yml

pre-commit:
parallel: true
Expand Down
3 changes: 1 addition & 2 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"version": "0.0.1",
"private": true,
"dependencies": {
"@daotl/web": "workspace:*",
"@daotl/yourutil": "workspace:*"
"@daotl/web": "workspace:*"
},
"devDependencies": {
"@daotl/eslint-config": "^2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"build": {
"executor": "nx:run-commands",
"options": {
"command": "mkdir -p dist && echo 'app' > dist/index.js",
"cwd": "./apps/desktop"
"cwd": "./apps/desktop",
"command": "mkdir -p dist && echo 'app' > dist/index.js"
}
},
"lint": {},
Expand Down
5 changes: 4 additions & 1 deletion apps/desktop/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "../../tsconfig.base.json"
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"baseUrl": "."
}
}
4 changes: 2 additions & 2 deletions apps/web/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"build": {
"executor": "nx:run-commands",
"options": {
"command": "mkdir -p dist && echo 'app' > dist/index.js",
"cwd": "./apps/web"
"cwd": "./apps/web",
"command": "mkdir -p dist && echo 'app' > dist/index.js"
}
},

Expand Down
6 changes: 5 additions & 1 deletion apps/web/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"extends": "../../tsconfig.base.json"

"extends": "../../tsconfig.base.json",
"compilerOptions": {
"baseUrl": "."
}
}
1 change: 1 addition & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"nx.json",
"./scripts/*",
"./k8s/*",
"./lib/*",
"./apps/*"
]
}
Expand Down
4 changes: 2 additions & 2 deletions k8s/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"targets": {
"lint": {
"options": {
"command": "[ '{args.fix}' = 'true' ] && biome check . || biome check --apply .",
"cwd": "k8s"
"cwd": "k8s",
"command": "[ '{args.fix}' = 'true' ] && biome check . || biome check --apply ."
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions lib/myutil/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "../../node_modules/@biomejs/biome/configuration_schema.json",
"extends": ["../../node_modules/@daotl/biome-config/dist/biome.json"],
"vcs": {
"root": "../.."
},
"overrides": [
{
"include": ["**/*.spec.ts"],
"javascript": {
"globals": ["describe", "it", "expect"]
}
}
]
}
9 changes: 6 additions & 3 deletions lib/myutil/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"name": "@daotl/myutil",
"version": "0.0.1",
"private": true,
"devDependencies": {
"@biomejs/biome": "1.4.0"
"type": "module",
"main": "./src/index.js",
"typings": "./src/index.d.ts",
"dependencies": {
"tslib": "^2.3.0"
}
}
}
28 changes: 23 additions & 5 deletions lib/myutil/project.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
{
"name": "myutil",
"$schema": "../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "lib/myutil/src",
"projectType": "library",
"targets": {
"build": {
"command": "echo build",
"options": {}
"executor": "@nx/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "lib/myutil/dist",
"main": "lib/myutil/src/index.ts",
"tsConfig": "lib/myutil/tsconfig.lib.json",
"assets": ["lib/myutil/*.md"]
}
},
"lint": {
"command": "echo lint",
"options": {}
"options": {
"cwd": "lib/myutil",
"command": "[ '{args.fix}' = 'true' ] && biome check . || biome check --apply ."
}
},
"test": {
"executor": "@nx/vite:test",
"outputs": ["{options.reportsDirectory}"],
"options": {
"reportsDirectory": "./coverage"
}
}
}
},
"tags": []
}
2 changes: 1 addition & 1 deletion lib/myutil/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default {}
export * from './lib/myutil.js'
7 changes: 7 additions & 0 deletions lib/myutil/src/lib/myutil.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { myutil } from './myutil'

describe('myutil', () => {
it('should work', () => {
expect(myutil()).toEqual('myutil')
})
})
3 changes: 3 additions & 0 deletions lib/myutil/src/lib/myutil.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function myutil(): string {
return 'myutil'
}
Empty file removed lib/myutil/test.js
Empty file.
15 changes: 14 additions & 1 deletion lib/myutil/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
{
"extends": "../../tsconfig.base.json"
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"baseUrl": "."
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
10 changes: 10 additions & 0 deletions lib/myutil/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./dist/out-tsc",
"declaration": true,
"types": ["node"]
},
"include": ["src/**/*.ts"],
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts"]
}
26 changes: 26 additions & 0 deletions lib/myutil/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./dist/out-tsc",
"types": [
"vitest/globals",
"vitest/importMeta",
"vite/client",
"node",
"vitest"
]
},
"include": [
"vite.config.ts",
"vitest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.test.tsx",
"src/**/*.spec.tsx",
"src/**/*.test.js",
"src/**/*.spec.js",
"src/**/*.test.jsx",
"src/**/*.spec.jsx",
"src/**/*.d.ts"
]
}
22 changes: 22 additions & 0 deletions lib/myutil/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { defineConfig } from 'vite'

import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'

export default defineConfig({
root: __dirname,

plugins: [nxViteTsPaths()],

// Uncomment this if you are using workers.
// worker: {
// plugins: [ nxViteTsPaths() ],
// },

test: {
globals: true,
environment: 'node',
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
reporters: ['default'],
coverage: { reportsDirectory: './coverage', provider: 'v8' },
},
})
7 changes: 0 additions & 7 deletions lib/yourutil/.lefthook.yml

This file was deleted.

8 changes: 0 additions & 8 deletions lib/yourutil/package.json

This file was deleted.

14 changes: 0 additions & 14 deletions lib/yourutil/project.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/yourutil/src/index.ts

This file was deleted.

Empty file removed lib/yourutil/test.js
Empty file.
3 changes: 0 additions & 3 deletions lib/yourutil/tsconfig.json

This file was deleted.

14 changes: 13 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@daotl/root",
"type": "module",
"version": "1.0.0",
"private": true,
"type": "module",
"packageManager": "[email protected]",
"description": "Web monorepo starter template",
"repository": {
Expand Down Expand Up @@ -31,7 +31,17 @@
"@manypkg/cli": "npm:@daotl/manypkg-cli@^0.21.1",
"@nx-tools/container-metadata": "^5.1.0",
"@nx-tools/nx-container": "^5.1.0",
"@nx/js": "^17.2.5",
"@nx/vite": "v17.2.5",
"@swc-node/register": "~1.6.7",
"@swc/core": "~1.3.85",
"@traf/nx": "^0.0.16",
"@tsconfig/esm": "^1.0.5",
"@tsconfig/node20": "^20.1.2",
"@tsconfig/strictest": "^2.0.2",
"@types/node": "^20.10.0",
"@vitest/coverage-v8": "^1.0.4",
"@vitest/ui": "^1.0.4",
"commitiquette": "^1.2.1",
"commitizen": "^4.3.0",
"commitlint-config-pnpm-workspace": "^0.2.2",
Expand All @@ -40,6 +50,8 @@
"nx": "^17.1.3",
"remeda": "^1.29.0",
"typescript": "^5.3.2",
"vite": "^5.0.0",
"vitest": "^1.0.4",
"zx": "^7.2.3"
}
}
Loading

0 comments on commit 63eab7d

Please sign in to comment.