@justeat/fozzie-updater
Advanced tools
Comparing version 0.2.5 to 0.3.5
@@ -6,2 +6,10 @@ # Changelog | ||
v0.3.5 | ||
------------------------------ | ||
*August 15, 2018* | ||
### Added | ||
- package service | ||
v0.2.5 | ||
@@ -8,0 +16,0 @@ ------------------------------ |
const log = base.require('log') | ||
const changelog = base.require('services/changelog') | ||
const package = base.require('services/package') | ||
@@ -10,11 +11,16 @@ module.exports = { | ||
command.action((args, cb) => { | ||
changelog | ||
.compose(state) | ||
.then( | ||
() => { | ||
log.success('Changelog successfully updated') | ||
process.exit(0) | ||
}, | ||
err => log.error(err) | ||
) | ||
Promise.all([ | ||
package | ||
.updateVersion(state.version) | ||
.then(() => log.success('package.json successfully updated')), | ||
changelog | ||
.compose(state) | ||
.then(() => log.success('CHANGELOG successfully updated')) | ||
]) | ||
.then( | ||
() => process.exit(0), | ||
err => log.error(err) | ||
) | ||
cb() | ||
@@ -21,0 +27,0 @@ }) |
exports.app = () => { | ||
// node functions | ||
const fs = require('fs') | ||
const path = require('path') | ||
const { promisify } = require('util') | ||
// register global methods | ||
global.base = { | ||
require(basePath) { | ||
return require(path.join(__dirname, basePath)) | ||
} | ||
filePath: filePath => path.join(process.cwd(), filePath), | ||
require: basePath => require(path.join(__dirname, basePath)), | ||
// promisify fs methods | ||
...['exists', 'readFile', 'writeFile'].reduce((p, func) => { | ||
p[func] = promisify(fs[func]) | ||
return p | ||
}, {}) | ||
} | ||
const fs = require('fs') | ||
const path = require('path') | ||
const log = base.require('log') | ||
@@ -16,25 +25,26 @@ const config = base.require('config') | ||
const commands = base.require('commands') | ||
const package = base.require('services/package') | ||
// NOTE: should ideally make this async/await function | ||
// initialize | ||
try { | ||
const packageJsonPath = path.join(process.cwd(), 'package.json') | ||
const packageJson = fs.readFileSync(packageJsonPath) | ||
state.version = JSON.parse(packageJson).version | ||
package | ||
.getVersion() | ||
.then(version => { | ||
// NOTE: easiest way to make change to version partial | ||
state._version[config.versionBump]++ | ||
} catch(e) { | ||
log.error('package.json not found', e) | ||
process.exit(1) | ||
} | ||
state.version = version | ||
// bootstrap all registered commands | ||
Object | ||
.keys(commands) | ||
.forEach(key => { | ||
if (key !== 'bootstrap') { | ||
commands.bootstrap(commands[key]) | ||
} | ||
// NOTE: easiest way to make change to version partial | ||
state._version[config.versionBump]++ | ||
// bootstrap all registered commands | ||
Object | ||
.keys(commands) | ||
.forEach(key => { | ||
if (key !== 'bootstrap') { | ||
commands.bootstrap(commands[key]) | ||
} | ||
}) | ||
}) | ||
} |
@@ -1,12 +0,4 @@ | ||
const fs = require('fs') | ||
const path = require('path') | ||
const { promisify } = require('util') | ||
const template = require('./template') | ||
const filePath = base.filePath('CHANGELOG.md') | ||
const fileExists = promisify(fs.exists) | ||
const readFile = promisify(fs.readFile) | ||
const writeFile = promisify(fs.writeFile) | ||
const filePath = path.join(process.cwd(), 'CHANGELOG.md') | ||
module.exports = { | ||
@@ -16,8 +8,8 @@ summarise: template.summarise, | ||
const contents = | ||
await fileExists(filePath) | ||
? await readFile(filePath, 'utf8') | ||
await base.exists(filePath) | ||
? await base.readFile(filePath, 'utf8') | ||
: '' | ||
const output = template.compose(state, contents) | ||
return await writeFile(filePath, output, 'utf8') | ||
return await base.writeFile(filePath, output, 'utf8') | ||
} | ||
} |
{ | ||
"name": "@justeat/fozzie-updater", | ||
"description": "Common update for use in Fozzie projects.", | ||
"version": "0.2.5", | ||
"files": [ | ||
"bin", | ||
"lib" | ||
], | ||
"homepage": "https://github.com/justeat/fozzie-updater", | ||
"contributors": [ | ||
"Github contributors <https://github.com/justeat/fozzie-updater/graphs/contributors>" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:justeat/fozzie-updater.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/justeat/fozzie-updater/issues" | ||
}, | ||
"license": "Apache-2.0", | ||
"engines": { | ||
"node": ">=6.14.0" | ||
}, | ||
"dependencies": { | ||
"chalk": "2.4.1", | ||
"dayjs": "1.7.5", | ||
"vorpal": "1.12.0" | ||
}, | ||
"devDependencies": {}, | ||
"keywords": [ | ||
"fozzie" | ||
], | ||
"scripts": { | ||
"start": "node bin/fozzie-updater.js" | ||
}, | ||
"preferGlobal": true, | ||
"bin": { | ||
"fozzie-updater": "bin/fozzie-updater.js" | ||
} | ||
} | ||
"name": "@justeat/fozzie-updater", | ||
"description": "Common update for use in Fozzie projects.", | ||
"version": "0.3.5", | ||
"files": [ | ||
"bin", | ||
"lib" | ||
], | ||
"homepage": "https://github.com/justeat/fozzie-updater", | ||
"contributors": [ | ||
"Github contributors <https://github.com/justeat/fozzie-updater/graphs/contributors>" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:justeat/fozzie-updater.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/justeat/fozzie-updater/issues" | ||
}, | ||
"license": "Apache-2.0", | ||
"engines": { | ||
"node": ">=6.14.0" | ||
}, | ||
"dependencies": { | ||
"chalk": "2.4.1", | ||
"dayjs": "1.7.5", | ||
"vorpal": "1.12.0" | ||
}, | ||
"devDependencies": {}, | ||
"keywords": [ | ||
"fozzie" | ||
], | ||
"scripts": { | ||
"start": "node bin/fozzie-updater.js" | ||
}, | ||
"preferGlobal": true, | ||
"bin": { | ||
"fozzie-updater": "bin/fozzie-updater.js" | ||
} | ||
} |
@@ -45,3 +45,2 @@ # Fozzie Updater | ||
## TODO | ||
- Update `package.json` | ||
- Create tag | ||
@@ -48,0 +47,0 @@ - Publish to npm |
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
9952
17
277
2
50