From 90bed33da3bcf89674699dcb8d6ff8aa7f024b4d Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Mon, 1 Jul 2019 23:27:24 +0430 Subject: [PATCH 01/52] feature: support for overriding host value --- skeleton/webpack/aurelia_project/aurelia.json | 1 + skeleton/webpack/aurelia_project/tasks/run.ext | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/skeleton/webpack/aurelia_project/aurelia.json b/skeleton/webpack/aurelia_project/aurelia.json index 23e789f73..0790da0d9 100644 --- a/skeleton/webpack/aurelia_project/aurelia.json +++ b/skeleton/webpack/aurelia_project/aurelia.json @@ -12,6 +12,7 @@ // @if feat.web "port": 8080, + "host": "localhost", "output": "dist", // @endif diff --git a/skeleton/webpack/aurelia_project/tasks/run.ext b/skeleton/webpack/aurelia_project/tasks/run.ext index 003fea0a1..6cc1094b8 100644 --- a/skeleton/webpack/aurelia_project/tasks/run.ext +++ b/skeleton/webpack/aurelia_project/tasks/run.ext @@ -18,14 +18,14 @@ import {CLIOptions, reportWebpackReadiness} from 'aurelia-cli'; function runWebpack(done) { // https://webpack.github.io/docs/webpack-dev-server.html let opts = { - host: 'localhost', + host: CLIOptions.getFlagValue('host') || project.platform.host, + port: CLIOptions.getFlagValue('port') || project.platform.port, + hot: project.platform.hmr || CLIOptions.hasFlag('hmr'), + open: project.platform.open || CLIOptions.hasFlag('open'), publicPath: config.output.publicPath, filename: config.output.filename, - hot: project.platform.hmr || CLIOptions.hasFlag('hmr'), - port: CLIOptions.getFlagValue('port') || project.platform.port, contentBase: config.output.path, historyApiFallback: true, - open: project.platform.open || CLIOptions.hasFlag('open'), stats: { colors: require('supports-color') }, From 0b552ae1ea55415c31fc3d4b03128c7fe9577310 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Mon, 1 Jul 2019 23:27:58 +0430 Subject: [PATCH 02/52] fix: --open, opens two tabs on the browser --- skeleton/webpack/aurelia_project/tasks/run.ext | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skeleton/webpack/aurelia_project/tasks/run.ext b/skeleton/webpack/aurelia_project/tasks/run.ext index 6cc1094b8..5aad8eb0a 100644 --- a/skeleton/webpack/aurelia_project/tasks/run.ext +++ b/skeleton/webpack/aurelia_project/tasks/run.ext @@ -49,7 +49,7 @@ function runWebpack(done) { server.listen(opts.port, opts.host, function(err) { if (err) throw err; - reportWebpackReadiness(opts); + // reportWebpackReadiness(opts); done(); }); } From caee4463d9f61c75977a3af0020b182622aeb0d4 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Tue, 2 Jul 2019 10:44:11 +0430 Subject: [PATCH 03/52] update: run.json with host help docs Add help documentation for `host` argument of the `au run` command in run.json file --- skeleton/webpack/aurelia_project/tasks/run.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/skeleton/webpack/aurelia_project/tasks/run.json b/skeleton/webpack/aurelia_project/tasks/run.json index 99b409d69..26cb2796d 100644 --- a/skeleton/webpack/aurelia_project/tasks/run.json +++ b/skeleton/webpack/aurelia_project/tasks/run.json @@ -17,6 +17,11 @@ "description": "Enable Hot Module Reload", "type": "boolean" }, + { + "name": "host", + "description": "Set host adddress of the dev server, the accessible URL", + "type": "string" + }, { "name": "port", "description": "Set port number of the dev server", From 1608d1b1c56ffd426da210b1636865936e7fbbcc Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Tue, 2 Jul 2019 22:21:56 +0430 Subject: [PATCH 04/52] fix: two open tabs with --open change the code slightly to be backward compatible with existing applications. --- lib/build/webpack-reporter.js | 10 +++++----- skeleton/webpack/aurelia_project/tasks/run.ext | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/build/webpack-reporter.js b/lib/build/webpack-reporter.js index 5971a15a6..791d869de 100644 --- a/lib/build/webpack-reporter.js +++ b/lib/build/webpack-reporter.js @@ -24,11 +24,11 @@ module.exports = function reportReadiness(options) { console.log(`404s will fallback to ${colorInfo(useColor, options.historyApiFallback.index || '/index.html')}`); } - if (options.open) { - open(uri).catch(function() { - console.log('Unable to open browser. If you are running in a headless environment, please do not use the open flag.'); - }); - } + // if (options.open) { + // open(uri).catch(function() { + // console.log('Unable to open browser. If you are running in a headless environment, please do not use the open flag.'); + // }); + // } }; function createDomain(opts) { diff --git a/skeleton/webpack/aurelia_project/tasks/run.ext b/skeleton/webpack/aurelia_project/tasks/run.ext index 5aad8eb0a..6cc1094b8 100644 --- a/skeleton/webpack/aurelia_project/tasks/run.ext +++ b/skeleton/webpack/aurelia_project/tasks/run.ext @@ -49,7 +49,7 @@ function runWebpack(done) { server.listen(opts.port, opts.host, function(err) { if (err) throw err; - // reportWebpackReadiness(opts); + reportWebpackReadiness(opts); done(); }); } From 89511887f84c78156dfd4f5ced89d91b990d4b5e Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Tue, 2 Jul 2019 22:26:52 +0430 Subject: [PATCH 05/52] fix: es-linter for unused variables --- lib/build/webpack-reporter.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lib/build/webpack-reporter.js b/lib/build/webpack-reporter.js index 791d869de..47d1dfa9d 100644 --- a/lib/build/webpack-reporter.js +++ b/lib/build/webpack-reporter.js @@ -3,7 +3,6 @@ module.exports = function reportReadiness(options) { const yargs = require('yargs'); const argv = yargs.argv; argv.color = require('supports-color'); - const open = require('open'); const useColor = argv.color; let startSentence = `Project is running at ${colorInfo(useColor, uri)}`; @@ -23,12 +22,6 @@ module.exports = function reportReadiness(options) { if (options.historyApiFallback) { console.log(`404s will fallback to ${colorInfo(useColor, options.historyApiFallback.index || '/index.html')}`); } - - // if (options.open) { - // open(uri).catch(function() { - // console.log('Unable to open browser. If you are running in a headless environment, please do not use the open flag.'); - // }); - // } }; function createDomain(opts) { From cc2aa0a26f895c086d8cc30c0f87610d5b4b626d Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Tue, 2 Jul 2019 23:52:56 +0430 Subject: [PATCH 06/52] add: override host and port while running cypress tests --- skeleton/cypress/cypress.config.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/skeleton/cypress/cypress.config.js b/skeleton/cypress/cypress.config.js index 16c6054a0..a7943ea29 100644 --- a/skeleton/cypress/cypress.config.js +++ b/skeleton/cypress/cypress.config.js @@ -1,9 +1,11 @@ +const CLIOptions = require( 'aurelia-cli').CLIOptions; const aureliaConfig = require('./aurelia_project/aurelia.json'); -const port = aureliaConfig.platform.port; +const PORT = CLIOptions.getFlagValue('port') || aureliaConfig.platform.port; +const HOST = CLIOptions.getFlagValue('host') || aureliaConfig.platform.host; module.exports = { config: { - baseUrl: `http://localhost:${port}`, + baseUrl: `http://${HOST}:${PORT}`, fixturesFolder: 'test/e2e/fixtures', integrationFolder: 'test/e2e/integration', pluginsFile: 'test/e2e/plugins/index.js', From 16c8fd709e48c153b6fded06f9912708b27554f9 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Tue, 2 Jul 2019 23:53:29 +0430 Subject: [PATCH 07/52] update: cypress.json for the dake of au help --- .../cypress/aurelia_project/tasks/cypress.json | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/skeleton/cypress/aurelia_project/tasks/cypress.json b/skeleton/cypress/aurelia_project/tasks/cypress.json index f63935ded..822e4f05f 100644 --- a/skeleton/cypress/aurelia_project/tasks/cypress.json +++ b/skeleton/cypress/aurelia_project/tasks/cypress.json @@ -4,7 +4,22 @@ "flags": [ { "name": "run", - "description": "Perfom a testrun and reports the results.", + "description": "Perform a test run and reports the results.", + "type": "boolean" + }, + { + "name": "host", + "description": "Set host address of the dev server, the accessible URL", + "type": "string" + }, + { + "name": "port", + "description": "Set port number of the dev server", + "type": "string" + }, + { + "name": "start", + "description": "Runs the application before starting to perform a testrun", "type": "boolean" } ] From df83789ff3a0cb9494abb8be350e103af9abaa54 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Tue, 2 Jul 2019 23:54:15 +0430 Subject: [PATCH 08/52] feature: run app automatically in the background before running cypress --- .../cypress/aurelia_project/tasks/cypress.ext | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/skeleton/cypress/aurelia_project/tasks/cypress.ext b/skeleton/cypress/aurelia_project/tasks/cypress.ext index 847f2d5d6..98fc81536 100644 --- a/skeleton/cypress/aurelia_project/tasks/cypress.ext +++ b/skeleton/cypress/aurelia_project/tasks/cypress.ext @@ -7,14 +7,27 @@ import * as cypress from 'cypress'; import * as config from '../../cypress.config'; // @endif import { CLIOptions } from 'aurelia-cli'; +import { default as runApp } from './run'; -export default (cb) => { +const runCypress = (cb) => { if (CLIOptions.hasFlag('run')) { cypress .run(config) - .then(results => (results.totalFailed === 0 ? cb() : cb('Run failed!'))) + .then(results => { + (results.totalFailed === 0 ? cb() : cb('Run failed!')) + process.exit(0); + }) .catch(cb); } else { cypress.open(config); } +} + +export default (cb) => { + if (CLIOptions.hasFlag('start')) { + runApp(runCypress(cb)); + return; + } + + runCypress(cb); }; From aa3139c972bec620302130052dde222d1a739e37 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Tue, 2 Jul 2019 23:54:34 +0430 Subject: [PATCH 09/52] add: scripts section in package.json for e2e tests --- skeleton/cypress/package.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/skeleton/cypress/package.json b/skeleton/cypress/package.json index 9f3be9ec3..a3786ed50 100644 --- a/skeleton/cypress/package.json +++ b/skeleton/cypress/package.json @@ -1,4 +1,8 @@ { + "scripts": { + "e2e": "au cypress", + "e2e:headless": "au cypress --run --start" + }, "devDependencies": { // @if feat.typescript "@cypress/webpack-preprocessor": "", @@ -7,4 +11,4 @@ // @endif "cypress": "" } -} \ No newline at end of file +} From 360e4c5b61bbb0b0119e6ad853ea8db9af039733 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Fri, 5 Jul 2019 22:44:38 +0430 Subject: [PATCH 10/52] removed: open npm package from package.json --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index e801b4e7e..fcfe01c79 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,6 @@ "mkdirp": "^0.5.1", "node-libs-browser": "^2.2.0", "npm-which": "^3.0.1", - "open": "^6.3.0", "preprocess": "^3.1.0", "pumpify": "^1.5.1", "querystring-es3": "1.0.0-0", From 0a7f64aac86cfe8faedbb1d9c71d3c55d2591a72 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Fri, 5 Jul 2019 22:44:38 +0430 Subject: [PATCH 11/52] removed: open npm package from package.json --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index e801b4e7e..fcfe01c79 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,6 @@ "mkdirp": "^0.5.1", "node-libs-browser": "^2.2.0", "npm-which": "^3.0.1", - "open": "^6.3.0", "preprocess": "^3.1.0", "pumpify": "^1.5.1", "querystring-es3": "1.0.0-0", From 4870ba66022e60b51d511578ff123556289a713c Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Fri, 5 Jul 2019 23:35:29 +0430 Subject: [PATCH 12/52] add: localhost to the aurelia.json when dotnet core This makes all bundlers to behave similarly when using webpack --- skeleton/webpack/aurelia_project/aurelia.json | 1 + 1 file changed, 1 insertion(+) diff --git a/skeleton/webpack/aurelia_project/aurelia.json b/skeleton/webpack/aurelia_project/aurelia.json index 0790da0d9..19d570eb9 100644 --- a/skeleton/webpack/aurelia_project/aurelia.json +++ b/skeleton/webpack/aurelia_project/aurelia.json @@ -18,6 +18,7 @@ // @if feat['dotnet-core'] "port": 5000, + "host": "localhost", "output": "wwwroot/dist", // @endif } From 51ec38b12b4a0d9602739f58e2cfc7d9f7d0d112 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Fri, 5 Jul 2019 23:36:17 +0430 Subject: [PATCH 13/52] add: helps for the au help command --- .../cypress/aurelia_project/tasks/cypress.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/skeleton/cypress/aurelia_project/tasks/cypress.json b/skeleton/cypress/aurelia_project/tasks/cypress.json index f63935ded..adc7d6773 100644 --- a/skeleton/cypress/aurelia_project/tasks/cypress.json +++ b/skeleton/cypress/aurelia_project/tasks/cypress.json @@ -6,6 +6,23 @@ "name": "run", "description": "Perfom a testrun and reports the results.", "type": "boolean" + }, + // @if feat.webpack + { + "name": "host", + "description": "Set host address of the dev server, the accessible URL", + "type": "string" + }, + // @endif + { + "name": "port", + "description": "Set port number of the dev server", + "type": "string" + }, + { + "name": "start", + "description": "Runs the application before starting to perform a testrun", + "type": "boolean" } ] } From dccda8929d92236cc0dee4864de5c9814c67f7d6 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Fri, 5 Jul 2019 23:38:01 +0430 Subject: [PATCH 14/52] update: CLI bundler, the --open can be configured The auto open browser option can now be configured both from aurelia.json file or as an --open flag from au run command --- skeleton/cli-bundler/aurelia_project/aurelia.json | 1 + skeleton/cli-bundler/aurelia_project/tasks/run.ext | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/skeleton/cli-bundler/aurelia_project/aurelia.json b/skeleton/cli-bundler/aurelia_project/aurelia.json index 8f8587fc9..c94bbe383 100644 --- a/skeleton/cli-bundler/aurelia_project/aurelia.json +++ b/skeleton/cli-bundler/aurelia_project/aurelia.json @@ -94,6 +94,7 @@ "platform": { // @if feat.web "port": 9000, + "open": false, "index": "index.html", "baseDir": ".", "output": "scripts", diff --git a/skeleton/cli-bundler/aurelia_project/tasks/run.ext b/skeleton/cli-bundler/aurelia_project/tasks/run.ext index 8aa3b915f..3c04085fb 100644 --- a/skeleton/cli-bundler/aurelia_project/tasks/run.ext +++ b/skeleton/cli-bundler/aurelia_project/tasks/run.ext @@ -19,7 +19,7 @@ let serve = gulp.series( done => { browserSync({ online: false, - open: CLIOptions.hasFlag('open'), + open: CLIOptions.hasFlag('open') || project.platform.open, port: CLIOptions.getFlagValue('port') || project.platform.port, logLevel: 'silent', server: { From 9caa6664e7e1638a5e36fb64d7764e13cf30636b Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Fri, 5 Jul 2019 23:52:52 +0430 Subject: [PATCH 15/52] add: "localhost" as the default value Add "localhost" as the default value in the absence of `host` value in the `aurelia.json` file, or in the `--host` flag of the `au run` command --- skeleton/webpack/aurelia_project/aurelia.json | 1 - skeleton/webpack/aurelia_project/tasks/run.ext | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/skeleton/webpack/aurelia_project/aurelia.json b/skeleton/webpack/aurelia_project/aurelia.json index 19d570eb9..0790da0d9 100644 --- a/skeleton/webpack/aurelia_project/aurelia.json +++ b/skeleton/webpack/aurelia_project/aurelia.json @@ -18,7 +18,6 @@ // @if feat['dotnet-core'] "port": 5000, - "host": "localhost", "output": "wwwroot/dist", // @endif } diff --git a/skeleton/webpack/aurelia_project/tasks/run.ext b/skeleton/webpack/aurelia_project/tasks/run.ext index 6cc1094b8..dca5edf41 100644 --- a/skeleton/webpack/aurelia_project/tasks/run.ext +++ b/skeleton/webpack/aurelia_project/tasks/run.ext @@ -18,7 +18,7 @@ import {CLIOptions, reportWebpackReadiness} from 'aurelia-cli'; function runWebpack(done) { // https://webpack.github.io/docs/webpack-dev-server.html let opts = { - host: CLIOptions.getFlagValue('host') || project.platform.host, + host: CLIOptions.getFlagValue('host') || project.platform.host || "localhost", port: CLIOptions.getFlagValue('port') || project.platform.port, hot: project.platform.hmr || CLIOptions.hasFlag('hmr'), open: project.platform.open || CLIOptions.hasFlag('open'), From 842d6594151d6beb9a804f355ec02266842f62b3 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Sat, 6 Jul 2019 15:36:33 +0430 Subject: [PATCH 16/52] typo: address Typo in run.json for host description of webpack skeleton --- skeleton/webpack/aurelia_project/tasks/run.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skeleton/webpack/aurelia_project/tasks/run.json b/skeleton/webpack/aurelia_project/tasks/run.json index 26cb2796d..053157b05 100644 --- a/skeleton/webpack/aurelia_project/tasks/run.json +++ b/skeleton/webpack/aurelia_project/tasks/run.json @@ -19,7 +19,7 @@ }, { "name": "host", - "description": "Set host adddress of the dev server, the accessible URL", + "description": "Set host address of the dev server, the accessible URL", "type": "string" }, { From 3499e710b68ec45440c5cf2383c937f98f636f4b Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Sat, 6 Jul 2019 15:36:56 +0430 Subject: [PATCH 17/52] add: host option for browser sync --- skeleton/cli-bundler/aurelia_project/tasks/run.ext | 1 + skeleton/cli-bundler/aurelia_project/tasks/run.json | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/skeleton/cli-bundler/aurelia_project/tasks/run.ext b/skeleton/cli-bundler/aurelia_project/tasks/run.ext index 3c04085fb..5e08c2bda 100644 --- a/skeleton/cli-bundler/aurelia_project/tasks/run.ext +++ b/skeleton/cli-bundler/aurelia_project/tasks/run.ext @@ -21,6 +21,7 @@ let serve = gulp.series( online: false, open: CLIOptions.hasFlag('open') || project.platform.open, port: CLIOptions.getFlagValue('port') || project.platform.port, + host: CLIOptions.getFlagValue('host') || project.platform.host || "localhost", logLevel: 'silent', server: { baseDir: [project.platform.baseDir], diff --git a/skeleton/cli-bundler/aurelia_project/tasks/run.json b/skeleton/cli-bundler/aurelia_project/tasks/run.json index 9b51ac57e..9de7be11d 100644 --- a/skeleton/cli-bundler/aurelia_project/tasks/run.json +++ b/skeleton/cli-bundler/aurelia_project/tasks/run.json @@ -19,6 +19,11 @@ "type": "boolean" }, // @endif + { + "name": "host", + "description": "Set host address of the dev server, the accessible URL", + "type": "string" + }, { "name": "port", "description": "Set port number of the dev server", From da926a3d0febdca390cb258958ceeecf7e0fc932 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Sat, 6 Jul 2019 15:56:12 +0430 Subject: [PATCH 18/52] update: run.ext, CLI Bundler to report --host value as well Report the --host value as well as urls --- skeleton/cli-bundler/aurelia_project/tasks/run.ext | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/skeleton/cli-bundler/aurelia_project/tasks/run.ext b/skeleton/cli-bundler/aurelia_project/tasks/run.ext index 5e08c2bda..aae37060f 100644 --- a/skeleton/cli-bundler/aurelia_project/tasks/run.ext +++ b/skeleton/cli-bundler/aurelia_project/tasks/run.ext @@ -33,6 +33,12 @@ let serve = gulp.series( }, function (err, bs) { if (err) return done(err); let urls = bs.options.get('urls').toJS(); + let host = bs.options.get('host'); + let port = bs.options.get('port'); + + if( host !== "localhost" ) + log(`Application Available At: http://${host}:${port}`); + log(`Application Available At: ${urls.local}`); log(`BrowserSync Available At: ${urls.ui}`); done(); From e306c3840c55a3a37c5e02296d3476395a96a068 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Sat, 6 Jul 2019 16:00:45 +0430 Subject: [PATCH 19/52] add: host, as a setting in aurelia.json file for CLI Bundler --- skeleton/cli-bundler/aurelia_project/aurelia.json | 1 + 1 file changed, 1 insertion(+) diff --git a/skeleton/cli-bundler/aurelia_project/aurelia.json b/skeleton/cli-bundler/aurelia_project/aurelia.json index c94bbe383..44e68b619 100644 --- a/skeleton/cli-bundler/aurelia_project/aurelia.json +++ b/skeleton/cli-bundler/aurelia_project/aurelia.json @@ -94,6 +94,7 @@ "platform": { // @if feat.web "port": 9000, + "host": "localhost", "open": false, "index": "index.html", "baseDir": ".", From f235dfa9120cf18ce98ea7d0f42df9e05c13a939 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Sat, 6 Jul 2019 18:16:47 +0430 Subject: [PATCH 20/52] update: override port and host for ptotractor updated protractor.conf.js to override port and host based on the platform settings in the aurelia.json file --- skeleton/protractor/test/protractor.conf.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skeleton/protractor/test/protractor.conf.js b/skeleton/protractor/test/protractor.conf.js index 6b10ddbb6..72ea0063b 100644 --- a/skeleton/protractor/test/protractor.conf.js +++ b/skeleton/protractor/test/protractor.conf.js @@ -1,10 +1,10 @@ const aureliaConfig = require('../aurelia_project/aurelia.json'); const port = aureliaConfig.platform.port; +const host = aureliaConfig.platform.host; exports.config = { port: port, - - baseUrl: `http://localhost:${port}/`, + baseUrl: `http://${host}:${port}/`, specs: [ // @if feat.babel From d7b47454f659e8d1939057cf443fff1849408d97 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Sat, 6 Jul 2019 20:30:54 +0430 Subject: [PATCH 21/52] auto start application before e2e tests --- .../protractor/aurelia_project/tasks/protractor.ext | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/skeleton/protractor/aurelia_project/tasks/protractor.ext b/skeleton/protractor/aurelia_project/tasks/protractor.ext index 6d0d5244a..a8efdd956 100644 --- a/skeleton/protractor/aurelia_project/tasks/protractor.ext +++ b/skeleton/protractor/aurelia_project/tasks/protractor.ext @@ -6,6 +6,18 @@ import * as gulp from 'gulp'; // @endif const {protractor, webdriver_update } = require('gulp-protractor'); +import { CLIOptions } from 'aurelia-cli'; +import * as project from '../aurelia.json'; +import { default as run } from './run'; + +function runApp(cb) { + if (CLIOptions.hasFlag('start')) { + run(); + cb(); + } +} +gulp.task('run-app' , runApp); + gulp.task('webdriver_update', webdriver_update); gulp.task('protractor', (cb) => { @@ -22,6 +34,7 @@ gulp.task('protractor', (cb) => { // Setting up the test task export default gulp.series( + 'run-app', 'webdriver_update', 'protractor' ); From ae8ee673db9a4170d412b7f705c7c0702ae3c488 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Sun, 7 Jul 2019 07:58:04 +0430 Subject: [PATCH 22/52] add: scripts to run e2e test && reformat protractor.ext --- skeleton/protractor/aurelia_project/tasks/protractor.ext | 5 ++--- skeleton/protractor/package.json | 6 +++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/skeleton/protractor/aurelia_project/tasks/protractor.ext b/skeleton/protractor/aurelia_project/tasks/protractor.ext index a8efdd956..144826f8d 100644 --- a/skeleton/protractor/aurelia_project/tasks/protractor.ext +++ b/skeleton/protractor/aurelia_project/tasks/protractor.ext @@ -7,14 +7,13 @@ import * as gulp from 'gulp'; const {protractor, webdriver_update } = require('gulp-protractor'); import { CLIOptions } from 'aurelia-cli'; -import * as project from '../aurelia.json'; import { default as run } from './run'; function runApp(cb) { - if (CLIOptions.hasFlag('start')) { + if (CLIOptions.hasFlag('start')) { run(); - cb(); } + cb(); } gulp.task('run-app' , runApp); diff --git a/skeleton/protractor/package.json b/skeleton/protractor/package.json index 63cc5da69..bae75cc81 100644 --- a/skeleton/protractor/package.json +++ b/skeleton/protractor/package.json @@ -1,4 +1,8 @@ { + "scripts": { + "e2e": "au protractor", + "e2e:headless": "au protractor --run --start" + }, "devDependencies": { // @if feat.typescript "ts-node": "", @@ -9,4 +13,4 @@ "gulp-protractor": "", "wait-on": "", } -} \ No newline at end of file +} From 2bba751b55ee9caa513e04899558f071b569245a Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Sun, 7 Jul 2019 22:44:30 +0430 Subject: [PATCH 23/52] update: run.ext, prioritize hmr & open flags Give higher priority to hmr and open flags than the settings in the aurelia.json file --- skeleton/webpack/aurelia_project/tasks/run.ext | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skeleton/webpack/aurelia_project/tasks/run.ext b/skeleton/webpack/aurelia_project/tasks/run.ext index dca5edf41..90377e145 100644 --- a/skeleton/webpack/aurelia_project/tasks/run.ext +++ b/skeleton/webpack/aurelia_project/tasks/run.ext @@ -20,8 +20,8 @@ function runWebpack(done) { let opts = { host: CLIOptions.getFlagValue('host') || project.platform.host || "localhost", port: CLIOptions.getFlagValue('port') || project.platform.port, - hot: project.platform.hmr || CLIOptions.hasFlag('hmr'), - open: project.platform.open || CLIOptions.hasFlag('open'), + open: CLIOptions.hasFlag('open') || project.platform.open, + hot: CLIOptions.hasFlag('hmr') || project.platform.hmr, publicPath: config.output.publicPath, filename: config.output.filename, contentBase: config.output.path, From 08d0fc8e813d6648df8621596a06c2deff174f0d Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Sun, 7 Jul 2019 22:45:08 +0430 Subject: [PATCH 24/52] add: arguments to the protractor child process --- .../protractor/aurelia_project/tasks/protractor.ext | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/skeleton/protractor/aurelia_project/tasks/protractor.ext b/skeleton/protractor/aurelia_project/tasks/protractor.ext index 144826f8d..2ba343937 100644 --- a/skeleton/protractor/aurelia_project/tasks/protractor.ext +++ b/skeleton/protractor/aurelia_project/tasks/protractor.ext @@ -10,10 +10,10 @@ import { CLIOptions } from 'aurelia-cli'; import { default as run } from './run'; function runApp(cb) { - if (CLIOptions.hasFlag('start')) { - run(); - } - cb(); + if (CLIOptions.hasFlag('start')) { + run(); + } + cb(); } gulp.task('run-app' , runApp); @@ -26,7 +26,7 @@ gulp.task('protractor', (cb) => { // @if feat.typescript gulp.src('test/e2e/**/*.e2e.ts') // @endif - .pipe(protractor({configFile: 'test/protractor.conf.js'})) + .pipe(protractor({configFile: 'test/protractor.conf.js', args: process.argv.slice(3) })) .on('error', cb) .on('end', cb); }); From 3c08c563037deded2a2b67c9f217a92b2598c6e0 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Sun, 7 Jul 2019 22:46:05 +0430 Subject: [PATCH 25/52] support: running protractor in headless mode by --run arg, like cypress --- skeleton/protractor/test/protractor.conf.js | 29 ++++++++++++++------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/skeleton/protractor/test/protractor.conf.js b/skeleton/protractor/test/protractor.conf.js index 72ea0063b..6f386457f 100644 --- a/skeleton/protractor/test/protractor.conf.js +++ b/skeleton/protractor/test/protractor.conf.js @@ -1,8 +1,16 @@ -const aureliaConfig = require('../aurelia_project/aurelia.json'); -const port = aureliaConfig.platform.port; -const host = aureliaConfig.platform.host; +const CLIOptions = require('aurelia-cli').CLIOptions; +const aureliaConfig = require('./aurelia_project/aurelia.json'); +const cliOptions = new CLIOptions(); -exports.config = { +Object.assign(cliOptions, { + args: process.argv.slice(3) +}); + +const port = cliOptions.getFlagValue('port') || aureliaConfig.platform.port; +const host = cliOptions.getFlagValue('host') || aureliaConfig.platform.host || "localhost"; +const headless = cliOptions.hasFlag('run') || false; + +const config = { port: port, baseUrl: `http://${host}:${port}/`, @@ -45,11 +53,7 @@ exports.config = { '--disable-translate', '--disable-background-timer-throttling', '--disable-renderer-backgrounding', - '--disable-device-discovery-notifications', - /* enable these if you'd like to test using Chrome Headless - '--no-gpu', - '--headless' - */ + '--disable-device-discovery-notifications' ] } }, @@ -69,3 +73,10 @@ exports.config = { package: 'aurelia-protractor-plugin' }], }; + +if (headless) { + config.capabilities.chromeOptions.args.push("--no-gpu"); + config.capabilities.chromeOptions.args.push("--headless"); +} + +exports.config = config; From 440d932e2ba0e9f3938aa9bf150969f105ef625c Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Sun, 7 Jul 2019 22:46:40 +0430 Subject: [PATCH 26/52] add: new flags for protractor for the sake of au help command --- .../aurelia_project/tasks/protractor.json | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/skeleton/protractor/aurelia_project/tasks/protractor.json b/skeleton/protractor/aurelia_project/tasks/protractor.json index 9d873a9f7..47f8df55d 100644 --- a/skeleton/protractor/aurelia_project/tasks/protractor.json +++ b/skeleton/protractor/aurelia_project/tasks/protractor.json @@ -1,4 +1,25 @@ { "name": "protractor", - "description": "Runs Protractor and reports the results. Start the application before running this task." + "description": "Runs Protractor and reports the results. Start the application before running this task.", + "flags": [{ + "name": "run", + "description": "Perform a test run and reports the results.", + "type": "boolean" + }, + { + "name": "host", + "description": "Set host address of the dev server, the accessible URL", + "type": "string" + }, + { + "name": "port", + "description": "Set port number of the dev server", + "type": "string" + }, + { + "name": "start", + "description": "Runs the application before starting to perform a testrun", + "type": "boolean" + } + ] } From 218cd496c5451f9f5cff0bcdd6c4d60aff18c76c Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Sun, 7 Jul 2019 22:46:51 +0430 Subject: [PATCH 27/52] update: cypress au help flags --- .../cypress/aurelia_project/tasks/cypress.json | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/skeleton/cypress/aurelia_project/tasks/cypress.json b/skeleton/cypress/aurelia_project/tasks/cypress.json index a883b36a9..822e4f05f 100644 --- a/skeleton/cypress/aurelia_project/tasks/cypress.json +++ b/skeleton/cypress/aurelia_project/tasks/cypress.json @@ -17,23 +17,6 @@ "description": "Set port number of the dev server", "type": "string" }, - { - "name": "start", - "description": "Runs the application before starting to perform a testrun", - "type": "boolean" - }, - // @if feat.webpack - { - "name": "host", - "description": "Set host address of the dev server, the accessible URL", - "type": "string" - }, - // @endif - { - "name": "port", - "description": "Set port number of the dev server", - "type": "string" - }, { "name": "start", "description": "Runs the application before starting to perform a testrun", From b537b09a90632ea5256eecfa44f9640d8f3eaf8b Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Sun, 7 Jul 2019 23:27:59 +0430 Subject: [PATCH 28/52] fix: protractor.conf.js file was accidentally moved --- skeleton/protractor/aurelia_project/tasks/protractor.ext | 2 +- skeleton/protractor/{test => }/protractor.conf.js | 0 skeleton/scaffold-minimum/test__if_protractor/e2e/demo.e2e.ext | 2 +- .../scaffold-navigation/test__if_protractor/e2e/demo.e2e.ext | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename skeleton/protractor/{test => }/protractor.conf.js (100%) diff --git a/skeleton/protractor/aurelia_project/tasks/protractor.ext b/skeleton/protractor/aurelia_project/tasks/protractor.ext index 2ba343937..109d95b35 100644 --- a/skeleton/protractor/aurelia_project/tasks/protractor.ext +++ b/skeleton/protractor/aurelia_project/tasks/protractor.ext @@ -26,7 +26,7 @@ gulp.task('protractor', (cb) => { // @if feat.typescript gulp.src('test/e2e/**/*.e2e.ts') // @endif - .pipe(protractor({configFile: 'test/protractor.conf.js', args: process.argv.slice(3) })) + .pipe(protractor({configFile: 'protractor.conf.js', args: process.argv.slice(3) })) .on('error', cb) .on('end', cb); }); diff --git a/skeleton/protractor/test/protractor.conf.js b/skeleton/protractor/protractor.conf.js similarity index 100% rename from skeleton/protractor/test/protractor.conf.js rename to skeleton/protractor/protractor.conf.js diff --git a/skeleton/scaffold-minimum/test__if_protractor/e2e/demo.e2e.ext b/skeleton/scaffold-minimum/test__if_protractor/e2e/demo.e2e.ext index 1a23020ba..d419e7fee 100644 --- a/skeleton/scaffold-minimum/test__if_protractor/e2e/demo.e2e.ext +++ b/skeleton/scaffold-minimum/test__if_protractor/e2e/demo.e2e.ext @@ -1,6 +1,6 @@ import {PageObjectWelcome} from './welcome.po'; import {PageObjectSkeleton} from './skeleton.po'; -import {config} from '../protractor.conf'; +import {config} from '../../protractor.conf'; // @if feat.typescript import {browser, element, by, By, $, $$, ExpectedConditions} from 'aurelia-protractor-plugin/protractor'; // @endif diff --git a/skeleton/scaffold-navigation/test__if_protractor/e2e/demo.e2e.ext b/skeleton/scaffold-navigation/test__if_protractor/e2e/demo.e2e.ext index 5bf12b2e9..0a7e4be4b 100644 --- a/skeleton/scaffold-navigation/test__if_protractor/e2e/demo.e2e.ext +++ b/skeleton/scaffold-navigation/test__if_protractor/e2e/demo.e2e.ext @@ -1,6 +1,6 @@ import {PageObjectWelcome} from './welcome.po'; import {PageObjectSkeleton} from './skeleton.po'; -import {config} from '../protractor.conf'; +import {config} from '../../protractor.conf'; // @if feat.typescript import {browser, element, by, By, $, $$, ExpectedConditions} from 'aurelia-protractor-plugin/protractor'; // @endif From 862b8e5fdf103467b809991f7365599b791b5638 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Sun, 7 Jul 2019 23:31:20 +0430 Subject: [PATCH 29/52] fix: stop e2e tests when finished, protractor --- skeleton/protractor/aurelia_project/tasks/protractor.ext | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/skeleton/protractor/aurelia_project/tasks/protractor.ext b/skeleton/protractor/aurelia_project/tasks/protractor.ext index 109d95b35..86a09342d 100644 --- a/skeleton/protractor/aurelia_project/tasks/protractor.ext +++ b/skeleton/protractor/aurelia_project/tasks/protractor.ext @@ -28,7 +28,10 @@ gulp.task('protractor', (cb) => { // @endif .pipe(protractor({configFile: 'protractor.conf.js', args: process.argv.slice(3) })) .on('error', cb) - .on('end', cb); + .on('end', () => { + cb() + process.exit(0); + }); }); // Setting up the test task From 74715141c87921fc6c3fcf026ce1090fccdccd64 Mon Sep 17 00:00:00 2001 From: Sayan751 Date: Thu, 16 May 2019 00:01:56 +0200 Subject: [PATCH 30/52] feat(webpack):enable CLI-less webpack build + run Usage of aurelia-cli is removed from building and running the webpack apps. This gives developers more control over webpack, and a way to easily change the configuration, without aurelia-cli meddling in between. The commands `au run` or `au build` will not work anymore in the webpack apps, use `npm start`, or `npm run build` instead. This commit closes the webpack part of the the issue #1098. Conflicts: skeleton/webpack/webpack.config.js --- build/tasks/release-checks/suite-steps.js | 10 +-- .../tests/generic/au-cypress.js | 2 +- .../tests/generic/au-protractor.js | 2 +- .../release-checks/tests/webpack/index.js | 2 +- .../tests/webpack/{au-run.js => run.js} | 42 ++++++------ skeleton/common/config/environment.json | 4 ++ .../common/config/environment.production.json | 4 ++ skeleton/common/tsconfig.json__if_typescript | 5 +- skeleton/scaffold-minimum/src/main.ext | 2 +- skeleton/scaffold-navigation/src/main.ext | 2 +- skeleton/webpack/README.md | 12 ++-- .../webpack/aurelia_project/tasks/build.ext | 67 ------------------- .../webpack/aurelia_project/tasks/build.json | 21 ------ .../webpack/aurelia_project/tasks/run.ext | 62 ----------------- .../webpack/aurelia_project/tasks/run.json | 31 --------- skeleton/webpack/gulpFile.js | 10 +++ skeleton/webpack/package.json | 13 ++++ skeleton/webpack/webpack.config.js | 20 +++--- 18 files changed, 81 insertions(+), 230 deletions(-) rename build/tasks/release-checks/tests/webpack/{au-run.js => run.js} (73%) create mode 100644 skeleton/common/config/environment.json create mode 100644 skeleton/common/config/environment.production.json delete mode 100644 skeleton/webpack/aurelia_project/tasks/build.ext delete mode 100644 skeleton/webpack/aurelia_project/tasks/build.json delete mode 100644 skeleton/webpack/aurelia_project/tasks/run.ext delete mode 100644 skeleton/webpack/aurelia_project/tasks/run.json create mode 100644 skeleton/webpack/gulpFile.js diff --git a/build/tasks/release-checks/suite-steps.js b/build/tasks/release-checks/suite-steps.js index ce584c821..472911c15 100644 --- a/build/tasks/release-checks/suite-steps.js +++ b/build/tasks/release-checks/suite-steps.js @@ -65,11 +65,11 @@ module.exports = function(suite) { if (applicable(features, 'webpack')) { steps.push( - new tests.webpack.AuRunDoesNotThrowCommandLineErrors(), - new tests.webpack.AuRunLaunchesServer(), - new tests.webpack.AuRunRendersPage(), - new tests.webpack.AuRunAppLaunchesWithoutJavascriptErrors(), - new tests.webpack.AuRunWatchPicksUpFileChanges() + new tests.webpack.NpmStartDoesNotThrowCommandLineErrors(), + new tests.webpack.NpmStartLaunchesServer(), + new tests.webpack.NpmStartRendersPage(), + new tests.webpack.NpmStartAppLaunchesWithoutJavascriptErrors(), + new tests.webpack.NpmStartWatchPicksUpFileChanges() ); } diff --git a/build/tasks/release-checks/tests/generic/au-cypress.js b/build/tasks/release-checks/tests/generic/au-cypress.js index 295f72159..22075f7e6 100644 --- a/build/tasks/release-checks/tests/generic/au-cypress.js +++ b/build/tasks/release-checks/tests/generic/au-cypress.js @@ -30,7 +30,7 @@ class AuCypressRunsTests extends Test { } execute() { - this.executeCommand = new ExecuteCommand('au', ['run'], (msg) => this.onOutput(msg)); + this.executeCommand = new ExecuteCommand('npm', ['start'], (msg) => this.onOutput(msg)); return this.executeCommand.executeAsNodeScript(); } } diff --git a/build/tasks/release-checks/tests/generic/au-protractor.js b/build/tasks/release-checks/tests/generic/au-protractor.js index bacb3a958..5590867dd 100644 --- a/build/tasks/release-checks/tests/generic/au-protractor.js +++ b/build/tasks/release-checks/tests/generic/au-protractor.js @@ -27,7 +27,7 @@ class AuProtractorRunsTests extends Test { } execute() { - this.executeCommand = new ExecuteCommand('au', ['run'], (msg) => this.onOutput(msg)); + this.executeCommand = new ExecuteCommand('npm', ['start'], (msg) => this.onOutput(msg)); return this.executeCommand.executeAsNodeScript(); } } diff --git a/build/tasks/release-checks/tests/webpack/index.js b/build/tasks/release-checks/tests/webpack/index.js index 1d098164b..1b996242d 100644 --- a/build/tasks/release-checks/tests/webpack/index.js +++ b/build/tasks/release-checks/tests/webpack/index.js @@ -1,3 +1,3 @@ module.exports = { - ...require('./au-run') + ...require('./run') }; diff --git a/build/tasks/release-checks/tests/webpack/au-run.js b/build/tasks/release-checks/tests/webpack/run.js similarity index 73% rename from build/tasks/release-checks/tests/webpack/au-run.js rename to build/tasks/release-checks/tests/webpack/run.js index 16e5fe62d..756fb55f1 100644 --- a/build/tasks/release-checks/tests/webpack/au-run.js +++ b/build/tasks/release-checks/tests/webpack/run.js @@ -6,9 +6,9 @@ const StepRunner = require('../../step-runner'); const path = require('path'); const fs = require('fs'); -class AuRunDoesNotThrowCommandLineErrors extends Test { +class NpmStartDoesNotThrowCommandLineErrors extends Test { constructor() { - super('au run does not throw commandline errors'); + super('npm start does not throw commandline errors'); } onOutput(message) { @@ -24,14 +24,14 @@ class AuRunDoesNotThrowCommandLineErrors extends Test { } execute() { - this.executeCommand = new ExecuteCommand('au', ['run'], (msg) => this.onOutput(msg)); + this.executeCommand = new ExecuteCommand('npm', ['start'], (msg) => this.onOutput(msg)); return this.executeCommand.executeAsNodeScript(); } } -class AuRunLaunchesServer extends Test { +class NpmStartLaunchesServer extends Test { constructor() { - super('au run launches server'); + super('npm start launches server'); } onOutput(message) { @@ -44,14 +44,14 @@ class AuRunLaunchesServer extends Test { } execute() { - this.executeCommand = new ExecuteCommand('au', ['run'], (msg) => this.onOutput(msg)); + this.executeCommand = new ExecuteCommand('npm', ['start'], (msg) => this.onOutput(msg)); return this.executeCommand.executeAsNodeScript(); } } -class AuRunWatchPicksUpFileChanges extends Test { +class NpmStartWatchPicksUpFileChanges extends Test { constructor(fileToChange) { - super('au run picks up file changes'); + super('npm start picks up file changes'); this.fileToChange = fileToChange || path.join('src', 'app.html'); this.watchingForFileChangeNotification = false; @@ -99,14 +99,14 @@ class AuRunWatchPicksUpFileChanges extends Test { execute(context) { this.context = context; - this.executeCommand = new ExecuteCommand('au', ['run'], (msg) => this.onOutput(msg)); + this.executeCommand = new ExecuteCommand('npm', ['start'], (msg) => this.onOutput(msg)); return this.executeCommand.executeAsNodeScript(); } } -class AuRunAppLaunchesWithoutJavascriptErrors extends Test { +class NpmStartAppLaunchesWithoutJavascriptErrors extends Test { constructor() { - super('au run app launches without javascript errors'); + super('npm start app launches without javascript errors'); } onOutput(message) { @@ -127,14 +127,14 @@ class AuRunAppLaunchesWithoutJavascriptErrors extends Test { } execute() { - this.executeCommand = new ExecuteCommand('au', ['run'], (msg) => this.onOutput(msg)); + this.executeCommand = new ExecuteCommand('npm', ['start'], (msg) => this.onOutput(msg)); return this.executeCommand.executeAsNodeScript(); } } -class AuRunRendersPage extends Test { +class NpmStartRendersPage extends Test { constructor() { - super('au run renders page'); + super('npm start renders page'); } onOutput(context, message) { @@ -144,7 +144,7 @@ class AuRunRendersPage extends Test { this.isUp = true; const url = getURL(message); - const screenshot = new TakeScreenShotOfPage(url, path.join(context.resultOutputFolder, 'screenshot-of-au-run.png')); + const screenshot = new TakeScreenShotOfPage(url, path.join(context.resultOutputFolder, 'screenshot-of-npm-start.png')); return new StepRunner(screenshot).run() .then(() => { @@ -155,7 +155,7 @@ class AuRunRendersPage extends Test { } execute(context) { - this.executeCommand = new ExecuteCommand('au', ['run'], (msg) => this.onOutput(context, msg)); + this.executeCommand = new ExecuteCommand('npm', ['start'], (msg) => this.onOutput(context, msg)); return this.executeCommand.executeAsNodeScript(); } } @@ -171,9 +171,9 @@ function getURL(msg) { } module.exports = { - AuRunDoesNotThrowCommandLineErrors, - AuRunLaunchesServer, - AuRunWatchPicksUpFileChanges, - AuRunAppLaunchesWithoutJavascriptErrors, - AuRunRendersPage + NpmStartDoesNotThrowCommandLineErrors, + NpmStartLaunchesServer, + NpmStartWatchPicksUpFileChanges, + NpmStartAppLaunchesWithoutJavascriptErrors, + NpmStartRendersPage }; diff --git a/skeleton/common/config/environment.json b/skeleton/common/config/environment.json new file mode 100644 index 000000000..a32129fd0 --- /dev/null +++ b/skeleton/common/config/environment.json @@ -0,0 +1,4 @@ +{ + "debug": true, + "testing": true +} \ No newline at end of file diff --git a/skeleton/common/config/environment.production.json b/skeleton/common/config/environment.production.json new file mode 100644 index 000000000..9ddbb4430 --- /dev/null +++ b/skeleton/common/config/environment.production.json @@ -0,0 +1,4 @@ +{ + "debug": false, + "testing": false +} \ No newline at end of file diff --git a/skeleton/common/tsconfig.json__if_typescript b/skeleton/common/tsconfig.json__if_typescript index fadcfe313..18cfbb56c 100644 --- a/skeleton/common/tsconfig.json__if_typescript +++ b/skeleton/common/tsconfig.json__if_typescript @@ -32,10 +32,8 @@ "types": ["node", "jest"], // @endif - // @if feat.webpack && feat['postcss-typical'] && feat.protractor "typeRoots": ["./node_modules/@types"], - // @endif - + "removeComments": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, @@ -44,6 +42,7 @@ "lib": ["es2015", "dom"], "moduleResolution": "node", "baseUrl": "src", + "resolveJsonModule": true, // @if feat.plugin "paths": { "resources": [ "" ] }, diff --git a/skeleton/scaffold-minimum/src/main.ext b/skeleton/scaffold-minimum/src/main.ext index 7ce184a19..b1d52cffa 100644 --- a/skeleton/scaffold-minimum/src/main.ext +++ b/skeleton/scaffold-minimum/src/main.ext @@ -6,7 +6,7 @@ import 'regenerator-runtime/runtime'; // @if feat.typescript import {Aurelia} from 'aurelia-framework' // @endif -import environment from './environment'; +import * as environment from '../config/environment.json'; // @if feat.webpack import {PLATFORM} from 'aurelia-pal'; // @endif diff --git a/skeleton/scaffold-navigation/src/main.ext b/skeleton/scaffold-navigation/src/main.ext index 7d27096d7..6af74b7df 100644 --- a/skeleton/scaffold-navigation/src/main.ext +++ b/skeleton/scaffold-navigation/src/main.ext @@ -7,7 +7,7 @@ import 'bootstrap'; // @if feat.typescript import {Aurelia} from 'aurelia-framework'; // @endif -import environment from './environment'; +import * as environment from '../config/environment.json'; // @if feat.webpack import {PLATFORM} from 'aurelia-pal'; // @endif diff --git a/skeleton/webpack/README.md b/skeleton/webpack/README.md index ba3ea9c6a..118f9f347 100644 --- a/skeleton/webpack/README.md +++ b/skeleton/webpack/README.md @@ -2,16 +2,14 @@ For more information, go to https://aurelia.io/docs/cli/webpack ## Run dev app -Run `au run`, then open `http://localhost:/* @if feat.web */8080/* @endif *//* @if feat['dotnet-core'] */5000/* @endif */` +Run `npm start`, then open `http://localhost:/* @if feat.web */8080/* @endif *//* @if feat['dotnet-core'] */5000/* @endif */` -To open browser automatically, do `au run --open`. +You can change the standard webpack configurations from CLI easily with something like this: `npm start -- --open --port 8888`. However, it is better to change the respective npm scripts or `webpack.config.js` with these options, as per your need. -To change dev server port, do `au run --port 8888`. +To enable Webpack Bundle Analyzer, do `npm run analyze` (production build). -To enable Webpack Bundle Analyzer, do `au run --analyze`. - -To enable hot module reload, do `au run --hmr`. +To enable hot module reload, do `npm start -- --env.hmr`. ## Build for production -Run `au build --env prod`. +Run `npm run build`. diff --git a/skeleton/webpack/aurelia_project/tasks/build.ext b/skeleton/webpack/aurelia_project/tasks/build.ext deleted file mode 100644 index e386af35a..000000000 --- a/skeleton/webpack/aurelia_project/tasks/build.ext +++ /dev/null @@ -1,67 +0,0 @@ -// @if feat.babel -import webpackConfig from '../../webpack.config'; -import webpack from 'webpack'; -import project from '../aurelia.json'; -import gulp from 'gulp'; -import del from 'del'; -// @endif -// @if feat.typescript -import * as webpackConfig from '../../webpack.config'; -import * as webpack from 'webpack'; -import * as project from '../aurelia.json'; -import * as gulp from 'gulp'; -import * as del from 'del'; -// @endif -import {CLIOptions, Configuration} from 'aurelia-cli'; -import configureEnvironment from './environment'; - -const analyze = CLIOptions.hasFlag('analyze'); -const buildOptions = new Configuration(project.build.options); -const production = CLIOptions.getEnvironment() === 'prod'; -const server = buildOptions.isApplicable('server'); -const extractCss = buildOptions.isApplicable('extractCss'); -const coverage = buildOptions.isApplicable('coverage'); - -const config = webpackConfig({ - production, server, extractCss, coverage, analyze -}); -const compiler = webpack(/* @if feat.typescript **/* @endif */config); - -function buildWebpack(done) { - if (CLIOptions.hasFlag('watch')) { - compiler.watch({}, onBuild); - } else { - compiler.run(onBuild); - compiler.hooks.done.tap('done', () => done()); - } -} - -function onBuild(err, stats) { - if (!CLIOptions.hasFlag('watch') && err) { - console.error(err.stack || err); - if (err.details) console.error(err.details); - process.exit(1); - } else { - process.stdout.write(stats.toString({ colors: require('supports-color') }) + '\n'); - - if (!CLIOptions.hasFlag('watch') && stats.hasErrors()) { - process.exit(1); - } - } -} - -function clearDist() { - return del([config.output.path]); -} - -const build = gulp.series( - clearDist, - configureEnvironment, - buildWebpack -); - -export { - config, - buildWebpack, - build as default -}; diff --git a/skeleton/webpack/aurelia_project/tasks/build.json b/skeleton/webpack/aurelia_project/tasks/build.json deleted file mode 100644 index 27a093605..000000000 --- a/skeleton/webpack/aurelia_project/tasks/build.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "build", - "description": "Builds and processes all application assets.", - "flags": [ - { - "name": "analyze", - "description": "Enable Webpack Bundle Analyzer. Typically paired with --env prod", - "type": "boolean" - }, - { - "name": "env", - "description": "Sets the build environment.", - "type": "string" - }, - { - "name": "watch", - "description": "Watches source files for changes and refreshes the bundles automatically.", - "type": "boolean" - } - ] -} diff --git a/skeleton/webpack/aurelia_project/tasks/run.ext b/skeleton/webpack/aurelia_project/tasks/run.ext deleted file mode 100644 index 003fea0a1..000000000 --- a/skeleton/webpack/aurelia_project/tasks/run.ext +++ /dev/null @@ -1,62 +0,0 @@ -// @if feat.babel -import webpack from 'webpack'; -import Server from 'webpack-dev-server'; -import project from '../aurelia.json'; -import gulp from 'gulp'; -// @endif -// @if feat.typescript -import * as webpack from 'webpack'; -import * as Server from 'webpack-dev-server'; -import * as project from '../aurelia.json'; -import * as gulp from 'gulp'; -// @endif - -import {config} from './build'; -import configureEnvironment from './environment'; -import {CLIOptions, reportWebpackReadiness} from 'aurelia-cli'; - -function runWebpack(done) { - // https://webpack.github.io/docs/webpack-dev-server.html - let opts = { - host: 'localhost', - publicPath: config.output.publicPath, - filename: config.output.filename, - hot: project.platform.hmr || CLIOptions.hasFlag('hmr'), - port: CLIOptions.getFlagValue('port') || project.platform.port, - contentBase: config.output.path, - historyApiFallback: true, - open: project.platform.open || CLIOptions.hasFlag('open'), - stats: { - colors: require('supports-color') - }, - ...config.devServer - }/* @if feat.typescript ** as any/* @endif */; - - // Add the webpack-dev-server client to the webpack entry point - // The path for the client to use such as `webpack-dev-server/client?http://${opts.host}:${opts.port}/` is not required - // The path used is derived from window.location in the browser and output.publicPath in the webpack.config. - if (project.platform.hmr || CLIOptions.hasFlag('hmr')) { - config.plugins.push(new webpack.HotModuleReplacementPlugin()); - config.entry.app.unshift('webpack-dev-server/client', 'webpack/hot/dev-server'); - } else { - // removed "" from index.ejs in favour of this method - config.entry.app.unshift('webpack-dev-server/client'); - } - - const compiler = webpack(config); - let server = new Server(compiler, opts); - - server.listen(opts.port, opts.host, function(err) { - if (err) throw err; - - reportWebpackReadiness(opts); - done(); - }); -} - -const run = gulp.series( - configureEnvironment, - runWebpack -); - -export { run as default }; diff --git a/skeleton/webpack/aurelia_project/tasks/run.json b/skeleton/webpack/aurelia_project/tasks/run.json deleted file mode 100644 index 99b409d69..000000000 --- a/skeleton/webpack/aurelia_project/tasks/run.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "run", - "description": "Builds the application and serves up the assets via a local web server, watching files for changes as you work.", - "flags": [ - { - "name": "analyze", - "description": "Enable Webpack Bundle Analyzer. Typically paired with --env prod", - "type": "boolean" - }, - { - "name": "env", - "description": "Sets the build environment.", - "type": "string" - }, - { - "name": "hmr", - "description": "Enable Hot Module Reload", - "type": "boolean" - }, - { - "name": "port", - "description": "Set port number of the dev server", - "type": "string" - }, - { - "name": "open", - "description": "Open the default browser at the application location.", - "type": "boolean" - } - ] -} diff --git a/skeleton/webpack/gulpFile.js b/skeleton/webpack/gulpFile.js new file mode 100644 index 000000000..5dfeb25ed --- /dev/null +++ b/skeleton/webpack/gulpFile.js @@ -0,0 +1,10 @@ +const del = require('del'); +const gulp = require('gulp'); +const path = require('path'); +const project = require('./aurelia_project/aurelia.json'); + +function clearDist() { + return del([path.resolve(__dirname, project.platform.output)]); +} + +gulp.task("prebuild", clearDist); \ No newline at end of file diff --git a/skeleton/webpack/package.json b/skeleton/webpack/package.json index 07d3fbe87..8d496e9a6 100644 --- a/skeleton/webpack/package.json +++ b/skeleton/webpack/package.json @@ -64,9 +64,22 @@ "del": "", "css-loader": "", "file-loader": "", + "app-settings-loader": "", "json-loader": "", "html-loader": "", "istanbul-instrumenter-loader": "", "webpack-bundle-analyzer": "", + }, + "scripts": { + "build": "gulp prebuild && webpack --env.production --env.extractCss", + "build:dev": "gulp prebuild && webpack --env.extractCss", + "analyze": "webpack --env.production --env.analyze", + // @if feat['dotnet-core'] + "start": "gulp prebuild && webpack-dev-server --env.extractCss --port 5000" + // @endif + + // @if feat.web + "start": "gulp prebuild && webpack-dev-server --env.extractCss --port 8080" + // @endif } } \ No newline at end of file diff --git a/skeleton/webpack/webpack.config.js b/skeleton/webpack/webpack.config.js index 27ac0f908..1461d9e63 100644 --- a/skeleton/webpack/webpack.config.js +++ b/skeleton/webpack/webpack.config.js @@ -51,7 +51,7 @@ const sassRules = [ ]; // @endif -module.exports = ({ production, server, extractCss, coverage, analyze, karma } = {}) => ({ +module.exports = ({ production, extractCss, analyze, tests, hmr } = {}) => ({ resolve: { // @if feat.typescript extensions: ['.ts', '.js'], @@ -207,7 +207,8 @@ module.exports = ({ production, server, extractCss, coverage, analyze, karma } = devServer: { contentBase: outDir, // serve index.html for all 404 (required for push-state) - historyApiFallback: true + historyApiFallback: true, + hot: hmr }, devtool: production ? 'nosources-source-map' : 'cheap-module-eval-source-map', module: { @@ -279,11 +280,11 @@ module.exports = ({ production, server, extractCss, coverage, analyze, karma } = // @if feat.babel { test: /\.js$/i, loader: 'babel-loader', exclude: nodeModulesDir, - options: coverage ? { sourceMap: 'inline', plugins: ['istanbul'] } : {} + options: tests ? { sourceMap: 'inline', plugins: ['istanbul'] } : {} }, // @endif // @if feat.typescript - { test: /\.ts$/, loader: "ts-loader", options: { reportFiles: [ srcDir+'/**/*.ts'] }, include: karma ? [srcDir, testDir] : srcDir }, + { test: /\.ts$/, loader: "ts-loader" }, // @endif // embed small images and fonts as Data Urls and larger ones as files: { test: /\.(png|gif|jpg|cur)$/i, loader: 'url-loader', options: { limit: 8192 } }, @@ -291,8 +292,11 @@ module.exports = ({ production, server, extractCss, coverage, analyze, karma } = { test: /\.woff(\?v=[0-9]\.[0-9]\.[0-9])?$/i, loader: 'url-loader', options: { limit: 10000, mimetype: 'application/font-woff' } }, // load these fonts normally, as files: { test: /\.(ttf|eot|svg|otf)(\?v=[0-9]\.[0-9]\.[0-9])?$/i, loader: 'file-loader' }, + { test: /environment\.json$/i, use: [ + {loader: "app-settings-loader", options: {env: production ? 'production' : 'development' }}, + ]}, // @if feat.typescript - ...when(coverage, { + ...when(tests, { test: /\.[jt]s$/i, loader: 'istanbul-instrumenter-loader', include: srcDir, exclude: [/\.(spec|test)\.[jt]s$/i], enforce: 'post', options: { esModules: true }, @@ -301,7 +305,7 @@ module.exports = ({ production, server, extractCss, coverage, analyze, karma } = ] }, plugins: [ - ...when(!karma, new DuplicatePackageCheckerPlugin()), + ...when(!tests, new DuplicatePackageCheckerPlugin()), new AureliaPlugin(), new ProvidePlugin({ // @if feat['scaffold-navigation'] @@ -337,7 +341,7 @@ module.exports = ({ production, server, extractCss, coverage, analyze, karma } = // @endif metadata: { // available in index.ejs // - title, server, baseUrl + title, baseUrl } }), // ref: https://webpack.js.org/plugins/mini-css-extract-plugin/ @@ -345,7 +349,7 @@ module.exports = ({ production, server, extractCss, coverage, analyze, karma } = filename: production ? 'css/[name].[contenthash].bundle.css' : 'css/[name].[hash].bundle.css', chunkFilename: production ? 'css/[name].[contenthash].chunk.css' : 'css/[name].[hash].chunk.css' })), - ...when(production || server, new CopyWebpackPlugin([ + ...when(!tests, new CopyWebpackPlugin([ { from: 'static', to: outDir, ignore: ['.*'] }])), // ignore dot (hidden) files ...when(analyze, new BundleAnalyzerPlugin()) ] From afb13d65a0a042e3286ff02ba77aaf5f81ee6452 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Mon, 15 Jul 2019 09:46:35 +0430 Subject: [PATCH 31/52] update: README webpack Update README.md file in webpack skeleton to reflect changes in #1132 --- skeleton/webpack/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/skeleton/webpack/README.md b/skeleton/webpack/README.md index ba3ea9c6a..5b7728c43 100644 --- a/skeleton/webpack/README.md +++ b/skeleton/webpack/README.md @@ -8,10 +8,14 @@ To open browser automatically, do `au run --open`. To change dev server port, do `au run --port 8888`. +To change dev server host, do `au run --host 127.0.0.1` + To enable Webpack Bundle Analyzer, do `au run --analyze`. To enable hot module reload, do `au run --hmr`. +**PS:** You could mix all the flags as well, `au run --host 127.0.0.1 --port 7070 --open --hmr` + ## Build for production Run `au build --env prod`. From d96c308a37b94a1609a8ee719d6273334cf8ad4a Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Mon, 15 Jul 2019 09:48:56 +0430 Subject: [PATCH 32/52] update: README cli-bundler Update README.md file in cli-bundler skeleton to reflect changes in #1132 --- skeleton/cli-bundler/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/skeleton/cli-bundler/README.md b/skeleton/cli-bundler/README.md index 5acea7e07..d3b9daae9 100644 --- a/skeleton/cli-bundler/README.md +++ b/skeleton/cli-bundler/README.md @@ -8,10 +8,14 @@ To open browser automatically, do `au run --open`. To change dev server port, do `au run --port 8888`. +To change dev server host, do `au run --host 127.0.0.1` + // @if feat.babel To install new npm packages automatically, do `au run --auto-install` // @endif +**PS:** You could mix all the flags as well, `au run --host 127.0.0.1 --port 7070 --open` + // @if !feat.plugin ## Build for production From ceab34e601266e9db1220b75bc97feeea4e7577f Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Mon, 15 Jul 2019 09:53:54 +0430 Subject: [PATCH 33/52] update: README cypress Update README.md file in cypress skeleton to reflect changes in #1132 --- skeleton/cypress/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/skeleton/cypress/README.md b/skeleton/cypress/README.md index aee065042..8b06c3bb9 100644 --- a/skeleton/cypress/README.md +++ b/skeleton/cypress/README.md @@ -7,3 +7,12 @@ First, run `au run` and keep it running. Then run `au cypress` to run cypress in interactive mode. To perform a test-run and reports the results, do `au cypress --run`. + +To ask the `cypress` to start the application first and then start testing: `au cypress --start` + +The two following flags are useful when using `--start` flag: + * To change dev server port, do `au run --port 8888`. + * To change dev server host, do `au run --host 127.0.0.1` + + +**PS:** It is also possible to mix the flags `au cypress --run --start --port 7070 --host 127.0.0.1` From 245ca1defe0905139871167f9247b320e41c38b6 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Mon, 15 Jul 2019 10:00:40 +0430 Subject: [PATCH 34/52] Update README.md --- skeleton/cypress/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skeleton/cypress/README.md b/skeleton/cypress/README.md index 8b06c3bb9..716fb793f 100644 --- a/skeleton/cypress/README.md +++ b/skeleton/cypress/README.md @@ -11,8 +11,8 @@ To perform a test-run and reports the results, do `au cypress --run`. To ask the `cypress` to start the application first and then start testing: `au cypress --start` The two following flags are useful when using `--start` flag: - * To change dev server port, do `au run --port 8888`. - * To change dev server host, do `au run --host 127.0.0.1` + * To change dev server port, do `au cypress --start --port 8888`. + * To change dev server host, do `au cypress --start --host 127.0.0.1` **PS:** It is also possible to mix the flags `au cypress --run --start --port 7070 --host 127.0.0.1` From 2a911f7221a02af0c80752e60aaf6420e02f6a5c Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Mon, 15 Jul 2019 10:01:51 +0430 Subject: [PATCH 35/52] update: README protractor Update README.md file in protractor skeleton to reflect changes in #1132 --- skeleton/protractor/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/skeleton/protractor/README.md b/skeleton/protractor/README.md index ced1972d9..b50ac9687 100644 --- a/skeleton/protractor/README.md +++ b/skeleton/protractor/README.md @@ -5,3 +5,14 @@ You need the app running for integration test. First, run `au run` and keep it running. Then run `au protractor`. + +To perform a test-run and reports the results, do `au protractor --run`. + +To ask the `protractor` to start the application first and then start testing: `au protractor --start` + +The two following flags are useful when using `--start` flag: + * To change dev server port, do `au protractor --start --port 8888`. + * To change dev server host, do `au protractor --start --host 127.0.0.1` + + +**PS:** It is also possible to mix the flags `au protractor --run --start --port 7070 --host 127.0.0.1` From a909a5a404fd988288d7cb4e1ecc238b398003a8 Mon Sep 17 00:00:00 2001 From: Sayan751 Date: Wed, 17 Jul 2019 05:50:08 +0200 Subject: [PATCH 36/52] chore(webpack): post review changes - Gulp is removed from webpack project; del is replaced by clean-webpack-plugin - Environment import is retained for cli-buindler --- skeleton/common/package.json | 2 ++ skeleton/scaffold-minimum/src/main.ext | 5 ++++- skeleton/scaffold-navigation/src/main.ext | 5 ++++- skeleton/webpack/gulpFile.js | 10 ---------- skeleton/webpack/package.json | 13 ++++++------- skeleton/webpack/webpack.config.js | 11 +++++++++-- 6 files changed, 25 insertions(+), 21 deletions(-) delete mode 100644 skeleton/webpack/gulpFile.js diff --git a/skeleton/common/package.json b/skeleton/common/package.json index d0056ddb8..1e75658c2 100644 --- a/skeleton/common/package.json +++ b/skeleton/common/package.json @@ -21,7 +21,9 @@ "aurelia-cli": "", "aurelia-testing": "", "aurelia-tools": "", + // @if ! feat.webpack "gulp": "", + // @endif "minimatch": "", "through2": "", "vinyl-fs": "", diff --git a/skeleton/scaffold-minimum/src/main.ext b/skeleton/scaffold-minimum/src/main.ext index b1d52cffa..e2b48ddbb 100644 --- a/skeleton/scaffold-minimum/src/main.ext +++ b/skeleton/scaffold-minimum/src/main.ext @@ -6,8 +6,11 @@ import 'regenerator-runtime/runtime'; // @if feat.typescript import {Aurelia} from 'aurelia-framework' // @endif -import * as environment from '../config/environment.json'; +// @if ! feat.webpack +import environment from './environment'; +// @endif // @if feat.webpack +import * as environment from '../config/environment.json'; import {PLATFORM} from 'aurelia-pal'; // @endif diff --git a/skeleton/scaffold-navigation/src/main.ext b/skeleton/scaffold-navigation/src/main.ext index 6af74b7df..69b7ccebe 100644 --- a/skeleton/scaffold-navigation/src/main.ext +++ b/skeleton/scaffold-navigation/src/main.ext @@ -7,8 +7,11 @@ import 'bootstrap'; // @if feat.typescript import {Aurelia} from 'aurelia-framework'; // @endif -import * as environment from '../config/environment.json'; +// @if ! feat.webpack +import environment from './environment'; +// @endif // @if feat.webpack +import * as environment from '../config/environment.json'; import {PLATFORM} from 'aurelia-pal'; // @endif diff --git a/skeleton/webpack/gulpFile.js b/skeleton/webpack/gulpFile.js deleted file mode 100644 index 5dfeb25ed..000000000 --- a/skeleton/webpack/gulpFile.js +++ /dev/null @@ -1,10 +0,0 @@ -const del = require('del'); -const gulp = require('gulp'); -const path = require('path'); -const project = require('./aurelia_project/aurelia.json'); - -function clearDist() { - return del([path.resolve(__dirname, project.platform.output)]); -} - -gulp.task("prebuild", clearDist); \ No newline at end of file diff --git a/skeleton/webpack/package.json b/skeleton/webpack/package.json index 8d496e9a6..0aa4326b1 100644 --- a/skeleton/webpack/package.json +++ b/skeleton/webpack/package.json @@ -49,19 +49,18 @@ "stylus": "", // @endif - "gulp-rename": "", "html-webpack-plugin": "", "copy-webpack-plugin": "", "mini-css-extract-plugin": "", "aurelia-webpack-plugin": "", "duplicate-package-checker-webpack-plugin": "", + "clean-webpack-plugin": "", "webpack": "", "webpack-cli": "", "webpack-dev-server": "", "expose-loader": "", "style-loader": "", "url-loader": "", - "del": "", "css-loader": "", "file-loader": "", "app-settings-loader": "", @@ -71,15 +70,15 @@ "webpack-bundle-analyzer": "", }, "scripts": { - "build": "gulp prebuild && webpack --env.production --env.extractCss", - "build:dev": "gulp prebuild && webpack --env.extractCss", + "build": "webpack --env.production --env.extractCss", + "build:dev": "webpack --env.extractCss", "analyze": "webpack --env.production --env.analyze", // @if feat['dotnet-core'] - "start": "gulp prebuild && webpack-dev-server --env.extractCss --port 5000" + "start": "webpack-dev-server --env.extractCss --port 5000" // @endif // @if feat.web - "start": "gulp prebuild && webpack-dev-server --env.extractCss --port 8080" + "start": "webpack-dev-server --env.extractCss --port 8080" // @endif } -} \ No newline at end of file +} diff --git a/skeleton/webpack/webpack.config.js b/skeleton/webpack/webpack.config.js index 1461d9e63..a0e4030e0 100644 --- a/skeleton/webpack/webpack.config.js +++ b/skeleton/webpack/webpack.config.js @@ -7,6 +7,7 @@ const project = require('./aurelia_project/aurelia.json'); const { AureliaPlugin, ModuleDependenciesPlugin } = require('aurelia-webpack-plugin'); const { ProvidePlugin } = require('webpack'); const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); +const CleanWebpackPlugin = require('clean-webpack-plugin'); // config helpers: const ensureArray = (config) => config && (Array.isArray(config) ? config : [config]) || []; @@ -17,7 +18,6 @@ const when = (condition, config, negativeConfig) => const title = 'Aurelia Navigation Skeleton'; const outDir = path.resolve(__dirname, project.platform.output); const srcDir = path.resolve(__dirname, 'src'); -const testDir = path.resolve(__dirname, 'test', 'unit'); const nodeModulesDir = path.resolve(__dirname, 'node_modules'); const baseUrl = '/'; @@ -351,6 +351,13 @@ module.exports = ({ production, extractCss, analyze, tests, hmr } = {}) => ({ })), ...when(!tests, new CopyWebpackPlugin([ { from: 'static', to: outDir, ignore: ['.*'] }])), // ignore dot (hidden) files - ...when(analyze, new BundleAnalyzerPlugin()) + ...when(analyze, new BundleAnalyzerPlugin()), + /** + * Note that the usage of following plugin cleans the webpack output directory before build. + * In case you want to generate any file in the output path as a part of pre-build step, this plugin will likely + * remove those before the webpack build. In that case consider disabling the plugin, and instead use something like + * `del` (https://www.npmjs.com/package/del), or `rimraf` (https://www.npmjs.com/package/rimraf). + */ + new CleanWebpackPlugin() ] }); From c03991f0be986a75079a663d81811659d28ecf12 Mon Sep 17 00:00:00 2001 From: Sayan751 Date: Wed, 17 Jul 2019 17:58:28 +0200 Subject: [PATCH 37/52] chore(webpack): added gulp back to webpack projects The dependency to gulp is added back for the webpack projects as there are still some au tasks that depends on gulp. Additionally, removed environment task. --- skeleton/common/package.json | 2 -- .../aurelia_project/tasks/environment.ext | 36 ------------------- 2 files changed, 38 deletions(-) delete mode 100644 skeleton/webpack/aurelia_project/tasks/environment.ext diff --git a/skeleton/common/package.json b/skeleton/common/package.json index 1e75658c2..d0056ddb8 100644 --- a/skeleton/common/package.json +++ b/skeleton/common/package.json @@ -21,9 +21,7 @@ "aurelia-cli": "", "aurelia-testing": "", "aurelia-tools": "", - // @if ! feat.webpack "gulp": "", - // @endif "minimatch": "", "through2": "", "vinyl-fs": "", diff --git a/skeleton/webpack/aurelia_project/tasks/environment.ext b/skeleton/webpack/aurelia_project/tasks/environment.ext deleted file mode 100644 index 073f46bac..000000000 --- a/skeleton/webpack/aurelia_project/tasks/environment.ext +++ /dev/null @@ -1,36 +0,0 @@ -// @if feat.babel -import project from '../aurelia.json'; -import rename from 'gulp-rename'; -import gulp from 'gulp'; -import fs from 'fs'; -import through from 'through2'; -// @endif -// @if feat.typescript -import * as project from '../aurelia.json'; -import * as rename from 'gulp-rename'; -import * as gulp from 'gulp'; -import * as fs from 'fs'; -import * as through from 'through2'; -// @endif -import {CLIOptions} from 'aurelia-cli'; - -function configureEnvironment() { - let env = CLIOptions.getEnvironment(); - - return gulp.src(`aurelia_project/environments/${env}${project.transpiler.fileExtension}`) - .pipe(rename(`environment${project.transpiler.fileExtension}`)) - .pipe(through.obj(function (file, _, cb) { - // https://github.com/aurelia/cli/issues/1031 - fs.unlink(`${project.paths.root}/${file.relative}`, function () { cb(null, file); }); - })) - .pipe(gulp.dest(project.paths.root)) - .pipe(through.obj(function(file, enc, cb) { - // https://github.com/webpack/watchpack/issues/25#issuecomment-287789288 - const now = Date.now() / 1000; - const then = now - 10; - fs.utimes(file.path, then, then, function(err) { if (err) throw err; }); - cb(null, file); - })); -} - -export default configureEnvironment; From 5525f490d54fa34d90c3960946514eccb5b3676b Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Thu, 18 Jul 2019 01:28:54 +0430 Subject: [PATCH 38/52] update: browserSync initialization to how it is recommended --- skeleton/cli-bundler/aurelia_project/tasks/run.ext | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/skeleton/cli-bundler/aurelia_project/tasks/run.ext b/skeleton/cli-bundler/aurelia_project/tasks/run.ext index aae37060f..4305416e4 100644 --- a/skeleton/cli-bundler/aurelia_project/tasks/run.ext +++ b/skeleton/cli-bundler/aurelia_project/tasks/run.ext @@ -14,10 +14,13 @@ import {CLIOptions} from 'aurelia-cli'; import build from './build'; import watch from './watch'; +// recommended: https://www.browsersync.io/docs/api#api-create +const bs = browserSync.create(); + let serve = gulp.series( build, done => { - browserSync({ + bs.init({ online: false, open: CLIOptions.hasFlag('open') || project.platform.open, port: CLIOptions.getFlagValue('port') || project.platform.port, From b33c363df6b9b9f3f222c3de6a77eabf67fd7bb1 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Thu, 18 Jul 2019 01:29:21 +0430 Subject: [PATCH 39/52] add: shutdownAppServer run.ext scripts in cli-bundler & webpack are now export another method named `shutdownAppServer`, which will be used in `e2e` scripts, `protractor.ext` & `cypress.ext` --- .../cli-bundler/aurelia_project/tasks/run.ext | 9 +++-- .../cypress/aurelia_project/tasks/cypress.ext | 7 ++-- .../aurelia_project/tasks/protractor.ext | 33 +++++++------------ .../webpack/aurelia_project/tasks/run.ext | 7 +++- 4 files changed, 27 insertions(+), 29 deletions(-) diff --git a/skeleton/cli-bundler/aurelia_project/tasks/run.ext b/skeleton/cli-bundler/aurelia_project/tasks/run.ext index 4305416e4..240e6d5a2 100644 --- a/skeleton/cli-bundler/aurelia_project/tasks/run.ext +++ b/skeleton/cli-bundler/aurelia_project/tasks/run.ext @@ -58,9 +58,14 @@ function reload() { browserSync.reload(); } -let run = gulp.series( +const run = gulp.series( serve, done => { watch(reload); done(); } ); -export default run; +const shutdownAppServer = (code) =>{ + bs.exit(); + process.exit(code || 0); +}; + +export { run as default , shutdownAppServer }; diff --git a/skeleton/cypress/aurelia_project/tasks/cypress.ext b/skeleton/cypress/aurelia_project/tasks/cypress.ext index 98fc81536..d4459998d 100644 --- a/skeleton/cypress/aurelia_project/tasks/cypress.ext +++ b/skeleton/cypress/aurelia_project/tasks/cypress.ext @@ -7,15 +7,14 @@ import * as cypress from 'cypress'; import * as config from '../../cypress.config'; // @endif import { CLIOptions } from 'aurelia-cli'; -import { default as runApp } from './run'; +import { default as runAppServer, shutdownAppServer } from './run'; const runCypress = (cb) => { if (CLIOptions.hasFlag('run')) { cypress .run(config) .then(results => { - (results.totalFailed === 0 ? cb() : cb('Run failed!')) - process.exit(0); + (results.totalFailed === 0 ? shutdownAppServer() : cb('Run failed!')); }) .catch(cb); } else { @@ -25,7 +24,7 @@ const runCypress = (cb) => { export default (cb) => { if (CLIOptions.hasFlag('start')) { - runApp(runCypress(cb)); + runAppServer(runCypress(cb)); return; } diff --git a/skeleton/protractor/aurelia_project/tasks/protractor.ext b/skeleton/protractor/aurelia_project/tasks/protractor.ext index 86a09342d..b1cacb839 100644 --- a/skeleton/protractor/aurelia_project/tasks/protractor.ext +++ b/skeleton/protractor/aurelia_project/tasks/protractor.ext @@ -7,36 +7,25 @@ import * as gulp from 'gulp'; const {protractor, webdriver_update } = require('gulp-protractor'); import { CLIOptions } from 'aurelia-cli'; -import { default as run } from './run'; +import { default as runAppServer, shutdownAppServer } from './run'; function runApp(cb) { if (CLIOptions.hasFlag('start')) { - run(); + runAppServer(); } cb(); } -gulp.task('run-app' , runApp); -gulp.task('webdriver_update', webdriver_update); - -gulp.task('protractor', (cb) => { - // @if feat.babel - gulp.src('test/e2e/**/*.e2e.js') - // @endif - // @if feat.typescript - gulp.src('test/e2e/**/*.e2e.ts') - // @endif - .pipe(protractor({configFile: 'protractor.conf.js', args: process.argv.slice(3) })) - .on('error', cb) - .on('end', () => { - cb() - process.exit(0); - }); -}); +function runProtractor() { + return gulp.src('test/e2e/**/*.e2e.ts') + .pipe(protractor({ configFile: 'protractor.conf.js', args: process.argv.slice(3) })) + .on('end', shutdownAppServer); +} // Setting up the test task export default gulp.series( - 'run-app', - 'webdriver_update', - 'protractor' + runApp, + webdriver_update, + runProtractor ); + diff --git a/skeleton/webpack/aurelia_project/tasks/run.ext b/skeleton/webpack/aurelia_project/tasks/run.ext index 90377e145..ed01eb0a0 100644 --- a/skeleton/webpack/aurelia_project/tasks/run.ext +++ b/skeleton/webpack/aurelia_project/tasks/run.ext @@ -15,6 +15,8 @@ import {config} from './build'; import configureEnvironment from './environment'; import {CLIOptions, reportWebpackReadiness} from 'aurelia-cli'; +let appServer; + function runWebpack(done) { // https://webpack.github.io/docs/webpack-dev-server.html let opts = { @@ -50,6 +52,7 @@ function runWebpack(done) { if (err) throw err; reportWebpackReadiness(opts); + appServer = server; done(); }); } @@ -59,4 +62,6 @@ const run = gulp.series( runWebpack ); -export { run as default }; +const shutdownAppServer = () => appServer.close(); + +export { run as default, shutdownAppServer }; From 02c568a0eb61a160617dcc4842a8a0567833b9d0 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Thu, 18 Jul 2019 01:32:23 +0430 Subject: [PATCH 40/52] fix: npm audit fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fcfe01c79..bbb981639 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "gulp": "^4.0.1", "htmlparser2": "^3.10.1", "lead": "^1.0.0", - "lodash": "^4.17.11", + "lodash": "^4.17.14", "map-stream": "0.0.7", "mkdirp": "^0.5.1", "node-libs-browser": "^2.2.0", From da83916cf17e13cf2f2d997446010bc8c6a68086 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Thu, 18 Jul 2019 01:39:55 +0430 Subject: [PATCH 41/52] fix: separate babel and typescript features in protractor.ext --- skeleton/protractor/aurelia_project/tasks/protractor.ext | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/skeleton/protractor/aurelia_project/tasks/protractor.ext b/skeleton/protractor/aurelia_project/tasks/protractor.ext index b1cacb839..16d0a638e 100644 --- a/skeleton/protractor/aurelia_project/tasks/protractor.ext +++ b/skeleton/protractor/aurelia_project/tasks/protractor.ext @@ -17,7 +17,12 @@ function runApp(cb) { } function runProtractor() { + // @if feat.babel + return gulp.src('test/e2e/**/*.e2e.js') + // @endif + // @if feat.typescript return gulp.src('test/e2e/**/*.e2e.ts') + // @endif .pipe(protractor({ configFile: 'protractor.conf.js', args: process.argv.slice(3) })) .on('end', shutdownAppServer); } From 76ffaef8a2150b40c50005d92ea592b432e0833e Mon Sep 17 00:00:00 2001 From: Sayan751 Date: Tue, 23 Jul 2019 16:08:40 +0200 Subject: [PATCH 42/52] chore(webpack): reactivation of au task as alias --- build/tasks/release-checks/suite-steps.js | 10 ++--- .../tests/generic/au-cypress.js | 2 +- .../tests/generic/au-protractor.js | 2 +- .../tests/webpack/{run.js => au-run.js} | 42 +++++++++---------- .../release-checks/tests/webpack/index.js | 2 +- .../webpack/aurelia_project/tasks/build.ext | 8 ++++ .../webpack/aurelia_project/tasks/build.json | 4 ++ .../webpack/aurelia_project/tasks/run.ext | 8 ++++ .../webpack/aurelia_project/tasks/run.json | 4 ++ 9 files changed, 53 insertions(+), 29 deletions(-) rename build/tasks/release-checks/tests/webpack/{run.js => au-run.js} (73%) create mode 100644 skeleton/webpack/aurelia_project/tasks/build.ext create mode 100644 skeleton/webpack/aurelia_project/tasks/build.json create mode 100644 skeleton/webpack/aurelia_project/tasks/run.ext create mode 100644 skeleton/webpack/aurelia_project/tasks/run.json diff --git a/build/tasks/release-checks/suite-steps.js b/build/tasks/release-checks/suite-steps.js index 472911c15..ce584c821 100644 --- a/build/tasks/release-checks/suite-steps.js +++ b/build/tasks/release-checks/suite-steps.js @@ -65,11 +65,11 @@ module.exports = function(suite) { if (applicable(features, 'webpack')) { steps.push( - new tests.webpack.NpmStartDoesNotThrowCommandLineErrors(), - new tests.webpack.NpmStartLaunchesServer(), - new tests.webpack.NpmStartRendersPage(), - new tests.webpack.NpmStartAppLaunchesWithoutJavascriptErrors(), - new tests.webpack.NpmStartWatchPicksUpFileChanges() + new tests.webpack.AuRunDoesNotThrowCommandLineErrors(), + new tests.webpack.AuRunLaunchesServer(), + new tests.webpack.AuRunRendersPage(), + new tests.webpack.AuRunAppLaunchesWithoutJavascriptErrors(), + new tests.webpack.AuRunWatchPicksUpFileChanges() ); } diff --git a/build/tasks/release-checks/tests/generic/au-cypress.js b/build/tasks/release-checks/tests/generic/au-cypress.js index 22075f7e6..295f72159 100644 --- a/build/tasks/release-checks/tests/generic/au-cypress.js +++ b/build/tasks/release-checks/tests/generic/au-cypress.js @@ -30,7 +30,7 @@ class AuCypressRunsTests extends Test { } execute() { - this.executeCommand = new ExecuteCommand('npm', ['start'], (msg) => this.onOutput(msg)); + this.executeCommand = new ExecuteCommand('au', ['run'], (msg) => this.onOutput(msg)); return this.executeCommand.executeAsNodeScript(); } } diff --git a/build/tasks/release-checks/tests/generic/au-protractor.js b/build/tasks/release-checks/tests/generic/au-protractor.js index 5590867dd..bacb3a958 100644 --- a/build/tasks/release-checks/tests/generic/au-protractor.js +++ b/build/tasks/release-checks/tests/generic/au-protractor.js @@ -27,7 +27,7 @@ class AuProtractorRunsTests extends Test { } execute() { - this.executeCommand = new ExecuteCommand('npm', ['start'], (msg) => this.onOutput(msg)); + this.executeCommand = new ExecuteCommand('au', ['run'], (msg) => this.onOutput(msg)); return this.executeCommand.executeAsNodeScript(); } } diff --git a/build/tasks/release-checks/tests/webpack/run.js b/build/tasks/release-checks/tests/webpack/au-run.js similarity index 73% rename from build/tasks/release-checks/tests/webpack/run.js rename to build/tasks/release-checks/tests/webpack/au-run.js index 756fb55f1..16e5fe62d 100644 --- a/build/tasks/release-checks/tests/webpack/run.js +++ b/build/tasks/release-checks/tests/webpack/au-run.js @@ -6,9 +6,9 @@ const StepRunner = require('../../step-runner'); const path = require('path'); const fs = require('fs'); -class NpmStartDoesNotThrowCommandLineErrors extends Test { +class AuRunDoesNotThrowCommandLineErrors extends Test { constructor() { - super('npm start does not throw commandline errors'); + super('au run does not throw commandline errors'); } onOutput(message) { @@ -24,14 +24,14 @@ class NpmStartDoesNotThrowCommandLineErrors extends Test { } execute() { - this.executeCommand = new ExecuteCommand('npm', ['start'], (msg) => this.onOutput(msg)); + this.executeCommand = new ExecuteCommand('au', ['run'], (msg) => this.onOutput(msg)); return this.executeCommand.executeAsNodeScript(); } } -class NpmStartLaunchesServer extends Test { +class AuRunLaunchesServer extends Test { constructor() { - super('npm start launches server'); + super('au run launches server'); } onOutput(message) { @@ -44,14 +44,14 @@ class NpmStartLaunchesServer extends Test { } execute() { - this.executeCommand = new ExecuteCommand('npm', ['start'], (msg) => this.onOutput(msg)); + this.executeCommand = new ExecuteCommand('au', ['run'], (msg) => this.onOutput(msg)); return this.executeCommand.executeAsNodeScript(); } } -class NpmStartWatchPicksUpFileChanges extends Test { +class AuRunWatchPicksUpFileChanges extends Test { constructor(fileToChange) { - super('npm start picks up file changes'); + super('au run picks up file changes'); this.fileToChange = fileToChange || path.join('src', 'app.html'); this.watchingForFileChangeNotification = false; @@ -99,14 +99,14 @@ class NpmStartWatchPicksUpFileChanges extends Test { execute(context) { this.context = context; - this.executeCommand = new ExecuteCommand('npm', ['start'], (msg) => this.onOutput(msg)); + this.executeCommand = new ExecuteCommand('au', ['run'], (msg) => this.onOutput(msg)); return this.executeCommand.executeAsNodeScript(); } } -class NpmStartAppLaunchesWithoutJavascriptErrors extends Test { +class AuRunAppLaunchesWithoutJavascriptErrors extends Test { constructor() { - super('npm start app launches without javascript errors'); + super('au run app launches without javascript errors'); } onOutput(message) { @@ -127,14 +127,14 @@ class NpmStartAppLaunchesWithoutJavascriptErrors extends Test { } execute() { - this.executeCommand = new ExecuteCommand('npm', ['start'], (msg) => this.onOutput(msg)); + this.executeCommand = new ExecuteCommand('au', ['run'], (msg) => this.onOutput(msg)); return this.executeCommand.executeAsNodeScript(); } } -class NpmStartRendersPage extends Test { +class AuRunRendersPage extends Test { constructor() { - super('npm start renders page'); + super('au run renders page'); } onOutput(context, message) { @@ -144,7 +144,7 @@ class NpmStartRendersPage extends Test { this.isUp = true; const url = getURL(message); - const screenshot = new TakeScreenShotOfPage(url, path.join(context.resultOutputFolder, 'screenshot-of-npm-start.png')); + const screenshot = new TakeScreenShotOfPage(url, path.join(context.resultOutputFolder, 'screenshot-of-au-run.png')); return new StepRunner(screenshot).run() .then(() => { @@ -155,7 +155,7 @@ class NpmStartRendersPage extends Test { } execute(context) { - this.executeCommand = new ExecuteCommand('npm', ['start'], (msg) => this.onOutput(context, msg)); + this.executeCommand = new ExecuteCommand('au', ['run'], (msg) => this.onOutput(context, msg)); return this.executeCommand.executeAsNodeScript(); } } @@ -171,9 +171,9 @@ function getURL(msg) { } module.exports = { - NpmStartDoesNotThrowCommandLineErrors, - NpmStartLaunchesServer, - NpmStartWatchPicksUpFileChanges, - NpmStartAppLaunchesWithoutJavascriptErrors, - NpmStartRendersPage + AuRunDoesNotThrowCommandLineErrors, + AuRunLaunchesServer, + AuRunWatchPicksUpFileChanges, + AuRunAppLaunchesWithoutJavascriptErrors, + AuRunRendersPage }; diff --git a/build/tasks/release-checks/tests/webpack/index.js b/build/tasks/release-checks/tests/webpack/index.js index 1b996242d..1d098164b 100644 --- a/build/tasks/release-checks/tests/webpack/index.js +++ b/build/tasks/release-checks/tests/webpack/index.js @@ -1,3 +1,3 @@ module.exports = { - ...require('./run') + ...require('./au-run') }; diff --git a/skeleton/webpack/aurelia_project/tasks/build.ext b/skeleton/webpack/aurelia_project/tasks/build.ext new file mode 100644 index 000000000..c1835fa35 --- /dev/null +++ b/skeleton/webpack/aurelia_project/tasks/build.ext @@ -0,0 +1,8 @@ +import { NPM } from 'aurelia-cli/lib/package-managers/npm'; + +export default function() { + console.log('`au build` is an alias of the `npm run build`, you may use either of those; see README for more details.'); + + const args = process.argv.slice(3); + return (new NPM()).install(['--', ...args], process.cwd(), 'run'); +} diff --git a/skeleton/webpack/aurelia_project/tasks/build.json b/skeleton/webpack/aurelia_project/tasks/build.json new file mode 100644 index 000000000..8cd81dc72 --- /dev/null +++ b/skeleton/webpack/aurelia_project/tasks/build.json @@ -0,0 +1,4 @@ +{ + "name": "build", + "description": "Builds and processes all application assets. It is an alias of the `npm run build`, you may use either of those; see README for more details." +} diff --git a/skeleton/webpack/aurelia_project/tasks/run.ext b/skeleton/webpack/aurelia_project/tasks/run.ext new file mode 100644 index 000000000..742dc17e5 --- /dev/null +++ b/skeleton/webpack/aurelia_project/tasks/run.ext @@ -0,0 +1,8 @@ +import { NPM } from 'aurelia-cli/lib/package-managers/npm'; + +export default function() { + console.log('`au run` is an alias of the `npm start`, you may use either of those; see README for more details.'); + + const args = process.argv.slice(3); + return (new NPM()).install(['--', ...args], process.cwd(), 'start'); +} diff --git a/skeleton/webpack/aurelia_project/tasks/run.json b/skeleton/webpack/aurelia_project/tasks/run.json new file mode 100644 index 000000000..fbaad3215 --- /dev/null +++ b/skeleton/webpack/aurelia_project/tasks/run.json @@ -0,0 +1,4 @@ +{ + "name": "run", + "description": "Builds the application and serves up the assets via a local web server, watching files for changes as you work. It is an alias of the `npm start`, you may use either of those; see README for more details." +} From 8550a99a82c6ea5714059f5e07b14b2d447b2c49 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Fri, 26 Jul 2019 12:37:18 +0430 Subject: [PATCH 43/52] chore(karma): Changed karma config to be in headless mode by default --- skeleton/karma/karma.conf.js__if_cli-bundler | 35 +++++++++++++++++-- skeleton/karma/test__if_webpack/karma.conf.js | 25 +++++++++++-- 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/skeleton/karma/karma.conf.js__if_cli-bundler b/skeleton/karma/karma.conf.js__if_cli-bundler index 4128ca649..864e1beb5 100644 --- a/skeleton/karma/karma.conf.js__if_cli-bundler +++ b/skeleton/karma/karma.conf.js__if_cli-bundler @@ -51,8 +51,39 @@ module.exports = function(config) { colors: true, logLevel: config.LOG_INFO, autoWatch: true, - browsers: ['Chrome'], - singleRun: false, + /* + * start these browsers + * available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + */ + // browsers: [ + // 'Chrome', + // ], + /* + * To run in non-headless mode: + * 1. Comment the following lines + * 2. Uncomment the above "browser" setting + */ + browsers: [ + 'ChromeHeadless', + ], + customLaunchers: { + 'ChromeHeadless': { + base: 'Chrome', + flags: [ + '--no-sandbox', + '--headless', + '--disable-gpu', + '--remote-debugging-port=9222' + ] + } + }, + /** **************************************************************************** */ + + /* + * Continuous Integration mode + * if true, Karma captures browsers, runs the tests and exits + */ + singleRun: true, // client.args must be a array of string. // Leave 'aurelia-root', project.paths.root in this order so we can find // the root of the aurelia project. diff --git a/skeleton/karma/test__if_webpack/karma.conf.js b/skeleton/karma/test__if_webpack/karma.conf.js index 98213c149..1e34c81b5 100644 --- a/skeleton/karma/test__if_webpack/karma.conf.js +++ b/skeleton/karma/test__if_webpack/karma.conf.js @@ -80,14 +80,35 @@ module.exports = function (config) { * start these browsers * available browser launchers: https://npmjs.org/browse/keyword/karma-launcher */ + // browsers: [ + // 'Chrome', + // ], + /* + * To run in non-headless mode: + * 1. Comment the following lines + * 2. Uncomment the above "browser" setting + */ browsers: [ - 'Chrome', + 'ChromeHeadless', ], + customLaunchers: { + 'ChromeHeadless': { + base: 'Chrome', + flags: [ + '--no-sandbox', + '--headless', + '--disable-gpu', + '--remote-debugging-port=9222' + ] + } + }, + /** **************************************************************************** */ + /* * Continuous Integration mode * if true, Karma captures browsers, runs the tests and exits */ singleRun: true }) -} \ No newline at end of file +} From a217fec9f9da9eac8159a5274b053f513b77c837 Mon Sep 17 00:00:00 2001 From: Sayan751 Date: Mon, 29 Jul 2019 06:18:31 +0200 Subject: [PATCH 44/52] fix(webpack): new release check Additionally small refactor in package manager to easily export NPM and Yarn. Added a new method `run` in base package manager. --- build/tasks/release-checks/suite-steps.js | 2 + .../release-checks/tests/webpack/au-build.js | 64 +++++++++++++++++++ .../release-checks/tests/webpack/index.js | 3 +- lib/index.js | 2 + lib/package-managers/base-package-manager.js | 6 +- .../webpack/aurelia_project/tasks/build.ext | 4 +- .../webpack/aurelia_project/tasks/run.ext | 4 +- 7 files changed, 79 insertions(+), 6 deletions(-) create mode 100644 build/tasks/release-checks/tests/webpack/au-build.js diff --git a/build/tasks/release-checks/suite-steps.js b/build/tasks/release-checks/suite-steps.js index ce584c821..4cc3fae1e 100644 --- a/build/tasks/release-checks/suite-steps.js +++ b/build/tasks/release-checks/suite-steps.js @@ -65,6 +65,8 @@ module.exports = function(suite) { if (applicable(features, 'webpack')) { steps.push( + new tests.webpack.AuBuildDoesNotThrowCommandLineErrors(), + new tests.webpack.AuBuildStartsWebpackInWatchMode(), new tests.webpack.AuRunDoesNotThrowCommandLineErrors(), new tests.webpack.AuRunLaunchesServer(), new tests.webpack.AuRunRendersPage(), diff --git a/build/tasks/release-checks/tests/webpack/au-build.js b/build/tasks/release-checks/tests/webpack/au-build.js new file mode 100644 index 000000000..1cf479faa --- /dev/null +++ b/build/tasks/release-checks/tests/webpack/au-build.js @@ -0,0 +1,64 @@ +const Test = require('../test'); +const ExecuteCommand = require('../../tasks/execute-command'); +const path = require('path'); +const fs = require('fs'); + +class AuBuildDoesNotThrowCommandLineErrors extends Test { + constructor() { + super('au build does not throw commandline errors'); + } + + onOutput(message) { + this.debug(message); + + if (message.toLowerCase().indexOf('error') > -1) { + this.executeCommand.stop(); + this.fail(); + } else if (isBuildCompletedMessage(message)) { + this.success(); + this.executeCommand.stop(); + } + } + + execute() { + this.executeCommand = new ExecuteCommand('au', ['build'], (msg) => this.onOutput(msg)); + return this.executeCommand.executeAsNodeScript(); + } +} + +class AuBuildStartsWebpackInWatchMode extends Test { + constructor(fileToChange) { + super('au build --watch starts webpack in watch mode'); + + this.fileToChange = fileToChange || path.join('src', 'app.html'); + this.firstBuildCompleted = false; + } + + onOutput(message) { + this.debug(message); + + if (message.toLowerCase().indexOf('error') > -1) { + this.executeCommand.stop(); + this.fail(); + } else if (message.indexOf('webpack is watching the files') > -1) { + this.success(); + this.executeCommand.stop(); + } + } + + execute(context) { + this.context = context; + + this.executeCommand = new ExecuteCommand('au', ['build', '--watch'], (msg) => this.onOutput(msg)); + return this.executeCommand.executeAsNodeScript(); + } +} + +function isBuildCompletedMessage(msg) { + return msg.indexOf('Built at') > -1; +} + +module.exports = { + AuBuildDoesNotThrowCommandLineErrors, + AuBuildStartsWebpackInWatchMode +}; diff --git a/build/tasks/release-checks/tests/webpack/index.js b/build/tasks/release-checks/tests/webpack/index.js index 1d098164b..86c3f4289 100644 --- a/build/tasks/release-checks/tests/webpack/index.js +++ b/build/tasks/release-checks/tests/webpack/index.js @@ -1,3 +1,4 @@ module.exports = { - ...require('./au-run') + ...require('./au-run'), + ...require('./au-build') }; diff --git a/lib/index.js b/lib/index.js index 07d6d0e49..ef1afe2e1 100644 --- a/lib/index.js +++ b/lib/index.js @@ -8,3 +8,5 @@ exports.ProjectItem = require('./project-item').ProjectItem; exports.build = require('./build'); exports.Configuration = require('./configuration').Configuration; exports.reportWebpackReadiness = require('./build/webpack-reporter'); +exports.NPM = require('./package-managers/npm').NPM; +exports.Yarn = require('./package-managers/yarn').Yarn; diff --git a/lib/package-managers/base-package-manager.js b/lib/package-managers/base-package-manager.js index 91d4d9a20..bc7534b9d 100644 --- a/lib/package-managers/base-package-manager.js +++ b/lib/package-managers/base-package-manager.js @@ -7,10 +7,14 @@ exports.BasePackageManager = class { } install(packages = [], workingDirectory = process.cwd(), command = 'install') { + return this.run(command, packages, workingDirectory); + } + + run(command, args = [], workingDirectory = process.cwd()) { return new Promise((resolve, reject) => { spawn( this.getExecutablePath(workingDirectory), - [command, ...packages], + [command, ...args], { stdio: 'inherit', cwd: workingDirectory } ) .on('close', resolve) diff --git a/skeleton/webpack/aurelia_project/tasks/build.ext b/skeleton/webpack/aurelia_project/tasks/build.ext index c1835fa35..1ad979d4b 100644 --- a/skeleton/webpack/aurelia_project/tasks/build.ext +++ b/skeleton/webpack/aurelia_project/tasks/build.ext @@ -1,8 +1,8 @@ -import { NPM } from 'aurelia-cli/lib/package-managers/npm'; +import { NPM } from 'aurelia-cli'; export default function() { console.log('`au build` is an alias of the `npm run build`, you may use either of those; see README for more details.'); const args = process.argv.slice(3); - return (new NPM()).install(['--', ...args], process.cwd(), 'run'); + return (new NPM()).run('run', ['build', '--', ...args]); } diff --git a/skeleton/webpack/aurelia_project/tasks/run.ext b/skeleton/webpack/aurelia_project/tasks/run.ext index 742dc17e5..79268fcf3 100644 --- a/skeleton/webpack/aurelia_project/tasks/run.ext +++ b/skeleton/webpack/aurelia_project/tasks/run.ext @@ -1,8 +1,8 @@ -import { NPM } from 'aurelia-cli/lib/package-managers/npm'; +import { NPM } from 'aurelia-cli'; export default function() { console.log('`au run` is an alias of the `npm start`, you may use either of those; see README for more details.'); const args = process.argv.slice(3); - return (new NPM()).install(['--', ...args], process.cwd(), 'start'); + return (new NPM()).run('start',['--', ...args]); } From ce394528fbdddbdb7ac60b2f59e7ae2e358f3748 Mon Sep 17 00:00:00 2001 From: Chunpeng Huo Date: Thu, 1 Aug 2019 11:06:54 +1000 Subject: [PATCH 45/52] chore: add app-settings-loader version --- lib/dependencies.json | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/dependencies.json b/lib/dependencies.json index a6244e0bb..f7ab0e8dd 100644 --- a/lib/dependencies.json +++ b/lib/dependencies.json @@ -4,6 +4,7 @@ "@types/lodash": "^4.14.117", "@types/node": "^10.11.6", "@types/webpack": "^4.4.15", + "app-settings-loader": "^1.0.2", "aspnet-webpack": "^3.0.0", "aurelia-animator-css": "^1.0.4", "aurelia-bootstrapper": "^2.3.2", From 68590f9f720cec417f1ba49a75f99e2b1c141bb3 Mon Sep 17 00:00:00 2001 From: Chunpeng Huo Date: Thu, 1 Aug 2019 11:44:28 +1000 Subject: [PATCH 46/52] chore(webpack): skip not-used env files for webpack app --- .../{environments => environments__if_not_webpack}/dev.ext | 0 .../{environments => environments__if_not_webpack}/prod.ext | 0 .../{environments => environments__if_not_webpack}/stage.ext | 0 ..._not_plugin => environment.ext__if_not_plugin_and_not_webpack} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename skeleton/common/aurelia_project/{environments => environments__if_not_webpack}/dev.ext (100%) rename skeleton/common/aurelia_project/{environments => environments__if_not_webpack}/prod.ext (100%) rename skeleton/common/aurelia_project/{environments => environments__if_not_webpack}/stage.ext (100%) rename skeleton/common/src/{environment.ext__if_not_plugin => environment.ext__if_not_plugin_and_not_webpack} (100%) diff --git a/skeleton/common/aurelia_project/environments/dev.ext b/skeleton/common/aurelia_project/environments__if_not_webpack/dev.ext similarity index 100% rename from skeleton/common/aurelia_project/environments/dev.ext rename to skeleton/common/aurelia_project/environments__if_not_webpack/dev.ext diff --git a/skeleton/common/aurelia_project/environments/prod.ext b/skeleton/common/aurelia_project/environments__if_not_webpack/prod.ext similarity index 100% rename from skeleton/common/aurelia_project/environments/prod.ext rename to skeleton/common/aurelia_project/environments__if_not_webpack/prod.ext diff --git a/skeleton/common/aurelia_project/environments/stage.ext b/skeleton/common/aurelia_project/environments__if_not_webpack/stage.ext similarity index 100% rename from skeleton/common/aurelia_project/environments/stage.ext rename to skeleton/common/aurelia_project/environments__if_not_webpack/stage.ext diff --git a/skeleton/common/src/environment.ext__if_not_plugin b/skeleton/common/src/environment.ext__if_not_plugin_and_not_webpack similarity index 100% rename from skeleton/common/src/environment.ext__if_not_plugin rename to skeleton/common/src/environment.ext__if_not_plugin_and_not_webpack From 3b224dd7733b93930214acff162543c000fef253 Mon Sep 17 00:00:00 2001 From: Chunpeng Huo Date: Thu, 1 Aug 2019 14:13:06 +1000 Subject: [PATCH 47/52] fix(webpack): fix overlooked refactoring --- skeleton/karma/test__if_webpack/karma.conf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skeleton/karma/test__if_webpack/karma.conf.js b/skeleton/karma/test__if_webpack/karma.conf.js index 98213c149..44c189256 100644 --- a/skeleton/karma/test__if_webpack/karma.conf.js +++ b/skeleton/karma/test__if_webpack/karma.conf.js @@ -30,7 +30,7 @@ module.exports = function (config) { 'test/karma-bundle.js': [ 'webpack' ] }, - webpack: require('../webpack.config')({ coverage: true, karma: true }), + webpack: require('../webpack.config')({ tests: true }), /* * test results reporter to use From bfdad5439aa8c17116698718b524142bc2a0fc19 Mon Sep 17 00:00:00 2001 From: Chunpeng Huo Date: Fri, 2 Aug 2019 09:51:25 +1000 Subject: [PATCH 48/52] test(release-check): fix proc kill on new webpack wrapper --- .../tasks/check-javascript-errors.js | 6 ------ .../release-checks/tasks/execute-command.js | 9 ++------- .../tasks/take-screenshot-of-page.js | 6 ------ build/tasks/release-checks/tasks/task.js | 12 ++++++++++++ build/tasks/release-checks/utils.js | 16 ---------------- package-lock.json | 6 ++++++ package.json | 1 + 7 files changed, 21 insertions(+), 35 deletions(-) delete mode 100644 build/tasks/release-checks/utils.js diff --git a/build/tasks/release-checks/tasks/check-javascript-errors.js b/build/tasks/release-checks/tasks/check-javascript-errors.js index b501dec38..3fec71766 100644 --- a/build/tasks/release-checks/tasks/check-javascript-errors.js +++ b/build/tasks/release-checks/tasks/check-javascript-errors.js @@ -1,6 +1,5 @@ const Task = require('./task'); const puppeteer = require('puppeteer'); -const { killProc } = require('../utils'); const PUPPETEER_TIMEOUT = 5000; module.exports = class CheckJavascriptErrors extends Task { @@ -42,11 +41,6 @@ module.exports = class CheckJavascriptErrors extends Task { }); } - stop() { - this.resolve(); - killProc(this.proc); - } - getTitle() { return super.getTitle() + ` (url: ${this.url})`; } diff --git a/build/tasks/release-checks/tasks/execute-command.js b/build/tasks/release-checks/tasks/execute-command.js index ded45c76d..aa5101e33 100644 --- a/build/tasks/release-checks/tasks/execute-command.js +++ b/build/tasks/release-checks/tasks/execute-command.js @@ -1,5 +1,4 @@ const Task = require('./task'); -const { killProc } = require('../utils'); const { spawn } = require('child_process'); const os = require('os'); @@ -24,8 +23,9 @@ module.exports = class ExecuteCommand extends Task { execute() { this.proc = spawn(this.command, this.parameters); - this.promise = new Promise((resolve) => { + this.promise = new Promise((resolve, reject) => { this.resolve = resolve; + this.reject = reject; }); this.proc.stdout.on('data', (data) => { @@ -62,11 +62,6 @@ module.exports = class ExecuteCommand extends Task { return this.execute(); } - stop() { - this.resolve(); - killProc(this.proc); - } - getTitle() { return super.getTitle() + ` (command: ${this.command} ${this.parameters.join(' ')})`; } diff --git a/build/tasks/release-checks/tasks/take-screenshot-of-page.js b/build/tasks/release-checks/tasks/take-screenshot-of-page.js index 2d9e3132a..16fc364f5 100644 --- a/build/tasks/release-checks/tasks/take-screenshot-of-page.js +++ b/build/tasks/release-checks/tasks/take-screenshot-of-page.js @@ -1,6 +1,5 @@ const Task = require('./task'); const puppeteer = require('puppeteer'); -const { killProc } = require('../utils'); const PUPPETEER_TIMEOUT = 5000; module.exports = class TakeScreenShotOfPage extends Task { @@ -38,11 +37,6 @@ module.exports = class TakeScreenShotOfPage extends Task { }); } - stop() { - this.resolve(); - killProc(this.proc); - } - getTitle() { return super.getTitle() + ` (url: ${this.url})`; } diff --git a/build/tasks/release-checks/tasks/task.js b/build/tasks/release-checks/tasks/task.js index a81e8552b..16225519b 100644 --- a/build/tasks/release-checks/tasks/task.js +++ b/build/tasks/release-checks/tasks/task.js @@ -1,4 +1,5 @@ const Step = require('../step'); +const kill = require('tree-kill'); module.exports = class Task extends Step { constructor(title) { @@ -13,4 +14,15 @@ module.exports = class Task extends Step { getTitle() { return `[TASK] ${this.title}`; } + + stop() { + this.resolve && this.resolve(); + kill(this.proc.pid, err => { + if (err) { + this.reject && this.reject(err); + } else { + this.resolve && this.resolve(); + } + }); + } }; diff --git a/build/tasks/release-checks/utils.js b/build/tasks/release-checks/utils.js deleted file mode 100644 index 94a2c79fe..000000000 --- a/build/tasks/release-checks/utils.js +++ /dev/null @@ -1,16 +0,0 @@ -const os = require('os'); -const childProcess = require('child_process'); - -function killProc(proc) { - if (os.platform() === 'win32') { - childProcess.exec('taskkill /pid ' + proc.pid + ' /T /F'); - } else { - proc.stdin.pause(); - proc.kill(); - } -} - -module.exports = { - killProc -}; - diff --git a/package-lock.json b/package-lock.json index 4a12ee0a0..823af3dc5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8804,6 +8804,12 @@ "nopt": "~1.0.10" } }, + "tree-kill": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.1.tgz", + "integrity": "sha512-4hjqbObwlh2dLyW4tcz0Ymw0ggoaVDMveUB9w8kFSQScdRLo0gxO9J7WFcUBo+W3C1TLdFIEwNOWebgZZ0RH9Q==", + "dev": true + }, "trim-newlines": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz", diff --git a/package.json b/package.json index 4c50d9a5f..af706ad19 100644 --- a/package.json +++ b/package.json @@ -96,6 +96,7 @@ "nyc": "^14.1.1", "puppeteer": "^1.19.0", "rimraf": "^2.6.3", + "tree-kill": "^1.2.1", "ts-node": "^8.3.0", "typescript": "^3.5.3", "yargs": "^13.3.0" From 63b6ebe4cd676128f4f5a14f038a2f85cbf10b3a Mon Sep 17 00:00:00 2001 From: Chunpeng Huo Date: Fri, 2 Aug 2019 11:23:17 +1000 Subject: [PATCH 49/52] chore: remove unnecessary resolve --- build/tasks/release-checks/tasks/task.js | 1 - 1 file changed, 1 deletion(-) diff --git a/build/tasks/release-checks/tasks/task.js b/build/tasks/release-checks/tasks/task.js index 16225519b..17ab408ef 100644 --- a/build/tasks/release-checks/tasks/task.js +++ b/build/tasks/release-checks/tasks/task.js @@ -16,7 +16,6 @@ module.exports = class Task extends Step { } stop() { - this.resolve && this.resolve(); kill(this.proc.pid, err => { if (err) { this.reject && this.reject(err); From 17d4fb11ef48eb03743dc9b49b40c1fa55172c2b Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Tue, 13 Aug 2019 23:07:33 +0430 Subject: [PATCH 50/52] typo: karma.conf.js --- skeleton/karma/karma.conf.js__if_cli-bundler | 2 +- skeleton/karma/test__if_webpack/karma.conf.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/skeleton/karma/karma.conf.js__if_cli-bundler b/skeleton/karma/karma.conf.js__if_cli-bundler index 864e1beb5..4a160fd53 100644 --- a/skeleton/karma/karma.conf.js__if_cli-bundler +++ b/skeleton/karma/karma.conf.js__if_cli-bundler @@ -61,7 +61,7 @@ module.exports = function(config) { /* * To run in non-headless mode: * 1. Comment the following lines - * 2. Uncomment the above "browser" setting + * 2. Uncomment the above "browsers" setting */ browsers: [ 'ChromeHeadless', diff --git a/skeleton/karma/test__if_webpack/karma.conf.js b/skeleton/karma/test__if_webpack/karma.conf.js index 78e0be4fb..fbdb24c67 100644 --- a/skeleton/karma/test__if_webpack/karma.conf.js +++ b/skeleton/karma/test__if_webpack/karma.conf.js @@ -86,7 +86,7 @@ module.exports = function (config) { /* * To run in non-headless mode: * 1. Comment the following lines - * 2. Uncomment the above "browser" setting + * 2. Uncomment the above "browsers" setting */ browsers: [ 'ChromeHeadless', From 8ecb03927dc2bbdf3397046cd0a59e14be0f73d0 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Thu, 15 Aug 2019 19:09:06 +0430 Subject: [PATCH 51/52] update: port && host detection, and shutdownAppServer * Update port and host detection with the new mechanism of running webpack applications * Update shutdownAppServer method to return a Promise which resolves when the app server is down. * Add host to the aurelia.json --- .../cli-bundler/aurelia_project/aurelia.json | 1 + .../cli-bundler/aurelia_project/tasks/run.ext | 7 +++- .../cypress/aurelia_project/tasks/cypress.ext | 15 +++++++- .../aurelia_project/tasks/protractor.ext | 9 ++++- skeleton/webpack/aurelia_project/aurelia.json | 1 + .../webpack/aurelia_project/tasks/run.ext | 37 ++++++++++++++++++- skeleton/webpack/package.json | 4 +- 7 files changed, 65 insertions(+), 9 deletions(-) diff --git a/skeleton/cli-bundler/aurelia_project/aurelia.json b/skeleton/cli-bundler/aurelia_project/aurelia.json index 44e68b619..a8a80ec71 100644 --- a/skeleton/cli-bundler/aurelia_project/aurelia.json +++ b/skeleton/cli-bundler/aurelia_project/aurelia.json @@ -103,6 +103,7 @@ // @if feat['dotnet-core'] "port": 5000, + "host": "localhost", "index": "wwwroot/index.html", "baseDir": "./wwwroot", "baseUrl": "scripts", diff --git a/skeleton/cli-bundler/aurelia_project/tasks/run.ext b/skeleton/cli-bundler/aurelia_project/tasks/run.ext index 240e6d5a2..d69af564b 100644 --- a/skeleton/cli-bundler/aurelia_project/tasks/run.ext +++ b/skeleton/cli-bundler/aurelia_project/tasks/run.ext @@ -64,8 +64,11 @@ const run = gulp.series( ); const shutdownAppServer = (code) =>{ - bs.exit(); - process.exit(code || 0); + return new Promise(resolve => { + bs.exit(); + process.exit(code || 0); + resolve(); + }); }; export { run as default , shutdownAppServer }; diff --git a/skeleton/cypress/aurelia_project/tasks/cypress.ext b/skeleton/cypress/aurelia_project/tasks/cypress.ext index d4459998d..472a991af 100644 --- a/skeleton/cypress/aurelia_project/tasks/cypress.ext +++ b/skeleton/cypress/aurelia_project/tasks/cypress.ext @@ -7,14 +7,24 @@ import * as cypress from 'cypress'; import * as config from '../../cypress.config'; // @endif import { CLIOptions } from 'aurelia-cli'; +import * as project from '../aurelia.json'; import { default as runAppServer, shutdownAppServer } from './run'; const runCypress = (cb) => { if (CLIOptions.hasFlag('run')) { + const port = CLIOptions.getFlagValue('port') || project.platform.port; cypress .run(config) .then(results => { - (results.totalFailed === 0 ? shutdownAppServer() : cb('Run failed!')); + if (results.totalFailed === 0) { + shutdownAppServer().then(cb); + } + else { + shutdownAppServer(1) + .then(_ => { + cb('Tests failed'); + }); + } }) .catch(cb); } else { @@ -24,7 +34,8 @@ const runCypress = (cb) => { export default (cb) => { if (CLIOptions.hasFlag('start')) { - runAppServer(runCypress(cb)); + runCypress(cb); + runAppServer(); return; } diff --git a/skeleton/protractor/aurelia_project/tasks/protractor.ext b/skeleton/protractor/aurelia_project/tasks/protractor.ext index 16d0a638e..225473042 100644 --- a/skeleton/protractor/aurelia_project/tasks/protractor.ext +++ b/skeleton/protractor/aurelia_project/tasks/protractor.ext @@ -16,7 +16,7 @@ function runApp(cb) { cb(); } -function runProtractor() { +function runProtractor(cb) { // @if feat.babel return gulp.src('test/e2e/**/*.e2e.js') // @endif @@ -24,7 +24,12 @@ function runProtractor() { return gulp.src('test/e2e/**/*.e2e.ts') // @endif .pipe(protractor({ configFile: 'protractor.conf.js', args: process.argv.slice(3) })) - .on('end', shutdownAppServer); + .on('end', () => { + shutdownAppServer().then(cb); + }) + .on('error', () => { + shutdownAppServer(1).then(cb); + }); } // Setting up the test task diff --git a/skeleton/webpack/aurelia_project/aurelia.json b/skeleton/webpack/aurelia_project/aurelia.json index 0790da0d9..19d570eb9 100644 --- a/skeleton/webpack/aurelia_project/aurelia.json +++ b/skeleton/webpack/aurelia_project/aurelia.json @@ -18,6 +18,7 @@ // @if feat['dotnet-core'] "port": 5000, + "host": "localhost", "output": "wwwroot/dist", // @endif } diff --git a/skeleton/webpack/aurelia_project/tasks/run.ext b/skeleton/webpack/aurelia_project/tasks/run.ext index 79268fcf3..88f85bfd9 100644 --- a/skeleton/webpack/aurelia_project/tasks/run.ext +++ b/skeleton/webpack/aurelia_project/tasks/run.ext @@ -1,8 +1,41 @@ import { NPM } from 'aurelia-cli'; +import { CLIOptions } from 'aurelia-cli'; +import * as project from '../aurelia.json'; -export default function() { +var find = require('find-process'); +var kill = require('tree-kill'); + +const port = CLIOptions.getFlagValue('port') || project.platform.port; +const host = CLIOptions.getFlagValue('host') || project.platform.host || "localhost"; + +const run = () => { console.log('`au run` is an alias of the `npm start`, you may use either of those; see README for more details.'); const args = process.argv.slice(3); - return (new NPM()).run('start',['--', ...args]); + + if (!CLIOptions.hasFlag('port')) { + args.push('--port'); + args.push(port); + } + if (!CLIOptions.hasFlag('host')) { + args.push('--host'); + args.push(host); + } + + return (new NPM()).run('start', ['--', ...args]); } + +const shutdownAppServer = () => { + return new Promise(resolve => { + find('port', port) + .then(function (list) { + if (list.length) { + kill(list[0].pid, 'SIGKILL', function (err) { + resolve(); + }); + } + }); + }); +}; + +export { run as default, shutdownAppServer }; diff --git a/skeleton/webpack/package.json b/skeleton/webpack/package.json index 0aa4326b1..9a64c26b1 100644 --- a/skeleton/webpack/package.json +++ b/skeleton/webpack/package.json @@ -68,6 +68,8 @@ "html-loader": "", "istanbul-instrumenter-loader": "", "webpack-bundle-analyzer": "", + "find-process": "^1.4.2", + "tree-kill": "^1.2.1", }, "scripts": { "build": "webpack --env.production --env.extractCss", @@ -78,7 +80,7 @@ // @endif // @if feat.web - "start": "webpack-dev-server --env.extractCss --port 8080" + "start": "webpack-dev-server --env.extractCss" // @endif } } From d8144daefe0ecc8dcd18359d554c115f86c0a063 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Thu, 15 Aug 2019 19:09:47 +0430 Subject: [PATCH 52/52] update: demo.e2e.ext for protractor to use baseUrl in config --- skeleton/protractor/protractor.conf.js | 1 + skeleton/scaffold-minimum/test__if_protractor/e2e/demo.e2e.ext | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/skeleton/protractor/protractor.conf.js b/skeleton/protractor/protractor.conf.js index 6f386457f..d08a71ff3 100644 --- a/skeleton/protractor/protractor.conf.js +++ b/skeleton/protractor/protractor.conf.js @@ -12,6 +12,7 @@ const headless = cliOptions.hasFlag('run') || false; const config = { port: port, + host: host, baseUrl: `http://${host}:${port}/`, specs: [ diff --git a/skeleton/scaffold-minimum/test__if_protractor/e2e/demo.e2e.ext b/skeleton/scaffold-minimum/test__if_protractor/e2e/demo.e2e.ext index d419e7fee..333be4530 100644 --- a/skeleton/scaffold-minimum/test__if_protractor/e2e/demo.e2e.ext +++ b/skeleton/scaffold-minimum/test__if_protractor/e2e/demo.e2e.ext @@ -14,7 +14,7 @@ describe('aurelia skeleton app', function() { poSkeleton = new PageObjectSkeleton(); poWelcome = new PageObjectWelcome(); - await browser.loadAndWaitForAureliaPage(`http://localhost:${config.port}`); + await browser.loadAndWaitForAureliaPage(`http://${config.baseUrl}`); }); it('should load the page and display the initial page title', async () => {