Skip to content

Commit

Permalink
feat(rari): use rari as default
Browse files Browse the repository at this point in the history
BREAKING CHANGE: rari is used by default use :legacy commands for yari
  • Loading branch information
fiji-flo committed Dec 17, 2024
1 parent 31e4a55 commit 0fadbb7
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 34 deletions.
43 changes: 21 additions & 22 deletions .github/workflows/prod-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ jobs:
mv mdn/translated-content-de/files/de mdn/translated-content/files/
rm -rf mdn/translated-content-de
- name: Clean and commit de
if: ${{ ! vars.SKIP_BUILD || ! vars.SKIP_FUNCTION }}
working-directory: mdn/translated-content
run: |
git add files/de
git -c user.name='MDN' -c user.email='[email protected]' commit -m 'de'
- uses: actions/checkout@v4
if: ${{ ! vars.SKIP_BUILD }}
with:
Expand All @@ -151,7 +158,8 @@ jobs:
if: ${{ ! vars.SKIP_BUILD }}
run: yarn --frozen-lockfile
env:
# https://github.com/microsoft/vscode-ripgrep#github-api-limit-note
# Use a GITHUB_TOKEN to bypass rate limiting for ripgrep and rari.
# See https://github.com/microsoft/vscode-ripgrep#github-api-limit-note
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install Python
Expand Down Expand Up @@ -198,6 +206,12 @@ jobs:
GENERIC_CONTENT_ROOT: ${{ github.workspace }}/mdn/generic-content/files
BASE_URL: "https://developer.mozilla.org"

# rari
BUILD_OUT_ROOT: "client/build"
LIVE_SAMPLES_BASE_URL: https://live.mdnplay.dev
INTERACTIVE_EXAMPLES_BASE_URL: https://interactive-examples.mdn.mozilla.net
ADDITIONAL_LOCALES_FOR_GENERICS_AND_SPAS: de

# The default for this environment variable is geared for writers
# (aka. local development). Usually defaults are supposed to be for
# secure production but this is an exception and default
Expand Down Expand Up @@ -285,32 +299,17 @@ jobs:
echo "CONTENT_ROOT=$CONTENT_ROOT"
echo "CONTENT_TRANSLATED_ROOT=$CONTENT_TRANSLATED_ROOT"
yarn build:sw
yarn build:prepare
yarn build:client
yarn build:ssr
yarn tool build-robots-txt
yarn tool sync-translated-content es fr ja ko pt-br ru zh-cn zh-tw
yarn rari content sync-translated-content
yarn rari git-history
# Build using one process per locale.
# Note: We have 4 cores, but 9 processes is a reasonable number.
for locale in en-us de es fr ja ko pt-br ru zh-cn zh-tw; do
yarn build:docs --locale $locale 2>&1 | sed "s/^/[$locale] /" &
pids+=($!)
done
for pid in "${pids[@]}"; do
wait $pid
done
yarn rari build --all --issues client/build/issues.json --templ-stats
du -sh client/build
# Build the blog
yarn build:blog
# Build the curriculum
yarn build:curriculum
# Generate sitemap index file
yarn build --sitemap-index
# SSR all pages
yarn render:html
Expand Down
4 changes: 4 additions & 0 deletions Procfile.rari.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
server: yarn start:rari-server
type-check: cd client && tsc --noEmit --watch
web: yarn start:client
ssr: yarn watch:ssr
5 changes: 5 additions & 0 deletions bins/build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env node
import { rariBin } from "@mdn/rari";
import { spawn } from "cross-spawn";

spawn(rariBin, ["build"], { stdio: "inherit" });
52 changes: 52 additions & 0 deletions bins/server.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env node
import { concurrently } from "concurrently";
import { rariBin } from "@mdn/rari";
import { filename } from "../server/filename.js";
import { config } from "dotenv";
import path from "node:path";
import { cwd } from "node:process";

config({
path: path.join(cwd(), process.env.ENV_FILE || ".env"),
});

const { commands, result } = concurrently(
[
{
command: `node ${filename}`,
name: "server",
env: {
RARI: true,
},
prefixColor: "red",
},
{
command: `${rariBin} serve -vv`,
name: "rari",
prefixColor: "blue",
env: {
...process.env,
},
},
],
{
killOthers: ["failure", "success"],
restartTries: 0,
handleInput: true,
inputStream: process.stdin,
}
);

const stop = new Promise((resolve, reject) => {
process.on("SIGINT", () => {
commands.forEach((cmd) => cmd.kill()); // Terminate all concurrently-run processes
reject();
});
result.finally(() => resolve(null));
});
try {
await stop;
console.log("All tasks completed successfully.");
} catch {
console.log("Killed ☠️");
}
5 changes: 5 additions & 0 deletions bins/tool.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env node
import { rariBin } from "@mdn/rari";
import { spawn } from "cross-spawn";

spawn(rariBin, ["content"], { stdio: "inherit" });
29 changes: 18 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"author": "MDN Web Docs",
"type": "module",
"bin": {
"rari-server": "server/cli.js",
"rari-build": "bins/build.mjs",
"rari-server": "bins/server.mjs",
"rari-tool": "bins/tool.mjs",
"yari-build": "build/cli.js",
"yari-build-blog": "build/build-blog.js",
"yari-filecheck": "filecheck/cli.js",
Expand All @@ -17,19 +19,22 @@
"scripts": {
"ai-help-macros": "cross-env NODE_OPTIONS=\"--no-warnings=ExperimentalWarning --loader ts-node/esm\" node scripts/ai-help-macros.ts",
"analyze": "(test -f client/build/stats.json || cross-env ANALYZE_BUNDLE=true yarn build:client) && webpack-bundle-analyzer client/build/stats.json",
"build": "cross-env NODE_ENV=production NODE_OPTIONS=\"--no-warnings=ExperimentalWarning --loader ts-node/esm\" node build/cli.ts",
"build:blog": "cross-env NODE_ENV=production NODE_OPTIONS=\"--no-warnings=ExperimentalWarning --loader ts-node/esm\" node build/build-blog.ts",
"build": "yarn rari build",
"build:client": "cd client && cross-env NODE_ENV=production BABEL_ENV=production node scripts/build.js",
"build:curriculum": "cross-env NODE_ENV=production NODE_OPTIONS=\"--no-warnings=ExperimentalWarning --loader ts-node/esm\" node build/build-curriculum.ts",
"build:dist": "tsc -p tsconfig.dist.json",
"build:docs": "cross-env NODE_ENV=production NODE_OPTIONS=\"--no-warnings=ExperimentalWarning --loader ts-node/esm\" node build/cli.ts -n",
"build:glean": "cd client && cross-env VIRTUAL_ENV=venv glean translate src/telemetry/metrics.yaml src/telemetry/pings.yaml -f typescript -o src/telemetry/generated",
"build:prepare": "yarn build:client && yarn build:ssr && yarn tool popularities && yarn tool spas && yarn tool gather-git-history && yarn tool build-robots-txt",
"build:legacy": "cross-env NODE_ENV=production NODE_OPTIONS=\"--no-warnings=ExperimentalWarning --loader ts-node/esm\" node build/cli.ts",
"build:legacy::curriculum": "cross-env NODE_ENV=production NODE_OPTIONS=\"--no-warnings=ExperimentalWarning --loader ts-node/esm\" node build/build-curriculum.ts",
"build:legacy::docs": "cross-env NODE_ENV=production NODE_OPTIONS=\"--no-warnings=ExperimentalWarning --loader ts-node/esm\" node build/cli.ts -n",
"build:legacy:blog": "cross-env NODE_ENV=production NODE_OPTIONS=\"--no-warnings=ExperimentalWarning --loader ts-node/esm\" node build/build-blog.ts",
"build:legacy:prepare": "yarn build:client && yarn build:ssr && yarn tool:legacy popularities && yarn tool:legacy spas && yarn tool:legacy gather-git-history && yarn tool:legacy build-robots-txt",
"build:prepare": "yarn build:client && yarn build:ssr && yarn tool:legacy build-robots-txt",
"build:ssr": "cross-env NODE_ENV=production NODE_OPTIONS=\"--no-warnings=ExperimentalWarning --loader ts-node/esm\" node ssr/prepare.ts && webpack --mode=production --config=ssr/webpack.config.js",
"build:sw": "cd client/pwa && yarn && yarn build:prod",
"build:sw-dev": "cd client/pwa && yarn && yarn build",
"check:tsc": "find . -name 'tsconfig.json' ! -wholename '**/node_modules/**' -print0 | xargs -n1 -P 2 -0 sh -c 'cd `dirname $0` && echo \"🔄 $(pwd)\" && npx tsc --noEmit && echo \"☑️ $(pwd)\" || exit 255'",
"dev": "yarn build:prepare && nf -j Procfile.dev start",
"dev": "yarn build:prepare && nf -j Procfile.rari.dev start",
"dev:legacy": "yarn build:legacy:prepare && nf -j Procfile.dev start",
"eslint": "eslint .",
"filecheck": "cross-env NODE_OPTIONS=\"--no-warnings=ExperimentalWarning --loader ts-node/esm\" node filecheck/cli.ts",
"install:all": "find . -mindepth 2 -name 'yarn.lock' ! -wholename '**/node_modules/**' -print0 | xargs -n1 -0 sh -cx 'yarn --cwd $(dirname $0) install'",
Expand All @@ -41,9 +46,9 @@
"prettier-check": "prettier --check .",
"prettier-format": "prettier --write .",
"render:html": "cross-env NODE_ENV=production NODE_OPTIONS=\"--no-warnings=ExperimentalWarning --loader ts-node/esm\" node build/ssr-cli.ts",
"start": "(test -f client/build/asset-manifest.json || yarn build:client) && (test -f ssr/dist/main.js || yarn build:ssr) && (test -f popularities.json || yarn tool popularities) && (test -d client/build/en-us/404 || yarn tool spas) && (test -d client/build/en-us/404/index.html || yarn render:html -s) && nf -j Procfile.start start",
"start": "(test -f client/build/asset-manifest.json || yarn build:client) && (test -f ssr/dist/main.js || yarn build:ssr) && cross-env RARI=true nf -j Procfile.rari start",
"start:client": "cd client && cross-env NODE_ENV=development BABEL_ENV=development PORT=3000 node scripts/start.js",
"start:rari": "(test -f client/build/asset-manifest.json || yarn build:client) && (test -f ssr/dist/main.js || yarn build:ssr) && cross-env RARI=true nf -j Procfile.rari start",
"start:legacy": "(test -f client/build/asset-manifest.json || yarn build:client) && (test -f ssr/dist/main.js || yarn build:ssr) && (test -f popularities.json || yarn tool:legacy popularities) && (test -d client/build/en-us/404 || yarn tool spas) && (test -d client/build/en-us/404/index.html || yarn render:html -s) && nf -j Procfile.start start",
"start:rari-external": "(test -f client/build/asset-manifest.json || yarn build:client) && (test -f ssr/dist/main.js || yarn build:ssr) && cross-env RARI=true nf -j Procfile.start start",
"start:rari-server": "cross-env NODE_OPTIONS=\"--no-warnings=ExperimentalWarning --loader ts-node/esm\" node server/cli.ts",
"start:server": "node-dev --experimental-loader ts-node/esm server/index.ts",
Expand All @@ -56,9 +61,10 @@
"test:headless": "playwright test headless",
"test:kumascript": "yarn jest --rootDir kumascript --env=node",
"test:libs": "yarn jest --rootDir libs --env=node",
"test:prepare": "yarn build:prepare && yarn build:docs && yarn render:html && yarn start:static-server",
"test:prepare": "yarn build:prepare && yarn build && yarn render:html && yarn start:static-server",
"test:testing": "yarn jest --rootDir testing",
"tool": "cross-env NODE_OPTIONS=\"--no-warnings=ExperimentalWarning --loader ts-node/esm\" node ./tool/cli.ts",
"tool": "yarn rari content",
"tool:legacy": "cross-env NODE_OPTIONS=\"--no-warnings=ExperimentalWarning --loader ts-node/esm\" node ./tool/cli.ts",
"watch:ssr": "webpack --mode=production --watch --config=ssr/webpack.config.js"
},
"resolutions": {
Expand Down Expand Up @@ -96,6 +102,7 @@
"concurrently": "^9.1.0",
"cookie": "^0.7.2",
"cookie-parser": "^1.4.7",
"cross-spawn": "^7.0.6",
"css-tree": "^2.3.1",
"dayjs": "^1.11.13",
"dexie": "^4.0.10",
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5472,7 +5472,7 @@ cross-spawn@^6.0.0:
shebang-command "^1.2.0"
which "^1.2.9"

cross-spawn@^7.0.0, cross-spawn@^7.0.1, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
cross-spawn@^7.0.0, cross-spawn@^7.0.1, cross-spawn@^7.0.2, cross-spawn@^7.0.3, cross-spawn@^7.0.6:
version "7.0.6"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.6.tgz#8a58fe78f00dcd70c370451759dfbfaf03e8ee9f"
integrity sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==
Expand Down

0 comments on commit 0fadbb7

Please sign in to comment.