Skip to content

Commit de8bb70

Browse files
feat: add "registry" option for the deploy executor (#483)
--------- Co-authored-by: dianjuar <[email protected]>
1 parent 313efdb commit de8bb70

File tree

7 files changed

+24
-32
lines changed

7 files changed

+24
-32
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,14 @@ Tells the registry whether to publish the package as public or restricted. It on
276276

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

279+
#### `--registry`
280+
281+
- **optional**
282+
- Example:
283+
- `nx deploy --registry http://localhost:4873`
284+
285+
Configure npm to use any compatible registry you like, and even run your own registry.
286+
279287
#### `--dry-run`
280288

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

305-
A list of all available options is also available [here](https://github.com/bikecoders/ngx-deploy-npm/blob/main/src/deploy/schema.json).
313+
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).
306314

307315
Example:
308316

packages/ngx-deploy-npm/src/executors/deploy/engine/engine.spec.ts

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ describe('engine', () => {
2828
tag: 'next',
2929
otp: 'someValue',
3030
buildTarget: 'production',
31+
registry: 'http://localhost:4873',
3132
dryRun: true,
3233
};
3334
const optionsArray = [
@@ -39,6 +40,8 @@ describe('engine', () => {
3940
'someValue',
4041
'--dry-run',
4142
'true',
43+
'--registry',
44+
'http://localhost:4873',
4245
];
4346

4447
await engine.run(dir, options);
@@ -73,32 +76,6 @@ describe('engine', () => {
7376
]);
7477
});
7578

76-
it('should overwrite the default option dry-run', async () => {
77-
const options: DeployExecutorOptions = {
78-
otp: 'random-text',
79-
dryRun: true,
80-
tag: 'random-tag',
81-
};
82-
const optionsArray = [
83-
'--access',
84-
'public',
85-
'--tag',
86-
options.tag,
87-
'--otp',
88-
options.otp,
89-
'--dry-run',
90-
'true',
91-
];
92-
93-
await engine.run(dir, options);
94-
95-
expect(spawn.spawnAsync).toHaveBeenCalledWith('npm', [
96-
'publish',
97-
dir,
98-
...optionsArray,
99-
]);
100-
});
101-
10279
it('should overwrite the default option access', async () => {
10380
const options = {
10481
tag: 'random-tag',
@@ -108,7 +85,7 @@ describe('engine', () => {
10885
'--access',
10986
npmAccess.restricted,
11087
'--tag',
111-
options.tag,
88+
'random-tag',
11289
];
11390

11491
await engine.run(dir, options);

packages/ngx-deploy-npm/src/executors/deploy/engine/engine.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ function extractOnlyNPMOptions({
5757
tag,
5858
otp,
5959
dryRun,
60+
registry,
6061
}: DeployExecutorOptions): NpmPublishOptions {
6162
return {
6263
access,
6364
tag,
6465
otp,
6566
dryRun,
67+
registry,
6668
};
6769
}
6870

packages/ngx-deploy-npm/src/executors/deploy/schema.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ export interface DeployExecutorOptions {
2727
* 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.
2828
*/
2929
otp?: string | number;
30+
/**
31+
* Configure npm to use any compatible registry you like, and even run your own registry.
32+
*/
33+
registry?: string;
3034
/**
3135
* For testing: Run through without making any changes. Execute with --dry-run and nothing will happen.
3236
*/

packages/ngx-deploy-npm/src/executors/deploy/schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
"type": ["string", "number"],
3939
"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."
4040
},
41+
"registry": {
42+
"type": "string",
43+
"description": "Configure npm to use any compatible registry you like, and even run your own registry."
44+
},
4145
"dryRun": {
4246
"type": "boolean",
4347
"description": "For testing: Run through without making any changes. Execute with --dry-run and nothing will happen.",

packages/ngx-deploy-npm/src/executors/deploy/utils/default-options.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,5 @@ import { npmAccess } from '../../../core';
22
import { NpmPublishOptions } from './interfaces';
33

44
export const defaults: NpmPublishOptions = {
5-
tag: undefined,
65
access: npmAccess.public,
7-
otp: undefined,
8-
dryRun: false,
96
};

packages/ngx-deploy-npm/src/executors/deploy/utils/interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { DeployExecutorOptions } from '../schema';
22

33
export type NpmPublishOptions = Pick<
44
DeployExecutorOptions,
5-
'access' | 'tag' | 'otp' | 'dryRun'
5+
'access' | 'tag' | 'otp' | 'dryRun' | 'registry'
66
>;
77

88
export interface BuildTarget {

0 commit comments

Comments
 (0)