From 17acc5273f8a9c5f1c9557c3ff95bfb616c8d2c2 Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Wed, 15 Feb 2017 10:10:00 +0100 Subject: [PATCH 1/6] Improve yarn logs --- lib/helpers/yarn.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/helpers/yarn.js b/lib/helpers/yarn.js index 3581970647ade5..bc541ecf5de292 100644 --- a/lib/helpers/yarn.js +++ b/lib/helpers/yarn.js @@ -20,7 +20,10 @@ async function generateLockFile(newPackageJson, npmrcContent, yarnrcContent) { if (yarnrcContent) { fs.writeFileSync(path.join(tmpDir.name, '.yarnrc'), yarnrcContent); } - cp.spawnSync('yarn', ['install'], { cwd: tmpDir.name }); + logger.debug('Spawning yarn install'); + const result = cp.spawnSync('yarn', ['install'], { cwd: tmpDir.name }); + logger.debug(String(result.stdout)); + logger.debug(String(result.stderr)); yarnLock = fs.readFileSync(path.join(tmpDir.name, 'yarn.lock')); } catch (error) { tmpDir.removeCallback(); From 63a79bedc84d1954242fb3872dd632064390344b Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Wed, 15 Feb 2017 10:15:40 +0100 Subject: [PATCH 2/6] Add processYarnLock --- lib/worker.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib/worker.js b/lib/worker.js index e85a361d31033d..1b67c5139e6293 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -1,4 +1,5 @@ const logger = require('winston'); +const path = require('path'); const stringify = require('json-stringify-pretty-compact'); const githubApi = require('./api/github'); const gitlabApi = require('./api/gitlab'); @@ -54,10 +55,36 @@ async function processPackageFile(repoName, packageFile, packageConfig) { // Find all upgrades for remaining dependencies const upgrades = await findUpgrades(dependencies, config); // Process all upgrades sequentially + await processYarnLock(config); await processUpgradesSequentially(config, upgrades); logger.info(`${repoName} ${packageFile} done`); } +async function processYarnLock(inputConfig) { + const packageContent = await inputConfig.api.getFileContent(inputConfig.packageFile); + const yarnLockFileName = path.join(path.dirname(inputConfig.packageFile), 'yarn.lock'); + logger.debug(`Checking for ${yarnLockFileName}`); + const existingYarnLock = await inputConfig.api.getFileContent(yarnLockFileName); + if (!existingYarnLock) { + return; + } + logger.debug('Found existing yarn.lock file'); + const newYarnLock = await branchWorker.getYarnLockFile(packageContent, inputConfig); + if (existingYarnLock === newYarnLock.contents) { + logger.debug('Yarn lock does not need updating'); + return; + } + logger.debug('Yarn lock needs updating'); + const commitMessage = 'Regenerate yarn.lock file'; + // API will know whether to create new branch or not + const params = Object.assign({}, inputConfig); + params.branchName = 'renovate/yarn-lock'; + params.prTitle = 'Renovate yarn.lock'; + params.prBody = 'This PR regenerates yarn.lock files based on the existing `package.json` files.'; + await inputConfig.api.commitFilesToBranch(config.branchName, [newYarnLock], commitMessage); + prWorker.ensurePr(params); +} + async function findUpgrades(dependencies, inputConfig) { const allUpgrades = []; // findDepUpgrades can add more than one upgrade to allUpgrades From 980816114bdf03732ffeedc656895f92f9e229de Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Tue, 21 Feb 2017 11:57:19 +0100 Subject: [PATCH 3/6] Update worker.js --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 1b67c5139e6293..009bb500c8fe36 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -75,7 +75,7 @@ async function processYarnLock(inputConfig) { return; } logger.debug('Yarn lock needs updating'); - const commitMessage = 'Regenerate yarn.lock file'; + const commitMessage = 'yarn.lock renovation'; // API will know whether to create new branch or not const params = Object.assign({}, inputConfig); params.branchName = 'renovate/yarn-lock'; From c8cfaec1b257097691fcad46c2dea8ad3cd8f708 Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Tue, 21 Feb 2017 11:58:16 +0100 Subject: [PATCH 4/6] Update worker.js --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 009bb500c8fe36..d0a67403f05f35 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -75,7 +75,7 @@ async function processYarnLock(inputConfig) { return; } logger.debug('Yarn lock needs updating'); - const commitMessage = 'yarn.lock renovation'; + const commitMessage = 'Renovate yarn.lock file'; // API will know whether to create new branch or not const params = Object.assign({}, inputConfig); params.branchName = 'renovate/yarn-lock'; From 0c9dd138509df259fcf26811cb3e920e5484a0d9 Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Mon, 13 Mar 2017 10:49:59 +0100 Subject: [PATCH 5/6] Fix and update docs --- docs/configuration.md | 38 ++++++++++++++++++++------------------ lib/config/definitions.js | 7 +++++++ lib/worker.js | 12 +++++++----- readme.md | 37 +++++++++++++++++++------------------ 4 files changed, 53 insertions(+), 41 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index fcf1f1bf630a93..2d067015dabcde 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -56,24 +56,25 @@ $ node renovate --help Options: - -h, --help output usage information - --enabled [boolean] Enable or disable renovate - --onboarding [boolean] Require a Configuration PR first - --platform Platform type of repository - --endpoint Custom endpoint to use - --token Repository Auth Token - --package-files Package file paths - --dep-types Dependency types - --ignore-deps Dependencies to ignore - --ignore-future [boolean] Ignore versions tagged as "future" - --ignore-unstable [boolean] Ignore versions with unstable semver - --respect-latest [boolean] Ignore versions newer than npm "latest" version - --recreate-closed [boolean] Recreate PRs even if same ones were closed previously - --rebase-stale-prs [boolean] Rebase stale PRs (GitHub only) - --labels Labels to add to Pull Request - --assignees Assignees for Pull Request - --reviewers Requested reviewers for Pull Requests (GitHub only) - --log-level Logging level + -h, --help output usage information + --enabled [boolean] Enable or disable renovate + --onboarding [boolean] Require a Configuration PR first + --platform Platform type of repository + --endpoint Custom endpoint to use + --token Repository Auth Token + --package-files Package file paths + --dep-types Dependency types + --ignore-deps Dependencies to ignore + --ignore-future [boolean] Ignore versions tagged as "future" + --ignore-unstable [boolean] Ignore versions with unstable semver + --respect-latest [boolean] Ignore versions newer than npm "latest" version + --recreate-closed [boolean] Recreate PRs even if same ones were closed previously + --rebase-stale-prs [boolean] Rebase stale PRs (GitHub only) + --labels Labels to add to Pull Request + --assignees Assignees for Pull Request + --reviewers Requested reviewers for Pull Requests (GitHub only) + --maintain-yarn-lock [boolean] Keep yarn.lock updated in main branch (no monorepo support) + --log-level Logging level Examples: @@ -126,4 +127,5 @@ Obviously, you can't set repository or package file location with this method. | `labels` | Labels to add to Pull Request | list | `[]` | `RENOVATE_LABELS` | `--labels` | | `assignees` | Assignees for Pull Request | list | `[]` | `RENOVATE_ASSIGNEES` | `--assignees` | | `reviewers` | Requested reviewers for Pull Requests (GitHub only) | list | `[]` | `RENOVATE_REVIEWERS` | `--reviewers` | +| `maintainYarnLock` | Keep yarn.lock updated in main branch (no monorepo support) | boolean | `false` | `RENOVATE_MAINTAIN_YARN_LOCK` | `--maintain-yarn-lock` | | `logLevel` | Logging level | string | `"info"` | `LOG_LEVEL` | `--log-level` | diff --git a/lib/config/definitions.js b/lib/config/definitions.js index dfa42e3f03c587..4f92f697d1d424 100644 --- a/lib/config/definitions.js +++ b/lib/config/definitions.js @@ -131,6 +131,13 @@ const options = [ description: 'Requested reviewers for Pull Requests (GitHub only)', type: 'list', }, + // Yarn options + { + name: 'maintainYarnLock', + description: 'Keep yarn.lock updated in main branch (no monorepo support)', + type: 'boolean', + default: false, + }, // Debug options { name: 'logLevel', diff --git a/lib/worker.js b/lib/worker.js index d0a67403f05f35..82128069a3f3cf 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -55,12 +55,14 @@ async function processPackageFile(repoName, packageFile, packageConfig) { // Find all upgrades for remaining dependencies const upgrades = await findUpgrades(dependencies, config); // Process all upgrades sequentially - await processYarnLock(config); + if (config.maintainYarnLock) { + await maintainYarnLock(config); + } await processUpgradesSequentially(config, upgrades); logger.info(`${repoName} ${packageFile} done`); } -async function processYarnLock(inputConfig) { +async function maintainYarnLock(inputConfig) { const packageContent = await inputConfig.api.getFileContent(inputConfig.packageFile); const yarnLockFileName = path.join(path.dirname(inputConfig.packageFile), 'yarn.lock'); logger.debug(`Checking for ${yarnLockFileName}`); @@ -71,7 +73,7 @@ async function processYarnLock(inputConfig) { logger.debug('Found existing yarn.lock file'); const newYarnLock = await branchWorker.getYarnLockFile(packageContent, inputConfig); if (existingYarnLock === newYarnLock.contents) { - logger.debug('Yarn lock does not need updating'); + logger.debug('Yarn lock file does not need updating'); return; } logger.debug('Yarn lock needs updating'); @@ -79,9 +81,9 @@ async function processYarnLock(inputConfig) { // API will know whether to create new branch or not const params = Object.assign({}, inputConfig); params.branchName = 'renovate/yarn-lock'; - params.prTitle = 'Renovate yarn.lock'; + params.prTitle = 'Renovate yarn.lock file'; params.prBody = 'This PR regenerates yarn.lock files based on the existing `package.json` files.'; - await inputConfig.api.commitFilesToBranch(config.branchName, [newYarnLock], commitMessage); + await inputConfig.api.commitFilesToBranch(params.branchName, [newYarnLock], commitMessage); prWorker.ensurePr(params); } diff --git a/readme.md b/readme.md index 2c9de89c893c81..44e2faa2017f4e 100644 --- a/readme.md +++ b/readme.md @@ -38,24 +38,25 @@ $ node renovate --help Options: - -h, --help output usage information - --enabled [boolean] Enable or disable renovate - --onboarding [boolean] Require a Configuration PR first - --platform Platform type of repository - --endpoint Custom endpoint to use - --token Repository Auth Token - --package-files Package file paths - --dep-types Dependency types - --ignore-deps Dependencies to ignore - --ignore-future [boolean] Ignore versions tagged as "future" - --ignore-unstable [boolean] Ignore versions with unstable semver - --respect-latest [boolean] Ignore versions newer than npm "latest" version - --recreate-closed [boolean] Recreate PRs even if same ones were closed previously - --rebase-stale-prs [boolean] Rebase stale PRs (GitHub only) - --labels Labels to add to Pull Request - --assignees Assignees for Pull Request - --reviewers Requested reviewers for Pull Requests (GitHub only) - --log-level Logging level + -h, --help output usage information + --enabled [boolean] Enable or disable renovate + --onboarding [boolean] Require a Configuration PR first + --platform Platform type of repository + --endpoint Custom endpoint to use + --token Repository Auth Token + --package-files Package file paths + --dep-types Dependency types + --ignore-deps Dependencies to ignore + --ignore-future [boolean] Ignore versions tagged as "future" + --ignore-unstable [boolean] Ignore versions with unstable semver + --respect-latest [boolean] Ignore versions newer than npm "latest" version + --recreate-closed [boolean] Recreate PRs even if same ones were closed previously + --rebase-stale-prs [boolean] Rebase stale PRs (GitHub only) + --labels Labels to add to Pull Request + --assignees Assignees for Pull Request + --reviewers Requested reviewers for Pull Requests (GitHub only) + --maintain-yarn-lock [boolean] Keep yarn.lock updated in main branch (no monorepo support) + --log-level Logging level Examples: From 694bc5bf6d55b94cae2806db8e845ae4f544c5f1 Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Fri, 7 Apr 2017 07:59:55 +0200 Subject: [PATCH 6/6] Make Yarn Maintenance strings into templates --- lib/config/definitions.js | 33 +++++++++++++++++++++++++++++++++ lib/worker.js | 8 ++++---- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/lib/config/definitions.js b/lib/config/definitions.js index 4f92f697d1d424..1f569171242ad2 100644 --- a/lib/config/definitions.js +++ b/lib/config/definitions.js @@ -115,6 +115,39 @@ const options = [ cli: false, env: false, }, + // Yarn Lock Maintenance + { + name: 'yarnMaintenanceBranchName', + description: 'Branch name template when maintaining yarn.lock', + type: 'string', + default: 'renovate/yarn-lock', + cli: false, + env: false, + }, + { + name: 'yarnMaintenanceCommitMessage', + description: 'Commit message template when maintaining yarn.lock', + type: 'string', + default: 'Renovate yarn.lock file', + cli: false, + env: false, + }, + { + name: 'yarnMaintenancePrTitle', + description: 'Pull Request title template when maintaining yarn.lock', + type: 'string', + default: 'Renovate yarn.lock file', + cli: false, + env: false, + }, + { + name: 'yarnMaintenancePrBody', + description: 'Pull Request body template when maintaining yarn.lock', + type: 'string', + default: 'This PR regenerates yarn.lock files based on the existing `package.json` files.', + cli: false, + env: false, + }, // Pull Request options { name: 'labels', diff --git a/lib/worker.js b/lib/worker.js index 82128069a3f3cf..a68720fac22014 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -77,12 +77,12 @@ async function maintainYarnLock(inputConfig) { return; } logger.debug('Yarn lock needs updating'); - const commitMessage = 'Renovate yarn.lock file'; // API will know whether to create new branch or not const params = Object.assign({}, inputConfig); - params.branchName = 'renovate/yarn-lock'; - params.prTitle = 'Renovate yarn.lock file'; - params.prBody = 'This PR regenerates yarn.lock files based on the existing `package.json` files.'; + const commitMessage = handlebars.compile(params.yarnMaintenanceCommitMessage)(params); + params.branchName = params.yarnMaintenanceBranchName; + params.prTitle = params.yarnMaintenancePrTitle; + params.prBody = params.yarnMaintenancePrBody; await inputConfig.api.commitFilesToBranch(params.branchName, [newYarnLock], commitMessage); prWorker.ensurePr(params); }