conductor-remote 1.9.0 → 1.10.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/bin/cli.js CHANGED
@@ -1,14 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
  // conductor-remote CLI entrypoint.
3
3
  //
4
- // Runs on plain Node ≥24 with zero flags: the relay is stdlib-only and the two
5
- // param-property constructors that once needed --experimental-transform-types
6
- // are gone, so default type-stripping handles the .ts sources on import.
4
+ // Runs on plain Node ≥24 with zero flags. The published tarball ships compiled JS
5
+ // under dist-node/ (Node REFUSES to type-strip .ts under node_modules, so an
6
+ // installed package can't run raw sources); a dev checkout has no dist-node/ and
7
+ // runs the .ts sources directly, since type-stripping works outside node_modules.
8
+ // resolveEntry() prefers compiled, falls back to source — one entrypoint, both worlds.
7
9
  //
8
10
  // The one remaining wrinkle is node:sqlite, still flagged experimental in 24.
9
11
  // We silence *only* that warning here (instead of re-execing node with
10
12
  // --disable-warning) so the entrypoint stays a shebang + import.
11
- import { readFileSync } from 'node:fs'
13
+ import { existsSync, readFileSync } from 'node:fs'
14
+ import { fileURLToPath } from 'node:url'
12
15
 
13
16
  const emitWarning = process.emitWarning.bind(process)
14
17
  process.emitWarning = (warning, ...rest) => {
@@ -27,6 +30,18 @@ if (major < REQUIRED_MAJOR) {
27
30
  process.exit(1)
28
31
  }
29
32
 
33
+ // Under node_modules (installed package) Node can't type-strip, so run compiled dist-node/; outside it
34
+ // (dev checkout) run the live .ts source so edits take effect without a build. Each falls back to the
35
+ // other if its preferred artifact is missing.
36
+ function resolveEntry(compiledRel, sourceRel) {
37
+ const order = import.meta.url.includes('/node_modules/') ? [compiledRel, sourceRel] : [sourceRel, compiledRel]
38
+ for (const rel of order) {
39
+ const url = new URL(rel, import.meta.url)
40
+ if (existsSync(fileURLToPath(url))) return url.href
41
+ }
42
+ return new URL(order[0], import.meta.url).href
43
+ }
44
+
30
45
  const [cmd, ...rest] = process.argv.slice(2)
31
46
 
32
47
  function version() {
@@ -65,12 +80,12 @@ function usage() {
65
80
  switch (cmd) {
66
81
  case undefined:
67
82
  case 'start':
68
- await import('../src/server.ts')
83
+ await import(resolveEntry('../dist-node/src/server.js', '../src/server.ts'))
69
84
  break
70
85
  case 'service':
71
86
  // service.ts reads its subcommand from argv[2]; re-shape argv so `service install` → `install`.
72
87
  process.argv = [process.argv[0], process.argv[1], ...rest]
73
- await import('../scripts/service.ts')
88
+ await import(resolveEntry('../dist-node/scripts/service.js', '../scripts/service.ts'))
74
89
  break
75
90
  case '-v':
76
91
  case '--version':