@intrig/core 0.0.15-11 → 0.0.15-13
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/main.js +347 -194
- package/package.json +2 -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3995
|
+
this.logger.debug(`Plugin is file-based: ${isFileDependency}`);
|
|
3943
3996
|
try {
|
|
3944
|
-
//
|
|
3945
|
-
const
|
|
3946
|
-
|
|
3947
|
-
|
|
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
|
-
|
|
3953
|
-
//
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
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}"
|
|
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
|
|
6146
|
-
this.logger.debug(`Resolved spec title: ${title}, server
|
|
6147
|
-
return
|
|
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:
|
|
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", [
|
|
@@ -7631,36 +7716,6 @@ DataSearchController = data_search_controller_ts_decorate([
|
|
|
7631
7716
|
])
|
|
7632
7717
|
], DataSearchController);
|
|
7633
7718
|
|
|
7634
|
-
;// ./src/app/plugins/plugin.module.ts
|
|
7635
|
-
function plugin_module_ts_decorate(decorators, target, key, desc) {
|
|
7636
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7637
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
7638
|
-
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;
|
|
7639
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7640
|
-
}
|
|
7641
|
-
|
|
7642
|
-
|
|
7643
|
-
// Token for dependency injection - keeping for backward compatibility
|
|
7644
|
-
const INTRIG_PLUGIN = Symbol('INTRIG_PLUGIN');
|
|
7645
|
-
const INTRIG_PLUGIN_NAME = Symbol('INTRIG_PLUGIN_NAME');
|
|
7646
|
-
class PluginModule {
|
|
7647
|
-
static forRootAsync() {
|
|
7648
|
-
return {
|
|
7649
|
-
module: PluginModule,
|
|
7650
|
-
providers: [
|
|
7651
|
-
LazyPluginService
|
|
7652
|
-
],
|
|
7653
|
-
exports: [
|
|
7654
|
-
LazyPluginService
|
|
7655
|
-
],
|
|
7656
|
-
global: true
|
|
7657
|
-
};
|
|
7658
|
-
}
|
|
7659
|
-
}
|
|
7660
|
-
PluginModule = plugin_module_ts_decorate([
|
|
7661
|
-
(0,common_namespaceObject.Module)({})
|
|
7662
|
-
], PluginModule);
|
|
7663
|
-
|
|
7664
7719
|
;// ./src/app/daemon/daemon.module.ts
|
|
7665
7720
|
function daemon_module_ts_decorate(decorators, target, key, desc) {
|
|
7666
7721
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -7682,7 +7737,6 @@ function daemon_module_ts_decorate(decorators, target, key, desc) {
|
|
|
7682
7737
|
|
|
7683
7738
|
|
|
7684
7739
|
|
|
7685
|
-
|
|
7686
7740
|
class DaemonModule {
|
|
7687
7741
|
}
|
|
7688
7742
|
DaemonModule = daemon_module_ts_decorate([
|
|
@@ -7690,8 +7744,7 @@ DaemonModule = daemon_module_ts_decorate([
|
|
|
7690
7744
|
imports: [
|
|
7691
7745
|
CommonModule,
|
|
7692
7746
|
OpenapiSourceModule,
|
|
7693
|
-
axios_namespaceObject.HttpModule
|
|
7694
|
-
PluginModule
|
|
7747
|
+
axios_namespaceObject.HttpModule
|
|
7695
7748
|
],
|
|
7696
7749
|
controllers: [
|
|
7697
7750
|
SourcesController,
|
|
@@ -7708,11 +7761,42 @@ DaemonModule = daemon_module_ts_decorate([
|
|
|
7708
7761
|
LazyCodeAnalyzerService
|
|
7709
7762
|
],
|
|
7710
7763
|
exports: [
|
|
7711
|
-
OperationsService
|
|
7764
|
+
OperationsService,
|
|
7765
|
+
IntrigConfigService
|
|
7712
7766
|
]
|
|
7713
7767
|
})
|
|
7714
7768
|
], DaemonModule);
|
|
7715
7769
|
|
|
7770
|
+
;// ./src/app/plugins/plugin.module.ts
|
|
7771
|
+
function plugin_module_ts_decorate(decorators, target, key, desc) {
|
|
7772
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7773
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
7774
|
+
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;
|
|
7775
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7776
|
+
}
|
|
7777
|
+
|
|
7778
|
+
|
|
7779
|
+
// Token for dependency injection - keeping for backward compatibility
|
|
7780
|
+
const INTRIG_PLUGIN = Symbol('INTRIG_PLUGIN');
|
|
7781
|
+
const INTRIG_PLUGIN_NAME = Symbol('INTRIG_PLUGIN_NAME');
|
|
7782
|
+
class PluginModule {
|
|
7783
|
+
static forRootAsync() {
|
|
7784
|
+
return {
|
|
7785
|
+
module: PluginModule,
|
|
7786
|
+
providers: [
|
|
7787
|
+
LazyPluginService
|
|
7788
|
+
],
|
|
7789
|
+
exports: [
|
|
7790
|
+
LazyPluginService
|
|
7791
|
+
],
|
|
7792
|
+
global: true
|
|
7793
|
+
};
|
|
7794
|
+
}
|
|
7795
|
+
}
|
|
7796
|
+
PluginModule = plugin_module_ts_decorate([
|
|
7797
|
+
(0,common_namespaceObject.Module)({})
|
|
7798
|
+
], PluginModule);
|
|
7799
|
+
|
|
7716
7800
|
;// ./src/app/cli/cli.module.ts
|
|
7717
7801
|
function cli_module_ts_decorate(decorators, target, key, desc) {
|
|
7718
7802
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -7736,6 +7820,7 @@ function cli_module_ts_decorate(decorators, target, key, desc) {
|
|
|
7736
7820
|
|
|
7737
7821
|
|
|
7738
7822
|
|
|
7823
|
+
|
|
7739
7824
|
class CliModule {
|
|
7740
7825
|
}
|
|
7741
7826
|
CliModule = cli_module_ts_decorate([
|
|
@@ -7749,6 +7834,7 @@ CliModule = cli_module_ts_decorate([
|
|
|
7749
7834
|
],
|
|
7750
7835
|
providers: [
|
|
7751
7836
|
ProcessManagerService,
|
|
7837
|
+
IntrigConfigService,
|
|
7752
7838
|
...DaemonCommand.registerWithSubCommands(),
|
|
7753
7839
|
GenerateCommand,
|
|
7754
7840
|
...SourcesCommand.registerWithSubCommands(),
|
|
@@ -8077,6 +8163,55 @@ McpModule = mcp_module_ts_decorate([
|
|
|
8077
8163
|
|
|
8078
8164
|
;// external "semver"
|
|
8079
8165
|
const external_semver_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("semver");
|
|
8166
|
+
;// external "schinquirer"
|
|
8167
|
+
const external_schinquirer_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("schinquirer");
|
|
8168
|
+
;// external "@intrig/plugin-sdk"
|
|
8169
|
+
const plugin_sdk_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("@intrig/plugin-sdk");
|
|
8170
|
+
;// ./src/app/init-cli/templates/schema.template.ts
|
|
8171
|
+
|
|
8172
|
+
|
|
8173
|
+
function schemaTemplate(pluginInstance) {
|
|
8174
|
+
const json = (0,plugin_sdk_namespaceObject.jsonLiteral)(external_path_namespaceObject.resolve('.intrig', 'schema.json'));
|
|
8175
|
+
return json`
|
|
8176
|
+
{
|
|
8177
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
8178
|
+
"type": "object",
|
|
8179
|
+
"properties": {
|
|
8180
|
+
"$schema": "./.intrig/schema.json",
|
|
8181
|
+
"sources": {
|
|
8182
|
+
"type": "array",
|
|
8183
|
+
"items": {
|
|
8184
|
+
"type": "object",
|
|
8185
|
+
"properties": {
|
|
8186
|
+
"id": { "type": "string" },
|
|
8187
|
+
"name": { "type": "string" },
|
|
8188
|
+
"specUrl": { "type": "string", "format": "uri" }
|
|
8189
|
+
},
|
|
8190
|
+
"required": ["id", "name", "specUrl"],
|
|
8191
|
+
"additionalProperties": false
|
|
8192
|
+
},
|
|
8193
|
+
"minItems": 1
|
|
8194
|
+
},
|
|
8195
|
+
"generator": {
|
|
8196
|
+
"type": "string",
|
|
8197
|
+
"enum": ["react", "vue", "angular", "svelte"]
|
|
8198
|
+
},
|
|
8199
|
+
"codeAnalyzer": {
|
|
8200
|
+
"type": "object",
|
|
8201
|
+
"properties": {
|
|
8202
|
+
"tsConfigPath": { "type": "string" }
|
|
8203
|
+
},
|
|
8204
|
+
"required": ["tsConfigPath"],
|
|
8205
|
+
"additionalProperties": false
|
|
8206
|
+
},
|
|
8207
|
+
"generatorOptions": ${pluginInstance && pluginInstance.$generatorSchema ? JSON.stringify(pluginInstance.$generatorSchema, null, 6) : '{ "type": "object" }'}
|
|
8208
|
+
},
|
|
8209
|
+
"required": ["sources", "generator"],
|
|
8210
|
+
"additionalProperties": false
|
|
8211
|
+
}
|
|
8212
|
+
`;
|
|
8213
|
+
}
|
|
8214
|
+
|
|
8080
8215
|
;// ./src/app/init-cli/commands/init.command.ts
|
|
8081
8216
|
function init_command_ts_decorate(decorators, target, key, desc) {
|
|
8082
8217
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -8092,24 +8227,38 @@ function init_command_ts_decorate(decorators, target, key, desc) {
|
|
|
8092
8227
|
|
|
8093
8228
|
|
|
8094
8229
|
|
|
8230
|
+
|
|
8231
|
+
|
|
8095
8232
|
class InitCommand extends external_nest_commander_namespaceObject.CommandRunner {
|
|
8096
8233
|
async run(passedParams, options) {
|
|
8097
|
-
|
|
8234
|
+
console.log(external_chalk_default().blue('🚀 Initializing Intrig setup...'));
|
|
8098
8235
|
const rootDir = process.cwd();
|
|
8099
8236
|
try {
|
|
8100
8237
|
// Read package.json to determine project type
|
|
8101
8238
|
const packageJsonPath = external_path_namespaceObject.resolve(rootDir, 'package.json');
|
|
8102
8239
|
if (!external_fs_namespaceObject.existsSync(packageJsonPath)) {
|
|
8103
|
-
|
|
8240
|
+
console.log(external_chalk_default().red('❌ package.json not found in current directory'));
|
|
8104
8241
|
throw new Error('package.json not found');
|
|
8105
8242
|
}
|
|
8106
8243
|
const packageJson = external_fs_extra_namespaceObject.readJsonSync(packageJsonPath);
|
|
8107
|
-
//
|
|
8108
|
-
const
|
|
8109
|
-
|
|
8110
|
-
|
|
8244
|
+
// Check for existing plugin dependency matching the plugin regex format
|
|
8245
|
+
const existingPlugin = this.checkForExistingPlugin(packageJson);
|
|
8246
|
+
let selectedPlugin;
|
|
8247
|
+
if (existingPlugin) {
|
|
8248
|
+
console.log(external_chalk_default().green(`✅ Found existing plugin dependency: ${existingPlugin.name}`));
|
|
8249
|
+
selectedPlugin = existingPlugin;
|
|
8250
|
+
} else {
|
|
8251
|
+
// Fetch approved plugins from GitHub
|
|
8252
|
+
const approvedPlugins = await this.fetchApprovedPlugins();
|
|
8253
|
+
// Prompt user to select plugin (show all plugins with best match as default)
|
|
8254
|
+
selectedPlugin = await this.promptUserForPlugin(approvedPlugins, packageJson);
|
|
8255
|
+
}
|
|
8111
8256
|
// Load and initialize the selected plugin
|
|
8112
8257
|
const pluginInstance = await this.loadAndInitializePlugin(selectedPlugin);
|
|
8258
|
+
// Check if plugin loading failed
|
|
8259
|
+
if (!pluginInstance) {
|
|
8260
|
+
throw new Error(`Failed to load and initialize plugin ${selectedPlugin.name}. Please check the plugin installation and try again.`);
|
|
8261
|
+
}
|
|
8113
8262
|
// Create .intrig directory if it doesn't exist
|
|
8114
8263
|
const intrigDir = external_path_namespaceObject.resolve(rootDir, '.intrig');
|
|
8115
8264
|
if (!external_fs_namespaceObject.existsSync(intrigDir)) {
|
|
@@ -8117,108 +8266,84 @@ class InitCommand extends external_nest_commander_namespaceObject.CommandRunner
|
|
|
8117
8266
|
recursive: true
|
|
8118
8267
|
});
|
|
8119
8268
|
}
|
|
8120
|
-
//
|
|
8121
|
-
const
|
|
8122
|
-
|
|
8123
|
-
|
|
8124
|
-
|
|
8125
|
-
|
|
8126
|
-
|
|
8127
|
-
|
|
8128
|
-
|
|
8129
|
-
|
|
8130
|
-
|
|
8131
|
-
|
|
8132
|
-
|
|
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
|
|
8269
|
+
// Write schema file using template
|
|
8270
|
+
const spinner = external_ora_default()('Writing configuration files...').start();
|
|
8271
|
+
// Create dump function for schema writing
|
|
8272
|
+
const dumpSchema = async (content)=>{
|
|
8273
|
+
const resolved = await content;
|
|
8274
|
+
const fullPath = external_path_namespaceObject.resolve(rootDir, resolved.path);
|
|
8275
|
+
const dir = external_path_namespaceObject.dirname(fullPath);
|
|
8276
|
+
if (!external_fs_namespaceObject.existsSync(dir)) {
|
|
8277
|
+
external_fs_namespaceObject.mkdirSync(dir, {
|
|
8278
|
+
recursive: true
|
|
8279
|
+
});
|
|
8280
|
+
}
|
|
8281
|
+
external_fs_namespaceObject.writeFileSync(fullPath, resolved.content, 'utf-8');
|
|
8181
8282
|
};
|
|
8182
|
-
//
|
|
8183
|
-
|
|
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');
|
|
8283
|
+
// Use template to create schema
|
|
8284
|
+
await dumpSchema(schemaTemplate(pluginInstance));
|
|
8190
8285
|
// Create intrig config
|
|
8191
8286
|
const config = {
|
|
8192
8287
|
$schema: './.intrig/schema.json',
|
|
8193
8288
|
sources: [],
|
|
8194
|
-
generator:
|
|
8289
|
+
generator: pluginInstance.meta().generator
|
|
8195
8290
|
};
|
|
8196
8291
|
// Write config file
|
|
8197
8292
|
const configPath = external_path_namespaceObject.resolve(rootDir, 'intrig.config.json');
|
|
8198
|
-
this.logger.debug('Writing config file...');
|
|
8199
8293
|
external_fs_namespaceObject.writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf-8');
|
|
8200
8294
|
// Add config file to git
|
|
8201
8295
|
this.addConfigToGit(rootDir);
|
|
8202
8296
|
// Update .gitignore
|
|
8203
8297
|
this.updateGitIgnore(rootDir);
|
|
8204
|
-
|
|
8298
|
+
spinner.succeed('Configuration files created successfully');
|
|
8299
|
+
console.log(external_chalk_default().green('✅ Intrig initialization completed successfully'));
|
|
8205
8300
|
} catch (error) {
|
|
8206
|
-
|
|
8301
|
+
console.log(external_chalk_default().red('❌ Failed to initialize Intrig:'), error?.message);
|
|
8207
8302
|
throw error;
|
|
8208
8303
|
}
|
|
8209
8304
|
}
|
|
8305
|
+
checkForExistingPlugin(packageJson) {
|
|
8306
|
+
const allDeps = {
|
|
8307
|
+
...packageJson?.dependencies ?? {},
|
|
8308
|
+
...packageJson?.devDependencies ?? {},
|
|
8309
|
+
...packageJson?.peerDependencies ?? {},
|
|
8310
|
+
...packageJson?.optionalDependencies ?? {}
|
|
8311
|
+
};
|
|
8312
|
+
const pluginPatterns = [
|
|
8313
|
+
/^@intrig\/plugin-.+/,
|
|
8314
|
+
/^@[^/]+\/intrig-plugin-.+/,
|
|
8315
|
+
/^intrig-plugin-.+/
|
|
8316
|
+
];
|
|
8317
|
+
const matchedPlugins = Object.keys(allDeps).filter((name)=>pluginPatterns.some((pattern)=>pattern.test(name)));
|
|
8318
|
+
if (matchedPlugins.length > 0) {
|
|
8319
|
+
const pluginName = matchedPlugins[0];
|
|
8320
|
+
return {
|
|
8321
|
+
type: 'generator',
|
|
8322
|
+
generator: 'custom',
|
|
8323
|
+
name: pluginName,
|
|
8324
|
+
compat: {
|
|
8325
|
+
latest: {
|
|
8326
|
+
dependencies: {}
|
|
8327
|
+
}
|
|
8328
|
+
}
|
|
8329
|
+
};
|
|
8330
|
+
}
|
|
8331
|
+
return null;
|
|
8332
|
+
}
|
|
8210
8333
|
async fetchApprovedPlugins() {
|
|
8211
|
-
|
|
8212
|
-
const url = 'https://raw.githubusercontent.com/intrigsoft/intrig-
|
|
8334
|
+
const spinner = external_ora_default()('Fetching approved plugins from registry...').start();
|
|
8335
|
+
const url = 'https://raw.githubusercontent.com/intrigsoft/intrig-registry/refs/heads/main/registry.json';
|
|
8213
8336
|
try {
|
|
8214
8337
|
const response = await fetch(url);
|
|
8215
8338
|
if (!response.ok) {
|
|
8216
8339
|
throw new Error(`Failed to fetch approved plugins: ${response.statusText}`);
|
|
8217
8340
|
}
|
|
8218
8341
|
const plugins = await response.json();
|
|
8342
|
+
spinner.succeed('Successfully fetched approved plugins');
|
|
8219
8343
|
return plugins;
|
|
8220
8344
|
} catch (error) {
|
|
8221
|
-
|
|
8345
|
+
spinner.fail('Failed to fetch approved plugins');
|
|
8346
|
+
console.log(external_chalk_default().red('❌ Error:'), error?.message);
|
|
8222
8347
|
throw error;
|
|
8223
8348
|
}
|
|
8224
8349
|
}
|
|
@@ -8238,7 +8363,7 @@ class InitCommand extends external_nest_commander_namespaceObject.CommandRunner
|
|
|
8238
8363
|
return external_semver_namespaceObject.satisfies(cleanProjectVersion.version, normalizedRequiredVersion);
|
|
8239
8364
|
} catch (error) {
|
|
8240
8365
|
// If semver parsing fails, fall back to string comparison
|
|
8241
|
-
|
|
8366
|
+
console.log(external_chalk_default().yellow('⚠️ Warning: Failed to parse version:'), `${projectVersion} vs ${requiredVersion}`);
|
|
8242
8367
|
return projectVersion === requiredVersion;
|
|
8243
8368
|
}
|
|
8244
8369
|
}
|
|
@@ -8316,41 +8441,36 @@ class InitCommand extends external_nest_commander_namespaceObject.CommandRunner
|
|
|
8316
8441
|
return selectedPlugin;
|
|
8317
8442
|
}
|
|
8318
8443
|
async loadAndInitializePlugin(plugin) {
|
|
8319
|
-
|
|
8444
|
+
const installSpinner = external_ora_default()(`Installing plugin: ${plugin.name}`).start();
|
|
8320
8445
|
try {
|
|
8321
8446
|
const rootDir = process.cwd();
|
|
8322
8447
|
// First, install the plugin in the project directory using npm
|
|
8323
|
-
this.logger.debug(`Installing ${plugin.name} using npm...`);
|
|
8324
8448
|
const { execSync } = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 1, 23));
|
|
8325
8449
|
try {
|
|
8326
8450
|
// Use npm to install the plugin in the project directory as dev dependency
|
|
8327
8451
|
execSync(`npm install --save-dev ${plugin.name}`, {
|
|
8328
8452
|
cwd: rootDir,
|
|
8329
|
-
stdio: '
|
|
8453
|
+
stdio: 'pipe'
|
|
8330
8454
|
});
|
|
8331
|
-
|
|
8455
|
+
installSpinner.text = `Installing @intrig/core as dev dependency...`;
|
|
8332
8456
|
// Install @intrig/core as a dev dependency
|
|
8333
|
-
this.logger.debug('Installing @intrig/core as dev dependency...');
|
|
8334
8457
|
execSync('npm install --save-dev @intrig/core', {
|
|
8335
8458
|
cwd: rootDir,
|
|
8336
|
-
stdio: '
|
|
8459
|
+
stdio: 'pipe'
|
|
8337
8460
|
});
|
|
8338
|
-
|
|
8461
|
+
installSpinner.succeed(`Plugin ${plugin.name} and @intrig/core installed successfully`);
|
|
8339
8462
|
} catch (npmError) {
|
|
8340
|
-
|
|
8463
|
+
installSpinner.fail(`Failed to install plugin ${plugin.name}`);
|
|
8464
|
+
console.log(external_chalk_default().red('❌ Error:'), npmError?.message);
|
|
8341
8465
|
throw new Error(`Failed to install plugin ${plugin.name}: ${npmError?.message}`);
|
|
8342
8466
|
}
|
|
8343
|
-
// Now use
|
|
8467
|
+
// Now use createRequire to load the plugin
|
|
8468
|
+
const loadSpinner = external_ora_default()(`Loading and initializing plugin: ${plugin.name}`).start();
|
|
8344
8469
|
try {
|
|
8345
|
-
|
|
8346
|
-
|
|
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
|
-
});
|
|
8470
|
+
const { createRequire: nodeCreateRequire } = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 2, 23));
|
|
8471
|
+
const projectRequire = nodeCreateRequire(external_path_namespaceObject.resolve(rootDir, 'package.json'));
|
|
8352
8472
|
// Try to require the plugin (it should be installed by npm already)
|
|
8353
|
-
const pluginModule =
|
|
8473
|
+
const pluginModule = projectRequire(plugin.name);
|
|
8354
8474
|
// Extract the factory function from the module
|
|
8355
8475
|
const factory = this.extractFactory(pluginModule, plugin.name);
|
|
8356
8476
|
// Create the plugin instance
|
|
@@ -8359,11 +8479,17 @@ class InitCommand extends external_nest_commander_namespaceObject.CommandRunner
|
|
|
8359
8479
|
if (!pluginInstance || typeof pluginInstance.meta !== 'function' || typeof pluginInstance.generate !== 'function') {
|
|
8360
8480
|
throw new Error(`Plugin factory from "${plugin.name}" did not return a valid Intrig plugin instance.`);
|
|
8361
8481
|
}
|
|
8482
|
+
// Collect generatorSchema information if plugin has one
|
|
8483
|
+
let generatorOptions = {};
|
|
8484
|
+
if (pluginInstance.$generatorSchema) {
|
|
8485
|
+
loadSpinner.text = 'Collecting generator configuration...';
|
|
8486
|
+
generatorOptions = await this.collectGeneratorOptions(pluginInstance.$generatorSchema, plugin.name);
|
|
8487
|
+
}
|
|
8362
8488
|
// Call init function if it exists on the plugin instance
|
|
8363
8489
|
if (typeof pluginInstance.init === 'function') {
|
|
8364
|
-
|
|
8490
|
+
loadSpinner.text = 'Calling plugin init function...';
|
|
8365
8491
|
await pluginInstance.init({
|
|
8366
|
-
options:
|
|
8492
|
+
options: generatorOptions,
|
|
8367
8493
|
rootDir: rootDir,
|
|
8368
8494
|
buildDir: external_path_namespaceObject.resolve(rootDir, '.intrig', 'generated'),
|
|
8369
8495
|
dump: async (content)=>{
|
|
@@ -8379,16 +8505,21 @@ class InitCommand extends external_nest_commander_namespaceObject.CommandRunner
|
|
|
8379
8505
|
}
|
|
8380
8506
|
});
|
|
8381
8507
|
}
|
|
8382
|
-
|
|
8508
|
+
// Save generator options to intrig.config.json
|
|
8509
|
+
if (Object.keys(generatorOptions).length > 0) {
|
|
8510
|
+
await this.saveGeneratorOptions(generatorOptions);
|
|
8511
|
+
}
|
|
8512
|
+
loadSpinner.succeed(`Plugin ${plugin.name} loaded and initialized successfully`);
|
|
8383
8513
|
return pluginInstance;
|
|
8384
8514
|
} catch (loadError) {
|
|
8385
|
-
|
|
8515
|
+
loadSpinner.warn(`Plugin ${plugin.name} was installed but could not be loaded/initialized`);
|
|
8516
|
+
console.log(external_chalk_default().yellow('⚠️ Warning:'), loadError?.message);
|
|
8386
8517
|
// Don't throw here - the plugin is installed which is the main requirement
|
|
8387
|
-
|
|
8518
|
+
console.log(external_chalk_default().blue('ℹ️ Info: Plugin installation completed (initialization skipped due to loading issues)'));
|
|
8388
8519
|
return null;
|
|
8389
8520
|
}
|
|
8390
8521
|
} catch (error) {
|
|
8391
|
-
|
|
8522
|
+
console.log(external_chalk_default().red('❌ Failed to install plugin'), `${plugin.name}:`, error?.message);
|
|
8392
8523
|
throw error;
|
|
8393
8524
|
}
|
|
8394
8525
|
}
|
|
@@ -8403,9 +8534,34 @@ class InitCommand extends external_nest_commander_namespaceObject.CommandRunner
|
|
|
8403
8534
|
throw new Error(`Plugin "${pluginName}" does not export a factory function. ` + `Expected "createPlugin()" or a default function export. ` + `Available exports: ${Object.keys(mod || {}).join(', ')}`);
|
|
8404
8535
|
}
|
|
8405
8536
|
}
|
|
8537
|
+
async collectGeneratorOptions(generatorSchema, pluginName) {
|
|
8538
|
+
const options = {};
|
|
8539
|
+
if (!generatorSchema.properties) {
|
|
8540
|
+
return options;
|
|
8541
|
+
}
|
|
8542
|
+
// Use schinquirer to generate questions from schema
|
|
8543
|
+
if (generatorSchema.properties && Object.keys(generatorSchema.properties).length > 0) {
|
|
8544
|
+
const schemaInquirer = (0,external_schinquirer_namespaceObject.createInquirer)(generatorSchema);
|
|
8545
|
+
const answers = await schemaInquirer.prompt();
|
|
8546
|
+
Object.assign(options, answers);
|
|
8547
|
+
}
|
|
8548
|
+
return options;
|
|
8549
|
+
}
|
|
8550
|
+
async saveGeneratorOptions(generatorOptions) {
|
|
8551
|
+
const configPath = external_path_namespaceObject.resolve(process.cwd(), 'intrig.config.json');
|
|
8552
|
+
let config = {};
|
|
8553
|
+
if (external_fs_namespaceObject.existsSync(configPath)) {
|
|
8554
|
+
const configContent = external_fs_namespaceObject.readFileSync(configPath, 'utf-8');
|
|
8555
|
+
config = JSON.parse(configContent);
|
|
8556
|
+
}
|
|
8557
|
+
config.generatorOptions = {
|
|
8558
|
+
...config.generatorOptions,
|
|
8559
|
+
...generatorOptions
|
|
8560
|
+
};
|
|
8561
|
+
external_fs_namespaceObject.writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf-8');
|
|
8562
|
+
}
|
|
8406
8563
|
addConfigToGit(rootDir) {
|
|
8407
8564
|
try {
|
|
8408
|
-
this.logger.debug('Adding intrig config files to git...');
|
|
8409
8565
|
const { execSync } = __webpack_require__(1);
|
|
8410
8566
|
// Check if git repository exists
|
|
8411
8567
|
try {
|
|
@@ -8414,7 +8570,7 @@ class InitCommand extends external_nest_commander_namespaceObject.CommandRunner
|
|
|
8414
8570
|
stdio: 'pipe'
|
|
8415
8571
|
});
|
|
8416
8572
|
} catch {
|
|
8417
|
-
|
|
8573
|
+
console.log(external_chalk_default().blue('ℹ️ Info: No git repository found, skipping git add'));
|
|
8418
8574
|
return;
|
|
8419
8575
|
}
|
|
8420
8576
|
// Add the config files to git
|
|
@@ -8422,9 +8578,9 @@ class InitCommand extends external_nest_commander_namespaceObject.CommandRunner
|
|
|
8422
8578
|
cwd: rootDir,
|
|
8423
8579
|
stdio: 'pipe'
|
|
8424
8580
|
});
|
|
8425
|
-
|
|
8581
|
+
console.log(external_chalk_default().green('✅ Successfully added intrig.config.json and .intrig/schema.json to git'));
|
|
8426
8582
|
} catch (error) {
|
|
8427
|
-
|
|
8583
|
+
console.log(external_chalk_default().yellow('⚠️ Warning: Failed to add config files to git:'), error?.message);
|
|
8428
8584
|
// Don't throw - git operations are optional
|
|
8429
8585
|
}
|
|
8430
8586
|
}
|
|
@@ -8443,13 +8599,10 @@ class InitCommand extends external_nest_commander_namespaceObject.CommandRunner
|
|
|
8443
8599
|
}
|
|
8444
8600
|
}
|
|
8445
8601
|
if (needsUpdate) {
|
|
8446
|
-
|
|
8602
|
+
console.log(external_chalk_default().green('✅ Updating .gitignore file...'));
|
|
8447
8603
|
external_fs_namespaceObject.writeFileSync(gitIgnorePath, gitIgnoreContent.join('\n'), 'utf-8');
|
|
8448
8604
|
}
|
|
8449
8605
|
}
|
|
8450
|
-
constructor(...args){
|
|
8451
|
-
super(...args), this.logger = new common_namespaceObject.Logger(InitCommand.name);
|
|
8452
|
-
}
|
|
8453
8606
|
}
|
|
8454
8607
|
InitCommand = init_command_ts_decorate([
|
|
8455
8608
|
(0,external_nest_commander_namespaceObject.Command)({
|
|
@@ -8516,14 +8669,14 @@ AppModule = app_module_ts_decorate([
|
|
|
8516
8669
|
]
|
|
8517
8670
|
}),
|
|
8518
8671
|
CommonModule,
|
|
8672
|
+
PluginModule.forRootAsync(),
|
|
8519
8673
|
CliModule,
|
|
8520
8674
|
DiscoveryModule,
|
|
8521
8675
|
DaemonModule,
|
|
8522
8676
|
InitModule,
|
|
8523
8677
|
...process?.argv?.[2] === 'mcp' || process?.env?.MCP_ENABLED === '1' ? [
|
|
8524
8678
|
McpModule
|
|
8525
|
-
] : []
|
|
8526
|
-
PluginModule.forRootAsync()
|
|
8679
|
+
] : []
|
|
8527
8680
|
],
|
|
8528
8681
|
controllers: [],
|
|
8529
8682
|
providers: []
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intrig/core",
|
|
3
|
-
"version": "0.0.15-
|
|
3
|
+
"version": "0.0.15-13",
|
|
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",
|
|
@@ -44,6 +43,7 @@
|
|
|
44
43
|
"proper-lockfile": "4.1.2",
|
|
45
44
|
"reflect-metadata": "0.1.14",
|
|
46
45
|
"rxjs": "7.8.2",
|
|
46
|
+
"schinquirer": "0.3.2",
|
|
47
47
|
"semver": "6.3.1",
|
|
48
48
|
"tcp-port-used": "1.0.2",
|
|
49
49
|
"ts-morph": "26.0.0",
|