Skip to content

Commit

Permalink
Merge branch 'main' into jc/i18n-path
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena committed May 27, 2022
2 parents 4b0dd5c + be912c6 commit 9bc740f
Show file tree
Hide file tree
Showing 105 changed files with 618 additions and 283 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: ['14', '16', '18']
node: ['16.14', '16', '18']
steps:
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: windows-latest
strategy:
matrix:
node: ['14', '16', '18']
node: ['16.14', '16', '18']
steps:
- name: Support longpaths
run: git config --system core.longpaths true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: ['14', '16', '18']
node: ['16.14', '16', '18']
steps:
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.14.0
18
13 changes: 11 additions & 2 deletions jest/deps.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,18 @@

// modules only used in tests

declare module 'to-vfile';
declare module 'to-vfile' {
import type {VFile} from 'vfile';

declare module 'remark-mdx';
export function read(path: string, encoding?: string): Promise<VFile>;
}

declare module 'remark-mdx' {
import type {Plugin} from 'unified';

const mdx: Plugin;
export = mdx;
}

declare module '@testing-utils/git' {
const createTempRepo: typeof import('./utils/git').createTempRepo;
Expand Down
3 changes: 2 additions & 1 deletion packages/create-docusaurus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"license": "MIT",
"dependencies": {
"@docusaurus/logger": "2.0.0-beta.20",
"@docusaurus/utils": "2.0.0-beta.20",
"commander": "^5.1.0",
"fs-extra": "^10.1.0",
"lodash": "^4.17.21",
Expand All @@ -36,6 +37,6 @@
"@types/supports-color": "^8.1.1"
},
"engines": {
"node": ">=14"
"node": ">=16.14"
}
}
9 changes: 6 additions & 3 deletions packages/create-docusaurus/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import logger from '@docusaurus/logger';
import shell from 'shelljs';
import prompts, {type Choice} from 'prompts';
import supportsColor from 'supports-color';
import {escapeShellArg} from '@docusaurus/utils';

type CLIOptions = {
packageManager?: PackageManager;
Expand Down Expand Up @@ -463,9 +464,11 @@ export default async function init(
logger.info('Creating new Docusaurus project...');

if (source.type === 'git') {
logger.info`Cloning Git template url=${source.url}...`;
const command = await getGitCommand(source.strategy);
if (shell.exec(`${command} ${source.url} ${dest}`).code !== 0) {
const gitCommand = await getGitCommand(source.strategy);
const gitCloneCommand = `${gitCommand} ${escapeShellArg(
source.url,
)} ${escapeShellArg(dest)}`;
if (shell.exec(gitCloneCommand).code !== 0) {
logger.error`Cloning Git template failed!`;
process.exit(1);
}
Expand Down
3 changes: 3 additions & 0 deletions packages/docusaurus-cssnano-preset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@
},
"devDependencies": {
"to-vfile": "^6.1.0"
},
"engines": {
"node": ">=16.14"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import vfile from 'to-vfile';
import postcss from 'postcss';
import postCssRemoveOverriddenCustomProperties from '../index';

const processFixture = (name: string) => {
const input = vfile.readSync(
const processFixture = async (name: string) => {
const input = await vfile.read(
path.join(__dirname, '__fixtures__', `${name}.css`),
'utf8',
);
Expand All @@ -23,11 +23,11 @@ const processFixture = (name: string) => {
};

describe('remove-overridden-custom-properties', () => {
it('overridden custom properties should be removed', () => {
expect(processFixture('normal')).toMatchSnapshot();
it('overridden custom properties should be removed', async () => {
await expect(processFixture('normal')).resolves.toMatchSnapshot();
});

it('overridden custom properties with `!important` rule should not be removed', () => {
expect(processFixture('important_rule')).toMatchSnapshot();
it('overridden custom properties with `!important` rule should not be removed', async () => {
await expect(processFixture('important_rule')).resolves.toMatchSnapshot();
});
});
2 changes: 1 addition & 1 deletion packages/docusaurus-logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"tslib": "^2.4.0"
},
"engines": {
"node": ">=14"
"node": ">=16.14"
},
"devDependencies": {
"@types/supports-color": "^8.1.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-mdx-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@
"react-dom": "^16.8.4 || ^17.0.0"
},
"engines": {
"node": ">=14"
"node": ">=16.14"
}
}
2 changes: 1 addition & 1 deletion packages/docusaurus-migrate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "A CLI tool to migrate from older versions of Docusaurus.",
"license": "MIT",
"engines": {
"node": ">=14"
"node": ">=16.14"
},
"scripts": {
"build": "tsc --build",
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-migrate/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ async function migrateVersionedSidebar(
(topLevel: SidebarEntries, value) => {
const key = value[0].replace(versionRegex, '');
topLevel[key] = Object.entries(value[1]).reduce<{
[key: string]: Array<string | {[key: string]: unknown}>;
[key: string]: (string | {[key: string]: unknown})[];
}>((acc, val) => {
acc[val[0].replace(versionRegex, '')] = (
val[1] as SidebarEntry[]
Expand Down
27 changes: 12 additions & 15 deletions packages/docusaurus-migrate/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export type SidebarEntry =
export type SidebarEntries = {
[key: string]:
| {[key: string]: unknown}
| Array<{[key: string]: unknown} | string>;
| ({[key: string]: unknown} | string)[];
};

export type VersionTwoConfig = {
Expand All @@ -49,7 +49,7 @@ export type VersionTwoConfig = {
githubHost?: string;
onBrokenLinks: string;
onBrokenMarkdownLinks: string;
plugins: Array<[string, {[key: string]: unknown}]>;
plugins: [string, {[key: string]: unknown}][];
themes?: [];
presets: [[string, ClassicPresetEntries]];
themeConfig: {
Expand All @@ -58,17 +58,14 @@ export type VersionTwoConfig = {
logo?: {
src?: string;
};
items: Array<{[key: string]: unknown} | null>;
items: ({[key: string]: unknown} | null)[];
};
image?: string;
footer: {
links: Array<{
links: {
title: string;
items: Array<{
label: string;
to: string;
}>;
}>;
items: {label: string; to: string}[];
}[];
copyright?: string;
logo: {
src?: string;
Expand Down Expand Up @@ -104,26 +101,26 @@ export type VersionOneConfig = {
organizationName?: string;
projectName?: string;
noIndex?: boolean;
headerLinks?: Array<{doc: string; href: string; label: string; page: string}>;
headerLinks?: {doc: string; href: string; label: string; page: string}[];
headerIcon?: string;
favicon?: string;
colors?: {primaryColor: string};
copyright?: string;
editUrl?: string;
customDocsPath?: string;
users?: Array<{[key: string]: unknown}>;
users?: {[key: string]: unknown}[];
disableHeaderTitle?: string;
disableTitleTagline?: string;
separateCss?: Array<{[key: string]: unknown}>;
separateCss?: {[key: string]: unknown}[];
footerIcon?: string;
translationRecruitingLink?: string;
algolia?: {[key: string]: unknown};
gaTrackingId?: string;
gaGtag?: boolean;
highlight?: {[key: string]: unknown};
markdownPlugins?: Array<() => void>;
scripts?: Array<{src: string; [key: string]: unknown} | string>;
stylesheets?: Array<{href: string; [key: string]: unknown} | string>;
markdownPlugins?: (() => void)[];
scripts?: ({src: string; [key: string]: unknown} | string)[];
stylesheets?: ({href: string; [key: string]: unknown} | string)[];
facebookAppId?: string;
facebookComments?: true;
facebookPixelId?: string;
Expand Down
23 changes: 11 additions & 12 deletions packages/docusaurus-module-type-aliases/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,9 @@ declare module '@theme-original/*';
declare module '@theme-init/*';

declare module '@theme/Error' {
import type {ComponentProps} from 'react';
import type ErrorBoundary from '@docusaurus/ErrorBoundary';
import type {FallbackParams} from '@docusaurus/ErrorBoundary';

type ErrorProps = ComponentProps<
NonNullable<ComponentProps<typeof ErrorBoundary>['fallback']>
>;

export interface Props extends ErrorProps {}
export interface Props extends FallbackParams {}
export default function Error(props: Props): JSX.Element;
}

Expand Down Expand Up @@ -125,13 +120,17 @@ declare module '@docusaurus/constants' {
}

declare module '@docusaurus/ErrorBoundary' {
import type {ReactNode, ComponentType} from 'react';
import type {ReactNode} from 'react';

export type FallbackParams = {
readonly error: Error;
readonly tryAgain: () => void;
};

export type FallbackFunction = (params: FallbackParams) => JSX.Element;

export interface Props {
readonly fallback?: ComponentType<{
readonly error: Error;
readonly tryAgain: () => void;
}>;
readonly fallback?: FallbackFunction;
readonly children: ReactNode;
}
export default function ErrorBoundary(props: Props): JSX.Element;
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-client-redirects/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@
"react-dom": "^16.8.4 || ^17.0.0"
},
"engines": {
"node": ">=14"
"node": ">=16.14"
}
}
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-content-blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@
"react-dom": "^16.8.4 || ^17.0.0"
},
"engines": {
"node": ">=14"
"node": ">=16.14"
}
}
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-content-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@
"react-dom": "^16.8.4 || ^17.0.0"
},
"engines": {
"node": ">=14"
"node": ">=16.14"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import type {
Options,
PluginOptions,
PropSidebarItemLink,
PropSidebars,
} from '@docusaurus/plugin-content-docs';
import type {
SidebarItemsGeneratorOption,
Expand Down Expand Up @@ -82,7 +83,7 @@ const createFakeActions = (contentDir: string) => {

// Query by prefix, because files have a hash at the end so it's not
// convenient to query by full filename
const getCreatedDataByPrefix = (prefix: string) => {
function getCreatedDataByPrefix(prefix: string) {
const entry = Object.entries(dataContainer).find(([key]) =>
key.startsWith(prefix),
);
Expand All @@ -92,8 +93,8 @@ Entries created:
- ${Object.keys(dataContainer).join('\n- ')}
`);
}
return JSON.parse(entry[1] as string);
};
return JSON.parse(entry[1] as string) as PropSidebars;
}

// Extra fns useful for tests!
const utils = {
Expand Down Expand Up @@ -571,8 +572,8 @@ describe('versioned website (community)', () => {
allContent: {},
});

utils.checkVersionMetadataPropCreated(currentVersion!);
utils.checkVersionMetadataPropCreated(version100!);
utils.checkVersionMetadataPropCreated(currentVersion);
utils.checkVersionMetadataPropCreated(version100);

utils.expectSnapshot();
});
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-content-pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
"react-dom": "^16.8.4 || ^17.0.0"
},
"engines": {
"node": ">=14"
"node": ">=16.14"
}
}
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-debug/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
"react-dom": "^16.8.4 || ^17.0.0"
},
"engines": {
"node": ">=14"
"node": ">=16.14"
}
}
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-google-analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
"react-dom": "^16.8.4 || ^17.0.0"
},
"engines": {
"node": ">=14"
"node": ">=16.14"
}
}
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-google-gtag/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
"react-dom": "^16.8.4 || ^17.0.0"
},
"engines": {
"node": ">=14"
"node": ">=16.14"
}
}
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-ideal-image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@
}
},
"engines": {
"node": ">=14"
"node": ">=16.14"
}
}
3 changes: 3 additions & 0 deletions packages/docusaurus-plugin-pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,8 @@
"peerDependencies": {
"react": "^16.8.4 || ^17.0.0",
"react-dom": "^16.8.4 || ^17.0.0"
},
"engines": {
"node": ">=16.14"
}
}
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-sitemap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
"react-dom": "^16.8.4 || ^17.0.0"
},
"engines": {
"node": ">=14"
"node": ">=16.14"
}
}
Loading

0 comments on commit 9bc740f

Please sign in to comment.