@intrig/core 0.0.15-24 → 0.0.15-26

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.
Files changed (2) hide show
  1. package/main.js +78 -22
  2. package/package.json +1 -1
package/main.js CHANGED
@@ -81,6 +81,8 @@ var src = __webpack_require__(1);
81
81
  var common = __webpack_require__(3);
82
82
  // EXTERNAL MODULE: ../../node_modules/cross-spawn/index.js
83
83
  var cross_spawn = __webpack_require__(1309);
84
+ // EXTERNAL MODULE: external "child_process"
85
+ var external_child_process_ = __webpack_require__(1020);
84
86
  // EXTERNAL MODULE: ../../node_modules/@nestjs/config/index.js
85
87
  var config = __webpack_require__(1322);
86
88
  // EXTERNAL MODULE: external "fs"
@@ -251,6 +253,7 @@ function process_manager_service_ts_metadata(k, v) {
251
253
 
252
254
 
253
255
 
256
+
254
257
  class ProcessManagerService {
255
258
  constructor(discovery, config){
256
259
  this.discovery = discovery;
@@ -272,6 +275,28 @@ class ProcessManagerService {
272
275
  child.unref();
273
276
  this.logger.log(`Spawned daemon (pid=${child.pid})`);
274
277
  }
278
+ /**
279
+ * Start the daemon in foreground mode with verbose logging.
280
+ * This blocks until the process exits or is interrupted.
281
+ */ async startForeground() {
282
+ if (await this.discovery.isRunning()) {
283
+ this.logger.log('Daemon already running (via discovery)');
284
+ return;
285
+ }
286
+ const result = (0,external_child_process_.spawnSync)('intrig', [
287
+ "run"
288
+ ], {
289
+ stdio: 'inherit',
290
+ cwd: this.config.get('rootDir') ?? process.cwd()
291
+ });
292
+ if (result.error) {
293
+ this.logger.error('Failed to start daemon:', result.error);
294
+ throw result.error;
295
+ }
296
+ if (result.status !== 0) {
297
+ this.logger.error(`Daemon exited with code ${result.status}`);
298
+ }
299
+ }
275
300
  async stop() {
276
301
  const meta = this.discovery.getMetadata();
277
302
  if (!meta) {
@@ -334,17 +359,35 @@ class UpSubCommand extends src.CommandRunner {
334
359
  constructor(pm){
335
360
  super(), this.pm = pm;
336
361
  }
337
- async run() {
362
+ parseVerbose() {
363
+ return true;
364
+ }
365
+ async run(passedParams, options) {
338
366
  const isRunning = await this.pm.isRunning();
339
367
  if (isRunning) {
340
368
  console.log('✓ Daemon is already running');
341
369
  return;
342
370
  }
343
- console.log('Starting daemon...');
344
- await this.pm.start();
345
- console.log(' Daemon started successfully');
371
+ if (options?.verbose) {
372
+ console.log('Starting daemon in verbose mode (foreground)...');
373
+ console.log('Press Ctrl+C to stop the daemon.\n');
374
+ await this.pm.startForeground();
375
+ } else {
376
+ console.log('Starting daemon...');
377
+ await this.pm.start();
378
+ console.log('✓ Daemon started successfully');
379
+ }
346
380
  }
347
381
  }
382
+ daemon_command_ts_decorate([
383
+ (0,src.Option)({
384
+ flags: '-v, --verbose',
385
+ description: 'Run daemon in foreground with verbose logging'
386
+ }),
387
+ daemon_command_ts_metadata("design:type", Function),
388
+ daemon_command_ts_metadata("design:paramtypes", []),
389
+ daemon_command_ts_metadata("design:returntype", Boolean)
390
+ ], UpSubCommand.prototype, "parseVerbose", null);
348
391
  UpSubCommand = daemon_command_ts_decorate([
349
392
  (0,src.SubCommand)({
350
393
  name: 'up',
@@ -2221,8 +2264,6 @@ SourceManagementService = source_management_service_ts_decorate([
2221
2264
 
2222
2265
  // EXTERNAL MODULE: external "util"
2223
2266
  var external_util_ = __webpack_require__(73);
2224
- // EXTERNAL MODULE: external "child_process"
2225
- var external_child_process_ = __webpack_require__(1020);
2226
2267
  ;// ../../lib/common/src/lib/package-manager.service.ts
2227
2268
  function package_manager_service_ts_decorate(decorators, target, key, desc) {
2228
2269
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -11205,6 +11246,10 @@ function lazy_plugin_service_ts_metadata(k, v) {
11205
11246
 
11206
11247
 
11207
11248
 
11249
+ // Dynamic import that bypasses webpack transformation
11250
+ // This is necessary because webpack transforms import() into __webpack_require__()
11251
+ // which can't handle truly external modules from user's node_modules
11252
+ const dynamicImport = new Function('modulePath', 'return import(modulePath)');
11208
11253
  class LazyPluginService {
11209
11254
  constructor(configService){
11210
11255
  this.configService = configService;
@@ -11239,6 +11284,14 @@ class LazyPluginService {
11239
11284
  await this.getPlugin();
11240
11285
  return this.pluginName;
11241
11286
  }
11287
+ /**
11288
+ * Returns the target library package name where generated SDK content should be copied.
11289
+ * Derived from the plugin's meta().generator field (e.g., 'react' -> '@intrig/react').
11290
+ */ async getTargetLibrary() {
11291
+ const plugin = await this.getPlugin();
11292
+ const meta = plugin.meta();
11293
+ return `@intrig/${meta.generator}`;
11294
+ }
11242
11295
  async loadPlugin() {
11243
11296
  const rootDir = this.configService.get('rootDir') ?? process.cwd();
11244
11297
  this.logger.debug(`Loading plugin from rootDir: ${rootDir}`);
@@ -11275,22 +11328,23 @@ class LazyPluginService {
11275
11328
  const isFileDependency = this.isFileBasedDependency(pluginVersion);
11276
11329
  this.logger.debug(`Plugin is file-based: ${isFileDependency}`);
11277
11330
  try {
11278
- // Create a require function from the current module
11279
- const { createRequire: nodeCreateRequire } = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 1645, 23));
11280
- const projectRequire = nodeCreateRequire(external_node_path_.resolve(rootDir, 'package.json'));
11281
- this.logger.debug(`Attempting to load plugin using createRequire: ${this.pluginName}`);
11331
+ this.logger.debug(`Attempting to load plugin: ${this.pluginName}`);
11282
11332
  let mod;
11283
11333
  if (isFileDependency) {
11284
- // For file-based dependencies, require from the resolved path
11334
+ // For file-based dependencies, import from the resolved path
11285
11335
  const pluginPath = this.resolvePluginPath(rootDir, pluginVersion);
11286
- this.logger.debug(`Requiring from file path: ${pluginPath}`);
11287
- mod = projectRequire(pluginPath);
11336
+ this.logger.debug(`Importing from file path: ${pluginPath}`);
11337
+ mod = await dynamicImport(pluginPath);
11288
11338
  } else {
11289
- // For npm-based dependencies, require by name (assumes already installed)
11290
- this.logger.debug(`Requiring npm package: ${this.pluginName}`);
11291
- mod = projectRequire(this.pluginName);
11292
- }
11293
- this.logger.debug(`Module require succeeded`);
11339
+ // For npm-based dependencies, resolve the path first then import
11340
+ // This ensures we load from the project's node_modules, not the daemon's
11341
+ const { createRequire: nodeCreateRequire } = await dynamicImport('node:module');
11342
+ const projectRequire = nodeCreateRequire(external_node_path_.resolve(rootDir, 'package.json'));
11343
+ const resolvedPath = projectRequire.resolve(this.pluginName);
11344
+ this.logger.debug(`Importing npm package from resolved path: ${resolvedPath}`);
11345
+ mod = await dynamicImport(resolvedPath);
11346
+ }
11347
+ this.logger.debug(`Module import succeeded`);
11294
11348
  const factory = this.extractFactory(mod, this.pluginName);
11295
11349
  this.pluginInstance = await Promise.resolve(factory());
11296
11350
  // Validate plugin instance
@@ -11522,8 +11576,10 @@ class OperationsService {
11522
11576
  ...targetPackage.devDependencies,
11523
11577
  ...sourcePackage.devDependencies
11524
11578
  },
11525
- exports: sourcePackage.exports ?? targetPackage.exports,
11526
- typesVersions: sourcePackage.typesVersions ?? targetPackage.typesVersions
11579
+ // Keep original plugin exports (pointing to dist/) - don't override with generated exports
11580
+ // The generated SDK code goes to src/ but the plugin entry point must remain dist/
11581
+ exports: targetPackage.exports,
11582
+ typesVersions: targetPackage.typesVersions
11527
11583
  };
11528
11584
  await lib.writeJson(targetFile, merged, {
11529
11585
  spaces: 2
@@ -11534,8 +11590,8 @@ class OperationsService {
11534
11590
  }
11535
11591
  }
11536
11592
  async copyContentToNodeModules(ctx, hashes) {
11537
- const pluginName = await this.lazyPluginService.getPluginName();
11538
- const targetLibDir = external_path_.join(this.config.get('rootDir') ?? process.cwd(), 'node_modules', pluginName);
11593
+ const targetLibrary = await this.lazyPluginService.getTargetLibrary();
11594
+ const targetLibDir = external_path_.join(this.config.get('rootDir') ?? process.cwd(), 'node_modules', targetLibrary);
11539
11595
  try {
11540
11596
  if (await lib.pathExists(external_path_.join(targetLibDir, 'src'))) {
11541
11597
  await lib.remove(external_path_.join(targetLibDir, 'src'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intrig/core",
3
- "version": "0.0.15-24",
3
+ "version": "0.0.15-26",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "bin": {