mirror of
https://github.com/gustjose/obsidian-syncthing-manager.git
synced 2026-07-22 06:40:35 +00:00
chore: setup linter rules and release scripts
This commit is contained in:
parent
20a693e0a5
commit
6ee408e8e8
9 changed files with 5108 additions and 2362 deletions
|
|
@ -1,3 +0,0 @@
|
|||
node_modules/
|
||||
|
||||
main.js
|
||||
23
.eslintrc
23
.eslintrc
|
|
@ -1,23 +0,0 @@
|
|||
{
|
||||
"root": true,
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"env": { "node": true },
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
],
|
||||
"parserOptions": {
|
||||
"sourceType": "module"
|
||||
},
|
||||
"rules": {
|
||||
"no-unused-vars": "off",
|
||||
"@typescript-eslint/no-unused-vars": ["error", { "args": "none" }],
|
||||
"@typescript-eslint/ban-ts-comment": "off",
|
||||
"no-prototype-builtins": "off",
|
||||
"@typescript-eslint/no-empty-function": "off"
|
||||
}
|
||||
}
|
||||
52
eslint.config.js
Normal file
52
eslint.config.js
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
import tsparser from "@typescript-eslint/parser";
|
||||
import { defineConfig } from "eslint/config";
|
||||
import obsidianmd from "eslint-plugin-obsidianmd";
|
||||
import globals from "globals";
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
ignores: [
|
||||
"eslint.config.js",
|
||||
"node_modules/",
|
||||
"dist/",
|
||||
"main.js",
|
||||
"package.json",
|
||||
"package-lock.json"
|
||||
]
|
||||
},
|
||||
// 2. Configuração para os SCRIPTS (Node.js)
|
||||
{
|
||||
files: ["scripts/**/*.mjs", "scripts/**/*.js"],
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.node
|
||||
}
|
||||
}
|
||||
},
|
||||
// 3. Configuração do PLUGIN (Obsidian/Browser)
|
||||
...obsidianmd.configs.recommendedWithLocalesEn,
|
||||
{
|
||||
files: ["src/**/*.ts", "src/**/*.tsx"],
|
||||
languageOptions: {
|
||||
parser: tsparser,
|
||||
parserOptions: { project: "./tsconfig.json" },
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.es2021
|
||||
}
|
||||
},
|
||||
|
||||
rules: {
|
||||
"obsidianmd/sample-names": "off",
|
||||
"obsidianmd/ui/sentence-case": [
|
||||
"warn",
|
||||
{
|
||||
brands: ["Syncthing", "Obsidian", "GitHub", "Android"],
|
||||
acronyms: ["OK", "API", "URL", "HTTPS", "TLS", "IP", "ID"],
|
||||
enforceCamelCaseLower: true,
|
||||
allowAutoFix: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
]);
|
||||
7310
package-lock.json
generated
7310
package-lock.json
generated
File diff suppressed because it is too large
Load diff
17
package.json
17
package.json
|
|
@ -2,13 +2,15 @@
|
|||
"name": "syncthing-manager",
|
||||
"version": "1.0.9",
|
||||
"description": "Control panel for Syncthing. Monitor status, resolve conflicts, and force synchronization on Desktop and Mobile.",
|
||||
"type": "module",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"dev": "node scripts/esbuild.config.mjs",
|
||||
"build": "tsc -noEmit -skipLibCheck && node scripts/esbuild.config.mjs production",
|
||||
"version": "node scripts/version-bump.mjs && git add manifest.json versions.json",
|
||||
"test-cofre": "node scripts/install-vault.mjs",
|
||||
"sync-conflict": "node scripts/create-conflict.mjs"
|
||||
"sync-conflict": "node scripts/create-conflict.mjs",
|
||||
"build": "tsc -noEmit -skipLibCheck && node scripts/esbuild.config.mjs production",
|
||||
"version": "node scripts/version-bump.mjs",
|
||||
"lint": "eslint ."
|
||||
},
|
||||
"keywords": [
|
||||
"obsidian",
|
||||
|
|
@ -20,12 +22,13 @@
|
|||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/node": "^16.11.6",
|
||||
"@typescript-eslint/eslint-plugin": "5.29.0",
|
||||
"@typescript-eslint/parser": "5.29.0",
|
||||
"builtin-modules": "3.3.0",
|
||||
"esbuild": "0.17.3",
|
||||
"esbuild": "^0.27.0",
|
||||
"eslint": "^9.39.1",
|
||||
"eslint-plugin-obsidianmd": "^0.1.9",
|
||||
"globals": "^16.5.0",
|
||||
"obsidian": "latest",
|
||||
"tslib": "2.4.0",
|
||||
"typescript": "4.7.4"
|
||||
"typescript": "^4.8.4"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ console.log(`📂 Destino: ${targetDir}`);
|
|||
try {
|
||||
console.log('🔨 Compilando (npm run build)...');
|
||||
execSync('npm run build', { stdio: 'inherit' });
|
||||
} catch (e) {
|
||||
} catch {
|
||||
console.error('❌ Erro na compilação. Processo abortado.');
|
||||
process.exit(1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,59 @@
|
|||
import { readFileSync, writeFileSync } from "fs";
|
||||
import { readFileSync, writeFileSync, existsSync } from "fs";
|
||||
|
||||
const targetVersion = process.env.npm_package_version;
|
||||
// Pega argumentos ou variável de ambiente
|
||||
const args = process.argv.slice(2);
|
||||
let targetVersion = args[0] || process.env.npm_package_version;
|
||||
|
||||
// read minAppVersion from manifest.json and bump version to target version
|
||||
if (!targetVersion) {
|
||||
console.error("❌ Erro: Nenhuma versão especificada.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(`📦 Processando versão: ${targetVersion}`);
|
||||
|
||||
// --- BLOCO 1: ATUALIZAR MANIFEST.JSON ---
|
||||
const manifest = JSON.parse(readFileSync("manifest.json", "utf8"));
|
||||
const { minAppVersion } = manifest;
|
||||
manifest.version = targetVersion;
|
||||
writeFileSync("manifest.json", JSON.stringify(manifest, null, "\t"));
|
||||
console.log("✅ manifest.json atualizado");
|
||||
|
||||
// update versions.json with target version and minAppVersion from manifest.json
|
||||
// but only if the target version is not already in versions.json
|
||||
const versions = JSON.parse(readFileSync('versions.json', 'utf8'));
|
||||
// --- BLOCO 2: ATUALIZAR VERSIONS.JSON (Lógica Inteligente) ---
|
||||
const versions = JSON.parse(readFileSync("versions.json", "utf8"));
|
||||
|
||||
// Só adiciona se a "minAppVersion" ainda não existir nos valores
|
||||
if (!Object.values(versions).includes(minAppVersion)) {
|
||||
versions[targetVersion] = minAppVersion;
|
||||
writeFileSync('versions.json', JSON.stringify(versions, null, '\t'));
|
||||
writeFileSync("versions.json", JSON.stringify(versions, null, "\t"));
|
||||
console.log(`✅ versions.json atualizado (Novo requisito: ${minAppVersion})`);
|
||||
} else {
|
||||
console.log(`ℹ️ versions.json mantido (Requisito ${minAppVersion} já existe)`);
|
||||
}
|
||||
|
||||
// --- BLOCO 3: ATUALIZAR PACKAGE.JSON ---
|
||||
const pkg = JSON.parse(readFileSync("package.json", "utf8"));
|
||||
if (pkg.version !== targetVersion) {
|
||||
pkg.version = targetVersion;
|
||||
writeFileSync("package.json", JSON.stringify(pkg, null, "\t") + "\n");
|
||||
console.log("✅ package.json atualizado");
|
||||
}
|
||||
|
||||
// --- BLOCO 4: ATUALIZAR PACKAGE-LOCK.JSON ---
|
||||
if (existsSync("package-lock.json")) {
|
||||
const lock = JSON.parse(readFileSync("package-lock.json", "utf8"));
|
||||
let mudouLock = false;
|
||||
|
||||
if (lock.version !== targetVersion) {
|
||||
lock.version = targetVersion;
|
||||
mudouLock = true;
|
||||
}
|
||||
if (lock.packages && lock.packages[""] && lock.packages[""].version !== targetVersion) {
|
||||
lock.packages[""].version = targetVersion;
|
||||
mudouLock = true;
|
||||
}
|
||||
|
||||
if (mudouLock) {
|
||||
writeFileSync("package-lock.json", JSON.stringify(lock, null, "\t") + "\n");
|
||||
console.log("✅ package-lock.json atualizado");
|
||||
}
|
||||
}
|
||||
|
|
@ -32,7 +32,7 @@ export default {
|
|||
|
||||
// Settings - Connection
|
||||
setting_https_name: 'Use HTTPS',
|
||||
setting_https_desc: 'Important: keep this disabled for android/mobile to work correctly. Only enable if you have configured a valid tls certificate on your desktop.',
|
||||
setting_https_desc: 'Important: keep this disabled for Android/mobile to work correctly. Only enable if you have configured a valid TLS certificate on your desktop.',
|
||||
setting_host_name: 'IP address / host',
|
||||
setting_host_desc: 'The address where syncthing GUI is running. Use "127.0.0.1" for localhost.',
|
||||
setting_port_name: 'Port',
|
||||
|
|
@ -43,7 +43,8 @@ export default {
|
|||
|
||||
// Settings - Folder
|
||||
setting_folder_name: 'Vault folder ID',
|
||||
setting_folder_desc: 'Select the syncthing folder ID that matches this obsidian vault to track its specific status.',
|
||||
// eslint-disable-next-line obsidianmd/ui/sentence-case-locale-module
|
||||
setting_folder_desc: 'Select the Syncthing folder ID that matches this Obsidian vault to track its specific status.',
|
||||
dropdown_default: 'Select a folder...',
|
||||
dropdown_none: 'No folder selected',
|
||||
btn_search_folders: 'Fetch folders from syncthing',
|
||||
|
|
|
|||
|
|
@ -325,7 +325,7 @@ export default class SyncthingController extends Plugin {
|
|||
// --- Data Persistence ---
|
||||
|
||||
async loadSettings() {
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, (await this.loadData()) as typeof DEFAULT_SETTINGS);
|
||||
|
||||
if (this.settings.syncthingHost === 'device-specific') this.settings.syncthingHost = '';
|
||||
if (this.settings.syncthingPort === 'device-specific') this.settings.syncthingPort = '';
|
||||
|
|
|
|||
Loading…
Reference in a new issue