diff --git a/.gitignore b/.gitignore index cae4d2a2db..3fb5035a38 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,7 @@ package-lock.json .vscode/ .env .env.* -/coverage +coverage /book /index.html # version file and tarball created by `npm pack` / `yarn pack` diff --git a/.prettierignore b/.prettierignore index 4b6991d3d9..b2455d46db 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,30 +1,30 @@ /build /dist /lib -/node_modules -/webapp +node_modules +/apps/web/webapp /*.log pnpm-lock.yaml electron/dist electron/pub **/.idea /.tmp -/webpack-stats.json +webpack-stats.json .vscode .vscode/ .env -/coverage +coverage # Auto-generated file -/src/modules.ts -/src/modules.js -/src/i18n/strings -/build_config.yaml +/apps/web/src/modules.ts +/apps/web/src/modules.js +src/i18n/strings +/apps/web//build_config.yaml # Raises an error because it contains a template var breaking the script tag -src/vector/index.html -src/vector/modernizr.cjs +/apps/web/src/vector/index.html +/apps/web/src/vector/modernizr.cjs /docs/lib /book -/debian/tmp +debian/tmp /.npmrc package-lock.json @@ -33,22 +33,22 @@ package-lock.json /docs/changelogs # Legacy skinning file that some people might still have -/src/component-index.js +/apps/web/src/component-index.js # Downloaded and already minified -res/jitsi_external_api.min.js +/apps/web/res/jitsi_external_api.min.js # This file is also machine-generated -/playwright/e2e/crypto/test_indexeddb_cryptostore_dump/dump.json -/playwright/test-results/ -/playwright/html-report/ -/playwright/logs/ -/playwright/snapshots/ +/apps/web/playwright/e2e/crypto/test_indexeddb_cryptostore_dump/dump.json +/apps/web/playwright/test-results/ +/apps/web/playwright/html-report/ +/apps/web/playwright/logs/ +/apps/web/playwright/snapshots/ # Shared components generated files -packages/shared-components/dist/ -packages/shared-components/src/i18n/i18nKeys.d.ts -packages/shared-components/typedoc/ -packages/shared-components/storybook-static/ +/packages/shared-components/dist/ +/packages/shared-components/src/i18n/i18nKeys.d.ts +/packages/shared-components/typedoc/ +/packages/shared-components/storybook-static/ /.nx/ diff --git a/apps/web/.stylelintrc.cjs b/apps/web/.stylelintrc.cjs index 97b6e53f31..57c39e8c05 100644 --- a/apps/web/.stylelintrc.cjs +++ b/apps/web/.stylelintrc.cjs @@ -61,10 +61,10 @@ module.exports = { { from: "res/css/views/settings/tabs/_SettingsTab.pcss", type: "css" }, { from: "res/css/structures/_RoomView.pcss", type: "css" }, // Compound vars - "node_modules/@vector-im/compound-design-tokens/assets/web/css/cpd-common-base.css", - "node_modules/@vector-im/compound-design-tokens/assets/web/css/cpd-common-semantic.css", - "node_modules/@vector-im/compound-design-tokens/assets/web/css/cpd-theme-light-base-mq.css", - "node_modules/@vector-im/compound-design-tokens/assets/web/css/cpd-theme-light-semantic-mq.css", + "../../node_modules/@vector-im/compound-design-tokens/assets/web/css/cpd-common-base.css", + "../../node_modules/@vector-im/compound-design-tokens/assets/web/css/cpd-common-semantic.css", + "../../node_modules/@vector-im/compound-design-tokens/assets/web/css/cpd-theme-light-base-mq.css", + "../../node_modules/@vector-im/compound-design-tokens/assets/web/css/cpd-theme-light-semantic-mq.css", ], }, ], diff --git a/apps/web/jest.config.ts b/apps/web/jest.config.ts index b19b884d30..43bfef70ab 100644 --- a/apps/web/jest.config.ts +++ b/apps/web/jest.config.ts @@ -28,9 +28,9 @@ const config: Config = { "\\.(gif|png|ttf|woff2)$": "/__mocks__/imageMock.js", "\\.svg$": "/__mocks__/svg.js", "\\$webapp/i18n/languages.json": "/__mocks__/languages.json", - "^react$": "/node_modules/react", - "^react-dom$": "/node_modules/react-dom", - "^matrix-js-sdk$": "/node_modules/matrix-js-sdk/src", + "^react$": "/../../node_modules/react", + "^react-dom$": "/../../node_modules/react-dom", + "^matrix-js-sdk$": "/../../node_modules/matrix-js-sdk/src", "^matrix-react-sdk$": "/src", "decoderWorker\\.min\\.js": "/__mocks__/empty.js", "decoderWorker\\.min\\.wasm": "/__mocks__/empty.js", @@ -39,8 +39,8 @@ const config: Config = { "workers/(.+)Factory": "/__mocks__/workerFactoryMock.js", "^!!raw-loader!.*": "jest-raw-loader", "recorderWorkletFactory": "/__mocks__/empty.js", - "counterpart": "/node_modules/counterpart", - "@vector-im/compound-web": "/node_modules/@vector-im/compound-web", + "counterpart": "/../../node_modules/counterpart", + "@vector-im/compound-web": "/../../node_modules/@vector-im/compound-web", }, transformIgnorePatterns: [ "/node_modules/(?!(mime|matrix-js-sdk|uuid|p-retry|is-network-error|react-merge-refs|is-ip|ip-regex|super-regex|function-timeout|time-span|convert-hrtime|clone-regexp|is-regexp|matrix-web-i18n|await-lock|@element-hq/web-shared-components|react-virtuoso|lodash)).+$", diff --git a/apps/web/package.json b/apps/web/package.json index ee4e6218cd..1312e011c9 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -14,8 +14,8 @@ ], "scripts": { "i18n": "matrix-gen-i18n src res && pnpm i18n:sort && pnpm i18n:lint", - "i18n:sort": "matrix-sort-i18n src/i18n/strings/en_EN.json && pnpm --dir packages/shared-components i18n:sort", - "i18n:lint": "matrix-i18n-lint && prettier --log-level=silent --write src/i18n/strings/ --ignore-path /dev/null && pnpm --dir packages/shared-components i18n:lint", + "i18n:sort": "matrix-sort-i18n src/i18n/strings/en_EN.json", + "i18n:lint": "matrix-i18n-lint && prettier --log-level=silent --write src/i18n/strings/ --ignore-path /dev/null", "i18n:diff": "cp src/i18n/strings/en_EN.json src/i18n/strings/en_EN_orig.json && pnpm i18n && matrix-compare-i18n-files src/i18n/strings/en_EN_orig.json src/i18n/strings/en_EN.json", "rethemendex": "sh ./res/css/rethemendex.sh", "build": "nx build", diff --git a/apps/web/playwright/e2e/voip/element-call.spec.ts b/apps/web/playwright/e2e/voip/element-call.spec.ts index aafe24a7aa..64f7a6f0f0 100644 --- a/apps/web/playwright/e2e/voip/element-call.spec.ts +++ b/apps/web/playwright/e2e/voip/element-call.spec.ts @@ -6,6 +6,7 @@ Please see LICENSE files in the repository root for full details. */ import { readFile } from "node:fs/promises"; +import { fileURLToPath } from "node:url"; import { type Page } from "@playwright/test"; import type { EventType, Preset } from "matrix-js-sdk/src/matrix"; @@ -19,7 +20,7 @@ import { isDendrite } from "../../plugins/homeserver/dendrite"; // The fake call app does *just* enough to convince Element Web that a call is ongoing // and functions like PiP work. It does not actually do anything though, to limit the // surface we test. -const widgetApi = readFile(require.resolve("matrix-widget-api/dist/api.min.js"), "utf-8"); +const widgetApi = readFile(fileURLToPath(import.meta.resolve("matrix-widget-api/dist/api.min.js")), "utf-8"); const fakeCallClient = readFile("playwright/sample-files/fake-element-call.html", "utf-8"); function assertCommonCallParameters( diff --git a/apps/web/playwright/tsconfig.json b/apps/web/playwright/tsconfig.json index 442e2527b3..1b612abfa3 100644 --- a/apps/web/playwright/tsconfig.json +++ b/apps/web/playwright/tsconfig.json @@ -12,7 +12,7 @@ "include": [ "**/*.ts", "../src/@types/matrix-js-sdk.d.ts", - "../node_modules/matrix-js-sdk/src/@types/*.d.ts", - "../node_modules/matrix-js-sdk/node_modules/@matrix-org/olm/index.d.ts" + "../../../node_modules/matrix-js-sdk/src/@types/*.d.ts", + "../../../node_modules/matrix-js-sdk/node_modules/@matrix-org/olm/index.d.ts" ] } diff --git a/apps/web/project.json b/apps/web/project.json index aa365d09ab..9e1d98bba1 100644 --- a/apps/web/project.json +++ b/apps/web/project.json @@ -1,41 +1,50 @@ { - "$schema": "./node_modules/nx/schemas/project-schema.json", + "$schema": "../../node_modules/nx/schemas/project-schema.json", "projectType": "application", "implicitDependencies": ["@element-hq/web-shared-components"], "targets": { "prebuild:i18n": { "cache": true, "command": "node scripts/copy-res.ts", - "inputs": ["{projectRoot}/src/i18n/strings/*.json"], - "outputs": ["{projectRoot}/webapp/i18n/"] + "inputs": [ + "{projectRoot}/src/i18n/strings/*.json", + "{workspaceRoot}/packages/shared-components/src/i18n/strings/*.json" + ], + "outputs": ["{projectRoot}/webapp/i18n/"], + "options": { "cwd": "apps/web" } }, "prebuild:module_system": { "cache": true, "command": "node module_system/scripts/install.ts", "inputs": ["{projectRoot}/build_config.yaml"], - "outputs": ["{projectRoot}/src/modules.js", "{projectRoot}/package.json", "{workspaceRoot}/pnpm-lock.yaml"] + "outputs": ["{projectRoot}/src/modules.js", "{projectRoot}/package.json", "{workspaceRoot}/pnpm-lock.yaml"], + "options": { "cwd": "apps/web" } }, "prebuild:rethemendex": { "cache": true, "executor": "nx:run-script", "options": { - "script": "rethemendex" + "script": "rethemendex", + "cwd": "apps/web" }, "inputs": ["{projectRoot}/res/css/**/*"], "outputs": ["{projectRoot}/res/css/_components.pcss"] }, "build": { "command": "webpack-cli --disable-interpret --progress --mode production", - "outputs": ["{projectRoot}/webapp"] + "outputs": ["{projectRoot}/webapp"], + "options": { "cwd": "apps/web" } }, "start:i18n": { "command": "node scripts/copy-res.ts -w", - "continuous": true + "continuous": true, + "options": { "cwd": "apps/web" } }, "start": { "command": "webpack-dev-server --disable-interpret --output-path webapp --output-filename=bundles/_dev_/[name].js --output-chunk-filename=bundles/_dev_/[name].js --mode development", "dependsOn": ["prebuild:module_system", "prebuild:rethemendex", "start:i18n", "^start"], - "continuous": true + "continuous": true, + "options": { "cwd": "apps/web" } }, "lint:types": { "executor": "nx:run-commands", @@ -45,14 +54,16 @@ "tsc --noEmit", "tsc --noEmit -p playwright" ], - "parallel": false + "parallel": false, + "cwd": "apps/web" }, "dependsOn": ["^build"] }, "test:unit": { "executor": "@nx/jest:jest", "options": { - "jestConfig": "jest.config.ts" + "jestConfig": "{projectRoot}/jest.config.ts", + "cwd": "apps/web" }, "dependsOn": ["^build"] } diff --git a/apps/web/scripts/copy-res.ts b/apps/web/scripts/copy-res.ts index 65ce545314..4ce96a3d8e 100755 --- a/apps/web/scripts/copy-res.ts +++ b/apps/web/scripts/copy-res.ts @@ -10,7 +10,7 @@ import webpack from "webpack"; import { type Translations } from "matrix-web-i18n"; const EW_I18N_BASE_PATH = "src/i18n/strings/"; -const SC_I18N_BASE_PATH = "packages/shared-components/src/i18n/strings/"; +const SC_I18N_BASE_PATH = "../../packages/shared-components/src/i18n/strings/"; const INCLUDE_LANGS = [...new Set([...fs.readdirSync(EW_I18N_BASE_PATH)])] .filter((fn) => fn.endsWith(".json")) diff --git a/apps/web/test/setup/setupLanguage.ts b/apps/web/test/setup/setupLanguage.ts index 705ffe039f..6e98061427 100644 --- a/apps/web/test/setup/setupLanguage.ts +++ b/apps/web/test/setup/setupLanguage.ts @@ -15,9 +15,9 @@ import enElementWeb from "../../src/i18n/strings/en_EN.json"; import deElementWeb from "../../src/i18n/strings/de_DE.json"; // Cheat and import relatively here as these aren't exported by the module (should they be?) // eslint-disable-next-line no-restricted-imports -import enSharedComponents from "../../packages/shared-components/src/i18n/strings/en_EN.json"; +import enSharedComponents from "../../../../packages/shared-components/src/i18n/strings/en_EN.json"; // eslint-disable-next-line no-restricted-imports -import deSharedComponents from "../../packages/shared-components/src/i18n/strings/de_DE.json"; +import deSharedComponents from "../../../../packages/shared-components/src/i18n/strings/de_DE.json"; import { ModuleApi } from "../../src/modules/Api"; const lv = { diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.json index b313ad09fb..70a03bcc8a 100644 --- a/apps/web/tsconfig.json +++ b/apps/web/tsconfig.json @@ -18,11 +18,11 @@ "strict": true, "paths": { "jest-matrix-react": ["./test/test-utils/jest-matrix-react"], - "rollup/parseAst": ["./node_modules/rollup/dist/parseAst"] + "rollup/parseAst": ["../../node_modules/rollup/dist/parseAst"] } }, "include": [ - "./node_modules/matrix-js-sdk/src/@types/*.d.ts", + "../../node_modules/matrix-js-sdk/src/@types/*.d.ts", "./src/**/*.ts", "./src/**/*.tsx", "./test/**/*.ts", diff --git a/apps/web/webpack.config.ts b/apps/web/webpack.config.ts index dddf5c8780..5595881b91 100644 --- a/apps/web/webpack.config.ts +++ b/apps/web/webpack.config.ts @@ -438,7 +438,7 @@ export default (env: string, argv: Record): webpack.Configuration = type: "javascript/auto", use: [ { - loader: path.resolve("./recorder-worklet-loader.cjs"), + loader: path.join(__dirname, "recorder-worklet-loader.cjs"), }, { loader: "babel-loader", diff --git a/package.json b/package.json index 7e312e88e4..9460ea5a43 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,9 @@ "license": "SEE LICENSE IN README.md", "type": "module", "scripts": { + "i18n": "pnpm -r i18n", + "i18n:sort": "pnpm -r i18n:sort", + "i18n:lint": "pnpm -r i18n:lint", "lint": "pnpm -r lint:types && pnpm lint:prettier && pnpm -r lint:js && pnpm -r lint:style && pnpm lint:workflows && pnpm lint:knip", "lint:prettier": "prettier --check .", "lint:prettier-fix": "prettier --log-level=warn --write .", diff --git a/packages/shared-components/.storybook/main.ts b/packages/shared-components/.storybook/main.ts index a2ff26fb5a..431e46b5f7 100644 --- a/packages/shared-components/.storybook/main.ts +++ b/packages/shared-components/.storybook/main.ts @@ -9,11 +9,13 @@ import type { StorybookConfig } from "@storybook/react-vite"; import fs from "node:fs"; import { nodePolyfills } from "vite-plugin-node-polyfills"; import { mergeConfig } from "vite"; -import { dirname } from "node:path"; +import { dirname, join } from "node:path"; import { fileURLToPath } from "node:url"; +const __dirname = dirname(fileURLToPath(import.meta.url)); + // Get a list of available languages so the language selector can display them at runtime -const languageFiles = fs.readdirSync("src/i18n/strings").map((f) => f.slice(0, -5)); +const languageFiles = fs.readdirSync(join(__dirname, "..", "src", "i18n", "strings")).map((f) => f.slice(0, -5)); const languages: Record = {}; for (const lang of languageFiles) { diff --git a/scripts/docker-package.sh b/scripts/docker-package.sh index 00a7381bd7..b9b6b6c284 100755 --- a/scripts/docker-package.sh +++ b/scripts/docker-package.sh @@ -18,4 +18,4 @@ fi DIST_VERSION=$("$DIR"/normalize-version.sh "$DIST_VERSION") -VERSION=$DIST_VERSION pnpm build +VERSION=$DIST_VERSION pnpm --dir apps/web build diff --git a/sonar-project.properties b/sonar-project.properties index 26970ca7f4..cb41f78e4e 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -4,23 +4,23 @@ sonar.organization=element-hq # Encoding of the source code. Default is default system encoding #sonar.sourceEncoding=UTF-8 -sonar.sources=src,res,packages/shared-components/src -sonar.tests=test,playwright,src,packages -sonar.test.inclusions=test/*,playwright/*,src/**/*.test.*,packages/*/src/**/*.test.*,packages/*/src/test/**/* -sonar.exclusions=__mocks__,docs,element.io,nginx,src/vector/modernizr.cjs +sonar.sources=apps/web/src,apps/web/res,packages/shared-components/src +sonar.tests=apps/web/test,apps/web/playwright,packages +sonar.test.inclusions=apps/web/test/*,apps/web/playwright/*,packages/*/src/**/*.test.*,packages/*/src/test/**/* +sonar.exclusions=apps/web/__mocks__,docs,apps/web/element.io,apps/web/nginx,apps/web/src/vector/modernizr.cjs -sonar.cpd.exclusions=src/i18n/strings/*.json -sonar.typescript.tsconfigPath=./tsconfig.json -sonar.javascript.lcov.reportPaths=coverage/lcov.info,packages/shared-components/coverage/lcov.info +sonar.cpd.exclusions=apps/web/src/i18n/strings/*.json,packages/*/src/i18n/strings/*.json +sonar.javascript.lcov.reportPaths=apps/web/coverage/lcov.info,packages/shared-components/coverage/lcov.info sonar.coverage.exclusions=\ - test/**/*,\ - playwright/**/*,\ - res/**/*,\ + apps/web/test/**/*,\ + apps/web/playwright/**/*,\ + apps/web/res/**/*,\ + apps/web/scripts/**/*,\ scripts/**/*,\ - src/components/views/dialogs/devtools/**/*,\ - src/utils/SessionLock.ts,\ - src/**/*.d.ts,\ - src/vector/mobile_guide/**/*,\ + apps/web/src/components/views/dialogs/devtools/**/*,\ + apps/web/src/utils/SessionLock.ts,\ + apps/web/src/**/*.d.ts,\ + apps/web/src/vector/mobile_guide/**/*,\ packages/shared-components/src/test/**/*,\ packages/shared-components/src/**/*.stories.tsx -sonar.testExecutionReportPaths=coverage/jest-sonar-report.xml +sonar.testExecutionReportPaths=apps/web/coverage/jest-sonar-report.xml