Skip to content

merge #9

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

Merged
merged 31 commits into from
Dec 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0490f98
add support for argument aliases
Nov 29, 2017
558e1d9
Merge branch 'master' of https://github.com/mgmarlow/angular-playgrou…
Nov 29, 2017
7cc2196
cleanup
Nov 29, 2017
945f181
migrate port and timeout attempts as cli params
Nov 29, 2017
f40c53a
add method to locate first available port
Nov 29, 2017
9dc1066
refactor flags
Nov 29, 2017
4915488
run angular CLi now uses config flags
Nov 29, 2017
299709e
watch and build now don't need config dep
Nov 30, 2017
dae462c
improve logging for timeout changes
Nov 30, 2017
e7bc6f7
make find-port into an async method
Nov 30, 2017
39bec87
fix base URL
Nov 30, 2017
0547d36
move ts-node and puppeteer to cli deps
Nov 30, 2017
1fb2561
remove console logs
Nov 30, 2017
55efeb6
allow for nested flags
Nov 30, 2017
63bd10c
fix applying configuration for nested flags
Nov 30, 2017
878ed91
add recursive findFlag
Nov 30, 2017
0a78f9a
get rid of unnecessary config log
Nov 30, 2017
b2b4a3a
refactor find implementation
Nov 30, 2017
1fa17d6
add default sourceRoot arg
Nov 30, 2017
aca0c29
refactor applyConfig to use recursion
Nov 30, 2017
315820f
add better error reporting on check errors
Dec 1, 2017
60f7cae
abstract hex colors
Dec 1, 2017
7e0f5a8
add bamboo report output to test runner
Dec 1, 2017
1f2970c
change report type to string const for easy configuration
Dec 1, 2017
0702740
rename reporter to json reporter, tweak json output
Dec 1, 2017
bfbeebe
update changelog
Dec 1, 2017
94c39a9
tidy up presentation
Dec 1, 2017
c55a483
add commits
Dec 2, 2017
e32e97e
fix urls on commit listings
Dec 2, 2017
53bf10e
Merge pull request #68 from mgmarlow/cli-overhaul
lurock Dec 2, 2017
7336e23
3.0.0
lurock Dec 2, 2017
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
51 changes: 51 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,54 @@
<a name="3.0.0"></a>

# 3.0.0 (2017-12-01)

### Features
* **cli:** Added a boat-load of new CLI configuration options. Every option available
in the `angular-playground.json` file is now also available as a CLI argument
(except @angular/cli arguments). [Read more about it in our docs](http://angularplayground.it/docs/api/configuration).
([9dc1066](https://github.com/SoCreate/angular-playground/commit/9dc1066))
* **new docs:** Speaking of docs, check out our newly-designed
[docs page](http://angularplayground.it/docs/getting-started/introduction).
* **new error checking utility:** A new CLI option has been introduced that will run and visit
all sandbox scenarios in headless chrome, surfacing any errors that appear in the
console. [Never forget to mock a dependency again!](http://angularplayground.it/docs/how-to/run-the-test-suite)
([6074586](https://github.com/SoCreate/angular-playground/commit/6074586))
* **report formats for builds:** Used in conjunction with the checking utility, you can now
generate a JSON report that your build system can read for error reporting. Read all
about it [here](http://angularplayground.it/docs/api/reporter-formats).
([7e0f5a8](https://github.com/SoCreate/angular-playground/commit/7e0f5a8))

* **command bar shows all components as default:** Got the Playground running but don't know where
to begin? We'll help you out by showing all of your available scenarios.
([51680fd](https://github.com/SoCreate/angular-playground/commit/51680fd)

### Breaking Changes
* **no default configuration argument**: The CLI no longer supports a default configuration file argument.
**Note:** `angular-playground` with no arguments will still default to using the
`angular-playground.json` file as expected.
([9dc1066](https://github.com/SoCreate/angular-playground/commit/9dc1066))

Before:
```
angular-playground my-configuration-file.json
```
After:
```
angular-playground --config my-configuration-file.json
```

* **new cli argument style**: CLI arguments now match typical npm style: `--argument` for full name, `-A` for abbreviation.

Before:
```
-no-watch -no-serve
```

After:
```
--no-watch --no-serve
```

<a name="2.3.0"></a>
# 2.3.0 (2017-11-13)

Expand Down
14 changes: 6 additions & 8 deletions package-lock.json

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

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-playground",
"version": "2.3.0",
"version": "3.0.0",
"description": "A drop in app module for working on Angular components in isolation (aka Scenario Driven Development).",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down Expand Up @@ -45,7 +45,10 @@
"zone.js": ">=0.8.14"
},
"dependencies": {
"node-watch": "^0.4.1"
"async": "^2.6.0",
"node-watch": "^0.4.1",
"ts-node": "^3.3.0",
"puppeteer": "^0.13.0"
},
"devDependencies": {
"@angular/common": "^5.0.0",
Expand All @@ -63,9 +66,7 @@
"glob": "^7.1.2",
"gulp": "^3.9.1",
"gulp-inline-ng2-template": "^4.0.0",
"puppeteer": "^0.13.0",
"rxjs": "^5.5.2",
"ts-node": "^3.3.0",
"tslint": "5.3.2",
"typescript": "2.4.2",
"zone.js": "0.8.4"
Expand Down
27 changes: 18 additions & 9 deletions src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { startWatch } from './start-watch';
import { runAngularCli } from './run-angular-cli';
import { Configuration } from './shared/configuration';
import { verifySandboxes } from './verify-sandboxes';
import { findFirstFreePort } from './shared/find-port';

(async () => {
await run();
Expand All @@ -13,28 +14,36 @@ import { verifySandboxes } from './verify-sandboxes';
async function run() {
const rawArgs = process.argv.slice(2);
const config = new Configuration(rawArgs);
let sandboxPort, playgroundConfig;

let configFile = path.resolve(config.configFilePath);
let playgroundConfig;
let configFile = path.resolve(config.flags.config.value);
try {
playgroundConfig = require(configFile.replace(/.json$/, ''));
} catch (e) {
process.stdout.write(`[angular-playground]: \x1b[31mFailed to load config file ${configFile}\x1b[0m\n`);
process.exit(1);
}

// Parity between command line arguments and configuration file
config.applyConfigurationFile(playgroundConfig);
const sandboxesPath = await build(playgroundConfig.sourceRoot);
config.port = playgroundConfig.angularCli.port ? playgroundConfig.angularCli.port : 4201;

if (config.runWatch) {
startWatch(playgroundConfig, () => build(playgroundConfig.sourceRoot));
if (config.flags.checkErrors.value) {
// get port dynamically
const port = await findFirstFreePort('127.0.0.1', 7000, 9000);
sandboxPort = port;
config.flags.angularCli.port.value = port;
}

if (config.runAngularCliServe && playgroundConfig.angularCli) {
runAngularCli(playgroundConfig.angularCli);
if (!config.flags.noWatch.value) {
startWatch(config.flags.sourceRoot.value, () => build(config.flags.sourceRoot.value));
}

if (config.runCheckErrors) {
verifySandboxes(config, sandboxesPath);
if (!config.flags.noServe.value && playgroundConfig.angularCli) {
runAngularCli(config, playgroundConfig.angularCli);
}

if (config.flags.checkErrors.value) {
verifySandboxes(config, sandboxesPath, sandboxPort);
}
}
43 changes: 43 additions & 0 deletions src/cli/reporters/json-reporter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
class JSONStats {
suites = 1;
passes: number;
pending = 0;
duration = 0;
time = 0;

constructor(
public tests: number,
public failures: number,
public start = 0,
public end = 0
) {
this.passes = this.tests - this.failures;
}

}

export class JSONReporter {
constructor (
public errors: any[],
public scenarioNames: string[]
) {}

getJson() {
return JSON.stringify({
stats: new JSONStats(this.scenarioNames.length, this.errors.length),
failures: this.errors.map(failure => {
if (!failure) return;
return {
title: failure.scenario,
err: {
message: failure.descriptions[0]
}
};
}),
passes: this.scenarioNames.map(pass => {
return { title: pass };
}),
skips: []
}, null, 2);
}
}
25 changes: 10 additions & 15 deletions src/cli/run-angular-cli.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
import { Configuration } from './shared/configuration';

const fs = require('fs');
const path = require('path');
const childProcess = require('child_process');

export const runAngularCli = (angularCliConfig) => {
let port = angularCliConfig.port ? angularCliConfig.port : 4201;
let cliName = '@angular/cli';
try {
fs.accessSync(path.resolve('node_modules/@angular/cli/bin/ng'));
} catch (e) {
cliName = 'angular-cl';
}
let cliPath = `node_modules/${cliName}/bin/ng`;
let args = [cliPath, 'serve', '-no-progress'];
export const runAngularCli = (config: Configuration, angularCliConfig: any) => {
const cliConfig = config.flags.angularCli;
let args = [cliConfig.cmdPath.value, 'serve', '-no-progress'];
args.push('--port');
args.push(port.toString());
if (angularCliConfig.appName) {
args.push(`-a=${angularCliConfig.appName}`);
args.push(cliConfig.port.value.toString());
if (cliConfig.appName.value) {
args.push(`-a=${cliConfig.appName.value}`);
}
if (angularCliConfig.environment) {
args.push(`-e=${angularCliConfig.environment}`);
if (cliConfig.environment.value) {
args.push(`-e=${cliConfig.environment.value}`);
}
if (angularCliConfig.args) {
args = args.concat(angularCliConfig.args);
Expand Down
Loading