@greenarmor/ges 1.2.8 → 1.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/dist/commands/init.js +98 -12
- package/package.json +14 -14
package/dist/commands/init.js
CHANGED
|
@@ -3,7 +3,7 @@ import { input, select, checkbox } from "../utils/prompts.js";
|
|
|
3
3
|
import { PROJECT_TYPES, FRAMEWORKS, DEFAULT_FRAMEWORKS, GES_DIR, COMPLIANCE_DIR, SECURITY_DIR, CONTROLS_DIR, POLICIES_DIR, CHECKLISTS_DIR, DOCS_DIR, REPORTS_DIR, } from "@greenarmor/ges-core";
|
|
4
4
|
import { CLI_VERSION } from "../utils/version.js";
|
|
5
5
|
import { recordActivity } from "@greenarmor/ges-core";
|
|
6
|
-
import { getPacksForProjectType } from "@greenarmor/ges-policy-engine";
|
|
6
|
+
import { getPacksForProjectType, getPack, PRIVACY_COUNTRIES, getCountryByCode } from "@greenarmor/ges-policy-engine";
|
|
7
7
|
import { generateComplianceDocs, generateSecurityDocs, generateConfigJson, generateMetadataJson, generateFrameworkVersionJson, generateScoreJson, } from "@greenarmor/ges-doc-generator";
|
|
8
8
|
import { generateAllWorkflows } from "@greenarmor/ges-cicd-generator";
|
|
9
9
|
import { writeFileSync } from "../utils/project.js";
|
|
@@ -15,6 +15,7 @@ export const initCommand = new Command("init")
|
|
|
15
15
|
.option("-n, --name <name>", "Project name")
|
|
16
16
|
.option("-t, --type <type>", "Project type")
|
|
17
17
|
.option("-f, --frameworks <frameworks>", "Comma-separated frameworks")
|
|
18
|
+
.option("-c, --country <country>", "Country of origin (e.g., BR, CA, US-CA, GB, SG)")
|
|
18
19
|
.option("--force", "Re-initialize even if GESF is already set up")
|
|
19
20
|
.action(async (options) => {
|
|
20
21
|
console.log("\n Green Engineering Standard Framework (GESF) v" + CLI_VERSION);
|
|
@@ -50,11 +51,81 @@ export const initCommand = new Command("init")
|
|
|
50
51
|
console.error(" Error: At least one framework must be selected.");
|
|
51
52
|
process.exit(1);
|
|
52
53
|
}
|
|
54
|
+
// --- Mandatory: Country of Origin ---
|
|
55
|
+
let countryCode = options.country || "";
|
|
56
|
+
if (!countryCode) {
|
|
57
|
+
const regions = ["Europe", "Asia-Pacific", "Americas", "Africa", "Middle East", "Global / EU-wide"];
|
|
58
|
+
const selectedRegion = await select({
|
|
59
|
+
message: "Select your project's primary country/region of operation:",
|
|
60
|
+
choices: regions.map(r => ({ value: r, name: r })),
|
|
61
|
+
});
|
|
62
|
+
if (selectedRegion === "Global / EU-wide") {
|
|
63
|
+
countryCode = "EU";
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const countriesInRegion = PRIVACY_COUNTRIES.filter(c => c.region === selectedRegion);
|
|
67
|
+
const countryChoice = await select({
|
|
68
|
+
message: "Select the country:",
|
|
69
|
+
choices: [
|
|
70
|
+
...countriesInRegion.map(c => ({
|
|
71
|
+
value: c.code,
|
|
72
|
+
name: `${c.name} — ${c.lawName}`,
|
|
73
|
+
})),
|
|
74
|
+
{ value: "OTHER", name: "Other / Not listed (skip privacy pack)" },
|
|
75
|
+
],
|
|
76
|
+
});
|
|
77
|
+
countryCode = countryChoice;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
countryCode = countryCode.toUpperCase();
|
|
81
|
+
const countryInfo = getCountryByCode(countryCode);
|
|
82
|
+
if (options.country && !countryInfo && countryCode !== "EU") {
|
|
83
|
+
console.warn(` ⚠ Country code '${options.country}' not recognized. No privacy pack will be auto-installed.`);
|
|
84
|
+
console.warn(` Available codes: ${PRIVACY_COUNTRIES.map(c => c.code).join(", ")}, EU`);
|
|
85
|
+
}
|
|
86
|
+
// --- Optional: Additional privacy packs ---
|
|
87
|
+
const additionalPacks = await checkbox({
|
|
88
|
+
message: "Select additional privacy packs (optional — you can add more later with 'ges policy install'):",
|
|
89
|
+
choices: PRIVACY_COUNTRIES
|
|
90
|
+
.filter(c => c.code !== countryCode)
|
|
91
|
+
.map(c => ({
|
|
92
|
+
value: c.packId,
|
|
93
|
+
name: `${c.name} (${c.lawName})`,
|
|
94
|
+
checked: false,
|
|
95
|
+
})),
|
|
96
|
+
});
|
|
97
|
+
// --- Determine which packs to install ---
|
|
98
|
+
const installedPackIds = new Set();
|
|
99
|
+
// Domain packs from project type
|
|
100
|
+
const allProjectPacks = getPacksForProjectType(projectType);
|
|
101
|
+
const fwLower = new Set(selectedFrameworks.map((f) => f.toLowerCase()));
|
|
102
|
+
const DOMAIN_PACKS = new Set(["ai", "blockchain", "government"]);
|
|
103
|
+
for (const pack of allProjectPacks) {
|
|
104
|
+
if (DOMAIN_PACKS.has(pack.id.toLowerCase()) || fwLower.has(pack.id.toLowerCase())) {
|
|
105
|
+
installedPackIds.add(pack.id);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// Privacy core (always installed)
|
|
109
|
+
installedPackIds.add("privacy-core");
|
|
110
|
+
// Country pack (auto-selected from country of origin)
|
|
111
|
+
if (countryInfo) {
|
|
112
|
+
installedPackIds.add(countryInfo.packId);
|
|
113
|
+
// EU maps to GDPR which is already in default frameworks
|
|
114
|
+
}
|
|
115
|
+
else if (countryCode === "EU") {
|
|
116
|
+
installedPackIds.add("gdpr");
|
|
117
|
+
}
|
|
118
|
+
// Additional packs selected by user
|
|
119
|
+
for (const packId of additionalPacks) {
|
|
120
|
+
installedPackIds.add(packId);
|
|
121
|
+
}
|
|
122
|
+
// Build config
|
|
53
123
|
const now = new Date().toISOString();
|
|
54
124
|
const config = {
|
|
55
125
|
project_name: projectName,
|
|
56
126
|
project_type: projectType,
|
|
57
127
|
frameworks: selectedFrameworks,
|
|
128
|
+
country: countryCode,
|
|
58
129
|
requirements: {
|
|
59
130
|
encryption: { required: true, level: "mandatory" },
|
|
60
131
|
mfa: { required: true, level: "mandatory" },
|
|
@@ -107,14 +178,16 @@ export const initCommand = new Command("init")
|
|
|
107
178
|
for (const doc of securityDocs) {
|
|
108
179
|
writeFileSync(path.join(process.cwd(), doc.filePath), doc.content);
|
|
109
180
|
}
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
181
|
+
// Install all selected packs
|
|
182
|
+
const packs = [];
|
|
183
|
+
for (const packId of installedPackIds) {
|
|
184
|
+
const pack = getPack(packId);
|
|
185
|
+
if (pack) {
|
|
186
|
+
const packDir = path.join(process.cwd(), CONTROLS_DIR, pack.id);
|
|
187
|
+
fs.mkdirSync(packDir, { recursive: true });
|
|
188
|
+
writeFileSync(path.join(packDir, "controls.json"), JSON.stringify(pack.controls, null, 2));
|
|
189
|
+
packs.push(pack);
|
|
190
|
+
}
|
|
118
191
|
}
|
|
119
192
|
const workflows = generateAllWorkflows(config);
|
|
120
193
|
for (const wf of workflows) {
|
|
@@ -124,20 +197,33 @@ export const initCommand = new Command("init")
|
|
|
124
197
|
console.log(" ✓ Configuration files generated");
|
|
125
198
|
console.log(" ✓ Compliance documents created");
|
|
126
199
|
console.log(" ✓ Security documents created");
|
|
200
|
+
if (countryInfo) {
|
|
201
|
+
console.log(` ✓ Country privacy pack auto-installed: ${countryInfo.packId} (${countryInfo.name})`);
|
|
202
|
+
}
|
|
203
|
+
else if (countryCode === "EU") {
|
|
204
|
+
console.log(" ✓ EU GDPR privacy pack auto-installed");
|
|
205
|
+
}
|
|
206
|
+
if (additionalPacks.length > 0) {
|
|
207
|
+
console.log(` ✓ Additional privacy packs installed: ${additionalPacks.join(", ")}`);
|
|
208
|
+
}
|
|
127
209
|
console.log(" ✓ Control packs installed:", packs.map(p => p.id).join(", "));
|
|
128
210
|
console.log(" ✓ GitHub Actions workflows generated");
|
|
129
211
|
console.log(" ✓ Developer logs directory created (.dev-logs/)");
|
|
130
212
|
console.log(`\n GESF initialized for "${projectName}" (${projectType})`);
|
|
213
|
+
if (countryInfo) {
|
|
214
|
+
console.log(` Country: ${countryInfo.name} — ${countryInfo.lawName}`);
|
|
215
|
+
}
|
|
131
216
|
console.log(" Next steps:");
|
|
132
217
|
console.log(" 1. Review generated compliance documents");
|
|
133
218
|
console.log(" 2. Run 'ges audit' to evaluate your project");
|
|
134
|
-
console.log(" 3. Run 'ges score' to see your compliance score
|
|
219
|
+
console.log(" 3. Run 'ges score' to see your compliance score");
|
|
220
|
+
console.log(" 4. Add more packs with 'ges policy install <pack-id>'\n");
|
|
135
221
|
recordActivity(process.cwd(), {
|
|
136
222
|
source: "cli",
|
|
137
223
|
action: "init",
|
|
138
224
|
title: `Project initialized: ${projectName}`,
|
|
139
|
-
description: `Initialized GESF for ${projectType} project with frameworks: ${selectedFrameworks.join(", ")}. Installed ${packs.length} policy packs: ${packs.map(p => p.id).join(", ")}.`,
|
|
140
|
-
details: { packs_affected: packs.map(p => p.id), frameworks_added: selectedFrameworks.map((f) => String(f)) },
|
|
225
|
+
description: `Initialized GESF for ${projectType} project${countryInfo ? ` in ${countryInfo.name}` : ""} with frameworks: ${selectedFrameworks.join(", ")}. Installed ${packs.length} policy packs: ${packs.map(p => p.id).join(", ")}.`,
|
|
226
|
+
details: { packs_affected: packs.map(p => p.id), frameworks_added: selectedFrameworks.map((f) => String(f)), country: countryCode },
|
|
141
227
|
});
|
|
142
228
|
await showNextStepsMenu("init");
|
|
143
229
|
});
|
package/package.json
CHANGED
|
@@ -3,19 +3,19 @@
|
|
|
3
3
|
"ges": "./dist/cli.js"
|
|
4
4
|
},
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@greenarmor/ges-audit-engine": "1.
|
|
7
|
-
"@greenarmor/ges-cicd-generator": "1.
|
|
8
|
-
"@greenarmor/ges-compliance-engine": "1.
|
|
9
|
-
"@greenarmor/ges-core": "1.
|
|
10
|
-
"@greenarmor/ges-doc-generator": "1.
|
|
11
|
-
"@greenarmor/ges-git-hooks": "1.
|
|
12
|
-
"@greenarmor/ges-mcp-server": "1.
|
|
13
|
-
"@greenarmor/ges-policy-engine": "1.
|
|
14
|
-
"@greenarmor/ges-report-generator": "1.
|
|
15
|
-
"@greenarmor/ges-rules-engine": "1.
|
|
16
|
-
"@greenarmor/ges-scanner-integration": "1.
|
|
17
|
-
"@greenarmor/ges-scoring-engine": "1.
|
|
18
|
-
"@greenarmor/ges-web-dashboard": "1.
|
|
6
|
+
"@greenarmor/ges-audit-engine": "1.3.0",
|
|
7
|
+
"@greenarmor/ges-cicd-generator": "1.3.0",
|
|
8
|
+
"@greenarmor/ges-compliance-engine": "1.3.0",
|
|
9
|
+
"@greenarmor/ges-core": "1.3.0",
|
|
10
|
+
"@greenarmor/ges-doc-generator": "1.3.0",
|
|
11
|
+
"@greenarmor/ges-git-hooks": "1.3.0",
|
|
12
|
+
"@greenarmor/ges-mcp-server": "1.3.0",
|
|
13
|
+
"@greenarmor/ges-policy-engine": "1.3.0",
|
|
14
|
+
"@greenarmor/ges-report-generator": "1.3.0",
|
|
15
|
+
"@greenarmor/ges-rules-engine": "1.3.0",
|
|
16
|
+
"@greenarmor/ges-scanner-integration": "1.3.0",
|
|
17
|
+
"@greenarmor/ges-scoring-engine": "1.3.0",
|
|
18
|
+
"@greenarmor/ges-web-dashboard": "1.3.0",
|
|
19
19
|
"commander": "^13.0.0"
|
|
20
20
|
},
|
|
21
21
|
"description": "Green Engineering Standard Framework - Compliance-as-Code CLI",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"type": "module",
|
|
55
55
|
"types": "./dist/index.d.ts",
|
|
56
|
-
"version": "1.
|
|
56
|
+
"version": "1.3.0",
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build": "tsc",
|
|
59
59
|
"clean": "rm -rf dist tsconfig.tsbuildinfo",
|