mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Tools: Clean up and fix tool dependencies
This commit is contained in:
parent
e91c94baca
commit
e8ae29adf2
@ -1,22 +1,8 @@
|
||||
const gulp = require('gulp');
|
||||
const fs = require('fs-extra');
|
||||
const utils = require('@joplin/tools/gulp/utils');
|
||||
const { setPackagePrivateField } = require('@joplin/tools/tool-utils');
|
||||
const tasks = {
|
||||
// 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'),
|
||||
};
|
||||
|
||||
// async function makePackagePublic(filePath) {
|
||||
// const text = await fs.readFile(filePath, 'utf8');
|
||||
// const obj = JSON.parse(text);
|
||||
// delete obj.private;
|
||||
// await fs.writeFile(filePath, JSON.stringify(obj), 'utf8');
|
||||
// }
|
||||
const tasks = {};
|
||||
|
||||
tasks.prepareBuild = {
|
||||
fn: async () => {
|
||||
@ -26,8 +12,7 @@ tasks.prepareBuild = {
|
||||
});
|
||||
|
||||
await utils.copyFile(`${__dirname}/package.json`, `${buildDir}/package.json`);
|
||||
// await makePackagePublic(`${buildDir}/package.json`);
|
||||
await setPackagePrivateField(`${buildDir}/package.json`, false);
|
||||
await utils.setPackagePrivateField(`${buildDir}/package.json`, false);
|
||||
|
||||
await utils.copyFile(`${__dirname}/package-lock.json`, `${buildDir}/package-lock.json`);
|
||||
await utils.copyFile(`${__dirname}/gulpfile.js`, `${buildDir}/gulpfile.js`);
|
||||
@ -50,14 +35,6 @@ tasks.prepareTestBuild = {
|
||||
],
|
||||
});
|
||||
|
||||
// const rootDir = utils.rootDir();
|
||||
|
||||
// await utils.copyDir(`${rootDir}/packages/app-mobile/lib`, `${testBuildDir}/lib`, {
|
||||
// excluded: [
|
||||
// `${rootDir}/packages/renderer/node_modules`,
|
||||
// ],
|
||||
// });
|
||||
// await utils.copyDir(`${rootDir}/packages/app-mobile/locales`, `${testBuildDir}/locales`);
|
||||
await fs.mkdirp(`${testBuildDir}/data`);
|
||||
},
|
||||
};
|
||||
@ -67,12 +44,4 @@ utils.registerGulpTasks(gulp, tasks);
|
||||
|
||||
gulp.task('build', gulp.series([
|
||||
'prepareBuild',
|
||||
// 'compileExtensions',
|
||||
// 'copyLib',
|
||||
]));
|
||||
|
||||
// gulp.task('buildTests', gulp.series([
|
||||
// // 'prepareTestBuild',
|
||||
// // 'compileExtensions',
|
||||
// // 'copyLib',
|
||||
// ]));
|
||||
|
@ -1,6 +1,5 @@
|
||||
const gulp = require('gulp');
|
||||
const utils = require('@joplin/tools/gulp/utils');
|
||||
const fs = require('fs-extra');
|
||||
|
||||
const tasks = {
|
||||
compileScripts: {
|
||||
@ -18,55 +17,18 @@ const tasks = {
|
||||
electronRebuild: {
|
||||
fn: require('./tools/electronRebuild.js'),
|
||||
},
|
||||
// compileExtensions: {
|
||||
// fn: require('@joplin/tools/gulp/tasks/compileExtensions.js'),
|
||||
// },
|
||||
// copyLib: require('@joplin/tools/gulp/tasks/copyLib'),
|
||||
tsc: require('@joplin/tools/gulp/tasks/tsc'),
|
||||
updateIgnoredTypeScriptBuild: require('@joplin/tools/gulp/tasks/updateIgnoredTypeScriptBuild'),
|
||||
|
||||
linkReact: {
|
||||
fn: async () => {
|
||||
// React is a dependency of both the lib and app-desktop
|
||||
// packages, which cause a duplicate React issue. To go around
|
||||
// this, one way is to manually link the package.
|
||||
//
|
||||
// Note that React must also be unlinked in preinstall step
|
||||
// otherwise there will be permission errors when running
|
||||
// `lerna bootstrap`
|
||||
//
|
||||
// https://reactjs.org/warnings/invalid-hook-call-warning.html#duplicate-react
|
||||
process.chdir(__dirname);
|
||||
await fs.remove('./node_modules/react');
|
||||
await fs.remove('./node_modules/react-dom');
|
||||
await utils.execCommand('npm link ../lib/node_modules/react');
|
||||
await utils.execCommand('npm link ../lib/node_modules/react-dom');
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
utils.registerGulpTasks(gulp, tasks);
|
||||
|
||||
// const buildSeries = [
|
||||
// // 'compileExtensions',
|
||||
// // 'copyLib',
|
||||
// ];
|
||||
|
||||
// On Windows also run tsc because `npm run watch` locks some folders
|
||||
// which makes the copyPluginAssets command fail. For that reason,
|
||||
// it's not possible to run watch on Windows while testing the desktop app.
|
||||
// if (require('os').platform() === 'win32') {
|
||||
// buildSeries.push('tsc');
|
||||
// }
|
||||
|
||||
const buildParallel = [
|
||||
// gulp.series(...buildSeries),
|
||||
'compileScripts',
|
||||
'compilePackageInfo',
|
||||
'copyPluginAssets',
|
||||
'copyTinyMceLangs',
|
||||
'updateIgnoredTypeScriptBuild',
|
||||
// 'linkReact',
|
||||
];
|
||||
|
||||
gulp.task('build', gulp.parallel(...buildParallel));
|
||||
|
@ -1,5 +1,4 @@
|
||||
const gulp = require('gulp');
|
||||
const fs = require('fs-extra');
|
||||
const utils = require('@joplin/tools/gulp/utils');
|
||||
|
||||
const tasks = {
|
||||
@ -12,23 +11,6 @@ const tasks = {
|
||||
podInstall: {
|
||||
fn: require('./tools/podInstall'),
|
||||
},
|
||||
prepareRelease: {
|
||||
fn: require('./tools/prepareRelease'),
|
||||
},
|
||||
// clean: {
|
||||
// fn: require('./tools/clean'),
|
||||
// },
|
||||
linkReact: {
|
||||
fn: async () => {
|
||||
// React is a dependency of both the lib and app-desktop
|
||||
// packages, which cause a duplicate React issue. To go around
|
||||
// this, one way is to manually link the package.
|
||||
// https://reactjs.org/warnings/invalid-hook-call-warning.html#duplicate-react
|
||||
process.chdir(__dirname);
|
||||
await fs.remove('./node_modules/react');
|
||||
await utils.execCommand('npm link ../lib/node_modules/react');
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
utils.registerGulpTasks(gulp, tasks);
|
||||
@ -36,6 +18,5 @@ utils.registerGulpTasks(gulp, tasks);
|
||||
gulp.task('build', gulp.series(
|
||||
'buildReactNativeInjectedJs',
|
||||
'encodeAssets',
|
||||
// 'linkReact',
|
||||
'podInstall'
|
||||
));
|
||||
|
@ -1,32 +0,0 @@
|
||||
// This is to replace the symlinks inside node_modules with the actual packages
|
||||
// as I assumed it was needed to build the final release. However it seems
|
||||
// Android `assembleRelease` handles symlinks properly so maybe this is not
|
||||
// needed after all ¯\_(ツ)_/¯
|
||||
|
||||
const { copyDir } = require('@joplin/tools/gulp/utils');
|
||||
const { rootDir, deleteLink, toSystemSlashes } = require('@joplin/tools/tool-utils');
|
||||
const mobileDir = `${rootDir}/packages/app-mobile`;
|
||||
|
||||
module.exports = async function() {
|
||||
const dirsToCopy = [
|
||||
'fork-htmlparser2',
|
||||
'fork-sax',
|
||||
'lib',
|
||||
'renderer',
|
||||
];
|
||||
|
||||
const destDir = `${mobileDir}/node_modules/@joplin`;
|
||||
|
||||
for (const dir of dirsToCopy) {
|
||||
const destPath = toSystemSlashes(`${destDir}/${dir}`);
|
||||
const sourcePath = toSystemSlashes(`${rootDir}/packages/${dir}`);
|
||||
|
||||
console.info(`Copying ${sourcePath} => ${destPath}`);
|
||||
|
||||
// TODO: copy symlink so that it can be restored
|
||||
await deleteLink(destPath);
|
||||
await copyDir(sourcePath, destPath, {
|
||||
excluded: ['node_modules'],
|
||||
});
|
||||
}
|
||||
};
|
@ -1,31 +0,0 @@
|
||||
// const fs = require('fs');
|
||||
// const { execSync } = require("child_process");
|
||||
|
||||
// const isWindows = process.platform === "win32";
|
||||
|
||||
// function toSystemSlashes(path) {
|
||||
// const os = process.platform;
|
||||
// if (os === 'win32') return path.replace(/\//g, '\\');
|
||||
// return path.replace(/\\/g, '/');
|
||||
// }
|
||||
|
||||
// const nodeModulesPath = `${__dirname}/../node_modules`;
|
||||
|
||||
// function deleteLink(path) {
|
||||
// if (isWindows) {
|
||||
// try {
|
||||
// execSync(`rmdir "${toSystemSlashes(path)}"`, { stdio : 'pipe' });
|
||||
// } catch (error) {
|
||||
// // console.info('Error: ' + error.message);
|
||||
// }
|
||||
// } else {
|
||||
// try {
|
||||
// fs.unlinkSync(toSystemSlashes(path));
|
||||
// } catch (error) {
|
||||
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// deleteLink(nodeModulesPath + '/react');
|
||||
// deleteLink(nodeModulesPath + '/react-dom');
|
@ -155,4 +155,15 @@ utils.registerGulpTasks = function(gulp, tasks) {
|
||||
}
|
||||
};
|
||||
|
||||
utils.setPackagePrivateField = async function(filePath, value) {
|
||||
const text = await fs.readFile(filePath, 'utf8');
|
||||
const obj = JSON.parse(text);
|
||||
if (!value) {
|
||||
delete obj.private;
|
||||
} else {
|
||||
obj.private = true;
|
||||
}
|
||||
await fs.writeFile(filePath, JSON.stringify(obj, null, 2), 'utf8');
|
||||
};
|
||||
|
||||
module.exports = utils;
|
||||
|
3336
packages/tools/package-lock.json
generated
3336
packages/tools/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,4 @@
|
||||
import * as fs from 'fs-extra';
|
||||
import { execSync } from 'child_process';
|
||||
|
||||
const fetch = require('node-fetch');
|
||||
const execa = require('execa');
|
||||
@ -142,22 +141,6 @@ export function toSystemSlashes(path: string) {
|
||||
return path.replace(/\\/g, '/');
|
||||
}
|
||||
|
||||
export function deleteLink(path: string) {
|
||||
if (isWindows()) {
|
||||
try {
|
||||
execSync(`rmdir "${toSystemSlashes(path)}"`, { stdio: 'pipe' });
|
||||
} catch (error) {
|
||||
// console.info('Error: ' + error.message);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
fs.unlinkSync(toSystemSlashes(path));
|
||||
} catch (error) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function setPackagePrivateField(filePath: string, value: any) {
|
||||
const text = await fs.readFile(filePath, 'utf8');
|
||||
const obj = JSON.parse(text);
|
||||
|
Loading…
Reference in New Issue
Block a user