@intrig/core 0.0.15-11 → 0.0.15-12

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 +266 -157
  2. package/package.json +1 -2
package/main.js CHANGED
@@ -10,6 +10,12 @@ import { createRequire as __WEBPACK_EXTERNAL_createRequire } from "node:module";
10
10
 
11
11
  module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("child_process");
12
12
 
13
+ /***/ }),
14
+ /* 2 */
15
+ /***/ ((module) => {
16
+
17
+ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:module");
18
+
13
19
  /***/ })
14
20
  /******/ ]);
15
21
  /************************************************************************/
@@ -1322,6 +1328,54 @@ intrig_source_config_ts_decorate([
1322
1328
  intrig_source_config_ts_metadata("design:type", String)
1323
1329
  ], IntrigSourceConfig.prototype, "specUrl", void 0);
1324
1330
 
1331
+ ;// ../../lib/common/src/lib/model/intrig-source-transform-response.ts
1332
+ function intrig_source_transform_response_ts_decorate(decorators, target, key, desc) {
1333
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1334
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1335
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1336
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1337
+ }
1338
+ function intrig_source_transform_response_ts_metadata(k, v) {
1339
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1340
+ }
1341
+
1342
+ class IntrigSourceTransformResponse {
1343
+ constructor(id, name, specUrl, serverUrl){
1344
+ this.id = id;
1345
+ this.name = name;
1346
+ this.specUrl = specUrl;
1347
+ this.serverUrl = serverUrl;
1348
+ }
1349
+ static from(source) {
1350
+ return new IntrigSourceTransformResponse(source.id, source.name, source.specUrl, source.serverUrl);
1351
+ }
1352
+ }
1353
+ intrig_source_transform_response_ts_decorate([
1354
+ (0,swagger_namespaceObject.ApiProperty)({
1355
+ description: 'Unique identifier for the source config'
1356
+ }),
1357
+ intrig_source_transform_response_ts_metadata("design:type", String)
1358
+ ], IntrigSourceTransformResponse.prototype, "id", void 0);
1359
+ intrig_source_transform_response_ts_decorate([
1360
+ (0,swagger_namespaceObject.ApiProperty)({
1361
+ description: 'Name of the source config'
1362
+ }),
1363
+ intrig_source_transform_response_ts_metadata("design:type", String)
1364
+ ], IntrigSourceTransformResponse.prototype, "name", void 0);
1365
+ intrig_source_transform_response_ts_decorate([
1366
+ (0,swagger_namespaceObject.ApiProperty)({
1367
+ description: 'URL of the specification'
1368
+ }),
1369
+ intrig_source_transform_response_ts_metadata("design:type", String)
1370
+ ], IntrigSourceTransformResponse.prototype, "specUrl", void 0);
1371
+ intrig_source_transform_response_ts_decorate([
1372
+ (0,swagger_namespaceObject.ApiProperty)({
1373
+ description: 'Resolved server URL from the OpenAPI spec',
1374
+ required: false
1375
+ }),
1376
+ intrig_source_transform_response_ts_metadata("design:type", String)
1377
+ ], IntrigSourceTransformResponse.prototype, "serverUrl", void 0);
1378
+
1325
1379
  ;// ../../lib/common/src/lib/model/resource-descriptor.ts
1326
1380
  function resource_descriptor_ts_decorate(decorators, target, key, desc) {
1327
1381
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -2294,6 +2348,7 @@ function splitPrefixSuffix(input, options = {}) {
2294
2348
 
2295
2349
 
2296
2350
 
2351
+
2297
2352
  // Templates
2298
2353
 
2299
2354
 
@@ -3855,8 +3910,6 @@ SearchService = search_service_ts_decorate([
3855
3910
 
3856
3911
  ;// external "node:path"
3857
3912
  const external_node_path_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:path");
3858
- ;// external "live-plugin-manager"
3859
- const external_live_plugin_manager_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("live-plugin-manager");
3860
3913
  ;// ./src/app/plugins/lazy-plugin.service.ts
3861
3914
  function lazy_plugin_service_ts_decorate(decorators, target, key, desc) {
3862
3915
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -3871,10 +3924,10 @@ function lazy_plugin_service_ts_metadata(k, v) {
3871
3924
 
3872
3925
 
3873
3926
 
3874
-
3875
3927
  class LazyPluginService {
3876
3928
  constructor(configService){
3877
3929
  this.configService = configService;
3930
+ this.logger = new common_namespaceObject.Logger(LazyPluginService.name);
3878
3931
  this.pluginInstance = null;
3879
3932
  this.pluginName = null;
3880
3933
  this.isLoading = false;
@@ -3907,7 +3960,7 @@ class LazyPluginService {
3907
3960
  }
3908
3961
  async loadPlugin() {
3909
3962
  const rootDir = this.configService.get('rootDir') ?? process.cwd();
3910
- console.log(`[DEBUG] Loading plugin from rootDir: ${rootDir}`);
3963
+ this.logger.debug(`Loading plugin from rootDir: ${rootDir}`);
3911
3964
  const pkgPath = external_node_path_namespaceObject.resolve(rootDir, 'package.json');
3912
3965
  let packageJson;
3913
3966
  try {
@@ -3936,38 +3989,27 @@ class LazyPluginService {
3936
3989
  }
3937
3990
  this.pluginName = matchedPlugins[0];
3938
3991
  const pluginVersion = allDeps[this.pluginName];
3939
- console.log(`[DEBUG] Found plugin: ${this.pluginName} with version/path: ${pluginVersion}`);
3992
+ this.logger.debug(`Found plugin: ${this.pluginName} with version/path: ${pluginVersion}`);
3940
3993
  // Check if plugin is a file-based dependency
3941
3994
  const isFileDependency = this.isFileBasedDependency(pluginVersion);
3942
- console.log(`[DEBUG] Plugin is file-based: ${isFileDependency}`);
3995
+ this.logger.debug(`Plugin is file-based: ${isFileDependency}`);
3943
3996
  try {
3944
- // Initialize PluginManager with rootDir as the plugin directory
3945
- const pluginManager = new external_live_plugin_manager_namespaceObject.PluginManager({
3946
- pluginsPath: external_node_path_namespaceObject.join(rootDir, 'plugins'),
3947
- npmRegistryUrl: 'https://registry.npmjs.org',
3948
- cwd: rootDir
3949
- });
3950
- console.log(`[DEBUG] Attempting to load plugin using PluginManager: ${this.pluginName}`);
3997
+ // Create a require function from the current module
3998
+ const { createRequire: nodeCreateRequire } = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 2, 23));
3999
+ const projectRequire = nodeCreateRequire(external_node_path_namespaceObject.resolve(rootDir, 'package.json'));
4000
+ this.logger.debug(`Attempting to load plugin using createRequire: ${this.pluginName}`);
3951
4001
  let mod;
3952
- try {
3953
- // First try to require the plugin if it's already installed
3954
- mod = pluginManager.require(this.pluginName);
3955
- console.log(`[DEBUG] PluginManager require succeeded`);
3956
- } catch (requireErr) {
3957
- console.log(`[DEBUG] PluginManager require failed, attempting install: ${requireErr.message}`);
3958
- if (isFileDependency) {
3959
- // For file-based dependencies, resolve the path and use installFromPath
3960
- const pluginPath = this.resolvePluginPath(rootDir, pluginVersion);
3961
- console.log(`[DEBUG] Installing from path: ${pluginPath}`);
3962
- await pluginManager.installFromPath(pluginPath);
3963
- } else {
3964
- // For npm-based dependencies, use regular install
3965
- console.log(`[DEBUG] Installing from npm: ${this.pluginName}`);
3966
- await pluginManager.install(this.pluginName);
3967
- }
3968
- mod = pluginManager.require(this.pluginName);
3969
- console.log(`[DEBUG] PluginManager install and require succeeded`);
4002
+ if (isFileDependency) {
4003
+ // For file-based dependencies, require from the resolved path
4004
+ const pluginPath = this.resolvePluginPath(rootDir, pluginVersion);
4005
+ this.logger.debug(`Requiring from file path: ${pluginPath}`);
4006
+ mod = projectRequire(pluginPath);
4007
+ } else {
4008
+ // For npm-based dependencies, require by name (assumes already installed)
4009
+ this.logger.debug(`Requiring npm package: ${this.pluginName}`);
4010
+ mod = projectRequire(this.pluginName);
3970
4011
  }
4012
+ this.logger.debug(`Module require succeeded`);
3971
4013
  const factory = this.extractFactory(mod, this.pluginName);
3972
4014
  this.pluginInstance = await Promise.resolve(factory());
3973
4015
  // Validate plugin instance
@@ -3975,7 +4017,7 @@ class LazyPluginService {
3975
4017
  throw new Error(`Plugin factory from "${this.pluginName}" did not return a valid Intrig plugin instance.`);
3976
4018
  }
3977
4019
  } catch (err) {
3978
- throw new Error(`Failed to load Intrig plugin "${this.pluginName}" using PluginManager: ${err.message}`);
4020
+ throw new Error(`Failed to load Intrig plugin "${this.pluginName}": ${err.message}`);
3979
4021
  }
3980
4022
  }
3981
4023
  isFileBasedDependency(version) {
@@ -5072,9 +5114,11 @@ function sources_command_ts_metadata(k, v) {
5072
5114
 
5073
5115
 
5074
5116
 
5117
+
5118
+
5075
5119
  class SourcesAddCommand extends external_nest_commander_namespaceObject.CommandRunner {
5076
- constructor(pm, httpService){
5077
- super(), this.pm = pm, this.httpService = httpService;
5120
+ constructor(pm, httpService, lazyPluginService, configService){
5121
+ super(), this.pm = pm, this.httpService = httpService, this.lazyPluginService = lazyPluginService, this.configService = configService;
5078
5122
  }
5079
5123
  async run(passedParams, options) {
5080
5124
  const metadata = await this.pm.getMetadata();
@@ -5129,6 +5173,23 @@ class SourcesAddCommand extends external_nest_commander_namespaceObject.CommandR
5129
5173
  // 8) Final output
5130
5174
  console.log(external_chalk_default().green.bold(`\n${spinner} Source "${id}" added!`));
5131
5175
  console.log(external_chalk_default().whiteBright('Response:'), external_chalk_default().white(JSON.stringify(addRes)));
5176
+ // 9) Call plugin addSource lifecycle method if available
5177
+ try {
5178
+ const plugin = await this.lazyPluginService.getPlugin();
5179
+ if (plugin.addSource && typeof plugin.addSource === 'function') {
5180
+ const rootDir = this.configService.get('rootDir') ?? process.cwd();
5181
+ await plugin.addSource({
5182
+ options: {},
5183
+ rootDir: rootDir,
5184
+ source: source,
5185
+ serverUrl: source.serverUrl
5186
+ });
5187
+ console.log(external_chalk_default().gray('✔ Plugin addSource lifecycle method executed'));
5188
+ }
5189
+ } catch (error) {
5190
+ console.log(external_chalk_default().yellow('⚠️ Warning: Failed to execute plugin addSource lifecycle method:'), error?.message);
5191
+ // Don't fail the command - lifecycle methods are optional
5192
+ }
5132
5193
  }
5133
5194
  }
5134
5195
  SourcesAddCommand = sources_command_ts_decorate([
@@ -5139,7 +5200,9 @@ SourcesAddCommand = sources_command_ts_decorate([
5139
5200
  sources_command_ts_metadata("design:type", Function),
5140
5201
  sources_command_ts_metadata("design:paramtypes", [
5141
5202
  typeof ProcessManagerService === "undefined" ? Object : ProcessManagerService,
5142
- typeof axios_namespaceObject.HttpService === "undefined" ? Object : axios_namespaceObject.HttpService
5203
+ typeof axios_namespaceObject.HttpService === "undefined" ? Object : axios_namespaceObject.HttpService,
5204
+ typeof LazyPluginService === "undefined" ? Object : LazyPluginService,
5205
+ typeof config_namespaceObject.ConfigService === "undefined" ? Object : config_namespaceObject.ConfigService
5143
5206
  ])
5144
5207
  ], SourcesAddCommand);
5145
5208
  class SourceListCommand extends external_nest_commander_namespaceObject.CommandRunner {
@@ -5184,8 +5247,8 @@ SourceListCommand = sources_command_ts_decorate([
5184
5247
  ])
5185
5248
  ], SourceListCommand);
5186
5249
  class SourceRemoveCommand extends external_nest_commander_namespaceObject.CommandRunner {
5187
- constructor(pm, httpService){
5188
- super(), this.pm = pm, this.httpService = httpService;
5250
+ constructor(pm, httpService, lazyPluginService, configService){
5251
+ super(), this.pm = pm, this.httpService = httpService, this.lazyPluginService = lazyPluginService, this.configService = configService;
5189
5252
  }
5190
5253
  async run(passedParams, options) {
5191
5254
  // 1) fetch metadata
@@ -5218,6 +5281,8 @@ class SourceRemoveCommand extends external_nest_commander_namespaceObject.Comman
5218
5281
  choices
5219
5282
  }
5220
5283
  ]);
5284
+ // Store the source details before deletion for lifecycle method
5285
+ const selectedSource = sources.find((src)=>src.id === id);
5221
5286
  // 4) confirm deletion
5222
5287
  const { confirm } = await external_inquirer_default().prompt([
5223
5288
  {
@@ -5237,6 +5302,23 @@ class SourceRemoveCommand extends external_nest_commander_namespaceObject.Comman
5237
5302
  await (0,external_rxjs_namespaceObject.lastValueFrom)(this.httpService.delete(removeUrl));
5238
5303
  // 6) success
5239
5304
  console.log(external_chalk_default().green.bold(`\n✔ Source "${id}" removed!`));
5305
+ // 7) Call plugin removeSource lifecycle method if available
5306
+ try {
5307
+ const plugin = await this.lazyPluginService.getPlugin();
5308
+ if (plugin.removeSource && typeof plugin.removeSource === 'function' && selectedSource) {
5309
+ const rootDir = this.configService.get('rootDir') ?? process.cwd();
5310
+ await plugin.removeSource({
5311
+ options: {},
5312
+ rootDir: rootDir,
5313
+ source: selectedSource,
5314
+ serverUrl: selectedSource.serverUrl
5315
+ });
5316
+ console.log(external_chalk_default().gray('✔ Plugin removeSource lifecycle method executed'));
5317
+ }
5318
+ } catch (error) {
5319
+ console.log(external_chalk_default().yellow('⚠️ Warning: Failed to execute plugin removeSource lifecycle method:'), error?.message);
5320
+ // Don't fail the command - lifecycle methods are optional
5321
+ }
5240
5322
  }
5241
5323
  }
5242
5324
  SourceRemoveCommand = sources_command_ts_decorate([
@@ -5247,7 +5329,9 @@ SourceRemoveCommand = sources_command_ts_decorate([
5247
5329
  sources_command_ts_metadata("design:type", Function),
5248
5330
  sources_command_ts_metadata("design:paramtypes", [
5249
5331
  typeof ProcessManagerService === "undefined" ? Object : ProcessManagerService,
5250
- typeof axios_namespaceObject.HttpService === "undefined" ? Object : axios_namespaceObject.HttpService
5332
+ typeof axios_namespaceObject.HttpService === "undefined" ? Object : axios_namespaceObject.HttpService,
5333
+ typeof LazyPluginService === "undefined" ? Object : LazyPluginService,
5334
+ typeof config_namespaceObject.ConfigService === "undefined" ? Object : config_namespaceObject.ConfigService
5251
5335
  ])
5252
5336
  ], SourceRemoveCommand);
5253
5337
  class SourcesCommand extends external_nest_commander_namespaceObject.CommandRunner {
@@ -6142,12 +6226,13 @@ class OpenapiService {
6142
6226
  }
6143
6227
  const title = spec?.info?.title ?? '';
6144
6228
  const servers = Array.isArray(spec?.servers) ? spec.servers : [];
6145
- const regex = servers.length > 0 ? servers[0].url : undefined;
6146
- this.logger.debug(`Resolved spec title: ${title}, server regex: ${regex}`);
6147
- return IntrigSourceConfig.from({
6229
+ const serverUrl = servers.length > 0 ? servers[0].url : undefined;
6230
+ this.logger.debug(`Resolved spec title: ${title}, server URL: ${serverUrl}`);
6231
+ return IntrigSourceTransformResponse.from({
6148
6232
  id: '',
6149
6233
  name: title,
6150
- specUrl: url
6234
+ specUrl: url,
6235
+ serverUrl: serverUrl
6151
6236
  });
6152
6237
  }
6153
6238
  }
@@ -6259,7 +6344,7 @@ sources_controller_ts_decorate([
6259
6344
  }),
6260
6345
  (0,swagger_namespaceObject.ApiResponse)({
6261
6346
  status: 201,
6262
- type: IntrigSourceConfig
6347
+ type: IntrigSourceTransformResponse
6263
6348
  }),
6264
6349
  (0,common_namespaceObject.Post)("transform"),
6265
6350
  _ts_param(0, (0,common_namespaceObject.Body)()),
@@ -6362,7 +6447,7 @@ sources_controller_ts_decorate([
6362
6447
  ], SourcesController.prototype, "downloadOpenApiFile", null);
6363
6448
  SourcesController = sources_controller_ts_decorate([
6364
6449
  (0,swagger_namespaceObject.ApiTags)('Sources'),
6365
- (0,swagger_namespaceObject.ApiExtraModels)(IntrigSourceConfig),
6450
+ (0,swagger_namespaceObject.ApiExtraModels)(IntrigSourceConfig, IntrigSourceTransformResponse),
6366
6451
  (0,common_namespaceObject.Controller)('config/sources'),
6367
6452
  sources_controller_ts_metadata("design:type", Function),
6368
6453
  sources_controller_ts_metadata("design:paramtypes", [
@@ -8077,6 +8162,53 @@ McpModule = mcp_module_ts_decorate([
8077
8162
 
8078
8163
  ;// external "semver"
8079
8164
  const external_semver_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("semver");
8165
+ ;// external "@intrig/plugin-sdk"
8166
+ const plugin_sdk_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("@intrig/plugin-sdk");
8167
+ ;// ./src/app/init-cli/templates/schema.template.ts
8168
+
8169
+
8170
+ function schemaTemplate(pluginInstance) {
8171
+ const json = (0,plugin_sdk_namespaceObject.jsonLiteral)(external_path_namespaceObject.resolve('.intrig', 'schema.json'));
8172
+ return json`
8173
+ {
8174
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
8175
+ "type": "object",
8176
+ "properties": {
8177
+ "$schema": "./.intrig/schema.json",
8178
+ "sources": {
8179
+ "type": "array",
8180
+ "items": {
8181
+ "type": "object",
8182
+ "properties": {
8183
+ "id": { "type": "string" },
8184
+ "name": { "type": "string" },
8185
+ "specUrl": { "type": "string", "format": "uri" }
8186
+ },
8187
+ "required": ["id", "name", "specUrl"],
8188
+ "additionalProperties": false
8189
+ },
8190
+ "minItems": 1
8191
+ },
8192
+ "generator": {
8193
+ "type": "string",
8194
+ "enum": ["react", "vue", "angular", "svelte"]
8195
+ },
8196
+ "codeAnalyzer": {
8197
+ "type": "object",
8198
+ "properties": {
8199
+ "tsConfigPath": { "type": "string" }
8200
+ },
8201
+ "required": ["tsConfigPath"],
8202
+ "additionalProperties": false
8203
+ },
8204
+ "generatorOptions": ${pluginInstance && pluginInstance.$generatorSchema ? JSON.stringify(pluginInstance.$generatorSchema, null, 6) : '{ "type": "object" }'}
8205
+ },
8206
+ "required": ["sources", "generator"],
8207
+ "additionalProperties": false
8208
+ }
8209
+ `;
8210
+ }
8211
+
8080
8212
  ;// ./src/app/init-cli/commands/init.command.ts
8081
8213
  function init_command_ts_decorate(decorators, target, key, desc) {
8082
8214
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -8092,22 +8224,31 @@ function init_command_ts_decorate(decorators, target, key, desc) {
8092
8224
 
8093
8225
 
8094
8226
 
8227
+
8095
8228
  class InitCommand extends external_nest_commander_namespaceObject.CommandRunner {
8096
8229
  async run(passedParams, options) {
8097
- this.logger.log('Initializing Intrig setup...');
8230
+ console.log(external_chalk_default().blue('🚀 Initializing Intrig setup...'));
8098
8231
  const rootDir = process.cwd();
8099
8232
  try {
8100
8233
  // Read package.json to determine project type
8101
8234
  const packageJsonPath = external_path_namespaceObject.resolve(rootDir, 'package.json');
8102
8235
  if (!external_fs_namespaceObject.existsSync(packageJsonPath)) {
8103
- this.logger.error('package.json not found in current directory');
8236
+ console.log(external_chalk_default().red('package.json not found in current directory'));
8104
8237
  throw new Error('package.json not found');
8105
8238
  }
8106
8239
  const packageJson = external_fs_extra_namespaceObject.readJsonSync(packageJsonPath);
8107
- // Fetch approved plugins from GitHub
8108
- const approvedPlugins = await this.fetchApprovedPlugins();
8109
- // Prompt user to select plugin (show all plugins with best match as default)
8110
- const selectedPlugin = await this.promptUserForPlugin(approvedPlugins, packageJson);
8240
+ // Check for existing plugin dependency matching the plugin regex format
8241
+ const existingPlugin = this.checkForExistingPlugin(packageJson);
8242
+ let selectedPlugin;
8243
+ if (existingPlugin) {
8244
+ console.log(external_chalk_default().green(`✅ Found existing plugin dependency: ${existingPlugin.name}`));
8245
+ selectedPlugin = existingPlugin;
8246
+ } else {
8247
+ // Fetch approved plugins from GitHub
8248
+ const approvedPlugins = await this.fetchApprovedPlugins();
8249
+ // Prompt user to select plugin (show all plugins with best match as default)
8250
+ selectedPlugin = await this.promptUserForPlugin(approvedPlugins, packageJson);
8251
+ }
8111
8252
  // Load and initialize the selected plugin
8112
8253
  const pluginInstance = await this.loadAndInitializePlugin(selectedPlugin);
8113
8254
  // Create .intrig directory if it doesn't exist
@@ -8117,108 +8258,84 @@ class InitCommand extends external_nest_commander_namespaceObject.CommandRunner
8117
8258
  recursive: true
8118
8259
  });
8119
8260
  }
8120
- // Create the base schema
8121
- const baseSchema = {
8122
- "$schema": "https://json-schema.org/draft/2020-12/schema",
8123
- "type": "object",
8124
- "properties": {
8125
- "$schema": "./.intrig/schema.json",
8126
- "sources": {
8127
- "type": "array",
8128
- "items": {
8129
- "type": "object",
8130
- "properties": {
8131
- "id": {
8132
- "type": "string"
8133
- },
8134
- "name": {
8135
- "type": "string"
8136
- },
8137
- "specUrl": {
8138
- "type": "string",
8139
- "format": "uri"
8140
- }
8141
- },
8142
- "required": [
8143
- "id",
8144
- "name",
8145
- "specUrl"
8146
- ],
8147
- "additionalProperties": false
8148
- },
8149
- "minItems": 1
8150
- },
8151
- "generator": {
8152
- "type": "string",
8153
- "enum": [
8154
- "react",
8155
- "vue",
8156
- "angular",
8157
- "svelte"
8158
- ]
8159
- },
8160
- "codeAnalyzer": {
8161
- "type": "object",
8162
- "properties": {
8163
- "tsConfigPath": {
8164
- "type": "string"
8165
- }
8166
- },
8167
- "required": [
8168
- "tsConfigPath"
8169
- ],
8170
- "additionalProperties": false
8171
- },
8172
- "generatorOptions": {
8173
- "type": "object"
8174
- }
8175
- },
8176
- "required": [
8177
- "sources",
8178
- "generator"
8179
- ],
8180
- "additionalProperties": false
8261
+ // Write schema file using template
8262
+ const spinner = external_ora_default()('Writing configuration files...').start();
8263
+ // Create dump function for schema writing
8264
+ const dumpSchema = async (content)=>{
8265
+ const resolved = await content;
8266
+ const fullPath = external_path_namespaceObject.resolve(rootDir, resolved.path);
8267
+ const dir = external_path_namespaceObject.dirname(fullPath);
8268
+ if (!external_fs_namespaceObject.existsSync(dir)) {
8269
+ external_fs_namespaceObject.mkdirSync(dir, {
8270
+ recursive: true
8271
+ });
8272
+ }
8273
+ external_fs_namespaceObject.writeFileSync(fullPath, resolved.content, 'utf-8');
8181
8274
  };
8182
- // Add generatorOptions if plugin has $generatorSchema
8183
- if (pluginInstance && pluginInstance.$generatorSchema) {
8184
- baseSchema.properties.generatorOptions = pluginInstance.$generatorSchema;
8185
- }
8186
- // Write schema file
8187
- const schemaPath = external_path_namespaceObject.resolve(intrigDir, 'schema.json');
8188
- this.logger.debug('Writing schema file...');
8189
- external_fs_namespaceObject.writeFileSync(schemaPath, JSON.stringify(baseSchema, null, 2), 'utf-8');
8275
+ // Use template to create schema
8276
+ await dumpSchema(schemaTemplate(pluginInstance));
8190
8277
  // Create intrig config
8191
8278
  const config = {
8192
8279
  $schema: './.intrig/schema.json',
8193
8280
  sources: [],
8194
- generator: selectedPlugin.generator
8281
+ generator: pluginInstance.meta().generator
8195
8282
  };
8196
8283
  // Write config file
8197
8284
  const configPath = external_path_namespaceObject.resolve(rootDir, 'intrig.config.json');
8198
- this.logger.debug('Writing config file...');
8199
8285
  external_fs_namespaceObject.writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf-8');
8200
8286
  // Add config file to git
8201
8287
  this.addConfigToGit(rootDir);
8202
8288
  // Update .gitignore
8203
8289
  this.updateGitIgnore(rootDir);
8204
- this.logger.log('Intrig initialization completed successfully');
8290
+ spinner.succeed('Configuration files created successfully');
8291
+ console.log(external_chalk_default().green('✅ Intrig initialization completed successfully'));
8205
8292
  } catch (error) {
8206
- this.logger.error('Failed to initialize Intrig:', error?.message);
8293
+ console.log(external_chalk_default().red('Failed to initialize Intrig:'), error?.message);
8207
8294
  throw error;
8208
8295
  }
8209
8296
  }
8297
+ checkForExistingPlugin(packageJson) {
8298
+ const allDeps = {
8299
+ ...packageJson?.dependencies ?? {},
8300
+ ...packageJson?.devDependencies ?? {},
8301
+ ...packageJson?.peerDependencies ?? {},
8302
+ ...packageJson?.optionalDependencies ?? {}
8303
+ };
8304
+ const pluginPatterns = [
8305
+ /^@intrig\/plugin-.+/,
8306
+ /^@[^/]+\/intrig-plugin-.+/,
8307
+ /^intrig-plugin-.+/
8308
+ ];
8309
+ const matchedPlugins = Object.keys(allDeps).filter((name)=>pluginPatterns.some((pattern)=>pattern.test(name)));
8310
+ if (matchedPlugins.length > 0) {
8311
+ const pluginName = matchedPlugins[0];
8312
+ return {
8313
+ type: 'generator',
8314
+ generator: 'custom',
8315
+ name: pluginName,
8316
+ compat: {
8317
+ latest: {
8318
+ dependencies: {}
8319
+ }
8320
+ }
8321
+ };
8322
+ }
8323
+ return null;
8324
+ }
8210
8325
  async fetchApprovedPlugins() {
8211
- this.logger.debug('Fetching approved plugins from GitHub...');
8212
- const url = 'https://raw.githubusercontent.com/intrigsoft/intrig-core/main/registry/approved.json';
8326
+ const spinner = external_ora_default()('Fetching approved plugins from registry...').start();
8327
+ const url = 'https://raw.githubusercontent.com/intrigsoft/intrig-registry/refs/heads/main/registry.json';
8213
8328
  try {
8214
8329
  const response = await fetch(url);
8215
8330
  if (!response.ok) {
8216
8331
  throw new Error(`Failed to fetch approved plugins: ${response.statusText}`);
8217
8332
  }
8218
8333
  const plugins = await response.json();
8334
+ spinner.succeed('Successfully fetched approved plugins');
8219
8335
  return plugins;
8220
8336
  } catch (error) {
8221
- this.logger.error('Failed to fetch approved plugins:', error?.message);
8337
+ spinner.fail('Failed to fetch approved plugins');
8338
+ console.log(external_chalk_default().red('❌ Error:'), error?.message);
8222
8339
  throw error;
8223
8340
  }
8224
8341
  }
@@ -8238,7 +8355,7 @@ class InitCommand extends external_nest_commander_namespaceObject.CommandRunner
8238
8355
  return external_semver_namespaceObject.satisfies(cleanProjectVersion.version, normalizedRequiredVersion);
8239
8356
  } catch (error) {
8240
8357
  // If semver parsing fails, fall back to string comparison
8241
- this.logger.warn(`Failed to parse version: ${projectVersion} vs ${requiredVersion}`);
8358
+ console.log(external_chalk_default().yellow('⚠️ Warning: Failed to parse version:'), `${projectVersion} vs ${requiredVersion}`);
8242
8359
  return projectVersion === requiredVersion;
8243
8360
  }
8244
8361
  }
@@ -8316,41 +8433,36 @@ class InitCommand extends external_nest_commander_namespaceObject.CommandRunner
8316
8433
  return selectedPlugin;
8317
8434
  }
8318
8435
  async loadAndInitializePlugin(plugin) {
8319
- this.logger.log(`Installing plugin: ${plugin.name}`);
8436
+ const installSpinner = external_ora_default()(`Installing plugin: ${plugin.name}`).start();
8320
8437
  try {
8321
8438
  const rootDir = process.cwd();
8322
8439
  // First, install the plugin in the project directory using npm
8323
- this.logger.debug(`Installing ${plugin.name} using npm...`);
8324
8440
  const { execSync } = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 1, 23));
8325
8441
  try {
8326
8442
  // Use npm to install the plugin in the project directory as dev dependency
8327
8443
  execSync(`npm install --save-dev ${plugin.name}`, {
8328
8444
  cwd: rootDir,
8329
- stdio: 'inherit'
8445
+ stdio: 'pipe'
8330
8446
  });
8331
- this.logger.log(`Plugin ${plugin.name} installed successfully`);
8447
+ installSpinner.text = `Installing @intrig/core as dev dependency...`;
8332
8448
  // Install @intrig/core as a dev dependency
8333
- this.logger.debug('Installing @intrig/core as dev dependency...');
8334
8449
  execSync('npm install --save-dev @intrig/core', {
8335
8450
  cwd: rootDir,
8336
- stdio: 'inherit'
8451
+ stdio: 'pipe'
8337
8452
  });
8338
- this.logger.log('@intrig/core installed successfully as dev dependency');
8453
+ installSpinner.succeed(`Plugin ${plugin.name} and @intrig/core installed successfully`);
8339
8454
  } catch (npmError) {
8340
- this.logger.error(`Failed to install plugin ${plugin.name} with npm:`, npmError?.message);
8455
+ installSpinner.fail(`Failed to install plugin ${plugin.name}`);
8456
+ console.log(external_chalk_default().red('❌ Error:'), npmError?.message);
8341
8457
  throw new Error(`Failed to install plugin ${plugin.name}: ${npmError?.message}`);
8342
8458
  }
8343
- // Now use PluginManager to load the plugin (same mechanism as LazyPluginService)
8459
+ // Now use createRequire to load the plugin
8460
+ const loadSpinner = external_ora_default()(`Loading and initializing plugin: ${plugin.name}`).start();
8344
8461
  try {
8345
- this.logger.debug(`Loading plugin ${plugin.name} using PluginManager...`);
8346
- // Initialize PluginManager with rootDir as the plugin directory
8347
- const pluginManager = new external_live_plugin_manager_namespaceObject.PluginManager({
8348
- pluginsPath: external_path_namespaceObject.join(rootDir, 'plugins'),
8349
- npmRegistryUrl: 'https://registry.npmjs.org',
8350
- cwd: rootDir
8351
- });
8462
+ const { createRequire: nodeCreateRequire } = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 2, 23));
8463
+ const projectRequire = nodeCreateRequire(external_path_namespaceObject.resolve(rootDir, 'package.json'));
8352
8464
  // Try to require the plugin (it should be installed by npm already)
8353
- const pluginModule = pluginManager.require(plugin.name);
8465
+ const pluginModule = projectRequire(plugin.name);
8354
8466
  // Extract the factory function from the module
8355
8467
  const factory = this.extractFactory(pluginModule, plugin.name);
8356
8468
  // Create the plugin instance
@@ -8361,7 +8473,7 @@ class InitCommand extends external_nest_commander_namespaceObject.CommandRunner
8361
8473
  }
8362
8474
  // Call init function if it exists on the plugin instance
8363
8475
  if (typeof pluginInstance.init === 'function') {
8364
- this.logger.debug('Calling plugin init function...');
8476
+ loadSpinner.text = 'Calling plugin init function...';
8365
8477
  await pluginInstance.init({
8366
8478
  options: {},
8367
8479
  rootDir: rootDir,
@@ -8379,16 +8491,17 @@ class InitCommand extends external_nest_commander_namespaceObject.CommandRunner
8379
8491
  }
8380
8492
  });
8381
8493
  }
8382
- this.logger.log(`Plugin ${plugin.name} loaded and initialized successfully using PluginManager`);
8494
+ loadSpinner.succeed(`Plugin ${plugin.name} loaded and initialized successfully`);
8383
8495
  return pluginInstance;
8384
8496
  } catch (loadError) {
8385
- this.logger.warn(`Plugin ${plugin.name} was installed but could not be loaded/initialized using PluginManager:`, loadError?.message);
8497
+ loadSpinner.warn(`Plugin ${plugin.name} was installed but could not be loaded/initialized`);
8498
+ console.log(external_chalk_default().yellow('⚠️ Warning:'), loadError?.message);
8386
8499
  // Don't throw here - the plugin is installed which is the main requirement
8387
- this.logger.log(`Plugin ${plugin.name} installation completed (initialization skipped due to loading issues)`);
8500
+ console.log(external_chalk_default().blue('ℹ️ Info: Plugin installation completed (initialization skipped due to loading issues)'));
8388
8501
  return null;
8389
8502
  }
8390
8503
  } catch (error) {
8391
- this.logger.error(`Failed to install plugin ${plugin.name}:`, error?.message);
8504
+ console.log(external_chalk_default().red('❌ Failed to install plugin'), `${plugin.name}:`, error?.message);
8392
8505
  throw error;
8393
8506
  }
8394
8507
  }
@@ -8405,7 +8518,6 @@ class InitCommand extends external_nest_commander_namespaceObject.CommandRunner
8405
8518
  }
8406
8519
  addConfigToGit(rootDir) {
8407
8520
  try {
8408
- this.logger.debug('Adding intrig config files to git...');
8409
8521
  const { execSync } = __webpack_require__(1);
8410
8522
  // Check if git repository exists
8411
8523
  try {
@@ -8414,7 +8526,7 @@ class InitCommand extends external_nest_commander_namespaceObject.CommandRunner
8414
8526
  stdio: 'pipe'
8415
8527
  });
8416
8528
  } catch {
8417
- this.logger.debug('No git repository found, skipping git add');
8529
+ console.log(external_chalk_default().blue('ℹ️ Info: No git repository found, skipping git add'));
8418
8530
  return;
8419
8531
  }
8420
8532
  // Add the config files to git
@@ -8422,9 +8534,9 @@ class InitCommand extends external_nest_commander_namespaceObject.CommandRunner
8422
8534
  cwd: rootDir,
8423
8535
  stdio: 'pipe'
8424
8536
  });
8425
- this.logger.debug('Successfully added intrig.config.json and .intrig/schema.json to git');
8537
+ console.log(external_chalk_default().green('Successfully added intrig.config.json and .intrig/schema.json to git'));
8426
8538
  } catch (error) {
8427
- this.logger.warn(`Failed to add config files to git: ${error?.message}`);
8539
+ console.log(external_chalk_default().yellow('⚠️ Warning: Failed to add config files to git:'), error?.message);
8428
8540
  // Don't throw - git operations are optional
8429
8541
  }
8430
8542
  }
@@ -8443,13 +8555,10 @@ class InitCommand extends external_nest_commander_namespaceObject.CommandRunner
8443
8555
  }
8444
8556
  }
8445
8557
  if (needsUpdate) {
8446
- this.logger.debug('Updating .gitignore file...');
8558
+ console.log(external_chalk_default().green('Updating .gitignore file...'));
8447
8559
  external_fs_namespaceObject.writeFileSync(gitIgnorePath, gitIgnoreContent.join('\n'), 'utf-8');
8448
8560
  }
8449
8561
  }
8450
- constructor(...args){
8451
- super(...args), this.logger = new common_namespaceObject.Logger(InitCommand.name);
8452
- }
8453
8562
  }
8454
8563
  InitCommand = init_command_ts_decorate([
8455
8564
  (0,external_nest_commander_namespaceObject.Command)({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intrig/core",
3
- "version": "0.0.15-11",
3
+ "version": "0.0.15-12",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "bin": {
@@ -31,7 +31,6 @@
31
31
  "inquirer": "12.9.3",
32
32
  "js-yaml": "4.1.0",
33
33
  "json-schema": "0.4.0",
34
- "live-plugin-manager": "1.1.0",
35
34
  "lodash": "4.17.21",
36
35
  "lowdb": "7.0.1",
37
36
  "minisearch": "7.1.2",