react-client 1.0.27 → 1.0.30

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.
@@ -1,48 +1,52 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
4
9
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.default = initCmd;
7
- const path_1 = __importDefault(require("path"));
8
- const fs_extra_1 = __importDefault(require("fs-extra"));
9
- const prompts_1 = __importDefault(require("prompts"));
10
- const chalk_1 = __importDefault(require("chalk"));
11
- const child_process_1 = require("child_process");
12
- async function initCmd(name, opts) {
13
- const root = process.cwd();
14
- const projectDir = path_1.default.resolve(root, name);
15
- const template = opts.template || 'react-ts';
16
- console.log(chalk_1.default.cyan(`\nšŸ“¦ Creating new React Client app: ${chalk_1.default.bold(name)}`));
17
- // 1ļøāƒ£ Check if directory exists
18
- if (fs_extra_1.default.existsSync(projectDir)) {
19
- const res = await (0, prompts_1.default)({
20
- type: 'confirm',
21
- name: 'overwrite',
22
- message: chalk_1.default.yellow(`Directory "${name}" already exists. Overwrite?`),
23
- initial: false,
24
- });
25
- if (!res.overwrite) {
26
- console.log(chalk_1.default.red('āŒ Operation cancelled.'));
10
+ import path from 'path';
11
+ import fs from 'fs-extra';
12
+ import prompts from 'prompts';
13
+ import chalk from 'chalk';
14
+ import { execSync } from 'child_process';
15
+ export default function initCmd(name, opts) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const root = process.cwd();
18
+ const projectDir = path.resolve(root, name);
19
+ const template = opts.template || 'react-ts';
20
+ console.log(chalk.cyan(`\nšŸ“¦ Creating new React Client app: ${chalk.bold(name)}`));
21
+ // 1ļøāƒ£ Check if directory exists
22
+ if (fs.existsSync(projectDir)) {
23
+ const res = yield prompts({
24
+ type: 'confirm',
25
+ name: 'overwrite',
26
+ message: chalk.yellow(`Directory "${name}" already exists. Overwrite?`),
27
+ initial: false,
28
+ });
29
+ if (!res.overwrite) {
30
+ console.log(chalk.red('āŒ Operation cancelled.'));
31
+ process.exit(1);
32
+ }
33
+ yield fs.remove(projectDir);
34
+ }
35
+ yield fs.ensureDir(projectDir);
36
+ // 2ļøāƒ£ Locate template
37
+ const templateDir = path.resolve(__dirname, '../../../templates', template);
38
+ if (!fs.existsSync(templateDir)) {
39
+ console.error(chalk.red(`āŒ Template not found: ${template}`));
27
40
  process.exit(1);
28
41
  }
29
- await fs_extra_1.default.remove(projectDir);
30
- }
31
- await fs_extra_1.default.ensureDir(projectDir);
32
- // 2ļøāƒ£ Locate template
33
- const templateDir = path_1.default.resolve(__dirname, '../../../templates', template);
34
- if (!fs_extra_1.default.existsSync(templateDir)) {
35
- console.error(chalk_1.default.red(`āŒ Template not found: ${template}`));
36
- process.exit(1);
37
- }
38
- // 3ļøāƒ£ Copy template
39
- console.log(chalk_1.default.gray(`\nšŸ“ Copying template: ${template}...`));
40
- await fs_extra_1.default.copy(templateDir, projectDir);
41
- // 4ļøāƒ£ Optionally create react-client.config.js (not .ts)
42
- if (opts.withConfig) {
43
- const configPath = path_1.default.join(projectDir, 'react-client.config.js');
44
- if (!fs_extra_1.default.existsSync(configPath)) {
45
- const configContent = `// react-client.config.js
42
+ // 3ļøāƒ£ Copy template
43
+ console.log(chalk.gray(`\nšŸ“ Copying template: ${template}...`));
44
+ yield fs.copy(templateDir, projectDir);
45
+ // 4ļøāƒ£ Optionally create react-client.config.js (not .ts)
46
+ if (opts.withConfig) {
47
+ const configPath = path.join(projectDir, 'react-client.config.js');
48
+ if (!fs.existsSync(configPath)) {
49
+ const configContent = `// react-client.config.js
46
50
  import { defineConfig } from 'react-client/config';
47
51
 
48
52
  export default defineConfig({
@@ -62,33 +66,34 @@ export default defineConfig({
62
66
  // šŸ’” Add plugins, aliases, etc.
63
67
  });
64
68
  `;
65
- await fs_extra_1.default.writeFile(configPath, configContent, 'utf8');
66
- console.log(chalk_1.default.green('šŸ“ Created react-client.config.js'));
69
+ yield fs.writeFile(configPath, configContent, 'utf8');
70
+ console.log(chalk.green('šŸ“ Created react-client.config.js'));
71
+ }
72
+ }
73
+ // 5ļøāƒ£ Initialize git repo
74
+ try {
75
+ execSync('git init', { cwd: projectDir, stdio: 'ignore' });
76
+ console.log(chalk.gray('šŸ”§ Initialized Git repository.'));
77
+ }
78
+ catch (_a) {
79
+ console.warn(chalk.yellow('āš ļø Git init failed (skipping).'));
80
+ }
81
+ // 6ļøāƒ£ Install dependencies
82
+ const pkgManager = /yarn/.test(process.env.npm_execpath || '') ? 'yarn' : 'npm';
83
+ console.log(chalk.gray(`\nšŸ“¦ Installing dependencies using ${pkgManager}...`));
84
+ try {
85
+ execSync(`${pkgManager} install`, { cwd: projectDir, stdio: 'inherit' });
86
+ }
87
+ catch (_b) {
88
+ console.warn(chalk.yellow('āš ļø Dependency installation failed, please run manually.'));
67
89
  }
68
- }
69
- // 5ļøāƒ£ Initialize git repo
70
- try {
71
- (0, child_process_1.execSync)('git init', { cwd: projectDir, stdio: 'ignore' });
72
- console.log(chalk_1.default.gray('šŸ”§ Initialized Git repository.'));
73
- }
74
- catch {
75
- console.warn(chalk_1.default.yellow('āš ļø Git init failed (skipping).'));
76
- }
77
- // 6ļøāƒ£ Install dependencies
78
- const pkgManager = /yarn/.test(process.env.npm_execpath || '') ? 'yarn' : 'npm';
79
- console.log(chalk_1.default.gray(`\nšŸ“¦ Installing dependencies using ${pkgManager}...`));
80
- try {
81
- (0, child_process_1.execSync)(`${pkgManager} install`, { cwd: projectDir, stdio: 'inherit' });
82
- }
83
- catch {
84
- console.warn(chalk_1.default.yellow('āš ļø Dependency installation failed, please run manually.'));
85
- }
86
- // 7ļøāƒ£ Completion message
87
- console.log();
88
- console.log(chalk_1.default.green('āœ… Project setup complete!'));
89
- console.log(chalk_1.default.cyan(`\nNext steps:`));
90
- console.log(chalk_1.default.gray(` cd ${name}`));
91
- console.log(chalk_1.default.gray(` ${pkgManager === 'yarn' ? 'yarn dev' : 'npm run dev'}`));
92
- console.log();
93
- console.log(chalk_1.default.dim('Happy coding! ⚔'));
90
+ // 7ļøāƒ£ Completion message
91
+ console.log();
92
+ console.log(chalk.green('āœ… Project setup complete!'));
93
+ console.log(chalk.cyan(`\nNext steps:`));
94
+ console.log(chalk.gray(` cd ${name}`));
95
+ console.log(chalk.gray(` ${pkgManager === 'yarn' ? 'yarn dev' : 'npm run dev'}`));
96
+ console.log();
97
+ console.log(chalk.dim('Happy coding! ⚔'));
98
+ });
94
99
  }
@@ -1,17 +1,20 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
4
9
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.default = preview;
7
- const http_1 = __importDefault(require("http"));
8
- const path_1 = __importDefault(require("path"));
9
- const fs_extra_1 = __importDefault(require("fs-extra"));
10
- const chalk_1 = __importDefault(require("chalk"));
11
- const detect_port_1 = __importDefault(require("detect-port"));
12
- const prompts_1 = __importDefault(require("prompts"));
13
- const open_1 = __importDefault(require("open"));
14
- const loadConfig_1 = require("../../utils/loadConfig");
10
+ import http from 'http';
11
+ import path from 'path';
12
+ import fs from 'fs-extra';
13
+ import chalk from 'chalk';
14
+ import detectPort from 'detect-port';
15
+ import prompts from 'prompts';
16
+ import open from 'open';
17
+ import { loadReactClientConfig } from '../../utils/loadConfig';
15
18
  const MIME = {
16
19
  '.html': 'text/html; charset=utf-8',
17
20
  '.js': 'application/javascript; charset=utf-8',
@@ -31,7 +34,7 @@ const MIME = {
31
34
  '.txt': 'text/plain; charset=utf-8',
32
35
  };
33
36
  function contentType(file) {
34
- return MIME[path_1.default.extname(file).toLowerCase()] || 'application/octet-stream';
37
+ return MIME[path.extname(file).toLowerCase()] || 'application/octet-stream';
35
38
  }
36
39
  function setCachingHeaders(res, stat) {
37
40
  // Short cache for preview by default, but set ETag/Last-Modified so browsers behave nicely
@@ -40,126 +43,129 @@ function setCachingHeaders(res, stat) {
40
43
  res.setHeader('Last-Modified', stat.mtime.toUTCString());
41
44
  res.setHeader('Cache-Control', 'public, max-age=0, must-revalidate');
42
45
  }
43
- async function preview() {
44
- const cwd = process.cwd();
45
- const config = await (0, loadConfig_1.loadReactClientConfig)(cwd);
46
- const appRoot = path_1.default.resolve(cwd, config.root || '.');
47
- const outDir = path_1.default.join(appRoot, config.build?.outDir || 'dist');
48
- const indexHtml = path_1.default.join(outDir, 'index.html');
49
- if (!(await fs_extra_1.default.pathExists(outDir))) {
50
- console.error(chalk_1.default.red(`āŒ Preview directory not found: ${outDir}`));
51
- process.exit(1);
52
- }
53
- if (!(await fs_extra_1.default.pathExists(indexHtml))) {
54
- console.warn(chalk_1.default.yellow(`āš ļø index.html not found in ${outDir}. SPA fallback will be disabled.`));
55
- }
56
- const defaultPort = config.server?.port || 4173;
57
- const port = await (0, detect_port_1.default)(defaultPort);
58
- if (port !== defaultPort) {
59
- const r = await (0, prompts_1.default)({
60
- type: 'confirm',
61
- name: 'useNewPort',
62
- initial: true,
63
- message: `Port ${defaultPort} is occupied. Use ${port} instead?`,
64
- });
65
- if (!r.useNewPort) {
66
- console.log('šŸ›‘ Preview cancelled.');
67
- process.exit(0);
46
+ export default function preview() {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ var _a, _b;
49
+ const cwd = process.cwd();
50
+ const config = yield loadReactClientConfig(cwd);
51
+ const appRoot = path.resolve(cwd, config.root || '.');
52
+ const outDir = path.join(appRoot, ((_a = config.build) === null || _a === void 0 ? void 0 : _a.outDir) || 'dist');
53
+ const indexHtml = path.join(outDir, 'index.html');
54
+ if (!(yield fs.pathExists(outDir))) {
55
+ console.error(chalk.red(`āŒ Preview directory not found: ${outDir}`));
56
+ process.exit(1);
68
57
  }
69
- }
70
- const server = http_1.default.createServer(async (req, res) => {
71
- try {
72
- const url = req.url || '/';
73
- // normalize and protect
74
- const relPath = decodeURIComponent(url.split('?')[0]);
75
- if (relPath.includes('..')) {
76
- res.writeHead(400);
77
- return res.end('Invalid request');
58
+ if (!(yield fs.pathExists(indexHtml))) {
59
+ console.warn(chalk.yellow(`āš ļø index.html not found in ${outDir}. SPA fallback will be disabled.`));
60
+ }
61
+ const defaultPort = ((_b = config.server) === null || _b === void 0 ? void 0 : _b.port) || 4173;
62
+ const port = yield detectPort(defaultPort);
63
+ if (port !== defaultPort) {
64
+ const r = yield prompts({
65
+ type: 'confirm',
66
+ name: 'useNewPort',
67
+ initial: true,
68
+ message: `Port ${defaultPort} is occupied. Use ${port} instead?`,
69
+ });
70
+ if (!r.useNewPort) {
71
+ console.log('šŸ›‘ Preview cancelled.');
72
+ process.exit(0);
78
73
  }
79
- // handle root -> index.html
80
- let filePath = path_1.default.join(outDir, relPath);
81
- const tryIndexFallback = async () => {
82
- if (await fs_extra_1.default.pathExists(indexHtml)) {
83
- const stat = await fs_extra_1.default.stat(indexHtml);
84
- setCachingHeaders(res, stat);
85
- res.setHeader('Content-Type', 'text/html; charset=utf-8');
86
- return fs_extra_1.default.createReadStream(indexHtml).pipe(res);
87
- }
88
- else {
89
- res.writeHead(404);
90
- return res.end('Not found');
74
+ }
75
+ const server = http.createServer((req, res) => __awaiter(this, void 0, void 0, function* () {
76
+ try {
77
+ const url = req.url || '/';
78
+ // normalize and protect
79
+ const relPath = decodeURIComponent(url.split('?')[0]);
80
+ if (relPath.includes('..')) {
81
+ res.writeHead(400);
82
+ return res.end('Invalid request');
91
83
  }
92
- };
93
- // If the request path is a directory, try index.html inside it
94
- if (relPath.endsWith('/')) {
95
- const candidate = path_1.default.join(filePath, 'index.html');
96
- if (await fs_extra_1.default.pathExists(candidate)) {
97
- filePath = candidate;
84
+ // handle root -> index.html
85
+ let filePath = path.join(outDir, relPath);
86
+ const tryIndexFallback = () => __awaiter(this, void 0, void 0, function* () {
87
+ if (yield fs.pathExists(indexHtml)) {
88
+ const stat = yield fs.stat(indexHtml);
89
+ setCachingHeaders(res, stat);
90
+ res.setHeader('Content-Type', 'text/html; charset=utf-8');
91
+ return fs.createReadStream(indexHtml).pipe(res);
92
+ }
93
+ else {
94
+ res.writeHead(404);
95
+ return res.end('Not found');
96
+ }
97
+ });
98
+ // If the request path is a directory, try index.html inside it
99
+ if (relPath.endsWith('/')) {
100
+ const candidate = path.join(filePath, 'index.html');
101
+ if (yield fs.pathExists(candidate)) {
102
+ filePath = candidate;
103
+ }
104
+ else {
105
+ return tryIndexFallback();
106
+ }
98
107
  }
99
- else {
108
+ // If file doesn't exist, fallback to index.html for SPA routes
109
+ if (!(yield fs.pathExists(filePath))) {
110
+ // If request appears to be a static asset (has extension), return 404
111
+ if (path.extname(filePath)) {
112
+ res.writeHead(404);
113
+ return res.end('Not found');
114
+ }
100
115
  return tryIndexFallback();
101
116
  }
102
- }
103
- // If file doesn't exist, fallback to index.html for SPA routes
104
- if (!(await fs_extra_1.default.pathExists(filePath))) {
105
- // If request appears to be a static asset (has extension), return 404
106
- if (path_1.default.extname(filePath)) {
107
- res.writeHead(404);
108
- return res.end('Not found');
109
- }
110
- return tryIndexFallback();
111
- }
112
- const stat = await fs_extra_1.default.stat(filePath);
113
- if (!stat.isFile()) {
114
- return tryIndexFallback();
115
- }
116
- // Compression/Precompressed support: prefer brotli -> gzip -> raw
117
- const accept = (req.headers['accept-encoding'] || '');
118
- const tryPrecompressed = async () => {
119
- if (accept.includes('br') && (await fs_extra_1.default.pathExists(filePath + '.br'))) {
120
- res.setHeader('Content-Encoding', 'br');
121
- res.setHeader('Content-Type', contentType(filePath));
122
- setCachingHeaders(res, stat);
123
- return fs_extra_1.default.createReadStream(filePath + '.br').pipe(res);
117
+ const stat = yield fs.stat(filePath);
118
+ if (!stat.isFile()) {
119
+ return tryIndexFallback();
124
120
  }
125
- if (accept.includes('gzip') && (await fs_extra_1.default.pathExists(filePath + '.gz'))) {
126
- res.setHeader('Content-Encoding', 'gzip');
121
+ // Compression/Precompressed support: prefer brotli -> gzip -> raw
122
+ const accept = (req.headers['accept-encoding'] || '');
123
+ const tryPrecompressed = () => __awaiter(this, void 0, void 0, function* () {
124
+ if (accept.includes('br') && (yield fs.pathExists(filePath + '.br'))) {
125
+ res.setHeader('Content-Encoding', 'br');
126
+ res.setHeader('Content-Type', contentType(filePath));
127
+ setCachingHeaders(res, stat);
128
+ return fs.createReadStream(filePath + '.br').pipe(res);
129
+ }
130
+ if (accept.includes('gzip') && (yield fs.pathExists(filePath + '.gz'))) {
131
+ res.setHeader('Content-Encoding', 'gzip');
132
+ res.setHeader('Content-Type', contentType(filePath));
133
+ setCachingHeaders(res, stat);
134
+ return fs.createReadStream(filePath + '.gz').pipe(res);
135
+ }
136
+ // default
127
137
  res.setHeader('Content-Type', contentType(filePath));
128
138
  setCachingHeaders(res, stat);
129
- return fs_extra_1.default.createReadStream(filePath + '.gz').pipe(res);
139
+ return fs.createReadStream(filePath).pipe(res);
140
+ });
141
+ // ETag / If-None-Match handling
142
+ const etag = `${stat.size}-${Date.parse(stat.mtime.toString())}`;
143
+ const inm = req.headers['if-none-match'];
144
+ if (inm && inm.toString() === etag) {
145
+ res.writeHead(304);
146
+ return res.end();
130
147
  }
131
- // default
132
- res.setHeader('Content-Type', contentType(filePath));
133
- setCachingHeaders(res, stat);
134
- return fs_extra_1.default.createReadStream(filePath).pipe(res);
135
- };
136
- // ETag / If-None-Match handling
137
- const etag = `${stat.size}-${Date.parse(stat.mtime.toString())}`;
138
- const inm = req.headers['if-none-match'];
139
- if (inm && inm.toString() === etag) {
140
- res.writeHead(304);
141
- return res.end();
148
+ return tryPrecompressed();
142
149
  }
143
- return tryPrecompressed();
144
- }
145
- catch (err) {
146
- const e = err;
147
- console.error('Preview server error:', e);
148
- res.writeHead(500);
149
- res.end('Internal Server Error');
150
- }
151
- });
152
- server.listen(port, async () => {
153
- const url = `http://localhost:${port}`;
154
- console.log(chalk_1.default.cyan.bold('\nšŸ”Ž react-client preview'));
155
- console.log(chalk_1.default.gray('────────────────────────'));
156
- console.log(chalk_1.default.green(`Serving: ${outDir}`));
157
- console.log(chalk_1.default.green(`Open: ${url}`));
158
- await (0, open_1.default)(url, { newInstance: true });
159
- });
160
- process.on('SIGINT', () => {
161
- console.log(chalk_1.default.red('\nšŸ›‘ Shutting down preview...'));
162
- server.close();
163
- process.exit(0);
150
+ catch (err) {
151
+ const e = err;
152
+ console.error('Preview server error:', e);
153
+ res.writeHead(500);
154
+ res.end('Internal Server Error');
155
+ }
156
+ }));
157
+ server.listen(port, () => __awaiter(this, void 0, void 0, function* () {
158
+ const url = `http://localhost:${port}`;
159
+ console.log(chalk.cyan.bold('\nšŸ”Ž react-client preview'));
160
+ console.log(chalk.gray('────────────────────────'));
161
+ console.log(chalk.green(`Serving: ${outDir}`));
162
+ console.log(chalk.green(`Open: ${url}`));
163
+ yield open(url, { newInstance: true });
164
+ }));
165
+ process.on('SIGINT', () => {
166
+ console.log(chalk.red('\nšŸ›‘ Shutting down preview...'));
167
+ server.close();
168
+ process.exit(0);
169
+ });
164
170
  });
165
171
  }
package/dist/cli/index.js CHANGED
@@ -1,50 +1,50 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const commander_1 = require("commander");
8
- const path_1 = __importDefault(require("path"));
9
- const fs_extra_1 = __importDefault(require("fs-extra"));
10
- const chalk_1 = __importDefault(require("chalk"));
11
- const init_1 = __importDefault(require("./commands/init"));
12
- const dev_1 = __importDefault(require("./commands/dev"));
13
- const build_1 = __importDefault(require("./commands/build"));
14
- const preview_1 = __importDefault(require("./commands/preview"));
2
+ import { dirname, resolve } from 'path';
3
+ import fs from 'fs-extra';
4
+ import chalk from 'chalk';
5
+ import { Command } from 'commander';
6
+ import { fileURLToPath, pathToFileURL } from 'url';
7
+ import initCmd from './commands/init';
8
+ import devCmd from './commands/dev';
9
+ import buildCmd from './commands/build';
10
+ import previewCmd from './commands/preview';
11
+ // Polyfill for __dirname in ESM
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = dirname(__filename);
15
14
  // Load package.json version dynamically
16
- const pkgPath = path_1.default.resolve(__dirname, '../../package.json');
17
- const pkg = fs_extra_1.default.existsSync(pkgPath)
18
- ? JSON.parse(fs_extra_1.default.readFileSync(pkgPath, 'utf8'))
15
+ const pkgPath = resolve(__dirname, '../../package.json');
16
+ const isMainModule = process.argv[1] && pathToFileURL(process.argv[1]).href === import.meta.url;
17
+ const pkg = fs.existsSync(pkgPath)
18
+ ? JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
19
19
  : { version: '0.0.0' };
20
20
  // 🧠 Fancy startup banner
21
21
  function showBanner(cmd) {
22
- const title = chalk_1.default.bold.cyan('⚔ React Client');
23
- const version = chalk_1.default.gray(`v${pkg.version}`);
24
- const tagline = chalk_1.default.dim('Fast esbuild-based React CLI with HMR & Overlay');
25
- const line = chalk_1.default.gray('──────────────────────────────────────────────────────────────');
22
+ const title = chalk.bold.cyan('⚔ React Client');
23
+ const version = chalk.gray(`v${pkg.version}`);
24
+ const tagline = chalk.dim('Fast esbuild-based React CLI with HMR & Overlay');
25
+ const line = chalk.gray('──────────────────────────────────────────────────────────────');
26
26
  console.log(`\n${title} ${version}`);
27
27
  console.log(tagline);
28
28
  console.log(line);
29
29
  switch (cmd) {
30
30
  case 'init':
31
- console.log(chalk_1.default.cyan('šŸ“¦ Initializing new React project...\n'));
31
+ console.log(chalk.cyan('šŸ“¦ Initializing new React project...\n'));
32
32
  break;
33
33
  case 'dev':
34
- console.log(chalk_1.default.green('šŸš€ Starting development server...\n'));
34
+ console.log(chalk.green('šŸš€ Starting development server...\n'));
35
35
  break;
36
36
  case 'build':
37
- console.log(chalk_1.default.yellow('šŸ—ļø Building for production...\n'));
37
+ console.log(chalk.yellow('šŸ—ļø Building for production...\n'));
38
38
  break;
39
39
  case 'preview':
40
- console.log(chalk_1.default.blue('🌐 Starting production preview server...\n'));
40
+ console.log(chalk.blue('🌐 Starting production preview server...\n'));
41
41
  break;
42
42
  default:
43
43
  console.log();
44
44
  }
45
45
  }
46
46
  // 🧩 Commander setup
47
- const program = new commander_1.Command();
47
+ const program = new Command();
48
48
  program
49
49
  .name('react-client')
50
50
  .description('react-client CLI – A lightweight React toolkit for fast builds & dev server')
@@ -59,34 +59,34 @@ program
59
59
  .description('initialize a new React project')
60
60
  .action((name, opts) => {
61
61
  showBanner('init');
62
- (0, init_1.default)(name, opts);
62
+ initCmd(name, opts);
63
63
  });
64
64
  program
65
65
  .command('dev')
66
66
  .description('start dev server (with React Fast Refresh)')
67
67
  .action(() => {
68
68
  showBanner('dev');
69
- (0, dev_1.default)();
69
+ devCmd();
70
70
  });
71
71
  program
72
72
  .command('build')
73
73
  .description('build production assets')
74
74
  .action(() => {
75
75
  showBanner('build');
76
- (0, build_1.default)();
76
+ buildCmd();
77
77
  });
78
78
  program
79
79
  .command('preview')
80
80
  .description('preview production build')
81
81
  .action(() => {
82
82
  showBanner('preview');
83
- (0, preview_1.default)();
83
+ previewCmd();
84
84
  });
85
85
  // ------------------------------------------------------
86
86
  // Default / Unknown command handling
87
87
  // ------------------------------------------------------
88
88
  program.on('command:*', () => {
89
- console.error(chalk_1.default.red('āŒ Invalid command:'), program.args.join(' '));
89
+ console.error(chalk.red('āŒ Invalid command:'), program.args.join(' '));
90
90
  console.log();
91
91
  program.outputHelp();
92
92
  process.exit(1);
@@ -94,7 +94,7 @@ program.on('command:*', () => {
94
94
  // ------------------------------------------------------
95
95
  // Entry point
96
96
  // ------------------------------------------------------
97
- if (require.main === module) {
97
+ if (isMainModule) {
98
98
  if (process.argv.length <= 2) {
99
99
  console.clear();
100
100
  showBanner();
@@ -104,4 +104,4 @@ if (require.main === module) {
104
104
  program.parse(process.argv);
105
105
  }
106
106
  }
107
- exports.default = program;
107
+ export default program;
package/dist/cli/types.js CHANGED
@@ -1,3 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = {};
1
+ export default {};
package/dist/index.js CHANGED
@@ -1,20 +1,2 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.defineConfig = void 0;
18
- const defineConfig = (c) => c;
19
- exports.defineConfig = defineConfig;
20
- __exportStar(require("./cli/index"), exports);
1
+ export const defineConfig = (c) => c;
2
+ export * from './cli/index';