diff --git a/.changeset/fix-template-scaffold-bugs.md b/.changeset/fix-template-scaffold-bugs.md new file mode 100644 index 0000000..7f3a833 --- /dev/null +++ b/.changeset/fix-template-scaffold-bugs.md @@ -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 `\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\n\`\`\`\n\n### Via NPM\n\n\`\`\`\nnpm install ${npmPackageName}\n\`\`\`` : `## Loading\n\n*Enter instructions for loading the extension package here.*` ) ) diff --git a/packages/new-extension/templates/extension-template-js/CITATION.cff b/packages/new-extension/templates/extension-template-js/CITATION.cff index 9ff27fd..e7dc4d6 100644 --- a/packages/new-extension/templates/extension-template-js/CITATION.cff +++ b/packages/new-extension/templates/extension-template-js/CITATION.cff @@ -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 \ No newline at end of file +# 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 diff --git a/packages/new-extension/templates/extension-template-js/gitignore b/packages/new-extension/templates/extension-template-js/gitignore new file mode 100644 index 0000000..763301f --- /dev/null +++ b/packages/new-extension/templates/extension-template-js/gitignore @@ -0,0 +1,2 @@ +dist/ +node_modules/ \ No newline at end of file diff --git a/packages/new-extension/templates/extension-template-ts/CITATION.cff b/packages/new-extension/templates/extension-template-ts/CITATION.cff index 9ff27fd..e7dc4d6 100644 --- a/packages/new-extension/templates/extension-template-ts/CITATION.cff +++ b/packages/new-extension/templates/extension-template-ts/CITATION.cff @@ -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 \ No newline at end of file +# 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 diff --git a/packages/new-extension/templates/extension-template-ts/gitignore b/packages/new-extension/templates/extension-template-ts/gitignore new file mode 100644 index 0000000..763301f --- /dev/null +++ b/packages/new-extension/templates/extension-template-ts/gitignore @@ -0,0 +1,2 @@ +dist/ +node_modules/ \ No newline at end of file diff --git a/packages/new-plugin/src/cli.js b/packages/new-plugin/src/cli.js index 31d7146..e89eb9d 100755 --- a/packages/new-plugin/src/cli.js +++ b/packages/new-plugin/src/cli.js @@ -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)) @@ -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)); } @@ -270,8 +282,8 @@ async function processAnswers(answers) { "{publishingComment}\n", answers.isContribRepo ? // prettier-ignore - `\n` - : `\n` + `\n` + : `\n` ) ) .pipe(dest(`${destPath}/examples`)); @@ -311,8 +323,8 @@ async function processAnswers(answers) { ? // prettier-ignore answers.language == "ts" ? // prettier-ignore - `## Loading\n\n### In browser\n\n\`\`\`html\n\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\n\`\`\`\n\n### Via NPM\n\n\`\`\`\nnpm install ${npmPackageName}\n\`\`\`` : `## Loading\n\n*Enter instructions for loading the plugin package here.*` ) ) diff --git a/packages/new-plugin/templates/plugin-template-js/CITATION.cff b/packages/new-plugin/templates/plugin-template-js/CITATION.cff index 9ff27fd..505fba5 100644 --- a/packages/new-plugin/templates/plugin-template-js/CITATION.cff +++ b/packages/new-plugin/templates/plugin-template-js/CITATION.cff @@ -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 \ No newline at end of file +# 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 diff --git a/packages/new-plugin/templates/plugin-template-js/examples/index.html b/packages/new-plugin/templates/plugin-template-js/examples/index.html index 8813615..4e8faa1 100644 --- a/packages/new-plugin/templates/plugin-template-js/examples/index.html +++ b/packages/new-plugin/templates/plugin-template-js/examples/index.html @@ -4,7 +4,7 @@ {globalName} Example {publishingComment} - + diff --git a/packages/new-plugin/templates/plugin-template-js/gitignore b/packages/new-plugin/templates/plugin-template-js/gitignore new file mode 100644 index 0000000..763301f --- /dev/null +++ b/packages/new-plugin/templates/plugin-template-js/gitignore @@ -0,0 +1,2 @@ +dist/ +node_modules/ \ No newline at end of file diff --git a/packages/new-plugin/templates/plugin-template-ts/CITATION.cff b/packages/new-plugin/templates/plugin-template-ts/CITATION.cff index 9ff27fd..505fba5 100644 --- a/packages/new-plugin/templates/plugin-template-ts/CITATION.cff +++ b/packages/new-plugin/templates/plugin-template-ts/CITATION.cff @@ -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 \ No newline at end of file +# 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 diff --git a/packages/new-plugin/templates/plugin-template-ts/examples/index.html b/packages/new-plugin/templates/plugin-template-ts/examples/index.html index 8813615..4e8faa1 100644 --- a/packages/new-plugin/templates/plugin-template-ts/examples/index.html +++ b/packages/new-plugin/templates/plugin-template-ts/examples/index.html @@ -4,7 +4,7 @@ {globalName} Example {publishingComment} - + diff --git a/packages/new-plugin/templates/plugin-template-ts/gitignore b/packages/new-plugin/templates/plugin-template-ts/gitignore new file mode 100644 index 0000000..763301f --- /dev/null +++ b/packages/new-plugin/templates/plugin-template-ts/gitignore @@ -0,0 +1,2 @@ +dist/ +node_modules/ \ No newline at end of file diff --git a/packages/new-timeline/src/cli.js b/packages/new-timeline/src/cli.js index 6c490e6..1f2fa0e 100755 --- a/packages/new-timeline/src/cli.js +++ b/packages/new-timeline/src/cli.js @@ -245,7 +245,10 @@ async function processAnswers(answers) { const gitRootHttpsUrl = getGitHttpsUrl(gitRootUrl); function processTemplate() { - return src(`${templatesDir}/timeline-template-${answers.language}/**/*`) + return src(`${templatesDir}/timeline-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)) @@ -258,6 +261,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)); } @@ -269,8 +281,8 @@ async function processAnswers(answers) { "{publishingComment}\n", answers.isTimelinesRepo ? // prettier-ignore - `\n` - : `\n` + `\n` + : `\n` ) ) .pipe(dest(`${destPath}/examples`)); @@ -299,7 +311,7 @@ async function processAnswers(answers) { `## Loading`, answers.isTimelinesRepo ? // prettier-ignore - `## Loading\n\n### In browser\n\n\`\`\`html\n\n\`\`\`\n\n### Via NPM\n\n\`\`\`\nnpm install ${npmPackageName}\n\`\`\`\n\n\`\`\`js\nimport { createTimeline, timelineUnits, utils } from "${npmPackageName}"\n\`\`\`` : `## Loading\n\n*Enter instructions for loading the timeline package here.*` ) ) diff --git a/packages/new-timeline/templates/timeline-template-js/examples/index.html b/packages/new-timeline/templates/timeline-template-js/examples/index.html index 23128df..f78942d 100644 --- a/packages/new-timeline/templates/timeline-template-js/examples/index.html +++ b/packages/new-timeline/templates/timeline-template-js/examples/index.html @@ -4,8 +4,8 @@ {globalName} Example - {publishingComment} + diff --git a/packages/new-timeline/templates/timeline-template-js/gitignore b/packages/new-timeline/templates/timeline-template-js/gitignore new file mode 100644 index 0000000..763301f --- /dev/null +++ b/packages/new-timeline/templates/timeline-template-js/gitignore @@ -0,0 +1,2 @@ +dist/ +node_modules/ \ No newline at end of file diff --git a/packages/new-timeline/templates/timeline-template-ts/examples/index.html b/packages/new-timeline/templates/timeline-template-ts/examples/index.html index 23128df..f78942d 100644 --- a/packages/new-timeline/templates/timeline-template-ts/examples/index.html +++ b/packages/new-timeline/templates/timeline-template-ts/examples/index.html @@ -4,8 +4,8 @@ {globalName} Example - {publishingComment} + diff --git a/packages/new-timeline/templates/timeline-template-ts/gitignore b/packages/new-timeline/templates/timeline-template-ts/gitignore new file mode 100644 index 0000000..763301f --- /dev/null +++ b/packages/new-timeline/templates/timeline-template-ts/gitignore @@ -0,0 +1,2 @@ +dist/ +node_modules/ \ No newline at end of file diff --git a/packages/new-timeline/templates/timeline-template-ts/package.json b/packages/new-timeline/templates/timeline-template-ts/package.json index bbfc12e..8f6b6b4 100644 --- a/packages/new-timeline/templates/timeline-template-ts/package.json +++ b/packages/new-timeline/templates/timeline-template-ts/package.json @@ -7,7 +7,7 @@ "types": "dist/index.d.ts", "unpkg": "dist/index.browser.min.js", "scripts": { - "build": "tsup src/index.ts --format esm,iife --sourcemap --dts --treeshake --clean --global-name {globalName}" + "build": "tsup" }, "repository": { "type": "git", diff --git a/packages/new-timeline/templates/timeline-template-ts/tsup.config.ts b/packages/new-timeline/templates/timeline-template-ts/tsup.config.ts new file mode 100644 index 0000000..ef53978 --- /dev/null +++ b/packages/new-timeline/templates/timeline-template-ts/tsup.config.ts @@ -0,0 +1,24 @@ +import { defineConfig } from "tsup"; + +export default defineConfig([ + { + // ES module build, consumed via `import` / bundlers + entry: ["src/index.ts"], + format: ["esm"], + outExtension: () => ({ js: ".mjs" }), + sourcemap: true, + dts: true, + treeshake: true, + clean: true, + }, + { + // Minified browser (IIFE) build, exposed on the page as `{globalName}` + entry: ["src/index.ts"], + format: ["iife"], + globalName: "{globalName}", + outExtension: () => ({ js: ".browser.min.js" }), + sourcemap: true, + treeshake: true, + minify: true, + }, +]);