Skip to content

Commit efc3c32

Browse files
committed
fix(@angular/cli): remove analytics prompt postinstall script
With this change we remove the postinstall hook that was used to prompt users to confirm if they'd like to share anonymous usage with the Angular team. This post install hook was used to set the global configuration, which was mainly used for commands that run outside of a workspace such as `ng new`, `ng version` and ng `config`. We now prompt once the users runs the above mentioned commands instead of the post install.
1 parent 65dc6f6 commit efc3c32

File tree

5 files changed

+12
-90
lines changed

5 files changed

+12
-90
lines changed

packages/angular/cli/bin/postinstall/analytics-prompt.js

-27
This file was deleted.

packages/angular/cli/bin/postinstall/script.js

-16
This file was deleted.

packages/angular/cli/package.json

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
"angular-cli",
1212
"Angular CLI"
1313
],
14-
"scripts": {
15-
"postinstall": "node ./bin/postinstall/script.js"
16-
},
1714
"repository": {
1815
"type": "git",
1916
"url": "https://github.com/angular/angular-cli.git"

packages/angular/cli/src/analytics/analytics.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -250,26 +250,26 @@ export async function createAnalytics(
250250
}
251251

252252
let config = globalConfig;
253-
// Not disabled globally, check locally.
254-
if (workspace) {
255-
let localConfig = await getAnalytics('local');
256-
if (localConfig === undefined) {
253+
// Not disabled globally, check locally or not set globally and command is run outside of workspace example: `ng new`
254+
if (workspace || globalConfig === undefined) {
255+
const level = workspace ? 'local' : 'global';
256+
let localOrGlobalConfig = await getAnalytics(level);
257+
if (localOrGlobalConfig === undefined) {
257258
if (!skipPrompt) {
258-
// local is not unset, prompt user.
259-
259+
// config is unset, prompt user.
260260
// TODO: This should honor the `no-interactive` option.
261261
// It is currently not an `ng` option but rather only an option for specific commands.
262262
// The concept of `ng`-wide options are needed to cleanly handle this.
263-
await promptAnalytics(false);
264-
localConfig = await getAnalytics('local');
263+
await promptAnalytics(!workspace /** global */);
264+
localOrGlobalConfig = await getAnalytics(level);
265265
}
266266
}
267267

268-
if (localConfig instanceof analytics.NoopAnalytics) {
269-
return localConfig;
270-
} else if (localConfig) {
268+
if (localOrGlobalConfig instanceof analytics.NoopAnalytics) {
269+
return localOrGlobalConfig;
270+
} else if (localOrGlobalConfig) {
271271
// Favor local settings over global when defined.
272-
config = localConfig;
272+
config = localOrGlobalConfig;
273273
}
274274
}
275275

tests/legacy-cli/e2e/tests/misc/ask-analytics-install.ts

-32
This file was deleted.

0 commit comments

Comments
 (0)