@pieai/pro-gov 0.7.0 → 0.7.1
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/cli.js +58 -9
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -3471,12 +3471,13 @@ function validateVersionPolicy(value, projectTypes, issues) {
|
|
|
3471
3471
|
issues.push({ type: "invalid-field", field: "technologyGovernance.versionPolicy", message: "Technology versionPolicy must be an object." });
|
|
3472
3472
|
return;
|
|
3473
3473
|
}
|
|
3474
|
-
validateAllowedFields(value, "versionPolicy", ["schemaVersion", "packageManager", "runtime", "packages"], issues);
|
|
3474
|
+
validateAllowedFields(value, "versionPolicy", ["schemaVersion", "packageManager", "runtime", "runtimes", "packages"], issues);
|
|
3475
3475
|
if (value.schemaVersion !== 1) {
|
|
3476
3476
|
issues.push({ type: "invalid-field", field: "technologyGovernance.versionPolicy.schemaVersion", message: "Technology versionPolicy schemaVersion must be 1." });
|
|
3477
3477
|
}
|
|
3478
3478
|
validateVersionRequirement(value.packageManager, "technologyGovernance.versionPolicy.packageManager", issues);
|
|
3479
3479
|
validateVersionRequirement(value.runtime, "technologyGovernance.versionPolicy.runtime", issues);
|
|
3480
|
+
validateRuntimeRequirements(value.runtimes, projectTypes, issues);
|
|
3480
3481
|
if (!Array.isArray(value.packages)) {
|
|
3481
3482
|
issues.push({ type: "invalid-field", field: "technologyGovernance.versionPolicy.packages", message: "Technology versionPolicy packages must be an array." });
|
|
3482
3483
|
return;
|
|
@@ -3507,6 +3508,39 @@ function validateVersionPolicy(value, projectTypes, issues) {
|
|
|
3507
3508
|
}
|
|
3508
3509
|
}
|
|
3509
3510
|
}
|
|
3511
|
+
function validateRuntimeRequirements(value, projectTypes, issues) {
|
|
3512
|
+
if (value === void 0) return;
|
|
3513
|
+
const field = "technologyGovernance.versionPolicy.runtimes";
|
|
3514
|
+
if (!Array.isArray(value)) {
|
|
3515
|
+
issues.push({ type: "invalid-field", field, message: "Technology versionPolicy runtimes must be an array." });
|
|
3516
|
+
return;
|
|
3517
|
+
}
|
|
3518
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3519
|
+
for (const entry of value) {
|
|
3520
|
+
if (!isRecord(entry)) {
|
|
3521
|
+
issues.push({ type: "invalid-field", field, message: "Version policy runtime entries must be objects." });
|
|
3522
|
+
continue;
|
|
3523
|
+
}
|
|
3524
|
+
validateAllowedFields(entry, "versionPolicy.runtimeEntry", ["name", "version", "appliesTo"], issues);
|
|
3525
|
+
const name = typeof entry.name === "string" ? entry.name : "";
|
|
3526
|
+
if (!name || seen.has(name)) {
|
|
3527
|
+
issues.push({ type: "invalid-field", field: `${field}.name`, message: `Version policy runtime name must be non-empty and unique: ${String(entry.name)}` });
|
|
3528
|
+
} else seen.add(name);
|
|
3529
|
+
if (typeof entry.version !== "string" || !isExactVersion(entry.version)) {
|
|
3530
|
+
issues.push({ type: "invalid-field", field: `${field}.version`, message: `Version policy runtime version must be exact semver: ${String(entry.version)}` });
|
|
3531
|
+
}
|
|
3532
|
+
if (entry.appliesTo !== void 0) {
|
|
3533
|
+
validateOptionalStringArray(entry.appliesTo, name, `${field}.appliesTo`, issues);
|
|
3534
|
+
if (Array.isArray(entry.appliesTo)) {
|
|
3535
|
+
for (const projectType of entry.appliesTo) {
|
|
3536
|
+
if (typeof projectType === "string" && !projectTypes.has(projectType)) {
|
|
3537
|
+
issues.push({ type: "invalid-field", field: `${field}.appliesTo`, message: `Version policy references unknown project type: ${projectType}` });
|
|
3538
|
+
}
|
|
3539
|
+
}
|
|
3540
|
+
}
|
|
3541
|
+
}
|
|
3542
|
+
}
|
|
3543
|
+
}
|
|
3510
3544
|
function validateVersionRequirement(value, field, issues) {
|
|
3511
3545
|
if (value === void 0) return;
|
|
3512
3546
|
if (!isRecord(value)) {
|
|
@@ -3697,7 +3731,7 @@ function isRecord(value) {
|
|
|
3697
3731
|
}
|
|
3698
3732
|
|
|
3699
3733
|
// src/portfolio/doctor.ts
|
|
3700
|
-
import { spawnSync as
|
|
3734
|
+
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
3701
3735
|
import { existsSync as existsSync22, readFileSync as readFileSync16 } from "node:fs";
|
|
3702
3736
|
import { createRequire as createRequire2 } from "node:module";
|
|
3703
3737
|
import { homedir as homedir3 } from "node:os";
|
|
@@ -3874,13 +3908,20 @@ function pathIsSymlink(path) {
|
|
|
3874
3908
|
}
|
|
3875
3909
|
|
|
3876
3910
|
// src/portfolio/version-policy.ts
|
|
3911
|
+
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
3877
3912
|
import { existsSync as existsSync21, readFileSync as readFileSync15 } from "node:fs";
|
|
3878
3913
|
import { join as join22 } from "node:path";
|
|
3879
3914
|
function inspectVersionPolicy(root, policy, projectType) {
|
|
3880
|
-
if (!policy) return { status: "compliant", packages: [], attentionCount: 0 };
|
|
3915
|
+
if (!policy) return { status: "compliant", packages: [], runtimes: [], attentionCount: 0 };
|
|
3881
3916
|
const packageJson = readJson2(join22(root, "package.json"));
|
|
3882
3917
|
const packageManager = policy.packageManager ? inspectPackageManager(packageJson, policy.packageManager.name, policy.packageManager.version) : void 0;
|
|
3883
3918
|
const runtime = policy.runtime ? inspectRuntime(policy.runtime.name, policy.runtime.version) : void 0;
|
|
3919
|
+
const runtimes = (policy.runtimes ?? []).map((requirement) => {
|
|
3920
|
+
if (requirement.appliesTo && (!projectType || !requirement.appliesTo.includes(projectType))) {
|
|
3921
|
+
return { name: requirement.name, expected: requirement.version, status: "not-applicable" };
|
|
3922
|
+
}
|
|
3923
|
+
return inspectRuntime(requirement.name, requirement.version);
|
|
3924
|
+
});
|
|
3884
3925
|
const packages = policy.packages.map((requirement) => {
|
|
3885
3926
|
if (requirement.appliesTo && (!projectType || !requirement.appliesTo.includes(projectType))) {
|
|
3886
3927
|
return { name: requirement.name, expected: requirement.version, status: "not-applicable" };
|
|
@@ -3897,12 +3938,13 @@ function inspectVersionPolicy(root, policy, projectType) {
|
|
|
3897
3938
|
status
|
|
3898
3939
|
};
|
|
3899
3940
|
});
|
|
3900
|
-
const all = [packageManager, runtime, ...packages].filter((item) => item !== void 0);
|
|
3941
|
+
const all = [packageManager, runtime, ...runtimes, ...packages].filter((item) => item !== void 0);
|
|
3901
3942
|
const attentionCount = all.filter((item) => item.status !== "compliant" && item.status !== "not-applicable").length;
|
|
3902
3943
|
return {
|
|
3903
3944
|
status: attentionCount === 0 ? "compliant" : "attention",
|
|
3904
3945
|
packageManager,
|
|
3905
3946
|
runtime,
|
|
3947
|
+
runtimes,
|
|
3906
3948
|
packages,
|
|
3907
3949
|
attentionCount
|
|
3908
3950
|
};
|
|
@@ -3919,7 +3961,7 @@ function inspectPackageManager(packageJson, expectedName, expectedVersion) {
|
|
|
3919
3961
|
};
|
|
3920
3962
|
}
|
|
3921
3963
|
function inspectRuntime(expectedName, expectedVersion) {
|
|
3922
|
-
const actual = expectedName
|
|
3964
|
+
const actual = readRuntimeVersion(expectedName);
|
|
3923
3965
|
return {
|
|
3924
3966
|
name: expectedName,
|
|
3925
3967
|
expected: expectedVersion,
|
|
@@ -3927,6 +3969,13 @@ function inspectRuntime(expectedName, expectedVersion) {
|
|
|
3927
3969
|
status: actual === void 0 ? "missing" : actual === expectedVersion ? "compliant" : "drift"
|
|
3928
3970
|
};
|
|
3929
3971
|
}
|
|
3972
|
+
function readRuntimeVersion(name) {
|
|
3973
|
+
if (name === "node") return process.versions.node;
|
|
3974
|
+
if (name !== "deno") return void 0;
|
|
3975
|
+
const result = spawnSync5("deno", ["--version"], { encoding: "utf8" });
|
|
3976
|
+
if (result.status !== 0) return void 0;
|
|
3977
|
+
return /^deno\s+(\d+\.\d+\.\d+)/m.exec(result.stdout)?.[1];
|
|
3978
|
+
}
|
|
3930
3979
|
function findDeclaredVersion(packageJson, name) {
|
|
3931
3980
|
for (const section of ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"]) {
|
|
3932
3981
|
const value = packageJson?.[section]?.[name];
|
|
@@ -4070,7 +4119,7 @@ function runTargetChecks(target) {
|
|
|
4070
4119
|
];
|
|
4071
4120
|
return commands.map((command2) => {
|
|
4072
4121
|
if (!existsSync22(command2.cli)) return { name: command2.name, status: null };
|
|
4073
|
-
const result =
|
|
4122
|
+
const result = spawnSync6(process.execPath, [command2.cli, ...command2.args], {
|
|
4074
4123
|
cwd: target.path,
|
|
4075
4124
|
encoding: "utf8",
|
|
4076
4125
|
timeout: 3e4
|
|
@@ -4079,13 +4128,13 @@ function runTargetChecks(target) {
|
|
|
4079
4128
|
});
|
|
4080
4129
|
}
|
|
4081
4130
|
function inspectGit(path) {
|
|
4082
|
-
const inside =
|
|
4131
|
+
const inside = spawnSync6("git", ["rev-parse", "--is-inside-work-tree"], {
|
|
4083
4132
|
cwd: path,
|
|
4084
4133
|
encoding: "utf8"
|
|
4085
4134
|
});
|
|
4086
4135
|
if (inside.status !== 0) return { isRepository: false, dirty: false };
|
|
4087
|
-
const status =
|
|
4088
|
-
const branch =
|
|
4136
|
+
const status = spawnSync6("git", ["status", "--porcelain"], { cwd: path, encoding: "utf8" });
|
|
4137
|
+
const branch = spawnSync6("git", ["branch", "--show-current"], { cwd: path, encoding: "utf8" });
|
|
4089
4138
|
return {
|
|
4090
4139
|
isRepository: true,
|
|
4091
4140
|
dirty: status.stdout.trim().length > 0,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pieai/pro-gov",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Project-level distribution kit for Project Governance System.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai-agents",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@pieai/doc-gov": "^0.7.
|
|
38
|
+
"@pieai/doc-gov": "^0.7.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@pieai/swimmer-ui-kit": "1.1.0",
|