Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .changeset/fix-template-scaffold-bugs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
"@jspsych/new-plugin": patch
"@jspsych/new-extension": patch
"@jspsych/new-timeline": patch
---

Fix several defects in the generated scaffold:

- CITATION.cff no longer stuffs the full author name into the `family-names`, `given-names`, and `name-particle` fields, and no longer leaves unsubstituted `{email}`/`{softwareUrl}`/`{title}` placeholders. These are now clean fill-in fields (new-plugin and new-extension).
- The generated README "Loading" snippet now imports from the scoped npm package name (e.g. `@jspsych-contrib/plugin-x`) and closes the in-browser `<script>` tag (new-plugin and new-extension).
- The example `index.html` now loads the local build as a live `<script>` instead of leaving it commented out inside the "once published" block, so examples work out of the box.
- new-timeline now builds the browser bundle as `dist/index.browser.min.js` (via a `tsup.config.ts`) to match the `unpkg` field and the other packages, instead of `dist/index.global.js`.
- Generated packages now include a `.gitignore` (ignoring `dist/` and `node_modules/`). The template ships as `gitignore` and is renamed during scaffolding to avoid npm rewriting it to `.npmignore` on publish.
22 changes: 17 additions & 5 deletions packages/new-extension/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,10 @@ async function processAnswers(answers) {
const gitRootHttpsUrl = getGitHttpsUrl(gitRootUrl);

function processTemplate() {
return src(`${templatesDir}/extension-template-${answers.language}/**/*`)
return src(`${templatesDir}/extension-template-${answers.language}/**/*`, {
dot: true, // Includes hidden files too
nodir: false // Includes directories
})
.pipe(replace("{npmPackageName}", npmPackageName))
.pipe(replace("{author}", answers.author))
.pipe(replace("{authorUrl}", answers.authorUrl))
Expand All @@ -259,6 +262,15 @@ async function processAnswers(answers) {
.pipe(replace("{gitRootHttpsUrl}", gitRootHttpsUrl))
.pipe(replace("{documentationUrl}", answers.readmePath))
.pipe(replace("{packageDir}", packageDir))
.pipe(
// npm renames a literal ".gitignore" to ".npmignore" when this package is
// published, so the template ships as "gitignore" and is restored here.
rename((p) => {
if (p.basename === "gitignore" && p.extname === "") {
p.basename = ".gitignore";
}
})
)
.pipe(dest(destPath));
}

Expand All @@ -270,8 +282,8 @@ async function processAnswers(answers) {
"{publishingComment}\n",
answers.isContribRepo
? // prettier-ignore
`<!-- Once this extension package is published, it can be loaded via\n<script src="https://unpkg.com/@jspsych-contrib/${packageName}"></script>\n<script src="../dist/index.browser.js"></script> -->\n`
: `<!-- Load the published extension package here, e.g.\n<script src="https://unpkg.com/${packageName}"></script>\n<script src="../dist/index.browser.js"></script> -->\n`
`<!-- Once this extension package is published, you can load it from a CDN instead:\n<script src="https://unpkg.com/@jspsych-contrib/${packageName}"></script> -->\n`
: `<!-- Once this extension package is published, you can load it from a CDN instead:\n<script src="https://unpkg.com/${packageName}"></script> -->\n`
)
)
.pipe(dest(`${destPath}/examples`));
Expand Down Expand Up @@ -311,8 +323,8 @@ async function processAnswers(answers) {
? // prettier-ignore
answers.language == "ts"
? // prettier-ignore
`## Loading\n\n### In browser\n\n\`\`\`html\n<script src="https://unpkg.com/@jspsych-contrib/${packageName}">\n\`\`\`\n\n### Via NPM\n\n\`\`\`\nnpm install ${npmPackageName}\n\`\`\`\n\n\`\`\`js\nimport ${globalName} from "${packageName}";\n\`\`\``
: `## Loading\n\n### In browser\n\n\`\`\`html\n<script src="https://unpkg.com/@jspsych-contrib/${packageName}">\n\`\`\`\n\n### Via NPM\n\n\`\`\`\nnpm install ${npmPackageName}\n\`\`\``
`## Loading\n\n### In browser\n\n\`\`\`html\n<script src="https://unpkg.com/@jspsych-contrib/${packageName}"></script>\n\`\`\`\n\n### Via NPM\n\n\`\`\`\nnpm install ${npmPackageName}\n\`\`\`\n\n\`\`\`js\nimport ${camelCaseName} from "${npmPackageName}";\n\`\`\``
: `## Loading\n\n### In browser\n\n\`\`\`html\n<script src="https://unpkg.com/@jspsych-contrib/${packageName}"></script>\n\`\`\`\n\n### Via NPM\n\n\`\`\`\nnpm install ${npmPackageName}\n\`\`\``
: `## Loading\n\n*Enter instructions for loading the extension package here.*`
)
)
Expand Down
30 changes: 15 additions & 15 deletions packages/new-extension/templates/extension-template-js/CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "{author}" # Replace with last name
given-names: "{author}" # Replace with first name
name-particle: "{author}" # Replace with name particle(s)
- family-names: "" # Replace with last name
given-names: "" # Replace with first name
# name-particle: "" # Optional: name particle(s), e.g. "de", "van"
orcid: "https://orcid.org/0000-0000-0000-0000" # Replace with ORCID
# More authors can be listed here in the same format as above
# More authors can be listed here in the same format as above
contact: # Contact person for this extension
- family-names: "{author}"
given-names: "{author}"
email: "{email}" # Replace with contact person's email
- family-names: "" # Replace with last name
given-names: "" # Replace with first name
email: "" # Replace with contact person's email
orcid: "https://orcid.org/0000-0000-0000-0000" # Replace with contact person's ORCID
title: "{globalName}"
version: 0.0.0
doi: 10.5281/zenodo.1234 # Replace with DOI
date-released: 2000-01-01
url: "{softwareUrl}" # Replace with URL to this extension
url: "" # Replace with URL to this extension

# If you wish to cite a paper on this extension instead, you can use the following template:
preferred-citation:
authors:
- family-names: "{author}"
given-names: "{author}"
name-particle: "{author}"
- family-names: "" # Replace with last name
given-names: "" # Replace with first name
# name-particle: "" # Optional: name particle(s)
orcid: "https://orcid.org/0000-0000-0000-0000"
# More authors can be listed here in the same format as above
date-published: 2023-05-11
doi: 10.21105/joss.12345
doi: 10.21105/joss.12345
issn: 1234-5678
issue: 01
journal: Journal for Open Source Software
publisher:
name: Open Journals
start: 0001
title: "{title}"
title: "" # Replace with the title of the publication
type: article # Other options include: book, pamphlet, conference-paper...
url: "{linkToPublicationInJournal}"
url: "" # Replace with URL to the publication
volume: 1

# More information on the preffered-citation CFF format can be found at https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-citation-files#citing-something-other-than-software
# More information on the preffered-citation CFF format can be found at https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-citation-files#citing-something-other-than-software
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
node_modules/
30 changes: 15 additions & 15 deletions packages/new-extension/templates/extension-template-ts/CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "{author}" # Replace with last name
given-names: "{author}" # Replace with first name
name-particle: "{author}" # Replace with name particle(s)
- family-names: "" # Replace with last name
given-names: "" # Replace with first name
# name-particle: "" # Optional: name particle(s), e.g. "de", "van"
orcid: "https://orcid.org/0000-0000-0000-0000" # Replace with ORCID
# More authors can be listed here in the same format as above
# More authors can be listed here in the same format as above
contact: # Contact person for this extension
- family-names: "{author}"
given-names: "{author}"
email: "{email}" # Replace with contact person's email
- family-names: "" # Replace with last name
given-names: "" # Replace with first name
email: "" # Replace with contact person's email
orcid: "https://orcid.org/0000-0000-0000-0000" # Replace with contact person's ORCID
title: "{globalName}"
version: 0.0.0
doi: 10.5281/zenodo.1234 # Replace with DOI
date-released: 2000-01-01
url: "{softwareUrl}" # Replace with URL to this extension
url: "" # Replace with URL to this extension

# If you wish to cite a paper on this extension instead, you can use the following template:
preferred-citation:
authors:
- family-names: "{author}"
given-names: "{author}"
name-particle: "{author}"
- family-names: "" # Replace with last name
given-names: "" # Replace with first name
# name-particle: "" # Optional: name particle(s)
orcid: "https://orcid.org/0000-0000-0000-0000"
# More authors can be listed here in the same format as above
date-published: 2023-05-11
doi: 10.21105/joss.12345
doi: 10.21105/joss.12345
issn: 1234-5678
issue: 01
journal: Journal for Open Source Software
publisher:
name: Open Journals
start: 0001
title: "{title}"
title: "" # Replace with the title of the publication
type: article # Other options include: book, pamphlet, conference-paper...
url: "{linkToPublicationInJournal}"
url: "" # Replace with URL to the publication
volume: 1

# More information on the preffered-citation CFF format can be found at https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-citation-files#citing-something-other-than-software
# More information on the preffered-citation CFF format can be found at https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-citation-files#citing-something-other-than-software
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
node_modules/
22 changes: 17 additions & 5 deletions packages/new-plugin/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,10 @@ async function processAnswers(answers) {
const gitRootHttpsUrl = getGitHttpsUrl(gitRootUrl);

function processTemplate() {
return src(`${templatesDir}/plugin-template-${answers.language}/**/*`)
return src(`${templatesDir}/plugin-template-${answers.language}/**/*`, {
dot: true, // Includes hidden files too
nodir: false // Includes directories
})
.pipe(replace("{npmPackageName}", npmPackageName))
.pipe(replace("{author}", answers.author))
.pipe(replace("{authorUrl}", answers.authorUrl))
Expand All @@ -259,6 +262,15 @@ async function processAnswers(answers) {
.pipe(replace("{gitRootHttpsUrl}", gitRootHttpsUrl))
.pipe(replace("{documentationUrl}", answers.readmePath))
.pipe(replace("{packageDir}", packageDir))
.pipe(
// npm renames a literal ".gitignore" to ".npmignore" when this package is
// published, so the template ships as "gitignore" and is restored here.
rename((p) => {
if (p.basename === "gitignore" && p.extname === "") {
p.basename = ".gitignore";
}
})
)
.pipe(dest(destPath));
}

Expand All @@ -270,8 +282,8 @@ async function processAnswers(answers) {
"{publishingComment}\n",
answers.isContribRepo
? // prettier-ignore
`<!-- Once this plugin package is published, it can be loaded via\n<script src="https://unpkg.com/@jspsych-contrib/${packageName}"></script>\n<script src="../dist/index.browser.js"></script> -->\n`
: `<!-- Load the published plugin package here, e.g.\n<script src="https://unpkg.com/${packageName}"></script>\n<script src="../dist/index.browser.js"></script> -->\n`
`<!-- Once this plugin package is published, you can load it from a CDN instead:\n<script src="https://unpkg.com/@jspsych-contrib/${packageName}"></script> -->\n`
: `<!-- Once this plugin package is published, you can load it from a CDN instead:\n<script src="https://unpkg.com/${packageName}"></script> -->\n`
)
)
.pipe(dest(`${destPath}/examples`));
Expand Down Expand Up @@ -311,8 +323,8 @@ async function processAnswers(answers) {
? // prettier-ignore
answers.language == "ts"
? // prettier-ignore
`## Loading\n\n### In browser\n\n\`\`\`html\n<script src="https://unpkg.com/@jspsych-contrib/${packageName}">\n\`\`\`\n\n### Via NPM\n\n\`\`\`\nnpm install ${npmPackageName}\n\`\`\`\n\n\`\`\`js\nimport ${globalName} from "${packageName}";\n\`\`\``
: `## Loading\n\n### In browser\n\n\`\`\`html\n<script src="https://unpkg.com/@jspsych-contrib/${packageName}">\n\`\`\`\n\n### Via NPM\n\n\`\`\`\nnpm install ${npmPackageName}\n\`\`\``
`## Loading\n\n### In browser\n\n\`\`\`html\n<script src="https://unpkg.com/@jspsych-contrib/${packageName}"></script>\n\`\`\`\n\n### Via NPM\n\n\`\`\`\nnpm install ${npmPackageName}\n\`\`\`\n\n\`\`\`js\nimport ${camelCaseName} from "${npmPackageName}";\n\`\`\``
: `## Loading\n\n### In browser\n\n\`\`\`html\n<script src="https://unpkg.com/@jspsych-contrib/${packageName}"></script>\n\`\`\`\n\n### Via NPM\n\n\`\`\`\nnpm install ${npmPackageName}\n\`\`\``
: `## Loading\n\n*Enter instructions for loading the plugin package here.*`
)
)
Expand Down
34 changes: 17 additions & 17 deletions packages/new-plugin/templates/plugin-template-js/CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "{author}" # Replace with last name
given-names: "{author}" # Replace with first name
name-particle: "{author}" # Replace with name particle(s)
- family-names: "" # Replace with last name
given-names: "" # Replace with first name
# name-particle: "" # Optional: name particle(s), e.g. "de", "van"
orcid: "https://orcid.org/0000-0000-0000-0000" # Replace with ORCID
# More authors can be listed here in the same format as above
contact: # Contact person for this extension
- family-names: "{author}"
given-names: "{author}"
email: "{email}" # Replace with contact person's email
# More authors can be listed here in the same format as above
contact: # Contact person for this plugin
- family-names: "" # Replace with last name
given-names: "" # Replace with first name
email: "" # Replace with contact person's email
orcid: "https://orcid.org/0000-0000-0000-0000" # Replace with contact person's ORCID
title: "{globalName}"
version: 0.0.0
doi: 10.5281/zenodo.1234 # Replace with DOI
date-released: 2000-01-01
url: "{softwareUrl}" # Replace with URL to this extension
url: "" # Replace with URL to this plugin

# If you wish to cite a paper on this extension instead, you can use the following template:
# If you wish to cite a paper on this plugin instead, you can use the following template:
preferred-citation:
authors:
- family-names: "{author}"
given-names: "{author}"
name-particle: "{author}"
- family-names: "" # Replace with last name
given-names: "" # Replace with first name
# name-particle: "" # Optional: name particle(s)
orcid: "https://orcid.org/0000-0000-0000-0000"
# More authors can be listed here in the same format as above
date-published: 2023-05-11
doi: 10.21105/joss.12345
doi: 10.21105/joss.12345
issn: 1234-5678
issue: 01
journal: Journal for Open Source Software
publisher:
name: Open Journals
start: 0001
title: "{title}"
title: "" # Replace with the title of the publication
type: article # Other options include: book, pamphlet, conference-paper...
url: "{linkToPublicationInJournal}"
url: "" # Replace with URL to the publication
volume: 1

# More information on the preffered-citation CFF format can be found at https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-citation-files#citing-something-other-than-software
# More information on the preffered-citation CFF format can be found at https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-citation-files#citing-something-other-than-software
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>{globalName} Example</title>
<script src="https://unpkg.com/jspsych"></script>
{publishingComment}
<script src="../dist/index.browser.js"></script>
<script src="../dist/index.browser.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/jspsych/css/jspsych.css" />
</head>

Expand Down
2 changes: 2 additions & 0 deletions packages/new-plugin/templates/plugin-template-js/gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
node_modules/
34 changes: 17 additions & 17 deletions packages/new-plugin/templates/plugin-template-ts/CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "{author}" # Replace with last name
given-names: "{author}" # Replace with first name
name-particle: "{author}" # Replace with name particle(s)
- family-names: "" # Replace with last name
given-names: "" # Replace with first name
# name-particle: "" # Optional: name particle(s), e.g. "de", "van"
orcid: "https://orcid.org/0000-0000-0000-0000" # Replace with ORCID
# More authors can be listed here in the same format as above
contact: # Contact person for this extension
- family-names: "{author}"
given-names: "{author}"
email: "{email}" # Replace with contact person's email
# More authors can be listed here in the same format as above
contact: # Contact person for this plugin
- family-names: "" # Replace with last name
given-names: "" # Replace with first name
email: "" # Replace with contact person's email
orcid: "https://orcid.org/0000-0000-0000-0000" # Replace with contact person's ORCID
title: "{globalName}"
version: 0.0.0
doi: 10.5281/zenodo.1234 # Replace with DOI
date-released: 2000-01-01
url: "{softwareUrl}" # Replace with URL to this extension
url: "" # Replace with URL to this plugin

# If you wish to cite a paper on this extension instead, you can use the following template:
# If you wish to cite a paper on this plugin instead, you can use the following template:
preferred-citation:
authors:
- family-names: "{author}"
given-names: "{author}"
name-particle: "{author}"
- family-names: "" # Replace with last name
given-names: "" # Replace with first name
# name-particle: "" # Optional: name particle(s)
orcid: "https://orcid.org/0000-0000-0000-0000"
# More authors can be listed here in the same format as above
date-published: 2023-05-11
doi: 10.21105/joss.12345
doi: 10.21105/joss.12345
issn: 1234-5678
issue: 01
journal: Journal for Open Source Software
publisher:
name: Open Journals
start: 0001
title: "{title}"
title: "" # Replace with the title of the publication
type: article # Other options include: book, pamphlet, conference-paper...
url: "{linkToPublicationInJournal}"
url: "" # Replace with URL to the publication
volume: 1

# More information on the preffered-citation CFF format can be found at https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-citation-files#citing-something-other-than-software
# More information on the preffered-citation CFF format can be found at https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-citation-files#citing-something-other-than-software
Loading