Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add startup script to check for oudated versions #1674

Merged
merged 8 commits into from
Dec 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Composer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand 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",
Expand Down
29 changes: 29 additions & 0 deletions Composer/scripts/update.js
Original file line number Diff line number Diff line change
@@ -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'));
}
}