Fixed various electron packager issues

- We have to reuse the `yarn.lock` file for the final app, not just
for the extensions.
 - Simplified the clean-up phase.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
Akos Kitta 2019-10-17 08:45:26 +02:00
parent 65a58ce2be
commit cc6a0ae212
2 changed files with 19 additions and 9 deletions

5
.vscode/launch.json vendored
View File

@ -7,8 +7,9 @@
{
"type": "node",
"request": "launch",
"name": "Launch Node.js Program",
"program": "${file}"
"name": "Launch Electron Packager",
"program": "${workspaceRoot}/electron/packager/index.js",
"cwd": "${workspaceFolder}/electron/packager"
},
{
"type": "node",

View File

@ -33,10 +33,8 @@
//---------------------------+
// rm -rf ../working-copy
rm('-rf', path('..', workingCopy));
// rm -rf ../build/dist
rm('-rf', path('..', 'build', 'dist'));
// rm -rf ../build/package.json
rm('-rf', path('..', 'build', 'package.json'));
// Clean up the `./electron/build` folder.
shell.exec(`git -C ${path('..', 'build')} clean -ffxdq`, { async: false });
//----------------------------------------------------------------------------------------------+
// Copy the following items into the `working-copy` folder. Make sure to reuse the `yarn.lock`. |
@ -79,7 +77,7 @@
pkg = require('../working-copy/electron-app/package.json');
// @ts-ignore
const template = require('../build/template-package.json');
template.build.files = [ ...template.build.files, ...unusedDependencies.map(name => `!node_modules/${name}`) ];
template.build.files = [...template.build.files, ...unusedDependencies.map(name => `!node_modules/${name}`)];
pkg.dependencies = { ...pkg.dependencies, ...template.dependencies };
pkg.devDependencies = { ...pkg.devDependencies, ...template.devDependencies };
fs.writeFileSync(path('..', 'build', 'package.json'), JSON.stringify({
@ -95,6 +93,17 @@ ${fs.readFileSync(path('..', 'build', 'package.json')).toString()}
-----------------------
`);
// Make sure the original `yarn.lock` file is used from the electron application.
if (fs.existsSync(path('..', 'build', 'yarn.lock'))) {
echo(`${path('..', 'build', 'yarn.lock')} must not exist.`);
shell.exit(1);
}
cp('-rf', path(rootPath, 'yarn.lock'), path('..', 'build'));
if (!fs.existsSync(path('..', 'build', 'yarn.lock'))) {
echo(`${path('..', 'build', 'yarn.lock')} does not exist.`);
shell.exit(1);
}
//-------------------------------------------------------------------------------------------+
// Install all private and public dependencies for the electron application and build Theia. |
//-------------------------------------------------------------------------------------------+