Skip to content

Commit

Permalink
fix: fixing example publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jan 28, 2018
1 parent e3ca364 commit a333610
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 62 deletions.
54 changes: 0 additions & 54 deletions .circleci/release_example

This file was deleted.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
"@types/yeoman-generator": "^2.0.1",
"@types/yosay": "^0.0.29",
"eslint": "^4.16.0",
"execa": "^0.9.0",
"fs-extra": "^5.0.0",
"husky": "^0.14.3",
"mocha": "^5.0.0",
"mocha-junit-reporter": "^1.17.0",
Expand Down
9 changes: 1 addition & 8 deletions release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,9 @@ module.exports = {
'@semantic-release/github',
],
publish: [
{
path: '@semantic-release/exec',
cmd: './.circleci/release_example ${nextRelease.version} ${nextRelease.type} ${nextRelease.notes}',
},
{path: './scripts/release_example'},
'@semantic-release/changelog',
'@semantic-release/npm',
{
path: '@semantic-release/git',
assets: ['package.json', 'CHANGELOG.md'],
},
'@semantic-release/github',
],
}
59 changes: 59 additions & 0 deletions scripts/release_example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* eslint-disable no-console */

module.exports = (_, options) => {
const sh = require('shelljs')
const execa = require('execa')
const fs = require('fs-extra')
const path = require('path')

sh.set('-ev')

sh.exec('yarn link')
const version = options.nextRelease.version
const releaseType = options.nextRelease.type
const notes = options.nextRelease.notes

const examples = [
'example-single-js',
'example-single-ts',
'example-plugin-js',
'example-plugin-ts',
'example-multi-js',
'example-multi-ts',
]

examples.forEach(example => {
const [, type, format] = example.split('-')

const options = format === 'typescript' ?
'--options=typescript,mocha,semantic-release' :
'--options=mocha,semantic-release'

const d = path.join(__dirname, '../tmp/examples', example)
sh.mkdir('-p', path.dirname(d))
sh.exec(`git clone git@github.com:dxcli/${example} ${d}`)
sh.cd(d)
const pjson = fs.readJSONSync('package.json')

let files = sh.ls('-A', '.')
files = files.filter(f => !['.git', 'CHANGELOG.md'].includes(f))
sh.rm('-rf', files)

fs.outputJSONSync('package.json', {
name: `@dxcli/${example}`,
repository: `dxcli/${example}`,
author: pjson.author,
version: pjson.version,
description: pjson.description,
})

sh.exec(`create-dxcli ${type} --force --defaults ${options}`)
sh.exec('git add -A')
try {
execa.sync('git', ['commit', '-m', `"${releaseType === 'patch' ? 'fix' : 'feat'}: create-dxcli v${version}"\n\n${notes}`], {stdio: 'inherit'})
sh.exec('git push')
} catch (err) {
console.error(err)
}
})
}

0 comments on commit a333610

Please sign in to comment.