1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-12 08:54:00 +02:00
joplin/CliClient/gulpfile.js

74 lines
2.1 KiB
JavaScript
Raw Normal View History

const gulp = require('gulp');
const fs = require('fs-extra');
const utils = require('../Tools/gulp/utils');
const tasks = {
2020-09-06 14:07:00 +02:00
compileExtensions: {
fn: require('../Tools/gulp/tasks/compileExtensions.js'),
},
copyLib: require('../Tools/gulp/tasks/copyLib'),
tsc: require('../Tools/gulp/tasks/tsc'),
updateIgnoredTypeScriptBuild: require('../Tools/gulp/tasks/updateIgnoredTypeScriptBuild'),
};
tasks.prepareBuild = {
fn: async () => {
const buildDir = `${__dirname}/build`;
await utils.copyDir(`${__dirname}/app`, buildDir, {
excluded: ['node_modules'],
});
await utils.copyDir(`${__dirname}/locales-build`, `${buildDir}/locales`);
2020-03-07 02:55:59 +02:00
await utils.copyDir(`${__dirname}/../patches`, `${buildDir}/patches`);
await tasks.copyLib.fn();
await utils.copyFile(`${__dirname}/package.json`, `${buildDir}/package.json`);
2020-03-07 03:09:15 +02:00
await utils.copyFile(`${__dirname}/package-lock.json`, `${buildDir}/package-lock.json`);
2020-03-07 03:11:35 +02:00
await utils.copyFile(`${__dirname}/gulpfile.js`, `${buildDir}/gulpfile.js`);
2020-03-07 02:55:59 +02:00
2020-03-07 03:19:41 +02:00
const packageRaw = await fs.readFile(`${buildDir}/package.json`);
const package = JSON.parse(packageRaw.toString());
package.scripts.postinstall = 'patch-package';
await fs.writeFile(`${buildDir}/package.json`, JSON.stringify(package, null, 2), 'utf8');
2020-03-07 02:55:59 +02:00
fs.chmodSync(`${buildDir}/main.js`, 0o755);
},
};
tasks.prepareTestBuild = {
fn: async () => {
const testBuildDir = `${__dirname}/tests-build`;
await utils.copyDir(`${__dirname}/tests`, testBuildDir, {
excluded: [
'lib/',
'locales/',
'node_modules/',
'*.ts',
'*.tsx',
],
});
const rootDir = utils.rootDir();
await utils.copyDir(`${rootDir}/ReactNativeClient/lib`, `${testBuildDir}/lib`, {
excluded: [
`${rootDir}/ReactNativeClient/lib/joplin-renderer/node_modules`,
],
});
await utils.copyDir(`${rootDir}/ReactNativeClient/locales`, `${testBuildDir}/locales`);
await fs.mkdirp(`${testBuildDir}/data`);
},
};
utils.registerGulpTasks(gulp, tasks);
gulp.task('build', gulp.series([
'prepareBuild',
2020-09-06 14:07:00 +02:00
'compileExtensions',
'copyLib',
]));
gulp.task('buildTests', gulp.series([
'prepareTestBuild',
2020-09-06 14:07:00 +02:00
'compileExtensions',
'copyLib',
]));