Skip to content

feat(@angular/cli): add build defaults to config #6889

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 1 commit into from
Jul 6, 2017

Conversation

filipesilva
Copy link
Contributor

Adds following defaults to .angular-cli.json under defaults: sourcemaps, baseHref, progress, poll, deleteOutputPath, preserveSymlinks, showCircularDependencies.

They can be set via ng set defaults.build.KEY = VALUE.

Also removes apps.0.showCircularDependencies. This is not a breaking chance since it was only added in 1.3.0-beta.0.

Followup to #6884 (comment).

Copy link
Contributor

@Brocco Brocco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor things.

`));
}

this.addAliases(cliConfig);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer referring to static methods via the class name and not this because this conveys an instance member and not a static method. (same thing other places).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -61,6 +61,12 @@ export class CliConfig<JsonType> {
this._config.$$set(jsonPath, value);
}

public getPaths(baseJsonPath: string, keys: string[]) {
const ret: { [k: string]: any } = {};
keys.forEach(key => ret[key] = this.get(`${baseJsonPath}.${key}`));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think map makes more sense here

return keys.map(key => ({[key]: this.get(`${baseJsonPath}.${key}`)});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your code and his are not equivalent :)

return keys.reduce((acc, k) => {
  acc[key] = this.get(`${baseJsonPath}.${key}`);
  return acc;
}, {});

might be more correct but more verbose.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually spent a fair bit of time figure out what the best way to do this function was, I was torn between the reduce and forEach. The reduce also needs a typing for the accumulator:

    return keys.reduce((acc, key) => {
      acc[key] = this.get(`${baseJsonPath}.${key}`);
      return acc;
    }, {} as { [k: string]: any });

All the same to me though, I left the forEach for now but will change if there's a preference.

@filipesilva filipesilva force-pushed the add-build-defaults branch 2 times, most recently from 759eab6 to 67f7608 Compare July 5, 2017 19:00
Brocco
Brocco previously approved these changes Jul 6, 2017
Copy link
Contributor

@Brocco Brocco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Adds following defaults to `.angular-cli.json` under `defaults`: `sourcemaps`, `baseHref`, `progress`, `poll`, `deleteOutputPath`, `preserveSymlinks`, `showCircularDependencies`.

They can be set via `ng set defaults.build.KEY = VALUE`.

Also removes `apps.0.showCircularDependencies`. This is not a breaking chance since it was only added in 1.3.0-beta.0.

Followup to angular#6884 (comment).
Copy link
Contributor

@hansl hansl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hansl hansl merged commit 7f28049 into angular:master Jul 6, 2017
@filipesilva filipesilva deleted the add-build-defaults branch July 6, 2017 22:32
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants