Add About screen, list of recently opened vaults, category filtering

This commit is contained in:
aet
2022-01-02 00:53:57 -05:00
parent 5883adc2c1
commit d8f2cddb74
27 changed files with 1108 additions and 558 deletions

View File

@ -0,0 +1,42 @@
#!/usr/bin/env node
const fs = require("fs")
const { resolve } = require("path")
const root = resolve(__dirname, "../../..")
const packages = [
root,
resolve(root, "packages/web"),
resolve(root, "packages/opvault.js"),
]
const readJSON = path => JSON.parse(fs.readFileSync(path, "utf-8"))
const infoMap = Object.fromEntries(
packages.flatMap(dir => {
const rootPkg = readJSON(resolve(dir, "package.json"))
const dependencies = Object.keys(rootPkg.dependencies || {})
return dependencies.map(dependency => {
const pkgDir = resolve(dir, "node_modules", dependency)
const pkg = readJSON(resolve(pkgDir, "package.json"))
const licenseFile = fs
.readdirSync(pkgDir)
.filter(x => x.toLowerCase().startsWith("license"))
if (licenseFile.length !== 1) {
console.error(fs.readdirSync(pkgDir))
throw new Error(`Cannot determine license file for ${pkg.name}`)
}
return [
pkg.name,
{
name: pkg.name,
author: pkg.author?.name ?? pkg.author,
license: fs.readFileSync(resolve(pkgDir, licenseFile[0]), "utf-8"),
},
]
})
})
)
fs.writeFileSync(
resolve(__dirname, "../src/third-party-licenses.json"),
JSON.stringify(infoMap, null, 2)
)

View File

@ -1,5 +1,7 @@
#!/bin/sh
npx vite build
NODE_ENV=production ./esbuild.js
./scripts/build-i18n-yml-typedef.js
./scripts/build-third-party-license.js
./scripts/build-package-json.js
./node_modules/.bin/electron-builder build

View File

@ -0,0 +1,41 @@
import * as babel from "@babel/core"
import type { PluginOption, TransformResult } from "vite"
const sourceRegex = /\.(j|t)sx?$/
export default function macrosPlugin(): PluginOption {
return {
name: "babel-macros",
enforce: "pre",
transform(source: string, filename: string) {
if (filename.includes("node_modules")) {
return undefined
}
if (!sourceRegex.test(filename)) {
return
}
const hasBabelMacro = source.includes('.macro"')
const hasEmotion = source.includes("@emotion")
if (!hasBabelMacro && !hasEmotion) {
return undefined
}
const result = babel.transformSync(source, {
filename,
parserOpts: {
plugins: ["jsx", "typescript", "decorators-legacy"],
},
plugins: [
hasBabelMacro && require.resolve("babel-plugin-macros"),
hasEmotion && require.resolve("@emotion/babel-plugin"),
].filter(Boolean),
generatorOpts: {
decoratorsBeforeExport: true,
},
babelrc: false,
configFile: false,
sourceMaps: true,
})
return result as TransformResult | null
},
}
}