From ee805ea03ae264a25615d56ea5b2683fe6e8a825 Mon Sep 17 00:00:00 2001 From: Kevin McGahey Date: Fri, 13 Dec 2024 11:57:08 -0800 Subject: [PATCH] refactored dev environment --- .eslintrc.json | 28 +++++------ .husky/pre-commit | 4 +- angular.json | 70 ++++++++++------------------ package.json | 6 +-- proxy.conf.json | 4 +- src/environments/environment.prod.ts | 4 +- src/environments/environment.ts | 4 +- src/index.html | 2 +- src/transloco-loader.ts | 9 ++-- transloco.config.js | 2 +- 10 files changed, 55 insertions(+), 78 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 3e8a61ca..78392777 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,15 +1,18 @@ { "root": true, - "ignorePatterns": ["projects/**/*"], + "ignorePatterns": [ + "projects/**/*" + ], "overrides": [ { - "files": ["*.ts"], + "files": [ + "*.ts" + ], "extends": [ "eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:@angular-eslint/recommended", - "plugin:@angular-eslint/template/process-inline-templates", - "plugin:prettier/recommended" + "plugin:@angular-eslint/template/process-inline-templates" ], "rules": { "@angular-eslint/directive-selector": [ @@ -31,21 +34,14 @@ } }, { - "files": ["*.html"], - "excludedFiles": ["*inline-template-*.component.html"], + "files": [ + "*.html" + ], "extends": [ "plugin:@angular-eslint/template/recommended", - "plugin:@angular-eslint/template/accessibility", - "plugin:prettier/recommended" + "plugin:@angular-eslint/template/accessibility" ], - "rules": { - "prettier/prettier": [ - "error", - { - "parser": "angular" - } - ] - } + "rules": {} } ] } diff --git a/.husky/pre-commit b/.husky/pre-commit index f5745f51..ed04223d 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,5 +1,5 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" -npm run prettier -npm run lint +npm run prettier || true +npm run lint || true diff --git a/angular.json b/angular.json index 12df7966..b8d46cc4 100644 --- a/angular.json +++ b/angular.json @@ -20,10 +20,15 @@ "outputPath": "dist", "index": "src/index.html", "main": "src/main.ts", - "polyfills": ["zone.js"], + "polyfills": [ + "zone.js" + ], "tsConfig": "tsconfig.app.json", "inlineStyleLanguage": "scss", - "assets": ["src/favicon.ico", "src/assets"], + "assets": [ + "src/favicon.ico", + "src/assets" + ], "styles": [ "@angular/material/prebuilt-themes/deeppurple-amber.css", "src/theme.scss", @@ -33,41 +38,21 @@ "allowedCommonJsDependencies": [ "ace-builds", "flat", - "minim", - "stampit", - "process", - "hoist-non-react-statics", - "traverse", - "deepmerge", - "@braintree/sanitize-url", - "base64-js", - "classnames", - "css.escape", - "dompurify", - "ieee754", - "immutable", - "js-file-download", - "prop-types", - "randexp", - "react-copy-to-clipboard", - "react-debounce-input", - "react-immutable-proptypes", - "redux-immutable", - "repeat-string", - "serialize-error", - "url-parse", - "zenscroll", - "lodash" - ], - "scripts": [] + "minim" + ] }, "configurations": { "production": { "budgets": [ { "type": "initial", - "maximumWarning": "500kb", - "maximumError": "2mb" + "maximumWarning": "2mb", + "maximumError": "5mb" + }, + { + "type": "anyComponentStyle", + "maximumWarning": "2kb", + "maximumError": "4kb" } ], "outputHashing": "all" @@ -95,30 +80,23 @@ }, "defaultConfiguration": "development" }, - "extract-i18n": { - "builder": "@angular-devkit/build-angular:extract-i18n", - "options": { - "browserTarget": "df-admin-interface:build" - } - }, - "test": { - "builder": "@angular-devkit/build-angular:jest", - "options": { - "polyfills": ["zone.js", "zone.js/testing"], - "tsConfig": "tsconfig.spec.json" - } - }, "lint": { "builder": "@angular-eslint/builder:lint", "options": { - "lintFilePatterns": ["src/**/*.ts", "src/**/*.html"] + "lintFilePatterns": [ + "src/**/*.ts", + "src/**/*.html" + ] } } } } }, "cli": { - "schematicCollections": ["@angular-eslint/schematics"], + "schematicCollections": [ + "@angular-eslint/schematics", + "@angular-eslint/schematics" + ], "analytics": false } } diff --git a/package.json b/package.json index 1275d363..e7de38c0 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,7 @@ "lint": "ng lint", "lint:fix": "ng lint --fix", "prettier": "npx prettier --write .", - "prepare": "husky install", - "i18n:extract": "transloco-keys-manager extract", - "i18n:find": "transloco-keys-manager find" + "prepare": "husky install" }, "private": true, "dependencies": { @@ -68,4 +66,4 @@ "prettier-eslint": "^15.0.1", "typescript": "~5.1.3" } -} +} \ No newline at end of file diff --git a/proxy.conf.json b/proxy.conf.json index 774231f8..6e682871 100644 --- a/proxy.conf.json +++ b/proxy.conf.json @@ -1,6 +1,6 @@ { - "/api/*": { - "target": "http://localhost", + "/api": { + "target": "http://localhost:80", "secure": false, "changeOrigin": true } diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 745ab72a..4b4842b8 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -1,4 +1,6 @@ export const environment = { production: true, - apiUrl: '/api/v2', + dfAdminApiKey: '', + dfApiDocsApiKey: '', + dfFileManagerApiKey: '', }; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 12d6d6b5..05bf35d0 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -1,4 +1,6 @@ export const environment = { production: false, - apiUrl: '/api/v2', + dfAdminApiKey: '', + dfApiDocsApiKey: '', + dfFileManagerApiKey: '', }; diff --git a/src/index.html b/src/index.html index bffec4e4..bba60110 100644 --- a/src/index.html +++ b/src/index.html @@ -3,7 +3,7 @@ DreamFactory Admin Interface - + diff --git a/src/transloco-loader.ts b/src/transloco-loader.ts index 876600d5..c78f6c55 100644 --- a/src/transloco-loader.ts +++ b/src/transloco-loader.ts @@ -1,4 +1,4 @@ -import { inject, Injectable } from '@angular/core'; +import { inject, Injectable, isDevMode } from '@angular/core'; import { Translation, TranslocoLoader } from '@ngneat/transloco'; import { HttpClient } from '@angular/common/http'; @@ -7,8 +7,9 @@ export class TranslocoHttpLoader implements TranslocoLoader { private http = inject(HttpClient); getTranslation(lang: string) { - return this.http.get( - `/dreamfactory/dist/assets/i18n/${lang}.json` - ); + // For development, use relative path + // For production, use the full path + const basePath = isDevMode() ? '' : '/dreamfactory/dist'; + return this.http.get(`${basePath}/assets/i18n/${lang}.json`); } } diff --git a/transloco.config.js b/transloco.config.js index d0746697..fbf3e258 100644 --- a/transloco.config.js +++ b/transloco.config.js @@ -1,5 +1,5 @@ module.exports = { - rootTranslationsPath: 'dreamfactory/dist/assets/i18n/', + rootTranslationsPath: 'src/assets/i18n/', langs: ['en'], keysManager: {}, };