express-generator-typescript 2.7.11 → 2.7.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/express-generator-typescript.js +44 -11
- package/lib/project-files/.prettierignore +12 -0
- package/lib/project-files/.prettierrc.json +15 -0
- package/lib/project-files/README.md +58 -65
- package/lib/project-files/config.ts +20 -22
- package/lib/project-files/eslint.config.ts +46 -100
- package/lib/project-files/package.json +59 -56
- package/lib/project-files/scripts/build.ts +23 -28
- package/lib/project-files/scripts/common/utils.ts +11 -11
- package/lib/project-files/src/common/constants/HttpStatusCodes.ts +393 -394
- package/lib/project-files/src/common/constants/Paths.ts +15 -15
- package/lib/project-files/src/common/constants/{EnvVars.ts → env.ts} +28 -19
- package/lib/project-files/src/common/utils/{misc.ts → number-utils.ts} +10 -11
- package/lib/project-files/src/common/utils/route-errors.ts +35 -36
- package/lib/project-files/src/common/utils/validators.ts +14 -14
- package/lib/project-files/src/{index.ts → main.ts} +24 -27
- package/lib/project-files/src/models/User.ts +69 -72
- package/lib/project-files/src/models/common/{types.ts → IModel.ts} +4 -5
- package/lib/project-files/src/public/stylesheets/users.css +50 -48
- package/lib/project-files/src/repos/MockOrm.ts +57 -63
- package/lib/project-files/src/repos/UserRepo.ts +133 -133
- package/lib/project-files/src/repos/common/database.test.json +22 -0
- package/lib/project-files/src/routes/UserRoutes.ts +77 -69
- package/lib/project-files/src/routes/{index.ts → apiRouter.ts} +28 -28
- package/lib/project-files/src/routes/common/{types.ts → express-types.ts} +9 -10
- package/lib/project-files/src/routes/common/{utils.ts → parseReq.ts} +19 -16
- package/lib/project-files/src/server.ts +79 -84
- package/lib/project-files/src/services/{UserService/index.ts → UserService.ts} +64 -58
- package/lib/project-files/src/views/users.html +118 -132
- package/lib/project-files/tests/common/{utils.ts → comparators.ts} +38 -55
- package/lib/project-files/tests/common/error-utils.ts +25 -0
- package/lib/project-files/tests/common/{types.ts → supertest-types.ts} +15 -16
- package/lib/project-files/tests/{aux/setup.ts → support/agent.ts} +23 -26
- package/lib/project-files/tests/users.test.ts +131 -123
- package/lib/project-files/tsconfig.json +30 -35
- package/lib/project-files/tsconfig.prod.json +27 -30
- package/lib/project-files/vitest.config.mts +18 -18
- package/package.json +1 -1
- package/lib/project-files/src/common/constants/index.ts +0 -11
- package/lib/project-files/src/repos/database.test.json +0 -1
- package/lib/project-files/src/services/UserService/constants.ts +0 -5
- /package/lib/project-files/src/repos/{database.json → common/database.json} +0 -0
|
@@ -9,18 +9,51 @@ const path = require('path'),
|
|
|
9
9
|
Constants
|
|
10
10
|
******************************************************************************/
|
|
11
11
|
|
|
12
|
-
// Project folder paths
|
|
13
12
|
const PROJECT_FOLDER_PATH = './project-files';
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
'
|
|
14
|
+
const DEPENDENCIES = [
|
|
15
|
+
'cookie-parser',
|
|
16
|
+
'dayjs',
|
|
17
|
+
'dotenv',
|
|
18
|
+
'express',
|
|
19
|
+
'helmet',
|
|
20
|
+
'jet-env',
|
|
21
|
+
'jet-logger',
|
|
22
|
+
'jet-paths',
|
|
18
23
|
'jet-validators',
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
'jsonfile',
|
|
25
|
+
'module-alias',
|
|
26
|
+
'morgan',
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
const DEV_DEPENDENCIES = [
|
|
30
|
+
'@eslint/js',
|
|
31
|
+
'@swc/core',
|
|
32
|
+
'@trivago/prettier-plugin-sort-imports',
|
|
33
|
+
'@types/cookie-parser',
|
|
34
|
+
'@types/find',
|
|
35
|
+
'@types/fs-extra',
|
|
36
|
+
'@types/jsonfile',
|
|
37
|
+
'@types/module-alias',
|
|
38
|
+
'@types/morgan',
|
|
39
|
+
'@types/node',
|
|
40
|
+
'@types/supertest',
|
|
41
|
+
'eslint',
|
|
42
|
+
'eslint-config-prettier',
|
|
43
|
+
'eslint-plugin-n',
|
|
44
|
+
'find',
|
|
45
|
+
'fs-extra',
|
|
46
|
+
'jiti',
|
|
47
|
+
'nodemon',
|
|
48
|
+
'prettier',
|
|
49
|
+
'supertest',
|
|
50
|
+
'ts-node',
|
|
51
|
+
'tsconfig-paths',
|
|
52
|
+
'typescript',
|
|
53
|
+
'typescript-eslint',
|
|
54
|
+
'vitest',
|
|
55
|
+
];
|
|
56
|
+
|
|
24
57
|
|
|
25
58
|
// "ncp" options
|
|
26
59
|
const ncpOpts = {
|
|
@@ -91,8 +124,8 @@ function renameGitigoreFile(destination) {
|
|
|
91
124
|
function downloadNodeModules(destination, useYarn) {
|
|
92
125
|
const options = { cwd: destination };
|
|
93
126
|
// Setup dependencies string
|
|
94
|
-
let depStr = DEPENDENCIES,
|
|
95
|
-
devDepStr = DEV_DEPENDENCIES;
|
|
127
|
+
let depStr = DEPENDENCIES.join(' '),
|
|
128
|
+
devDepStr = DEV_DEPENDENCIES.join(' ');
|
|
96
129
|
// Setup download command
|
|
97
130
|
let downloadLibCmd,
|
|
98
131
|
downloadDepCmd;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"plugins": ["@trivago/prettier-plugin-sort-imports"],
|
|
3
|
+
"importOrder": [
|
|
4
|
+
"<THIRD_PARTY_MODULES>",
|
|
5
|
+
"^@src/[^/]+(/.*)?$",
|
|
6
|
+
"^\\.(?!.*\\.css$).*$",
|
|
7
|
+
"^.+\\.css$"
|
|
8
|
+
],
|
|
9
|
+
"importOrderSeparation": true,
|
|
10
|
+
"importOrderSortSpecifiers": true,
|
|
11
|
+
"importOrderCaseInsensitive": true,
|
|
12
|
+
"singleQuote": true,
|
|
13
|
+
"printWidth": 80,
|
|
14
|
+
"tabWidth": 2
|
|
15
|
+
}
|
|
@@ -1,65 +1,58 @@
|
|
|
1
|
-
## About
|
|
2
|
-
|
|
3
|
-
This project was created with [express-generator-typescript](https://github.com/seanpmaxwell/express-generator-typescript).
|
|
4
|
-
|
|
5
|
-
**IMPORTANT** for demo purposes I had to disable `helmet` in production. In any real world app you should change these 3 lines of code in `src/server.ts`:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
### `npm run dev` or `npm run dev:hot` (hot reloading)
|
|
27
|
-
|
|
28
|
-
Run the server in development mode.<br/>
|
|
29
|
-
|
|
30
|
-
**IMPORTANT** development mode uses `swc` for performance reasons which DOES NOT check for typescript errors. Run `npm run type-check` to check for type errors. NOTE: you should use your IDE to prevent most type errors.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
### `npm
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
Check for typescript errors.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
## Additional Notes
|
|
64
|
-
|
|
65
|
-
- If `npm run dev` gives you issues with bcrypt on MacOS you may need to run: `npm rebuild bcrypt --build-from-source`.
|
|
1
|
+
## About
|
|
2
|
+
|
|
3
|
+
This project was created with [express-generator-typescript](https://github.com/seanpmaxwell/express-generator-typescript).
|
|
4
|
+
|
|
5
|
+
**IMPORTANT** for demo purposes I had to disable `helmet` in production. In any real world app you should change these 3 lines of code in `src/server.ts`:
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
// eslint-disable-next-line n/no-process-env
|
|
9
|
+
if (!process.env.DISABLE_HELMET) {
|
|
10
|
+
app.use(helmet());
|
|
11
|
+
}
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
To just this:
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
app.use(helmet());
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Available Scripts
|
|
21
|
+
|
|
22
|
+
### `npm run clean-install`
|
|
23
|
+
|
|
24
|
+
Remove the existing `node_modules/` folder, `package-lock.json`, and reinstall all library modules.
|
|
25
|
+
|
|
26
|
+
### `npm run dev` or `npm run dev:hot` (hot reloading)
|
|
27
|
+
|
|
28
|
+
Run the server in development mode.<br/>
|
|
29
|
+
|
|
30
|
+
**IMPORTANT** development mode uses `swc` for performance reasons which DOES NOT check for typescript errors. Run `npm run type-check` to check for type errors. NOTE: you should use your IDE to prevent most type errors.
|
|
31
|
+
|
|
32
|
+
### `npm test` or `npm run test:hot` (hot reloading)
|
|
33
|
+
|
|
34
|
+
Run all unit-tests.
|
|
35
|
+
|
|
36
|
+
### `npm test -- "name of test file" (i.e. users).`
|
|
37
|
+
|
|
38
|
+
Run a single unit-test.
|
|
39
|
+
|
|
40
|
+
### `npm run lint`
|
|
41
|
+
|
|
42
|
+
Check for linting errors.
|
|
43
|
+
|
|
44
|
+
### `npm run build`
|
|
45
|
+
|
|
46
|
+
Build the project for production.
|
|
47
|
+
|
|
48
|
+
### `npm start`
|
|
49
|
+
|
|
50
|
+
Run the production build (Must be built first).
|
|
51
|
+
|
|
52
|
+
### `npm run type-check`
|
|
53
|
+
|
|
54
|
+
Check for typescript errors.
|
|
55
|
+
|
|
56
|
+
## Additional Notes
|
|
57
|
+
|
|
58
|
+
- If `npm run dev` gives you issues with bcrypt on MacOS you may need to run: `npm rebuild bcrypt --build-from-source`.
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import path from 'path';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
moduleAlias.addAlias('@src', __dirname + '/dist');
|
|
22
|
-
}
|
|
1
|
+
import dotenv from 'dotenv';
|
|
2
|
+
import moduleAlias from 'module-alias';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
|
|
5
|
+
// Check the env
|
|
6
|
+
// eslint-disable-next-line no-process-env
|
|
7
|
+
const NODE_ENV = process.env.NODE_ENV ?? 'development';
|
|
8
|
+
|
|
9
|
+
// Configure "dotenv"
|
|
10
|
+
const result2 = dotenv.config({
|
|
11
|
+
path: path.join(__dirname, `./config/.env.${NODE_ENV}`),
|
|
12
|
+
});
|
|
13
|
+
if (result2.error) {
|
|
14
|
+
throw result2.error;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Configure moduleAlias
|
|
18
|
+
if (__filename.endsWith('js')) {
|
|
19
|
+
moduleAlias.addAlias('@src', __dirname + '/dist');
|
|
20
|
+
}
|
|
@@ -1,100 +1,46 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
export default defineConfig(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
'
|
|
38
|
-
'
|
|
39
|
-
'
|
|
40
|
-
|
|
41
|
-
'
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
],
|
|
48
|
-
'@typescript-eslint/no-unused-vars': [
|
|
49
|
-
'warn',
|
|
50
|
-
{
|
|
51
|
-
argsIgnorePattern: '^_',
|
|
52
|
-
varsIgnorePattern: '^_',
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
'@typescript-eslint/no-unsafe-enum-comparison': 0,
|
|
56
|
-
'@typescript-eslint/no-unnecessary-type-parameters': 0,
|
|
57
|
-
'@stylistic/no-extra-semi': 'warn',
|
|
58
|
-
'max-len': [
|
|
59
|
-
'warn',
|
|
60
|
-
{
|
|
61
|
-
'code': 80,
|
|
62
|
-
},
|
|
63
|
-
],
|
|
64
|
-
'@stylistic/semi': ['warn', 'always'],
|
|
65
|
-
'@stylistic/member-delimiter-style': ['warn', {
|
|
66
|
-
'multiline': {
|
|
67
|
-
'delimiter': 'comma',
|
|
68
|
-
'requireLast': true,
|
|
69
|
-
},
|
|
70
|
-
'singleline': {
|
|
71
|
-
'delimiter': 'comma',
|
|
72
|
-
'requireLast': false,
|
|
73
|
-
},
|
|
74
|
-
'overrides': {
|
|
75
|
-
'interface': {
|
|
76
|
-
'singleline': {
|
|
77
|
-
'delimiter': 'semi',
|
|
78
|
-
'requireLast': false,
|
|
79
|
-
},
|
|
80
|
-
'multiline': {
|
|
81
|
-
'delimiter': 'semi',
|
|
82
|
-
'requireLast': true,
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
}],
|
|
87
|
-
'@typescript-eslint/no-non-null-assertion': 0,
|
|
88
|
-
'@typescript-eslint/no-unused-expressions': 'warn',
|
|
89
|
-
'comma-dangle': ['warn', 'always-multiline'],
|
|
90
|
-
'no-console': 1,
|
|
91
|
-
'no-extra-boolean-cast': 0,
|
|
92
|
-
'indent': ['warn', 2],
|
|
93
|
-
'quotes': ['warn', 'single'],
|
|
94
|
-
'n/no-process-env': 1,
|
|
95
|
-
'n/no-missing-import': 0,
|
|
96
|
-
'n/no-unpublished-import': 0,
|
|
97
|
-
'prefer-const': 'warn',
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
);
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import eslintConfigPrettier from 'eslint-config-prettier/flat';
|
|
3
|
+
import n from 'eslint-plugin-n';
|
|
4
|
+
import { defineConfig, globalIgnores } from 'eslint/config';
|
|
5
|
+
import tseslint from 'typescript-eslint';
|
|
6
|
+
|
|
7
|
+
export default defineConfig([
|
|
8
|
+
// global ignores
|
|
9
|
+
globalIgnores(['**/dist/**']),
|
|
10
|
+
// linting rules (code quality only)
|
|
11
|
+
{
|
|
12
|
+
files: ['**/*.{ts,tsx}'],
|
|
13
|
+
extends: [
|
|
14
|
+
js.configs.recommended,
|
|
15
|
+
...tseslint.configs.recommendedTypeChecked,
|
|
16
|
+
],
|
|
17
|
+
languageOptions: {
|
|
18
|
+
parser: tseslint.parser,
|
|
19
|
+
parserOptions: {
|
|
20
|
+
project: './tsconfig.json',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
plugins: {
|
|
24
|
+
n,
|
|
25
|
+
},
|
|
26
|
+
rules: {
|
|
27
|
+
// code quality / correctness
|
|
28
|
+
'@typescript-eslint/no-unused-vars': [
|
|
29
|
+
'warn',
|
|
30
|
+
{
|
|
31
|
+
argsIgnorePattern: '^_',
|
|
32
|
+
caughtErrorsIgnorePattern: '^_',
|
|
33
|
+
destructuredArrayIgnorePattern: '^_',
|
|
34
|
+
ignoreRestSiblings: true,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
'no-console': 'warn',
|
|
38
|
+
'no-extra-boolean-cast': 'off',
|
|
39
|
+
'no-process-env': 'warn',
|
|
40
|
+
// node correctness
|
|
41
|
+
'n/no-extraneous-import': 'error'
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
// MUST be last — disables ALL formatting rules
|
|
45
|
+
eslintConfigPrettier,
|
|
46
|
+
]);
|
|
@@ -1,56 +1,59 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "express-typescript-example",
|
|
3
|
-
"version": "0.0.0",
|
|
4
|
-
"scripts": {
|
|
5
|
-
"build": "ts-node ./scripts/build.ts",
|
|
6
|
-
"clean-install": "rm -rf ./node_modules && rm -r package-lock.json && npm i",
|
|
7
|
-
"dev": "NODE_ENV=development ts-node ./src",
|
|
8
|
-
"dev:hot": "nodemon --exec \"npm run dev\" --watch ./src --ext .ts",
|
|
9
|
-
"lint": "eslint .",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"jet-
|
|
25
|
-
"jet-
|
|
26
|
-
"jet-
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"@
|
|
34
|
-
"@swc/core": "^1.15.8",
|
|
35
|
-
"@
|
|
36
|
-
"@types/
|
|
37
|
-
"@types/
|
|
38
|
-
"@types/
|
|
39
|
-
"@types/
|
|
40
|
-
"@types/
|
|
41
|
-
"@types/
|
|
42
|
-
"@types/
|
|
43
|
-
"
|
|
44
|
-
"eslint
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "express-typescript-example",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"build": "ts-node ./scripts/build.ts",
|
|
6
|
+
"clean-install": "rm -rf ./node_modules && rm -r package-lock.json && npm i",
|
|
7
|
+
"dev": "NODE_ENV=development ts-node ./src/main",
|
|
8
|
+
"dev:hot": "nodemon --exec \"npm run dev\" --watch ./src --ext .ts",
|
|
9
|
+
"lint": "eslint .",
|
|
10
|
+
"format": "prettier --write .",
|
|
11
|
+
"start": "NODE_ENV=production node -r ./config.js ./dist/main",
|
|
12
|
+
"test": "NODE_ENV=test vitest",
|
|
13
|
+
"type-check": "tsc -b --noEmit"
|
|
14
|
+
},
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=16.0.0"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"cookie-parser": "^1.4.7",
|
|
20
|
+
"dayjs": "^1.11.19",
|
|
21
|
+
"dotenv": "^17.2.3",
|
|
22
|
+
"express": "^5.2.1",
|
|
23
|
+
"helmet": "^8.1.0",
|
|
24
|
+
"jet-env": "^1.1.6",
|
|
25
|
+
"jet-logger": "^2.2.3",
|
|
26
|
+
"jet-paths": "^2.0.1",
|
|
27
|
+
"jet-validators": "2.2.5",
|
|
28
|
+
"jsonfile": "^6.2.0",
|
|
29
|
+
"module-alias": "^2.2.3",
|
|
30
|
+
"morgan": "^1.10.1"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@eslint/js": "^9.39.2",
|
|
34
|
+
"@swc/core": "^1.15.8",
|
|
35
|
+
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
36
|
+
"@types/cookie-parser": "^1.4.10",
|
|
37
|
+
"@types/find": "^0.2.4",
|
|
38
|
+
"@types/fs-extra": "^11.0.4",
|
|
39
|
+
"@types/jsonfile": "^6.1.4",
|
|
40
|
+
"@types/module-alias": "^2.0.4",
|
|
41
|
+
"@types/morgan": "^1.9.10",
|
|
42
|
+
"@types/node": "^25.0.5",
|
|
43
|
+
"@types/supertest": "^6.0.3",
|
|
44
|
+
"eslint": "^9.39.2",
|
|
45
|
+
"eslint-config-prettier": "^10.1.8",
|
|
46
|
+
"eslint-plugin-n": "^17.23.2",
|
|
47
|
+
"find": "^0.3.0",
|
|
48
|
+
"fs-extra": "^11.3.3",
|
|
49
|
+
"jiti": "^2.6.1",
|
|
50
|
+
"nodemon": "^3.1.11",
|
|
51
|
+
"prettier": "^3.8.0",
|
|
52
|
+
"supertest": "^7.2.2",
|
|
53
|
+
"ts-node": "^10.9.2",
|
|
54
|
+
"tsconfig-paths": "^4.2.0",
|
|
55
|
+
"typescript": "^5.9.3",
|
|
56
|
+
"typescript-eslint": "^8.52.0",
|
|
57
|
+
"vitest": "^4.0.16"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -1,28 +1,23 @@
|
|
|
1
|
-
import logger from 'jet-logger';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
await
|
|
16
|
-
await
|
|
17
|
-
|
|
18
|
-
await
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// eslint-disable-next-line n/no-process-exit
|
|
25
|
-
process.exit(1);
|
|
26
|
-
}
|
|
27
|
-
})();
|
|
28
|
-
|
|
1
|
+
import logger from 'jet-logger';
|
|
2
|
+
|
|
3
|
+
import { copy, copyFilesRec, exec, remove } from './common/utils';
|
|
4
|
+
|
|
5
|
+
/******************************************************************************
|
|
6
|
+
Run
|
|
7
|
+
******************************************************************************/
|
|
8
|
+
|
|
9
|
+
(async () => {
|
|
10
|
+
// Remove current build
|
|
11
|
+
await remove('./dist/');
|
|
12
|
+
await exec('npm run lint', '../');
|
|
13
|
+
await exec('tsc --project tsconfig.prod.json', '../');
|
|
14
|
+
// Copy
|
|
15
|
+
await copyFilesRec('./src', './dist', ['.ts']);
|
|
16
|
+
await copy('./temp/config.js', './config.js');
|
|
17
|
+
await copy('./temp/src', './dist');
|
|
18
|
+
await remove('./temp/');
|
|
19
|
+
})().catch((err) => {
|
|
20
|
+
logger.err(err);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
})
|
|
23
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import childProcess from 'child_process';
|
|
1
2
|
import fs from 'fs-extra';
|
|
2
3
|
import logger from 'jet-logger';
|
|
3
|
-
import childProcess from 'child_process';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
|
|
6
6
|
/******************************************************************************
|
|
@@ -12,8 +12,8 @@ import path from 'path';
|
|
|
12
12
|
*/
|
|
13
13
|
export function copy(src: string, dest: string): Promise<void> {
|
|
14
14
|
return new Promise((res, rej) => {
|
|
15
|
-
return fs.copy(src, dest, err => {
|
|
16
|
-
return
|
|
15
|
+
return fs.copy(src, dest, (err) => {
|
|
16
|
+
return !!err ? rej(err) : res();
|
|
17
17
|
});
|
|
18
18
|
});
|
|
19
19
|
}
|
|
@@ -23,8 +23,8 @@ export function copy(src: string, dest: string): Promise<void> {
|
|
|
23
23
|
*/
|
|
24
24
|
export function remove(loc: string): Promise<void> {
|
|
25
25
|
return new Promise((res, rej) => {
|
|
26
|
-
return fs.remove(loc, err => {
|
|
27
|
-
return
|
|
26
|
+
return fs.remove(loc, (err) => {
|
|
27
|
+
return !!err ? rej(err) : res();
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
30
|
}
|
|
@@ -37,7 +37,7 @@ export function exec(cmd: string, loc = './'): Promise<string> {
|
|
|
37
37
|
const callingDir = path.dirname(require.main?.filename ?? './'),
|
|
38
38
|
cwd = path.join(callingDir, loc);
|
|
39
39
|
// Wrap in promise
|
|
40
|
-
return new Promise((res, rej) =>
|
|
40
|
+
return new Promise((res, rej) =>
|
|
41
41
|
childProcess.exec(cmd, { cwd }, (err, stdout, stderr) => {
|
|
42
42
|
if (!!stdout) {
|
|
43
43
|
logger.info(stdout);
|
|
@@ -57,18 +57,18 @@ export function exec(cmd: string, loc = './'): Promise<string> {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
-
* Recursively search for a folder for all files and copy them to the new
|
|
60
|
+
* Recursively search for a folder for all files and copy them to the new
|
|
61
61
|
* destination keeping their paths relative to the "src" param.
|
|
62
|
-
*
|
|
63
|
-
* Example:
|
|
62
|
+
*
|
|
63
|
+
* Example:
|
|
64
64
|
* If file "./src/foo/bar.txt" exists then:
|
|
65
65
|
* copyFilesRec('./src', './dest') => ["./dest/foo/bar.txt"]
|
|
66
|
-
*
|
|
66
|
+
*
|
|
67
67
|
* @param excludeExt Exlude a list of file extensions.
|
|
68
68
|
*/
|
|
69
69
|
export async function copyFilesRec(
|
|
70
70
|
src: string,
|
|
71
|
-
dest: string,
|
|
71
|
+
dest: string,
|
|
72
72
|
excludeExt?: string[],
|
|
73
73
|
): Promise<void> {
|
|
74
74
|
const copyReqs: Promise<void>[] = [];
|