mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
add rollup plugin for building citation
This commit is contained in:
parent
47d57f03ed
commit
1c5f826fbe
173
package-lock.json
generated
173
package-lock.json
generated
@ -7,6 +7,11 @@
|
|||||||
"workspaces": [
|
"workspaces": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
],
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"@citation-js/core": "^0.7.14",
|
||||||
|
"@citation-js/plugin-software-formats": "^0.6.1",
|
||||||
|
"fs": "^0.0.1-security"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@changesets/changelog-github": "^0.4.7",
|
"@changesets/changelog-github": "^0.4.7",
|
||||||
"@changesets/cli": "^2.25.2",
|
"@changesets/cli": "^2.25.2",
|
||||||
@ -2201,6 +2206,126 @@
|
|||||||
"prettier": "^2.7.1"
|
"prettier": "^2.7.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@citation-js/core": {
|
||||||
|
"version": "0.7.14",
|
||||||
|
"resolved": "https://registry.npmjs.org/@citation-js/core/-/core-0.7.14.tgz",
|
||||||
|
"integrity": "sha512-dgeGqYDSQmn2MtnWZkwPGpJQPh43yr1lAAr9jl1NJ9pIY1RXUQxtlAUZVur0V9PHdbfQC+kkvB1KC3VpgVV3MA==",
|
||||||
|
"dependencies": {
|
||||||
|
"@citation-js/date": "^0.5.0",
|
||||||
|
"@citation-js/name": "^0.4.2",
|
||||||
|
"fetch-ponyfill": "^7.1.0",
|
||||||
|
"sync-fetch": "^0.4.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@citation-js/date": {
|
||||||
|
"version": "0.5.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@citation-js/date/-/date-0.5.1.tgz",
|
||||||
|
"integrity": "sha512-1iDKAZ4ie48PVhovsOXQ+C6o55dWJloXqtznnnKy6CltJBQLIuLLuUqa8zlIvma0ZigjVjgDUhnVaNU1MErtZw==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@citation-js/name": {
|
||||||
|
"version": "0.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@citation-js/name/-/name-0.4.2.tgz",
|
||||||
|
"integrity": "sha512-brSPsjs2fOVzSnARLKu0qncn6suWjHVQtrqSUrnqyaRH95r/Ad4wPF5EsoWr+Dx8HzkCGb/ogmoAzfCsqlTwTQ==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@citation-js/plugin-cff": {
|
||||||
|
"version": "0.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@citation-js/plugin-cff/-/plugin-cff-0.6.1.tgz",
|
||||||
|
"integrity": "sha512-tLjTgsfzNOdQWGn5mNc2NAaydHnlRucSERoyAXLN7u0BQBfp7j5zwdxCmxcQD/N7hH3fpDKMG+qDzbqpJuKyNA==",
|
||||||
|
"dependencies": {
|
||||||
|
"@citation-js/date": "^0.5.0",
|
||||||
|
"@citation-js/plugin-yaml": "^0.6.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@citation-js/plugin-github": {
|
||||||
|
"version": "0.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@citation-js/plugin-github/-/plugin-github-0.6.1.tgz",
|
||||||
|
"integrity": "sha512-1ZeSgQ5AoYsa8n2acVooUeRk76oA8rLszYNBjzj5z6MPa11BZlQJ9O+Gy4tHjlImvsENLbLPx5f8/V1VHXaCfQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"@citation-js/date": "^0.5.0",
|
||||||
|
"@citation-js/name": "^0.4.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@citation-js/plugin-npm": {
|
||||||
|
"version": "0.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@citation-js/plugin-npm/-/plugin-npm-0.6.1.tgz",
|
||||||
|
"integrity": "sha512-rojJA+l/p2KBpDoY+8n0YfNyQO1Aw03fQR5BN+gXD1LNAP1V+8wqvdPsaHnzPsrhrd4ZXDR7ch/Nk0yynPkJ3Q==",
|
||||||
|
"dependencies": {
|
||||||
|
"@citation-js/date": "^0.5.0",
|
||||||
|
"@citation-js/name": "^0.4.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@citation-js/plugin-software-formats": {
|
||||||
|
"version": "0.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@citation-js/plugin-software-formats/-/plugin-software-formats-0.6.1.tgz",
|
||||||
|
"integrity": "sha512-BDF9rqi56K0hoTgYTVANCFVRSbWKC9V06Uap7oa8SjqCTgnHJAy8t/F3NxsyYPPG+zmRsLW9VNbcIsJOl0eu/w==",
|
||||||
|
"dependencies": {
|
||||||
|
"@citation-js/plugin-cff": "^0.6.1",
|
||||||
|
"@citation-js/plugin-github": "^0.6.1",
|
||||||
|
"@citation-js/plugin-npm": "^0.6.1",
|
||||||
|
"@citation-js/plugin-yaml": "^0.6.1",
|
||||||
|
"@citation-js/plugin-zenodo": "^0.6.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@citation-js/plugin-yaml": {
|
||||||
|
"version": "0.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@citation-js/plugin-yaml/-/plugin-yaml-0.6.1.tgz",
|
||||||
|
"integrity": "sha512-XEVVks1cJTqRbjy+nmthfw/puR6NwRB3fyJWi1tX13UYXlkhP/h45nsv4zjgLLGekdcMHQvhad9MAYunOftGKA==",
|
||||||
|
"dependencies": {
|
||||||
|
"js-yaml": "^4.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@citation-js/plugin-yaml/node_modules/argparse": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
|
||||||
|
},
|
||||||
|
"node_modules/@citation-js/plugin-yaml/node_modules/js-yaml": {
|
||||||
|
"version": "4.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
|
||||||
|
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
|
||||||
|
"dependencies": {
|
||||||
|
"argparse": "^2.0.1"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"js-yaml": "bin/js-yaml.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@citation-js/plugin-zenodo": {
|
||||||
|
"version": "0.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@citation-js/plugin-zenodo/-/plugin-zenodo-0.6.1.tgz",
|
||||||
|
"integrity": "sha512-bUybENHoZqJ6gheUqgkumjI+mu+fA2bg6VoniDmZTb7Qng9iEpi+IWEAR26/vBE0gK0EWrJjczyDW3HCwrhvVw==",
|
||||||
|
"dependencies": {
|
||||||
|
"@citation-js/date": "^0.5.0",
|
||||||
|
"@citation-js/name": "^0.4.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@discoveryjs/json-ext": {
|
"node_modules/@discoveryjs/json-ext": {
|
||||||
"version": "0.5.7",
|
"version": "0.5.7",
|
||||||
"resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz",
|
"resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz",
|
||||||
@ -7064,6 +7189,14 @@
|
|||||||
"bser": "2.1.1"
|
"bser": "2.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/fetch-ponyfill": {
|
||||||
|
"version": "7.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/fetch-ponyfill/-/fetch-ponyfill-7.1.0.tgz",
|
||||||
|
"integrity": "sha512-FhbbL55dj/qdVO3YNK7ZEkshvj3eQ7EuIGV2I6ic/2YiocvyWv+7jg2s4AyS0wdRU75s3tA8ZxI/xPigb0v5Aw==",
|
||||||
|
"dependencies": {
|
||||||
|
"node-fetch": "~2.6.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/figures": {
|
"node_modules/figures": {
|
||||||
"version": "3.2.0",
|
"version": "3.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz",
|
||||||
@ -7289,6 +7422,11 @@
|
|||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/fs": {
|
||||||
|
"version": "0.0.1-security",
|
||||||
|
"resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
|
||||||
|
"integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w=="
|
||||||
|
},
|
||||||
"node_modules/fs-extra": {
|
"node_modules/fs-extra": {
|
||||||
"version": "7.0.1",
|
"version": "7.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz",
|
||||||
@ -15003,6 +15141,41 @@
|
|||||||
"resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz",
|
||||||
"integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw=="
|
"integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw=="
|
||||||
},
|
},
|
||||||
|
"node_modules/sync-fetch": {
|
||||||
|
"version": "0.4.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/sync-fetch/-/sync-fetch-0.4.5.tgz",
|
||||||
|
"integrity": "sha512-esiWJ7ixSKGpd9DJPBTC4ckChqdOjIwJfYhVHkcQ2Gnm41323p1TRmEI+esTQ9ppD+b5opps2OTEGTCGX5kF+g==",
|
||||||
|
"dependencies": {
|
||||||
|
"buffer": "^5.7.1",
|
||||||
|
"node-fetch": "^2.6.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/sync-fetch/node_modules/buffer": {
|
||||||
|
"version": "5.7.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
|
||||||
|
"integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "patreon",
|
||||||
|
"url": "https://www.patreon.com/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "consulting",
|
||||||
|
"url": "https://feross.org/support"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"base64-js": "^1.3.1",
|
||||||
|
"ieee754": "^1.1.13"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/tapable": {
|
"node_modules/tapable": {
|
||||||
"version": "2.2.1",
|
"version": "2.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz",
|
||||||
|
@ -51,5 +51,9 @@
|
|||||||
"projects": [
|
"projects": [
|
||||||
"<rootDir>/packages/*/jest.config.cjs"
|
"<rootDir>/packages/*/jest.config.cjs"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@citation-js/core": "^0.7.14",
|
||||||
|
"@citation-js/plugin-software-formats": "^0.6.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ const makeConfig = ({
|
|||||||
outputOptions = {},
|
outputOptions = {},
|
||||||
globalOptions = {},
|
globalOptions = {},
|
||||||
iifeOutputOptions = {},
|
iifeOutputOptions = {},
|
||||||
|
plugins = [],
|
||||||
isNodeOnlyBuild = false,
|
isNodeOnlyBuild = false,
|
||||||
}) => {
|
}) => {
|
||||||
const input = "src/index.ts";
|
const input = "src/index.ts";
|
||||||
@ -70,6 +71,7 @@ const makeConfig = ({
|
|||||||
...globalOptions,
|
...globalOptions,
|
||||||
input,
|
input,
|
||||||
plugins: [
|
plugins: [
|
||||||
|
...plugins,
|
||||||
externals(),
|
externals(),
|
||||||
esbuild({ ...esBuildPluginOptions, target: "node18" }),
|
esbuild({ ...esBuildPluginOptions, target: "node18" }),
|
||||||
commonjs(commonjsPluginOptions),
|
commonjs(commonjsPluginOptions),
|
||||||
@ -95,6 +97,7 @@ const makeConfig = ({
|
|||||||
...globalOptions,
|
...globalOptions,
|
||||||
input,
|
input,
|
||||||
plugins: [
|
plugins: [
|
||||||
|
...plugins,
|
||||||
externals({ deps: false }),
|
externals({ deps: false }),
|
||||||
resolve({ preferBuiltins: false }),
|
resolve({ preferBuiltins: false }),
|
||||||
esbuild({ ...esBuildPluginOptions, target: "esnext" }),
|
esbuild({ ...esBuildPluginOptions, target: "esnext" }),
|
||||||
@ -114,6 +117,7 @@ const makeConfig = ({
|
|||||||
...globalOptions,
|
...globalOptions,
|
||||||
input,
|
input,
|
||||||
plugins: [
|
plugins: [
|
||||||
|
...plugins,
|
||||||
externals({ deps: false }),
|
externals({ deps: false }),
|
||||||
resolve({ preferBuiltins: false }),
|
resolve({ preferBuiltins: false }),
|
||||||
esbuild({ ...esBuildPluginOptions, target: "es2015", minify: true }),
|
esbuild({ ...esBuildPluginOptions, target: "es2015", minify: true }),
|
||||||
@ -144,6 +148,7 @@ export const makeRollupConfig = (iifeName) =>
|
|||||||
outputOptions: {
|
outputOptions: {
|
||||||
exports: "default",
|
exports: "default",
|
||||||
globals: { jspsych: "jsPsychModule" },
|
globals: { jspsych: "jsPsychModule" },
|
||||||
|
plugins: [cffToJsonPlugin()],
|
||||||
},
|
},
|
||||||
globalOptions: { external: ["jspsych"] },
|
globalOptions: { external: ["jspsych"] },
|
||||||
iifeOutputOptions: { name: iifeName },
|
iifeOutputOptions: { name: iifeName },
|
||||||
|
@ -1,9 +1,20 @@
|
|||||||
|
import "@citation-js/plugin-software-formats";
|
||||||
|
|
||||||
|
import fs from "fs";
|
||||||
|
import path from "path";
|
||||||
|
|
||||||
|
import { Cite } from "@citation-js/core";
|
||||||
import autoBind from "auto-bind";
|
import autoBind from "auto-bind";
|
||||||
|
// To work with citations
|
||||||
|
import { Class } from "type-fest";
|
||||||
|
|
||||||
import { version } from "../package.json";
|
import { version } from "../package.json";
|
||||||
import { ExtensionManager, ExtensionManagerDependencies } from "./ExtensionManager";
|
import { ExtensionManager, ExtensionManagerDependencies } from "./ExtensionManager";
|
||||||
import { JsPsychData, JsPsychDataDependencies } from "./modules/data";
|
import { JsPsychData, JsPsychDataDependencies } from "./modules/data";
|
||||||
|
import { JsPsychExtension } from "./modules/extensions";
|
||||||
import { PluginAPI, createJointPluginAPIObject } from "./modules/plugin-api";
|
import { PluginAPI, createJointPluginAPIObject } from "./modules/plugin-api";
|
||||||
|
import { JsPsychPlugin } from "./modules/plugins";
|
||||||
|
import { PluginInfo } from "./modules/plugins";
|
||||||
import * as randomization from "./modules/randomization";
|
import * as randomization from "./modules/randomization";
|
||||||
import * as turk from "./modules/turk";
|
import * as turk from "./modules/turk";
|
||||||
import * as utils from "./modules/utils";
|
import * as utils from "./modules/utils";
|
||||||
@ -257,6 +268,27 @@ export class JsPsych {
|
|||||||
return this.timeline?.description.timeline;
|
return this.timeline?.description.timeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getCitations(
|
||||||
|
plugins: Array<Class<JsPsychPlugin<any>> | JsPsychExtension>,
|
||||||
|
format: "apa" | "bibtex"
|
||||||
|
) {
|
||||||
|
plugins.map((plugin) => {
|
||||||
|
let pluginCite = Cite(plugin["info"].citation);
|
||||||
|
let apaCitation = pluginCite.format("data", {
|
||||||
|
format: "string",
|
||||||
|
template: "citation-apa",
|
||||||
|
lang: "en-us",
|
||||||
|
});
|
||||||
|
let bibtexCitation = pluginCite.format("data", {
|
||||||
|
format: "string",
|
||||||
|
template: "citation-bibtex",
|
||||||
|
lang: "en-us",
|
||||||
|
});
|
||||||
|
console.log(apaCitation);
|
||||||
|
console.log(bibtexCitation);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
get extensions() {
|
get extensions() {
|
||||||
return this.extensionManager?.extensions ?? {};
|
return this.extensionManager?.extensions ?? {};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user