@docusaurus/logger 2.0.0-beta.16 → 2.0.0-beta.19

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/README.md CHANGED
@@ -7,19 +7,33 @@ An encapsulated logger for semantically formatting console messages.
7
7
  It exports a single object as default export: `logger`. `logger` has the following properties:
8
8
 
9
9
  - Some useful colors.
10
- - Formatters. These functions have the same signature as the formatters of `picocolors`. Note that their implementations are not guaranteed. You should only care about their semantics.
11
- - `path`: formats a file path or URL.
12
- - `id`: formats an identifier.
10
+ - `red`
11
+ - `yellow`
12
+ - `green`
13
+ - `bold`
14
+ - `dim`
15
+ - Formatters. These functions all have the signature `(msg: unknown) => string`. Note that their implementations are not guaranteed. You should only care about their semantics.
16
+ - `path`: formats a file path.
17
+ - `url`: formats a URL.
18
+ - `name`: formats an identifier.
13
19
  - `code`: formats a code snippet.
14
20
  - `subdue`: subdues the text.
15
21
  - `num`: formats a number.
16
- - The `interpolate` function. It is a template literal tag.
17
- - Logging functions. All logging functions can both be used as functions (in which it has the same usage as `console.log`) or template literal tags.
22
+ - The `interpolate` function. It is a template literal tag. The syntax can be found below.
23
+ - Logging functions. All logging functions can both be used as normal functions (similar to the `console.log` family, but only accepts one parameter) or template literal tags.
18
24
  - `info`: prints information.
19
25
  - `warn`: prints a warning that should be payed attention to.
20
26
  - `error`: prints an error (not necessarily halting the program) that signals significant problems.
21
27
  - `success`: prints a success message.
22
28
 
29
+ ### A word on the `error` formatter
30
+
31
+ Beware that an `error` message, even when it doesn't hang the program, is likely going to cause confusion. When users inspect logs and find an `[ERROR]`, even when the build succeeds, they will assume something is going wrong. Use it sparingly.
32
+
33
+ Docusaurus only uses `logger.error` when printing messages immediately before throwing an error, or when user has set the reporting severity of `onBrokenLink`, etc. to `"error"`.
34
+
35
+ In addition, `warn` and `error` will color the **entire** message for better attention. If you are printing large blocks of help text about an error, better use `logger.info`.
36
+
23
37
  ### Using the template literal tag
24
38
 
25
39
  The template literal tag evaluates the template and expressions embedded. `interpolate` returns a new string, while other logging functions prints it. Below is a typical usage:
@@ -31,10 +45,11 @@ logger.info`Hello name=${name}! You have number=${money} dollars. Here are the $
31
45
  To buy anything, enter code=${'buy x'} where code=${'x'} is the item's name; to quit, press code=${'Ctrl + C'}.`;
32
46
  ```
33
47
 
34
- An embedded expression is optionally preceded by a flag in the form `%[a-z]+` (a percentage sign followed by a few lowercase letters). If it's not preceded by any flag, it's printed out as-is. Otherwise, it's formatted with one of the formatters:
48
+ An embedded expression is optionally preceded by a flag in the form `[a-z]+=` (a few lowercase letters, followed by an equals sign, directly preceding the embedded expression). If the expression is not preceded by any flag, it's printed out as-is. Otherwise, it's formatted with one of the formatters:
35
49
 
36
50
  - `path=`: `path`
37
- - `name=`: `id`
51
+ - `url=`: `url`
52
+ - `name=`: `name`
38
53
  - `code=`: `code`
39
54
  - `subdue=`: `subdue`
40
55
  - `number=`: `num`
package/lib/index.d.ts CHANGED
@@ -23,10 +23,11 @@ declare const logger: {
23
23
  bold: chalk.Chalk;
24
24
  dim: chalk.Chalk;
25
25
  path: (msg: unknown) => string;
26
+ url: (msg: unknown) => string;
26
27
  name: (msg: unknown) => string;
27
28
  code: (msg: unknown) => string;
28
- subdue: chalk.Chalk;
29
- num: chalk.Chalk;
29
+ subdue: (msg: unknown) => string;
30
+ num: (msg: unknown) => string;
30
31
  interpolate: typeof interpolate;
31
32
  info: typeof info;
32
33
  warn: typeof warn;
@@ -34,5 +35,5 @@ declare const logger: {
34
35
  success: typeof success;
35
36
  newLine: typeof newLine;
36
37
  };
37
- export default logger;
38
+ export = logger;
38
39
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,aAAK,mBAAmB,GAAG,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM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lib/index.js CHANGED
@@ -5,14 +5,14 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
8
  const tslib_1 = require("tslib");
10
- const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
11
- const path = (msg) => chalk_1.default.cyan(chalk_1.default.underline(msg));
12
- const name = (msg) => chalk_1.default.blue(chalk_1.default.bold(msg));
9
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
10
+ const path = (msg) => chalk_1.default.cyan.underline(`"${msg}"`);
11
+ const url = (msg) => chalk_1.default.cyan.underline(msg);
12
+ const name = (msg) => chalk_1.default.blue.bold(msg);
13
13
  const code = (msg) => chalk_1.default.cyan(`\`${msg}\``);
14
- const subdue = chalk_1.default.gray;
15
- const num = chalk_1.default.yellow;
14
+ const subdue = (msg) => chalk_1.default.gray(msg);
15
+ const num = (msg) => chalk_1.default.yellow(msg);
16
16
  function interpolate(msgs, ...values) {
17
17
  let res = '';
18
18
  values.forEach((value, idx) => {
@@ -25,6 +25,8 @@ function interpolate(msgs, ...values) {
25
25
  switch (flag[0]) {
26
26
  case 'path=':
27
27
  return path;
28
+ case 'url=':
29
+ return url;
28
30
  case 'number=':
29
31
  return num;
30
32
  case 'name=':
@@ -51,7 +53,7 @@ function stringify(msg) {
51
53
  return String(msg);
52
54
  }
53
55
  function info(msg, ...values) {
54
- console.info(`${chalk_1.default.cyan(chalk_1.default.bold('[INFO]'))} ${values.length === 0
56
+ console.info(`${chalk_1.default.cyan.bold('[INFO]')} ${values.length === 0
55
57
  ? stringify(msg)
56
58
  : interpolate(msg, ...values)}`);
57
59
  }
@@ -66,7 +68,7 @@ function error(msg, ...values) {
66
68
  : interpolate(msg, ...values)}`));
67
69
  }
68
70
  function success(msg, ...values) {
69
- console.log(`${chalk_1.default.green(chalk_1.default.bold('[SUCCESS]'))} ${values.length === 0
71
+ console.log(`${chalk_1.default.green.bold('[SUCCESS]')} ${values.length === 0
70
72
  ? stringify(msg)
71
73
  : interpolate(msg, ...values)}`);
72
74
  }
@@ -80,6 +82,7 @@ const logger = {
80
82
  bold: chalk_1.default.bold,
81
83
  dim: chalk_1.default.dim,
82
84
  path,
85
+ url,
83
86
  name,
84
87
  code,
85
88
  subdue,
@@ -91,9 +94,5 @@ const logger = {
91
94
  success,
92
95
  newLine,
93
96
  };
94
- // TODO remove when migrating to ESM
95
- // logger can only be default-imported in ESM with this
96
97
  module.exports = logger;
97
- module.exports.default = logger;
98
- exports.default = logger;
99
98
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,+DAAwC;AAIxC,MAAM,IAAI,GAAG,CAAC,GAAY,EAAU,EAAE,CAAC,eAAK,CAAC,IAAI,CAAC,eAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;AACxE,MAAM,IAAI,GAAG,CAAC,GAAY,EAAU,EAAE,CAAC,eAAK,CAAC,IAAI,CAAC,eAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACnE,MAAM,IAAI,GAAG,CAAC,GAAY,EAAU,EAAE,CAAC,eAAK,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;AAChE,MAAM,MAAM,GAAU,eAAK,CAAC,IAAI,CAAC;AACjC,MAAM,GAAG,GAAU,eAAK,CAAC,MAAM,CAAC;AAEhC,SAAS,WAAW,CAClB,IAA0B,EAC1B,GAAG,MAA6B;IAEhC,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACzC,GAAG,IAAI,IAAI,CAAC,GAAG,CA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C,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,IAC9B,MAAM,CAAC,MAAM,KAAK,CAAC;QACjB,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC;QAChB,CAAC,CAAC,WAAW,CAAC,GAA2B,EAAE,GAAG,MAAM,CACxD,EAAE,CACH,CAAC;AACJ,CAAC;AAED,SAAS,OAAO;IACd,OAAO,CAAC,GAAG,EAAE,CAAC;AAChB,CAAC;AAED,MAAM,MAAM,GAAG;IACb,GAAG,EAAE,eAAK,CAAC,GAAG;IACd,MAAM,EAAE,eAAK,CAAC,MAAM;IACpB,KAAK,EAAE,eAAK,CAAC,KAAK;IAClB,IAAI,EAAE,eAAK,CAAC,IAAI;IAChB,GAAG,EAAE,eAAK,CAAC,GAAG;IACd,IAAI;IACJ,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,MAAM;IACN,GAAG;IACH,WAAW;IACX,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,OAAO;IACP,OAAO;CACR,CAAC;AAIF,iBAAS,MAAM,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/logger",
3
- "version": "2.0.0-beta.16",
3
+ "version": "2.0.0-beta.19",
4
4
  "description": "An encapsulated logger for semantically formatting console messages.",
5
5
  "main": "./lib/index.js",
6
6
  "repository": {
@@ -21,7 +21,7 @@
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
23
  "chalk": "^4.1.2",
24
- "tslib": "^2.3.1"
24
+ "tslib": "^2.4.0"
25
25
  },
26
26
  "engines": {
27
27
  "node": ">=14"
@@ -29,5 +29,5 @@
29
29
  "devDependencies": {
30
30
  "@types/supports-color": "^8.1.1"
31
31
  },
32
- "gitHead": "eb43c4d4f95a4fb97dc9bb9dc615413e0dc2e1e7"
32
+ "gitHead": "a71e60a49cce93c1006ef10c41ac03187f057102"
33
33
  }
package/src/index.ts CHANGED
@@ -5,15 +5,16 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import chalk, {type Chalk} from 'chalk';
8
+ import chalk from 'chalk';
9
9
 
10
10
  type InterpolatableValue = string | number | (string | number)[];
11
11
 
12
- const path = (msg: unknown): string => chalk.cyan(chalk.underline(msg));
13
- const name = (msg: unknown): string => chalk.blue(chalk.bold(msg));
12
+ const path = (msg: unknown): string => chalk.cyan.underline(`"${msg}"`);
13
+ const url = (msg: unknown): string => chalk.cyan.underline(msg);
14
+ const name = (msg: unknown): string => chalk.blue.bold(msg);
14
15
  const code = (msg: unknown): string => chalk.cyan(`\`${msg}\``);
15
- const subdue: Chalk = chalk.gray;
16
- const num: Chalk = chalk.yellow;
16
+ const subdue = (msg: unknown): string => chalk.gray(msg);
17
+ const num = (msg: unknown): string => chalk.yellow(msg);
17
18
 
18
19
  function interpolate(
19
20
  msgs: TemplateStringsArray,
@@ -21,8 +22,8 @@ function interpolate(
21
22
  ): string {
22
23
  let res = '';
23
24
  values.forEach((value, idx) => {
24
- const flag = msgs[idx].match(/[a-z]+=$/);
25
- res += msgs[idx].replace(/[a-z]+=$/, '');
25
+ const flag = msgs[idx]!.match(/[a-z]+=$/);
26
+ res += msgs[idx]!.replace(/[a-z]+=$/, '');
26
27
  const format = (() => {
27
28
  if (!flag) {
28
29
  return (a: string | number) => a;
@@ -30,6 +31,8 @@ function interpolate(
30
31
  switch (flag[0]) {
31
32
  case 'path=':
32
33
  return path;
34
+ case 'url=':
35
+ return url;
33
36
  case 'number=':
34
37
  return num;
35
38
  case 'name=':
@@ -66,7 +69,7 @@ function info(
66
69
  ): void;
67
70
  function info(msg: unknown, ...values: InterpolatableValue[]): void {
68
71
  console.info(
69
- `${chalk.cyan(chalk.bold('[INFO]'))} ${
72
+ `${chalk.cyan.bold('[INFO]')} ${
70
73
  values.length === 0
71
74
  ? stringify(msg)
72
75
  : interpolate(msg as TemplateStringsArray, ...values)
@@ -112,7 +115,7 @@ function success(
112
115
  ): void;
113
116
  function success(msg: unknown, ...values: InterpolatableValue[]): void {
114
117
  console.log(
115
- `${chalk.green(chalk.bold('[SUCCESS]'))} ${
118
+ `${chalk.green.bold('[SUCCESS]')} ${
116
119
  values.length === 0
117
120
  ? stringify(msg)
118
121
  : interpolate(msg as TemplateStringsArray, ...values)
@@ -131,6 +134,7 @@ const logger = {
131
134
  bold: chalk.bold,
132
135
  dim: chalk.dim,
133
136
  path,
137
+ url,
134
138
  name,
135
139
  code,
136
140
  subdue,
@@ -145,7 +149,4 @@ const logger = {
145
149
 
146
150
  // TODO remove when migrating to ESM
147
151
  // logger can only be default-imported in ESM with this
148
- module.exports = logger;
149
- module.exports.default = logger;
150
-
151
- export default logger;
152
+ export = logger;