nodejs / nodejs.org

The Node.js® Website
https://nodejs.org
MIT License
5.99k stars 6.15k forks source link

Scaffold multi-package workspace. #6850

Open anthonyshew opened 1 week ago

anthonyshew commented 1 week ago

Description

Create the structure for a multi-package workspace for the Node.js website.

Core maintainers have expressed a desire for re-using code from the website in other places. These changes allows for those publishable packages to be created, since they can now be broken out to their own separate packages.

Unfortunately, this involves a large-scale cutover from the repository's previous structure, invalidating PR's that come from current main. I've received maintainer approval for my disruptiveness. 🙏

Fortunately, those outstanding PRs can be fairly easily re-aligned with this PR, since I've made near-zero changes as far as the source code is concerned. This PR updates tooling, rather than functional code. (Prettier updated ~10 files that I saw at one point, but I don't believe this came from the changes I've made. I think the source code was somehow out-of-sync with the Prettier configuration.) If you'd like your PR to meet back up with this one, you should be able to move them from their current location to ./apps/site/<your-path>.

Validation

Anthony's Checklist

vercel[bot] commented 1 week ago

The latest updates on your projects. Learn more about Vercel for Git ↗

Name Status Preview Updated (UTC)
nodejs-org ✅ Ready (Inspect) Visit Preview Jul 1, 2024 3:49pm
bmuenzenmeyer commented 1 week ago

I looked into crowdin renames - this was the best I could find so far.

https://community.crowdin.com/t/change-source-file-name-without-loosing-progress/7594/3

I will ask in our Slack channel with Crowdin to confirm or supply something more detailed

Andrulko commented 1 week ago

One thing I can say I certainly don't know about in this repo is crowdin.yml. I'm not familiar with that tool so I don't know if it makes sense to move into the apps/site directory or if it needs to stay in the root.

Please keep this file in the root of the branch, it is used by Crowdin <-> GitHub connector: https://support.crowdin.com/github-integration/

It would be required to update paths to EN files to be able to sync sources and translations: https://github.com/nodejs/nodejs.org/blob/main/crowdin.yml

Please pause Crowdin <-> GitHub sync before merging the PR, then after it's merged Crowdin team will help to adapt the existing Crowdin project and configuration file to the new structure.

anthonyshew commented 1 week ago

Thanks, @Andrulko! I've remapped those paths now, if you'd like to check them to confirm I've done so correctly.

Andrulko commented 1 week ago

@anthonyshew Just to make sure that everything would work fine, let's insert / at the beginning of path. Please use the configuration below:

commit_message: 'chore: synced translations from crowdin [skip ci]'
append_commit_message: false
pull_request_title: '[automated]: crowdin sync'
pull_request_labels:
  - 'github_actions:pull-request'
files:
  - source: /apps/site/pages/en/**/*.md
    translation: /apps/site/pages/%two_letters_code%/**/%original_file_name%
    content_segmentation: 0
    ignore:
      - /apps/site/pages/en/blog/**/*.md
      - /apps/site/pages/en/learn/**/*.md
      - /apps/site/pages/en/download/index.md
      - /apps/site/pages/en/download/current.md
    languages_mapping:
      two_letters_code:
        es-ES: es
        pt-BR: pt-br
        zh-CN: zh-cn
        zh-TW: zh-tw
  - source: /apps/site/pages/en/**/*.mdx
    translation: /apps/site/pages/%two_letters_code%/**/%original_file_name%
    content_segmentation: 0
    ignore:
      - /apps/site/pages/en/blog/**/*.mdx
      - /apps/site/pages/en/learn/**/*.mdx
    languages_mapping:
      two_letters_code:
        es-ES: es
        pt-BR: pt-br
        zh-CN: zh-cn
        zh-TW: zh-tw
  - source: /apps/site/i18n/locales/en.json
    translation: /apps/site/i18n/locales/%two_letters_code%.json
    languages_mapping:
      two_letters_code:
        es-ES: es
        pt-BR: pt-br
        zh-CN: zh-cn
        zh-TW: zh-tw

Everything else looks good! Before you merge this branch, please pause GitHub sync in Crowdin (otherwise, it will upload new /apps/site folders along with files). I will help to move the existing files in Crowdin project to the new path and then we can safely resume the sync. No new files will be uploaded in this case 👌

anthonyshew commented 1 week ago

Updated with that. Thank you!

bmuenzenmeyer commented 1 week ago

Windows Testing

✅ npm run dev ✅ npm run build ✅ npm run lint ❌ npm run format

PS C:\src\nodejsorg> npm run format

> format
> npm run lint:fix && npm run prettier:fix

> lint:fix
> turbo run lint --force -- --fix

╭──────────────────────────────────────────────────────────────────────╮
│                                                                      │
│                   Update available v2.0.3 ≫ v2.0.5                   │
│    Changelog: https://github.com/vercel/turbo/releases/tag/v2.0.5    │
│           Run "npx @turbo/codemod@latest update" to update           │
│                                                                      │
│        Follow @turborepo for updates: https://x.com/turborepo        │
╰──────────────────────────────────────────────────────────────────────╯
• Packages in scope: @nodejs/website
• Running lint in 1 packages
• Remote caching disabled
┌ @nodejs/website#lint > cache bypass, force executing e6bbf3daeb3b7be9
│
│ > lint
│ > turbo run lint:md lint:js lint:css --fix
│
│ ╭──────────────────────────────────────────────────────────────────────╮
│ │                                                                      │
│ │                   Update available v2.0.3 ≫ v2.0.5                   │
│ │    Changelog: https://github.com/vercel/turbo/releases/tag/v2.0.5    │
│ │           Run "npx @turbo/codemod@latest update" to update           │
│ │                                                                      │
│ │        Follow @turborepo for updates: https://x.com/turborepo        │
│ ╰──────────────────────────────────────────────────────────────────────╯
│  ERROR  unexpected argument '--fix' found
│
│   tip: to pass '--fix' as a value, use '-- --fix'
│
│ Usage: turbo.exe run <--cache-dir <CACHE_DIR>|--concurrency <CONCURRENCY>|--continue|--singl
│ e-package|--force [<FORCE>]
│ |--framework-inference [<BOOL>]|--global-deps <GLOBAL_DEPS>|--env-mode [<ENV_MODE>]|--filter
│  <FILTER>|--output-logs <OU
│ TPUT_LOGS>|--log-order <LOG_ORDER>|--only|--pkg-inference-root <PKG_INFERENCE_ROOT>|--remote
│ -only [<BOOL>]|--log-prefix
│  <LOG_PREFIX>|TASKS|PASS_THROUGH_ARGS>
│
│ For more information, try '--help'.
│
│ npm ERR! Lifecycle script `lint` failed with error:
│ npm ERR! Error: command failed
│ npm ERR!   in workspace: @nodejs/website
│ npm ERR!   at location: C:\src\nodejsorg\apps\site
│ command finished with error: command (C:\src\nodejsorg\apps\site) C:\Program Files\nodejs\np
│ m.cmd run lint -- --fix exited (1)
└────>
┌ @nodejs/website#lint:css > cache bypass, force executing c5eb2653016c9fd1
│
│ > lint:css
│ > stylelint "**/*.css" --allow-empty-input --cache --cache-strategy=content --cache-location
│ =.stylelintcache
└────>
┌ @nodejs/website#lint:js > cache bypass, force executing d4e4c6408b1b624b
│
│ > lint:js
│ > eslint "**/*.{js,mjs,ts,tsx}" --cache --cache-strategy=content --cache-location=.eslintjsc
│ ache
└────>
┌ @nodejs/website#lint:md > cache bypass, force executing 0a254661a087c88d
│
│ > lint:md
│ > eslint "**/*.md?(x)" --cache --cache-strategy=content --cache-location=.eslintmdcache
└────>
 ERROR  run failed: command  exited (1)
github-actions[bot] commented 4 days ago

Running Lighthouse audit...

ovflowd commented 1 day ago

cc @anthonyshew some of the CI steps are still failing

anthonyshew commented 1 day ago

Yep, working on those right now!

ovflowd commented 1 day ago

@anthonyshew lmk when you believe this PR is ready.

Also don't forget to fix the sync orama script and ensure the blog post generation one is also working!

bmuenzenmeyer commented 1 day ago

I've paused Crowdin Sync and made a discussion post over there to describe the changes.