Merge branch 'develop' into renovate/apple-actions-import-codesign-certs-5.x
@ -0,0 +1,44 @@
|
||||
{
|
||||
"typescript": {
|
||||
"indentWidth": 4,
|
||||
"quoteStyle": "preferDouble",
|
||||
"semiColons": "prefer",
|
||||
"quoteProps": "asNeeded",
|
||||
"newLineKind": "lf",
|
||||
"lineWidth": 200,
|
||||
"trailingCommas": "never",
|
||||
"arrayPattern.spaceAround": true,
|
||||
"arrayExpression.spaceAround": true
|
||||
},
|
||||
"json": {
|
||||
},
|
||||
"markdown": {
|
||||
},
|
||||
"dockerfile": {
|
||||
},
|
||||
"malva": {
|
||||
},
|
||||
"markup": {
|
||||
},
|
||||
"yaml": {
|
||||
},
|
||||
"excludes": [
|
||||
"**/node_modules",
|
||||
"**/*-lock.json",
|
||||
"*.html",
|
||||
"*.md",
|
||||
"*.yml",
|
||||
"libraries/*",
|
||||
"docs/*",
|
||||
"src/public/app/doc_notes"
|
||||
],
|
||||
"plugins": [
|
||||
"https://plugins.dprint.dev/typescript-0.94.0.wasm",
|
||||
"https://plugins.dprint.dev/json-0.20.0.wasm",
|
||||
"https://plugins.dprint.dev/markdown-0.18.0.wasm",
|
||||
"https://plugins.dprint.dev/dockerfile-0.3.2.wasm",
|
||||
"https://plugins.dprint.dev/g-plane/malva-v0.11.1.wasm",
|
||||
"https://plugins.dprint.dev/g-plane/markup_fmt-v0.19.0.wasm",
|
||||
"https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.0.wasm"
|
||||
]
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
*.html
|
||||
*.md
|
||||
*.yml
|
||||
libraries/*
|
||||
docs/*
|
||||
src/public/app/doc_notes/**/*
|
||||
@ -1,22 +0,0 @@
|
||||
{
|
||||
"printWidth": 200,
|
||||
"tabWidth": 4,
|
||||
"useTabs": false,
|
||||
"semi": true,
|
||||
"singleQuote": false,
|
||||
"quoteProps": "as-needed",
|
||||
"trailingComma": "none",
|
||||
"bracketSpacing": true,
|
||||
"arrowParens": "always",
|
||||
"proseWrap": "preserve",
|
||||
"htmlWhitespaceSensitivity": "css",
|
||||
"endOfLine": "lf",
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.json"],
|
||||
"options": {
|
||||
"tabWidth": 2
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,109 @@
|
||||
import fs from "fs-extra";
|
||||
import path from "path";
|
||||
import type { Dirent } from "fs-extra";
|
||||
import { execSync } from "node:child_process";
|
||||
|
||||
/**
|
||||
* Example usage with node >= v22:
|
||||
* node --experimental-strip-types bin/cleanupNodeModules.ts /path/to/build/folder [--skip-prune-dev-deps]
|
||||
* Example usage with tsx:
|
||||
* tsx bin/cleanupNodeModules.ts /path/to/build/folder [--skip-prune-dev-deps]
|
||||
*/
|
||||
function main() {
|
||||
|
||||
if (process.argv.length > 4 || process.argv.length < 3) {
|
||||
console.error("Usage: cleanupNodeModules.ts [path-to-build-folder] [--skip-prune-dev-deps]");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const basePath = process.argv[2];
|
||||
const pruneDevDeps = process.argv[3] !== "--skip-prune-dev-deps";
|
||||
|
||||
if (!fs.existsSync(basePath)) {
|
||||
console.error(`Supplied path '${basePath}' does not exist. Aborting.`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(`Starting pruning of node_modules ${!pruneDevDeps ? '(skipping npm pruning)' : ''} in '${basePath}'...`);
|
||||
cleanupNodeModules(basePath, pruneDevDeps);
|
||||
console.log("Successfully pruned node_modules.");
|
||||
}
|
||||
|
||||
function cleanupNodeModules(basePath: string, pruneDevDeps: boolean = true) {
|
||||
|
||||
// This needs to run for the server and Docker build,
|
||||
// but needs to be skipped for electron-forge: its
|
||||
// built-in pruning takes care of it already
|
||||
if (pruneDevDeps) {
|
||||
execSync(`npm ci --omit=dev --prefix ${basePath}`);
|
||||
}
|
||||
|
||||
const nodeModulesDirPath = path.join(basePath, "node_modules");
|
||||
const nodeModulesContent = fs.readdirSync(nodeModulesDirPath, { recursive: true, withFileTypes: true });
|
||||
//const libDir = fs.readdirSync(path.join(basePath, "./libraries"), { recursive: true, withFileTypes: true });
|
||||
|
||||
/**
|
||||
* Delete unnecessary folders
|
||||
*/
|
||||
const filterableDirs = new Set([
|
||||
"demo",
|
||||
"demos",
|
||||
"doc",
|
||||
"docs",
|
||||
"example",
|
||||
"examples",
|
||||
"test",
|
||||
"tests"
|
||||
]);
|
||||
|
||||
nodeModulesContent
|
||||
.filter(el => el.isDirectory() && filterableDirs.has(el.name))
|
||||
.forEach(dir => removeDirent(dir));
|
||||
|
||||
/**
|
||||
* Delete unnecessary files based on file extension
|
||||
* TODO filter out useless (README).md files
|
||||
*/
|
||||
const filterableFileExt = new Set([
|
||||
"ts",
|
||||
"map"
|
||||
]);
|
||||
|
||||
nodeModulesContent
|
||||
// TriliumNextTODO: check if we can improve this naive file ext matching, without introducing any additional dependency
|
||||
.filter(el => el.isFile() && filterableFileExt.has(el.name.split(".").at(-1) || ""))
|
||||
.forEach(dir => removeDirent(dir));
|
||||
|
||||
|
||||
/**
|
||||
* Delete specific unnecessary folders
|
||||
* TODO: check if we want removeSync to throw an error, if path does not exist anymore -> currently it will silently fail
|
||||
*/
|
||||
const extraFoldersDelete = new Set([
|
||||
path.join(nodeModulesDirPath, ".bin"),
|
||||
path.join(nodeModulesDirPath, "@excalidraw", "excalidraw", "dist", "dev"),
|
||||
path.join(nodeModulesDirPath, "boxicons", "svg"),
|
||||
path.join(nodeModulesDirPath, "boxicons", "node_modules"),
|
||||
path.join(nodeModulesDirPath, "boxicons", "src"),
|
||||
path.join(nodeModulesDirPath, "boxicons", "iconjar"),
|
||||
path.join(nodeModulesDirPath, "@jimp", "plugin-print", "fonts"),
|
||||
path.join(nodeModulesDirPath, "jimp", "dist", "browser") // missing "@" in front of jimp is not a typo here
|
||||
]);
|
||||
|
||||
nodeModulesContent
|
||||
.filter(el => el.isDirectory() && extraFoldersDelete.has(path.join(el.parentPath, el.name)))
|
||||
.forEach(dir => removeDirent(dir))
|
||||
}
|
||||
|
||||
|
||||
function removeDirent(el: Dirent) {
|
||||
const elementToDelete = path.join(el.parentPath, el.name);
|
||||
fs.removeSync(elementToDelete);
|
||||
|
||||
if (process.env.VERBOSE) {
|
||||
console.log(`Deleted ${elementToDelete}`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
main()
|
||||
@ -1,44 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e # Fail on any command error
|
||||
shopt -s globstar
|
||||
|
||||
BUILD_DIR="./build"
|
||||
|
||||
if ! [[ $(which npm) ]]; then
|
||||
echo "Missing npm"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Trigger the build
|
||||
echo Build start
|
||||
npm run build:prepare-dist
|
||||
echo Build finished
|
||||
|
||||
# Patch package.json main
|
||||
sed -i 's|./dist/electron-main.js|electron-main.js|g' "$BUILD_DIR/package.json"
|
||||
|
||||
# run in subshell (so we return to original dir)
|
||||
(cd $BUILD_DIR && npm ci --omit=dev)
|
||||
|
||||
if [[ -d "$BUILD_DIR"/node_modules ]]; then
|
||||
# cleanup of useless files in dependencies
|
||||
for d in 'image-q/demo' \
|
||||
'@excalidraw/excalidraw/dist/excalidraw-assets-dev' '@excalidraw/excalidraw/dist/excalidraw.development.js' '@excalidraw/excalidraw/dist/excalidraw-with-preact.development.js' \
|
||||
'mermaid/dist/mermaid.js' \
|
||||
'boxicons/svg' 'boxicons/node_modules/react'/* \
|
||||
'@jimp/plugin-print/fonts' 'jimp/browser' 'jimp/fonts'; do
|
||||
[[ -e "$BUILD_DIR"/node_modules/"$d" ]] && rm -r "$BUILD_DIR"/node_modules/"$d"
|
||||
done
|
||||
|
||||
# delete all tests (there are often large images as test file for jimp etc.)
|
||||
for d in 'test' 'docs' 'demo' 'example'; do
|
||||
find "$BUILD_DIR"/node_modules -name "$d" -exec rm -rf {} +
|
||||
done
|
||||
fi
|
||||
|
||||
find $BUILD_DIR/libraries -name "*.map" -type f -delete
|
||||
find $BUILD_DIR/node_modules -name "*.map" -type f -delete
|
||||
find $BUILD_DIR -name "*.ts" -type f -delete
|
||||
|
||||
unset f d BUILD_DIR
|
||||
|
After Width: | Height: | Size: 348 B |
|
After Width: | Height: | Size: 427 B |
|
After Width: | Height: | Size: 514 B |
|
After Width: | Height: | Size: 649 B |
|
After Width: | Height: | Size: 331 B |
|
After Width: | Height: | Size: 409 B |
|
After Width: | Height: | Size: 481 B |
|
After Width: | Height: | Size: 626 B |