packages/cli: add publish config sync to plugin:diff

This commit is contained in:
Patrik Oldsberg
2020-05-14 11:51:45 +02:00
parent 579ba54480
commit 75395ecff1
2 changed files with 31 additions and 0 deletions
@@ -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",