Skip to content

Commit 3c279f2

Browse files
committed
feat(options): enhance ux and options page
1 parent f5ba741 commit 3c279f2

File tree

21 files changed

+773
-504
lines changed

21 files changed

+773
-504
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ jobs:
4545
run: pnpm install
4646

4747
- name: Build application
48+
env:
49+
NODE_ENV: production
4850
run: pnpm build
4951

5052
- name: Release

build.mjs

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import archiver from 'archiver'
2-
import autoprefixer from 'autoprefixer'
3-
import * as dotenv from 'dotenv'
4-
import esbuild from 'esbuild'
5-
import postcssPlugin from 'esbuild-style-plugin'
6-
import fs from 'fs-extra'
7-
import process from 'node:process'
8-
import tailwindcss from 'tailwindcss'
9-
import getManifest from "./src/manifest.json.cjs"
1+
import archiver from 'archiver';
2+
import autoprefixer from 'autoprefixer';
3+
import * as dotenv from 'dotenv';
4+
import esbuild from 'esbuild';
5+
import postcssPlugin from 'esbuild-style-plugin';
6+
import fs from 'fs-extra';
7+
import process from 'node:process';
8+
import tailwindcss from 'tailwindcss';
9+
import getManifest from './src/manifest.json.cjs';
1010

11-
dotenv.config()
11+
dotenv.config();
1212

13-
const outdir = 'build'
13+
const outdir = 'build';
1414

1515
const env = JSON.stringify(process.env.NODE_ENV || 'production');
1616

1717
async function deleteOldDir() {
18-
await fs.remove(outdir)
18+
await fs.remove(outdir);
1919
}
2020

2121
async function runEsbuild() {
@@ -28,11 +28,13 @@ async function runEsbuild() {
2828
bundle: true,
2929
outdir: outdir,
3030
treeShaking: true,
31-
minify: env === 'production'? true: false,
31+
minify: env === 'production' ? true : false,
3232
legalComments: 'none',
3333
define: {
3434
'process.env.NODE_ENV': env,
35-
'process.env.AXIOM_TOKEN': JSON.stringify(process.env.AXIOM_TOKEN || 'UNDEFINED'),
35+
'process.env.AXIOM_TOKEN': JSON.stringify(
36+
process.env.AXIOM_TOKEN || 'UNDEFINED',
37+
),
3638
},
3739
jsxFragment: 'Fragment',
3840
jsx: 'automatic',
@@ -46,31 +48,31 @@ async function runEsbuild() {
4648
},
4749
}),
4850
],
49-
})
51+
});
5052
}
5153

5254
async function zipFolder(dir) {
53-
const output = fs.createWriteStream(`${dir}.zip`)
55+
const output = fs.createWriteStream(`${dir}.zip`);
5456
const archive = archiver('zip', {
5557
zlib: { level: 9 },
56-
})
57-
archive.pipe(output)
58-
archive.directory(dir, false)
59-
await archive.finalize()
58+
});
59+
archive.pipe(output);
60+
archive.directory(dir, false);
61+
await archive.finalize();
6062
}
6163

6264
async function copyFiles(entryPoints, targetDir) {
63-
await fs.ensureDir(targetDir)
65+
await fs.ensureDir(targetDir);
6466
await Promise.all(
6567
entryPoints.map(async (entryPoint) => {
66-
await fs.copy(entryPoint.src, `${targetDir}/${entryPoint.dst}`)
68+
await fs.copy(entryPoint.src, `${targetDir}/${entryPoint.dst}`);
6769
}),
68-
)
70+
);
6971
}
7072

7173
async function build() {
72-
await deleteOldDir()
73-
await runEsbuild()
74+
await deleteOldDir();
75+
await runEsbuild();
7476

7577
const commonFiles = [
7678
{ src: 'build/content/index.js', dst: 'content-script.js' },
@@ -80,25 +82,25 @@ async function build() {
8082
{ src: 'build/options/index.css', dst: 'options.css' },
8183
{ src: 'src/pages/options/index.html', dst: 'options.html' },
8284
{ src: 'src/assets', dst: 'assets' },
83-
]
85+
];
8486

8587
// chromium
86-
await copyFiles(
87-
[...commonFiles],
88-
`./${outdir}/chrome`,
89-
)
90-
await fs.writeFile(`./${outdir}/chrome/manifest.json`, JSON.stringify(getManifest('chrome')))
91-
await zipFolder(`./${outdir}/chrome`)
88+
await copyFiles([...commonFiles], `./${outdir}/chrome`);
89+
await fs.writeFile(
90+
`./${outdir}/chrome/manifest.json`,
91+
JSON.stringify(getManifest('chrome')),
92+
);
93+
await zipFolder(`./${outdir}/chrome`);
9294

9395
// edge
94-
await copyFiles(
95-
[...commonFiles],
96-
`./${outdir}/edge`,
97-
)
98-
await fs.writeFile(`./${outdir}/edge/manifest.json`, JSON.stringify(getManifest('edge')))
99-
await zipFolder(`./${outdir}/edge`)
96+
await copyFiles([...commonFiles], `./${outdir}/edge`);
97+
await fs.writeFile(
98+
`./${outdir}/edge/manifest.json`,
99+
JSON.stringify(getManifest('edge')),
100+
);
101+
await zipFolder(`./${outdir}/edge`);
100102

101-
console.log('Build success.')
103+
console.log('Build success.');
102104
}
103105

104-
build()
106+
build();

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "logseq-copliot",
3-
"version": "0.0.1",
3+
"version": "0.0.5",
44
"description": "Logseq Copilot, Connect with you logseq API server, bring your information when you browsing.",
55
"license": "MIT",
66
"repository": {
@@ -15,8 +15,8 @@
1515
},
1616
"dependencies": {
1717
"@chakra-ui/react": "^2.4.9",
18-
"@emotion/react": "^11.10.5",
19-
"@emotion/styled": "^11.10.5",
18+
"@emotion/react": "^11.10.6",
19+
"@emotion/styled": "^11.10.6",
2020
"@tailwindcss/typography": "^0.5.9",
2121
"@types/marked": "^4.0.8",
2222
"axios": "^1.3.2",
@@ -67,4 +67,4 @@
6767
"type-fest": "^3.5.2",
6868
"typescript": "^4.9.4"
6969
}
70-
}
70+
}

0 commit comments

Comments
 (0)