* Update to docusaurus release 2.0. Fix MDX inline plugin to fit with updated docusaurus mdx loader.

* docs(changeset): Update to docusaurus 2.0 release build, fix MDX-include plugin

* "eject" docsite from the monorepo. Give it a private lock file and node version. Update PR/build steps to run yarn specifically for docsite.

* trying to find a yaml bug - attempt 1

* trying to find a yaml bug - attempt 2

* docusaurus can no longer be managed by changesets since it isn't part of the monorepo anymore

* update test
This commit is contained in:
Adam Foxman 2022-08-16 08:53:40 -07:00 коммит произвёл GitHub
Родитель 624f357c75
Коммит e98dd546ad
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
12 изменённых файлов: 7726 добавлений и 4631 удалений

Просмотреть файл

@ -0,0 +1,5 @@
---
---
Update to docusaurus 2.0 release build, fix MDX-include plugin, eject Docusaurus
from monorepo

6
.github/actions/yarn/action.yml поставляемый
Просмотреть файл

@ -1,5 +1,10 @@
name: Yarn
description: Runs `yarn install` and caches downloaded dependencies
inputs:
working-directory:
description: The working directory to use when running yarn
type: string
default: .
runs:
using: composite
@ -7,5 +12,6 @@ runs:
- name: Install package dependencies
run: yarn ci
shell: bash
working-directory: ${{ inputs.working-directory }}
env:
CI_SKIP_GO: 1

4
.github/workflows/build.yml поставляемый
Просмотреть файл

@ -22,6 +22,10 @@ jobs:
run: yarn build:ci:all
- name: Bundle packages
run: yarn bundle
- name: Install package dependencies (docsite)
uses: ./.github/actions/yarn
with:
working-directory: docsite
- name: Build website
run: yarn build
working-directory: docsite

4
.github/workflows/pr.yml поставляемый
Просмотреть файл

@ -102,8 +102,10 @@ jobs:
fetch-depth: 0
- name: Setup the toolchain
uses: ./.github/actions/setup-toolchain
- name: Install package dependencies
- name: Install package dependencies (docsite)
uses: ./.github/actions/yarn
with:
working-directory: docsite
- name: Build website
run: yarn build
working-directory: docsite

Просмотреть файл

@ -1,38 +0,0 @@
# @rnx-kit/docsite
## 0.1.4
### Patch Changes
- a7d2ada2: update unified package
## 0.1.3
### Patch Changes
- 058063ea: Adding more references to the default list of capabilities
## 0.1.2
### Patch Changes
- e905856: Add bundling guide. Polish existing web pages. Add placeholder pages for some tools packages (needed by bundling guide).
- ac38af7: Upgrade Docusaurus. Change code-block theme to vsLight when in light mode, and fix the font-color and shadows so the code stands out.
## 0.1.1
### Patch Changes
- 3bb4a34: Another round of additions and refinments to the documentation website.
## 0.1.0
### Minor Changes
- 7a22979: Update navigation and landing page
## 0.0.1
### Patch Changes
- ee96c01: Documentation site framework and theming. No content yet other than the landing page.

Просмотреть файл

@ -3,6 +3,7 @@
"version": "0.1.4",
"private": true,
"scripts": {
"ci": "yarn --prefer-offline --frozen-lockfile --non-interactive",
"docusaurus": "docusaurus",
"start": "docusaurus start",
"build": "docusaurus build",
@ -15,8 +16,8 @@
"typecheck": "tsc"
},
"dependencies": {
"@docusaurus/core": "2.0.0-beta.18",
"@docusaurus/preset-classic": "2.0.0-beta.18",
"@docusaurus/core": "^2.0.0",
"@docusaurus/preset-classic": "^2.0.0",
"@mdx-js/react": "^1.6.21",
"clsx": "^1.1.1",
"prism-react-renderer": "^1.2.1",
@ -24,7 +25,7 @@
"react-dom": "17.0.2"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "2.0.0-beta.18",
"@docusaurus/module-type-aliases": "^2.0.0",
"@mdx-js/util": "1.6.22",
"@tsconfig/docusaurus": "^1.0.5",
"mdast-zone": "^4.0.1",
@ -37,6 +38,9 @@
"unist-util-visit": "^2.0.3",
"vfile": "^4.0.0"
},
"engines": {
"node": ">=16.14.0"
},
"browserslist": {
"production": [
">0.5%",

Просмотреть файл

@ -8,7 +8,6 @@ const visit = require("unist-util-visit");
const { isInclude, getIncludePath } = require("./util/include");
const parseMdxToAst = require("./util/parseMdxToAst");
const readVFile = require("./util/readVFile");
const getDocusaurusMdxContext = require("./util/docusaurusMdxContext");
/**
* @typedef {import("unist").Node} UnistNode
@ -51,8 +50,6 @@ function isMarkdownFile(file) {
* MDXAST, replacing the include directive node.
*/
function plugin() {
const { currentDir } = getDocusaurusMdxContext(this);
return transform;
/**
@ -60,8 +57,9 @@ function plugin() {
* the included file.
*
* @param {MdAstNode} root MDXAST to transform
* @param {import("vfile").VFile} vfile Virtual file object
*/
function transform(root) {
function transform(root, vfile) {
const locations = [];
/**
@ -78,7 +76,7 @@ function plugin() {
*/
function processIncludeDirective(node, index, parent) {
// Resolve the included file, relative to the current markdown file.
const p = path.resolve(currentDir, getIncludePath(node));
const p = path.resolve(vfile.dirname, getIncludePath(node));
if (isMarkdownFile(p)) {
// Include a markdown file

Просмотреть файл

@ -1,81 +0,0 @@
/* jshint esversion: 8, node: true */
// @ts-check
"use strict";
const path = require("path");
/**
* @typedef {import("unified").Plugin} Plugin
* @typedef {import("unified").PluginTuple} PluginTuple
* @typedef {{attachers: (Plugin | PluginTuple)[]}} UnifiedProcessorContext
*
* Types for the Docusaurus MDX loader are in @docusaurus/mdx-loader, but they
* are internal so we can't use them. Define a subset of what we need here.
* @typedef {{filepath: string}} DocusaurusMdxLoaderOptions
*
* @typedef {{currentFile: string, currentDir: string}} DocusaurusMdxContext
*/
/**
* Report an error by throwing an exception with the given message, along with
* helpful, actionable information for the developer who sees the error.
*
* @param {string} message Error message
* @returns {never} Never returns
*/
function error(message) {
throw new Error(
message +
". Did you recently update Docusaurus? This code may need to be updated as well."
);
}
/**
* Get information about the current MDX document being read by Docusaurus.
*
* @param {UnifiedProcessorContext} context Unified processor context
* @returns {DocusaurusMdxContext} Docusaurus MDX context
*/
function getDocusaurusMdxContext(context) {
// Read the MDX options that Docusaurus passes to @mdx-js/mdx. They are
// always paired with the first unified plugin, which parses markdown text
// into an MDAST.
//
// Probe carefully. This makes assumptions about Docusaurus and how it
// uses unified.
if (!context.attachers) {
error("Failed to find the list of Unified plugins");
}
const attachers = context.attachers;
if (
!Array.isArray(context.attachers) ||
attachers.length < 1 ||
!attachers[0]
) {
error("Failed to get the first Unified plugin");
}
const attacher = attachers[0];
if (!Array.isArray(attacher) || attacher.length < 2 || !attacher[1]) {
error("Failed to get options for the first Unified plugin");
}
/** @type {Partial<DocusaurusMdxLoaderOptions>} */
const options = attacher[1];
const currentFile = options.filepath;
if (!currentFile) {
error(
"Failed to get the path of the current markdown file being processed. " +
"This comes from the Docusaurus MDX loader context"
);
}
const currentDir = path.dirname(currentFile);
return {
currentFile,
currentDir,
};
}
module.exports = getDocusaurusMdxContext;

7508
docsite/yarn.lock Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -54,7 +54,6 @@
},
"workspaces": {
"packages": [
"docsite",
"incubator/*",
"packages/@types/*",
"packages/*",

Просмотреть файл

@ -14,7 +14,6 @@ Array [
"anser",
"base64-js",
"event-target-shim",
"eventemitter3",
"fbjs",
"invariant",
"metro",
@ -29,6 +28,7 @@ Array [
"react-native",
"react-refresh",
"regenerator-runtime",
"rnx-kit",
"scheduler",
"stacktrace-parser",
"use-subscription",

4690
yarn.lock

Разница между файлами не показана из-за своего большого размера Загрузить разницу