@socketsecurity/lib 3.3.11 → 3.5.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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,30 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [3.5.0](https://github.com/SocketDev/socket-lib/releases/tag/v3.5.0) - 2025-11-14
9
+
10
+ ### Added
11
+
12
+ - **argv/quote**: New utilities for quoting command-line arguments when using `spawn()` with `shell: true`
13
+ - `posixQuote(arg)`: Quote arguments for POSIX shells (bash, sh, zsh) using single quotes
14
+ - `win32Quote(arg)`: Quote arguments for Windows cmd.exe using double quotes
15
+
16
+ ## [3.4.0](https://github.com/SocketDev/socket-lib/releases/tag/v3.4.0) - 2025-11-14
17
+
18
+ ### Added
19
+
20
+ - **Spinner**: New `skip()` and `skipAndStop()` methods for displaying skipped operations
21
+ - `skip(text)`: Display skip message alongside spinner (e.g., "Skipping optional step...")
22
+ - `skipAndStop(text)`: Display skip message and stop spinner in one call
23
+ - Uses cyan ↻ (refresh/reload) symbol with @ ASCII fallback
24
+ - Normalizes text formatting consistently with other spinner methods
25
+ - Useful for communicating skipped steps during long-running operations
26
+
27
+ - **Logger**: New `skip()` method and symbol for skipped operations
28
+ - `LOG_SYMBOLS.skip`: New cyan ↻ symbol for skip output (@ ASCII fallback)
29
+ - `skip(message)`: Display skip messages with dedicated symbol
30
+ - Complements existing info/step/success/error/warning/reason methods
31
+
8
32
  ## [3.3.11](https://github.com/SocketDev/socket-lib/releases/tag/v3.3.11) - 2025-11-14
9
33
 
10
34
  ### Fixed
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Argument quoting utilities for shell execution with spawn()
3
+ *
4
+ * These functions handle quoting of command-line arguments when using
5
+ * child_process.spawn() with shell: true.
6
+ *
7
+ * IMPORTANT: Only needed when shell: true. With shell: false, arguments
8
+ * are passed directly to the OS kernel as an array (no quoting needed).
9
+ */
10
+ /**
11
+ * Quote an argument for POSIX shell execution (bash, sh, zsh).
12
+ *
13
+ * Uses single quotes (POSIX standard) which prevent all expansions except
14
+ * single quotes themselves. Internal single quotes are escaped using '\''
15
+ *
16
+ * @param arg - Argument to quote
17
+ * @returns Quoted argument safe for POSIX shells when using shell: true
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import { posixQuote } from '@socketsecurity/lib/argv/quote'
22
+ *
23
+ * // With shell: true on Unix
24
+ * const path = '/path/with spaces/file.txt'
25
+ * spawn('sh', ['-c', 'cat', posixQuote(path)], { shell: true })
26
+ * // sh receives: sh -c cat '/path/with spaces/file.txt'
27
+ * ```
28
+ */
29
+ export declare function posixQuote(arg: string): string;
30
+ /**
31
+ * Quote an argument for Windows cmd.exe shell execution.
32
+ *
33
+ * Uses double quotes (cmd.exe standard) and escapes internal quotes by doubling.
34
+ * Handles all cmd.exe special characters: space, &, |, <, >, ^, %, (, ), !, "
35
+ *
36
+ * @param arg - Argument to quote
37
+ * @returns Quoted argument safe for cmd.exe when using shell: true
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * import { win32Quote } from '@socketsecurity/lib/argv/quote'
42
+ *
43
+ * // With shell: true on Windows
44
+ * const path = 'C:\\Program Files\\app.exe'
45
+ * spawn('cmd', ['/c', 'app', win32Quote(path)], { shell: true })
46
+ * // cmd.exe receives: cmd /c app "C:\Program Files\app.exe"
47
+ * ```
48
+ */
49
+ export declare function win32Quote(arg: string): string;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ /* Socket Lib - Built with esbuild */
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var quote_exports = {};
21
+ __export(quote_exports, {
22
+ posixQuote: () => posixQuote,
23
+ win32Quote: () => win32Quote
24
+ });
25
+ module.exports = __toCommonJS(quote_exports);
26
+ function posixQuote(arg) {
27
+ if (!/[\s&|<>$`\\*?[\](){};"'~!#]/.test(arg)) {
28
+ return arg;
29
+ }
30
+ return `'${arg.replace(/'/g, "'\\''")}'`;
31
+ }
32
+ function win32Quote(arg) {
33
+ if (!/[\s&|<>^%()!"]/.test(arg)) {
34
+ return arg;
35
+ }
36
+ return `"${arg.replace(/"/g, '""')}"`;
37
+ }
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ posixQuote,
41
+ win32Quote
42
+ });
package/dist/logger.d.ts CHANGED
@@ -26,6 +26,8 @@ type LogSymbols = {
26
26
  progress: string;
27
27
  /** Dimmed yellow reasoning/working symbol (∴ or :. in ASCII) */
28
28
  reason: string;
29
+ /** Cyan colored skip symbol (↻ or @ in ASCII) */
30
+ skip: string;
29
31
  /** Cyan colored step symbol (→ or > in ASCII) */
30
32
  step: string;
31
33
  /** Green colored success symbol (✔ or √ in ASCII) */
@@ -741,6 +743,24 @@ export declare class Logger {
741
743
  * ```
742
744
  */
743
745
  resetIndent(): this;
746
+ /**
747
+ * Logs a skip message with a cyan colored skip symbol.
748
+ *
749
+ * Automatically prefixes the message with `LOG_SYMBOLS.skip` (cyan ↻).
750
+ * Always outputs to stderr. If the message starts with an existing
751
+ * symbol, it will be stripped and replaced.
752
+ *
753
+ * @param args - Message and additional arguments to log
754
+ * @returns The logger instance for chaining
755
+ *
756
+ * @example
757
+ * ```typescript
758
+ * logger.skip('Test skipped due to environment')
759
+ * logger.skip('Skipping optional step')
760
+ * logger.skip('Feature disabled, skipping')
761
+ * ```
762
+ */
763
+ skip(...args: unknown[]): this;
744
764
  /**
745
765
  * Logs a main step message with a cyan arrow symbol and blank line before it.
746
766
  *
package/dist/logger.js CHANGED
@@ -92,6 +92,7 @@ const LOG_SYMBOLS = /* @__PURE__ */ (() => {
92
92
  target.reason = colors.dim(
93
93
  /* @__PURE__ */ applyColor(supported ? "\u2234" : ":.", warningColor, colors)
94
94
  );
95
+ target.skip = /* @__PURE__ */ applyColor(supported ? "\u21BB" : "@", stepColor, colors);
95
96
  target.step = /* @__PURE__ */ applyColor(supported ? "\u2192" : ">", stepColor, colors);
96
97
  target.success = /* @__PURE__ */ applyColor(supported ? "\u2714" : "\u221A", successColor, colors);
97
98
  target.warn = /* @__PURE__ */ applyColor(supported ? "\u26A0" : "\u203C", warningColor, colors);
@@ -332,6 +333,7 @@ class Logger {
332
333
  reason: colors.dim(
333
334
  /* @__PURE__ */ applyColor(supported ? "\u2234" : ":.", theme.colors.warning, colors)
334
335
  ),
336
+ skip: /* @__PURE__ */ applyColor(supported ? "\u21BB" : "@", theme.colors.step, colors),
335
337
  step: /* @__PURE__ */ applyColor(supported ? "\u2192" : ">", theme.colors.step, colors),
336
338
  success: /* @__PURE__ */ applyColor(supported ? "\u2714" : "\u221A", theme.colors.success, colors),
337
339
  warn: /* @__PURE__ */ applyColor(supported ? "\u26A0" : "\u203C", theme.colors.warning, colors)
@@ -381,7 +383,7 @@ class Logger {
381
383
  * @private
382
384
  */
383
385
  #stripSymbols(text) {
384
- return text.replace(/^(?:[✖✗×⚠‼✔✓√ℹ→∴]|:.)[\uFE0F\s]*/u, "");
386
+ return text.replace(/^(?:[✖✗×⚠‼✔✓√ℹ→∴↻]|:.)[\uFE0F\s]*/u, "");
385
387
  }
386
388
  /**
387
389
  * Apply a method with a symbol prefix.
@@ -1119,6 +1121,26 @@ class Logger {
1119
1121
  }
1120
1122
  return this;
1121
1123
  }
1124
+ /**
1125
+ * Logs a skip message with a cyan colored skip symbol.
1126
+ *
1127
+ * Automatically prefixes the message with `LOG_SYMBOLS.skip` (cyan ↻).
1128
+ * Always outputs to stderr. If the message starts with an existing
1129
+ * symbol, it will be stripped and replaced.
1130
+ *
1131
+ * @param args - Message and additional arguments to log
1132
+ * @returns The logger instance for chaining
1133
+ *
1134
+ * @example
1135
+ * ```typescript
1136
+ * logger.skip('Test skipped due to environment')
1137
+ * logger.skip('Skipping optional step')
1138
+ * logger.skip('Feature disabled, skipping')
1139
+ * ```
1140
+ */
1141
+ skip(...args) {
1142
+ return this.#symbolApply("skip", args);
1143
+ }
1122
1144
  /**
1123
1145
  * Logs a main step message with a cyan arrow symbol and blank line before it.
1124
1146
  *
package/dist/spinner.d.ts CHANGED
@@ -7,9 +7,9 @@ import type { ColorInherit, ColorRgb, ColorValue } from './colors';
7
7
  import type { ShimmerColorGradient, ShimmerConfig, ShimmerDirection, ShimmerState } from './effects/text-shimmer';
8
8
  /**
9
9
  * Symbol types for status messages.
10
- * Maps to log symbols: fail (✗), info (ℹ), reason (∴), success (✓), warn (⚠).
10
+ * Maps to log symbols: fail (✗), info (ℹ), reason (∴), skip (↻), success (✓), warn (⚠).
11
11
  */
12
- export type SymbolType = 'fail' | 'info' | 'reason' | 'success' | 'warn';
12
+ export type SymbolType = 'fail' | 'info' | 'reason' | 'skip' | 'success' | 'warn';
13
13
  /**
14
14
  * Progress tracking information for display in spinner.
15
15
  * Used by `progress()` and `progressStep()` methods to show animated progress bars.
@@ -107,6 +107,10 @@ export type Spinner = {
107
107
  reasonAndStop(text?: string | undefined, ...extras: unknown[]): Spinner;
108
108
  /** Set complete shimmer configuration */
109
109
  setShimmer(config: ShimmerConfig): Spinner;
110
+ /** Show skip (↻) message without stopping the spinner */
111
+ skip(text?: string | undefined, ...extras: unknown[]): Spinner;
112
+ /** Show skip (↻) message and stop the spinner, auto-clearing the line */
113
+ skipAndStop(text?: string | undefined, ...extras: unknown[]): Spinner;
110
114
  /** Start spinning with optional text */
111
115
  start(text?: string | undefined): Spinner;
112
116
  /** Show main step message to stderr without stopping */
package/dist/spinner.js CHANGED
@@ -605,6 +605,37 @@ function Spinner(options) {
605
605
  }
606
606
  return this;
607
607
  }
608
+ /**
609
+ * Show a skip message (↻) without stopping the spinner.
610
+ * Outputs to stderr and continues spinning.
611
+ *
612
+ * @param text - Skip message to display
613
+ * @param extras - Additional values to log
614
+ * @returns This spinner for chaining
615
+ */
616
+ skip(text, ...extras) {
617
+ return this.#showStatusAndKeepSpinning("skip", [text, ...extras]);
618
+ }
619
+ /**
620
+ * Show a skip message (↻) and stop the spinner.
621
+ * Auto-clears the spinner line before displaying the message.
622
+ *
623
+ * Implementation note: Similar to reasonAndStop(), this method cannot use #apply()
624
+ * with a 'skip' method name because yocto-spinner doesn't have a built-in 'skip'
625
+ * method. Instead, we manually stop the spinner then log the message with the skip symbol.
626
+ *
627
+ * @param text - Skip message to display
628
+ * @param extras - Additional values to log
629
+ * @returns This spinner for chaining
630
+ */
631
+ skipAndStop(text, ...extras) {
632
+ this.#apply("stop", []);
633
+ const normalized = normalizeText(text);
634
+ if (normalized) {
635
+ logger.error(`${import_logger.LOG_SYMBOLS.skip} ${normalized}`, ...extras);
636
+ }
637
+ return this;
638
+ }
608
639
  /**
609
640
  * Set complete shimmer configuration.
610
641
  * Replaces any existing shimmer config with the provided values.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socketsecurity/lib",
3
- "version": "3.3.11",
3
+ "version": "3.5.0",
4
4
  "packageManager": "pnpm@10.22.0",
5
5
  "license": "MIT",
6
6
  "description": "Core utilities and infrastructure for Socket.dev security tools",
@@ -111,6 +111,10 @@
111
111
  "types": "./dist/argv/parse.d.ts",
112
112
  "default": "./dist/argv/parse.js"
113
113
  },
114
+ "./argv/quote": {
115
+ "types": "./dist/argv/quote.d.ts",
116
+ "default": "./dist/argv/quote.js"
117
+ },
114
118
  "./arrays": {
115
119
  "types": "./dist/arrays.d.ts",
116
120
  "default": "./dist/arrays.js"
@@ -687,7 +691,7 @@
687
691
  "@socketregistry/is-unicode-supported": "1.0.5",
688
692
  "@socketregistry/packageurl-js": "1.3.5",
689
693
  "@socketregistry/yocto-spinner": "1.0.25",
690
- "@socketsecurity/lib-stable": "npm:@socketsecurity/lib@3.3.7",
694
+ "@socketsecurity/lib-stable": "npm:@socketsecurity/lib@3.4.0",
691
695
  "@types/node": "24.9.2",
692
696
  "@typescript/native-preview": "7.0.0-dev.20250920.1",
693
697
  "@vitest/coverage-v8": "4.0.3",