Skip to content

Commit a9ff053

Browse files
authored
Merge pull request #166 from chocolat-chaud-io/151-update-libraries
fix: updated all libraries to their latest versions
2 parents 06df447 + 8146195 commit a9ff053

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+29729
-31180
lines changed

.eslintrc.json

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"root": true,
3+
"ignorePatterns": ["**/*"],
4+
"plugins": ["@nrwl/nx"],
5+
"overrides": [
6+
{
7+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
8+
"rules": {
9+
"@nrwl/nx/enforce-module-boundaries": [
10+
"error",
11+
{
12+
"enforceBuildableLibDependency": true,
13+
"allow": [],
14+
"depConstraints": [
15+
{
16+
"sourceTag": "*",
17+
"onlyDependOnLibsWithTags": ["*"]
18+
}
19+
]
20+
}
21+
]
22+
}
23+
},
24+
{
25+
"files": ["*.ts", "*.tsx"],
26+
"extends": ["plugin:@nrwl/nx/typescript"],
27+
"rules": {}
28+
},
29+
{
30+
"files": ["*.js", "*.jsx"],
31+
"extends": ["plugin:@nrwl/nx/javascript"],
32+
"rules": {}
33+
}
34+
]
35+
}

.github/scripts/get-base.sh

-2
This file was deleted.

.github/scripts/get-head.sh

-2
This file was deleted.

.github/workflows/nx-affected.yml renamed to .github/workflows/build-test-release.yml

+30-31
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,9 @@ on:
77
- master
88

99
jobs:
10-
build:
10+
build-test-release:
1111
runs-on: ubuntu-latest
1212

13-
strategy:
14-
matrix:
15-
node-version: [14.13.1]
16-
1713
steps:
1814
- name: Cancel previous runs
1915
uses: styfle/[email protected]
@@ -28,17 +24,10 @@ jobs:
2824
with:
2925
fetch-depth: 0
3026

31-
- name: Set head
32-
run: sh .github/scripts/get-head.sh >> $GITHUB_ENV
33-
env:
34-
PR_HEAD: ${{ github.event.pull_request.head.sha }}
35-
MERGE_HEAD: ${{ github.event.after }}
36-
37-
- name: Set base
38-
run: sh .github/scripts/get-base.sh >> $GITHUB_ENV
39-
env:
40-
PR_BASE: ${{ github.event.pull_request.base.sha }}
41-
MERGE_BASE: ${{ github.event.before }}
27+
- name: Derive appropriate SHAs for base and head for `nx affected` commands
28+
uses: nrwl/nx-set-shas@v2
29+
with:
30+
main-branch-name: master
4231

4332
- name: Inject Nx Cloud token
4433
shell: bash
@@ -50,33 +39,43 @@ jobs:
5039
- name: Setup postgres container
5140
run: docker-compose -f $GITHUB_WORKSPACE/apps/database/postgres/docker-compose.yml up -d
5241

53-
- name: Use Node.js ${{ matrix.node-version }}
54-
uses: actions/setup-node@v2-beta
42+
- name: Setup node.js 14.18.0
43+
uses: actions/setup-node@v2
5544
with:
56-
node-version: ${{ matrix.node-version }}
45+
node-version: 14.18.0
46+
47+
- name: Cache dependencies
48+
id: cache
49+
uses: actions/cache@v2
50+
with:
51+
path: |
52+
./node_modules
53+
/home/runner/.cache/Cypress
54+
key: modules-${{ hashFiles('package-lock.json') }}
5755

5856
- name: Install npm packages
57+
if: steps.cache.outputs.cache-hit != 'true'
5958
run: npm i
6059

61-
- name: Lint files
62-
run: npm run affected:lint -- --base=$BASE --head=$HEAD
60+
- name: Start api
61+
run: npm run typeorm -- migration:run && npm start api &
62+
env:
63+
TEST: true
6364

6465
- name: Enforce naming conventions
6566
run: npm run lint:file-folder-convention
6667

67-
- name: Build affected apps
68-
run: npm run affected:build -- --base=$BASE --head=$HEAD
68+
- name: Lint affected files
69+
run: npm run affected:lint
6970

70-
- name: Start api
71-
run: npm run typeorm -- migration:run && npm start api &
72-
env:
73-
TEST: true
71+
- name: Build affected apps
72+
run: npm run affected:build
7473

75-
- name: Run tests
76-
run: npm run affected:test -- --base=$BASE --head=$HEAD --code-coverage
74+
- name: Test affected apps
75+
run: npm run affected:test -- --code-coverage
7776

78-
- name: Run e2e tests
79-
run: npm run affected:e2e -- --base=$BASE --head=$HEAD
77+
- name: Test affected apps e2e
78+
run: npm run affected:e2e
8079

8180
- name: Codecov
8281
uses: codecov/codecov-action@v2

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ npm run rename-project -- --organization {YOUR_ORGANIZATION_NAME} --project {YOU
138138

139139
\*Note: I highly recommend that the project name is the same as your git repository.
140140

141-
The file will delete itself once it has been completed.
142141
On completion, you will see the following message:
143142

144143
![project appropriation success](readme-assets/project-appropriation-success.png)

apps/api/jest.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ module.exports = {
1212
moduleFileExtensions: ["ts", "js", "html"],
1313
coverageDirectory: "../../coverage/apps/api",
1414
coveragePathIgnorePatterns: ["./src/config/"],
15+
testEnvironment: "node",
1516
}

apps/api/src/config/configuration.ts

+15-18
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,21 @@ export const configuration = () => ({
1414
...ormConfig,
1515
certificateAuthority: process.env.DATABASE_CA_CERT,
1616
keepConnectionAlive: false,
17-
entities: [Todo],
18-
logging: ["error"],
19-
retries: 1,
17+
retryAttempts: 1,
2018
},
2119
})
2220

23-
export const getOrmConfigFn = async (configService: ConfigService): Promise<TypeOrmModuleOptions> =>
24-
Promise.resolve({
25-
type: "postgres",
26-
host: configService.get("database.host"),
27-
port: configService.get<number>("database.port"),
28-
database: configService.get("database.name"),
29-
username: configService.get("database.username"),
30-
password: configService.get("database.password"),
31-
synchronize: configService.get("database.synchronize"),
32-
keepConnectionAlive: configService.get("database.keepConnectionAlive"),
33-
ssl: configService.get("database.certificateAuthority") ?? false,
34-
entities: configService.get("database.entities"),
35-
logging: configService.get("database.logging"),
36-
retries: configService.get("database.retries"),
37-
})
21+
export const getOrmConfigFn = async (configService: ConfigService): Promise<TypeOrmModuleOptions> => ({
22+
type: "postgres",
23+
host: configService.get("database.host"),
24+
port: configService.get<number>("database.port"),
25+
database: configService.get("database.database"),
26+
username: configService.get("database.username"),
27+
password: configService.get("database.password"),
28+
synchronize: configService.get("database.synchronize"),
29+
keepConnectionAlive: configService.get("database.keepConnectionAlive"),
30+
ssl: configService.get("database.certificateAuthority") ?? false,
31+
entities: [Todo],
32+
logging: ["error"],
33+
retryAttempts: configService.get<number>("database.retryAttempts"),
34+
})

apps/api/src/endpoints/health/health.e2e.spec.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ describe("Health", () => {
1010
testingHelper = await new TestingHelper().initializeModuleAndApp("health", [HealthModule])
1111
})
1212

13-
beforeEach(() => testingHelper.reloadFixtures())
13+
afterAll(async () => {
14+
await testingHelper.shutdownServer()
15+
})
1416

1517
describe("GET /health", () => {
1618
it("should return status 200", async () => {

apps/api/src/utils/test.ts

+10-15
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,35 @@
11
import fs from "fs"
22
import path from "path"
33

4-
import { INestApplication } from "@nestjs/common"
5-
import { DynamicModule } from "@nestjs/common/interfaces/modules/dynamic-module.interface"
6-
import { ForwardReference } from "@nestjs/common/interfaces/modules/forward-reference.interface"
4+
import { ModuleMetadata } from "@nestjs/common/interfaces/modules/module-metadata.interface"
75
import { Provider } from "@nestjs/common/interfaces/modules/provider.interface"
8-
import { Type } from "@nestjs/common/interfaces/type.interface"
9-
import { FastifyAdapter } from "@nestjs/platform-fastify"
6+
import { FastifyAdapter, NestFastifyApplication } from "@nestjs/platform-fastify"
107
import { Test, TestingModule } from "@nestjs/testing"
118
import { Connection, createConnection } from "typeorm"
12-
import { getRepository } from "typeorm"
139
import { Builder, Loader, Parser, Resolver, fixturesIterator } from "typeorm-fixtures-cli/dist"
10+
import { ConnectionOptions } from "typeorm/connection/ConnectionOptions"
1411

1512
import { configurationTest } from "../config/configuration.test"
1613
import { getRootModuleImports } from "./utils"
1714

1815
export class TestingHelper {
1916
module: TestingModule
20-
app: INestApplication
17+
app: NestFastifyApplication
2118

22-
async initializeModuleAndApp(
23-
testName: string,
24-
importedModules: Array<Type<unknown> | DynamicModule | Promise<DynamicModule> | ForwardReference>,
25-
providers: Provider[] = []
26-
) {
19+
async initializeModuleAndApp(testName: string, importedModules: ModuleMetadata["imports"], providers: Provider[] = undefined) {
2720
const databaseName = `stator_test_${testName}`
2821
const configuration = configurationTest.bind(this, databaseName)
2922

30-
const connection = await createConnection({ ...configuration().database })
23+
const connectionOptions: ConnectionOptions = { ...configuration().database }
24+
const connection = await createConnection(connectionOptions)
3125
await this.createDatabaseIfNotExist(connection, databaseName)
3226

3327
this.module = await Test.createTestingModule({
3428
imports: [...getRootModuleImports(configuration), ...importedModules],
3529
providers: providers,
3630
}).compile()
3731

38-
this.app = this.module.createNestApplication(new FastifyAdapter())
32+
this.app = this.module.createNestApplication<NestFastifyApplication>(new FastifyAdapter())
3933

4034
await this.app.init()
4135
await this.app.getHttpAdapter().getInstance().ready()
@@ -56,7 +50,7 @@ export class TestingHelper {
5650

5751
for (const fixture of fixtures) {
5852
const entity = await builder.build(fixture)
59-
await getRepository(entity.constructor.name).save(entity)
53+
await connection.getRepository(entity.constructor.name).save(entity)
6054
}
6155
}
6256

@@ -81,5 +75,6 @@ PERFORM dblink_exec('', 'CREATE DATABASE ${databaseName}');
8175
EXCEPTION WHEN duplicate_database THEN RAISE NOTICE '%, skipping', SQLERRM USING ERRCODE = SQLSTATE;
8276
END
8377
$$;`)
78+
await connection.close()
8479
}
8580
}

apps/api/src/utils/utils.ts

+8-11
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,14 @@ import winston from "winston"
77
import { getOrmConfigFn } from "../config/configuration"
88
import { environment } from "../environments/environment"
99

10-
export const getWinstonConsoleFormat = () => {
11-
if (environment.production) {
12-
return winston.format.json()
13-
}
14-
15-
return winston.format.combine(
16-
winston.format.timestamp(),
17-
winston.format.ms(),
18-
nestWinstonModuleUtilities.format.nestLike("MyApp", { prettyPrint: true })
19-
)
20-
}
10+
export const getWinstonConsoleFormat = () =>
11+
environment.production
12+
? winston.format.json()
13+
: winston.format.combine(
14+
winston.format.timestamp(),
15+
winston.format.ms(),
16+
nestWinstonModuleUtilities.format.nestLike("MyApp", { prettyPrint: true })
17+
)
2118

2219
export const getRootModuleImports = (configuration: ConfigFactory) => [
2320
ConfigModule.forRoot({ isGlobal: true, load: [configuration] }),

apps/api/tsconfig.app.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
"emitDecoratorMetadata": true,
77
"target": "es2015"
88
},
9-
"exclude": ["**/*.spec.ts"],
9+
"exclude": ["**/*.spec.ts", "**/*.test.ts"],
1010
"include": ["**/*.ts", "**/*.html"]
1111
}

apps/api/tsconfig.spec.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
"module": "commonjs",
66
"types": ["jest", "node"]
77
},
8-
"include": ["**/*.spec.ts", "**/*.d.ts"]
8+
"include": ["**/*.spec.ts", "**/*.test.ts", "**/*.d.ts"]
99
}

apps/api/webpack.config.ts

-8
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
const path = require("path")
33
const webpack = require("webpack")
44
const ts = require("typescript")
5-
const HookShellScriptPlugin = require("hook-shell-script-webpack-plugin")
6-
const ExtraWatchWebpackPlugin = require("extra-watch-webpack-plugin")
75

86
/**
97
* Extend the default Webpack configuration from nx / ng.
@@ -18,12 +16,6 @@ module.exports = config => {
1816
new webpack.ProvidePlugin({
1917
openapi: "@nestjs/swagger",
2018
}),
21-
new ExtraWatchWebpackPlugin({
22-
dirs: ["libs/models/src"],
23-
}),
24-
new HookShellScriptPlugin({
25-
watchRun: ["node ./tools/generators/generate-entity-index-file.js"],
26-
}),
2719
]
2820

2921
return config

apps/cli/.eslintrc.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"extends": ["../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {
8+
"no-irregular-whitespace": "off"
9+
}
10+
},
11+
{
12+
"files": ["*.ts", "*.tsx"],
13+
"rules": {}
14+
},
15+
{
16+
"files": ["*.js", "*.jsx"],
17+
"rules": {}
18+
}
19+
]
20+
}

apps/cli/jest.config.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
displayName: "cli",
3+
preset: "../../jest.preset.js",
4+
globals: {
5+
"ts-jest": {
6+
tsconfig: "<rootDir>/tsconfig.spec.json",
7+
},
8+
},
9+
testEnvironment: "node",
10+
transform: {
11+
"^.+\\.[tj]s$": "ts-jest",
12+
},
13+
moduleFileExtensions: ["ts", "js", "html"],
14+
coverageDirectory: "../../coverage/apps/cli",
15+
}

0 commit comments

Comments
 (0)