neex 0.6.63 → 0.6.64

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,4 +1,27 @@
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
@@ -13,7 +36,19 @@ const figures_1 = __importDefault(require("figures"));
13
36
  const path_1 = __importDefault(require("path"));
14
37
  const fs_1 = __importDefault(require("fs"));
15
38
  const lodash_1 = require("lodash");
16
- const child_process_2 = require("child_process");
39
+ async function isCommandAvailable(command) {
40
+ try {
41
+ const { exec } = await Promise.resolve().then(() => __importStar(require('child_process')));
42
+ return new Promise((resolve) => {
43
+ exec(`command -v ${command}`, (error) => {
44
+ resolve(!error);
45
+ });
46
+ });
47
+ }
48
+ catch (e) {
49
+ return false;
50
+ }
51
+ }
17
52
  class DevManager {
18
53
  constructor(options) {
19
54
  this.process = null;
@@ -47,109 +82,24 @@ class DevManager {
47
82
  }
48
83
  }
49
84
  }
50
- checkCommandExists(command) {
51
- try {
52
- (0, child_process_2.execSync)(`command -v ${command}`, { stdio: 'ignore' });
53
- return true;
54
- }
55
- catch (_a) {
56
- try {
57
- (0, child_process_2.execSync)(`where ${command}`, { stdio: 'ignore' });
58
- return true;
59
- }
60
- catch (_b) {
61
- return false;
62
- }
63
- }
64
- }
65
- findBestExecutor() {
66
- const fileExt = path_1.default.extname(this.options.file).toLowerCase();
67
- const isTypeScript = fileExt === '.ts' || fileExt === '.tsx';
68
- // اگر کاربر خودش command مشخص کرده
85
+ async getExecuteCommand() {
69
86
  if (this.options.execCommand) {
70
87
  const parts = this.options.execCommand.split(' ');
71
- return {
72
- command: parts[0],
73
- args: [...parts.slice(1), this.options.file],
74
- needsRegister: false
75
- };
88
+ return { command: parts[0], args: [...parts.slice(1), this.options.file] };
76
89
  }
77
- const baseArgs = [this.options.file];
90
+ // Default to tsx for TypeScript files
91
+ const tsxExists = await isCommandAvailable('tsx');
92
+ if (!tsxExists) {
93
+ throw new Error('`tsx` command not found. Please install `tsx`');
94
+ }
95
+ const args = [this.options.file];
78
96
  if (this.options.inspect) {
79
- baseArgs.unshift('--inspect');
97
+ args.unshift('--inspect');
80
98
  }
81
99
  if (this.options.inspectBrk) {
82
- baseArgs.unshift('--inspect-brk');
83
- }
84
- // بررسی tsx
85
- if (this.checkCommandExists('tsx')) {
86
- if (this.options.verbose) {
87
- logger_manager_js_1.loggerManager.printLine('Using tsx for execution', 'info');
88
- }
89
- return { command: 'tsx', args: baseArgs, needsRegister: false };
90
- }
91
- // بررسی ts-node
92
- if (isTypeScript && this.checkCommandExists('ts-node')) {
93
- if (this.options.verbose) {
94
- logger_manager_js_1.loggerManager.printLine('Using ts-node for execution', 'info');
95
- }
96
- return { command: 'ts-node', args: baseArgs, needsRegister: false };
97
- }
98
- // بررسی bun
99
- if (this.checkCommandExists('bun')) {
100
- if (this.options.verbose) {
101
- logger_manager_js_1.loggerManager.printLine('Using bun for execution', 'info');
102
- }
103
- return { command: 'bun', args: baseArgs, needsRegister: false };
104
- }
105
- // بررسی deno
106
- if (this.checkCommandExists('deno')) {
107
- if (this.options.verbose) {
108
- logger_manager_js_1.loggerManager.printLine('Using deno for execution', 'info');
109
- }
110
- return { command: 'deno', args: ['run', '--allow-all', this.options.file], needsRegister: false };
111
- }
112
- // Fallback به node با ts-node/register اگر فایل TypeScript باشه
113
- if (isTypeScript) {
114
- // بررسی ts-node/register
115
- try {
116
- require.resolve('ts-node/register');
117
- if (this.options.verbose) {
118
- logger_manager_js_1.loggerManager.printLine('Using node with ts-node/register', 'info');
119
- }
120
- return {
121
- command: 'node',
122
- args: ['--require', 'ts-node/register', ...baseArgs],
123
- needsRegister: true
124
- };
125
- }
126
- catch (_a) {
127
- // اگر ts-node نباشه، خطا بده
128
- throw new Error('TypeScript file detected but no TypeScript executor found. Please install one of:\n' +
129
- ' • tsx: npm install -g tsx\n' +
130
- ' • ts-node: npm install -g ts-node\n' +
131
- ' • bun: curl -fsSL https://bun.sh/install | bash\n' +
132
- ' • Or compile to JavaScript first');
133
- }
134
- }
135
- // برای فایل‌های JavaScript از node استفاده کن
136
- if (this.options.verbose) {
137
- logger_manager_js_1.loggerManager.printLine('Using node for execution', 'info');
138
- }
139
- return { command: 'node', args: baseArgs, needsRegister: false };
140
- }
141
- showExecutorInfo(executor) {
142
- const fileExt = path_1.default.extname(this.options.file).toLowerCase();
143
- const isTypeScript = fileExt === '.ts' || fileExt === '.tsx';
144
- if (!this.options.quiet) {
145
- if (isTypeScript && executor.command === 'node' && executor.needsRegister) {
146
- logger_manager_js_1.loggerManager.printLine(`${chalk_1.default.yellow(figures_1.default.warning)} TypeScript support via ts-node/register (consider installing tsx for better performance)`, 'warn');
147
- }
148
- if (this.options.verbose) {
149
- logger_manager_js_1.loggerManager.printLine(`Executor: ${executor.command}`, 'info');
150
- logger_manager_js_1.loggerManager.printLine(`Arguments: ${executor.args.join(' ')}`, 'info');
151
- }
100
+ args.unshift('--inspect-brk');
152
101
  }
102
+ return { command: 'tsx', args };
153
103
  }
154
104
  clearConsole() {
155
105
  if (this.options.clearConsole && process.stdout.isTTY) {
@@ -162,12 +112,11 @@ class DevManager {
162
112
  return;
163
113
  }
164
114
  this.loadEnvFile();
165
- const executor = this.findBestExecutor();
166
- this.showExecutorInfo(executor);
115
+ const { command, args } = await this.getExecuteCommand();
167
116
  if (this.options.verbose) {
168
- logger_manager_js_1.loggerManager.printLine(`Executing: ${executor.command} ${executor.args.join(' ')}`, 'info');
117
+ logger_manager_js_1.loggerManager.printLine(`Executing: ${command} ${args.join(' ')}`, 'info');
169
118
  }
170
- this.process = (0, child_process_1.spawn)(executor.command, executor.args, {
119
+ this.process = (0, child_process_1.spawn)(command, args, {
171
120
  stdio: ['ignore', 'pipe', 'pipe'],
172
121
  shell: false,
173
122
  env: {
@@ -195,10 +144,6 @@ class DevManager {
195
144
  });
196
145
  this.process.on('error', (error) => {
197
146
  logger_manager_js_1.loggerManager.printLine(`Process error: ${error.message}`, 'error');
198
- // اگر خطا مربوط به نبود command باشه، راهنمایی بده
199
- if (error.message.includes('ENOENT')) {
200
- logger_manager_js_1.loggerManager.printLine('Command not found. Please check if the executor is installed and accessible.', 'error');
201
- }
202
147
  });
203
148
  this.process.on('exit', (code, signal) => {
204
149
  if (this.process) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neex",
3
- "version": "0.6.63",
3
+ "version": "0.6.64",
4
4
  "description": "The Modern Build System for Polyrepo-in-Monorepo Architecture",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",