From ffb342fae6669d8cfb0278982f25e6450272cc96 Mon Sep 17 00:00:00 2001 From: Ryan Sonshine Date: Thu, 6 May 2021 13:27:52 -0400 Subject: [PATCH 1/5] Add `PackageJson.PublishConfig` type This change adds the interface for the PackageJson.PublishConfig. Closes #204 --- source/package-json.d.ts | 20 ++++++++++++++++++-- test-d/package-json.ts | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/source/package-json.d.ts b/source/package-json.d.ts index cf355d03a..9860d6cca 100644 --- a/source/package-json.d.ts +++ b/source/package-json.d.ts @@ -571,7 +571,7 @@ declare namespace PackageJson { /** A set of config values that will be used at publish-time. It's especially handy to set the tag, registry or access, to ensure that a given package is not tagged with 'latest', published to the global public registry or that a scoped module is private by default. */ - publishConfig?: Record; + publishConfig?: PublishConfig; /** Describes and notifies consumers of a package's monetary support information. @@ -598,6 +598,21 @@ declare namespace PackageJson { url: string; }; } + + export interface PublishConfig { + /** + When publishing scoped packages, the access level defaults to restricted. If you want your scoped package to be publicly viewable (and installable) set --access=public. The only valid values for access are public and restricted. Unscoped packages always have an access level of public. + */ + access?: 'public' | 'restricted'; + /** + The base URL of the npm registry. Defaults to "https://registry.npmjs.org/" + */ + registry?: string; + /** + The tag to publish the package under. Defaults to "latest" + */ + tag?: string; + } } /** @@ -608,4 +623,5 @@ PackageJson.PackageJsonStandard & PackageJson.NonStandardEntryPoints & PackageJson.TypeScriptConfiguration & PackageJson.YarnConfiguration & -PackageJson.JSPMConfiguration; +PackageJson.JSPMConfiguration & +PackageJson.PublishConfig; diff --git a/test-d/package-json.ts b/test-d/package-json.ts index be4b5b162..3164023e2 100644 --- a/test-d/package-json.ts +++ b/test-d/package-json.ts @@ -54,7 +54,7 @@ expectAssignable< >(packageJson.cpu); expectType(packageJson.preferGlobal); expectType(packageJson.private); -expectType | undefined>(packageJson.publishConfig); +expectType(packageJson.publishConfig); expectType(packageJson.module); expectType< | string From 0910da987d98fca1d4b50a1134d9ba75e18982df Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Fri, 7 May 2021 00:35:52 +0700 Subject: [PATCH 2/5] Update package-json.d.ts --- source/package-json.d.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source/package-json.d.ts b/source/package-json.d.ts index 9860d6cca..f842e8fff 100644 --- a/source/package-json.d.ts +++ b/source/package-json.d.ts @@ -601,15 +601,21 @@ declare namespace PackageJson { export interface PublishConfig { /** - When publishing scoped packages, the access level defaults to restricted. If you want your scoped package to be publicly viewable (and installable) set --access=public. The only valid values for access are public and restricted. Unscoped packages always have an access level of public. + When publishing scoped packages, the access level defaults to restricted. If you want your scoped package to be publicly viewable (and installable) set `--access=public`. The only valid values for access are public and restricted. Unscoped packages always have an access level of public. */ access?: 'public' | 'restricted'; + /** - The base URL of the npm registry. Defaults to "https://registry.npmjs.org/" + The base URL of the npm registry. + + Default: `'https://registry.npmjs.org/'` */ registry?: string; + /** - The tag to publish the package under. Defaults to "latest" + The tag to publish the package under. + + Default: `'latest'` */ tag?: string; } From f8166b97cbd4b0f6da260ae6a525430d2ac12a8a Mon Sep 17 00:00:00 2001 From: Ryan Sonshine Date: Thu, 6 May 2021 13:58:49 -0400 Subject: [PATCH 3/5] Add support for additional props on publishConfig --- source/package-json.d.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/package-json.d.ts b/source/package-json.d.ts index f842e8fff..c0c8a0f3b 100644 --- a/source/package-json.d.ts +++ b/source/package-json.d.ts @@ -600,6 +600,11 @@ declare namespace PackageJson { } export interface PublishConfig { + /** + Additional, less common properties from the [npm docs on publishConfig](https://docs.npmjs.com/cli/v7/configuring-npm/package-json#publishconfig) + */ + [additionalProp: string]: unknown; + /** When publishing scoped packages, the access level defaults to restricted. If you want your scoped package to be publicly viewable (and installable) set `--access=public`. The only valid values for access are public and restricted. Unscoped packages always have an access level of public. */ @@ -607,14 +612,14 @@ declare namespace PackageJson { /** The base URL of the npm registry. - + Default: `'https://registry.npmjs.org/'` */ registry?: string; /** The tag to publish the package under. - + Default: `'latest'` */ tag?: string; @@ -629,5 +634,4 @@ PackageJson.PackageJsonStandard & PackageJson.NonStandardEntryPoints & PackageJson.TypeScriptConfiguration & PackageJson.YarnConfiguration & -PackageJson.JSPMConfiguration & -PackageJson.PublishConfig; +PackageJson.JSPMConfiguration; From eb15693ff9cb85bd572e949dab9c75e4eea87c41 Mon Sep 17 00:00:00 2001 From: Ryan Sonshine Date: Thu, 6 May 2021 14:00:12 -0400 Subject: [PATCH 4/5] Add missing period --- source/package-json.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/package-json.d.ts b/source/package-json.d.ts index c0c8a0f3b..6b3019e34 100644 --- a/source/package-json.d.ts +++ b/source/package-json.d.ts @@ -601,7 +601,7 @@ declare namespace PackageJson { export interface PublishConfig { /** - Additional, less common properties from the [npm docs on publishConfig](https://docs.npmjs.com/cli/v7/configuring-npm/package-json#publishconfig) + Additional, less common properties from the [npm docs on publishConfig](https://docs.npmjs.com/cli/v7/configuring-npm/package-json#publishconfig). */ [additionalProp: string]: unknown; From 37aa4476cc5f681dbf1a332052b3eb3d52c88987 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Fri, 7 May 2021 01:04:40 +0700 Subject: [PATCH 5/5] Update package-json.d.ts --- source/package-json.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/package-json.d.ts b/source/package-json.d.ts index 6b3019e34..ea0ad37e3 100644 --- a/source/package-json.d.ts +++ b/source/package-json.d.ts @@ -601,9 +601,9 @@ declare namespace PackageJson { export interface PublishConfig { /** - Additional, less common properties from the [npm docs on publishConfig](https://docs.npmjs.com/cli/v7/configuring-npm/package-json#publishconfig). + Additional, less common properties from the [npm docs on `publishConfig`](https://docs.npmjs.com/cli/v7/configuring-npm/package-json#publishconfig). */ - [additionalProp: string]: unknown; + [additionalProperties: string]: unknown; /** When publishing scoped packages, the access level defaults to restricted. If you want your scoped package to be publicly viewable (and installable) set `--access=public`. The only valid values for access are public and restricted. Unscoped packages always have an access level of public.