@emberkit/cli 0.5.0 → 0.5.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/cli.js CHANGED
@@ -1,7 +1,9 @@
1
+ import inquirer from "inquirer";
1
2
  import { dev } from "./commands/dev.js";
2
3
  import { build } from "./commands/build.js";
3
4
  import { preview } from "./commands/preview.js";
4
5
  import { create } from "./commands/create.js";
6
+ import { TEMPLATES } from "./commands/create.js";
5
7
  export async function runCLI(args) {
6
8
  const [command, ...restArgs] = args.slice(2);
7
9
  if (!command) {
@@ -45,36 +47,122 @@ function showHelp() {
45
47
  Usage: emberkit <command> [options]
46
48
 
47
49
  Commands:
48
- create <name> Create a new EmberKit project
50
+ create [name] Create a new EmberKit project
49
51
  dev Start development server
50
52
  build Build for production
51
53
  preview Preview production build
52
54
  generate <type> Generate code (routes, components, etc.)
53
55
 
54
56
  Options:
55
- --help, -h Show this help message
56
- --version, -v Show version number
57
+ --template, -t <id> Project template to use
58
+ --no-install Skip dependency installation
59
+ --help, -h Show this help message
60
+ --version, -v Show version number
61
+
62
+ Templates:
63
+ basic Simple starter with Tailwind CSS (default)
64
+ with-ui Starter with EmberKit UI components
65
+ minimal Barebones project, no CSS framework
66
+ blog Blog with file-based routing and Tailwind
67
+ saas SaaS landing page with auth routes
68
+ dashboard Admin dashboard with sidebar layout
69
+ api REST API server with CRUD endpoints
57
70
 
58
71
  Examples:
59
72
  emberkit create my-app
60
- emberkit dev
61
- emberkit build
62
- emberkit generate route about
73
+ emberkit create my-blog --template blog
74
+ emberkit create my-saas -t saas
75
+ emberkit create
63
76
  `);
64
77
  }
65
78
  async function handleCreate(args) {
66
- const name = args[0];
67
- if (!name) {
68
- console.error("Error: Project name is required.");
69
- console.error("Usage: emberkit create <project-name>");
70
- process.exit(1);
79
+ if (args.includes("--help") || args.includes("-h")) {
80
+ showCreateHelp();
81
+ return;
71
82
  }
83
+ const name = extractFlag(args, 0);
84
+ const template = extractFlagValue(args, "--template", "-t");
72
85
  const noInstall = args.includes("--no-install");
86
+ if (!name) {
87
+ const answers = await inquirer.prompt([
88
+ {
89
+ type: "input",
90
+ name: "name",
91
+ message: "What is your project name?",
92
+ default: "my-emberkit-app",
93
+ },
94
+ {
95
+ type: "list",
96
+ name: "template",
97
+ message: "Choose a template:",
98
+ choices: TEMPLATES.map((t) => ({
99
+ name: `${t.name.padEnd(12)} — ${t.desc}`,
100
+ value: t.id,
101
+ })),
102
+ default: "basic",
103
+ },
104
+ ]);
105
+ await create({
106
+ name: answers.name,
107
+ template: answers.template,
108
+ noInstall,
109
+ });
110
+ return;
111
+ }
73
112
  await create({
74
113
  name,
114
+ template,
75
115
  noInstall,
76
116
  });
77
117
  }
118
+ function showCreateHelp() {
119
+ console.log(`
120
+ 🔥 EmberKit — Create a new project
121
+
122
+ Usage: emberkit create [name] [options]
123
+
124
+ Arguments:
125
+ name Project name (optional, prompts if omitted)
126
+
127
+ Options:
128
+ --template, -t <id> Project template to use
129
+ --no-install Skip dependency installation
130
+ --help, -h Show this help
131
+
132
+ Templates:
133
+ basic Simple starter with Tailwind CSS (default)
134
+ with-ui Starter with EmberKit UI components
135
+ minimal Barebones project, no CSS framework
136
+ blog Blog with file-based routing and Tailwind
137
+ saas SaaS landing page with auth routes
138
+ dashboard Admin dashboard with sidebar layout
139
+ api REST API server with CRUD endpoints
140
+
141
+ Examples:
142
+ emberkit create my-app
143
+ emberkit create my-blog --template blog
144
+ emberkit create my-saas -t saas
145
+ emberkit create (interactive mode)
146
+ `);
147
+ }
148
+ function extractFlag(args, index) {
149
+ return args.filter((a) => !a.startsWith("-"))[index];
150
+ }
151
+ function extractFlagValue(args, longFlag, shortFlag) {
152
+ const flags = shortFlag ? [longFlag, shortFlag] : [longFlag];
153
+ for (let i = 0; i < args.length; i++) {
154
+ if (flags.includes(args[i])) {
155
+ return args[i + 1];
156
+ }
157
+ if (args[i].startsWith(`${longFlag}=`)) {
158
+ return args[i].split("=")[1];
159
+ }
160
+ if (shortFlag && args[i].startsWith(`${shortFlag}=`)) {
161
+ return args[i].split("=")[1];
162
+ }
163
+ }
164
+ return undefined;
165
+ }
78
166
  async function runGenerate(args) {
79
167
  const [type, name] = args;
80
168
  if (!type || !name) {
@@ -19,7 +19,7 @@ const BRIGHT_CYAN = "\x1b[96m";
19
19
  const BRIGHT_WHITE = "\x1b[97m";
20
20
  const BRIGHT_YELLOW = "\x1b[93m";
21
21
  const ORANGE_BG = "\x1b[48;5;208m";
22
- const TEMPLATES = [
22
+ export const TEMPLATES = [
23
23
  { id: "basic", name: "Basic", desc: "Simple starter with Tailwind CSS", files: starterFiles },
24
24
  { id: "with-ui", name: "With UI", desc: "Starter with EmberKit UI components", files: withUiTemplate },
25
25
  { id: "minimal", name: "Minimal", desc: "Barebones project, no CSS framework", files: minimalTemplate },
@@ -1,26 +1,26 @@
1
+ import { existsSync, mkdirSync, readFileSync as fsReadFileSync, writeFileSync as fsWriteFileSync } from "fs";
2
+ import { resolve, dirname } from "path";
3
+ import { execSync } from "child_process";
4
+ import { platform } from "os";
1
5
  export { generate, toPascalCase, toKebabCase } from "./generator.js";
2
6
  export function ensureDirSync(dirPath) {
3
- const { mkdirSync, existsSync } = require("fs");
4
7
  if (!existsSync(dirPath)) {
5
8
  mkdirSync(dirPath, { recursive: true });
6
9
  }
7
10
  }
8
11
  export function readFileSync(filePath) {
9
- const { readFileSync } = require("fs");
10
- return readFileSync(filePath, "utf-8");
12
+ return fsReadFileSync(filePath, "utf-8");
11
13
  }
12
14
  export function writeFileSync(filePath, content, options) {
13
- const fs = require("fs");
14
- const dir = require("path").dirname(filePath);
15
+ const dir = dirname(filePath);
15
16
  ensureDirSync(dir);
16
- fs.writeFileSync(filePath, content, options ?? { encoding: "utf-8" });
17
+ fsWriteFileSync(filePath, content, options ?? { encoding: "utf-8" });
17
18
  }
18
19
  export function fileExists(filePath) {
19
- const { existsSync } = require("fs");
20
20
  return existsSync(filePath);
21
21
  }
22
22
  export function resolvePath(...segments) {
23
- return require("path").resolve(...segments);
23
+ return resolve(...segments);
24
24
  }
25
25
  export function getPackageManager() {
26
26
  const userAgent = process.env.npm_config_user_agent ?? "";
@@ -30,16 +30,14 @@ export function getPackageManager() {
30
30
  return "yarn";
31
31
  if (userAgent.startsWith("npm"))
32
32
  return "npm";
33
- const { existsSync } = require("fs");
34
- const { platform } = require("os");
35
33
  try {
36
34
  if (platform() === "win32") {
37
- if (existsSync("C:\\Program Files\\pnpm\\pnpm.exe") || existsSync(process.env.LOCALAPPDATA + "\\pnpm\\pnpm.exe")) {
35
+ const localAppData = process.env.LOCALAPPDATA ?? "";
36
+ if (existsSync("C:\\Program Files\\pnpm\\pnpm.exe") || existsSync(localAppData + "\\pnpm\\pnpm.exe")) {
38
37
  return "pnpm";
39
38
  }
40
39
  }
41
40
  else {
42
- const { execSync } = require("child_process");
43
41
  execSync("pnpm --version", { stdio: "ignore" });
44
42
  return "pnpm";
45
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emberkit/cli",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "description": "CLI tool for EmberKit projects",