Skip to content

Commit eefd728

Browse files
authored
Merge pull request #25 from firstsun-dev/issue-23-code-quality
feat: support hidden file sync and expand binary extension list
2 parents d41d98d + 8d7a25f commit eefd728

25 files changed

Lines changed: 1068 additions & 128 deletions
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import esbuild from "esbuild";
2+
import process from "process";
3+
import builtins from 'builtin-modules'
4+
5+
const banner =
6+
`/*
7+
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
8+
if you want to view the source, please visit the github repository of this plugin
9+
*/
10+
`;
11+
12+
const prod = (process.argv[2] === 'production');
13+
14+
const buildOptions = {
15+
banner: {
16+
js: banner,
17+
},
18+
entryPoints: ['src/main.ts'],
19+
bundle: true,
20+
external: [
21+
'obsidian',
22+
'electron',
23+
'@codemirror/autocomplete',
24+
'@codemirror/collab',
25+
'@codemirror/commands',
26+
'@codemirror/language',
27+
'@codemirror/lint',
28+
'@codemirror/search',
29+
'@codemirror/state',
30+
'@codemirror/view',
31+
'@lezer/common',
32+
'@lezer/highlight',
33+
'@lezer/lr',
34+
...builtins],
35+
format: 'cjs',
36+
target: 'es2018',
37+
logLevel: "info",
38+
sourcemap: prod ? false : 'inline',
39+
treeShaking: true,
40+
outfile: 'main.js',
41+
};
42+
43+
if (prod) {
44+
esbuild.build(buildOptions).catch(() => process.exit(1));
45+
} else {
46+
esbuild.context(buildOptions).then(ctx => ctx.watch()).catch(() => process.exit(1));
47+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"id": "my-plugin-id",
3+
"name": "My Plugin Name",
4+
"version": "1.0.0",
5+
"minAppVersion": "1.4.0",
6+
"description": "A concise description under 250 characters that explains exactly what this plugin does for the user.",
7+
"author": "Your Name",
8+
"authorUrl": "https://your-website.com",
9+
"isDesktopOnly": false
10+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Minimal stub so uploader.ts can be imported in the test environment
2+
export const requestUrl = () => Promise.resolve({ headers: {}, status: 200, arrayBuffer: new ArrayBuffer(0) });
3+
export type RequestUrlParam = unknown;
4+
export class Notice { constructor(_msg: string) {} }
5+
export class Plugin {}
6+
export class PluginSettingTab {}
7+
export class Setting {}
8+
export class TextComponent {}
9+
export const setIcon = () => {};
10+
export class TFile {}
11+
export class MarkdownView {}
12+
export class Editor {}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"name": "watermark-s3-uploader",
3+
"version": "1.1.0",
4+
"description": "Obsidian plugin: upload images to Cloudflare R2 with WebP conversion and watermark support.",
5+
"main": "main.js",
6+
"scripts": {
7+
"dev": "node esbuild.config.mjs",
8+
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
9+
"version": "node version-bump.mjs && git add manifest.json versions.json",
10+
"deploy": "node esbuild.config.mjs production && cp main.js manifest.json styles.css ../../src/content/.obsidian/plugins/watermark-s3-uploader/",
11+
"prepare": "husky",
12+
"lint": "eslint src/",
13+
"test": "vitest run",
14+
"semantic-release": "npx semantic-release"
15+
},
16+
"keywords": [],
17+
"author": "ClaudiaFang",
18+
"license": "MIT",
19+
"engines": {
20+
"node": ">=20"
21+
},
22+
"devDependencies": {
23+
"@semantic-release/changelog": "^6.0.3",
24+
"@semantic-release/exec": "^6.0.3",
25+
"@semantic-release/git": "^10.0.1",
26+
"@semantic-release/github": "^10.3.5",
27+
"@semantic-release/npm": "^12.0.1",
28+
"@types/mime-types": "^2.1.1",
29+
"@types/node": "^20.19.37",
30+
"@vitest/coverage-v8": "4.1.5",
31+
"browser-resolve": "^2.0.0",
32+
"builtin-modules": "3.3.0",
33+
"conventional-changelog-conventionalcommits": "^8.0.0",
34+
"detective": "^5.2.1",
35+
"esbuild": "^0.27.0",
36+
"eslint": "^9.0.0",
37+
"eslint-plugin-obsidianmd": "^0.2.4",
38+
"eslint-plugin-sonarjs": "^4.0.3",
39+
"globals": "^16.0.0",
40+
"husky": "^9.1.7",
41+
"jiti": "^2.0.0",
42+
"obsidian": "^1.12.3",
43+
"process": "^0.11.10",
44+
"semantic-release": "^24.2.3",
45+
"tslib": "2.4.0",
46+
"typescript": "^5.0.0",
47+
"typescript-eslint": "^8.0.0",
48+
"vitest": "4.1.5"
49+
},
50+
"dependencies": {
51+
"@aws-sdk/client-s3": "^3.1019.0",
52+
"@aws-sdk/fetch-http-handler": "^3.310.0",
53+
"@aws-sdk/protocol-http": "^3.310.0",
54+
"@aws-sdk/querystring-builder": "^3.310.0",
55+
"@aws-sdk/types": "^3.310.0",
56+
"@smithy/fetch-http-handler": "^2.2.7",
57+
"browser-image-compression": "^2.0.2",
58+
"filesize": "^10.1.6",
59+
"minimatch": "^10.2.3"
60+
}
61+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: CI/CD
2+
3+
permissions:
4+
contents: write
5+
issues: write
6+
pull-requests: write
7+
8+
on:
9+
push:
10+
branches: [main, master, '**']
11+
pull_request:
12+
types: [opened, synchronize, reopened]
13+
14+
jobs:
15+
CI:
16+
uses: firstsun-dev/.github/.github/workflows/obsidian-plugin-ci.yml@main
17+
with:
18+
plugin-id: "watermark-image-bucket-uploader"
19+
secrets:
20+
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { defineConfig } from "vitest/config";
2+
3+
export default defineConfig({
4+
test: {
5+
environment: "node",
6+
coverage: {
7+
reporter: ["text", "lcov", "html"],
8+
exclude: ["node_modules/**", "tests/**"],
9+
include: ["src/**"],
10+
all: true,
11+
},
12+
},
13+
resolve: {
14+
alias: {
15+
obsidian: new URL("./tests/__mocks__/obsidian.ts", import.meta.url).pathname,
16+
},
17+
},
18+
});

.claude/skills/obsidian-development/SKILL.md

Lines changed: 0 additions & 61 deletions
This file was deleted.

.claude/skills/obsidian-development/evals/evals.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

.claude/skills/obsidian-development/references/pr-template.md

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/workflows/codeql.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [ "main", "master" ]
6+
pull_request:
7+
branches: [ "main", "master" ]
8+
schedule:
9+
- cron: '30 1 * * 1'
10+
11+
jobs:
12+
analyze:
13+
name: Analyze
14+
runs-on: ubuntu-latest
15+
permissions:
16+
actions: read
17+
contents: read
18+
security-events: write
19+
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
language: [ 'javascript-typescript' ]
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Initialize CodeQL
30+
uses: github/codeql-action/init@v3
31+
with:
32+
languages: ${{ matrix.language }}
33+
# Queries can be 'security-extended' or 'security-and-quality'
34+
queries: security-extended
35+
36+
- name: Auto-build
37+
uses: github/codeql-action/autobuild@v3
38+
39+
- name: Perform CodeQL Analysis
40+
uses: github/codeql-action/analyze@v3
41+
with:
42+
category: "/language:${{matrix.language}}"

0 commit comments

Comments
 (0)