@hublo/sentinel 1.2.0-alpha.2 → 1.2.0-alpha.4
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/dist/bin/sentinel.js
CHANGED
|
@@ -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-
|
|
24
|
+
} from "../chunk-6DBTDMSN.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 {
|
|
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 =
|
|
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 {
|
|
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
|
|
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
|
|
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) ??
|
|
281
|
+
value: { name: readNxProjectName(cwd) ?? basename2(cwd), private: true, ...value }
|
|
278
282
|
};
|
|
279
283
|
}
|
|
280
284
|
|
|
@@ -465,7 +469,7 @@ var BUILD_CONFIG_FILES = [
|
|
|
465
469
|
];
|
|
466
470
|
var BUILD_PRESET_SPECIFIER = "@hublo/sentinel/build/react";
|
|
467
471
|
var BUILD_SCRIPT_NAME = "build";
|
|
468
|
-
var SENTINEL_BUILD_COMMAND = "sentinel --run --build";
|
|
472
|
+
var SENTINEL_BUILD_COMMAND = "sentinel --run --build --";
|
|
469
473
|
var DEV_SCRIPT_NAME = "serve";
|
|
470
474
|
var SENTINEL_DEV_COMMAND = "sentinel --run --dev";
|
|
471
475
|
function buildTarget() {
|
|
@@ -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,10 +723,12 @@ function buildScripts(cwd) {
|
|
|
718
723
|
};
|
|
719
724
|
const existingDev = existingCommand(cwd, DEV_SCRIPT_NAME);
|
|
720
725
|
if (existingDev !== void 0) {
|
|
721
|
-
const own2 =
|
|
726
|
+
const own2 = moduleName(cwd);
|
|
722
727
|
scripts[DEV_SCRIPT_NAME] = composeDevScript(
|
|
723
728
|
existingDev,
|
|
724
|
-
|
|
729
|
+
// Trailing `--` for the same reason as the build script: whatever the caller appends
|
|
730
|
+
// reaches Vite, not sentinel's parser. It goes after `--module`, which is sentinel's own.
|
|
731
|
+
`${selfCommand(cwd, "--run --dev") ?? SENTINEL_DEV_COMMAND} --module ${own2} --`
|
|
725
732
|
);
|
|
726
733
|
}
|
|
727
734
|
return scripts;
|
|
@@ -929,6 +936,26 @@ var ViteDevAdapter = class extends ViteRoleAdapter {
|
|
|
929
936
|
get label() {
|
|
930
937
|
return "dev";
|
|
931
938
|
}
|
|
939
|
+
/**
|
|
940
|
+
* `--init --dev` does the same thing as `--init --build`, and now says so.
|
|
941
|
+
*
|
|
942
|
+
* The shared plan is deliberate (see `ViteRoleAdapter.plan`): one plan writes both scripts,
|
|
943
|
+
* because adopting one without the other leaves the module half-migrated. What was missing
|
|
944
|
+
* was only the telling: the run printed a message about the build and nothing about `serve`,
|
|
945
|
+
* so a developer could believe the dev server had been adopted on its own. Refusing was the
|
|
946
|
+
* wrong correction, it added friction to a command that already produced the right result.
|
|
947
|
+
*/
|
|
948
|
+
plan(context) {
|
|
949
|
+
const planned = super.plan(context);
|
|
950
|
+
if (planned.operations.length === 0) return planned;
|
|
951
|
+
return {
|
|
952
|
+
...planned,
|
|
953
|
+
notes: [
|
|
954
|
+
...planned.notes ?? [],
|
|
955
|
+
"--init --dev adopts the build too: one plan writes both `build` and `serve`."
|
|
956
|
+
]
|
|
957
|
+
};
|
|
958
|
+
}
|
|
932
959
|
/**
|
|
933
960
|
* Start the dev server. It does not return until stopped, so there is no verdict to report
|
|
934
961
|
* beyond the exit code the developer's own Ctrl-C produces.
|
|
@@ -6222,7 +6249,7 @@ export {
|
|
|
6222
6249
|
resolveBin,
|
|
6223
6250
|
readOwnVersion,
|
|
6224
6251
|
readProjectPackageJson,
|
|
6225
|
-
|
|
6252
|
+
moduleName,
|
|
6226
6253
|
VERBS,
|
|
6227
6254
|
TARGETS,
|
|
6228
6255
|
LONG_RUNNING_TARGETS,
|
|
@@ -6238,4 +6265,4 @@ export {
|
|
|
6238
6265
|
detectFramework,
|
|
6239
6266
|
dispatch
|
|
6240
6267
|
};
|
|
6241
|
-
//# sourceMappingURL=chunk-
|
|
6268
|
+
//# sourceMappingURL=chunk-6DBTDMSN.js.map
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hublo/sentinel",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.4",
|
|
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",
|