-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
279 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
<%# | ||
Copyright 2013-2024 the original author or authors from the JHipster project. | ||
This file is part of the JHipster project, see https://www.jhipster.tech/ | ||
for more information. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
https://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
-%> | ||
{ | ||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json", | ||
"version": 1, | ||
"newProjectRoot": "projects", | ||
"projects": { | ||
"<%= dasherizedBaseName %>": { | ||
"projectType": "application", | ||
"schematics": { | ||
"@schematics/angular:component": { | ||
"style": "scss" | ||
}, | ||
"@schematics/angular:application": { | ||
"strict": true | ||
} | ||
}, | ||
"root": "", | ||
"sourceRoot": "<%= this.relativeDir(clientRootDir, clientSrcDir).replace(/\/$/, "") %>", | ||
"prefix": "<%= jhiPrefixDashed %>", | ||
"architect": { | ||
"build": { | ||
"builder": "@angular-builders/custom-esbuild:application", | ||
"options": { | ||
"plugins": ["./build-plugins/esbuild-define.mjs", "./build-plugins/esbuild-copy.mjs"], | ||
"outputPath": { | ||
"base": "<%= this.relativeDir(clientRootDir, clientDistDir) %>", | ||
"browser": "", | ||
"server": "node-server", | ||
"media": "resources" | ||
}, | ||
"index": "<%= this.relativeDir(clientRootDir, clientSrcDir) %>index.html", | ||
"browser": "<%= this.relativeDir(clientRootDir, clientSrcDir) %>main.ts", | ||
"polyfills": [ | ||
<%_ if (communicationSpringWebsocket) { _%> | ||
"./<%= this.relativeDir(clientRootDir, clientSrcDir) %>sockjs-client.polyfill", | ||
<%_ } _%> | ||
"zone.js" | ||
], | ||
"tsConfig": "tsconfig.app.json", | ||
"inlineStyleLanguage": "scss", | ||
"assets": [ | ||
"<%= this.relativeDir(clientRootDir, clientSrcDir) %>content", | ||
"<%= this.relativeDir(clientRootDir, clientSrcDir) %>favicon.ico", | ||
"<%= this.relativeDir(clientRootDir, clientSrcDir) %>manifest.webapp", | ||
"<%= this.relativeDir(clientRootDir, clientSrcDir) %>robots.txt" | ||
], | ||
"styles": [ | ||
"<%= this.relativeDir(clientRootDir, clientSrcDir) %>content/scss/vendor.scss", | ||
"<%= this.relativeDir(clientRootDir, clientSrcDir) %>content/scss/global.scss" | ||
], | ||
"scripts": [] | ||
}, | ||
"configurations": { | ||
"production": { | ||
"optimization": true, | ||
"outputHashing": "all", | ||
"sourceMap": false, | ||
"namedChunks": <%= Boolean(microfrontend) %>, | ||
"extractLicenses": true, | ||
"budgets": [ | ||
{ | ||
"type": "initial", | ||
"maximumWarning": "500kb", | ||
"maximumError": "1mb" | ||
}, | ||
{ | ||
"type": "anyComponentStyle", | ||
"maximumWarning": "2kb", | ||
"maximumError": "4kb" | ||
} | ||
] | ||
}, | ||
"development": { | ||
"optimization": false, | ||
"extractLicenses": false, | ||
"sourceMap": true, | ||
"namedChunks": true, | ||
"fileReplacements": [ | ||
{ | ||
"replace": "<%= this.relativeDir(clientRootDir, clientSrcDir) %>environments/environment.ts", | ||
"with": "<%= this.relativeDir(clientRootDir, clientSrcDir) %>environments/environment.development.ts" | ||
} | ||
] | ||
} | ||
}, | ||
"defaultConfiguration": "production" | ||
}, | ||
"serve": { | ||
"builder": "@angular-builders/custom-esbuild:dev-server", | ||
"options": { | ||
"buildTarget": "<%= dasherizedBaseName %>:build:development", | ||
"middlewares": ["build-plugins/vite-middleware.mjs"], | ||
"open": true, | ||
"proxyConfig": "proxy.conf.json", | ||
"port": <%= devServerPort %> | ||
}, | ||
"configurations": { | ||
"production": { | ||
"buildTarget": "<%= dasherizedBaseName %>:build:production" | ||
}, | ||
"development": { | ||
"buildTarget": "<%= dasherizedBaseName %>:build:development" | ||
} | ||
}, | ||
"defaultConfiguration": "development" | ||
}, | ||
"test": { | ||
"builder": "@angular-builders/jest:run", | ||
"options": { | ||
"configPath": "jest.conf.js", | ||
"tsConfig": "tsconfig.spec.json" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"cli": { | ||
"cache": { | ||
"enabled": true, | ||
"path": "./<%= this.relativeDir(clientRootDir, temporaryDir) %>angular/", | ||
"environment": "all" | ||
}, | ||
"packageManager": "<%= clientPackageManager %>" | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
generators/angular/templates/build-plugins/esbuild-copy.mjs.ejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// @ts-check | ||
import { copyFile, mkdir } from 'node:fs/promises'; | ||
import { dirname, join } from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { getSwaggerUiFileMap } from './swagger-ui.mjs'; | ||
|
||
/** @type {import('esbuild').Plugin} */ | ||
export default { | ||
name: 'copy:files', | ||
async setup() { | ||
const destDir = join(fileURLToPath(new URL('..', import.meta.url)), 'target/classes/static', 'swagger-ui'); | ||
const swaggerFiles = await getSwaggerUiFileMap(); | ||
for (const [dest, src] of Object.entries(swaggerFiles)) { | ||
const destFile = join(destDir, dest); | ||
await mkdir(dirname(destFile), { recursive: true }); | ||
await copyFile(src, destFile); | ||
} | ||
}, | ||
}; |
12 changes: 12 additions & 0 deletions
12
generators/angular/templates/build-plugins/esbuild-define.mjs.ejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// @ts-check | ||
/** @type {import('esbuild').Plugin} */ | ||
export default { | ||
name: 'define:vars', | ||
setup(build) { | ||
build.initialOptions.define ??= {}; | ||
Object.assign(build.initialOptions.define, { | ||
SERVER_API_URL: JSON.stringify(''), | ||
__VERSION__: JSON.stringify(process.env.APP_VERSION ?? 'unknown'), | ||
}); | ||
}, | ||
}; |
19 changes: 19 additions & 0 deletions
19
generators/angular/templates/build-plugins/swagger-ui.mjs.ejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// @ts-check | ||
import { dirname, join } from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { globby } from 'globby'; | ||
|
||
const lookup = async (pattern, sourcesDir, destDir) => { | ||
const files = await globby(pattern, { cwd: sourcesDir }); | ||
return Object.fromEntries(files.map(file => [join(destDir, file), join(sourcesDir, file)])); | ||
}; | ||
|
||
export const getSwaggerUiFileMap = async () => { | ||
const destDir = 'swagger-ui'; | ||
const { getAbsoluteFSPath } = await import('swagger-ui-dist'); | ||
return { | ||
[`${destDir}/axios.min.js`]: join(dirname(fileURLToPath(import.meta.resolve('axios/package.json'))), 'dist/axios.min.js'), | ||
...(await lookup('*.{js,css,png}', getAbsoluteFSPath(), destDir)), | ||
...(await lookup('**/*.*', join(fileURLToPath(new URL('.', import.meta.url)), '../<%= clientSrcDir %>/swagger-ui/'), destDir)), | ||
}; | ||
}; |
18 changes: 18 additions & 0 deletions
18
generators/angular/templates/build-plugins/vite-middleware.mjs.ejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { readFile } from 'node:fs/promises'; | ||
import { getSwaggerUiFileMap } from './swagger-ui.mjs'; | ||
|
||
const swaggerFiles = await getSwaggerUiFileMap(); | ||
swaggerFiles['swagger-ui'] = swaggerFiles['swagger-ui/index.html']; | ||
const cache = new Map(); | ||
|
||
export default async (req, res, next) => { | ||
const file = swaggerFiles[req.url.slice(1)]; | ||
if (file) { | ||
if (!cache.has(file)) { | ||
cache.set(file, await readFile(file, 'utf8')); | ||
} | ||
res.end(cache.get(file)); | ||
} else { | ||
next(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<%# | ||
Copyright 2013-2024 the original author or authors from the JHipster project. | ||
|
||
This file is part of the JHipster project, see https://www.jhipster.tech/ | ||
for more information. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
https://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
-%> | ||
{ | ||
<%_ if (communicationSpringWebsocket) { _%> | ||
"/websocket": { | ||
"target": "ws://localhost:8080", | ||
"ws": true | ||
}, | ||
<%_ } _%> | ||
"^/(api|management|v3/api-docs<% if (databaseTypeSql && devDatabaseTypeH2Any) { %>|h2-console<% } %><% if (authenticationTypeOauth2) { %>|oauth2|login<% } %><% if (authenticationTypeSession) { %>|login<% } %><% if (applicationTypeGateway || applicationTypeMicroservice) { %>|services<% } %>)": "http://localhost:<%= applicationTypeMicroservice ? gatewayServerPort : serverPort %>" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.