diff --git a/Composer/package.json b/Composer/package.json index 52a879a14e..619741f985 100644 --- a/Composer/package.json +++ b/Composer/package.json @@ -19,7 +19,7 @@ "packages/tools/language-servers/*" ], "scripts": { - "build": "node scripts/begin.js && yarn build:prod", + "build": "node scripts/update.js && node scripts/begin.js && yarn build:prod", "build:prod": "yarn build:dev && yarn build:server && yarn build:client", "build:dev": "yarn build:tools && yarn build:lib && yarn build:extensions", "build:lib": "yarn workspace @bfc/libs build:all", @@ -28,7 +28,7 @@ "build:client": "yarn workspace @bfc/client build", "build:tools": "yarn workspace @bfc/tools build:all", "start": "cross-env NODE_ENV=production PORT=3000 yarn start:server", - "startall": "concurrently --kill-others-on-fail \"npm:runtime\" \"npm:start\"", + "startall": "node scripts/update.js && concurrently --kill-others-on-fail \"npm:runtime\" \"npm:start\"", "start:dev": "concurrently \"npm:start:client\" \"npm:start:server:dev\"", "start:client": "yarn workspace @bfc/client start", "start:server": "yarn workspace @bfc/server start", diff --git a/Composer/scripts/update.js b/Composer/scripts/update.js new file mode 100644 index 0000000000..12e16bac9d --- /dev/null +++ b/Composer/scripts/update.js @@ -0,0 +1,29 @@ +const chalk = require('react-dev-utils/chalk'); +const { execSync } = require('child_process'); + +const RELEASE_BRANCH = 'stable'; +const branch = execSync("git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* (.*)/ \1/'"); +const trimmedBranch = branch + .toString() + .trim() + .replace(/\*\s?/, ''); + +if (trimmedBranch === RELEASE_BRANCH) { + console.log(chalk.yellow('Checking for updates...\n')); + try { + execSync('git fetch'); + const sha = execSync(`git rev-parse --short ${RELEASE_BRANCH}`).toString(); + const originSha = execSync(`git rev-parse --short origin/${RELEASE_BRANCH}`).toString(); + if (sha !== originSha) { + console.log( + chalk.yellow( + `An update to Composer is available.\n\nRun 'git pull origin stable' or fetch from origin/stable using another git-based tool.\n\nSee the CHANGELOG for more details.\nhttps://github.com/microsoft/BotFramework-Composer/blob/stable/CHANGELOG.md#releases\n` + ) + ); + } else { + console.log(chalk.green('You are using the most up to date version of Composer.')); + } + } catch (e) { + console.log(chalk.yellow('Unable to compare applications versions.. continuing')); + } +}