Allow registry to be configured in lerna.json
This commit is contained in:
@@ -9,5 +9,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"useWorkspaces": true
|
"useWorkspaces": true,
|
||||||
|
"registry": "http://localhost:4873"
|
||||||
}
|
}
|
||||||
|
@@ -50,7 +50,7 @@ async function checkGitTagsForNextVersionAndDeleteIfExistAsync(updatedPublicPack
|
|||||||
async function checkCurrentVersionMatchesLatestPublishedNPMPackageAsync(
|
async function checkCurrentVersionMatchesLatestPublishedNPMPackageAsync(
|
||||||
updatedPublicPackages: Package[],
|
updatedPublicPackages: Package[],
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
utils.log('Check package versions against npmjs.org...');
|
utils.log('Check package versions against npm registry...');
|
||||||
const versionMismatches = [];
|
const versionMismatches = [];
|
||||||
for (const pkg of updatedPublicPackages) {
|
for (const pkg of updatedPublicPackages) {
|
||||||
const packageName = pkg.packageJson.name;
|
const packageName = pkg.packageJson.name;
|
||||||
|
@@ -172,8 +172,7 @@ async function updateChangeLogsAsync(updatedPublicPackages: Package[]): Promise<
|
|||||||
async function lernaPublishAsync(packageToVersionChange: { [name: string]: string }): Promise<void> {
|
async function lernaPublishAsync(packageToVersionChange: { [name: string]: string }): Promise<void> {
|
||||||
// HACK: Lerna publish does not provide a way to specify multiple package versions via
|
// HACK: Lerna publish does not provide a way to specify multiple package versions via
|
||||||
// flags so instead we need to interact with their interactive prompt interface.
|
// flags so instead we need to interact with their interactive prompt interface.
|
||||||
const PACKAGE_REGISTRY = 'https://registry.npmjs.org/';
|
const child = spawn('lerna', ['publish'], {
|
||||||
const child = spawn('lerna', ['publish', `--registry=${PACKAGE_REGISTRY}`], {
|
|
||||||
cwd: constants.monorepoRootPath,
|
cwd: constants.monorepoRootPath,
|
||||||
});
|
});
|
||||||
let shouldPrintOutput = false;
|
let shouldPrintOutput = false;
|
||||||
|
@@ -1,9 +1,11 @@
|
|||||||
|
import * as fs from 'fs';
|
||||||
import 'isomorphic-fetch';
|
import 'isomorphic-fetch';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { PackageRegistryJson } from '../types';
|
import { PackageRegistryJson } from '../types';
|
||||||
|
|
||||||
const NPM_REGISTRY_BASE_URL = 'https://registry.npmjs.org';
|
const lernaJson = JSON.parse(fs.readFileSync('lerna.json').toString());
|
||||||
|
const NPM_REGISTRY_BASE_URL = lernaJson.registry;
|
||||||
const SUCCESS_STATUS = 200;
|
const SUCCESS_STATUS = 200;
|
||||||
const NOT_FOUND_STATUS = 404;
|
const NOT_FOUND_STATUS = 404;
|
||||||
|
|
||||||
@@ -15,7 +17,7 @@ export const npmUtils = {
|
|||||||
if (response.status === NOT_FOUND_STATUS) {
|
if (response.status === NOT_FOUND_STATUS) {
|
||||||
return undefined;
|
return undefined;
|
||||||
} else if (response.status !== SUCCESS_STATUS) {
|
} else if (response.status !== SUCCESS_STATUS) {
|
||||||
throw new Error(`Request to ${url} failed. Check your internet connection and that npmjs.org is up.`);
|
throw new Error(`Request to ${url} failed. Check your internet connection and that npm registry is up.`);
|
||||||
}
|
}
|
||||||
const packageRegistryJson = await response.json();
|
const packageRegistryJson = await response.json();
|
||||||
return packageRegistryJson;
|
return packageRegistryJson;
|
||||||
|
Reference in New Issue
Block a user