mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-02-10 18:05:07 +08:00
Add addon support
(cherry picked from commit 2191174c19958449be69adfedc83e847a2f19d6a)
This commit is contained in:
@ -35,6 +35,8 @@
|
||||
},
|
||||
"pkg": {
|
||||
"scripts": [
|
||||
"./sources/editorDataMemory.js",
|
||||
"./sources/editorDataRedis.js",
|
||||
"./sources/pubsubRabbitMQ.js",
|
||||
"../Common/sources/storage-fs.js",
|
||||
"../Common/sources/storage-s3.js"
|
||||
|
||||
67
Gruntfile.js
67
Gruntfile.js
@ -29,10 +29,52 @@
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
const path = require('path');
|
||||
const _ = require('lodash');
|
||||
var packageFile = require('./package.json');
|
||||
|
||||
module.exports = function (grunt) {
|
||||
|
||||
let addons = grunt.option('addon') || [];
|
||||
if (!Array.isArray(addons))
|
||||
addons = [addons];
|
||||
|
||||
addons.forEach((element,index,self) => self[index] = path.join('..', element));
|
||||
addons = addons.filter(element => grunt.file.isDir(element));
|
||||
|
||||
function _merge(target, ...sources) {
|
||||
if (!sources.length) return target;
|
||||
const source = sources.shift();
|
||||
|
||||
for (const key in source) {
|
||||
if (_.isObject(source[key])) {
|
||||
if (_.isArray(source[key])) {
|
||||
if (!_.isArray(target[key])){
|
||||
target[key]=[];
|
||||
}
|
||||
target[key].push(...source[key])
|
||||
}
|
||||
else {
|
||||
if (!target[key]) {
|
||||
Object.assign(target, { [key]: {} });
|
||||
}
|
||||
_merge(target[key], source[key]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Object.assign(target, { [key]: source[key] });
|
||||
}
|
||||
}
|
||||
}
|
||||
addons.forEach(element => {
|
||||
let _path = path.join(element, 'package.json');
|
||||
if (grunt.file.exists(_path)) {
|
||||
_merge(packageFile, require(_path));
|
||||
grunt.log.ok('addon '.green + element + ' is merged successfully'.green);
|
||||
}
|
||||
});
|
||||
|
||||
//grunt.file.write("package-test.json", JSON.stringify(packageFile, null, 4));
|
||||
|
||||
var checkDependencies = {};
|
||||
|
||||
@ -47,26 +89,9 @@ module.exports = function (grunt) {
|
||||
}
|
||||
|
||||
grunt.initConfig({
|
||||
clean: {
|
||||
options: {
|
||||
force: true
|
||||
},
|
||||
build: packageFile.build.dest
|
||||
},
|
||||
mkdir: {
|
||||
build: {
|
||||
options: {
|
||||
create: [packageFile.build.dest]
|
||||
},
|
||||
},
|
||||
},
|
||||
copy: {
|
||||
main: {
|
||||
expand: true,
|
||||
src: packageFile.build.src,
|
||||
dest: packageFile.build.dest
|
||||
}
|
||||
},
|
||||
clean: packageFile.grunt.clean,
|
||||
mkdir: packageFile.grunt.mkdir,
|
||||
copy: packageFile.grunt.copy,
|
||||
comments: {
|
||||
js: {
|
||||
options: {
|
||||
|
||||
53
package.json
53
package.json
@ -3,23 +3,44 @@
|
||||
"version": "0.0.0",
|
||||
"homepage": "http://www.teamlab.com",
|
||||
"private": true,
|
||||
"build": {
|
||||
"src": [
|
||||
"./**/sources/*.js",
|
||||
"./Common/package.json",
|
||||
"./DocService/package.json",
|
||||
"./DocService/public/healthcheck.docx",
|
||||
"./FileConverter/package.json",
|
||||
"./FileConverter/bin/DoctRenderer.config",
|
||||
"./Metrics/package.json",
|
||||
"./SpellChecker/package.json",
|
||||
"./Common/config/*.json",
|
||||
"./Common/config/log4js/*.json",
|
||||
"./Common/sources/licenseKey.pem",
|
||||
"./Metrics/config/config.js"
|
||||
],
|
||||
"dest": "./build/server"
|
||||
"grunt": {
|
||||
"copy": {
|
||||
"server": {
|
||||
"expand": true,
|
||||
"src": [
|
||||
"./**/sources/*.js",
|
||||
"./Common/package.json",
|
||||
"./DocService/package.json",
|
||||
"./DocService/public/healthcheck.docx",
|
||||
"./FileConverter/package.json",
|
||||
"./FileConverter/bin/DoctRenderer.config",
|
||||
"./Metrics/package.json",
|
||||
"./SpellChecker/package.json",
|
||||
"./Common/config/*.json",
|
||||
"./Common/config/log4js/*.json",
|
||||
"./Common/sources/licenseKey.pem",
|
||||
"./Metrics/config/config.js"
|
||||
],
|
||||
"dest": "./build/server"
|
||||
}
|
||||
},
|
||||
"clean": {
|
||||
"options": {
|
||||
"force": true
|
||||
},
|
||||
"server": "./build/server"
|
||||
},
|
||||
"mkdir": {
|
||||
"server": {
|
||||
"options": {
|
||||
"create": [
|
||||
"./build/server"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"postprocess": {
|
||||
"src": [
|
||||
"./build/server/**/sources/*.js"
|
||||
|
||||
Reference in New Issue
Block a user