@steedos/service-package-loader 3.0.0-beta.30 → 3.0.0-beta.32
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 +22 -8
- 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
|
}
|
|
@@ -237,6 +237,13 @@ module.exports = {
|
|
|
237
237
|
if (true != isUnmanaged) {
|
|
238
238
|
// 受管软件包加载元数据文件,非受管软件包不加载
|
|
239
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
|
+
}
|
|
240
247
|
}
|
|
241
248
|
if(isPackage !== false){
|
|
242
249
|
try {
|
|
@@ -247,7 +254,7 @@ module.exports = {
|
|
|
247
254
|
_packageInfo = metaDataCore.loadJSONFile(path.join(_path, '..', 'package.json'));
|
|
248
255
|
}
|
|
249
256
|
const packageYmlData = getPackageYmlData(_path);
|
|
250
|
-
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}})
|
|
251
258
|
} catch (error) {
|
|
252
259
|
console.log(`error`, error)
|
|
253
260
|
}
|
|
@@ -297,14 +304,18 @@ module.exports = {
|
|
|
297
304
|
await datasource.init();
|
|
298
305
|
}
|
|
299
306
|
},
|
|
300
|
-
async deployPackage(sourcePath, userSession){
|
|
307
|
+
async deployPackage(sourcePath, userSession, packageInfo){
|
|
301
308
|
try {
|
|
302
309
|
var tempDir = mkTempFolder('deploy-');
|
|
303
310
|
var option = { includeJs: false, tableTitle: 'Steedos Deploy', showLog: true, inDeploy: true };
|
|
304
|
-
|
|
311
|
+
const dbPackage = await await this.getObject('steedos_packages').directFind({filters: ['name', '=', packageInfo.name]});
|
|
312
|
+
if(dbPackage.length > 0){
|
|
313
|
+
return ;
|
|
314
|
+
}
|
|
305
315
|
compressFiles(sourcePath, sourcePath, tempDir, option, async (base64, zipDir) => {
|
|
306
316
|
const result = await this.broker.call('~packages-@steedos/metadata-api.deploy', {
|
|
307
317
|
fileBase64: base64,
|
|
318
|
+
packageInfo
|
|
308
319
|
}, {
|
|
309
320
|
timeout: 0,
|
|
310
321
|
meta: {
|
|
@@ -364,9 +375,12 @@ module.exports = {
|
|
|
364
375
|
* Service started lifecycle event handler
|
|
365
376
|
*/
|
|
366
377
|
async started() {
|
|
367
|
-
|
|
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}})
|
|
368
382
|
await this.onStarted();
|
|
369
|
-
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}})
|
|
370
384
|
},
|
|
371
385
|
|
|
372
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.32",
|
|
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.32",
|
|
14
|
+
"@steedos/metadata-registrar": "3.0.0-beta.32",
|
|
15
|
+
"@steedos/router": "3.0.0-beta.32",
|
|
16
|
+
"@steedos/service-object-mixin": "3.0.0-beta.32",
|
|
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": "fcff940305b05294cce7c852009c04a769ae0df7"
|
|
32
32
|
}
|