chore(readme): update readme unpkg link on each deploy

This commit is contained in:
Adam Bradley
2018-05-02 15:01:51 -05:00
parent 0f086ce7b5
commit 3b5365dd8a
3 changed files with 38 additions and 2 deletions

View File

@ -114,6 +114,9 @@ async function preparePackages(packages, version) {
// generate changelog
generateChangeLog(tasks);
// update core readme with version number
updateCoreReadme(tasks, version);
const listr = new Listr(tasks, { showSubtasks: true });
await listr.run();
}
@ -253,7 +256,7 @@ function updatePackageVersion(tasks, package, version) {
}
async function generateChangeLog(tasks) {
function generateChangeLog(tasks) {
tasks.push({
title: `Generate CHANGELOG.md`,
task: () => execa('npm', ['run', 'changelog'], { cwd: common.rootDir }),
@ -261,6 +264,14 @@ async function generateChangeLog(tasks) {
}
function updateCoreReadme(tasks, version) {
tasks.push({
title: `Update core README.md`,
task: () => execa('node', ['update-readme.js', version], { cwd: path.join(common.rootDir, 'core', 'scripts') }),
});
}
const SEMVER_INCREMENTS = ['patch', 'minor', 'major'];
const isValidVersion = input => Boolean(semver.valid(input));

View File

@ -20,7 +20,7 @@ The Ionic Core package contains the Web Components that make up the reusable UI
Easiest way to start using Ionic Core is by adding a script tag to the CDN:
<script src="https://unpkg.com/@ionic/core@latest/dist/ionic.js"></script>
<script src="https://unpkg.com/@ionic/core@4.0.0-alpha.4/dist/ionic.js"></script>
Any Ionic component added to the webpage will automatically load. This includes writing the component tag directly in HTML, or using JavaScript such as `document.createElement('ion-toggle')`.

View File

@ -0,0 +1,25 @@
// the unpkg link cannot use "latest" in the url
// so this script is to keep the link updated
// with the latest
const fs = require('fs-extra');
const path = require('path');
const version = process.argv[2];
if (!version) {
throw new Error('version arg missing');
}
const readmePath = path.join(__dirname, '..', 'README.md');
let readmeContent = fs.readFileSync(readmePath, 'utf-8');
// https://unpkg.com/@ionic/core@latest/dist/ionic.js
readmeContent = readmeContent.replace(
/https\:\/\/unpkg.com\/@ionic\/core@(.+?)\/dist\/ionic\.js/,
'https://unpkg.com/@ionic/core@' + version + '/dist/ionic.js'
);
fs.writeFileSync(readmePath, readmeContent);