@emberkit/cli 0.1.2 → 0.2.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
- import { dev } from './commands/dev.js';
2
- import { build } from './commands/build.js';
3
- import { preview } from './commands/preview.js';
4
- import { create } from './commands/create.js';
1
+ import { dev } from "./commands/dev.js";
2
+ import { build } from "./commands/build.js";
3
+ import { preview } from "./commands/preview.js";
4
+ import { create } from "./commands/create.js";
5
5
  export async function runCLI(args) {
6
6
  const [command, ...restArgs] = args.slice(2);
7
7
  if (!command) {
@@ -9,27 +9,27 @@ export async function runCLI(args) {
9
9
  return;
10
10
  }
11
11
  switch (command) {
12
- case 'dev':
12
+ case "dev":
13
13
  await dev(restArgs);
14
14
  break;
15
- case 'build':
15
+ case "build":
16
16
  await build(restArgs);
17
17
  break;
18
- case 'preview':
18
+ case "preview":
19
19
  await preview(restArgs);
20
20
  break;
21
- case 'create':
21
+ case "create":
22
22
  await handleCreate(restArgs);
23
23
  break;
24
- case 'generate':
24
+ case "generate":
25
25
  await runGenerate(restArgs);
26
26
  break;
27
- case '--version':
28
- case '-v':
29
- console.log('EmberKit CLI v0.1.0');
27
+ case "--version":
28
+ case "-v":
29
+ console.log("EmberKit CLI v0.1.0");
30
30
  break;
31
- case '--help':
32
- case '-h':
31
+ case "--help":
32
+ case "-h":
33
33
  showHelp();
34
34
  break;
35
35
  default:
@@ -65,11 +65,11 @@ Examples:
65
65
  async function handleCreate(args) {
66
66
  const name = args[0];
67
67
  if (!name) {
68
- console.error('Error: Project name is required.');
69
- console.error('Usage: emberkit create <project-name>');
68
+ console.error("Error: Project name is required.");
69
+ console.error("Usage: emberkit create <project-name>");
70
70
  process.exit(1);
71
71
  }
72
- const noInstall = args.includes('--no-install');
72
+ const noInstall = args.includes("--no-install");
73
73
  await create({
74
74
  name,
75
75
  noInstall,
@@ -78,9 +78,9 @@ async function handleCreate(args) {
78
78
  async function runGenerate(args) {
79
79
  const [type, name] = args;
80
80
  if (!type || !name) {
81
- console.error('Usage: emberkit generate <type> <name>');
81
+ console.error("Usage: emberkit generate <type> <name>");
82
82
  process.exit(1);
83
83
  }
84
84
  console.log(`🎨 Generating ${type}: ${name}`);
85
- console.log('(Not yet implemented)');
85
+ console.log("(Not yet implemented)");
86
86
  }
@@ -1,23 +1,23 @@
1
- import { spawn } from 'child_process';
2
- import { platform } from 'os';
1
+ import { spawn } from "child_process";
2
+ import { platform } from "os";
3
3
  export async function build(args) {
4
- console.log('🔨 Building for production...\n');
5
- const isWindows = platform() === 'win32';
6
- const vite = spawn('vite', ['build', ...args], {
7
- stdio: 'inherit',
4
+ console.log("🔨 Building for production...\n");
5
+ const isWindows = platform() === "win32";
6
+ const vite = spawn("vite", ["build", ...args], {
7
+ stdio: "inherit",
8
8
  shell: isWindows,
9
9
  });
10
10
  return new Promise((resolve, reject) => {
11
- vite.on('exit', (code) => {
11
+ vite.on("exit", (code) => {
12
12
  if (code === 0) {
13
- console.log('\n✨ Build complete!');
13
+ console.log("\n✨ Build complete!");
14
14
  resolve();
15
15
  }
16
16
  else {
17
17
  reject(new Error(`Build failed with code ${code}`));
18
18
  }
19
19
  });
20
- vite.on('error', (error) => {
20
+ vite.on("error", (error) => {
21
21
  reject(error);
22
22
  });
23
23
  });
@@ -1,24 +1,24 @@
1
- import { existsSync, mkdirSync, writeFileSync } from 'fs';
2
- import { join, resolve } from 'path';
3
- import { execSync } from 'child_process';
4
- import { starterFiles } from '../templates/starter.js';
5
- import { getPackageManager, getInstallCommand } from '../utils/filesystem.js';
1
+ import { existsSync, mkdirSync, writeFileSync } from "fs";
2
+ import { join, resolve } from "path";
3
+ import { execSync } from "child_process";
4
+ import { starterFiles } from "../templates/starter.js";
5
+ import { getPackageManager, getInstallCommand } from "../utils/filesystem.js";
6
6
  function formatTemplate(template, vars) {
7
7
  let result = template;
8
8
  for (const [key, value] of Object.entries(vars)) {
9
- result = result.replace(new RegExp(`\\{\\{${key}\\}\\}`, 'g'), value);
9
+ result = result.replace(new RegExp(`\\{\\{${key}\\}\\}`, "g"), value);
10
10
  }
11
11
  return result;
12
12
  }
13
13
  function toKebabCase(str) {
14
14
  return str
15
- .replace(/([a-z])([A-Z])/g, '$1-$2')
16
- .replace(/[\s_]+/g, '-')
15
+ .replace(/([a-z])([A-Z])/g, "$1-$2")
16
+ .replace(/[\s_]+/g, "-")
17
17
  .toLowerCase();
18
18
  }
19
19
  function getNpmPackageName(name) {
20
20
  const kebab = toKebabCase(name);
21
- return kebab.startsWith('@') ? kebab : kebab.replace(/^emberkit-/, '');
21
+ return kebab.startsWith("@") ? kebab : kebab.replace(/^emberkit-/, "");
22
22
  }
23
23
  export async function create(options) {
24
24
  const { name, noInstall = false } = options;
@@ -38,11 +38,11 @@ export async function create(options) {
38
38
  mkdirSync(targetDir, { recursive: true });
39
39
  for (const [filePath, content] of Object.entries(starterFiles)) {
40
40
  const fullPath = join(targetDir, filePath);
41
- const dir = join(targetDir, filePath.split('/').slice(0, -1).join('/'));
41
+ const dir = join(targetDir, filePath.split("/").slice(0, -1).join("/"));
42
42
  if (!existsSync(dir)) {
43
43
  mkdirSync(dir, { recursive: true });
44
44
  }
45
- writeFileSync(fullPath, formatTemplate(content, templateVars), 'utf-8');
45
+ writeFileSync(fullPath, formatTemplate(content, templateVars), "utf-8");
46
46
  }
47
47
  console.log(` Project created successfully!\n`);
48
48
  if (!noInstall) {
@@ -50,7 +50,7 @@ export async function create(options) {
50
50
  const installCmd = getInstallCommand();
51
51
  console.log(` Installing dependencies with ${pm}...`);
52
52
  try {
53
- execSync(installCmd, { cwd: targetDir, stdio: 'inherit' });
53
+ execSync(installCmd, { cwd: targetDir, stdio: "inherit" });
54
54
  console.log(`\n Dependencies installed!\n`);
55
55
  }
56
56
  catch {
@@ -1,14 +1,14 @@
1
- import { spawn } from 'child_process';
2
- import { platform } from 'os';
1
+ import { spawn } from "child_process";
2
+ import { platform } from "os";
3
3
  export async function dev(args) {
4
- console.log('🔥 Starting EmberKit dev server...\n');
5
- const isWindows = platform() === 'win32';
6
- const vite = spawn('vite', args, {
7
- stdio: 'inherit',
4
+ console.log("🔥 Starting EmberKit dev server...\n");
5
+ const isWindows = platform() === "win32";
6
+ const vite = spawn("vite", args, {
7
+ stdio: "inherit",
8
8
  shell: isWindows,
9
9
  });
10
10
  return new Promise((resolve, reject) => {
11
- vite.on('exit', (code) => {
11
+ vite.on("exit", (code) => {
12
12
  if (code === 0) {
13
13
  resolve();
14
14
  }
@@ -16,7 +16,7 @@ export async function dev(args) {
16
16
  reject(new Error(`Vite exited with code ${code}`));
17
17
  }
18
18
  });
19
- vite.on('error', (error) => {
19
+ vite.on("error", (error) => {
20
20
  reject(error);
21
21
  });
22
22
  });
@@ -1,14 +1,14 @@
1
- import { spawn } from 'child_process';
2
- import { platform } from 'os';
1
+ import { spawn } from "child_process";
2
+ import { platform } from "os";
3
3
  export async function preview(args) {
4
- console.log('👀 Previewing production build...\n');
5
- const isWindows = platform() === 'win32';
6
- const vite = spawn('vite', ['preview', ...args], {
7
- stdio: 'inherit',
4
+ console.log("👀 Previewing production build...\n");
5
+ const isWindows = platform() === "win32";
6
+ const vite = spawn("vite", ["preview", ...args], {
7
+ stdio: "inherit",
8
8
  shell: isWindows,
9
9
  });
10
10
  return new Promise((resolve, reject) => {
11
- vite.on('exit', (code) => {
11
+ vite.on("exit", (code) => {
12
12
  if (code === 0) {
13
13
  resolve();
14
14
  }
@@ -16,7 +16,7 @@ export async function preview(args) {
16
16
  reject(new Error(`Preview exited with code ${code}`));
17
17
  }
18
18
  });
19
- vite.on('error', (error) => {
19
+ vite.on("error", (error) => {
20
20
  reject(error);
21
21
  });
22
22
  });
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { runCLI } from './cli.js';
1
+ import { runCLI } from "./cli.js";
2
2
  export { runCLI };
3
3
  export async function main() {
4
4
  await runCLI(process.argv);
@@ -126,7 +126,7 @@ export function formatTemplate(template, params) {
126
126
  }
127
127
  export function toKebabCase(str) {
128
128
  return str
129
- .replace(/([a-z])([A-Z])/g, '$1-$2')
130
- .replace(/[\s_]+/g, '-')
129
+ .replace(/([a-z])([A-Z])/g, "$1-$2")
130
+ .replace(/[\s_]+/g, "-")
131
131
  .toLowerCase();
132
132
  }
@@ -1,5 +1,5 @@
1
1
  export const starterFiles = {
2
- 'package.json': `{
2
+ "package.json": `{
3
3
  "name": "{{name}}",
4
4
  "version": "0.1.0",
5
5
  "private": true,
@@ -20,7 +20,7 @@ export const starterFiles = {
20
20
  "vite": "^6.0.0"
21
21
  }
22
22
  }`,
23
- 'tsconfig.json': `{
23
+ "tsconfig.json": `{
24
24
  "compilerOptions": {
25
25
  "target": "ES2022",
26
26
  "module": "ESNext",
@@ -42,7 +42,7 @@ export const starterFiles = {
42
42
  "include": ["src"],
43
43
  "exclude": ["node_modules", "dist"]
44
44
  }`,
45
- 'emberkit.config.ts': `import { defineConfig } from '@emberkit/core';
45
+ "emberkit.config.ts": `import { defineConfig } from '@emberkit/core';
46
46
 
47
47
  export default defineConfig({
48
48
  mode: 'spa',
@@ -51,7 +51,7 @@ export default defineConfig({
51
51
  target: 'esnext',
52
52
  },
53
53
  });`,
54
- 'vite.config.ts': `import { defineConfig } from 'vite';
54
+ "vite.config.ts": `import { defineConfig } from 'vite';
55
55
  import { emberkitVitePlugin } from '@emberkit/core/vite-plugin';
56
56
 
57
57
  export default defineConfig({
@@ -64,7 +64,7 @@ export default defineConfig({
64
64
  jsxImportSource: '@emberkit/core',
65
65
  },
66
66
  });`,
67
- 'index.html': `<!DOCTYPE html>
67
+ "index.html": `<!DOCTYPE html>
68
68
  <html lang="en">
69
69
  <head>
70
70
  <meta charset="UTF-8">
@@ -76,7 +76,7 @@ export default defineConfig({
76
76
  <script type="module" src="/src/index.tsx"></script>
77
77
  </body>
78
78
  </html>`,
79
- 'src/index.tsx': `import { render } from '@emberkit/core';
79
+ "src/index.tsx": `import { render } from '@emberkit/core';
80
80
  import App from './routes/_layout';
81
81
 
82
82
  const root = document.getElementById('app');
@@ -84,7 +84,7 @@ const root = document.getElementById('app');
84
84
  if (root) {
85
85
  render(App, root);
86
86
  }`,
87
- 'src/routes/_layout.tsx': `import type { RouteComponent } from '@emberkit/core';
87
+ "src/routes/_layout.tsx": `import type { RouteComponent } from '@emberkit/core';
88
88
  import { Head } from '@emberkit/core';
89
89
 
90
90
  const Layout: RouteComponent = ({ children }) => {
@@ -111,7 +111,7 @@ const Layout: RouteComponent = ({ children }) => {
111
111
  };
112
112
 
113
113
  export default Layout;`,
114
- 'src/routes/index.tsx': `import type { RouteComponent } from '@emberkit/core';
114
+ "src/routes/index.tsx": `import type { RouteComponent } from '@emberkit/core';
115
115
 
116
116
  const HomePage: RouteComponent = () => {
117
117
  return (
@@ -158,7 +158,7 @@ const HomePage: RouteComponent = () => {
158
158
  };
159
159
 
160
160
  export default HomePage;`,
161
- 'src/routes/about.tsx': `import type { RouteComponent } from '@emberkit/core';
161
+ "src/routes/about.tsx": `import type { RouteComponent } from '@emberkit/core';
162
162
  import { Head } from '@emberkit/core';
163
163
 
164
164
  const AboutPage: RouteComponent = () => {
@@ -1,43 +1,43 @@
1
- export { generate, toPascalCase, toKebabCase } from './generator.js';
1
+ export { generate, toPascalCase, toKebabCase } from "./generator.js";
2
2
  export function ensureDirSync(dirPath) {
3
- const { mkdirSync, existsSync } = require('fs');
3
+ const { mkdirSync, existsSync } = require("fs");
4
4
  if (!existsSync(dirPath)) {
5
5
  mkdirSync(dirPath, { recursive: true });
6
6
  }
7
7
  }
8
8
  export function readFileSync(filePath) {
9
- const { readFileSync } = require('fs');
10
- return readFileSync(filePath, 'utf-8');
9
+ const { readFileSync } = require("fs");
10
+ return readFileSync(filePath, "utf-8");
11
11
  }
12
12
  export function writeFileSync(filePath, content, options) {
13
- const fs = require('fs');
14
- const dir = require('path').dirname(filePath);
13
+ const fs = require("fs");
14
+ const dir = require("path").dirname(filePath);
15
15
  ensureDirSync(dir);
16
- fs.writeFileSync(filePath, content, options ?? { encoding: 'utf-8' });
16
+ fs.writeFileSync(filePath, content, options ?? { encoding: "utf-8" });
17
17
  }
18
18
  export function fileExists(filePath) {
19
- const { existsSync } = require('fs');
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 require("path").resolve(...segments);
24
24
  }
25
25
  export function getPackageManager() {
26
- const userAgent = process.env.npm_config_user_agent ?? '';
27
- if (userAgent.startsWith('pnpm'))
28
- return 'pnpm';
29
- if (userAgent.startsWith('yarn'))
30
- return 'yarn';
31
- return 'npm';
26
+ const userAgent = process.env.npm_config_user_agent ?? "";
27
+ if (userAgent.startsWith("pnpm"))
28
+ return "pnpm";
29
+ if (userAgent.startsWith("yarn"))
30
+ return "yarn";
31
+ return "npm";
32
32
  }
33
33
  export function getInstallCommand() {
34
34
  const pm = getPackageManager();
35
35
  switch (pm) {
36
- case 'pnpm':
37
- return 'pnpm install';
38
- case 'yarn':
39
- return 'yarn';
36
+ case "pnpm":
37
+ return "pnpm install";
38
+ case "yarn":
39
+ return "yarn";
40
40
  default:
41
- return 'npm install';
41
+ return "npm install";
42
42
  }
43
43
  }
@@ -1,6 +1,6 @@
1
- import { existsSync, mkdirSync, writeFileSync } from 'fs';
2
- import { dirname, join } from 'path';
3
- import { getTemplate, formatTemplate, toKebabCase } from '../templates/index.js';
1
+ import { existsSync, mkdirSync, writeFileSync } from "fs";
2
+ import { dirname, join } from "path";
3
+ import { getTemplate, formatTemplate, toKebabCase, } from "../templates/index.js";
4
4
  export async function generate(options) {
5
5
  const { name, path, template, params = {} } = options;
6
6
  const fullPath = join(process.cwd(), path);
@@ -23,7 +23,7 @@ export async function generate(options) {
23
23
  error: `File already exists: ${fullPath}`,
24
24
  };
25
25
  }
26
- writeFileSync(fullPath, content, 'utf-8');
26
+ writeFileSync(fullPath, content, "utf-8");
27
27
  return {
28
28
  success: true,
29
29
  path: fullPath,
@@ -34,14 +34,14 @@ export async function generate(options) {
34
34
  return {
35
35
  success: false,
36
36
  path: fullPath,
37
- error: err instanceof Error ? err.message : 'Unknown error',
37
+ error: err instanceof Error ? err.message : "Unknown error",
38
38
  };
39
39
  }
40
40
  }
41
41
  export async function initProject(options) {
42
- const { template = 'basic', targetDir = process.cwd(), name } = options;
42
+ const { template = "basic", targetDir = process.cwd(), name } = options;
43
43
  console.log(`Initializing EmberKit project with ${template} template...`);
44
- const projectName = name ?? 'emberkit-app';
44
+ const projectName = name ?? "emberkit-app";
45
45
  console.log(`Project: ${projectName}`);
46
46
  console.log(`Location: ${targetDir}`);
47
47
  }
@@ -49,6 +49,6 @@ function toPascalCase(str) {
49
49
  return str
50
50
  .split(/[-_\s]+/)
51
51
  .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
52
- .join('');
52
+ .join("");
53
53
  }
54
54
  export { toPascalCase, toKebabCase };
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@emberkit/cli",
3
- "version": "0.1.2",
3
+ "version": "0.2.1-alpha.0",
4
4
  "type": "module",
5
+ "private": false,
5
6
  "description": "CLI tool for EmberKit projects",
6
7
  "license": "Apache-2.0",
7
8
  "repository": {
@@ -22,6 +23,9 @@
22
23
  },
23
24
  "main": "./dist/index.js",
24
25
  "types": "./dist/index.d.ts",
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
25
29
  "files": [
26
30
  "dist",
27
31
  "bin"
@@ -41,7 +45,8 @@
41
45
  },
42
46
  "scripts": {
43
47
  "build": "tsc",
44
- "dev": "tsc --watch",
45
- "test": "vitest"
48
+ "lint": "eslint src --ext .ts",
49
+ "format": "prettier --write \"src/**/*.ts\"",
50
+ "typecheck": "tsc --noEmit"
46
51
  }
47
52
  }