2020-11-05 18:58:23 +02:00
|
|
|
const gulp = require('gulp');
|
|
|
|
const fs = require('fs-extra');
|
2020-11-07 17:59:37 +02:00
|
|
|
const utils = require('@joplin/tools/gulp/utils');
|
2020-11-05 18:58:23 +02:00
|
|
|
|
2021-01-18 22:09:11 +02:00
|
|
|
const tasks = {};
|
2020-11-06 23:25:07 +02:00
|
|
|
|
2020-11-05 18:58:23 +02:00
|
|
|
tasks.prepareBuild = {
|
|
|
|
fn: async () => {
|
|
|
|
const buildDir = `${__dirname}/build`;
|
|
|
|
await utils.copyDir(`${__dirname}/app`, buildDir, {
|
|
|
|
excluded: ['node_modules'],
|
|
|
|
});
|
2020-11-06 23:25:07 +02:00
|
|
|
|
2020-11-05 18:58:23 +02:00
|
|
|
await utils.copyFile(`${__dirname}/package.json`, `${buildDir}/package.json`);
|
2021-01-18 22:09:11 +02:00
|
|
|
await utils.setPackagePrivateField(`${buildDir}/package.json`, false);
|
2020-11-06 23:25:07 +02:00
|
|
|
|
2020-11-05 18:58:23 +02:00
|
|
|
await utils.copyFile(`${__dirname}/package-lock.json`, `${buildDir}/package-lock.json`);
|
|
|
|
await utils.copyFile(`${__dirname}/gulpfile.js`, `${buildDir}/gulpfile.js`);
|
|
|
|
|
|
|
|
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',
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
await fs.mkdirp(`${testBuildDir}/data`);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
utils.registerGulpTasks(gulp, tasks);
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('build', gulp.series([
|
|
|
|
'prepareBuild',
|
|
|
|
]));
|