@backtest-kit/cli 3.3.5 → 3.3.6

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/build/index.cjs CHANGED
@@ -239,11 +239,11 @@ const TYPES = {
239
239
  const entrySubject = new functoolsKit.BehaviorSubject();
240
240
 
241
241
  const __filename$2 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
242
- const __dirname$1 = path.dirname(__filename$2);
243
- const require$2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
242
+ const __dirname$2 = path.dirname(__filename$2);
243
+ const require$3 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
244
244
  const REQUIRE_ENTRY_FACTORY = (filePath) => {
245
245
  try {
246
- require$2(filePath);
246
+ require$3(filePath);
247
247
  return true;
248
248
  }
249
249
  catch {
@@ -261,7 +261,8 @@ const BABEL_ENTRY_FACTORY = async (filePath, self) => {
261
261
  await self.babelService.transpileAndRun(code);
262
262
  return true;
263
263
  }
264
- catch {
264
+ catch (error) {
265
+ console.log(functoolsKit.getErrorMessage(error));
265
266
  return false;
266
267
  }
267
268
  };
@@ -282,7 +283,7 @@ class ResolveService {
282
283
  constructor() {
283
284
  this.loggerService = inject(TYPES.loggerService);
284
285
  this.babelService = inject(TYPES.babelService);
285
- this.DEFAULT_TEMPLATE_DIR = path.resolve(__dirname$1, '..', 'template');
286
+ this.DEFAULT_TEMPLATE_DIR = path.resolve(__dirname$2, '..', 'template');
286
287
  this.OVERRIDE_TEMPLATE_DIR = path.resolve(process.cwd(), 'template');
287
288
  this.OVERRIDE_MODULES_DIR = path.resolve(process.cwd(), 'modules');
288
289
  this.attachEntryPoint = async (entryPoint) => {
@@ -1629,7 +1630,7 @@ class TelegramTemplateService {
1629
1630
  }
1630
1631
  }
1631
1632
 
1632
- const require$1 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
1633
+ const require$2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
1633
1634
  const getExtVariants = (fileName) => {
1634
1635
  const ext = path.extname(fileName);
1635
1636
  const base = ext ? fileName.slice(0, -ext.length) : fileName;
@@ -1638,7 +1639,7 @@ const getExtVariants = (fileName) => {
1638
1639
  const REQUIRE_MODULE_FACTORY = (fileName) => {
1639
1640
  for (const variant of getExtVariants(fileName)) {
1640
1641
  try {
1641
- return require$1(variant);
1642
+ return require$2(variant);
1642
1643
  }
1643
1644
  catch {
1644
1645
  continue;
@@ -1655,10 +1656,11 @@ const BABEL_MODULE_FACTORY = async (fileName, self) => {
1655
1656
  for (const variant of getExtVariants(fileName)) {
1656
1657
  try {
1657
1658
  const code = await fs$1.readFile(variant, "utf-8");
1658
- const exports = self.babelService.transpileAndRun(code);
1659
+ const { exports } = self.babelService.transpileAndRun(code);
1659
1660
  return exports.default ?? exports;
1660
1661
  }
1661
- catch {
1662
+ catch (error) {
1663
+ console.log(functoolsKit.getErrorMessage(error));
1662
1664
  continue;
1663
1665
  }
1664
1666
  }
@@ -1883,9 +1885,9 @@ class LiveProviderService {
1883
1885
  }
1884
1886
 
1885
1887
  standalone.registerPlugin("plugin-transform-modules-umd", pluginUMD);
1886
- module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
1888
+ const require$1 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
1887
1889
  const __filename$1 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
1888
- path.dirname(__filename$1);
1890
+ const __dirname$1 = path.dirname(__filename$1);
1889
1891
  const BacktestKitCli = new Proxy({}, {
1890
1892
  get(_target, prop) {
1891
1893
  throw new Error(`@backtest-kit/cli is not available in this context (accessed: ${String(prop)})`);
@@ -1923,8 +1925,15 @@ class BabelService {
1923
1925
  codeLen: code.length,
1924
1926
  });
1925
1927
  const module = { exports: {} };
1928
+ const exports = module.exports;
1926
1929
  eval(this.transpile(code));
1927
- return module.exports;
1930
+ return {
1931
+ require: require$1,
1932
+ __filename: __filename$1,
1933
+ __dirname: __dirname$1,
1934
+ exports,
1935
+ module,
1936
+ };
1928
1937
  };
1929
1938
  }
1930
1939
  }
package/build/index.mjs CHANGED
@@ -217,7 +217,7 @@ const TYPES = {
217
217
  const entrySubject = new BehaviorSubject();
218
218
 
219
219
  const __filename$1 = fileURLToPath(import.meta.url);
220
- const __dirname = path.dirname(__filename$1);
220
+ const __dirname$1 = path.dirname(__filename$1);
221
221
  createRequire(import.meta.url);
222
222
  const REQUIRE_ENTRY_FACTORY = (filePath) => {
223
223
  {
@@ -239,7 +239,8 @@ const BABEL_ENTRY_FACTORY = async (filePath, self) => {
239
239
  await self.babelService.transpileAndRun(code);
240
240
  return true;
241
241
  }
242
- catch {
242
+ catch (error) {
243
+ console.log(getErrorMessage(error));
243
244
  return false;
244
245
  }
245
246
  };
@@ -260,7 +261,7 @@ class ResolveService {
260
261
  constructor() {
261
262
  this.loggerService = inject(TYPES.loggerService);
262
263
  this.babelService = inject(TYPES.babelService);
263
- this.DEFAULT_TEMPLATE_DIR = path.resolve(__dirname, '..', 'template');
264
+ this.DEFAULT_TEMPLATE_DIR = path.resolve(__dirname$1, '..', 'template');
264
265
  this.OVERRIDE_TEMPLATE_DIR = path.resolve(process.cwd(), 'template');
265
266
  this.OVERRIDE_MODULES_DIR = path.resolve(process.cwd(), 'modules');
266
267
  this.attachEntryPoint = async (entryPoint) => {
@@ -1633,10 +1634,11 @@ const BABEL_MODULE_FACTORY = async (fileName, self) => {
1633
1634
  for (const variant of getExtVariants(fileName)) {
1634
1635
  try {
1635
1636
  const code = await fs$1.readFile(variant, "utf-8");
1636
- const exports = self.babelService.transpileAndRun(code);
1637
+ const { exports } = self.babelService.transpileAndRun(code);
1637
1638
  return exports.default ?? exports;
1638
1639
  }
1639
- catch {
1640
+ catch (error) {
1641
+ console.log(getErrorMessage(error));
1640
1642
  continue;
1641
1643
  }
1642
1644
  }
@@ -1861,9 +1863,9 @@ class LiveProviderService {
1861
1863
  }
1862
1864
 
1863
1865
  registerPlugin("plugin-transform-modules-umd", pluginUMD);
1864
- createRequire(import.meta.url);
1866
+ const require = createRequire(import.meta.url);
1865
1867
  const __filename = fileURLToPath(import.meta.url);
1866
- path.dirname(__filename);
1868
+ const __dirname = path.dirname(__filename);
1867
1869
  const BacktestKitCli = new Proxy({}, {
1868
1870
  get(_target, prop) {
1869
1871
  throw new Error(`@backtest-kit/cli is not available in this context (accessed: ${String(prop)})`);
@@ -1901,8 +1903,15 @@ class BabelService {
1901
1903
  codeLen: code.length,
1902
1904
  });
1903
1905
  const module = { exports: {} };
1906
+ const exports = module.exports;
1904
1907
  eval(this.transpile(code));
1905
- return module.exports;
1908
+ return {
1909
+ require,
1910
+ __filename,
1911
+ __dirname,
1912
+ exports,
1913
+ module,
1914
+ };
1906
1915
  };
1907
1916
  }
1908
1917
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backtest-kit/cli",
3
- "version": "3.3.5",
3
+ "version": "3.3.6",
4
4
  "description": "Zero-boilerplate CLI runner for backtest-kit strategies. Run backtests, paper trading, and live bots with candle cache warming, web dashboard, and Telegram notifications — no setup code required.",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
package/types.d.ts CHANGED
@@ -96,7 +96,15 @@ declare global {
96
96
  declare class BabelService {
97
97
  readonly loggerService: LoggerService;
98
98
  transpile: (code: string) => any;
99
- transpileAndRun: (code: string) => Record<string, unknown>;
99
+ transpileAndRun: (code: string) => {
100
+ require: NodeRequire;
101
+ __filename: string;
102
+ __dirname: string;
103
+ exports: Record<string, unknown>;
104
+ module: {
105
+ exports: Record<string, unknown>;
106
+ };
107
+ };
100
108
  }
101
109
 
102
110
  declare class ResolveService {