Skip to content

Commit

Permalink
Upgrades dependencies of libms (#943)
Browse files Browse the repository at this point in the history
 - Upgrades the npm packages of libms
   to the latest versions.
 - Upgrades eslint and tsconfig to be compatibe
   with the latest versions of these packages
 - Adds Windows OS to Github actions of libms
  • Loading branch information
nichlaes authored Oct 8, 2024
1 parent 865c74b commit 8313de1
Show file tree
Hide file tree
Showing 25 changed files with 2,483 additions and 2,804 deletions.
20 changes: 17 additions & 3 deletions .github/workflows/lib-ms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ on:
jobs:
test-lib-ms:
name: Test library microservice
runs-on: ubuntu-latest
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: servers/lib
Expand Down Expand Up @@ -67,15 +70,26 @@ jobs:
yarn build
yarn start:pm2
- name: Check server is running
- name: Check server is running (Windows)
if: runner.os == 'Windows'
env:
PORT: 4003
uses: nick-fields/retry@v3
with:
timeout_seconds: 10
max_attempts: 4
command: "Invoke-WebRequest -Uri http://localhost:${{ env.PORT }}/lib/files -Method Head -UseBasicParsing"

- name: Check server is running (Linux)
if: runner.os != 'Windows'
env:
PORT: 4003
uses: nick-fields/retry@v3
with:
timeout_seconds: 10
max_attempts: 4
command: "curl -f -LI http://localhost:${{ env.PORT }}/lib/files"

- name: Run http test
env:
PORT: 4003
Expand Down
6 changes: 0 additions & 6 deletions servers/lib/.eslintignore

This file was deleted.

53 changes: 0 additions & 53 deletions servers/lib/.eslintrc

This file was deleted.

1 change: 0 additions & 1 deletion servers/lib/compose.lib.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3'
services:
libms:
image: intocps/libms:latest
Expand Down
60 changes: 60 additions & 0 deletions servers/lib/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { fixupConfigRules } from '@eslint/compat';
import { FlatCompat } from '@eslint/eslintrc';
import globals from 'globals';
import jest from 'eslint-plugin-jest';
import js from '@eslint/js';
import prettier from 'eslint-config-prettier';
import ts from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import imprt from 'eslint-plugin-import'; // 'import' is ambiguous & prettier has trouble

const flatCompat = new FlatCompat();

export default [
{
...js.configs.recommended,
files: ['src/**', 'test/**'],
},
{
...fixupConfigRules(flatCompat.extends('airbnb-base')),
files: ['src/**', 'test/**'],
},
prettier,
{
languageOptions: {
globals: {
...globals.jest,
...globals.node,
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parser: tsParser,
parserOptions: {
project: './tsconfig.json',
requireConfigFile: false,
ecmaVersion: 2022,
ecmaFeatures: { modules: true },
},
},
files: ['src/**', 'test/**'],
plugins: { jest, '@typescript-eslint': ts, import: imprt, ts },
rules: {
'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
'no-console': 'error',
'import/first': 'error',
'linebreak-style': 0, // disable linter linebreak rule, to allow for both unix and windows developement
'import/no-unresolved': 'off', // Whatever IDE will pass an error if if the module is not found, so no reason for this..
'import/extensions': 'off', // That includes the production build.. We use linter for code checking / clean code optimization..
'no-use-before-define': 'off',
},
ignores: [
'api/*',
'build/*',
'coverage/*',
'dist/*',
'node_modules/*',
'script/*',
'src/types.ts',
],
},
];
31 changes: 0 additions & 31 deletions servers/lib/jest.config.json

This file was deleted.

47 changes: 47 additions & 0 deletions servers/lib/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { createDefaultEsmPreset, type JestConfigWithTsJest } from 'ts-jest';

const jestConfig: JestConfigWithTsJest = {
testEnvironment: 'node',
transform: {
...createDefaultEsmPreset().transform,
'\\.[jt]sx?$": "ts-jest': [
'ts-jest',
{
useESM: true,
},
],
},
collectCoverage: true,
coverageReporters: ['text', 'cobertura', 'clover', 'lcov', 'json'],
collectCoverageFrom: ['src/**/*.{ts,js}'],
coveragePathIgnorePatterns: [
'node_modules',
'./dist',
'./src/app.module.ts',
'./src/main.ts',
'./src/bootstrap.ts',
],
extensionsToTreatAsEsm: ['.ts'],
moduleFileExtensions: ['js', 'json', 'ts'],
modulePathIgnorePatterns: [],
coverageDirectory: '<rootDir>/coverage/',
coverageThreshold: {
global: {
branches: 20,
functions: 30,
lines: 50,
statements: 50,
},
},
verbose: true,
testRegex: './test/.*\\.spec.tsx?$',
modulePaths: ['<rootDir>', '<rootDir>/src/', '<rootDir>/test/'],
moduleDirectories: ['node_modules', 'src', 'test'],
rootDir: './',
roots: ['<rootDir>', 'src/', 'test/'],
moduleNameMapper: {
'^(\\.\\.?\\/.+)\\.jsx?$': '$1',
},
};

export default jestConfig;
91 changes: 48 additions & 43 deletions servers/lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,72 +10,77 @@
],
"private": false,
"license": "SEE LICENSE IN <LICENSE.md>",
"type": "module",
"main": "dist/src/main.js",
"scripts": {
"build": "tsc",
"clean": "npx rimraf build node_modules coverage dist src.svg test.svg",
"format": "prettier --ignore-path ../.gitignore --write \"**/*.{ts,tsx,css,scss}\"",
"graph": "npx madge --image src.svg src && npx madge --image test.svg test",
"start": "node dist/src/main.js",
"start:pm2": "pm2 start pm2.config.js",
"start": "tsc & node dist/src/main.js",
"start:pm2": "pm2 start pm2.config.cjs",
"stop:pm2": "pm2 delete libms",
"syntax": "eslint . --fix",
"pretest": "npx shx cp test/data/user2/tools/README.md ../../files/user2/tools/README.md",
"posttest": "npx rimraf ../../files/user2/tools/README.md",
"test:all": "npx cross-env LOCAL_PATH=test/data jest --testPathIgnorePatterns=cloudcmd --coverage",
"test:e2e": "npx cross-env LOCAL_PATH=test/data jest --config ./test/jest-e2e.json --coverage",
"test:all": "npx cross-env NODE_OPTIONS=--experimental-vm-modules LOCAL_PATH=test/data jest --testPathIgnorePatterns=cloudcmd --coverage",
"test:e2e": "npx cross-env NODE_OPTIONS=--experimental-vm-modules LOCAL_PATH=test/data jest --config ./test/jest-e2e.json --coverage",
"test:http": "yarn build && pm2 start -f --name libms-test dist/src/main.js -- -c .env -H ./config/http.json && jest test/cloudcmd --coverage --coverageThreshold=\"{}\" && pm2 delete libms-test",
"test:http-nocov": "yarn build && pm2 start -f --name libms-test dist/src/main.js -- -c .env -H ./config/http.json && jest test/cloudcmd --coverage=false && pm2 delete libms-test",
"test:http-github": "jest test/cloudcmd --coverage --coverageThreshold=\"{}\"",
"test:int": "npx cross-env LOCAL_PATH=test/data jest ../test/integration --coverage",
"test:int": "npx cross-env NODE_OPTIONS=--experimental-vm-modules LOCAL_PATH=test/data jest ../test/integration --coverage",
"test:nocov": "yarn test:http-nocov && npx cross-env LOCAL_PATH=test/data jest --testPathIgnorePatterns=cloudcmd --coverage=false",
"test:unit": "npx cross-env LOCAL_PATH=test/data jest ../test/unit --coverage"
"test:unit": "npx cross-env NODE_OPTIONS=--experimental-vm-modules LOCAL_PATH=test/data jest ../test/unit --coverage"
},
"bin": "./dist/src/main.js",
"dependencies": {
"@apollo/client": "^3.8.9",
"@apollo/server": "^4.10.0",
"@nestjs/apollo": "^12.0.11",
"@nestjs/common": "^10.3.7",
"@nestjs/config": "^3.2.0",
"@nestjs/core": "^10.3.3",
"@nestjs/graphql": "^12.0.11",
"@nestjs/platform-express": "^10.3.7",
"axios": "^1.5.1",
"cloudcmd": "^16.17.7",
"commander": "^11.1.0",
"dotenv": "^16.3.1",
"graphql": "^16.8.1",
"mock-fs": "^5.2.0",
"reflect-metadata": "^0.2.1",
"@apollo/client": "^3.11.8",
"@apollo/server": "^4.11.0",
"@nestjs/apollo": "^12.2.0",
"@nestjs/common": "^10.4.4",
"@nestjs/config": "^3.2.3",
"@nestjs/core": "^10.4.4",
"@nestjs/graphql": "^12.2.0",
"@nestjs/platform-express": "^10.4.4",
"axios": "^1.7.7",
"cloudcmd": "^18.1.0",
"commander": "^12.1.0",
"dotenv": "^16.4.5",
"globals": "^15.9.0",
"graphql": "^16.9.0",
"mock-fs": "^5.3.0",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1",
"socket.io": "^4.7.2",
"type-graphql": "^2.0.0-beta.3"
"socket.io": "^4.8.0",
"type-graphql": "^2.0.0-rc.2"
},
"devDependencies": {
"@nestjs/cli": "^10.3.2",
"@nestjs/schematics": "^10.1.1",
"@nestjs/testing": "^10.3.3",
"@types/express": "^4.17.21",
"@types/jest": "^29.5.12",
"@types/node": "20.12.5",
"@eslint/compat": "^1.1.1",
"@eslint/eslintrc": "^3.1.0",
"@nestjs/cli": "^10.4.5",
"@nestjs/schematics": "^10.1.4",
"@nestjs/testing": "^10.4.4",
"@types/express": "^5.0.0",
"@types/jest": "^29.5.13",
"@types/node": "22.7.0",
"@types/supertest": "^6.0.2",
"@typescript-eslint/eslint-plugin": "^8.4.0",
"@typescript-eslint/parser": "^8.4.0",
"@typescript-eslint/eslint-plugin": "^8.8.0",
"@typescript-eslint/parser": "^8.8.0",
"cross-fetch": "^4.0.0",
"eslint": "^8.56.0",
"eslint": "^9.11.1",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^28.2.0",
"eslint-plugin-prettier": "^5.1.3",
"graphql-scalars": "^1.22.2",
"jest": "29.7.0",
"prettier": "^3.2.2",
"react": "^18.2.0",
"supertest": "^6.3.4",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jest": "^28.8.3",
"eslint-plugin-prettier": "^5.2.1",
"graphql-scalars": "^1.23.0",
"jest": "^29.7.0",
"prettier": "^3.3.3",
"react": "^18.3.1",
"supertest": "^7.0.0",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"tsconfig-paths": "4.2.0",
"typescript": "^5.2.2"
"typescript": "^5.6.2"
}
}
File renamed without changes.
2 changes: 1 addition & 1 deletion servers/lib/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { ApolloDriver } from '@nestjs/apollo';
import { join } from 'path';
import FilesModule from './files/files.module';
import FilesModule from './files/files.module.js';

@Module({
imports: [
Expand Down
4 changes: 2 additions & 2 deletions servers/lib/src/bootstrap.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { NestFactory } from '@nestjs/core';
import { ConfigService } from '@nestjs/config';
import * as dotenv from 'dotenv';
import AppModule from './app.module';
import cloudCMD from './cloudcmd/cloudcmd';
import AppModule from './app.module.js';
import cloudCMD from './cloudcmd/cloudcmd.js';

type BootstrapOptions = {
config?: string;
Expand Down
2 changes: 1 addition & 1 deletion servers/lib/src/cloudcmd/cloudcmd.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { INestApplication } from '@nestjs/common';
import { Server } from 'socket.io';
import * as cloudcmd from 'cloudcmd';
import cloudcmd from 'cloudcmd';
import { join, relative } from 'path';

const isWindowsAbsolutePath = (filesPath: string) => filesPath.includes(':');
Expand Down
Loading

0 comments on commit 8313de1

Please sign in to comment.