Skip to content

Commit 50e990c

Browse files
committed
Revert "feat(core): add nx register (#30321)"
This reverts commit 77c1dda.
1 parent 9c95eca commit 50e990c

File tree

15 files changed

+337
-461
lines changed

15 files changed

+337
-461
lines changed

Diff for: package.json

+3-5
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,18 @@
7171
"@nuxt/kit": "^3.10.0",
7272
"@nuxt/schema": "^3.10.0",
7373
"@nx/angular": "20.5.0-rc.4",
74-
"@nx/conformance": "1.3.0-beta.7",
7574
"@nx/cypress": "20.5.0-rc.4",
7675
"@nx/devkit": "20.5.0-rc.4",
7776
"@nx/esbuild": "20.5.0-rc.4",
7877
"@nx/eslint": "20.5.0-rc.4",
7978
"@nx/eslint-plugin": "20.5.0-rc.4",
8079
"@nx/jest": "20.5.0-rc.4",
8180
"@nx/js": "20.5.0-rc.4",
82-
"@nx/key": "1.3.0-beta.7",
8381
"@nx/next": "20.5.0-rc.4",
8482
"@nx/playwright": "20.5.0-rc.4",
85-
"@nx/powerpack-conformance": "1.3.0-beta.7",
86-
"@nx/powerpack-enterprise-cloud": "1.3.0-beta.7",
87-
"@nx/powerpack-license": "1.3.0-beta.7",
83+
"@nx/powerpack-conformance": "1.2.5",
84+
"@nx/powerpack-enterprise-cloud": "1.2.5",
85+
"@nx/powerpack-license": "1.2.5",
8886
"@nx/react": "20.5.0-rc.4",
8987
"@nx/rsbuild": "20.5.0-rc.4",
9088
"@nx/rspack": "20.5.0-rc.4",

Diff for: packages/nx/.eslintrc.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,8 @@
131131
"@nx/nx-win32-arm64-msvc",
132132
"@nx/nx-freebsd-x64",
133133
"@nx/powerpack-license",
134-
"@nx/key",
135134
// Powerpack plugin conditionally available dynamically at runtime
136-
"@nx/powerpack-conformance",
137-
"@nx/conformance"
135+
"@nx/powerpack-conformance"
138136
]
139137
}
140138
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { workspaceRoot } from '../../utils/workspace-root';
2+
import { ActivatePowerpackOptions } from './command-object';
3+
import { prompt } from 'enquirer';
4+
import { execSync } from 'child_process';
5+
import { getPackageManagerCommand } from '../../utils/package-manager';
6+
7+
export async function handleActivatePowerpack(
8+
options: ActivatePowerpackOptions
9+
) {
10+
const license =
11+
options.license ??
12+
(await prompt({
13+
type: 'input',
14+
name: 'license',
15+
message: 'Enter your License Key',
16+
}));
17+
const { activatePowerpack } = await requirePowerpack();
18+
activatePowerpack(workspaceRoot, license);
19+
}
20+
21+
async function requirePowerpack(): Promise<any> {
22+
// @ts-ignore
23+
return import('@nx/powerpack-license').catch(async (e) => {
24+
if ('code' in e && e.code === 'MODULE_NOT_FOUND') {
25+
try {
26+
execSync(
27+
`${getPackageManagerCommand().addDev} @nx/powerpack-license@latest`,
28+
{
29+
windowsHide: false,
30+
}
31+
);
32+
33+
// @ts-ignore
34+
return await import('@nx/powerpack-license');
35+
} catch (e) {
36+
throw new Error(
37+
'Failed to install @nx/powerpack-license. Please install @nx/powerpack-license and try again.'
38+
);
39+
}
40+
}
41+
});
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { CommandModule } from 'yargs';
2+
import { withVerbose } from '../yargs-utils/shared-options';
3+
import { handleErrors } from '../../utils/handle-errors';
4+
5+
export interface ActivatePowerpackOptions {
6+
license: string;
7+
verbose: boolean;
8+
}
9+
10+
export const yargsActivatePowerpackCommand: CommandModule<
11+
{},
12+
ActivatePowerpackOptions
13+
> = {
14+
command: 'activate-powerpack <license>',
15+
describe: false,
16+
// describe: 'Activate a Nx Powerpack license.',
17+
builder: (yargs) =>
18+
withVerbose(yargs)
19+
.parserConfiguration({
20+
'strip-dashed': true,
21+
'unknown-options-as-args': true,
22+
})
23+
.positional('license', {
24+
type: 'string',
25+
description: 'This is a License Key for Nx Powerpack.',
26+
})
27+
.example(
28+
'$0 activate-powerpack <license key>',
29+
'Activate a Nx Powerpack license'
30+
),
31+
handler: async (args) => {
32+
const exitCode = await handleErrors(args.verbose as boolean, async () => {
33+
return (await import('./activate-powerpack')).handleActivatePowerpack(
34+
args
35+
);
36+
});
37+
process.exit(exitCode);
38+
},
39+
};

Diff for: packages/nx/src/command-line/nx-commands.ts

+7-17
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as chalk from 'chalk';
22
import * as yargs from 'yargs';
33

4-
import { yargsRegisterCommand } from './register/command-object';
4+
import { yargsActivatePowerpackCommand } from './activate-powerpack/command-object';
55
import {
66
yargsAffectedBuildCommand,
77
yargsAffectedCommand,
@@ -65,7 +65,7 @@ export const commandsObject = yargs
6565
.parserConfiguration(parserConfiguration)
6666
.usage(chalk.bold('Smart Monorepos · Fast CI'))
6767
.demandCommand(1, '')
68-
.command(yargsRegisterCommand)
68+
.command(yargsActivatePowerpackCommand)
6969
.command(yargsAddCommand)
7070
.command(yargsAffectedBuildCommand)
7171
.command(yargsAffectedCommand)
@@ -121,7 +121,7 @@ function createMissingConformanceCommand(
121121
output.error({
122122
title: `${command} is not available`,
123123
bodyLines: [
124-
`In order to use the \`nx ${command}\` command you must have an active Nx key and the \`@nx/conformance\` plugin installed.`,
124+
`In order to use the \`nx ${command}\` command you must have an active Powerpack license and the \`@nx/powerpack-conformance\` plugin installed.`,
125125
'',
126126
'To learn more, visit https://nx.dev/nx-enterprise/powerpack/conformance',
127127
],
@@ -133,13 +133,7 @@ function createMissingConformanceCommand(
133133

134134
function resolveConformanceCommandObject() {
135135
try {
136-
const { yargsConformanceCommand } = (() => {
137-
try {
138-
return require('@nx/powerpack-conformance');
139-
} catch {
140-
return require('@nx/conformance');
141-
}
142-
})();
136+
const { yargsConformanceCommand } = require('@nx/powerpack-conformance');
143137
return yargsConformanceCommand;
144138
} catch {
145139
return createMissingConformanceCommand('conformance');
@@ -148,13 +142,9 @@ function resolveConformanceCommandObject() {
148142

149143
function resolveConformanceCheckCommandObject() {
150144
try {
151-
const { yargsConformanceCheckCommand } = (() => {
152-
try {
153-
return require('@nx/powerpack-conformance');
154-
} catch {
155-
return require('@nx/conformance');
156-
}
157-
})();
145+
const {
146+
yargsConformanceCheckCommand,
147+
} = require('@nx/powerpack-conformance');
158148
return yargsConformanceCheckCommand;
159149
} catch {
160150
return createMissingConformanceCommand('conformance:check');

Diff for: packages/nx/src/command-line/register/command-object.ts

-31
This file was deleted.

Diff for: packages/nx/src/command-line/register/register.ts

-28
This file was deleted.

0 commit comments

Comments
 (0)