@jspsych/config 1.1.0 → 1.3.1

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 CHANGED
@@ -1,5 +1,33 @@
1
1
  # @jspsych/config
2
2
 
3
+ ## 1.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2643](https://github.com/jspsych/jsPsych/pull/2643) [`dc005661`](https://github.com/jspsych/jsPsych/commit/dc005661420dcc5c8aec62651687fc9aeac5fb65) Thanks [@bjoluc](https://github.com/bjoluc)! - Include previously undefined `regeneratorRuntime` in the Babel build of the `jspsych` package
8
+
9
+ ## 1.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`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.
14
+
15
+ ### Patch Changes
16
+
17
+ - [#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.
18
+
19
+ * [#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.
20
+
21
+ ## 1.2.0
22
+
23
+ ### Minor Changes
24
+
25
+ - [#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`.
26
+
27
+ ### Patch Changes
28
+
29
+ - [#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 `/>`
30
+
3
31
  ## 1.1.0
4
32
 
5
33
  ### Minor Changes
package/gulp.js CHANGED
@@ -13,6 +13,20 @@ const { dest, src } = gulp;
13
13
 
14
14
  const readJsonFile = (filename) => JSON.parse(readFileSync(filename, "utf8"));
15
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
+
16
30
  const getVersionFileContents = () =>
17
31
  [
18
32
  "Included in this release:\n",
@@ -25,19 +39,7 @@ const getVersionFileContents = () =>
25
39
  "/";
26
40
 
27
41
  return (
28
- glob
29
- // Get an array of all package.json filenames
30
- .sync("packages/*/package.json")
31
-
32
- // Map file names to package details
33
- .map((filename) => {
34
- const packageJson = readJsonFile(filename);
35
- return {
36
- name: packageJson.name,
37
- version: packageJson.version,
38
- };
39
- })
40
-
42
+ getAllPackages()
41
43
  // Filter packages that should not be listed
42
44
  .filter(({ name }) => !["@jspsych/config", "@jspsych/test-utils"].includes(name))
43
45
 
@@ -85,15 +87,15 @@ export const createCoreDistArchive = () =>
85
87
  // Rewrite script source paths
86
88
  .pipe(
87
89
  replace(
88
- /<script src="(.*)\/packages\/(.*)\/dist\/index\.browser\.js"><\/script>/g,
89
- '<script src="$1/dist/$2.js"></script>'
90
+ /<script src="(.*)\/packages\/(.*)\/dist\/index\.browser\.js"/g,
91
+ '<script src="$1/dist/$2.js"'
90
92
  )
91
93
  )
92
94
  // Rewrite jspsych css source paths
93
95
  .pipe(
94
96
  replace(
95
- /<link rel="stylesheet" href="(.*)\/packages\/jspsych\/css\/(.*)" \/>/g,
96
- '<link rel="stylesheet" href="$1/dist/$2" />'
97
+ /<link rel="stylesheet" href="(.*)\/packages\/jspsych\/css\/(.*)"/g,
98
+ '<link rel="stylesheet" href="$1/dist/$2"'
97
99
  )
98
100
  ),
99
101
 
@@ -105,3 +107,46 @@ export const createCoreDistArchive = () =>
105
107
  )
106
108
  .pipe(zip("dist.zip"))
107
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/utils");
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.1.0",
3
+ "version": "1.3.1",
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,31 +39,33 @@
43
39
  },
44
40
  "homepage": "https://www.jspsych.org/latest/developers/configuration",
45
41
  "dependencies": {
46
- "@babel/cli": "7.15.7",
47
- "@babel/core": "7.15.5",
48
- "@babel/preset-env": "7.15.6",
49
- "@rollup/plugin-babel": "5.3.0",
50
- "@rollup/plugin-commonjs": "19.0.0",
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.5",
48
+ "@rollup/plugin-node-resolve": "13.3.0",
49
+ "@rollup/plugin-replace": "4.0.0",
53
50
  "@types/gulp": "4.0.9",
54
- "@types/jest": "27.0.2",
55
- "babel-preset-minify": "0.5.1",
56
- "canvas": "2.8.0",
51
+ "@types/jest": "27.5.1",
52
+ "babel-preset-minify": "0.5.2",
53
+ "canvas": "2.9.1",
57
54
  "gulp": "4.0.2",
58
55
  "gulp-cli": "2.3.0",
59
56
  "gulp-file": "^0.4.0",
60
57
  "gulp-rename": "2.0.0",
61
58
  "gulp-replace": "1.1.3",
62
59
  "gulp-zip": "5.1.0",
63
- "jest": "27.2.4",
64
- "jest-environment-jsdom": "27.2.4",
60
+ "jest": "28.1.0",
61
+ "jest-environment-jsdom": "28.1.0",
65
62
  "merge-stream": "2.0.0",
66
- "rollup": "2.58.0",
63
+ "regenerator-runtime": "0.13.9",
64
+ "rollup": "2.73.0",
67
65
  "rollup-plugin-terser": "7.0.2",
68
- "rollup-plugin-typescript2": "0.30.0",
69
- "ts-jest": "27.0.5",
70
- "tslib": "2.3.1",
71
- "typescript": "4.4.3"
66
+ "rollup-plugin-typescript2": "0.31.2",
67
+ "ts-jest": "28.0.2",
68
+ "tslib": "2.4.0",
69
+ "typescript": "^4.6.4"
72
70
  }
73
71
  }
package/rollup.js CHANGED
@@ -1,7 +1,9 @@
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";
4
5
  import resolve from "@rollup/plugin-node-resolve";
6
+ import replace from "@rollup/plugin-replace";
5
7
  import { defineConfig } from "rollup";
6
8
  import { terser } from "rollup-plugin-terser";
7
9
  import typescript from "rollup-plugin-typescript2";
@@ -77,12 +79,24 @@ const makeConfig = ({
77
79
  // Babel build
78
80
  config.push({
79
81
  ...commonConfig,
80
- plugins: commonConfig.plugins.concat(
82
+ plugins: [
83
+ // Import `regenerator-runtime` if requested:
84
+ replace({
85
+ values: {
86
+ "// __rollup-babel-import-regenerator-runtime__":
87
+ 'import "regenerator-runtime/runtime.js";',
88
+ },
89
+ delimiters: ["", ""],
90
+ preventAssignment: true,
91
+ }),
92
+ ...commonConfig.plugins,
81
93
  babel({
82
94
  babelHelpers: "bundled",
83
95
  extends: "@jspsych/config/babel",
84
- })
85
- ),
96
+ // https://github.com/ezolenko/rollup-plugin-typescript2#rollupplugin-babel
97
+ extensions: [...babelDefaultExtensions, ".ts"],
98
+ }),
99
+ ],
86
100
  output: [
87
101
  {
88
102
  // Minified production build file