@pho9ubenaa/siro 0.1.3 → 0.3.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 +36 -0
- package/README.md +3 -2
- package/dist/cli.js +2 -3
- package/dist/cli.mjs +428 -3
- package/dist/index.d.mts +36 -38
- package/dist/index.mjs +8 -1
- package/dist/node-io-CUcMwlGH.mjs +2578 -0
- package/package.json +4 -4
- package/dist/node-io-BLwef7p6.mjs +0 -4
package/dist/index.d.mts
CHANGED
|
@@ -47,7 +47,8 @@ interface IO {
|
|
|
47
47
|
declare const nodeIO: IO;
|
|
48
48
|
//#endregion
|
|
49
49
|
//#region src/domain/entities/config-value.d.ts
|
|
50
|
-
|
|
50
|
+
declare const CODEC_KINDS: readonly ["json", "npmrc", "toml", "yaml"];
|
|
51
|
+
type CodecKind = (typeof CODEC_KINDS)[number];
|
|
51
52
|
/** Scalar value that can be written back to a config file. */
|
|
52
53
|
type ConfigValue = string | number | boolean;
|
|
53
54
|
/** Scalar value as it appears when reading (codecs may produce `null`). */
|
|
@@ -106,6 +107,10 @@ declare const PackageJsonSchema: vb.LooseObjectSchema<{
|
|
|
106
107
|
}, undefined>;
|
|
107
108
|
type PackageJson = vb.InferOutput<typeof PackageJsonSchema>;
|
|
108
109
|
//#endregion
|
|
110
|
+
//#region src/domain/entities/project-type.d.ts
|
|
111
|
+
declare const PROJECT_TYPES: readonly ["application", "package"];
|
|
112
|
+
type ProjectType = (typeof PROJECT_TYPES)[number];
|
|
113
|
+
//#endregion
|
|
109
114
|
//#region src/domain/ports/repo-context.d.ts
|
|
110
115
|
/** Read-only view of a repository, passed to every rule's `check` and `fix`. */
|
|
111
116
|
interface RepoContext {
|
|
@@ -113,6 +118,7 @@ interface RepoContext {
|
|
|
113
118
|
exists: (relPath: RelPath) => boolean;
|
|
114
119
|
readText: (relPath: RelPath) => string | undefined;
|
|
115
120
|
readonly packageJson: PackageJson | undefined;
|
|
121
|
+
readonly projectType?: ProjectType;
|
|
116
122
|
}
|
|
117
123
|
//#endregion
|
|
118
124
|
//#region src/domain/entities/rule.d.ts
|
|
@@ -178,6 +184,12 @@ type FixOp = {
|
|
|
178
184
|
* - `advisory`: `fix` only produces notes/ensureFileTracked hints.
|
|
179
185
|
*/
|
|
180
186
|
type FixKind = 'auto' | 'advisory';
|
|
187
|
+
/** Display-only package-manager version metadata. */
|
|
188
|
+
interface VersionNote {
|
|
189
|
+
readonly configAvailableSince?: string;
|
|
190
|
+
readonly defaultSafeSince?: string;
|
|
191
|
+
readonly note?: string;
|
|
192
|
+
}
|
|
181
193
|
type SetKeyOp = Extract<FixOp, {
|
|
182
194
|
op: 'setKey';
|
|
183
195
|
}>;
|
|
@@ -197,6 +209,7 @@ interface AutoRuleBinding {
|
|
|
197
209
|
* override always wins over both.
|
|
198
210
|
*/
|
|
199
211
|
readonly severity?: Severity;
|
|
212
|
+
readonly versionNote?: VersionNote;
|
|
200
213
|
check: (ctx: RepoContext, config: ParsedConfig) => CheckStatus;
|
|
201
214
|
fix: (ctx: RepoContext) => readonly SetKeyOp[];
|
|
202
215
|
}
|
|
@@ -207,17 +220,20 @@ interface AdvisoryRuleBinding {
|
|
|
207
220
|
readonly docs?: string;
|
|
208
221
|
/** See {@link AutoRuleBinding.severity}. */
|
|
209
222
|
readonly severity?: Severity;
|
|
223
|
+
readonly versionNote?: VersionNote;
|
|
210
224
|
check: (ctx: RepoContext, config: ParsedConfig) => CheckStatus;
|
|
211
225
|
fix: (ctx: RepoContext) => readonly AdvisoryOp[];
|
|
212
226
|
}
|
|
213
227
|
type RuleBinding = AutoRuleBinding | AdvisoryRuleBinding;
|
|
214
228
|
/** A package-manager-agnostic security intent, realized per PM via `bindings`. */
|
|
215
|
-
interface Rule {
|
|
216
|
-
readonly id:
|
|
229
|
+
interface Rule<Id extends string = string> {
|
|
230
|
+
readonly id: Id;
|
|
217
231
|
readonly title: string;
|
|
218
232
|
readonly description: string;
|
|
219
233
|
readonly severity: Severity;
|
|
220
234
|
readonly docs?: string;
|
|
235
|
+
/** Project types this rule applies to; omission means both types. */
|
|
236
|
+
readonly projectTypes?: readonly ProjectType[];
|
|
221
237
|
/** Absence of a PM key means the rule does not apply (N/A) to that PM. */
|
|
222
238
|
readonly bindings: Partial<Record<PM, RuleBinding>>;
|
|
223
239
|
}
|
|
@@ -317,6 +333,8 @@ interface LintOptions {
|
|
|
317
333
|
cwd: AbsPath;
|
|
318
334
|
/** Restrict to a single PM; otherwise PMs are auto-detected. */
|
|
319
335
|
pm?: PM;
|
|
336
|
+
/** Select application or published-package policy; otherwise infer it. */
|
|
337
|
+
projectType?: ProjectType;
|
|
320
338
|
/** Reporter name or instance; defaults to `pretty`. */
|
|
321
339
|
reporter?: string | Reporter;
|
|
322
340
|
/** Extra reporters to make available by name (merged with the user config). */
|
|
@@ -334,7 +352,7 @@ interface LintOptions {
|
|
|
334
352
|
severity?: Severity;
|
|
335
353
|
/**
|
|
336
354
|
* Inject a non-default FS (e.g. memfs in tests). Caveat: `siro.config.{ts,mjs,js}`
|
|
337
|
-
* is
|
|
355
|
+
* is imported from the REAL disk — only the config's existence is probed
|
|
338
356
|
* through this FS. A config that lives solely in an injected FS won't load.
|
|
339
357
|
*/
|
|
340
358
|
fs?: FileSystem;
|
|
@@ -431,13 +449,9 @@ declare const PM_SIGNALS: {
|
|
|
431
449
|
};
|
|
432
450
|
};
|
|
433
451
|
//#endregion
|
|
434
|
-
//#region src/domain/
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
* type `rules` keys without depending on the engine.
|
|
438
|
-
*/
|
|
439
|
-
declare const BUILTIN_RULE_IDS: readonly ["advisory-check", "approved-git-repos", "audit-suppression", "block-auto-install", "block-exotic-subdeps", "bun-security-scanner", "checksum-verification", "commit-lockfile", "dependency-overrides", "disable-lifecycle-scripts", "enforce-strict-ssl", "files-field", "frozen-lockfile", "frozen-store", "hardened-mode", "minimum-release-age", "named-registries", "paranoid-mode", "patched-dependencies", "pin-exact-versions", "provenance", "publish-access", "store-server", "strict-allow-scripts", "strict-release-age", "strict-store-integrity", "trust-policy"];
|
|
440
|
-
type BuiltinRuleId = (typeof BUILTIN_RULE_IDS)[number];
|
|
452
|
+
//#region src/domain/builtin-rules.d.ts
|
|
453
|
+
declare const rules: readonly [Rule<"advisory-check">, Rule<"approved-git-repos">, Rule<"audit-suppression">, Rule<"block-auto-install">, Rule<"block-exotic-subdeps">, Rule<"bun-security-scanner">, Rule<"checksum-verification">, Rule<"commit-lockfile">, Rule<"dependency-overrides">, Rule<"disable-lifecycle-scripts">, Rule<"enforce-strict-ssl">, Rule<"files-field">, Rule<"frozen-lockfile">, Rule<"frozen-store">, Rule<"hardened-mode">, Rule<"minimum-release-age">, Rule<"named-registries">, Rule<"paranoid-mode">, Rule<"patched-dependencies">, Rule<"pin-exact-versions">, Rule<"provenance">, Rule<"publish-access">, Rule<"store-server">, Rule<"strict-allow-scripts">, Rule<"strict-release-age">, Rule<"strict-store-integrity">, Rule<"trust-policy">];
|
|
454
|
+
type BuiltinRuleId = (typeof rules)[number]['id'];
|
|
441
455
|
//#endregion
|
|
442
456
|
//#region src/domain/entities/siro-config.d.ts
|
|
443
457
|
/** Per-rule setting. `'off'` disables; a Severity overrides the default level. */
|
|
@@ -454,6 +468,7 @@ type RuleSetting = Severity | 'off';
|
|
|
454
468
|
*/
|
|
455
469
|
interface SiroConfig {
|
|
456
470
|
readonly pms?: readonly PM[];
|
|
471
|
+
readonly projectType?: ProjectType;
|
|
457
472
|
readonly rules?: Readonly<Partial<Record<BuiltinRuleId | (string & Record<never, never>), RuleSetting>>>;
|
|
458
473
|
readonly customRules?: readonly Rule[];
|
|
459
474
|
readonly reporters?: readonly Reporter[];
|
|
@@ -470,21 +485,6 @@ interface ConfigCodec {
|
|
|
470
485
|
type CodecFor = (kind: CodecKind) => ConfigCodec;
|
|
471
486
|
//#endregion
|
|
472
487
|
//#region src/domain/rules/builders/require-config-key.d.ts
|
|
473
|
-
/**
|
|
474
|
-
* Display-only metadata for a binding. siro itself is intentionally
|
|
475
|
-
* version-agnostic (we never branch on the user's actual PM version) — these
|
|
476
|
-
* fields exist so the rendered message can still tell the reader *when* a key
|
|
477
|
-
* appeared and *when* the PM started shipping a safe default. They MUST NOT
|
|
478
|
-
* be consulted by any code path that decides severity or applicability.
|
|
479
|
-
*/
|
|
480
|
-
interface VersionNote {
|
|
481
|
-
/** PM version that first shipped this config key (e.g. `'pnpm 10.16.0'`). */
|
|
482
|
-
readonly configAvailableSince?: string;
|
|
483
|
-
/** PM version whose built-in default first satisfies the rule (e.g. `'pnpm 11.0.0 (1440 minutes)'`). */
|
|
484
|
-
readonly defaultSafeSince?: string;
|
|
485
|
-
/** Free-form trailing note rendered last (e.g. `'replaces auto-install-peers'`). */
|
|
486
|
-
readonly note?: string;
|
|
487
|
-
}
|
|
488
488
|
interface RequireConfigKeySpec {
|
|
489
489
|
readonly file: ConfigFileRef;
|
|
490
490
|
readonly keyPath: KeyPath;
|
|
@@ -524,12 +524,13 @@ interface RequireConfigKeySpec {
|
|
|
524
524
|
readonly defaultSatisfiedSeverity?: Severity | 'off';
|
|
525
525
|
readonly versionNote?: VersionNote;
|
|
526
526
|
}
|
|
527
|
-
interface RequireConfigKeyOptions {
|
|
528
|
-
readonly id:
|
|
527
|
+
interface RequireConfigKeyOptions<Id extends string = string> {
|
|
528
|
+
readonly id: Id;
|
|
529
529
|
readonly title: string;
|
|
530
530
|
readonly description: string;
|
|
531
531
|
readonly severity: Severity;
|
|
532
532
|
readonly docs?: string;
|
|
533
|
+
readonly projectTypes?: Rule['projectTypes'];
|
|
533
534
|
/** Bindings keyed by PM. PMs absent from this map are treated as N/A. */
|
|
534
535
|
readonly bindings: Partial<Record<PM, RequireConfigKeySpec>>;
|
|
535
536
|
/** Return false to short-circuit `check` as N/A (e.g. private packages). */
|
|
@@ -542,10 +543,12 @@ interface RequireConfigKeyOptions {
|
|
|
542
543
|
* the hand-written bindings in via this helper rather than rebuilding from
|
|
543
544
|
* scratch or mutating the source rule.
|
|
544
545
|
*/
|
|
545
|
-
declare const overrideBindings: (rule: Rule
|
|
546
|
-
declare const renderVersionNoteMessage: (message: string, versionNote: VersionNote | undefined) => string;
|
|
546
|
+
declare const overrideBindings: <Id extends string>(rule: Rule<Id>, overrides: Partial<Rule["bindings"]>) => Rule<Id>;
|
|
547
547
|
/** Build a Rule from a per-PM table of {file, keyPath, value, message}. */
|
|
548
|
-
declare const requireConfigKey: (options: RequireConfigKeyOptions) => Rule
|
|
548
|
+
declare const requireConfigKey: <const Id extends string>(options: RequireConfigKeyOptions<Id>) => Rule<Id>;
|
|
549
|
+
//#endregion
|
|
550
|
+
//#region src/domain/services/render-version-note.d.ts
|
|
551
|
+
declare const renderVersionNoteMessage: (message: string, versionNote: VersionNote | undefined) => string;
|
|
549
552
|
//#endregion
|
|
550
553
|
//#region src/domain/services/detect-pms.d.ts
|
|
551
554
|
declare const detectPMs: (ctx: RepoContext) => PM[];
|
|
@@ -565,11 +568,6 @@ declare const exitCodeForLint: (result: LintResult, threshold?: Severity) => num
|
|
|
565
568
|
* place so individual commands never have to think about exit semantics.
|
|
566
569
|
* The exit-code table lives in docs/configuration.md S"Exit codes" and
|
|
567
570
|
* src/cli/help.ts (HELP_LINT) -- not restated here.
|
|
568
|
-
*
|
|
569
|
-
* One mapping note that belongs at this altitude: filesystem errno errors
|
|
570
|
-
* are routed to 2 by SHAPE (numeric `errno`) in cli run(), so an
|
|
571
|
-
* errno-bearing throw from a user extension also lands on 2 rather than the
|
|
572
|
-
* 70 crash path -- same remedy (fix the environment) either way.
|
|
573
571
|
*/
|
|
574
572
|
declare class SiroError extends Error {
|
|
575
573
|
/** Recommended process exit code for this error. */
|
|
@@ -599,7 +597,7 @@ declare class UsageError extends SiroError {
|
|
|
599
597
|
declare const wrapCodecError: <TResult>(filePath: string, fn: () => TResult) => TResult;
|
|
600
598
|
//#endregion
|
|
601
599
|
//#region src/version.d.ts
|
|
602
|
-
declare const version = "0.
|
|
600
|
+
declare const version = "0.3.0";
|
|
603
601
|
//#endregion
|
|
604
|
-
export { type AbsPath, type AdvisoryRuleBinding, type AutoRuleBinding, BUILTIN_REPORTER_NAMES, type BuiltinReporterName, CONFIG_FILES, type CheckStatus, type CodecFor, type ConfigCodec, ConfigError, type ConfigFileRef, type ConfigReadValue, type ConfigScalar, type ConfigValue, type FileSystem, type Finding, type FixKind, type FixOp, type IO, type KeyAssignment, type KeyPath, type LintOptions, type LintResult, type PM, PMS, type PMSignals, PM_SIGNALS, type PackageJson, type ParsedConfig, type RelPath, type RepoContext, type Reporter, type ReporterRegistry, type RequireConfigKeyOptions, type Rule, type RuleBinding, type RuleSetting, SEVERITIES, type Severity, type SiroConfig, SiroError, UsageError, type VersionNote, asAbsPath, asRelPath, createRegistry, defineConfig, detectPMs, exitCodeForLint, filterBySeverity, getByPath, githubReporter, isPM, isReporterShape, isSeverity, jsonReporter, lintCommand, nodeFileSystem, nodeIO, overrideBindings, prettyReporter, renderVersionNoteMessage, requireConfigKey, version, wrapCodecError };
|
|
602
|
+
export { type AbsPath, type AdvisoryRuleBinding, type AutoRuleBinding, BUILTIN_REPORTER_NAMES, type BuiltinReporterName, CONFIG_FILES, type CheckStatus, type CodecFor, type ConfigCodec, ConfigError, type ConfigFileRef, type ConfigReadValue, type ConfigScalar, type ConfigValue, type FileSystem, type Finding, type FixKind, type FixOp, type IO, type KeyAssignment, type KeyPath, type LintOptions, type LintResult, type PM, PMS, type PMSignals, PM_SIGNALS, PROJECT_TYPES, type PackageJson, type ParsedConfig, type ProjectType, type RelPath, type RepoContext, type Reporter, type ReporterRegistry, type RequireConfigKeyOptions, type Rule, type RuleBinding, type RuleSetting, SEVERITIES, type Severity, type SiroConfig, SiroError, UsageError, type VersionNote, asAbsPath, asRelPath, createRegistry, defineConfig, detectPMs, exitCodeForLint, filterBySeverity, getByPath, githubReporter, isPM, isReporterShape, isSeverity, jsonReporter, lintCommand, nodeFileSystem, nodeIO, overrideBindings, prettyReporter, renderVersionNoteMessage, requireConfigKey, version, wrapCodecError };
|
|
605
603
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
import{A as
|
|
1
|
+
import { A as isSeverity, C as jsonReporter, D as PMS, E as isReporterShape, F as asAbsPath, I as asRelPath, M as UsageError, N as ConfigError, O as SEVERITIES, P as SiroError, S as prettyReporter, T as githubReporter, a as nodeFileSystem, c as requireConfigKey, d as exitCodeForLint, f as filterBySeverity, i as detectPMs, j as wrapCodecError, k as isPM, l as CONFIG_FILES, m as PROJECT_TYPES, n as lintCommand, o as PM_SIGNALS, r as renderVersionNoteMessage, s as overrideBindings, t as nodeIO, u as getByPath, v as BUILTIN_REPORTER_NAMES, w as version, x as createRegistry } from "./node-io-CUcMwlGH.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/domain/entities/siro-config.ts
|
|
4
|
+
/** Identity helper for type-checked config files. */
|
|
5
|
+
const defineConfig = (config) => config;
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { BUILTIN_REPORTER_NAMES, CONFIG_FILES, ConfigError, PMS, PM_SIGNALS, PROJECT_TYPES, SEVERITIES, SiroError, UsageError, asAbsPath, asRelPath, createRegistry, defineConfig, detectPMs, exitCodeForLint, filterBySeverity, getByPath, githubReporter, isPM, isReporterShape, isSeverity, jsonReporter, lintCommand, nodeFileSystem, nodeIO, overrideBindings, prettyReporter, renderVersionNoteMessage, requireConfigKey, version, wrapCodecError };
|
|
2
9
|
//# sourceMappingURL=index.mjs.map
|