-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add integration with nx powerpack (#27972)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> There is no Nx Powerpack product. ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> Integration with Nx Powerpack is added. Nx Powerpack is optional, stay tuned for more information which will be released soon. ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes # --------- Co-authored-by: Craigory Coppola <[email protected]> Co-authored-by: JamesHenry <[email protected]>
- Loading branch information
1 parent
fb91ed5
commit b06f515
Showing
24 changed files
with
454 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
title: 'activate-powerpack - CLI command' | ||
description: 'Activate a Nx Powerpack license.' | ||
--- | ||
|
||
# activate-powerpack | ||
|
||
Activate a Nx Powerpack license. | ||
|
||
## Usage | ||
|
||
```shell | ||
nx activate-powerpack <license> | ||
``` | ||
|
||
Install `nx` globally to invoke the command directly using `nx`, or use `npx nx`, `yarn nx`, or `pnpm nx`. | ||
|
||
## Options | ||
|
||
| Option | Type | Description | | ||
| ----------- | ------- | ---------------------------------------------------------------------- | | ||
| `--help` | boolean | Show help. | | ||
| `--license` | string | This is a License Key for Nx Powerpack. | | ||
| `--verbose` | boolean | Prints additional information about the commands (e.g., stack traces). | | ||
| `--version` | boolean | Show version number. | |
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
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
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
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
25 changes: 25 additions & 0 deletions
25
docs/generated/packages/nx/documents/activate-powerpack.md
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,25 @@ | ||
--- | ||
title: 'activate-powerpack - CLI command' | ||
description: 'Activate a Nx Powerpack license.' | ||
--- | ||
|
||
# activate-powerpack | ||
|
||
Activate a Nx Powerpack license. | ||
|
||
## Usage | ||
|
||
```shell | ||
nx activate-powerpack <license> | ||
``` | ||
|
||
Install `nx` globally to invoke the command directly using `nx`, or use `npx nx`, `yarn nx`, or `pnpm nx`. | ||
|
||
## Options | ||
|
||
| Option | Type | Description | | ||
| ----------- | ------- | ---------------------------------------------------------------------- | | ||
| `--help` | boolean | Show help. | | ||
| `--license` | string | This is a License Key for Nx Powerpack. | | ||
| `--verbose` | boolean | Prints additional information about the commands (e.g., stack traces). | | ||
| `--version` | boolean | Show version number. | |
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
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
39 changes: 39 additions & 0 deletions
39
packages/nx/src/command-line/activate-powerpack/activate-powerpack.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,39 @@ | ||
import { workspaceRoot } from '../../utils/workspace-root'; | ||
import { ActivatePowerpackOptions } from './command-object'; | ||
import { prompt } from 'enquirer'; | ||
import { execSync } from 'child_process'; | ||
import { getPackageManagerCommand } from '../../utils/package-manager'; | ||
|
||
export async function handleActivatePowerpack( | ||
options: ActivatePowerpackOptions | ||
) { | ||
const license = | ||
options.license ?? | ||
(await prompt({ | ||
type: 'input', | ||
name: 'license', | ||
message: 'Enter your License Key', | ||
})); | ||
const { activatePowerpack } = await requirePowerpack(); | ||
activatePowerpack(workspaceRoot, license); | ||
} | ||
|
||
async function requirePowerpack(): Promise<any> { | ||
// @ts-ignore | ||
return import('@nx/powerpack-license').catch(async (e) => { | ||
if ('code' in e && e.code === 'MODULE_NOT_FOUND') { | ||
try { | ||
execSync( | ||
`${getPackageManagerCommand().addDev} @nx/powerpack-license@latest` | ||
); | ||
|
||
// @ts-ignore | ||
return await import('@nx/powerpack-license'); | ||
} catch (e) { | ||
throw new Error( | ||
'Failed to install @nx/powerpack-license. Please install @nx/powerpack-license and try again.' | ||
); | ||
} | ||
} | ||
}); | ||
} |
38 changes: 38 additions & 0 deletions
38
packages/nx/src/command-line/activate-powerpack/command-object.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,38 @@ | ||
import { CommandModule } from 'yargs'; | ||
import { withVerbose } from '../yargs-utils/shared-options'; | ||
import { handleErrors } from '../../utils/handle-errors'; | ||
|
||
export interface ActivatePowerpackOptions { | ||
license: string; | ||
verbose: boolean; | ||
} | ||
|
||
export const yargsActivatePowerpackCommand: CommandModule< | ||
{}, | ||
ActivatePowerpackOptions | ||
> = { | ||
command: 'activate-powerpack <license>', | ||
describe: 'Activate a Nx Powerpack license.', | ||
builder: (yargs) => | ||
withVerbose(yargs) | ||
.parserConfiguration({ | ||
'strip-dashed': true, | ||
'unknown-options-as-args': true, | ||
}) | ||
.positional('license', { | ||
type: 'string', | ||
description: 'This is a License Key for Nx Powerpack.', | ||
}) | ||
.example( | ||
'$0 activate-powerpack <license key>', | ||
'Activate a Nx Powerpack license' | ||
), | ||
handler: async (args) => { | ||
const exitCode = await handleErrors(args.verbose as boolean, async () => { | ||
return (await import('./activate-powerpack')).handleActivatePowerpack( | ||
args | ||
); | ||
}); | ||
process.exit(exitCode); | ||
}, | ||
}; |
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
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
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
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
Oops, something went wrong.