diff --git a/packages/cli/src/commands/plugin/diff/handlers.ts b/packages/cli/src/commands/plugin/diff/handlers.ts index 32079415ea..87518eab3e 100644 --- a/packages/cli/src/commands/plugin/diff/handlers.ts +++ b/packages/cli/src/commands/plugin/diff/handlers.ts @@ -54,6 +54,7 @@ class PackageJsonHandler { await this.syncField('types'); await this.syncField('files'); await this.syncScripts(); + await this.syncPublishConfig(); await this.syncDependencies('dependencies'); await this.syncDependencies('devDependencies'); } @@ -105,6 +106,33 @@ class PackageJsonHandler { } } + private async syncPublishConfig() { + const pkgPublishConf = this.pkg.publishConfig; + const targetPublishConf = this.targetPkg.publishConfig; + + // If template doesn't have a publish config we're done + if (!pkgPublishConf) { + return; + } + + // Publish config can be removed the the target, skip in that case + if (!targetPublishConf) { + return; + } + + for (const key of Object.keys(pkgPublishConf)) { + // Don't want to mess with peoples internal setup + if (!['access', 'registry'].includes(key)) { + await this.syncField( + key, + pkgPublishConf, + targetPublishConf, + 'publishConfig', + ); + } + } + } + private async syncDependencies(fieldName: string) { const pkgDeps = this.pkg[fieldName]; const targetDeps = (this.targetPkg[fieldName] = diff --git a/packages/cli/templates/default-plugin/package.json.hbs b/packages/cli/templates/default-plugin/package.json.hbs index c4a72c6b06..2cdd8fe03d 100644 --- a/packages/cli/templates/default-plugin/package.json.hbs +++ b/packages/cli/templates/default-plugin/package.json.hbs @@ -5,6 +5,9 @@ "types": "dist/index.d.ts", "license": "Apache-2.0", "private": true, + "publishConfig": { + "access": "public" + }, "scripts": { "build": "backstage-cli plugin:build", "start": "backstage-cli plugin:serve",