Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@angular/cli): do not collect analytics when running in non TTY mode
Prior to this change we collected analytics when config was not present and the CLI was running in non TTY mode. (cherry picked from commit 61fab64)
- Loading branch information
1 parent
6280741
commit 22955f2
Showing
4 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
tests/legacy-cli/e2e/tests/commands/analytics/analytics-enable-disable.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import assert from 'node:assert'; | ||
import { readFile } from '../../../utils/fs'; | ||
import { ng } from '../../../utils/process'; | ||
|
||
export default async function () { | ||
await ng('analytics', 'enable'); | ||
assert.ok(JSON.parse(await readFile('angular.json')).cli.analytics); | ||
|
||
await ng('analytics', 'disable'); | ||
assert.strictEqual(JSON.parse(await readFile('angular.json')).cli.analytics, false); | ||
} |
27 changes: 27 additions & 0 deletions
27
tests/legacy-cli/e2e/tests/commands/analytics/analytics-info.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { execAndWaitForOutputToMatch } from '../../../utils/process'; | ||
import { updateJsonFile } from '../../../utils/project'; | ||
|
||
export default async function () { | ||
// Should be disabled by default. | ||
await configureTest(undefined /** analytics */); | ||
await execAndWaitForOutputToMatch('ng', ['analytics', 'info'], /Effective status: disabled/, { | ||
NG_FORCE_TTY: '0', // Disable prompts | ||
}); | ||
|
||
await configureTest('1dba0835-38a3-4957-bf34-9974e2df0df3' /** analytics */); | ||
await execAndWaitForOutputToMatch('ng', ['analytics', 'info'], /Effective status: enabled/, { | ||
NG_FORCE_TTY: '0', // Disable prompts | ||
}); | ||
|
||
await configureTest(false /** analytics */); | ||
await execAndWaitForOutputToMatch('ng', ['analytics', 'info'], /Effective status: disabled/, { | ||
NG_FORCE_TTY: '0', // Disable prompts | ||
}); | ||
} | ||
|
||
async function configureTest(analytics: false | string | undefined): Promise<void> { | ||
await updateJsonFile('angular.json', (config) => { | ||
config.cli ??= {}; | ||
config.cli.analytics = analytics; | ||
}); | ||
} |
4 changes: 2 additions & 2 deletions
4
...i/e2e/tests/misc/ask-analytics-command.ts → ...mmands/analytics/ask-analytics-command.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters