Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rari): support rari as beta feature #12051

Merged
merged 56 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
b8f5a89
feat(rari): support rari as beta feature
fiji-flo Oct 29, 2024
8419dc2
feat(rari): add rari server to bin
fiji-flo Oct 30, 2024
988aa9f
Merge remote-tracking branch 'upstream/main' into rari-beta
fiji-flo Oct 30, 2024
54337d0
fix server cli
fiji-flo Oct 31, 2024
9f0a8ae
Merge remote-tracking branch 'upstream/main' into rari-beta
fiji-flo Oct 31, 2024
13cbf0a
update rari
fiji-flo Oct 31, 2024
84bfd79
Merge remote-tracking branch 'upstream/main' into rari-beta
fiji-flo Nov 4, 2024
bcf52c1
Merge remote-tracking branch 'upstream/main' into rari-beta
fiji-flo Nov 4, 2024
924779c
Merge remote-tracking branch 'upstream/main' into rari-beta
fiji-flo Nov 6, 2024
88a07af
Merge remote-tracking branch 'upstream/main' into rari-beta
fiji-flo Nov 7, 2024
9e69b7e
Merge remote-tracking branch 'upstream/main' into rari-beta
fiji-flo Nov 7, 2024
184c537
add de
fiji-flo Nov 7, 2024
4e440ae
Merge remote-tracking branch 'upstream/main' into rari-beta
fiji-flo Nov 8, 2024
3cd614b
update rari
fiji-flo Nov 8, 2024
e994cd9
fix(playground): fix testing url
fiji-flo Nov 11, 2024
11e3889
Merge remote-tracking branch 'upstream/main' into rari-beta
fiji-flo Nov 11, 2024
de59651
yarn.lock
argl Nov 13, 2024
46dd34f
Merge branch 'main' into rari-beta
argl Nov 13, 2024
0e3653e
squelch a linter warning
argl Nov 13, 2024
1a3977c
Update server/index.ts
fiji-flo Nov 13, 2024
de68cc8
content merged
fiji-flo Nov 14, 2024
0abcb1f
rari 19
fiji-flo Nov 14, 2024
1b272c4
search index
fiji-flo Nov 17, 2024
c121361
Merge remote-tracking branch 'upstream/main' into rari-beta
fiji-flo Nov 18, 2024
23b3e23
rari 20
fiji-flo Nov 18, 2024
6834ee1
Merge remote-tracking branch 'upstream/main' into rari-beta
fiji-flo Nov 18, 2024
485ff2e
contributors.txt
fiji-flo Nov 18, 2024
3202e0e
stage
fiji-flo Nov 18, 2024
cf799bd
commit de
fiji-flo Nov 18, 2024
410cece
comment
fiji-flo Nov 19, 2024
58bf02a
Merge remote-tracking branch 'upstream/main' into rari-beta
fiji-flo Nov 19, 2024
37d9086
fix rari-server
fiji-flo Nov 19, 2024
e4fa1e0
robots
fiji-flo Nov 19, 2024
e097803
switch if
fiji-flo Nov 19, 2024
5e97ddc
fix missing summary field on search indexer
argl Nov 19, 2024
b953ac6
fix for windows
fiji-flo Nov 19, 2024
154b38e
improve windows support
fiji-flo Nov 19, 2024
d6b0c66
update rari
fiji-flo Nov 21, 2024
4af4948
Merge remote-tracking branch 'upstream/main' into rari-beta
fiji-flo Nov 22, 2024
b3b1d9f
config for spas
fiji-flo Nov 22, 2024
41b30e6
Merge remote-tracking branch 'upstream/main' into rari-beta
fiji-flo Nov 25, 2024
f24f3bc
update rari
fiji-flo Nov 25, 2024
042267a
update popularities format in yari to match rari implementation
argl Nov 25, 2024
19a961f
update bcd dependency
argl Nov 25, 2024
dd480b0
update bcd dependency
argl Nov 25, 2024
47ad519
update popularities usage
fiji-flo Nov 25, 2024
94863aa
update rari and fix generic content
fiji-flo Nov 25, 2024
42f7055
fix package
fiji-flo Nov 26, 2024
4e73f09
shebang
fiji-flo Nov 26, 2024
e32e0cb
Merge remote-tracking branch 'upstream/main' into rari-beta
fiji-flo Nov 27, 2024
5ee5b49
update rari
fiji-flo Nov 27, 2024
237bd95
clean up
fiji-flo Nov 27, 2024
0ba3634
implicit popularities
fiji-flo Nov 27, 2024
84cfec5
add community route
fiji-flo Nov 28, 2024
05d6c0e
Merge remote-tracking branch 'upstream/main' into rari-beta
fiji-flo Nov 28, 2024
7ed4653
fix config.json
fiji-flo Nov 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 22 additions & 24 deletions .github/workflows/stage-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,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 @@ -168,7 +175,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 @@ -214,6 +222,13 @@ jobs:
CURRICULUM_ROOT: ${{ github.workspace }}/mdn/curriculum
BASE_URL: "https://developer.allizom.org"

# rari
BUILD_OUT_ROOT: "client/build"
GENERIC_CONTENT_ROOT: "copy"
LIVE_SAMPLES_BASE_URL: https://live.mdnyalp.dev
INTERACTIVE_EXAMPLES_BASE_URL: https://interactive-examples.mdn.allizom.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 @@ -290,31 +305,14 @@ jobs:
echo "BLOG_ROOT=$BLOG_ROOT"
# Build the ServiceWorker first
yarn build:sw
yarn build:prepare
yarn tool sync-translated-content es fr ja ko pt-br ru zh-cn zh-tw
# 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
du -sh client/build
# Build the blog
yarn build:blog
yarn build:client
yarn build:ssr
yarn tool build-robots-txt
# Build the curriculum
yarn build:curriculum
yarn rari content sync-translated-content
yarn rari git-history
# Generate sitemap index file
yarn build --sitemap-index
yarn rari build --issues client/build/issues.json --templ-stats
# SSR all pages
yarn render:html
Expand Down
62 changes: 37 additions & 25 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,26 @@ jobs:
# See matching warning for mdn/content checkout step
fetch-depth: 0

- name: Checkout (translated-content-de)
uses: actions/checkout@v4
if: ${{ ! vars.SKIP_BUILD || ! vars.SKIP_FUNCTION }}
with:
repository: mdn/translated-content-de
path: mdn/translated-content-de

- name: Move de into translated-content
if: ${{ ! vars.SKIP_BUILD || ! vars.SKIP_FUNCTION }}
run: |
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 @@ -89,7 +109,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: Print information about build
Expand All @@ -111,6 +132,13 @@ jobs:
CURRICULUM_ROOT: ${{ github.workspace }}/mdn/curriculum
BASE_URL: "https://test.developer.allizom.org"

# rari
BUILD_OUT_ROOT: "client/build"
GENERIC_CONTENT_ROOT: "copy"
LIVE_SAMPLES_BASE_URL: https://live.test.mdnyalp.dev
INTERACTIVE_EXAMPLES_BASE_URL: https://interactive-examples.mdn.allizom.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 @@ -155,7 +183,7 @@ jobs:
REACT_APP_PLACEMENT_ENABLED: true

# Playground
REACT_APP_PLAYGROUND_BASE_HOST: play.test.mdn.allizom.net
REACT_APP_PLAYGROUND_BASE_HOST: test.mdnyalp.dev

# Observatory
REACT_APP_OBSERVATORY_API_URL: https://observatory-api.mdn.allizom.net
Expand All @@ -168,31 +196,14 @@ jobs:
echo "BLOG_ROOT=$BLOG_ROOT"
# Build the ServiceWorker first
yarn build:sw
yarn build:prepare
#yarn tool sync-translated-content
# Build using one process per locale.
# Note: We have 4 cores, but 9 processes is a reasonable number.
for locale in en-us fr; do
yarn build:docs --locale $locale 2>&1 | sed "s/^/[$locale] /" &
pids+=($!)
done
for pid in "${pids[@]}"; do
wait $pid
done
du -sh client/build
# Build the blog
yarn build:blog
yarn build:client
yarn build:ssr
yarn tool build-robots-txt
# Build the curriculum
yarn build:curriculum
yarn rari content sync-translated-content
yarn rari git-history
# Generate sitemap index file
yarn build --sitemap-index
yarn rari build --issues client/build/issues.json --templ-stats
# SSR all pages
yarn render:html
Expand Down Expand Up @@ -241,6 +252,7 @@ jobs:
run: |
npm ci
npm run build-redirects
npm run build-canonicals
- name: Deploy Function
if: ${{ ! vars.SKIP_FUNCTION }}
Expand Down
2 changes: 2 additions & 0 deletions Procfile.rari
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
server: yarn start:rari-server
web: yarn start:client
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,14 @@ this, you can pick any unused port (e.g., 6000) and run the following:

echo SERVER_PORT=6000 >> .env

### Problems running with rari on Windows

Download and install:

Microsoft Visual C++ Redistributable for Visual Studio 2019 (
[x86](https://aka.ms/vs/16/release/VC_redist.x86.exe),
[ARM64](https://aka.ms/vs/16/release/VC_redist.arm64.exe) )

### Yarn install errors

If you get errors while installing dependencies via yarn on a Mac, you may need
Expand Down
20 changes: 18 additions & 2 deletions client/src/document/toolbar/flaws.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ function Flaws({
/>
);
default:
throw new Error(`Unknown flaw check '${flaw.name}'`);
return <Unknown key="unknown" flaws={doc.flaws.unknown || []} />;
}
})}
</div>
Expand Down Expand Up @@ -531,6 +531,20 @@ function BrokenLinks({
);
}

function Unknown({ flaws }: { flaws: GenericFlaw[] }) {
return (
<div className="flaw flaw__unkown">
<h3>{humanizeFlawName("unknown")}</h3>
<ul>
{flaws.map((flaw) => (
<li key={flaw.id}>
<code>{flaw.explanation}</code>
</li>
))}
</ul>
</div>
);
}
function BadBCDQueries({ flaws }: { flaws: BadBCDQueryFlaw[] }) {
return (
<div className="flaw flaw__bad_bcd_queries">
Expand Down Expand Up @@ -692,7 +706,9 @@ function Macros({
<div className="flaw flaw__macros">
<h3>{humanizeFlawName("macros")}</h3>
{flaws.map((flaw) => {
const inPrerequisiteMacro = !flaw.filepath.includes(sourceFilePath);
const inPrerequisiteMacro = flaw.filepath
? !flaw.filepath.includes(sourceFilePath)
: false;
return (
<details
key={flaw.id}
Expand Down
6 changes: 5 additions & 1 deletion content/popularities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ export function getPopularities() {
if (!popularities.size) {
// This is the file that's *not* checked into git.
const filePath = new URL("../popularities.json", import.meta.url);
Object.entries(JSON.parse(fs.readFileSync(filePath, "utf-8"))).forEach(
const json = JSON.parse(fs.readFileSync(filePath, "utf-8"));
if (!("popularities" in json)) {
throw Error("run: yarn tool popularities --refresh");
}
Object.entries(json.popularities).forEach(
([url, value]: [string, unknown]) => {
popularities.set(url, value as number);
}
Expand Down
4 changes: 4 additions & 0 deletions copy/community/community.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: Contribute to MDN
---

# MDN Community

Where web enthusiasts learn, collaborate, and create
Expand Down
29 changes: 29 additions & 0 deletions copy/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"pages": {
"community": {
"titleSuffix": "Contribute to MDN"
},
"plus": {
"slugPrefix": "plus/docs",
"titleSuffix": "MDN Plus"
},
"observatory": {
"slugPrefix": "observatory/docs",
"titleSuffix": "HTTP Observatory"
}
},
"spas": {
"about": {
"slug": "about",
"pageTitle": "About MDN"
},
"advertising": {
"slug": "advertising",
"pageTitle": "Advertise with us"
},
"plus": {
"slug": "plus",
"pageTitle": "MDN Plus"
}
}
}
2 changes: 1 addition & 1 deletion deployer/src/deployer/search/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def to_search(file, _index=None):
)
),
popularity=doc["popularity"],
summary=doc["summary"],
summary=doc.get("summary", ""),
# Note! We're always lowercasing the 'slug'. This way we can search on it,
# still as a `keyword` index, but filtering by prefix.
# E.g. in kuma; ?slug_prefix=weB/Css
Expand Down
2 changes: 2 additions & 0 deletions libs/env/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const BUILD_OUT_ROOT: string;
export const DEFAULT_FLAW_LEVELS: string;
export const RARI: boolean;
export const BASE_URL: string;
export const FILES: string;
export const FOLDERSEARCH: string;
Expand Down Expand Up @@ -27,6 +28,7 @@ export const STATIC_ROOT: string;
export const PROXY_HOSTNAME: string;
export const CONTENT_HOSTNAME: string;
export const FAKE_V1_API: boolean;
export const EXTERNAL_DEV_SERVER: sting;
export const SENTRY_DSN_BUILD: string;
export const OPENAI_KEY: string;
export const PG_URI: string;
Expand Down
3 changes: 3 additions & 0 deletions libs/env/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dotenv.config({
// build
// -----

export const RARI = Boolean(parse(process.env.RARI || "false"));
export const BASE_URL = process.env.BASE_URL || "https://developer.mozilla.org";

export const BUILD_OUT_ROOT =
Expand Down Expand Up @@ -178,6 +179,8 @@ export const PROXY_HOSTNAME =
export const CONTENT_HOSTNAME = process.env.SERVER_CONTENT_HOST;

export const FAKE_V1_API = parse(process.env.SERVER_FAKE_V1_API || false);
export const EXTERNAL_DEV_SERVER =
process.env.EXTERNAL_DEV_SERVER || "http://localhost:8083";

// ----
// tool
Expand Down
1 change: 1 addition & 0 deletions libs/types/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export type Flaws = Partial<{
heading_links: HeadingLinksFlaw[];
translation_differences: TranslationDifferenceFlaw[];
unsafe_html: UnsafeHTMLFlaw[];
unknown: GenericFlaw[];
}>;

export type Translation = {
Expand Down
Loading