Initialize project files
This commit is contained in:
parent
22a4cc1611
commit
643b2e0c88
16 changed files with 1833 additions and 0 deletions
47
scripts/linkFoundry.mjs
Normal file
47
scripts/linkFoundry.mjs
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import { existsSync } from "fs";
|
||||
import { symlink, unlink } from "fs/promises";
|
||||
import { join } from "path";
|
||||
import { config } from "dotenv";
|
||||
|
||||
config({ quiet: true });
|
||||
|
||||
const root = process.env.FOUNDRY_ROOT;
|
||||
|
||||
// Early exit
|
||||
if (!root) {
|
||||
console.error(`Must provide a FOUNDRY_ROOT environment variable`);
|
||||
process.exit(1);
|
||||
};
|
||||
|
||||
// Assert Foundry exists
|
||||
if (!existsSync(root)) {
|
||||
console.error(`Foundry root not found.`);
|
||||
process.exit(1);
|
||||
};
|
||||
|
||||
// Removing existing symlink
|
||||
if (existsSync(`foundry`)) {
|
||||
console.log(`Attempting to unlink foundry instance`);
|
||||
try {
|
||||
await unlink(`foundry`);
|
||||
} catch {
|
||||
console.error(`Failed to unlink foundry folder.`);
|
||||
process.exit(1);
|
||||
};
|
||||
};
|
||||
|
||||
// Account for if the root is pointing at an Electron install
|
||||
let targetRoot = root;
|
||||
if (existsSync(join(root, `resources`, `app`))) {
|
||||
console.log(`Switching to use the "${root}/resources/app" directory`);
|
||||
targetRoot = join(root, `resources`, `app`);
|
||||
};
|
||||
|
||||
// Create symlink
|
||||
console.log(`Linking foundry source into folder`);
|
||||
try {
|
||||
await symlink(targetRoot, `foundry`);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
};
|
||||
35
scripts/prepareManifest.mjs
Normal file
35
scripts/prepareManifest.mjs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
The intent of this script is to do all of the modifications of the manifest file
|
||||
that we need to do in order to release the package. This can include removing
|
||||
dev-only fields/attributes that end users will never, and should never, care
|
||||
about nor need.
|
||||
*/
|
||||
import { readFile, writeFile } from "fs/promises";
|
||||
|
||||
const MANIFEST_PATH = `module.json`;
|
||||
|
||||
let manifest;
|
||||
try {
|
||||
manifest = JSON.parse(await readFile(MANIFEST_PATH, `utf-8`));
|
||||
} catch {
|
||||
console.error(`Failed to parse manifest file.`);
|
||||
process.exit(1);
|
||||
};
|
||||
|
||||
|
||||
// Filter out dev-only resources
|
||||
if (manifest.esmodules) {
|
||||
manifest.esmodules = manifest.esmodules.filter(
|
||||
filepath => !filepath.startsWith(`dev/`)
|
||||
);
|
||||
};
|
||||
|
||||
// Remove dev flags
|
||||
delete manifest.flags?.hotReload;
|
||||
delete manifest.flags?.inDev;
|
||||
|
||||
if (Object.keys(manifest.flags).length === 0) {
|
||||
delete manifest.flags;
|
||||
};
|
||||
|
||||
await writeFile(MANIFEST_PATH, JSON.stringify(manifest, undefined, `\t`));
|
||||
Loading…
Add table
Add a link
Reference in a new issue