chore(): improve publish scripts

This commit is contained in:
Manu Mtz.-Almeida
2018-03-22 14:45:41 +01:00
parent 6f5b86982c
commit 7b50ea974f
3 changed files with 46 additions and 16 deletions

View File

@ -18,10 +18,19 @@ async function main() {
const version = await askVersion(); const version = await askVersion();
await checkTagVersion(version); await checkTagVersion(version);
// compiler and verify projects (read-only)
await prepareProject('core', version); await prepareProject('core', version);
await prepareProject('angular', version, ['@ionic/core']); await prepareProject('angular', version, ['@ionic/core']);
// writes start here
// update package.json of each project
await updateVersion('core', version);
await updateVersion('angular', version);
// generate changelog
await generateChangeLog(version); await generateChangeLog(version);
process.exit(0); process.exit(0);
} catch(err) { } catch(err) {
console.log('\n', chalk.red(err), '\n'); console.log('\n', chalk.red(err), '\n');
@ -172,17 +181,21 @@ async function prepareProject(project, version, dependencies) {
{ {
title: 'Linking', title: 'Linking',
task: () => execa('npm', ['link'], { cwd: projectRoot }) task: () => execa('npm', ['link'], { cwd: projectRoot })
}, }
{
title: `Updating ${project}/package.json version ${chalk.dim(`(${version})`)}`,
task: () => execa('npm', ['version', version], { cwd: projectRoot }),
},
); );
const listr = new Listr(tasks, { showSubtasks: false }); const listr = new Listr(tasks, { showSubtasks: false });
await listr.run(); await listr.run();
} }
async function updateVersion(project, version) {
const projectRoot = common.projectPath(project);
const listr = new Listr([{
title: `Updating ${project}/package.json version ${chalk.dim(`(${version})`)}`,
task: () => execa('npm', ['version', version], { cwd: projectRoot }),
}]);
await listr.run();
}
async function generateChangeLog() { async function generateChangeLog() {
const rootDir = common.rootPath(); const rootDir = common.rootPath();

View File

@ -12,15 +12,16 @@ async function main() {
try { try {
const {version} = common.readPkg('core'); const {version} = common.readPkg('core');
// repo must be clean
await common.checkGit(); await common.checkGit();
await publishProject('core', version); // publish each project in NPM
await publishProject('angular', version); await publishProjects(['core', 'angular'], version);
// push commits and tags to git remote
await publishGit(version); await publishGit(version);
console.log(`\n @ionic/core ${version} published!! 🎉`); console.log(`\n${version} published!! 🎉\n`);
console.log(`@ionic/angular ${version} published!! 🎉\n`);
process.exit(0); process.exit(0);
} catch (err) { } catch (err) {
@ -29,12 +30,28 @@ async function main() {
} }
} }
async function publishProject(project, version) { async function publishProjects(projects, newVersion) {
const tasks = [];
projects.forEach((project) => {
const {name, version} = common.readPkg(project);
tasks.push({
title: `Checking version of name (must match: ${version})`,
task: () => {
if(newVersion !== version) {
throw new Error('version does not match');
}
}
});
});
projects.forEach((project) => {
const projectRoot = common.projectPath(project); const projectRoot = common.projectPath(project);
const listr = new Listr([{ tasks.push({
title: `Publish (latest) ${project} (v${version})`, title: `Publish (latest) ${project} (v${newVersion})`,
task: () => execa('npm', ['publish', '--tag', 'latest'], { cwd: projectRoot }) task: () => execa('npm', ['publish', '--tag', 'latest'], { cwd: projectRoot })
}], { showSubtasks: false }); });
});
const listr = new Listr(tasks);
await listr.run(); await listr.run();
} }

View File

@ -4,7 +4,7 @@
// -------------------------------------------------- // --------------------------------------------------
ion-modal { ion-modal {
@include position(0, null, null, 0); @include position(0);
position: absolute; position: absolute;