Skip to content

ng version updates #27670

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 2 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/angular/cli/src/command-builder/command-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ export abstract class CommandModule<T extends {} = {}> implements CommandModuleI

const userId = await getAnalyticsUserId(
this.context,
// Don't prompt for `ng update` and `ng analytics` commands.
['update', 'analytics'].includes(this.commandName),
// Don't prompt on `ng update`, 'ng version' or `ng analytics`.
['version', 'update', 'analytics'].includes(this.commandName),
);

return userId ? new AnalyticsCollector(this.context, userId) : undefined;
Expand Down
3 changes: 2 additions & 1 deletion packages/angular/cli/src/command-builder/command-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { colors } from '../utilities/color';
import { AngularWorkspace, getWorkspace } from '../utilities/config';
import { assertIsError } from '../utilities/error';
import { PackageManagerUtils } from '../utilities/package-manager';
import { VERSION } from '../utilities/version';
import { CommandContext, CommandModuleError } from './command-module';
import {
CommandModuleConstructor,
Expand Down Expand Up @@ -122,7 +123,7 @@ export async function runCommand(args: string[], logger: logging.Logger): Promis
.demandCommand(1, demandCommandFailureMessage)
.recommendCommands()
.middleware(normalizeOptionsMiddleware)
.version(false)
.version('version', 'Show Angular CLI version.', VERSION.full)
.showHelpOnFail(false)
.strict()
.fail((msg, err) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/cli/src/utilities/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ async function shouldPromptForAutocompletionSetup(
return forceAutocomplete;
}

// Don't prompt on `ng update` or `ng completion`.
if (command === 'update' || command === 'completion') {
// Don't prompt on `ng update`, 'ng version' or `ng completion`.
if (['version', 'update', 'completion'].includes(command)) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default async function () {
await mockHome(async () => {
const { stdout } = await execWithEnv(
'ng',
['version'],
['config'],
{
...process.env,
NG_FORCE_TTY: '1',
Expand All @@ -24,7 +24,7 @@ export default async function () {

// CLI should skip analytics prompt with `NG_CLI_ANALYTICS=false`.
await mockHome(async () => {
const { stdout } = await execWithEnv('ng', ['version'], {
const { stdout } = await execWithEnv('ng', ['config'], {
...process.env,
NG_FORCE_TTY: '1',
NG_CLI_ANALYTICS: 'false',
Expand Down
34 changes: 17 additions & 17 deletions tests/legacy-cli/e2e/tests/commands/completion/completion-prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default async function () {

const { stdout } = await execWithEnv(
'ng',
['version'],
['config'],
{
...DEFAULT_ENV,
SHELL: '/bin/bash',
Expand Down Expand Up @@ -74,7 +74,7 @@ export default async function () {

const { stdout } = await execWithEnv(
'ng',
['version'],
['config'],
{
...DEFAULT_ENV,
SHELL: '/bin/bash',
Expand Down Expand Up @@ -112,7 +112,7 @@ export default async function () {

const { stdout: stdout1 } = await execWithEnv(
'ng',
['version'],
['config'],
{
...DEFAULT_ENV,
SHELL: '/bin/bash',
Expand All @@ -136,7 +136,7 @@ export default async function () {
// User modifies their configuration and removes `ng completion`.
await fs.writeFile(bashrc, '# Some new commands...');

const { stdout: stdout2 } = await execWithEnv('ng', ['version'], {
const { stdout: stdout2 } = await execWithEnv('ng', ['config'], {
...DEFAULT_ENV,
SHELL: '/bin/bash',
HOME: home,
Expand Down Expand Up @@ -165,7 +165,7 @@ export default async function () {

const { stdout: stdout1 } = await execWithEnv(
'ng',
['version'],
['config'],
{
...DEFAULT_ENV,
SHELL: '/bin/bash',
Expand All @@ -178,7 +178,7 @@ export default async function () {
throw new Error('First execution did not prompt for autocompletion setup.');
}

const { stdout: stdout2 } = await execWithEnv('ng', ['version'], {
const { stdout: stdout2 } = await execWithEnv('ng', ['config'], {
...DEFAULT_ENV,
SHELL: '/bin/bash',
HOME: home,
Expand Down Expand Up @@ -211,7 +211,7 @@ export default async function () {

const err = await execAndCaptureError(
'ng',
['version'],
['config'],
{
...DEFAULT_ENV,
SHELL: '/bin/bash',
Expand All @@ -231,7 +231,7 @@ export default async function () {

const { stdout: stdout2 } = await execWithEnv(
'ng',
['version'],
['config'],
{
...DEFAULT_ENV,
SHELL: '/bin/bash',
Expand Down Expand Up @@ -283,7 +283,7 @@ export default async function () {

// Does *not* prompt user for CI executions.
{
const { stdout } = await execWithEnv('ng', ['version'], {
const { stdout } = await execWithEnv('ng', ['config'], {
...DEFAULT_ENV,
CI: 'true',
NG_FORCE_TTY: undefined,
Expand All @@ -296,7 +296,7 @@ export default async function () {

// Does *not* prompt user for non-TTY executions.
{
const { stdout } = await execWithEnv('ng', ['version'], {
const { stdout } = await execWithEnv('ng', ['config'], {
...DEFAULT_ENV,
NG_FORCE_TTY: 'false',
});
Expand All @@ -308,7 +308,7 @@ export default async function () {

// Does *not* prompt user for executions without a `$HOME`.
{
const { stdout } = await execWithEnv('ng', ['version'], {
const { stdout } = await execWithEnv('ng', ['config'], {
...DEFAULT_ENV,
HOME: undefined,
});
Expand All @@ -323,7 +323,7 @@ export default async function () {

// Does *not* prompt user for executions without a `$SHELL`.
{
const { stdout } = await execWithEnv('ng', ['version'], {
const { stdout } = await execWithEnv('ng', ['config'], {
...DEFAULT_ENV,
SHELL: undefined,
});
Expand All @@ -338,7 +338,7 @@ export default async function () {

// Does *not* prompt user for executions from unknown shells.
{
const { stdout } = await execWithEnv('ng', ['version'], {
const { stdout } = await execWithEnv('ng', ['config'], {
...DEFAULT_ENV,
SHELL: '/usr/bin/unknown',
});
Expand All @@ -364,7 +364,7 @@ source <(ng completion script)
`.trim(),
);

const { stdout } = await execWithEnv('ng', ['version'], {
const { stdout } = await execWithEnv('ng', ['config'], {
...DEFAULT_ENV,
SHELL: '/bin/bash',
HOME: home,
Expand All @@ -383,7 +383,7 @@ source <(ng completion script)
const bashrc = path.join(home, '.bashrc');
await fs.writeFile(bashrc, `# Other content...`);

await execAndWaitForOutputToMatch('ng', ['version'], AUTOCOMPLETION_PROMPT, {
await execAndWaitForOutputToMatch('ng', ['config'], AUTOCOMPLETION_PROMPT, {
...DEFAULT_ENV,
SHELL: '/bin/bash',
HOME: home,
Expand Down Expand Up @@ -411,7 +411,7 @@ source <(ng completion script)
const localCliBinary = path.join(localCliDir, 'ng');
const pathDirs = process.env['PATH']!.split(':');
const pathEnvVar = [...pathDirs, localCliDir].join(':');
const { stdout } = await execWithEnv(localCliBinary, ['version'], {
const { stdout } = await execWithEnv(localCliBinary, ['config'], {
...DEFAULT_ENV,
SHELL: '/bin/bash',
HOME: home,
Expand All @@ -437,7 +437,7 @@ async function windowsTests(): Promise<void> {
const bashrc = path.join(home, '.bashrc');
await fs.writeFile(bashrc, `# Other content...`);

const { stdout } = await execWithEnv('ng', ['version'], { ...env });
const { stdout } = await execWithEnv('ng', ['config'], { ...env });

if (AUTOCOMPLETION_PROMPT.test(stdout)) {
throw new Error(
Expand Down
5 changes: 5 additions & 0 deletions tests/legacy-cli/e2e/tests/commands/help/help-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export default async function () {
'description': 'If provided, a new value for the given configuration key.',
'positional': 1,
},
{
'name': 'version',
'type': 'boolean',
'description': 'Show Angular CLI version.',
},
],
});

Expand Down