Merge branch 'ci' into 'main'

Added CI

See merge request root/fileserver!1
This commit is contained in:
Mutzi 2022-08-23 18:03:06 +00:00
commit 2e5d965af3
10 changed files with 12879 additions and 40392 deletions

78
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,78 @@
image: node:latest
stages:
- test
- build
- package
cache:
- key:
files:
- yarn.lock
- frontend/yarn.lock
paths:
- node_modules
- frontend/node_modules
before_script:
- yarn install
- cd frontend
- yarn install
- cd ..
test_backend:
stage: test
script:
- yarn lint
test_frontend:
stage: test
script:
- cd frontend
- yarn lint
build_backend:
stage: build
needs:
- job: test_backend
artifacts: false
script:
- yarn webpack
artifacts:
paths:
- dist/
expire_in: 1h
build_frontend:
stage: build
needs:
- job: test_frontend
artifacts: false
script:
- cd frontend
- yarn build
artifacts:
paths:
- frontend/dist/
expire_in: 1h
package_server:
stage: package
cache: []
before_script: []
needs:
- job: build_backend
artifacts: true
- job: build_frontend
artifacts: true
script:
- TMP=$(mktemp -d)
- mv dist/* "$TMP"
- mkdir "$TMP/frontend"
- mv frontend/dist/* "$TMP/frontend"
- rm -r *
- rm -r .* || true
- mv "$TMP/"* .
artifacts:
paths:
- .

21588
frontend/package-lock.json generated

File diff suppressed because it is too large Load Diff

6789
frontend/yarn.lock Normal file

File diff suppressed because it is too large Load Diff

18695
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,88 +1,94 @@
{ {
"name": "nest-typescript-starter", "name": "fileserver",
"private": true, "private": true,
"version": "1.0.0", "version": "1.0.0",
"description": "Nest TypeScript starter repository", "description": "Crackhead fileserver",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"prebuild": "rimraf dist", "prebuild": "rimraf dist",
"build": "nest build", "build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start", "start": "nest start",
"start:dev": "nest start --watch", "start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch", "lint": "eslint \"src/**/*.ts\"",
"start:prod": "node dist/main", "lint-fix": "eslint \"src/**/*.ts\" --fix",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", "test": "jest",
"test": "jest", "test:watch": "jest --watch",
"test:watch": "jest --watch", "test:cov": "jest --coverage",
"test:cov": "jest --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", "test:e2e": "jest --config ./test/jest-e2e.json",
"test:e2e": "jest --config ./test/jest-e2e.json", "webpack": "webpack --config webpack.config.ts",
"genapi": "ts-node tools/apigen.ts" "genapi": "ts-node tools/apigen.ts"
}, },
"dependencies": { "dependencies": {
"@fastify/multipart": "^7.1.0", "@fastify/multipart": "^7.1.0",
"@fastify/static": "^6.5.0", "@fastify/static": "^6.5.0",
"@nestjs/common": "^9.0.8", "@nestjs/common": "^9.0.8",
"@nestjs/core": "^9.0.8", "@nestjs/core": "^9.0.8",
"@nestjs/jwt": "^9.0.0", "@nestjs/jwt": "^9.0.0",
"@nestjs/passport": "^9.0.0", "@nestjs/passport": "^9.0.0",
"@nestjs/platform-fastify": "^9.0.8", "@nestjs/platform-fastify": "^9.0.8",
"@nestjs/serve-static": "^3.0.0", "@nestjs/serve-static": "^3.0.0",
"@nestjs/typeorm": "^9.0.0", "@nestjs/typeorm": "^9.0.0",
"@typescript-eslint/typescript-estree": "^5.33.0", "argon2": "^0.28.7",
"argon2": "^0.28.7", "jsonwebtoken": "^8.5.1",
"jsonwebtoken": "^8.5.1", "passport": "^0.6.0",
"passport": "^0.6.0", "passport-jwt": "^4.0.0",
"passport-jwt": "^4.0.0", "passport-local": "^1.0.0",
"passport-local": "^1.0.0", "reflect-metadata": "^0.1.13",
"reflect-metadata": "^0.1.13", "rxjs": "^7.5.6",
"rimraf": "^3.0.2", "sqlite3": "^5.0.11",
"rxjs": "^7.5.6", "typeorm": "^0.3.7"
"sqlite3": "^5.0.11", },
"typeorm": "^0.3.7" "devDependencies": {
}, "@nestjs/cli": "^9.0.0",
"devDependencies": { "@nestjs/schematics": "^9.0.1",
"@nestjs/cli": "^9.0.0", "@nestjs/testing": "^9.0.8",
"@nestjs/schematics": "^9.0.1", "@types/express": "^4.17.13",
"@nestjs/testing": "^9.0.8", "@types/jest": "^28.1.6",
"@types/express": "^4.17.13", "@types/jsonwebtoken": "^8.5.8",
"@types/jest": "^28.1.6", "@types/node": "^18.6.5",
"@types/jsonwebtoken": "^8.5.8", "@types/passport-jwt": "^3.0.6",
"@types/node": "^18.6.5", "@types/passport-local": "^1.0.34",
"@types/passport-jwt": "^3.0.6", "@types/supertest": "^2.0.12",
"@types/passport-local": "^1.0.34", "@types/webpack": "^5.28.0",
"@types/supertest": "^2.0.12", "@types/webpack-node-externals": "^2.5.3",
"@typescript-eslint/eslint-plugin": "^5.33.0", "@typescript-eslint/eslint-plugin": "^5.33.0",
"@typescript-eslint/parser": "^5.33.0", "@typescript-eslint/parser": "^5.33.0",
"eslint": "^8.21.0", "@typescript-eslint/typescript-estree": "^5.33.0",
"eslint-config-prettier": "^8.5.0", "copy-webpack-plugin": "^11.0.0",
"eslint-plugin-prettier": "^4.2.1", "eslint": "^8.21.0",
"jest": "^28.1.3", "eslint-config-prettier": "^8.5.0",
"prettier": "^2.7.1", "eslint-plugin-prettier": "^4.2.1",
"source-map-support": "^0.5.21", "jest": "^28.1.3",
"supertest": "^6.2.4", "prettier": "^2.7.1",
"ts-jest": "^28.0.7", "rimraf": "^3.0.2",
"ts-loader": "^9.3.1", "source-map-support": "^0.5.21",
"ts-node": "^10.9.1", "supertest": "^6.2.4",
"tsconfig-paths": "^4.1.0", "ts-jest": "^28.0.7",
"typescript": "^4.7.4" "ts-loader": "^9.3.1",
}, "ts-node": "^10.9.1",
"jest": { "tsconfig-paths": "^4.1.0",
"moduleFileExtensions": [ "typescript": "^4.7.4",
"js", "webpack": "^5.74.0",
"json", "webpack-cli": "^4.10.0",
"ts" "webpack-node-externals": "^3.0.0"
], },
"rootDir": "src", "jest": {
"testRegex": ".*\\.spec\\.ts$", "moduleFileExtensions": [
"transform": { "js",
"^.+\\.(t|j)s$": "ts-jest" "json",
}, "ts"
"collectCoverageFrom": [ ],
"**/*.(t|j)s" "rootDir": "src",
], "testRegex": ".*\\.spec\\.ts$",
"coverageDirectory": "../coverage", "transform": {
"testEnvironment": "node" "^.+\\.(t|j)s$": "ts-jest"
} },
} "collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}

View File

@ -7,6 +7,8 @@ import AuthModule from './modules/auth';
import { ServeStaticModule } from '@nestjs/serve-static'; import { ServeStaticModule } from '@nestjs/serve-static';
import { join } from 'path'; import { join } from 'path';
declare const PROD: boolean | undefined;
@Controller('test') @Controller('test')
class TestController { class TestController {
@Role(UserRole.USER) @Role(UserRole.USER)
@ -31,7 +33,10 @@ class TestController {
entities: [User, INode, JWTToken] entities: [User, INode, JWTToken]
}), }),
ServeStaticModule.forRoot({ ServeStaticModule.forRoot({
rootPath: join(__dirname, '..', '..', 'frontend', 'dist'), rootPath:
typeof PROD !== 'undefined' && PROD
? join(__dirname, 'frontend')
: join(__dirname, '..', '..', 'frontend', 'dist'),
exclude: ['/api*'] exclude: ['/api*']
}), }),
FileSystemModule, FileSystemModule,

View File

@ -1,4 +0,0 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "dist", "test", "**/*spec.ts", "frontend"]
}

View File

@ -1,16 +1,17 @@
{ {
"compilerOptions": { "compilerOptions": {
"module": "commonjs", "module": "commonjs",
"declaration": true, "declaration": false,
"removeComments": true, "removeComments": true,
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"target": "es2017", "target": "es2017",
"sourceMap": true, "sourceMap": true,
"outDir": "./dist", "outDir": "./dist",
"baseUrl": "./", "baseUrl": "./",
"incremental": true, "incremental": true,
"skipLibCheck": true "skipLibCheck": true
} },
} "exclude": ["node_modules", "dist", "test", "**/*spec.ts", "frontend"]
}

55
webpack.config.ts Normal file
View File

@ -0,0 +1,55 @@
import { DefinePlugin } from 'webpack';
import * as nodeExternals from 'webpack-node-externals';
import * as copyPlugin from 'copy-webpack-plugin';
import { resolve } from 'path';
function transform_package(input: Buffer): string {
const pkg = JSON.parse(input.toString());
delete pkg['devDependencies'];
delete pkg['jest'];
pkg['scripts'] = {
start: 'node server.js'
};
return JSON.stringify(pkg);
}
export default {
entry: './src/main.ts',
plugins: [
new DefinePlugin({
PROD: JSON.stringify(true)
}),
new copyPlugin({
patterns: [
{
from: resolve(__dirname, 'package.json'),
to: resolve(__dirname, 'dist', 'package.json'),
transform: transform_package
},
{
from: resolve(__dirname, 'yarn.lock'),
to: resolve(__dirname, 'dist', 'yarn.lock')
}
]
})
],
module: {
rules: [
{
test: /\.ts?$/,
use: 'ts-loader'
}
]
},
externalsPresets: { node: true },
mode: 'production',
devtool: 'inline-source-map',
resolve: {
extensions: ['.ts', '.js']
},
output: {
filename: 'server.js',
path: resolve(__dirname, 'dist')
},
externals: [nodeExternals()]
};

5840
yarn.lock Normal file

File diff suppressed because it is too large Load Diff