aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-04-19 13:10:48 +0800
committerFabio Berger <me@fabioberger.com>2018-04-19 13:10:48 +0800
commitfc2b7f747bf15b8c9329f2940ed2f6cf71353c33 (patch)
tree37429f4473542c071a8be28e29d1e91b5f38dea3
parent1a0d68d49a066d4624677eab518bdca0e6603fe3 (diff)
downloaddexon-sol-tools-fc2b7f747bf15b8c9329f2940ed2f6cf71353c33.tar
dexon-sol-tools-fc2b7f747bf15b8c9329f2940ed2f6cf71353c33.tar.gz
dexon-sol-tools-fc2b7f747bf15b8c9329f2940ed2f6cf71353c33.tar.bz2
dexon-sol-tools-fc2b7f747bf15b8c9329f2940ed2f6cf71353c33.tar.lz
dexon-sol-tools-fc2b7f747bf15b8c9329f2940ed2f6cf71353c33.tar.xz
dexon-sol-tools-fc2b7f747bf15b8c9329f2940ed2f6cf71353c33.tar.zst
dexon-sol-tools-fc2b7f747bf15b8c9329f2940ed2f6cf71353c33.zip
Add checks for the required local setup before running the publish script
-rw-r--r--packages/monorepo-scripts/src/publish.ts50
1 files changed, 50 insertions, 0 deletions
diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts
index a2d641ff9..9bd9ff6be 100644
--- a/packages/monorepo-scripts/src/publish.ts
+++ b/packages/monorepo-scripts/src/publish.ts
@@ -38,6 +38,11 @@ const packageNameToWebsitePath: { [name: string]: string } = {
};
(async () => {
+ const hasRequiredSetup = await checkPublishRequiredSetupAsync();
+ if (!hasRequiredSetup) {
+ return; // abort
+ }
+
// Fetch public, updated Lerna packages
const updatedPublicLernaPackages = await getUpdatedPublicLernaPackagesAsync();
@@ -107,6 +112,51 @@ package.ts. Please add an entry for it and try again.`,
}
}
+async function checkPublishRequiredSetupAsync(): Promise<boolean> {
+ // check to see if logged into npm before publishing (npm whoami)
+ try {
+ await execAsync(`sudo npm whoami`);
+ } catch (err) {
+ utils.log('You must be logged into npm in the commandline to publish. Run `npm login` and try again.');
+ return false;
+ }
+
+ // Check to see if Git creds setup (check for ENV 'GITHUB_PERSONAL_ACCESS_TOKEN_0X_JS')
+ if (_.isUndefined(process.env.GITHUB_PERSONAL_ACCESS_TOKEN_0X_JS)) {
+ utils.log(
+ 'You must have a Github personal access token set to an envVar named `GITHUB_PERSONAL_ACCESS_TOKEN_0X_JS`. Add it then try again.',
+ );
+ return false;
+ }
+ // Check NPM version is 5.X
+ const result = await execAsync(`npm --version`);
+ const version = result.stdout;
+ const versionSegments = version.split('.');
+ const majorVersion = _.parseInt(versionSegments[0]);
+ if (majorVersion < 5) {
+ utils.log('You npm version must be v5.x or higher. Upgrade your npm and try again.');
+ return false;
+ }
+
+ // Check that `aws` commandline is installed
+ try {
+ await execAsync(`aws help`);
+ } catch (err) {
+ utils.log('You must have `awscli` commandline tool installed. Install it and try again.');
+ return false;
+ }
+
+ // Check that `aws` creds are setup
+ try {
+ await execAsync(`aws sts get-caller-identity`);
+ } catch (err) {
+ utils.log('You must setup your AWS credentials by running `aws configure`. Do this and try again.');
+ return false;
+ }
+
+ return true;
+}
+
async function pushChangelogsToGithubAsync() {
await execAsync(`git add . --all`, { cwd: constants.monorepoRootPath });
await execAsync(`git commit -m "Updated CHANGELOGS"`, { cwd: constants.monorepoRootPath });