diff --git a/README.md b/README.md index 5383ee45..0dacef2b 100644 --- a/README.md +++ b/README.md @@ -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** @@ -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: diff --git a/packages/ngx-deploy-npm/src/executors/deploy/engine/engine.spec.ts b/packages/ngx-deploy-npm/src/executors/deploy/engine/engine.spec.ts index 780c13c4..20464563 100644 --- a/packages/ngx-deploy-npm/src/executors/deploy/engine/engine.spec.ts +++ b/packages/ngx-deploy-npm/src/executors/deploy/engine/engine.spec.ts @@ -28,6 +28,7 @@ describe('engine', () => { tag: 'next', otp: 'someValue', buildTarget: 'production', + registry: 'http://localhost:4873', dryRun: true, }; const optionsArray = [ @@ -39,6 +40,8 @@ describe('engine', () => { 'someValue', '--dry-run', 'true', + '--registry', + 'http://localhost:4873', ]; await engine.run(dir, options); @@ -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', @@ -108,7 +85,7 @@ describe('engine', () => { '--access', npmAccess.restricted, '--tag', - options.tag, + 'random-tag', ]; await engine.run(dir, options); diff --git a/packages/ngx-deploy-npm/src/executors/deploy/engine/engine.ts b/packages/ngx-deploy-npm/src/executors/deploy/engine/engine.ts index 13416ee2..e0e3eb8e 100644 --- a/packages/ngx-deploy-npm/src/executors/deploy/engine/engine.ts +++ b/packages/ngx-deploy-npm/src/executors/deploy/engine/engine.ts @@ -57,12 +57,14 @@ function extractOnlyNPMOptions({ tag, otp, dryRun, + registry, }: DeployExecutorOptions): NpmPublishOptions { return { access, tag, otp, dryRun, + registry, }; } diff --git a/packages/ngx-deploy-npm/src/executors/deploy/schema.d.ts b/packages/ngx-deploy-npm/src/executors/deploy/schema.d.ts index dc4b0cf0..97889f9d 100644 --- a/packages/ngx-deploy-npm/src/executors/deploy/schema.d.ts +++ b/packages/ngx-deploy-npm/src/executors/deploy/schema.d.ts @@ -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. */ diff --git a/packages/ngx-deploy-npm/src/executors/deploy/schema.json b/packages/ngx-deploy-npm/src/executors/deploy/schema.json index 6c65b721..47d055a5 100644 --- a/packages/ngx-deploy-npm/src/executors/deploy/schema.json +++ b/packages/ngx-deploy-npm/src/executors/deploy/schema.json @@ -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.", diff --git a/packages/ngx-deploy-npm/src/executors/deploy/utils/default-options.ts b/packages/ngx-deploy-npm/src/executors/deploy/utils/default-options.ts index 3f247211..2a2ee5be 100644 --- a/packages/ngx-deploy-npm/src/executors/deploy/utils/default-options.ts +++ b/packages/ngx-deploy-npm/src/executors/deploy/utils/default-options.ts @@ -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, }; diff --git a/packages/ngx-deploy-npm/src/executors/deploy/utils/interfaces.ts b/packages/ngx-deploy-npm/src/executors/deploy/utils/interfaces.ts index b4761fe6..573d1d29 100644 --- a/packages/ngx-deploy-npm/src/executors/deploy/utils/interfaces.ts +++ b/packages/ngx-deploy-npm/src/executors/deploy/utils/interfaces.ts @@ -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 {