frontend-hamroun 1.1.43 → 1.1.44

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/bin/cli.js +3 -87
  2. package/package.json +1 -2
package/bin/cli.js CHANGED
@@ -7,107 +7,23 @@ import path from 'path';
7
7
  import { fileURLToPath } from 'url';
8
8
  import chalk from 'chalk';
9
9
  import { createSpinner } from 'nanospinner';
10
- import { createServer } from 'http';
11
10
 
12
11
  const __filename = fileURLToPath(import.meta.url);
13
12
  const __dirname = path.dirname(__filename);
14
13
 
15
- async function createDevServer(options = {}) {
16
- const { port = 3000, isSSR = false } = options;
17
-
18
- try {
19
- const esbuild = await import('esbuild');
20
-
21
- const ctx = await esbuild.context({
22
- entryPoints: ['src/main.tsx'],
23
- bundle: true,
24
- outdir: 'dist',
25
- format: 'esm',
26
- platform: isSSR ? 'node' : 'browser',
27
- sourcemap: true,
28
- loader: { '.tsx': 'tsx', '.ts': 'tsx' },
29
- jsxFactory: '_jsx',
30
- jsxFragment: '_Fragment',
31
- banner: {
32
- js: `import { jsx as _jsx, Fragment as _Fragment } from 'frontend-hamroun';`,
33
- }
34
- });
35
-
36
- await ctx.watch();
37
-
38
- const server = createServer((req, res) => {
39
- const url = new URL(req.url || '', `http://${req.headers.host}`);
40
-
41
- if (url.pathname === '/') {
42
- res.writeHead(200, { 'Content-Type': 'text/html' });
43
- res.end(fs.readFileSync('index.html', 'utf8'));
44
- } else if (url.pathname.endsWith('.js')) {
45
- res.writeHead(200, { 'Content-Type': 'application/javascript' });
46
- res.end(fs.readFileSync(path.join('dist', url.pathname), 'utf8'));
47
- } else {
48
- res.writeHead(404);
49
- res.end();
50
- }
51
- });
52
-
53
- server.listen(port);
54
- console.log(chalk.green(`Development server running at http://localhost:${port}`));
55
-
56
- return { server, ctx };
57
- } catch (error) {
58
- console.error('Failed to load esbuild:', error);
59
- throw error;
60
- }
61
- }
62
-
63
14
  async function init() {
64
15
  const program = new Command();
65
16
 
66
17
  program
67
- .name('frontend-hamroun')
68
- .description('Frontend Hamroun CLI')
69
- .version('1.0.0');
70
-
71
- // Create command
72
- program
73
- .command('create')
74
- .description('Create a new project')
18
+ .name('create-frontend-app')
19
+ .description('Create a new Frontend Hamroun application')
75
20
  .argument('[name]', 'Project name')
76
21
  .action(async (name) => {
77
22
  const projectName = name || await askProjectName();
78
23
  await createProject(projectName);
79
24
  });
80
25
 
81
- // Dev command
82
- program
83
- .command('dev')
84
- .description('Start development server')
85
- .option('-p, --port <port>', 'Port number', '3000')
86
- .option('--ssr', 'Enable SSR mode')
87
- .action(async (options) => {
88
- const spinner = createSpinner('Starting development server...').start();
89
- try {
90
- const { server, ctx } = await createDevServer({
91
- port: parseInt(options.port),
92
- isSSR: options.ssr
93
- });
94
-
95
- spinner.success({ text: `Development server running at http://localhost:${options.port}` });
96
-
97
- // Handle cleanup
98
- process.on('SIGINT', async () => {
99
- await ctx.dispose();
100
- server.close();
101
- process.exit(0);
102
- });
103
- } catch (error) {
104
- spinner.error({ text: 'Failed to start development server' });
105
- console.error(chalk.red(error));
106
- process.exit(1);
107
- }
108
- });
109
-
110
- program.parse(process.argv);
26
+ program.parse();
111
27
  }
112
28
 
113
29
  async function askProjectName() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frontend-hamroun",
3
- "version": "1.1.43",
3
+ "version": "1.1.44",
4
4
  "description": "A lightweight frontend framework with hooks and virtual DOM",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -61,7 +61,6 @@
61
61
  "dependencies": {
62
62
  "chalk": "^5.3.0",
63
63
  "commander": "^11.0.0",
64
- "esbuild": "^0.19.2",
65
64
  "fs-extra": "^11.1.1",
66
65
  "inquirer": "^9.2.10",
67
66
  "nanospinner": "^1.1.0"