diff --git a/.codex/environments/environment.toml b/.codex/environments/environment.toml new file mode 100644 index 00000000000..526490c93c5 --- /dev/null +++ b/.codex/environments/environment.toml @@ -0,0 +1,34 @@ +# THIS IS AUTOGENERATED. DO NOT EDIT MANUALLY +version = 1 +name = "Misskey" + +[setup] +script = ''' +cd "$CODEX_WORKTREE_PATH" +mise install node pnpm ffmpeg +mise exec -- pnpm install --frozen-lockfile +mise exec -- node scripts/setup-codex-environment.mjs +mise exec -- pnpm build-pre +mise exec -- pnpm --filter backend build +mise exec -- pnpm migrate''' + +[[actions]] +name = "Prepare LAN HTTPS" +icon = "tool" +command = ''' +. ./.config/codex-portless.env +if [ "$(uname -s)" = "Linux" ] && ! command -v avahi-publish-address >/dev/null 2>&1; then + if command -v apt-get >/dev/null 2>&1; then + sudo apt-get update + sudo apt-get install -y avahi-utils + else + echo "Portless LAN mode requires an mDNS publisher (for example, avahi-utils)." >&2 + exit 1 + fi +fi +mise exec -- pnpm exec portless trust''' + +[[actions]] +name = "Run" +icon = "run" +command = "mise exec -- pnpm dev:portless" diff --git a/package.json b/package.json index fabc8e880ab..6f0438ddad0 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "migrateandstart": "pnpm migrate && pnpm start", "watch": "pnpm dev", "dev": "node scripts/dev.mjs", + "dev:portless": ". ./.config/codex-portless.env && portless run node scripts/dev-portless.mjs", "check-dts": "node scripts/check-dts.mjs", "lint": "pnpm --no-bail -r lint && pnpm check-dts", "e2e": "pnpm start-server-and-test start:test http://localhost:61812 \"pnpm --filter frontend test:e2e\"", @@ -76,6 +77,7 @@ "globals": "17.9.0", "ncp": "2.0.0", "pnpm": "11.21.0", + "portless": "0.15.5", "start-server-and-test": "3.0.12", "typescript": "npm:@typescript/typescript6@6.0.2" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index acff34a0226..caccc337e93 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -62,6 +62,9 @@ importers: pnpm: specifier: 11.21.0 version: 11.21.0 + portless: + specifier: 0.15.5 + version: 0.15.5 start-server-and-test: specifier: 3.0.12 version: 3.0.12(supports-color@10.2.2) @@ -804,7 +807,7 @@ importers: version: 10.5.7(@types/react@19.2.14)(react@19.2.8)(storybook@10.5.7(@emnapi/core@2.0.0-alpha.3)(@emnapi/runtime@2.0.0-alpha.3)(@types/react@19.2.14)(bufferutil@4.1.0)(prettier@3.9.6)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(utf-8-validate@6.0.6)) '@storybook/addon-mdx-gfm': specifier: 8.6.18 - version: 8.6.18(storybook@10.5.7(@emnapi/core@2.0.0-alpha.3)(@emnapi/runtime@2.0.0-alpha.3)(@types/react@19.2.14)(bufferutil@4.1.0)(prettier@3.9.6)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(utf-8-validate@6.0.6))(supports-color@5.5.0) + version: 8.6.18(storybook@10.5.7(@emnapi/core@2.0.0-alpha.3)(@emnapi/runtime@2.0.0-alpha.3)(@types/react@19.2.14)(bufferutil@4.1.0)(prettier@3.9.6)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(utf-8-validate@6.0.6))(supports-color@10.2.2) '@storybook/addon-storysource': specifier: 8.6.18 version: 8.6.18(storybook@10.5.7(@emnapi/core@2.0.0-alpha.3)(@emnapi/runtime@2.0.0-alpha.3)(@types/react@19.2.14)(bufferutil@4.1.0)(prettier@3.9.6)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(utf-8-validate@6.0.6)) @@ -882,10 +885,10 @@ importers: version: 1.4.6 '@typescript-eslint/eslint-plugin': specifier: 8.67.0 - version: 8.67.0(@typescript-eslint/parser@8.67.0(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)(typescript@6.0.3))(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)(typescript@6.0.3) + version: 8.67.0(@typescript-eslint/parser@8.67.0(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3))(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3) '@typescript-eslint/parser': specifier: 8.67.0 - version: 8.67.0(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)(typescript@6.0.3) + version: 8.67.0(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3) '@vitest/browser-playwright': specifier: 4.1.10 version: 4.1.10(bufferutil@4.1.0)(msw@2.15.0(@types/node@26.2.0)(typescript@6.0.3))(playwright@1.62.1)(utf-8-validate@6.0.6)(vite@8.2.1(@types/node@26.2.0)(esbuild@0.28.2)(sass-embedded@1.100.0)(sass@1.100.0)(terser@5.48.0)(tsx@4.23.12))(vitest@4.1.10) @@ -903,10 +906,10 @@ importers: version: 18.1.0 eslint-plugin-import: specifier: 2.32.0 - version: 2.32.0(@typescript-eslint/parser@8.67.0(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)(typescript@6.0.3))(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0) + version: 2.32.0(@typescript-eslint/parser@8.67.0(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3))(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2) eslint-plugin-vue: specifier: 10.10.0 - version: 10.10.0(@stylistic/eslint-plugin@5.10.0(eslint@9.39.5(supports-color@5.5.0)))(@typescript-eslint/parser@8.67.0(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)(typescript@6.0.3))(eslint@9.39.5(supports-color@5.5.0))(vue-eslint-parser@10.4.1(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)) + version: 10.10.0(@stylistic/eslint-plugin@5.10.0(eslint@9.39.5(supports-color@10.2.2)))(@typescript-eslint/parser@8.67.0(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3))(eslint@9.39.5(supports-color@10.2.2))(vue-eslint-parser@10.4.1(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)) execa: specifier: 10.0.1 version: 10.0.1 @@ -990,7 +993,7 @@ importers: version: 3.3.9 vue-eslint-parser: specifier: 10.4.1 - version: 10.4.1(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0) + version: 10.4.1(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2) vue-tsc: specifier: 3.3.9 version: 3.3.9(typescript@6.0.3) @@ -1203,10 +1206,10 @@ importers: version: 26.2.0 '@typescript-eslint/eslint-plugin': specifier: 8.67.0 - version: 8.67.0(@typescript-eslint/parser@8.67.0(@typescript/typescript6@6.0.2)(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2))(@typescript/typescript6@6.0.2)(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2) + version: 8.67.0(@typescript-eslint/parser@8.67.0(@typescript/typescript6@6.0.2)(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0))(@typescript/typescript6@6.0.2)(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0) '@typescript-eslint/parser': specifier: 8.67.0 - version: 8.67.0(@typescript/typescript6@6.0.2)(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2) + version: 8.67.0(@typescript/typescript6@6.0.2)(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0) chokidar: specifier: 5.0.0 version: 5.0.0 @@ -5533,6 +5536,7 @@ packages: eslint@9.39.5: resolution: {integrity: sha512-DgZS62aPLXKlnxILS/AYCoRvHaZeXceIzlXPkkGGzJWSow1aEk0lbTlxUSlyjC8jcaKxAdOnTDz+o1JFSBsyjw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + deprecated: This version is no longer supported. Please see https://eslint.org/version-support for other options. hasBin: true peerDependencies: jiti: '*' @@ -7493,6 +7497,12 @@ packages: resolution: {integrity: sha512-OBatVyC/N7SCW/FaDHrSd+vn0o5cS855TOmYi4OkdWUMSJCET/xip//ch8xGUvtr3i44X9LVyWwQlRMTN3pwSA==} engines: {node: '>=10'} + portless@0.15.5: + resolution: {integrity: sha512-zmJu4Q8/fY54oVUT/5NnmF4Ih8wTdCvCf6JCN783dRYl9mXkJBzXSckX2lztGCLIbM70varDjCudAbGKT73XPg==} + engines: {node: '>=24'} + os: [darwin, linux, win32] + hasBin: true + possible-typed-array-names@1.1.0: resolution: {integrity: sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==} engines: {node: '>= 0.4'} @@ -11527,9 +11537,9 @@ snapshots: '@types/react': 19.2.14 react: 19.2.8 - '@storybook/addon-mdx-gfm@8.6.18(storybook@10.5.7(@emnapi/core@2.0.0-alpha.3)(@emnapi/runtime@2.0.0-alpha.3)(@types/react@19.2.14)(bufferutil@4.1.0)(prettier@3.9.6)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(utf-8-validate@6.0.6))(supports-color@5.5.0)': + '@storybook/addon-mdx-gfm@8.6.18(storybook@10.5.7(@emnapi/core@2.0.0-alpha.3)(@emnapi/runtime@2.0.0-alpha.3)(@types/react@19.2.14)(bufferutil@4.1.0)(prettier@3.9.6)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(utf-8-validate@6.0.6))(supports-color@10.2.2)': dependencies: - remark-gfm: 4.0.1(supports-color@5.5.0) + remark-gfm: 4.0.1(supports-color@10.2.2) storybook: 10.5.7(@emnapi/core@2.0.0-alpha.3)(@emnapi/runtime@2.0.0-alpha.3)(@types/react@19.2.14)(bufferutil@4.1.0)(prettier@3.9.6)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(utf-8-validate@6.0.6) ts-dedent: 2.2.0 transitivePeerDependencies: @@ -11697,17 +11707,6 @@ snapshots: estraverse: 5.3.0 picomatch: 4.0.5 - '@stylistic/eslint-plugin@5.10.0(eslint@9.39.5(supports-color@5.5.0))': - dependencies: - '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.5(supports-color@5.5.0)) - '@typescript-eslint/types': 8.67.0 - eslint: 9.39.5(supports-color@5.5.0) - eslint-visitor-keys: 4.2.1 - espree: 10.4.0 - estraverse: 5.3.0 - picomatch: 4.0.5 - optional: true - '@syuilo/aiscript@0.19.0': dependencies: seedrandom: 3.0.5 @@ -12010,31 +12009,31 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/eslint-plugin@8.67.0(@typescript-eslint/parser@8.67.0(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3))(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3)': + '@typescript-eslint/eslint-plugin@8.67.0(@typescript-eslint/parser@8.67.0(@typescript/typescript6@6.0.2)(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0))(@typescript/typescript6@6.0.2)(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)': dependencies: '@eslint-community/regexpp': 4.12.2 - '@typescript-eslint/parser': 8.67.0(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3) + '@typescript-eslint/parser': 8.67.0(@typescript/typescript6@6.0.2)(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0) '@typescript-eslint/scope-manager': 8.67.0 - '@typescript-eslint/type-utils': 8.67.0(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3) - '@typescript-eslint/utils': 8.67.0(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3) + '@typescript-eslint/type-utils': 8.67.0(@typescript/typescript6@6.0.2)(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0) + '@typescript-eslint/utils': 8.67.0(@typescript/typescript6@6.0.2)(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0) '@typescript-eslint/visitor-keys': 8.67.0 - eslint: 9.39.5(supports-color@10.2.2) + eslint: 9.39.5(supports-color@5.5.0) ignore: 7.0.5 natural-compare: 1.4.0 - ts-api-utils: 2.5.0(typescript@6.0.3) - typescript: 6.0.3 + ts-api-utils: 2.5.0(@typescript/typescript6@6.0.2) + typescript: '@typescript/typescript6@6.0.2' transitivePeerDependencies: - supports-color - '@typescript-eslint/eslint-plugin@8.67.0(@typescript-eslint/parser@8.67.0(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)(typescript@6.0.3))(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)(typescript@6.0.3)': + '@typescript-eslint/eslint-plugin@8.67.0(@typescript-eslint/parser@8.67.0(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3))(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3)': dependencies: '@eslint-community/regexpp': 4.12.2 - '@typescript-eslint/parser': 8.67.0(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)(typescript@6.0.3) + '@typescript-eslint/parser': 8.67.0(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3) '@typescript-eslint/scope-manager': 8.67.0 - '@typescript-eslint/type-utils': 8.67.0(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)(typescript@6.0.3) - '@typescript-eslint/utils': 8.67.0(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)(typescript@6.0.3) + '@typescript-eslint/type-utils': 8.67.0(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3) + '@typescript-eslint/utils': 8.67.0(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3) '@typescript-eslint/visitor-keys': 8.67.0 - eslint: 9.39.5(supports-color@5.5.0) + eslint: 9.39.5(supports-color@10.2.2) ignore: 7.0.5 natural-compare: 1.4.0 ts-api-utils: 2.5.0(typescript@6.0.3) @@ -12054,26 +12053,26 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.67.0(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3)': + '@typescript-eslint/parser@8.67.0(@typescript/typescript6@6.0.2)(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)': dependencies: '@typescript-eslint/scope-manager': 8.67.0 '@typescript-eslint/types': 8.67.0 - '@typescript-eslint/typescript-estree': 8.67.0(supports-color@10.2.2)(typescript@6.0.3) + '@typescript-eslint/typescript-estree': 8.67.0(@typescript/typescript6@6.0.2)(supports-color@5.5.0) '@typescript-eslint/visitor-keys': 8.67.0 - debug: 4.4.3(supports-color@10.2.2) - eslint: 9.39.5(supports-color@10.2.2) - typescript: 6.0.3 + debug: 4.4.3(supports-color@5.5.0) + eslint: 9.39.5(supports-color@5.5.0) + typescript: '@typescript/typescript6@6.0.2' transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.67.0(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)(typescript@6.0.3)': + '@typescript-eslint/parser@8.67.0(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3)': dependencies: '@typescript-eslint/scope-manager': 8.67.0 '@typescript-eslint/types': 8.67.0 - '@typescript-eslint/typescript-estree': 8.67.0(supports-color@5.5.0)(typescript@6.0.3) + '@typescript-eslint/typescript-estree': 8.67.0(supports-color@10.2.2)(typescript@6.0.3) '@typescript-eslint/visitor-keys': 8.67.0 - debug: 4.4.3(supports-color@5.5.0) - eslint: 9.39.5(supports-color@5.5.0) + debug: 4.4.3(supports-color@10.2.2) + eslint: 9.39.5(supports-color@10.2.2) typescript: 6.0.3 transitivePeerDependencies: - supports-color @@ -12087,20 +12086,20 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/project-service@8.67.0(supports-color@10.2.2)(typescript@6.0.3)': + '@typescript-eslint/project-service@8.67.0(@typescript/typescript6@6.0.2)(supports-color@5.5.0)': dependencies: - '@typescript-eslint/tsconfig-utils': 8.67.0(typescript@6.0.3) + '@typescript-eslint/tsconfig-utils': 8.67.0(@typescript/typescript6@6.0.2) '@typescript-eslint/types': 8.67.0 - debug: 4.4.3(supports-color@10.2.2) - typescript: 6.0.3 + debug: 4.4.3(supports-color@5.5.0) + typescript: '@typescript/typescript6@6.0.2' transitivePeerDependencies: - supports-color - '@typescript-eslint/project-service@8.67.0(supports-color@5.5.0)(typescript@6.0.3)': + '@typescript-eslint/project-service@8.67.0(supports-color@10.2.2)(typescript@6.0.3)': dependencies: '@typescript-eslint/tsconfig-utils': 8.67.0(typescript@6.0.3) '@typescript-eslint/types': 8.67.0 - debug: 4.4.3(supports-color@5.5.0) + debug: 4.4.3(supports-color@10.2.2) typescript: 6.0.3 transitivePeerDependencies: - supports-color @@ -12130,25 +12129,25 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/type-utils@8.67.0(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3)': + '@typescript-eslint/type-utils@8.67.0(@typescript/typescript6@6.0.2)(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)': dependencies: '@typescript-eslint/types': 8.67.0 - '@typescript-eslint/typescript-estree': 8.67.0(supports-color@10.2.2)(typescript@6.0.3) - '@typescript-eslint/utils': 8.67.0(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3) - debug: 4.4.3(supports-color@10.2.2) - eslint: 9.39.5(supports-color@10.2.2) - ts-api-utils: 2.5.0(typescript@6.0.3) - typescript: 6.0.3 + '@typescript-eslint/typescript-estree': 8.67.0(@typescript/typescript6@6.0.2)(supports-color@5.5.0) + '@typescript-eslint/utils': 8.67.0(@typescript/typescript6@6.0.2)(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0) + debug: 4.4.3(supports-color@5.5.0) + eslint: 9.39.5(supports-color@5.5.0) + ts-api-utils: 2.5.0(@typescript/typescript6@6.0.2) + typescript: '@typescript/typescript6@6.0.2' transitivePeerDependencies: - supports-color - '@typescript-eslint/type-utils@8.67.0(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)(typescript@6.0.3)': + '@typescript-eslint/type-utils@8.67.0(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3)': dependencies: '@typescript-eslint/types': 8.67.0 - '@typescript-eslint/typescript-estree': 8.67.0(supports-color@5.5.0)(typescript@6.0.3) - '@typescript-eslint/utils': 8.67.0(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)(typescript@6.0.3) - debug: 4.4.3(supports-color@5.5.0) - eslint: 9.39.5(supports-color@5.5.0) + '@typescript-eslint/typescript-estree': 8.67.0(supports-color@10.2.2)(typescript@6.0.3) + '@typescript-eslint/utils': 8.67.0(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3) + debug: 4.4.3(supports-color@10.2.2) + eslint: 9.39.5(supports-color@10.2.2) ts-api-utils: 2.5.0(typescript@6.0.3) typescript: 6.0.3 transitivePeerDependencies: @@ -12171,28 +12170,28 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/typescript-estree@8.67.0(supports-color@10.2.2)(typescript@6.0.3)': + '@typescript-eslint/typescript-estree@8.67.0(@typescript/typescript6@6.0.2)(supports-color@5.5.0)': dependencies: - '@typescript-eslint/project-service': 8.67.0(supports-color@10.2.2)(typescript@6.0.3) - '@typescript-eslint/tsconfig-utils': 8.67.0(typescript@6.0.3) + '@typescript-eslint/project-service': 8.67.0(@typescript/typescript6@6.0.2)(supports-color@5.5.0) + '@typescript-eslint/tsconfig-utils': 8.67.0(@typescript/typescript6@6.0.2) '@typescript-eslint/types': 8.67.0 '@typescript-eslint/visitor-keys': 8.67.0 - debug: 4.4.3(supports-color@10.2.2) + debug: 4.4.3(supports-color@5.5.0) minimatch: 10.2.6 semver: 7.8.5 tinyglobby: 0.2.17 - ts-api-utils: 2.5.0(typescript@6.0.3) - typescript: 6.0.3 + ts-api-utils: 2.5.0(@typescript/typescript6@6.0.2) + typescript: '@typescript/typescript6@6.0.2' transitivePeerDependencies: - supports-color - '@typescript-eslint/typescript-estree@8.67.0(supports-color@5.5.0)(typescript@6.0.3)': + '@typescript-eslint/typescript-estree@8.67.0(supports-color@10.2.2)(typescript@6.0.3)': dependencies: - '@typescript-eslint/project-service': 8.67.0(supports-color@5.5.0)(typescript@6.0.3) + '@typescript-eslint/project-service': 8.67.0(supports-color@10.2.2)(typescript@6.0.3) '@typescript-eslint/tsconfig-utils': 8.67.0(typescript@6.0.3) '@typescript-eslint/types': 8.67.0 '@typescript-eslint/visitor-keys': 8.67.0 - debug: 4.4.3(supports-color@5.5.0) + debug: 4.4.3(supports-color@10.2.2) minimatch: 10.2.6 semver: 7.8.5 tinyglobby: 0.2.17 @@ -12212,24 +12211,24 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.67.0(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3)': + '@typescript-eslint/utils@8.67.0(@typescript/typescript6@6.0.2)(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)': dependencies: - '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.5(supports-color@10.2.2)) + '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.5(supports-color@5.5.0)) '@typescript-eslint/scope-manager': 8.67.0 '@typescript-eslint/types': 8.67.0 - '@typescript-eslint/typescript-estree': 8.67.0(supports-color@10.2.2)(typescript@6.0.3) - eslint: 9.39.5(supports-color@10.2.2) - typescript: 6.0.3 + '@typescript-eslint/typescript-estree': 8.67.0(@typescript/typescript6@6.0.2)(supports-color@5.5.0) + eslint: 9.39.5(supports-color@5.5.0) + typescript: '@typescript/typescript6@6.0.2' transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.67.0(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)(typescript@6.0.3)': + '@typescript-eslint/utils@8.67.0(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3)': dependencies: - '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.5(supports-color@5.5.0)) + '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.5(supports-color@10.2.2)) '@typescript-eslint/scope-manager': 8.67.0 '@typescript-eslint/types': 8.67.0 - '@typescript-eslint/typescript-estree': 8.67.0(supports-color@5.5.0)(typescript@6.0.3) - eslint: 9.39.5(supports-color@5.5.0) + '@typescript-eslint/typescript-estree': 8.67.0(supports-color@10.2.2)(typescript@6.0.3) + eslint: 9.39.5(supports-color@10.2.2) typescript: 6.0.3 transitivePeerDependencies: - supports-color @@ -13420,12 +13419,6 @@ snapshots: optionalDependencies: supports-color: 10.2.2 - debug@3.2.7(supports-color@5.5.0): - dependencies: - ms: 2.1.3 - optionalDependencies: - supports-color: 5.5.0 - debug@4.4.3(supports-color@10.2.2): dependencies: ms: 2.1.3 @@ -13814,14 +13807,6 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-import-resolver-node@0.3.10(supports-color@5.5.0): - dependencies: - debug: 3.2.7(supports-color@5.5.0) - is-core-module: 2.16.2 - resolve: 2.0.0-next.6 - transitivePeerDependencies: - - supports-color - eslint-module-utils@2.12.1(@typescript-eslint/parser@8.67.0(@typescript/typescript6@6.0.2)(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2))(eslint-import-resolver-node@0.3.10(supports-color@10.2.2))(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2): dependencies: debug: 3.2.7(supports-color@10.2.2) @@ -13842,16 +13827,6 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-module-utils@2.12.1(@typescript-eslint/parser@8.67.0(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)(typescript@6.0.3))(eslint-import-resolver-node@0.3.10(supports-color@10.2.2))(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0): - dependencies: - debug: 3.2.7(supports-color@5.5.0) - optionalDependencies: - '@typescript-eslint/parser': 8.67.0(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)(typescript@6.0.3) - eslint: 9.39.5(supports-color@5.5.0) - eslint-import-resolver-node: 0.3.10(supports-color@10.2.2) - transitivePeerDependencies: - - supports-color - eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.67.0(@typescript/typescript6@6.0.2)(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2))(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2): dependencies: '@rtsao/scc': 1.1.0 @@ -13910,35 +13885,6 @@ snapshots: - eslint-import-resolver-webpack - supports-color - eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.67.0(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)(typescript@6.0.3))(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0): - dependencies: - '@rtsao/scc': 1.1.0 - array-includes: 3.1.9 - array.prototype.findlastindex: 1.2.6 - array.prototype.flat: 1.3.3 - array.prototype.flatmap: 1.3.3 - debug: 3.2.7(supports-color@5.5.0) - doctrine: 2.1.0 - eslint: 9.39.5(supports-color@5.5.0) - eslint-import-resolver-node: 0.3.10(supports-color@5.5.0) - eslint-module-utils: 2.12.1(@typescript-eslint/parser@8.67.0(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)(typescript@6.0.3))(eslint-import-resolver-node@0.3.10(supports-color@10.2.2))(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0) - hasown: 2.0.4 - is-core-module: 2.16.2 - is-glob: 4.0.3 - minimatch: 3.1.5 - object.fromentries: 2.0.8 - object.groupby: 1.0.3 - object.values: 1.2.1 - semver: 6.3.1 - string.prototype.trimend: 1.0.9 - tsconfig-paths: 3.15.0 - optionalDependencies: - '@typescript-eslint/parser': 8.67.0(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)(typescript@6.0.3) - transitivePeerDependencies: - - eslint-import-resolver-typescript - - eslint-import-resolver-webpack - - supports-color - eslint-plugin-vue@10.10.0(@stylistic/eslint-plugin@5.10.0(eslint@9.39.5(supports-color@10.2.2)))(@typescript-eslint/parser@8.67.0(@typescript/typescript6@6.0.2)(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2))(eslint@9.39.5(supports-color@10.2.2))(vue-eslint-parser@10.4.1(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)): dependencies: '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.5(supports-color@10.2.2)) @@ -13967,20 +13913,6 @@ snapshots: '@stylistic/eslint-plugin': 5.10.0(eslint@9.39.5(supports-color@10.2.2)) '@typescript-eslint/parser': 8.67.0(eslint@9.39.5(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3) - eslint-plugin-vue@10.10.0(@stylistic/eslint-plugin@5.10.0(eslint@9.39.5(supports-color@5.5.0)))(@typescript-eslint/parser@8.67.0(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)(typescript@6.0.3))(eslint@9.39.5(supports-color@5.5.0))(vue-eslint-parser@10.4.1(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)): - dependencies: - '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.5(supports-color@5.5.0)) - eslint: 9.39.5(supports-color@5.5.0) - natural-compare: 1.4.0 - nth-check: 2.1.1 - postcss-selector-parser: 7.1.4 - semver: 7.8.5 - vue-eslint-parser: 10.4.1(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0) - xml-name-validator: 5.0.0 - optionalDependencies: - '@stylistic/eslint-plugin': 5.10.0(eslint@9.39.5(supports-color@5.5.0)) - '@typescript-eslint/parser': 8.67.0(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0)(typescript@6.0.3) - eslint-rule-docs@1.1.235: {} eslint-scope@8.4.0: @@ -15373,23 +15305,6 @@ snapshots: transitivePeerDependencies: - supports-color - mdast-util-from-markdown@2.0.3(supports-color@5.5.0): - dependencies: - '@types/mdast': 4.0.4 - '@types/unist': 3.0.3 - decode-named-character-reference: 1.3.0 - devlop: 1.1.0 - mdast-util-to-string: 4.0.0 - micromark: 4.0.2(supports-color@5.5.0) - micromark-util-decode-numeric-character-reference: 2.0.2 - micromark-util-decode-string: 2.0.1 - micromark-util-normalize-identifier: 2.0.1 - micromark-util-symbol: 2.0.1 - micromark-util-types: 2.0.2 - unist-util-stringify-position: 4.0.0 - transitivePeerDependencies: - - supports-color - mdast-util-gfm-autolink-literal@2.0.1: dependencies: '@types/mdast': 4.0.4 @@ -15398,51 +15313,51 @@ snapshots: mdast-util-find-and-replace: 3.0.2 micromark-util-character: 2.1.1 - mdast-util-gfm-footnote@2.1.0(supports-color@5.5.0): + mdast-util-gfm-footnote@2.1.0(supports-color@10.2.2): dependencies: '@types/mdast': 4.0.4 devlop: 1.1.0 - mdast-util-from-markdown: 2.0.3(supports-color@5.5.0) + mdast-util-from-markdown: 2.0.3(supports-color@10.2.2) mdast-util-to-markdown: 2.1.2 micromark-util-normalize-identifier: 2.0.1 transitivePeerDependencies: - supports-color - mdast-util-gfm-strikethrough@2.0.0(supports-color@5.5.0): + mdast-util-gfm-strikethrough@2.0.0(supports-color@10.2.2): dependencies: '@types/mdast': 4.0.4 - mdast-util-from-markdown: 2.0.3(supports-color@5.5.0) + mdast-util-from-markdown: 2.0.3(supports-color@10.2.2) mdast-util-to-markdown: 2.1.2 transitivePeerDependencies: - supports-color - mdast-util-gfm-table@2.0.0(supports-color@5.5.0): + mdast-util-gfm-table@2.0.0(supports-color@10.2.2): dependencies: '@types/mdast': 4.0.4 devlop: 1.1.0 markdown-table: 3.0.4 - mdast-util-from-markdown: 2.0.3(supports-color@5.5.0) + mdast-util-from-markdown: 2.0.3(supports-color@10.2.2) mdast-util-to-markdown: 2.1.2 transitivePeerDependencies: - supports-color - mdast-util-gfm-task-list-item@2.0.0(supports-color@5.5.0): + mdast-util-gfm-task-list-item@2.0.0(supports-color@10.2.2): dependencies: '@types/mdast': 4.0.4 devlop: 1.1.0 - mdast-util-from-markdown: 2.0.3(supports-color@5.5.0) + mdast-util-from-markdown: 2.0.3(supports-color@10.2.2) mdast-util-to-markdown: 2.1.2 transitivePeerDependencies: - supports-color - mdast-util-gfm@3.1.0(supports-color@5.5.0): + mdast-util-gfm@3.1.0(supports-color@10.2.2): dependencies: - mdast-util-from-markdown: 2.0.3(supports-color@5.5.0) + mdast-util-from-markdown: 2.0.3(supports-color@10.2.2) mdast-util-gfm-autolink-literal: 2.0.1 - mdast-util-gfm-footnote: 2.1.0(supports-color@5.5.0) - mdast-util-gfm-strikethrough: 2.0.0(supports-color@5.5.0) - mdast-util-gfm-table: 2.0.0(supports-color@5.5.0) - mdast-util-gfm-task-list-item: 2.0.0(supports-color@5.5.0) + mdast-util-gfm-footnote: 2.1.0(supports-color@10.2.2) + mdast-util-gfm-strikethrough: 2.0.0(supports-color@10.2.2) + mdast-util-gfm-table: 2.0.0(supports-color@10.2.2) + mdast-util-gfm-task-list-item: 2.0.0(supports-color@10.2.2) mdast-util-to-markdown: 2.1.2 transitivePeerDependencies: - supports-color @@ -15713,28 +15628,6 @@ snapshots: transitivePeerDependencies: - supports-color - micromark@4.0.2(supports-color@5.5.0): - dependencies: - '@types/debug': 4.1.13 - debug: 4.4.3(supports-color@5.5.0) - decode-named-character-reference: 1.3.0 - devlop: 1.1.0 - micromark-core-commonmark: 2.0.3 - micromark-factory-space: 2.0.1 - micromark-util-character: 2.1.1 - micromark-util-chunked: 2.0.1 - micromark-util-combine-extensions: 2.0.1 - micromark-util-decode-numeric-character-reference: 2.0.2 - micromark-util-encode: 2.0.1 - micromark-util-normalize-identifier: 2.0.1 - micromark-util-resolve-all: 2.0.1 - micromark-util-sanitize-uri: 2.0.1 - micromark-util-subtokenize: 2.1.0 - micromark-util-symbol: 2.0.1 - micromark-util-types: 2.0.2 - transitivePeerDependencies: - - supports-color - micromatch@4.0.8: dependencies: braces: 3.0.3 @@ -16452,6 +16345,8 @@ snapshots: dependencies: '@babel/runtime': 7.29.7 + portless@0.15.5: {} + possible-typed-array-names@1.1.0: {} postcss-nesting@14.0.0(postcss@8.5.25): @@ -16794,12 +16689,12 @@ snapshots: gopd: 1.2.0 set-function-name: 2.0.2 - remark-gfm@4.0.1(supports-color@5.5.0): + remark-gfm@4.0.1(supports-color@10.2.2): dependencies: '@types/mdast': 4.0.4 - mdast-util-gfm: 3.1.0(supports-color@5.5.0) + mdast-util-gfm: 3.1.0(supports-color@10.2.2) micromark-extension-gfm: 3.0.0 - remark-parse: 11.0.0(supports-color@5.5.0) + remark-parse: 11.0.0(supports-color@10.2.2) remark-stringify: 11.0.0 unified: 11.0.5 transitivePeerDependencies: @@ -16814,15 +16709,6 @@ snapshots: transitivePeerDependencies: - supports-color - remark-parse@11.0.0(supports-color@5.5.0): - dependencies: - '@types/mdast': 4.0.4 - mdast-util-from-markdown: 2.0.3(supports-color@5.5.0) - micromark-util-types: 2.0.2 - unified: 11.0.5 - transitivePeerDependencies: - - supports-color - remark-stringify@11.0.0: dependencies: '@types/mdast': 4.0.4 @@ -18283,18 +18169,6 @@ snapshots: transitivePeerDependencies: - supports-color - vue-eslint-parser@10.4.1(eslint@9.39.5(supports-color@5.5.0))(supports-color@5.5.0): - dependencies: - debug: 4.4.3(supports-color@5.5.0) - eslint: 9.39.5(supports-color@5.5.0) - eslint-scope: 9.1.2 - eslint-visitor-keys: 5.0.1 - espree: 11.2.0 - esquery: 1.7.0 - semver: 7.8.5 - transitivePeerDependencies: - - supports-color - vue-inbrowser-compiler-independent-utils@4.71.1(vue@3.5.41(typescript@6.0.3)): dependencies: vue: 3.5.41(typescript@6.0.3) diff --git a/scripts/setup-codex-environment.mjs b/scripts/setup-codex-environment.mjs new file mode 100644 index 00000000000..698f0590a2b --- /dev/null +++ b/scripts/setup-codex-environment.mjs @@ -0,0 +1,166 @@ +/* + * SPDX-FileCopyrightText: syuilo and misskey-project + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import { createHash } from 'node:crypto'; +import { createRequire } from 'node:module'; +import { createServer } from 'node:net'; +import { dirname, resolve } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { promises as fsp } from 'node:fs'; +import * as yaml from 'js-yaml'; + +const _filename = fileURLToPath(import.meta.url); +const rootDir = resolve(dirname(_filename), '..'); +const configDir = resolve(rootDir, '.config'); +const sourceConfigPath = resolve(configDir, 'example.yml'); +const generatedConfigPath = resolve(configDir, 'default.yml'); +const portlessEnvPath = resolve(configDir, 'codex-portless.env'); +const portlessStateDir = resolve(configDir, 'portless'); +const require = createRequire(resolve(rootDir, 'packages/backend/package.json')); +const { Client } = require('pg'); +const Redis = require('ioredis'); + +const environmentId = createHash('sha256') + .update(await fsp.realpath(rootDir)) + .digest('hex') + .slice(0, 12); +const databaseName = process.env.MISSKEY_CODEX_DB_NAME ?? `misskey_codex_${environmentId}`; +const databaseHost = process.env.MISSKEY_CODEX_DB_HOST ?? '127.0.0.1'; +const databasePort = Number(process.env.MISSKEY_CODEX_DB_PORT ?? 5432); +const redisHost = process.env.MISSKEY_CODEX_REDIS_HOST ?? '127.0.0.1'; +const redisPort = Number(process.env.MISSKEY_CODEX_REDIS_PORT ?? 6379); +const redisDb = Number(process.env.MISSKEY_CODEX_REDIS_DB ?? 1); +const preferredPortlessPort = 10000 + (Number.parseInt(environmentId.slice(0, 8), 16) % 50000); + +if (!/^[a-zA-Z_][a-zA-Z0-9_]{0,62}$/.test(databaseName)) { + throw new Error(`Invalid PostgreSQL database name: ${databaseName}`); +} + +if (!Number.isInteger(databasePort) || databasePort <= 0 || databasePort > 65535) { + throw new Error(`Invalid PostgreSQL port: ${databasePort}`); +} + +if (!Number.isInteger(redisPort) || redisPort <= 0 || redisPort > 65535) { + throw new Error(`Invalid Redis port: ${redisPort}`); +} + +if (!Number.isInteger(redisDb) || redisDb < 0) { + throw new Error(`Invalid Redis database number: ${redisDb}`); +} + +const databaseCredentialCandidates = process.env.MISSKEY_CODEX_DB_USER + ? [{ + user: process.env.MISSKEY_CODEX_DB_USER, + password: process.env.MISSKEY_CODEX_DB_PASSWORD ?? '', + }] + : [{ + user: 'example-misskey-user', + password: 'example-misskey-pass', + }, { + user: 'misskey', + password: '', + }]; +const connectionErrors = []; +let postgres = null; +let databaseUser = ''; +let databasePassword = ''; + +for (const credentials of databaseCredentialCandidates) { + const candidate = new Client({ + host: databaseHost, + port: databasePort, + database: 'postgres', + ...credentials, + }); + + try { + await candidate.connect(); + postgres = candidate; + databaseUser = credentials.user; + databasePassword = credentials.password; + break; + } catch (error) { + connectionErrors.push(error); + await candidate.end().catch(() => {}); + } +} + +if (postgres == null) { + throw new AggregateError(connectionErrors, `Could not connect to PostgreSQL at ${databaseHost}:${databasePort}.`); +} + +try { + const result = await postgres.query('SELECT 1 FROM pg_database WHERE datname = $1', [databaseName]); + if (result.rowCount === 0) { + try { + await postgres.query(`CREATE DATABASE "${databaseName}"`); + } catch (error) { + if (error?.code !== '42P04') throw error; + } + } +} finally { + await postgres.end(); +} + +const redis = new Redis({ + host: redisHost, + port: redisPort, + db: redisDb, + lazyConnect: true, + maxRetriesPerRequest: 0, +}); + +await redis.connect(); + +try { + await redis.ping(); +} finally { + await redis.quit(); +} + +const canListen = async (port) => await new Promise(resolveAvailable => { + const server = createServer(); + server.once('error', () => resolveAvailable(false)); + server.listen(port, '0.0.0.0', () => { + server.close(() => resolveAvailable(true)); + }); +}); + +let portlessPort = preferredPortlessPort; + +while (!(await canListen(portlessPort))) { + portlessPort = portlessPort === 59999 ? 10000 : portlessPort + 1; + if (portlessPort === preferredPortlessPort) { + throw new Error('Could not find an available Portless proxy port.'); + } +} + +const config = yaml.load(await fsp.readFile(sourceConfigPath, 'utf-8')) ?? {}; +config.url = 'https://misskey.local/'; +config.db = { + ...config.db, + host: databaseHost, + port: databasePort, + db: databaseName, + user: databaseUser, + pass: databasePassword, +}; +config.redis = { + ...config.redis, + host: redisHost, + port: redisPort, + db: redisDb, +}; + +await fsp.writeFile(generatedConfigPath, yaml.dump(config), { mode: 0o600 }); +await fsp.writeFile(portlessEnvPath, [ + `export PORTLESS_STATE_DIR='${portlessStateDir.replaceAll("'", "'\\''")}'`, + `export PORTLESS_PORT=${portlessPort}`, + 'export PORTLESS_LAN=1', + 'export PORTLESS_HTTPS=1', + '', +].join('\n'), { mode: 0o600 }); + +console.log(`Codex environment configured with PostgreSQL database ${databaseName}, Redis DB ${redisDb}, and Portless proxy port ${portlessPort}.`);