Skip to content

Commit

Permalink
Update Package.swift on plugin add/remove
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile committed Apr 27, 2024
1 parent 7ae36ee commit 4e432e8
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions lib/Api.js
Expand Up @@ -279,6 +279,11 @@ class Api {
return this.addPodSpecs(plugin, podSpecs, installOptions);
}
})
.then(()=>{

Check failure on line 282 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on ubuntu-latest

Missing space before =>

Check failure on line 282 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on ubuntu-latest

Missing space after =>

Check failure on line 282 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on ubuntu-latest

Missing space before =>

Check failure on line 282 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on ubuntu-latest

Missing space after =>

Check failure on line 282 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on macos-14

Missing space before =>

Check failure on line 282 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on macos-14

Missing space after =>

Check failure on line 282 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on macos-14

Missing space before =>

Check failure on line 282 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on macos-14

Missing space after =>

Check failure on line 282 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 16.x on macos-14

Missing space before =>

Check failure on line 282 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 16.x on macos-14

Missing space after =>

Check failure on line 282 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on ubuntu-latest

Missing space before =>

Check failure on line 282 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on ubuntu-latest

Missing space after =>

Check failure on line 282 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on ubuntu-latest

Missing space before =>

Check failure on line 282 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on ubuntu-latest

Missing space after =>

Check failure on line 282 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 16.x on ubuntu-latest

Missing space before =>

Check failure on line 282 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 16.x on ubuntu-latest

Missing space after =>

Check failure on line 282 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on macos-14

Missing space before =>

Check failure on line 282 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on macos-14

Missing space after =>

Check failure on line 282 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 16.x on macos-14

Missing space before =>

Check failure on line 282 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 16.x on macos-14

Missing space after =>

Check failure on line 282 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on macos-14

Missing space before =>

Check failure on line 282 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on macos-14

Missing space after =>
if (plugin != null && fs.existsSync(path.join(plugin.dir, 'Package.swift'))) {
return this.updatePackageSwift(plugin, "add");

Check failure on line 284 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on ubuntu-latest

Strings must use singlequote

Check failure on line 284 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on ubuntu-latest

Strings must use singlequote

Check failure on line 284 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on macos-14

Strings must use singlequote

Check failure on line 284 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on macos-14

Strings must use singlequote

Check failure on line 284 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 16.x on macos-14

Strings must use singlequote

Check failure on line 284 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on ubuntu-latest

Strings must use singlequote

Check failure on line 284 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on ubuntu-latest

Strings must use singlequote

Check failure on line 284 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 16.x on ubuntu-latest

Strings must use singlequote

Check failure on line 284 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on macos-14

Strings must use singlequote

Check failure on line 284 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 16.x on macos-14

Strings must use singlequote

Check failure on line 284 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on macos-14

Strings must use singlequote
}
})
// CB-11022 Return truthy value to prevent running prepare after
.then(() => true);
}
Expand Down Expand Up @@ -325,6 +330,11 @@ class Api {
return this.removePodSpecs(plugin, podSpecs, uninstallOptions);
}
})
.then(()=>{

Check failure on line 333 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on ubuntu-latest

Missing space before =>

Check failure on line 333 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on ubuntu-latest

Missing space after =>

Check failure on line 333 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on ubuntu-latest

Missing space before =>

Check failure on line 333 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on ubuntu-latest

Missing space after =>

Check failure on line 333 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on macos-14

Missing space before =>

Check failure on line 333 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on macos-14

Missing space after =>

Check failure on line 333 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on macos-14

Missing space before =>

Check failure on line 333 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on macos-14

Missing space after =>

Check failure on line 333 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 16.x on macos-14

Missing space before =>

Check failure on line 333 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 16.x on macos-14

Missing space after =>

Check failure on line 333 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on ubuntu-latest

Missing space before =>

Check failure on line 333 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on ubuntu-latest

Missing space after =>

Check failure on line 333 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on ubuntu-latest

Missing space before =>

Check failure on line 333 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on ubuntu-latest

Missing space after =>

Check failure on line 333 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 16.x on ubuntu-latest

Missing space before =>

Check failure on line 333 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 16.x on ubuntu-latest

Missing space after =>

Check failure on line 333 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on macos-14

Missing space before =>

Check failure on line 333 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on macos-14

Missing space after =>

Check failure on line 333 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 16.x on macos-14

Missing space before =>

Check failure on line 333 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 16.x on macos-14

Missing space after =>

Check failure on line 333 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on macos-14

Missing space before =>

Check failure on line 333 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on macos-14

Missing space after =>
if (plugin != null && fs.existsSync(path.join(plugin.dir, 'Package.swift'))) {
return this.updatePackageSwift(plugin, "remove");

Check failure on line 335 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on ubuntu-latest

Strings must use singlequote

Check failure on line 335 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on ubuntu-latest

Strings must use singlequote

Check failure on line 335 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on macos-14

Strings must use singlequote

Check failure on line 335 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on macos-14

Strings must use singlequote

Check failure on line 335 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 16.x on macos-14

Strings must use singlequote

Check failure on line 335 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on ubuntu-latest

Strings must use singlequote

Check failure on line 335 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on ubuntu-latest

Strings must use singlequote

Check failure on line 335 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 16.x on ubuntu-latest

Strings must use singlequote

Check failure on line 335 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on macos-14

Strings must use singlequote

Check failure on line 335 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 16.x on macos-14

Strings must use singlequote

Check failure on line 335 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on macos-14

Strings must use singlequote
}
})
// CB-11022 Return truthy value to prevent running prepare after
.then(() => true);
}
Expand Down Expand Up @@ -512,6 +522,28 @@ class Api {
return Promise.resolve();
}

/**
* Updates the Package.swift file to add or remove plugin dependencies
* @param {PluginInfo} plugin plugin to edit the Package.swift with
* @param {String} mode Add or remove plugin
*/
updatePackageSwift(plugin, mode) {

Check failure on line 530 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on ubuntu-latest

Missing space before function parentheses

Check failure on line 530 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on ubuntu-latest

Missing space before function parentheses

Check failure on line 530 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on macos-14

Missing space before function parentheses

Check failure on line 530 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on macos-14

Missing space before function parentheses

Check failure on line 530 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 16.x on macos-14

Missing space before function parentheses

Check failure on line 530 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on ubuntu-latest

Missing space before function parentheses

Check failure on line 530 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on ubuntu-latest

Missing space before function parentheses

Check failure on line 530 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 16.x on ubuntu-latest

Missing space before function parentheses

Check failure on line 530 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on macos-14

Missing space before function parentheses

Check failure on line 530 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 16.x on macos-14

Missing space before function parentheses

Check failure on line 530 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on macos-14

Missing space before function parentheses
const project_dir = this.locations.root;
const pluginDep = `
package.dependencies.append(.package(name: "${plugin.id}", path: "../../../plugins/${plugin.id}"))
package.targets.first?.dependencies.append(.product(name: "${plugin.id}", package: "${plugin.id}"))
`;
const packagePath = path.join(project_dir, 'CordovaPluginsSPM', 'Package.swift');
let packageContent = fs.readFileSync(packagePath, 'utf8');
if (mode === "add") {

Check failure on line 538 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on ubuntu-latest

Strings must use singlequote

Check failure on line 538 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on ubuntu-latest

Strings must use singlequote

Check failure on line 538 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on macos-14

Strings must use singlequote

Check failure on line 538 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on macos-14

Strings must use singlequote

Check failure on line 538 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 16.x on macos-14

Strings must use singlequote

Check failure on line 538 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on ubuntu-latest

Strings must use singlequote

Check failure on line 538 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on ubuntu-latest

Strings must use singlequote

Check failure on line 538 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 16.x on ubuntu-latest

Strings must use singlequote

Check failure on line 538 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 20.x on macos-14

Strings must use singlequote

Check failure on line 538 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 16.x on macos-14

Strings must use singlequote

Check failure on line 538 in lib/Api.js

View workflow job for this annotation

GitHub Actions / NodeJS 18.x on macos-14

Strings must use singlequote
packageContent = packageContent + pluginDep;
} else {
packageContent = packageContent.replace(pluginDep, '');
}
fs.writeFileSync(packagePath, packageContent);
return Promise.resolve();
}

/**
* set Swift Version for all CocoaPods libraries
*
Expand Down

0 comments on commit 4e432e8

Please sign in to comment.