-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Update dependencies to enable Greenkeeper 🌴 #2323
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
cb05062
chore: add required config for greenkeeper integration
raymondfeng ba4a12a
chore: update dependencies proposed by greenkeeper
raymondfeng 1593116
chore: whitelist greenkeeper branches
raymondfeng a0a374a
chore: add Greenkeeper badge
raymondfeng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,4 @@ matrix: | |
branches: | ||
only: | ||
- master | ||
- /^greenkeeper/.*$/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#!/usr/bin/env node | ||
// Copyright IBM Corp. 2018. All Rights Reserved. | ||
// Node module: loopback-next | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
/** | ||
* This is an internal script to update `greenkeeper.json` with lerna packages. | ||
*/ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
const Project = require('@lerna/project'); | ||
|
||
async function updateGreenKeeperJson() { | ||
const project = new Project(process.cwd()); | ||
const packages = await project.getPackages(); | ||
const rootPath = project.rootPath; | ||
const packageJsonPaths = packages.map(p => | ||
path.relative(rootPath, p.manifestLocation), | ||
); | ||
const greenKeeperJson = { | ||
groups: { | ||
default: { | ||
packages: ['package.json'], | ||
}, | ||
}, | ||
}; | ||
|
||
for (const p of packageJsonPaths) { | ||
greenKeeperJson.groups.default.packages.push(p); | ||
} | ||
|
||
const greenKeeperJsonFile = path.join(rootPath, 'greenkeeper.json'); | ||
let currentConfig = {}; | ||
if (fs.existsSync(greenKeeperJsonFile)) { | ||
currentConfig = readJsonFile(greenKeeperJsonFile); | ||
} | ||
|
||
let updateRequired = false; | ||
if ( | ||
!( | ||
currentConfig.groups && | ||
currentConfig.groups.default && | ||
Array.isArray(currentConfig.groups.default.packages) | ||
) | ||
) { | ||
// Current config does not exist | ||
updateRequired = true; | ||
} | ||
|
||
if (!updateRequired) { | ||
// Check if packages are the same | ||
updateRequired = !arraysContainSameElements( | ||
currentConfig.groups.default.packages, | ||
greenKeeperJson.groups.default.packages, | ||
); | ||
} | ||
|
||
if (!updateRequired) { | ||
console.log('%s is up to date.', 'greenkeeper.json'); | ||
return; | ||
} | ||
|
||
if (process.argv[2] === '-f') { | ||
// Update `greenkeeper.json` | ||
writeJsonFile(greenKeeperJsonFile, greenKeeperJson); | ||
} else { | ||
// Print out `greenkeeper.json` | ||
console.error('%s is out of date.', 'greenkeeper.json'); | ||
console.log(JSON.stringify(greenKeeperJson, null, 2)); | ||
} | ||
} | ||
|
||
if (require.main === module) updateGreenKeeperJson(); | ||
|
||
/** | ||
* Test if two arrays contain the same set of elements | ||
* @param {Array} actual | ||
* @param {Array} expected | ||
*/ | ||
function arraysContainSameElements(actual, expected) { | ||
return ( | ||
// Same size | ||
actual.length == expected.length && | ||
// `expected` contains all elements of `actual` | ||
actual.every(e => expected.includes(e)) && | ||
// `actual` contains all elements of `expected` | ||
expected.every(e => actual.includes(e)) | ||
); | ||
} | ||
|
||
function readJsonFile(filePath) { | ||
return JSON.parse(fs.readFileSync(filePath, 'utf-8')); | ||
} | ||
|
||
function writeJsonFile(filePath, data) { | ||
fs.writeFileSync(filePath, JSON.stringify(data, null, 2) + '\n', 'utf-8'); | ||
console.log('%s has been updated.', filePath); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"groups": { | ||
"default": { | ||
"packages": [ | ||
"package.json", | ||
"benchmark/package.json", | ||
"docs/package.json", | ||
"examples/hello-world/package.json", | ||
"examples/log-extension/package.json", | ||
"examples/rpc-server/package.json", | ||
"examples/soap-calculator/package.json", | ||
"examples/todo-list/package.json", | ||
"examples/todo/package.json", | ||
"packages/authentication/package.json", | ||
"packages/boot/package.json", | ||
"packages/build/package.json", | ||
"packages/cli/package.json", | ||
"packages/context/package.json", | ||
"packages/core/package.json", | ||
"packages/http-caching-proxy/package.json", | ||
"packages/http-server/package.json", | ||
"packages/metadata/package.json", | ||
"packages/openapi-spec-builder/package.json", | ||
"packages/openapi-v3-types/package.json", | ||
"packages/openapi-v3/package.json", | ||
"packages/repository-json-schema/package.json", | ||
"packages/repository/package.json", | ||
"packages/rest-explorer/package.json", | ||
"packages/rest/package.json", | ||
"packages/service-proxy/package.json", | ||
"packages/testlab/package.json", | ||
"packages/tslint-config/package.json", | ||
"sandbox/example/package.json" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 is not really solving the problem, is it? If the person does not run install after adding a new package, or perhaps revert changes made to greepkeeper config, then we won't know the pull request is not complete.
What I would like to see instead:
update-greenkeeper-json.js
is run with no arguments (or perhaps with a special new arg), and the config file requires an update, then the tool exits with non-zero status code.travisyml
to run consistency check, see commit-lint and code-lint for inspirationbin/travis.sh
implementing the new check by runningupdate-greenkeeper-json.js
I am ok to defer this changes to a follow-up pull request if you prefer.
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.
Let's get greenkeeper to do the job first as it awaits this PR to be landed :-).