Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/sumitparakh/klingon into …
Browse files Browse the repository at this point in the history
…issue5-generate
  • Loading branch information
sumitparakh committed Nov 26, 2018
2 parents f595733 + 12a4f80 commit 352c61d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ export class TerminalService {
this.term.attach(this.socket);
this.term._initialized = true;
setTimeout(_ => resolve(), 100);

/** If root directory is set, then update shell's current directory to it. */
const rootDir = localStorage.getItem('ui.lastUsedRootDirectory');
if (rootDir) {
this.command(`cd ` + rootDir);
}

};
this.socket.onclose = this.socketError;
this.socket.onerror = this.socketError;
Expand Down
3 changes: 2 additions & 1 deletion packages/klingon-ui/src/app/cli/cli.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export class CliService {
values[key] !== null &&
values[key] !== '' &&
key !== 'app-name' &&
key !== 'root-dir'
key !== 'root-dir' &&
key !== 'dir'
)
.map(key => `--${key}=${values[key]}`)
.join(' ');
Expand Down
10 changes: 6 additions & 4 deletions packages/klingon-ui/src/app/cli/flags/flags.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ export class FlagsComponent implements OnInit {
}

buildForm(flag: number) {
if (flag === FlagsComponent.Flags.CREATE) {
const lastUsedRootDirectory = localStorage.getItem(
'ui.lastUsedRootDirectory'
);

const lastUsedRootDirectory = localStorage.getItem(
'ui.lastUsedRootDirectory'
);

if (flag === FlagsComponent.Flags.CREATE) {
return new FormGroup({
'app-name': new FormControl('', Validators.required),
'root-dir': new FormControl(lastUsedRootDirectory),
Expand All @@ -67,6 +68,7 @@ export class FlagsComponent implements OnInit {
});
} else if (flag === FlagsComponent.Flags.SERVE) {
return new FormGroup({
dir: new FormControl(lastUsedRootDirectory),
host: new FormControl('127.0.0.1'),
app: new FormControl(''),
hmr: new FormControl(false),
Expand Down
22 changes: 15 additions & 7 deletions packages/klingon-ui/src/app/cli/serve/serve.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@
<mat-hint align="start">Port to listen to for serving.</mat-hint>
</mat-form-field>
</p>

<p>
<mat-form-field>
<input autocomplete="off" formControlName="dir" matInput placeholder="Project Root Directory">
<mat-hint align="start">Angular CLI will treat this directory as a root directory to serve angular application. Leave empty to use your home directory.</mat-hint>
</mat-form-field>
</p>

<p>
<mat-form-field>
<input autocomplete="off" formControlName="app" matInput placeholder="Application" required autofocus/>
<mat-hint align="start">The application to serve.</mat-hint>
</mat-form-field>
</p>

</section>

<app-drop-down [open]="false" contentHeight="1990px">
Expand All @@ -21,13 +36,6 @@ <h3 class="title">Advanced Options</h3>
<h6 class="sub-title">Configure other flags for the serve command</h6>
<main class="content">

<p>
<mat-form-field>
<input formControlName="app" matInput placeholder="Application" />
<mat-hint align="start">The application to serve.</mat-hint>
</mat-form-field>
</p>

<p>
<mat-form-field>
<input formControlName="proxy-config" matInput placeholder="Proxy Configuration File" />
Expand Down
2 changes: 1 addition & 1 deletion packages/klingon-ui/src/app/cli/serve/serve.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class CliServeComponent extends FlagsComponent implements OnInit {
serve() {
this.isWorking = true;
this.cli
.runNgCommand(`serve ${this.cli.serialize(this.form.value)}`)
.runNgCommand(`serve ${this.cli.serialize(this.form.value)}`, this.form.value['dir'] + '/' + this.form.value['app'])
.subscribe(data => {
this.isWorking = false;

Expand Down

0 comments on commit 352c61d

Please sign in to comment.