diff --git a/.syncpackrc.ts b/.syncpackrc.ts index e1ec52583e5d..9e1904846e1d 100644 --- a/.syncpackrc.ts +++ b/.syncpackrc.ts @@ -16,6 +16,7 @@ export default { 'packages/*/package.json', 'website/package.json', 'argos/package.json', + 'admin/scripts/package.json', 'packages/create-docusaurus/templates/*/package.json', ], diff --git a/admin/scripts/copyUntypedFiles.js b/admin/scripts/copyUntypedFiles.js old mode 100644 new mode 100755 index 093237cddb5f..becf3eb20f91 --- a/admin/scripts/copyUntypedFiles.js +++ b/admin/scripts/copyUntypedFiles.js @@ -1,3 +1,4 @@ +#!/usr/bin/env node /** * Copyright (c) Facebook, Inc. and its affiliates. * diff --git a/admin/scripts/package.json b/admin/scripts/package.json index 03df6476e25f..07569e18d8dc 100644 --- a/admin/scripts/package.json +++ b/admin/scripts/package.json @@ -1,7 +1,20 @@ { - "name": "docu-scripts", - "description": "These are the scripts used in various places of Docusaurus maintenance", + "name": "@docusaurus/monorepo-scripts", + "version": "4.0.0", + "description": "Scripts used in various places of Docusaurus maintenance", "private": true, "license": "MIT", - "type": "module" + "type": "module", + "bin": { + "copy-untyped-files": "copyUntypedFiles.js" + }, + "dependencies": { + "@docusaurus/fs": "workspace:*", + "@docusaurus/logger": "workspace:*", + "commander": "^15.0.0", + "execa": "^10.0.1", + "image-size": "^2.0.4", + "lodash": "^4.18.1", + "sharp": "^0.35.1" + } } diff --git a/knip.config.ts b/knip.config.ts index b2aff7113c1e..c6138fc75f6e 100644 --- a/knip.config.ts +++ b/knip.config.ts @@ -44,7 +44,6 @@ const config: KnipConfig = { workspaces: { '.': { entry: [ - 'admin/scripts/*.js', // Vitest alias for @generated/* modules 'test/emptyModule.ts', ], @@ -69,6 +68,10 @@ const config: KnipConfig = { // The plugin reads functions entry points from netlify.toml netlify: true, }, + 'admin/scripts': { + // Run directly with node, or through the package bin commands + entry: ['*.js'], + }, 'packages/create-docusaurus': { // Used to test the CLI package ignoreBinaries: ['create-docusaurus'], diff --git a/package.json b/package.json index 2df802ae9869..1c3513dd500c 100644 --- a/package.json +++ b/package.json @@ -79,6 +79,7 @@ "@ai-sdk/react": "^3.0.280", "@crowdin/cli": "^5.0.2", "@docusaurus/eslint-plugin": "workspace:*", + "@docusaurus/monorepo-scripts": "workspace:*", "@docusaurus/plugin-content-blog": "workspace:*", "@docusaurus/plugin-content-docs": "workspace:*", "@docusaurus/plugin-content-pages": "workspace:*", @@ -94,7 +95,6 @@ "@types/semver": "^7.8.0", "@vitejs/plugin-react": "^6.1.1", "@vitest/eslint-plugin": "^1.6.27", - "commander": "^15.0.0", "cross-env": "^10.1.0", "cspell": "^10.3.3", "eslint": "^9.39.5", @@ -107,10 +107,8 @@ "eslint-plugin-react-hooks": "^7.1.1", "eslint-plugin-react-you-might-not-need-an-effect": "^1.0.2", "eslint-plugin-regexp": "^3.3.0", - "execa": "^10.0.1", "globals": "^17.12.0", "husky": "^9.1.7", - "image-size": "^2.0.4", "jest-serializer-ansi-escapes": "^5.0.0", "jest-serializer-react-helmet-async": "^1.0.21", "jiti": "^2.7.0", @@ -127,7 +125,6 @@ "react-dom": "^19.3.0", "react-helmet-async": "npm:@slorber/react-helmet-async@1.3.0", "rimraf": "^6.1.3", - "sharp": "^0.35.1", "stylelint": "^17.15.0", "stylelint-config-standard": "^40.0.0", "stylelint-copyright": "workspace:*", diff --git a/packages/docusaurus-plugin-debug/package.json b/packages/docusaurus-plugin-debug/package.json index b2bb4c5a013e..15aca4ce3255 100644 --- a/packages/docusaurus-plugin-debug/package.json +++ b/packages/docusaurus-plugin-debug/package.json @@ -5,10 +5,10 @@ "main": "lib/index.js", "types": "src/plugin-debug.d.ts", "scripts": { - "build": "tsc --build && node ../../admin/scripts/copyUntypedFiles.js && oxfmt \"lib/theme/**/*.js\"", + "build": "tsc --build && copy-untyped-files && oxfmt \"lib/theme/**/*.js\"", "watch": "run-p -c copy:watch build:watch", "build:watch": "tsc --build --watch", - "copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch" + "copy:watch": "copy-untyped-files --watch" }, "publishConfig": { "access": "public" diff --git a/packages/docusaurus-plugin-google-gtag/package.json b/packages/docusaurus-plugin-google-gtag/package.json index 67f7b16de31a..580a9bcbf540 100644 --- a/packages/docusaurus-plugin-google-gtag/package.json +++ b/packages/docusaurus-plugin-google-gtag/package.json @@ -5,10 +5,10 @@ "main": "lib/index.js", "types": "lib/index.d.ts", "scripts": { - "build": "tsc --build && node ../../admin/scripts/copyUntypedFiles.js", + "build": "tsc --build && copy-untyped-files", "watch": "run-p -c copy:watch build:watch", "build:watch": "tsc --build --watch", - "copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch" + "copy:watch": "copy-untyped-files --watch" }, "publishConfig": { "access": "public" diff --git a/packages/docusaurus-plugin-ideal-image/package.json b/packages/docusaurus-plugin-ideal-image/package.json index 973844ca38d6..1d4c0ede7a38 100644 --- a/packages/docusaurus-plugin-ideal-image/package.json +++ b/packages/docusaurus-plugin-ideal-image/package.json @@ -5,10 +5,10 @@ "main": "lib/index.js", "types": "src/plugin-ideal-image.d.ts", "scripts": { - "build": "tsc --build && node ../../admin/scripts/copyUntypedFiles.js && oxfmt \"lib/theme/**/*.js\"", + "build": "tsc --build && copy-untyped-files && oxfmt \"lib/theme/**/*.js\"", "watch": "run-p -c copy:watch build:watch", "build:watch": "tsc --build --watch", - "copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch" + "copy:watch": "copy-untyped-files --watch" }, "publishConfig": { "access": "public" diff --git a/packages/docusaurus-plugin-pwa/package.json b/packages/docusaurus-plugin-pwa/package.json index 65c4bd5703d5..530eda4191c9 100644 --- a/packages/docusaurus-plugin-pwa/package.json +++ b/packages/docusaurus-plugin-pwa/package.json @@ -5,10 +5,10 @@ "main": "lib/index.js", "types": "src/plugin-pwa.d.ts", "scripts": { - "build": "tsc --build && node ../../admin/scripts/copyUntypedFiles.js && oxfmt \"lib/theme/**/*.js\"", + "build": "tsc --build && copy-untyped-files && oxfmt \"lib/theme/**/*.js\"", "watch": "run-p -c copy:watch build:watch", "build:watch": "tsc --build --watch", - "copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch" + "copy:watch": "copy-untyped-files --watch" }, "publishConfig": { "access": "public" diff --git a/packages/docusaurus-theme-classic/package.json b/packages/docusaurus-theme-classic/package.json index a50a46e7c676..086059104ed4 100644 --- a/packages/docusaurus-theme-classic/package.json +++ b/packages/docusaurus-theme-classic/package.json @@ -14,10 +14,10 @@ }, "license": "MIT", "scripts": { - "build": "tsc --build && node ../../admin/scripts/copyUntypedFiles.js && oxfmt \"lib/theme/**/*.js\"", + "build": "tsc --build && copy-untyped-files && oxfmt \"lib/theme/**/*.js\"", "watch": "run-p -c copy:watch build:watch", "build:watch": "tsc --build --watch", - "copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch" + "copy:watch": "copy-untyped-files --watch" }, "dependencies": { "@docusaurus/core": "workspace:*", diff --git a/packages/docusaurus-theme-common/package.json b/packages/docusaurus-theme-common/package.json index a1f9fb255337..726d6dcb722a 100644 --- a/packages/docusaurus-theme-common/package.json +++ b/packages/docusaurus-theme-common/package.json @@ -14,10 +14,10 @@ "./Details": "./lib/components/Details/index.js" }, "scripts": { - "build": "tsc && node ../../admin/scripts/copyUntypedFiles.js", + "build": "tsc && copy-untyped-files", "watch": "run-p -c copy:watch build:watch", "build:watch": "tsc --watch", - "copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch", + "copy:watch": "copy-untyped-files --watch", "removeThemeInternalReexport": "node removeThemeInternalReexport.mjs" }, "publishConfig": { diff --git a/packages/docusaurus-theme-live-codeblock/package.json b/packages/docusaurus-theme-live-codeblock/package.json index 5d6b1b15a16a..919c05f4365e 100644 --- a/packages/docusaurus-theme-live-codeblock/package.json +++ b/packages/docusaurus-theme-live-codeblock/package.json @@ -23,10 +23,10 @@ "access": "public" }, "scripts": { - "build": "tsc --build && node ../../admin/scripts/copyUntypedFiles.js && oxfmt \"lib/theme/**/*.js\"", + "build": "tsc --build && copy-untyped-files && oxfmt \"lib/theme/**/*.js\"", "watch": "run-p -c copy:watch build:watch", "build:watch": "tsc --build --watch", - "copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch" + "copy:watch": "copy-untyped-files --watch" }, "repository": { "type": "git", diff --git a/packages/docusaurus-theme-mermaid/package.json b/packages/docusaurus-theme-mermaid/package.json index 744d4da851fc..08e1cb62404b 100644 --- a/packages/docusaurus-theme-mermaid/package.json +++ b/packages/docusaurus-theme-mermaid/package.json @@ -27,10 +27,10 @@ }, "license": "MIT", "scripts": { - "build": "tsc --build && node ../../admin/scripts/copyUntypedFiles.js && oxfmt \"lib/theme/**/*.js\"", + "build": "tsc --build && copy-untyped-files && oxfmt \"lib/theme/**/*.js\"", "watch": "run-p -c copy:watch build:watch", "build:watch": "tsc --build --watch", - "copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch" + "copy:watch": "copy-untyped-files --watch" }, "dependencies": { "@docusaurus/core": "workspace:*", diff --git a/packages/docusaurus-theme-search-algolia/package.json b/packages/docusaurus-theme-search-algolia/package.json index e4433748f241..0ccbd70bedb6 100644 --- a/packages/docusaurus-theme-search-algolia/package.json +++ b/packages/docusaurus-theme-search-algolia/package.json @@ -27,10 +27,10 @@ }, "license": "MIT", "scripts": { - "build": "tsc --build && node ../../admin/scripts/copyUntypedFiles.js && oxfmt \"lib/theme/**/*.js\"", + "build": "tsc --build && copy-untyped-files && oxfmt \"lib/theme/**/*.js\"", "watch": "run-p -c copy:watch build:watch", "build:watch": "tsc --build --watch", - "copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch" + "copy:watch": "copy-untyped-files --watch" }, "dependencies": { "@algolia/autocomplete-core": "^1.19.10", diff --git a/packages/docusaurus/package.json b/packages/docusaurus/package.json index f4af3c394847..536235e2a2e9 100644 --- a/packages/docusaurus/package.json +++ b/packages/docusaurus/package.json @@ -24,10 +24,10 @@ "docusaurus": "bin/docusaurus.mjs" }, "scripts": { - "build": "tsc --build && node ../../admin/scripts/copyUntypedFiles.js", + "build": "tsc --build && copy-untyped-files", "watch": "run-p -c copy:watch build:watch", "build:watch": "tsc --build --watch", - "copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch" + "copy:watch": "copy-untyped-files --watch" }, "bugs": { "url": "https://github.com/facebook/docusaurus/issues" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dde36cfaf9bb..059848a7a703 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -126,6 +126,9 @@ importers: '@docusaurus/fs': specifier: workspace:* version: link:packages/docusaurus-fs + '@docusaurus/monorepo-scripts': + specifier: workspace:* + version: link:admin/scripts '@docusaurus/plugin-content-blog': specifier: workspace:* version: link:packages/docusaurus-plugin-content-blog @@ -171,9 +174,6 @@ importers: '@vitest/eslint-plugin': specifier: ^1.6.27 version: 1.6.27(@typescript-eslint/eslint-plugin@8.70.0(@typescript-eslint/parser@8.70.0(@typescript/typescript6@6.0.2)(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0))(@typescript/typescript6@6.0.2)(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0))(@typescript/typescript6@6.0.2)(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(vitest@5.0.0(@opentelemetry/api@1.9.1)(@types/node@26.6.1)(jsdom@30.1.0)(vite@8.2.2(@types/node@26.6.1)(jiti@2.7.0)(terser@5.51.2)(yaml@2.9.0))) - commander: - specifier: ^15.0.0 - version: 15.0.0 cross-env: specifier: ^10.1.0 version: 10.1.0 @@ -210,18 +210,12 @@ importers: eslint-plugin-regexp: specifier: ^3.3.0 version: 3.3.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0)) - execa: - specifier: ^10.0.1 - version: 10.0.1 globals: specifier: ^17.12.0 version: 17.12.0 husky: specifier: ^9.1.7 version: 9.1.7 - image-size: - specifier: ^2.0.4 - version: 2.0.4 jest-serializer-ansi-escapes: specifier: ^5.0.0 version: 5.0.0 @@ -270,9 +264,6 @@ importers: rimraf: specifier: ^6.1.3 version: 6.1.3 - sharp: - specifier: ^0.35.1 - version: 0.35.4(@types/node@26.6.1) stylelint: specifier: ^17.15.0 version: 17.15.0(@typescript/typescript6@6.0.2)(supports-color@7.2.0) @@ -300,6 +291,30 @@ importers: admin/new.docusaurus.io: {} + admin/scripts: + dependencies: + '@docusaurus/fs': + specifier: workspace:* + version: link:../../packages/docusaurus-fs + '@docusaurus/logger': + specifier: workspace:* + version: link:../../packages/docusaurus-logger + commander: + specifier: ^15.0.0 + version: 15.0.0 + execa: + specifier: ^10.0.1 + version: 10.0.1 + image-size: + specifier: ^2.0.4 + version: 2.0.4 + lodash: + specifier: ^4.18.1 + version: 4.18.1 + sharp: + specifier: ^0.35.1 + version: 0.35.4(@types/node@26.6.1) + admin/test-bad-package: dependencies: '@mdx-js/react': @@ -2321,6 +2336,9 @@ importers: cross-env: specifier: ^10.1.0 version: 10.1.0 + image-size: + specifier: ^2.0.4 + version: 2.0.4 lodash: specifier: ^4.18.1 version: 4.18.1 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index cdda6d3a042f..80bb2a8b4137 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -9,6 +9,7 @@ packages: - 'website' - 'test-website-in-workspace' - 'packages/create-docusaurus/templates/*' + - 'admin/scripts' - 'admin/test-bad-package' - 'admin/new.docusaurus.io' diff --git a/website/package.json b/website/package.json index a624075014e0..25b7f9c23ec5 100644 --- a/website/package.json +++ b/website/package.json @@ -90,6 +90,7 @@ "@types/prismjs": "^1.26.6", "copy-text-to-clipboard": "^3.2.2", "cross-env": "^10.1.0", + "image-size": "^2.0.4", "lodash": "^4.18.1", "prismjs": "^1.30.0", "rimraf": "^6.1.3",