@steedos/service-package-loader 3.0.0-beta.8 → 3.0.0-beta.80
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 +27 -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,15 @@ 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
|
+
if(primarySpace){
|
|
244
|
+
const packageJSON = require(`${_path}/package.json`)
|
|
245
|
+
const userSession = { spaceId: primarySpace._id, userId: primarySpace.owner };
|
|
246
|
+
await this.deployPackage(_path, userSession, {name: packageJSON.name, version: packageJSON.version});
|
|
247
|
+
}
|
|
248
|
+
}
|
|
238
249
|
}
|
|
239
250
|
if(isPackage !== false){
|
|
240
251
|
try {
|
|
@@ -245,7 +256,7 @@ module.exports = {
|
|
|
245
256
|
_packageInfo = metaDataCore.loadJSONFile(path.join(_path, '..', 'package.json'));
|
|
246
257
|
}
|
|
247
258
|
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}})
|
|
259
|
+
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
260
|
} catch (error) {
|
|
250
261
|
console.log(`error`, error)
|
|
251
262
|
}
|
|
@@ -295,14 +306,18 @@ module.exports = {
|
|
|
295
306
|
await datasource.init();
|
|
296
307
|
}
|
|
297
308
|
},
|
|
298
|
-
async deployPackage(sourcePath, userSession){
|
|
309
|
+
async deployPackage(sourcePath, userSession, packageInfo){
|
|
299
310
|
try {
|
|
300
311
|
var tempDir = mkTempFolder('deploy-');
|
|
301
312
|
var option = { includeJs: false, tableTitle: 'Steedos Deploy', showLog: true, inDeploy: true };
|
|
302
|
-
|
|
313
|
+
const dbPackage = await await this.getObject('steedos_packages').directFind({filters: ['name', '=', packageInfo.name]});
|
|
314
|
+
if(dbPackage.length > 0){
|
|
315
|
+
return ;
|
|
316
|
+
}
|
|
303
317
|
compressFiles(sourcePath, sourcePath, tempDir, option, async (base64, zipDir) => {
|
|
304
318
|
const result = await this.broker.call('~packages-@steedos/metadata-api.deploy', {
|
|
305
319
|
fileBase64: base64,
|
|
320
|
+
packageInfo
|
|
306
321
|
}, {
|
|
307
322
|
timeout: 0,
|
|
308
323
|
meta: {
|
|
@@ -362,9 +377,12 @@ module.exports = {
|
|
|
362
377
|
* Service started lifecycle event handler
|
|
363
378
|
*/
|
|
364
379
|
async started() {
|
|
365
|
-
|
|
380
|
+
const packageInfo = this.settings.packageInfo;
|
|
381
|
+
const isUnmanaged = packageInfo?.isUnmanaged || false;
|
|
382
|
+
|
|
383
|
+
await this.broker.call(`@steedos/service-packages.starting`, {serviceInfo: {name: this.name, nodeID: this.broker.nodeID, instanceID: this.broker.instanceID, isUnmanaged}})
|
|
366
384
|
await this.onStarted();
|
|
367
|
-
await this.broker.call(`@steedos/service-packages.started`, {serviceInfo: {name: this.name, nodeID: this.broker.nodeID, instanceID: this.broker.instanceID}})
|
|
385
|
+
await this.broker.call(`@steedos/service-packages.started`, {serviceInfo: {name: this.name, nodeID: this.broker.nodeID, instanceID: this.broker.instanceID, isUnmanaged}})
|
|
368
386
|
},
|
|
369
387
|
|
|
370
388
|
/**
|
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.80",
|
|
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.80",
|
|
14
|
+
"@steedos/metadata-registrar": "3.0.0-beta.80",
|
|
15
|
+
"@steedos/router": "3.0.0-beta.80",
|
|
16
|
+
"@steedos/service-object-mixin": "3.0.0-beta.80",
|
|
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": "32e451dcb9225c8968200081644d507bb67ebe17"
|
|
32
32
|
}
|