@greenarmor/ges 0.3.4 → 0.3.5
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 +1 -1
- package/dist/commands/mcp-setup.js +1 -1
- package/dist/utils/next-steps.js +1 -1
- package/dist/utils/prompts.d.ts +19 -0
- package/dist/utils/prompts.js +94 -0
- package/package.json +12 -15
package/dist/commands/init.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
-
import { input, select, checkbox } from "
|
|
2
|
+
import { input, select, checkbox } from "../utils/prompts.js";
|
|
3
3
|
import { PROJECT_TYPES, FRAMEWORKS, DEFAULT_FRAMEWORKS, GESF_VERSION, GES_DIR, COMPLIANCE_DIR, SECURITY_DIR, CONTROLS_DIR, POLICIES_DIR, CHECKLISTS_DIR, DOCS_DIR, REPORTS_DIR, } from "@greenarmor/ges-core";
|
|
4
4
|
import { getPacksForProjectType } from "@greenarmor/ges-policy-engine";
|
|
5
5
|
import { generateComplianceDocs, generateSecurityDocs, generateConfigYaml, generateConfigJson, generateMetadataJson, generateFrameworkVersionJson, generateScoreJson, } from "@greenarmor/ges-doc-generator";
|
|
@@ -3,7 +3,7 @@ import * as fs from "node:fs";
|
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import * as os from "node:os";
|
|
5
5
|
import * as url from "node:url";
|
|
6
|
-
import { select } from "
|
|
6
|
+
import { select } from "../utils/prompts.js";
|
|
7
7
|
import { showNextStepsMenu } from "../utils/next-steps.js";
|
|
8
8
|
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
9
9
|
const SERVER_NAME = "gesf";
|
package/dist/utils/next-steps.js
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare function input(options: {
|
|
2
|
+
message: string;
|
|
3
|
+
default?: string;
|
|
4
|
+
}): Promise<string>;
|
|
5
|
+
export declare function select<T = string>(options: {
|
|
6
|
+
message: string;
|
|
7
|
+
choices: {
|
|
8
|
+
name: string;
|
|
9
|
+
value: T;
|
|
10
|
+
}[];
|
|
11
|
+
}): Promise<T>;
|
|
12
|
+
export declare function checkbox<T = string>(options: {
|
|
13
|
+
message: string;
|
|
14
|
+
choices: {
|
|
15
|
+
name: string;
|
|
16
|
+
value: T;
|
|
17
|
+
checked?: boolean;
|
|
18
|
+
}[];
|
|
19
|
+
}): Promise<T[]>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import * as readline from "node:readline";
|
|
2
|
+
function isInteractive() {
|
|
3
|
+
return process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
4
|
+
}
|
|
5
|
+
function createRL() {
|
|
6
|
+
return readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
7
|
+
}
|
|
8
|
+
let cachedInquirer;
|
|
9
|
+
async function getInquirer() {
|
|
10
|
+
if (cachedInquirer !== undefined)
|
|
11
|
+
return cachedInquirer;
|
|
12
|
+
try {
|
|
13
|
+
const mod = await import(String("@inquirer/prompts"));
|
|
14
|
+
cachedInquirer = mod;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
cachedInquirer = null;
|
|
18
|
+
}
|
|
19
|
+
return cachedInquirer;
|
|
20
|
+
}
|
|
21
|
+
export async function input(options) {
|
|
22
|
+
if (!isInteractive()) {
|
|
23
|
+
return options.default ?? "";
|
|
24
|
+
}
|
|
25
|
+
const inquirer = await getInquirer();
|
|
26
|
+
if (inquirer) {
|
|
27
|
+
return inquirer.input({ message: options.message, default: options.default });
|
|
28
|
+
}
|
|
29
|
+
const rl = createRL();
|
|
30
|
+
const suffix = options.default ? ` (${options.default})` : "";
|
|
31
|
+
return new Promise((resolve) => {
|
|
32
|
+
rl.question(` ${options.message}${suffix}: `, (answer) => {
|
|
33
|
+
rl.close();
|
|
34
|
+
resolve(answer.trim() || options.default || "");
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
export async function select(options) {
|
|
39
|
+
if (!isInteractive()) {
|
|
40
|
+
return options.choices[0].value;
|
|
41
|
+
}
|
|
42
|
+
const inquirer = await getInquirer();
|
|
43
|
+
if (inquirer) {
|
|
44
|
+
return inquirer.select({ message: options.message, choices: options.choices });
|
|
45
|
+
}
|
|
46
|
+
console.log(`\n ${options.message}:\n`);
|
|
47
|
+
options.choices.forEach((c, i) => {
|
|
48
|
+
console.log(` ${i + 1}) ${c.name}`);
|
|
49
|
+
});
|
|
50
|
+
const rl = createRL();
|
|
51
|
+
return new Promise((resolve) => {
|
|
52
|
+
rl.question(`\n Enter choice [1-${options.choices.length}]: `, (answer) => {
|
|
53
|
+
rl.close();
|
|
54
|
+
const num = parseInt(answer.trim(), 10);
|
|
55
|
+
if (num >= 1 && num <= options.choices.length) {
|
|
56
|
+
resolve(options.choices[num - 1].value);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
resolve(options.choices[0].value);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
export async function checkbox(options) {
|
|
65
|
+
if (!isInteractive()) {
|
|
66
|
+
return options.choices.filter(c => c.checked).map(c => c.value);
|
|
67
|
+
}
|
|
68
|
+
const inquirer = await getInquirer();
|
|
69
|
+
if (inquirer) {
|
|
70
|
+
return inquirer.checkbox({ message: options.message, choices: options.choices });
|
|
71
|
+
}
|
|
72
|
+
console.log(`\n ${options.message} (comma-separated numbers):\n`);
|
|
73
|
+
options.choices.forEach((c, i) => {
|
|
74
|
+
const marker = c.checked ? "[x]" : "[ ]";
|
|
75
|
+
console.log(` ${marker} ${i + 1}) ${c.name}`);
|
|
76
|
+
});
|
|
77
|
+
const rl = createRL();
|
|
78
|
+
return new Promise((resolve) => {
|
|
79
|
+
rl.question(`\n Enter choices [1-${options.choices.length}]: `, (answer) => {
|
|
80
|
+
rl.close();
|
|
81
|
+
const trimmed = answer.trim();
|
|
82
|
+
if (!trimmed) {
|
|
83
|
+
resolve(options.choices.filter(c => c.checked).map(c => c.value));
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const indices = trimmed.split(",").map(s => parseInt(s.trim(), 10) - 1).filter(n => n >= 0 && n < options.choices.length);
|
|
87
|
+
if (indices.length === 0) {
|
|
88
|
+
resolve(options.choices.filter(c => c.checked).map(c => c.value));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
resolve([...new Set(indices)].map(i => options.choices[i].value));
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@greenarmor/ges",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "Green Engineering Standard Framework - Compliance-as-Code CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -12,23 +12,20 @@
|
|
|
12
12
|
"dist"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@inquirer/prompts": "^8.0.0",
|
|
16
15
|
"commander": "^13.0.0",
|
|
17
|
-
"
|
|
18
|
-
"@greenarmor/ges-
|
|
19
|
-
"@greenarmor/ges-
|
|
20
|
-
"@greenarmor/ges-
|
|
21
|
-
"@greenarmor/ges-
|
|
22
|
-
"@greenarmor/ges-
|
|
23
|
-
"@greenarmor/ges-
|
|
24
|
-
"@greenarmor/ges-
|
|
25
|
-
"@greenarmor/ges-scanner-integration": "0.3.
|
|
26
|
-
"@greenarmor/ges-
|
|
27
|
-
"@greenarmor/ges-
|
|
28
|
-
"@greenarmor/ges-mcp-server": "0.3.4"
|
|
16
|
+
"@greenarmor/ges-audit-engine": "0.3.5",
|
|
17
|
+
"@greenarmor/ges-cicd-generator": "0.3.5",
|
|
18
|
+
"@greenarmor/ges-core": "0.3.5",
|
|
19
|
+
"@greenarmor/ges-compliance-engine": "0.3.5",
|
|
20
|
+
"@greenarmor/ges-report-generator": "0.3.5",
|
|
21
|
+
"@greenarmor/ges-rules-engine": "0.3.5",
|
|
22
|
+
"@greenarmor/ges-policy-engine": "0.3.5",
|
|
23
|
+
"@greenarmor/ges-scoring-engine": "0.3.5",
|
|
24
|
+
"@greenarmor/ges-scanner-integration": "0.3.5",
|
|
25
|
+
"@greenarmor/ges-doc-generator": "0.3.5",
|
|
26
|
+
"@greenarmor/ges-mcp-server": "0.3.5"
|
|
29
27
|
},
|
|
30
28
|
"devDependencies": {
|
|
31
|
-
"@types/js-yaml": "^4.0.0",
|
|
32
29
|
"@types/node": "^22.0.0",
|
|
33
30
|
"typescript": "^6.0.0"
|
|
34
31
|
},
|