mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-21 09:38:01 +02:00
Improving build
This commit is contained in:
parent
ca9102d4f5
commit
4c97aa8542
@ -50,9 +50,10 @@ ReactNativeClient/pluginAssets/
|
||||
ReactNativeClient/lib/joplin-renderer/vendor/fountain.min.js
|
||||
ReactNativeClient/lib/joplin-renderer/assets/
|
||||
|
||||
# Ignore files generated from TypeScript files
|
||||
# AUTO-GENERATED - EXCLUDED TYPESCRIPT BUILD
|
||||
ElectronClient/app/gui/ShareNoteDialog.js
|
||||
ReactNativeClient/lib/JoplinServerApi.js
|
||||
ReactNativeClient/PluginAssetsLoader.js
|
||||
ReactNativeClient/lib/JoplinServerApi.js
|
||||
ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/mermaid.js
|
||||
ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/sanitize_html.js
|
||||
# AUTO-GENERATED - EXCLUDED TYPESCRIPT BUILD
|
||||
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -46,9 +46,10 @@ Tools/commit_hook.txt
|
||||
.vscode/*
|
||||
*.map
|
||||
|
||||
# Ignore files generated from TypeScript files
|
||||
# AUTO-GENERATED - EXCLUDED TYPESCRIPT BUILD
|
||||
ElectronClient/app/gui/ShareNoteDialog.js
|
||||
ReactNativeClient/lib/JoplinServerApi.js
|
||||
ReactNativeClient/PluginAssetsLoader.js
|
||||
ReactNativeClient/lib/JoplinServerApi.js
|
||||
ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/mermaid.js
|
||||
ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/sanitize_html.js
|
||||
# AUTO-GENERATED - EXCLUDED TYPESCRIPT BUILD
|
||||
|
56
ElectronClient/app/package-lock.json
generated
56
ElectronClient/app/package-lock.json
generated
@ -3244,24 +3244,6 @@
|
||||
"webidl-conversions": "^4.0.2"
|
||||
}
|
||||
},
|
||||
"domhandler": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/domhandler/-/domhandler-3.0.0.tgz",
|
||||
"integrity": "sha512-eKLdI5v9m67kbXQbJSNn1zjh0SDzvzWVWtX+qEI3eMjZw8daH9k8rlj1FZY9memPwjiskQFbe7vHVVJIAqoEhw==",
|
||||
"requires": {
|
||||
"domelementtype": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"domutils": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/domutils/-/domutils-2.0.0.tgz",
|
||||
"integrity": "sha512-n5SelJ1axbO636c2yUtOGia/IcJtVtlhQbFiVDBZHKV5ReJO1ViX7sFEemtuyoAnBxk5meNSYgA8V4s0271efg==",
|
||||
"requires": {
|
||||
"dom-serializer": "^0.2.1",
|
||||
"domelementtype": "^2.0.1",
|
||||
"domhandler": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"dot-prop": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.2.0.tgz",
|
||||
@ -4693,24 +4675,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"htmlparser2": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-4.0.0.tgz",
|
||||
"integrity": "sha512-cChwXn5Vam57fyXajDtPXL1wTYc8JtLbr2TN76FYu05itVVVealxLowe2B3IEznJG4p9HAYn/0tJaRlGuEglFQ==",
|
||||
"requires": {
|
||||
"domelementtype": "^2.0.1",
|
||||
"domhandler": "^3.0.0",
|
||||
"domutils": "^2.0.0",
|
||||
"entities": "^2.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"entities": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/entities/-/entities-2.0.0.tgz",
|
||||
"integrity": "sha512-D9f7V0JSRwIxlRI2mjMqufDrRDnx8p+eEOz7aUM9SuvF8gsBzra0/6tbjl1m8eQHrZlYj6PxqE00hZ1SAIKPLw=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"http-cache-semantics": {
|
||||
"version": "4.0.3",
|
||||
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.0.3.tgz",
|
||||
@ -7302,9 +7266,9 @@
|
||||
}
|
||||
},
|
||||
"react": {
|
||||
"version": "16.12.0",
|
||||
"resolved": "https://registry.npmjs.org/react/-/react-16.12.0.tgz",
|
||||
"integrity": "sha512-fglqy3k5E+81pA8s+7K0/T3DBCF0ZDOher1elBFzF7O6arXJgzyu/FW+COxFvAWXJoJN9KIZbT2LXlukwphYTA==",
|
||||
"version": "16.9.0",
|
||||
"resolved": "https://registry.npmjs.org/react/-/react-16.9.0.tgz",
|
||||
"integrity": "sha512-+7LQnFBwkiw+BobzOF6N//BdoNw0ouwmSJTEm9cglOOmsg/TMiFHZLe2sEoN5M7LgJTj9oHH0gxklfnQe66S1w==",
|
||||
"requires": {
|
||||
"loose-envify": "^1.1.0",
|
||||
"object-assign": "^4.1.1",
|
||||
@ -7364,14 +7328,14 @@
|
||||
}
|
||||
},
|
||||
"react-dom": {
|
||||
"version": "16.12.0",
|
||||
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.12.0.tgz",
|
||||
"integrity": "sha512-LMxFfAGrcS3kETtQaCkTKjMiifahaMySFDn71fZUNpPHZQEzmk/GiAeIT8JSOrHB23fnuCOMruL2a8NYlw+8Gw==",
|
||||
"version": "16.9.0",
|
||||
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.9.0.tgz",
|
||||
"integrity": "sha512-YFT2rxO9hM70ewk9jq0y6sQk8cL02xm4+IzYBz75CQGlClQQ1Bxq0nhHF6OtSbit+AIahujJgb/CPRibFkMNJQ==",
|
||||
"requires": {
|
||||
"loose-envify": "^1.1.0",
|
||||
"object-assign": "^4.1.1",
|
||||
"prop-types": "^15.6.2",
|
||||
"scheduler": "^0.18.0"
|
||||
"scheduler": "^0.15.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"prop-types": {
|
||||
@ -7875,9 +7839,9 @@
|
||||
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
|
||||
},
|
||||
"scheduler": {
|
||||
"version": "0.18.0",
|
||||
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.18.0.tgz",
|
||||
"integrity": "sha512-agTSHR1Nbfi6ulI0kYNK0203joW2Y5W4po4l+v03tOoiJKpTBbxpNhWDvqc/4IcOw+KLmSiQLTasZ4cab2/UWQ==",
|
||||
"version": "0.15.0",
|
||||
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.15.0.tgz",
|
||||
"integrity": "sha512-xAefmSfN6jqAa7Kuq7LIJY0bwAPG3xlCj0HMEBQk1lxYiDKZscY2xJ5U/61ZTrYbmNQbXa+gc7czPkVo11tnCg==",
|
||||
"requires": {
|
||||
"loose-envify": "^1.1.0",
|
||||
"object-assign": "^4.1.1"
|
||||
|
@ -141,10 +141,10 @@
|
||||
"node-notifier": "^6.0.0",
|
||||
"promise": "^8.0.1",
|
||||
"query-string": "^5.1.1",
|
||||
"react": "^16.12.0",
|
||||
"react": "^16.9.0",
|
||||
"react-ace": "^6.1.4",
|
||||
"react-datetime": "^2.14.0",
|
||||
"react-dom": "^16.12.0",
|
||||
"react-dom": "^16.9.0",
|
||||
"react-redux": "^5.0.7",
|
||||
"react-select": "^2.4.3",
|
||||
"react-tooltip": "^3.10.0",
|
||||
|
157
gulpfile.js
Normal file
157
gulpfile.js
Normal file
@ -0,0 +1,157 @@
|
||||
const gulp = require('gulp');
|
||||
const ts = require('gulp-typescript');
|
||||
const fs = require('fs-extra');
|
||||
|
||||
const toolUtils = {};
|
||||
|
||||
toolUtils.isLinux = () => {
|
||||
return process && process.platform === 'linux';
|
||||
};
|
||||
|
||||
toolUtils.isWindows = () => {
|
||||
return process && process.platform === 'win32';
|
||||
};
|
||||
|
||||
toolUtils.isMac = () => {
|
||||
return process && process.platform === 'darwin';
|
||||
};
|
||||
|
||||
toolUtils.execCommand = function(command) {
|
||||
const exec = require('child_process').exec;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(command, (error, stdout) => {
|
||||
if (error) {
|
||||
if (error.signal == 'SIGTERM') {
|
||||
resolve('Process was killed');
|
||||
} else {
|
||||
reject(error);
|
||||
}
|
||||
} else {
|
||||
resolve(stdout.trim());
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const pathUtils = {};
|
||||
|
||||
pathUtils.dirname = function(path) {
|
||||
if (!path) throw new Error('Path is empty');
|
||||
let s = path.split(/\/|\\/);
|
||||
s.pop();
|
||||
return s.join('/');
|
||||
};
|
||||
|
||||
pathUtils.basename = function(path) {
|
||||
if (!path) throw new Error('Path is empty');
|
||||
let s = path.split(/\/|\\/);
|
||||
return s[s.length - 1];
|
||||
};
|
||||
|
||||
pathUtils.filename = function(path, includeDir = false) {
|
||||
if (!path) throw new Error('Path is empty');
|
||||
let output = includeDir ? path : pathUtils.basename(path);
|
||||
if (output.indexOf('.') < 0) return output;
|
||||
|
||||
output = output.split('.');
|
||||
output.pop();
|
||||
return output.join('.');
|
||||
};
|
||||
|
||||
pathUtils.fileExtension = function(path) {
|
||||
if (!path) throw new Error('Path is empty');
|
||||
|
||||
let output = path.split('.');
|
||||
if (output.length <= 1) return '';
|
||||
return output[output.length - 1];
|
||||
};
|
||||
|
||||
toolUtils.getAllFiles = function(dir, options = null) {
|
||||
var results = [];
|
||||
var list = fs.readdirSync(dir);
|
||||
list.forEach(function(file) {
|
||||
file = `${dir}/${file}`;
|
||||
const filename = pathUtils.basename(file);
|
||||
const ext = pathUtils.fileExtension(file).toLowerCase();
|
||||
|
||||
var stat = fs.statSync(file);
|
||||
if (stat && stat.isDirectory()) {
|
||||
if (file.indexOf('ElectronClient/app/lib') >= 0) return;
|
||||
if (file.indexOf('CliClient/lib') >= 0) return;
|
||||
if (filename === 'node_modules' || filename === '.git' || filename === 'build' || filename === 'tests-build' || filename === 'dist') return;
|
||||
results = results.concat(toolUtils.getAllFiles(file, options));
|
||||
} else {
|
||||
let addIt = true;
|
||||
|
||||
if (options.extensions && options.extensions.length && !options.extensions.includes(ext)) {
|
||||
addIt = false;
|
||||
}
|
||||
|
||||
if (addIt) results.push(file.substr(__dirname.length + 1));
|
||||
}
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
async function replaceFileText(filePath, regex, toInsert) {
|
||||
const content = await fs.readFile(filePath, 'utf8');
|
||||
const newContent = content.replace(regex, toInsert);
|
||||
await fs.writeFile(filePath, newContent);
|
||||
}
|
||||
|
||||
const tsProject = ts.createProject('tsconfig.json');
|
||||
|
||||
const tscTaskSrc = [
|
||||
'ReactNativeClient/**/*.tsx',
|
||||
'ReactNativeClient/**/*.ts',
|
||||
'ElectronClient/**/*.tsx',
|
||||
'ElectronClient/**/*.ts',
|
||||
'CliClient/**/*.tsx',
|
||||
'CliClient/**/*.ts',
|
||||
];
|
||||
|
||||
const tscTask = function() {
|
||||
return tsProject.src()
|
||||
.pipe(tsProject())
|
||||
.js.pipe(gulp.dest('./'));
|
||||
};
|
||||
|
||||
const copyLibSrc = 'ReactNativeClient/lib/**/*';
|
||||
|
||||
const copyLibTask = async function() {
|
||||
if (toolUtils.isWindows()) {
|
||||
await toolUtils.execCommand(`xcopy /C /I /H /R /Y /S "${__dirname}\\ReactNativeClient\\lib" ElectronClient\\app\\lib`);
|
||||
} else {
|
||||
await toolUtils.execCommand(`rsync -a --delete "${__dirname}/ReactNativeClient/lib/" "ElectronClient/app/lib/"`);
|
||||
await toolUtils.execCommand(`rsync -a --delete "${__dirname}/ReactNativeClient/lib/" "CliClient/build/lib/"`);
|
||||
}
|
||||
};
|
||||
|
||||
const updateIgnoredTypeScriptBuildTask = async function() {
|
||||
const tsFiles = toolUtils.getAllFiles(__dirname, { extensions: ['tsx', 'ts'] });
|
||||
|
||||
const ignoredFiles = tsFiles.map(f => {
|
||||
const s = f.split('.');
|
||||
s.pop();
|
||||
return `${s.join('.')}.js`;
|
||||
});
|
||||
|
||||
const regex = /(# AUTO-GENERATED - EXCLUDED TYPESCRIPT BUILD)[\s\S]*(# AUTO-GENERATED - EXCLUDED TYPESCRIPT BUILD)/;
|
||||
const replacement = `$1\n${ignoredFiles.join('\n')}\n$2`;
|
||||
|
||||
await replaceFileText(`${__dirname}/.gitignore`, regex, replacement);
|
||||
await replaceFileText(`${__dirname}/.eslintignore`, regex, replacement);
|
||||
};
|
||||
|
||||
gulp.task('tsc', tscTask);
|
||||
gulp.task('copyLib', copyLibTask);
|
||||
|
||||
gulp.task('watch', function() {
|
||||
gulp.watch(tscTaskSrc, tscTask);
|
||||
gulp.watch(copyLibSrc, copyLibTask);
|
||||
});
|
||||
|
||||
gulp.task('build', gulp.series(tscTask, copyLibTask));
|
||||
|
||||
gulp.task('updateIgnoredTypeScriptBuild', updateIgnoredTypeScriptBuildTask);
|
3774
package-lock.json
generated
3774
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -26,12 +26,16 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/react": "^16.9.16",
|
||||
"@types/react-dom": "^16.9.4",
|
||||
"@types/react": "^16.9.0",
|
||||
"@types/react-dom": "^16.9.0",
|
||||
"@typescript-eslint/eslint-plugin": "^2.10.0",
|
||||
"@typescript-eslint/parser": "^2.10.0",
|
||||
"eslint": "^6.1.0",
|
||||
"eslint-plugin-react": "^7.18.0",
|
||||
"fs-extra": "^8.1.0",
|
||||
"glob": "^7.1.6",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-typescript": "^6.0.0-alpha.1",
|
||||
"husky": "^3.0.2",
|
||||
"lint-staged": "^9.2.1",
|
||||
"typescript": "^3.7.3"
|
||||
|
Loading…
Reference in New Issue
Block a user