@hublo/sentinel 1.2.0-alpha.2 → 1.2.0-alpha.3

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.
@@ -14,21 +14,21 @@ import {
14
14
  ensureWorkspacePrep,
15
15
  findWorkspaceRoot,
16
16
  inspectWorkspacePrep,
17
+ moduleName,
17
18
  palette,
18
- readNxProjectName,
19
19
  readOwnVersion,
20
20
  readProjectPackageJson,
21
21
  registerAdapters,
22
22
  resolve,
23
23
  resolveBin
24
- } from "../chunk-SA2RMTVI.js";
24
+ } from "../chunk-YZ4EKBK7.js";
25
25
 
26
26
  // bin/sentinel.ts
27
27
  import { program } from "commander";
28
28
 
29
29
  // src/core/context.ts
30
30
  import { existsSync } from "fs";
31
- import { basename, join as join2 } from "path";
31
+ import { join as join2 } from "path";
32
32
 
33
33
  // src/core/discover-modules.ts
34
34
  import { execFileSync } from "child_process";
@@ -96,7 +96,7 @@ function resolveContext(cwd2, opts2) {
96
96
  if (opts2.ci) {
97
97
  throw new Error("--ci selects the affected set from the workspace root; run it there.");
98
98
  }
99
- const name = readNxProjectName(cwd2) ?? basename(cwd2);
99
+ const name = moduleName(cwd2);
100
100
  return { modules: [{ name, root: cwd2 }], scope: "cwd-module" };
101
101
  }
102
102
  if (atRoot) {
@@ -82,7 +82,7 @@ var BaseAdapter = class {
82
82
 
83
83
  // src/shared/package-json.ts
84
84
  import { existsSync, readFileSync } from "fs";
85
- import { dirname, join } from "path";
85
+ import { basename, dirname, join } from "path";
86
86
  import { fileURLToPath } from "url";
87
87
  function readOwnPackage() {
88
88
  let dir = dirname(fileURLToPath(import.meta.url));
@@ -127,6 +127,10 @@ function readNxProjectName(dir) {
127
127
  return void 0;
128
128
  }
129
129
  }
130
+ function moduleName(dir) {
131
+ const declared = readProjectPackageJson(dir).name;
132
+ return readNxProjectName(dir) ?? (declared === void 0 ? basename(dir) : declared);
133
+ }
130
134
 
131
135
  // src/core/domain.ts
132
136
  var VERBS = ["run", "inspect", "init", "migrate", "report", "status"];
@@ -217,7 +221,7 @@ function binSearchPath(cwd) {
217
221
 
218
222
  // src/roles/build/plan.ts
219
223
  import { existsSync as existsSync7, readFileSync as readFileSync5 } from "fs";
220
- import { basename as basename2, join as join7 } from "path";
224
+ import { join as join7 } from "path";
221
225
 
222
226
  // src/core/config/existing-command.ts
223
227
  import { readFileSync as readFileSync3 } from "fs";
@@ -237,7 +241,7 @@ function parseJsonc(text, source = "config") {
237
241
 
238
242
  // src/core/config/manifest.ts
239
243
  import { existsSync as existsSync4, readFileSync as readFileSync2 } from "fs";
240
- import { basename, join as join3 } from "path";
244
+ import { basename as basename2, join as join3 } from "path";
241
245
  function moduleScripts(cwd) {
242
246
  try {
243
247
  const pkg = JSON.parse(readFileSync2(join3(cwd, "package.json"), "utf8"));
@@ -246,7 +250,7 @@ function moduleScripts(cwd) {
246
250
  return {};
247
251
  }
248
252
  }
249
- function moduleName(cwd) {
253
+ function moduleName2(cwd) {
250
254
  try {
251
255
  const pkg = JSON.parse(readFileSync2(join3(cwd, "package.json"), "utf8"));
252
256
  return pkg.name;
@@ -255,7 +259,7 @@ function moduleName(cwd) {
255
259
  }
256
260
  }
257
261
  function isSelfAdoption(cwd) {
258
- return moduleName(cwd) === readOwnPackage().name;
262
+ return moduleName2(cwd) === readOwnPackage().name;
259
263
  }
260
264
  function selfCommand(cwd, flags) {
261
265
  const own = readOwnPackage();
@@ -274,7 +278,7 @@ function manifestOperation(cwd, scripts) {
274
278
  return {
275
279
  kind: "merge-json",
276
280
  path: "package.json",
277
- value: { name: readNxProjectName(cwd) ?? basename(cwd), private: true, ...value }
281
+ value: { name: readNxProjectName(cwd) ?? basename2(cwd), private: true, ...value }
278
282
  };
279
283
  }
280
284
 
@@ -526,6 +530,7 @@ var REACT_PLUGIN_SPECIFIERS = ["@vitejs/plugin-react", "@tanstack/react-start"];
526
530
  function declaredBuildPreset(cwd) {
527
531
  const source = readBuildConfigSource(cwd);
528
532
  if (source === void 0) return void 0;
533
+ if (importsPreset(source)) return "react";
529
534
  return REACT_PLUGIN_SPECIFIERS.some((specifier) => importsSpecifier(source, specifier)) ? "react" : void 0;
530
535
  }
531
536
  function readBuildConfigSource(cwd) {
@@ -718,7 +723,7 @@ function buildScripts(cwd) {
718
723
  };
719
724
  const existingDev = existingCommand(cwd, DEV_SCRIPT_NAME);
720
725
  if (existingDev !== void 0) {
721
- const own2 = basename2(cwd);
726
+ const own2 = moduleName(cwd);
722
727
  scripts[DEV_SCRIPT_NAME] = composeDevScript(
723
728
  existingDev,
724
729
  `${selfCommand(cwd, "--run --dev") ?? SENTINEL_DEV_COMMAND} --module ${own2}`
@@ -929,6 +934,24 @@ var ViteDevAdapter = class extends ViteRoleAdapter {
929
934
  get label() {
930
935
  return "dev";
931
936
  }
937
+ /**
938
+ * There is no such thing as adopting the dev server on its own.
939
+ *
940
+ * `ViteRoleAdapter.plan()` is shared with `--build` because everything else about the two
941
+ * targets is shared, and inheriting it here made `--init --dev` perform the FULL build
942
+ * adoption, silently, under a message that only ever mentioned the build. Exiting 0 on that
943
+ * is the worst of the options: it teaches that dev can be adopted by itself, and that belief
944
+ * is what produces the half-migrated module this role exists to prevent (see the class
945
+ * comment above, and `registerBuild`).
946
+ *
947
+ * A single plan writes both scripts, so the honest answer is to name the command that does
948
+ * it rather than to do it under a different name.
949
+ */
950
+ plan() {
951
+ throw new Error(
952
+ "the dev server is adopted together with the build, never on its own. Run --init --build: one plan writes both the `build` and the `serve` scripts."
953
+ );
954
+ }
932
955
  /**
933
956
  * Start the dev server. It does not return until stopped, so there is no verdict to report
934
957
  * beyond the exit code the developer's own Ctrl-C produces.
@@ -6222,7 +6245,7 @@ export {
6222
6245
  resolveBin,
6223
6246
  readOwnVersion,
6224
6247
  readProjectPackageJson,
6225
- readNxProjectName,
6248
+ moduleName,
6226
6249
  VERBS,
6227
6250
  TARGETS,
6228
6251
  LONG_RUNNING_TARGETS,
@@ -6238,4 +6261,4 @@ export {
6238
6261
  detectFramework,
6239
6262
  dispatch
6240
6263
  };
6241
- //# sourceMappingURL=chunk-SA2RMTVI.js.map
6264
+ //# sourceMappingURL=chunk-YZ4EKBK7.js.map
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  registerAdapters,
8
8
  resolve,
9
9
  setDefaultRunner
10
- } from "./chunk-SA2RMTVI.js";
10
+ } from "./chunk-YZ4EKBK7.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.2.0-alpha.2",
3
+ "version": "1.2.0-alpha.3",
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",