Publish all packages to npm on release
Summary: Publish all the public packages (excluding those with "private=true") included as workspaces to "desktop" project. Reviewed By: jknoxville Differential Revision: D20765097 fbshipit-source-id: 444541e9a682a90eba02cb3da85ada9bd00d93d0
This commit is contained in:
committed by
Facebook GitHub Bot
parent
eb9a2cb5e7
commit
bf32297ad9
@@ -79,7 +79,7 @@
|
|||||||
"ws": "^7.2.3",
|
"ws": "^7.2.3",
|
||||||
"xdg-basedir": "^4.0.0",
|
"xdg-basedir": "^4.0.0",
|
||||||
"xml2js": "^0.4.19",
|
"xml2js": "^0.4.19",
|
||||||
"yargs": "^15.0.1",
|
"yargs": "^15.3.1",
|
||||||
"yazl": "^2.5.1"
|
"yazl": "^2.5.1"
|
||||||
},
|
},
|
||||||
"greenkeeper": {
|
"greenkeeper": {
|
||||||
|
|||||||
@@ -143,6 +143,7 @@
|
|||||||
"@types/uuid": "^7.0.0",
|
"@types/uuid": "^7.0.0",
|
||||||
"@types/which": "^1.3.2",
|
"@types/which": "^1.3.2",
|
||||||
"@types/ws": "^7.2.0",
|
"@types/ws": "^7.2.0",
|
||||||
|
"@types/yargs": "^15.0.4",
|
||||||
"@types/yazl": "^2.4.2",
|
"@types/yazl": "^2.4.2",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.19.2",
|
"@typescript-eslint/eslint-plugin": "^2.19.2",
|
||||||
"@typescript-eslint/parser": "^2.19.2",
|
"@typescript-eslint/parser": "^2.19.2",
|
||||||
@@ -177,7 +178,8 @@
|
|||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"ts-jest": "^25.1.0",
|
"ts-jest": "^25.1.0",
|
||||||
"ts-node": "^8.8.1",
|
"ts-node": "^8.8.1",
|
||||||
"typescript": "^3.7.2"
|
"typescript": "^3.7.2",
|
||||||
|
"yargs": "^15.3.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"preinstall": "node scripts/prepare-watchman-config.js && yarn config set ignore-engines",
|
"preinstall": "node scripts/prepare-watchman-config.js && yarn config set ignore-engines",
|
||||||
@@ -211,7 +213,8 @@
|
|||||||
"lint:eslint": "eslint . --ext .js,.ts,.tsx",
|
"lint:eslint": "eslint . --ext .js,.ts,.tsx",
|
||||||
"lint:flow": "flow check",
|
"lint:flow": "flow check",
|
||||||
"lint": "yarn lint:eslint && yarn lint:flow && yarn lint:tsc",
|
"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",
|
"bump-versions": "cross-env TS_NODE_FILES=true node --require ts-node/register scripts/bump-versions.ts",
|
||||||
|
"publish-packages": "cross-env TS_NODE_FILES=true node --require ts-node/register scripts/publish-packages.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"
|
"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": {
|
"optionalDependencies": {
|
||||||
|
|||||||
28
desktop/scripts/bump-versions.ts
Normal file
28
desktop/scripts/bump-versions.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/**
|
||||||
|
* 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 {bumpVersions} from './workspaces';
|
||||||
|
import yargs from 'yargs';
|
||||||
|
|
||||||
|
const argv = yargs
|
||||||
|
.usage('$0 [args]')
|
||||||
|
.options({
|
||||||
|
newVersion: {key: 'new-version', alias: 'v', type: 'string'},
|
||||||
|
})
|
||||||
|
.help().argv;
|
||||||
|
|
||||||
|
bumpVersions(argv)
|
||||||
|
.then((version) => {
|
||||||
|
console.log(`Versions bumped to ${version}`);
|
||||||
|
process.exit(0);
|
||||||
|
})
|
||||||
|
.catch((err: any) => {
|
||||||
|
console.error(err);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
26
desktop/scripts/publish-packages.ts
Normal file
26
desktop/scripts/publish-packages.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/**
|
||||||
|
* 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 {publishPackages} from './workspaces';
|
||||||
|
import yargs from 'yargs';
|
||||||
|
|
||||||
|
const argv = yargs
|
||||||
|
.usage('$0 [args]')
|
||||||
|
.options({
|
||||||
|
newVersion: {key: 'new-version', alias: 'v', type: 'string'},
|
||||||
|
proxy: {key: 'proxy', alias: 'p', type: 'string'},
|
||||||
|
})
|
||||||
|
.help().argv;
|
||||||
|
|
||||||
|
publishPackages(argv)
|
||||||
|
.then(() => process.exit(0))
|
||||||
|
.catch((err: any) => {
|
||||||
|
console.error(err);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
123
desktop/scripts/workspaces.ts
Normal file
123
desktop/scripts/workspaces.ts
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
/**
|
||||||
|
* 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';
|
||||||
|
import {execSync} from 'child_process';
|
||||||
|
const glob = promisify(globImport);
|
||||||
|
|
||||||
|
export interface Package {
|
||||||
|
dir: string;
|
||||||
|
json: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Workspaces {
|
||||||
|
rootPackage: Package;
|
||||||
|
packages: Package[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getWorkspaces(): Promise<Workspaces> {
|
||||||
|
const rootPackageJson = await fs.readJson(path.join(rootDir, 'package.json'));
|
||||||
|
const packageGlobs = rootPackageJson.workspaces.packages as string[];
|
||||||
|
const packages = 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,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
rootPackage: {
|
||||||
|
dir: rootDir,
|
||||||
|
json: rootPackageJson,
|
||||||
|
},
|
||||||
|
packages,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function bumpVersions({newVersion}: {newVersion?: string}) {
|
||||||
|
return await bumpWorkspaceVersions(await getWorkspaces(), newVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function savePackageJson({dir, json}: Package) {
|
||||||
|
await fs.writeJson(path.join(dir, 'package.json'), json, {
|
||||||
|
spaces: 2,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function bumpWorkspaceVersions(
|
||||||
|
{rootPackage, packages}: Workspaces,
|
||||||
|
newVersion?: string,
|
||||||
|
): Promise<string> {
|
||||||
|
newVersion = newVersion || (rootPackage.json.version as string);
|
||||||
|
if (rootPackage.json.version !== newVersion) {
|
||||||
|
rootPackage.json.version = newVersion;
|
||||||
|
await savePackageJson(rootPackage);
|
||||||
|
}
|
||||||
|
const localPackageNames = packages.map(({json}) => json.name as string);
|
||||||
|
for (const pkg of packages) {
|
||||||
|
const json = pkg.json;
|
||||||
|
let changed = false;
|
||||||
|
if (json.version !== newVersion) {
|
||||||
|
json.version = newVersion;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
if (json.dependencies) {
|
||||||
|
for (const localPackageName of localPackageNames) {
|
||||||
|
if (
|
||||||
|
json.dependencies[localPackageName] !== undefined &&
|
||||||
|
json.dependencies[localPackageName] !== newVersion
|
||||||
|
) {
|
||||||
|
json.dependencies[localPackageName] = newVersion;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (changed) {
|
||||||
|
await savePackageJson(pkg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function publishPackages({
|
||||||
|
newVersion,
|
||||||
|
proxy,
|
||||||
|
}: {
|
||||||
|
newVersion?: string;
|
||||||
|
proxy?: string;
|
||||||
|
}) {
|
||||||
|
const workspaces = await getWorkspaces();
|
||||||
|
const version = await bumpWorkspaceVersions(workspaces, newVersion);
|
||||||
|
let cmd = `yarn publish --new-version ${version}`;
|
||||||
|
if (proxy) {
|
||||||
|
cmd += ` --http-proxy ${proxy} --https-proxy ${proxy}`;
|
||||||
|
}
|
||||||
|
const publicPackages = workspaces.packages.filter((pkg) => !pkg.json.private);
|
||||||
|
for (const pkg of publicPackages) {
|
||||||
|
execSync(cmd, {cwd: pkg.dir, stdio: 'inherit'});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
"recursive-readdir": "2.2.2",
|
"recursive-readdir": "2.2.2",
|
||||||
"uuid": "^7.0.1",
|
"uuid": "^7.0.1",
|
||||||
"xdg-basedir": "^4.0.0",
|
"xdg-basedir": "^4.0.0",
|
||||||
"yargs": "^15.0.1",
|
"yargs": "^15.3.1",
|
||||||
"ws": "^7.2.3"
|
"ws": "^7.2.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2285,7 +2285,7 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@types/yargs-parser" "*"
|
"@types/yargs-parser" "*"
|
||||||
|
|
||||||
"@types/yargs@^15.0.0":
|
"@types/yargs@^15.0.0", "@types/yargs@^15.0.4":
|
||||||
version "15.0.4"
|
version "15.0.4"
|
||||||
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-15.0.4.tgz#7e5d0f8ca25e9d5849f2ea443cf7c402decd8299"
|
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-15.0.4.tgz#7e5d0f8ca25e9d5849f2ea443cf7c402decd8299"
|
||||||
integrity sha512-9T1auFmbPZoxHz0enUFlUuKRy3it01R+hlggyVUMtnCTQRunsQYifnSGb8hET4Xo8yiC0o0r1paW3ud5+rbURg==
|
integrity sha512-9T1auFmbPZoxHz0enUFlUuKRy3it01R+hlggyVUMtnCTQRunsQYifnSGb8hET4Xo8yiC0o0r1paW3ud5+rbURg==
|
||||||
@@ -11972,7 +11972,7 @@ yargs@^14.2.0:
|
|||||||
y18n "^4.0.0"
|
y18n "^4.0.0"
|
||||||
yargs-parser "^15.0.0"
|
yargs-parser "^15.0.0"
|
||||||
|
|
||||||
yargs@^15.0.0, yargs@^15.0.1, yargs@^15.1.0:
|
yargs@^15.0.0, yargs@^15.1.0, yargs@^15.3.1:
|
||||||
version "15.3.1"
|
version "15.3.1"
|
||||||
resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.3.1.tgz#9505b472763963e54afe60148ad27a330818e98b"
|
resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.3.1.tgz#9505b472763963e54afe60148ad27a330818e98b"
|
||||||
integrity sha512-92O1HWEjw27sBfgmXiixJWT5hRBp2eobqXicLtPBIDBhYB+1HpwZlXmbW2luivBJHBzki+7VyCLRtAkScbTBQA==
|
integrity sha512-92O1HWEjw27sBfgmXiixJWT5hRBp2eobqXicLtPBIDBhYB+1HpwZlXmbW2luivBJHBzki+7VyCLRtAkScbTBQA==
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ fi
|
|||||||
echo "Preparing release $VERSION..."
|
echo "Preparing release $VERSION..."
|
||||||
|
|
||||||
# Update all the packages included as workspaces to the very same version
|
# Update all the packages included as workspaces to the very same version
|
||||||
yarn --cwd "$DESKTOP_DIR" bump-workspace-versions "$VERSION"
|
yarn --cwd "$DESKTOP_DIR" bump-versions --new-version "$VERSION"
|
||||||
|
|
||||||
# Update react-native-flipper to the very same version
|
# Update react-native-flipper to the very same version
|
||||||
yarn --cwd "$SONAR_DIR"/react-native/react-native-flipper version --new-version "$VERSION" --no-git-tag-version
|
yarn --cwd "$SONAR_DIR"/react-native/react-native-flipper version --new-version "$VERSION" --no-git-tag-version
|
||||||
|
|||||||
Reference in New Issue
Block a user