Skip to content

Commit 176fc53

Browse files
chore: improved project setup
1 parent eb37b62 commit 176fc53

File tree

10 files changed

+726
-182
lines changed

10 files changed

+726
-182
lines changed

.env.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VAR_LOADED=true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
/node_modules
33

44
.env.*
5+
!.env.test
56
.DS_Store

.vscode/launch.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"configurations": [
3+
{
4+
"type": "node",
5+
"name": "Debug Tests",
6+
"request": "launch",
7+
"args": [
8+
"test",
9+
"--",
10+
"--runInBand",
11+
"--watchAll=false",
12+
"--testNamePattern",
13+
"${jest.testNamePattern}",
14+
"--runTestsByPath",
15+
"${jest.testFile}"
16+
],
17+
"console": "integratedTerminal",
18+
"internalConsoleOptions": "neverOpen",
19+
"disableOptimisticBPs": true,
20+
"runtimeExecutable": "pnpm"
21+
}
22+
]
23+
}

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"statusBar.background": "#212121",
77
"statusBar.border":"#C637CB",
88
"statusBar.foreground": "#F0F0F0",
9+
"activityBar.activeBorder": "#C637CB",
910
},
1011
}

__tests__/jest.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
describe( 'Jest', () => {
2+
3+
it( 'loads .env files correctly', () => {
4+
// Arrange ...
5+
const envVar = process.env.VAR_LOADED
6+
7+
// Act ...
8+
const isLoaded = envVar === 'true'
9+
10+
// Assert ...
11+
expect( isLoaded ).toBe( true )
12+
} )
13+
14+
} )
File renamed without changes.
Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1+
import type { JestConfigWithTsJest } from 'ts-jest'
2+
import dotenv from 'dotenv'
3+
14
const env = process.env.NODE_ENV
25

3-
// eslint-disable-next-line @typescript-eslint/no-require-imports
4-
require( 'dotenv' )
5-
.config( { path: [ `.env.${ env }`, '.env.local', '.env' ] } )
6+
dotenv.config( { path: [
7+
`.env.${ env }.local`,
8+
`.env.${ env }`,
9+
'.env.local',
10+
'.env'
11+
] } )
612

713

814
/**
915
* Initial file generated with `npx ts-jest config:init`
1016
*
11-
* @type {import('ts-jest').JestConfigWithTsJest}
1217
*/
13-
module.exports = {
18+
const config: JestConfigWithTsJest = {
19+
/** https://jestjs.io/docs/configuration#testenvironment-string */
1420
testEnvironment: 'node',
1521
moduleDirectories: [ 'node_modules', '<rootDir>/' ],
1622
/**
@@ -24,4 +30,6 @@ module.exports = {
2430
transform: {
2531
'^.+.tsx?$': [ 'ts-jest', {} ],
2632
},
27-
}
33+
}
34+
35+
export default config

package.json

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
],
3232
"exports": {
3333
".": {
34+
"types": "./dist/index.d.ts",
3435
"import": "./dist/index.mjs",
3536
"require": "./dist/index.js"
3637
},
@@ -77,31 +78,41 @@
7778
},
7879
"sideEffects": false,
7980
"scripts": {
80-
"build": "eslint && jest --ci --verbose && tsup",
81+
"build": "pnpm lint && pnpm test:ci && tsup",
82+
"build:watch": "tsup --watch",
83+
"release": "node scripts/publish.js --verbose",
8184
"lint": "eslint",
82-
"test": "jest --watchAll --verbose",
85+
"test:watch": "jest --watchAll --verbose",
8386
"test:ci": "jest --ci --verbose",
87+
"test:coverage": "pnpm test:watch --coverage",
88+
"test:ci:coverage": "pnpm test:ci --coverage",
89+
"test:serve-coverage": "http-server ./coverage/lcov-report --gzip true -p 0 -o --silent",
90+
"test:coverage:serve": "concurrently --prefix none --kill-others \"pnpm test:coverage\" \"pnpm test:serve-coverage\"",
91+
"test:jest": "pnpm test:watch jest.test.ts",
8492
"test:common": "pnpm test common.test.ts",
8593
"test:format": "pnpm test format.test.ts",
8694
"test:timezones": "pnpm test timezones.test.ts",
8795
"test:utils": "pnpm test utils.test.ts"
8896
},
8997
"devDependencies": {
90-
"@eslint/js": "^9.16.0",
98+
"@eslint/js": "^9.17.0",
9199
"@jest/globals": "^29.7.0",
92100
"@types/jest": "^29.5.14",
93-
"@types/node": "^22.10.1",
94-
"dotenv": "^16.4.5",
95-
"eslint": "^9.16.0",
96-
"globals": "^15.12.0",
101+
"@types/node": "^22.10.2",
102+
"concurrently": "^9.1.0",
103+
"dotenv": "^16.4.7",
104+
"eslint": "^9.17.0",
105+
"globals": "^15.14.0",
106+
"http-server": "^14.1.1",
97107
"jest": "^29.7.0",
98108
"ts-jest": "^29.2.5",
109+
"ts-node": "^10.9.2",
99110
"tsup": "^8.3.5",
100111
"typescript": "^5.7.2",
101-
"typescript-eslint": "^8.16.0"
112+
"typescript-eslint": "^8.18.2"
102113
},
103114
"dependencies": {
104-
"@alessiofrittoli/math-utils": "^0.3.0",
105-
"@alessiofrittoli/type-utils": "^0.3.0"
115+
"@alessiofrittoli/math-utils": "^1.2.0",
116+
"@alessiofrittoli/type-utils": "^1.4.0"
106117
}
107118
}

0 commit comments

Comments
 (0)