create-typescript-app 1.29.20 → 1.29.22

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 (47) hide show
  1. package/lib/bin/index.d.ts +3 -1
  2. package/lib/bin/index.js +18 -8
  3. package/lib/bin/index.js.map +1 -1
  4. package/lib/bin/mode.d.ts +10 -2
  5. package/lib/bin/mode.js +2 -2
  6. package/lib/bin/mode.js.map +1 -1
  7. package/lib/create/createAndEnterRepository.d.ts +3 -0
  8. package/lib/create/createAndEnterRepository.js +15 -0
  9. package/lib/create/createAndEnterRepository.js.map +1 -0
  10. package/lib/create/createRerunSuggestion.d.ts +2 -1
  11. package/lib/create/createRerunSuggestion.js.map +1 -1
  12. package/lib/create/index.d.ts +5 -1
  13. package/lib/create/index.js +45 -44
  14. package/lib/create/index.js.map +1 -1
  15. package/lib/initialize/index.d.ts +5 -1
  16. package/lib/initialize/index.js +31 -21
  17. package/lib/initialize/index.js.map +1 -1
  18. package/lib/migrate/index.d.ts +5 -1
  19. package/lib/migrate/index.js +28 -18
  20. package/lib/migrate/index.js.map +1 -1
  21. package/lib/shared/codes.d.ts +8 -0
  22. package/lib/shared/codes.js +9 -0
  23. package/lib/shared/codes.js.map +1 -0
  24. package/lib/shared/options/augmentOptionsWithExcludes.d.ts +1 -1
  25. package/lib/shared/options/augmentOptionsWithExcludes.js +5 -3
  26. package/lib/shared/options/augmentOptionsWithExcludes.js.map +1 -1
  27. package/lib/shared/options/ensureRepositoryExists.d.ts +1 -1
  28. package/lib/shared/options/ensureRepositoryExists.js +7 -5
  29. package/lib/shared/options/ensureRepositoryExists.js.map +1 -1
  30. package/lib/shared/options/getPrefillOrPromptedOption.d.ts +1 -1
  31. package/lib/shared/options/getPrefillOrPromptedOption.js +2 -2
  32. package/lib/shared/options/getPrefillOrPromptedOption.js.map +1 -1
  33. package/lib/shared/options/readOptions.d.ts +10 -2
  34. package/lib/shared/options/readOptions.js +84 -49
  35. package/lib/shared/options/readOptions.js.map +1 -1
  36. package/lib/shared/prompts.d.ts +2 -3
  37. package/lib/shared/prompts.js +3 -11
  38. package/lib/shared/prompts.js.map +1 -1
  39. package/lib/shared/runOrRestore.d.ts +1 -1
  40. package/lib/shared/runOrRestore.js +11 -16
  41. package/lib/shared/runOrRestore.js.map +1 -1
  42. package/lib/steps/writing/creation/writePackageJson.js +1 -1
  43. package/lib/steps/writing/creation/writePackageJson.js.map +1 -1
  44. package/package.json +2 -2
  45. package/lib/shared/options/optionalDefault.d.ts +0 -3
  46. package/lib/shared/options/optionalDefault.js +0 -13
  47. package/lib/shared/options/optionalDefault.js.map +0 -1
@@ -1,3 +1,5 @@
1
- declare function bin(args: string[]): Promise<1 | 0 | undefined>;
1
+ import { StatusCode } from '../shared/codes.js';
2
+
3
+ declare function bin(args: string[]): Promise<StatusCode>;
2
4
 
3
5
  export { bin };
package/lib/bin/index.js CHANGED
@@ -1,11 +1,14 @@
1
1
  import * as prompts from "@clack/prompts";
2
2
  import chalk from "chalk";
3
3
  import { parseArgs } from "node:util";
4
+ import { createRerunSuggestion } from "../create/createRerunSuggestion.js";
4
5
  import { create } from "../create/index.js";
5
6
  import { initialize } from "../initialize/index.js";
6
7
  import { migrate } from "../migrate/index.js";
7
8
  import { logLine } from "../shared/cli/lines.js";
9
+ import { StatusCodes } from "../shared/codes.js";
8
10
  import { promptForMode } from "./mode.js";
11
+ const operationMessage = (verb) => `Operation ${verb}. Exiting - maybe another time? \u{1F44B}`;
9
12
  async function bin(args) {
10
13
  console.clear();
11
14
  prompts.intro(
@@ -34,17 +37,24 @@ async function bin(args) {
34
37
  strict: false
35
38
  });
36
39
  const mode = await promptForMode(values.mode);
37
- if (mode instanceof Error) {
38
- prompts.outro(chalk.red(mode.message));
40
+ if (typeof mode !== "string") {
41
+ prompts.outro(chalk.red(mode?.message ?? operationMessage("cancelled")));
39
42
  return 1;
40
43
  }
41
- logLine();
42
- logLine(
43
- chalk.blue(
44
- "Let's collect some information to fill out repository details..."
45
- )
44
+ const { code, options } = await { create, initialize, migrate }[mode](args);
45
+ prompts.log.info(
46
+ [
47
+ chalk.italic(`Tip: to run again with the same input values, use:`),
48
+ chalk.blue(createRerunSuggestion(mode, options))
49
+ ].join(" ")
46
50
  );
47
- return await { create, initialize, migrate }[mode](args);
51
+ if (code) {
52
+ logLine();
53
+ prompts.cancel(
54
+ code === StatusCodes.Cancelled ? operationMessage("cancelled") : operationMessage("failed")
55
+ );
56
+ }
57
+ return code;
48
58
  }
49
59
  export {
50
60
  bin
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/bin/index.ts"],"sourcesContent":["import * as prompts from \"@clack/prompts\";\nimport chalk from \"chalk\";\nimport { parseArgs } from \"node:util\";\n\nimport { create } from \"../create/index.js\";\nimport { initialize } from \"../initialize/index.js\";\nimport { migrate } from \"../migrate/index.js\";\nimport { logLine } from \"../shared/cli/lines.js\";\nimport { promptForMode } from \"./mode.js\";\n\nexport async function bin(args: string[]) {\n\tconsole.clear();\n\n\tprompts.intro(\n\t\t[\n\t\t\tchalk.greenBright(`Welcome to`),\n\t\t\tchalk.bgGreenBright.black(`create-typescript-app`),\n\t\t\tchalk.greenBright(`! 🎉`),\n\t\t].join(\" \"),\n\t);\n\n\tlogLine();\n\tlogLine(\n\t\tchalk.yellow(\n\t\t\t\"⚠️ This template is early stage, opinionated, and not endorsed by the TypeScript team. ⚠️\",\n\t\t),\n\t);\n\tlogLine(\n\t\tchalk.yellow(\n\t\t\t\"⚠️ If any tooling it sets displeases you, you can always remove that portion manually. ⚠️\",\n\t\t),\n\t);\n\n\tconst { values } = parseArgs({\n\t\targs,\n\t\toptions: {\n\t\t\tmode: { type: \"string\" },\n\t\t},\n\t\tstrict: false,\n\t});\n\n\tconst mode = await promptForMode(values.mode);\n\tif (mode instanceof Error) {\n\t\tprompts.outro(chalk.red(mode.message));\n\t\treturn 1;\n\t}\n\n\tlogLine();\n\tlogLine(\n\t\tchalk.blue(\n\t\t\t\"Let's collect some information to fill out repository details...\",\n\t\t),\n\t);\n\n\treturn await { create, initialize, migrate }[mode](args);\n}\n"],"mappings":"AAAA,YAAY,aAAa;AACzB,OAAO,WAAW;AAClB,SAAS,iBAAiB;AAE1B,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAE9B,eAAsB,IAAI,MAAgB;AACzC,UAAQ,MAAM;AAEd,UAAQ;AAAA,IACP;AAAA,MACC,MAAM,YAAY,YAAY;AAAA,MAC9B,MAAM,cAAc,MAAM,uBAAuB;AAAA,MACjD,MAAM,YAAY,aAAM;AAAA,IACzB,EAAE,KAAK,GAAG;AAAA,EACX;AAEA,UAAQ;AACR;AAAA,IACC,MAAM;AAAA,MACL;AAAA,IACD;AAAA,EACD;AACA;AAAA,IACC,MAAM;AAAA,MACL;AAAA,IACD;AAAA,EACD;AAEA,QAAM,EAAE,OAAO,IAAI,UAAU;AAAA,IAC5B;AAAA,IACA,SAAS;AAAA,MACR,MAAM,EAAE,MAAM,SAAS;AAAA,IACxB;AAAA,IACA,QAAQ;AAAA,EACT,CAAC;AAED,QAAM,OAAO,MAAM,cAAc,OAAO,IAAI;AAC5C,MAAI,gBAAgB,OAAO;AAC1B,YAAQ,MAAM,MAAM,IAAI,KAAK,OAAO,CAAC;AACrC,WAAO;AAAA,EACR;AAEA,UAAQ;AACR;AAAA,IACC,MAAM;AAAA,MACL;AAAA,IACD;AAAA,EACD;AAEA,SAAO,MAAM,EAAE,QAAQ,YAAY,QAAQ,EAAE,IAAI,EAAE,IAAI;AACxD;","names":[]}
1
+ {"version":3,"sources":["../../src/bin/index.ts"],"sourcesContent":["import * as prompts from \"@clack/prompts\";\nimport chalk from \"chalk\";\nimport { parseArgs } from \"node:util\";\n\nimport { createRerunSuggestion } from \"../create/createRerunSuggestion.js\";\nimport { create } from \"../create/index.js\";\nimport { initialize } from \"../initialize/index.js\";\nimport { migrate } from \"../migrate/index.js\";\nimport { logLine } from \"../shared/cli/lines.js\";\nimport { StatusCodes } from \"../shared/codes.js\";\nimport { promptForMode } from \"./mode.js\";\n\nconst operationMessage = (verb: string) =>\n\t`Operation ${verb}. Exiting - maybe another time? 👋`;\n\nexport async function bin(args: string[]) {\n\tconsole.clear();\n\n\tprompts.intro(\n\t\t[\n\t\t\tchalk.greenBright(`Welcome to`),\n\t\t\tchalk.bgGreenBright.black(`create-typescript-app`),\n\t\t\tchalk.greenBright(`! 🎉`),\n\t\t].join(\" \"),\n\t);\n\n\tlogLine();\n\tlogLine(\n\t\tchalk.yellow(\n\t\t\t\"⚠️ This template is early stage, opinionated, and not endorsed by the TypeScript team. ⚠️\",\n\t\t),\n\t);\n\tlogLine(\n\t\tchalk.yellow(\n\t\t\t\"⚠️ If any tooling it sets displeases you, you can always remove that portion manually. ⚠️\",\n\t\t),\n\t);\n\n\tconst { values } = parseArgs({\n\t\targs,\n\t\toptions: {\n\t\t\tmode: { type: \"string\" },\n\t\t},\n\t\tstrict: false,\n\t});\n\n\tconst mode = await promptForMode(values.mode);\n\tif (typeof mode !== \"string\") {\n\t\tprompts.outro(chalk.red(mode?.message ?? operationMessage(\"cancelled\")));\n\t\treturn 1;\n\t}\n\n\tconst { code, options } = await { create, initialize, migrate }[mode](args);\n\n\tprompts.log.info(\n\t\t[\n\t\t\tchalk.italic(`Tip: to run again with the same input values, use:`),\n\t\t\tchalk.blue(createRerunSuggestion(mode, options)),\n\t\t].join(\" \"),\n\t);\n\n\tif (code) {\n\t\tlogLine();\n\t\tprompts.cancel(\n\t\t\tcode === StatusCodes.Cancelled\n\t\t\t\t? operationMessage(\"cancelled\")\n\t\t\t\t: operationMessage(\"failed\"),\n\t\t);\n\t}\n\n\treturn code;\n}\n"],"mappings":"AAAA,YAAY,aAAa;AACzB,OAAO,WAAW;AAClB,SAAS,iBAAiB;AAE1B,SAAS,6BAA6B;AACtC,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAE9B,MAAM,mBAAmB,CAAC,SACzB,aAAa,IAAI;AAElB,eAAsB,IAAI,MAAgB;AACzC,UAAQ,MAAM;AAEd,UAAQ;AAAA,IACP;AAAA,MACC,MAAM,YAAY,YAAY;AAAA,MAC9B,MAAM,cAAc,MAAM,uBAAuB;AAAA,MACjD,MAAM,YAAY,aAAM;AAAA,IACzB,EAAE,KAAK,GAAG;AAAA,EACX;AAEA,UAAQ;AACR;AAAA,IACC,MAAM;AAAA,MACL;AAAA,IACD;AAAA,EACD;AACA;AAAA,IACC,MAAM;AAAA,MACL;AAAA,IACD;AAAA,EACD;AAEA,QAAM,EAAE,OAAO,IAAI,UAAU;AAAA,IAC5B;AAAA,IACA,SAAS;AAAA,MACR,MAAM,EAAE,MAAM,SAAS;AAAA,IACxB;AAAA,IACA,QAAQ;AAAA,EACT,CAAC;AAED,QAAM,OAAO,MAAM,cAAc,OAAO,IAAI;AAC5C,MAAI,OAAO,SAAS,UAAU;AAC7B,YAAQ,MAAM,MAAM,IAAI,MAAM,WAAW,iBAAiB,WAAW,CAAC,CAAC;AACvE,WAAO;AAAA,EACR;AAEA,QAAM,EAAE,MAAM,QAAQ,IAAI,MAAM,EAAE,QAAQ,YAAY,QAAQ,EAAE,IAAI,EAAE,IAAI;AAE1E,UAAQ,IAAI;AAAA,IACX;AAAA,MACC,MAAM,OAAO,oDAAoD;AAAA,MACjE,MAAM,KAAK,sBAAsB,MAAM,OAAO,CAAC;AAAA,IAChD,EAAE,KAAK,GAAG;AAAA,EACX;AAEA,MAAI,MAAM;AACT,YAAQ;AACR,YAAQ;AAAA,MACP,SAAS,YAAY,YAClB,iBAAiB,WAAW,IAC5B,iBAAiB,QAAQ;AAAA,IAC7B;AAAA,EACD;AAEA,SAAO;AACR;","names":[]}
package/lib/bin/mode.d.ts CHANGED
@@ -1,4 +1,12 @@
1
+ import { StatusCode } from '../shared/codes.js';
2
+ import { Options } from '../shared/types.js';
3
+
4
+ interface ModeResult {
5
+ code: StatusCode;
6
+ options: Partial<Options>;
7
+ }
8
+ type ModeRunner = (args: string[]) => Promise<ModeResult>;
1
9
  type Mode = "create" | "initialize" | "migrate";
2
- declare function promptForMode(input: boolean | string | undefined): Promise<Error | Mode>;
10
+ declare function promptForMode(input: boolean | string | undefined): Promise<Mode | Error | undefined>;
3
11
 
4
- export { Mode, promptForMode };
12
+ export { Mode, ModeResult, ModeRunner, promptForMode };
package/lib/bin/mode.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as prompts from "@clack/prompts";
2
2
  import chalk from "chalk";
3
- import { handlePromptCancel } from "../shared/prompts.js";
3
+ import { filterPromptCancel } from "../shared/prompts.js";
4
4
  const allowedModes = ["create", "initialize", "migrate"];
5
5
  function isMode(input) {
6
6
  return allowedModes.includes(input);
@@ -16,7 +16,7 @@ async function promptForMode(input) {
16
16
  }
17
17
  return input;
18
18
  }
19
- const selection = handlePromptCancel(
19
+ const selection = filterPromptCancel(
20
20
  await prompts.select({
21
21
  message: chalk.blue("How would you like to use the template?"),
22
22
  options: [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/bin/mode.ts"],"sourcesContent":["import * as prompts from \"@clack/prompts\";\nimport chalk from \"chalk\";\n\nimport { handlePromptCancel } from \"../shared/prompts.js\";\n\nexport type Mode = \"create\" | \"initialize\" | \"migrate\";\n\nconst allowedModes = [\"create\", \"initialize\", \"migrate\"] satisfies Mode[];\n\nfunction isMode(input: boolean | string): input is Mode {\n\treturn allowedModes.includes(input as Mode);\n}\n\nexport async function promptForMode(\n\tinput: boolean | string | undefined,\n): Promise<Error | Mode> {\n\tif (input) {\n\t\tif (!isMode(input)) {\n\t\t\treturn new Error(\n\t\t\t\t`Unknown --mode: ${input}. Allowed modes are: ${allowedModes.join(\n\t\t\t\t\t\", \",\n\t\t\t\t)}.`,\n\t\t\t);\n\t\t}\n\n\t\treturn input;\n\t}\n\n\tconst selection = handlePromptCancel(\n\t\t(await prompts.select({\n\t\t\tmessage: chalk.blue(\"How would you like to use the template?\"),\n\t\t\toptions: [\n\t\t\t\t{\n\t\t\t\t\tlabel: \"--create a new repository in a child directory\",\n\t\t\t\t\tvalue: \"create\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: \"--initialize a freshly repository in the current directory\",\n\t\t\t\t\tvalue: \"initialize\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: \"--migrate an existing repository in the current directory\",\n\t\t\t\t\tvalue: \"migrate\",\n\t\t\t\t},\n\t\t\t],\n\t\t})) as Mode | symbol,\n\t);\n\n\treturn selection;\n}\n"],"mappings":"AAAA,YAAY,aAAa;AACzB,OAAO,WAAW;AAElB,SAAS,0BAA0B;AAInC,MAAM,eAAe,CAAC,UAAU,cAAc,SAAS;AAEvD,SAAS,OAAO,OAAwC;AACvD,SAAO,aAAa,SAAS,KAAa;AAC3C;AAEA,eAAsB,cACrB,OACwB;AACxB,MAAI,OAAO;AACV,QAAI,CAAC,OAAO,KAAK,GAAG;AACnB,aAAO,IAAI;AAAA,QACV,mBAAmB,KAAK,wBAAwB,aAAa;AAAA,UAC5D;AAAA,QACD,CAAC;AAAA,MACF;AAAA,IACD;AAEA,WAAO;AAAA,EACR;AAEA,QAAM,YAAY;AAAA,IAChB,MAAM,QAAQ,OAAO;AAAA,MACrB,SAAS,MAAM,KAAK,yCAAyC;AAAA,MAC7D,SAAS;AAAA,QACR;AAAA,UACC,OAAO;AAAA,UACP,OAAO;AAAA,QACR;AAAA,QACA;AAAA,UACC,OAAO;AAAA,UACP,OAAO;AAAA,QACR;AAAA,QACA;AAAA,UACC,OAAO;AAAA,UACP,OAAO;AAAA,QACR;AAAA,MACD;AAAA,IACD,CAAC;AAAA,EACF;AAEA,SAAO;AACR;","names":[]}
1
+ {"version":3,"sources":["../../src/bin/mode.ts"],"sourcesContent":["import * as prompts from \"@clack/prompts\";\nimport chalk from \"chalk\";\n\nimport { StatusCode } from \"../shared/codes.js\";\nimport { filterPromptCancel } from \"../shared/prompts.js\";\nimport { Options } from \"../shared/types.js\";\n\nexport interface ModeResult {\n\tcode: StatusCode;\n\toptions: Partial<Options>;\n}\n\nexport type ModeRunner = (args: string[]) => Promise<ModeResult>;\n\nexport type Mode = \"create\" | \"initialize\" | \"migrate\";\n\nconst allowedModes = [\"create\", \"initialize\", \"migrate\"] satisfies Mode[];\n\nfunction isMode(input: boolean | string): input is Mode {\n\treturn allowedModes.includes(input as Mode);\n}\n\nexport async function promptForMode(input: boolean | string | undefined) {\n\tif (input) {\n\t\tif (!isMode(input)) {\n\t\t\treturn new Error(\n\t\t\t\t`Unknown --mode: ${input}. Allowed modes are: ${allowedModes.join(\n\t\t\t\t\t\", \",\n\t\t\t\t)}.`,\n\t\t\t);\n\t\t}\n\n\t\treturn input;\n\t}\n\n\tconst selection = filterPromptCancel(\n\t\t(await prompts.select({\n\t\t\tmessage: chalk.blue(\"How would you like to use the template?\"),\n\t\t\toptions: [\n\t\t\t\t{\n\t\t\t\t\tlabel: \"--create a new repository in a child directory\",\n\t\t\t\t\tvalue: \"create\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: \"--initialize a freshly repository in the current directory\",\n\t\t\t\t\tvalue: \"initialize\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: \"--migrate an existing repository in the current directory\",\n\t\t\t\t\tvalue: \"migrate\",\n\t\t\t\t},\n\t\t\t],\n\t\t})) as Mode | symbol,\n\t);\n\n\treturn selection;\n}\n"],"mappings":"AAAA,YAAY,aAAa;AACzB,OAAO,WAAW;AAGlB,SAAS,0BAA0B;AAYnC,MAAM,eAAe,CAAC,UAAU,cAAc,SAAS;AAEvD,SAAS,OAAO,OAAwC;AACvD,SAAO,aAAa,SAAS,KAAa;AAC3C;AAEA,eAAsB,cAAc,OAAqC;AACxE,MAAI,OAAO;AACV,QAAI,CAAC,OAAO,KAAK,GAAG;AACnB,aAAO,IAAI;AAAA,QACV,mBAAmB,KAAK,wBAAwB,aAAa;AAAA,UAC5D;AAAA,QACD,CAAC;AAAA,MACF;AAAA,IACD;AAEA,WAAO;AAAA,EACR;AAEA,QAAM,YAAY;AAAA,IAChB,MAAM,QAAQ,OAAO;AAAA,MACrB,SAAS,MAAM,KAAK,yCAAyC;AAAA,MAC7D,SAAS;AAAA,QACR;AAAA,UACC,OAAO;AAAA,UACP,OAAO;AAAA,QACR;AAAA,QACA;AAAA,UACC,OAAO;AAAA,UACP,OAAO;AAAA,QACR;AAAA,QACA;AAAA,UACC,OAAO;AAAA,UACP,OAAO;AAAA,QACR;AAAA,MACD;AAAA,IACD,CAAC;AAAA,EACF;AAEA,SAAO;AACR;","names":[]}
@@ -0,0 +1,3 @@
1
+ declare function createAndEnterRepository(repository: string): Promise<boolean>;
2
+
3
+ export { createAndEnterRepository };
@@ -0,0 +1,15 @@
1
+ import { $ } from "execa";
2
+ import fs from "node:fs/promises";
3
+ async function createAndEnterRepository(repository) {
4
+ if ((await fs.readdir(".")).includes(repository)) {
5
+ return false;
6
+ }
7
+ await fs.mkdir(repository);
8
+ process.chdir(repository);
9
+ await $`git init`;
10
+ return true;
11
+ }
12
+ export {
13
+ createAndEnterRepository
14
+ };
15
+ //# sourceMappingURL=createAndEnterRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/create/createAndEnterRepository.ts"],"sourcesContent":["import { $ } from \"execa\";\nimport fs from \"node:fs/promises\";\n\nexport async function createAndEnterRepository(repository: string) {\n\tif ((await fs.readdir(\".\")).includes(repository)) {\n\t\treturn false;\n\t}\n\n\tawait fs.mkdir(repository);\n\tprocess.chdir(repository);\n\tawait $`git init`;\n\n\treturn true;\n}\n"],"mappings":"AAAA,SAAS,SAAS;AAClB,OAAO,QAAQ;AAEf,eAAsB,yBAAyB,YAAoB;AAClE,OAAK,MAAM,GAAG,QAAQ,GAAG,GAAG,SAAS,UAAU,GAAG;AACjD,WAAO;AAAA,EACR;AAEA,QAAM,GAAG,MAAM,UAAU;AACzB,UAAQ,MAAM,UAAU;AACxB,QAAM;AAEN,SAAO;AACR;","names":[]}
@@ -1,6 +1,7 @@
1
1
  import { Mode } from '../bin/mode.js';
2
2
  import { Options } from '../shared/types.js';
3
+ import '../shared/codes.js';
3
4
 
4
- declare function createRerunSuggestion(mode: Mode, options: Options): string;
5
+ declare function createRerunSuggestion(mode: Mode, options: Partial<Options>): string;
5
6
 
6
7
  export { createRerunSuggestion };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/create/createRerunSuggestion.ts"],"sourcesContent":["import { Mode } from \"../bin/mode.js\";\nimport { allArgOptions } from \"../shared/options/args.js\";\nimport { Options } from \"../shared/types.js\";\n\nfunction getFirstMatchingArg(key: string) {\n\treturn Object.keys(allArgOptions).find(\n\t\t(arg) => arg.replaceAll(\"-\", \"\") === key.toLowerCase(),\n\t);\n}\n\nexport function createRerunSuggestion(mode: Mode, options: Options): string {\n\tconst args = Object.entries(options)\n\t\t.filter(([, value]) => !!value)\n\t\t.map(([key, value]) => {\n\t\t\tconst valueStringified = `${value}`;\n\t\t\treturn `--${getFirstMatchingArg(key)} ${\n\t\t\t\tvalueStringified.includes(\" \") ? `\"${value}\"` : value\n\t\t\t}`;\n\t\t})\n\t\t.join(\" \");\n\n\treturn `npx create-typescript-app --mode ${mode} ${args}`;\n}\n"],"mappings":"AACA,SAAS,qBAAqB;AAG9B,SAAS,oBAAoB,KAAa;AACzC,SAAO,OAAO,KAAK,aAAa,EAAE;AAAA,IACjC,CAAC,QAAQ,IAAI,WAAW,KAAK,EAAE,MAAM,IAAI,YAAY;AAAA,EACtD;AACD;AAEO,SAAS,sBAAsB,MAAY,SAA0B;AAC3E,QAAM,OAAO,OAAO,QAAQ,OAAO,EACjC,OAAO,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC,KAAK,EAC7B,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AACtB,UAAM,mBAAmB,GAAG,KAAK;AACjC,WAAO,KAAK,oBAAoB,GAAG,CAAC,IACnC,iBAAiB,SAAS,GAAG,IAAI,IAAI,KAAK,MAAM,KACjD;AAAA,EACD,CAAC,EACA,KAAK,GAAG;AAEV,SAAO,oCAAoC,IAAI,IAAI,IAAI;AACxD;","names":[]}
1
+ {"version":3,"sources":["../../src/create/createRerunSuggestion.ts"],"sourcesContent":["import { Mode } from \"../bin/mode.js\";\nimport { allArgOptions } from \"../shared/options/args.js\";\nimport { Options } from \"../shared/types.js\";\n\nfunction getFirstMatchingArg(key: string) {\n\treturn Object.keys(allArgOptions).find(\n\t\t(arg) => arg.replaceAll(\"-\", \"\") === key.toLowerCase(),\n\t);\n}\n\nexport function createRerunSuggestion(\n\tmode: Mode,\n\toptions: Partial<Options>,\n): string {\n\tconst args = Object.entries(options)\n\t\t.filter(([, value]) => !!value)\n\t\t.map(([key, value]) => {\n\t\t\tconst valueStringified = `${value}`;\n\t\t\treturn `--${getFirstMatchingArg(key)} ${\n\t\t\t\tvalueStringified.includes(\" \") ? `\"${value}\"` : value\n\t\t\t}`;\n\t\t})\n\t\t.join(\" \");\n\n\treturn `npx create-typescript-app --mode ${mode} ${args}`;\n}\n"],"mappings":"AACA,SAAS,qBAAqB;AAG9B,SAAS,oBAAoB,KAAa;AACzC,SAAO,OAAO,KAAK,aAAa,EAAE;AAAA,IACjC,CAAC,QAAQ,IAAI,WAAW,KAAK,EAAE,MAAM,IAAI,YAAY;AAAA,EACtD;AACD;AAEO,SAAS,sBACf,MACA,SACS;AACT,QAAM,OAAO,OAAO,QAAQ,OAAO,EACjC,OAAO,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC,KAAK,EAC7B,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AACtB,UAAM,mBAAmB,GAAG,KAAK;AACjC,WAAO,KAAK,oBAAoB,GAAG,CAAC,IACnC,iBAAiB,SAAS,GAAG,IAAI,IAAI,KAAK,MAAM,KACjD;AAAA,EACD,CAAC,EACA,KAAK,GAAG;AAEV,SAAO,oCAAoC,IAAI,IAAI,IAAI;AACxD;","names":[]}
@@ -1,3 +1,7 @@
1
- declare function create(args: string[]): Promise<1 | 0 | undefined>;
1
+ import { ModeResult } from '../bin/mode.js';
2
+ import '../shared/codes.js';
3
+ import '../shared/types.js';
4
+
5
+ declare function create(args: string[]): Promise<ModeResult>;
2
6
 
3
7
  export { create };
@@ -1,62 +1,63 @@
1
1
  import * as prompts from "@clack/prompts";
2
2
  import chalk from "chalk";
3
- import { $ } from "execa";
4
- import fs from "node:fs/promises";
5
3
  import { outro } from "../shared/cli/outro.js";
4
+ import { StatusCodes } from "../shared/codes.js";
6
5
  import { readOptions } from "../shared/options/readOptions.js";
7
6
  import { runOrRestore } from "../shared/runOrRestore.js";
7
+ import { createAndEnterRepository } from "./createAndEnterRepository.js";
8
8
  import { createRerunSuggestion } from "./createRerunSuggestion.js";
9
9
  import { createWithOptions } from "./createWithOptions.js";
10
10
  async function create(args) {
11
11
  const inputs = await readOptions(args);
12
- if (!await createAndEnterRepository(inputs.options.repository)) {
12
+ if (inputs.cancelled) {
13
+ return {
14
+ code: StatusCodes.Cancelled,
15
+ options: inputs.options
16
+ };
17
+ }
18
+ const wat = await createAndEnterRepository(inputs.options.repository);
19
+ if (!wat) {
13
20
  prompts.outro(
14
21
  chalk.red(
15
22
  `The ${inputs.options.repository} directory already exists. Please remove the directory or try a different name.`
16
23
  )
17
24
  );
18
- return;
19
- }
20
- return await runOrRestore({
21
- run: async () => {
22
- const { sentToGitHub } = await createWithOptions(inputs);
23
- outro(
24
- sentToGitHub ? [
25
- {
26
- label: "Now all you have to do is populate the repository's ACCESS_TOKEN and NPM_TOKEN secrets, and enable the Codecov and Renovate GitHub apps."
27
- }
28
- ] : [
29
- {
30
- label: "Consider creating a GitHub repository from the new directory:",
31
- lines: [
32
- `cd ${inputs.options.repository}`,
33
- createRerunSuggestion("initialize", {
34
- ...inputs.options,
35
- skipGitHubApi: false,
36
- skipInstall: false
37
- }),
38
- `git add -A`,
39
- `git commit -m "feat: initial commit \u2728"`,
40
- `git push -u origin main`
41
- ]
42
- },
43
- {
44
- label: "If you do, be sure to populate its ACCESS_TOKEN and NPM_TOKEN secrets, and enable the Codecov and Renovate GitHub apps."
45
- }
46
- ]
47
- );
48
- },
49
- skipRestore: inputs.options.skipRestore
50
- });
51
- }
52
- async function createAndEnterRepository(repository) {
53
- if ((await fs.readdir(".")).includes(repository)) {
54
- return false;
25
+ return { code: StatusCodes.Failure, options: inputs.options };
55
26
  }
56
- await fs.mkdir(repository);
57
- process.chdir(repository);
58
- await $`git init`;
59
- return true;
27
+ return {
28
+ code: await runOrRestore({
29
+ run: async () => {
30
+ const { sentToGitHub } = await createWithOptions(inputs);
31
+ outro(
32
+ sentToGitHub ? [
33
+ {
34
+ label: "Now all you have to do is populate the repository's ACCESS_TOKEN and NPM_TOKEN secrets, and enable the Codecov and Renovate GitHub apps."
35
+ }
36
+ ] : [
37
+ {
38
+ label: "Consider creating a GitHub repository from the new directory:",
39
+ lines: [
40
+ `cd ${inputs.options.repository}`,
41
+ createRerunSuggestion("initialize", {
42
+ ...inputs.options,
43
+ skipGitHubApi: false,
44
+ skipInstall: false
45
+ }),
46
+ `git add -A`,
47
+ `git commit -m "feat: initial commit \u2728"`,
48
+ `git push -u origin main`
49
+ ]
50
+ },
51
+ {
52
+ label: "If you do, be sure to populate its ACCESS_TOKEN and NPM_TOKEN secrets, and enable the Codecov and Renovate GitHub apps."
53
+ }
54
+ ]
55
+ );
56
+ },
57
+ skipRestore: inputs.options.skipRestore
58
+ }),
59
+ options: inputs.options
60
+ };
60
61
  }
61
62
  export {
62
63
  create
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/create/index.ts"],"sourcesContent":["import * as prompts from \"@clack/prompts\";\nimport chalk from \"chalk\";\nimport { $ } from \"execa\";\nimport fs from \"node:fs/promises\";\n\nimport { outro } from \"../shared/cli/outro.js\";\nimport { readOptions } from \"../shared/options/readOptions.js\";\nimport { runOrRestore } from \"../shared/runOrRestore.js\";\nimport { createRerunSuggestion } from \"./createRerunSuggestion.js\";\nimport { createWithOptions } from \"./createWithOptions.js\";\n\nexport async function create(args: string[]) {\n\tconst inputs = await readOptions(args);\n\n\tif (!(await createAndEnterRepository(inputs.options.repository))) {\n\t\tprompts.outro(\n\t\t\tchalk.red(\n\t\t\t\t`The ${inputs.options.repository} directory already exists. Please remove the directory or try a different name.`,\n\t\t\t),\n\t\t);\n\t\treturn;\n\t}\n\n\treturn await runOrRestore({\n\t\trun: async () => {\n\t\t\tconst { sentToGitHub } = await createWithOptions(inputs);\n\n\t\t\toutro(\n\t\t\t\tsentToGitHub\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel:\n\t\t\t\t\t\t\t\t\t\"Now all you have to do is populate the repository's ACCESS_TOKEN and NPM_TOKEN secrets, and enable the Codecov and Renovate GitHub apps.\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel:\n\t\t\t\t\t\t\t\t\t\"Consider creating a GitHub repository from the new directory:\",\n\t\t\t\t\t\t\t\tlines: [\n\t\t\t\t\t\t\t\t\t`cd ${inputs.options.repository}`,\n\t\t\t\t\t\t\t\t\tcreateRerunSuggestion(\"initialize\", {\n\t\t\t\t\t\t\t\t\t\t...inputs.options,\n\t\t\t\t\t\t\t\t\t\tskipGitHubApi: false,\n\t\t\t\t\t\t\t\t\t\tskipInstall: false,\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t`git add -A`,\n\t\t\t\t\t\t\t\t\t`git commit -m \"feat: initial commit ✨\"`,\n\t\t\t\t\t\t\t\t\t`git push -u origin main`,\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel:\n\t\t\t\t\t\t\t\t\t\"If you do, be sure to populate its ACCESS_TOKEN and NPM_TOKEN secrets, and enable the Codecov and Renovate GitHub apps.\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ],\n\t\t\t);\n\t\t},\n\t\tskipRestore: inputs.options.skipRestore,\n\t});\n}\n\nasync function createAndEnterRepository(repository: string) {\n\tif ((await fs.readdir(\".\")).includes(repository)) {\n\t\treturn false;\n\t}\n\n\tawait fs.mkdir(repository);\n\tprocess.chdir(repository);\n\tawait $`git init`;\n\n\treturn true;\n}\n"],"mappings":"AAAA,YAAY,aAAa;AACzB,OAAO,WAAW;AAClB,SAAS,SAAS;AAClB,OAAO,QAAQ;AAEf,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,6BAA6B;AACtC,SAAS,yBAAyB;AAElC,eAAsB,OAAO,MAAgB;AAC5C,QAAM,SAAS,MAAM,YAAY,IAAI;AAErC,MAAI,CAAE,MAAM,yBAAyB,OAAO,QAAQ,UAAU,GAAI;AACjE,YAAQ;AAAA,MACP,MAAM;AAAA,QACL,OAAO,OAAO,QAAQ,UAAU;AAAA,MACjC;AAAA,IACD;AACA;AAAA,EACD;AAEA,SAAO,MAAM,aAAa;AAAA,IACzB,KAAK,YAAY;AAChB,YAAM,EAAE,aAAa,IAAI,MAAM,kBAAkB,MAAM;AAEvD;AAAA,QACC,eACG;AAAA,UACA;AAAA,YACC,OACC;AAAA,UACF;AAAA,QACA,IACA;AAAA,UACA;AAAA,YACC,OACC;AAAA,YACD,OAAO;AAAA,cACN,MAAM,OAAO,QAAQ,UAAU;AAAA,cAC/B,sBAAsB,cAAc;AAAA,gBACnC,GAAG,OAAO;AAAA,gBACV,eAAe;AAAA,gBACf,aAAa;AAAA,cACd,CAAC;AAAA,cACD;AAAA,cACA;AAAA,cACA;AAAA,YACD;AAAA,UACD;AAAA,UACA;AAAA,YACC,OACC;AAAA,UACF;AAAA,QACA;AAAA,MACJ;AAAA,IACD;AAAA,IACA,aAAa,OAAO,QAAQ;AAAA,EAC7B,CAAC;AACF;AAEA,eAAe,yBAAyB,YAAoB;AAC3D,OAAK,MAAM,GAAG,QAAQ,GAAG,GAAG,SAAS,UAAU,GAAG;AACjD,WAAO;AAAA,EACR;AAEA,QAAM,GAAG,MAAM,UAAU;AACzB,UAAQ,MAAM,UAAU;AACxB,QAAM;AAEN,SAAO;AACR;","names":[]}
1
+ {"version":3,"sources":["../../src/create/index.ts"],"sourcesContent":["import * as prompts from \"@clack/prompts\";\nimport chalk from \"chalk\";\n\nimport { ModeResult } from \"../bin/mode.js\";\nimport { outro } from \"../shared/cli/outro.js\";\nimport { StatusCodes } from \"../shared/codes.js\";\nimport { readOptions } from \"../shared/options/readOptions.js\";\nimport { runOrRestore } from \"../shared/runOrRestore.js\";\nimport { createAndEnterRepository } from \"./createAndEnterRepository.js\";\nimport { createRerunSuggestion } from \"./createRerunSuggestion.js\";\nimport { createWithOptions } from \"./createWithOptions.js\";\n\nexport async function create(args: string[]): Promise<ModeResult> {\n\tconst inputs = await readOptions(args);\n\tif (inputs.cancelled) {\n\t\treturn {\n\t\t\tcode: StatusCodes.Cancelled,\n\t\t\toptions: inputs.options,\n\t\t};\n\t}\n\n\tconst wat = await createAndEnterRepository(inputs.options.repository);\n\tif (!wat) {\n\t\tprompts.outro(\n\t\t\tchalk.red(\n\t\t\t\t`The ${inputs.options.repository} directory already exists. Please remove the directory or try a different name.`,\n\t\t\t),\n\t\t);\n\t\treturn { code: StatusCodes.Failure, options: inputs.options };\n\t}\n\n\treturn {\n\t\tcode: await runOrRestore({\n\t\t\trun: async () => {\n\t\t\t\tconst { sentToGitHub } = await createWithOptions(inputs);\n\n\t\t\t\toutro(\n\t\t\t\t\tsentToGitHub\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlabel:\n\t\t\t\t\t\t\t\t\t\t\"Now all you have to do is populate the repository's ACCESS_TOKEN and NPM_TOKEN secrets, and enable the Codecov and Renovate GitHub apps.\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t ]\n\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlabel:\n\t\t\t\t\t\t\t\t\t\t\"Consider creating a GitHub repository from the new directory:\",\n\t\t\t\t\t\t\t\t\tlines: [\n\t\t\t\t\t\t\t\t\t\t`cd ${inputs.options.repository}`,\n\t\t\t\t\t\t\t\t\t\tcreateRerunSuggestion(\"initialize\", {\n\t\t\t\t\t\t\t\t\t\t\t...inputs.options,\n\t\t\t\t\t\t\t\t\t\t\tskipGitHubApi: false,\n\t\t\t\t\t\t\t\t\t\t\tskipInstall: false,\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\t`git add -A`,\n\t\t\t\t\t\t\t\t\t\t`git commit -m \"feat: initial commit ✨\"`,\n\t\t\t\t\t\t\t\t\t\t`git push -u origin main`,\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlabel:\n\t\t\t\t\t\t\t\t\t\t\"If you do, be sure to populate its ACCESS_TOKEN and NPM_TOKEN secrets, and enable the Codecov and Renovate GitHub apps.\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t ],\n\t\t\t\t);\n\t\t\t},\n\t\t\tskipRestore: inputs.options.skipRestore,\n\t\t}),\n\t\toptions: inputs.options,\n\t};\n}\n"],"mappings":"AAAA,YAAY,aAAa;AACzB,OAAO,WAAW;AAGlB,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,gCAAgC;AACzC,SAAS,6BAA6B;AACtC,SAAS,yBAAyB;AAElC,eAAsB,OAAO,MAAqC;AACjE,QAAM,SAAS,MAAM,YAAY,IAAI;AACrC,MAAI,OAAO,WAAW;AACrB,WAAO;AAAA,MACN,MAAM,YAAY;AAAA,MAClB,SAAS,OAAO;AAAA,IACjB;AAAA,EACD;AAEA,QAAM,MAAM,MAAM,yBAAyB,OAAO,QAAQ,UAAU;AACpE,MAAI,CAAC,KAAK;AACT,YAAQ;AAAA,MACP,MAAM;AAAA,QACL,OAAO,OAAO,QAAQ,UAAU;AAAA,MACjC;AAAA,IACD;AACA,WAAO,EAAE,MAAM,YAAY,SAAS,SAAS,OAAO,QAAQ;AAAA,EAC7D;AAEA,SAAO;AAAA,IACN,MAAM,MAAM,aAAa;AAAA,MACxB,KAAK,YAAY;AAChB,cAAM,EAAE,aAAa,IAAI,MAAM,kBAAkB,MAAM;AAEvD;AAAA,UACC,eACG;AAAA,YACA;AAAA,cACC,OACC;AAAA,YACF;AAAA,UACA,IACA;AAAA,YACA;AAAA,cACC,OACC;AAAA,cACD,OAAO;AAAA,gBACN,MAAM,OAAO,QAAQ,UAAU;AAAA,gBAC/B,sBAAsB,cAAc;AAAA,kBACnC,GAAG,OAAO;AAAA,kBACV,eAAe;AAAA,kBACf,aAAa;AAAA,gBACd,CAAC;AAAA,gBACD;AAAA,gBACA;AAAA,gBACA;AAAA,cACD;AAAA,YACD;AAAA,YACA;AAAA,cACC,OACC;AAAA,YACF;AAAA,UACA;AAAA,QACJ;AAAA,MACD;AAAA,MACA,aAAa,OAAO,QAAQ;AAAA,IAC7B,CAAC;AAAA,IACD,SAAS,OAAO;AAAA,EACjB;AACD;","names":[]}
@@ -1,3 +1,7 @@
1
- declare function initialize(args: string[]): Promise<1 | 0>;
1
+ import { ModeRunner } from '../bin/mode.js';
2
+ import '../shared/codes.js';
3
+ import '../shared/types.js';
4
+
5
+ declare const initialize: ModeRunner;
2
6
 
3
7
  export { initialize };
@@ -1,31 +1,41 @@
1
1
  import { outro } from "../shared/cli/outro.js";
2
+ import { StatusCodes } from "../shared/codes.js";
2
3
  import { ensureGitRepository } from "../shared/ensureGitRepository.js";
3
4
  import { readOptions } from "../shared/options/readOptions.js";
4
5
  import { runOrRestore } from "../shared/runOrRestore.js";
5
6
  import { initializeWithOptions } from "./initializeWithOptions.js";
6
- async function initialize(args) {
7
+ const initialize = async (args) => {
7
8
  const inputs = await readOptions(args);
9
+ if (inputs.cancelled) {
10
+ return {
11
+ code: StatusCodes.Cancelled,
12
+ options: inputs.options
13
+ };
14
+ }
8
15
  await ensureGitRepository();
9
- return await runOrRestore({
10
- run: async () => {
11
- await initializeWithOptions(inputs);
12
- outro([
13
- {
14
- label: "You may consider committing these changes:",
15
- lines: [
16
- `git add -A`,
17
- `git commit -m "feat: initialized repo \u2728`,
18
- `git push`
19
- ]
20
- },
21
- {
22
- label: "Otherwise, all you have to do is populate the repository's ACCESS_TOKEN and NPM_TOKEN secrets, and enable the Codecov and Renovate GitHub apps."
23
- }
24
- ]);
25
- },
26
- skipRestore: inputs.options.skipRestore
27
- });
28
- }
16
+ return {
17
+ code: await runOrRestore({
18
+ run: async () => {
19
+ await initializeWithOptions(inputs);
20
+ outro([
21
+ {
22
+ label: "You may consider committing these changes:",
23
+ lines: [
24
+ `git add -A`,
25
+ `git commit -m "feat: initialized repo \u2728`,
26
+ `git push`
27
+ ]
28
+ },
29
+ {
30
+ label: "Otherwise, all you have to do is populate the repository's ACCESS_TOKEN and NPM_TOKEN secrets, and enable the Codecov and Renovate GitHub apps."
31
+ }
32
+ ]);
33
+ },
34
+ skipRestore: inputs.options.skipRestore
35
+ }),
36
+ options: inputs.options
37
+ };
38
+ };
29
39
  export {
30
40
  initialize
31
41
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/initialize/index.ts"],"sourcesContent":["import { outro } from \"../shared/cli/outro.js\";\nimport { ensureGitRepository } from \"../shared/ensureGitRepository.js\";\nimport { readOptions } from \"../shared/options/readOptions.js\";\nimport { runOrRestore } from \"../shared/runOrRestore.js\";\nimport { initializeWithOptions } from \"./initializeWithOptions.js\";\n\nexport async function initialize(args: string[]) {\n\tconst inputs = await readOptions(args);\n\n\tawait ensureGitRepository();\n\n\treturn await runOrRestore({\n\t\trun: async () => {\n\t\t\tawait initializeWithOptions(inputs);\n\n\t\t\toutro([\n\t\t\t\t{\n\t\t\t\t\tlabel: \"You may consider committing these changes:\",\n\t\t\t\t\tlines: [\n\t\t\t\t\t\t`git add -A`,\n\t\t\t\t\t\t`git commit -m \"feat: initialized repo ✨`,\n\t\t\t\t\t\t`git push`,\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel:\n\t\t\t\t\t\t\"Otherwise, all you have to do is populate the repository's ACCESS_TOKEN and NPM_TOKEN secrets, and enable the Codecov and Renovate GitHub apps.\",\n\t\t\t\t},\n\t\t\t]);\n\t\t},\n\t\tskipRestore: inputs.options.skipRestore,\n\t});\n}\n"],"mappings":"AAAA,SAAS,aAAa;AACtB,SAAS,2BAA2B;AACpC,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,6BAA6B;AAEtC,eAAsB,WAAW,MAAgB;AAChD,QAAM,SAAS,MAAM,YAAY,IAAI;AAErC,QAAM,oBAAoB;AAE1B,SAAO,MAAM,aAAa;AAAA,IACzB,KAAK,YAAY;AAChB,YAAM,sBAAsB,MAAM;AAElC,YAAM;AAAA,QACL;AAAA,UACC,OAAO;AAAA,UACP,OAAO;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,UACD;AAAA,QACD;AAAA,QACA;AAAA,UACC,OACC;AAAA,QACF;AAAA,MACD,CAAC;AAAA,IACF;AAAA,IACA,aAAa,OAAO,QAAQ;AAAA,EAC7B,CAAC;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/initialize/index.ts"],"sourcesContent":["import { ModeRunner } from \"../bin/mode.js\";\nimport { outro } from \"../shared/cli/outro.js\";\nimport { StatusCodes } from \"../shared/codes.js\";\nimport { ensureGitRepository } from \"../shared/ensureGitRepository.js\";\nimport { readOptions } from \"../shared/options/readOptions.js\";\nimport { runOrRestore } from \"../shared/runOrRestore.js\";\nimport { initializeWithOptions } from \"./initializeWithOptions.js\";\n\nexport const initialize: ModeRunner = async (args) => {\n\tconst inputs = await readOptions(args);\n\tif (inputs.cancelled) {\n\t\treturn {\n\t\t\tcode: StatusCodes.Cancelled,\n\t\t\toptions: inputs.options,\n\t\t};\n\t}\n\n\tawait ensureGitRepository();\n\n\treturn {\n\t\tcode: await runOrRestore({\n\t\t\trun: async () => {\n\t\t\t\tawait initializeWithOptions(inputs);\n\n\t\t\t\toutro([\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: \"You may consider committing these changes:\",\n\t\t\t\t\t\tlines: [\n\t\t\t\t\t\t\t`git add -A`,\n\t\t\t\t\t\t\t`git commit -m \"feat: initialized repo ✨`,\n\t\t\t\t\t\t\t`git push`,\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel:\n\t\t\t\t\t\t\t\"Otherwise, all you have to do is populate the repository's ACCESS_TOKEN and NPM_TOKEN secrets, and enable the Codecov and Renovate GitHub apps.\",\n\t\t\t\t\t},\n\t\t\t\t]);\n\t\t\t},\n\t\t\tskipRestore: inputs.options.skipRestore,\n\t\t}),\n\t\toptions: inputs.options,\n\t};\n};\n"],"mappings":"AACA,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAC5B,SAAS,2BAA2B;AACpC,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,6BAA6B;AAE/B,MAAM,aAAyB,OAAO,SAAS;AACrD,QAAM,SAAS,MAAM,YAAY,IAAI;AACrC,MAAI,OAAO,WAAW;AACrB,WAAO;AAAA,MACN,MAAM,YAAY;AAAA,MAClB,SAAS,OAAO;AAAA,IACjB;AAAA,EACD;AAEA,QAAM,oBAAoB;AAE1B,SAAO;AAAA,IACN,MAAM,MAAM,aAAa;AAAA,MACxB,KAAK,YAAY;AAChB,cAAM,sBAAsB,MAAM;AAElC,cAAM;AAAA,UACL;AAAA,YACC,OAAO;AAAA,YACP,OAAO;AAAA,cACN;AAAA,cACA;AAAA,cACA;AAAA,YACD;AAAA,UACD;AAAA,UACA;AAAA,YACC,OACC;AAAA,UACF;AAAA,QACD,CAAC;AAAA,MACF;AAAA,MACA,aAAa,OAAO,QAAQ;AAAA,IAC7B,CAAC;AAAA,IACD,SAAS,OAAO;AAAA,EACjB;AACD;","names":[]}
@@ -1,3 +1,7 @@
1
- declare function migrate(args: string[]): Promise<1 | 0>;
1
+ import { ModeRunner } from '../bin/mode.js';
2
+ import '../shared/codes.js';
3
+ import '../shared/types.js';
4
+
5
+ declare const migrate: ModeRunner;
2
6
 
3
7
  export { migrate };
@@ -1,28 +1,38 @@
1
1
  import { outro } from "../shared/cli/outro.js";
2
+ import { StatusCodes } from "../shared/codes.js";
2
3
  import { ensureGitRepository } from "../shared/ensureGitRepository.js";
3
4
  import { readOptions } from "../shared/options/readOptions.js";
4
5
  import { runOrRestore } from "../shared/runOrRestore.js";
5
6
  import { migrateWithOptions } from "./migrateWithOptions.js";
6
- async function migrate(args) {
7
+ const migrate = async (args) => {
7
8
  const inputs = await readOptions(args);
9
+ if (inputs.cancelled) {
10
+ return {
11
+ code: StatusCodes.Cancelled,
12
+ options: inputs.options
13
+ };
14
+ }
8
15
  await ensureGitRepository();
9
- return await runOrRestore({
10
- run: async () => {
11
- await migrateWithOptions(inputs);
12
- outro([
13
- {
14
- label: "You may consider committing these changes:",
15
- lines: [
16
- `git add -A`,
17
- `git commit -m "migrated repo to create-typescript-app \u2728`,
18
- `git push`
19
- ]
20
- }
21
- ]);
22
- },
23
- skipRestore: inputs.options.skipRestore
24
- });
25
- }
16
+ return {
17
+ code: await runOrRestore({
18
+ run: async () => {
19
+ await migrateWithOptions(inputs);
20
+ outro([
21
+ {
22
+ label: "You may consider committing these changes:",
23
+ lines: [
24
+ `git add -A`,
25
+ `git commit -m "migrated repo to create-typescript-app \u2728`,
26
+ `git push`
27
+ ]
28
+ }
29
+ ]);
30
+ },
31
+ skipRestore: inputs.options.skipRestore
32
+ }),
33
+ options: inputs.options
34
+ };
35
+ };
26
36
  export {
27
37
  migrate
28
38
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/migrate/index.ts"],"sourcesContent":["import { outro } from \"../shared/cli/outro.js\";\nimport { ensureGitRepository } from \"../shared/ensureGitRepository.js\";\nimport { readOptions } from \"../shared/options/readOptions.js\";\nimport { runOrRestore } from \"../shared/runOrRestore.js\";\nimport { migrateWithOptions } from \"./migrateWithOptions.js\";\n\nexport async function migrate(args: string[]) {\n\tconst inputs = await readOptions(args);\n\n\tawait ensureGitRepository();\n\n\treturn await runOrRestore({\n\t\trun: async () => {\n\t\t\tawait migrateWithOptions(inputs);\n\n\t\t\toutro([\n\t\t\t\t{\n\t\t\t\t\tlabel: \"You may consider committing these changes:\",\n\t\t\t\t\tlines: [\n\t\t\t\t\t\t`git add -A`,\n\t\t\t\t\t\t`git commit -m \"migrated repo to create-typescript-app ✨`,\n\t\t\t\t\t\t`git push`,\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t]);\n\t\t},\n\t\tskipRestore: inputs.options.skipRestore,\n\t});\n}\n"],"mappings":"AAAA,SAAS,aAAa;AACtB,SAAS,2BAA2B;AACpC,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,0BAA0B;AAEnC,eAAsB,QAAQ,MAAgB;AAC7C,QAAM,SAAS,MAAM,YAAY,IAAI;AAErC,QAAM,oBAAoB;AAE1B,SAAO,MAAM,aAAa;AAAA,IACzB,KAAK,YAAY;AAChB,YAAM,mBAAmB,MAAM;AAE/B,YAAM;AAAA,QACL;AAAA,UACC,OAAO;AAAA,UACP,OAAO;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,UACD;AAAA,QACD;AAAA,MACD,CAAC;AAAA,IACF;AAAA,IACA,aAAa,OAAO,QAAQ;AAAA,EAC7B,CAAC;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/migrate/index.ts"],"sourcesContent":["import { ModeRunner } from \"../bin/mode.js\";\nimport { outro } from \"../shared/cli/outro.js\";\nimport { StatusCodes } from \"../shared/codes.js\";\nimport { ensureGitRepository } from \"../shared/ensureGitRepository.js\";\nimport { readOptions } from \"../shared/options/readOptions.js\";\nimport { runOrRestore } from \"../shared/runOrRestore.js\";\nimport { migrateWithOptions } from \"./migrateWithOptions.js\";\n\nexport const migrate: ModeRunner = async (args) => {\n\tconst inputs = await readOptions(args);\n\tif (inputs.cancelled) {\n\t\treturn {\n\t\t\tcode: StatusCodes.Cancelled,\n\t\t\toptions: inputs.options,\n\t\t};\n\t}\n\n\tawait ensureGitRepository();\n\n\treturn {\n\t\tcode: await runOrRestore({\n\t\t\trun: async () => {\n\t\t\t\tawait migrateWithOptions(inputs);\n\n\t\t\t\toutro([\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: \"You may consider committing these changes:\",\n\t\t\t\t\t\tlines: [\n\t\t\t\t\t\t\t`git add -A`,\n\t\t\t\t\t\t\t`git commit -m \"migrated repo to create-typescript-app ✨`,\n\t\t\t\t\t\t\t`git push`,\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t]);\n\t\t\t},\n\t\t\tskipRestore: inputs.options.skipRestore,\n\t\t}),\n\t\toptions: inputs.options,\n\t};\n};\n"],"mappings":"AACA,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAC5B,SAAS,2BAA2B;AACpC,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,0BAA0B;AAE5B,MAAM,UAAsB,OAAO,SAAS;AAClD,QAAM,SAAS,MAAM,YAAY,IAAI;AACrC,MAAI,OAAO,WAAW;AACrB,WAAO;AAAA,MACN,MAAM,YAAY;AAAA,MAClB,SAAS,OAAO;AAAA,IACjB;AAAA,EACD;AAEA,QAAM,oBAAoB;AAE1B,SAAO;AAAA,IACN,MAAM,MAAM,aAAa;AAAA,MACxB,KAAK,YAAY;AAChB,cAAM,mBAAmB,MAAM;AAE/B,cAAM;AAAA,UACL;AAAA,YACC,OAAO;AAAA,YACP,OAAO;AAAA,cACN;AAAA,cACA;AAAA,cACA;AAAA,YACD;AAAA,UACD;AAAA,QACD,CAAC;AAAA,MACF;AAAA,MACA,aAAa,OAAO,QAAQ;AAAA,IAC7B,CAAC;AAAA,IACD,SAAS,OAAO;AAAA,EACjB;AACD;","names":[]}
@@ -0,0 +1,8 @@
1
+ declare const StatusCodes: {
2
+ readonly Cancelled: 2;
3
+ readonly Failure: 1;
4
+ readonly Success: 0;
5
+ };
6
+ type StatusCode = (typeof StatusCodes)[keyof typeof StatusCodes];
7
+
8
+ export { StatusCode, StatusCodes };
@@ -0,0 +1,9 @@
1
+ const StatusCodes = {
2
+ Cancelled: 2,
3
+ Failure: 1,
4
+ Success: 0
5
+ };
6
+ export {
7
+ StatusCodes
8
+ };
9
+ //# sourceMappingURL=codes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/shared/codes.ts"],"sourcesContent":["export const StatusCodes = {\n\tCancelled: 2,\n\tFailure: 1,\n\tSuccess: 0,\n} as const;\n\nexport type StatusCode = (typeof StatusCodes)[keyof typeof StatusCodes];\n"],"mappings":"AAAO,MAAM,cAAc;AAAA,EAC1B,WAAW;AAAA,EACX,SAAS;AAAA,EACT,SAAS;AACV;","names":[]}
@@ -1,5 +1,5 @@
1
1
  import { Options } from '../types.js';
2
2
 
3
- declare function augmentOptionsWithExcludes(options: Options): Promise<Options>;
3
+ declare function augmentOptionsWithExcludes(options: Options): Promise<Options | undefined>;
4
4
 
5
5
  export { augmentOptionsWithExcludes };
@@ -1,5 +1,5 @@
1
1
  import * as prompts from "@clack/prompts";
2
- import { handlePromptCancel } from "../prompts.js";
2
+ import { filterPromptCancel } from "../prompts.js";
3
3
  const exclusionDescriptions = {
4
4
  excludeCompliance: {
5
5
  hint: "--exclude-compliance",
@@ -61,7 +61,7 @@ async function augmentOptionsWithExcludes(options) {
61
61
  )) {
62
62
  return options;
63
63
  }
64
- const base = options.base ?? handlePromptCancel(
64
+ const base = options.base ?? filterPromptCancel(
65
65
  await prompts.select({
66
66
  message: `How much tooling would you like the template to set up for you?`,
67
67
  options: [
@@ -82,6 +82,8 @@ async function augmentOptionsWithExcludes(options) {
82
82
  })
83
83
  );
84
84
  switch (base) {
85
+ case void 0:
86
+ return void 0;
85
87
  case "everything":
86
88
  return options;
87
89
  case "minimum":
@@ -96,7 +98,7 @@ async function augmentOptionsWithExcludes(options) {
96
98
  };
97
99
  case "prompt":
98
100
  const exclusionsNotEnabled = new Set(
99
- handlePromptCancel(
101
+ filterPromptCancel(
100
102
  await prompts.multiselect({
101
103
  initialValues: exclusionKeys,
102
104
  message: "Select the tooling portions you'd like to remove. All are enabled by default.",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/shared/options/augmentOptionsWithExcludes.ts"],"sourcesContent":["import * as prompts from \"@clack/prompts\";\n\nimport { handlePromptCancel } from \"../prompts.js\";\nimport { Options } from \"../types.js\";\n\ntype Base = \"everything\" | \"minimum\" | \"prompt\";\n\nconst exclusionDescriptions = {\n\texcludeCompliance: {\n\t\thint: \"--exclude-compliance\",\n\t\tlabel:\n\t\t\t\"Add a GitHub Actions workflow to verify that PRs match an expected format.\",\n\t},\n\texcludeContributors: {\n\t\thint: \"--exclude-contributors\",\n\t\tlabel:\n\t\t\t\"Add all-contributors to track contributions and display them in a README.md table.\",\n\t},\n\texcludeLintJson: {\n\t\thint: \"--exclude-lint-json\",\n\t\tlabel: \"Apply linting and sorting to *.json and *.jsonc files.\",\n\t},\n\texcludeLintKnip: {\n\t\thint: \"--exclude-lint-knip\",\n\t\tlabel: \"Add Knip to detect unused files, dependencies, and code exports.\",\n\t},\n\texcludeLintMd: {\n\t\thint: \"--exclude-lint-md\",\n\t\tlabel: \"Apply linting to *.md files.\",\n\t},\n\texcludeLintPackageJson: {\n\t\thint: \"--exclude-lint-package-json\",\n\t\tlabel: \"Add npm-package-json-lint to lint for package.json correctness.\",\n\t},\n\texcludeLintPackages: {\n\t\thint: \"--exclude-lint-packages\",\n\t\tlabel:\n\t\t\t\"Add a pnpm dedupe workflow to ensure packages aren't duplicated unnecessarily.\",\n\t},\n\texcludeLintPerfectionist: {\n\t\thint: \"--exclude-lint-perfectionist\",\n\t\tlabel:\n\t\t\t\"Apply eslint-plugin-perfectionist to ensure imports, keys, and so on are in sorted order.\",\n\t},\n\texcludeLintSpelling: {\n\t\thint: \"--exclude-lint-spelling\",\n\t\tlabel: \"Add cspell to spell check against dictionaries of known words.\",\n\t},\n\texcludeLintYml: {\n\t\thint: \"--exclude-lint-yml\",\n\t\tlabel: \"Apply linting and sorting to *.yaml and *.yml files.\",\n\t},\n\texcludeReleases: {\n\t\thint: \"--exclude-releases\",\n\t\tlabel:\n\t\t\t\"Add release-it to generate changelogs, package bumps, and publishes based on conventional commits.\",\n\t},\n\texcludeRenovate: {\n\t\thint: \"--exclude-renovate\",\n\t\tlabel: \"Add a Renovate config to dependencies up-to-date with PRs.\",\n\t},\n\texcludeTests: {\n\t\thint: \"--exclude-tests\",\n\t\tlabel:\n\t\t\t\"Add Vitest tooling for fast unit tests, configured with coverage tracking.\",\n\t},\n} as const;\n\ntype ExclusionKey = keyof typeof exclusionDescriptions;\n\nconst exclusionKeys = Object.keys(exclusionDescriptions) as ExclusionKey[];\n\nexport async function augmentOptionsWithExcludes(\n\toptions: Options,\n): Promise<Options> {\n\tif (\n\t\tObject.keys(options).some(\n\t\t\t(key) =>\n\t\t\t\tkey in exclusionDescriptions &&\n\t\t\t\toptions[key as keyof typeof options] !== undefined,\n\t\t)\n\t) {\n\t\treturn options;\n\t}\n\n\tconst base =\n\t\toptions.base ??\n\t\thandlePromptCancel<Base | symbol>(\n\t\t\tawait prompts.select({\n\t\t\t\tmessage: `How much tooling would you like the template to set up for you?`,\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\thint: \"recommended\",\n\t\t\t\t\t\tlabel: \"Everything! 🙌\",\n\t\t\t\t\t\tvalue: \"everything\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: \"Just the bare essentials, please.\",\n\t\t\t\t\t\tvalue: \"minimum\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: \"Allow me to customize.\",\n\t\t\t\t\t\tvalue: \"prompt\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t}),\n\t\t);\n\n\tswitch (base) {\n\t\tcase \"everything\":\n\t\t\treturn options;\n\n\t\tcase \"minimum\":\n\t\t\treturn {\n\t\t\t\t...options,\n\t\t\t\t...Object.fromEntries(\n\t\t\t\t\texclusionKeys.map((exclusion) => [\n\t\t\t\t\t\texclusion,\n\t\t\t\t\t\toptions[exclusion] ?? true,\n\t\t\t\t\t]),\n\t\t\t\t),\n\t\t\t};\n\n\t\tcase \"prompt\":\n\t\t\tconst exclusionsNotEnabled = new Set(\n\t\t\t\thandlePromptCancel(\n\t\t\t\t\tawait prompts.multiselect({\n\t\t\t\t\t\tinitialValues: exclusionKeys,\n\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\"Select the tooling portions you'd like to remove. All are enabled by default.\",\n\t\t\t\t\t\toptions: Object.entries(exclusionDescriptions).map(\n\t\t\t\t\t\t\t([value, { hint, label }]) => ({\n\t\t\t\t\t\t\t\thint,\n\t\t\t\t\t\t\t\tlabel,\n\t\t\t\t\t\t\t\tvalue: value as ExclusionKey,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\t...options,\n\t\t\t\t...Object.fromEntries(\n\t\t\t\t\texclusionKeys.map(\n\t\t\t\t\t\t(exclusionKey) =>\n\t\t\t\t\t\t\t[exclusionKey, !exclusionsNotEnabled.has(exclusionKey)] as const,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t};\n\t}\n}\n"],"mappings":"AAAA,YAAY,aAAa;AAEzB,SAAS,0BAA0B;AAKnC,MAAM,wBAAwB;AAAA,EAC7B,mBAAmB;AAAA,IAClB,MAAM;AAAA,IACN,OACC;AAAA,EACF;AAAA,EACA,qBAAqB;AAAA,IACpB,MAAM;AAAA,IACN,OACC;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IAChB,MAAM;AAAA,IACN,OAAO;AAAA,EACR;AAAA,EACA,iBAAiB;AAAA,IAChB,MAAM;AAAA,IACN,OAAO;AAAA,EACR;AAAA,EACA,eAAe;AAAA,IACd,MAAM;AAAA,IACN,OAAO;AAAA,EACR;AAAA,EACA,wBAAwB;AAAA,IACvB,MAAM;AAAA,IACN,OAAO;AAAA,EACR;AAAA,EACA,qBAAqB;AAAA,IACpB,MAAM;AAAA,IACN,OACC;AAAA,EACF;AAAA,EACA,0BAA0B;AAAA,IACzB,MAAM;AAAA,IACN,OACC;AAAA,EACF;AAAA,EACA,qBAAqB;AAAA,IACpB,MAAM;AAAA,IACN,OAAO;AAAA,EACR;AAAA,EACA,gBAAgB;AAAA,IACf,MAAM;AAAA,IACN,OAAO;AAAA,EACR;AAAA,EACA,iBAAiB;AAAA,IAChB,MAAM;AAAA,IACN,OACC;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IAChB,MAAM;AAAA,IACN,OAAO;AAAA,EACR;AAAA,EACA,cAAc;AAAA,IACb,MAAM;AAAA,IACN,OACC;AAAA,EACF;AACD;AAIA,MAAM,gBAAgB,OAAO,KAAK,qBAAqB;AAEvD,eAAsB,2BACrB,SACmB;AACnB,MACC,OAAO,KAAK,OAAO,EAAE;AAAA,IACpB,CAAC,QACA,OAAO,yBACP,QAAQ,GAA2B,MAAM;AAAA,EAC3C,GACC;AACD,WAAO;AAAA,EACR;AAEA,QAAM,OACL,QAAQ,QACR;AAAA,IACC,MAAM,QAAQ,OAAO;AAAA,MACpB,SAAS;AAAA,MACT,SAAS;AAAA,QACR;AAAA,UACC,MAAM;AAAA,UACN,OAAO;AAAA,UACP,OAAO;AAAA,QACR;AAAA,QACA;AAAA,UACC,OAAO;AAAA,UACP,OAAO;AAAA,QACR;AAAA,QACA;AAAA,UACC,OAAO;AAAA,UACP,OAAO;AAAA,QACR;AAAA,MACD;AAAA,IACD,CAAC;AAAA,EACF;AAED,UAAQ,MAAM;AAAA,IACb,KAAK;AACJ,aAAO;AAAA,IAER,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,GAAG,OAAO;AAAA,UACT,cAAc,IAAI,CAAC,cAAc;AAAA,YAChC;AAAA,YACA,QAAQ,SAAS,KAAK;AAAA,UACvB,CAAC;AAAA,QACF;AAAA,MACD;AAAA,IAED,KAAK;AACJ,YAAM,uBAAuB,IAAI;AAAA,QAChC;AAAA,UACC,MAAM,QAAQ,YAAY;AAAA,YACzB,eAAe;AAAA,YACf,SACC;AAAA,YACD,SAAS,OAAO,QAAQ,qBAAqB,EAAE;AAAA,cAC9C,CAAC,CAAC,OAAO,EAAE,MAAM,MAAM,CAAC,OAAO;AAAA,gBAC9B;AAAA,gBACA;AAAA,gBACA;AAAA,cACD;AAAA,YACD;AAAA,UACD,CAAC;AAAA,QACF;AAAA,MACD;AAEA,aAAO;AAAA,QACN,GAAG;AAAA,QACH,GAAG,OAAO;AAAA,UACT,cAAc;AAAA,YACb,CAAC,iBACA,CAAC,cAAc,CAAC,qBAAqB,IAAI,YAAY,CAAC;AAAA,UACxD;AAAA,QACD;AAAA,MACD;AAAA,EACF;AACD;","names":[]}
1
+ {"version":3,"sources":["../../../src/shared/options/augmentOptionsWithExcludes.ts"],"sourcesContent":["import * as prompts from \"@clack/prompts\";\n\nimport { filterPromptCancel } from \"../prompts.js\";\nimport { Options } from \"../types.js\";\n\ntype Base = \"everything\" | \"minimum\" | \"prompt\";\n\nconst exclusionDescriptions = {\n\texcludeCompliance: {\n\t\thint: \"--exclude-compliance\",\n\t\tlabel:\n\t\t\t\"Add a GitHub Actions workflow to verify that PRs match an expected format.\",\n\t},\n\texcludeContributors: {\n\t\thint: \"--exclude-contributors\",\n\t\tlabel:\n\t\t\t\"Add all-contributors to track contributions and display them in a README.md table.\",\n\t},\n\texcludeLintJson: {\n\t\thint: \"--exclude-lint-json\",\n\t\tlabel: \"Apply linting and sorting to *.json and *.jsonc files.\",\n\t},\n\texcludeLintKnip: {\n\t\thint: \"--exclude-lint-knip\",\n\t\tlabel: \"Add Knip to detect unused files, dependencies, and code exports.\",\n\t},\n\texcludeLintMd: {\n\t\thint: \"--exclude-lint-md\",\n\t\tlabel: \"Apply linting to *.md files.\",\n\t},\n\texcludeLintPackageJson: {\n\t\thint: \"--exclude-lint-package-json\",\n\t\tlabel: \"Add npm-package-json-lint to lint for package.json correctness.\",\n\t},\n\texcludeLintPackages: {\n\t\thint: \"--exclude-lint-packages\",\n\t\tlabel:\n\t\t\t\"Add a pnpm dedupe workflow to ensure packages aren't duplicated unnecessarily.\",\n\t},\n\texcludeLintPerfectionist: {\n\t\thint: \"--exclude-lint-perfectionist\",\n\t\tlabel:\n\t\t\t\"Apply eslint-plugin-perfectionist to ensure imports, keys, and so on are in sorted order.\",\n\t},\n\texcludeLintSpelling: {\n\t\thint: \"--exclude-lint-spelling\",\n\t\tlabel: \"Add cspell to spell check against dictionaries of known words.\",\n\t},\n\texcludeLintYml: {\n\t\thint: \"--exclude-lint-yml\",\n\t\tlabel: \"Apply linting and sorting to *.yaml and *.yml files.\",\n\t},\n\texcludeReleases: {\n\t\thint: \"--exclude-releases\",\n\t\tlabel:\n\t\t\t\"Add release-it to generate changelogs, package bumps, and publishes based on conventional commits.\",\n\t},\n\texcludeRenovate: {\n\t\thint: \"--exclude-renovate\",\n\t\tlabel: \"Add a Renovate config to dependencies up-to-date with PRs.\",\n\t},\n\texcludeTests: {\n\t\thint: \"--exclude-tests\",\n\t\tlabel:\n\t\t\t\"Add Vitest tooling for fast unit tests, configured with coverage tracking.\",\n\t},\n} as const;\n\ntype ExclusionKey = keyof typeof exclusionDescriptions;\n\nconst exclusionKeys = Object.keys(exclusionDescriptions) as ExclusionKey[];\n\nexport async function augmentOptionsWithExcludes(\n\toptions: Options,\n): Promise<Options | undefined> {\n\tif (\n\t\tObject.keys(options).some(\n\t\t\t(key) =>\n\t\t\t\tkey in exclusionDescriptions &&\n\t\t\t\toptions[key as keyof typeof options] !== undefined,\n\t\t)\n\t) {\n\t\treturn options;\n\t}\n\n\tconst base =\n\t\toptions.base ??\n\t\tfilterPromptCancel<Base | symbol>(\n\t\t\tawait prompts.select({\n\t\t\t\tmessage: `How much tooling would you like the template to set up for you?`,\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\thint: \"recommended\",\n\t\t\t\t\t\tlabel: \"Everything! 🙌\",\n\t\t\t\t\t\tvalue: \"everything\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: \"Just the bare essentials, please.\",\n\t\t\t\t\t\tvalue: \"minimum\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: \"Allow me to customize.\",\n\t\t\t\t\t\tvalue: \"prompt\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t}),\n\t\t);\n\n\tswitch (base) {\n\t\tcase undefined:\n\t\t\treturn undefined;\n\n\t\tcase \"everything\":\n\t\t\treturn options;\n\n\t\tcase \"minimum\":\n\t\t\treturn {\n\t\t\t\t...options,\n\t\t\t\t...Object.fromEntries(\n\t\t\t\t\texclusionKeys.map((exclusion) => [\n\t\t\t\t\t\texclusion,\n\t\t\t\t\t\toptions[exclusion] ?? true,\n\t\t\t\t\t]),\n\t\t\t\t),\n\t\t\t};\n\n\t\tcase \"prompt\":\n\t\t\tconst exclusionsNotEnabled = new Set(\n\t\t\t\tfilterPromptCancel(\n\t\t\t\t\tawait prompts.multiselect({\n\t\t\t\t\t\tinitialValues: exclusionKeys,\n\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\"Select the tooling portions you'd like to remove. All are enabled by default.\",\n\t\t\t\t\t\toptions: Object.entries(exclusionDescriptions).map(\n\t\t\t\t\t\t\t([value, { hint, label }]) => ({\n\t\t\t\t\t\t\t\thint,\n\t\t\t\t\t\t\t\tlabel,\n\t\t\t\t\t\t\t\tvalue: value as ExclusionKey,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\t...options,\n\t\t\t\t...Object.fromEntries(\n\t\t\t\t\texclusionKeys.map(\n\t\t\t\t\t\t(exclusionKey) =>\n\t\t\t\t\t\t\t[exclusionKey, !exclusionsNotEnabled.has(exclusionKey)] as const,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t};\n\t}\n}\n"],"mappings":"AAAA,YAAY,aAAa;AAEzB,SAAS,0BAA0B;AAKnC,MAAM,wBAAwB;AAAA,EAC7B,mBAAmB;AAAA,IAClB,MAAM;AAAA,IACN,OACC;AAAA,EACF;AAAA,EACA,qBAAqB;AAAA,IACpB,MAAM;AAAA,IACN,OACC;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IAChB,MAAM;AAAA,IACN,OAAO;AAAA,EACR;AAAA,EACA,iBAAiB;AAAA,IAChB,MAAM;AAAA,IACN,OAAO;AAAA,EACR;AAAA,EACA,eAAe;AAAA,IACd,MAAM;AAAA,IACN,OAAO;AAAA,EACR;AAAA,EACA,wBAAwB;AAAA,IACvB,MAAM;AAAA,IACN,OAAO;AAAA,EACR;AAAA,EACA,qBAAqB;AAAA,IACpB,MAAM;AAAA,IACN,OACC;AAAA,EACF;AAAA,EACA,0BAA0B;AAAA,IACzB,MAAM;AAAA,IACN,OACC;AAAA,EACF;AAAA,EACA,qBAAqB;AAAA,IACpB,MAAM;AAAA,IACN,OAAO;AAAA,EACR;AAAA,EACA,gBAAgB;AAAA,IACf,MAAM;AAAA,IACN,OAAO;AAAA,EACR;AAAA,EACA,iBAAiB;AAAA,IAChB,MAAM;AAAA,IACN,OACC;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IAChB,MAAM;AAAA,IACN,OAAO;AAAA,EACR;AAAA,EACA,cAAc;AAAA,IACb,MAAM;AAAA,IACN,OACC;AAAA,EACF;AACD;AAIA,MAAM,gBAAgB,OAAO,KAAK,qBAAqB;AAEvD,eAAsB,2BACrB,SAC+B;AAC/B,MACC,OAAO,KAAK,OAAO,EAAE;AAAA,IACpB,CAAC,QACA,OAAO,yBACP,QAAQ,GAA2B,MAAM;AAAA,EAC3C,GACC;AACD,WAAO;AAAA,EACR;AAEA,QAAM,OACL,QAAQ,QACR;AAAA,IACC,MAAM,QAAQ,OAAO;AAAA,MACpB,SAAS;AAAA,MACT,SAAS;AAAA,QACR;AAAA,UACC,MAAM;AAAA,UACN,OAAO;AAAA,UACP,OAAO;AAAA,QACR;AAAA,QACA;AAAA,UACC,OAAO;AAAA,UACP,OAAO;AAAA,QACR;AAAA,QACA;AAAA,UACC,OAAO;AAAA,UACP,OAAO;AAAA,QACR;AAAA,MACD;AAAA,IACD,CAAC;AAAA,EACF;AAED,UAAQ,MAAM;AAAA,IACb,KAAK;AACJ,aAAO;AAAA,IAER,KAAK;AACJ,aAAO;AAAA,IAER,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,GAAG,OAAO;AAAA,UACT,cAAc,IAAI,CAAC,cAAc;AAAA,YAChC;AAAA,YACA,QAAQ,SAAS,KAAK;AAAA,UACvB,CAAC;AAAA,QACF;AAAA,MACD;AAAA,IAED,KAAK;AACJ,YAAM,uBAAuB,IAAI;AAAA,QAChC;AAAA,UACC,MAAM,QAAQ,YAAY;AAAA,YACzB,eAAe;AAAA,YACf,SACC;AAAA,YACD,SAAS,OAAO,QAAQ,qBAAqB,EAAE;AAAA,cAC9C,CAAC,CAAC,OAAO,EAAE,MAAM,MAAM,CAAC,OAAO;AAAA,gBAC9B;AAAA,gBACA;AAAA,gBACA;AAAA,cACD;AAAA,YACD;AAAA,UACD,CAAC;AAAA,QACF;AAAA,MACD;AAEA,aAAO;AAAA,QACN,GAAG;AAAA,QACH,GAAG,OAAO;AAAA,UACT,cAAc;AAAA,YACb,CAAC,iBACA,CAAC,cAAc,CAAC,qBAAqB,IAAI,YAAY,CAAC;AAAA,UACxD;AAAA,QACD;AAAA,MACD;AAAA,EACF;AACD;","names":[]}
@@ -6,6 +6,6 @@ interface RepositoryExistsResult {
6
6
  octokit: Octokit | undefined;
7
7
  repository: string;
8
8
  }
9
- declare function ensureRepositoryExists(octokit: Octokit | undefined, options: EnsureRepositoryExistsOptions): Promise<RepositoryExistsResult>;
9
+ declare function ensureRepositoryExists(octokit: Octokit | undefined, options: EnsureRepositoryExistsOptions): Promise<Partial<RepositoryExistsResult>>;
10
10
 
11
11
  export { EnsureRepositoryExistsOptions, RepositoryExistsResult, ensureRepositoryExists };
@@ -1,13 +1,13 @@
1
1
  import * as prompts from "@clack/prompts";
2
2
  import { doesRepositoryExist } from "../doesRepositoryExist.js";
3
- import { handleCancel, handlePromptCancel } from "../prompts.js";
3
+ import { filterPromptCancel } from "../prompts.js";
4
4
  async function ensureRepositoryExists(octokit, options) {
5
5
  let { createRepository, repository } = options;
6
6
  while (octokit) {
7
7
  if (await doesRepositoryExist(octokit, options)) {
8
8
  return { octokit, repository };
9
9
  }
10
- const selection = createRepository ? "create" : handlePromptCancel(
10
+ const selection = createRepository ? "create" : filterPromptCancel(
11
11
  await prompts.select({
12
12
  message: `Repository ${options.repository} doesn't seem to exist under ${options.owner}. What would you like to do?`,
13
13
  options: [
@@ -27,8 +27,7 @@ async function ensureRepositoryExists(octokit, options) {
27
27
  createRepository = false;
28
28
  switch (selection) {
29
29
  case "bail":
30
- handleCancel();
31
- break;
30
+ return {};
32
31
  case "create":
33
32
  await octokit.rest.repos.createUsingTemplate({
34
33
  name: repository,
@@ -38,11 +37,14 @@ async function ensureRepositoryExists(octokit, options) {
38
37
  });
39
38
  return { octokit, repository };
40
39
  case "different":
41
- const newRepository = handlePromptCancel(
40
+ const newRepository = filterPromptCancel(
42
41
  await prompts.text({
43
42
  message: `What would you like to call the repository?`
44
43
  })
45
44
  );
45
+ if (!newRepository) {
46
+ return {};
47
+ }
46
48
  repository = newRepository;
47
49
  break;
48
50
  case "local":
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/shared/options/ensureRepositoryExists.ts"],"sourcesContent":["import * as prompts from \"@clack/prompts\";\nimport { Octokit } from \"octokit\";\n\nimport { doesRepositoryExist } from \"../doesRepositoryExist.js\";\nimport { handleCancel, handlePromptCancel } from \"../prompts.js\";\nimport { Options } from \"../types.js\";\n\nexport type EnsureRepositoryExistsOptions = Pick<\n\tOptions,\n\t\"createRepository\" | \"owner\" | \"repository\"\n>;\n\nexport interface RepositoryExistsResult {\n\toctokit: Octokit | undefined;\n\trepository: string;\n}\n\nexport async function ensureRepositoryExists(\n\toctokit: Octokit | undefined,\n\toptions: EnsureRepositoryExistsOptions,\n): Promise<RepositoryExistsResult> {\n\t// We'll only respect input options once before prompting for them\n\tlet { createRepository, repository } = options;\n\n\t// We'll continuously pester the user for a repository\n\t// until they bail, create a new one, or it exists.\n\twhile (octokit) {\n\t\tif (await doesRepositoryExist(octokit, options)) {\n\t\t\treturn { octokit, repository };\n\t\t}\n\n\t\tconst selection = createRepository\n\t\t\t? \"create\"\n\t\t\t: handlePromptCancel(\n\t\t\t\t\t(await prompts.select({\n\t\t\t\t\t\tmessage: `Repository ${options.repository} doesn't seem to exist under ${options.owner}. What would you like to do?`,\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{ label: \"Create a new repository\", value: \"create\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: \"Switch to a different repository name\",\n\t\t\t\t\t\t\t\tvalue: \"different\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: \"Keep changes local\",\n\t\t\t\t\t\t\t\tvalue: \"local\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ label: \"Bail out and maybe try again later\", value: \"bail\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t})) as \"bail\" | \"create\" | \"different\" | \"local\",\n\t\t\t );\n\n\t\tcreateRepository = false;\n\n\t\tswitch (selection) {\n\t\t\tcase \"bail\":\n\t\t\t\thandleCancel();\n\t\t\t\tbreak;\n\n\t\t\tcase \"create\":\n\t\t\t\tawait octokit.rest.repos.createUsingTemplate({\n\t\t\t\t\tname: repository,\n\t\t\t\t\towner: options.owner,\n\t\t\t\t\ttemplate_owner: \"JoshuaKGoldberg\",\n\t\t\t\t\ttemplate_repo: \"create-typescript-app\",\n\t\t\t\t});\n\t\t\t\treturn { octokit, repository };\n\n\t\t\tcase \"different\":\n\t\t\t\tconst newRepository = handlePromptCancel(\n\t\t\t\t\tawait prompts.text({\n\t\t\t\t\t\tmessage: `What would you like to call the repository?`,\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\trepository = newRepository;\n\t\t\t\tbreak;\n\n\t\t\tcase \"local\":\n\t\t\t\toctokit = undefined;\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn { octokit, repository };\n}\n"],"mappings":"AAAA,YAAY,aAAa;AAGzB,SAAS,2BAA2B;AACpC,SAAS,cAAc,0BAA0B;AAajD,eAAsB,uBACrB,SACA,SACkC;AAElC,MAAI,EAAE,kBAAkB,WAAW,IAAI;AAIvC,SAAO,SAAS;AACf,QAAI,MAAM,oBAAoB,SAAS,OAAO,GAAG;AAChD,aAAO,EAAE,SAAS,WAAW;AAAA,IAC9B;AAEA,UAAM,YAAY,mBACf,WACA;AAAA,MACC,MAAM,QAAQ,OAAO;AAAA,QACrB,SAAS,cAAc,QAAQ,UAAU,gCAAgC,QAAQ,KAAK;AAAA,QACtF,SAAS;AAAA,UACR,EAAE,OAAO,2BAA2B,OAAO,SAAS;AAAA,UACpD;AAAA,YACC,OAAO;AAAA,YACP,OAAO;AAAA,UACR;AAAA,UACA;AAAA,YACC,OAAO;AAAA,YACP,OAAO;AAAA,UACR;AAAA,UACA,EAAE,OAAO,sCAAsC,OAAO,OAAO;AAAA,QAC9D;AAAA,MACD,CAAC;AAAA,IACD;AAEH,uBAAmB;AAEnB,YAAQ,WAAW;AAAA,MAClB,KAAK;AACJ,qBAAa;AACb;AAAA,MAED,KAAK;AACJ,cAAM,QAAQ,KAAK,MAAM,oBAAoB;AAAA,UAC5C,MAAM;AAAA,UACN,OAAO,QAAQ;AAAA,UACf,gBAAgB;AAAA,UAChB,eAAe;AAAA,QAChB,CAAC;AACD,eAAO,EAAE,SAAS,WAAW;AAAA,MAE9B,KAAK;AACJ,cAAM,gBAAgB;AAAA,UACrB,MAAM,QAAQ,KAAK;AAAA,YAClB,SAAS;AAAA,UACV,CAAC;AAAA,QACF;AAEA,qBAAa;AACb;AAAA,MAED,KAAK;AACJ,kBAAU;AACV;AAAA,IACF;AAAA,EACD;AAEA,SAAO,EAAE,SAAS,WAAW;AAC9B;","names":[]}
1
+ {"version":3,"sources":["../../../src/shared/options/ensureRepositoryExists.ts"],"sourcesContent":["import * as prompts from \"@clack/prompts\";\nimport { Octokit } from \"octokit\";\n\nimport { doesRepositoryExist } from \"../doesRepositoryExist.js\";\nimport { filterPromptCancel } from \"../prompts.js\";\nimport { Options } from \"../types.js\";\n\nexport type EnsureRepositoryExistsOptions = Pick<\n\tOptions,\n\t\"createRepository\" | \"owner\" | \"repository\"\n>;\n\nexport interface RepositoryExistsResult {\n\toctokit: Octokit | undefined;\n\trepository: string;\n}\n\nexport async function ensureRepositoryExists(\n\toctokit: Octokit | undefined,\n\toptions: EnsureRepositoryExistsOptions,\n): Promise<Partial<RepositoryExistsResult>> {\n\t// We'll only respect input options once before prompting for them\n\tlet { createRepository, repository } = options;\n\n\t// We'll continuously pester the user for a repository\n\t// until they bail, create a new one, or it exists.\n\twhile (octokit) {\n\t\tif (await doesRepositoryExist(octokit, options)) {\n\t\t\treturn { octokit, repository };\n\t\t}\n\n\t\tconst selection = createRepository\n\t\t\t? \"create\"\n\t\t\t: filterPromptCancel(\n\t\t\t\t\t(await prompts.select({\n\t\t\t\t\t\tmessage: `Repository ${options.repository} doesn't seem to exist under ${options.owner}. What would you like to do?`,\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{ label: \"Create a new repository\", value: \"create\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: \"Switch to a different repository name\",\n\t\t\t\t\t\t\t\tvalue: \"different\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: \"Keep changes local\",\n\t\t\t\t\t\t\t\tvalue: \"local\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ label: \"Bail out and maybe try again later\", value: \"bail\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t})) as \"bail\" | \"create\" | \"different\" | \"local\",\n\t\t\t );\n\n\t\tcreateRepository = false;\n\n\t\tswitch (selection) {\n\t\t\tcase \"bail\":\n\t\t\t\treturn {};\n\n\t\t\tcase \"create\":\n\t\t\t\tawait octokit.rest.repos.createUsingTemplate({\n\t\t\t\t\tname: repository,\n\t\t\t\t\towner: options.owner,\n\t\t\t\t\ttemplate_owner: \"JoshuaKGoldberg\",\n\t\t\t\t\ttemplate_repo: \"create-typescript-app\",\n\t\t\t\t});\n\t\t\t\treturn { octokit, repository };\n\n\t\t\tcase \"different\":\n\t\t\t\tconst newRepository = filterPromptCancel(\n\t\t\t\t\tawait prompts.text({\n\t\t\t\t\t\tmessage: `What would you like to call the repository?`,\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\tif (!newRepository) {\n\t\t\t\t\treturn {};\n\t\t\t\t}\n\n\t\t\t\trepository = newRepository;\n\t\t\t\tbreak;\n\n\t\t\tcase \"local\":\n\t\t\t\toctokit = undefined;\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn { octokit, repository };\n}\n"],"mappings":"AAAA,YAAY,aAAa;AAGzB,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AAanC,eAAsB,uBACrB,SACA,SAC2C;AAE3C,MAAI,EAAE,kBAAkB,WAAW,IAAI;AAIvC,SAAO,SAAS;AACf,QAAI,MAAM,oBAAoB,SAAS,OAAO,GAAG;AAChD,aAAO,EAAE,SAAS,WAAW;AAAA,IAC9B;AAEA,UAAM,YAAY,mBACf,WACA;AAAA,MACC,MAAM,QAAQ,OAAO;AAAA,QACrB,SAAS,cAAc,QAAQ,UAAU,gCAAgC,QAAQ,KAAK;AAAA,QACtF,SAAS;AAAA,UACR,EAAE,OAAO,2BAA2B,OAAO,SAAS;AAAA,UACpD;AAAA,YACC,OAAO;AAAA,YACP,OAAO;AAAA,UACR;AAAA,UACA;AAAA,YACC,OAAO;AAAA,YACP,OAAO;AAAA,UACR;AAAA,UACA,EAAE,OAAO,sCAAsC,OAAO,OAAO;AAAA,QAC9D;AAAA,MACD,CAAC;AAAA,IACD;AAEH,uBAAmB;AAEnB,YAAQ,WAAW;AAAA,MAClB,KAAK;AACJ,eAAO,CAAC;AAAA,MAET,KAAK;AACJ,cAAM,QAAQ,KAAK,MAAM,oBAAoB;AAAA,UAC5C,MAAM;AAAA,UACN,OAAO,QAAQ;AAAA,UACf,gBAAgB;AAAA,UAChB,eAAe;AAAA,QAChB,CAAC;AACD,eAAO,EAAE,SAAS,WAAW;AAAA,MAE9B,KAAK;AACJ,cAAM,gBAAgB;AAAA,UACrB,MAAM,QAAQ,KAAK;AAAA,YAClB,SAAS;AAAA,UACV,CAAC;AAAA,QACF;AAEA,YAAI,CAAC,eAAe;AACnB,iBAAO,CAAC;AAAA,QACT;AAEA,qBAAa;AACb;AAAA,MAED,KAAK;AACJ,kBAAU;AACV;AAAA,IACF;AAAA,EACD;AAEA,SAAO,EAAE,SAAS,WAAW;AAC9B;","names":[]}
@@ -1,3 +1,3 @@
1
- declare function getPrefillOrPromptedOption(existingValue: string | undefined, message: string, placeholder?: string): Promise<string>;
1
+ declare function getPrefillOrPromptedOption(existingValue: string | undefined, message: string, placeholder?: string): Promise<string | undefined>;
2
2
 
3
3
  export { getPrefillOrPromptedOption };
@@ -1,10 +1,10 @@
1
1
  import * as prompts from "@clack/prompts";
2
- import { handlePromptCancel } from "../prompts.js";
2
+ import { filterPromptCancel } from "../prompts.js";
3
3
  async function getPrefillOrPromptedOption(existingValue, message, placeholder) {
4
4
  if (existingValue) {
5
5
  return existingValue;
6
6
  }
7
- const value = handlePromptCancel(
7
+ const value = filterPromptCancel(
8
8
  await prompts.text({
9
9
  message,
10
10
  placeholder,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/shared/options/getPrefillOrPromptedOption.ts"],"sourcesContent":["import * as prompts from \"@clack/prompts\";\n\nimport { handlePromptCancel } from \"../prompts.js\";\n\nexport async function getPrefillOrPromptedOption(\n\texistingValue: string | undefined,\n\tmessage: string,\n\tplaceholder?: string,\n) {\n\tif (existingValue) {\n\t\treturn existingValue;\n\t}\n\n\tconst value = handlePromptCancel(\n\t\tawait prompts.text({\n\t\t\tmessage,\n\t\t\tplaceholder,\n\t\t\tvalidate: (val) => {\n\t\t\t\tif (val.length === 0) {\n\t\t\t\t\treturn \"Please enter a value.\";\n\t\t\t\t}\n\t\t\t},\n\t\t}),\n\t);\n\n\treturn value;\n}\n"],"mappings":"AAAA,YAAY,aAAa;AAEzB,SAAS,0BAA0B;AAEnC,eAAsB,2BACrB,eACA,SACA,aACC;AACD,MAAI,eAAe;AAClB,WAAO;AAAA,EACR;AAEA,QAAM,QAAQ;AAAA,IACb,MAAM,QAAQ,KAAK;AAAA,MAClB;AAAA,MACA;AAAA,MACA,UAAU,CAAC,QAAQ;AAClB,YAAI,IAAI,WAAW,GAAG;AACrB,iBAAO;AAAA,QACR;AAAA,MACD;AAAA,IACD,CAAC;AAAA,EACF;AAEA,SAAO;AACR;","names":[]}
1
+ {"version":3,"sources":["../../../src/shared/options/getPrefillOrPromptedOption.ts"],"sourcesContent":["import * as prompts from \"@clack/prompts\";\n\nimport { filterPromptCancel } from \"../prompts.js\";\n\nexport async function getPrefillOrPromptedOption(\n\texistingValue: string | undefined,\n\tmessage: string,\n\tplaceholder?: string,\n) {\n\tif (existingValue) {\n\t\treturn existingValue;\n\t}\n\n\tconst value = filterPromptCancel(\n\t\tawait prompts.text({\n\t\t\tmessage,\n\t\t\tplaceholder,\n\t\t\tvalidate: (val) => {\n\t\t\t\tif (val.length === 0) {\n\t\t\t\t\treturn \"Please enter a value.\";\n\t\t\t\t}\n\t\t\t},\n\t\t}),\n\t);\n\n\treturn value;\n}\n"],"mappings":"AAAA,YAAY,aAAa;AAEzB,SAAS,0BAA0B;AAEnC,eAAsB,2BACrB,eACA,SACA,aACC;AACD,MAAI,eAAe;AAClB,WAAO;AAAA,EACR;AAEA,QAAM,QAAQ;AAAA,IACb,MAAM,QAAQ,KAAK;AAAA,MAClB;AAAA,MACA;AAAA,MACA,UAAU,CAAC,QAAQ;AAClB,YAAI,IAAI,WAAW,GAAG;AACrB,iBAAO;AAAA,QACR;AAAA,MACD;AAAA,IACD,CAAC;AAAA,EACF;AAEA,SAAO;AACR;","names":[]}
@@ -5,6 +5,14 @@ interface OctokitAndOptions {
5
5
  octokit: Octokit | undefined;
6
6
  options: Options;
7
7
  }
8
- declare function readOptions(args: string[]): Promise<OctokitAndOptions>;
8
+ interface OptionsParseCancelled {
9
+ cancelled: true;
10
+ options: Partial<Options>;
11
+ }
12
+ interface OptionsParseSuccess extends OctokitAndOptions {
13
+ cancelled: false;
14
+ }
15
+ type OptionsParseResult = OptionsParseCancelled | OptionsParseSuccess;
16
+ declare function readOptions(args: string[]): Promise<OptionsParseResult>;
9
17
 
10
- export { OctokitAndOptions, readOptions };
18
+ export { OctokitAndOptions, OptionsParseCancelled, OptionsParseResult, OptionsParseSuccess, readOptions };
@@ -6,7 +6,6 @@ import { augmentOptionsWithExcludes } from "./augmentOptionsWithExcludes.js";
6
6
  import { ensureRepositoryExists } from "./ensureRepositoryExists.js";
7
7
  import { getOctokit } from "./getOctokit.js";
8
8
  import { getPrefillOrPromptedOption } from "./getPrefillOrPromptedOption.js";
9
- import { optionalDefault } from "./optionalDefault.js";
10
9
  import { getGitAndNpmDefaults } from "./readGitAndNpmDefaults/index.js";
11
10
  async function readOptions(args) {
12
11
  const defaults = await getGitAndNpmDefaults();
@@ -16,65 +15,101 @@ async function readOptions(args) {
16
15
  strict: false,
17
16
  tokens: true
18
17
  });
19
- const owner = await getPrefillOrPromptedOption(
18
+ const options = {
19
+ author: values.author,
20
+ base: values.base,
21
+ createRepository: values["create-repository"],
22
+ description: values.description,
23
+ email: values.email,
24
+ excludeCompliance: values["exclude-compliance"],
25
+ excludeContributors: values["exclude-contributors"],
26
+ excludeLintJson: values["exclude-lint-json"],
27
+ excludeLintKnip: values["exclude-lint-knip"],
28
+ excludeLintMd: values["exclude-lint-md"],
29
+ excludeLintPackageJson: values["exclude-lint-package-json"],
30
+ excludeLintPackages: values["exclude-lint-packages"],
31
+ excludeLintPerfectionist: values["exclude-lint-perfectionist"],
32
+ excludeLintSpelling: values["exclude-lint-spelling"],
33
+ excludeLintYml: values["exclude-lint-yml"],
34
+ excludeReleases: values["exclude-releases"],
35
+ excludeRenovate: values["exclude-renovate"],
36
+ excludeTests: values["unit-tests"],
37
+ funding: values.funding,
38
+ owner: values.owner,
39
+ repository: values.repository,
40
+ skipGitHubApi: !!values["skip-github-api"],
41
+ skipInstall: !!values["skip-install"],
42
+ skipRemoval: !!values["skip-removal"],
43
+ skipRestore: values["skip-restore"],
44
+ skipUninstall: !!values["skip-uninstall"],
45
+ title: values.title
46
+ };
47
+ options.owner ??= await getPrefillOrPromptedOption(
20
48
  values.owner,
21
49
  "What organization or user will the repository be under?",
22
50
  defaults.owner
23
51
  );
52
+ if (!options.owner) {
53
+ return {
54
+ cancelled: true,
55
+ options
56
+ };
57
+ }
58
+ options.repository ??= await getPrefillOrPromptedOption(
59
+ options.repository,
60
+ "What will the kebab-case name of the repository be?",
61
+ defaults.repository
62
+ );
63
+ if (!options.repository) {
64
+ return {
65
+ cancelled: true,
66
+ options
67
+ };
68
+ }
24
69
  const { octokit, repository } = await ensureRepositoryExists(
25
70
  values["skip-github-api"] ? void 0 : await withSpinner("Checking GitHub authentication", getOctokit),
26
71
  {
27
- createRepository: values["create-repository"],
28
- owner,
29
- repository: await getPrefillOrPromptedOption(
30
- values.repository,
31
- "What will the kebab-case name of the repository be?",
32
- defaults.repository
33
- )
72
+ createRepository: options.createRepository,
73
+ owner: options.owner,
74
+ repository: options.repository
34
75
  }
35
76
  );
77
+ if (!repository) {
78
+ return { cancelled: true, options };
79
+ }
80
+ options.description ??= await getPrefillOrPromptedOption(
81
+ options.description,
82
+ "How would you describe the new package?",
83
+ defaults.description ?? "A very lovely package. Hooray!"
84
+ );
85
+ if (!options.description) {
86
+ return { cancelled: true, options };
87
+ }
88
+ options.title ??= await getPrefillOrPromptedOption(
89
+ options.title,
90
+ "What will the Title Case title of the repository be?",
91
+ defaults.title ?? titleCase(repository).replaceAll("-", " ")
92
+ );
93
+ if (!options.title) {
94
+ return { cancelled: true, options };
95
+ }
96
+ const augmentedOptions = await augmentOptionsWithExcludes({
97
+ ...options,
98
+ author: options.author ?? defaults.owner,
99
+ email: options.email ?? defaults.email,
100
+ funding: options.funding ?? defaults.funding,
101
+ repository
102
+ });
103
+ if (!augmentedOptions) {
104
+ return {
105
+ cancelled: true,
106
+ options
107
+ };
108
+ }
36
109
  return {
110
+ cancelled: false,
37
111
  octokit,
38
- options: await augmentOptionsWithExcludes({
39
- author: values.author ?? defaults.author ?? owner.toLowerCase(),
40
- base: values.base,
41
- createRepository: values["create-repository"],
42
- description: await getPrefillOrPromptedOption(
43
- values.description,
44
- "How would you describe the new package?",
45
- defaults.description ?? "A very lovely package. Hooray!"
46
- ),
47
- email: values.email ?? defaults.email,
48
- excludeCompliance: values["exclude-compliance"],
49
- excludeContributors: values["exclude-contributors"],
50
- excludeLintJson: values["exclude-lint-json"],
51
- excludeLintKnip: values["exclude-lint-knip"],
52
- excludeLintMd: values["exclude-lint-md"],
53
- excludeLintPackageJson: values["exclude-lint-package-json"],
54
- excludeLintPackages: values["exclude-lint-packages"],
55
- excludeLintPerfectionist: values["exclude-lint-perfectionist"],
56
- excludeLintSpelling: values["exclude-lint-spelling"],
57
- excludeLintYml: values["exclude-lint-yml"],
58
- excludeReleases: values["exclude-releases"],
59
- excludeRenovate: values["exclude-renovate"],
60
- excludeTests: values["unit-tests"],
61
- funding: await optionalDefault(
62
- values.funding,
63
- defaults.funding
64
- ),
65
- owner,
66
- repository,
67
- skipGitHubApi: !!values["skip-github-api"],
68
- skipInstall: !!values["skip-install"],
69
- skipRemoval: !!values["skip-removal"],
70
- skipRestore: values["skip-restore"],
71
- skipUninstall: !!values["skip-uninstall"],
72
- title: await getPrefillOrPromptedOption(
73
- values.title,
74
- "What will the Title Case title of the repository be?",
75
- defaults.title ?? titleCase(repository).replaceAll("-", " ")
76
- )
77
- })
112
+ options: augmentedOptions
78
113
  };
79
114
  }
80
115
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/shared/options/readOptions.ts"],"sourcesContent":["import { parseArgs } from \"node:util\";\nimport { Octokit } from \"octokit\";\nimport { titleCase } from \"title-case\";\n\nimport { withSpinner } from \"../cli/spinners.js\";\nimport { InputBase, Options } from \"../types.js\";\nimport { allArgOptions } from \"./args.js\";\nimport { augmentOptionsWithExcludes } from \"./augmentOptionsWithExcludes.js\";\nimport { ensureRepositoryExists } from \"./ensureRepositoryExists.js\";\nimport { getOctokit } from \"./getOctokit.js\";\nimport { getPrefillOrPromptedOption } from \"./getPrefillOrPromptedOption.js\";\nimport { optionalDefault } from \"./optionalDefault.js\";\nimport { getGitAndNpmDefaults } from \"./readGitAndNpmDefaults/index.js\";\n\nexport interface OctokitAndOptions {\n\toctokit: Octokit | undefined;\n\toptions: Options;\n}\n\nexport async function readOptions(args: string[]): Promise<OctokitAndOptions> {\n\tconst defaults = await getGitAndNpmDefaults();\n\tconst { values } = parseArgs({\n\t\targs,\n\t\toptions: allArgOptions,\n\t\tstrict: false,\n\t\ttokens: true,\n\t});\n\n\tconst owner = await getPrefillOrPromptedOption(\n\t\tvalues.owner as string | undefined,\n\t\t\"What organization or user will the repository be under?\",\n\t\tdefaults.owner,\n\t);\n\n\tconst { octokit, repository } = await ensureRepositoryExists(\n\t\tvalues[\"skip-github-api\"]\n\t\t\t? undefined\n\t\t\t: await withSpinner(\"Checking GitHub authentication\", getOctokit),\n\t\t{\n\t\t\tcreateRepository: values[\"create-repository\"] as boolean | undefined,\n\t\t\towner,\n\t\t\trepository: await getPrefillOrPromptedOption(\n\t\t\t\tvalues.repository as string | undefined,\n\t\t\t\t\"What will the kebab-case name of the repository be?\",\n\t\t\t\tdefaults.repository,\n\t\t\t),\n\t\t},\n\t);\n\n\treturn {\n\t\toctokit,\n\t\toptions: await augmentOptionsWithExcludes({\n\t\t\tauthor:\n\t\t\t\t(values.author as string | undefined) ??\n\t\t\t\tdefaults.author ??\n\t\t\t\towner.toLowerCase(),\n\t\t\tbase: values.base as InputBase,\n\t\t\tcreateRepository: values[\"create-repository\"] as boolean | undefined,\n\t\t\tdescription: await getPrefillOrPromptedOption(\n\t\t\t\tvalues.description as string | undefined,\n\t\t\t\t\"How would you describe the new package?\",\n\t\t\t\tdefaults.description ?? \"A very lovely package. Hooray!\",\n\t\t\t),\n\t\t\temail: (values.email as string | undefined) ?? defaults.email,\n\t\t\texcludeCompliance: values[\"exclude-compliance\"] as boolean | undefined,\n\t\t\texcludeContributors: values[\"exclude-contributors\"] as\n\t\t\t\t| boolean\n\t\t\t\t| undefined,\n\t\t\texcludeLintJson: values[\"exclude-lint-json\"] as boolean | undefined,\n\t\t\texcludeLintKnip: values[\"exclude-lint-knip\"] as boolean | undefined,\n\t\t\texcludeLintMd: values[\"exclude-lint-md\"] as boolean | undefined,\n\t\t\texcludeLintPackageJson: values[\"exclude-lint-package-json\"] as\n\t\t\t\t| boolean\n\t\t\t\t| undefined,\n\t\t\texcludeLintPackages: values[\"exclude-lint-packages\"] as\n\t\t\t\t| boolean\n\t\t\t\t| undefined,\n\t\t\texcludeLintPerfectionist: values[\"exclude-lint-perfectionist\"] as\n\t\t\t\t| boolean\n\t\t\t\t| undefined,\n\t\t\texcludeLintSpelling: values[\"exclude-lint-spelling\"] as\n\t\t\t\t| boolean\n\t\t\t\t| undefined,\n\t\t\texcludeLintYml: values[\"exclude-lint-yml\"] as boolean | undefined,\n\t\t\texcludeReleases: values[\"exclude-releases\"] as boolean | undefined,\n\t\t\texcludeRenovate: values[\"exclude-renovate\"] as boolean | undefined,\n\t\t\texcludeTests: values[\"unit-tests\"] as boolean | undefined,\n\t\t\tfunding: await optionalDefault(\n\t\t\t\tvalues.funding as string | undefined,\n\t\t\t\tdefaults.funding,\n\t\t\t),\n\t\t\towner,\n\t\t\trepository: repository,\n\t\t\tskipGitHubApi: !!values[\"skip-github-api\"],\n\t\t\tskipInstall: !!values[\"skip-install\"],\n\t\t\tskipRemoval: !!values[\"skip-removal\"],\n\t\t\tskipRestore: values[\"skip-restore\"] as boolean | undefined,\n\t\t\tskipUninstall: !!values[\"skip-uninstall\"],\n\t\t\ttitle: await getPrefillOrPromptedOption(\n\t\t\t\tvalues.title as string | undefined,\n\t\t\t\t\"What will the Title Case title of the repository be?\",\n\t\t\t\tdefaults.title ?? titleCase(repository).replaceAll(\"-\", \" \"),\n\t\t\t),\n\t\t}),\n\t};\n}\n"],"mappings":"AAAA,SAAS,iBAAiB;AAE1B,SAAS,iBAAiB;AAE1B,SAAS,mBAAmB;AAE5B,SAAS,qBAAqB;AAC9B,SAAS,kCAAkC;AAC3C,SAAS,8BAA8B;AACvC,SAAS,kBAAkB;AAC3B,SAAS,kCAAkC;AAC3C,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AAOrC,eAAsB,YAAY,MAA4C;AAC7E,QAAM,WAAW,MAAM,qBAAqB;AAC5C,QAAM,EAAE,OAAO,IAAI,UAAU;AAAA,IAC5B;AAAA,IACA,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,QAAQ;AAAA,EACT,CAAC;AAED,QAAM,QAAQ,MAAM;AAAA,IACnB,OAAO;AAAA,IACP;AAAA,IACA,SAAS;AAAA,EACV;AAEA,QAAM,EAAE,SAAS,WAAW,IAAI,MAAM;AAAA,IACrC,OAAO,iBAAiB,IACrB,SACA,MAAM,YAAY,kCAAkC,UAAU;AAAA,IACjE;AAAA,MACC,kBAAkB,OAAO,mBAAmB;AAAA,MAC5C;AAAA,MACA,YAAY,MAAM;AAAA,QACjB,OAAO;AAAA,QACP;AAAA,QACA,SAAS;AAAA,MACV;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AAAA,IACN;AAAA,IACA,SAAS,MAAM,2BAA2B;AAAA,MACzC,QACE,OAAO,UACR,SAAS,UACT,MAAM,YAAY;AAAA,MACnB,MAAM,OAAO;AAAA,MACb,kBAAkB,OAAO,mBAAmB;AAAA,MAC5C,aAAa,MAAM;AAAA,QAClB,OAAO;AAAA,QACP;AAAA,QACA,SAAS,eAAe;AAAA,MACzB;AAAA,MACA,OAAQ,OAAO,SAAgC,SAAS;AAAA,MACxD,mBAAmB,OAAO,oBAAoB;AAAA,MAC9C,qBAAqB,OAAO,sBAAsB;AAAA,MAGlD,iBAAiB,OAAO,mBAAmB;AAAA,MAC3C,iBAAiB,OAAO,mBAAmB;AAAA,MAC3C,eAAe,OAAO,iBAAiB;AAAA,MACvC,wBAAwB,OAAO,2BAA2B;AAAA,MAG1D,qBAAqB,OAAO,uBAAuB;AAAA,MAGnD,0BAA0B,OAAO,4BAA4B;AAAA,MAG7D,qBAAqB,OAAO,uBAAuB;AAAA,MAGnD,gBAAgB,OAAO,kBAAkB;AAAA,MACzC,iBAAiB,OAAO,kBAAkB;AAAA,MAC1C,iBAAiB,OAAO,kBAAkB;AAAA,MAC1C,cAAc,OAAO,YAAY;AAAA,MACjC,SAAS,MAAM;AAAA,QACd,OAAO;AAAA,QACP,SAAS;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MACA,eAAe,CAAC,CAAC,OAAO,iBAAiB;AAAA,MACzC,aAAa,CAAC,CAAC,OAAO,cAAc;AAAA,MACpC,aAAa,CAAC,CAAC,OAAO,cAAc;AAAA,MACpC,aAAa,OAAO,cAAc;AAAA,MAClC,eAAe,CAAC,CAAC,OAAO,gBAAgB;AAAA,MACxC,OAAO,MAAM;AAAA,QACZ,OAAO;AAAA,QACP;AAAA,QACA,SAAS,SAAS,UAAU,UAAU,EAAE,WAAW,KAAK,GAAG;AAAA,MAC5D;AAAA,IACD,CAAC;AAAA,EACF;AACD;","names":[]}
1
+ {"version":3,"sources":["../../../src/shared/options/readOptions.ts"],"sourcesContent":["import { parseArgs } from \"node:util\";\nimport { Octokit } from \"octokit\";\nimport { titleCase } from \"title-case\";\n\nimport { withSpinner } from \"../cli/spinners.js\";\nimport { InputBase, Options } from \"../types.js\";\nimport { allArgOptions } from \"./args.js\";\nimport { augmentOptionsWithExcludes } from \"./augmentOptionsWithExcludes.js\";\nimport { ensureRepositoryExists } from \"./ensureRepositoryExists.js\";\nimport { getOctokit } from \"./getOctokit.js\";\nimport { getPrefillOrPromptedOption } from \"./getPrefillOrPromptedOption.js\";\nimport { getGitAndNpmDefaults } from \"./readGitAndNpmDefaults/index.js\";\n\nexport interface OctokitAndOptions {\n\toctokit: Octokit | undefined;\n\toptions: Options;\n}\n\nexport interface OptionsParseCancelled {\n\tcancelled: true;\n\toptions: Partial<Options>;\n}\n\nexport interface OptionsParseSuccess extends OctokitAndOptions {\n\tcancelled: false;\n}\n\nexport type OptionsParseResult = OptionsParseCancelled | OptionsParseSuccess;\n\nexport async function readOptions(args: string[]): Promise<OptionsParseResult> {\n\tconst defaults = await getGitAndNpmDefaults();\n\tconst { values } = parseArgs({\n\t\targs,\n\t\toptions: allArgOptions,\n\t\tstrict: false,\n\t\ttokens: true,\n\t});\n\n\tconst options = {\n\t\tauthor: values.author as string | undefined,\n\t\tbase: values.base as InputBase,\n\t\tcreateRepository: values[\"create-repository\"] as boolean | undefined,\n\t\tdescription: values.description as string | undefined,\n\t\temail: values.email as string | undefined,\n\t\texcludeCompliance: values[\"exclude-compliance\"] as boolean | undefined,\n\t\texcludeContributors: values[\"exclude-contributors\"] as boolean | undefined,\n\t\texcludeLintJson: values[\"exclude-lint-json\"] as boolean | undefined,\n\t\texcludeLintKnip: values[\"exclude-lint-knip\"] as boolean | undefined,\n\t\texcludeLintMd: values[\"exclude-lint-md\"] as boolean | undefined,\n\t\texcludeLintPackageJson: values[\"exclude-lint-package-json\"] as\n\t\t\t| boolean\n\t\t\t| undefined,\n\t\texcludeLintPackages: values[\"exclude-lint-packages\"] as boolean | undefined,\n\t\texcludeLintPerfectionist: values[\"exclude-lint-perfectionist\"] as\n\t\t\t| boolean\n\t\t\t| undefined,\n\t\texcludeLintSpelling: values[\"exclude-lint-spelling\"] as boolean | undefined,\n\t\texcludeLintYml: values[\"exclude-lint-yml\"] as boolean | undefined,\n\t\texcludeReleases: values[\"exclude-releases\"] as boolean | undefined,\n\t\texcludeRenovate: values[\"exclude-renovate\"] as boolean | undefined,\n\t\texcludeTests: values[\"unit-tests\"] as boolean | undefined,\n\t\tfunding: values.funding as string | undefined,\n\t\towner: values.owner as string | undefined,\n\t\trepository: values.repository as string | undefined,\n\t\tskipGitHubApi: !!values[\"skip-github-api\"],\n\t\tskipInstall: !!values[\"skip-install\"],\n\t\tskipRemoval: !!values[\"skip-removal\"],\n\t\tskipRestore: values[\"skip-restore\"] as boolean | undefined,\n\t\tskipUninstall: !!values[\"skip-uninstall\"],\n\t\ttitle: values.title as string | undefined,\n\t};\n\n\toptions.owner ??= await getPrefillOrPromptedOption(\n\t\tvalues.owner as string | undefined,\n\t\t\"What organization or user will the repository be under?\",\n\t\tdefaults.owner,\n\t);\n\tif (!options.owner) {\n\t\treturn {\n\t\t\tcancelled: true,\n\t\t\toptions,\n\t\t};\n\t}\n\n\toptions.repository ??= await getPrefillOrPromptedOption(\n\t\toptions.repository,\n\t\t\"What will the kebab-case name of the repository be?\",\n\t\tdefaults.repository,\n\t);\n\tif (!options.repository) {\n\t\treturn {\n\t\t\tcancelled: true,\n\t\t\toptions,\n\t\t};\n\t}\n\n\tconst { octokit, repository } = await ensureRepositoryExists(\n\t\tvalues[\"skip-github-api\"]\n\t\t\t? undefined\n\t\t\t: await withSpinner(\"Checking GitHub authentication\", getOctokit),\n\t\t{\n\t\t\tcreateRepository: options.createRepository,\n\t\t\towner: options.owner,\n\t\t\trepository: options.repository,\n\t\t},\n\t);\n\tif (!repository) {\n\t\treturn { cancelled: true, options };\n\t}\n\n\toptions.description ??= await getPrefillOrPromptedOption(\n\t\toptions.description,\n\t\t\"How would you describe the new package?\",\n\t\tdefaults.description ?? \"A very lovely package. Hooray!\",\n\t);\n\tif (!options.description) {\n\t\treturn { cancelled: true, options };\n\t}\n\n\toptions.title ??= await getPrefillOrPromptedOption(\n\t\toptions.title,\n\t\t\"What will the Title Case title of the repository be?\",\n\t\tdefaults.title ?? titleCase(repository).replaceAll(\"-\", \" \"),\n\t);\n\tif (!options.title) {\n\t\treturn { cancelled: true, options };\n\t}\n\n\tconst augmentedOptions = await augmentOptionsWithExcludes({\n\t\t...options,\n\t\tauthor: options.author ?? defaults.owner,\n\t\temail: options.email ?? defaults.email,\n\t\tfunding: options.funding ?? defaults.funding,\n\t\trepository,\n\t} as Options);\n\n\tif (!augmentedOptions) {\n\t\treturn {\n\t\t\tcancelled: true,\n\t\t\toptions,\n\t\t};\n\t}\n\n\treturn {\n\t\tcancelled: false,\n\t\toctokit,\n\t\toptions: augmentedOptions,\n\t};\n}\n"],"mappings":"AAAA,SAAS,iBAAiB;AAE1B,SAAS,iBAAiB;AAE1B,SAAS,mBAAmB;AAE5B,SAAS,qBAAqB;AAC9B,SAAS,kCAAkC;AAC3C,SAAS,8BAA8B;AACvC,SAAS,kBAAkB;AAC3B,SAAS,kCAAkC;AAC3C,SAAS,4BAA4B;AAkBrC,eAAsB,YAAY,MAA6C;AAC9E,QAAM,WAAW,MAAM,qBAAqB;AAC5C,QAAM,EAAE,OAAO,IAAI,UAAU;AAAA,IAC5B;AAAA,IACA,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,QAAQ;AAAA,EACT,CAAC;AAED,QAAM,UAAU;AAAA,IACf,QAAQ,OAAO;AAAA,IACf,MAAM,OAAO;AAAA,IACb,kBAAkB,OAAO,mBAAmB;AAAA,IAC5C,aAAa,OAAO;AAAA,IACpB,OAAO,OAAO;AAAA,IACd,mBAAmB,OAAO,oBAAoB;AAAA,IAC9C,qBAAqB,OAAO,sBAAsB;AAAA,IAClD,iBAAiB,OAAO,mBAAmB;AAAA,IAC3C,iBAAiB,OAAO,mBAAmB;AAAA,IAC3C,eAAe,OAAO,iBAAiB;AAAA,IACvC,wBAAwB,OAAO,2BAA2B;AAAA,IAG1D,qBAAqB,OAAO,uBAAuB;AAAA,IACnD,0BAA0B,OAAO,4BAA4B;AAAA,IAG7D,qBAAqB,OAAO,uBAAuB;AAAA,IACnD,gBAAgB,OAAO,kBAAkB;AAAA,IACzC,iBAAiB,OAAO,kBAAkB;AAAA,IAC1C,iBAAiB,OAAO,kBAAkB;AAAA,IAC1C,cAAc,OAAO,YAAY;AAAA,IACjC,SAAS,OAAO;AAAA,IAChB,OAAO,OAAO;AAAA,IACd,YAAY,OAAO;AAAA,IACnB,eAAe,CAAC,CAAC,OAAO,iBAAiB;AAAA,IACzC,aAAa,CAAC,CAAC,OAAO,cAAc;AAAA,IACpC,aAAa,CAAC,CAAC,OAAO,cAAc;AAAA,IACpC,aAAa,OAAO,cAAc;AAAA,IAClC,eAAe,CAAC,CAAC,OAAO,gBAAgB;AAAA,IACxC,OAAO,OAAO;AAAA,EACf;AAEA,UAAQ,UAAU,MAAM;AAAA,IACvB,OAAO;AAAA,IACP;AAAA,IACA,SAAS;AAAA,EACV;AACA,MAAI,CAAC,QAAQ,OAAO;AACnB,WAAO;AAAA,MACN,WAAW;AAAA,MACX;AAAA,IACD;AAAA,EACD;AAEA,UAAQ,eAAe,MAAM;AAAA,IAC5B,QAAQ;AAAA,IACR;AAAA,IACA,SAAS;AAAA,EACV;AACA,MAAI,CAAC,QAAQ,YAAY;AACxB,WAAO;AAAA,MACN,WAAW;AAAA,MACX;AAAA,IACD;AAAA,EACD;AAEA,QAAM,EAAE,SAAS,WAAW,IAAI,MAAM;AAAA,IACrC,OAAO,iBAAiB,IACrB,SACA,MAAM,YAAY,kCAAkC,UAAU;AAAA,IACjE;AAAA,MACC,kBAAkB,QAAQ;AAAA,MAC1B,OAAO,QAAQ;AAAA,MACf,YAAY,QAAQ;AAAA,IACrB;AAAA,EACD;AACA,MAAI,CAAC,YAAY;AAChB,WAAO,EAAE,WAAW,MAAM,QAAQ;AAAA,EACnC;AAEA,UAAQ,gBAAgB,MAAM;AAAA,IAC7B,QAAQ;AAAA,IACR;AAAA,IACA,SAAS,eAAe;AAAA,EACzB;AACA,MAAI,CAAC,QAAQ,aAAa;AACzB,WAAO,EAAE,WAAW,MAAM,QAAQ;AAAA,EACnC;AAEA,UAAQ,UAAU,MAAM;AAAA,IACvB,QAAQ;AAAA,IACR;AAAA,IACA,SAAS,SAAS,UAAU,UAAU,EAAE,WAAW,KAAK,GAAG;AAAA,EAC5D;AACA,MAAI,CAAC,QAAQ,OAAO;AACnB,WAAO,EAAE,WAAW,MAAM,QAAQ;AAAA,EACnC;AAEA,QAAM,mBAAmB,MAAM,2BAA2B;AAAA,IACzD,GAAG;AAAA,IACH,QAAQ,QAAQ,UAAU,SAAS;AAAA,IACnC,OAAO,QAAQ,SAAS,SAAS;AAAA,IACjC,SAAS,QAAQ,WAAW,SAAS;AAAA,IACrC;AAAA,EACD,CAAY;AAEZ,MAAI,CAAC,kBAAkB;AACtB,WAAO;AAAA,MACN,WAAW;AAAA,MACX;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AAAA,IACN,WAAW;AAAA,IACX;AAAA,IACA,SAAS;AAAA,EACV;AACD;","names":[]}
@@ -1,4 +1,3 @@
1
- declare function handleCancel(): never;
2
- declare function handlePromptCancel<Value>(value: Value): Exclude<Value, symbol>;
1
+ declare function filterPromptCancel<Value>(value: Value | symbol): Value | undefined;
3
2
 
4
- export { handleCancel, handlePromptCancel };
3
+ export { filterPromptCancel };
@@ -1,16 +1,8 @@
1
1
  import * as prompts from "@clack/prompts";
2
- function handleCancel() {
3
- prompts.cancel("Operation cancelled. Exiting - maybe another time? \u{1F44B}");
4
- process.exit(1);
5
- }
6
- function handlePromptCancel(value) {
7
- if (prompts.isCancel(value)) {
8
- handleCancel();
9
- }
10
- return value;
2
+ function filterPromptCancel(value) {
3
+ return prompts.isCancel(value) ? void 0 : value;
11
4
  }
12
5
  export {
13
- handleCancel,
14
- handlePromptCancel
6
+ filterPromptCancel
15
7
  };
16
8
  //# sourceMappingURL=prompts.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/shared/prompts.ts"],"sourcesContent":["import * as prompts from \"@clack/prompts\";\n\nexport function handleCancel(): never {\n\tprompts.cancel(\"Operation cancelled. Exiting - maybe another time? 👋\");\n\t// eslint-disable-next-line n/no-process-exit\n\tprocess.exit(1);\n}\n\nexport function handlePromptCancel<Value>(value: Value) {\n\tif (prompts.isCancel(value)) {\n\t\thandleCancel();\n\t}\n\n\treturn value as Exclude<Value, symbol>;\n}\n"],"mappings":"AAAA,YAAY,aAAa;AAElB,SAAS,eAAsB;AACrC,UAAQ,OAAO,8DAAuD;AAEtE,UAAQ,KAAK,CAAC;AACf;AAEO,SAAS,mBAA0B,OAAc;AACvD,MAAI,QAAQ,SAAS,KAAK,GAAG;AAC5B,iBAAa;AAAA,EACd;AAEA,SAAO;AACR;","names":[]}
1
+ {"version":3,"sources":["../../src/shared/prompts.ts"],"sourcesContent":["import * as prompts from \"@clack/prompts\";\n\nexport function filterPromptCancel<Value>(value: Value | symbol) {\n\treturn prompts.isCancel(value) ? undefined : value;\n}\n"],"mappings":"AAAA,YAAY,aAAa;AAElB,SAAS,mBAA0B,OAAuB;AAChE,SAAO,QAAQ,SAAS,KAAK,IAAI,SAAY;AAC9C;","names":[]}
@@ -2,6 +2,6 @@ interface RunOrRestoreOptions {
2
2
  run: () => Promise<void>;
3
3
  skipRestore: boolean | undefined;
4
4
  }
5
- declare function runOrRestore({ run, skipRestore }: RunOrRestoreOptions): Promise<1 | 0>;
5
+ declare function runOrRestore({ run, skipRestore }: RunOrRestoreOptions): Promise<2 | 0>;
6
6
 
7
7
  export { RunOrRestoreOptions, runOrRestore };
@@ -1,38 +1,33 @@
1
1
  import * as prompts from "@clack/prompts";
2
2
  import chalk from "chalk";
3
3
  import { $ } from "execa";
4
- import { handlePromptCancel } from "./prompts.js";
4
+ import { logLine } from "./cli/lines.js";
5
5
  async function runOrRestore({ run, skipRestore }) {
6
6
  try {
7
7
  await run();
8
8
  return 0;
9
9
  } catch (error) {
10
- prompts.outro(
11
- chalk.red`Looks like there was a problem. Correct it and try again? 😕`
12
- );
13
- console.log();
10
+ logLine();
14
11
  console.log(error);
15
12
  if (skipRestore) {
16
- console.log();
17
- console.log(chalk.gray`Leaving changes to the local directory on disk.`);
18
- console.log();
13
+ logLine();
14
+ logLine(chalk.gray`Leaving changes to the local directory on disk.`);
19
15
  } else {
20
16
  const shouldRestore = await prompts.confirm({
21
17
  message: "Do you want to restore the repository to how it was?"
22
18
  });
23
- handlePromptCancel(shouldRestore);
24
19
  if (shouldRestore) {
25
- console.log();
26
- console.log(
27
- chalk.gray`Resetting repository using`,
28
- chalk.reset`git restore .`
20
+ logLine();
21
+ logLine(
22
+ [
23
+ chalk.gray`Resetting repository using`,
24
+ chalk.reset`git restore .`
25
+ ].join(" ")
29
26
  );
30
27
  await $`git restore .`;
31
- console.log("Repository is reset. Ready to try again?");
32
- console.log();
33
28
  }
34
29
  }
35
- return 1;
30
+ return 2;
36
31
  }
37
32
  }
38
33
  export {
@@ -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 { handlePromptCancel } from \"./prompts.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\tprompts.outro(\n\t\t\tchalk.red`Looks like there was a problem. Correct it and try again? 😕`,\n\t\t);\n\n\t\tconsole.log();\n\t\tconsole.log(error);\n\n\t\tif (skipRestore) {\n\t\t\tconsole.log();\n\t\t\tconsole.log(chalk.gray`Leaving changes to the local directory on disk.`);\n\t\t\tconsole.log();\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\thandlePromptCancel(shouldRestore);\n\n\t\t\tif (shouldRestore) {\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(\n\t\t\t\t\tchalk.gray`Resetting repository using`,\n\t\t\t\t\tchalk.reset`git restore .`,\n\t\t\t\t);\n\t\t\t\tawait $`git restore .`;\n\t\t\t\tconsole.log(\"Repository is reset. Ready to try again?\");\n\t\t\t\tconsole.log();\n\t\t\t}\n\t\t}\n\n\t\treturn 1;\n\t}\n}\n"],"mappings":"AAAA,YAAY,aAAa;AACzB,OAAO,WAAW;AAClB,SAAS,SAAS;AAElB,SAAS,0BAA0B;AAOnC,eAAsB,aAAa,EAAE,KAAK,YAAY,GAAwB;AAC7E,MAAI;AACH,UAAM,IAAI;AACV,WAAO;AAAA,EACR,SAAS,OAAO;AACf,YAAQ;AAAA,MACP,MAAM;AAAA,IACP;AAEA,YAAQ,IAAI;AACZ,YAAQ,IAAI,KAAK;AAEjB,QAAI,aAAa;AAChB,cAAQ,IAAI;AACZ,cAAQ,IAAI,MAAM,qDAAqD;AACvE,cAAQ,IAAI;AAAA,IACb,OAAO;AACN,YAAM,gBAAgB,MAAM,QAAQ,QAAQ;AAAA,QAC3C,SAAS;AAAA,MACV,CAAC;AAED,yBAAmB,aAAa;AAEhC,UAAI,eAAe;AAClB,gBAAQ,IAAI;AACZ,gBAAQ;AAAA,UACP,MAAM;AAAA,UACN,MAAM;AAAA,QACP;AACA,cAAM;AACN,gBAAQ,IAAI,0CAA0C;AACtD,gBAAQ,IAAI;AAAA,MACb;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\";\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":[]}
@@ -47,7 +47,7 @@ async function writePackageJson(options) {
47
47
  },
48
48
  main: "./lib/index.js",
49
49
  name: options.repository,
50
- packageManager: "pnpm@8.5.0",
50
+ packageManager: "pnpm@8.7.0",
51
51
  publishConfig: {
52
52
  provenance: true
53
53
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/steps/writing/creation/writePackageJson.ts"],"sourcesContent":["import { readFileSafeAsJson } from \"../../../shared/readFileSafeAsJson.js\";\nimport { Options } from \"../../../shared/types.js\";\nimport { formatJson } from \"./formatters/formatJson.js\";\n\nconst devDependenciesToRemove = [\n\t\"@babel/core\",\n\t\"@babel/preset-env\",\n\t\"@babel/preset-react\",\n\t\"@babel/preset-typescript\",\n\t\"@swc/jest\",\n\t\"ava\",\n\t\"babel-jest\",\n\t\"commitlint\",\n\t\"cson-parser\",\n\t\"esbuild\",\n\t\"eslint-config-prettier\",\n\t\"eslint-plugin-prettier\",\n\t\"eslint-plugin-simple-import-sort\",\n\t\"jasmine\",\n\t\"jest\",\n\t\"mocha\",\n\t\"npm-run-all\",\n\t\"pretty-quick\",\n];\n\nexport async function writePackageJson(options: Options) {\n\tconst existingPackageJson =\n\t\t((await readFileSafeAsJson(\"./package.json\")) as null | object) ?? {};\n\n\treturn await formatJson({\n\t\t// If we didn't already have a version, set it to 0.0.0\n\t\tversion: \"0.0.0\",\n\n\t\t// To start, copy over all existing package fields (e.g. \"dependencies\")\n\t\t...existingPackageJson,\n\n\t\tauthor: { email: options.email, name: options.author },\n\t\tdescription: options.description,\n\n\t\t// We copy all existing dev dependencies except those we know are not used anymore\n\t\tdevDependencies: copyDevDependencies(existingPackageJson),\n\n\t\t// Remove fields we know we don't want, such as old or redundant configs\n\t\teslintConfig: undefined,\n\t\thusky: undefined,\n\t\tprettierConfig: undefined,\n\t\ttypes: undefined,\n\n\t\t// The rest of the fields are ones we know from our template\n\t\tengines: {\n\t\t\tnode: \">=18\",\n\t\t},\n\t\tfiles: [\"lib/\", \"package.json\", \"LICENSE.md\", \"README.md\"],\n\t\tlicense: \"MIT\",\n\t\t\"lint-staged\": {\n\t\t\t\"*\": \"prettier --ignore-unknown --write\",\n\t\t},\n\t\tmain: \"./lib/index.js\",\n\t\tname: options.repository,\n\t\tpackageManager: \"pnpm@8.5.0\",\n\t\tpublishConfig: {\n\t\t\tprovenance: true,\n\t\t},\n\t\trepository: {\n\t\t\ttype: \"git\",\n\t\t\turl: `https://github.com/${options.owner}/${options.repository}`,\n\t\t},\n\t\tscripts: {\n\t\t\tbuild: \"tsup\",\n\t\t\tformat: 'prettier \"**/*\" --ignore-unknown',\n\t\t\t\"format:write\": \"pnpm format --write\",\n\t\t\tlint: \"eslint . .*js --max-warnings 0 --report-unused-disable-directives\",\n\t\t\t...(!options.excludeLintKnip && {\n\t\t\t\t\"lint:knip\": \"knip\",\n\t\t\t}),\n\t\t\t...(!options.excludeLintMd && {\n\t\t\t\t\"lint:md\":\n\t\t\t\t\t'markdownlint \"**/*.md\" \".github/**/*.md\" --rules sentences-per-line',\n\t\t\t}),\n\t\t\t...(!options.excludeLintPackageJson && {\n\t\t\t\t\"lint:package-json\": \"npmPkgJsonLint .\",\n\t\t\t}),\n\t\t\t...(!options.excludeLintPackages && {\n\t\t\t\t\"lint:packages\": \"pnpm dedupe --check\",\n\t\t\t}),\n\t\t\t...(!options.excludeLintSpelling && {\n\t\t\t\t\"lint:spelling\": 'cspell \"**\" \".github/**/*\"',\n\t\t\t}),\n\t\t\tprepare: \"husky install\",\n\t\t\t...(!options.excludeReleases && {\n\t\t\t\t\"should-semantic-release\": \"should-semantic-release --verbose\",\n\t\t\t}),\n\t\t\t...(!options.excludeReleases && { test: \"vitest\" }),\n\t\t\ttsc: \"tsc\",\n\t\t},\n\t\ttype: \"module\",\n\t});\n}\n\nfunction copyDevDependencies(existingPackageJson: object) {\n\tconst devDependencies =\n\t\t\"devDependencies\" in existingPackageJson\n\t\t\t? (existingPackageJson.devDependencies as Record<string, string>)\n\t\t\t: {};\n\n\tfor (const devDependencyToRemove of devDependenciesToRemove) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\tdelete devDependencies[devDependencyToRemove];\n\t}\n\n\treturn devDependencies;\n}\n"],"mappings":"AAAA,SAAS,0BAA0B;AAEnC,SAAS,kBAAkB;AAE3B,MAAM,0BAA0B;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEA,eAAsB,iBAAiB,SAAkB;AACxD,QAAM,sBACH,MAAM,mBAAmB,gBAAgB,KAAwB,CAAC;AAErE,SAAO,MAAM,WAAW;AAAA;AAAA,IAEvB,SAAS;AAAA;AAAA,IAGT,GAAG;AAAA,IAEH,QAAQ,EAAE,OAAO,QAAQ,OAAO,MAAM,QAAQ,OAAO;AAAA,IACrD,aAAa,QAAQ;AAAA;AAAA,IAGrB,iBAAiB,oBAAoB,mBAAmB;AAAA;AAAA,IAGxD,cAAc;AAAA,IACd,OAAO;AAAA,IACP,gBAAgB;AAAA,IAChB,OAAO;AAAA;AAAA,IAGP,SAAS;AAAA,MACR,MAAM;AAAA,IACP;AAAA,IACA,OAAO,CAAC,QAAQ,gBAAgB,cAAc,WAAW;AAAA,IACzD,SAAS;AAAA,IACT,eAAe;AAAA,MACd,KAAK;AAAA,IACN;AAAA,IACA,MAAM;AAAA,IACN,MAAM,QAAQ;AAAA,IACd,gBAAgB;AAAA,IAChB,eAAe;AAAA,MACd,YAAY;AAAA,IACb;AAAA,IACA,YAAY;AAAA,MACX,MAAM;AAAA,MACN,KAAK,sBAAsB,QAAQ,KAAK,IAAI,QAAQ,UAAU;AAAA,IAC/D;AAAA,IACA,SAAS;AAAA,MACR,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,gBAAgB;AAAA,MAChB,MAAM;AAAA,MACN,GAAI,CAAC,QAAQ,mBAAmB;AAAA,QAC/B,aAAa;AAAA,MACd;AAAA,MACA,GAAI,CAAC,QAAQ,iBAAiB;AAAA,QAC7B,WACC;AAAA,MACF;AAAA,MACA,GAAI,CAAC,QAAQ,0BAA0B;AAAA,QACtC,qBAAqB;AAAA,MACtB;AAAA,MACA,GAAI,CAAC,QAAQ,uBAAuB;AAAA,QACnC,iBAAiB;AAAA,MAClB;AAAA,MACA,GAAI,CAAC,QAAQ,uBAAuB;AAAA,QACnC,iBAAiB;AAAA,MAClB;AAAA,MACA,SAAS;AAAA,MACT,GAAI,CAAC,QAAQ,mBAAmB;AAAA,QAC/B,2BAA2B;AAAA,MAC5B;AAAA,MACA,GAAI,CAAC,QAAQ,mBAAmB,EAAE,MAAM,SAAS;AAAA,MACjD,KAAK;AAAA,IACN;AAAA,IACA,MAAM;AAAA,EACP,CAAC;AACF;AAEA,SAAS,oBAAoB,qBAA6B;AACzD,QAAM,kBACL,qBAAqB,sBACjB,oBAAoB,kBACrB,CAAC;AAEL,aAAW,yBAAyB,yBAAyB;AAE5D,WAAO,gBAAgB,qBAAqB;AAAA,EAC7C;AAEA,SAAO;AACR;","names":[]}
1
+ {"version":3,"sources":["../../../../src/steps/writing/creation/writePackageJson.ts"],"sourcesContent":["import { readFileSafeAsJson } from \"../../../shared/readFileSafeAsJson.js\";\nimport { Options } from \"../../../shared/types.js\";\nimport { formatJson } from \"./formatters/formatJson.js\";\n\nconst devDependenciesToRemove = [\n\t\"@babel/core\",\n\t\"@babel/preset-env\",\n\t\"@babel/preset-react\",\n\t\"@babel/preset-typescript\",\n\t\"@swc/jest\",\n\t\"ava\",\n\t\"babel-jest\",\n\t\"commitlint\",\n\t\"cson-parser\",\n\t\"esbuild\",\n\t\"eslint-config-prettier\",\n\t\"eslint-plugin-prettier\",\n\t\"eslint-plugin-simple-import-sort\",\n\t\"jasmine\",\n\t\"jest\",\n\t\"mocha\",\n\t\"npm-run-all\",\n\t\"pretty-quick\",\n];\n\nexport async function writePackageJson(options: Options) {\n\tconst existingPackageJson =\n\t\t((await readFileSafeAsJson(\"./package.json\")) as null | object) ?? {};\n\n\treturn await formatJson({\n\t\t// If we didn't already have a version, set it to 0.0.0\n\t\tversion: \"0.0.0\",\n\n\t\t// To start, copy over all existing package fields (e.g. \"dependencies\")\n\t\t...existingPackageJson,\n\n\t\tauthor: { email: options.email, name: options.author },\n\t\tdescription: options.description,\n\n\t\t// We copy all existing dev dependencies except those we know are not used anymore\n\t\tdevDependencies: copyDevDependencies(existingPackageJson),\n\n\t\t// Remove fields we know we don't want, such as old or redundant configs\n\t\teslintConfig: undefined,\n\t\thusky: undefined,\n\t\tprettierConfig: undefined,\n\t\ttypes: undefined,\n\n\t\t// The rest of the fields are ones we know from our template\n\t\tengines: {\n\t\t\tnode: \">=18\",\n\t\t},\n\t\tfiles: [\"lib/\", \"package.json\", \"LICENSE.md\", \"README.md\"],\n\t\tlicense: \"MIT\",\n\t\t\"lint-staged\": {\n\t\t\t\"*\": \"prettier --ignore-unknown --write\",\n\t\t},\n\t\tmain: \"./lib/index.js\",\n\t\tname: options.repository,\n\t\tpackageManager: \"pnpm@8.7.0\",\n\t\tpublishConfig: {\n\t\t\tprovenance: true,\n\t\t},\n\t\trepository: {\n\t\t\ttype: \"git\",\n\t\t\turl: `https://github.com/${options.owner}/${options.repository}`,\n\t\t},\n\t\tscripts: {\n\t\t\tbuild: \"tsup\",\n\t\t\tformat: 'prettier \"**/*\" --ignore-unknown',\n\t\t\t\"format:write\": \"pnpm format --write\",\n\t\t\tlint: \"eslint . .*js --max-warnings 0 --report-unused-disable-directives\",\n\t\t\t...(!options.excludeLintKnip && {\n\t\t\t\t\"lint:knip\": \"knip\",\n\t\t\t}),\n\t\t\t...(!options.excludeLintMd && {\n\t\t\t\t\"lint:md\":\n\t\t\t\t\t'markdownlint \"**/*.md\" \".github/**/*.md\" --rules sentences-per-line',\n\t\t\t}),\n\t\t\t...(!options.excludeLintPackageJson && {\n\t\t\t\t\"lint:package-json\": \"npmPkgJsonLint .\",\n\t\t\t}),\n\t\t\t...(!options.excludeLintPackages && {\n\t\t\t\t\"lint:packages\": \"pnpm dedupe --check\",\n\t\t\t}),\n\t\t\t...(!options.excludeLintSpelling && {\n\t\t\t\t\"lint:spelling\": 'cspell \"**\" \".github/**/*\"',\n\t\t\t}),\n\t\t\tprepare: \"husky install\",\n\t\t\t...(!options.excludeReleases && {\n\t\t\t\t\"should-semantic-release\": \"should-semantic-release --verbose\",\n\t\t\t}),\n\t\t\t...(!options.excludeReleases && { test: \"vitest\" }),\n\t\t\ttsc: \"tsc\",\n\t\t},\n\t\ttype: \"module\",\n\t});\n}\n\nfunction copyDevDependencies(existingPackageJson: object) {\n\tconst devDependencies =\n\t\t\"devDependencies\" in existingPackageJson\n\t\t\t? (existingPackageJson.devDependencies as Record<string, string>)\n\t\t\t: {};\n\n\tfor (const devDependencyToRemove of devDependenciesToRemove) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\tdelete devDependencies[devDependencyToRemove];\n\t}\n\n\treturn devDependencies;\n}\n"],"mappings":"AAAA,SAAS,0BAA0B;AAEnC,SAAS,kBAAkB;AAE3B,MAAM,0BAA0B;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEA,eAAsB,iBAAiB,SAAkB;AACxD,QAAM,sBACH,MAAM,mBAAmB,gBAAgB,KAAwB,CAAC;AAErE,SAAO,MAAM,WAAW;AAAA;AAAA,IAEvB,SAAS;AAAA;AAAA,IAGT,GAAG;AAAA,IAEH,QAAQ,EAAE,OAAO,QAAQ,OAAO,MAAM,QAAQ,OAAO;AAAA,IACrD,aAAa,QAAQ;AAAA;AAAA,IAGrB,iBAAiB,oBAAoB,mBAAmB;AAAA;AAAA,IAGxD,cAAc;AAAA,IACd,OAAO;AAAA,IACP,gBAAgB;AAAA,IAChB,OAAO;AAAA;AAAA,IAGP,SAAS;AAAA,MACR,MAAM;AAAA,IACP;AAAA,IACA,OAAO,CAAC,QAAQ,gBAAgB,cAAc,WAAW;AAAA,IACzD,SAAS;AAAA,IACT,eAAe;AAAA,MACd,KAAK;AAAA,IACN;AAAA,IACA,MAAM;AAAA,IACN,MAAM,QAAQ;AAAA,IACd,gBAAgB;AAAA,IAChB,eAAe;AAAA,MACd,YAAY;AAAA,IACb;AAAA,IACA,YAAY;AAAA,MACX,MAAM;AAAA,MACN,KAAK,sBAAsB,QAAQ,KAAK,IAAI,QAAQ,UAAU;AAAA,IAC/D;AAAA,IACA,SAAS;AAAA,MACR,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,gBAAgB;AAAA,MAChB,MAAM;AAAA,MACN,GAAI,CAAC,QAAQ,mBAAmB;AAAA,QAC/B,aAAa;AAAA,MACd;AAAA,MACA,GAAI,CAAC,QAAQ,iBAAiB;AAAA,QAC7B,WACC;AAAA,MACF;AAAA,MACA,GAAI,CAAC,QAAQ,0BAA0B;AAAA,QACtC,qBAAqB;AAAA,MACtB;AAAA,MACA,GAAI,CAAC,QAAQ,uBAAuB;AAAA,QACnC,iBAAiB;AAAA,MAClB;AAAA,MACA,GAAI,CAAC,QAAQ,uBAAuB;AAAA,QACnC,iBAAiB;AAAA,MAClB;AAAA,MACA,SAAS;AAAA,MACT,GAAI,CAAC,QAAQ,mBAAmB;AAAA,QAC/B,2BAA2B;AAAA,MAC5B;AAAA,MACA,GAAI,CAAC,QAAQ,mBAAmB,EAAE,MAAM,SAAS;AAAA,MACjD,KAAK;AAAA,IACN;AAAA,IACA,MAAM;AAAA,EACP,CAAC;AACF;AAEA,SAAS,oBAAoB,qBAA6B;AACzD,QAAM,kBACL,qBAAqB,sBACjB,oBAAoB,kBACrB,CAAC;AAEL,aAAW,yBAAyB,yBAAyB;AAE5D,WAAO,gBAAgB,qBAAqB;AAAA,EAC7C;AAEA,SAAO;AACR;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-typescript-app",
3
- "version": "1.29.20",
3
+ "version": "1.29.22",
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",
@@ -87,7 +87,7 @@
87
87
  "globby": "^13.2.2",
88
88
  "husky": "^8.0.3",
89
89
  "jsonc-eslint-parser": "^2.3.0",
90
- "knip": "2.20.2",
90
+ "knip": "2.21.0",
91
91
  "lint-staged": "^14.0.1",
92
92
  "markdownlint": "^0.30.0",
93
93
  "markdownlint-cli": "^0.35.0",
@@ -1,3 +0,0 @@
1
- declare function optionalDefault<T extends boolean | number | string>(value: T | undefined, getDefault?: (() => Promise<T | undefined>) | T | undefined): Promise<T | undefined>;
2
-
3
- export { optionalDefault };
@@ -1,13 +0,0 @@
1
- async function optionalDefault(value, getDefault) {
2
- if (value !== void 0) {
3
- return value;
4
- }
5
- if (typeof getDefault === "function") {
6
- return await getDefault();
7
- }
8
- return getDefault;
9
- }
10
- export {
11
- optionalDefault
12
- };
13
- //# sourceMappingURL=optionalDefault.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/shared/options/optionalDefault.ts"],"sourcesContent":["export async function optionalDefault<T extends boolean | number | string>(\n\tvalue: T | undefined,\n\tgetDefault?: (() => Promise<T | undefined>) | T | undefined,\n) {\n\tif (value !== undefined) {\n\t\treturn value;\n\t}\n\n\tif (typeof getDefault === \"function\") {\n\t\treturn await getDefault();\n\t}\n\n\treturn getDefault;\n}\n"],"mappings":"AAAA,eAAsB,gBACrB,OACA,YACC;AACD,MAAI,UAAU,QAAW;AACxB,WAAO;AAAA,EACR;AAEA,MAAI,OAAO,eAAe,YAAY;AACrC,WAAO,MAAM,WAAW;AAAA,EACzB;AAEA,SAAO;AACR;","names":[]}