create-giggles-app 1.0.1 → 1.0.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.
Files changed (2) hide show
  1. package/dist/index.js +31 -21
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2,9 +2,11 @@
2
2
 
3
3
  // src/index.ts
4
4
  import * as p from "@clack/prompts";
5
- import { execSync } from "child_process";
5
+ import { exec } from "child_process";
6
6
  import fs from "fs";
7
7
  import path from "path";
8
+ import { promisify } from "util";
9
+ var execAsync = promisify(exec);
8
10
  function detectPackageManager() {
9
11
  const userAgent = process.env.npm_config_user_agent ?? "";
10
12
  if (userAgent.startsWith("yarn")) return "yarn";
@@ -30,38 +32,38 @@ async function main() {
30
32
  const options = await p.group(
31
33
  {
32
34
  name: () => p.text({
33
- message: "Project name?",
35
+ message: "project name?",
34
36
  placeholder: "my-tui",
35
37
  initialValue: argName ?? "",
36
38
  validate: (value) => {
37
- if (!value.trim()) return "Project name is required.";
38
- if (/[^\w\-.]/.test(value)) return "Project name contains invalid characters.";
39
+ if (!value.trim()) return "project name is required.";
40
+ if (/[^\w\-.]/.test(value)) return "project name contains invalid characters.";
39
41
  }
40
42
  }),
41
43
  location: ({ results }) => p.text({
42
- message: "Where should we create the project?",
44
+ message: "where should we create the project?",
43
45
  placeholder: `./${results.name}`,
44
46
  initialValue: `./${results.name}`
45
47
  }),
46
48
  language: () => p.select({
47
- message: "Language?",
49
+ message: "language?",
48
50
  options: [
49
- { value: "typescript", label: "TypeScript", hint: "recommended" },
50
- { value: "javascript", label: "JavaScript" }
51
+ { value: "typescript", label: "typescript", hint: "recommended" },
52
+ { value: "javascript", label: "javascript" }
51
53
  ]
52
54
  }),
53
55
  linting: () => p.confirm({
54
- message: "Add ESLint + Prettier?",
56
+ message: "add eslint + prettier?",
55
57
  initialValue: true
56
58
  }),
57
59
  install: () => p.confirm({
58
- message: "Install dependencies?",
60
+ message: "install dependencies?",
59
61
  initialValue: true
60
62
  })
61
63
  },
62
64
  {
63
65
  onCancel: () => {
64
- p.cancel("Cancelled.");
66
+ p.cancel("cancelled.");
65
67
  process.exit(0);
66
68
  }
67
69
  }
@@ -74,12 +76,12 @@ async function main() {
74
76
  if (fs.existsSync(projectDir)) {
75
77
  const files = fs.readdirSync(projectDir);
76
78
  if (files.length > 0) {
77
- p.cancel(`Directory ${options.location} is not empty.`);
79
+ p.cancel(`directory ${options.location} is not empty.`);
78
80
  process.exit(1);
79
81
  }
80
82
  }
81
83
  fs.mkdirSync(projectDir, { recursive: true });
82
- s.start("Scaffolding project...");
84
+ s.start("scaffolding project...");
83
85
  copyDir(path.join(templatesDir, "base"), projectDir, {
84
86
  _gitignore: ".gitignore"
85
87
  });
@@ -128,19 +130,27 @@ async function main() {
128
130
  devDependencies: devDeps
129
131
  };
130
132
  fs.writeFileSync(path.join(projectDir, "package.json"), JSON.stringify(pkg, null, 2) + "\n");
131
- s.stop("Project scaffolded.");
133
+ s.stop("project scaffolded.");
132
134
  if (options.install) {
133
- s.start("Installing dependencies...");
135
+ const messages = ["installing dependencies...", "giggling...", "hehehe...", "almost there...", "still giggling..."];
136
+ let i = 0;
137
+ s.start(messages[0]);
138
+ const interval = setInterval(() => {
139
+ i = (i + 1) % messages.length;
140
+ s.message(messages[i]);
141
+ }, 2e3);
134
142
  try {
135
- execSync(`${pm} install`, { cwd: projectDir, stdio: "ignore" });
136
- s.stop("Dependencies installed.");
143
+ await execAsync(`${pm} install`, { cwd: projectDir });
144
+ clearInterval(interval);
145
+ s.stop("dependencies installed.");
137
146
  } catch {
138
- s.stop("Failed to install dependencies.");
139
- p.log.warning(`Run \`${pm} install\` manually in the project directory.`);
147
+ clearInterval(interval);
148
+ s.stop("failed to install dependencies.");
149
+ p.log.warning(`run \`${pm} install\` manually in the project directory.`);
140
150
  }
141
151
  }
142
152
  const relative = path.relative(process.cwd(), projectDir);
143
- p.note([`cd ${relative}`, `${pm} dev`].join("\n"), "Next steps");
144
- p.outro("Happy building!");
153
+ p.note([`cd ${relative}`, `${pm} dev`].join("\n"), "next steps");
154
+ p.outro("done! :p");
145
155
  }
146
156
  main().catch(console.error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-giggles-app",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "scaffold a giggles terminal app",
5
5
  "license": "MIT",
6
6
  "repository": {