diff --git a/examples/bodyPose-blazePose-keypoints/index.html b/examples/bodyPose-blazePose-keypoints/index.html
index 3da4dd6f..dbefaf17 100644
--- a/examples/bodyPose-blazePose-keypoints/index.html
+++ b/examples/bodyPose-blazePose-keypoints/index.html
@@ -10,7 +10,7 @@
ml5.js bodyPose BlazePose Detection Example
-
+
diff --git a/examples/bodyPose-blazePose-skeleton/index.html b/examples/bodyPose-blazePose-skeleton/index.html
index d617f66f..1f2ca3b0 100644
--- a/examples/bodyPose-blazePose-skeleton/index.html
+++ b/examples/bodyPose-blazePose-skeleton/index.html
@@ -10,7 +10,7 @@
ml5.js bodyPose BlazePose Skeleton Example
-
+
diff --git a/examples/bodyPose-keypoints/index.html b/examples/bodyPose-keypoints/index.html
index 22d2d581..811ee61f 100644
--- a/examples/bodyPose-keypoints/index.html
+++ b/examples/bodyPose-keypoints/index.html
@@ -10,7 +10,7 @@
ml5.js bodyPose Detection Example
-
+
diff --git a/examples/bodyPose-skeleton/index.html b/examples/bodyPose-skeleton/index.html
index bc4e2914..08a1fb65 100644
--- a/examples/bodyPose-skeleton/index.html
+++ b/examples/bodyPose-skeleton/index.html
@@ -10,7 +10,7 @@
ml5.js bodyPose Skeleton Example
-
+
diff --git a/examples/bodySegmentation-mask-background/index.html b/examples/bodySegmentation-mask-background/index.html
index cdd96672..5e9ed6a5 100644
--- a/examples/bodySegmentation-mask-background/index.html
+++ b/examples/bodySegmentation-mask-background/index.html
@@ -13,7 +13,7 @@
ml5.js bodySegmentation Mask Background Example
-
+
diff --git a/examples/bodySegmentation-mask-body-parts/index.html b/examples/bodySegmentation-mask-body-parts/index.html
index 67a317df..54111ef3 100644
--- a/examples/bodySegmentation-mask-body-parts/index.html
+++ b/examples/bodySegmentation-mask-body-parts/index.html
@@ -13,7 +13,7 @@
ml5.js bodySegmentation Parts Example
-
+
diff --git a/examples/bodySegmentation-mask-person/index.html b/examples/bodySegmentation-mask-person/index.html
index 15abee40..d7932242 100644
--- a/examples/bodySegmentation-mask-person/index.html
+++ b/examples/bodySegmentation-mask-person/index.html
@@ -13,7 +13,7 @@
ml5.js bodySegmentation Mask Person Example
-
+
diff --git a/examples/bodySegmentation-select-bodypart/index.html b/examples/bodySegmentation-select-bodypart/index.html
index 67a317df..54111ef3 100644
--- a/examples/bodySegmentation-select-bodypart/index.html
+++ b/examples/bodySegmentation-select-bodypart/index.html
@@ -13,7 +13,7 @@
ml5.js bodySegmentation Parts Example
-
+
diff --git a/examples/faceMesh-bounding-box/index.html b/examples/faceMesh-bounding-box/index.html
index 2fd3083e..0f44ca8f 100644
--- a/examples/faceMesh-bounding-box/index.html
+++ b/examples/faceMesh-bounding-box/index.html
@@ -13,7 +13,7 @@
ml5.js faceMesh Bounding Box Example
-
+
diff --git a/examples/faceMesh-keypoints-from-parts/index.html b/examples/faceMesh-keypoints-from-parts/index.html
index 11e3b271..4bd649e7 100644
--- a/examples/faceMesh-keypoints-from-parts/index.html
+++ b/examples/faceMesh-keypoints-from-parts/index.html
@@ -13,7 +13,7 @@
ml5.js faceMesh Keypoints from Parts Example
-
+
diff --git a/examples/faceMesh-keypoints/index.html b/examples/faceMesh-keypoints/index.html
index 0eefbdeb..0a07e429 100644
--- a/examples/faceMesh-keypoints/index.html
+++ b/examples/faceMesh-keypoints/index.html
@@ -13,7 +13,7 @@
ml5.js faceMesh Webcam Example
-
+
diff --git a/examples/faceMesh-parts-bounding-box/index.html b/examples/faceMesh-parts-bounding-box/index.html
index d3c4dfdc..a61060fc 100644
--- a/examples/faceMesh-parts-bounding-box/index.html
+++ b/examples/faceMesh-parts-bounding-box/index.html
@@ -13,7 +13,7 @@
ml5.js faceMesh Parts Bounding Box Example
-
+
diff --git a/examples/faceMesh-parts/index.html b/examples/faceMesh-parts/index.html
index 8e6f8c27..c6f9e6c2 100644
--- a/examples/faceMesh-parts/index.html
+++ b/examples/faceMesh-parts/index.html
@@ -13,7 +13,7 @@
ml5.js faceMesh p5 Webcam Example
-
+
diff --git a/examples/faceMesh-shapes-from-parts/index.html b/examples/faceMesh-shapes-from-parts/index.html
index b310f7f2..fe57e1a7 100644
--- a/examples/faceMesh-shapes-from-parts/index.html
+++ b/examples/faceMesh-shapes-from-parts/index.html
@@ -13,7 +13,7 @@
ml5.js faceMesh Shapes from Parts Example
-
+
diff --git a/examples/faceMesh-single-image/index.html b/examples/faceMesh-single-image/index.html
index e48070ca..4eb134a5 100644
--- a/examples/faceMesh-single-image/index.html
+++ b/examples/faceMesh-single-image/index.html
@@ -13,7 +13,7 @@
ml5.js faceMesh Image Example
-
+
diff --git a/examples/handPose-detect-start-stop/index.html b/examples/handPose-detect-start-stop/index.html
index ccd05afb..f9a10ddd 100644
--- a/examples/handPose-detect-start-stop/index.html
+++ b/examples/handPose-detect-start-stop/index.html
@@ -13,7 +13,7 @@
ml5.js handPose Start and Stop Example
-
+
diff --git a/examples/handPose-keypoints/index.html b/examples/handPose-keypoints/index.html
index 00ce8926..9277dfa0 100644
--- a/examples/handPose-keypoints/index.html
+++ b/examples/handPose-keypoints/index.html
@@ -13,7 +13,7 @@
ml5.js handPose Webcam Example
-
+
diff --git a/examples/handPose-parts/index.html b/examples/handPose-parts/index.html
index 5da0de32..0309b2ac 100644
--- a/examples/handPose-parts/index.html
+++ b/examples/handPose-parts/index.html
@@ -13,7 +13,7 @@
ml5.js handPose p5 Webcam Example
-
+
diff --git a/examples/handPose-single-image/index.html b/examples/handPose-single-image/index.html
index 4e8690ca..35c47592 100644
--- a/examples/handPose-single-image/index.html
+++ b/examples/handPose-single-image/index.html
@@ -13,7 +13,7 @@
ml5.js handPose Image Example
-
+
diff --git a/examples/imageClassifier-single-image/index.html b/examples/imageClassifier-single-image/index.html
index f3486335..1d7d3724 100644
--- a/examples/imageClassifier-single-image/index.html
+++ b/examples/imageClassifier-single-image/index.html
@@ -13,7 +13,7 @@
ml5.js imageClassifier Example
-
+
diff --git a/examples/imageClassifier-teachable-machine/index.html b/examples/imageClassifier-teachable-machine/index.html
index 4326e12e..6d4d1448 100644
--- a/examples/imageClassifier-teachable-machine/index.html
+++ b/examples/imageClassifier-teachable-machine/index.html
@@ -13,7 +13,7 @@
ml5.js imageClassifier + Teachable Machine Example
-
+
diff --git a/examples/imageClassifier-webcam/index.html b/examples/imageClassifier-webcam/index.html
index e6a1e2c4..4900210c 100644
--- a/examples/imageClassifier-webcam/index.html
+++ b/examples/imageClassifier-webcam/index.html
@@ -13,7 +13,7 @@
ml5.js imageClassifier Webcam Example
-
+
diff --git a/examples/neuralNetwork-color-classifier/index.html b/examples/neuralNetwork-color-classifier/index.html
index 1b0c97c0..369514dd 100644
--- a/examples/neuralNetwork-color-classifier/index.html
+++ b/examples/neuralNetwork-color-classifier/index.html
@@ -13,7 +13,7 @@
ml5.js neuralNetwork Color Classifier Example
-
+
diff --git a/examples/neuralNetwork-load-model/index.html b/examples/neuralNetwork-load-model/index.html
index 607c7a84..a2c4a5fd 100644
--- a/examples/neuralNetwork-load-model/index.html
+++ b/examples/neuralNetwork-load-model/index.html
@@ -13,7 +13,7 @@
ml5.js neuralNetwork Loading Pre-trained Model Example
-
+
diff --git a/examples/neuralNetwork-mouse-gesture/index.html b/examples/neuralNetwork-mouse-gesture/index.html
index 93fc468d..c406a501 100644
--- a/examples/neuralNetwork-mouse-gesture/index.html
+++ b/examples/neuralNetwork-mouse-gesture/index.html
@@ -13,7 +13,7 @@
ml5.js neuralNetwork Gesture Classifier Example
-
+
diff --git a/examples/neuralNetwork-train-and-save/index.html b/examples/neuralNetwork-train-and-save/index.html
index 14f95ab9..a8a1c9c0 100644
--- a/examples/neuralNetwork-train-and-save/index.html
+++ b/examples/neuralNetwork-train-and-save/index.html
@@ -13,7 +13,7 @@
ml5.js neuralNetwork Training and Saving Example
-
+
diff --git a/examples/neuroEvolution-flappy-bird/index.html b/examples/neuroEvolution-flappy-bird/index.html
index 15b81124..ab498dcf 100644
--- a/examples/neuroEvolution-flappy-bird/index.html
+++ b/examples/neuroEvolution-flappy-bird/index.html
@@ -13,7 +13,7 @@
ml5.js neuralNetwork Neuroevolution Flappy Bird
-
+
diff --git a/examples/neuroEvolution-sensors/index.html b/examples/neuroEvolution-sensors/index.html
index 12602daf..2f5765e1 100644
--- a/examples/neuroEvolution-sensors/index.html
+++ b/examples/neuroEvolution-sensors/index.html
@@ -13,7 +13,7 @@
ml5.js neuralNetwork Neuroevolution Sensors
-
+
diff --git a/examples/neuroEvolution-steering/index.html b/examples/neuroEvolution-steering/index.html
index 673629f2..b90a565f 100644
--- a/examples/neuroEvolution-steering/index.html
+++ b/examples/neuroEvolution-steering/index.html
@@ -13,7 +13,7 @@
ml5.js neuralNetwork Neuroevolution Steering
-
+
diff --git a/examples/sentiment/index.html b/examples/sentiment/index.html
index d6506acb..d6a99363 100644
--- a/examples/sentiment/index.html
+++ b/examples/sentiment/index.html
@@ -9,7 +9,7 @@
ml5.js Sentiment Analysis Example
-
+
diff --git a/examples/soundClassifier-speech-command/index.html b/examples/soundClassifier-speech-command/index.html
index 3e3e88f5..3ae14989 100644
--- a/examples/soundClassifier-speech-command/index.html
+++ b/examples/soundClassifier-speech-command/index.html
@@ -12,7 +12,7 @@
Sound classification using SpeechCommands18w and p5.js
-
+
diff --git a/examples/soundClassifier-teachable-machine/index.html b/examples/soundClassifier-teachable-machine/index.html
index cecf5e18..149929cf 100644
--- a/examples/soundClassifier-teachable-machine/index.html
+++ b/examples/soundClassifier-teachable-machine/index.html
@@ -13,7 +13,7 @@
Sound classification using pre-trained custom model
-
+
diff --git a/package.json b/package.json
index c91d2355..8591720a 100644
--- a/package.json
+++ b/package.json
@@ -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"
diff --git a/scripts/updateP5Version.js b/scripts/updateP5Version.js
new file mode 100644
index 00000000..525a18e2
--- /dev/null
+++ b/scripts/updateP5Version.js
@@ -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} 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();