mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
A set of tweaks to simplify electron packaging (#421)
* Replace `ormconfig.js` with a newer mechanism of configuring
TypeORM that can be included in the source code properly.
The path to `ormconfig.js` has always been awkward to handle,
and eliminating the file makes building different Grist setups
a bit simpler.
* Remove `electron` package. It is barely used, just for some old
remnants of an older attempt at electron packaging. It was used
for two types, which I left at `any` for now. More code pruning is
no doubt possible here, but I'd rather do it when Electron packaging
has solidified.
* Add a hook for replacing the login system, and for adding some
extra middleware the login system may need.
* Add support for some more possible locations of Python, which
arise when a standalone version of it is included in the Electron
package. This isn't very general purpose, just configurations
that I found useful.
* Support using grist-core within a yarn workspace - the only tweak
needed was webpack related.
* Allow an external ID to be optionally associated with documents.
This commit is contained in:
@@ -9,14 +9,25 @@ import * as path from 'path';
|
||||
*/
|
||||
export const codeRoot = path.dirname(path.dirname(path.dirname(__dirname)));
|
||||
|
||||
let _cachedAppRoot: string|undefined;
|
||||
|
||||
/**
|
||||
* Returns the appRoot, i.e. the directory containing ./sandbox, ./node_modules, ./ormconfig.js,
|
||||
* Returns the appRoot, i.e. the directory containing ./sandbox, ./node_modules,
|
||||
* etc.
|
||||
*/
|
||||
export function getAppRoot(): string {
|
||||
if (_cachedAppRoot) { return _cachedAppRoot; }
|
||||
_cachedAppRoot = getAppRootWithoutCaching();
|
||||
return _cachedAppRoot;
|
||||
}
|
||||
|
||||
// Uncached version of getAppRoot()
|
||||
function getAppRootWithoutCaching(): string {
|
||||
if (process.env.APP_ROOT_PATH) { return process.env.APP_ROOT_PATH; }
|
||||
if (codeRoot.endsWith('/_build/core')) { return path.dirname(path.dirname(codeRoot)); }
|
||||
return codeRoot.endsWith('/_build') ? path.dirname(codeRoot) : codeRoot;
|
||||
if (codeRoot.endsWith('/_build/core') || codeRoot.endsWith('\\_build\\core')) {
|
||||
return path.dirname(path.dirname(codeRoot));
|
||||
}
|
||||
return (codeRoot.endsWith('/_build') || codeRoot.endsWith('\\_build')) ? path.dirname(codeRoot) : codeRoot;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -25,7 +36,14 @@ export function getAppRoot(): string {
|
||||
* which is that .asar file in packaged form, and returns a directory where
|
||||
* remaining files are available on the regular filesystem.
|
||||
*/
|
||||
export function getUnpackedAppRoot(appRoot: string): string {
|
||||
export function getUnpackedAppRoot(appRoot: string = getAppRoot()): string {
|
||||
if (path.basename(appRoot) == 'app.asar') {
|
||||
return path.resolve(path.dirname(appRoot), 'app.asar.unpacked');
|
||||
}
|
||||
if (path.dirname(appRoot).endsWith('app.asar')) {
|
||||
return path.resolve(path.dirname(path.dirname(appRoot)),
|
||||
'app.asar.unpacked', 'core');
|
||||
}
|
||||
return path.resolve(path.dirname(appRoot), path.basename(appRoot, '.asar'));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user