@docusaurus/plugin-client-redirects 0.0.0-4291 → 0.0.0-4297

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.
@@ -11,7 +11,7 @@ const lodash_1 = require("lodash");
11
11
  const extensionRedirects_1 = require("./extensionRedirects");
12
12
  const redirectValidation_1 = require("./redirectValidation");
13
13
  const utils_common_1 = require("@docusaurus/utils-common");
14
- const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
14
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
15
15
  function collectRedirects(pluginContext, trailingSlash) {
16
16
  let redirects = doCollectRedirects(pluginContext);
17
17
  redirects = applyRedirectsTrailingSlash(redirects, {
@@ -66,19 +66,15 @@ function filterUnwantedRedirects(redirects, pluginContext) {
66
66
  // that would lead to writing twice the same html redirection file
67
67
  Object.entries((0, lodash_1.groupBy)(redirects, (redirect) => redirect.from)).forEach(([from, groupedFromRedirects]) => {
68
68
  if (groupedFromRedirects.length > 1) {
69
- console.error(chalk_1.default.red(`@docusaurus/plugin-client-redirects: multiple redirects are created with the same "from" pathname=${from}
70
- It is not possible to redirect the same pathname to multiple destinations:
71
- - ${groupedFromRedirects.map((r) => JSON.stringify(r)).join('\n- ')}
72
- `));
69
+ logger_1.default.error `name=${'@docusaurus/plugin-client-redirects'}: multiple redirects are created with the same "from" pathname: path=${from}
70
+ It is not possible to redirect the same pathname to multiple destinations: ${groupedFromRedirects.map((r) => JSON.stringify(r))}`;
73
71
  }
74
72
  });
75
73
  const collectedRedirects = (0, lodash_1.uniqBy)(redirects, (redirect) => redirect.from);
76
74
  // We don't want to override an already existing route with a redirect file!
77
75
  const redirectsOverridingExistingPath = collectedRedirects.filter((redirect) => pluginContext.relativeRoutesPaths.includes(redirect.from));
78
76
  if (redirectsOverridingExistingPath.length > 0) {
79
- console.error(chalk_1.default.red(`@docusaurus/plugin-client-redirects: some redirects would override existing paths, and will be ignored:
80
- - ${redirectsOverridingExistingPath.map((r) => JSON.stringify(r)).join('\n- ')}
81
- `));
77
+ logger_1.default.error `name=${'@docusaurus/plugin-client-redirects'}: some redirects would override existing paths, and will be ignored: ${redirectsOverridingExistingPath.map((r) => JSON.stringify(r))}`;
82
78
  }
83
79
  return collectedRedirects.filter((redirect) => !pluginContext.relativeRoutesPaths.includes(redirect.from));
84
80
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-client-redirects",
3
- "version": "0.0.0-4291",
3
+ "version": "0.0.0-4297",
4
4
  "description": "Client redirects plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/plugin-client-redirects.d.ts",
@@ -18,10 +18,11 @@
18
18
  },
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@docusaurus/core": "0.0.0-4291",
22
- "@docusaurus/utils": "0.0.0-4291",
23
- "@docusaurus/utils-common": "0.0.0-4291",
24
- "@docusaurus/utils-validation": "0.0.0-4291",
21
+ "@docusaurus/core": "0.0.0-4297",
22
+ "@docusaurus/logger": "0.0.0-4297",
23
+ "@docusaurus/utils": "0.0.0-4297",
24
+ "@docusaurus/utils-common": "0.0.0-4297",
25
+ "@docusaurus/utils-validation": "0.0.0-4297",
25
26
  "chalk": "^4.1.2",
26
27
  "eta": "^1.12.3",
27
28
  "fs-extra": "^10.0.0",
@@ -29,7 +30,7 @@
29
30
  "tslib": "^2.3.1"
30
31
  },
31
32
  "devDependencies": {
32
- "@docusaurus/types": "0.0.0-4291"
33
+ "@docusaurus/types": "0.0.0-4297"
33
34
  },
34
35
  "peerDependencies": {
35
36
  "react": "^16.8.4 || ^17.0.0",
@@ -38,5 +39,5 @@
38
39
  "engines": {
39
40
  "node": ">=14"
40
41
  },
41
- "gitHead": "7097980fb8a57b1950c0714707966eea27f69975"
42
+ "gitHead": "84ae34c33c664bf856f3a92047919a074e087d77"
42
43
  }
@@ -22,7 +22,7 @@ import {
22
22
  ApplyTrailingSlashParams,
23
23
  } from '@docusaurus/utils-common';
24
24
 
25
- import chalk from 'chalk';
25
+ import logger from '@docusaurus/logger';
26
26
 
27
27
  export default function collectRedirects(
28
28
  pluginContext: PluginContext,
@@ -99,14 +99,10 @@ function filterUnwantedRedirects(
99
99
  Object.entries(groupBy(redirects, (redirect) => redirect.from)).forEach(
100
100
  ([from, groupedFromRedirects]) => {
101
101
  if (groupedFromRedirects.length > 1) {
102
- console.error(
103
- chalk.red(
104
- `@docusaurus/plugin-client-redirects: multiple redirects are created with the same "from" pathname=${from}
105
- It is not possible to redirect the same pathname to multiple destinations:
106
- - ${groupedFromRedirects.map((r) => JSON.stringify(r)).join('\n- ')}
107
- `,
108
- ),
109
- );
102
+ logger.error`name=${'@docusaurus/plugin-client-redirects'}: multiple redirects are created with the same "from" pathname: path=${from}
103
+ It is not possible to redirect the same pathname to multiple destinations: ${groupedFromRedirects.map(
104
+ (r) => JSON.stringify(r),
105
+ )}`;
110
106
  }
111
107
  },
112
108
  );
@@ -117,13 +113,9 @@ It is not possible to redirect the same pathname to multiple destinations:
117
113
  (redirect) => pluginContext.relativeRoutesPaths.includes(redirect.from),
118
114
  );
119
115
  if (redirectsOverridingExistingPath.length > 0) {
120
- console.error(
121
- chalk.red(
122
- `@docusaurus/plugin-client-redirects: some redirects would override existing paths, and will be ignored:
123
- - ${redirectsOverridingExistingPath.map((r) => JSON.stringify(r)).join('\n- ')}
124
- `,
125
- ),
126
- );
116
+ logger.error`name=${'@docusaurus/plugin-client-redirects'}: some redirects would override existing paths, and will be ignored: ${redirectsOverridingExistingPath.map(
117
+ (r) => JSON.stringify(r),
118
+ )}`;
127
119
  }
128
120
  return collectedRedirects.filter(
129
121
  (redirect) => !pluginContext.relativeRoutesPaths.includes(redirect.from),