@jspsych/config 1.0.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -2
- package/gulp.js +105 -4
- package/jest.cjs +4 -5
- package/package.json +18 -21
- package/rollup.js +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,35 @@
|
|
|
1
1
|
# @jspsych/config
|
|
2
2
|
|
|
3
|
-
## 1.
|
|
4
|
-
|
|
3
|
+
## 1.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`3463e977`](https://github.com/jspsych/jsPsych/commit/3463e9778f3c2787b9c75c0f9bd7d19cc79798b3) Thanks [@becky-gilbert](https://github.com/becky-gilbert)! - Add the updatePluginVersions gulp task. This task looks at each of the docs/plugins markdown files, finds the page title and "Current version" string, adds the current version number (from the package.json file), and uses the package name as the page title.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#2631](https://github.com/jspsych/jsPsych/pull/2631) [`e77371e9`](https://github.com/jspsych/jsPsych/commit/e77371e94b3496361138d681c16840829f4c5cd2) Thanks [@bjoluc](https://github.com/bjoluc)! - Update dependencies, including Jest v27 to v28. The changelogs have been carefully checked and no breaking changes are to be expected in packages using `@jspsych/config`. Check out the [Jest 28 blog post](https://jestjs.io/blog/2022/04/25/jest-28) for a summary of the changes in Jest.
|
|
12
|
+
|
|
13
|
+
* [#2632](https://github.com/jspsych/jsPsych/pull/2632) [`a17f423f`](https://github.com/jspsych/jsPsych/commit/a17f423f18df24c73baeb06d4079f9f2f9211386) Thanks [@bjoluc](https://github.com/bjoluc)! - Apply Babel Rollup plugin to `.ts` files in the `index.browser.min.js` build. It was erroneously ignoring transpiled `.ts` files before.
|
|
14
|
+
|
|
15
|
+
## 1.2.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
5
18
|
|
|
19
|
+
- [#2431](https://github.com/jspsych/jsPsych/pull/2431) [`87f332f9`](https://github.com/jspsych/jsPsych/commit/87f332f92540eef028bbed7284e30c1cf614cc96) Thanks [@bjoluc](https://github.com/bjoluc)! - Implement an `updateUnpkgLinks` Gulp task to update each unpkg link with a precise version number to the corresponding package's current version as defined in the package's `package.json`.
|
|
6
20
|
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [#2505](https://github.com/jspsych/jsPsych/pull/2505) [`9486bc50`](https://github.com/jspsych/jsPsych/commit/9486bc509f8fe4b4ac4b93510ddd8fd17e5f1b05) Thanks [@bjoluc](https://github.com/bjoluc)! - Fix css path rewriting in `createCoreDistArchive` Gulp task when `link` tags do not end in `/>`
|
|
24
|
+
|
|
25
|
+
## 1.1.0
|
|
26
|
+
|
|
27
|
+
### Minor Changes
|
|
28
|
+
|
|
29
|
+
- [#2357](https://github.com/jspsych/jsPsych/pull/2357) [`c44ac202`](https://github.com/jspsych/jsPsych/commit/c44ac2024ae51cf14efa60ca285bb2e4dc0ebef7) Thanks [@bjoluc](https://github.com/bjoluc)! - Add a VERSION.md file to the release archive created by the `createCoreDistArchive` Gulp task
|
|
30
|
+
|
|
31
|
+
## 1.0.0
|
|
32
|
+
|
|
33
|
+
### Major Changes
|
|
7
34
|
|
|
8
35
|
- [`bc058590`](https://github.com/jspsych/jsPsych/commit/bc058590950285e52116f809e4ccc57bae5a67f5) Thanks [@bjoluc](https://github.com/bjoluc)! - Initial release
|
package/gulp.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { readFileSync } from "fs";
|
|
1
2
|
import { sep as pathSeparator } from "path";
|
|
2
3
|
|
|
4
|
+
import glob from "glob";
|
|
3
5
|
import gulp from "gulp";
|
|
6
|
+
import file from "gulp-file";
|
|
4
7
|
import rename from "gulp-rename";
|
|
5
8
|
import replace from "gulp-replace";
|
|
6
9
|
import zip from "gulp-zip";
|
|
@@ -8,6 +11,58 @@ import merge from "merge-stream";
|
|
|
8
11
|
|
|
9
12
|
const { dest, src } = gulp;
|
|
10
13
|
|
|
14
|
+
const readJsonFile = (filename) => JSON.parse(readFileSync(filename, "utf8"));
|
|
15
|
+
|
|
16
|
+
const getAllPackages = () =>
|
|
17
|
+
glob
|
|
18
|
+
// Get an array of all package.json filenames
|
|
19
|
+
.sync("packages/*/package.json")
|
|
20
|
+
|
|
21
|
+
// Map file names to package details
|
|
22
|
+
.map((filename) => {
|
|
23
|
+
const packageJson = readJsonFile(filename);
|
|
24
|
+
return {
|
|
25
|
+
name: packageJson.name,
|
|
26
|
+
version: packageJson.version,
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const getVersionFileContents = () =>
|
|
31
|
+
[
|
|
32
|
+
"Included in this release:\n",
|
|
33
|
+
"Package|Version|Documentation",
|
|
34
|
+
"--- | --- | ---",
|
|
35
|
+
...(() => {
|
|
36
|
+
const docsBaseUrl =
|
|
37
|
+
"https://www.jspsych.org/" +
|
|
38
|
+
readJsonFile("packages/jspsych/package.json").version.split(".").slice(0, -1).join(".") +
|
|
39
|
+
"/";
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
getAllPackages()
|
|
43
|
+
// Filter packages that should not be listed
|
|
44
|
+
.filter(({ name }) => !["@jspsych/config", "@jspsych/test-utils"].includes(name))
|
|
45
|
+
|
|
46
|
+
// Move the core package to the top of the list
|
|
47
|
+
.sort(({ name: n1 }, { name: n2 }) => (n1 === "jspsych" ? -1 : n2 === "jspsych" ? 1 : 0))
|
|
48
|
+
|
|
49
|
+
// Map package details to MarkDown table row strings
|
|
50
|
+
.map(({ name, version }) => {
|
|
51
|
+
return `${name.replace("@jspsych/", "")}|${version}|${
|
|
52
|
+
name === "jspsych"
|
|
53
|
+
? docsBaseUrl
|
|
54
|
+
: name.startsWith("@jspsych/plugin-")
|
|
55
|
+
? docsBaseUrl + "plugins/" + name.replace("@jspsych/plugin-", "")
|
|
56
|
+
: name.startsWith("@jspsych/extension-")
|
|
57
|
+
? docsBaseUrl + "extensions/" + name.replace("@jspsych/extension-", "")
|
|
58
|
+
: ""
|
|
59
|
+
}`;
|
|
60
|
+
})
|
|
61
|
+
);
|
|
62
|
+
})(),
|
|
63
|
+
"",
|
|
64
|
+
].join("\n");
|
|
65
|
+
|
|
11
66
|
export const createCoreDistArchive = () =>
|
|
12
67
|
merge(
|
|
13
68
|
// index.browser.js files
|
|
@@ -32,20 +87,66 @@ export const createCoreDistArchive = () =>
|
|
|
32
87
|
// Rewrite script source paths
|
|
33
88
|
.pipe(
|
|
34
89
|
replace(
|
|
35
|
-
/<script src="(.*)\/packages\/(.*)\/dist\/index\.browser\.js"
|
|
36
|
-
'<script src="$1/dist/$2.js"
|
|
90
|
+
/<script src="(.*)\/packages\/(.*)\/dist\/index\.browser\.js"/g,
|
|
91
|
+
'<script src="$1/dist/$2.js"'
|
|
37
92
|
)
|
|
38
93
|
)
|
|
39
94
|
// Rewrite jspsych css source paths
|
|
40
95
|
.pipe(
|
|
41
96
|
replace(
|
|
42
|
-
/<link rel="stylesheet" href="(.*)\/packages\/jspsych\/css\/(.*)"
|
|
43
|
-
'<link rel="stylesheet" href="$1/dist/$2"
|
|
97
|
+
/<link rel="stylesheet" href="(.*)\/packages\/jspsych\/css\/(.*)"/g,
|
|
98
|
+
'<link rel="stylesheet" href="$1/dist/$2"'
|
|
44
99
|
)
|
|
45
100
|
),
|
|
46
101
|
|
|
102
|
+
// VERSION.md
|
|
103
|
+
file("VERSION.md", getVersionFileContents(), { src: true }),
|
|
104
|
+
|
|
47
105
|
// Other files
|
|
48
106
|
src(["*.md", "license.txt"])
|
|
49
107
|
)
|
|
50
108
|
.pipe(zip("dist.zip"))
|
|
51
109
|
.pipe(dest("."));
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Updates each unpkg link with a precise version number to the corresponding package's current
|
|
113
|
+
* version as defined in the package's `package.json`. Only considers `.md` and `.html` files.
|
|
114
|
+
*/
|
|
115
|
+
export const updateUnpkgLinks = () => {
|
|
116
|
+
const packageVersions = new Map(getAllPackages().map(({ name, version }) => [name, version]));
|
|
117
|
+
|
|
118
|
+
return src(["./**/*.{md,html}"])
|
|
119
|
+
.pipe(
|
|
120
|
+
replace(
|
|
121
|
+
/"https:\/\/unpkg\.com\/(@?.*)@(\d+.\d+.\d+)(\/[^"]*)?"/g,
|
|
122
|
+
(url, packageName, currentVersion, path) => {
|
|
123
|
+
const latestVersion = packageVersions.get(packageName) ?? currentVersion;
|
|
124
|
+
return `"https://unpkg.com/${packageName}@${latestVersion}${path ?? ""}"`;
|
|
125
|
+
}
|
|
126
|
+
)
|
|
127
|
+
)
|
|
128
|
+
.pipe(dest("./"));
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Substitutes the string "current-plugin-version" or version number that follows the text "Current version: "
|
|
133
|
+
* in the plugin docs pages with the package's current version, as defined in the package's `package.json`.
|
|
134
|
+
* Only considers `.md` files in `docs/plugins` folder.
|
|
135
|
+
* Gets the package name from the docs page title (i.e. following "# "), ignoring the string " plugin" in the title.
|
|
136
|
+
*/
|
|
137
|
+
export const updatePluginVersions = () => {
|
|
138
|
+
const packageVersions = new Map(getAllPackages().map(({ name, version }) => [name, version]));
|
|
139
|
+
|
|
140
|
+
return src(["././docs/plugins/*.md"])
|
|
141
|
+
.pipe(
|
|
142
|
+
replace(
|
|
143
|
+
/\# (.+?)(?: plugin)?[\s]*?[\n]*Current version: (\d+.\d+.\d+|current-plugin-version)\./gi,
|
|
144
|
+
(match_str, packageName, currentVersionText) => {
|
|
145
|
+
const fullPackageName = "@jspsych/plugin-" + packageName;
|
|
146
|
+
const latestVersion = packageVersions.get(fullPackageName) ?? currentVersionText;
|
|
147
|
+
return `# ${packageName}\n\nCurrent version: ${latestVersion}.`;
|
|
148
|
+
}
|
|
149
|
+
)
|
|
150
|
+
)
|
|
151
|
+
.pipe(dest("./docs/plugins"));
|
|
152
|
+
};
|
package/jest.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const ts = require("typescript");
|
|
2
|
-
const { pathsToModuleNameMapper } = require("ts-jest
|
|
2
|
+
const { pathsToModuleNameMapper } = require("ts-jest");
|
|
3
3
|
|
|
4
|
+
/** @type { (dirname: string) => import('@jest/types').Config.InitialOptions } */
|
|
4
5
|
module.exports.makePackageConfig = (dirname) => {
|
|
5
6
|
const packageJson = require(dirname + "/package.json");
|
|
6
7
|
const packageBaseName = packageJson.name.replace("@jspsych/", "");
|
|
@@ -14,15 +15,13 @@ module.exports.makePackageConfig = (dirname) => {
|
|
|
14
15
|
|
|
15
16
|
return {
|
|
16
17
|
preset: "ts-jest",
|
|
17
|
-
moduleNameMapper: pathsToModuleNameMapper(tsCompilerOptions.paths, {
|
|
18
|
-
prefix: "<rootDir>/",
|
|
19
|
-
}),
|
|
18
|
+
moduleNameMapper: pathsToModuleNameMapper(tsCompilerOptions.paths, { prefix: "<rootDir>/" }),
|
|
20
19
|
testEnvironment: "jsdom",
|
|
21
20
|
testEnvironmentOptions: {
|
|
22
21
|
fetchExternalResources: true,
|
|
23
22
|
pretendToBeVisual: true,
|
|
23
|
+
url: "http://localhost/",
|
|
24
24
|
},
|
|
25
|
-
testURL: "http://localhost/",
|
|
26
25
|
displayName: {
|
|
27
26
|
name: packageBaseName,
|
|
28
27
|
color: packageBaseName === "jspsych" ? "white" : "cyanBright",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jspsych/config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Shared (build) configuration for jsPsych packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -27,10 +27,6 @@
|
|
|
27
27
|
"engines": {
|
|
28
28
|
"node": ">=14.0.0"
|
|
29
29
|
},
|
|
30
|
-
"scripts": {
|
|
31
|
-
"build": "",
|
|
32
|
-
"tsc": ""
|
|
33
|
-
},
|
|
34
30
|
"repository": {
|
|
35
31
|
"type": "git",
|
|
36
32
|
"url": "git+https://github.com/jspsych/jsPsych.git",
|
|
@@ -43,30 +39,31 @@
|
|
|
43
39
|
},
|
|
44
40
|
"homepage": "https://www.jspsych.org/latest/developers/configuration",
|
|
45
41
|
"dependencies": {
|
|
46
|
-
"@babel/cli": "7.
|
|
47
|
-
"@babel/core": "7.
|
|
48
|
-
"@babel/preset-env": "7.
|
|
49
|
-
"@rollup/plugin-babel": "5.3.
|
|
50
|
-
"@rollup/plugin-commonjs": "
|
|
42
|
+
"@babel/cli": "7.17.10",
|
|
43
|
+
"@babel/core": "7.17.10",
|
|
44
|
+
"@babel/preset-env": "7.17.10",
|
|
45
|
+
"@rollup/plugin-babel": "5.3.1",
|
|
46
|
+
"@rollup/plugin-commonjs": "22.0.0",
|
|
51
47
|
"@rollup/plugin-json": "4.1.0",
|
|
52
|
-
"@rollup/plugin-node-resolve": "13.0
|
|
48
|
+
"@rollup/plugin-node-resolve": "13.3.0",
|
|
53
49
|
"@types/gulp": "4.0.9",
|
|
54
|
-
"@types/jest": "27.
|
|
55
|
-
"babel-preset-minify": "0.5.
|
|
56
|
-
"canvas": "2.
|
|
50
|
+
"@types/jest": "27.5.1",
|
|
51
|
+
"babel-preset-minify": "0.5.2",
|
|
52
|
+
"canvas": "2.9.1",
|
|
57
53
|
"gulp": "4.0.2",
|
|
58
54
|
"gulp-cli": "2.3.0",
|
|
55
|
+
"gulp-file": "^0.4.0",
|
|
59
56
|
"gulp-rename": "2.0.0",
|
|
60
57
|
"gulp-replace": "1.1.3",
|
|
61
58
|
"gulp-zip": "5.1.0",
|
|
62
|
-
"jest": "
|
|
63
|
-
"jest-environment-jsdom": "
|
|
59
|
+
"jest": "28.1.0",
|
|
60
|
+
"jest-environment-jsdom": "28.1.0",
|
|
64
61
|
"merge-stream": "2.0.0",
|
|
65
|
-
"rollup": "2.
|
|
62
|
+
"rollup": "2.73.0",
|
|
66
63
|
"rollup-plugin-terser": "7.0.2",
|
|
67
|
-
"rollup-plugin-typescript2": "0.
|
|
68
|
-
"ts-jest": "
|
|
69
|
-
"tslib": "2.
|
|
70
|
-
"typescript": "4.4
|
|
64
|
+
"rollup-plugin-typescript2": "0.31.2",
|
|
65
|
+
"ts-jest": "28.0.2",
|
|
66
|
+
"tslib": "2.4.0",
|
|
67
|
+
"typescript": "^4.6.4"
|
|
71
68
|
}
|
|
72
69
|
}
|
package/rollup.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DEFAULT_EXTENSIONS as babelDefaultExtensions } from "@babel/core";
|
|
1
2
|
import { babel } from "@rollup/plugin-babel";
|
|
2
3
|
import commonjs from "@rollup/plugin-commonjs";
|
|
3
4
|
import json from "@rollup/plugin-json";
|
|
@@ -81,6 +82,8 @@ const makeConfig = ({
|
|
|
81
82
|
babel({
|
|
82
83
|
babelHelpers: "bundled",
|
|
83
84
|
extends: "@jspsych/config/babel",
|
|
85
|
+
// https://github.com/ezolenko/rollup-plugin-typescript2#rollupplugin-babel
|
|
86
|
+
extensions: [...babelDefaultExtensions, ".ts"],
|
|
84
87
|
})
|
|
85
88
|
),
|
|
86
89
|
output: [
|