create-typescript-app 1.29.47 → 1.29.48

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.
@@ -6,7 +6,7 @@ import { addToolAllContributors } from "../steps/addToolAllContributors.js";
6
6
  import { finalizeDependencies } from "../steps/finalizeDependencies.js";
7
7
  import { initializeGitHubRepository } from "../steps/initializeGitHubRepository/index.js";
8
8
  import { runCommands } from "../steps/runCommands.js";
9
- import { writeReadme } from "../steps/writeReadme.js";
9
+ import { writeReadme } from "../steps/writeReadme/index.js";
10
10
  import { writeStructure } from "../steps/writing/writeStructure.js";
11
11
  async function createWithOptions({ github, options }) {
12
12
  await withSpinners("Creating repository structure", [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/create/createWithOptions.ts"],"sourcesContent":["import * as prompts from \"@clack/prompts\";\nimport { $ } from \"execa\";\n\nimport { withSpinner, withSpinners } from \"../shared/cli/spinners.js\";\nimport { doesRepositoryExist } from \"../shared/doesRepositoryExist.js\";\nimport { GitHubAndOptions } from \"../shared/options/readOptions.js\";\nimport { addToolAllContributors } from \"../steps/addToolAllContributors.js\";\nimport { finalizeDependencies } from \"../steps/finalizeDependencies.js\";\nimport { initializeGitHubRepository } from \"../steps/initializeGitHubRepository/index.js\";\nimport { runCommands } from \"../steps/runCommands.js\";\nimport { writeReadme } from \"../steps/writeReadme.js\";\nimport { writeStructure } from \"../steps/writing/writeStructure.js\";\n\nexport async function createWithOptions({ github, options }: GitHubAndOptions) {\n\tawait withSpinners(\"Creating repository structure\", [\n\t\t[\n\t\t\t\"Writing structure\",\n\t\t\tasync () => {\n\t\t\t\tawait writeStructure(options, \"create\");\n\t\t\t},\n\t\t],\n\t\t[\n\t\t\t\"Writing README.md\",\n\t\t\tasync () => {\n\t\t\t\tawait writeReadme(options);\n\t\t\t},\n\t\t],\n\t]);\n\n\tif (!options.excludeContributors) {\n\t\tawait withSpinner(\"Adding contributors to table\", async () => {\n\t\t\tawait addToolAllContributors(options.owner);\n\t\t});\n\t}\n\n\tif (!options.skipInstall) {\n\t\tawait withSpinner(\"Installing packages\", async () =>\n\t\t\tfinalizeDependencies(options),\n\t\t);\n\t}\n\n\tawait runCommands(\"Cleaning up files\", [\n\t\t\"pnpm dedupe\",\n\t\t\"pnpm format --write\",\n\t\t\"pnpm lint --fix\",\n\t]);\n\n\tconst sendToGitHub =\n\t\tgithub &&\n\t\t(await doesRepositoryExist(github.octokit, options)) &&\n\t\t(options.createRepository ??\n\t\t\t(await prompts.confirm({\n\t\t\t\tmessage:\n\t\t\t\t\t\"Would you like to push the template's tooling up to the repository on GitHub?\",\n\t\t\t})) === true);\n\n\tif (sendToGitHub) {\n\t\tawait withSpinner(\"Initializing GitHub repository\", async () => {\n\t\t\tawait $`git remote add origin https://github.com/${options.owner}/${options.repository}`;\n\t\t\tawait $`git add -A`;\n\t\t\tawait $`git commit --message ${\"feat: initialized repo ✨\"}`;\n\t\t\tawait $`git push -u origin main --force`;\n\t\t\tawait initializeGitHubRepository(github.octokit, options);\n\t\t});\n\t}\n\n\treturn { sentToGitHub: sendToGitHub };\n}\n"],"mappings":"AAAA,YAAY,aAAa;AACzB,SAAS,SAAS;AAElB,SAAS,aAAa,oBAAoB;AAC1C,SAAS,2BAA2B;AAEpC,SAAS,8BAA8B;AACvC,SAAS,4BAA4B;AACrC,SAAS,kCAAkC;AAC3C,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAE/B,eAAsB,kBAAkB,EAAE,QAAQ,QAAQ,GAAqB;AAC9E,QAAM,aAAa,iCAAiC;AAAA,IACnD;AAAA,MACC;AAAA,MACA,YAAY;AACX,cAAM,eAAe,SAAS,QAAQ;AAAA,MACvC;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA,YAAY;AACX,cAAM,YAAY,OAAO;AAAA,MAC1B;AAAA,IACD;AAAA,EACD,CAAC;AAED,MAAI,CAAC,QAAQ,qBAAqB;AACjC,UAAM,YAAY,gCAAgC,YAAY;AAC7D,YAAM,uBAAuB,QAAQ,KAAK;AAAA,IAC3C,CAAC;AAAA,EACF;AAEA,MAAI,CAAC,QAAQ,aAAa;AACzB,UAAM;AAAA,MAAY;AAAA,MAAuB,YACxC,qBAAqB,OAAO;AAAA,IAC7B;AAAA,EACD;AAEA,QAAM,YAAY,qBAAqB;AAAA,IACtC;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAC;AAED,QAAM,eACL,UACC,MAAM,oBAAoB,OAAO,SAAS,OAAO,MACjD,QAAQ,oBACP,MAAM,QAAQ,QAAQ;AAAA,IACtB,SACC;AAAA,EACF,CAAC,MAAO;AAEV,MAAI,cAAc;AACjB,UAAM,YAAY,kCAAkC,YAAY;AAC/D,YAAM,6CAA6C,QAAQ,KAAK,IAAI,QAAQ,UAAU;AACtF,YAAM;AACN,YAAM,yBAAyB,+BAA0B;AACzD,YAAM;AACN,YAAM,2BAA2B,OAAO,SAAS,OAAO;AAAA,IACzD,CAAC;AAAA,EACF;AAEA,SAAO,EAAE,cAAc,aAAa;AACrC;","names":[]}
1
+ {"version":3,"sources":["../../src/create/createWithOptions.ts"],"sourcesContent":["import * as prompts from \"@clack/prompts\";\nimport { $ } from \"execa\";\n\nimport { withSpinner, withSpinners } from \"../shared/cli/spinners.js\";\nimport { doesRepositoryExist } from \"../shared/doesRepositoryExist.js\";\nimport { GitHubAndOptions } from \"../shared/options/readOptions.js\";\nimport { addToolAllContributors } from \"../steps/addToolAllContributors.js\";\nimport { finalizeDependencies } from \"../steps/finalizeDependencies.js\";\nimport { initializeGitHubRepository } from \"../steps/initializeGitHubRepository/index.js\";\nimport { runCommands } from \"../steps/runCommands.js\";\nimport { writeReadme } from \"../steps/writeReadme/index.js\";\nimport { writeStructure } from \"../steps/writing/writeStructure.js\";\n\nexport async function createWithOptions({ github, options }: GitHubAndOptions) {\n\tawait withSpinners(\"Creating repository structure\", [\n\t\t[\n\t\t\t\"Writing structure\",\n\t\t\tasync () => {\n\t\t\t\tawait writeStructure(options, \"create\");\n\t\t\t},\n\t\t],\n\t\t[\n\t\t\t\"Writing README.md\",\n\t\t\tasync () => {\n\t\t\t\tawait writeReadme(options);\n\t\t\t},\n\t\t],\n\t]);\n\n\tif (!options.excludeContributors) {\n\t\tawait withSpinner(\"Adding contributors to table\", async () => {\n\t\t\tawait addToolAllContributors(options.owner);\n\t\t});\n\t}\n\n\tif (!options.skipInstall) {\n\t\tawait withSpinner(\"Installing packages\", async () =>\n\t\t\tfinalizeDependencies(options),\n\t\t);\n\t}\n\n\tawait runCommands(\"Cleaning up files\", [\n\t\t\"pnpm dedupe\",\n\t\t\"pnpm format --write\",\n\t\t\"pnpm lint --fix\",\n\t]);\n\n\tconst sendToGitHub =\n\t\tgithub &&\n\t\t(await doesRepositoryExist(github.octokit, options)) &&\n\t\t(options.createRepository ??\n\t\t\t(await prompts.confirm({\n\t\t\t\tmessage:\n\t\t\t\t\t\"Would you like to push the template's tooling up to the repository on GitHub?\",\n\t\t\t})) === true);\n\n\tif (sendToGitHub) {\n\t\tawait withSpinner(\"Initializing GitHub repository\", async () => {\n\t\t\tawait $`git remote add origin https://github.com/${options.owner}/${options.repository}`;\n\t\t\tawait $`git add -A`;\n\t\t\tawait $`git commit --message ${\"feat: initialized repo ✨\"}`;\n\t\t\tawait $`git push -u origin main --force`;\n\t\t\tawait initializeGitHubRepository(github.octokit, options);\n\t\t});\n\t}\n\n\treturn { sentToGitHub: sendToGitHub };\n}\n"],"mappings":"AAAA,YAAY,aAAa;AACzB,SAAS,SAAS;AAElB,SAAS,aAAa,oBAAoB;AAC1C,SAAS,2BAA2B;AAEpC,SAAS,8BAA8B;AACvC,SAAS,4BAA4B;AACrC,SAAS,kCAAkC;AAC3C,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAE/B,eAAsB,kBAAkB,EAAE,QAAQ,QAAQ,GAAqB;AAC9E,QAAM,aAAa,iCAAiC;AAAA,IACnD;AAAA,MACC;AAAA,MACA,YAAY;AACX,cAAM,eAAe,SAAS,QAAQ;AAAA,MACvC;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA,YAAY;AACX,cAAM,YAAY,OAAO;AAAA,MAC1B;AAAA,IACD;AAAA,EACD,CAAC;AAED,MAAI,CAAC,QAAQ,qBAAqB;AACjC,UAAM,YAAY,gCAAgC,YAAY;AAC7D,YAAM,uBAAuB,QAAQ,KAAK;AAAA,IAC3C,CAAC;AAAA,EACF;AAEA,MAAI,CAAC,QAAQ,aAAa;AACzB,UAAM;AAAA,MAAY;AAAA,MAAuB,YACxC,qBAAqB,OAAO;AAAA,IAC7B;AAAA,EACD;AAEA,QAAM,YAAY,qBAAqB;AAAA,IACtC;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAC;AAED,QAAM,eACL,UACC,MAAM,oBAAoB,OAAO,SAAS,OAAO,MACjD,QAAQ,oBACP,MAAM,QAAQ,QAAQ;AAAA,IACtB,SACC;AAAA,EACF,CAAC,MAAO;AAEV,MAAI,cAAc;AACjB,UAAM,YAAY,kCAAkC,YAAY;AAC/D,YAAM,6CAA6C,QAAQ,KAAK,IAAI,QAAQ,UAAU;AACtF,YAAM;AACN,YAAM,yBAAyB,+BAA0B;AACzD,YAAM;AACN,YAAM,2BAA2B,OAAO,SAAS,OAAO;AAAA,IACzD,CAAC;AAAA,EACF;AAEA,SAAO,EAAE,cAAc,aAAa;AACrC;","names":[]}
@@ -6,7 +6,7 @@ import { initializeGitHubRepository } from "../steps/initializeGitHubRepository/
6
6
  import { runCommands } from "../steps/runCommands.js";
7
7
  import { updateAllContributorsTable } from "../steps/updateAllContributorsTable.js";
8
8
  import { updateLocalFiles } from "../steps/updateLocalFiles.js";
9
- import { writeReadme } from "../steps/writeReadme.js";
9
+ import { writeReadme } from "../steps/writeReadme/index.js";
10
10
  import { writeStructure } from "../steps/writing/writeStructure.js";
11
11
  async function migrateWithOptions({
12
12
  github,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/migrate/migrateWithOptions.ts"],"sourcesContent":["import { withSpinner, withSpinners } from \"../shared/cli/spinners.js\";\nimport { GitHubAndOptions } from \"../shared/options/readOptions.js\";\nimport { clearUnnecessaryFiles } from \"../steps/clearUnnecessaryFiles.js\";\nimport { detectExistingContributors } from \"../steps/detectExistingContributors.js\";\nimport { finalizeDependencies } from \"../steps/finalizeDependencies.js\";\nimport { initializeGitHubRepository } from \"../steps/initializeGitHubRepository/index.js\";\nimport { runCommands } from \"../steps/runCommands.js\";\nimport { updateAllContributorsTable } from \"../steps/updateAllContributorsTable.js\";\nimport { updateLocalFiles } from \"../steps/updateLocalFiles.js\";\nimport { writeReadme } from \"../steps/writeReadme.js\";\nimport { writeStructure } from \"../steps/writing/writeStructure.js\";\n\nexport async function migrateWithOptions({\n\tgithub,\n\toptions,\n}: GitHubAndOptions) {\n\tawait withSpinners(\"Migrating repository structure\", [\n\t\t[\"Clearing unnecessary files\", clearUnnecessaryFiles],\n\t\t[\n\t\t\t\"Writing structure\",\n\t\t\tasync () => {\n\t\t\t\tawait writeStructure(options, \"migrate\");\n\t\t\t},\n\t\t],\n\t\t[\n\t\t\t\"Writing README.md\",\n\t\t\tasync () => {\n\t\t\t\tawait writeReadme(options);\n\t\t\t},\n\t\t],\n\t\t[\n\t\t\t\"Updating local files\",\n\t\t\tasync () => {\n\t\t\t\tawait updateLocalFiles(options);\n\t\t\t},\n\t\t],\n\t\t[\n\t\t\t\"Updating all-contributors table\",\n\t\t\tasync () => {\n\t\t\t\tawait updateAllContributorsTable(options);\n\t\t\t},\n\t\t],\n\t]);\n\n\tif (github) {\n\t\tawait withSpinner(\"Initializing GitHub repository\", async () => {\n\t\t\tawait initializeGitHubRepository(github.octokit, options);\n\t\t});\n\t}\n\n\tif (!options.excludeContributors) {\n\t\tawait withSpinner(\"Detecting existing contributors\", async () =>\n\t\t\tdetectExistingContributors(github?.auth, options),\n\t\t);\n\t}\n\n\tif (!options.skipInstall) {\n\t\tawait withSpinner(\"Installing packages\", async () =>\n\t\t\tfinalizeDependencies(options),\n\t\t);\n\t}\n\n\tawait runCommands(\"Cleaning up files\", [\n\t\t\"pnpm lint --fix\",\n\t\t\"pnpm format --write\",\n\t]);\n}\n"],"mappings":"AAAA,SAAS,aAAa,oBAAoB;AAE1C,SAAS,6BAA6B;AACtC,SAAS,kCAAkC;AAC3C,SAAS,4BAA4B;AACrC,SAAS,kCAAkC;AAC3C,SAAS,mBAAmB;AAC5B,SAAS,kCAAkC;AAC3C,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAE/B,eAAsB,mBAAmB;AAAA,EACxC;AAAA,EACA;AACD,GAAqB;AACpB,QAAM,aAAa,kCAAkC;AAAA,IACpD,CAAC,8BAA8B,qBAAqB;AAAA,IACpD;AAAA,MACC;AAAA,MACA,YAAY;AACX,cAAM,eAAe,SAAS,SAAS;AAAA,MACxC;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA,YAAY;AACX,cAAM,YAAY,OAAO;AAAA,MAC1B;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA,YAAY;AACX,cAAM,iBAAiB,OAAO;AAAA,MAC/B;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA,YAAY;AACX,cAAM,2BAA2B,OAAO;AAAA,MACzC;AAAA,IACD;AAAA,EACD,CAAC;AAED,MAAI,QAAQ;AACX,UAAM,YAAY,kCAAkC,YAAY;AAC/D,YAAM,2BAA2B,OAAO,SAAS,OAAO;AAAA,IACzD,CAAC;AAAA,EACF;AAEA,MAAI,CAAC,QAAQ,qBAAqB;AACjC,UAAM;AAAA,MAAY;AAAA,MAAmC,YACpD,2BAA2B,QAAQ,MAAM,OAAO;AAAA,IACjD;AAAA,EACD;AAEA,MAAI,CAAC,QAAQ,aAAa;AACzB,UAAM;AAAA,MAAY;AAAA,MAAuB,YACxC,qBAAqB,OAAO;AAAA,IAC7B;AAAA,EACD;AAEA,QAAM,YAAY,qBAAqB;AAAA,IACtC;AAAA,IACA;AAAA,EACD,CAAC;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/migrate/migrateWithOptions.ts"],"sourcesContent":["import { withSpinner, withSpinners } from \"../shared/cli/spinners.js\";\nimport { GitHubAndOptions } from \"../shared/options/readOptions.js\";\nimport { clearUnnecessaryFiles } from \"../steps/clearUnnecessaryFiles.js\";\nimport { detectExistingContributors } from \"../steps/detectExistingContributors.js\";\nimport { finalizeDependencies } from \"../steps/finalizeDependencies.js\";\nimport { initializeGitHubRepository } from \"../steps/initializeGitHubRepository/index.js\";\nimport { runCommands } from \"../steps/runCommands.js\";\nimport { updateAllContributorsTable } from \"../steps/updateAllContributorsTable.js\";\nimport { updateLocalFiles } from \"../steps/updateLocalFiles.js\";\nimport { writeReadme } from \"../steps/writeReadme/index.js\";\nimport { writeStructure } from \"../steps/writing/writeStructure.js\";\n\nexport async function migrateWithOptions({\n\tgithub,\n\toptions,\n}: GitHubAndOptions) {\n\tawait withSpinners(\"Migrating repository structure\", [\n\t\t[\"Clearing unnecessary files\", clearUnnecessaryFiles],\n\t\t[\n\t\t\t\"Writing structure\",\n\t\t\tasync () => {\n\t\t\t\tawait writeStructure(options, \"migrate\");\n\t\t\t},\n\t\t],\n\t\t[\n\t\t\t\"Writing README.md\",\n\t\t\tasync () => {\n\t\t\t\tawait writeReadme(options);\n\t\t\t},\n\t\t],\n\t\t[\n\t\t\t\"Updating local files\",\n\t\t\tasync () => {\n\t\t\t\tawait updateLocalFiles(options);\n\t\t\t},\n\t\t],\n\t\t[\n\t\t\t\"Updating all-contributors table\",\n\t\t\tasync () => {\n\t\t\t\tawait updateAllContributorsTable(options);\n\t\t\t},\n\t\t],\n\t]);\n\n\tif (github) {\n\t\tawait withSpinner(\"Initializing GitHub repository\", async () => {\n\t\t\tawait initializeGitHubRepository(github.octokit, options);\n\t\t});\n\t}\n\n\tif (!options.excludeContributors) {\n\t\tawait withSpinner(\"Detecting existing contributors\", async () =>\n\t\t\tdetectExistingContributors(github?.auth, options),\n\t\t);\n\t}\n\n\tif (!options.skipInstall) {\n\t\tawait withSpinner(\"Installing packages\", async () =>\n\t\t\tfinalizeDependencies(options),\n\t\t);\n\t}\n\n\tawait runCommands(\"Cleaning up files\", [\n\t\t\"pnpm lint --fix\",\n\t\t\"pnpm format --write\",\n\t]);\n}\n"],"mappings":"AAAA,SAAS,aAAa,oBAAoB;AAE1C,SAAS,6BAA6B;AACtC,SAAS,kCAAkC;AAC3C,SAAS,4BAA4B;AACrC,SAAS,kCAAkC;AAC3C,SAAS,mBAAmB;AAC5B,SAAS,kCAAkC;AAC3C,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAE/B,eAAsB,mBAAmB;AAAA,EACxC;AAAA,EACA;AACD,GAAqB;AACpB,QAAM,aAAa,kCAAkC;AAAA,IACpD,CAAC,8BAA8B,qBAAqB;AAAA,IACpD;AAAA,MACC;AAAA,MACA,YAAY;AACX,cAAM,eAAe,SAAS,SAAS;AAAA,MACxC;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA,YAAY;AACX,cAAM,YAAY,OAAO;AAAA,MAC1B;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA,YAAY;AACX,cAAM,iBAAiB,OAAO;AAAA,MAC/B;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA,YAAY;AACX,cAAM,2BAA2B,OAAO;AAAA,MACzC;AAAA,IACD;AAAA,EACD,CAAC;AAED,MAAI,QAAQ;AACX,UAAM,YAAY,kCAAkC,YAAY;AAC/D,YAAM,2BAA2B,OAAO,SAAS,OAAO;AAAA,IACzD,CAAC;AAAA,EACF;AAEA,MAAI,CAAC,QAAQ,qBAAqB;AACjC,UAAM;AAAA,MAAY;AAAA,MAAmC,YACpD,2BAA2B,QAAQ,MAAM,OAAO;AAAA,IACjD;AAAA,EACD;AAEA,MAAI,CAAC,QAAQ,aAAa;AACzB,UAAM;AAAA,MAAY;AAAA,MAAuB,YACxC,qBAAqB,OAAO;AAAA,IAC7B;AAAA,EACD;AAEA,QAAM,YAAY,qBAAqB;AAAA,IACtC;AAAA,IACA;AAAA,EACD,CAAC;AACF;","names":[]}
@@ -0,0 +1,4 @@
1
+ declare const existingBadgeMatcherCreators: (() => RegExp)[];
2
+ declare function findExistingBadges(contents: string): string[];
3
+
4
+ export { existingBadgeMatcherCreators, findExistingBadges };
@@ -0,0 +1,31 @@
1
+ const existingBadgeMatcherCreators = [
2
+ () => /\[!\[.+\]\(.+\)\]\(.+\)/g,
3
+ () => /!\[.+\]\(.+\)/g,
4
+ () => /^\s*<a[ \tA-Za-z_\-=#&;?./:'"]*>[\s\S]+?<\/a>/gm,
5
+ () => /<img.+src.+\/>/g
6
+ ];
7
+ function findExistingBadges(contents) {
8
+ const badges = [];
9
+ let remaining = contents.split(/<\s*h2.*>|##/)[0];
10
+ for (const createMatcher of existingBadgeMatcherCreators) {
11
+ const matcher = createMatcher();
12
+ while (true) {
13
+ const matched = matcher.exec(remaining);
14
+ if (!matched) {
15
+ break;
16
+ }
17
+ const [badge] = matched;
18
+ badges.push(badge.trim());
19
+ remaining = [
20
+ remaining.slice(0, matched.index),
21
+ remaining.slice(matched.index + badge.length)
22
+ ].join("");
23
+ }
24
+ }
25
+ return badges;
26
+ }
27
+ export {
28
+ existingBadgeMatcherCreators,
29
+ findExistingBadges
30
+ };
31
+ //# sourceMappingURL=findExistingBadges.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/steps/writeReadme/findExistingBadges.ts"],"sourcesContent":["export const existingBadgeMatcherCreators = [\n\t() => /\\[!\\[.+\\]\\(.+\\)\\]\\(.+\\)/g,\n\t() => /!\\[.+\\]\\(.+\\)/g,\n\t() => /^\\s*<a[ \\tA-Za-z_\\-=#&;?./:'\"]*>[\\s\\S]+?<\\/a>/gm,\n\t() => /<img.+src.+\\/>/g,\n];\n\nexport function findExistingBadges(contents: string): string[] {\n\tconst badges: string[] = [];\n\tlet remaining = contents.split(/<\\s*h2.*>|##/)[0];\n\n\tfor (const createMatcher of existingBadgeMatcherCreators) {\n\t\tconst matcher = createMatcher();\n\n\t\twhile (true) {\n\t\t\tconst matched = matcher.exec(remaining);\n\n\t\t\tif (!matched) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tconst [badge] = matched;\n\n\t\t\tbadges.push(badge.trim());\n\t\t\tremaining = [\n\t\t\t\tremaining.slice(0, matched.index),\n\t\t\t\tremaining.slice(matched.index + badge.length),\n\t\t\t].join(\"\");\n\t\t}\n\t}\n\n\treturn badges;\n}\n"],"mappings":"AAAO,MAAM,+BAA+B;AAAA,EAC3C,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACP;AAEO,SAAS,mBAAmB,UAA4B;AAC9D,QAAM,SAAmB,CAAC;AAC1B,MAAI,YAAY,SAAS,MAAM,cAAc,EAAE,CAAC;AAEhD,aAAW,iBAAiB,8BAA8B;AACzD,UAAM,UAAU,cAAc;AAE9B,WAAO,MAAM;AACZ,YAAM,UAAU,QAAQ,KAAK,SAAS;AAEtC,UAAI,CAAC,SAAS;AACb;AAAA,MACD;AAEA,YAAM,CAAC,KAAK,IAAI;AAEhB,aAAO,KAAK,MAAM,KAAK,CAAC;AACxB,kBAAY;AAAA,QACX,UAAU,MAAM,GAAG,QAAQ,KAAK;AAAA,QAChC,UAAU,MAAM,QAAQ,QAAQ,MAAM,MAAM;AAAA,MAC7C,EAAE,KAAK,EAAE;AAAA,IACV;AAAA,EACD;AAEA,SAAO;AACR;","names":[]}
@@ -0,0 +1,3 @@
1
+ declare function findIntroSectionClose(contents: string): number;
2
+
3
+ export { findIntroSectionClose };
@@ -0,0 +1,18 @@
1
+ import { existingBadgeMatcherCreators } from "./findExistingBadges.js";
2
+ function findIntroSectionClose(contents) {
3
+ const indexOfH2OrCodeBlock = contents.search(/## |<\s*h2|```/);
4
+ if (indexOfH2OrCodeBlock !== -1) {
5
+ return indexOfH2OrCodeBlock - 2;
6
+ }
7
+ for (const createMatcher of existingBadgeMatcherCreators) {
8
+ const lastMatch = [...contents.matchAll(createMatcher())].at(-1);
9
+ if (lastMatch?.index) {
10
+ return lastMatch.index + lastMatch[0].length + 2;
11
+ }
12
+ }
13
+ return contents.indexOf("\n", 2);
14
+ }
15
+ export {
16
+ findIntroSectionClose
17
+ };
18
+ //# sourceMappingURL=findIntroSectionClose.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/steps/writeReadme/findIntroSectionClose.ts"],"sourcesContent":["import { existingBadgeMatcherCreators } from \"./findExistingBadges.js\";\n\nexport function findIntroSectionClose(contents: string) {\n\t// Highest priority match: an h2, presumably following badges\n\tconst indexOfH2OrCodeBlock = contents.search(/## |<\\s*h2|```/);\n\n\tif (indexOfH2OrCodeBlock !== -1) {\n\t\treturn indexOfH2OrCodeBlock - 2;\n\t}\n\n\t// Failing that, if any badges are found, go after the last of them\n\tfor (const createMatcher of existingBadgeMatcherCreators) {\n\t\tconst lastMatch = [...contents.matchAll(createMatcher())].at(-1);\n\n\t\tif (lastMatch?.index) {\n\t\t\treturn lastMatch.index + lastMatch[0].length + 2;\n\t\t}\n\t}\n\n\t// Lastly, go for the second line altogether\n\treturn contents.indexOf(\"\\n\", 2);\n}\n"],"mappings":"AAAA,SAAS,oCAAoC;AAEtC,SAAS,sBAAsB,UAAkB;AAEvD,QAAM,uBAAuB,SAAS,OAAO,gBAAgB;AAE7D,MAAI,yBAAyB,IAAI;AAChC,WAAO,uBAAuB;AAAA,EAC/B;AAGA,aAAW,iBAAiB,8BAA8B;AACzD,UAAM,YAAY,CAAC,GAAG,SAAS,SAAS,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE;AAE/D,QAAI,WAAW,OAAO;AACrB,aAAO,UAAU,QAAQ,UAAU,CAAC,EAAE,SAAS;AAAA,IAChD;AAAA,EACD;AAGA,SAAO,SAAS,QAAQ,MAAM,CAAC;AAChC;","names":[]}
@@ -0,0 +1,5 @@
1
+ import { Options } from '../../shared/types.js';
2
+
3
+ declare function generateTopContent(options: Options, existingBadges: string[]): string;
4
+
5
+ export { generateTopContent };
@@ -0,0 +1,72 @@
1
+ function generateTopContent(options, existingBadges) {
2
+ const remainingExistingBadges = new Set(existingBadges);
3
+ const badges = [];
4
+ function spliceBadge(badgeLine, existingMatcher) {
5
+ const existingMatch = existingBadges.find(
6
+ (existingLine) => existingMatcher.test(existingLine)
7
+ );
8
+ if (existingMatch) {
9
+ remainingExistingBadges.delete(existingMatch);
10
+ }
11
+ if (badgeLine) {
12
+ badges.push(badgeLine);
13
+ }
14
+ }
15
+ for (const [badgeLine, existingMatcher] of [
16
+ [
17
+ !options.excludeContributors && `<a href="#contributors" target="_blank">
18
+ <!-- prettier-ignore-start -->
19
+ <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
20
+ <img alt="All Contributors: 2" src="https://img.shields.io/badge/all_contributors-17-21bb42.svg" />
21
+ <!-- ALL-CONTRIBUTORS-BADGE:END -->
22
+ <!-- prettier-ignore-end -->
23
+ </a>`,
24
+ /ALL-CONTRIBUTORS-BADGE:START/
25
+ ],
26
+ [
27
+ !options.excludeTests && `<a href="https://codecov.io/gh/${options.owner}/${options.repository}" target="_blank">
28
+ <img alt="Codecov Test Coverage" src="https://codecov.io/gh/${options.owner}/${options.repository}/branch/main/graph/badge.svg"/>
29
+ </a>`,
30
+ /https:\/\/codecov\.io\/gh/
31
+ ],
32
+ [
33
+ `<a href="https://github.com/${options.owner}/${options.repository}/blob/main/.github/CODE_OF_CONDUCT.md" target="_blank">
34
+ <img alt="Contributor Covenant" src="https://img.shields.io/badge/code_of_conduct-enforced-21bb42" />
35
+ </a>`,
36
+ /CODE_OF_CONDUCT\.md/
37
+ ],
38
+ [
39
+ `<a href="https://github.com/${options.owner}/${options.repository}/blob/main/LICENSE.md" target="_blank">
40
+ <img alt="License: MIT" src="https://img.shields.io/github/license/${options.owner}/${options.repository}?color=21bb42">
41
+ </a>`,
42
+ /LICENSE\.(md|txt)/
43
+ ],
44
+ [
45
+ options.funding && `<a href="https://github.com/sponsors/${options.funding}" target="_blank">
46
+ <img alt="Sponsor: On GitHub" src="https://img.shields.io/badge/sponsor-on_github-21bb42.svg" />
47
+ </a>`,
48
+ /github.+sponsors/
49
+ ],
50
+ [
51
+ `<img alt="Style: Prettier" src="https://img.shields.io/badge/style-prettier-21bb42.svg" />`,
52
+ /style.*prettier/i
53
+ ],
54
+ [
55
+ `<img alt="TypeScript: Strict" src="https://img.shields.io/badge/typescript-strict-21bb42.svg" />`,
56
+ /typescript.*strict/i
57
+ ]
58
+ ]) {
59
+ spliceBadge(badgeLine, existingMatcher);
60
+ }
61
+ return `<h1 align="center">${options.title}</h1>
62
+
63
+ <p align="center">${options.description}</p>
64
+
65
+ <p align="center">
66
+ ${[...badges, ...remainingExistingBadges].map((badge) => ` ${badge}`).join("\n")}
67
+ </p>`;
68
+ }
69
+ export {
70
+ generateTopContent
71
+ };
72
+ //# sourceMappingURL=generateTopContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/steps/writeReadme/generateTopContent.ts"],"sourcesContent":["import { Options } from \"../../shared/types.js\";\n\nexport function generateTopContent(options: Options, existingBadges: string[]) {\n\tconst remainingExistingBadges = new Set(existingBadges);\n\tconst badges: string[] = [];\n\n\tfunction spliceBadge(\n\t\tbadgeLine: false | string | undefined,\n\t\texistingMatcher: RegExp,\n\t) {\n\t\tconst existingMatch = existingBadges.find((existingLine) =>\n\t\t\texistingMatcher.test(existingLine),\n\t\t);\n\n\t\tif (existingMatch) {\n\t\t\tremainingExistingBadges.delete(existingMatch);\n\t\t}\n\n\t\tif (badgeLine) {\n\t\t\tbadges.push(badgeLine);\n\t\t}\n\t}\n\n\tfor (const [badgeLine, existingMatcher] of [\n\t\t[\n\t\t\t!options.excludeContributors &&\n\t\t\t\t`<a href=\"#contributors\" target=\"_blank\">\n<!-- prettier-ignore-start -->\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n<img alt=\"All Contributors: 2\" src=\"https://img.shields.io/badge/all_contributors-17-21bb42.svg\" />\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n<!-- prettier-ignore-end -->\n</a>`,\n\t\t\t/ALL-CONTRIBUTORS-BADGE:START/,\n\t\t],\n\t\t[\n\t\t\t!options.excludeTests &&\n\t\t\t\t`<a href=\"https://codecov.io/gh/${options.owner}/${options.repository}\" target=\"_blank\">\n\t\t<img alt=\"Codecov Test Coverage\" src=\"https://codecov.io/gh/${options.owner}/${options.repository}/branch/main/graph/badge.svg\"/>\n\t</a>`,\n\t\t\t/https:\\/\\/codecov\\.io\\/gh/,\n\t\t],\n\t\t[\n\t\t\t`<a href=\"https://github.com/${options.owner}/${options.repository}/blob/main/.github/CODE_OF_CONDUCT.md\" target=\"_blank\">\n\t\t<img alt=\"Contributor Covenant\" src=\"https://img.shields.io/badge/code_of_conduct-enforced-21bb42\" />\n\t</a>`,\n\t\t\t/CODE_OF_CONDUCT\\.md/,\n\t\t],\n\t\t[\n\t\t\t`<a href=\"https://github.com/${options.owner}/${options.repository}/blob/main/LICENSE.md\" target=\"_blank\">\n\t\t<img alt=\"License: MIT\" src=\"https://img.shields.io/github/license/${options.owner}/${options.repository}?color=21bb42\">\n\t</a>`,\n\t\t\t/LICENSE\\.(md|txt)/,\n\t\t],\n\t\t[\n\t\t\toptions.funding &&\n\t\t\t\t`<a href=\"https://github.com/sponsors/${options.funding}\" target=\"_blank\">\n\t\t<img alt=\"Sponsor: On GitHub\" src=\"https://img.shields.io/badge/sponsor-on_github-21bb42.svg\" />\n\t</a>`,\n\t\t\t/github.+sponsors/,\n\t\t],\n\t\t[\n\t\t\t`<img alt=\"Style: Prettier\" src=\"https://img.shields.io/badge/style-prettier-21bb42.svg\" />`,\n\t\t\t/style.*prettier/i,\n\t\t],\n\t\t[\n\t\t\t`<img alt=\"TypeScript: Strict\" src=\"https://img.shields.io/badge/typescript-strict-21bb42.svg\" />`,\n\t\t\t/typescript.*strict/i,\n\t\t],\n\t] as const) {\n\t\tspliceBadge(badgeLine, existingMatcher);\n\t}\n\n\treturn `<h1 align=\"center\">${options.title}</h1>\n\n<p align=\"center\">${options.description}</p>\n\n<p align=\"center\">\n${[...badges, ...remainingExistingBadges]\n\t.map((badge) => `\\t${badge}`)\n\t.join(\"\\n\")}\n</p>`;\n}\n"],"mappings":"AAEO,SAAS,mBAAmB,SAAkB,gBAA0B;AAC9E,QAAM,0BAA0B,IAAI,IAAI,cAAc;AACtD,QAAM,SAAmB,CAAC;AAE1B,WAAS,YACR,WACA,iBACC;AACD,UAAM,gBAAgB,eAAe;AAAA,MAAK,CAAC,iBAC1C,gBAAgB,KAAK,YAAY;AAAA,IAClC;AAEA,QAAI,eAAe;AAClB,8BAAwB,OAAO,aAAa;AAAA,IAC7C;AAEA,QAAI,WAAW;AACd,aAAO,KAAK,SAAS;AAAA,IACtB;AAAA,EACD;AAEA,aAAW,CAAC,WAAW,eAAe,KAAK;AAAA,IAC1C;AAAA,MACC,CAAC,QAAQ,uBACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOD;AAAA,IACD;AAAA,IACA;AAAA,MACC,CAAC,QAAQ,gBACR,kCAAkC,QAAQ,KAAK,IAAI,QAAQ,UAAU;AAAA,gEACT,QAAQ,KAAK,IAAI,QAAQ,UAAU;AAAA;AAAA,MAEhG;AAAA,IACD;AAAA,IACA;AAAA,MACC,+BAA+B,QAAQ,KAAK,IAAI,QAAQ,UAAU;AAAA;AAAA;AAAA,MAGlE;AAAA,IACD;AAAA,IACA;AAAA,MACC,+BAA+B,QAAQ,KAAK,IAAI,QAAQ,UAAU;AAAA,uEACE,QAAQ,KAAK,IAAI,QAAQ,UAAU;AAAA;AAAA,MAEvG;AAAA,IACD;AAAA,IACA;AAAA,MACC,QAAQ,WACP,wCAAwC,QAAQ,OAAO;AAAA;AAAA;AAAA,MAGxD;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,IACD;AAAA,EACD,GAAY;AACX,gBAAY,WAAW,eAAe;AAAA,EACvC;AAEA,SAAO,sBAAsB,QAAQ,KAAK;AAAA;AAAA,oBAEvB,QAAQ,WAAW;AAAA;AAAA;AAAA,EAGrC,CAAC,GAAG,QAAQ,GAAG,uBAAuB,EACtC,IAAI,CAAC,UAAU,IAAK,KAAK,EAAE,EAC3B,KAAK,IAAI,CAAC;AAAA;AAEZ;","names":[]}
@@ -1,4 +1,4 @@
1
- import { Options } from '../shared/types.js';
1
+ import { Options } from '../../shared/types.js';
2
2
 
3
3
  declare function writeReadme(options: Options): Promise<void>;
4
4
 
@@ -0,0 +1,57 @@
1
+ import fs from "node:fs/promises";
2
+ import { readFileSafe } from "../../shared/readFileSafe.js";
3
+ import { endOfReadmeNotice } from "../updateReadme.js";
4
+ import { findExistingBadges } from "./findExistingBadges.js";
5
+ import { findIntroSectionClose } from "./findIntroSectionClose.js";
6
+ import { generateTopContent } from "./generateTopContent.js";
7
+ const contributorsIndicator = `<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->`;
8
+ function generateAllContributorsContent(options) {
9
+ return [
10
+ `## Contributors`,
11
+ ``,
12
+ `<!-- spellchecker: disable -->`,
13
+ contributorsIndicator,
14
+ `<!-- prettier-ignore-start -->`,
15
+ !options.excludeLintMd && `<!-- markdownlint-disable -->`,
16
+ `<table>`,
17
+ `<!-- (this will be filled in by all-contributors) -->`,
18
+ `</table>`,
19
+ ``,
20
+ !options.excludeLintMd && `<!-- markdownlint-restore -->`,
21
+ `<!-- prettier-ignore-end -->`,
22
+ ``,
23
+ `<!-- ALL-CONTRIBUTORS-LIST:END -->`,
24
+ `<!-- spellchecker: enable -->`
25
+ ].filter(Boolean).join("\n");
26
+ }
27
+ async function writeReadme(options) {
28
+ const allContributorsContent = !options.excludeContributors && generateAllContributorsContent(options);
29
+ let contents = await readFileSafe("README.md", "");
30
+ if (!contents) {
31
+ await fs.writeFile(
32
+ "README.md",
33
+ [
34
+ generateTopContent(options, []),
35
+ allContributorsContent,
36
+ endOfReadmeNotice
37
+ ].filter(Boolean).join("\n\n")
38
+ );
39
+ return;
40
+ }
41
+ const endOfIntroSection = findIntroSectionClose(contents);
42
+ contents = [
43
+ generateTopContent(options, findExistingBadges(contents)),
44
+ contents.slice(endOfIntroSection)
45
+ ].join("").replace(/\[!\[.+\]\(.+\)\]\(.+\)/g, "").replace(/!\[.+\]\(.+\)/g, "").replaceAll("\r", "").replaceAll("\n\n\n", "\n\n");
46
+ if (allContributorsContent && !contents.includes(contributorsIndicator)) {
47
+ contents = [contents, allContributorsContent].join("\n\n");
48
+ }
49
+ if (!contents.includes(endOfReadmeNotice)) {
50
+ contents = [contents, endOfReadmeNotice].join("\n\n");
51
+ }
52
+ await fs.writeFile("README.md", contents);
53
+ }
54
+ export {
55
+ writeReadme
56
+ };
57
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/steps/writeReadme/index.ts"],"sourcesContent":["import fs from \"node:fs/promises\";\n\nimport { readFileSafe } from \"../../shared/readFileSafe.js\";\nimport { Options } from \"../../shared/types.js\";\nimport { endOfReadmeNotice } from \"../updateReadme.js\";\nimport { findExistingBadges } from \"./findExistingBadges.js\";\nimport { findIntroSectionClose } from \"./findIntroSectionClose.js\";\nimport { generateTopContent } from \"./generateTopContent.js\";\n\nconst contributorsIndicator = `<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->`;\n\nfunction generateAllContributorsContent(options: Options) {\n\treturn [\n\t\t`## Contributors`,\n\t\t``,\n\t\t`<!-- spellchecker: disable -->`,\n\t\tcontributorsIndicator,\n\t\t`<!-- prettier-ignore-start -->`,\n\t\t!options.excludeLintMd && `<!-- markdownlint-disable -->`,\n\t\t`<table>`,\n\t\t`<!-- (this will be filled in by all-contributors) -->`,\n\t\t`</table>`,\n\t\t``,\n\t\t!options.excludeLintMd && `<!-- markdownlint-restore -->`,\n\t\t`<!-- prettier-ignore-end -->`,\n\t\t``,\n\t\t`<!-- ALL-CONTRIBUTORS-LIST:END -->`,\n\t\t`<!-- spellchecker: enable -->`,\n\t]\n\t\t.filter(Boolean)\n\t\t.join(\"\\n\");\n}\n\nexport async function writeReadme(options: Options) {\n\tconst allContributorsContent =\n\t\t!options.excludeContributors && generateAllContributorsContent(options);\n\tlet contents = await readFileSafe(\"README.md\", \"\");\n\tif (!contents) {\n\t\tawait fs.writeFile(\n\t\t\t\"README.md\",\n\t\t\t[\n\t\t\t\tgenerateTopContent(options, []),\n\t\t\t\tallContributorsContent,\n\t\t\t\tendOfReadmeNotice,\n\t\t\t]\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(\"\\n\\n\"),\n\t\t);\n\t\treturn;\n\t}\n\n\tconst endOfIntroSection = findIntroSectionClose(contents);\n\n\tcontents = [\n\t\tgenerateTopContent(options, findExistingBadges(contents)),\n\t\tcontents.slice(endOfIntroSection),\n\t]\n\t\t.join(\"\")\n\t\t.replace(/\\[!\\[.+\\]\\(.+\\)\\]\\(.+\\)/g, \"\")\n\t\t.replace(/!\\[.+\\]\\(.+\\)/g, \"\")\n\t\t.replaceAll(\"\\r\", \"\")\n\t\t.replaceAll(\"\\n\\n\\n\", \"\\n\\n\");\n\n\tif (allContributorsContent && !contents.includes(contributorsIndicator)) {\n\t\tcontents = [contents, allContributorsContent].join(\"\\n\\n\");\n\t}\n\n\tif (!contents.includes(endOfReadmeNotice)) {\n\t\tcontents = [contents, endOfReadmeNotice].join(\"\\n\\n\");\n\t}\n\n\tawait fs.writeFile(\"README.md\", contents);\n}\n"],"mappings":"AAAA,OAAO,QAAQ;AAEf,SAAS,oBAAoB;AAE7B,SAAS,yBAAyB;AAClC,SAAS,0BAA0B;AACnC,SAAS,6BAA6B;AACtC,SAAS,0BAA0B;AAEnC,MAAM,wBAAwB;AAE9B,SAAS,+BAA+B,SAAkB;AACzD,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,CAAC,QAAQ,iBAAiB;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,CAAC,QAAQ,iBAAiB;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,EACE,OAAO,OAAO,EACd,KAAK,IAAI;AACZ;AAEA,eAAsB,YAAY,SAAkB;AACnD,QAAM,yBACL,CAAC,QAAQ,uBAAuB,+BAA+B,OAAO;AACvE,MAAI,WAAW,MAAM,aAAa,aAAa,EAAE;AACjD,MAAI,CAAC,UAAU;AACd,UAAM,GAAG;AAAA,MACR;AAAA,MACA;AAAA,QACC,mBAAmB,SAAS,CAAC,CAAC;AAAA,QAC9B;AAAA,QACA;AAAA,MACD,EACE,OAAO,OAAO,EACd,KAAK,MAAM;AAAA,IACd;AACA;AAAA,EACD;AAEA,QAAM,oBAAoB,sBAAsB,QAAQ;AAExD,aAAW;AAAA,IACV,mBAAmB,SAAS,mBAAmB,QAAQ,CAAC;AAAA,IACxD,SAAS,MAAM,iBAAiB;AAAA,EACjC,EACE,KAAK,EAAE,EACP,QAAQ,4BAA4B,EAAE,EACtC,QAAQ,kBAAkB,EAAE,EAC5B,WAAW,MAAM,EAAE,EACnB,WAAW,UAAU,MAAM;AAE7B,MAAI,0BAA0B,CAAC,SAAS,SAAS,qBAAqB,GAAG;AACxE,eAAW,CAAC,UAAU,sBAAsB,EAAE,KAAK,MAAM;AAAA,EAC1D;AAEA,MAAI,CAAC,SAAS,SAAS,iBAAiB,GAAG;AAC1C,eAAW,CAAC,UAAU,iBAAiB,EAAE,KAAK,MAAM;AAAA,EACrD;AAEA,QAAM,GAAG,UAAU,aAAa,QAAQ;AACzC;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-typescript-app",
3
- "version": "1.29.47",
3
+ "version": "1.29.48",
4
4
  "description": "Quickstart-friendly TypeScript template with comprehensive formatting, linting, releases, testing, and other great tooling built-in. ✨",
5
5
  "repository": {
6
6
  "type": "git",
@@ -107,7 +107,7 @@
107
107
  "vitest": "^0.34.3",
108
108
  "yaml-eslint-parser": "^1.2.2"
109
109
  },
110
- "packageManager": "pnpm@8.7.5",
110
+ "packageManager": "pnpm@8.7.6",
111
111
  "engines": {
112
112
  "node": ">=18"
113
113
  },
@@ -1,86 +0,0 @@
1
- import fs from "node:fs/promises";
2
- import { readFileSafe } from "../shared/readFileSafe.js";
3
- import { endOfReadmeNotice } from "./updateReadme.js";
4
- const contributorsIndicator = `<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->`;
5
- function generateAllContributorsContent(options) {
6
- return [
7
- `## Contributors`,
8
- ``,
9
- `<!-- spellchecker: disable -->`,
10
- contributorsIndicator,
11
- `<!-- prettier-ignore-start -->`,
12
- !options.excludeLintMd && `<!-- markdownlint-disable -->`,
13
- `<table>`,
14
- `<!-- (this will be filled in by all-contributors) -->`,
15
- `</table>`,
16
- ``,
17
- !options.excludeLintMd && `<!-- markdownlint-restore -->`,
18
- `<!-- prettier-ignore-end -->`,
19
- ``,
20
- `<!-- ALL-CONTRIBUTORS-LIST:END -->`,
21
- `<!-- spellchecker: enable -->`
22
- ].filter(Boolean).join("\n");
23
- }
24
- async function writeReadme(options) {
25
- const allContributorsContent = !options.excludeContributors && generateAllContributorsContent(options);
26
- let contents = await readFileSafe("README.md", "");
27
- if (!contents) {
28
- await fs.writeFile(
29
- "README.md",
30
- [generateTopContent(options), allContributorsContent, endOfReadmeNotice].filter(Boolean).join("\n\n")
31
- );
32
- return;
33
- }
34
- const endOfH1 = findH1Close(contents);
35
- contents = [generateTopContent(options), contents.slice(endOfH1)].join("").replace(/\[!\[.+\]\(.+\)\]\(.+\)/g, "").replace(/!\[.+\]\(.+\)/g, "").replaceAll("\r", "").replaceAll("\n\n\n", "\n\n");
36
- if (allContributorsContent && !contents.includes(contributorsIndicator)) {
37
- contents = [contents, allContributorsContent].join("\n\n");
38
- }
39
- if (!contents.includes(endOfReadmeNotice)) {
40
- contents = [contents, endOfReadmeNotice].join("\n\n");
41
- }
42
- await fs.writeFile("README.md", contents);
43
- }
44
- function findH1Close(contents) {
45
- const markdownMatch = contents.match(/^#.+/);
46
- if (markdownMatch) {
47
- return (markdownMatch.index ?? 0) + markdownMatch[0].length;
48
- }
49
- return contents.indexOf("</h1>") + "</h1>".length;
50
- }
51
- function generateTopContent(options) {
52
- const badgeLines = [
53
- !options.excludeContributors && ` <a href="#contributors" target="_blank">
54
- <!-- prettier-ignore-start -->
55
- <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
56
- <img alt="All Contributors: 2" src="https://img.shields.io/badge/all_contributors-17-21bb42.svg" />
57
- <!-- ALL-CONTRIBUTORS-BADGE:END -->
58
- <!-- prettier-ignore-end -->
59
- </a>`,
60
- !options.excludeTests && ` <a href="https://codecov.io/gh/${options.owner}/${options.repository}" target="_blank">
61
- <img alt="Codecov Test Coverage" src="https://codecov.io/gh/${options.owner}/${options.repository}/branch/main/graph/badge.svg"/>
62
- </a>`,
63
- ` <a href="https://github.com/${options.owner}/${options.repository}/blob/main/.github/CODE_OF_CONDUCT.md" target="_blank">
64
- <img alt="Contributor Covenant" src="https://img.shields.io/badge/code_of_conduct-enforced-21bb42" />
65
- </a>`,
66
- ` <a href="https://github.com/${options.owner}/${options.repository}/blob/main/LICENSE.md" target="_blank">
67
- <img alt="License: MIT" src="https://img.shields.io/github/license/${options.owner}/${options.repository}?color=21bb42">
68
- </a>`,
69
- options.funding && ` <a href="https://github.com/sponsors/${options.funding}" target="_blank">
70
- <img alt="Sponsor: On GitHub" src="https://img.shields.io/badge/sponsor-on_github-21bb42.svg" />
71
- </a>`,
72
- ` <img alt="Style: Prettier" src="https://img.shields.io/badge/style-prettier-21bb42.svg" />`,
73
- ` <img alt="TypeScript: Strict" src="https://img.shields.io/badge/typescript-strict-21bb42.svg" />`
74
- ].filter(Boolean);
75
- return `<h1 align="center">${options.title}</h1>
76
-
77
- <p align="center">${options.description}</p>
78
-
79
- <p align="center">
80
- ${badgeLines.join("\n")}
81
- </p>`;
82
- }
83
- export {
84
- writeReadme
85
- };
86
- //# sourceMappingURL=writeReadme.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/steps/writeReadme.ts"],"sourcesContent":["import fs from \"node:fs/promises\";\n\nimport { readFileSafe } from \"../shared/readFileSafe.js\";\nimport { Options } from \"../shared/types.js\";\nimport { endOfReadmeNotice } from \"./updateReadme.js\";\n\nconst contributorsIndicator = `<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->`;\n\nfunction generateAllContributorsContent(options: Options) {\n\treturn [\n\t\t`## Contributors`,\n\t\t``,\n\t\t`<!-- spellchecker: disable -->`,\n\t\tcontributorsIndicator,\n\t\t`<!-- prettier-ignore-start -->`,\n\t\t!options.excludeLintMd && `<!-- markdownlint-disable -->`,\n\t\t`<table>`,\n\t\t`<!-- (this will be filled in by all-contributors) -->`,\n\t\t`</table>`,\n\t\t``,\n\t\t!options.excludeLintMd && `<!-- markdownlint-restore -->`,\n\t\t`<!-- prettier-ignore-end -->`,\n\t\t``,\n\t\t`<!-- ALL-CONTRIBUTORS-LIST:END -->`,\n\t\t`<!-- spellchecker: enable -->`,\n\t]\n\t\t.filter(Boolean)\n\t\t.join(\"\\n\");\n}\n\nexport async function writeReadme(options: Options) {\n\tconst allContributorsContent =\n\t\t!options.excludeContributors && generateAllContributorsContent(options);\n\tlet contents = await readFileSafe(\"README.md\", \"\");\n\tif (!contents) {\n\t\tawait fs.writeFile(\n\t\t\t\"README.md\",\n\t\t\t[generateTopContent(options), allContributorsContent, endOfReadmeNotice]\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(\"\\n\\n\"),\n\t\t);\n\t\treturn;\n\t}\n\n\tconst endOfH1 = findH1Close(contents);\n\n\tcontents = [generateTopContent(options), contents.slice(endOfH1)]\n\t\t.join(\"\")\n\t\t.replace(/\\[!\\[.+\\]\\(.+\\)\\]\\(.+\\)/g, \"\")\n\t\t.replace(/!\\[.+\\]\\(.+\\)/g, \"\")\n\t\t.replaceAll(\"\\r\", \"\")\n\t\t.replaceAll(\"\\n\\n\\n\", \"\\n\\n\");\n\n\tif (allContributorsContent && !contents.includes(contributorsIndicator)) {\n\t\tcontents = [contents, allContributorsContent].join(\"\\n\\n\");\n\t}\n\n\tif (!contents.includes(endOfReadmeNotice)) {\n\t\tcontents = [contents, endOfReadmeNotice].join(\"\\n\\n\");\n\t}\n\n\tawait fs.writeFile(\"README.md\", contents);\n}\n\nfunction findH1Close(contents: string) {\n\tconst markdownMatch = contents.match(/^#.+/);\n\tif (markdownMatch) {\n\t\treturn (markdownMatch.index ?? 0) + markdownMatch[0].length;\n\t}\n\n\treturn contents.indexOf(\"</h1>\") + \"</h1>\".length;\n}\n\nfunction generateTopContent(options: Options) {\n\tconst badgeLines = [\n\t\t!options.excludeContributors &&\n\t\t\t`\t<a href=\"#contributors\" target=\"_blank\">\n<!-- prettier-ignore-start -->\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n<img alt=\"All Contributors: 2\" src=\"https://img.shields.io/badge/all_contributors-17-21bb42.svg\" />\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n<!-- prettier-ignore-end -->\n\t</a>`,\n\t\t!options.excludeTests &&\n\t\t\t`\t<a href=\"https://codecov.io/gh/${options.owner}/${options.repository}\" target=\"_blank\">\n\t\t<img alt=\"Codecov Test Coverage\" src=\"https://codecov.io/gh/${options.owner}/${options.repository}/branch/main/graph/badge.svg\"/>\n\t</a>`,\n\t\t`\t<a href=\"https://github.com/${options.owner}/${options.repository}/blob/main/.github/CODE_OF_CONDUCT.md\" target=\"_blank\">\n\t\t<img alt=\"Contributor Covenant\" src=\"https://img.shields.io/badge/code_of_conduct-enforced-21bb42\" />\n\t</a>`,\n\t\t`\t<a href=\"https://github.com/${options.owner}/${options.repository}/blob/main/LICENSE.md\" target=\"_blank\">\n\t\t<img alt=\"License: MIT\" src=\"https://img.shields.io/github/license/${options.owner}/${options.repository}?color=21bb42\">\n\t</a>`,\n\t\toptions.funding &&\n\t\t\t`\t<a href=\"https://github.com/sponsors/${options.funding}\" target=\"_blank\">\n\t\t<img alt=\"Sponsor: On GitHub\" src=\"https://img.shields.io/badge/sponsor-on_github-21bb42.svg\" />\n\t</a>`,\n\t\t`\t<img alt=\"Style: Prettier\" src=\"https://img.shields.io/badge/style-prettier-21bb42.svg\" />`,\n\t\t`\t<img alt=\"TypeScript: Strict\" src=\"https://img.shields.io/badge/typescript-strict-21bb42.svg\" />`,\n\t].filter(Boolean);\n\n\treturn `<h1 align=\"center\">${options.title}</h1>\n\n<p align=\"center\">${options.description}</p>\n\n<p align=\"center\">\n${badgeLines.join(\"\\n\")}\n</p>`;\n}\n"],"mappings":"AAAA,OAAO,QAAQ;AAEf,SAAS,oBAAoB;AAE7B,SAAS,yBAAyB;AAElC,MAAM,wBAAwB;AAE9B,SAAS,+BAA+B,SAAkB;AACzD,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,CAAC,QAAQ,iBAAiB;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,CAAC,QAAQ,iBAAiB;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,EACE,OAAO,OAAO,EACd,KAAK,IAAI;AACZ;AAEA,eAAsB,YAAY,SAAkB;AACnD,QAAM,yBACL,CAAC,QAAQ,uBAAuB,+BAA+B,OAAO;AACvE,MAAI,WAAW,MAAM,aAAa,aAAa,EAAE;AACjD,MAAI,CAAC,UAAU;AACd,UAAM,GAAG;AAAA,MACR;AAAA,MACA,CAAC,mBAAmB,OAAO,GAAG,wBAAwB,iBAAiB,EACrE,OAAO,OAAO,EACd,KAAK,MAAM;AAAA,IACd;AACA;AAAA,EACD;AAEA,QAAM,UAAU,YAAY,QAAQ;AAEpC,aAAW,CAAC,mBAAmB,OAAO,GAAG,SAAS,MAAM,OAAO,CAAC,EAC9D,KAAK,EAAE,EACP,QAAQ,4BAA4B,EAAE,EACtC,QAAQ,kBAAkB,EAAE,EAC5B,WAAW,MAAM,EAAE,EACnB,WAAW,UAAU,MAAM;AAE7B,MAAI,0BAA0B,CAAC,SAAS,SAAS,qBAAqB,GAAG;AACxE,eAAW,CAAC,UAAU,sBAAsB,EAAE,KAAK,MAAM;AAAA,EAC1D;AAEA,MAAI,CAAC,SAAS,SAAS,iBAAiB,GAAG;AAC1C,eAAW,CAAC,UAAU,iBAAiB,EAAE,KAAK,MAAM;AAAA,EACrD;AAEA,QAAM,GAAG,UAAU,aAAa,QAAQ;AACzC;AAEA,SAAS,YAAY,UAAkB;AACtC,QAAM,gBAAgB,SAAS,MAAM,MAAM;AAC3C,MAAI,eAAe;AAClB,YAAQ,cAAc,SAAS,KAAK,cAAc,CAAC,EAAE;AAAA,EACtD;AAEA,SAAO,SAAS,QAAQ,OAAO,IAAI,QAAQ;AAC5C;AAEA,SAAS,mBAAmB,SAAkB;AAC7C,QAAM,aAAa;AAAA,IAClB,CAAC,QAAQ,uBACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOD,CAAC,QAAQ,gBACR,mCAAmC,QAAQ,KAAK,IAAI,QAAQ,UAAU;AAAA,gEACT,QAAQ,KAAK,IAAI,QAAQ,UAAU;AAAA;AAAA,IAEjG,gCAAgC,QAAQ,KAAK,IAAI,QAAQ,UAAU;AAAA;AAAA;AAAA,IAGnE,gCAAgC,QAAQ,KAAK,IAAI,QAAQ,UAAU;AAAA,uEACE,QAAQ,KAAK,IAAI,QAAQ,UAAU;AAAA;AAAA,IAExG,QAAQ,WACP,yCAAyC,QAAQ,OAAO;AAAA;AAAA;AAAA,IAGzD;AAAA,IACA;AAAA,EACD,EAAE,OAAO,OAAO;AAEhB,SAAO,sBAAsB,QAAQ,KAAK;AAAA;AAAA,oBAEvB,QAAQ,WAAW;AAAA;AAAA;AAAA,EAGrC,WAAW,KAAK,IAAI,CAAC;AAAA;AAEvB;","names":[]}