Skip to content

feat: add environment options (DTAP) #552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ module.exports = Generator.make({
'electron-linux': props => props.desktop && props.desktop.includes('linux'),
'tools-hads': props => props.tools && props.tools.includes('hads'),
'tools-jest': props => props.tools && props.tools.includes('jest'),
'tools-karma': props => props.tools && !props.tools.includes('jest')
'tools-karma': props => props.tools && !props.tools.includes('jest'),
'dtap': props => props.dtap
})
});
6 changes: 6 additions & 0 deletions generators/app/prompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,12 @@ module.exports = [
}
]
},
{
type: 'confirm',
name: 'dtap',
message: 'Do you want common architecture development, testing, acceptance and production (DTAP)?',
default: false
},
{
type: 'list',
name: 'deploy',
Expand Down
2 changes: 2 additions & 0 deletions generators/app/templates/_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ Task | Description
`npm run build [-- --configuration=production]` | Lint code and build web app for production (with [AOT](https://angular.io/guide/aot-compiler)) in `www/` folder
<% } else { -%>
`npm run build [-- --configuration=production]` | Lint code and build web app for production (with [AOT](https://angular.io/guide/aot-compiler)) in `dist/` folder
`npm run build:testing` | Lint code and build web app for user testing (with [AOT](https://angular.io/guide/aot-compiler)) in `dist/` folder
`npm run build:acceptance` | Lint code and build web app for user acceptance (with [AOT](https://angular.io/guide/aot-compiler)) in `dist/` folder
<% } -%>
<% } -%>
<% if (props.target.includes('cordova')) { -%>
Expand Down
64 changes: 64 additions & 0 deletions generators/app/templates/_angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,70 @@
}
]
},
<% if (props.dtap) { -%>
"testing": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
],
<% if (props.pwa) { -%>
"serviceWorker": true,
<% } -%>
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.testing.ts"
}
]
},
"acceptance": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
],
<% if (props.pwa) { -%>
"serviceWorker": true,
<% } -%>
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.acceptance.ts"
}
]
},
<% } -%>
"ci": {
"progress": false
}
Expand Down
4 changes: 4 additions & 0 deletions generators/app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"scripts": {
"ng": "ng",
"build": "<%= run('env') %> && ng build --prod",
<% if (props.dtap) { -%>
"build:testing": "<%= run('env') %> && ng build --prod --configuration=testing",
"build:acceptance": "<%= run('env') %> && ng build --prod --configuration=acceptance",
<% } -%>
"start": "<%= run('env') %> && ng serve --proxy-config proxy.conf.js",
<% if (props.deploy !== 'none') { -%>
"deploy": "<%= run('env') %> && ng deploy",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// `.env.ts` is generated by the `npm run env` command
// `npm run env` exposes environment variables as JSON for any usage you might
// want, like displaying the version or getting extra config from your CI bot, etc.
// This is useful for granularity you might need beyond just the environment.
// Note that as usual, any environment variables you expose through it will end up in your
// bundle, and you should not use it for any sensitive information like passwords or keys.
import { env } from './.env';

export const environment = {
production: true,
hmr: false,
version: env.npm_package_version + '-acceptance',
serverUrl: 'https://api.chucknorris.io',
defaultLanguage: '<%= props.languages.includes('en-US') ? 'en-US' : props.languages[0] %>',
supportedLanguages: [<%- (props['languages']).map(language => `'${language}'`).join(', ') %>]
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// `.env.ts` is generated by the `npm run env` command
// `npm run env` exposes environment variables as JSON for any usage you might
// want, like displaying the version or getting extra config from your CI bot, etc.
// This is useful for granularity you might need beyond just the environment.
// Note that as usual, any environment variables you expose through it will end up in your
// bundle, and you should not use it for any sensitive information like passwords or keys.
import { env } from './.env';

export const environment = {
production: true,
hmr: false,
version: env.npm_package_version + '-testing',
serverUrl: 'https://api.chucknorris.io',
defaultLanguage: '<%= props.languages.includes('en-US') ? 'en-US' : props.languages[0] %>',
supportedLanguages: [<%- (props['languages']).map(language => `'${language}'`).join(', ') %>]
};