@hublo/sentinel 1.1.6 → 1.1.7

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.
@@ -17,7 +17,7 @@ import {
17
17
  registerAdapters,
18
18
  resolve,
19
19
  resolveBin
20
- } from "../chunk-RGIEWANO.js";
20
+ } from "../chunk-W73ISYMG.js";
21
21
 
22
22
  // bin/sentinel.ts
23
23
  import { program } from "commander";
@@ -110,20 +110,6 @@ function readNxProjectName(dir) {
110
110
  }
111
111
  }
112
112
 
113
- // src/shared/color.ts
114
- import { styleText } from "util";
115
- function palette(stream) {
116
- const paint = (format, text) => styleText(format, text, { stream });
117
- return {
118
- ok: (text) => paint(["green", "bold"], text),
119
- fail: (text) => paint(["red", "bold"], text),
120
- warn: (text) => paint("yellow", text),
121
- strong: (text) => paint("bold", text),
122
- dim: (text) => paint("dim", text),
123
- accent: (text) => paint("cyan", text)
124
- };
125
- }
126
-
127
113
  // src/core/domain.ts
128
114
  var VERBS = ["run", "inspect", "init", "migrate", "report", "status"];
129
115
  var TARGETS = [
@@ -138,6 +124,20 @@ var TARGETS = [
138
124
  ];
139
125
  var PRESET_NAMES = ["react", "nest", "svelte", "node", "tools"];
140
126
 
127
+ // src/shared/color.ts
128
+ import { styleText } from "util";
129
+ function palette(stream) {
130
+ const paint = (format, text) => styleText(format, text, { stream });
131
+ return {
132
+ ok: (text) => paint(["green", "bold"], text),
133
+ fail: (text) => paint(["red", "bold"], text),
134
+ warn: (text) => paint("yellow", text),
135
+ strong: (text) => paint("bold", text),
136
+ dim: (text) => paint("dim", text),
137
+ accent: (text) => paint("cyan", text)
138
+ };
139
+ }
140
+
141
141
  // src/roles/format/adapters/oxfmt/oxfmt.adapter.ts
142
142
  import { spawnSync } from "child_process";
143
143
  import { existsSync as existsSync10, readFileSync as readFileSync9 } from "fs";
@@ -941,6 +941,22 @@ var OxfmtAdapter = class extends BaseAdapter {
941
941
  appliesTo(_preset) {
942
942
  return true;
943
943
  }
944
+ /**
945
+ * The preset this module COMMITTED to, read from the `$sentinel` block it writes.
946
+ *
947
+ * Every other role implements this and format did not, so it was the only one answering from
948
+ * dependency detection alone. On an adopted Nest module whose own `.oxfmtrc.json` records
949
+ * `"preset": "nest"`, `--inspect` reported `flavour=node` — the module knew, and the role did
950
+ * not pass it on. Same command, four rows, two different answers about what the module is.
951
+ *
952
+ * It reads the RECORD rather than re-deriving: the block is what `--init` wrote, so it is the
953
+ * module's declaration, and a re-derivation from hoisted dependencies is exactly the wrong
954
+ * answer this exists to avoid.
955
+ */
956
+ declaredPreset(cwd) {
957
+ const declared = readFormatAdoption(cwd).preset;
958
+ return declared !== null && PRESET_NAMES.includes(declared) ? declared : void 0;
959
+ }
944
960
  plan(context) {
945
961
  if (!hasSourceFiles(context.cwd, FORMATTABLE_EXTENSIONS)) {
946
962
  return {
@@ -5232,13 +5248,26 @@ async function dispatch(opts) {
5232
5248
  const detected = resolveFlavour(opts);
5233
5249
  const adapter = resolve(opts.target, detected, opts.runner);
5234
5250
  const preset = opts.preset ?? adapter.declaredPreset?.(opts.cwd) ?? detected;
5235
- const contradiction = presetContradiction(preset, opts.cwd);
5236
- if (contradiction !== void 0) {
5237
- process.stderr.write(`sentinel (${opts.target}): ${contradiction}
5251
+ if (opts.preset !== void 0) {
5252
+ const contradiction = presetContradiction(opts.preset, opts.cwd);
5253
+ if (contradiction !== void 0) {
5254
+ process.stderr.write(`sentinel (${opts.target}): ${contradiction}
5238
5255
  `);
5239
- return 1;
5256
+ return 1;
5257
+ }
5240
5258
  }
5241
- const context = { cwd: opts.cwd, preset };
5259
+ let effective = preset;
5260
+ if (opts.preset === void 0 && adapter.declaredPreset?.(opts.cwd) === void 0) {
5261
+ const [signal] = presetSignals(opts.cwd);
5262
+ if (signal !== void 0 && signal.preset !== preset) {
5263
+ effective = signal.preset;
5264
+ process.stderr.write(
5265
+ ` detected "${preset}" from dependencies, but ${signal.evidence}, so adopting as "${signal.preset}". Pass --preset to override.
5266
+ `
5267
+ );
5268
+ }
5269
+ }
5270
+ const context = { cwd: opts.cwd, preset: effective };
5242
5271
  const plan2 = await adapter.plan(context);
5243
5272
  if (plan2.blocked) {
5244
5273
  process.stderr.write(`sentinel (${opts.target}): ${plan2.blocked}
@@ -5283,18 +5312,18 @@ export {
5283
5312
  readOwnVersion,
5284
5313
  readProjectPackageJson,
5285
5314
  readNxProjectName,
5315
+ VERBS,
5316
+ TARGETS,
5317
+ PRESET_NAMES,
5286
5318
  WORKSPACE_ROOT_MARKER,
5287
5319
  findWorkspaceRoot,
5288
5320
  ensureWorkspacePrep,
5289
5321
  inspectWorkspacePrep,
5290
5322
  palette,
5291
5323
  resolveBin,
5292
- VERBS,
5293
- TARGETS,
5294
- PRESET_NAMES,
5295
5324
  registerAdapters,
5296
5325
  describeFramework,
5297
5326
  detectFramework,
5298
5327
  dispatch
5299
5328
  };
5300
- //# sourceMappingURL=chunk-RGIEWANO.js.map
5329
+ //# sourceMappingURL=chunk-W73ISYMG.js.map
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  registerAdapters,
8
8
  resolve,
9
9
  setDefaultRunner
10
- } from "./chunk-RGIEWANO.js";
10
+ } from "./chunk-W73ISYMG.js";
11
11
  export {
12
12
  BaseAdapter,
13
13
  all,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hublo/sentinel",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "One CLI that guards code health across Hublo repos: shared lint/typescript/build/test presets, static & dynamic analysis, and architecture checks.",
5
5
  "type": "module",
6
6
  "license": "MIT",