Skip to content

Commit ef0aabb

Browse files
authored
updated readme and readme updater (#632)
1 parent 70d6a53 commit ef0aabb

File tree

2 files changed

+25
-62
lines changed

2 files changed

+25
-62
lines changed

README.md

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,46 +21,34 @@ ml5.js is heavily inspired by [Processing](https://processing.org/) and [p5.js](
2121

2222
There are several ways you can use the ml5.js library:
2323

24-
<p id="latest-version">
2524

26-
* You can use the latest version (0.3.1) by adding it to the head section of your HTML document:
2725

28-
**v0.3.1**
29-
```javascript
30-
<script src="https://unpkg.com/[email protected]/dist/ml5.min.js" type="text/javascript"></script>
31-
```
3226

33-
</p data-id="latest-version">
34-
35-
36-
37-
* If you need to use an earlier version for any reason, you can change the version number.
3827

28+
<p id="latest-version">
3929

30+
* You can use the latest version (0.3.1) by adding it to the head section of your HTML document:
4031

41-
<p id="legacy-versions">
32+
**v0.3.1**
4233

43-
**v0.3.0**
34+
<script src="https://unpkg.com/[email protected]/dist/ml5.min.js" type="text/javascript"></script>
4435

45-
<script src="https://unpkg.com/[email protected]/dist/ml5.min.js" type="text/javascript"></script>
36+
</p data-id="latest-version">
37+
38+
4639

4740

48-
**v0.3.0**
49-
50-
<script src="https://unpkg.com/[email protected]/dist/ml5.min.js" type="text/javascript"></script>
51-
52-
53-
**v0.2.3**
54-
55-
<script src="https://unpkg.com/[email protected]/dist/ml5.min.js" type="text/javascript"></script>
56-
57-
58-
**v0.1.3**
5941

60-
<script src="https://unpkg.com/[email protected]/dist/ml5.min.js" type="text/javascript"></script>
42+
* If you need to use an earlier version for any reason, you can change the version number. The [previous versions of ml5 can be found here](https://www.npmjs.com/package/ml5). You can use those previous versions by replacing `<version>` with the ml5 version of interest:
6143

44+
```js
45+
<script src="https://unpkg.com/ml5@<version>/dist/ml5.min.js" type="text/javascript"></script>
46+
```
6247

63-
</p data-id="legacy-versions">
48+
For example:
49+
```js
50+
<script src="https://unpkg.com/[email protected]/dist/ml5.min.js" type="text/javascript"></script>
51+
```
6452

6553
* You can also reference "latest", but we do not recommend this as your code may break as we update ml5.
6654

scripts/updateReadme.js

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
const fs = require('fs');
2-
const oldVersionNumber = process.env.pversion;
3-
4-
function checkVersionGiven(){
5-
if(oldVersionNumber === undefined){
6-
console.log('🔥🔥🔥submit the previous version number 🔥🔥🔥');
7-
process.exit(22);
8-
}
9-
}
102

113
function getReadme(fpath){
12-
let readme = fs.readFileSync(fpath, 'utf8');
4+
5+
const readme = fs.readFileSync(fpath, 'utf8');
6+
137
return readme;
148
}
159

@@ -22,7 +16,6 @@ function readPackageJson(fpath){
2216
function makeNewVersionString(newVersionNumber){
2317

2418
const newVersionString = `
25-
2619
<p id="latest-version">
2720
2821
* You can use the latest version (${newVersionNumber}) by adding it to the head section of your HTML document:
@@ -31,41 +24,23 @@ function makeNewVersionString(newVersionNumber){
3124
3225
<script src="https://unpkg.com/ml5@${newVersionNumber}/dist/ml5.min.js" type="text/javascript"></script>
3326
34-
</p>
27+
</p data-id="latest-version">
3528
`
3629

3730
return newVersionString;
3831
}
3932

40-
function makeLegacyVersionString(oldVersionNumber){
41-
const legacyVersionString = `
42-
43-
<p id="legacy-versions">
44-
45-
**v${oldVersionNumber}**
46-
47-
<script src="https://unpkg.com/ml5@${oldVersionNumber}/dist/ml5.min.js" type="text/javascript"></script>
48-
`
49-
50-
return legacyVersionString
51-
}
52-
5333

5434
function make(){
55-
checkVersionGiven();
56-
let packageJson = readPackageJson('./package.json');
57-
const newVersionNumber = packageJson.version;
58-
59-
console.log(`updating version: ${oldVersionNumber} to version: ${newVersionNumber}`);
6035

36+
const packageJson = readPackageJson('./package.json');
37+
const newVersionNumber = packageJson.version;
6138
const newVersionString = makeNewVersionString(newVersionNumber);
62-
const legacyVersionString = makeLegacyVersionString(oldVersionNumber);
63-
39+
40+
console.log(`---- updating README to version ${newVersionNumber} ----`)
6441

65-
let readme = getReadme('./README.md');
66-
let newReadme = readme.replace(/<p id="latest-version">([\s\S]*)<\/p data-id="latest-version">/g, newVersionString);
67-
// add the last version to the legacy section
68-
newReadme = readme.replace(/<p id="legacy-versions">/g, legacyVersionString);
42+
const readme = getReadme('./README.md');
43+
const newReadme = readme.replace(/<p id="latest-version">([\s\S]*)<\/p data-id="latest-version">/g, newVersionString);
6944

7045
fs.writeFileSync('./README.md', newReadme);
7146

0 commit comments

Comments
 (0)