rajt 0.0.104 → 0.0.106
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/bin/rajt.js +13 -10
- package/package.json +1 -1
- package/src/cli/commands/dev.ts +18 -6
- package/src/cli/utils.ts +21 -1
package/bin/rajt.js
CHANGED
|
@@ -51,20 +51,23 @@ Consider using a Node.js version manager such as https://volta.sh or https://git
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
function findTsx() {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
const exts = ['', '.exe', '.cmd'];
|
|
55
|
+
const paths = [
|
|
56
|
+
[__dirname, '../node_modules/tsx/dist/cli.mjs'],
|
|
57
|
+
[process.cwd(), 'node_modules/tsx/dist/cli.mjs'],
|
|
58
|
+
[__dirname, '../node_modules/.bin/tsx'],
|
|
59
|
+
[process.cwd(), 'node_modules/.bin/tsx'],
|
|
59
60
|
];
|
|
60
61
|
|
|
61
|
-
for (const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
for (const _path of paths) {
|
|
63
|
+
const path = join(..._path);
|
|
64
|
+
for (const ext of exts) {
|
|
65
|
+
const entry = path + ext;
|
|
66
|
+
if (existsSync(entry)) return entry;
|
|
67
|
+
}
|
|
65
68
|
}
|
|
66
69
|
|
|
67
|
-
return
|
|
70
|
+
return ''
|
|
68
71
|
}
|
|
69
72
|
|
|
70
73
|
function execute(command, args) {
|
package/package.json
CHANGED
package/src/cli/commands/dev.ts
CHANGED
|
@@ -7,7 +7,8 @@ import type { WranglerConfig } from 'localflare-core'
|
|
|
7
7
|
import {
|
|
8
8
|
build, wait, watch, normalizePlatform, platformError, getRuntime,
|
|
9
9
|
wranglerConfig, createMiniflare, localflareManifest,
|
|
10
|
-
getDockerHost
|
|
10
|
+
getDockerHost,
|
|
11
|
+
findTsx
|
|
11
12
|
} from '../utils'
|
|
12
13
|
import { error, event, log, rn, warn } from '../../utils/log'
|
|
13
14
|
import { _root } from '../../utils/paths'
|
|
@@ -201,12 +202,23 @@ export default defineCommand({
|
|
|
201
202
|
default:
|
|
202
203
|
case 'node':
|
|
203
204
|
return withPort(desiredPort, async (port) => {
|
|
204
|
-
started(port)
|
|
205
205
|
const isBun = getRuntime() === 'bun'
|
|
206
|
-
|
|
206
|
+
const isWin32 = process.platform === 'win32'
|
|
207
|
+
|
|
208
|
+
const _arg = isBun ? 'run' : findTsx()
|
|
209
|
+
|
|
210
|
+
if (!_arg) {
|
|
211
|
+
console.error('Error: "tsx" is not available. Please install tsx:')
|
|
212
|
+
console.error(' npm i -D tsx')
|
|
213
|
+
console.error(' or')
|
|
214
|
+
console.error(' bun i -D tsx')
|
|
215
|
+
process.exit(1)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
started(port)
|
|
207
219
|
const params = isBun
|
|
208
|
-
? ['
|
|
209
|
-
: [
|
|
220
|
+
? ['--port=' + port, '--hot', '--silent', '--no-clear-screen', '--no-summary']
|
|
221
|
+
: ['watch']
|
|
210
222
|
|
|
211
223
|
let nodeApp: ChildProcess | null = null
|
|
212
224
|
const stopNode = async () => {
|
|
@@ -218,7 +230,7 @@ export default defineCommand({
|
|
|
218
230
|
|
|
219
231
|
nodeApp = spawn(
|
|
220
232
|
isBun && isWin32 ? 'bun' : process.execPath,
|
|
221
|
-
params,
|
|
233
|
+
[_arg, ...params, join(_root, `node_modules/rajt/src/dev${isBun ? '' : '-node'}.ts`)],
|
|
222
234
|
{
|
|
223
235
|
stdio: ['inherit', isBun ? 'pipe' : 'inherit', 'inherit', 'ipc'],
|
|
224
236
|
env: {...process.env, PORT: port},
|
package/src/cli/utils.ts
CHANGED
|
@@ -142,7 +142,7 @@ export const build = async (platform: Platform, env: string = 'prd') => {
|
|
|
142
142
|
const opts = {
|
|
143
143
|
entryPoints: [join(_rajt, `prod${platform}.ts`)],
|
|
144
144
|
bundle: true,
|
|
145
|
-
minify:
|
|
145
|
+
minify: true,
|
|
146
146
|
outfile: join(_root, dist +'/index.js'),
|
|
147
147
|
format: 'esm',
|
|
148
148
|
target: isCF ? 'es2022' : 'node20',
|
|
@@ -548,3 +548,23 @@ export const highlightedURI = (uri: string, method: string) => uri.replace(
|
|
|
548
548
|
/(?::([a-zA-Z_][a-zA-Z0-9_]*)(\{[^}]+\})?|\*)/g,
|
|
549
549
|
_ => highlightedMethod(method, _)
|
|
550
550
|
)
|
|
551
|
+
|
|
552
|
+
export function findTsx() {
|
|
553
|
+
const exts = ['', '.exe', '.cmd']
|
|
554
|
+
const paths = [
|
|
555
|
+
[_root, '../node_modules/tsx/dist/cli.mjs'],
|
|
556
|
+
[process.cwd(), 'node_modules/tsx/dist/cli.mjs'],
|
|
557
|
+
[_root, '../node_modules/.bin/tsx'],
|
|
558
|
+
[process.cwd(), 'node_modules/.bin/tsx'],
|
|
559
|
+
] as const
|
|
560
|
+
|
|
561
|
+
for (const _path of paths) {
|
|
562
|
+
const path = join(..._path)
|
|
563
|
+
for (const ext of exts) {
|
|
564
|
+
const entry = path + ext
|
|
565
|
+
if (existsSync(entry)) return entry
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
return ''
|
|
570
|
+
}
|