@westbayberry/dg 1.0.49 → 1.0.51

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.
Files changed (2) hide show
  1. package/dist/index.mjs +106 -97
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -46426,21 +46426,28 @@ import { join as join5, dirname as dirname3 } from "node:path";
46426
46426
  import { fileURLToPath } from "node:url";
46427
46427
  import { homedir as homedir2 } from "node:os";
46428
46428
  function loadDgrc() {
46429
- const candidates = [
46430
- join5(process.cwd(), ".dgrc.json"),
46431
- join5(homedir2(), ".dgrc.json")
46432
- ];
46433
- for (const filepath of candidates) {
46434
- if (existsSync3(filepath)) {
46435
- try {
46436
- return JSON.parse(readFileSync3(filepath, "utf-8"));
46437
- } catch {
46438
- process.stderr.write(`Warning: Failed to parse ${filepath}, ignoring.
46429
+ const cwdPath = join5(process.cwd(), ".dgrc.json");
46430
+ const homePath = join5(homedir2(), ".dgrc.json");
46431
+ let config3 = {};
46432
+ if (existsSync3(homePath)) {
46433
+ try {
46434
+ config3 = JSON.parse(readFileSync3(homePath, "utf-8"));
46435
+ } catch {
46436
+ process.stderr.write(`Warning: Failed to parse ${homePath}, ignoring.
46439
46437
  `);
46440
- }
46441
46438
  }
46442
46439
  }
46443
- return {};
46440
+ if (existsSync3(cwdPath) && cwdPath !== homePath) {
46441
+ try {
46442
+ const cwd2 = JSON.parse(readFileSync3(cwdPath, "utf-8"));
46443
+ const { apiKey: _k, apiUrl: _u, ...safeKeys } = cwd2;
46444
+ Object.assign(config3, safeKeys);
46445
+ } catch {
46446
+ process.stderr.write(`Warning: Failed to parse ${cwdPath}, ignoring.
46447
+ `);
46448
+ }
46449
+ }
46450
+ return config3;
46444
46451
  }
46445
46452
  function validateApiUrl(url) {
46446
46453
  try {
@@ -84173,6 +84180,40 @@ var init_useInit = __esm({
84173
84180
  }
84174
84181
  });
84175
84182
 
84183
+ // src/ui/hooks/useTerminalSize.ts
84184
+ function useTerminalSize() {
84185
+ const { stdout } = use_stdout_default();
84186
+ const [size, setSize] = (0, import_react23.useState)({
84187
+ rows: stdout?.rows ?? process.stdout.rows ?? 24,
84188
+ cols: stdout?.columns ?? process.stdout.columns ?? 80
84189
+ });
84190
+ (0, import_react23.useEffect)(() => {
84191
+ const handle = () => {
84192
+ const rows = process.stdout.rows ?? 24;
84193
+ const cols = process.stdout.columns ?? 80;
84194
+ if (process.stdout.isTTY) {
84195
+ process.stdout.write("\x1B[2J\x1B[H");
84196
+ }
84197
+ setSize({ rows, cols });
84198
+ };
84199
+ process.stdout.setMaxListeners(process.stdout.getMaxListeners() + 1);
84200
+ process.stdout.on("resize", handle);
84201
+ return () => {
84202
+ process.stdout.off("resize", handle);
84203
+ process.stdout.setMaxListeners(Math.max(0, process.stdout.getMaxListeners() - 1));
84204
+ };
84205
+ }, []);
84206
+ return size;
84207
+ }
84208
+ var import_react23;
84209
+ var init_useTerminalSize = __esm({
84210
+ async "src/ui/hooks/useTerminalSize.ts"() {
84211
+ "use strict";
84212
+ import_react23 = __toESM(require_react());
84213
+ await init_build2();
84214
+ }
84215
+ });
84216
+
84176
84217
  // node_modules/cli-spinners/spinners.json
84177
84218
  var require_spinners = __commonJS({
84178
84219
  "node_modules/cli-spinners/spinners.json"(exports, module2) {
@@ -85820,9 +85861,9 @@ var require_cli_spinners = __commonJS({
85820
85861
 
85821
85862
  // node_modules/ink-spinner/build/index.js
85822
85863
  function Spinner({ type = "dots" }) {
85823
- const [frame, setFrame] = (0, import_react23.useState)(0);
85864
+ const [frame, setFrame] = (0, import_react24.useState)(0);
85824
85865
  const spinner = import_cli_spinners.default[type];
85825
- (0, import_react23.useEffect)(() => {
85866
+ (0, import_react24.useEffect)(() => {
85826
85867
  const timer = setInterval(() => {
85827
85868
  setFrame((previousFrame) => {
85828
85869
  const isLastFrame = previousFrame === spinner.frames.length - 1;
@@ -85833,12 +85874,12 @@ function Spinner({ type = "dots" }) {
85833
85874
  clearInterval(timer);
85834
85875
  };
85835
85876
  }, [spinner]);
85836
- return import_react23.default.createElement(Text, null, spinner.frames[frame]);
85877
+ return import_react24.default.createElement(Text, null, spinner.frames[frame]);
85837
85878
  }
85838
- var import_react23, import_cli_spinners, build_default;
85879
+ var import_react24, import_cli_spinners, build_default;
85839
85880
  var init_build3 = __esm({
85840
85881
  async "node_modules/ink-spinner/build/index.js"() {
85841
- import_react23 = __toESM(require_react(), 1);
85882
+ import_react24 = __toESM(require_react(), 1);
85842
85883
  await init_build2();
85843
85884
  import_cli_spinners = __toESM(require_cli_spinners(), 1);
85844
85885
  build_default = Spinner;
@@ -86984,17 +87025,17 @@ var init_ScanResultCard = __esm({
86984
87025
  });
86985
87026
 
86986
87027
  // src/ui/components/DemoScanAnimation.tsx
86987
- var import_react24, import_jsx_runtime4, DemoScanAnimation;
87028
+ var import_react25, import_jsx_runtime4, DemoScanAnimation;
86988
87029
  var init_DemoScanAnimation = __esm({
86989
87030
  async "src/ui/components/DemoScanAnimation.tsx"() {
86990
87031
  "use strict";
86991
- import_react24 = __toESM(require_react());
87032
+ import_react25 = __toESM(require_react());
86992
87033
  await init_Spinner();
86993
87034
  init_wizard_demo_data();
86994
87035
  import_jsx_runtime4 = __toESM(require_jsx_runtime());
86995
87036
  DemoScanAnimation = ({ onComplete }) => {
86996
- const [labelIdx, setLabelIdx] = (0, import_react24.useState)(0);
86997
- (0, import_react24.useEffect)(() => {
87037
+ const [labelIdx, setLabelIdx] = (0, import_react25.useState)(0);
87038
+ (0, import_react25.useEffect)(() => {
86998
87039
  const tickMs = Math.floor(DEMO_SCAN_TOTAL_MS / DEMO_SCAN_LABELS.length);
86999
87040
  const interval = setInterval(() => {
87000
87041
  setLabelIdx((i) => {
@@ -87064,13 +87105,14 @@ import { basename as basename3 } from "node:path";
87064
87105
  function defaultYesNoCursor(phase) {
87065
87106
  return phase === "confirm_wrap" ? 1 : 0;
87066
87107
  }
87067
- var import_react25, import_jsx_runtime6, YES_NO_PHASES, InitApp;
87108
+ var import_react26, import_jsx_runtime6, YES_NO_PHASES, InitApp;
87068
87109
  var init_InitApp = __esm({
87069
87110
  async "src/ui/InitApp.tsx"() {
87070
87111
  "use strict";
87071
- import_react25 = __toESM(require_react());
87112
+ import_react26 = __toESM(require_react());
87072
87113
  await init_build2();
87073
87114
  init_useInit();
87115
+ await init_useTerminalSize();
87074
87116
  await init_Spinner();
87075
87117
  await init_Mascot();
87076
87118
  await init_ScanResultCard();
@@ -87094,21 +87136,22 @@ var init_InitApp = __esm({
87094
87136
  }) => {
87095
87137
  const { state, canGoBack: canGoBack2, runDetect, runInstallHook, runVerifyHook, runScan, dispatch } = useInit({ dryRun, firstRun });
87096
87138
  const { exit } = use_app_default();
87097
- const [yesNoCursor, setYesNoCursor] = (0, import_react25.useState)(defaultYesNoCursor(state.phase));
87098
- (0, import_react25.useEffect)(() => {
87139
+ useTerminalSize();
87140
+ const [yesNoCursor, setYesNoCursor] = (0, import_react26.useState)(defaultYesNoCursor(state.phase));
87141
+ (0, import_react26.useEffect)(() => {
87099
87142
  if (YES_NO_PHASES.has(state.phase)) {
87100
87143
  setYesNoCursor(defaultYesNoCursor(state.phase));
87101
87144
  }
87102
87145
  }, [state.phase]);
87103
- (0, import_react25.useEffect)(() => {
87146
+ (0, import_react26.useEffect)(() => {
87104
87147
  if (state.phase === "detect") {
87105
87148
  runDetect();
87106
87149
  }
87107
87150
  }, [state.phase, runDetect]);
87108
- (0, import_react25.useEffect)(() => {
87151
+ (0, import_react26.useEffect)(() => {
87109
87152
  if (state.scanRan && onScanRan) onScanRan();
87110
87153
  }, [state.scanRan, onScanRan]);
87111
- (0, import_react25.useEffect)(() => {
87154
+ (0, import_react26.useEffect)(() => {
87112
87155
  if (state.phase === "install_hook") {
87113
87156
  runInstallHook();
87114
87157
  }
@@ -87807,11 +87850,11 @@ function reducer2(state, action) {
87807
87850
  }
87808
87851
  }
87809
87852
  function useLogin() {
87810
- const [state, dispatch] = (0, import_react26.useReducer)(reducer2, { phase: "creating" });
87811
- const started = (0, import_react26.useRef)(false);
87812
- const sessionRef = (0, import_react26.useRef)(null);
87813
- const cancelledRef = (0, import_react26.useRef)(false);
87814
- (0, import_react26.useEffect)(() => {
87853
+ const [state, dispatch] = (0, import_react27.useReducer)(reducer2, { phase: "creating" });
87854
+ const started = (0, import_react27.useRef)(false);
87855
+ const sessionRef = (0, import_react27.useRef)(null);
87856
+ const cancelledRef = (0, import_react27.useRef)(false);
87857
+ (0, import_react27.useEffect)(() => {
87815
87858
  if (started.current) return;
87816
87859
  started.current = true;
87817
87860
  (async () => {
@@ -87855,7 +87898,7 @@ function useLogin() {
87855
87898
  cancelledRef.current = true;
87856
87899
  };
87857
87900
  }, []);
87858
- const openAndPoll = (0, import_react26.useCallback)(() => {
87901
+ const openAndPoll = (0, import_react27.useCallback)(() => {
87859
87902
  const session = sessionRef.current;
87860
87903
  if (!session) return;
87861
87904
  dispatch({ type: "BROWSER_OPENED" });
@@ -87891,11 +87934,11 @@ function useLogin() {
87891
87934
  }, []);
87892
87935
  return { state, openAndPoll };
87893
87936
  }
87894
- var import_react26, POLL_INTERVAL_MS, MAX_POLL_ATTEMPTS;
87937
+ var import_react27, POLL_INTERVAL_MS, MAX_POLL_ATTEMPTS;
87895
87938
  var init_useLogin = __esm({
87896
87939
  "src/ui/hooks/useLogin.ts"() {
87897
87940
  "use strict";
87898
- import_react26 = __toESM(require_react());
87941
+ import_react27 = __toESM(require_react());
87899
87942
  init_auth();
87900
87943
  POLL_INTERVAL_MS = 2e3;
87901
87944
  MAX_POLL_ATTEMPTS = 150;
@@ -87907,11 +87950,11 @@ var LoginApp_exports = {};
87907
87950
  __export(LoginApp_exports, {
87908
87951
  LoginApp: () => LoginApp
87909
87952
  });
87910
- var import_react27, import_jsx_runtime7, LoginApp;
87953
+ var import_react28, import_jsx_runtime7, LoginApp;
87911
87954
  var init_LoginApp = __esm({
87912
87955
  async "src/ui/LoginApp.tsx"() {
87913
87956
  "use strict";
87914
- import_react27 = __toESM(require_react());
87957
+ import_react28 = __toESM(require_react());
87915
87958
  await init_build2();
87916
87959
  init_useLogin();
87917
87960
  await init_Spinner();
@@ -87919,7 +87962,7 @@ var init_LoginApp = __esm({
87919
87962
  LoginApp = () => {
87920
87963
  const { state, openAndPoll } = useLogin();
87921
87964
  const { exit } = use_app_default();
87922
- (0, import_react27.useEffect)(() => {
87965
+ (0, import_react28.useEffect)(() => {
87923
87966
  if (state.phase === "success") {
87924
87967
  process.exitCode = 0;
87925
87968
  const timer = setTimeout(() => exit(), 0);
@@ -88259,11 +88302,11 @@ function reducer3(state, action) {
88259
88302
  return { ...state, error: action.error };
88260
88303
  }
88261
88304
  }
88262
- var import_react28, import_chalk4, import_jsx_runtime8, VISIBLE_ROWS, FileSavePrompt;
88305
+ var import_react29, import_chalk4, import_jsx_runtime8, VISIBLE_ROWS, FileSavePrompt;
88263
88306
  var init_FileSavePrompt = __esm({
88264
88307
  async "src/ui/components/FileSavePrompt.tsx"() {
88265
88308
  "use strict";
88266
- import_react28 = __toESM(require_react());
88309
+ import_react29 = __toESM(require_react());
88267
88310
  await init_build2();
88268
88311
  import_chalk4 = __toESM(require_source());
88269
88312
  import_jsx_runtime8 = __toESM(require_jsx_runtime());
@@ -88278,8 +88321,8 @@ var init_FileSavePrompt = __esm({
88278
88321
  onSaved,
88279
88322
  onCancel
88280
88323
  }) => {
88281
- const initialEntries = (0, import_react28.useMemo)(() => listDirectory(initialDir), [initialDir]);
88282
- const [state, dispatch] = (0, import_react28.useReducer)(reducer3, {
88324
+ const initialEntries = (0, import_react29.useMemo)(() => listDirectory(initialDir), [initialDir]);
88325
+ const [state, dispatch] = (0, import_react29.useReducer)(reducer3, {
88283
88326
  filename: defaultName,
88284
88327
  cursorPos: defaultName.length,
88285
88328
  directory: initialDir,
@@ -88291,7 +88334,7 @@ var init_FileSavePrompt = __esm({
88291
88334
  confirmOverwrite: false,
88292
88335
  error: null
88293
88336
  });
88294
- const filteredEntries = (0, import_react28.useMemo)(() => {
88337
+ const filteredEntries = (0, import_react29.useMemo)(() => {
88295
88338
  const dirs = state.entries.filter((e) => e.isDirectory);
88296
88339
  if (!state.filterText) return dirs;
88297
88340
  const q = state.filterText.toLowerCase();
@@ -89213,10 +89256,10 @@ function reducer4(_state, action) {
89213
89256
  }
89214
89257
  }
89215
89258
  function useScan(config3) {
89216
- const [state, dispatch] = (0, import_react29.useReducer)(reducer4, { phase: "discovering" });
89217
- const started = (0, import_react29.useRef)(false);
89218
- const [multiProjects, setMultiProjects] = (0, import_react29.useState)(null);
89219
- (0, import_react29.useEffect)(() => {
89259
+ const [state, dispatch] = (0, import_react30.useReducer)(reducer4, { phase: "discovering" });
89260
+ const started = (0, import_react30.useRef)(false);
89261
+ const [multiProjects, setMultiProjects] = (0, import_react30.useState)(null);
89262
+ (0, import_react30.useEffect)(() => {
89220
89263
  if (started.current) return;
89221
89264
  started.current = true;
89222
89265
  const projects = discoverProjects(process.cwd());
@@ -89243,11 +89286,11 @@ function useScan(config3) {
89243
89286
  scanProjects(projects, config3, dispatch);
89244
89287
  }
89245
89288
  }, [config3]);
89246
- const scanSelectedProjects = (0, import_react29.useCallback)((projects) => {
89289
+ const scanSelectedProjects = (0, import_react30.useCallback)((projects) => {
89247
89290
  dispatch({ type: "DISCOVERY_COMPLETE", packages: [], skippedCount: 0 });
89248
89291
  scanProjects(projects, config3, dispatch);
89249
89292
  }, [config3]);
89250
- const restartSelection = (0, import_react29.useCallback)(() => {
89293
+ const restartSelection = (0, import_react30.useCallback)(() => {
89251
89294
  if (!multiProjects) return;
89252
89295
  dispatch({ type: "RESTART_SELECTION", projects: multiProjects });
89253
89296
  }, [multiProjects]);
@@ -89367,11 +89410,11 @@ async function scanProjects(projects, config3, dispatch) {
89367
89410
  dispatch({ type: "ERROR", error: err });
89368
89411
  }
89369
89412
  }
89370
- var import_react29;
89413
+ var import_react30;
89371
89414
  var init_useScan = __esm({
89372
89415
  "src/ui/hooks/useScan.ts"() {
89373
89416
  "use strict";
89374
- import_react29 = __toESM(require_react());
89417
+ import_react30 = __toESM(require_react());
89375
89418
  init_lockfile();
89376
89419
  init_api3();
89377
89420
  init_discover();
@@ -89390,11 +89433,11 @@ function formatTime(seconds) {
89390
89433
  const s = seconds % 60;
89391
89434
  return s > 0 ? `${m}m ${s}s` : `${m}m`;
89392
89435
  }
89393
- var import_react30, import_chalk6, import_jsx_runtime9, ProgressBar;
89436
+ var import_react31, import_chalk6, import_jsx_runtime9, ProgressBar;
89394
89437
  var init_ProgressBar = __esm({
89395
89438
  async "src/ui/components/ProgressBar.tsx"() {
89396
89439
  "use strict";
89397
- import_react30 = __toESM(require_react());
89440
+ import_react31 = __toESM(require_react());
89398
89441
  await init_build2();
89399
89442
  await init_build3();
89400
89443
  import_chalk6 = __toESM(require_source());
@@ -89404,9 +89447,9 @@ var init_ProgressBar = __esm({
89404
89447
  total,
89405
89448
  label
89406
89449
  }) => {
89407
- const startRef = (0, import_react30.useRef)(Date.now());
89408
- const [elapsed, setElapsed] = (0, import_react30.useState)(0);
89409
- (0, import_react30.useEffect)(() => {
89450
+ const startRef = (0, import_react31.useRef)(Date.now());
89451
+ const [elapsed, setElapsed] = (0, import_react31.useState)(0);
89452
+ (0, import_react31.useEffect)(() => {
89410
89453
  const timer = setInterval(() => {
89411
89454
  setElapsed(Math.floor((Date.now() - startRef.current) / 1e3));
89412
89455
  }, 1e3);
@@ -89651,9 +89694,9 @@ var init_ScoreHeader = __esm({
89651
89694
 
89652
89695
  // src/ui/hooks/useExpandAnimation.ts
89653
89696
  function useExpandAnimation(targetHeight, active, durationMs = 180) {
89654
- const [visibleLines, setVisibleLines] = (0, import_react31.useState)(0);
89655
- const timerRef = (0, import_react31.useRef)(null);
89656
- (0, import_react31.useEffect)(() => {
89697
+ const [visibleLines, setVisibleLines] = (0, import_react32.useState)(0);
89698
+ const timerRef = (0, import_react32.useRef)(null);
89699
+ (0, import_react32.useEffect)(() => {
89657
89700
  if (timerRef.current) {
89658
89701
  clearInterval(timerRef.current);
89659
89702
  timerRef.current = null;
@@ -89687,45 +89730,11 @@ function useExpandAnimation(targetHeight, active, durationMs = 180) {
89687
89730
  isAnimating: active && visibleLines > 0 && visibleLines < targetHeight
89688
89731
  };
89689
89732
  }
89690
- var import_react31;
89733
+ var import_react32;
89691
89734
  var init_useExpandAnimation = __esm({
89692
89735
  "src/ui/hooks/useExpandAnimation.ts"() {
89693
- "use strict";
89694
- import_react31 = __toESM(require_react());
89695
- }
89696
- });
89697
-
89698
- // src/ui/hooks/useTerminalSize.ts
89699
- function useTerminalSize() {
89700
- const { stdout } = use_stdout_default();
89701
- const [size, setSize] = (0, import_react32.useState)({
89702
- rows: stdout?.rows ?? process.stdout.rows ?? 24,
89703
- cols: stdout?.columns ?? process.stdout.columns ?? 80
89704
- });
89705
- (0, import_react32.useEffect)(() => {
89706
- const handle = () => {
89707
- const rows = process.stdout.rows ?? 24;
89708
- const cols = process.stdout.columns ?? 80;
89709
- if (process.stdout.isTTY) {
89710
- process.stdout.write("\x1B[2J\x1B[H");
89711
- }
89712
- setSize({ rows, cols });
89713
- };
89714
- process.stdout.setMaxListeners(process.stdout.getMaxListeners() + 1);
89715
- process.stdout.on("resize", handle);
89716
- return () => {
89717
- process.stdout.off("resize", handle);
89718
- process.stdout.setMaxListeners(Math.max(0, process.stdout.getMaxListeners() - 1));
89719
- };
89720
- }, []);
89721
- return size;
89722
- }
89723
- var import_react32;
89724
- var init_useTerminalSize = __esm({
89725
- async "src/ui/hooks/useTerminalSize.ts"() {
89726
89736
  "use strict";
89727
89737
  import_react32 = __toESM(require_react());
89728
- await init_build2();
89729
89738
  }
89730
89739
  });
89731
89740
 
@@ -91897,7 +91906,7 @@ async function main() {
91897
91906
  return;
91898
91907
  }
91899
91908
  if (rawCommand === "status") {
91900
- const { getStoredApiKey: getStoredApiKey2, maskKey: maskKey2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
91909
+ const { getStoredApiKey: getStoredApiKey2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
91901
91910
  const chalk11 = (await Promise.resolve().then(() => __toESM(require_source()))).default;
91902
91911
  const apiKey = getStoredApiKey2();
91903
91912
  if (!apiKey) {
@@ -91905,7 +91914,7 @@ async function main() {
91905
91914
  `));
91906
91915
  return;
91907
91916
  }
91908
- process.stderr.write(chalk11.green(` Authenticated`) + chalk11.dim(` (key: ${maskKey2(apiKey)})
91917
+ process.stderr.write(chalk11.green(` Authenticated
91909
91918
  `));
91910
91919
  try {
91911
91920
  const { parseConfig: parseConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@westbayberry/dg",
3
- "version": "1.0.49",
3
+ "version": "1.0.51",
4
4
  "description": "Supply chain security scanner for npm and Python dependencies — detects malicious packages, typosquatting, dependency confusion, and 26+ attack patterns",
5
5
  "bin": {
6
6
  "dependency-guardian": "dist/index.mjs",