Skip to content

feat: add "registry" option for the deploy executor #483

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
Feb 19, 2023
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
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,14 @@ Tells the registry whether to publish the package as public or restricted. It on

If you have two-factor authentication enabled in auth-and-writes mode, you can provide a code from your authenticator.

#### `--registry`

- **optional**
- Example:
- `nx deploy --registry http://localhost:4873`

Configure npm to use any compatible registry you like, and even run your own registry.

#### `--dry-run`

- **optional**
Expand All @@ -302,7 +310,7 @@ configuration in the `workspace.json` file in the `options` attribute
of your deploy project's executor.
Just change the option to lower camel case.

A list of all available options is also available [here](https://github.com/bikecoders/ngx-deploy-npm/blob/main/src/deploy/schema.json).
A list of all available options is also available [here](https://github.com/bikecoders/ngx-deploy-npm/blob/main/packages/ngx-deploy-npm/src/executors/deploy/schema.json).

Example:

Expand Down
31 changes: 4 additions & 27 deletions packages/ngx-deploy-npm/src/executors/deploy/engine/engine.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('engine', () => {
tag: 'next',
otp: 'someValue',
buildTarget: 'production',
registry: 'http://localhost:4873',
dryRun: true,
};
const optionsArray = [
Expand All @@ -39,6 +40,8 @@ describe('engine', () => {
'someValue',
'--dry-run',
'true',
'--registry',
'http://localhost:4873',
];

await engine.run(dir, options);
Expand Down Expand Up @@ -73,32 +76,6 @@ describe('engine', () => {
]);
});

it('should overwrite the default option dry-run', async () => {
const options: DeployExecutorOptions = {
otp: 'random-text',
dryRun: true,
tag: 'random-tag',
};
const optionsArray = [
'--access',
'public',
'--tag',
options.tag,
'--otp',
options.otp,
'--dry-run',
'true',
];

await engine.run(dir, options);

expect(spawn.spawnAsync).toHaveBeenCalledWith('npm', [
'publish',
dir,
...optionsArray,
]);
});

it('should overwrite the default option access', async () => {
const options = {
tag: 'random-tag',
Expand All @@ -108,7 +85,7 @@ describe('engine', () => {
'--access',
npmAccess.restricted,
'--tag',
options.tag,
'random-tag',
];

await engine.run(dir, options);
Expand Down
2 changes: 2 additions & 0 deletions packages/ngx-deploy-npm/src/executors/deploy/engine/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ function extractOnlyNPMOptions({
tag,
otp,
dryRun,
registry,
}: DeployExecutorOptions): NpmPublishOptions {
return {
access,
tag,
otp,
dryRun,
registry,
};
}

Expand Down
4 changes: 4 additions & 0 deletions packages/ngx-deploy-npm/src/executors/deploy/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export interface DeployExecutorOptions {
* If you have two-factor authentication enabled in auth-and-writes mode then you can provide a code from your authenticator with this. If you don’t include this and you’re running from a TTY then you’ll be prompted.
*/
otp?: string | number;
/**
* Configure npm to use any compatible registry you like, and even run your own registry.
*/
registry?: string;
/**
* For testing: Run through without making any changes. Execute with --dry-run and nothing will happen.
*/
Expand Down
4 changes: 4 additions & 0 deletions packages/ngx-deploy-npm/src/executors/deploy/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
"type": ["string", "number"],
"description": "If you have two-factor authentication enabled in auth-and-writes mode then you can provide a code from your authenticator with this. If you don't include this and you're running from a TTY then you'll be prompted."
},
"registry": {
"type": "string",
"description": "Configure npm to use any compatible registry you like, and even run your own registry."
},
"dryRun": {
"type": "boolean",
"description": "For testing: Run through without making any changes. Execute with --dry-run and nothing will happen.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@ import { npmAccess } from '../../../core';
import { NpmPublishOptions } from './interfaces';

export const defaults: NpmPublishOptions = {
tag: undefined,
access: npmAccess.public,
otp: undefined,
dryRun: false,
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DeployExecutorOptions } from '../schema';

export type NpmPublishOptions = Pick<
DeployExecutorOptions,
'access' | 'tag' | 'otp' | 'dryRun'
'access' | 'tag' | 'otp' | 'dryRun' | 'registry'
>;

export interface BuildTarget {
Expand Down