@docusaurus/core 0.0.0-4891 → 0.0.0-4894

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/beforeCli.mjs CHANGED
@@ -14,15 +14,21 @@ import path from 'path';
14
14
  import updateNotifier from 'update-notifier';
15
15
  import boxen from 'boxen';
16
16
  import {createRequire} from 'module';
17
+ import {DOCUSAURUS_VERSION} from '@docusaurus/utils';
17
18
 
18
19
  const packageJson = createRequire(import.meta.url)('../package.json');
19
- const sitePkg = createRequire(path.join(process.cwd(), 'package.json'))(
20
- './package.json',
21
- );
20
+ /** @type {Record<string, any>} */
21
+ let sitePkg;
22
+ try {
23
+ sitePkg = createRequire(path.resolve('package.json'))('./package.json');
24
+ } catch {
25
+ logger.warn`path=${'package.json'} file not found at CWD: path=${process.cwd()}.`;
26
+ logger.info`This is non-critical, but could lead to undesired behavior downstream. Docusaurus assumes that path=${'package.json'} exists at CWD, because it's where the package manager looks up the script at. A common reason is because you have changed directory in the script. Instead of writing code=${'"start": "cd website && docusaurus start"'}, consider using the code=${'[siteDir]'} argument: code=${'"start": "docusaurus start website"'}.`;
27
+ sitePkg = {};
28
+ }
22
29
 
23
30
  const {
24
31
  name,
25
- version,
26
32
  engines: {node: requiredVersion},
27
33
  } = packageJson;
28
34
 
@@ -40,7 +46,7 @@ export default async function beforeCli() {
40
46
  const notifier = updateNotifier({
41
47
  pkg: {
42
48
  name,
43
- version,
49
+ version: DOCUSAURUS_VERSION,
44
50
  },
45
51
  // Check is in background so it's fine to use a small value like 1h
46
52
  // Use 0 for debugging
@@ -11,7 +11,7 @@
11
11
  import logger from '@docusaurus/logger';
12
12
  import fs from 'fs-extra';
13
13
  import cli from 'commander';
14
- import {createRequire} from 'module';
14
+ import {DOCUSAURUS_VERSION} from '@docusaurus/utils';
15
15
  import {
16
16
  build,
17
17
  swizzle,
@@ -29,9 +29,7 @@ await beforeCli();
29
29
 
30
30
  const resolveDir = (dir = '.') => fs.realpath(dir);
31
31
 
32
- cli
33
- .version(createRequire(import.meta.url)('../package.json').version)
34
- .usage('<command> [options]');
32
+ cli.version(DOCUSAURUS_VERSION).usage('<command> [options]');
35
33
 
36
34
  cli
37
35
  .command('build [siteDir]')
@@ -20,8 +20,7 @@ import { createStatefulLinksCollector, LinksCollectorProvider, } from './LinksCo
20
20
  import logger from '@docusaurus/logger';
21
21
  // eslint-disable-next-line no-restricted-imports
22
22
  import _ from 'lodash';
23
- // eslint-disable-next-line @typescript-eslint/no-var-requires
24
- const packageJson = require('../../package.json');
23
+ import { DOCUSAURUS_VERSION } from '@docusaurus/utils';
25
24
  const getCompiledSSRTemplate = _.memoize((template) => eta.compile(template.trim(), {
26
25
  rmWhitespace: true,
27
26
  }));
@@ -97,7 +96,7 @@ async function doRender(locals) {
97
96
  scripts,
98
97
  stylesheets,
99
98
  noIndex,
100
- version: packageJson.version,
99
+ version: DOCUSAURUS_VERSION,
101
100
  });
102
101
  try {
103
102
  // Minify html with https://github.com/DanielRuf/html-minifier-terser
@@ -8,6 +8,7 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.loadSiteMetadata = exports.getPluginVersion = void 0;
10
10
  const tslib_1 = require("tslib");
11
+ const utils_1 = require("@docusaurus/utils");
11
12
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
13
  const path_1 = tslib_1.__importDefault(require("path"));
13
14
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
@@ -68,7 +69,7 @@ Maybe you want to check, or regenerate your yarn.lock or package-lock.json file?
68
69
  }
69
70
  async function loadSiteMetadata({ plugins, siteDir, }) {
70
71
  const siteMetadata = {
71
- docusaurusVersion: (await getPackageJsonVersion(path_1.default.join(__dirname, '../../package.json'))),
72
+ docusaurusVersion: utils_1.DOCUSAURUS_VERSION,
72
73
  siteVersion: await getPackageJsonVersion(path_1.default.join(siteDir, 'package.json')),
73
74
  pluginVersions: Object.fromEntries(plugins
74
75
  .filter(({ version: { type } }) => type !== 'synthetic')
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@docusaurus/core",
3
3
  "description": "Easy to Maintain Open Source Documentation Websites",
4
- "version": "0.0.0-4891",
4
+ "version": "0.0.0-4894",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -41,13 +41,13 @@
41
41
  "@babel/runtime": "^7.17.9",
42
42
  "@babel/runtime-corejs3": "^7.17.9",
43
43
  "@babel/traverse": "^7.17.9",
44
- "@docusaurus/cssnano-preset": "0.0.0-4891",
45
- "@docusaurus/logger": "0.0.0-4891",
46
- "@docusaurus/mdx-loader": "0.0.0-4891",
44
+ "@docusaurus/cssnano-preset": "0.0.0-4894",
45
+ "@docusaurus/logger": "0.0.0-4894",
46
+ "@docusaurus/mdx-loader": "0.0.0-4894",
47
47
  "@docusaurus/react-loadable": "5.5.2",
48
- "@docusaurus/utils": "0.0.0-4891",
49
- "@docusaurus/utils-common": "0.0.0-4891",
50
- "@docusaurus/utils-validation": "0.0.0-4891",
48
+ "@docusaurus/utils": "0.0.0-4894",
49
+ "@docusaurus/utils-common": "0.0.0-4894",
50
+ "@docusaurus/utils-validation": "0.0.0-4894",
51
51
  "@slorber/static-site-generator-webpack-plugin": "^4.0.4",
52
52
  "@svgr/webpack": "^6.2.1",
53
53
  "autoprefixer": "^10.4.4",
@@ -105,8 +105,8 @@
105
105
  "webpackbar": "^5.0.2"
106
106
  },
107
107
  "devDependencies": {
108
- "@docusaurus/module-type-aliases": "0.0.0-4891",
109
- "@docusaurus/types": "0.0.0-4891",
108
+ "@docusaurus/module-type-aliases": "0.0.0-4894",
109
+ "@docusaurus/types": "0.0.0-4894",
110
110
  "@types/detect-port": "^1.3.2",
111
111
  "@types/nprogress": "^0.2.0",
112
112
  "@types/react-dom": "^18.0.1",
@@ -127,5 +127,5 @@
127
127
  "engines": {
128
128
  "node": ">=14"
129
129
  },
130
- "gitHead": "a153f30a465e19bf4bb0956790ca98c9772492db"
130
+ "gitHead": "02fc752beb497f3a9b055b36f811495f5c0b66f7"
131
131
  }