Bump versions for all npm packages on release

Summary:
Automatically bump versions for all local npm packages included as workspaces and fix local dependencies correspondingly.

As a part of this I have also aligned versioning for all the packages by using the same version for all of them.

Reviewed By: jknoxville

Differential Revision: D20745632

fbshipit-source-id: 2d438c4b23ee72f7d7c068c5ce161063c7ceb9e5
This commit is contained in:
Anton Nikolaev
2020-03-31 06:25:39 -07:00
committed by Facebook GitHub Bot
parent 971e0f80fd
commit eb9a2cb5e7
10 changed files with 105 additions and 20 deletions

View File

@@ -32,7 +32,7 @@
"expand-tilde": "^2.0.2",
"express": "^4.15.2",
"fb-watchman": "^2.0.0",
"flipper-doctor": "^0.7.0",
"flipper-doctor": "0.35.0",
"fs-extra": "^8.0.1",
"immer": "^6.0.0",
"immutable": "^4.0.0-rc.12",

View File

@@ -1,6 +1,6 @@
{
"name": "flipper-babel-transformer",
"version": "0.2.0",
"version": "0.35.0",
"description": "Babel transformer for Flipper plugins",
"repository": "facebook/flipper",
"main": "lib/index.js",

View File

@@ -1,6 +1,6 @@
{
"name": "flipper-doctor",
"version": "0.7.0",
"version": "0.35.0",
"description": "Utility for checking for issues with a flipper installation",
"main": "lib/index.js",
"flipper:source": "src",

View File

@@ -1,7 +1,8 @@
{
"name": "headless-tests",
"version": "1.0.0",
"name": "flipper-headless-tests",
"version": "0.35.0",
"main": "index.js",
"private": true,
"scripts": {
"test": "jest",
"test:debug": "node --inspect node_modules/.bin/jest --runInBand"

View File

@@ -168,6 +168,8 @@
"jest-fetch-mock": "^3.0.0",
"metro": "^0.58.0",
"metro-resolver": "^0.58.0",
"p-filter": "^2.1.0",
"p-map": "^4.0.0",
"prettier": "^2.0.0",
"react-async": "^10.0.0",
"recursive-readdir": "^2.2.2",
@@ -209,6 +211,7 @@
"lint:eslint": "eslint . --ext .js,.ts,.tsx",
"lint:flow": "flow check",
"lint": "yarn lint:eslint && yarn lint:flow && yarn lint:tsc",
"bump-workspace-versions": "cross-env TS_NODE_FILES=true node --require ts-node/register scripts/bump-workspace-versions.ts",
"everything": "yarn reset && yarn install && yarn lint && yarn test && yarn test-electron && yarn build --mac --mac-dmg --win --linux && yarn build-headless --mac --linux && yarn start"
},
"optionalDependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "flipper-pkg",
"version": "0.0.0",
"version": "0.35.0",
"description": "Utility for building and publishing Flipper plugins",
"repository": "facebook/flipper",
"main": "lib/index.js",
@@ -20,7 +20,7 @@
"@types/node": "^13.7.5",
"cli-ux": "^5.4.5",
"fs-extra": "^8.1.0",
"flipper-babel-transformer": "0.2.0",
"flipper-babel-transformer": "0.35.0",
"inquirer": "^7.0.5",
"metro": "^0.58.0",
"tslib": "^1"

View File

@@ -0,0 +1,67 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import {rootDir, pluginsDir} from './paths';
import fs from 'fs-extra';
import path from 'path';
import {promisify} from 'util';
import globImport from 'glob';
import pfilter from 'p-filter';
import pmap from 'p-map';
const glob = promisify(globImport);
const lastArg = process.argv[process.argv.length - 1];
const version =
lastArg === __filename ? undefined : process.argv[process.argv.length - 1];
bump(version)
.then(() => process.exit(0))
.catch((err) => {
console.error(err);
process.exit(1);
});
async function bump(version?: string) {
const rootPackageJson = await fs.readJson(path.join(rootDir, 'package.json'));
version = version || (rootPackageJson.version as string);
const packageGlobs = rootPackageJson.workspaces.packages as string[];
const localPackages = await pmap(
await pfilter(
([] as string[]).concat(
...(await pmap(packageGlobs, (pattern) =>
glob(path.join(rootDir, pattern, '')),
)),
),
async (dir) =>
!dir.startsWith(pluginsDir) &&
(await fs.pathExists(path.join(dir, 'package.json'))),
),
async (dir) => {
const json = await fs.readJson(path.join(dir, 'package.json'));
return {
dir,
json,
};
},
);
const localPackageNames = localPackages.map(({json}) => json.name as string);
for (const {dir, json} of localPackages) {
json.version = version;
if (json.dependencies) {
for (const localPackageName of localPackageNames) {
if (json.dependencies[localPackageName] !== undefined) {
json.dependencies[localPackageName] = version;
}
}
}
await fs.writeJson(path.join(dir, 'package.json'), json, {
spaces: 2,
});
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "flipper-static",
"version": "1.0.0",
"version": "0.35.0",
"main": "index.js",
"private": true,
"license": "MIT",
@@ -10,7 +10,7 @@
"fb-watchman": "^2.0.0",
"fix-path": "^3.0.0",
"fs-extra": "^8.1.0",
"flipper-babel-transformer": "0.2.0",
"flipper-babel-transformer": "0.35.0",
"mem": "^6.0.0",
"metro": "^0.58.0",
"mkdirp": "^1.0.0",

View File

@@ -2286,9 +2286,9 @@
"@types/yargs-parser" "*"
"@types/yargs@^15.0.0":
version "15.0.3"
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-15.0.3.tgz#41453a0bc7ab393e995d1f5451455638edbd2baf"
integrity sha512-XCMQRK6kfpNBixHLyHUsGmXrpEmFFxzMrcnSXFMziHd8CoNJo8l16FkHyQq4x+xbM7E2XL83/O78OD8u+iZTdQ==
version "15.0.4"
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-15.0.4.tgz#7e5d0f8ca25e9d5849f2ea443cf7c402decd8299"
integrity sha512-9T1auFmbPZoxHz0enUFlUuKRy3it01R+hlggyVUMtnCTQRunsQYifnSGb8hET4Xo8yiC0o0r1paW3ud5+rbURg==
dependencies:
"@types/yargs-parser" "*"
@@ -8740,6 +8740,13 @@ p-each-series@^2.1.0:
resolved "https://registry.yarnpkg.com/p-each-series/-/p-each-series-2.1.0.tgz#961c8dd3f195ea96c747e636b262b800a6b1af48"
integrity sha512-ZuRs1miPT4HrjFa+9fRfOFXxGJfORgelKV9f9nNOWw2gl6gVsRaVDOQP0+MI0G0wGKns1Yacsu0GjOFbTK0JFQ==
p-filter@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/p-filter/-/p-filter-2.1.0.tgz#1b1472562ae7a0f742f0f3d3d3718ea66ff9c09c"
integrity sha512-ZBxxZ5sL2HghephhpGAQdoskxplTwr7ICaehZwLIlfL6acuVgZPm8yBNuRAFBGEqtD/hmUeq9eqLg2ys9Xr/yw==
dependencies:
p-map "^2.0.0"
p-finally@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae"
@@ -8795,6 +8802,11 @@ p-locate@^4.1.0:
dependencies:
p-limit "^2.2.0"
p-map@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/p-map/-/p-map-2.1.0.tgz#310928feef9c9ecc65b68b17693018a665cea175"
integrity sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==
p-map@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/p-map/-/p-map-4.0.0.tgz#bb2f95a5eda2ec168ec9274e06a747c3e2904d2b"
@@ -11961,9 +11973,9 @@ yargs@^14.2.0:
yargs-parser "^15.0.0"
yargs@^15.0.0, yargs@^15.0.1, yargs@^15.1.0:
version "15.1.0"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.1.0.tgz#e111381f5830e863a89550bd4b136bb6a5f37219"
integrity sha512-T39FNN1b6hCW4SOIk1XyTOWxtXdcen0t+XYrysQmChzSipvhBO8Bj0nK1ozAasdk24dNWuMZvr4k24nz+8HHLg==
version "15.3.1"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.3.1.tgz#9505b472763963e54afe60148ad27a330818e98b"
integrity sha512-92O1HWEjw27sBfgmXiixJWT5hRBp2eobqXicLtPBIDBhYB+1HpwZlXmbW2luivBJHBzki+7VyCLRtAkScbTBQA==
dependencies:
cliui "^6.0.0"
decamelize "^1.2.0"
@@ -11975,7 +11987,7 @@ yargs@^15.0.0, yargs@^15.0.1, yargs@^15.1.0:
string-width "^4.2.0"
which-module "^2.0.0"
y18n "^4.0.0"
yargs-parser "^16.1.0"
yargs-parser "^18.1.1"
yauzl@2.4.1:
version "2.4.1"