create-leo-app 0.7.3 → 0.8.4
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/README.md +3 -3
- package/dist/index.mjs +38 -38
- package/package.json +5 -7
- package/template-extension/package.json +4 -4
- package/template-nextjs-ts/package.json +9 -9
- package/template-node/package.json +2 -2
- package/template-node-ts/package.json +5 -5
- package/template-offline-public-transaction-ts/package.json +5 -5
- package/template-react-leo/README.md +3 -8
- package/template-react-leo/package.json +23 -23
- package/template-react-leo/vite.config.js +2 -1
- package/template-react-managed-worker/README.md +1 -3
- package/template-react-managed-worker/package.json +22 -22
- package/template-react-managed-worker/vite.config.js +2 -1
- package/template-react-ts/README.md +3 -8
- package/template-react-ts/package.json +28 -28
- package/template-react-ts/vite.config.ts +2 -1
- package/template-vanilla/main.js +1 -1
- package/template-vanilla/package.json +3 -3
- package/template-vanilla/vite.config.js +3 -1
- package/template-nextjs-ts/node_modules/@types/node/LICENSE +0 -21
- package/template-nextjs-ts/node_modules/@types/node/README.md +0 -15
- package/template-nextjs-ts/node_modules/@types/node/assert/strict.d.ts +0 -8
- package/template-nextjs-ts/node_modules/@types/node/assert.d.ts +0 -1040
- package/template-nextjs-ts/node_modules/@types/node/async_hooks.d.ts +0 -541
- package/template-nextjs-ts/node_modules/@types/node/buffer.d.ts +0 -2301
- package/template-nextjs-ts/node_modules/@types/node/child_process.d.ts +0 -1544
- package/template-nextjs-ts/node_modules/@types/node/cluster.d.ts +0 -578
- package/template-nextjs-ts/node_modules/@types/node/console.d.ts +0 -452
- package/template-nextjs-ts/node_modules/@types/node/constants.d.ts +0 -19
- package/template-nextjs-ts/node_modules/@types/node/crypto.d.ts +0 -4524
- package/template-nextjs-ts/node_modules/@types/node/dgram.d.ts +0 -596
- package/template-nextjs-ts/node_modules/@types/node/diagnostics_channel.d.ts +0 -554
- package/template-nextjs-ts/node_modules/@types/node/dns/promises.d.ts +0 -476
- package/template-nextjs-ts/node_modules/@types/node/dns.d.ts +0 -864
- package/template-nextjs-ts/node_modules/@types/node/dom-events.d.ts +0 -124
- package/template-nextjs-ts/node_modules/@types/node/domain.d.ts +0 -170
- package/template-nextjs-ts/node_modules/@types/node/events.d.ts +0 -931
- package/template-nextjs-ts/node_modules/@types/node/fs/promises.d.ts +0 -1245
- package/template-nextjs-ts/node_modules/@types/node/fs.d.ts +0 -4317
- package/template-nextjs-ts/node_modules/@types/node/globals.d.ts +0 -503
- package/template-nextjs-ts/node_modules/@types/node/globals.global.d.ts +0 -1
- package/template-nextjs-ts/node_modules/@types/node/http.d.ts +0 -1908
- package/template-nextjs-ts/node_modules/@types/node/http2.d.ts +0 -2418
- package/template-nextjs-ts/node_modules/@types/node/https.d.ts +0 -550
- package/template-nextjs-ts/node_modules/@types/node/index.d.ts +0 -89
- package/template-nextjs-ts/node_modules/@types/node/inspector.d.ts +0 -3696
- package/template-nextjs-ts/node_modules/@types/node/module.d.ts +0 -315
- package/template-nextjs-ts/node_modules/@types/node/net.d.ts +0 -999
- package/template-nextjs-ts/node_modules/@types/node/os.d.ts +0 -495
- package/template-nextjs-ts/node_modules/@types/node/package.json +0 -217
- package/template-nextjs-ts/node_modules/@types/node/path.d.ts +0 -191
- package/template-nextjs-ts/node_modules/@types/node/perf_hooks.d.ts +0 -934
- package/template-nextjs-ts/node_modules/@types/node/process.d.ts +0 -1879
- package/template-nextjs-ts/node_modules/@types/node/punycode.d.ts +0 -117
- package/template-nextjs-ts/node_modules/@types/node/querystring.d.ts +0 -153
- package/template-nextjs-ts/node_modules/@types/node/readline/promises.d.ts +0 -150
- package/template-nextjs-ts/node_modules/@types/node/readline.d.ts +0 -540
- package/template-nextjs-ts/node_modules/@types/node/repl.d.ts +0 -430
- package/template-nextjs-ts/node_modules/@types/node/sea.d.ts +0 -153
- package/template-nextjs-ts/node_modules/@types/node/stream/consumers.d.ts +0 -12
- package/template-nextjs-ts/node_modules/@types/node/stream/promises.d.ts +0 -83
- package/template-nextjs-ts/node_modules/@types/node/stream/web.d.ts +0 -521
- package/template-nextjs-ts/node_modules/@types/node/stream.d.ts +0 -1707
- package/template-nextjs-ts/node_modules/@types/node/string_decoder.d.ts +0 -67
- package/template-nextjs-ts/node_modules/@types/node/test.d.ts +0 -1874
- package/template-nextjs-ts/node_modules/@types/node/timers/promises.d.ts +0 -97
- package/template-nextjs-ts/node_modules/@types/node/timers.d.ts +0 -240
- package/template-nextjs-ts/node_modules/@types/node/tls.d.ts +0 -1217
- package/template-nextjs-ts/node_modules/@types/node/trace_events.d.ts +0 -197
- package/template-nextjs-ts/node_modules/@types/node/tty.d.ts +0 -208
- package/template-nextjs-ts/node_modules/@types/node/url.d.ts +0 -952
- package/template-nextjs-ts/node_modules/@types/node/util.d.ts +0 -2298
- package/template-nextjs-ts/node_modules/@types/node/v8.d.ts +0 -808
- package/template-nextjs-ts/node_modules/@types/node/vm.d.ts +0 -924
- package/template-nextjs-ts/node_modules/@types/node/wasi.d.ts +0 -181
- package/template-nextjs-ts/node_modules/@types/node/worker_threads.d.ts +0 -694
- package/template-nextjs-ts/node_modules/@types/node/zlib.d.ts +0 -539
- package/template-react-ts/node_modules/@types/node/LICENSE +0 -21
- package/template-react-ts/node_modules/@types/node/README.md +0 -15
- package/template-react-ts/node_modules/@types/node/assert/strict.d.ts +0 -8
- package/template-react-ts/node_modules/@types/node/assert.d.ts +0 -1040
- package/template-react-ts/node_modules/@types/node/async_hooks.d.ts +0 -541
- package/template-react-ts/node_modules/@types/node/buffer.d.ts +0 -2301
- package/template-react-ts/node_modules/@types/node/child_process.d.ts +0 -1544
- package/template-react-ts/node_modules/@types/node/cluster.d.ts +0 -578
- package/template-react-ts/node_modules/@types/node/console.d.ts +0 -452
- package/template-react-ts/node_modules/@types/node/constants.d.ts +0 -19
- package/template-react-ts/node_modules/@types/node/crypto.d.ts +0 -4524
- package/template-react-ts/node_modules/@types/node/dgram.d.ts +0 -596
- package/template-react-ts/node_modules/@types/node/diagnostics_channel.d.ts +0 -554
- package/template-react-ts/node_modules/@types/node/dns/promises.d.ts +0 -476
- package/template-react-ts/node_modules/@types/node/dns.d.ts +0 -864
- package/template-react-ts/node_modules/@types/node/dom-events.d.ts +0 -124
- package/template-react-ts/node_modules/@types/node/domain.d.ts +0 -170
- package/template-react-ts/node_modules/@types/node/events.d.ts +0 -931
- package/template-react-ts/node_modules/@types/node/fs/promises.d.ts +0 -1245
- package/template-react-ts/node_modules/@types/node/fs.d.ts +0 -4317
- package/template-react-ts/node_modules/@types/node/globals.d.ts +0 -503
- package/template-react-ts/node_modules/@types/node/globals.global.d.ts +0 -1
- package/template-react-ts/node_modules/@types/node/http.d.ts +0 -1908
- package/template-react-ts/node_modules/@types/node/http2.d.ts +0 -2418
- package/template-react-ts/node_modules/@types/node/https.d.ts +0 -550
- package/template-react-ts/node_modules/@types/node/index.d.ts +0 -89
- package/template-react-ts/node_modules/@types/node/inspector.d.ts +0 -3696
- package/template-react-ts/node_modules/@types/node/module.d.ts +0 -315
- package/template-react-ts/node_modules/@types/node/net.d.ts +0 -999
- package/template-react-ts/node_modules/@types/node/os.d.ts +0 -495
- package/template-react-ts/node_modules/@types/node/package.json +0 -217
- package/template-react-ts/node_modules/@types/node/path.d.ts +0 -191
- package/template-react-ts/node_modules/@types/node/perf_hooks.d.ts +0 -934
- package/template-react-ts/node_modules/@types/node/process.d.ts +0 -1879
- package/template-react-ts/node_modules/@types/node/punycode.d.ts +0 -117
- package/template-react-ts/node_modules/@types/node/querystring.d.ts +0 -153
- package/template-react-ts/node_modules/@types/node/readline/promises.d.ts +0 -150
- package/template-react-ts/node_modules/@types/node/readline.d.ts +0 -540
- package/template-react-ts/node_modules/@types/node/repl.d.ts +0 -430
- package/template-react-ts/node_modules/@types/node/sea.d.ts +0 -153
- package/template-react-ts/node_modules/@types/node/stream/consumers.d.ts +0 -12
- package/template-react-ts/node_modules/@types/node/stream/promises.d.ts +0 -83
- package/template-react-ts/node_modules/@types/node/stream/web.d.ts +0 -521
- package/template-react-ts/node_modules/@types/node/stream.d.ts +0 -1707
- package/template-react-ts/node_modules/@types/node/string_decoder.d.ts +0 -67
- package/template-react-ts/node_modules/@types/node/test.d.ts +0 -1874
- package/template-react-ts/node_modules/@types/node/timers/promises.d.ts +0 -97
- package/template-react-ts/node_modules/@types/node/timers.d.ts +0 -240
- package/template-react-ts/node_modules/@types/node/tls.d.ts +0 -1217
- package/template-react-ts/node_modules/@types/node/trace_events.d.ts +0 -197
- package/template-react-ts/node_modules/@types/node/tty.d.ts +0 -208
- package/template-react-ts/node_modules/@types/node/url.d.ts +0 -952
- package/template-react-ts/node_modules/@types/node/util.d.ts +0 -2298
- package/template-react-ts/node_modules/@types/node/v8.d.ts +0 -808
- package/template-react-ts/node_modules/@types/node/vm.d.ts +0 -924
- package/template-react-ts/node_modules/@types/node/wasi.d.ts +0 -181
- package/template-react-ts/node_modules/@types/node/worker_threads.d.ts +0 -694
- package/template-react-ts/node_modules/@types/node/zlib.d.ts +0 -539
- package/template-react-ts/node_modules/diff/CONTRIBUTING.md +0 -39
- package/template-react-ts/node_modules/diff/LICENSE +0 -31
- package/template-react-ts/node_modules/diff/README.md +0 -207
- package/template-react-ts/node_modules/diff/dist/diff.js +0 -1585
- package/template-react-ts/node_modules/diff/dist/diff.min.js +0 -38
- package/template-react-ts/node_modules/diff/lib/convert/dmp.js +0 -32
- package/template-react-ts/node_modules/diff/lib/convert/xml.js +0 -42
- package/template-react-ts/node_modules/diff/lib/diff/array.js +0 -45
- package/template-react-ts/node_modules/diff/lib/diff/base.js +0 -304
- package/template-react-ts/node_modules/diff/lib/diff/character.js +0 -37
- package/template-react-ts/node_modules/diff/lib/diff/css.js +0 -41
- package/template-react-ts/node_modules/diff/lib/diff/json.js +0 -163
- package/template-react-ts/node_modules/diff/lib/diff/line.js +0 -89
- package/template-react-ts/node_modules/diff/lib/diff/sentence.js +0 -41
- package/template-react-ts/node_modules/diff/lib/diff/word.js +0 -107
- package/template-react-ts/node_modules/diff/lib/index.es6.js +0 -1519
- package/template-react-ts/node_modules/diff/lib/index.js +0 -216
- package/template-react-ts/node_modules/diff/lib/patch/apply.js +0 -243
- package/template-react-ts/node_modules/diff/lib/patch/create.js +0 -247
- package/template-react-ts/node_modules/diff/lib/patch/merge.js +0 -609
- package/template-react-ts/node_modules/diff/lib/patch/parse.js +0 -156
- package/template-react-ts/node_modules/diff/lib/util/array.js +0 -32
- package/template-react-ts/node_modules/diff/lib/util/distance-iterator.js +0 -57
- package/template-react-ts/node_modules/diff/lib/util/params.js +0 -24
- package/template-react-ts/node_modules/diff/package.json +0 -73
- package/template-react-ts/node_modules/diff/release-notes.md +0 -261
- package/template-react-ts/node_modules/diff/runtime.js +0 -3
- package/template-react-ts/node_modules/ts-node/LICENSE +0 -21
- package/template-react-ts/node_modules/ts-node/README.md +0 -1442
- package/template-react-ts/node_modules/ts-node/child-loader.mjs +0 -8
- package/template-react-ts/node_modules/ts-node/dist/bin-cwd.d.ts +0 -2
- package/template-react-ts/node_modules/ts-node/dist/bin-cwd.js +0 -6
- package/template-react-ts/node_modules/ts-node/dist/bin-cwd.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/bin-esm.d.ts +0 -2
- package/template-react-ts/node_modules/ts-node/dist/bin-esm.js +0 -6
- package/template-react-ts/node_modules/ts-node/dist/bin-esm.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/bin-script-deprecated.d.ts +0 -2
- package/template-react-ts/node_modules/ts-node/dist/bin-script-deprecated.js +0 -7
- package/template-react-ts/node_modules/ts-node/dist/bin-script-deprecated.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/bin-script.d.ts +0 -2
- package/template-react-ts/node_modules/ts-node/dist/bin-script.js +0 -6
- package/template-react-ts/node_modules/ts-node/dist/bin-script.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/bin-transpile.d.ts +0 -2
- package/template-react-ts/node_modules/ts-node/dist/bin-transpile.js +0 -6
- package/template-react-ts/node_modules/ts-node/dist/bin-transpile.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/bin.d.ts +0 -11
- package/template-react-ts/node_modules/ts-node/dist/bin.js +0 -581
- package/template-react-ts/node_modules/ts-node/dist/bin.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/child/argv-payload.d.ts +0 -1
- package/template-react-ts/node_modules/ts-node/dist/child/argv-payload.js +0 -19
- package/template-react-ts/node_modules/ts-node/dist/child/argv-payload.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/child/child-entrypoint.d.ts +0 -1
- package/template-react-ts/node_modules/ts-node/dist/child/child-entrypoint.js +0 -24
- package/template-react-ts/node_modules/ts-node/dist/child/child-entrypoint.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/child/child-loader.d.ts +0 -1
- package/template-react-ts/node_modules/ts-node/dist/child/child-loader.js +0 -32
- package/template-react-ts/node_modules/ts-node/dist/child/child-loader.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/child/child-require.d.ts +0 -7
- package/template-react-ts/node_modules/ts-node/dist/child/child-require.js +0 -22
- package/template-react-ts/node_modules/ts-node/dist/child/child-require.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/child/spawn-child.d.ts +0 -1
- package/template-react-ts/node_modules/ts-node/dist/child/spawn-child.js +0 -49
- package/template-react-ts/node_modules/ts-node/dist/child/spawn-child.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/cjs-resolve-hooks.d.ts +0 -1
- package/template-react-ts/node_modules/ts-node/dist/cjs-resolve-hooks.js +0 -29
- package/template-react-ts/node_modules/ts-node/dist/cjs-resolve-hooks.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/configuration.d.ts +0 -1
- package/template-react-ts/node_modules/ts-node/dist/configuration.js +0 -308
- package/template-react-ts/node_modules/ts-node/dist/configuration.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/esm.d.ts +0 -53
- package/template-react-ts/node_modules/ts-node/dist/esm.js +0 -228
- package/template-react-ts/node_modules/ts-node/dist/esm.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/file-extensions.d.ts +0 -1
- package/template-react-ts/node_modules/ts-node/dist/file-extensions.js +0 -133
- package/template-react-ts/node_modules/ts-node/dist/file-extensions.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/index.d.ts +0 -332
- package/template-react-ts/node_modules/ts-node/dist/index.js +0 -953
- package/template-react-ts/node_modules/ts-node/dist/index.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/module-type-classifier.d.ts +0 -1
- package/template-react-ts/node_modules/ts-node/dist/module-type-classifier.js +0 -64
- package/template-react-ts/node_modules/ts-node/dist/module-type-classifier.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/node-module-type-classifier.d.ts +0 -1
- package/template-react-ts/node_modules/ts-node/dist/node-module-type-classifier.js +0 -39
- package/template-react-ts/node_modules/ts-node/dist/node-module-type-classifier.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/repl.d.ts +0 -78
- package/template-react-ts/node_modules/ts-node/dist/repl.js +0 -561
- package/template-react-ts/node_modules/ts-node/dist/repl.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/resolver-functions.d.ts +0 -1
- package/template-react-ts/node_modules/ts-node/dist/resolver-functions.js +0 -143
- package/template-react-ts/node_modules/ts-node/dist/resolver-functions.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/transpilers/swc.d.ts +0 -11
- package/template-react-ts/node_modules/ts-node/dist/transpilers/swc.js +0 -218
- package/template-react-ts/node_modules/ts-node/dist/transpilers/swc.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/transpilers/types.d.ts +0 -35
- package/template-react-ts/node_modules/ts-node/dist/transpilers/types.js +0 -3
- package/template-react-ts/node_modules/ts-node/dist/transpilers/types.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/ts-compiler-types.d.ts +0 -63
- package/template-react-ts/node_modules/ts-node/dist/ts-compiler-types.js +0 -3
- package/template-react-ts/node_modules/ts-node/dist/ts-compiler-types.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/ts-internals.d.ts +0 -6
- package/template-react-ts/node_modules/ts-node/dist/ts-internals.js +0 -321
- package/template-react-ts/node_modules/ts-node/dist/ts-internals.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/ts-transpile-module.d.ts +0 -1
- package/template-react-ts/node_modules/ts-node/dist/ts-transpile-module.js +0 -100
- package/template-react-ts/node_modules/ts-node/dist/ts-transpile-module.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/tsconfig-schema.d.ts +0 -13
- package/template-react-ts/node_modules/ts-node/dist/tsconfig-schema.js +0 -3
- package/template-react-ts/node_modules/ts-node/dist/tsconfig-schema.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/tsconfigs.d.ts +0 -1
- package/template-react-ts/node_modules/ts-node/dist/tsconfigs.js +0 -36
- package/template-react-ts/node_modules/ts-node/dist/tsconfigs.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist/util.d.ts +0 -4
- package/template-react-ts/node_modules/ts-node/dist/util.js +0 -175
- package/template-react-ts/node_modules/ts-node/dist/util.js.map +0 -1
- package/template-react-ts/node_modules/ts-node/dist-raw/NODE-LICENSE.md +0 -24
- package/template-react-ts/node_modules/ts-node/dist-raw/README.md +0 -36
- package/template-react-ts/node_modules/ts-node/dist-raw/node-internal-constants.js +0 -4
- package/template-react-ts/node_modules/ts-node/dist-raw/node-internal-errors.js +0 -82
- package/template-react-ts/node_modules/ts-node/dist-raw/node-internal-modules-cjs-helpers.js +0 -89
- package/template-react-ts/node_modules/ts-node/dist-raw/node-internal-modules-cjs-loader.js +0 -593
- package/template-react-ts/node_modules/ts-node/dist-raw/node-internal-modules-esm-get_format.js +0 -106
- package/template-react-ts/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js +0 -962
- package/template-react-ts/node_modules/ts-node/dist-raw/node-internal-modules-package_json_reader.js +0 -44
- package/template-react-ts/node_modules/ts-node/dist-raw/node-internal-repl-await.js +0 -254
- package/template-react-ts/node_modules/ts-node/dist-raw/node-internalBinding-fs.js +0 -58
- package/template-react-ts/node_modules/ts-node/dist-raw/node-nativemodule.js +0 -9
- package/template-react-ts/node_modules/ts-node/dist-raw/node-options.js +0 -103
- package/template-react-ts/node_modules/ts-node/dist-raw/node-primordials.js +0 -37
- package/template-react-ts/node_modules/ts-node/dist-raw/runmain-hack.js +0 -9
- package/template-react-ts/node_modules/ts-node/esm/transpile-only.mjs +0 -8
- package/template-react-ts/node_modules/ts-node/esm.mjs +0 -8
- package/template-react-ts/node_modules/ts-node/node10/tsconfig.json +0 -3
- package/template-react-ts/node_modules/ts-node/node12/tsconfig.json +0 -3
- package/template-react-ts/node_modules/ts-node/node14/tsconfig.json +0 -3
- package/template-react-ts/node_modules/ts-node/node16/tsconfig.json +0 -3
- package/template-react-ts/node_modules/ts-node/package.json +0 -182
- package/template-react-ts/node_modules/ts-node/register/files.js +0 -3
- package/template-react-ts/node_modules/ts-node/register/index.js +0 -1
- package/template-react-ts/node_modules/ts-node/register/transpile-only.js +0 -3
- package/template-react-ts/node_modules/ts-node/register/type-check.js +0 -3
- package/template-react-ts/node_modules/ts-node/transpilers/swc-experimental.js +0 -1
- package/template-react-ts/node_modules/ts-node/transpilers/swc.js +0 -1
- package/template-react-ts/node_modules/ts-node/tsconfig.schema.json +0 -183
- package/template-react-ts/node_modules/ts-node/tsconfig.schemastore-schema.json +0 -1326
|
@@ -1,581 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.bootstrap = exports.main = void 0;
|
|
5
|
-
const path_1 = require("path");
|
|
6
|
-
const util_1 = require("util");
|
|
7
|
-
const Module = require("module");
|
|
8
|
-
let arg;
|
|
9
|
-
const util_2 = require("./util");
|
|
10
|
-
const repl_1 = require("./repl");
|
|
11
|
-
const index_1 = require("./index");
|
|
12
|
-
const node_internal_modules_cjs_helpers_1 = require("../dist-raw/node-internal-modules-cjs-helpers");
|
|
13
|
-
const spawn_child_1 = require("./child/spawn-child");
|
|
14
|
-
const configuration_1 = require("./configuration");
|
|
15
|
-
/**
|
|
16
|
-
* Main `bin` functionality.
|
|
17
|
-
*
|
|
18
|
-
* This file is split into a chain of functions (phases), each one adding to a shared state object.
|
|
19
|
-
* This is done so that the next function can either be invoked in-process or, if necessary, invoked in a child process.
|
|
20
|
-
*
|
|
21
|
-
* The functions are intentionally given uncreative names and left in the same order as the original code, to make a
|
|
22
|
-
* smaller git diff.
|
|
23
|
-
*/
|
|
24
|
-
function main(argv = process.argv.slice(2), entrypointArgs = {}) {
|
|
25
|
-
const args = parseArgv(argv, entrypointArgs);
|
|
26
|
-
const state = {
|
|
27
|
-
shouldUseChildProcess: false,
|
|
28
|
-
isInChildProcess: false,
|
|
29
|
-
isCli: true,
|
|
30
|
-
tsNodeScript: __filename,
|
|
31
|
-
parseArgvResult: args,
|
|
32
|
-
};
|
|
33
|
-
return bootstrap(state);
|
|
34
|
-
}
|
|
35
|
-
exports.main = main;
|
|
36
|
-
/** @internal */
|
|
37
|
-
function bootstrap(state) {
|
|
38
|
-
if (!state.phase2Result) {
|
|
39
|
-
state.phase2Result = phase2(state);
|
|
40
|
-
if (state.shouldUseChildProcess && !state.isInChildProcess) {
|
|
41
|
-
// Note: When transitioning into the child-process after `phase2`,
|
|
42
|
-
// the updated working directory needs to be preserved.
|
|
43
|
-
return (0, spawn_child_1.callInChild)(state);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
if (!state.phase3Result) {
|
|
47
|
-
state.phase3Result = phase3(state);
|
|
48
|
-
if (state.shouldUseChildProcess && !state.isInChildProcess) {
|
|
49
|
-
// Note: When transitioning into the child-process after `phase2`,
|
|
50
|
-
// the updated working directory needs to be preserved.
|
|
51
|
-
return (0, spawn_child_1.callInChild)(state);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return phase4(state);
|
|
55
|
-
}
|
|
56
|
-
exports.bootstrap = bootstrap;
|
|
57
|
-
function parseArgv(argv, entrypointArgs) {
|
|
58
|
-
arg !== null && arg !== void 0 ? arg : (arg = require('arg'));
|
|
59
|
-
// HACK: technically, this function is not marked @internal so it's possible
|
|
60
|
-
// that libraries in the wild are doing `require('ts-node/dist/bin').main({'--transpile-only': true})`
|
|
61
|
-
// We can mark this function @internal in next major release.
|
|
62
|
-
// For now, rewrite args to avoid a breaking change.
|
|
63
|
-
entrypointArgs = { ...entrypointArgs };
|
|
64
|
-
for (const key of Object.keys(entrypointArgs)) {
|
|
65
|
-
entrypointArgs[key.replace(/([a-z])-([a-z])/g, (_$0, $1, $2) => `${$1}${$2.toUpperCase()}`)] = entrypointArgs[key];
|
|
66
|
-
}
|
|
67
|
-
const args = {
|
|
68
|
-
...entrypointArgs,
|
|
69
|
-
...arg({
|
|
70
|
-
// Node.js-like options.
|
|
71
|
-
'--eval': String,
|
|
72
|
-
'--interactive': Boolean,
|
|
73
|
-
'--print': Boolean,
|
|
74
|
-
'--require': [String],
|
|
75
|
-
// CLI options.
|
|
76
|
-
'--help': Boolean,
|
|
77
|
-
'--cwdMode': Boolean,
|
|
78
|
-
'--scriptMode': Boolean,
|
|
79
|
-
'--version': arg.COUNT,
|
|
80
|
-
'--showConfig': Boolean,
|
|
81
|
-
'--esm': Boolean,
|
|
82
|
-
// Project options.
|
|
83
|
-
'--cwd': String,
|
|
84
|
-
'--files': Boolean,
|
|
85
|
-
'--compiler': String,
|
|
86
|
-
'--compilerOptions': util_2.parse,
|
|
87
|
-
'--project': String,
|
|
88
|
-
'--ignoreDiagnostics': [String],
|
|
89
|
-
'--ignore': [String],
|
|
90
|
-
'--transpileOnly': Boolean,
|
|
91
|
-
'--transpiler': String,
|
|
92
|
-
'--swc': Boolean,
|
|
93
|
-
'--typeCheck': Boolean,
|
|
94
|
-
'--compilerHost': Boolean,
|
|
95
|
-
'--pretty': Boolean,
|
|
96
|
-
'--skipProject': Boolean,
|
|
97
|
-
'--skipIgnore': Boolean,
|
|
98
|
-
'--preferTsExts': Boolean,
|
|
99
|
-
'--logError': Boolean,
|
|
100
|
-
'--emit': Boolean,
|
|
101
|
-
'--scope': Boolean,
|
|
102
|
-
'--scopeDir': String,
|
|
103
|
-
'--noExperimentalReplAwait': Boolean,
|
|
104
|
-
'--experimentalSpecifierResolution': String,
|
|
105
|
-
// Aliases.
|
|
106
|
-
'-e': '--eval',
|
|
107
|
-
'-i': '--interactive',
|
|
108
|
-
'-p': '--print',
|
|
109
|
-
'-r': '--require',
|
|
110
|
-
'-h': '--help',
|
|
111
|
-
'-s': '--script-mode',
|
|
112
|
-
'-v': '--version',
|
|
113
|
-
'-T': '--transpileOnly',
|
|
114
|
-
'-H': '--compilerHost',
|
|
115
|
-
'-I': '--ignore',
|
|
116
|
-
'-P': '--project',
|
|
117
|
-
'-C': '--compiler',
|
|
118
|
-
'-D': '--ignoreDiagnostics',
|
|
119
|
-
'-O': '--compilerOptions',
|
|
120
|
-
'--dir': '--cwd',
|
|
121
|
-
// Support both tsc-style camelCase and node-style hypen-case for *all* flags
|
|
122
|
-
'--cwd-mode': '--cwdMode',
|
|
123
|
-
'--script-mode': '--scriptMode',
|
|
124
|
-
'--show-config': '--showConfig',
|
|
125
|
-
'--compiler-options': '--compilerOptions',
|
|
126
|
-
'--ignore-diagnostics': '--ignoreDiagnostics',
|
|
127
|
-
'--transpile-only': '--transpileOnly',
|
|
128
|
-
'--type-check': '--typeCheck',
|
|
129
|
-
'--compiler-host': '--compilerHost',
|
|
130
|
-
'--skip-project': '--skipProject',
|
|
131
|
-
'--skip-ignore': '--skipIgnore',
|
|
132
|
-
'--prefer-ts-exts': '--preferTsExts',
|
|
133
|
-
'--log-error': '--logError',
|
|
134
|
-
'--scope-dir': '--scopeDir',
|
|
135
|
-
'--no-experimental-repl-await': '--noExperimentalReplAwait',
|
|
136
|
-
'--experimental-specifier-resolution': '--experimentalSpecifierResolution',
|
|
137
|
-
}, {
|
|
138
|
-
argv,
|
|
139
|
-
stopAtPositional: true,
|
|
140
|
-
}),
|
|
141
|
-
};
|
|
142
|
-
// Only setting defaults for CLI-specific flags
|
|
143
|
-
// Anything passed to `register()` can be `undefined`; `create()` will apply
|
|
144
|
-
// defaults.
|
|
145
|
-
const { '--cwd': cwdArg, '--help': help = false, '--scriptMode': scriptMode, '--cwdMode': cwdMode, '--version': version = 0, '--showConfig': showConfig, '--require': argsRequire = [], '--eval': code = undefined, '--print': print = false, '--interactive': interactive = false, '--files': files, '--compiler': compiler, '--compilerOptions': compilerOptions, '--project': project, '--ignoreDiagnostics': ignoreDiagnostics, '--ignore': ignore, '--transpileOnly': transpileOnly, '--typeCheck': typeCheck, '--transpiler': transpiler, '--swc': swc, '--compilerHost': compilerHost, '--pretty': pretty, '--skipProject': skipProject, '--skipIgnore': skipIgnore, '--preferTsExts': preferTsExts, '--logError': logError, '--emit': emit, '--scope': scope = undefined, '--scopeDir': scopeDir = undefined, '--noExperimentalReplAwait': noExperimentalReplAwait, '--experimentalSpecifierResolution': experimentalSpecifierResolution, '--esm': esm, _: restArgs, } = args;
|
|
146
|
-
return {
|
|
147
|
-
// Note: argv and restArgs may be overwritten by child process
|
|
148
|
-
argv: process.argv,
|
|
149
|
-
restArgs,
|
|
150
|
-
cwdArg,
|
|
151
|
-
help,
|
|
152
|
-
scriptMode,
|
|
153
|
-
cwdMode,
|
|
154
|
-
version,
|
|
155
|
-
showConfig,
|
|
156
|
-
argsRequire,
|
|
157
|
-
code,
|
|
158
|
-
print,
|
|
159
|
-
interactive,
|
|
160
|
-
files,
|
|
161
|
-
compiler,
|
|
162
|
-
compilerOptions,
|
|
163
|
-
project,
|
|
164
|
-
ignoreDiagnostics,
|
|
165
|
-
ignore,
|
|
166
|
-
transpileOnly,
|
|
167
|
-
typeCheck,
|
|
168
|
-
transpiler,
|
|
169
|
-
swc,
|
|
170
|
-
compilerHost,
|
|
171
|
-
pretty,
|
|
172
|
-
skipProject,
|
|
173
|
-
skipIgnore,
|
|
174
|
-
preferTsExts,
|
|
175
|
-
logError,
|
|
176
|
-
emit,
|
|
177
|
-
scope,
|
|
178
|
-
scopeDir,
|
|
179
|
-
noExperimentalReplAwait,
|
|
180
|
-
experimentalSpecifierResolution,
|
|
181
|
-
esm,
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
function phase2(payload) {
|
|
185
|
-
const { help, version, cwdArg, esm } = payload.parseArgvResult;
|
|
186
|
-
if (help) {
|
|
187
|
-
console.log(`
|
|
188
|
-
Usage: ts-node [options] [ -e script | script.ts ] [arguments]
|
|
189
|
-
|
|
190
|
-
Options:
|
|
191
|
-
|
|
192
|
-
-e, --eval [code] Evaluate code
|
|
193
|
-
-p, --print Print result of \`--eval\`
|
|
194
|
-
-r, --require [path] Require a node module before execution
|
|
195
|
-
-i, --interactive Opens the REPL even if stdin does not appear to be a terminal
|
|
196
|
-
|
|
197
|
-
--esm Bootstrap with the ESM loader, enabling full ESM support
|
|
198
|
-
--swc Use the faster swc transpiler
|
|
199
|
-
|
|
200
|
-
-h, --help Print CLI usage
|
|
201
|
-
-v, --version Print module version information. -vvv to print additional information
|
|
202
|
-
--showConfig Print resolved configuration and exit
|
|
203
|
-
|
|
204
|
-
-T, --transpileOnly Use TypeScript's faster \`transpileModule\` or a third-party transpiler
|
|
205
|
-
-H, --compilerHost Use TypeScript's compiler host API
|
|
206
|
-
-I, --ignore [pattern] Override the path patterns to skip compilation
|
|
207
|
-
-P, --project [path] Path to TypeScript JSON project file
|
|
208
|
-
-C, --compiler [name] Specify a custom TypeScript compiler
|
|
209
|
-
--transpiler [name] Specify a third-party, non-typechecking transpiler
|
|
210
|
-
-D, --ignoreDiagnostics [code] Ignore TypeScript warnings by diagnostic code
|
|
211
|
-
-O, --compilerOptions [opts] JSON object to merge with compiler options
|
|
212
|
-
|
|
213
|
-
--cwd Behave as if invoked within this working directory.
|
|
214
|
-
--files Load \`files\`, \`include\` and \`exclude\` from \`tsconfig.json\` on startup
|
|
215
|
-
--pretty Use pretty diagnostic formatter (usually enabled by default)
|
|
216
|
-
--cwdMode Use current directory instead of <script.ts> for config resolution
|
|
217
|
-
--skipProject Skip reading \`tsconfig.json\`
|
|
218
|
-
--skipIgnore Skip \`--ignore\` checks
|
|
219
|
-
--emit Emit output files into \`.ts-node\` directory
|
|
220
|
-
--scope Scope compiler to files within \`scopeDir\`. Anything outside this directory is ignored.
|
|
221
|
-
--scopeDir Directory for \`--scope\`
|
|
222
|
-
--preferTsExts Prefer importing TypeScript files over JavaScript files
|
|
223
|
-
--logError Logs TypeScript errors to stderr instead of throwing exceptions
|
|
224
|
-
--noExperimentalReplAwait Disable top-level await in REPL. Equivalent to node's --no-experimental-repl-await
|
|
225
|
-
--experimentalSpecifierResolution [node|explicit]
|
|
226
|
-
Equivalent to node's --experimental-specifier-resolution
|
|
227
|
-
`);
|
|
228
|
-
process.exit(0);
|
|
229
|
-
}
|
|
230
|
-
// Output project information.
|
|
231
|
-
if (version === 1) {
|
|
232
|
-
console.log(`v${index_1.VERSION}`);
|
|
233
|
-
process.exit(0);
|
|
234
|
-
}
|
|
235
|
-
const cwd = cwdArg ? (0, path_1.resolve)(cwdArg) : process.cwd();
|
|
236
|
-
// If ESM is explicitly enabled through the flag, stage3 should be run in a child process
|
|
237
|
-
// with the ESM loaders configured.
|
|
238
|
-
if (esm)
|
|
239
|
-
payload.shouldUseChildProcess = true;
|
|
240
|
-
return {
|
|
241
|
-
cwd,
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
function phase3(payload) {
|
|
245
|
-
const { emit, files, pretty, transpileOnly, transpiler, noExperimentalReplAwait, typeCheck, swc, compilerHost, ignore, preferTsExts, logError, scriptMode, cwdMode, project, skipProject, skipIgnore, compiler, ignoreDiagnostics, compilerOptions, argsRequire, scope, scopeDir, esm, experimentalSpecifierResolution, } = payload.parseArgvResult;
|
|
246
|
-
const { cwd } = payload.phase2Result;
|
|
247
|
-
// NOTE: When we transition to a child process for ESM, the entry-point script determined
|
|
248
|
-
// here might not be the one used later in `phase4`. This can happen when we execute the
|
|
249
|
-
// original entry-point but then the process forks itself using e.g. `child_process.fork`.
|
|
250
|
-
// We will always use the original TS project in forked processes anyway, so it is
|
|
251
|
-
// expected and acceptable to retrieve the entry-point information here in `phase2`.
|
|
252
|
-
// See: https://github.com/TypeStrong/ts-node/issues/1812.
|
|
253
|
-
const { entryPointPath } = getEntryPointInfo(payload);
|
|
254
|
-
const preloadedConfig = (0, configuration_1.findAndReadConfig)({
|
|
255
|
-
cwd,
|
|
256
|
-
emit,
|
|
257
|
-
files,
|
|
258
|
-
pretty,
|
|
259
|
-
transpileOnly: (transpileOnly !== null && transpileOnly !== void 0 ? transpileOnly : transpiler != null) ? true : undefined,
|
|
260
|
-
experimentalReplAwait: noExperimentalReplAwait ? false : undefined,
|
|
261
|
-
typeCheck,
|
|
262
|
-
transpiler,
|
|
263
|
-
swc,
|
|
264
|
-
compilerHost,
|
|
265
|
-
ignore,
|
|
266
|
-
logError,
|
|
267
|
-
projectSearchDir: getProjectSearchDir(cwd, scriptMode, cwdMode, entryPointPath),
|
|
268
|
-
project,
|
|
269
|
-
skipProject,
|
|
270
|
-
skipIgnore,
|
|
271
|
-
compiler,
|
|
272
|
-
ignoreDiagnostics,
|
|
273
|
-
compilerOptions,
|
|
274
|
-
require: argsRequire,
|
|
275
|
-
scope,
|
|
276
|
-
scopeDir,
|
|
277
|
-
preferTsExts,
|
|
278
|
-
esm,
|
|
279
|
-
experimentalSpecifierResolution: experimentalSpecifierResolution,
|
|
280
|
-
});
|
|
281
|
-
// If ESM is enabled through the parsed tsconfig, stage4 should be run in a child
|
|
282
|
-
// process with the ESM loaders configured.
|
|
283
|
-
if (preloadedConfig.options.esm)
|
|
284
|
-
payload.shouldUseChildProcess = true;
|
|
285
|
-
return { preloadedConfig };
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Determines the entry-point information from the argv and phase2 result. This
|
|
289
|
-
* method will be invoked in two places:
|
|
290
|
-
*
|
|
291
|
-
* 1. In phase 3 to be able to find a project from the potential entry-point script.
|
|
292
|
-
* 2. In phase 4 to determine the actual entry-point script.
|
|
293
|
-
*
|
|
294
|
-
* Note that we need to explicitly re-resolve the entry-point information in the final
|
|
295
|
-
* stage because the previous stage information could be modified when the bootstrap
|
|
296
|
-
* invocation transitioned into a child process for ESM.
|
|
297
|
-
*
|
|
298
|
-
* Stages before (phase 4) can and will be cached by the child process through the Brotli
|
|
299
|
-
* configuration and entry-point information is only reliable in the final phase. More
|
|
300
|
-
* details can be found in here: https://github.com/TypeStrong/ts-node/issues/1812.
|
|
301
|
-
*/
|
|
302
|
-
function getEntryPointInfo(state) {
|
|
303
|
-
const { code, interactive, restArgs } = state.parseArgvResult;
|
|
304
|
-
const { cwd } = state.phase2Result;
|
|
305
|
-
const { isCli } = state;
|
|
306
|
-
// Figure out which we are executing: piped stdin, --eval, REPL, and/or entrypoint
|
|
307
|
-
// This is complicated because node's behavior is complicated
|
|
308
|
-
// `node -e code -i ./script.js` ignores -e
|
|
309
|
-
const executeEval = code != null && !(interactive && restArgs.length);
|
|
310
|
-
const executeEntrypoint = !executeEval && restArgs.length > 0;
|
|
311
|
-
const executeRepl = !executeEntrypoint &&
|
|
312
|
-
(interactive || (process.stdin.isTTY && !executeEval));
|
|
313
|
-
const executeStdin = !executeEval && !executeRepl && !executeEntrypoint;
|
|
314
|
-
/**
|
|
315
|
-
* Unresolved. May point to a symlink, not realpath. May be missing file extension
|
|
316
|
-
* NOTE: resolution relative to cwd option (not `process.cwd()`) is legacy backwards-compat; should be changed in next major: https://github.com/TypeStrong/ts-node/issues/1834
|
|
317
|
-
*/
|
|
318
|
-
const entryPointPath = executeEntrypoint
|
|
319
|
-
? isCli
|
|
320
|
-
? (0, path_1.resolve)(cwd, restArgs[0])
|
|
321
|
-
: (0, path_1.resolve)(restArgs[0])
|
|
322
|
-
: undefined;
|
|
323
|
-
return {
|
|
324
|
-
executeEval,
|
|
325
|
-
executeEntrypoint,
|
|
326
|
-
executeRepl,
|
|
327
|
-
executeStdin,
|
|
328
|
-
entryPointPath,
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
function phase4(payload) {
|
|
332
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
333
|
-
const { isInChildProcess, tsNodeScript } = payload;
|
|
334
|
-
const { version, showConfig, restArgs, code, print, argv } = payload.parseArgvResult;
|
|
335
|
-
const { cwd } = payload.phase2Result;
|
|
336
|
-
const { preloadedConfig } = payload.phase3Result;
|
|
337
|
-
const { entryPointPath, executeEntrypoint, executeEval, executeRepl, executeStdin, } = getEntryPointInfo(payload);
|
|
338
|
-
let evalStuff;
|
|
339
|
-
let replStuff;
|
|
340
|
-
let stdinStuff;
|
|
341
|
-
let evalAwarePartialHost = undefined;
|
|
342
|
-
if (executeEval) {
|
|
343
|
-
const state = new repl_1.EvalState((0, path_1.join)(cwd, repl_1.EVAL_FILENAME));
|
|
344
|
-
evalStuff = {
|
|
345
|
-
state,
|
|
346
|
-
repl: (0, repl_1.createRepl)({
|
|
347
|
-
state,
|
|
348
|
-
composeWithEvalAwarePartialHost: evalAwarePartialHost,
|
|
349
|
-
ignoreDiagnosticsThatAreAnnoyingInInteractiveRepl: false,
|
|
350
|
-
}),
|
|
351
|
-
};
|
|
352
|
-
({ evalAwarePartialHost } = evalStuff.repl);
|
|
353
|
-
// Create a local module instance based on `cwd`.
|
|
354
|
-
const module = (evalStuff.module = new Module(repl_1.EVAL_NAME));
|
|
355
|
-
module.filename = evalStuff.state.path;
|
|
356
|
-
module.paths = Module._nodeModulePaths(cwd);
|
|
357
|
-
}
|
|
358
|
-
if (executeStdin) {
|
|
359
|
-
const state = new repl_1.EvalState((0, path_1.join)(cwd, repl_1.STDIN_FILENAME));
|
|
360
|
-
stdinStuff = {
|
|
361
|
-
state,
|
|
362
|
-
repl: (0, repl_1.createRepl)({
|
|
363
|
-
state,
|
|
364
|
-
composeWithEvalAwarePartialHost: evalAwarePartialHost,
|
|
365
|
-
ignoreDiagnosticsThatAreAnnoyingInInteractiveRepl: false,
|
|
366
|
-
}),
|
|
367
|
-
};
|
|
368
|
-
({ evalAwarePartialHost } = stdinStuff.repl);
|
|
369
|
-
// Create a local module instance based on `cwd`.
|
|
370
|
-
const module = (stdinStuff.module = new Module(repl_1.STDIN_NAME));
|
|
371
|
-
module.filename = stdinStuff.state.path;
|
|
372
|
-
module.paths = Module._nodeModulePaths(cwd);
|
|
373
|
-
}
|
|
374
|
-
if (executeRepl) {
|
|
375
|
-
const state = new repl_1.EvalState((0, path_1.join)(cwd, repl_1.REPL_FILENAME));
|
|
376
|
-
replStuff = {
|
|
377
|
-
state,
|
|
378
|
-
repl: (0, repl_1.createRepl)({
|
|
379
|
-
state,
|
|
380
|
-
composeWithEvalAwarePartialHost: evalAwarePartialHost,
|
|
381
|
-
}),
|
|
382
|
-
};
|
|
383
|
-
({ evalAwarePartialHost } = replStuff.repl);
|
|
384
|
-
}
|
|
385
|
-
// Register the TypeScript compiler instance.
|
|
386
|
-
const service = (0, index_1.createFromPreloadedConfig)({
|
|
387
|
-
// Since this struct may have been marshalled across thread or process boundaries, we must restore
|
|
388
|
-
// un-marshall-able values.
|
|
389
|
-
...preloadedConfig,
|
|
390
|
-
options: {
|
|
391
|
-
...preloadedConfig.options,
|
|
392
|
-
readFile: (_a = evalAwarePartialHost === null || evalAwarePartialHost === void 0 ? void 0 : evalAwarePartialHost.readFile) !== null && _a !== void 0 ? _a : undefined,
|
|
393
|
-
fileExists: (_b = evalAwarePartialHost === null || evalAwarePartialHost === void 0 ? void 0 : evalAwarePartialHost.fileExists) !== null && _b !== void 0 ? _b : undefined,
|
|
394
|
-
tsTrace: index_1.DEFAULTS.tsTrace,
|
|
395
|
-
},
|
|
396
|
-
});
|
|
397
|
-
(0, index_1.register)(service);
|
|
398
|
-
if (isInChildProcess)
|
|
399
|
-
require('./child/child-loader').lateBindHooks((0, index_1.createEsmHooks)(service));
|
|
400
|
-
// Bind REPL service to ts-node compiler service (chicken-and-egg problem)
|
|
401
|
-
replStuff === null || replStuff === void 0 ? void 0 : replStuff.repl.setService(service);
|
|
402
|
-
evalStuff === null || evalStuff === void 0 ? void 0 : evalStuff.repl.setService(service);
|
|
403
|
-
stdinStuff === null || stdinStuff === void 0 ? void 0 : stdinStuff.repl.setService(service);
|
|
404
|
-
// Output project information.
|
|
405
|
-
if (version === 2) {
|
|
406
|
-
console.log(`ts-node v${index_1.VERSION}`);
|
|
407
|
-
console.log(`node ${process.version}`);
|
|
408
|
-
console.log(`compiler v${service.ts.version}`);
|
|
409
|
-
process.exit(0);
|
|
410
|
-
}
|
|
411
|
-
if (version >= 3) {
|
|
412
|
-
console.log(`ts-node v${index_1.VERSION} ${(0, path_1.dirname)(__dirname)}`);
|
|
413
|
-
console.log(`node ${process.version}`);
|
|
414
|
-
console.log(`compiler v${service.ts.version} ${(_c = service.compilerPath) !== null && _c !== void 0 ? _c : ''}`);
|
|
415
|
-
process.exit(0);
|
|
416
|
-
}
|
|
417
|
-
if (showConfig) {
|
|
418
|
-
const ts = service.ts;
|
|
419
|
-
if (typeof ts.convertToTSConfig !== 'function') {
|
|
420
|
-
console.error('Error: --showConfig requires a typescript versions >=3.2 that support --showConfig');
|
|
421
|
-
process.exit(1);
|
|
422
|
-
}
|
|
423
|
-
let moduleTypes = undefined;
|
|
424
|
-
if (service.options.moduleTypes) {
|
|
425
|
-
// Assumption: this codepath requires CLI invocation, so moduleTypes must have come from a tsconfig, not API.
|
|
426
|
-
const showRelativeTo = (0, path_1.dirname)(service.configFilePath);
|
|
427
|
-
moduleTypes = {};
|
|
428
|
-
for (const [key, value] of Object.entries(service.options.moduleTypes)) {
|
|
429
|
-
moduleTypes[(0, path_1.relative)(showRelativeTo, (0, path_1.resolve)((_d = service.options.optionBasePaths) === null || _d === void 0 ? void 0 : _d.moduleTypes, key))] = value;
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
const json = {
|
|
433
|
-
['ts-node']: {
|
|
434
|
-
...service.options,
|
|
435
|
-
require: ((_e = service.options.require) === null || _e === void 0 ? void 0 : _e.length)
|
|
436
|
-
? service.options.require
|
|
437
|
-
: undefined,
|
|
438
|
-
moduleTypes,
|
|
439
|
-
optionBasePaths: undefined,
|
|
440
|
-
compilerOptions: undefined,
|
|
441
|
-
project: (_f = service.configFilePath) !== null && _f !== void 0 ? _f : service.options.project,
|
|
442
|
-
},
|
|
443
|
-
...ts.convertToTSConfig(service.config, (_g = service.configFilePath) !== null && _g !== void 0 ? _g : (0, path_1.join)(cwd, 'ts-node-implicit-tsconfig.json'), service.ts.sys),
|
|
444
|
-
};
|
|
445
|
-
console.log(
|
|
446
|
-
// Assumes that all configuration options which can possibly be specified via the CLI are JSON-compatible.
|
|
447
|
-
// If, in the future, we must log functions, for example readFile and fileExists, then we can implement a JSON
|
|
448
|
-
// replacer function.
|
|
449
|
-
JSON.stringify(json, null, 2));
|
|
450
|
-
process.exit(0);
|
|
451
|
-
}
|
|
452
|
-
// Prepend `ts-node` arguments to CLI for child processes.
|
|
453
|
-
process.execArgv.push(tsNodeScript, ...argv.slice(2, argv.length - restArgs.length));
|
|
454
|
-
// TODO this comes from BootstrapState
|
|
455
|
-
process.argv = [process.argv[1]]
|
|
456
|
-
.concat(executeEntrypoint ? [entryPointPath] : [])
|
|
457
|
-
.concat(restArgs.slice(executeEntrypoint ? 1 : 0));
|
|
458
|
-
// Execute the main contents (either eval, script or piped).
|
|
459
|
-
if (executeEntrypoint) {
|
|
460
|
-
if (payload.isInChildProcess &&
|
|
461
|
-
(0, util_2.versionGteLt)(process.versions.node, '18.6.0')) {
|
|
462
|
-
// HACK workaround node regression
|
|
463
|
-
require('../dist-raw/runmain-hack.js').run(entryPointPath);
|
|
464
|
-
}
|
|
465
|
-
else {
|
|
466
|
-
Module.runMain();
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
else {
|
|
470
|
-
// Note: eval and repl may both run, but never with stdin.
|
|
471
|
-
// If stdin runs, eval and repl will not.
|
|
472
|
-
if (executeEval) {
|
|
473
|
-
(0, node_internal_modules_cjs_helpers_1.addBuiltinLibsToObject)(global);
|
|
474
|
-
evalAndExitOnTsError(evalStuff.repl, evalStuff.module, code, print, 'eval');
|
|
475
|
-
}
|
|
476
|
-
if (executeRepl) {
|
|
477
|
-
replStuff.repl.start();
|
|
478
|
-
}
|
|
479
|
-
if (executeStdin) {
|
|
480
|
-
let buffer = code || '';
|
|
481
|
-
process.stdin.on('data', (chunk) => (buffer += chunk));
|
|
482
|
-
process.stdin.on('end', () => {
|
|
483
|
-
evalAndExitOnTsError(stdinStuff.repl, stdinStuff.module, buffer,
|
|
484
|
-
// `echo 123 | node -p` still prints 123
|
|
485
|
-
print, 'stdin');
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
/**
|
|
491
|
-
* Get project search path from args.
|
|
492
|
-
*/
|
|
493
|
-
function getProjectSearchDir(cwd, scriptMode, cwdMode, scriptPath) {
|
|
494
|
-
// Validate `--script-mode` / `--cwd-mode` / `--cwd` usage is correct.
|
|
495
|
-
if (scriptMode && cwdMode) {
|
|
496
|
-
throw new TypeError('--cwd-mode cannot be combined with --script-mode');
|
|
497
|
-
}
|
|
498
|
-
if (scriptMode && !scriptPath) {
|
|
499
|
-
throw new TypeError('--script-mode must be used with a script name, e.g. `ts-node --script-mode <script.ts>`');
|
|
500
|
-
}
|
|
501
|
-
const doScriptMode = scriptMode === true ? true : cwdMode === true ? false : !!scriptPath;
|
|
502
|
-
if (doScriptMode) {
|
|
503
|
-
// Use node's own resolution behavior to ensure we follow symlinks.
|
|
504
|
-
// scriptPath may omit file extension or point to a directory with or without package.json.
|
|
505
|
-
// This happens before we are registered, so we tell node's resolver to consider ts, tsx, and jsx files.
|
|
506
|
-
// In extremely rare cases, is is technically possible to resolve the wrong directory,
|
|
507
|
-
// because we do not yet know preferTsExts, jsx, nor allowJs.
|
|
508
|
-
// See also, justification why this will not happen in real-world situations:
|
|
509
|
-
// https://github.com/TypeStrong/ts-node/pull/1009#issuecomment-613017081
|
|
510
|
-
const exts = ['.js', '.jsx', '.ts', '.tsx'];
|
|
511
|
-
const extsTemporarilyInstalled = [];
|
|
512
|
-
for (const ext of exts) {
|
|
513
|
-
if (!(0, util_2.hasOwnProperty)(require.extensions, ext)) {
|
|
514
|
-
extsTemporarilyInstalled.push(ext);
|
|
515
|
-
require.extensions[ext] = function () { };
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
try {
|
|
519
|
-
return (0, path_1.dirname)(requireResolveNonCached(scriptPath));
|
|
520
|
-
}
|
|
521
|
-
finally {
|
|
522
|
-
for (const ext of extsTemporarilyInstalled) {
|
|
523
|
-
delete require.extensions[ext];
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
return cwd;
|
|
528
|
-
}
|
|
529
|
-
const guaranteedNonexistentDirectoryPrefix = (0, path_1.resolve)(__dirname, 'doesnotexist');
|
|
530
|
-
let guaranteedNonexistentDirectorySuffix = 0;
|
|
531
|
-
/**
|
|
532
|
-
* require.resolve an absolute path, tricking node into *not* caching the results.
|
|
533
|
-
* Necessary so that we do not pollute require.resolve cache prior to installing require.extensions
|
|
534
|
-
*
|
|
535
|
-
* Is a terrible hack, because node does not expose the necessary cache invalidation APIs
|
|
536
|
-
* https://stackoverflow.com/questions/59865584/how-to-invalidate-cached-require-resolve-results
|
|
537
|
-
*/
|
|
538
|
-
function requireResolveNonCached(absoluteModuleSpecifier) {
|
|
539
|
-
// node <= 12.1.x fallback: The trick below triggers a node bug on old versions.
|
|
540
|
-
// On these old versions, pollute the require cache instead. This is a deliberate
|
|
541
|
-
// ts-node limitation that will *rarely* manifest, and will not matter once node 12
|
|
542
|
-
// is end-of-life'd on 2022-04-30
|
|
543
|
-
const isSupportedNodeVersion = (0, util_2.versionGteLt)(process.versions.node, '12.2.0');
|
|
544
|
-
if (!isSupportedNodeVersion)
|
|
545
|
-
return require.resolve(absoluteModuleSpecifier);
|
|
546
|
-
const { dir, base } = (0, path_1.parse)(absoluteModuleSpecifier);
|
|
547
|
-
const relativeModuleSpecifier = `./${base}`;
|
|
548
|
-
const req = (0, util_2.createRequire)((0, path_1.join)(dir, 'imaginaryUncacheableRequireResolveScript'));
|
|
549
|
-
return req.resolve(relativeModuleSpecifier, {
|
|
550
|
-
paths: [
|
|
551
|
-
`${guaranteedNonexistentDirectoryPrefix}${guaranteedNonexistentDirectorySuffix++}`,
|
|
552
|
-
...(req.resolve.paths(relativeModuleSpecifier) || []),
|
|
553
|
-
],
|
|
554
|
-
});
|
|
555
|
-
}
|
|
556
|
-
/**
|
|
557
|
-
* Evaluate an [eval] or [stdin] script
|
|
558
|
-
*/
|
|
559
|
-
function evalAndExitOnTsError(replService, module, code, isPrinted, filenameAndDirname) {
|
|
560
|
-
let result;
|
|
561
|
-
(0, repl_1.setupContext)(global, module, filenameAndDirname);
|
|
562
|
-
try {
|
|
563
|
-
result = replService.evalCode(code);
|
|
564
|
-
}
|
|
565
|
-
catch (error) {
|
|
566
|
-
if (error instanceof index_1.TSError) {
|
|
567
|
-
console.error(error);
|
|
568
|
-
process.exit(1);
|
|
569
|
-
}
|
|
570
|
-
throw error;
|
|
571
|
-
}
|
|
572
|
-
if (isPrinted) {
|
|
573
|
-
console.log(typeof result === 'string'
|
|
574
|
-
? result
|
|
575
|
-
: (0, util_1.inspect)(result, { colors: process.stdout.isTTY }));
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
if (require.main === module) {
|
|
579
|
-
main();
|
|
580
|
-
}
|
|
581
|
-
//# sourceMappingURL=bin.js.map
|