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

Version data file management script #1

Merged
merged 1 commit into from Jan 16, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Version data file management script

  * Updates osx.json and winx64.json
  * Handles version and notes
  * Allows preview without --overwrite parameter
  • Loading branch information
aekeus committed Jan 16, 2016
commit bf0acf8272c72225556969f9580611d4ab48fccc
@@ -15,3 +15,11 @@ GET /1/release/{platform}/{version} - get latest release meta-data if newer than
## Start

`npm run build && npm start`

## Update

`node tools/update.js --version=X.X.X --notes="Release notes" --overwrite`

## Verification

`npm run verify`
@@ -1,6 +1,6 @@
{
"name": "vault-updater",
"version": "0.0.1",
"version": "0.0.2",
"description": "Auto-update server for Brave laptop browser",
"main": "index.js",
"scripts": {
@@ -24,7 +24,8 @@
"joi": "^7.0.1",
"kerberos": "0.0.17",
"mongodb": "^2.1.4",
"underscore": "^1.8.3"
"underscore": "^1.8.3",
"yargs": "^3.31.0"
},
"devDependencies": {
"standard": "^5.4.1"
@@ -0,0 +1,47 @@
/*
Update metadata for release
*/

var fs = require('fs')
var path = require('path')
var _ = require('underscore')

var args = require('yargs')
.usage('Update version files\n\nNote: Will not replace data files unless --overwrite flag set\n\nnode $0 --version=X.X.X --notes="release notes" --overwrite')
.demand(['version', 'notes'])
.default('overwrite', false)
.argv

if (!args.version.match(/^[0-9]+\.[0-9]+\.[0-9]+$/)) {
throw "Invalid version format. Must be X.X.X"
}

const OSX_TEMPLATE = 'https://brave-download.global.ssl.fastly.net/releases/VERSION/osx/Brave-VERSION.zip'

var winx64_entry = {
version: args.version,
name: 'Brave ' + args.version,
pub_date: (new Date()).toISOString(),
notes: args.notes
}

var osx_entry = _.clone(winx64_entry)
osx_entry.url = OSX_TEMPLATE
osx_entry.url = osx_entry.url.replace(/VERSION/g, args.version)

var winx64_json = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'data', 'winx64.json')))
var osx_json = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'data', 'osx.json')))

winx64_json.unshift(winx64_entry)
osx_json.unshift(osx_entry)

console.log("Contents")
console.log(winx64_json)
console.log(osx_json)

if (args.overwrite) {
console.log("Writing data files")
fs.writeFileSync(path.join(__dirname, '..', 'data', 'winx64.json'), JSON.stringify(winx64_json, null, 2))
fs.writeFileSync(path.join(__dirname, '..', 'data', 'osx.json'), JSON.stringify(osx_json, null, 2))
console.log("Done")
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.