mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-15 01:03:03 +08:00
chore(readme): update readme unpkg link on each deploy
This commit is contained in:
@ -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));
|
||||
|
@ -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')`.
|
||||
|
||||
|
25
core/scripts/update-readme.js
Normal file
25
core/scripts/update-readme.js
Normal 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);
|
Reference in New Issue
Block a user