Skip to content

Commit

Permalink
Nx migration (#275)
Browse files Browse the repository at this point in the history
* refactor: created apps and libs folder

* init: new project.json file for each project

* refactor: changed the lib folder to src in each package

* refgactor: added new files to gitignore

* fix: updated github action to support the folder rename

* fix: test fix to support the new src folder

* feat: NX

* feat: build and only then install

* test: added general jest config file

* test: build test files in commons

* feat: nx will build the test-commons package

* test: updated jest for test-commons

* added nx files to config package

* added NX files to the security package

* added NX files to the core package

* updated the workapace files

* fix: right import from db-commons

* megartion to postgres package

* updated some jest config files in core package

* NX migration to the mysql package

* updated the mysql test script

* NX migration to the mssql package

* NX migration to the spanner package

* NX migration to the mongo package

* NX migration to the firestore package

* NX migration to the firestore package

* NX migration to the airtable package

* NX migration to the bigquery package

* NX migration to the google-sheets package

* fixed the jest config of the security package

* NX migration to the external-db app

* refactor: rearranging files in the test-commons package

* feat: new tool that will publish the packages

* nx files

* nop

* refactor: db-commons files rearrangement

* nop

* skip-nx-cache in tests

* updated github test yml

* disable google-sheets tests for now

* test: fixed the test for firestore

* spec files will not be compiled

* refactor: new build stage in the main dockerfile

* Merge branch 'master' into nx-migration

* fix: added new isObject function to the item_trasformer

* feat: updated the package name in the publish script
  • Loading branch information
MXPOL committed Jun 8, 2022
1 parent eb0abfc commit a29fba4
Show file tree
Hide file tree
Showing 528 changed files with 2,664 additions and 993 deletions.
26 changes: 25 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
packages/**/node_modules
# FOLDERS

node_modules
.vscode
.github
.husky
scripts
tmp
dist
tools


# FILES

npm-debug.log
Dockerfile*
docker-compose*
.dockerignore
.git
.gitignore
README.md
LICENSE
.eslintcache
.eslintrc.json
.nvmrc
127 changes: 53 additions & 74 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,84 +5,63 @@
"es2021": true,
"node": true
},
"settings": {
"jest": {
"version": "latest"
}
},

"extends": ["eslint:recommended", "plugin:jest/recommended"],
"ignorePatterns": [""],
"parserOptions": {
"ecmaVersion": 12
},
"plugins": ["jest"],
"plugins": ["jest", "@nrwl/nx"],
"rules": {
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"never"
],
"comma-spacing": [
"error",
{
"before": false,
"after": true
}
],
"space-before-function-paren": [
"error",
"never"
],
"space-before-blocks": [
"error",
"always"
],
"eqeqeq": [
"error",
"always"
],
"quote-props": [
"error",
"as-needed"
],
"no-case-declarations": [
"off"
],
"key-spacing": [
"error",
{ "afterColon": true }
],
"object-curly-spacing": [
"error",
"always"
],
"arrow-spacing": [
"error",
{ "before": true, "after": true }
],
"jest/no-standalone-expect": [
"off",
{ "additionalTestBlockFunctions": ["each.test"] }
],
"jest/no-conditional-expect": [
"off"
],
"jest/no-identical-title": [
"off"
],
"no-unused-vars": [
"error",
{
"ignoreRestSiblings": true,
"argsIgnorePattern": "^_"
}
]

},
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nrwl/nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nrwl/nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nrwl/nx/javascript"],
"rules": {
"@typescript-eslint/no-empty-function": ["off"],
"no-case-declarations": "off",
"linebreak-style": [ "error", "unix" ],
"quotes": [ "error", "single" ],
"semi": [ "error", "never" ],
"comma-spacing": [ "error", { "before": false, "after": true } ],
"space-before-function-paren": [ "error", "never" ],
"space-before-blocks": [ "error", "always" ],
"eqeqeq": [ "error", "always" ],
"quote-props": [ "error", "as-needed" ],
"no-case-declarations": [ "off" ],
"key-spacing": [ "error", { "afterColon": true } ],
"object-curly-spacing": [ "error", "always" ],
"arrow-spacing": [ "error", { "before": true, "after": true } ],
"jest/no-standalone-expect": [ "off", { "additionalTestBlockFunctions": ["each.test"] } ],
"jest/no-conditional-expect": [ "off" ],
"jest/no-identical-title": [ "off" ],
"no-unused-vars": [ "error", { "ignoreRestSiblings": true, "argsIgnorePattern": "^_" } ],
"@typescript-eslint/no-unused-vars": [ "error", { "ignoreRestSiblings": true, "argsIgnorePattern": "^_" } ]
}
}
]
}
9 changes: 4 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ jobs:
"mongo", "mongo4",
"firestore",
"airtable",
"dynamodb",
"google-sheets"
"dynamodb"
]

steps:
Expand All @@ -68,13 +67,13 @@ jobs:
- name: Downloading Image
if: ${{ ( matrix.database != 'google-sheets') }}
run: |
cd packages/velo-external-db/test/resources
cd apps/velo-external-db/test/resources
docker compose pull --quiet ${{ matrix.database }}
- name: Start Container
if: ${{ ( matrix.database != 'google-sheets') }}
run: |
cd packages/velo-external-db/test/resources
cd apps/velo-external-db/test/resources
docker compose up --detach ${{ matrix.database }}
- name: Installing Dependencies
Expand All @@ -89,7 +88,7 @@ jobs:
- name: Stop Container
if: ${{ ( matrix.database != 'google-sheets') }}
run: |
cd packages/velo-external-db/test/resources
cd apps/velo-external-db/test/resources
docker compose down
# test_bigquery:
Expand Down
12 changes: 10 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package-lock.json
node_modules

config.json
schemas.json
.gcloudignore
Expand All @@ -8,4 +8,12 @@ schemas.json
.vscode
packages/.DS_Store
.DS_Store
.eslintcache
.eslintcache

# dependencies
node_modules

# compiled output
/dist
/tmp
/out-tsc
34 changes: 16 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
FROM node:lts-slim as full_version
# Compile stage
FROM node:lts-slim
WORKDIR /usr/lib/app

COPY package.json .
# Copy the project dir
COPY . .

RUN npm install -g lerna
# Install NX and project dependencies
RUN npm install -g nx
RUN npm install

COPY packages ./packages/
COPY lerna.json .
# Build the JS files
RUN nx run-many --target=build --all

RUN lerna bootstrap -- --production

CMD [ "npm", "--prefix", "packages/velo-external-db", "start" ]
FROM node:lts-alpine

FROM node:lts-slim
ARG TYPE
WORKDIR /usr/lib/app

COPY --from=full_version /usr/lib/app/packages/external-db-config/ ./packages/external-db-config/
COPY --from=full_version /usr/lib/app/packages/velo-external-db/ ./packages/velo-external-db/
COPY --from=full_version /usr/lib/app/packages/velo-external-db-core/ ./packages/velo-external-db-core/
COPY --from=full_version /usr/lib/app/packages/external-db-security/ ./packages/external-db-security/
COPY --from=full_version /usr/lib/app/packages/velo-external-db-commons/ ./packages/velo-external-db-commons/
# Copy the compiled JS files from the compile stage
COPY --from=0 /usr/lib/app/dist/apps/velo-external-db .

COPY --from=full_version /usr/lib/app/packages/external-db-${TYPE}/ ./packages/external-db-${TYPE}/
# Install dependencies
RUN npm install --production

ENV TYPE=${TYPE}

CMD [ "npm", "--prefix", "packages/velo-external-db", "start" ]
# Run the app
CMD node ./main.js
18 changes: 18 additions & 0 deletions apps/velo-external-db/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions apps/velo-external-db/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:lts-alpine
WORKDIR /app
COPY ./dist/apps/velo-external-db .
# ENV PORT=8080
# EXPOSE ${PORT}
RUN npm install --production
# dependencies that nestjs needs
# RUN npm install reflect-metadata tslib rxjs @nestjs/platform-express
CMD node ./main.js
24 changes: 24 additions & 0 deletions apps/velo-external-db/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
displayName: 'velo-external-db',
preset: '../../jest.preset.js',
clearMocks: true,
verbose: true,
roots: ['<rootDir>/src', '<rootDir>/test'],
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
},
},
// testRegex: '(.*\\.spec\\.)js$',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': 'ts-jest',
},
globalSetup: './test/env/env.db.setup.js',
globalTeardown: './test/env/env.db.teardown.js',
testTimeout: 20000,
moduleFileExtensions: ['ts', 'js', 'html'],
setupFilesAfterEnv: ['jest-extended/all'],
coverageDirectory: '../../coverage/apps/ex-db-template',
maxWorkers: 1,
}
73 changes: 73 additions & 0 deletions apps/velo-external-db/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/velo-external-db/src",
"projectType": "application",
"targets": {
"build": {
"executor": "@nrwl/node:webpack",
"outputs": [ "{options.outputPath}" ],
"options": {
"outputPath": "dist/apps/velo-external-db",
"main": "apps/velo-external-db/src/app.js",
"tsConfig": "apps/velo-external-db/tsconfig.app.json",
"generatePackageJson": true,
"progress": true,
"buildLibsFromSource": true,
"assets": [
{ "glob": "**/*", "input": "libs/velo-external-db-core/src/views", "output": "./views" },
{ "glob": "**/*", "input": "libs/velo-external-db-core/src/assets", "output": "./assets" }
],
"fileReplacements": [
{ "replace": "apps/velo-external-db/src/environments/environment.js", "with": "apps/velo-external-db/src/environments/environment.prod.js" },
{ "replace": "libs/velo-external-db-core/src/utils/router_utils.js", "with": "libs/velo-external-db-core/src/utils/router_utils.build.js" }
]
},
"configurations": {
"production": {
"optimization": true,
"inspect": false

}
}
},
"serve": {
"executor": "@nrwl/node:node",
"options": {
"buildTarget": "velo-external-db:build"
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": [
"{options.outputFile}"
],
"options": {
"lintFilePatterns": [
"apps/velo-external-db/**/*.js"
]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": [
"coverage/apps/velo-external-db"
],
"options": {
"jestConfig": "apps/velo-external-db/jest.config.js",
"passWithNoTests": true
}
},

"build-image": {
"builder": "@nrwl/workspace:run-commands",
"options": {
"commands": [
"nx run velo-external-db:build",
"docker build -f ./apps/velo-external-db/Dockerfile . -t velo-external-db"
],
"parallel": false
}
}
},
"tags": []
}
File renamed without changes.
Loading

0 comments on commit a29fba4

Please sign in to comment.