-
Notifications
You must be signed in to change notification settings - Fork 903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(pluginsdk-peerdeps): Create a separate package for managing peer dependencies for plugins #8637
feat(pluginsdk-peerdeps): Create a separate package for managing peer dependencies for plugins #8637
Conversation
81c2ded
to
e639304
Compare
@@ -0,0 +1 @@ | |||
.scaffolddir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The temp directory created for the scaffolded plugin is written into a file .scaffolddir
e639304
to
eae8d81
Compare
"scripts": { | ||
"usage": "cat USAGE.txt", | ||
"stage": "npm run clean && ./sync-stage.sh", | ||
"sync": "./sync-save.js", | ||
"clean": "./clean.sh" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These package scripts are written to help maintain this package.
They make it easier to update the peerDependencies
"peerDependencies": { | ||
"@spinnaker/core": "0.0.507", | ||
"@spinnaker/pluginsdk": "0.0.21", | ||
"@uirouter/core": "6.0.4", | ||
"@uirouter/react": "1.0.2", | ||
"lodash-es": "4.17.15", | ||
"prop-types": "15.6.1", | ||
"react": "16.8.6", | ||
"react-dom": "16.8.6", | ||
"rxjs": "5.4.2", | ||
"@rollup/plugin-commonjs": "15.1.0", | ||
"@rollup/plugin-node-resolve": "9.0.0", | ||
"@rollup/plugin-typescript": "6.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the packages+versions of both regular dependencies and devDependencies, all mixed together.
"peerDevDependencies": [ | ||
"@rollup/plugin-commonjs", | ||
"@rollup/plugin-node-resolve", | ||
"@rollup/plugin-typescript", | ||
"@spinnaker/eslint-plugin", | ||
"@types/react", | ||
"@typescript-eslint/eslint-plugin", | ||
"@typescript-eslint/parser", | ||
"bufferutil", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This list disambiguates the regular vs devDependencies in the list of peer dependencies above.
#!/usr/bin/env node | ||
/* @ts-check */ | ||
/* eslint-disable no-console */ | ||
/* Synchronizes versions of all (non-dev) dependencies from Deck's root package.json */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After a plugin is scaffolded, this script copies the versions from deck's package.json
, but only for regular dependencies. This is used to keep the version of react
up to date, for example.
const versionToUse = sourcesOfTruth | ||
.map((path) => JSON.parse(fs.readFileSync(path).toString())) | ||
.reduce((packages, pkgJson) => { | ||
const { peerDependencies = {}, devDependencies = {}, dependencies = {} } = pkgJson; | ||
|
||
return { | ||
...packages, | ||
...peerDependencies, | ||
...devDependencies, | ||
...dependencies, | ||
}; | ||
}, {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a dependency is duplicated, this code prefers:
- dependencies
- devDependencies
- peerDependencies
It also allows other sources of truth besides the main Deck package.json. In the future, dependencies will be moved from Deck into @spinnaker/core
for example
|
||
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2)); | ||
|
||
console.log(`Synchronized non-dev peer peerDependencies to ${packageJsonPath} from Deck`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: print the changes
#!/usr/bin/env node | ||
/* @ts-check */ | ||
/* eslint-disable no-console */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This script synchronizes the contents of the scaffolded plugin's package.json
and re-writes the peerDependencies
and devPeerDependencies
of the @spinnaker/pluginsdk-peerdeps
package.
#!/usr/bin/env bash | ||
set -e | ||
[[ -e .scaffolddir ]] || { | ||
echo Nothing to clean... | ||
exit 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clean up the temporary directory, because why not be nice?
"peerDependencies": { | ||
"@rollup/plugin-commonjs": "15.0.0", | ||
"@rollup/plugin-node-resolve": "9.0.0", | ||
"@rollup/plugin-typescript": "6.0.0", | ||
"@spinnaker/core": "0.0.507", | ||
"@spinnaker/eslint-plugin": "1.0.7", | ||
"@types/react": "16.8.25", | ||
"@typescript-eslint/eslint-plugin": "2.26.0", | ||
"@typescript-eslint/parser": "2.26.0", | ||
"@uirouter/core": "6.0.4", | ||
"@uirouter/react": "1.0.2", | ||
"eslint": "6.8.0", | ||
"eslint-config-prettier": "6.10.1", | ||
"eslint-plugin-react-hooks": "3.0.0", | ||
"husky": "4.2.5", | ||
"lodash-es": "4.17.15", | ||
"npm-run-all": "4.1.5", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the previous peerDependencies that got moved into pluginsdk-peerdeps
// const latestPeerDepsVersion = getLatestPackageVersion(PEER_DEPS); | ||
const latestPeerDepsVersion = getLatestPackageVersion(PLUGIN_SDK); | ||
const installedPeerDepsVersion = getInstalledPackageVersion(pkgJson, PEER_DEPS); | ||
|
||
report( | ||
installedPeerDepsVersion | ||
? `This plugin uses an out of date ${PEER_DEPS}@${installedPeerDepsVersion}` | ||
: `This plugin does not have ${PEER_DEPS} installed`, | ||
installedPeerDepsVersion === latestPeerDepsVersion, | ||
{ | ||
description: `Install ${PEER_DEPS}@${latestPeerDepsVersion}`, | ||
command: `yarn add ${PEER_DEPS}@${latestPeerDepsVersion}`, | ||
}, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the check-plugin
script to ensure the plugin has the most recent versions of both @spinnaker/pluginsdk
AND @spinnaker/pluginsdk-peerdeps
87e5b14
to
34413ea
Compare
… dependencies for plugins
This functionality has been moved to pluginsdk-peerdeps
59061a4
to
87a9933
Compare
feat(pluginsdk): Add 'yarn lint' script to package.json ([30fd60d](spinnaker@30fd60d)) feat(promiselike): Add then() and finally() methods to PromiseLike interface ([5886373](spinnaker@5886373)) feat(pluginsdk-peerdeps): Create a separate package for managing peer dependencies for plugins [spinnaker#8637](spinnaker#8637) ([c0897f1](spinnaker@c0897f1)) fix(pluginsdk): Remove package.json 'module' lint rule from check-plugin [spinnaker#8635](spinnaker#8635) ([98a16ea](spinnaker@98a16ea)) feat(pluginsdk): Add cli flags to scaffold.js to allow non-interactive scaffolding [spinnaker#8636](spinnaker#8636) ([5c84d68](spinnaker@5c84d68))
feat(pluginsdk): Add 'yarn lint' script to package.json ([30fd60d](spinnaker@30fd60d)) feat(promiselike): Add then() and finally() methods to PromiseLike interface ([5886373](spinnaker@5886373)) feat(pluginsdk-peerdeps): Create a separate package for managing peer dependencies for plugins [spinnaker#8637](spinnaker#8637) ([c0897f1](spinnaker@c0897f1)) fix(pluginsdk): Remove package.json 'module' lint rule from check-plugin [spinnaker#8635](spinnaker#8635) ([98a16ea](spinnaker@98a16ea)) feat(pluginsdk): Add cli flags to scaffold.js to allow non-interactive scaffolding [spinnaker#8636](spinnaker#8636) ([5c84d68](spinnaker@5c84d68))
feat(pluginsdk): Add 'yarn lint' script to package.json ([30fd60d](spinnaker@30fd60d)) feat(promiselike): Add then() and finally() methods to PromiseLike interface ([5886373](spinnaker@5886373)) feat(pluginsdk-peerdeps): Create a separate package for managing peer dependencies for plugins [spinnaker#8637](spinnaker#8637) ([c0897f1](spinnaker@c0897f1)) fix(pluginsdk): Remove package.json 'module' lint rule from check-plugin [spinnaker#8635](spinnaker#8635) ([98a16ea](spinnaker@98a16ea)) feat(pluginsdk): Add cli flags to scaffold.js to allow non-interactive scaffolding [spinnaker#8636](spinnaker#8636) ([5c84d68](spinnaker@5c84d68))
* chore(pluginsdk): publish 0.0.22 feat(pluginsdk): Add 'yarn lint' script to package.json ([30fd60d](30fd60d)) feat(promiselike): Add then() and finally() methods to PromiseLike interface ([5886373](5886373)) feat(pluginsdk-peerdeps): Create a separate package for managing peer dependencies for plugins [#8637](#8637) ([c0897f1](c0897f1)) fix(pluginsdk): Remove package.json 'module' lint rule from check-plugin [#8635](#8635) ([98a16ea](98a16ea)) feat(pluginsdk): Add cli flags to scaffold.js to allow non-interactive scaffolding [#8636](#8636) ([5c84d68](5c84d68)) * fix(pluginsdk): Fix peer deps lint rule * chore(pluginsdk): release 0.0.23
Today, plugins depend on
@spinnaker/pluginsdk
which:peerDependencies
This PR splits #2 into a separate npm package
@spinnaker/pluginsdk-peerdeps
.Now, a plugin depends on both
@spinnaker/pluginsdk
and@spinnaker/pluginsdk-peerdeps
. This is "enforced" using theyarn check-plugin
tooling inpluginsdk
.The
peerDependencies
in@spinnaker/pluginsdk-peerdeps
are managed using its package.json scripts.@spinnaker/pluginsdk-peerdeps
package.json
.@spinnaker/pluginsdk-peerdeps
package is published to NPM.