Skip to content

Commit

Permalink
chore: master version in lerna.json (instead of root package.json) (a…
Browse files Browse the repository at this point in the history
…ws#6445)

* chore: master version in lerna.json (instead of root package.json)

Use lerna.json to master the repo version instead of the root package.json.

Move standard-version configuration to .versionrc.json and consult it when aligning the repo version to determine where the version is mastered.

* scripts/get-version

returns the current repo version, and reused by align-version. then we can use it in our AutoBump build project
instead of hard-coding the fact that lerna.json is where we master the version.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
Elad Ben-Israel and mergify[bot] authored Feb 25, 2020
1 parent efef1b8 commit b04accc
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .versionrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"skip": { "tag": true },
"packageFiles": [ { "filename": "lerna.json", "type": "json" } ],
"bumpFiles": [ { "filename": "lerna.json", "type": "json" } ]
}
11 changes: 2 additions & 9 deletions bump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,5 @@ echo "Starting ${version} version bump"

# /bin/bash ./install.sh

# Generate CHANGELOG and create a commit
# --skip.tag because we create the tag as part of creating the github release
npx standard-version \
--bumpFiles package.json \
--release-as ${version} \
--skip.tag=true \
--releaseCommitMessageFormat="chore(release): v{{currentTag}}" \
--commit-all

# Generate CHANGELOG and create a commit (see .versionrc.json)
npx standard-version --release-as ${version}
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"tools/*"
],
"rejectCycles": "true",
"version": "999.0.0"
"version": "1.25.0"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aws-cdk",
"version": "1.25.0",
"version": "999.0.0",
"private": true,
"pkglint": {
"include": "dependencies/node-version"
Expand Down
5 changes: 3 additions & 2 deletions scripts/align-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
const fs = require('fs');

const marker = '999.0.0';
const repoVersion = require('../package.json').version;
const repoVersion = require('./get-version');

for (const file of process.argv.splice(2)) {
const pkg = JSON.parse(fs.readFileSync(file).toString());
Expand All @@ -20,6 +20,7 @@ for (const file of process.argv.splice(2)) {
processSection(pkg.devDependencies || { });
processSection(pkg.peerDependencies || { });

console.error(`${file} => ${repoVersion}`);
fs.writeFileSync(file, JSON.stringify(pkg, undefined, 2));
}

Expand All @@ -29,4 +30,4 @@ function processSection(section) {
section[name] = version.replace(marker, repoVersion);
}
}
}
}
4 changes: 2 additions & 2 deletions scripts/align-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ scriptdir=$(cd $(dirname $0) && pwd)
# go to repo root
cd ${scriptdir}/..

files="lerna.json $(find . -name package.json | grep -v node_modules | grep -v "^./package.json" | xargs)"
files="$(find . -name package.json | grep -v node_modules | xargs)"
${scriptdir}/align-version.js ${files}

# validation
if find . -name package.json | grep -v node_modules | xargs grep "999.0.0"; then
echo "ERROR: unexpected version marker 999.0.0 in a package.json file"
exit 1
fi
fi
18 changes: 18 additions & 0 deletions scripts/get-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Returns the current repo version.
*
* Usage:
*
* const version = require('./get-version');
*
* Or from the command line:
*
* node -p require('./get-version')
*
*/
const versionFile = require('../.versionrc.json').packageFiles[0].filename;
if (!versionFile) {
throw new Error(`unable to determine version filename from .versionrc.json at the root of the repo`);
}

module.exports = require(`../${versionFile}`).version;
120 changes: 116 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2416,6 +2416,11 @@ anymatch@^2.0.0:
micromatch "^3.1.4"
normalize-path "^2.1.1"

app-root-path@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/app-root-path/-/app-root-path-2.2.1.tgz#d0df4a682ee408273583d43f6f79e9892624bc9a"
integrity sha512-91IFKeKk7FjfmezPKkwtaRvSpnUc4gDwPAjA1YZ9Gn0q0PPeW+vbeUsZuyDwjI7+QTHhcLen2v25fi/AmhvbJA==

append-transform@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/append-transform/-/append-transform-1.0.0.tgz#046a52ae582a228bd72f58acfbe2967c678759ab"
Expand Down Expand Up @@ -4551,11 +4556,21 @@ dotenv-expand@^5.1.0:
resolved "https://registry.yarnpkg.com/dotenv-expand/-/dotenv-expand-5.1.0.tgz#3fbaf020bfd794884072ea26b1e9791d45a629f0"
integrity sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA==

dotenv-json@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/dotenv-json/-/dotenv-json-1.0.0.tgz#fc7f672aafea04bed33818733b9f94662332815c"
integrity sha512-jAssr+6r4nKhKRudQ0HOzMskOFFi9+ubXWwmrSGJFgTvpjyPXCXsCsYbjif6mXp7uxA7xY3/LGaiTQukZzSbOQ==

dotenv@^5.0.0:
version "5.0.1"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-5.0.1.tgz#a5317459bd3d79ab88cff6e44057a6a3fbb1fcef"
integrity sha512-4As8uPrjfwb7VXC+WnLCbXK7y+Ueb2B3zgNCePYfhxS1PYeaO1YTeplffTEcbfLhvFNGLAz90VvJs9yomG7bow==

dotenv@^8.0.0:
version "8.2.0"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a"
integrity sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==

dotgitignore@2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/dotgitignore/-/dotgitignore-2.1.0.tgz#a4b15a4e4ef3cf383598aaf1dfa4a04bcc089b7b"
Expand Down Expand Up @@ -4790,6 +4805,11 @@ escodegen@~1.9.0:
optionalDependencies:
source-map "~0.6.1"

eslint-config-standard@^14.1.0:
version "14.1.0"
resolved "https://registry.yarnpkg.com/eslint-config-standard/-/eslint-config-standard-14.1.0.tgz#b23da2b76fe5a2eba668374f246454e7058f15d4"
integrity sha512-EF6XkrrGVbvv8hL/kYa/m6vnvmUT+K82pJJc4JJVMM6+Qgqh0pnwprSxdduDLB9p/7bIxD+YV5O0wfb8lmcPbA==

eslint-import-resolver-node@^0.3.2, eslint-import-resolver-node@^0.3.3:
version "0.3.3"
resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.3.tgz#dbaa52b6b2816b50bc6711af75422de808e98404"
Expand Down Expand Up @@ -4817,7 +4837,15 @@ eslint-module-utils@^2.4.1:
debug "^2.6.9"
pkg-dir "^2.0.0"

eslint-plugin-import@^2.20.1:
eslint-plugin-es@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-es/-/eslint-plugin-es-2.0.0.tgz#0f5f5da5f18aa21989feebe8a73eadefb3432976"
integrity sha512-f6fceVtg27BR02EYnBhgWLFQfK6bN4Ll0nQFrBHOlCsAyxeZkn0NHns5O0YZOPrV1B3ramd6cgFwaoFLcSkwEQ==
dependencies:
eslint-utils "^1.4.2"
regexpp "^3.0.0"

eslint-plugin-import@^2.19.1, eslint-plugin-import@^2.20.1:
version "2.20.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.20.1.tgz#802423196dcb11d9ce8435a5fc02a6d3b46939b3"
integrity sha512-qQHgFOTjguR+LnYRoToeZWT62XM55MBVXObHM6SKFd1VzDcX/vqT1kAz8ssqigh5eMj8qXcRoXXGZpPP6RfdCw==
Expand All @@ -4835,6 +4863,28 @@ eslint-plugin-import@^2.20.1:
read-pkg-up "^2.0.0"
resolve "^1.12.0"

eslint-plugin-node@^10.0.0:
version "10.0.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-10.0.0.tgz#fd1adbc7a300cf7eb6ac55cf4b0b6fc6e577f5a6"
integrity sha512-1CSyM/QCjs6PXaT18+zuAXsjXGIGo5Rw630rSKwokSs2jrYURQc4R5JZpoanNCqwNmepg+0eZ9L7YiRUJb8jiQ==
dependencies:
eslint-plugin-es "^2.0.0"
eslint-utils "^1.4.2"
ignore "^5.1.1"
minimatch "^3.0.4"
resolve "^1.10.1"
semver "^6.1.0"

eslint-plugin-promise@^4.2.1:
version "4.2.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-4.2.1.tgz#845fd8b2260ad8f82564c1222fce44ad71d9418a"
integrity sha512-VoM09vT7bfA7D+upt+FjeBO5eHIJQBUWki1aPvB+vbNiHS3+oGIJGIeyBtKQTME6UPXXy3vV07OL1tHd3ANuDw==

eslint-plugin-standard@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-standard/-/eslint-plugin-standard-4.0.1.tgz#ff0519f7ffaff114f76d1bd7c3996eef0f6e20b4"
integrity sha512-v/KBnfyaOMPmZc/dmc6ozOdWqekGp7bBGq4jLAecEfPGmfKiWS4sA8sC0LqiV9w5qmXAtXVn4M3p1jSyhY85SQ==

eslint-scope@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.0.0.tgz#e87c8887c73e8d1ec84f1ca591645c358bfc8fb9"
Expand All @@ -4843,7 +4893,7 @@ eslint-scope@^5.0.0:
esrecurse "^4.1.0"
estraverse "^4.1.1"

eslint-utils@^1.4.3:
eslint-utils@^1.4.2, eslint-utils@^1.4.3:
version "1.4.3"
resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-1.4.3.tgz#74fec7c54d0776b6f67e0251040b5806564e981f"
integrity sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==
Expand Down Expand Up @@ -5984,6 +6034,11 @@ ignore@^4.0.3, ignore@^4.0.6:
resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"
integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==

ignore@^5.1.1:
version "5.1.4"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.4.tgz#84b7b3dbe64552b6ef0eca99f6743dbec6d97adf"
integrity sha512-MzbUSahkTW1u7JpKKjY7LCARd1fU5W2rLdxlM4kdkayuCwZImjkpluF9CM1aLewYJguPDqewLam18Y6AU69A8A==

immediate@~3.0.5:
version "3.0.6"
resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.0.6.tgz#9db1dbd0faf8de6fbe0f5dd5e56bb606280de69b"
Expand Down Expand Up @@ -7313,6 +7368,24 @@ kleur@^3.0.3:
resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e"
integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==

lambda-leak@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/lambda-leak/-/lambda-leak-2.0.0.tgz#771985d3628487f6e885afae2b54510dcfb2cd7e"
integrity sha1-dxmF02KEh/boha+uK1RRDc+yzX4=

lambda-tester@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/lambda-tester/-/lambda-tester-3.6.0.tgz#ceb7d4f4f0da768487a05cff37dcd088508b5247"
integrity sha512-F2ZTGWCLyIR95o/jWK46V/WnOCFAEUG/m/V7/CLhPJ7PCM+pror1rZ6ujP3TkItSGxUfpJi0kqwidw+M/nEqWw==
dependencies:
app-root-path "^2.2.1"
dotenv "^8.0.0"
dotenv-json "^1.0.0"
lambda-leak "^2.0.0"
semver "^6.1.1"
uuid "^3.3.2"
vandium-utils "^1.1.1"

lazystream@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/lazystream/-/lazystream-1.0.0.tgz#f6995fe0f820392f61396be89462407bb77168e4"
Expand Down Expand Up @@ -8108,6 +8181,17 @@ nise@^4.0.1:
just-extend "^4.0.2"
path-to-regexp "^1.7.0"

nock@^11.7.0:
version "11.9.1"
resolved "https://registry.yarnpkg.com/nock/-/nock-11.9.1.tgz#2b026c5beb6d0dbcb41e7e4cefa671bc36db9c61"
integrity sha512-U5wPctaY4/ar2JJ5Jg4wJxlbBfayxgKbiAeGh+a1kk6Pwnc2ZEuKviLyDSG6t0uXl56q7AALIxoM6FJrBSsVXA==
dependencies:
debug "^4.1.0"
json-stringify-safe "^5.0.1"
lodash "^4.17.13"
mkdirp "^0.5.0"
propagate "^2.0.0"

nock@^12.0.1:
version "12.0.1"
resolved "https://registry.yarnpkg.com/nock/-/nock-12.0.1.tgz#6d497d01f23cb52c733545c97e09e8318f6af801"
Expand Down Expand Up @@ -10186,6 +10270,13 @@ resolve@1.x, resolve@^1.1.5, resolve@^1.10.0, resolve@^1.11.1, resolve@^1.12.0,
dependencies:
path-parse "^1.0.6"

resolve@^1.10.1:
version "1.15.1"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.15.1.tgz#27bdcdeffeaf2d6244b95bb0f9f4b4653451f3e8"
integrity sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w==
dependencies:
path-parse "^1.0.6"

restore-cursor@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf"
Expand Down Expand Up @@ -10348,7 +10439,7 @@ semver-intersect@^1.4.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==

semver@6.3.0, semver@^6.0.0, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0:
semver@6.3.0, semver@^6.0.0, semver@^6.1.0, semver@^6.1.1, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0:
version "6.3.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
Expand Down Expand Up @@ -11462,6 +11553,22 @@ trivial-deferred@^1.0.1:
resolved "https://registry.yarnpkg.com/trivial-deferred/-/trivial-deferred-1.0.1.tgz#376d4d29d951d6368a6f7a0ae85c2f4d5e0658f3"
integrity sha1-N21NKdlR1jaKb3oK6FwvTV4GWPM=

ts-jest@^24.2.0:
version "24.3.0"
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-24.3.0.tgz#b97814e3eab359ea840a1ac112deae68aa440869"
integrity sha512-Hb94C/+QRIgjVZlJyiWwouYUF+siNJHJHknyspaOcZ+OQAIdFG/UrdQVXw/0B8Z3No34xkUXZJpOTy9alOWdVQ==
dependencies:
bs-logger "0.x"
buffer-from "1.x"
fast-json-stable-stringify "2.x"
json5 "2.x"
lodash.memoize "4.x"
make-error "1.x"
mkdirp "0.x"
resolve "1.x"
semver "^5.5"
yargs-parser "10.x"

ts-jest@^25.2.0:
version "25.2.1"
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-25.2.1.tgz#49bf05da26a8b7fbfbc36b4ae2fcdc2fef35c85d"
Expand Down Expand Up @@ -11858,6 +11965,11 @@ validate-npm-package-name@^3.0.0:
dependencies:
builtins "^1.0.3"

vandium-utils@^1.1.1:
version "1.2.0"
resolved "https://registry.yarnpkg.com/vandium-utils/-/vandium-utils-1.2.0.tgz#44735de4b7641a05de59ebe945f174e582db4f59"
integrity sha1-RHNd5LdkGgXeWevpRfF05YLbT1k=

vendors@^1.0.0:
version "1.0.3"
resolved "https://registry.yarnpkg.com/vendors/-/vendors-1.0.3.tgz#a6467781abd366217c050f8202e7e50cc9eef8c0"
Expand Down Expand Up @@ -12213,7 +12325,7 @@ yapool@^1.0.0:
resolved "https://registry.yarnpkg.com/yapool/-/yapool-1.0.0.tgz#f693f29a315b50d9a9da2646a7a6645c96985b6a"
integrity sha1-9pPymjFbUNmp2iZGp6ZkXJaYW2o=

yargs-parser@^10.0.0:
yargs-parser@10.x, yargs-parser@^10.0.0:
version "10.1.0"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-10.1.0.tgz#7202265b89f7e9e9f2e5765e0fe735a905edbaa8"
integrity sha512-VCIyR1wJoEBZUqk5PA+oOBF6ypbwh5aNB3I50guxAL/quggdfs4TtNHQrSazFA3fYZ+tEqfs0zIGlv0c/rgjbQ==
Expand Down

0 comments on commit b04accc

Please sign in to comment.