mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
add updatePluginVersion gulp task
This commit is contained in:
parent
262cc1cd89
commit
74cc2ece69
@ -1 +1 @@
|
|||||||
export { createCoreDistArchive, updateUnpkgLinks } from "@jspsych/config/gulp";
|
export { createCoreDistArchive, updateUnpkgLinks, updatePluginVersion } from "@jspsych/config/gulp";
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
"build": "turbo run build",
|
"build": "turbo run build",
|
||||||
"build:archive": "gulp createCoreDistArchive",
|
"build:archive": "gulp createCoreDistArchive",
|
||||||
"update-unpkg-links": "gulp updateUnpkgLinks",
|
"update-unpkg-links": "gulp updateUnpkgLinks",
|
||||||
|
"update-plugin-version": "gulp updatePluginVersion",
|
||||||
"prepare": "node -e 'process.exit(!process.env.CI)' || (husky install && npm run build)",
|
"prepare": "node -e 'process.exit(!process.env.CI)' || (husky install && npm run build)",
|
||||||
"tsc": "turbo tsc",
|
"tsc": "turbo tsc",
|
||||||
"changeset": "changeset",
|
"changeset": "changeset",
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { readFileSync } from "fs";
|
import { readFileSync } from "fs";
|
||||||
import { sep as pathSeparator } from "path";
|
import { sep as pathSeparator } from "path";
|
||||||
|
import { StringDecoder } from "string_decoder";
|
||||||
|
|
||||||
import glob from "glob";
|
import glob from "glob";
|
||||||
import gulp from "gulp";
|
import gulp from "gulp";
|
||||||
@ -127,3 +128,26 @@ export const updateUnpkgLinks = () => {
|
|||||||
)
|
)
|
||||||
.pipe(dest("./"));
|
.pipe(dest("./"));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Substitutes the string "current-plugin-version" or version number that follows the text "Current version: "
|
||||||
|
* in the plugin docs pages with the package's current version, as defined in the package's `package.json`.
|
||||||
|
* Only considers `.md` files in `docs/plugins` folder.
|
||||||
|
* Gets the package name from the docs page title (i.e. following "# "), ignoring the string " plugin" in the title.
|
||||||
|
*/
|
||||||
|
export const updatePluginVersion = () => {
|
||||||
|
const packageVersions = new Map(getAllPackages().map(({ name, version }) => [name, version]));
|
||||||
|
|
||||||
|
return src(["././docs/plugins/*.md"])
|
||||||
|
.pipe(
|
||||||
|
replace(
|
||||||
|
/\# (.+?)(?: plugin)?[\s]*?[\n]*Current version: (\d+.\d+.\d+|current-plugin-version)\./gi,
|
||||||
|
(match_str, packageName, currentVersionText) => {
|
||||||
|
const fullPackageName = "@jspsych/plugin-" + packageName;
|
||||||
|
const latestVersion = packageVersions.get(fullPackageName) ?? currentVersionText;
|
||||||
|
return `# ${packageName}\n\nCurrent version: ${latestVersion}.`;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.pipe(dest("./docs/plugins"));
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user