From b62a565c8aceb160fa92646d690efda0a9460cf8 Mon Sep 17 00:00:00 2001 From: vorotamoroz Date: Fri, 12 Jun 2026 05:10:18 +0100 Subject: [PATCH] trial: monoreponised some trivial fix --- .prettierignore | 1 + .../trystero/TrysteroReplicatorP2PServer.d.ts | 2 +- eslint.config.common.mjs | 67 +++++++++ eslint.config.mjs | 70 ++-------- package-lock.json | 130 +++++++++++++++++- package.json | 9 +- src/apps/cli/eslint.config.mjs | 19 +++ src/apps/cli/package.json | 94 ++++++++++++- src/apps/cli/scripts/apply-package.mjs | 28 ++++ src/apps/cli/tsconfig.json | 16 +-- src/apps/webapp/eslint.config.mjs | 18 +++ src/apps/webapp/package.json | 4 +- src/apps/webpeer/eslint.config.mjs | 28 ++++ src/apps/webpeer/package.json | 5 +- src/apps/webpeer/src/UITest.svelte | 2 +- .../ObsidianLiveSyncSettingTab.ts | 2 +- tsconfig.json | 2 +- tsconfig.types.json | 2 +- utilsdeno/deno.lock | 3 +- utilsdeno/types-add-ignore.ts | 58 ++++++++ 20 files changed, 476 insertions(+), 84 deletions(-) create mode 100644 eslint.config.common.mjs create mode 100644 src/apps/cli/eslint.config.mjs create mode 100644 src/apps/cli/scripts/apply-package.mjs create mode 100644 src/apps/webapp/eslint.config.mjs create mode 100644 src/apps/webpeer/eslint.config.mjs create mode 100644 utilsdeno/types-add-ignore.ts diff --git a/.prettierignore b/.prettierignore index 91ec641..3856cb0 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,2 +1,3 @@ pouchdb-browser.js main_org.js +_types \ No newline at end of file diff --git a/_types/src/lib/src/replication/trystero/TrysteroReplicatorP2PServer.d.ts b/_types/src/lib/src/replication/trystero/TrysteroReplicatorP2PServer.d.ts index 473d5a2..553a2a5 100644 --- a/_types/src/lib/src/replication/trystero/TrysteroReplicatorP2PServer.d.ts +++ b/_types/src/lib/src/replication/trystero/TrysteroReplicatorP2PServer.d.ts @@ -93,7 +93,7 @@ export declare class TrysteroReplicatorP2PServer { _acceptablePeers: Computed<[settings: P2PSyncSetting], RegExp[]>; _shouldDenyPeers: Computed<[settings: P2PSyncSetting], RegExp[]>; isAcceptablePeer(peerId: string): Promise; - __send(data: Payload, peerId: string): Promise; + __send(data: Payload, peerId: string): Promise; processArrivedRPC(data: Payload, peerId: string): Promise; private _onPeerJoin; private _onPeerLeave; diff --git a/eslint.config.common.mjs b/eslint.config.common.mjs new file mode 100644 index 0000000..97d2ca7 --- /dev/null +++ b/eslint.config.common.mjs @@ -0,0 +1,67 @@ +import tsParser from "@typescript-eslint/parser"; +import tsPlugin from "@typescript-eslint/eslint-plugin"; +import svelteParser from "svelte-eslint-parser"; + +const warnWhileDev = "off"; + +export const tsBaseRules = { + // -- Base rules (turned off in favour of TS specific versions or explicitly disabled). + "no-unused-vars": "off", + "no-unused-labels": "off", + "no-prototype-builtins": "off", + "require-await": "off", + // -- TypeScript specific rules + "@typescript-eslint/no-explicit-any": "warn", + "@typescript-eslint/no-redundant-type-constituents": "warn", + "@typescript-eslint/no-unsafe-argument": "off", + "@typescript-eslint/no-unsafe-call": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + "@typescript-eslint/no-unsafe-return": "off", + "@typescript-eslint/no-unsafe-assignment": "off", + "@typescript-eslint/no-deprecated": warnWhileDev, + "@typescript-eslint/no-unused-vars": ["error", { args: "none" }], + "@typescript-eslint/ban-ts-comment": "off", + "@typescript-eslint/no-empty-function": "off", + "@typescript-eslint/require-await": "error", + "@typescript-eslint/no-misused-promises": "error", + "@typescript-eslint/no-floating-promises": "error", + "@typescript-eslint/no-unnecessary-type-assertion": "error", + + // -- General rules + "no-async-promise-executor": warnWhileDev, + "no-constant-condition": ["error", { checkLoops: false }], + "no-undef": "off", +}; + +export const tsBaseConfig = { + files: ["**/*.ts"], + plugins: { + "@typescript-eslint": tsPlugin, + }, + languageOptions: { + parser: tsParser, + parserOptions: { + project: "./tsconfig.json", + rootDir: "./", + }, + }, + rules: tsBaseRules, +}; + +export const svelteBaseConfig = { + files: ["**/*.svelte"], + plugins: { + "@typescript-eslint": tsPlugin, + }, + languageOptions: { + parser: svelteParser, + parserOptions: { + parser: tsParser, + extraFileExtensions: [".svelte"], + rootDir: "./", + }, + }, + rules: { + "no-unused-vars": "off", + }, +}; diff --git a/eslint.config.mjs b/eslint.config.mjs index ae8a6b6..1c1e1b3 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -5,6 +5,7 @@ import { defineConfig, globalIgnores } from "eslint/config"; import * as sveltePlugin from "eslint-plugin-svelte"; import svelteParser from "svelte-eslint-parser"; import importAlias from "@dword-design/eslint-plugin-import-alias"; +import { tsBaseConfig, svelteBaseConfig } from "./eslint.config.common.mjs"; const warnWhileDev = "off"; // Change to "warn" to enable warnings for rules that are currently disabled. export default defineConfig([ globalIgnores([ @@ -57,63 +58,21 @@ export default defineConfig([ ...obsidianmd.configs.recommended, importAlias.configs.recommended, { - files: ["**/*.ts"], - // ignores:["src/lib/**/*.ts"], // Exclude library files from root linting (they have different environments and rules). + ...tsBaseConfig, languageOptions: { + ...tsBaseConfig.languageOptions, globals: { ...globals.browser, PouchDB: "readonly" }, - parser: tsParser, - parserOptions: { - project: "./tsconfig.json", - }, }, - linterOptions: { - reportUnusedDisableDirectives: false, + plugins: { + ...tsBaseConfig.plugins, }, rules: { - // -- Base rules (turned off in favour of TS specific versions or explicitly disabled). - "no-unused-vars": "off", - "no-unused-labels": "off", - "no-prototype-builtins": "off", - "require-await": "off", - // -- TypeScript specific rules (Gradual adoption of stricter rules, currently set to 'warn' for a while). - "@typescript-eslint/no-explicit-any": "warn", - "@typescript-eslint/no-redundant-type-constituents": "warn", - // -- TypeScript specific rules - // @typescript-eslint/no-unsafe-* rules and @typescript-eslint/no-explicit-any: - // This project contains a lot of library-sh code where the use of `any` is often necessary and justified. - // Rules is now set to 'off' for a while. - "@typescript-eslint/no-unsafe-argument": "off", - "@typescript-eslint/no-unsafe-call": "off", - "@typescript-eslint/no-unsafe-member-access": "off", - "@typescript-eslint/no-unsafe-return": "off", - "@typescript-eslint/no-unsafe-assignment": "off", - // -- Reasonable rules. - "@typescript-eslint/no-deprecated": warnWhileDev, - "@typescript-eslint/no-unused-vars": ["error", { args: "none" }], - "@typescript-eslint/ban-ts-comment": "off", - "@typescript-eslint/no-empty-function": "off", - "@typescript-eslint/require-await": "error", - "@typescript-eslint/no-misused-promises": "error", - "@typescript-eslint/no-floating-promises": "error", - "@typescript-eslint/no-unnecessary-type-assertion": "error", - + ...tsBaseConfig.rules, // -- Obsidian rules - // obsidianmd/no-unsupported-api: usually this project checks for API support at runtime, so this rule is not critical but can be helpful to catch potential issues. "obsidianmd/no-unsupported-api": warnWhileDev, - - // -- General rules - "no-async-promise-executor": warnWhileDev, - "no-constant-condition": ["error", { checkLoops: false }], - // -- Disabled rules - // no-undef: This option breaks the global declarations for the library files and is not worth the effort to fix at this time. - "no-undef": "off", - - // -- Plugin specific overrides "obsidianmd/rule-custom-message": "off", "obsidianmd/ui/sentence-case": "off", "obsidianmd/no-plugin-as-component": "off", - - // -- Temporary overrides for migration "obsidianmd/no-static-styles-assignment": "off", // -- Project specific rules @@ -130,21 +89,16 @@ export default defineConfig([ }, }, { - files: ["**/*.svelte"], + ...svelteBaseConfig, languageOptions: { + ...svelteBaseConfig.languageOptions, globals: { ...globals.browser, PouchDB: "readonly" }, - parser: svelteParser, - parserOptions: { - parser: tsParser, - extraFileExtensions: [".svelte"], - project: "./tsconfig.json", - }, + }, + plugins: { + ...svelteBaseConfig.plugins, }, rules: { - // no-unused-vars: - // Svelte template's declarations have a lot of false positives and the rule is not worth the effort to fix at this time. - // it may improve in the future with some options as like ["error", { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }],] - "no-unused-vars": "off", + ...svelteBaseConfig.rules, "obsidianmd/no-plugin-as-component": "off", "obsidianmd/ui/sentence-case": "off", "@dword-design/import-alias/prefer-alias": [ diff --git a/package-lock.json b/package-lock.json index 5103114..f0add2a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,11 @@ "name": "obsidian-livesync", "version": "0.25.74", "license": "MIT", + "workspaces": [ + "src/apps/cli", + "src/apps/webpeer", + "src/apps/webapp" + ], "dependencies": { "@aws-sdk/client-s3": "^3.808.0", "@smithy/fetch-http-handler": "^5.3.10", @@ -4695,7 +4700,6 @@ "integrity": "sha512-SR7FqgegaexEg73xvf3ArtygXegagMdXnL0EZMpxrWvvhQxvicD/E8p0ib0J91riPRtQUViyh67Xjw3NqvyhVg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@vitest/browser": "4.1.8", "@vitest/mocker": "4.1.8", @@ -4720,7 +4724,6 @@ "integrity": "sha512-lt3kovsyHwYe00wq4D1ti0Z974fWj4NLp6siqiyEufUpyFwK9Yhi7rBhac9JL5aA0zoMrJqc4vYPZRUnI7l7nw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@bcoe/v8-coverage": "^1.0.2", "@vitest/utils": "4.1.8", @@ -10585,6 +10588,10 @@ "uc.micro": "^2.0.0" } }, + "node_modules/livesync-webapp": { + "resolved": "src/apps/webapp", + "link": true + }, "node_modules/locate-app": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/locate-app/-/locate-app-2.5.0.tgz", @@ -11733,7 +11740,6 @@ "integrity": "sha512-vA30H8Nvkq/cPBnNw4Q8TWz1EJyqgpuinBcHET0YVJVFldr8JDNiU9LaWAE1KqSkRYazuaBhTpB5ZzShOezQ6A==", "dev": true, "license": "Apache-2.0", - "peer": true, "dependencies": { "playwright-core": "1.58.2" }, @@ -12853,6 +12859,10 @@ "dev": true, "license": "MIT" }, + "node_modules/self-hosted-livesync-cli": { + "resolved": "src/apps/cli", + "link": true + }, "node_modules/semver": { "version": "7.8.1", "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.1.tgz", @@ -15845,6 +15855,10 @@ "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", "license": "BSD-2-Clause" }, + "node_modules/webpeer": { + "resolved": "src/apps/webpeer", + "link": true + }, "node_modules/werift": { "version": "0.23.0", "resolved": "https://registry.npmjs.org/werift/-/werift-0.23.0.tgz", @@ -16517,6 +16531,116 @@ "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } + }, + "src/apps/cli": { + "name": "self-hosted-livesync-cli", + "version": "0.25.74-cli", + "dependencies": { + "@aws-sdk/client-s3": "^3.808.0", + "@smithy/fetch-http-handler": "^5.3.10", + "@smithy/md5-js": "^4.2.9", + "@smithy/middleware-apply-body-checksum": "^4.3.9", + "@smithy/protocol-http": "^5.3.9", + "@smithy/querystring-builder": "^4.2.9", + "@smithy/types": "^4.14.3", + "@smithy/util-retry": "^4.4.5", + "@trystero-p2p/nostr": "^0.24.0", + "chokidar": "^4.0.0", + "diff-match-patch": "^1.0.5", + "fflate": "^0.8.2", + "idb": "^8.0.3", + "markdown-it": "^14.1.1", + "minimatch": "^10.2.2", + "obsidian": "^1.12.3", + "octagonal-wheels": "^0.1.46", + "pouchdb-adapter-leveldb": "^9.0.0", + "qrcode-generator": "^1.4.4", + "werift": "^0.23.0", + "xxhash-wasm-102": "npm:xxhash-wasm@^1.0.2" + }, + "devDependencies": { + "@dword-design/eslint-plugin-import-alias": "^8.1.8", + "@eslint/js": "^9.39.3", + "@sveltejs/vite-plugin-svelte": "^6.2.4", + "@tsconfig/svelte": "^5.0.8", + "@types/deno": "^2.5.0", + "@types/diff-match-patch": "^1.0.36", + "@types/markdown-it": "^14.1.2", + "@types/micromatch": "^4.0.10", + "@types/node": "^24.10.13", + "@types/pouchdb": "^6.4.2", + "@types/pouchdb-adapter-http": "^6.1.6", + "@types/pouchdb-adapter-idb": "^6.1.7", + "@types/pouchdb-browser": "^6.1.5", + "@types/pouchdb-core": "^7.0.15", + "@types/pouchdb-mapreduce": "^6.1.10", + "@types/pouchdb-replication": "^6.4.7", + "@types/transform-pouch": "^1.0.6", + "@typescript-eslint/eslint-plugin": "^8.61.0", + "@typescript-eslint/parser": "8.61.0", + "@vitest/browser": "^4.1.8", + "@vitest/browser-playwright": "^4.1.8", + "@vitest/coverage-v8": "^4.1.8", + "dotenv-cli": "^11.0.0", + "esbuild": "0.25.0", + "esbuild-plugin-inline-worker": "^0.1.1", + "esbuild-svelte": "^0.9.4", + "eslint": "^9.39.3", + "eslint-plugin-obsidianmd": "^0.3.0", + "eslint-plugin-svelte": "^3.15.0", + "events": "^3.3.0", + "globals": "^14.0.0", + "playwright": "^1.58.2", + "postcss": "^8.5.6", + "pouchdb-adapter-http": "^9.0.0", + "pouchdb-adapter-idb": "^9.0.0", + "pouchdb-adapter-indexeddb": "^9.0.0", + "pouchdb-adapter-memory": "^9.0.0", + "pouchdb-core": "^9.0.0", + "pouchdb-errors": "^9.0.0", + "pouchdb-find": "^9.0.0", + "pouchdb-mapreduce": "^9.0.0", + "pouchdb-merge": "^9.0.0", + "pouchdb-replication": "^9.0.0", + "pouchdb-utils": "^9.0.0", + "prettier": "3.8.1", + "rollup-plugin-copy": "^3.5.0", + "svelte": "5.41.1", + "svelte-check": "^4.4.3", + "svelte-eslint-parser": "^1.8.0", + "svelte-preprocess": "^6.0.3", + "terser": "^5.39.0", + "tinyglobby": "^0.2.15", + "transform-pouch": "^2.0.0", + "tsx": "^4.21.0", + "typescript": "5.9.3", + "typescript-eslint": "^8.61.0", + "vite": "^7.3.1", + "vite-plugin-istanbul": "^8.0.0", + "vitest": "^4.1.8", + "webdriverio": "^9.27.0", + "yaml": "^2.8.2" + } + }, + "src/apps/webapp": { + "name": "livesync-webapp", + "version": "0.0.1", + "devDependencies": { + "typescript": "5.9.3", + "vite": "^7.3.1" + } + }, + "src/apps/webpeer": { + "version": "0.0.0", + "devDependencies": { + "@sveltejs/vite-plugin-svelte": "^6.2.4", + "@tsconfig/svelte": "^5.0.8", + "eslint-plugin-svelte": "^3.15.0", + "svelte": "5.41.1", + "svelte-check": "^4.4.3", + "typescript": "5.9.3", + "vite": "^7.3.1" + } } } } diff --git a/package.json b/package.json index dd05a0d..f68919d 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "dev": "node --env-file=.env esbuild.config.mjs", "prebuild": "npm run bakei18n", "build": "node esbuild.config.mjs production", - "lib:build:types":"node generate-types.mjs", + "lib:build:types": "node generate-types.mjs", "postbuild": "npm run lib:build:types", "buildVite": "npx dotenv-cli -e .env -- vite build --mode production", "buildViteOriginal": "npx dotenv-cli -e .env -- vite build --mode original", @@ -147,5 +147,10 @@ "qrcode-generator": "^1.4.4", "werift": "^0.23.0", "xxhash-wasm-102": "npm:xxhash-wasm@^1.0.2" - } + }, + "workspaces": [ + "src/apps/cli", + "src/apps/webpeer", + "src/apps/webapp" + ] } diff --git a/src/apps/cli/eslint.config.mjs b/src/apps/cli/eslint.config.mjs new file mode 100644 index 0000000..e591fc7 --- /dev/null +++ b/src/apps/cli/eslint.config.mjs @@ -0,0 +1,19 @@ +import { tsBaseConfig } from "../../../eslint.config.common.mjs"; +import globals from "globals"; +import { defineConfig, globalIgnores } from "eslint/config"; + +export default defineConfig([ + globalIgnores([ + "dist", + "node_modules", + "test", + "testdeno" + ]), + { + ...tsBaseConfig, + languageOptions: { + ...tsBaseConfig.languageOptions, + globals: { ...globals.node }, + }, + } +]); diff --git a/src/apps/cli/package.json b/src/apps/cli/package.json index 07337bc..e5d0ff4 100644 --- a/src/apps/cli/package.json +++ b/src/apps/cli/package.json @@ -1,18 +1,20 @@ { "name": "self-hosted-livesync-cli", "private": true, - "version": "0.0.0", + "version": "0.25.74-cli", "main": "dist/index.cjs", "type": "module", "scripts": { "dev": "vite", + "package:apply-repo": "node scripts/apply-package.mjs", "prebuild": "node scripts/check-submodule.mjs", "build": "vite build", "preview": "vite preview", "cli": "node dist/index.cjs", "buildRun": "npm run build && npm run cli --", "build:docker": "docker build -f Dockerfile -t livesync-cli ../../..", - "check": "svelte-check --tsconfig ./tsconfig.app.json && tsc -p tsconfig.node.json", + "lint": "eslint --cache .", + "check": "tsc --noEmit", "test:unit": "cd ../../.. && npx vitest run --config vitest.config.unit.ts src/apps/cli/main.unit.spec.ts src/apps/cli/commands/utils.unit.spec.ts src/apps/cli/commands/runCommand.unit.spec.ts src/apps/cli/commands/p2p.unit.spec.ts", "test:e2e:two-vaults": "bash test/test-e2e-two-vaults-with-docker-linux.sh", "test:e2e:two-vaults:common": "bash test/test-e2e-two-vaults-common.sh", @@ -38,6 +40,90 @@ "test:e2e:docker:p2p-sync": "RUN_BUILD=0 LIVESYNC_TEST_DOCKER=1 bash test/test-p2p-sync-linux.sh", "test:e2e:docker:all": "export RUN_BUILD=0 && npm run test:e2e:docker:setup-put-cat && npm run test:e2e:docker:push-pull && npm run test:e2e:docker:sync-two-local && npm run test:e2e:docker:mirror && npm run test:e2e:docker:remote-commands" }, - "dependencies": {}, - "devDependencies": {} + "dependencies": { + "@aws-sdk/client-s3": "^3.808.0", + "@smithy/fetch-http-handler": "^5.3.10", + "@smithy/md5-js": "^4.2.9", + "@smithy/middleware-apply-body-checksum": "^4.3.9", + "@smithy/protocol-http": "^5.3.9", + "@smithy/querystring-builder": "^4.2.9", + "@smithy/types": "^4.14.3", + "@smithy/util-retry": "^4.4.5", + "@trystero-p2p/nostr": "^0.24.0", + "chokidar": "^4.0.0", + "diff-match-patch": "^1.0.5", + "fflate": "^0.8.2", + "idb": "^8.0.3", + "markdown-it": "^14.1.1", + "minimatch": "^10.2.2", + "obsidian": "^1.12.3", + "octagonal-wheels": "^0.1.46", + "pouchdb-adapter-leveldb": "^9.0.0", + "qrcode-generator": "^1.4.4", + "werift": "^0.23.0", + "xxhash-wasm-102": "npm:xxhash-wasm@^1.0.2" + }, + "devDependencies": { + "@dword-design/eslint-plugin-import-alias": "^8.1.8", + "@eslint/js": "^9.39.3", + "@sveltejs/vite-plugin-svelte": "^6.2.4", + "@tsconfig/svelte": "^5.0.8", + "@types/deno": "^2.5.0", + "@types/diff-match-patch": "^1.0.36", + "@types/markdown-it": "^14.1.2", + "@types/micromatch": "^4.0.10", + "@types/node": "^24.10.13", + "@types/pouchdb": "^6.4.2", + "@types/pouchdb-adapter-http": "^6.1.6", + "@types/pouchdb-adapter-idb": "^6.1.7", + "@types/pouchdb-browser": "^6.1.5", + "@types/pouchdb-core": "^7.0.15", + "@types/pouchdb-mapreduce": "^6.1.10", + "@types/pouchdb-replication": "^6.4.7", + "@types/transform-pouch": "^1.0.6", + "@typescript-eslint/eslint-plugin": "^8.61.0", + "@typescript-eslint/parser": "8.61.0", + "@vitest/browser": "^4.1.8", + "@vitest/browser-playwright": "^4.1.8", + "@vitest/coverage-v8": "^4.1.8", + "dotenv-cli": "^11.0.0", + "esbuild": "0.25.0", + "esbuild-plugin-inline-worker": "^0.1.1", + "esbuild-svelte": "^0.9.4", + "eslint": "^9.39.3", + "eslint-plugin-obsidianmd": "^0.3.0", + "eslint-plugin-svelte": "^3.15.0", + "events": "^3.3.0", + "globals": "^14.0.0", + "playwright": "^1.58.2", + "postcss": "^8.5.6", + "pouchdb-adapter-http": "^9.0.0", + "pouchdb-adapter-idb": "^9.0.0", + "pouchdb-adapter-indexeddb": "^9.0.0", + "pouchdb-adapter-memory": "^9.0.0", + "pouchdb-core": "^9.0.0", + "pouchdb-errors": "^9.0.0", + "pouchdb-find": "^9.0.0", + "pouchdb-mapreduce": "^9.0.0", + "pouchdb-merge": "^9.0.0", + "pouchdb-replication": "^9.0.0", + "pouchdb-utils": "^9.0.0", + "prettier": "3.8.1", + "rollup-plugin-copy": "^3.5.0", + "svelte": "5.41.1", + "svelte-check": "^4.4.3", + "svelte-eslint-parser": "^1.8.0", + "svelte-preprocess": "^6.0.3", + "terser": "^5.39.0", + "tinyglobby": "^0.2.15", + "transform-pouch": "^2.0.0", + "tsx": "^4.21.0", + "typescript": "5.9.3", + "typescript-eslint": "^8.61.0", + "vite": "^7.3.1", + "vite-plugin-istanbul": "^8.0.0", + "vitest": "^4.1.8", + "webdriverio": "^9.27.0", + "yaml": "^2.8.2" + } } diff --git a/src/apps/cli/scripts/apply-package.mjs b/src/apps/cli/scripts/apply-package.mjs new file mode 100644 index 0000000..426deab --- /dev/null +++ b/src/apps/cli/scripts/apply-package.mjs @@ -0,0 +1,28 @@ +// Copy package.json dependencies and devDependencies from the repo root to the cli package.json, and set the version to match the repo root version with a -cli suffix. +import fs from "node:fs"; +import path from "node:path"; +import process from "node:process"; + +const cliDir = process.cwd(); +const repoRoot = path.resolve(cliDir, "../../.."); +const repoPackageJsonPath = path.join(repoRoot, "package.json"); +const repoPackageJson = JSON.parse(fs.readFileSync(repoPackageJsonPath, "utf-8")); +const devDependenciesToCopy = repoPackageJson.devDependencies || {}; +const dependenciesToCopy = repoPackageJson.dependencies || {}; +const packageJsonPath = path.join(cliDir, "package.json"); +const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8")); +packageJson.dependencies = { + ...packageJson.dependencies, + ...dependenciesToCopy, +}; +packageJson.devDependencies = { + ...packageJson.devDependencies, + ...devDependenciesToCopy, +}; +packageJson.version = `${repoPackageJson.version}-cli`; +fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 4), "utf-8"); + +console.log("Applied package.json dependencies and version from repo root to cli package.json"); +console.log( + "Please do not forget to pick dependencies that are actually needed in the cli package.json, and remove the ones that are not needed." +); diff --git a/src/apps/cli/tsconfig.json b/src/apps/cli/tsconfig.json index f79193a..054d9c4 100644 --- a/src/apps/cli/tsconfig.json +++ b/src/apps/cli/tsconfig.json @@ -16,17 +16,17 @@ /* Linting */ "strict": false, + // "noImplicitAny": false, "noUnusedLocals": false, "noUnusedParameters": false, - "noFallthroughCasesInSwitch": true, + "noFallthroughCasesInSwitch": true - /* Path mapping */ - "baseUrl": ".", - "paths": { - "@/*": ["../../*"], - "@lib/*": ["../../lib/src/*"] - } + // /* Path mapping */ + // "paths": { + // "@/*": ["../../*"], + // "@lib/*": ["../../lib/src/*"] + // } }, "include": ["*.ts", "**/*.ts", "**/*.tsx"], - "exclude": ["node_modules", "dist"] + "exclude": ["node_modules", "dist", "test", "testdeno"] } diff --git a/src/apps/webapp/eslint.config.mjs b/src/apps/webapp/eslint.config.mjs new file mode 100644 index 0000000..e3eb3c6 --- /dev/null +++ b/src/apps/webapp/eslint.config.mjs @@ -0,0 +1,18 @@ +import { tsBaseConfig } from "../../../eslint.config.common.mjs"; +import globals from "globals"; +import { defineConfig, globalIgnores } from "eslint/config"; + +export default defineConfig([ + globalIgnores([ + "dist", + "node_modules", + "test" + ]), + { + ...tsBaseConfig, + languageOptions: { + ...tsBaseConfig.languageOptions, + globals: { ...globals.browser }, + }, + } +]); diff --git a/src/apps/webapp/package.json b/src/apps/webapp/package.json index 07e8f94..4830b94 100644 --- a/src/apps/webapp/package.json +++ b/src/apps/webapp/package.json @@ -9,7 +9,9 @@ "build": "vite build", "build:docker": "docker build -f Dockerfile -t livesync-webapp ../../..", "run:docker": "docker run -p 8002:80 livesync-webapp", - "preview": "vite preview" + "preview": "vite preview", + "check": "tsc --noEmit", + "lint": "eslint --cache ." }, "dependencies": {}, "devDependencies": { diff --git a/src/apps/webpeer/eslint.config.mjs b/src/apps/webpeer/eslint.config.mjs new file mode 100644 index 0000000..c6b8b5d --- /dev/null +++ b/src/apps/webpeer/eslint.config.mjs @@ -0,0 +1,28 @@ +import { tsBaseConfig, svelteBaseConfig } from "../../../eslint.config.common.mjs"; +import globals from "globals"; +import { defineConfig, globalIgnores } from "eslint/config"; +import * as sveltePlugin from "eslint-plugin-svelte"; + +export default defineConfig([ + globalIgnores([ + "dist", + "node_modules" + ]), + ...sveltePlugin.configs["flat/base"], + { + ...tsBaseConfig, + files: ["src/**/*.ts"], + languageOptions: { + ...tsBaseConfig.languageOptions, + globals: { ...globals.browser }, + }, + }, + { + ...svelteBaseConfig, + files: ["src/**/*.svelte"], + languageOptions: { + ...svelteBaseConfig.languageOptions, + globals: { ...globals.browser }, + }, + }, +]); diff --git a/src/apps/webpeer/package.json b/src/apps/webpeer/package.json index b2201f6..d1f3e4d 100644 --- a/src/apps/webpeer/package.json +++ b/src/apps/webpeer/package.json @@ -9,7 +9,8 @@ "build:docker": "docker build -f Dockerfile -t livesync-webpeer ../../..", "run:docker": "docker run -p 8001:80 livesync-webpeer", "preview": "vite preview", - "check": "svelte-check --tsconfig ./tsconfig.app.json && tsc -p tsconfig.node.json" + "check": "svelte-check --tsconfig ./tsconfig.app.json && tsc -p tsconfig.node.json", + "lint": "eslint --cache src" }, "dependencies": {}, "devDependencies": { @@ -17,7 +18,7 @@ "@sveltejs/vite-plugin-svelte": "^6.2.4", "@tsconfig/svelte": "^5.0.8", "svelte": "5.41.1", - "svelte-check": "^443.3", + "svelte-check": "^4.4.3", "typescript": "5.9.3", "vite": "^7.3.1" }, diff --git a/src/apps/webpeer/src/UITest.svelte b/src/apps/webpeer/src/UITest.svelte index 8cd83fc..0e6af79 100644 --- a/src/apps/webpeer/src/UITest.svelte +++ b/src/apps/webpeer/src/UITest.svelte @@ -1,5 +1,5 @@