61 Commits

Author SHA1 Message Date
Charles Lyding
3d99468b45 fix(@angular/cli): support update migration packages with no entry points
Some schematic only packages may not have entry points defined (`main`/`exports`).  These type of packages will now be correctly resolved when attempting to locate update migrations.

Fixes #20032
2021-02-17 12:43:13 -06:00
Charles Lyding
9a44bf4aaf fix(@angular/cli): improve error logging when resolving update migrations
Failure to resolve a migration package from the workspace root will now not crash and instead error with a message.  Verbose logging (`--verbose`) is also added to provide more details regarding the resolution process.
2021-02-11 14:25:55 -05:00
Alan Agius
cae2209ca8 fix(@angular/cli): only show incompatible NPM error when NPM is used as package manager 2021-02-05 12:40:47 -05:00
Charles Lyding
331f628139 fix(@angular/cli): temporarily limit npm to version 6
This change will display an error message if using npm 7 (or versions earlier than 6). This is a temporarily change while npm 7 usability concerns are addressed.
2021-02-04 14:59:40 -08:00
Charles Lyding
30758d1cc4 fix(@angular/cli): resolve migration collections from containing package
This change ensures that migration collections defined in a package's `ng-update` metadata are resolved from the containing package.  This avoids issues that may arise from package manager hoisting behavior which can result in the wrong migration collection being chosen.  The `--migrate-only` option already contained this resolution logic and now the full update contains it as well.
2021-02-03 12:21:52 -05:00
Charles Lyding
86d69e22fb fix(@angular/cli): redirect Angular schematic dependency requests to known versions
This change adds logic to redirect module resolution requests for Angular schematics to ensure that the correct versions of core schematic related packages are used.  This also ensures that the runtime version of the schematics package matches the version used inside the schematic and that object instances passed into the schematic are compatible.
The current set of core schematic related packages are `@angular-devkit/*` and `@schematics/angular`.  Only first-party Angular schematics are currently affected by this change.
2021-01-28 12:44:34 +01:00
Lukas Spirig
01c99e9cd8 fix(@angular/cli): correctly read transitive dependency
For `ng update --migrateOnly ...` the update implementation checks for transitive
dependencies and tries to parse the containing directory as JSON. This PR
fixes this by providing the correct path to the package.json.
2020-11-03 17:43:14 -06:00
Alan Agius
212374a5f1 refactor(@angular/cli): remove install-package under utils
Remove the lone `install-package.ts` file from tasks to utilities
2020-10-19 19:28:13 +02:00
Drummond Dawson
7254d18ccb fix(@angular/cli): add blank line in migration commit message
Adds a blank line in the commit message between the subject and body in order to properly separate the two.
2020-10-04 16:50:00 -04:00
Charles Lyding
d903d39fc8 refactor(@angular/cli): use new NodeWorkflow schematic features
This change reduces the amount of schematic runtime setup code by leveraging the new options for the root path and schema validation in the NodeWorkflow class.
2020-10-02 18:56:11 -04:00
Charles Lyding
b2b536789b refactor(@angular/cli): discover/load workspace on startup
Previously, the workspace configuration file was found and loaded by individual commands potentially multiple times.  This change moves the initial workspace location discovery and loading of the workspace to the CLI startup.  It also provides the workspace to each command so that the commands can reuse the already loaded and parsed workspace configuration.
2020-10-02 07:53:07 -04:00
Alan Agius
824add1778 fix(@angular/cli): no-op ng update --all
'--all' functionality has been removed from `ng update` as updating multiple packages at once is not recommended. To update the depencencies in your workspace 'package.json' use the update command of your package manager.

Closes #15278
Closes #13095
Closes #12261
Closes #12243
Closes #18813
2020-09-29 16:48:51 +02:00
Alan Agius
64cc005f0b refactor: change UPDATE action color to cyan 2020-09-14 16:36:30 -04:00
Alan Agius
a21eb1588e fix(@angular/cli): improve logs in ng update
These addresses;
- When a large number of migration are executed, it's hard to differentiate between the title and description.
- Fix alignments of logs
2020-09-14 16:36:30 -04:00
Andrei Alecu
d01d647431 refactor(@angular/cli): improve update package discovery 2020-09-03 18:21:06 +02:00
Charles Lyding
5275892f63 refactor(@angular/cli): remove any type usage 2020-08-24 07:50:01 -04:00
Alan Agius
c824bbb4f7 refactor(@angular/cli): update CLI package to be strict compliant 2020-08-12 19:29:13 +01:00
Alan Agius
ef465487fd fix(@angular/cli): resolve external schematics from workspace root
Resolve schematics collections from the workspace root, as otherwise it will be resolved from the temporary installed CLI version

Closes #18083
2020-07-01 11:29:25 -07:00
Alan Agius
4f50aa0e40 fix(@angular/cli): display post migration message when updating from previous major version
Fixes #17256
2020-03-23 14:18:06 -07:00
Alan Agius
66b218c5f6 fix(@angular/cli): print ng update errors stack to log file
When an error occurs during ng update we currently discard the stack trace which in some cases made it hard to identify the cause of the error.

Now, we print the stack trace to a log file similarly to unhandled exceptions.

Example of CMD output;
```cmd
** Executing migrations of package '@angular/core' **

> Static flag migration.
  Removes the `static` flag from dynamic queries.
  As of Angular 9, the "static" flag defaults to false and is no longer required for your view and content queries.
  Read more about this here: https://v9.angular.io/guide/migration-dynamic-flag
× Migration failed: x
  See "C:\Users\alag\AppData\Local\Temp\ng-NgmC1G\angular-errors.log" for further details.
```

Example of log file contents:
```txt
[error] Error: x
    at UpdateCommand.executeSchematic (C:\git\angular-cli\test\node_modules\@angular\cli\commands\update-impl.js:98:19)
    at UpdateCommand.executePackageMigrations (C:\git\angular-cli\test\node_modules\@angular\cli\commands\update-impl.js:167:39)
    at UpdateCommand.executeMigrations (C:\git\angular-cli\test\node_modules\@angular\cli\commands\update-impl.js:161:21)
    at UpdateCommand.run (C:\git\angular-cli\test\node_modules\@angular\cli\commands\update-impl.js:394:38)
    at async UpdateCommand.validateAndRun (C:\git\angular-cli\test\node_modules\@angular\cli\models\command.js:134:28)
    at async Object.runCommand (C:\git\angular-cli\test\node_modules\@angular\cli\models\command-runner.js:201:24)
    at async default_1 (C:\git\angular-cli\test\node_modules\@angular\cli\lib\cli\index.js:62:31)
```
2020-02-18 12:43:35 -08:00
John Papa
5f3ff00dd8 fix(@angular/cli): added clarity on angular cli version issues
fixes #16888
2020-02-10 16:01:49 -08:00
Charles
835100c908 refactor(@angular/cli): allow update version check to be disabled (#16543)
This allows the CLI version check during update bootstrapping to be disabled via the `NG_DISABLE_VERSION_CHECK` environment variable.  This is not considered an officially supported option and is intended mainly for testing/troubleshooting scenarios.
2020-01-04 11:13:53 -08:00
Charles
d9d233e39a fix(@angular/cli): inform user and error if schematics package is in unreachable location (#16466)
This is a workaround for the schematics runtime to support the requirement of packages containing migrations (or other schematics) to not have a direct/runtime dependency on the schematics package.

Closes: #16392
2019-12-20 16:34:05 -08:00
Alan Agius
35ca3901ac refactor: strip leading slash to prevent confusion 2019-12-02 10:10:34 -08:00
Alan Agius
0ee5f2fdb9 fix(@angular/cli): support running a single migration from a package 2019-11-15 10:43:07 -08:00
Doug Parker
823c6589ae fix(@angular/cli): Renames final message to "Migration completed". (#16016)
We don't actually know for certain that the migration was successful, only that it finished. This updates the messaging to be more clear about this distinction. I also removed the check mark and green coloring which implied success.
2019-11-13 11:11:14 -08:00
Alan Agius
a6f3d14c08 fix(@angular/cli): clarify ng update outdated message 2019-11-12 11:46:07 -08:00
Doug Parker
208a7008b0 fix(@angular/cli): Prints out when a commit is made in ng update.
Fixes #16060.

Any time a `git commit` is made, the CLI now prints out the hash and short message. For migrations, the message is simply the first line of the commit. For schematics, the commit message isn't all that helpful, so I used the list of packages instead.
2019-11-11 16:51:44 -08:00
Alan Agius
524bff6f43 fix(@angular/cli): add link to update guide post running Angular migrations 2019-11-09 11:52:42 -08:00
Alan Agius
bd840b2ea5 fix(@schematics/angular): improve cli migration name and description (#16093) 2019-11-07 16:41:56 -08:00
Charles Lyding
7735516949 fix(@angular/cli): disable update commit creation by default
Closes #16013
2019-11-07 11:32:52 -08:00
Charles Lyding
6f3d162e41 fix(@angular/cli): remove unneeded git HEAD update message
Closes #16031
2019-11-05 16:29:19 -08:00
Alan Agius
2d66fecee8 fix(@angular/cli): add migration name to commit header
Closes: #16030
2019-11-04 13:27:48 -08:00
Charles Lyding
98bc458480 fix(@angular/cli): pass next option to all update logic
Fixes #16015
2019-11-04 13:27:17 -08:00
Alan Agius
1c855b2365 style(@angular/cli): fix alignment of messages
Before
```
>  NGCC postinstall migration.
   Adds an ngcc invocation to npm/yarn's postinstall script.
   Read more about this here: https://v9.angular.io/guide/migration-ngcc
UPDATE package.json (1490 bytes)
√ Packages installed successfully.
√  Migration succeeded.
```

After
```

> NGCC postinstall migration.
  Adds an ngcc invocation to npm/yarn's postinstall script.
  Read more about this here: https://v9.angular.io/guide/migration-ngcc
UPDATE package.json (1490 bytes)
√ Packages installed successfully.
√ Migration succeeded.

```
2019-11-04 13:23:24 -08:00
Alan Agius
94b48d734f fix(@angular/cli): improve statues and description logs during update
With this change we improve the log messages of migration;

> the migration description
> the outcome of the migration
> we also remove the version of the migration which was misleading (Ex: 9.0.0-beta)
2019-10-30 13:38:53 -07:00
Charles Lyding
5df776780d fix(@angular-devkit/schematics): use NodeWorkflow root to resolve collections 2019-10-28 17:48:08 -07:00
Charles Lyding
dfc3b74665 fix(@angular/cli): return success in update execute migrations function 2019-10-27 12:08:53 -07:00
Charles Lyding
d4dc16fa28 fix(@angular/cli): support prerelease CLI versions when bootstrapping update 2019-10-27 12:08:53 -07:00
Alan Agius
b0dcfd08a0 fix(@angular/cli): logic to determine if the installed CLI is out of date
With this change we now check if the current CLI version is the latest published version. If it is not, we install a temporary version to run the `ng update` with.
2019-10-22 13:13:54 -07:00
Tom Sullivan
6c6ae08ec7 fix(@angular/cli): Determine relative paths correctly
As `git status --porcelain` always shows paths relative to the top
level, fetch the top level path in `checkCleanGit` and properly
determine whether any modified files are actually within the
Angular workspace root.
2019-10-17 14:14:07 -07:00
Alan Agius
cf349433ab fix(@angular/cli): ng update log messages printed twice
After the logs are printing to console clean the logs queue.

Fixes #15839
2019-10-15 11:23:16 -07:00
Charles Lyding
0abeadbc10 refactor(@angular/cli): use canonical npm logic to determine update package version 2019-09-19 14:41:04 -07:00
Charles
ace02f6c2a feat(@angular/cli): create commits per migration during update (#15611) 2019-09-17 08:35:18 -07:00
Charles Lyding
2565077dbe fix(@angular/cli): correctly account for linked packages in update
Fixes #15511
Fixes #15294
2019-09-11 10:10:48 -07:00
Charles
891fe527d7 feat(@angular/cli): update with migrate only creates commit per migration (#15414)
* feat(@angular/cli): update with migrate only creates commit per migration

* refactor(@angular/cli): simplify update command schematic execution
2019-08-26 11:48:43 -07:00
Charles Lyding
b630317b4b refactor(@angular/cli): convert workspace access to async
This is in preparation for conversion from the experimental workspace API to the stable workspace API.
2019-08-16 09:32:04 -07:00
Alan
3d1d225dd2 fix(@angular/cli): add verbose option to update and add
At the moment there is no way to turn on the verbose logging for `ng update` and `ng add`. This is useful for use so that when users report issues such as npmrc is not read we can see the lookup locations.

This also removes some reduncant that were being provided in `executeSchematic`.

Related to https://github.com/angular/angular-cli/issues/14993
2019-07-10 04:15:05 +08:00
Charles Lyding
dea6bb317b fix(@angular/cli): only enable CLI 1.x update handling when no new config
Fixes #14703
2019-06-11 14:23:04 -07:00
Charles Lyding
09149fe5e4 fix(@angular/cli): allow update when git is unclean outside the workspace 2019-06-11 09:53:56 -07:00