feat(package): release-next script

This commit is contained in:
Pooya Parsa 2017-11-24 19:47:27 +03:30
parent 79ce2ebc5d
commit c7a0d3d55a
No known key found for this signature in database
GPG Key ID: C3C77C557D8883CD
3 changed files with 42 additions and 2 deletions

View File

@ -33,3 +33,12 @@ jobs:
- run:
name: Tests
command: yarn test && yarn coverage
# Release next
- run:
name: Release Next version
command: |
if [ "${CIRCLE_BRANCH}" == "dev" ]; then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm run release-next
fi

31
build/release-next.js Normal file
View File

@ -0,0 +1,31 @@
#!/usr/bin/env node
const { readFileSync, writeFileSync } = require('fs-extra')
const { resolve } = require('path')
const { spawnSync } = require('child_process')
// paths
const packagePath = resolve(__dirname, '..', 'package.json')
// Read original contents of package.json
const originalPackage = readFileSync(packagePath, 'utf-8')
// Write to backup file
// writeFileSync(packagePath + '.backup', originalPackage)
// Parse package.json
const p = JSON.parse(originalPackage)
// Change package name
p.name = 'nuxt-next'
// Get latest git commit id
const gitCommit = String(spawnSync('git', 'rev-parse --short HEAD'.split(' ')).stdout).trim()
// Version with git tag
p.version = p.version.split('-')[0] + '-gh-' + gitCommit
// Write package.json
writeFileSync(packagePath, JSON.stringify(p, null, 2) + '\r\n')
// Log
console.log(p.name + '@' + p.version) // eslint-disable-line no-console

View File

@ -56,8 +56,8 @@
"watch": "npm run build:nuxt -- -w",
"make-start": "node ./build/start.js",
"precommit": "npm run lint",
"prepare": "npm run build && npm run make-start",
"postinstall": "opencollective postinstall || exit 0"
"postinstall": "opencollective postinstall || exit 0",
"release-next": "npm run build && node ./build/release-next && npm publish --tag next"
},
"engines": {
"node": ">=6.11",