Skip to content

Commit

Permalink
vx: auto increment dep versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Dec 13, 2021
1 parent dbea7ac commit a01e5ce
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 27 deletions.
2 changes: 1 addition & 1 deletion vx/config/jest/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module.exports = (custom = {}) => ({
'ts-jest': {
tsconfig: usePackage()
? vxPath.packageTsConfig()
: path.join(vxPath.ROOT_PATH, 'tsconfig.json'),
: path.join(vxPath.ROOT_PATH, vxPath.TSCONFIG_JSON),
diagnostics: {
// Essentially ignoring "any" errors in TESTS
ignoreCodes: [
Expand Down
6 changes: 5 additions & 1 deletion vx/config/rollup/plugins/addCJSPackageJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const path = require('path');
const fse = require('fs-extra');

const opts = require('vx/opts');
const vxPath = require('vx/vxPath');

module.exports = addEsPackageJson;

Expand All @@ -14,7 +15,10 @@ function addEsPackageJson() {
return;
}

const packageJsonPath = path.join(path.dirname(file), 'package.json');
const packageJsonPath = path.join(
path.dirname(file),
vxPath.PACKAGE_JSON
);

if (fse.existsSync(packageJsonPath)) {
return;
Expand Down
6 changes: 5 additions & 1 deletion vx/config/rollup/plugins/addModulePackageJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const path = require('path');
const fse = require('fs-extra');

const opts = require('vx/opts');
const vxPath = require('vx/vxPath');

module.exports = addEsPackageJson;

Expand All @@ -14,7 +15,10 @@ function addEsPackageJson() {
return;
}

const packageJsonPath = path.join(path.dirname(file), 'package.json');
const packageJsonPath = path.join(
path.dirname(file),
vxPath.PACKAGE_JSON
);

if (fse.existsSync(packageJsonPath)) {
return;
Expand Down
2 changes: 1 addition & 1 deletion vx/config/rollup/plugins/handleExports.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function writePackageJson(name, exportPath, { namespace } = {}) {
pkgJson = { ...packageJson(name), ...pkgJson };
}

fse.writeJSONSync(joinPath(exportPath, 'package.json'), pkgJson, {
fse.writeJSONSync(joinPath(exportPath, vxPath.PACKAGE_JSON), pkgJson, {
spaces: 2,
});
}
Expand Down
2 changes: 1 addition & 1 deletion vx/packageNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = Object.defineProperty(
);

const paths = glob.sync(vxPath.package('*')).filter(packagePath => {
const packageJson = require(path.resolve(packagePath, 'package.json'));
const packageJson = require(path.resolve(packagePath, vxPath.PACKAGE_JSON));

return !packageJson.private;
});
Expand Down
13 changes: 8 additions & 5 deletions vx/scripts/release/releasePackage.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const build = require('./../build/buildPackage');
const genDiffData = require('./../release/genDiffData');
const getDiff = require('./../release/github/getDiff');
const publishPackage = require('./../release/steps/publishPackage');
const setNextVersion = require('./../release/steps/setNextVersion');
const updateChangelog = require('./../release/steps/updateChangelog');
const genDiffData = require('./genDiffData');
const getDiff = require('./github/getDiff');
const publishPackage = require('./steps/publishPackage');
const setNextVersion = require('./steps/setNextVersion');
const updateChangelog = require('./steps/updateChangelog');
const updateLocalDepsToLatest = require('./steps/updateLocalDepsToLatest');

const logger = require('vx/logger');
const { usePackage } = require('vx/vxContext');
Expand All @@ -27,6 +28,8 @@ function releasePackage() {

setNextVersion(diffData);

updateLocalDepsToLatest();

build();

updateChangelog(diffData);
Expand Down
33 changes: 33 additions & 0 deletions vx/scripts/release/steps/updateLocalDepsToLatest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const fse = require('fs-extra');

const logger = require('vx/logger');
const packageNames = require('vx/packageNames');
const packageJson = require('vx/util/packageJson');
const vxPath = require('vx/vxPath');

// eslint-disable-next-line complexity
module.exports = function updateLocalDepsToLatest() {
logger.log('Updating local dependencies to latest version');
const pkgJson = packageJson();
const deps = pkgJson.dependencies;

if (!deps) {
return;
}

for (const name in packageNames.names) {
if (!deps[name]) {
continue;
}

const depPkgJson = packageJson(name);

if (depPkgJson && depPkgJson.name === name) {
deps[name] = depPkgJson.version;
}
}

fse.writeJSONSync(vxPath.packageJson(), pkgJson, {
spaces: 2,
});
};
2 changes: 1 addition & 1 deletion vx/util/rootPackageJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const vxPath = require('vx/vxPath');
function rootPackageJson() {
// Manually reading it instead of requiring to avoid caching
const jsonString = fs.readFileSync(
path.join(vxPath.ROOT_PATH, 'package.json'),
path.join(vxPath.ROOT_PATH, vxPath.PACKAGE_JSON),
'utf8'
);
return JSON.parse(jsonString);
Expand Down
3 changes: 3 additions & 0 deletions vx/vxPath.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ const PACKAGE_JSON = 'package.json';
const TSCONFIG_JSON = 'tsconfig.json';
const VX = 'vx';

vxPath.PACKAGE_JSON = PACKAGE_JSON;
vxPath.TSCONFIG_JSON = TSCONFIG_JSON;

vxPath.vxRoot = () => {
return vxPath.closest(process.cwd(), (current, breakout) => {
const pkgJsonPath = path.resolve(current, PACKAGE_JSON);
Expand Down
37 changes: 21 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1338,9 +1338,9 @@
integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4=

"@types/lodash@^4.14.170":
version "4.14.171"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.171.tgz#f01b3a5fe3499e34b622c362a46a609fdb23573b"
integrity sha512-7eQ2xYLLI/LsicL2nejW9Wyko3lcpN6O/z0ZLHrEQsg280zIdCv1t/0m6UtBjUHokCGBQ3gYTbHzDkZ1xOBwwg==
version "4.14.178"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.178.tgz#341f6d2247db528d4a13ddbb374bcdc80406f4f8"
integrity sha512-0d5Wd09ItQWH1qFbEyQ7oTQ3GZrMfth5JkbN3EvTKLXcHLRDSXeLnlvlOn0wvxVIwK5o2M8JzP/OWz7T3NRsbw==

"@types/minimatch@^3.0.3":
version "3.0.5"
Expand Down Expand Up @@ -3748,9 +3748,9 @@ is-stream@^1.1.0:
integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ=

is-stream@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.0.tgz#bde9c32680d6fae04129d6ac9d921ce7815f78e3"
integrity sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw==
version "2.0.1"
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.1.tgz#fac1e3d53b97ad5a9d0ae9cef2389f5810a5c077"
integrity sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==

is-string@^1.0.5, is-string@^1.0.7:
version "1.0.7"
Expand Down Expand Up @@ -4615,9 +4615,9 @@ module-lookup-amd@^7.0.0:
requirejs-config-file "^4.0.0"

mri@^1.1.5:
version "1.1.6"
resolved "https://registry.yarnpkg.com/mri/-/mri-1.1.6.tgz#49952e1044db21dbf90f6cd92bc9c9a777d415a6"
integrity sha512-oi1b3MfbyGa7FJMP9GmLTttni5JoICpYBRlq+x5V16fZbLsnL9N3wFqqIm/nIG43FjUFkFh9Epzp/kzUGUnJxQ==
version "1.2.0"
resolved "https://registry.yarnpkg.com/mri/-/mri-1.2.0.tgz#6721480fec2a11a4889861115a48b6cbe7cc8f0b"
integrity sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==

ms@2.0.0:
version "2.0.0"
Expand Down Expand Up @@ -5088,9 +5088,9 @@ prelude-ls@~1.1.2:
integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=

prettier@^2.3.0:
version "2.3.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.3.2.tgz#ef280a05ec253712e486233db5c6f23441e7342d"
integrity sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ==
version "2.5.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.5.1.tgz#fff75fa9d519c54cf0fce328c1017d94546bc56a"
integrity sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==

pretty-format@^26.0.0, pretty-format@^26.6.2:
version "26.6.2"
Expand All @@ -5110,9 +5110,9 @@ pretty-ms@^7.0.1:
parse-ms "^2.1.0"

pretty-quick@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/pretty-quick/-/pretty-quick-3.1.1.tgz#93ca4e2dd38cc4e970e3f54a0ead317a25454688"
integrity sha512-ZYLGiMoV2jcaas3vTJrLvKAYsxDoXQBUn8OSTxkl67Fyov9lyXivJTl0+2WVh+y6EovGcw7Lm5ThYpH+Sh3XxQ==
version "3.1.2"
resolved "https://registry.yarnpkg.com/pretty-quick/-/pretty-quick-3.1.2.tgz#89d8741af7122cbd7f34182df746c5a7ea360b5c"
integrity sha512-T+fpTJrDjTzewql4p3lKrRA7z3MrNyjBK1MKeaBm5PpKwATgVm885TpY7TgY8KFt5Q1Qn3QDseRQcyX9AKTKkA==
dependencies:
chalk "^3.0.0"
execa "^4.0.0"
Expand Down Expand Up @@ -5595,11 +5595,16 @@ side-channel@^1.0.4:
get-intrinsic "^1.0.2"
object-inspect "^1.9.0"

signal-exit@^3.0.0, signal-exit@^3.0.2:
signal-exit@^3.0.0:
version "3.0.3"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c"
integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==

signal-exit@^3.0.2:
version "3.0.6"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.6.tgz#24e630c4b0f03fea446a2bd299e62b4a6ca8d0af"
integrity sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ==

sisteransi@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed"
Expand Down

0 comments on commit a01e5ce

Please sign in to comment.