Skip to content

Commit

Permalink
Update p5 version of example sketches (#150)
Browse files Browse the repository at this point in the history
* add p5 version update script

* update p5 version
  • Loading branch information
ziyuan-linn authored Jun 21, 2024
1 parent fc1b156 commit ee4a246
Show file tree
Hide file tree
Showing 34 changed files with 76 additions and 33 deletions.
2 changes: 1 addition & 1 deletion examples/bodyPose-blazePose-keypoints/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<head>
<meta charset="UTF-8" />
<title>ml5.js bodyPose BlazePose Detection Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>

Expand Down
2 changes: 1 addition & 1 deletion examples/bodyPose-blazePose-skeleton/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<head>
<meta charset="UTF-8" />
<title>ml5.js bodyPose BlazePose Skeleton Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>

Expand Down
2 changes: 1 addition & 1 deletion examples/bodyPose-keypoints/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<head>
<meta charset="UTF-8" />
<title>ml5.js bodyPose Detection Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>

Expand Down
2 changes: 1 addition & 1 deletion examples/bodyPose-skeleton/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<head>
<meta charset="UTF-8" />
<title>ml5.js bodyPose Skeleton Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>

Expand Down
2 changes: 1 addition & 1 deletion examples/bodySegmentation-mask-background/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ml5.js bodySegmentation Mask Background Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/bodySegmentation-mask-body-parts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ml5.js bodySegmentation Parts Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/bodySegmentation-mask-person/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ml5.js bodySegmentation Mask Person Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/bodySegmentation-select-bodypart/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ml5.js bodySegmentation Parts Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/faceMesh-bounding-box/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ml5.js faceMesh Bounding Box Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/faceMesh-keypoints-from-parts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ml5.js faceMesh Keypoints from Parts Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/faceMesh-keypoints/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ml5.js faceMesh Webcam Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/faceMesh-parts-bounding-box/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ml5.js faceMesh Parts Bounding Box Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/faceMesh-parts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ml5.js faceMesh p5 Webcam Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/faceMesh-shapes-from-parts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ml5.js faceMesh Shapes from Parts Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/faceMesh-single-image/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ml5.js faceMesh Image Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/handPose-detect-start-stop/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ml5.js handPose Start and Stop Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/handPose-keypoints/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ml5.js handPose Webcam Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/handPose-parts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ml5.js handPose p5 Webcam Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/handPose-single-image/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ml5.js handPose Image Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/imageClassifier-single-image/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ml5.js imageClassifier Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/imageClassifier-teachable-machine/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ml5.js imageClassifier + Teachable Machine Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/imageClassifier-webcam/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ml5.js imageClassifier Webcam Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/neuralNetwork-color-classifier/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ml5.js neuralNetwork Color Classifier Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/neuralNetwork-load-model/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ml5.js neuralNetwork Loading Pre-trained Model Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/neuralNetwork-mouse-gesture/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ml5.js neuralNetwork Gesture Classifier Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/neuralNetwork-train-and-save/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ml5.js neuralNetwork Training and Saving Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/neuroEvolution-flappy-bird/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ml5.js neuralNetwork Neuroevolution Flappy Bird</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/neuroEvolution-sensors/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ml5.js neuralNetwork Neuroevolution Sensors</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/neuroEvolution-steering/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ml5.js neuralNetwork Neuroevolution Steering</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/sentiment/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<html>
<head>
<title>ml5.js Sentiment Analysis Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>

Expand Down
2 changes: 1 addition & 1 deletion examples/soundClassifier-speech-command/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sound classification using SpeechCommands18w and p5.js</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.0/p5.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>

Expand Down
2 changes: 1 addition & 1 deletion examples/soundClassifier-teachable-machine/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sound classification using pre-trained custom model</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.0/p5.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="../../dist/ml5.js"></script>
</head>

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"format": "prettier --write \"**/*.js\"",
"postinstall": "patch-package",
"test": "jest --config tests/jest.config.js",
"upload-examples": "node scripts/uploadExamples.js"
"upload-examples": "node scripts/uploadExamples.js",
"update-p5-version": "node scripts/updateP5Version.js"
},
"files": [
"dist"
Expand Down
42 changes: 42 additions & 0 deletions scripts/updateP5Version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const fs = require("node:fs/promises");
const path = require("path");

const examplesPath = path.join(__dirname, "../examples");
/**
* a function that fetches the latest version of p5.js from the GitHub API
* @returns {Promise<string>} The latest version of p5.js
*/
async function getP5Version() {
const res = await fetch(
"https://api.github.com/repos/processing/p5.js/releases/latest"
);
const data = await res.json();
const version = data.tag_name.slice(1);
return version;
}

async function main() {
const version = await getP5Version();
console.log(`Updating p5.js to version ${version}...`);

const sketches = await fs.readdir(examplesPath);

for (const sketch of sketches) {
const sketchFiles = await fs.readdir(path.join(examplesPath, sketch));
for (const file of sketchFiles) {
if (file === "index.html") {
const filePath = path.join(examplesPath, sketch, file);
const fileContent = await fs.readFile(filePath, "utf-8");
const updatedContent = fileContent.replace(
/https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/p5.js\/\d+\.\d+\.\d+\/p5(\.min)?\.js/,
`https://cdnjs.cloudflare.com/ajax/libs/p5.js/${version}/p5.min.js`
);
await fs.writeFile(filePath, updatedContent);
}
}
}

console.log("p5.js version updated successfully!");
}

main();

0 comments on commit ee4a246

Please sign in to comment.