create-typescript-app 1.70.0 → 1.71.0

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.
Files changed (29) hide show
  1. package/README.md +1 -1
  2. package/lib/create/createWithOptions.js +1 -1
  3. package/lib/create/createWithOptions.js.map +1 -1
  4. package/lib/initialize/initializeWithOptions.js +1 -1
  5. package/lib/initialize/initializeWithOptions.js.map +1 -1
  6. package/lib/shared/getGitHubUserAsAllContributor.d.ts +2 -1
  7. package/lib/shared/getGitHubUserAsAllContributor.js +13 -9
  8. package/lib/shared/getGitHubUserAsAllContributor.js.map +1 -1
  9. package/lib/shared/options/createRepositoryWithApi.js +14 -8
  10. package/lib/shared/options/createRepositoryWithApi.js.map +1 -1
  11. package/lib/shared/options/getGitHub.js +4 -3
  12. package/lib/shared/options/getGitHub.js.map +1 -1
  13. package/lib/shared/options/optionsSchema.d.ts +6 -6
  14. package/lib/shared/runOrRestore.js +2 -1
  15. package/lib/shared/runOrRestore.js.map +1 -1
  16. package/lib/steps/addOwnerAsAllContributor.d.ts +2 -1
  17. package/lib/steps/addOwnerAsAllContributor.js +2 -2
  18. package/lib/steps/addOwnerAsAllContributor.js.map +1 -1
  19. package/lib/steps/addToolAllContributors.d.ts +2 -1
  20. package/lib/steps/addToolAllContributors.js +2 -2
  21. package/lib/steps/addToolAllContributors.js.map +1 -1
  22. package/lib/steps/initializeGitHubRepository/index.js +1 -1
  23. package/lib/steps/initializeGitHubRepository/index.js.map +1 -1
  24. package/lib/steps/initializeGitHubRepository/labels/getExistingEquivalentLabels.d.ts +1 -1
  25. package/lib/steps/initializeGitHubRepository/labels/getExistingEquivalentLabels.js.map +1 -1
  26. package/lib/steps/initializeGitHubRepository/labels/initializeRepositoryLabels.d.ts +6 -1
  27. package/lib/steps/initializeGitHubRepository/labels/initializeRepositoryLabels.js +40 -10
  28. package/lib/steps/initializeGitHubRepository/labels/initializeRepositoryLabels.js.map +1 -1
  29. package/package.json +2 -2
package/README.md CHANGED
@@ -24,9 +24,9 @@ It includes options not just for building and testing but also GitHub repository
24
24
 
25
25
  First make sure you have the following installed:
26
26
 
27
- - [GitHub CLI](https://cli.github.com) _(you'll need to be logged in)_
28
27
  - [Node.js](https://nodejs.org)
29
28
  - [pnpm](https://pnpm.io)
29
+ - _(optional, but helpful)_ [GitHub CLI](https://cli.github.com) _(you'll need to be logged in)_
30
30
 
31
31
  Then in an existing repository or in your directory where you'd like to make a new repository:
32
32
 
@@ -27,7 +27,7 @@ async function createWithOptions({ github, options }) {
27
27
  ]);
28
28
  if (!options.excludeAllContributors && !options.skipAllContributorsApi) {
29
29
  await withSpinner("Adding contributors to table", async () => {
30
- await addToolAllContributors(options);
30
+ await addToolAllContributors(github?.octokit, options);
31
31
  });
32
32
  }
33
33
  if (!options.skipInstall) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/create/createWithOptions.ts"],"sourcesContent":["import { $ } from \"execa\";\n\nimport { withSpinner, withSpinners } from \"../shared/cli/spinners.js\";\nimport { createCleanupCommands } from \"../shared/createCleanupCommands.js\";\nimport { doesRepositoryExist } from \"../shared/doesRepositoryExist.js\";\nimport { GitHubAndOptions } from \"../shared/options/readOptions.js\";\nimport { addToolAllContributors } from \"../steps/addToolAllContributors.js\";\nimport { clearLocalGitTags } from \"../steps/clearLocalGitTags.js\";\nimport { finalizeDependencies } from \"../steps/finalizeDependencies.js\";\nimport { initializeGitHubRepository } from \"../steps/initializeGitHubRepository/index.js\";\nimport { populateCSpellDictionary } from \"../steps/populateCSpellDictionary.js\";\nimport { runCleanup } from \"../steps/runCleanup.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);\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.excludeAllContributors && !options.skipAllContributorsApi) {\n\t\tawait withSpinner(\"Adding contributors to table\", async () => {\n\t\t\tawait addToolAllContributors(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\n\t\tif (!options.excludeLintSpelling) {\n\t\t\tawait withSpinner(\n\t\t\t\t\"Populating CSpell dictionary\",\n\t\t\t\tpopulateCSpellDictionary,\n\t\t\t);\n\t\t}\n\n\t\tawait runCleanup(createCleanupCommands(options.bin), options.mode);\n\t}\n\n\tawait withSpinner(\"Clearing any local Git tags\", clearLocalGitTags);\n\n\tconst sendToGitHub =\n\t\tgithub && (await doesRepositoryExist(github.octokit, options));\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 ✨\"} --no-gpg-sign`;\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,SAAS,SAAS;AAElB,SAAS,aAAa,oBAAoB;AAC1C,SAAS,6BAA6B;AACtC,SAAS,2BAA2B;AAEpC,SAAS,8BAA8B;AACvC,SAAS,yBAAyB;AAClC,SAAS,4BAA4B;AACrC,SAAS,kCAAkC;AAC3C,SAAS,gCAAgC;AACzC,SAAS,kBAAkB;AAC3B,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,OAAO;AAAA,MAC7B;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA,YAAY;AACX,cAAM,YAAY,OAAO;AAAA,MAC1B;AAAA,IACD;AAAA,EACD,CAAC;AAED,MAAI,CAAC,QAAQ,0BAA0B,CAAC,QAAQ,wBAAwB;AACvE,UAAM,YAAY,gCAAgC,YAAY;AAC7D,YAAM,uBAAuB,OAAO;AAAA,IACrC,CAAC;AAAA,EACF;AAEA,MAAI,CAAC,QAAQ,aAAa;AACzB,UAAM;AAAA,MAAY;AAAA,MAAuB,YACxC,qBAAqB,OAAO;AAAA,IAC7B;AAEA,QAAI,CAAC,QAAQ,qBAAqB;AACjC,YAAM;AAAA,QACL;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAEA,UAAM,WAAW,sBAAsB,QAAQ,GAAG,GAAG,QAAQ,IAAI;AAAA,EAClE;AAEA,QAAM,YAAY,+BAA+B,iBAAiB;AAElE,QAAM,eACL,UAAW,MAAM,oBAAoB,OAAO,SAAS,OAAO;AAE7D,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 { $ } from \"execa\";\n\nimport { withSpinner, withSpinners } from \"../shared/cli/spinners.js\";\nimport { createCleanupCommands } from \"../shared/createCleanupCommands.js\";\nimport { doesRepositoryExist } from \"../shared/doesRepositoryExist.js\";\nimport { GitHubAndOptions } from \"../shared/options/readOptions.js\";\nimport { addToolAllContributors } from \"../steps/addToolAllContributors.js\";\nimport { clearLocalGitTags } from \"../steps/clearLocalGitTags.js\";\nimport { finalizeDependencies } from \"../steps/finalizeDependencies.js\";\nimport { initializeGitHubRepository } from \"../steps/initializeGitHubRepository/index.js\";\nimport { populateCSpellDictionary } from \"../steps/populateCSpellDictionary.js\";\nimport { runCleanup } from \"../steps/runCleanup.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);\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.excludeAllContributors && !options.skipAllContributorsApi) {\n\t\tawait withSpinner(\"Adding contributors to table\", async () => {\n\t\t\tawait addToolAllContributors(github?.octokit, 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\n\t\tif (!options.excludeLintSpelling) {\n\t\t\tawait withSpinner(\n\t\t\t\t\"Populating CSpell dictionary\",\n\t\t\t\tpopulateCSpellDictionary,\n\t\t\t);\n\t\t}\n\n\t\tawait runCleanup(createCleanupCommands(options.bin), options.mode);\n\t}\n\n\tawait withSpinner(\"Clearing any local Git tags\", clearLocalGitTags);\n\n\tconst sendToGitHub =\n\t\tgithub && (await doesRepositoryExist(github.octokit, options));\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 ✨\"} --no-gpg-sign`;\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,SAAS,SAAS;AAElB,SAAS,aAAa,oBAAoB;AAC1C,SAAS,6BAA6B;AACtC,SAAS,2BAA2B;AAEpC,SAAS,8BAA8B;AACvC,SAAS,yBAAyB;AAClC,SAAS,4BAA4B;AACrC,SAAS,kCAAkC;AAC3C,SAAS,gCAAgC;AACzC,SAAS,kBAAkB;AAC3B,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,OAAO;AAAA,MAC7B;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA,YAAY;AACX,cAAM,YAAY,OAAO;AAAA,MAC1B;AAAA,IACD;AAAA,EACD,CAAC;AAED,MAAI,CAAC,QAAQ,0BAA0B,CAAC,QAAQ,wBAAwB;AACvE,UAAM,YAAY,gCAAgC,YAAY;AAC7D,YAAM,uBAAuB,QAAQ,SAAS,OAAO;AAAA,IACtD,CAAC;AAAA,EACF;AAEA,MAAI,CAAC,QAAQ,aAAa;AACzB,UAAM;AAAA,MAAY;AAAA,MAAuB,YACxC,qBAAqB,OAAO;AAAA,IAC7B;AAEA,QAAI,CAAC,QAAQ,qBAAqB;AACjC,YAAM;AAAA,QACL;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAEA,UAAM,WAAW,sBAAsB,QAAQ,GAAG,GAAG,QAAQ,IAAI;AAAA,EAClE;AAEA,QAAM,YAAY,+BAA+B,iBAAiB;AAElE,QAAM,eACL,UAAW,MAAM,oBAAoB,OAAO,SAAS,OAAO;AAE7D,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":[]}
@@ -38,7 +38,7 @@ async function initializeWithOptions({
38
38
  ]);
39
39
  if (!options.excludeAllContributors) {
40
40
  await withSpinner("Updating existing contributor details", async () => {
41
- await addOwnerAsAllContributor(options);
41
+ await addOwnerAsAllContributor(github?.octokit, options);
42
42
  });
43
43
  }
44
44
  if (github) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/initialize/initializeWithOptions.ts"],"sourcesContent":["import { withSpinner, withSpinners } from \"../shared/cli/spinners.js\";\nimport { createCleanupCommands } from \"../shared/createCleanupCommands.js\";\nimport { GitHubAndOptions } from \"../shared/options/readOptions.js\";\nimport { addOwnerAsAllContributor } from \"../steps/addOwnerAsAllContributor.js\";\nimport { clearChangelog } from \"../steps/clearChangelog.js\";\nimport { initializeGitHubRepository } from \"../steps/initializeGitHubRepository/index.js\";\nimport { removeSetupScripts } from \"../steps/removeSetupScripts.js\";\nimport { resetGitTags } from \"../steps/resetGitTags.js\";\nimport { runCleanup } from \"../steps/runCleanup.js\";\nimport { uninstallPackages } from \"../steps/uninstallPackages.js\";\nimport { updateAllContributorsTable } from \"../steps/updateAllContributorsTable.js\";\nimport { updateLocalFiles } from \"../steps/updateLocalFiles.js\";\nimport { updateReadme } from \"../steps/updateReadme.js\";\n\nexport async function initializeWithOptions({\n\tgithub,\n\toptions,\n}: GitHubAndOptions) {\n\tawait withSpinners(\"Initializing local files\", [\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 README.md\",\n\t\t\tasync () => {\n\t\t\t\tawait updateReadme(options);\n\t\t\t},\n\t\t],\n\t\t[\"Clearing changelog\", clearChangelog],\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\t[\"Resetting Git tags\", resetGitTags],\n\t]);\n\n\tif (!options.excludeAllContributors) {\n\t\tawait withSpinner(\"Updating existing contributor details\", async () => {\n\t\t\tawait addOwnerAsAllContributor(options);\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.skipRemoval) {\n\t\tawait withSpinner(\"Removing setup scripts\", removeSetupScripts);\n\t}\n\n\tif (!options.skipUninstall) {\n\t\tawait withSpinner(\"Uninstalling initialization-only packages\", async () =>\n\t\t\tuninstallPackages(options.offline),\n\t\t);\n\t}\n\n\tawait runCleanup(\n\t\tcreateCleanupCommands(options.bin, \"pnpm dedupe --offline\"),\n\t\toptions.mode,\n\t);\n}\n"],"mappings":"AAAA,SAAS,aAAa,oBAAoB;AAC1C,SAAS,6BAA6B;AAEtC,SAAS,gCAAgC;AACzC,SAAS,sBAAsB;AAC/B,SAAS,kCAAkC;AAC3C,SAAS,0BAA0B;AACnC,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,yBAAyB;AAClC,SAAS,kCAAkC;AAC3C,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAE7B,eAAsB,sBAAsB;AAAA,EAC3C;AAAA,EACA;AACD,GAAqB;AACpB,QAAM,aAAa,4BAA4B;AAAA,IAC9C;AAAA,MACC;AAAA,MACA,YAAY;AACX,cAAM,iBAAiB,OAAO;AAAA,MAC/B;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA,YAAY;AACX,cAAM,aAAa,OAAO;AAAA,MAC3B;AAAA,IACD;AAAA,IACA,CAAC,sBAAsB,cAAc;AAAA,IACrC;AAAA,MACC;AAAA,MACA,YAAY;AACX,cAAM,2BAA2B,OAAO;AAAA,MACzC;AAAA,IACD;AAAA,IACA,CAAC,sBAAsB,YAAY;AAAA,EACpC,CAAC;AAED,MAAI,CAAC,QAAQ,wBAAwB;AACpC,UAAM,YAAY,yCAAyC,YAAY;AACtE,YAAM,yBAAyB,OAAO;AAAA,IACvC,CAAC;AAAA,EACF;AAEA,MAAI,QAAQ;AACX,UAAM,YAAY,kCAAkC,YAAY;AAC/D,YAAM,2BAA2B,OAAO,SAAS,OAAO;AAAA,IACzD,CAAC;AAAA,EACF;AAEA,MAAI,CAAC,QAAQ,aAAa;AACzB,UAAM,YAAY,0BAA0B,kBAAkB;AAAA,EAC/D;AAEA,MAAI,CAAC,QAAQ,eAAe;AAC3B,UAAM;AAAA,MAAY;AAAA,MAA6C,YAC9D,kBAAkB,QAAQ,OAAO;AAAA,IAClC;AAAA,EACD;AAEA,QAAM;AAAA,IACL,sBAAsB,QAAQ,KAAK,uBAAuB;AAAA,IAC1D,QAAQ;AAAA,EACT;AACD;","names":[]}
1
+ {"version":3,"sources":["../../src/initialize/initializeWithOptions.ts"],"sourcesContent":["import { withSpinner, withSpinners } from \"../shared/cli/spinners.js\";\nimport { createCleanupCommands } from \"../shared/createCleanupCommands.js\";\nimport { GitHubAndOptions } from \"../shared/options/readOptions.js\";\nimport { addOwnerAsAllContributor } from \"../steps/addOwnerAsAllContributor.js\";\nimport { clearChangelog } from \"../steps/clearChangelog.js\";\nimport { initializeGitHubRepository } from \"../steps/initializeGitHubRepository/index.js\";\nimport { removeSetupScripts } from \"../steps/removeSetupScripts.js\";\nimport { resetGitTags } from \"../steps/resetGitTags.js\";\nimport { runCleanup } from \"../steps/runCleanup.js\";\nimport { uninstallPackages } from \"../steps/uninstallPackages.js\";\nimport { updateAllContributorsTable } from \"../steps/updateAllContributorsTable.js\";\nimport { updateLocalFiles } from \"../steps/updateLocalFiles.js\";\nimport { updateReadme } from \"../steps/updateReadme.js\";\n\nexport async function initializeWithOptions({\n\tgithub,\n\toptions,\n}: GitHubAndOptions) {\n\tawait withSpinners(\"Initializing local files\", [\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 README.md\",\n\t\t\tasync () => {\n\t\t\t\tawait updateReadme(options);\n\t\t\t},\n\t\t],\n\t\t[\"Clearing changelog\", clearChangelog],\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\t[\"Resetting Git tags\", resetGitTags],\n\t]);\n\n\tif (!options.excludeAllContributors) {\n\t\tawait withSpinner(\"Updating existing contributor details\", async () => {\n\t\t\tawait addOwnerAsAllContributor(github?.octokit, options);\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.skipRemoval) {\n\t\tawait withSpinner(\"Removing setup scripts\", removeSetupScripts);\n\t}\n\n\tif (!options.skipUninstall) {\n\t\tawait withSpinner(\"Uninstalling initialization-only packages\", async () =>\n\t\t\tuninstallPackages(options.offline),\n\t\t);\n\t}\n\n\tawait runCleanup(\n\t\tcreateCleanupCommands(options.bin, \"pnpm dedupe --offline\"),\n\t\toptions.mode,\n\t);\n}\n"],"mappings":"AAAA,SAAS,aAAa,oBAAoB;AAC1C,SAAS,6BAA6B;AAEtC,SAAS,gCAAgC;AACzC,SAAS,sBAAsB;AAC/B,SAAS,kCAAkC;AAC3C,SAAS,0BAA0B;AACnC,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,yBAAyB;AAClC,SAAS,kCAAkC;AAC3C,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAE7B,eAAsB,sBAAsB;AAAA,EAC3C;AAAA,EACA;AACD,GAAqB;AACpB,QAAM,aAAa,4BAA4B;AAAA,IAC9C;AAAA,MACC;AAAA,MACA,YAAY;AACX,cAAM,iBAAiB,OAAO;AAAA,MAC/B;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA,YAAY;AACX,cAAM,aAAa,OAAO;AAAA,MAC3B;AAAA,IACD;AAAA,IACA,CAAC,sBAAsB,cAAc;AAAA,IACrC;AAAA,MACC;AAAA,MACA,YAAY;AACX,cAAM,2BAA2B,OAAO;AAAA,MACzC;AAAA,IACD;AAAA,IACA,CAAC,sBAAsB,YAAY;AAAA,EACpC,CAAC;AAED,MAAI,CAAC,QAAQ,wBAAwB;AACpC,UAAM,YAAY,yCAAyC,YAAY;AACtE,YAAM,yBAAyB,QAAQ,SAAS,OAAO;AAAA,IACxD,CAAC;AAAA,EACF;AAEA,MAAI,QAAQ;AACX,UAAM,YAAY,kCAAkC,YAAY;AAC/D,YAAM,2BAA2B,OAAO,SAAS,OAAO;AAAA,IACzD,CAAC;AAAA,EACF;AAEA,MAAI,CAAC,QAAQ,aAAa;AACzB,UAAM,YAAY,0BAA0B,kBAAkB;AAAA,EAC/D;AAEA,MAAI,CAAC,QAAQ,eAAe;AAC3B,UAAM;AAAA,MAAY;AAAA,MAA6C,YAC9D,kBAAkB,QAAQ,OAAO;AAAA,IAClC;AAAA,EACD;AAEA,QAAM;AAAA,IACL,sBAAsB,QAAQ,KAAK,uBAAuB;AAAA,IAC1D,QAAQ;AAAA,EACT;AACD;","names":[]}
@@ -1,7 +1,8 @@
1
+ import { Octokit } from 'octokit';
1
2
  import { Options } from './types.js';
2
3
  import 'zod';
3
4
  import './codes.js';
4
5
 
5
- declare function getGitHubUserAsAllContributor(options: Pick<Options, "offline" | "owner">): Promise<string>;
6
+ declare function getGitHubUserAsAllContributor(octokit: Octokit | undefined, options: Pick<Options, "offline" | "owner">): Promise<string>;
6
7
 
7
8
  export { getGitHubUserAsAllContributor };
@@ -1,6 +1,6 @@
1
1
  import chalk from "chalk";
2
2
  import { $ } from "execa";
3
- async function getGitHubUserAsAllContributor(options) {
3
+ async function getGitHubUserAsAllContributor(octokit, options) {
4
4
  if (options.offline) {
5
5
  console.warn(
6
6
  chalk.gray(
@@ -10,14 +10,18 @@ async function getGitHubUserAsAllContributor(options) {
10
10
  return options.owner;
11
11
  }
12
12
  let user;
13
- try {
14
- user = JSON.parse((await $`gh api user`).stdout).login;
15
- } catch {
16
- console.warn(
17
- chalk.gray(
18
- `Couldn't authenticate GitHub user, falling back to the provided owner name '${options.owner}'.`
19
- )
20
- );
13
+ if (octokit) {
14
+ try {
15
+ user = (await octokit.rest.users.getAuthenticated()).data.login;
16
+ } catch {
17
+ console.warn(
18
+ chalk.gray(
19
+ `Couldn't authenticate GitHub user, falling back to the provided owner name '${options.owner}'.`
20
+ )
21
+ );
22
+ user = options.owner;
23
+ }
24
+ } else {
21
25
  user = options.owner;
22
26
  }
23
27
  const contributions = [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/shared/getGitHubUserAsAllContributor.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport { $ } from \"execa\";\n\nimport { Options } from \"./types.js\";\n\ninterface GhUserOutput {\n\tlogin: string;\n}\n\nexport async function getGitHubUserAsAllContributor(\n\toptions: Pick<Options, \"offline\" | \"owner\">,\n) {\n\tif (options.offline) {\n\t\tconsole.warn(\n\t\t\tchalk.gray(\n\t\t\t\t`Skipping populating all-contributors contributions for ${options.owner} because in --offline mode.`,\n\t\t\t),\n\t\t);\n\t\treturn options.owner;\n\t}\n\n\tlet user: string;\n\n\ttry {\n\t\tuser = (JSON.parse((await $`gh api user`).stdout) as GhUserOutput).login;\n\t} catch {\n\t\tconsole.warn(\n\t\t\tchalk.gray(\n\t\t\t\t`Couldn't authenticate GitHub user, falling back to the provided owner name '${options.owner}'.`,\n\t\t\t),\n\t\t);\n\t\tuser = options.owner;\n\t}\n\n\tconst contributions = [\n\t\t\"code\",\n\t\t\"content\",\n\t\t\"doc\",\n\t\t\"ideas\",\n\t\t\"infra\",\n\t\t\"maintenance\",\n\t\t\"projectManagement\",\n\t\t\"tool\",\n\t].join(\",\");\n\tawait $`npx -y all-contributors-cli@6.25 add ${user} ${contributions}`;\n\n\treturn user;\n}\n"],"mappings":"AAAA,OAAO,WAAW;AAClB,SAAS,SAAS;AAQlB,eAAsB,8BACrB,SACC;AACD,MAAI,QAAQ,SAAS;AACpB,YAAQ;AAAA,MACP,MAAM;AAAA,QACL,0DAA0D,QAAQ,KAAK;AAAA,MACxE;AAAA,IACD;AACA,WAAO,QAAQ;AAAA,EAChB;AAEA,MAAI;AAEJ,MAAI;AACH,WAAQ,KAAK,OAAO,MAAM,gBAAgB,MAAM,EAAmB;AAAA,EACpE,QAAQ;AACP,YAAQ;AAAA,MACP,MAAM;AAAA,QACL,+EAA+E,QAAQ,KAAK;AAAA,MAC7F;AAAA,IACD;AACA,WAAO,QAAQ;AAAA,EAChB;AAEA,QAAM,gBAAgB;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,EAAE,KAAK,GAAG;AACV,QAAM,yCAAyC,IAAI,IAAI,aAAa;AAEpE,SAAO;AACR;","names":[]}
1
+ {"version":3,"sources":["../../src/shared/getGitHubUserAsAllContributor.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport { $ } from \"execa\";\nimport { Octokit } from \"octokit\";\n\nimport { Options } from \"./types.js\";\n\nexport async function getGitHubUserAsAllContributor(\n\toctokit: Octokit | undefined,\n\toptions: Pick<Options, \"offline\" | \"owner\">,\n) {\n\tif (options.offline) {\n\t\tconsole.warn(\n\t\t\tchalk.gray(\n\t\t\t\t`Skipping populating all-contributors contributions for ${options.owner} because in --offline mode.`,\n\t\t\t),\n\t\t);\n\t\treturn options.owner;\n\t}\n\n\tlet user: string;\n\n\tif (octokit) {\n\t\ttry {\n\t\t\tuser = (await octokit.rest.users.getAuthenticated()).data.login;\n\t\t} catch {\n\t\t\tconsole.warn(\n\t\t\t\tchalk.gray(\n\t\t\t\t\t`Couldn't authenticate GitHub user, falling back to the provided owner name '${options.owner}'.`,\n\t\t\t\t),\n\t\t\t);\n\t\t\tuser = options.owner;\n\t\t}\n\t} else {\n\t\tuser = options.owner;\n\t}\n\n\tconst contributions = [\n\t\t\"code\",\n\t\t\"content\",\n\t\t\"doc\",\n\t\t\"ideas\",\n\t\t\"infra\",\n\t\t\"maintenance\",\n\t\t\"projectManagement\",\n\t\t\"tool\",\n\t].join(\",\");\n\tawait $`npx -y all-contributors-cli@6.25 add ${user} ${contributions}`;\n\n\treturn user;\n}\n"],"mappings":"AAAA,OAAO,WAAW;AAClB,SAAS,SAAS;AAKlB,eAAsB,8BACrB,SACA,SACC;AACD,MAAI,QAAQ,SAAS;AACpB,YAAQ;AAAA,MACP,MAAM;AAAA,QACL,0DAA0D,QAAQ,KAAK;AAAA,MACxE;AAAA,IACD;AACA,WAAO,QAAQ;AAAA,EAChB;AAEA,MAAI;AAEJ,MAAI,SAAS;AACZ,QAAI;AACH,cAAQ,MAAM,QAAQ,KAAK,MAAM,iBAAiB,GAAG,KAAK;AAAA,IAC3D,QAAQ;AACP,cAAQ;AAAA,QACP,MAAM;AAAA,UACL,+EAA+E,QAAQ,KAAK;AAAA,QAC7F;AAAA,MACD;AACA,aAAO,QAAQ;AAAA,IAChB;AAAA,EACD,OAAO;AACN,WAAO,QAAQ;AAAA,EAChB;AAEA,QAAM,gBAAgB;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,EAAE,KAAK,GAAG;AACV,QAAM,yCAAyC,IAAI,IAAI,aAAa;AAEpE,SAAO;AACR;","names":[]}
@@ -9,14 +9,20 @@ async function createRepositoryWithApi(octokit, options) {
9
9
  return;
10
10
  }
11
11
  const currentUser = await octokit.rest.users.getAuthenticated();
12
- if (currentUser.data.login === options.owner) {
13
- await octokit.rest.repos.createForAuthenticatedUser({
14
- name: options.repository
15
- });
16
- } else {
17
- await octokit.rest.repos.createInOrg({
18
- name: options.repository,
19
- org: options.owner
12
+ try {
13
+ if (currentUser.data.login === options.owner) {
14
+ await octokit.rest.repos.createForAuthenticatedUser({
15
+ name: options.repository
16
+ });
17
+ } else {
18
+ await octokit.rest.repos.createInOrg({
19
+ name: options.repository,
20
+ org: options.owner
21
+ });
22
+ }
23
+ } catch (error) {
24
+ throw new Error("Failed to create new repository on GitHub.", {
25
+ cause: error
20
26
  });
21
27
  }
22
28
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/shared/options/createRepositoryWithApi.ts"],"sourcesContent":["import { Octokit } from \"octokit\";\n\nexport interface CreateRepositoryWithApiOptions {\n\towner: string;\n\tpreserveGeneratedFrom?: boolean;\n\trepository: string;\n}\n\nexport async function createRepositoryWithApi(\n\toctokit: Octokit,\n\toptions: CreateRepositoryWithApiOptions,\n) {\n\tif (options.preserveGeneratedFrom) {\n\t\tawait octokit.rest.repos.createUsingTemplate({\n\t\t\tname: options.repository,\n\t\t\towner: options.owner,\n\t\t\ttemplate_owner: \"JoshuaKGoldberg\",\n\t\t\ttemplate_repo: \"create-typescript-app\",\n\t\t});\n\t\treturn;\n\t}\n\n\tconst currentUser = await octokit.rest.users.getAuthenticated();\n\n\tif (currentUser.data.login === options.owner) {\n\t\tawait octokit.rest.repos.createForAuthenticatedUser({\n\t\t\tname: options.repository,\n\t\t});\n\t} else {\n\t\tawait octokit.rest.repos.createInOrg({\n\t\t\tname: options.repository,\n\t\t\torg: options.owner,\n\t\t});\n\t}\n}\n"],"mappings":"AAQA,eAAsB,wBACrB,SACA,SACC;AACD,MAAI,QAAQ,uBAAuB;AAClC,UAAM,QAAQ,KAAK,MAAM,oBAAoB;AAAA,MAC5C,MAAM,QAAQ;AAAA,MACd,OAAO,QAAQ;AAAA,MACf,gBAAgB;AAAA,MAChB,eAAe;AAAA,IAChB,CAAC;AACD;AAAA,EACD;AAEA,QAAM,cAAc,MAAM,QAAQ,KAAK,MAAM,iBAAiB;AAE9D,MAAI,YAAY,KAAK,UAAU,QAAQ,OAAO;AAC7C,UAAM,QAAQ,KAAK,MAAM,2BAA2B;AAAA,MACnD,MAAM,QAAQ;AAAA,IACf,CAAC;AAAA,EACF,OAAO;AACN,UAAM,QAAQ,KAAK,MAAM,YAAY;AAAA,MACpC,MAAM,QAAQ;AAAA,MACd,KAAK,QAAQ;AAAA,IACd,CAAC;AAAA,EACF;AACD;","names":[]}
1
+ {"version":3,"sources":["../../../src/shared/options/createRepositoryWithApi.ts"],"sourcesContent":["import { Octokit } from \"octokit\";\n\nexport interface CreateRepositoryWithApiOptions {\n\towner: string;\n\tpreserveGeneratedFrom?: boolean;\n\trepository: string;\n}\n\nexport async function createRepositoryWithApi(\n\toctokit: Octokit,\n\toptions: CreateRepositoryWithApiOptions,\n) {\n\tif (options.preserveGeneratedFrom) {\n\t\tawait octokit.rest.repos.createUsingTemplate({\n\t\t\tname: options.repository,\n\t\t\towner: options.owner,\n\t\t\ttemplate_owner: \"JoshuaKGoldberg\",\n\t\t\ttemplate_repo: \"create-typescript-app\",\n\t\t});\n\t\treturn;\n\t}\n\n\tconst currentUser = await octokit.rest.users.getAuthenticated();\n\n\ttry {\n\t\tif (currentUser.data.login === options.owner) {\n\t\t\tawait octokit.rest.repos.createForAuthenticatedUser({\n\t\t\t\tname: options.repository,\n\t\t\t});\n\t\t} else {\n\t\t\tawait octokit.rest.repos.createInOrg({\n\t\t\t\tname: options.repository,\n\t\t\t\torg: options.owner,\n\t\t\t});\n\t\t}\n\t} catch (error) {\n\t\tthrow new Error(\"Failed to create new repository on GitHub.\", {\n\t\t\tcause: error,\n\t\t});\n\t}\n}\n"],"mappings":"AAQA,eAAsB,wBACrB,SACA,SACC;AACD,MAAI,QAAQ,uBAAuB;AAClC,UAAM,QAAQ,KAAK,MAAM,oBAAoB;AAAA,MAC5C,MAAM,QAAQ;AAAA,MACd,OAAO,QAAQ;AAAA,MACf,gBAAgB;AAAA,MAChB,eAAe;AAAA,IAChB,CAAC;AACD;AAAA,EACD;AAEA,QAAM,cAAc,MAAM,QAAQ,KAAK,MAAM,iBAAiB;AAE9D,MAAI;AACH,QAAI,YAAY,KAAK,UAAU,QAAQ,OAAO;AAC7C,YAAM,QAAQ,KAAK,MAAM,2BAA2B;AAAA,QACnD,MAAM,QAAQ;AAAA,MACf,CAAC;AAAA,IACF,OAAO;AACN,YAAM,QAAQ,KAAK,MAAM,YAAY;AAAA,QACpC,MAAM,QAAQ;AAAA,QACd,KAAK,QAAQ;AAAA,MACd,CAAC;AAAA,IACF;AAAA,EACD,SAAS,OAAO;AACf,UAAM,IAAI,MAAM,8CAA8C;AAAA,MAC7D,OAAO;AAAA,IACR,CAAC;AAAA,EACF;AACD;","names":[]}
@@ -3,9 +3,10 @@ import { Octokit } from "octokit";
3
3
  async function getGitHub() {
4
4
  const auth = await getGitHubAuthToken();
5
5
  if (!auth.succeeded) {
6
- throw new Error("GitHub authentication failed.", {
7
- cause: auth.error
8
- });
6
+ throw new Error(
7
+ "Couldn't authenticate with GitHub. Either log in with `gh auth login` (https://cli.github.com) or set a GH_TOKEN environment variable.",
8
+ { cause: auth.error }
9
+ );
9
10
  }
10
11
  const octokit = new Octokit({ auth: auth.token });
11
12
  return { auth: auth.token, octokit };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/shared/options/getGitHub.ts"],"sourcesContent":["import { getGitHubAuthToken } from \"get-github-auth-token\";\nimport { Octokit } from \"octokit\";\n\nexport interface GitHub {\n\tauth: string;\n\toctokit: Octokit;\n}\n\nexport async function getGitHub(): Promise<GitHub | undefined> {\n\tconst auth = await getGitHubAuthToken();\n\n\tif (!auth.succeeded) {\n\t\tthrow new Error(\"GitHub authentication failed.\", {\n\t\t\tcause: auth.error,\n\t\t});\n\t}\n\n\tconst octokit = new Octokit({ auth: auth.token });\n\n\treturn { auth: auth.token, octokit };\n}\n"],"mappings":"AAAA,SAAS,0BAA0B;AACnC,SAAS,eAAe;AAOxB,eAAsB,YAAyC;AAC9D,QAAM,OAAO,MAAM,mBAAmB;AAEtC,MAAI,CAAC,KAAK,WAAW;AACpB,UAAM,IAAI,MAAM,iCAAiC;AAAA,MAChD,OAAO,KAAK;AAAA,IACb,CAAC;AAAA,EACF;AAEA,QAAM,UAAU,IAAI,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;AAEhD,SAAO,EAAE,MAAM,KAAK,OAAO,QAAQ;AACpC;","names":[]}
1
+ {"version":3,"sources":["../../../src/shared/options/getGitHub.ts"],"sourcesContent":["import { getGitHubAuthToken } from \"get-github-auth-token\";\nimport { Octokit } from \"octokit\";\n\nexport interface GitHub {\n\tauth: string;\n\toctokit: Octokit;\n}\n\nexport async function getGitHub(): Promise<GitHub | undefined> {\n\tconst auth = await getGitHubAuthToken();\n\n\tif (!auth.succeeded) {\n\t\tthrow new Error(\n\t\t\t\"Couldn't authenticate with GitHub. Either log in with `gh auth login` (https://cli.github.com) or set a GH_TOKEN environment variable.\",\n\t\t\t{ cause: auth.error },\n\t\t);\n\t}\n\n\tconst octokit = new Octokit({ auth: auth.token });\n\n\treturn { auth: auth.token, octokit };\n}\n"],"mappings":"AAAA,SAAS,0BAA0B;AACnC,SAAS,eAAe;AAOxB,eAAsB,YAAyC;AAC9D,QAAM,OAAO,MAAM,mBAAmB;AAEtC,MAAI,CAAC,KAAK,WAAW;AACpB,UAAM,IAAI;AAAA,MACT;AAAA,MACA,EAAE,OAAO,KAAK,MAAM;AAAA,IACrB;AAAA,EACD;AAEA,QAAM,UAAU,IAAI,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;AAEhD,SAAO,EAAE,MAAM,KAAK,OAAO,QAAQ;AACpC;","names":[]}
@@ -112,12 +112,11 @@ declare const optionsSchema: z.ZodObject<{
112
112
  skipUninstall: z.ZodOptional<z.ZodBoolean>;
113
113
  title: z.ZodOptional<z.ZodString>;
114
114
  }, "strip", z.ZodTypeAny, {
115
- mode?: "create" | "initialize" | "migrate" | undefined;
116
- auto?: boolean | undefined;
117
- offline?: boolean | undefined;
118
115
  description?: string | undefined;
116
+ offline?: boolean | undefined;
119
117
  access?: "public" | "restricted" | undefined;
120
118
  author?: string | undefined;
119
+ auto?: boolean | undefined;
121
120
  base?: "common" | "everything" | "minimal" | "prompt" | undefined;
122
121
  bin?: string | undefined;
123
122
  directory?: string | undefined;
@@ -129,6 +128,7 @@ declare const optionsSchema: z.ZodObject<{
129
128
  guide?: string | undefined;
130
129
  keywords?: string[] | undefined;
131
130
  logo?: string | undefined;
131
+ mode?: "create" | "initialize" | "migrate" | undefined;
132
132
  owner?: string | undefined;
133
133
  repository?: string | undefined;
134
134
  title?: string | undefined;
@@ -161,12 +161,11 @@ declare const optionsSchema: z.ZodObject<{
161
161
  guideTitle?: string | undefined;
162
162
  logoAlt?: string | undefined;
163
163
  }, {
164
- mode?: "create" | "initialize" | "migrate" | undefined;
165
- auto?: boolean | undefined;
166
- offline?: boolean | undefined;
167
164
  description?: string | undefined;
165
+ offline?: boolean | undefined;
168
166
  access?: "public" | "restricted" | undefined;
169
167
  author?: string | undefined;
168
+ auto?: boolean | undefined;
170
169
  base?: "common" | "everything" | "minimal" | "prompt" | undefined;
171
170
  bin?: string | undefined;
172
171
  directory?: string | undefined;
@@ -178,6 +177,7 @@ declare const optionsSchema: z.ZodObject<{
178
177
  guide?: string | undefined;
179
178
  keywords?: string[] | undefined;
180
179
  logo?: string | undefined;
180
+ mode?: "create" | "initialize" | "migrate" | undefined;
181
181
  owner?: string | undefined;
182
182
  repository?: string | undefined;
183
183
  title?: string | undefined;
@@ -2,10 +2,11 @@ import * as prompts from "@clack/prompts";
2
2
  import chalk from "chalk";
3
3
  import { $ } from "execa";
4
4
  import { logLine } from "./cli/lines.js";
5
+ import { StatusCodes } from "./codes.js";
5
6
  async function runOrRestore({ run, skipRestore }) {
6
7
  try {
7
8
  await run();
8
- return 0;
9
+ return StatusCodes.Success;
9
10
  } catch (error) {
10
11
  logLine();
11
12
  console.log(error);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/shared/runOrRestore.ts"],"sourcesContent":["import * as prompts from \"@clack/prompts\";\nimport chalk from \"chalk\";\nimport { $ } from \"execa\";\n\nimport { logLine } from \"./cli/lines.js\";\n\nexport interface RunOrRestoreOptions {\n\trun: () => Promise<void>;\n\tskipRestore: boolean | undefined;\n}\n\nexport async function runOrRestore({ run, skipRestore }: RunOrRestoreOptions) {\n\ttry {\n\t\tawait run();\n\t\treturn 0;\n\t} catch (error) {\n\t\tlogLine();\n\t\tconsole.log(error);\n\n\t\tif (skipRestore) {\n\t\t\tlogLine();\n\t\t\tlogLine(chalk.gray`Leaving changes to the local directory on disk.`);\n\t\t} else {\n\t\t\tconst shouldRestore = await prompts.confirm({\n\t\t\t\tmessage: \"Do you want to restore the repository to how it was?\",\n\t\t\t});\n\n\t\t\tif (shouldRestore) {\n\t\t\t\tlogLine();\n\t\t\t\tlogLine(\n\t\t\t\t\t[\n\t\t\t\t\t\tchalk.gray`Resetting repository using`,\n\t\t\t\t\t\tchalk.reset`git restore .`,\n\t\t\t\t\t].join(\" \"),\n\t\t\t\t);\n\t\t\t\tawait $`git restore .`;\n\t\t\t}\n\t\t}\n\n\t\treturn 2;\n\t}\n}\n"],"mappings":"AAAA,YAAY,aAAa;AACzB,OAAO,WAAW;AAClB,SAAS,SAAS;AAElB,SAAS,eAAe;AAOxB,eAAsB,aAAa,EAAE,KAAK,YAAY,GAAwB;AAC7E,MAAI;AACH,UAAM,IAAI;AACV,WAAO;AAAA,EACR,SAAS,OAAO;AACf,YAAQ;AACR,YAAQ,IAAI,KAAK;AAEjB,QAAI,aAAa;AAChB,cAAQ;AACR,cAAQ,MAAM,qDAAqD;AAAA,IACpE,OAAO;AACN,YAAM,gBAAgB,MAAM,QAAQ,QAAQ;AAAA,QAC3C,SAAS;AAAA,MACV,CAAC;AAED,UAAI,eAAe;AAClB,gBAAQ;AACR;AAAA,UACC;AAAA,YACC,MAAM;AAAA,YACN,MAAM;AAAA,UACP,EAAE,KAAK,GAAG;AAAA,QACX;AACA,cAAM;AAAA,MACP;AAAA,IACD;AAEA,WAAO;AAAA,EACR;AACD;","names":[]}
1
+ {"version":3,"sources":["../../src/shared/runOrRestore.ts"],"sourcesContent":["import * as prompts from \"@clack/prompts\";\nimport chalk from \"chalk\";\nimport { $ } from \"execa\";\n\nimport { logLine } from \"./cli/lines.js\";\nimport { StatusCodes } from \"./codes.js\";\n\nexport interface RunOrRestoreOptions {\n\trun: () => Promise<void>;\n\tskipRestore: boolean | undefined;\n}\n\nexport async function runOrRestore({ run, skipRestore }: RunOrRestoreOptions) {\n\ttry {\n\t\tawait run();\n\t\treturn StatusCodes.Success;\n\t} catch (error) {\n\t\tlogLine();\n\t\tconsole.log(error);\n\n\t\tif (skipRestore) {\n\t\t\tlogLine();\n\t\t\tlogLine(chalk.gray`Leaving changes to the local directory on disk.`);\n\t\t} else {\n\t\t\tconst shouldRestore = await prompts.confirm({\n\t\t\t\tmessage: \"Do you want to restore the repository to how it was?\",\n\t\t\t});\n\n\t\t\tif (shouldRestore) {\n\t\t\t\tlogLine();\n\t\t\t\tlogLine(\n\t\t\t\t\t[\n\t\t\t\t\t\tchalk.gray`Resetting repository using`,\n\t\t\t\t\t\tchalk.reset`git restore .`,\n\t\t\t\t\t].join(\" \"),\n\t\t\t\t);\n\t\t\t\tawait $`git restore .`;\n\t\t\t}\n\t\t}\n\n\t\treturn 2;\n\t}\n}\n"],"mappings":"AAAA,YAAY,aAAa;AACzB,OAAO,WAAW;AAClB,SAAS,SAAS;AAElB,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAO5B,eAAsB,aAAa,EAAE,KAAK,YAAY,GAAwB;AAC7E,MAAI;AACH,UAAM,IAAI;AACV,WAAO,YAAY;AAAA,EACpB,SAAS,OAAO;AACf,YAAQ;AACR,YAAQ,IAAI,KAAK;AAEjB,QAAI,aAAa;AAChB,cAAQ;AACR,cAAQ,MAAM,qDAAqD;AAAA,IACpE,OAAO;AACN,YAAM,gBAAgB,MAAM,QAAQ,QAAQ;AAAA,QAC3C,SAAS;AAAA,MACV,CAAC;AAED,UAAI,eAAe;AAClB,gBAAQ;AACR;AAAA,UACC;AAAA,YACC,MAAM;AAAA,YACN,MAAM;AAAA,UACP,EAAE,KAAK,GAAG;AAAA,QACX;AACA,cAAM;AAAA,MACP;AAAA,IACD;AAEA,WAAO;AAAA,EACR;AACD;","names":[]}
@@ -1,7 +1,8 @@
1
+ import { Octokit } from 'octokit';
1
2
  import { Options } from '../shared/types.js';
2
3
  import 'zod';
3
4
  import '../shared/codes.js';
4
5
 
5
- declare function addOwnerAsAllContributor(options: Pick<Options, "offline" | "owner">): Promise<void>;
6
+ declare function addOwnerAsAllContributor(octokit: Octokit | undefined, options: Pick<Options, "offline" | "owner">): Promise<void>;
6
7
 
7
8
  export { addOwnerAsAllContributor };
@@ -2,8 +2,8 @@ import * as fs from "node:fs/promises";
2
2
  import { getGitHubUserAsAllContributor } from "../shared/getGitHubUserAsAllContributor.js";
3
3
  import { readFileAsJson } from "../shared/readFileAsJson.js";
4
4
  import { formatJson } from "./writing/creation/formatters/formatJson.js";
5
- async function addOwnerAsAllContributor(options) {
6
- const user = await getGitHubUserAsAllContributor(options);
5
+ async function addOwnerAsAllContributor(octokit, options) {
6
+ const user = await getGitHubUserAsAllContributor(octokit, options);
7
7
  const existingContributors = await readFileAsJson(
8
8
  "./.all-contributorsrc"
9
9
  );
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/steps/addOwnerAsAllContributor.ts"],"sourcesContent":["import * as fs from \"node:fs/promises\";\n\nimport { getGitHubUserAsAllContributor } from \"../shared/getGitHubUserAsAllContributor.js\";\nimport { readFileAsJson } from \"../shared/readFileAsJson.js\";\nimport { AllContributorsData, Options } from \"../shared/types.js\";\nimport { formatJson } from \"./writing/creation/formatters/formatJson.js\";\n\nexport async function addOwnerAsAllContributor(\n\toptions: Pick<Options, \"offline\" | \"owner\">,\n) {\n\tconst user = await getGitHubUserAsAllContributor(options);\n\n\tconst existingContributors = (await readFileAsJson(\n\t\t\"./.all-contributorsrc\",\n\t)) as AllContributorsData;\n\tif (!isValidAllContributorsData(existingContributors)) {\n\t\tthrow new Error(\n\t\t\t`Invalid .all-contributorsrc: ${JSON.stringify(existingContributors)}`,\n\t\t);\n\t}\n\n\tconst contributors = existingContributors.contributors\n\t\t.filter(({ login }) => [\"JoshuaKGoldberg\", user].includes(login))\n\t\t.map((contributor) =>\n\t\t\tcontributor.login === \"JoshuaKGoldberg\"\n\t\t\t\t? { ...contributor, contributions: [\"tool\"] }\n\t\t\t\t: {\n\t\t\t\t\t\t...contributor,\n\t\t\t\t\t\tcontributions: Array.from(\n\t\t\t\t\t\t\tnew Set([...contributor.contributions, \"tool\"]),\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t);\n\n\tif (!contributors.some((contributor) => contributor.login === user)) {\n\t\tcontributors.push({\n\t\t\tcontributions: [\"tool\"],\n\t\t\tlogin: user,\n\t\t});\n\t}\n\n\tawait fs.writeFile(\n\t\t\"./.all-contributorsrc\",\n\t\tawait formatJson({\n\t\t\t...existingContributors,\n\t\t\tcontributors,\n\t\t}),\n\t);\n}\n\nfunction isValidAllContributorsData(\n\tvalue: unknown,\n): value is AllContributorsData {\n\treturn !!value && typeof value === \"object\" && \"contributors\" in value;\n}\n"],"mappings":"AAAA,YAAY,QAAQ;AAEpB,SAAS,qCAAqC;AAC9C,SAAS,sBAAsB;AAE/B,SAAS,kBAAkB;AAE3B,eAAsB,yBACrB,SACC;AACD,QAAM,OAAO,MAAM,8BAA8B,OAAO;AAExD,QAAM,uBAAwB,MAAM;AAAA,IACnC;AAAA,EACD;AACA,MAAI,CAAC,2BAA2B,oBAAoB,GAAG;AACtD,UAAM,IAAI;AAAA,MACT,gCAAgC,KAAK,UAAU,oBAAoB,CAAC;AAAA,IACrE;AAAA,EACD;AAEA,QAAM,eAAe,qBAAqB,aACxC,OAAO,CAAC,EAAE,MAAM,MAAM,CAAC,mBAAmB,IAAI,EAAE,SAAS,KAAK,CAAC,EAC/D;AAAA,IAAI,CAAC,gBACL,YAAY,UAAU,oBACnB,EAAE,GAAG,aAAa,eAAe,CAAC,MAAM,EAAE,IAC1C;AAAA,MACA,GAAG;AAAA,MACH,eAAe,MAAM;AAAA,QACpB,oBAAI,IAAI,CAAC,GAAG,YAAY,eAAe,MAAM,CAAC;AAAA,MAC/C;AAAA,IACD;AAAA,EACH;AAED,MAAI,CAAC,aAAa,KAAK,CAAC,gBAAgB,YAAY,UAAU,IAAI,GAAG;AACpE,iBAAa,KAAK;AAAA,MACjB,eAAe,CAAC,MAAM;AAAA,MACtB,OAAO;AAAA,IACR,CAAC;AAAA,EACF;AAEA,QAAM,GAAG;AAAA,IACR;AAAA,IACA,MAAM,WAAW;AAAA,MAChB,GAAG;AAAA,MACH;AAAA,IACD,CAAC;AAAA,EACF;AACD;AAEA,SAAS,2BACR,OAC+B;AAC/B,SAAO,CAAC,CAAC,SAAS,OAAO,UAAU,YAAY,kBAAkB;AAClE;","names":[]}
1
+ {"version":3,"sources":["../../src/steps/addOwnerAsAllContributor.ts"],"sourcesContent":["import * as fs from \"node:fs/promises\";\nimport { Octokit } from \"octokit\";\n\nimport { getGitHubUserAsAllContributor } from \"../shared/getGitHubUserAsAllContributor.js\";\nimport { readFileAsJson } from \"../shared/readFileAsJson.js\";\nimport { AllContributorsData, Options } from \"../shared/types.js\";\nimport { formatJson } from \"./writing/creation/formatters/formatJson.js\";\n\nexport async function addOwnerAsAllContributor(\n\toctokit: Octokit | undefined,\n\toptions: Pick<Options, \"offline\" | \"owner\">,\n) {\n\tconst user = await getGitHubUserAsAllContributor(octokit, options);\n\n\tconst existingContributors = (await readFileAsJson(\n\t\t\"./.all-contributorsrc\",\n\t)) as AllContributorsData;\n\tif (!isValidAllContributorsData(existingContributors)) {\n\t\tthrow new Error(\n\t\t\t`Invalid .all-contributorsrc: ${JSON.stringify(existingContributors)}`,\n\t\t);\n\t}\n\n\tconst contributors = existingContributors.contributors\n\t\t.filter(({ login }) => [\"JoshuaKGoldberg\", user].includes(login))\n\t\t.map((contributor) =>\n\t\t\tcontributor.login === \"JoshuaKGoldberg\"\n\t\t\t\t? { ...contributor, contributions: [\"tool\"] }\n\t\t\t\t: {\n\t\t\t\t\t\t...contributor,\n\t\t\t\t\t\tcontributions: Array.from(\n\t\t\t\t\t\t\tnew Set([...contributor.contributions, \"tool\"]),\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t);\n\n\tif (!contributors.some((contributor) => contributor.login === user)) {\n\t\tcontributors.push({\n\t\t\tcontributions: [\"tool\"],\n\t\t\tlogin: user,\n\t\t});\n\t}\n\n\tawait fs.writeFile(\n\t\t\"./.all-contributorsrc\",\n\t\tawait formatJson({\n\t\t\t...existingContributors,\n\t\t\tcontributors,\n\t\t}),\n\t);\n}\n\nfunction isValidAllContributorsData(\n\tvalue: unknown,\n): value is AllContributorsData {\n\treturn !!value && typeof value === \"object\" && \"contributors\" in value;\n}\n"],"mappings":"AAAA,YAAY,QAAQ;AAGpB,SAAS,qCAAqC;AAC9C,SAAS,sBAAsB;AAE/B,SAAS,kBAAkB;AAE3B,eAAsB,yBACrB,SACA,SACC;AACD,QAAM,OAAO,MAAM,8BAA8B,SAAS,OAAO;AAEjE,QAAM,uBAAwB,MAAM;AAAA,IACnC;AAAA,EACD;AACA,MAAI,CAAC,2BAA2B,oBAAoB,GAAG;AACtD,UAAM,IAAI;AAAA,MACT,gCAAgC,KAAK,UAAU,oBAAoB,CAAC;AAAA,IACrE;AAAA,EACD;AAEA,QAAM,eAAe,qBAAqB,aACxC,OAAO,CAAC,EAAE,MAAM,MAAM,CAAC,mBAAmB,IAAI,EAAE,SAAS,KAAK,CAAC,EAC/D;AAAA,IAAI,CAAC,gBACL,YAAY,UAAU,oBACnB,EAAE,GAAG,aAAa,eAAe,CAAC,MAAM,EAAE,IAC1C;AAAA,MACA,GAAG;AAAA,MACH,eAAe,MAAM;AAAA,QACpB,oBAAI,IAAI,CAAC,GAAG,YAAY,eAAe,MAAM,CAAC;AAAA,MAC/C;AAAA,IACD;AAAA,EACH;AAED,MAAI,CAAC,aAAa,KAAK,CAAC,gBAAgB,YAAY,UAAU,IAAI,GAAG;AACpE,iBAAa,KAAK;AAAA,MACjB,eAAe,CAAC,MAAM;AAAA,MACtB,OAAO;AAAA,IACR,CAAC;AAAA,EACF;AAEA,QAAM,GAAG;AAAA,IACR;AAAA,IACA,MAAM,WAAW;AAAA,MAChB,GAAG;AAAA,MACH;AAAA,IACD,CAAC;AAAA,EACF;AACD;AAEA,SAAS,2BACR,OAC+B;AAC/B,SAAO,CAAC,CAAC,SAAS,OAAO,UAAU,YAAY,kBAAkB;AAClE;","names":[]}
@@ -1,7 +1,8 @@
1
+ import { Octokit } from 'octokit';
1
2
  import { Options } from '../shared/types.js';
2
3
  import 'zod';
3
4
  import '../shared/codes.js';
4
5
 
5
- declare function addToolAllContributors(options: Pick<Options, "offline" | "owner">): Promise<void>;
6
+ declare function addToolAllContributors(octokit: Octokit | undefined, options: Pick<Options, "offline" | "owner">): Promise<void>;
6
7
 
7
8
  export { addToolAllContributors };
@@ -1,7 +1,7 @@
1
1
  import { $ } from "execa";
2
2
  import { getGitHubUserAsAllContributor } from "../shared/getGitHubUserAsAllContributor.js";
3
- async function addToolAllContributors(options) {
4
- const login = await getGitHubUserAsAllContributor(options);
3
+ async function addToolAllContributors(octokit, options) {
4
+ const login = await getGitHubUserAsAllContributor(octokit, options);
5
5
  if (login !== "JoshuaKGoldberg") {
6
6
  await $`npx -y all-contributors-cli add JoshuaKGoldberg tool`;
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/steps/addToolAllContributors.ts"],"sourcesContent":["import { $ } from \"execa\";\n\nimport { getGitHubUserAsAllContributor } from \"../shared/getGitHubUserAsAllContributor.js\";\nimport { Options } from \"../shared/types.js\";\n\nexport async function addToolAllContributors(\n\toptions: Pick<Options, \"offline\" | \"owner\">,\n) {\n\tconst login = await getGitHubUserAsAllContributor(options);\n\n\tif (login !== \"JoshuaKGoldberg\") {\n\t\tawait $`npx -y all-contributors-cli add JoshuaKGoldberg tool`;\n\t}\n}\n"],"mappings":"AAAA,SAAS,SAAS;AAElB,SAAS,qCAAqC;AAG9C,eAAsB,uBACrB,SACC;AACD,QAAM,QAAQ,MAAM,8BAA8B,OAAO;AAEzD,MAAI,UAAU,mBAAmB;AAChC,UAAM;AAAA,EACP;AACD;","names":[]}
1
+ {"version":3,"sources":["../../src/steps/addToolAllContributors.ts"],"sourcesContent":["import { $ } from \"execa\";\nimport { Octokit } from \"octokit\";\n\nimport { getGitHubUserAsAllContributor } from \"../shared/getGitHubUserAsAllContributor.js\";\nimport { Options } from \"../shared/types.js\";\n\nexport async function addToolAllContributors(\n\toctokit: Octokit | undefined,\n\toptions: Pick<Options, \"offline\" | \"owner\">,\n) {\n\tconst login = await getGitHubUserAsAllContributor(octokit, options);\n\n\tif (login !== \"JoshuaKGoldberg\") {\n\t\tawait $`npx -y all-contributors-cli add JoshuaKGoldberg tool`;\n\t}\n}\n"],"mappings":"AAAA,SAAS,SAAS;AAGlB,SAAS,qCAAqC;AAG9C,eAAsB,uBACrB,SACA,SACC;AACD,QAAM,QAAQ,MAAM,8BAA8B,SAAS,OAAO;AAElE,MAAI,UAAU,mBAAmB;AAChC,UAAM;AAAA,EACP;AACD;","names":[]}
@@ -6,7 +6,7 @@ async function initializeGitHubRepository(octokit, options) {
6
6
  await initializeGitRemote(options);
7
7
  await initializeRepositorySettings(octokit, options);
8
8
  await initializeBranchProtectionSettings(octokit, options);
9
- await initializeRepositoryLabels();
9
+ await initializeRepositoryLabels(octokit, options);
10
10
  }
11
11
  export {
12
12
  initializeGitHubRepository
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/steps/initializeGitHubRepository/index.ts"],"sourcesContent":["import { Octokit } from \"octokit\";\n\nimport { Options } from \"../../shared/types.js\";\nimport { initializeGitRemote } from \"../initializeGitRemote.js\";\nimport { initializeRepositorySettings } from \"../initializeRepositorySettings.js\";\nimport { initializeBranchProtectionSettings } from \"./initializeBranchProtectionSettings.js\";\nimport { initializeRepositoryLabels } from \"./labels/initializeRepositoryLabels.js\";\n\nexport async function initializeGitHubRepository(\n\toctokit: Octokit,\n\toptions: Options,\n) {\n\tawait initializeGitRemote(options);\n\tawait initializeRepositorySettings(octokit, options);\n\tawait initializeBranchProtectionSettings(octokit, options);\n\tawait initializeRepositoryLabels();\n}\n"],"mappings":"AAGA,SAAS,2BAA2B;AACpC,SAAS,oCAAoC;AAC7C,SAAS,0CAA0C;AACnD,SAAS,kCAAkC;AAE3C,eAAsB,2BACrB,SACA,SACC;AACD,QAAM,oBAAoB,OAAO;AACjC,QAAM,6BAA6B,SAAS,OAAO;AACnD,QAAM,mCAAmC,SAAS,OAAO;AACzD,QAAM,2BAA2B;AAClC;","names":[]}
1
+ {"version":3,"sources":["../../../src/steps/initializeGitHubRepository/index.ts"],"sourcesContent":["import { Octokit } from \"octokit\";\n\nimport { Options } from \"../../shared/types.js\";\nimport { initializeGitRemote } from \"../initializeGitRemote.js\";\nimport { initializeRepositorySettings } from \"../initializeRepositorySettings.js\";\nimport { initializeBranchProtectionSettings } from \"./initializeBranchProtectionSettings.js\";\nimport { initializeRepositoryLabels } from \"./labels/initializeRepositoryLabels.js\";\n\nexport async function initializeGitHubRepository(\n\toctokit: Octokit,\n\toptions: Options,\n) {\n\tawait initializeGitRemote(options);\n\tawait initializeRepositorySettings(octokit, options);\n\tawait initializeBranchProtectionSettings(octokit, options);\n\tawait initializeRepositoryLabels(octokit, options);\n}\n"],"mappings":"AAGA,SAAS,2BAA2B;AACpC,SAAS,oCAAoC;AAC7C,SAAS,0CAA0C;AACnD,SAAS,kCAAkC;AAE3C,eAAsB,2BACrB,SACA,SACC;AACD,QAAM,oBAAoB,OAAO;AACjC,QAAM,6BAA6B,SAAS,OAAO;AACnD,QAAM,mCAAmC,SAAS,OAAO;AACzD,QAAM,2BAA2B,SAAS,OAAO;AAClD;","names":[]}
@@ -1,6 +1,6 @@
1
1
  interface GhLabelData {
2
2
  color: string;
3
- description: string;
3
+ description: null | string;
4
4
  name: string;
5
5
  }
6
6
  declare function getExistingEquivalentLabels(existingLabels: GhLabelData[], outcomeLabelName: string): GhLabelData[];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/steps/initializeGitHubRepository/labels/getExistingEquivalentLabels.ts"],"sourcesContent":["const aliases = new Map([\n\t[\"enhancement\", \"type: feature\"],\n\t[\"help wanted\", \"status: accepting prs\"],\n]);\n\nexport interface GhLabelData {\n\tcolor: string;\n\tdescription: string;\n\tname: string;\n}\n\nexport function getExistingEquivalentLabels(\n\texistingLabels: GhLabelData[],\n\toutcomeLabelName: string,\n) {\n\tconst outcomeTrimmed = outcomeLabelName.replace(/\\w+: (\\w+)/, \"$1\");\n\n\treturn existingLabels.filter(({ name: existingName }) => {\n\t\treturn (\n\t\t\texistingName === outcomeLabelName ||\n\t\t\texistingName === outcomeTrimmed ||\n\t\t\taliases.get(existingName) === outcomeLabelName ||\n\t\t\texistingName.replace(/\\w+: (\\w+)/, \"$1\") === outcomeLabelName\n\t\t);\n\t});\n}\n"],"mappings":"AAAA,MAAM,UAAU,oBAAI,IAAI;AAAA,EACvB,CAAC,eAAe,eAAe;AAAA,EAC/B,CAAC,eAAe,uBAAuB;AACxC,CAAC;AAQM,SAAS,4BACf,gBACA,kBACC;AACD,QAAM,iBAAiB,iBAAiB,QAAQ,cAAc,IAAI;AAElE,SAAO,eAAe,OAAO,CAAC,EAAE,MAAM,aAAa,MAAM;AACxD,WACC,iBAAiB,oBACjB,iBAAiB,kBACjB,QAAQ,IAAI,YAAY,MAAM,oBAC9B,aAAa,QAAQ,cAAc,IAAI,MAAM;AAAA,EAE/C,CAAC;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/steps/initializeGitHubRepository/labels/getExistingEquivalentLabels.ts"],"sourcesContent":["const aliases = new Map([\n\t[\"enhancement\", \"type: feature\"],\n\t[\"help wanted\", \"status: accepting prs\"],\n]);\n\nexport interface GhLabelData {\n\tcolor: string;\n\tdescription: null | string;\n\tname: string;\n}\n\nexport function getExistingEquivalentLabels(\n\texistingLabels: GhLabelData[],\n\toutcomeLabelName: string,\n) {\n\tconst outcomeTrimmed = outcomeLabelName.replace(/\\w+: (\\w+)/, \"$1\");\n\n\treturn existingLabels.filter(({ name: existingName }) => {\n\t\treturn (\n\t\t\texistingName === outcomeLabelName ||\n\t\t\texistingName === outcomeTrimmed ||\n\t\t\taliases.get(existingName) === outcomeLabelName ||\n\t\t\texistingName.replace(/\\w+: (\\w+)/, \"$1\") === outcomeLabelName\n\t\t);\n\t});\n}\n"],"mappings":"AAAA,MAAM,UAAU,oBAAI,IAAI;AAAA,EACvB,CAAC,eAAe,eAAe;AAAA,EAC/B,CAAC,eAAe,uBAAuB;AACxC,CAAC;AAQM,SAAS,4BACf,gBACA,kBACC;AACD,QAAM,iBAAiB,iBAAiB,QAAQ,cAAc,IAAI;AAElE,SAAO,eAAe,OAAO,CAAC,EAAE,MAAM,aAAa,MAAM;AACxD,WACC,iBAAiB,oBACjB,iBAAiB,kBACjB,QAAQ,IAAI,YAAY,MAAM,oBAC9B,aAAa,QAAQ,cAAc,IAAI,MAAM;AAAA,EAE/C,CAAC;AACF;","names":[]}
@@ -1,3 +1,8 @@
1
- declare function initializeRepositoryLabels(): Promise<void>;
1
+ import { Octokit } from 'octokit';
2
+ import { Options } from '../../../shared/types.js';
3
+ import 'zod';
4
+ import '../../../shared/codes.js';
5
+
6
+ declare function initializeRepositoryLabels(octokit: Octokit, options: Pick<Options, "owner" | "repository">): Promise<void>;
2
7
 
3
8
  export { initializeRepositoryLabels };
@@ -1,11 +1,15 @@
1
- import { $ } from "execa";
2
- import {
3
- getExistingEquivalentLabels
4
- } from "./getExistingEquivalentLabels.js";
1
+ import { getExistingEquivalentLabels } from "./getExistingEquivalentLabels.js";
5
2
  import { outcomeLabels } from "./outcomeLabels.js";
6
- async function initializeRepositoryLabels() {
7
- const existingLabels = JSON.parse(
8
- (await $`gh label list --json color,description,name`).stdout || "[]"
3
+ async function initializeRepositoryLabels(octokit, options) {
4
+ const { data: existingLabels } = await octokit.request(
5
+ "GET /repos/{owner}/{repo}/labels",
6
+ {
7
+ headers: {
8
+ "X-GitHub-Api-Version": "2022-11-28"
9
+ },
10
+ owner: options.owner,
11
+ repo: options.repository
12
+ }
9
13
  );
10
14
  for (const outcome of outcomeLabels) {
11
15
  const existingEquivalents = getExistingEquivalentLabels(
@@ -13,16 +17,42 @@ async function initializeRepositoryLabels() {
13
17
  outcome.name
14
18
  );
15
19
  if (!existingEquivalents.length) {
16
- await $`gh label create ${outcome.name} --color ${outcome.color} --description ${outcome.description}`;
20
+ await octokit.request("POST /repos/{owner}/{repo}/labels", {
21
+ color: outcome.color.replace("#", ""),
22
+ description: outcome.description,
23
+ headers: {
24
+ "X-GitHub-Api-Version": "2022-11-28"
25
+ },
26
+ name: outcome.name,
27
+ owner: options.owner,
28
+ repo: options.repository
29
+ });
17
30
  continue;
18
31
  }
19
32
  for (const existingEquivalent of existingEquivalents) {
20
33
  if (existingEquivalent.name !== outcome.name && existingLabels.some((existing) => existing.name === outcome.name)) {
21
- await $`gh label delete ${existingEquivalent.name} --yes`;
34
+ await octokit.request("DELETE /repos/{owner}/{repo}/labels/{name}", {
35
+ headers: {
36
+ "X-GitHub-Api-Version": "2022-11-28"
37
+ },
38
+ name: existingEquivalent.name,
39
+ owner: options.owner,
40
+ repo: options.repository
41
+ });
22
42
  continue;
23
43
  }
24
44
  if (outcome.color !== existingEquivalent.color || outcome.description !== existingEquivalent.description || outcome.name !== existingEquivalent.name) {
25
- await $`gh label edit ${existingEquivalent.name} --color ${outcome.color} --description ${outcome.description} --name ${outcome.name}`;
45
+ await octokit.request("PATCH /repos/{owner}/{repo}/labels/{name}", {
46
+ color: outcome.color.replace("#", ""),
47
+ description: outcome.description,
48
+ headers: {
49
+ "X-GitHub-Api-Version": "2022-11-28"
50
+ },
51
+ name: existingEquivalent.name,
52
+ new_name: outcome.name,
53
+ owner: options.owner,
54
+ repo: options.repository
55
+ });
26
56
  }
27
57
  }
28
58
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/steps/initializeGitHubRepository/labels/initializeRepositoryLabels.ts"],"sourcesContent":["import { $ } from \"execa\";\n\nimport {\n\tgetExistingEquivalentLabels,\n\tGhLabelData,\n} from \"./getExistingEquivalentLabels.js\";\nimport { outcomeLabels } from \"./outcomeLabels.js\";\n\nexport async function initializeRepositoryLabels() {\n\tconst existingLabels = JSON.parse(\n\t\t(await $`gh label list --json color,description,name`).stdout || \"[]\",\n\t) as GhLabelData[];\n\n\tfor (const outcome of outcomeLabels) {\n\t\tconst existingEquivalents = getExistingEquivalentLabels(\n\t\t\texistingLabels,\n\t\t\toutcome.name,\n\t\t);\n\n\t\t// Case: the repo has neither of the two label types\n\t\tif (!existingEquivalents.length) {\n\t\t\tawait $`gh label create ${outcome.name} --color ${outcome.color} --description ${outcome.description}`;\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (const existingEquivalent of existingEquivalents) {\n\t\t\t// Case: the repo already has both prefixed and non-prefixed label name types\n\t\t\t// E.g. both \"area: documentation\" and \"documentation\"\n\t\t\tif (\n\t\t\t\texistingEquivalent.name !== outcome.name &&\n\t\t\t\texistingLabels.some((existing) => existing.name === outcome.name)\n\t\t\t) {\n\t\t\t\tawait $`gh label delete ${existingEquivalent.name} --yes`;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Case: the repo has one of the two label types, with >=1 different property\n\t\t\t// E.g. \"documentation\" and the same color and description\n\t\t\t// E.g. \"area: documentation\" but with a different color\n\t\t\tif (\n\t\t\t\toutcome.color !== existingEquivalent.color ||\n\t\t\t\toutcome.description !== existingEquivalent.description ||\n\t\t\t\toutcome.name !== existingEquivalent.name\n\t\t\t) {\n\t\t\t\tawait $`gh label edit ${existingEquivalent.name} --color ${outcome.color} --description ${outcome.description} --name ${outcome.name}`;\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":"AAAA,SAAS,SAAS;AAElB;AAAA,EACC;AAAA,OAEM;AACP,SAAS,qBAAqB;AAE9B,eAAsB,6BAA6B;AAClD,QAAM,iBAAiB,KAAK;AAAA,KAC1B,MAAM,gDAAgD,UAAU;AAAA,EAClE;AAEA,aAAW,WAAW,eAAe;AACpC,UAAM,sBAAsB;AAAA,MAC3B;AAAA,MACA,QAAQ;AAAA,IACT;AAGA,QAAI,CAAC,oBAAoB,QAAQ;AAChC,YAAM,oBAAoB,QAAQ,IAAI,YAAY,QAAQ,KAAK,kBAAkB,QAAQ,WAAW;AACpG;AAAA,IACD;AAEA,eAAW,sBAAsB,qBAAqB;AAGrD,UACC,mBAAmB,SAAS,QAAQ,QACpC,eAAe,KAAK,CAAC,aAAa,SAAS,SAAS,QAAQ,IAAI,GAC/D;AACD,cAAM,oBAAoB,mBAAmB,IAAI;AACjD;AAAA,MACD;AAKA,UACC,QAAQ,UAAU,mBAAmB,SACrC,QAAQ,gBAAgB,mBAAmB,eAC3C,QAAQ,SAAS,mBAAmB,MACnC;AACD,cAAM,kBAAkB,mBAAmB,IAAI,YAAY,QAAQ,KAAK,kBAAkB,QAAQ,WAAW,WAAW,QAAQ,IAAI;AAAA,MACrI;AAAA,IACD;AAAA,EACD;AACD;","names":[]}
1
+ {"version":3,"sources":["../../../../src/steps/initializeGitHubRepository/labels/initializeRepositoryLabels.ts"],"sourcesContent":["import { Octokit } from \"octokit\";\n\nimport { Options } from \"../../../shared/types.js\";\nimport { getExistingEquivalentLabels } from \"./getExistingEquivalentLabels.js\";\nimport { outcomeLabels } from \"./outcomeLabels.js\";\n\nexport async function initializeRepositoryLabels(\n\toctokit: Octokit,\n\toptions: Pick<Options, \"owner\" | \"repository\">,\n) {\n\tconst { data: existingLabels } = await octokit.request(\n\t\t\"GET /repos/{owner}/{repo}/labels\",\n\t\t{\n\t\t\theaders: {\n\t\t\t\t\"X-GitHub-Api-Version\": \"2022-11-28\",\n\t\t\t},\n\t\t\towner: options.owner,\n\t\t\trepo: options.repository,\n\t\t},\n\t);\n\n\tfor (const outcome of outcomeLabels) {\n\t\tconst existingEquivalents = getExistingEquivalentLabels(\n\t\t\texistingLabels,\n\t\t\toutcome.name,\n\t\t);\n\n\t\t// Case: the repo has neither of the two label types\n\t\tif (!existingEquivalents.length) {\n\t\t\tawait octokit.request(\"POST /repos/{owner}/{repo}/labels\", {\n\t\t\t\tcolor: outcome.color.replace(\"#\", \"\"),\n\t\t\t\tdescription: outcome.description,\n\t\t\t\theaders: {\n\t\t\t\t\t\"X-GitHub-Api-Version\": \"2022-11-28\",\n\t\t\t\t},\n\t\t\t\tname: outcome.name,\n\t\t\t\towner: options.owner,\n\t\t\t\trepo: options.repository,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (const existingEquivalent of existingEquivalents) {\n\t\t\t// Case: the repo already has both prefixed and non-prefixed label name types\n\t\t\t// E.g. both \"area: documentation\" and \"documentation\"\n\t\t\tif (\n\t\t\t\texistingEquivalent.name !== outcome.name &&\n\t\t\t\texistingLabels.some((existing) => existing.name === outcome.name)\n\t\t\t) {\n\t\t\t\tawait octokit.request(\"DELETE /repos/{owner}/{repo}/labels/{name}\", {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"X-GitHub-Api-Version\": \"2022-11-28\",\n\t\t\t\t\t},\n\t\t\t\t\tname: existingEquivalent.name,\n\t\t\t\t\towner: options.owner,\n\t\t\t\t\trepo: options.repository,\n\t\t\t\t});\n\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Case: the repo has one of the two label types, with >=1 different property\n\t\t\t// E.g. \"documentation\" and the same color and description\n\t\t\t// E.g. \"area: documentation\" but with a different color\n\t\t\tif (\n\t\t\t\toutcome.color !== existingEquivalent.color ||\n\t\t\t\toutcome.description !== existingEquivalent.description ||\n\t\t\t\toutcome.name !== existingEquivalent.name\n\t\t\t) {\n\t\t\t\tawait octokit.request(\"PATCH /repos/{owner}/{repo}/labels/{name}\", {\n\t\t\t\t\tcolor: outcome.color.replace(\"#\", \"\"),\n\t\t\t\t\tdescription: outcome.description,\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"X-GitHub-Api-Version\": \"2022-11-28\",\n\t\t\t\t\t},\n\t\t\t\t\tname: existingEquivalent.name,\n\t\t\t\t\tnew_name: outcome.name,\n\t\t\t\t\towner: options.owner,\n\t\t\t\t\trepo: options.repository,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":"AAGA,SAAS,mCAAmC;AAC5C,SAAS,qBAAqB;AAE9B,eAAsB,2BACrB,SACA,SACC;AACD,QAAM,EAAE,MAAM,eAAe,IAAI,MAAM,QAAQ;AAAA,IAC9C;AAAA,IACA;AAAA,MACC,SAAS;AAAA,QACR,wBAAwB;AAAA,MACzB;AAAA,MACA,OAAO,QAAQ;AAAA,MACf,MAAM,QAAQ;AAAA,IACf;AAAA,EACD;AAEA,aAAW,WAAW,eAAe;AACpC,UAAM,sBAAsB;AAAA,MAC3B;AAAA,MACA,QAAQ;AAAA,IACT;AAGA,QAAI,CAAC,oBAAoB,QAAQ;AAChC,YAAM,QAAQ,QAAQ,qCAAqC;AAAA,QAC1D,OAAO,QAAQ,MAAM,QAAQ,KAAK,EAAE;AAAA,QACpC,aAAa,QAAQ;AAAA,QACrB,SAAS;AAAA,UACR,wBAAwB;AAAA,QACzB;AAAA,QACA,MAAM,QAAQ;AAAA,QACd,OAAO,QAAQ;AAAA,QACf,MAAM,QAAQ;AAAA,MACf,CAAC;AACD;AAAA,IACD;AAEA,eAAW,sBAAsB,qBAAqB;AAGrD,UACC,mBAAmB,SAAS,QAAQ,QACpC,eAAe,KAAK,CAAC,aAAa,SAAS,SAAS,QAAQ,IAAI,GAC/D;AACD,cAAM,QAAQ,QAAQ,8CAA8C;AAAA,UACnE,SAAS;AAAA,YACR,wBAAwB;AAAA,UACzB;AAAA,UACA,MAAM,mBAAmB;AAAA,UACzB,OAAO,QAAQ;AAAA,UACf,MAAM,QAAQ;AAAA,QACf,CAAC;AAED;AAAA,MACD;AAKA,UACC,QAAQ,UAAU,mBAAmB,SACrC,QAAQ,gBAAgB,mBAAmB,eAC3C,QAAQ,SAAS,mBAAmB,MACnC;AACD,cAAM,QAAQ,QAAQ,6CAA6C;AAAA,UAClE,OAAO,QAAQ,MAAM,QAAQ,KAAK,EAAE;AAAA,UACpC,aAAa,QAAQ;AAAA,UACrB,SAAS;AAAA,YACR,wBAAwB;AAAA,UACzB;AAAA,UACA,MAAM,mBAAmB;AAAA,UACzB,UAAU,QAAQ;AAAA,UAClB,OAAO,QAAQ;AAAA,UACf,MAAM,QAAQ;AAAA,QACf,CAAC;AAAA,MACF;AAAA,IACD;AAAA,EACD;AACD;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-typescript-app",
3
- "version": "1.70.0",
3
+ "version": "1.71.0",
4
4
  "description": "Quickstart-friendly TypeScript template with comprehensive, configurable, opinionated tooling. 💝",
5
5
  "repository": {
6
6
  "type": "git",
@@ -98,7 +98,7 @@
98
98
  "release-it": "^17.6.0",
99
99
  "sentences-per-line": "^0.2.1",
100
100
  "tsup": "^8.2.4",
101
- "tsx": "^4.16.5",
101
+ "tsx": "^4.17.0",
102
102
  "typescript": "^5.5.4",
103
103
  "typescript-eslint": "^8.0.1",
104
104
  "vitest": "^2.0.5"