Skip to content

Commit

Permalink
feat: some more improvements related to NX / NG / Packages updates etc
Browse files Browse the repository at this point in the history
  • Loading branch information
evereq committed Feb 2, 2021
1 parent 496feb4 commit 44edd60
Show file tree
Hide file tree
Showing 17 changed files with 424 additions and 336 deletions.
36 changes: 36 additions & 0 deletions .eslintrc.json
@@ -0,0 +1,36 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nrwl/nx"],
"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"],
"parserOptions": { "project": "./tsconfig.*?.json" },
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nrwl/nx/javascript"],
"rules": {}
}
]
}
5 changes: 4 additions & 1 deletion .prettierignore
@@ -1,3 +1,6 @@
# Add files here to ignore them from prettier formatting

**/xplat/*/.xplatframework
**/xplat/*/.xplatframework

/dist
/coverage
30 changes: 23 additions & 7 deletions angular.json
Expand Up @@ -71,17 +71,17 @@
"with": "apps/gauzy/src/environments/environment.prod.ts"
}
],
"optimization": false,
"optimization": true,
"outputHashing": "all",
"serviceWorker": false,
"sourceMap": false,
"namedChunks": false,
"ngswConfigPath": "apps/gauzy/ngsw-config.prod.json",
"showCircularDependencies": false,
"aot": true,
"extractLicenses": false,
"extractLicenses": true,
"vendorChunk": true,
"buildOptimizer": false,
"buildOptimizer": true,
"statsJson": false,
"progress": true,
"budgets": [
Expand All @@ -92,7 +92,8 @@
},
{
"type": "anyComponentStyle",
"maximumWarning": "100kb"
"maximumWarning": "100kb",
"maximumError": "1mb"
}
]
}
Expand Down Expand Up @@ -156,9 +157,9 @@
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"builder": "@nrwl/linter:eslint",
"options": {
"tsConfig": "apps/gauzy-e2e/tsconfig.e2e.json"
"lintFilePatterns": ["apps/gauzy-e2e/**/*.{js,ts}"]
}
}
}
Expand Down Expand Up @@ -678,18 +679,33 @@
}
},
"schematics": {
"@nrwl/angular": {
"application": {
"linter": "eslint"
},
"library": {
"linter": "eslint"
},
"storybook-configuration": {
"linter": "eslint"
}
},
"@nrwl/angular:application": {
"style": "scss",
"linter": "eslint",
"unitTestRunner": "jest",
"e2eTestRunner": "cypress"
},
"@nrwl/angular:component": {
"prefix": "ngx",
"styleext": "scss"
"style": "scss"
},
"@nrwl/angular:directive": {
"prefix": "ngx"
},
"@nrwl/angular:library": {
"style": "scss",
"linter": "eslint",
"unitTestRunner": "jest"
}
},
Expand Down
14 changes: 14 additions & 0 deletions apps/gauzy-e2e/.eslintrc.json
@@ -0,0 +1,14 @@
{
"extends": ["plugin:cypress/recommended", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"rules": {},
"overrides": [
{
"files": ["src/plugins/index.ts"],
"rules": {
"@typescript-eslint/no-var-requires": "off",
"no-undef": "off"
}
}
]
}
2 changes: 1 addition & 1 deletion apps/gauzy-e2e/package.json
Expand Up @@ -18,7 +18,7 @@
"jasmine-core": "^3.6.0",
"jasmine-spec-reporter": "^6.0.0",
"jest": "^26.4.2",
"jest-preset-angular": "^8.3.0",
"jest-preset-angular": "^8.3.2",
"karma": "^5.2.3",
"karma-chrome-launcher": "^3.1.0",
"karma-cli": "^2.0.0",
Expand Down
10 changes: 6 additions & 4 deletions apps/gauzy-e2e/src/plugins/index.ts
@@ -1,5 +1,3 @@
import { preprocessTypescript } from '@nrwl/cypress/plugins/preprocessor';

// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
Expand All @@ -13,8 +11,12 @@ import { preprocessTypescript } from '@nrwl/cypress/plugins/preprocessor';
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

module.exports = (on: Cypress.Actions, config: Cypress.ConfigOptions) => {
const { preprocessTypescript } = require('@nrwl/cypress/plugins/preprocessor');

module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
// on('file:preprocessor', preprocessTypescript(config));

// Preprocess Typescript file using Nx helper
on('file:preprocessor', preprocessTypescript(config));
};
59 changes: 32 additions & 27 deletions apps/gauzy/ngsw-config.json
@@ -1,28 +1,33 @@
{
"$schema": "../../node_modules/@angular/service-worker/config/schema.json",
"index": "/index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": ["/favicon.ico", "/index.html", "/silent-refresh.html", "/*.css", "/*.js"],
"urls": []
}
}
],
"dataGroups": [
{
"name": "gauzy-api",
"version": 1,
"urls": ["http://localhost:3000/api/**"],
"cacheConfig": {
"strategy": "freshness",
"maxSize": 100,
"maxAge": "12h",
"timeout": "2s"
}
}
]
}

"$schema": "./node_modules/@angular/service-worker/config/schema.json",
"index": "/index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/favicon.ico",
"/index.html",
"/silent-refresh.html",
"/*.css",
"/*.js"
],
"urls": []
}
}
],
"dataGroups": [
{
"name": "gauzy-api",
"version": 1,
"urls": ["http://localhost:3000/api/**"],
"cacheConfig": {
"strategy": "freshness",
"maxSize": 100,
"maxAge": "12h",
"timeout": "2s"
}
}
]
}
4 changes: 2 additions & 2 deletions apps/gauzy/ngsw-config.prod.json
@@ -1,5 +1,5 @@
{
"$schema": "../../node_modules/@angular/service-worker/config/schema.json",
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
"index": "/index.html",
"assetGroups": [
{
Expand All @@ -22,7 +22,7 @@
{
"name": "gauzy-api",
"version": 1,
"urls": ["http://localhost:8080/api/**"],
"urls": ["http://localhost:4200/api/**"],
"cacheConfig": {
"strategy": "freshness",
"maxSize": 100,
Expand Down
2 changes: 1 addition & 1 deletion apps/gauzy/package.json
Expand Up @@ -166,7 +166,7 @@
"jasmine-core": "^3.6.0",
"jasmine-spec-reporter": "^6.0.0",
"jest": "^26.4.2",
"jest-preset-angular": "^8.3.0",
"jest-preset-angular": "^8.3.2",
"karma": "^5.2.3",
"karma-chrome-launcher": "^3.1.0",
"karma-cli": "^2.0.0",
Expand Down
11 changes: 6 additions & 5 deletions apps/gauzy/proxy.conf.json
@@ -1,7 +1,8 @@
{
"/api": {
"target": "http://localhost:3000",
"secure": false,
"logLevel": "debug"
}
"/api": {
"target": "http://localhost:3000",
"secure": false,
"changeOrigin": true,
"logLevel": "debug"
}
}
4 changes: 2 additions & 2 deletions apps/gauzy/src/app/@core/api.interceptor.ts
Expand Up @@ -18,9 +18,9 @@ export class APIInterceptor implements HttpInterceptor {
request: HttpRequest<any>,
next: HttpHandler
): Observable<HttpEvent<any>> {
if (request.url.startsWith('/api')) {
if (baseUrl && request.url.startsWith('/api')) {
const url = baseUrl + request.url;
// console.log(`API Request: ${request.url} -> ${url}`);
console.log(`API Request: ${request.url} -> ${url}`);
request = request.clone({
url: url
});
Expand Down
7 changes: 6 additions & 1 deletion jest.config.js
Expand Up @@ -7,5 +7,10 @@ module.exports = {
moduleFileExtensions: ['ts', 'js', 'html'],
collectCoverage: true,
coverageReporters: ['html'],
projects: '<rootDir>/libs/desktop-ui-lib'
projects: [
'<rootDir>/apps/gauzy',
'<rootDir>/apps/api',
'<rootDir>/apps/desktop',
'<rootDir>/libs/desktop-ui-lib'
]
};
15 changes: 13 additions & 2 deletions nx.json
@@ -1,15 +1,26 @@
{
"npmScope": "gauzy",
"affected": { "defaultBase": "master" },
"implicitDependencies": {
"angular.json": "*",
"package.json": "*",
"package.json": { "dependencies": "*", "devDependencies": "*" },
"tsconfig.json": "*",
"tslint.json": "*",
".eslintrc.json": "*",
"nx.json": "*"
},
"tasksRunnerOptions": {
"default": {
"runner": "@nrwl/workspace/tasks-runners/default",
"options": {
"cacheableOperations": ["build", "lint", "test", "e2e"]
}
}
},
"projects": {
"gauzy-e2e": {
"tags": []
"tags": [],
"implicitDependencies": ["gauzy"]
},
"gauzy": {
"tags": []
Expand Down
32 changes: 16 additions & 16 deletions package.json
Expand Up @@ -25,11 +25,11 @@
"config:prod": "yarn run config -- --environment=prod",
"start": "yarn build:package:all && yarn concurrently --raw --kill-others \"yarn start:api\" \"yarn start:gauzy\"",
"start:prod": "yarn build:package:all && yarn concurrently --raw --kill-others \"yarn start:api:prod\" \"yarn start:gauzy:prod\"",
"start:gauzy": "yarn run postinstall.web && cross-env NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 yarn run config:dev && yarn ng serve gauzy",
"start:gauzy": "yarn run postinstall.web && cross-env NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 yarn run config:dev && yarn nx serve gauzy",
"start:gauzy:pm2": "cross-env NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 yarn build:package:all && yarn build:gauzy && yarn ts-node ./apps/gauzy/src/pm2bootstrap.ts",
"start:gauzy:prod": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 yarn run config:prod && yarn ng serve gauzy --disable-host-check --host 0.0.0.0 -c=production --prod",
"start:api": "cross-env NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 yarn ng serve api",
"start:api:prod": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 yarn ng serve api --host 0.0.0.0 -c=production --prod",
"start:gauzy:prod": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 yarn run config:prod && yarn nx serve gauzy --disable-host-check --host 0.0.0.0 -c=production --prod",
"start:api": "cross-env NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 && yarn nx serve api",
"start:api:prod": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 yarn nx serve api --host 0.0.0.0 -c=production --prod",
"start:api:ci": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=7000 yarn --frozen-lockfile --cache-folder ~/.cache/yarn ng:ci serve api -c=production --prod",
"start:api:pm2": "cross-env NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 yarn run build:api && yarn ts-node -r tsconfig-paths/register --project apps/api/tsconfig.app.json ./apps/api/src/pm2bootstrap.ts",
"seed": "cross-env NODE_ENV=development NODE_OPTIONS=--max_old_space_size=7000 yarn build:package:all && yarn run config:dev && yarn ts-node -r tsconfig-paths/register --project apps/api/tsconfig.app.json ./apps/api/src/seed.ts",
Expand All @@ -42,19 +42,19 @@
"build": "yarn build:package:all && concurrently --raw \"yarn build:api\" \"yarn build:gauzy\"",
"build:lerna": "yarn lerna run --parallel build",
"build:prod": "yarn build:package:all && concurrently --raw \"yarn build:api:prod\" \"yarn build:gauzy:prod\"",
"build:gauzy": "yarn run postinstall.web && cross-env NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 yarn run config:dev && yarn ng build gauzy",
"build:gauzy:prod": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 yarn run config:prod && yarn ng build gauzy -c=production --prod",
"build:gauzy": "yarn run postinstall.web && cross-env NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 yarn run config:dev && yarn nx build gauzy",
"build:gauzy:prod": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 yarn run config:prod && yarn nx build gauzy -c=production --prod",
"build:gauzy:prod:ci": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=7000 yarn run config:prod && yarn --frozen-lockfile --cache-folder ~/.cache/yarn ng:ci build gauzy -c=production --prod",
"build:api": "cross-env NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 yarn ng build api",
"build:api:prod": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 yarn ng build api -c=production --prod",
"build:api": "cross-env NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 yarn nx build api",
"build:api:prod": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 yarn nx build api -c=production --prod",
"build:api:prod:ci": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=7000 yarn --frozen-lockfile --cache-folder ~/.cache/yarn ng:ci build api -c=production --prod",
"bundle-report": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 yarn run config:prod && yarn ng build -c=production --stats-json && webpack-bundle-analyzer dist/apps/gauzy/stats.json",
"bundle-report": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 yarn run config:prod && yarn nx build -c=production --stats-json && webpack-bundle-analyzer dist/apps/gauzy/stats.json",
"commit": "git-cz",
"commit:lint": "commitlint -E HUSKY_GIT_PARAMS",
"semantic-release": "semantic-release",
"test": "yarn run postinstall.web && cross-env NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 yarn run config:dev && yarn ng test",
"lint": "cross-env NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 yarn run config:dev && yarn nx lint && yarn ng lint",
"e2e": "yarn run postinstall.web && cross-env NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 yarn run config:dev && yarn ng e2e",
"test": "yarn run postinstall.web && cross-env NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 yarn run config:dev && yarn nx test",
"lint": "cross-env NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 yarn run config:dev && yarn nx lint && yarn nx lint",
"e2e": "yarn run postinstall.web && cross-env NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 yarn run config:dev && yarn nx e2e",
"e2e:ci": "yarn run postinstall.web && cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=7000 yarn run config:prod && yarn --frozen-lockfile --cache-folder ~/.cache/yarn ng:ci e2e -c=production --prod --headless",
"affected:apps": "nx affected:apps",
"affected:libs": "nx affected:libs",
Expand All @@ -78,7 +78,7 @@
"postinstall": "yarn node ./decorate-angular-cli.js && ngcc --properties es2016 browser module main --first-only --create-ivy-entry-points",
"postinstall.electron": "yarn electron-builder install-app-deps && yarn node tools/electron/postinstall",
"postinstall.web": "yarn node tools/web/postinstall",
"build:desktop": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 yarn run postinstall.electron && yarn build:package:all && yarn run config:prod && ng build desktop --prod --base-href ./ && yarn run prepare:desktop && ng build desktop-api --prod && ng build api-desktop --prod && ng build desktop-ui --prod --base-href ./",
"build:desktop": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 yarn run postinstall.electron && yarn build:package:all && yarn run config:prod && yarn nx build desktop --prod --base-href ./ && yarn run prepare:desktop && yarn nx build desktop-api --prod && yarn nx build api-desktop --prod && yarn nx build desktop-ui --prod --base-href ./",
"build:desktop:local": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 yarn run config:prod && yarn run build:desktop && electron dist/apps/desktop",
"build:desktop:linux": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 yarn run config:prod && yarn run build:desktop && npm config set cache .cache && cd dist/apps/desktop && npx electron-builder@22.9.1 -c.electronVersion=10.1.3 build --linux",
"build:desktop:windows": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 yarn run config:prod && yarn run build:desktop && npm config set cache .cache && cd dist/apps/desktop && npx electron-builder@22.9.1 -c.electronVersion=10.1.3 build --windows",
Expand All @@ -97,10 +97,10 @@
"build:sqlite:mac": "cd node_modules/sqlite3 && HOME=~/.electron-gyp node-pre-gyp rebuild --target=8.3.0 --arch=x64 --dist-url=https://electronjs.org/headers",
"build:sqlite:windows": "cd node_modules/sqlite3 && cross-env HOME=~/.electron-gyp node-pre-gyp rebuild --target=8.3.0 --arch=x64 --target_platform=win32 --dist-url=https://electronjs.org/headers",
"debug:desktop:app:mac": "lldb ./dist/apps/desktop-packages/mac/GauzyDesktop.app && run",
"start:desktop:ui": "yarn run postinstall.web && cross-env NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 && yarn ng serve desktop-ui",
"build:desktop:ui": "yarn run postinstall.web && cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 && yarn ng build desktop-ui --prod --base-href ./",
"start:desktop:ui": "yarn run postinstall.web && cross-env NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 && yarn nx serve desktop-ui",
"build:desktop:ui": "yarn run postinstall.web && cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 && yarn nx build desktop-ui --prod --base-href ./",
"prepare:desktop:dev": "yarn run postinstall.electron && tsc -p apps/desktop/tsconfig.dev.json",
"start:api:desktop": "cross-env NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 yarn ng serve api-desktop",
"start:api:desktop": "cross-env NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 yarn nx serve api-desktop",
"deploy:desktop:mac": "npm config set cache .cache && cd dist/apps/desktop && npx electron-builder@22.9.1 -c.electronVersion=10.1.3 build --mac --publish always",
"build:package:core": "yarn --cwd ./packages/core build",
"build:package:common": "yarn --cwd ./packages/common build",
Expand Down

0 comments on commit 44edd60

Please sign in to comment.