packages/cli: add publish config sync to plugin:diff
This commit is contained in:
@@ -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] =
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user