Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feature: support overriding host name on au run, and e2e tests #1132

Closed
wants to merge 58 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
90bed33
feature: support for overriding host value
shahabganji Jul 1, 2019
0b552ae
fix: --open, opens two tabs on the browser
shahabganji Jul 1, 2019
3e4bc2d
Merge branch 'feature/port_host_overrride' into develop
shahabganji Jul 1, 2019
caee446
update: run.json with host help docs
shahabganji Jul 2, 2019
1608d1b
fix: two open tabs with --open
shahabganji Jul 2, 2019
dbe0e15
Merge remote-tracking branch 'origin/master'
shahabganji Jul 2, 2019
8951188
fix: es-linter for unused variables
shahabganji Jul 2, 2019
cc2aa0a
add: override host and port while running cypress tests
shahabganji Jul 2, 2019
16c8fd7
update: cypress.json for the dake of au help
shahabganji Jul 2, 2019
df83789
feature: run app automatically in the background before running cypress
shahabganji Jul 2, 2019
aa3139c
add: scripts section in package.json for e2e tests
shahabganji Jul 2, 2019
360e4c5
removed: open npm package from package.json
shahabganji Jul 5, 2019
0a7f64a
removed: open npm package from package.json
shahabganji Jul 5, 2019
4870ba6
add: localhost to the aurelia.json when dotnet core
shahabganji Jul 5, 2019
51ec38b
add: helps for the au help command
shahabganji Jul 5, 2019
dccda89
update: CLI bundler, the --open can be configured
shahabganji Jul 5, 2019
9caa666
add: "localhost" as the default value
shahabganji Jul 5, 2019
842d659
typo: address
shahabganji Jul 6, 2019
3499e71
add: host option for browser sync
shahabganji Jul 6, 2019
da926a3
update: run.ext, CLI Bundler to report --host value as well
shahabganji Jul 6, 2019
e306c38
add: host, as a setting in aurelia.json file for CLI Bundler
shahabganji Jul 6, 2019
bb52172
Merge branch 'feature/e2e_cypress' into feature/e2e
shahabganji Jul 6, 2019
f235dfa
update: override port and host for ptotractor
shahabganji Jul 6, 2019
d7b4745
auto start application before e2e tests
shahabganji Jul 6, 2019
ae8ee67
add: scripts to run e2e test && reformat protractor.ext
shahabganji Jul 7, 2019
2bba751
update: run.ext, prioritize hmr & open flags
shahabganji Jul 7, 2019
08d0fc8
add: arguments to the protractor child process
shahabganji Jul 7, 2019
3c08c56
support: running protractor in headless mode by --run arg, like cypress
shahabganji Jul 7, 2019
440d932
add: new flags for protractor for the sake of au help command
shahabganji Jul 7, 2019
218cd49
update: cypress au help flags
shahabganji Jul 7, 2019
b537b09
fix: protractor.conf.js file was accidentally moved
shahabganji Jul 7, 2019
862b8e5
fix: stop e2e tests when finished, protractor
shahabganji Jul 7, 2019
7471514
feat(webpack):enable CLI-less webpack build + run
Sayan751 May 15, 2019
afb13d6
update: README webpack
shahabganji Jul 15, 2019
d96c308
update: README cli-bundler
shahabganji Jul 15, 2019
ceab34e
update: README cypress
shahabganji Jul 15, 2019
245ca1d
Update README.md
shahabganji Jul 15, 2019
2a911f7
update: README protractor
shahabganji Jul 15, 2019
a909a5a
chore(webpack): post review changes
Sayan751 Jul 17, 2019
c03991f
chore(webpack): added gulp back to webpack projects
Sayan751 Jul 17, 2019
5525f49
update: browserSync initialization to how it is recommended
shahabganji Jul 17, 2019
b33c363
add: shutdownAppServer
shahabganji Jul 17, 2019
02c568a
fix: npm audit fix
shahabganji Jul 17, 2019
da83916
fix: separate babel and typescript features in protractor.ext
shahabganji Jul 17, 2019
76ffaef
chore(webpack): reactivation of au task as alias
Sayan751 Jul 23, 2019
8550a99
chore(karma): Changed karma config to be in headless mode by default
shahabganji Jul 26, 2019
a217fec
fix(webpack): new release check
Sayan751 Jul 29, 2019
5343380
Merge branch 'cli-less-webpack-build' of git://github.com/Sayan751/cl…
3cp Aug 1, 2019
67572cb
Merge branch 'Sayan751-cli-less-webpack-build'
3cp Aug 1, 2019
ce39452
chore: add app-settings-loader version
3cp Aug 1, 2019
68590f9
chore(webpack): skip not-used env files for webpack app
3cp Aug 1, 2019
3b224dd
fix(webpack): fix overlooked refactoring
3cp Aug 1, 2019
bfdad54
test(release-check): fix proc kill on new webpack wrapper
3cp Aug 1, 2019
63b6ebe
chore: remove unnecessary resolve
3cp Aug 2, 2019
b20f8ba
resolve conflicts between 'feature/host' into master
shahabganji Aug 13, 2019
17d4fb1
typo: karma.conf.js
shahabganji Aug 13, 2019
8ecb039
update: port && host detection, and shutdownAppServer
shahabganji Aug 15, 2019
d8144da
update: demo.e2e.ext for protractor to use baseUrl in config
shahabganji Aug 15, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build/tasks/release-checks/suite-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
6 changes: 0 additions & 6 deletions build/tasks/release-checks/tasks/check-javascript-errors.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -42,11 +41,6 @@ module.exports = class CheckJavascriptErrors extends Task {
});
}

stop() {
this.resolve();
killProc(this.proc);
}

getTitle() {
return super.getTitle() + ` (url: ${this.url})`;
}
Expand Down
9 changes: 2 additions & 7 deletions build/tasks/release-checks/tasks/execute-command.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const Task = require('./task');
const { killProc } = require('../utils');
const { spawn } = require('child_process');
const os = require('os');

Expand All @@ -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) => {
Expand Down Expand Up @@ -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(' ')})`;
}
Expand Down
6 changes: 0 additions & 6 deletions build/tasks/release-checks/tasks/take-screenshot-of-page.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -38,11 +37,6 @@ module.exports = class TakeScreenShotOfPage extends Task {
});
}

stop() {
this.resolve();
killProc(this.proc);
}

getTitle() {
return super.getTitle() + ` (url: ${this.url})`;
}
Expand Down
11 changes: 11 additions & 0 deletions build/tasks/release-checks/tasks/task.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const Step = require('../step');
const kill = require('tree-kill');

module.exports = class Task extends Step {
constructor(title) {
Expand All @@ -13,4 +14,14 @@ module.exports = class Task extends Step {
getTitle() {
return `[TASK] ${this.title}`;
}

stop() {
kill(this.proc.pid, err => {
if (err) {
this.reject && this.reject(err);
} else {
this.resolve && this.resolve();
}
});
}
};
64 changes: 64 additions & 0 deletions build/tasks/release-checks/tests/webpack/au-build.js
Original file line number Diff line number Diff line change
@@ -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
};
3 changes: 2 additions & 1 deletion build/tasks/release-checks/tests/webpack/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module.exports = {
...require('./au-run')
...require('./au-run'),
...require('./au-build')
};
16 changes: 0 additions & 16 deletions build/tasks/release-checks/utils.js

This file was deleted.

7 changes: 0 additions & 7 deletions lib/build/webpack-reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`;
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions lib/dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
6 changes: 5 additions & 1 deletion lib/package-managers/base-package-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@
"gulp": "^4.0.2",
"htmlparser2": "^3.10.1",
"lead": "^1.0.0",
"lodash": "^4.17.15",
"lodash": "^4.17.14",
"map-stream": "0.0.7",
"mkdirp": "^0.5.1",
"node-libs-browser": "^2.2.1",
"npm-which": "^3.0.1",
"open": "^6.4.0",
"preprocess": "^3.1.0",
"pumpify": "^2.0.0",
"querystring-es3": "1.0.0-0",
Expand Down Expand Up @@ -96,6 +95,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"
Expand Down
4 changes: 4 additions & 0 deletions skeleton/cli-bundler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions skeleton/cli-bundler/aurelia_project/aurelia.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,16 @@
"platform": {
// @if feat.web
"port": 9000,
"host": "localhost",
"open": false,
"index": "index.html",
"baseDir": ".",
"output": "scripts",
// @endif

// @if feat['dotnet-core']
"port": 5000,
"host": "localhost",
"index": "wwwroot/index.html",
"baseDir": "./wwwroot",
"baseUrl": "scripts",
Expand Down
26 changes: 22 additions & 4 deletions skeleton/cli-bundler/aurelia_project/tasks/run.ext
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ 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'),
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],
Expand All @@ -32,6 +36,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();
Expand All @@ -48,9 +58,17 @@ function reload() {
browserSync.reload();
}

let run = gulp.series(
const run = gulp.series(
serve,
done => { watch(reload); done(); }
);

export default run;
const shutdownAppServer = (code) =>{
return new Promise(resolve => {
bs.exit();
process.exit(code || 0);
resolve();
});
};

export { run as default , shutdownAppServer };
5 changes: 5 additions & 0 deletions skeleton/cli-bundler/aurelia_project/tasks/run.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions skeleton/common/config/environment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"debug": true,
"testing": true
}
4 changes: 4 additions & 0 deletions skeleton/common/config/environment.production.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"debug": false,
"testing": false
}
5 changes: 2 additions & 3 deletions skeleton/common/tsconfig.json__if_typescript
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -44,6 +42,7 @@
"lib": ["es2015", "dom"],
"moduleResolution": "node",
"baseUrl": "src",
"resolveJsonModule": true,

// @if feat.plugin
"paths": { "resources": [ "" ] },
Expand Down
Loading