@steedos/service-package-loader 3.0.0-beta.14 → 3.0.0-beta.141
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/index.js +33 -13
- package/lib/triggerLoader/index.js +2 -2
- package/lib/triggerLoader/index.js.map +1 -1
- package/package.json +7 -8
package/index.js
CHANGED
|
@@ -19,7 +19,7 @@ const {
|
|
|
19
19
|
} = require('@steedos/metadata-core');
|
|
20
20
|
const sRouter = require('@steedos/router');
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
const chalk = require("chalk");
|
|
23
23
|
|
|
24
24
|
const getPackageYmlData = (packagePath)=>{
|
|
25
25
|
let packageYmlData = {};
|
|
@@ -87,8 +87,10 @@ module.exports = {
|
|
|
87
87
|
}
|
|
88
88
|
const { path: packagePath, isUnmanaged } = packageInfo;
|
|
89
89
|
if (isUnmanaged && packagePath) {
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
91
|
+
const packageJSON = require(`${packagePath}/package.json`)
|
|
90
92
|
const userSession = { spaceId: spaceId, userId: spaceDoc.owner };
|
|
91
|
-
await this.deployPackage(packagePath, userSession);
|
|
93
|
+
await this.deployPackage(packagePath, userSession, {name: packageJSON.name, version: packageJSON.version});
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
96
|
}
|
|
@@ -112,7 +114,9 @@ module.exports = {
|
|
|
112
114
|
]
|
|
113
115
|
const matchedPaths2 = metaDataCore.syncMatchFiles(filePatten2);
|
|
114
116
|
for await (const filePath of matchedPaths2) {
|
|
115
|
-
|
|
117
|
+
if(!filePath.endsWith("_base/base.object.js")){
|
|
118
|
+
this.broker.logger.warn(`The object.js file has been deprecated. ${filePath}`);
|
|
119
|
+
}
|
|
116
120
|
}
|
|
117
121
|
|
|
118
122
|
// 扫描软件包中的元数据, 如果有 .router.js 文件, 则输出警告信息
|
|
@@ -199,7 +203,7 @@ module.exports = {
|
|
|
199
203
|
}
|
|
200
204
|
},
|
|
201
205
|
async errorHandler(error) {
|
|
202
|
-
|
|
206
|
+
console.error(chalk.red(`[${this.name}] 启动失败: ${error.message}`));
|
|
203
207
|
await await this.broker.call(`@steedos/service-project.disablePackage`, {
|
|
204
208
|
module: this.schema.packageName
|
|
205
209
|
})
|
|
@@ -235,6 +239,15 @@ module.exports = {
|
|
|
235
239
|
if (true != isUnmanaged) {
|
|
236
240
|
// 受管软件包加载元数据文件,非受管软件包不加载
|
|
237
241
|
await this.loadPackageMetadataFiles(_path, this.name, datasource);
|
|
242
|
+
}else{
|
|
243
|
+
if(process.env.STEEDOS_TENANT_ENABLE_SAAS != "true"){
|
|
244
|
+
const primarySpace = await this.broker.call("objectql.getPrimarySpace");
|
|
245
|
+
if(primarySpace){
|
|
246
|
+
const packageJSON = require(`${_path}/package.json`)
|
|
247
|
+
const userSession = { spaceId: primarySpace._id, userId: primarySpace.owner };
|
|
248
|
+
await this.deployPackage(_path, userSession, {name: packageJSON.name, version: packageJSON.version});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
238
251
|
}
|
|
239
252
|
if(isPackage !== false){
|
|
240
253
|
try {
|
|
@@ -245,7 +258,7 @@ module.exports = {
|
|
|
245
258
|
_packageInfo = metaDataCore.loadJSONFile(path.join(_path, '..', 'package.json'));
|
|
246
259
|
}
|
|
247
260
|
const packageYmlData = getPackageYmlData(_path);
|
|
248
|
-
await this.broker.call(`@steedos/service-packages.online`, {serviceInfo: {packageYmlData: packageYmlData, name: this.name, nodeID: this.broker.nodeID, instanceID: this.broker.instanceID, path: _path, version: _packageInfo.version, description: _packageInfo.description}})
|
|
261
|
+
await this.broker.call(`@steedos/service-packages.online`, {serviceInfo: {isUnmanaged: isUnmanaged, packageYmlData: packageYmlData, name: this.name, nodeID: this.broker.nodeID, instanceID: this.broker.instanceID, path: _path, version: _packageInfo.version, description: _packageInfo.description}})
|
|
249
262
|
} catch (error) {
|
|
250
263
|
console.log(`error`, error)
|
|
251
264
|
}
|
|
@@ -257,12 +270,12 @@ module.exports = {
|
|
|
257
270
|
this.started = true;
|
|
258
271
|
const endTime = moment();
|
|
259
272
|
const serviceName = this.name.length < 50 ? `${_.padEnd(this.name, 50, ' ')}` : this.name
|
|
260
|
-
|
|
273
|
+
console.log(chalk.green(`service ${serviceName} started: ${endTime.diff(startTime, 'seconds', true)}s`));
|
|
261
274
|
if(this.afterStart){
|
|
262
275
|
try {
|
|
263
276
|
await this.afterStart();
|
|
264
277
|
} catch (error) {
|
|
265
|
-
|
|
278
|
+
console.error(chalk.error(`[${this.name}]: ${error.message}`));
|
|
266
279
|
}
|
|
267
280
|
}
|
|
268
281
|
},
|
|
@@ -295,14 +308,18 @@ module.exports = {
|
|
|
295
308
|
await datasource.init();
|
|
296
309
|
}
|
|
297
310
|
},
|
|
298
|
-
async deployPackage(sourcePath, userSession){
|
|
311
|
+
async deployPackage(sourcePath, userSession, packageInfo){
|
|
299
312
|
try {
|
|
300
313
|
var tempDir = mkTempFolder('deploy-');
|
|
301
314
|
var option = { includeJs: false, tableTitle: 'Steedos Deploy', showLog: true, inDeploy: true };
|
|
302
|
-
|
|
315
|
+
const dbPackage = await await this.getObject('steedos_packages').directFind({filters: ['name', '=', packageInfo.name]});
|
|
316
|
+
if(dbPackage.length > 0){
|
|
317
|
+
return ;
|
|
318
|
+
}
|
|
303
319
|
compressFiles(sourcePath, sourcePath, tempDir, option, async (base64, zipDir) => {
|
|
304
|
-
const result = await this.broker.call('
|
|
320
|
+
const result = await this.broker.call('@steedos/metadata-api.deploy', {
|
|
305
321
|
fileBase64: base64,
|
|
322
|
+
packageInfo
|
|
306
323
|
}, {
|
|
307
324
|
timeout: 0,
|
|
308
325
|
meta: {
|
|
@@ -341,7 +358,7 @@ module.exports = {
|
|
|
341
358
|
merged(schema) {
|
|
342
359
|
schema.packageName = schema.name;
|
|
343
360
|
if(!schema.metadata || !schema.metadata.$package){
|
|
344
|
-
schema.name =
|
|
361
|
+
schema.name = `${schema.name}`;
|
|
345
362
|
}
|
|
346
363
|
|
|
347
364
|
schema.settings.packageInfo = {
|
|
@@ -362,9 +379,12 @@ module.exports = {
|
|
|
362
379
|
* Service started lifecycle event handler
|
|
363
380
|
*/
|
|
364
381
|
async started() {
|
|
365
|
-
|
|
382
|
+
const packageInfo = this.settings.packageInfo;
|
|
383
|
+
const isUnmanaged = packageInfo?.isUnmanaged || false;
|
|
384
|
+
|
|
385
|
+
await this.broker.call(`@steedos/service-packages.starting`, {serviceInfo: {name: this.name, nodeID: this.broker.nodeID, instanceID: this.broker.instanceID, isUnmanaged}})
|
|
366
386
|
await this.onStarted();
|
|
367
|
-
await this.broker.call(`@steedos/service-packages.started`, {serviceInfo: {name: this.name, nodeID: this.broker.nodeID, instanceID: this.broker.instanceID}})
|
|
387
|
+
await this.broker.call(`@steedos/service-packages.started`, {serviceInfo: {name: this.name, nodeID: this.broker.nodeID, instanceID: this.broker.instanceID, isUnmanaged}})
|
|
368
388
|
},
|
|
369
389
|
|
|
370
390
|
/**
|
|
@@ -13,8 +13,8 @@ function load(broker, packagePath, packageServiceName) {
|
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
15
|
for (const trigger of objTriggers) {
|
|
16
|
-
broker.emit(
|
|
17
|
-
objectName: trigger[
|
|
16
|
+
broker.emit("trigger.loaded", {
|
|
17
|
+
objectName: trigger["listenTo"],
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/triggerLoader/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/triggerLoader/index.ts"],"names":[],"mappings":";;AAuBA,oBAuDC;;AAvED,gCAAgC;AAChC,6BAA6B;AAE7B,oEAAiE;AAajE,SAAsB,IAAI,CACxB,MAAW,EACX,WAAmB,EACnB,kBAA0B;;QAI1B,IAAI,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QAC5C,IAAI,WAAW,GAAG,IAAA,uCAAkB,EAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;QACnE,IAAI,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;YAC3B,OAAO;QACT,CAAC;QAeD,KAAK,MAAM,OAAO,IAAI,WAAW,EAAE,CAAC;YAgBlC,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE;gBAC5B,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC;aAChC,CAAC,CAAC;QACL,CAAC;IAUH,CAAC;CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/service-package-loader",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.141",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
"author": "",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@steedos/metadata-core": "3.0.0-beta.
|
|
14
|
-
"@steedos/metadata-registrar": "3.0.0-beta.
|
|
15
|
-
"@steedos/router": "3.0.0-beta.
|
|
16
|
-
"@steedos/service-object-mixin": "3.0.0-beta.
|
|
13
|
+
"@steedos/metadata-core": "3.0.0-beta.141",
|
|
14
|
+
"@steedos/metadata-registrar": "3.0.0-beta.141",
|
|
15
|
+
"@steedos/router": "3.0.0-beta.141",
|
|
16
|
+
"@steedos/service-object-mixin": "3.0.0-beta.141",
|
|
17
17
|
"clone": "^2.1.2",
|
|
18
18
|
"csvtojson": "~2.0.10",
|
|
19
|
-
"moleculer": "^0.14.
|
|
19
|
+
"moleculer": "^0.14.35",
|
|
20
20
|
"moment": "^2.24.0",
|
|
21
21
|
"node-xlsx": "^0.16.1",
|
|
22
22
|
"underscore": "^1.12.0"
|
|
@@ -24,9 +24,8 @@
|
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"typescript": "5.7.3"
|
|
26
26
|
},
|
|
27
|
-
"private": false,
|
|
28
27
|
"publishConfig": {
|
|
29
28
|
"access": "public"
|
|
30
29
|
},
|
|
31
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "f448582d11cedf0fd7bd9767c6e57da5414f7530"
|
|
32
31
|
}
|