forked from ionic-team/ionic-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from ionic-team/master
pull `master`
- Loading branch information
Showing
38 changed files
with
644 additions
and
355 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
const tc = require('turbocolor'); | ||
const semver = require('semver'); | ||
const execa = require('execa'); | ||
const inquirer = require('inquirer'); | ||
const Listr = require('listr'); | ||
const fs = require('fs-extra'); | ||
|
||
const common = require('./common'); | ||
|
||
const DIST_TAG = 'dev'; | ||
|
||
async function main() { | ||
const { packages } = common; | ||
|
||
const orgPkg = packages.map(package => { | ||
const packageJsonPath = common.packagePath(package); | ||
return { | ||
filePath: packageJsonPath, | ||
packageContent: fs.readFileSync(packageJsonPath, 'utf-8') | ||
} | ||
}); | ||
|
||
try { | ||
const originalVersion = common.readPkg('core').version; | ||
const devVersion = await getDevVersion(originalVersion); | ||
|
||
const confirm = await askDevVersion(devVersion); | ||
if (!confirm) { | ||
console.log(``); | ||
return; | ||
} | ||
|
||
const tasks = []; | ||
|
||
await setPackageVersionChanges(packages, devVersion); | ||
|
||
packages.forEach(package => { | ||
common.prepareDevPackage(tasks, package, devVersion); | ||
}); | ||
common.publishPackages(tasks, packages, devVersion, DIST_TAG); | ||
|
||
const listr = new Listr(tasks); | ||
await listr.run(); | ||
|
||
console.log(`\nionic ${devVersion} published!! 🎉\n`); | ||
|
||
} catch (err) { | ||
console.log('\n', tc.red(err), '\n'); | ||
process.exit(1); | ||
} | ||
|
||
orgPkg.forEach(pkg => { | ||
fs.writeFileSync(pkg.filePath, pkg.packageContent); | ||
}); | ||
} | ||
|
||
async function askDevVersion(devVersion) { | ||
|
||
const prompts = [ | ||
{ | ||
type: 'confirm', | ||
name: 'confirm', | ||
value: true, | ||
message: () => { | ||
return `Publish the dev build ${tc.cyan(devVersion)}?`; | ||
} | ||
} | ||
]; | ||
|
||
const { confirm } = await inquirer.prompt(prompts); | ||
return confirm; | ||
} | ||
|
||
async function setPackageVersionChanges(packages, version) { | ||
await Promise.all(packages.map(async package => { | ||
if (package !== 'core') { | ||
const pkg = common.readPkg(package); | ||
common.updateDependency(pkg, '@ionic/core', version); | ||
common.writePkg(package, pkg); | ||
} | ||
const projectRoot = common.projectPath(package); | ||
await execa('npm', ['version', version], { cwd: projectRoot }); | ||
})); | ||
} | ||
|
||
async function getDevVersion(originalVersion) { | ||
const { stdout: sha } = await execa('git', ['log', '-1', '--format=%H']); | ||
const shortSha = sha.substring(0, 7); | ||
const baseVersion = semver.inc(originalVersion, 'minor'); | ||
|
||
const d = new Date(); | ||
|
||
let timestamp = (d.getUTCFullYear() + ''); | ||
timestamp += ('0' + (d.getUTCMonth() + 1)).slice(-2); | ||
timestamp += ('0' + d.getUTCDate()).slice(-2); | ||
timestamp += ('0' + d.getUTCHours()).slice(-2); | ||
timestamp += ('0' + d.getUTCMinutes()).slice(-2); | ||
|
||
return `${baseVersion}-${DIST_TAG}.${timestamp}.${shortSha}`; | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.