@steedos/service-package-loader 3.0.0-beta.7 → 3.0.0-beta.71
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 +25 -9
- package/package.json +6 -6
package/index.js
CHANGED
|
@@ -19,8 +19,6 @@ const {
|
|
|
19
19
|
} = require('@steedos/metadata-core');
|
|
20
20
|
const sRouter = require('@steedos/router');
|
|
21
21
|
|
|
22
|
-
const loadFlowFile = new metaDataCore.LoadFlowFile();
|
|
23
|
-
|
|
24
22
|
const getPackageYmlData = (packagePath)=>{
|
|
25
23
|
let packageYmlData = {};
|
|
26
24
|
if(fs.existsSync(path.join(packagePath, 'package.service.yml'))){
|
|
@@ -87,8 +85,10 @@ module.exports = {
|
|
|
87
85
|
}
|
|
88
86
|
const { path: packagePath, isUnmanaged } = packageInfo;
|
|
89
87
|
if (isUnmanaged && packagePath) {
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
89
|
+
const packageJSON = require(`${packagePath}/package.json`)
|
|
90
90
|
const userSession = { spaceId: spaceId, userId: spaceDoc.owner };
|
|
91
|
-
await this.deployPackage(packagePath, userSession);
|
|
91
|
+
await this.deployPackage(packagePath, userSession, {name: packageJSON.name, version: packageJSON.version});
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -112,7 +112,9 @@ module.exports = {
|
|
|
112
112
|
]
|
|
113
113
|
const matchedPaths2 = metaDataCore.syncMatchFiles(filePatten2);
|
|
114
114
|
for await (const filePath of matchedPaths2) {
|
|
115
|
-
|
|
115
|
+
if(!filePath.endsWith("_base/base.object.js")){
|
|
116
|
+
this.broker.logger.warn(`The object.js file has been deprecated. ${filePath}`);
|
|
117
|
+
}
|
|
116
118
|
}
|
|
117
119
|
|
|
118
120
|
// 扫描软件包中的元数据, 如果有 .router.js 文件, 则输出警告信息
|
|
@@ -235,6 +237,13 @@ module.exports = {
|
|
|
235
237
|
if (true != isUnmanaged) {
|
|
236
238
|
// 受管软件包加载元数据文件,非受管软件包不加载
|
|
237
239
|
await this.loadPackageMetadataFiles(_path, this.name, datasource);
|
|
240
|
+
}else{
|
|
241
|
+
if(process.env.STEEDOS_TENANT_ENABLE_SAAS != "true"){
|
|
242
|
+
const primarySpace = await this.broker.call("objectql.getPrimarySpace");
|
|
243
|
+
const packageJSON = require(`${_path}/package.json`)
|
|
244
|
+
const userSession = { spaceId: primarySpace._id, userId: primarySpace.owner };
|
|
245
|
+
await this.deployPackage(_path, userSession, {name: packageJSON.name, version: packageJSON.version});
|
|
246
|
+
}
|
|
238
247
|
}
|
|
239
248
|
if(isPackage !== false){
|
|
240
249
|
try {
|
|
@@ -245,7 +254,7 @@ module.exports = {
|
|
|
245
254
|
_packageInfo = metaDataCore.loadJSONFile(path.join(_path, '..', 'package.json'));
|
|
246
255
|
}
|
|
247
256
|
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}})
|
|
257
|
+
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
258
|
} catch (error) {
|
|
250
259
|
console.log(`error`, error)
|
|
251
260
|
}
|
|
@@ -295,14 +304,18 @@ module.exports = {
|
|
|
295
304
|
await datasource.init();
|
|
296
305
|
}
|
|
297
306
|
},
|
|
298
|
-
async deployPackage(sourcePath, userSession){
|
|
307
|
+
async deployPackage(sourcePath, userSession, packageInfo){
|
|
299
308
|
try {
|
|
300
309
|
var tempDir = mkTempFolder('deploy-');
|
|
301
310
|
var option = { includeJs: false, tableTitle: 'Steedos Deploy', showLog: true, inDeploy: true };
|
|
302
|
-
|
|
311
|
+
const dbPackage = await await this.getObject('steedos_packages').directFind({filters: ['name', '=', packageInfo.name]});
|
|
312
|
+
if(dbPackage.length > 0){
|
|
313
|
+
return ;
|
|
314
|
+
}
|
|
303
315
|
compressFiles(sourcePath, sourcePath, tempDir, option, async (base64, zipDir) => {
|
|
304
316
|
const result = await this.broker.call('~packages-@steedos/metadata-api.deploy', {
|
|
305
317
|
fileBase64: base64,
|
|
318
|
+
packageInfo
|
|
306
319
|
}, {
|
|
307
320
|
timeout: 0,
|
|
308
321
|
meta: {
|
|
@@ -362,9 +375,12 @@ module.exports = {
|
|
|
362
375
|
* Service started lifecycle event handler
|
|
363
376
|
*/
|
|
364
377
|
async started() {
|
|
365
|
-
|
|
378
|
+
const packageInfo = this.settings.packageInfo;
|
|
379
|
+
const isUnmanaged = packageInfo?.isUnmanaged || false;
|
|
380
|
+
|
|
381
|
+
await this.broker.call(`@steedos/service-packages.starting`, {serviceInfo: {name: this.name, nodeID: this.broker.nodeID, instanceID: this.broker.instanceID, isUnmanaged}})
|
|
366
382
|
await this.onStarted();
|
|
367
|
-
await this.broker.call(`@steedos/service-packages.started`, {serviceInfo: {name: this.name, nodeID: this.broker.nodeID, instanceID: this.broker.instanceID}})
|
|
383
|
+
await this.broker.call(`@steedos/service-packages.started`, {serviceInfo: {name: this.name, nodeID: this.broker.nodeID, instanceID: this.broker.instanceID, isUnmanaged}})
|
|
368
384
|
},
|
|
369
385
|
|
|
370
386
|
/**
|
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.71",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -10,10 +10,10 @@
|
|
|
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.71",
|
|
14
|
+
"@steedos/metadata-registrar": "3.0.0-beta.71",
|
|
15
|
+
"@steedos/router": "3.0.0-beta.71",
|
|
16
|
+
"@steedos/service-object-mixin": "3.0.0-beta.71",
|
|
17
17
|
"clone": "^2.1.2",
|
|
18
18
|
"csvtojson": "~2.0.10",
|
|
19
19
|
"moleculer": "^0.14.25",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "32cf4e8cafda54a3e30a46a6506eaa021fa25fb7"
|
|
32
32
|
}
|