diff --git a/.scripts/prepare.js b/.scripts/prepare.js
index 55d7894c3c..968275e625 100644
--- a/.scripts/prepare.js
+++ b/.scripts/prepare.js
@@ -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));
diff --git a/core/README.md b/core/README.md
index 389ad6615e..ef6da81cf1 100644
--- a/core/README.md
+++ b/core/README.md
@@ -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:
-
+
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')`.
diff --git a/core/scripts/update-readme.js b/core/scripts/update-readme.js
new file mode 100644
index 0000000000..14f3442cb6
--- /dev/null
+++ b/core/scripts/update-readme.js
@@ -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);