@rsdoctor/utils 1.1.0-alpha.0 → 1.1.0

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.
@@ -33,7 +33,7 @@ __export(error_exports, {
33
33
  module.exports = __toCommonJS(error_exports);
34
34
  var import_code_frame = require("@babel/code-frame");
35
35
  var import_types = require("@rsdoctor/types");
36
- var import_chalk = require("chalk");
36
+ var import_picocolors = require("picocolors");
37
37
  var import_deep_eql = __toESM(require("deep-eql"));
38
38
  var import_strip_ansi = __toESM(require("strip-ansi"));
39
39
  var import_transform = require("./transform");
@@ -164,13 +164,13 @@ class DevToolError extends Error {
164
164
  referenceUrl,
165
165
  _controller: controller
166
166
  } = this;
167
- const print = controller.noColor ? new import_chalk.Instance({ level: 0 }) : new import_chalk.Instance({ level: 3 });
167
+ const print = (0, import_picocolors.createColors)(!controller.noColor);
168
168
  const mainColorPrint = this._level === import_types.Err.ErrorLevel.Error ? print.red : print.yellow;
169
- const codeText = code ? `${mainColorPrint.blue(code)}:` : "";
169
+ const codeText = code ? `${mainColorPrint(print.blue(code))}:` : "";
170
170
  msgs.push(
171
- mainColorPrint.bold(
172
- `[${codeText}${this.level}:${title.toUpperCase()}] `
173
- ) + message
171
+ mainColorPrint(
172
+ print.bold(`[${codeText}${this.level}:${title.toUpperCase()}] `) + message
173
+ )
174
174
  );
175
175
  msgs.push(...this.printCodeFrame(print));
176
176
  if (hint || referenceUrl) {
@@ -180,12 +180,12 @@ class DevToolError extends Error {
180
180
  msgs.push(` ${print.blue(`HINT: ${hint}`)}`);
181
181
  }
182
182
  if (referenceUrl) {
183
- msgs.push(print.magenta.bold(` See: ${referenceUrl}`));
183
+ msgs.push(print.magenta(print.bold(` See: ${referenceUrl}`)));
184
184
  }
185
185
  if (!controller.noStack && this.stack) {
186
- msgs.push(print.red.bold(` Error Stack:
186
+ msgs.push(print.red(print.bold(` Error Stack:
187
187
  ${this.stack}
188
- `));
188
+ `)));
189
189
  }
190
190
  return msgs.join("\n");
191
191
  }
@@ -28,12 +28,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var logger_exports = {};
30
30
  __export(logger_exports, {
31
- chalk: () => import_chalk.default,
31
+ chalk: () => import_picocolors.default,
32
32
  debug: () => debug,
33
33
  logger: () => import_rslog.logger
34
34
  });
35
35
  module.exports = __toCommonJS(logger_exports);
36
- var import_chalk = __toESM(require("chalk"));
36
+ var import_picocolors = __toESM(require("picocolors"));
37
37
  var import_rslog = require("rslog");
38
38
  var import_types = require("@rsdoctor/types");
39
39
  function debug(getMsg, prefix = "") {
@@ -1,6 +1,6 @@
1
1
  import { codeFrameColumns } from "@babel/code-frame";
2
2
  import { Err } from "@rsdoctor/types";
3
- import { Instance } from "chalk";
3
+ import { createColors } from "picocolors";
4
4
  import deepEql from "deep-eql";
5
5
  import stripAnsi from "strip-ansi";
6
6
  import { transform } from "./transform";
@@ -131,13 +131,13 @@ class DevToolError extends Error {
131
131
  referenceUrl,
132
132
  _controller: controller
133
133
  } = this;
134
- const print = controller.noColor ? new Instance({ level: 0 }) : new Instance({ level: 3 });
134
+ const print = createColors(!controller.noColor);
135
135
  const mainColorPrint = this._level === Err.ErrorLevel.Error ? print.red : print.yellow;
136
- const codeText = code ? `${mainColorPrint.blue(code)}:` : "";
136
+ const codeText = code ? `${mainColorPrint(print.blue(code))}:` : "";
137
137
  msgs.push(
138
- mainColorPrint.bold(
139
- `[${codeText}${this.level}:${title.toUpperCase()}] `
140
- ) + message
138
+ mainColorPrint(
139
+ print.bold(`[${codeText}${this.level}:${title.toUpperCase()}] `) + message
140
+ )
141
141
  );
142
142
  msgs.push(...this.printCodeFrame(print));
143
143
  if (hint || referenceUrl) {
@@ -147,12 +147,12 @@ class DevToolError extends Error {
147
147
  msgs.push(` ${print.blue(`HINT: ${hint}`)}`);
148
148
  }
149
149
  if (referenceUrl) {
150
- msgs.push(print.magenta.bold(` See: ${referenceUrl}`));
150
+ msgs.push(print.magenta(print.bold(` See: ${referenceUrl}`)));
151
151
  }
152
152
  if (!controller.noStack && this.stack) {
153
- msgs.push(print.red.bold(` Error Stack:
153
+ msgs.push(print.red(print.bold(` Error Stack:
154
154
  ${this.stack}
155
- `));
155
+ `)));
156
156
  }
157
157
  return msgs.join("\n");
158
158
  }
@@ -1,4 +1,4 @@
1
- import chalk from "chalk";
1
+ import c from "picocolors";
2
2
  import { logger } from "rslog";
3
3
  import { Constants } from "@rsdoctor/types";
4
4
  function debug(getMsg, prefix = "") {
@@ -37,7 +37,7 @@ logger.override({
37
37
  }
38
38
  });
39
39
  export {
40
- chalk,
40
+ c as chalk,
41
41
  debug,
42
42
  logger
43
43
  };
@@ -1 +1 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/error/error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAU5C,qBAAa,YAAa,SAAQ,KAAM,YAAW,GAAG,CAAC,oBAAoB;IACzE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,kBAAkB,GAAG,YAAY;IAQrE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAE3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,QAAQ,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC;IAEtB,QAAQ,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IAE/B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEvB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAE/B,OAAO,CAAC,UAAU,CAAC,CAAs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AAG,CAAC,OAAO,CAAC;IAE/B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEvB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAE/B,OAAO,CAAC,UAAU,CAAC,CAAsB;IAEzC,OAAO,CAAC,WAAW,CAGjB;IAEF,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;gBAE5B,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,kBAAkB;IAiBzE,IAAI,KAAK,IAC+B,MAAM,OAAO,GAAG,CAAC,UAAU,CAClE;IAED,IAAI,IAAI,IAIO,MAAM,GAAG,SAAS,CAFhC;IAED,IAAI,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAahC;IAED,IAAI,SAAS,oCAEZ;IAED,OAAO,CAAC,cAAc;IAkFtB,QAAQ;IA6CR,MAAM,IAAI,IAAI,CAAC,iBAAiB;IAYhC,OAAO;IAUP;;OAEG;IACH,MAAM;;;;;IAQN,mBAAmB,CAAC,GAAG,EAAE,GAAG,CAAC,gBAAgB;IAO7C,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,eAAe;IAIrC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,oBAAoB;CAYvC"}
@@ -1,8 +1,8 @@
1
- import chalk from 'chalk';
1
+ import c from 'picocolors';
2
2
  import { logger } from 'rslog';
3
3
  /**
4
4
  * log debug message
5
5
  */
6
6
  export declare function debug(getMsg: () => string, prefix?: string): void;
7
- export { chalk, logger };
7
+ export { c as chalk, logger };
8
8
  //# sourceMappingURL=logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAG/B;;GAEG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,MAAM,EAAE,MAAM,SAAK,QAOtD;AAED,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,YAAY,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAG/B;;GAEG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,MAAM,EAAE,MAAM,SAAK,QAOtD;AAED,OAAO,EAAE,CAAC,IAAI,KAAK,EAAE,MAAM,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdoctor/utils",
3
- "version": "1.1.0-alpha.0",
3
+ "version": "1.1.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/web-infra-dev/rsdoctor",
@@ -72,7 +72,7 @@
72
72
  "acorn": "^8.10.0",
73
73
  "acorn-import-attributes": "^1.9.5",
74
74
  "acorn-walk": "8.3.4",
75
- "chalk": "^4.1.2",
75
+ "picocolors": "^1.1.1",
76
76
  "connect": "3.7.0",
77
77
  "deep-eql": "4.1.4",
78
78
  "envinfo": "7.14.0",
@@ -83,7 +83,7 @@
83
83
  "lines-and-columns": "2.0.4",
84
84
  "rslog": "^1.2.3",
85
85
  "strip-ansi": "^6.0.1",
86
- "@rsdoctor/types": "1.1.0-alpha.0"
86
+ "@rsdoctor/types": "1.1.0"
87
87
  },
88
88
  "devDependencies": {
89
89
  "@types/babel__code-frame": "7.0.6",