@storm-software/config-tools 1.35.5 → 1.35.6

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/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 1.35.6 (2024-04-08)
2
+
3
+
4
+ ### 🩹 Fixes
5
+
6
+ - **config-tools:** Export `getChalk` function so that it can be used in other packages ([2ca2241a](https://github.com/storm-software/storm-ops/commit/2ca2241a))
7
+
8
+
9
+ ### ❤️ Thank You
10
+
11
+ - Patrick Sullivan
12
+
1
13
  ## 1.35.5 (2024-04-08)
2
14
 
3
15
 
package/declarations.d.ts CHANGED
@@ -267,3 +267,29 @@ declare function applyWorkspaceTokens<
267
267
  tokenizerFn: (option: string, config: TConfig) => string | Promise<string>
268
268
  ): Promise<Record<string, any>>;
269
269
  export { applyWorkspaceTokens };
270
+
271
+ export type GetChalkReturn = {
272
+ hex: (_: string) => (message?: string) => string | undefined;
273
+ bgHex: (_: string) => {
274
+ whiteBright: (message?: string) => string | undefined;
275
+ };
276
+ whiteBright: (message?: string) => string | undefined;
277
+ bold: {
278
+ hex: (_: string) => (message?: string) => string | undefined;
279
+ bgHex: (_: string) => {
280
+ whiteBright: (message?: string) => string | undefined;
281
+ };
282
+ whiteBright: (message?: string) => string | undefined;
283
+ };
284
+ };
285
+
286
+ /**
287
+ * Get the chalk instance
288
+ *
289
+ * @remarks
290
+ * Annoying polyfill to temporarily fix the issue with the `chalk` import
291
+ *
292
+ * @returns The chalk instance
293
+ */
294
+ declare function getChalk(): GetChalkReturn;
295
+ export { getChalk };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storm-software/config-tools",
3
- "version": "1.35.5",
3
+ "version": "1.35.6",
4
4
  "private": false,
5
5
  "description": "⚡The Storm-Ops monorepo contains utility applications, tools, and various libraries to create modern and scalable web applications.",
6
6
  "repository": {
package/project.json CHANGED
@@ -11,6 +11,7 @@
11
11
  "main": "packages/config-tools/src/index.ts",
12
12
  "additionalEntryPoints": [
13
13
  "packages/config-tools/src/utilities/find-workspace-root.ts",
14
+ "packages/config-tools/src/utilities/chalk.ts",
14
15
  "packages/config-tools/src/utilities/logger.ts"
15
16
  ],
16
17
  "outputPath": "dist/packages/config-tools",
@@ -0,0 +1,53 @@
1
+ import chalk from "chalk";
2
+
3
+ export type GetChalkReturn = {
4
+ hex: (_: string) => (message?: string) => string | undefined;
5
+ bgHex: (_: string) => {
6
+ whiteBright: (message?: string) => string | undefined;
7
+ };
8
+ whiteBright: (message?: string) => string | undefined;
9
+ bold: {
10
+ hex: (_: string) => (message?: string) => string | undefined;
11
+ bgHex: (_: string) => {
12
+ whiteBright: (message?: string) => string | undefined;
13
+ };
14
+ whiteBright: (message?: string) => string | undefined;
15
+ };
16
+ };
17
+
18
+ const chalkDefault: GetChalkReturn = {
19
+ hex: (_: string) => (message?: string) => message,
20
+ bgHex: (_: string) => ({
21
+ whiteBright: (message?: string) => message
22
+ }),
23
+ whiteBright: (message?: string) => message,
24
+ bold: {
25
+ hex: (_: string) => (message?: string) => message,
26
+ bgHex: (_: string) => ({
27
+ whiteBright: (message?: string) => message
28
+ }),
29
+ whiteBright: (message?: string) => message
30
+ }
31
+ };
32
+
33
+ /**
34
+ * Get the chalk instance
35
+ *
36
+ * @remarks
37
+ * Annoying polyfill to temporarily fix the issue with the `chalk` import
38
+ *
39
+ * @returns The chalk instance
40
+ */
41
+ export const getChalk = (): GetChalkReturn => {
42
+ let _chalk = chalk as GetChalkReturn;
43
+ if (
44
+ !_chalk?.hex ||
45
+ !_chalk?.bold?.hex ||
46
+ !_chalk?.bgHex ||
47
+ !_chalk?.whiteBright
48
+ ) {
49
+ _chalk = chalkDefault;
50
+ }
51
+
52
+ return _chalk;
53
+ };
@@ -7,3 +7,4 @@ export * from "./run";
7
7
  export * from "./correct-paths";
8
8
  export * from "./file-path-utils";
9
9
  export * from "./apply-workspace-tokens";
10
+ export * from "./chalk";
@@ -1,24 +1,7 @@
1
1
  import { LogLevel, LogLevelLabel } from "../types";
2
2
  import type { StormConfig } from "@storm-software/config";
3
3
  import { getLogLevel } from "./get-log-level";
4
- import chalk from "chalk";
5
-
6
- // Annoying chalk polyfill to temporarily fix the issue with the `chalk` import
7
- const chalkDefault = {
8
- hex: (_: string) => (message?: string) => message,
9
- bgHex: (_: string) => ({
10
- whiteBright: (message?: string) => message
11
- }),
12
- whiteBright: (message?: string) => message,
13
- bold: {
14
- hex: (_: string) => (message?: string) => message,
15
- bgHex: (_: string) => ({
16
- whiteBright: (message?: string) => message
17
- }),
18
- whiteBright: (message?: string) => message
19
- }
20
- } as any;
21
- // const chalk = chalkDefault;
4
+ import { getChalk } from "./chalk";
22
5
 
23
6
  /**
24
7
  * Get the log function for a log level
@@ -31,10 +14,7 @@ export const getLogFn = (
31
14
  config: Partial<StormConfig> = {},
32
15
  logLevel: number | LogLevel = LogLevel.INFO
33
16
  ): ((message?: string) => void) => {
34
- let _chalk = chalk;
35
- if (!_chalk?.hex || !_chalk?.bold?.hex || !_chalk?.bgHex || !_chalk?.whiteBright) {
36
- _chalk = chalkDefault;
37
- }
17
+ let _chalk = getChalk();
38
18
 
39
19
  const configLogLevel = (config.logLevel ??
40
20
  process.env?.STORM_LOG_LEVEL ??
@@ -42,8 +22,10 @@ export const getLogFn = (
42
22
 
43
23
  if (
44
24
  (typeof logLevel === "number" &&
45
- (logLevel >= getLogLevel(configLogLevel) || logLevel <= LogLevel.SILENT)) ||
46
- (typeof logLevel === "string" && getLogLevel(logLevel) >= getLogLevel(configLogLevel))
25
+ (logLevel >= getLogLevel(configLogLevel) ||
26
+ logLevel <= LogLevel.SILENT)) ||
27
+ (typeof logLevel === "string" &&
28
+ getLogLevel(logLevel) >= getLogLevel(configLogLevel))
47
29
  ) {
48
30
  return (_: string) => {
49
31
  /* noop */