mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-29 22:47:52 +02:00
fix(migrate): import siteConfig with file extension (#7766)
* fix(migrate): import siteConfig with file extension
* fix test
* Revert "fix test"
This reverts commit f5d00ab0e6
.
This commit is contained in:
parent
337463ae1c
commit
a4b4a7f28d
2 changed files with 4 additions and 5 deletions
|
@ -32,7 +32,6 @@
|
||||||
"fs-extra": "^10.1.0",
|
"fs-extra": "^10.1.0",
|
||||||
"hast-util-to-string": "^1.0.4",
|
"hast-util-to-string": "^1.0.4",
|
||||||
"html-tags": "^3.2.0",
|
"html-tags": "^3.2.0",
|
||||||
"import-fresh": "^3.3.0",
|
|
||||||
"jscodeshift": "^0.13.1",
|
"jscodeshift": "^0.13.1",
|
||||||
"rehype-parse": "^7.0.1",
|
"rehype-parse": "^7.0.1",
|
||||||
"remark-parse": "^8.0.2",
|
"remark-parse": "^8.0.2",
|
||||||
|
|
|
@ -9,7 +9,6 @@ import path from 'path';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import logger from '@docusaurus/logger';
|
import logger from '@docusaurus/logger';
|
||||||
import {Globby, DOCUSAURUS_VERSION} from '@docusaurus/utils';
|
import {Globby, DOCUSAURUS_VERSION} from '@docusaurus/utils';
|
||||||
import importFresh from 'import-fresh';
|
|
||||||
import Color from 'color';
|
import Color from 'color';
|
||||||
|
|
||||||
import extractMetadata, {shouldQuotifyFrontMatter} from './frontMatter';
|
import extractMetadata, {shouldQuotifyFrontMatter} from './frontMatter';
|
||||||
|
@ -79,7 +78,7 @@ export async function migrateDocusaurusProject(
|
||||||
shouldMigratePages: boolean = false,
|
shouldMigratePages: boolean = false,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
async function createMigrationContext(): Promise<MigrationContext> {
|
async function createMigrationContext(): Promise<MigrationContext> {
|
||||||
const v1Config = (await import(`${siteDir}/siteConfig`))
|
const v1Config = (await import(`${siteDir}/siteConfig.js`))
|
||||||
.default as VersionOneConfig;
|
.default as VersionOneConfig;
|
||||||
logger.info('Starting migration from v1 to v2...');
|
logger.info('Starting migration from v1 to v2...');
|
||||||
const deps = {
|
const deps = {
|
||||||
|
@ -709,12 +708,13 @@ async function migrateLatestDocs(context: MigrationContext) {
|
||||||
|
|
||||||
async function migratePackageFile(context: MigrationContext): Promise<void> {
|
async function migratePackageFile(context: MigrationContext): Promise<void> {
|
||||||
const {deps, siteDir, newDir} = context;
|
const {deps, siteDir, newDir} = context;
|
||||||
const packageFile = importFresh<{
|
// eslint-disable-next-line global-require, import/no-dynamic-require
|
||||||
|
const packageFile = (await require(`${siteDir}/package.json`)) as {
|
||||||
scripts?: {[key: string]: string};
|
scripts?: {[key: string]: string};
|
||||||
dependencies?: {[key: string]: string};
|
dependencies?: {[key: string]: string};
|
||||||
devDependencies?: {[key: string]: string};
|
devDependencies?: {[key: string]: string};
|
||||||
[otherKey: string]: unknown;
|
[otherKey: string]: unknown;
|
||||||
}>(`${siteDir}/package.json`);
|
};
|
||||||
packageFile.scripts = {
|
packageFile.scripts = {
|
||||||
...packageFile.scripts,
|
...packageFile.scripts,
|
||||||
start: 'docusaurus start',
|
start: 'docusaurus start',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue