mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-02 16:29:47 +02:00
refactor(theme-common): split package into public/internal API entrypoints (#7660)
* add theme-common/internal export * Split @docusaurus/theme-common into public/internal apis * fixes * public <-> private * public <-> private * public <-> private * fix * add "removeThemeInternalReexport" CI script * :s windows CI check not working: not that useful * remove bad import * refactors * reorder * make useBackToTopButton internal Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
This commit is contained in:
parent
35d320fa2c
commit
9473508c33
59 changed files with 278 additions and 204 deletions
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import fs from 'fs-extra';
|
||||
|
||||
// See comment in src/internal.ts
|
||||
// This script should be run by CI tests to remove:
|
||||
// export * from './index'
|
||||
|
||||
const filePath = 'lib/internal.js';
|
||||
const lineToRemove = "export * from './index';\n";
|
||||
|
||||
if (!(await fs.pathExists(filePath))) {
|
||||
throw new Error(`internal entrypoint file not found at ${filePath}`);
|
||||
}
|
||||
|
||||
const fileContent = await fs.readFile(filePath, 'utf8');
|
||||
|
||||
const fileContentUpdated = fileContent.replaceAll(lineToRemove, '');
|
||||
|
||||
// Ensure the script correctly removes the re-export
|
||||
if (fileContent === fileContentUpdated) {
|
||||
throw new Error(
|
||||
'Unexpected: internal re-export has not been replaced.\nMake sure this script works, and is only run once.',
|
||||
);
|
||||
}
|
||||
|
||||
await fs.writeFile(filePath, fileContentUpdated);
|
Loading…
Add table
Add a link
Reference in a new issue