create-tsdown 0.20.0 → 0.20.2

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.
package/dist/index.mjs CHANGED
@@ -1,3 +1,94 @@
1
- import { n as resolveOptions, r as templateOptions, t as create } from "./src-am5un8-C.mjs";
1
+ import process from "node:process";
2
+ import { styleText } from "node:util";
3
+ import { cancel, intro, isCancel, outro, select, spinner, text } from "@clack/prompts";
4
+ import { downloadTemplate } from "giget";
5
+ import { getUserAgent } from "package-manager-detector";
2
6
 
7
+ //#region src/index.ts
8
+ const templateOptions = [
9
+ {
10
+ value: "default",
11
+ label: "Default"
12
+ },
13
+ {
14
+ value: "minimal",
15
+ label: "Minimal"
16
+ },
17
+ {
18
+ value: "vue",
19
+ label: "Vue"
20
+ },
21
+ {
22
+ value: "react",
23
+ label: "React"
24
+ },
25
+ {
26
+ value: "react-compiler",
27
+ label: "React with React Compiler"
28
+ },
29
+ {
30
+ value: "solid",
31
+ label: "Solid"
32
+ },
33
+ {
34
+ value: "svelte",
35
+ label: "Svelte"
36
+ }
37
+ ];
38
+ /**
39
+ * Create a tsdown project.
40
+ */
41
+ async function create(path, options) {
42
+ intro(`Creating a tsdown project...`);
43
+ const resolved = await resolveOptions({
44
+ ...options,
45
+ path
46
+ });
47
+ const s = spinner();
48
+ s.start("Cloning the template...");
49
+ await downloadTemplate(`gh:sxzz/tsdown-templates/${resolved.template}`, { dir: resolved.path });
50
+ s.stop("Template cloned");
51
+ const pm = getUserAgent() || "npm";
52
+ outro(`Done! Now run:\n ${styleText("green", `cd ${resolved.path}`)}\n ${styleText("green", `${pm} install`)}\n ${styleText("green", `${pm} run build`)}\n\nFor more information, visit: ${styleText("underline", `https://tsdown.dev/`)}`);
53
+ }
54
+ /**
55
+ * Resolve the user options and configs
56
+ * @param options The user options
57
+ * @returns The resolved options
58
+ */
59
+ async function resolveOptions(options) {
60
+ let path = options.path;
61
+ if (!path) {
62
+ const defaultPath = "./my-tsdown-package";
63
+ path = await text({
64
+ message: "What is the name of your package?",
65
+ placeholder: defaultPath
66
+ }) || defaultPath;
67
+ if (isCancel(path)) {
68
+ cancel("Operation cancelled.");
69
+ process.exit(1);
70
+ }
71
+ }
72
+ let template = options.template;
73
+ if (template) {
74
+ const templateOptionsValues = templateOptions.map((option) => option.value);
75
+ if (!templateOptionsValues.includes(template)) throw new Error(`Invalid template "${template}". Available templates: ${templateOptionsValues.join(", ")}`);
76
+ } else {
77
+ template = await select({
78
+ message: "Which template do you want to use?",
79
+ options: [...templateOptions],
80
+ initialValue: "default"
81
+ });
82
+ if (isCancel(template)) {
83
+ cancel("Operation cancelled.");
84
+ process.exit(1);
85
+ }
86
+ }
87
+ return {
88
+ path,
89
+ template
90
+ };
91
+ }
92
+
93
+ //#endregion
3
94
  export { create, resolveOptions, templateOptions };
package/dist/run.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import { r as templateOptions, t as create } from "./src-am5un8-C.mjs";
2
+ import { create, templateOptions } from "./index.mjs";
3
3
  import process from "node:process";
4
4
  import { log } from "@clack/prompts";
5
5
  import { cac } from "cac";
6
6
 
7
7
  //#region package.json
8
8
  var name = "create-tsdown";
9
- var version = "0.20.0";
9
+ var version = "0.20.2";
10
10
 
11
11
  //#endregion
12
12
  //#region src/cli.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-tsdown",
3
3
  "type": "module",
4
- "version": "0.20.0",
4
+ "version": "0.20.2",
5
5
  "description": "Create a new tsdown project",
6
6
  "author": "Kevin Deng <sxzz@sxzz.moe>",
7
7
  "license": "MIT",
@@ -42,7 +42,7 @@
42
42
  "node": ">=20.19.0"
43
43
  },
44
44
  "dependencies": {
45
- "@clack/prompts": "^0.11.0",
45
+ "@clack/prompts": "^1.0.0",
46
46
  "cac": "^6.7.14",
47
47
  "giget": "^3.1.1",
48
48
  "package-manager-detector": "^1.6.0"
@@ -1,94 +0,0 @@
1
- import process from "node:process";
2
- import { styleText } from "node:util";
3
- import { cancel, intro, isCancel, outro, select, spinner, text } from "@clack/prompts";
4
- import { downloadTemplate } from "giget";
5
- import { getUserAgent } from "package-manager-detector";
6
-
7
- //#region src/index.ts
8
- const templateOptions = [
9
- {
10
- value: "default",
11
- label: "Default"
12
- },
13
- {
14
- value: "minimal",
15
- label: "Minimal"
16
- },
17
- {
18
- value: "vue",
19
- label: "Vue"
20
- },
21
- {
22
- value: "react",
23
- label: "React"
24
- },
25
- {
26
- value: "react-compiler",
27
- label: "React with React Compiler"
28
- },
29
- {
30
- value: "solid",
31
- label: "Solid"
32
- },
33
- {
34
- value: "svelte",
35
- label: "Svelte"
36
- }
37
- ];
38
- /**
39
- * Create a tsdown project.
40
- */
41
- async function create(path, options) {
42
- intro(`Creating a tsdown project...`);
43
- const resolved = await resolveOptions({
44
- ...options,
45
- path
46
- });
47
- const s = spinner();
48
- s.start("Cloning the template...");
49
- await downloadTemplate(`gh:sxzz/tsdown-templates/${resolved.template}`, { dir: resolved.path });
50
- s.stop("Template cloned");
51
- const pm = getUserAgent() || "npm";
52
- outro(`Done! Now run:\n ${styleText("green", `cd ${resolved.path}`)}\n ${styleText("green", `${pm} install`)}\n ${styleText("green", `${pm} run build`)}\n\nFor more information, visit: ${styleText("underline", `https://tsdown.dev/`)}`);
53
- }
54
- /**
55
- * Resolve the user options and configs
56
- * @param options The user options
57
- * @returns The resolved options
58
- */
59
- async function resolveOptions(options) {
60
- let path = options.path;
61
- if (!path) {
62
- const defaultPath = "./my-tsdown-package";
63
- path = await text({
64
- message: "What is the name of your package?",
65
- placeholder: defaultPath
66
- }) || defaultPath;
67
- if (isCancel(path)) {
68
- cancel("Operation cancelled.");
69
- process.exit(1);
70
- }
71
- }
72
- let template = options.template;
73
- if (template) {
74
- const templateOptionsValues = templateOptions.map((option) => option.value);
75
- if (!templateOptionsValues.includes(template)) throw new Error(`Invalid template "${template}". Available templates: ${templateOptionsValues.join(", ")}`);
76
- } else {
77
- template = await select({
78
- message: "Which template do you want to use?",
79
- options: [...templateOptions],
80
- initialValue: "default"
81
- });
82
- if (isCancel(template)) {
83
- cancel("Operation cancelled.");
84
- process.exit(1);
85
- }
86
- }
87
- return {
88
- path,
89
- template
90
- };
91
- }
92
-
93
- //#endregion
94
- export { resolveOptions as n, templateOptions as r, create as t };