@venizia/vulcan 0.3.6 → 0.3.7
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/package.json +3 -3
- package/src/commands/doctor.command.ts +12 -2
- package/src/create/dockerignore.ts +13 -2
- package/src/doctor/checks.ts +54 -3
- package/src/doctor/runner.ts +16 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venizia/vulcan",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"description": "VULCAN - one setup, one workflow for every project: init, sync, doctor, upgrade, and `vulcan x` for the shipped tools. Bun-only.",
|
|
5
5
|
"homepage": "https://github.com/VENIZIA-AI/vulcan/tree/main/packages/cli",
|
|
6
6
|
"repository": {
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"test": "NODE_ENV=test bun test --env-file=.env.test"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@venizia/vulcan-atlas": "0.3.
|
|
48
|
-
"@venizia/vulcan-okf": "0.3.
|
|
47
|
+
"@venizia/vulcan-atlas": "0.3.7",
|
|
48
|
+
"@venizia/vulcan-okf": "0.3.7",
|
|
49
49
|
"zod": "^4.5.4"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExitCodes } from '../common/index.ts';
|
|
2
2
|
import type { ICommandContext } from '../common/index.ts';
|
|
3
|
-
import { runDoctorChecks, runDoctorNotes } from '../doctor/index.ts';
|
|
3
|
+
import { runDoctorChecks, runDoctorNotes, runDoctorWarnings } from '../doctor/index.ts';
|
|
4
4
|
|
|
5
5
|
export const runDoctorCommand = async (opts: ICommandContext): Promise<number> => {
|
|
6
6
|
const violations = await runDoctorChecks({ root: opts.cwd });
|
|
@@ -9,6 +9,12 @@ export const runDoctorCommand = async (opts: ICommandContext): Promise<number> =
|
|
|
9
9
|
process.stderr.write(` [${violation.check}] ${violation.file}: ${violation.message}\n`);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
const warnings = await runDoctorWarnings({ root: opts.cwd });
|
|
13
|
+
|
|
14
|
+
for (const warning of warnings) {
|
|
15
|
+
process.stderr.write(` warning [${warning.check}] ${warning.file}: ${warning.message}\n`);
|
|
16
|
+
}
|
|
17
|
+
|
|
12
18
|
for (const note of await runDoctorNotes({ root: opts.cwd })) {
|
|
13
19
|
process.stderr.write(` info [${note.check}] ${note.file}: ${note.message}\n`);
|
|
14
20
|
}
|
|
@@ -19,7 +25,11 @@ export const runDoctorCommand = async (opts: ICommandContext): Promise<number> =
|
|
|
19
25
|
return ExitCodes.FAILURE;
|
|
20
26
|
}
|
|
21
27
|
|
|
22
|
-
process.stderr.write(
|
|
28
|
+
process.stderr.write(
|
|
29
|
+
warnings.length === 0
|
|
30
|
+
? 'vulcan doctor: OK\n'
|
|
31
|
+
: `vulcan doctor: OK with ${warnings.length} warning(s)\n`,
|
|
32
|
+
);
|
|
23
33
|
|
|
24
34
|
return ExitCodes.OK;
|
|
25
35
|
};
|
|
@@ -13,6 +13,15 @@ const BASE_PATTERNS = [
|
|
|
13
13
|
'.agents/plans',
|
|
14
14
|
];
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* `.env` files hold secrets (database passwords, tokens) and a Dockerfile that copies the project
|
|
18
|
+
* would put them in a layer a CI cache can keep. The example file stays: the negation comes after
|
|
19
|
+
* the excludes, or Docker would not apply it.
|
|
20
|
+
*/
|
|
21
|
+
const SECRET_PATTERNS = ['**/.env', '**/.env.*', '!**/.env.example'];
|
|
22
|
+
const SECRET_COMMENT =
|
|
23
|
+
'# .env files hold secrets: keep them out of every image layer; the example stays.';
|
|
24
|
+
|
|
16
25
|
/**
|
|
17
26
|
* The root `.dockerignore` of a new project: a Dockerfile is built from the project root, so the
|
|
18
27
|
* context must not carry dependencies, build output or git. Beside the base patterns it lists the
|
|
@@ -26,11 +35,13 @@ export const renderDockerignore = (): string => {
|
|
|
26
35
|
})
|
|
27
36
|
.flatMap(group => group.paths)
|
|
28
37
|
.map(path => path.replace(/^\//, '').replace(/\/$/, ''));
|
|
29
|
-
const patterns = [...new Set([...BASE_PATTERNS, ...agentPaths])];
|
|
38
|
+
const patterns = [...new Set([...BASE_PATTERNS, ...SECRET_PATTERNS, ...agentPaths])];
|
|
30
39
|
|
|
31
40
|
return [
|
|
32
41
|
'# Written by vulcan init; edit it freely, vulcan never overwrites it. .git is excluded, so pass the commit: docker build --build-arg APP_BUILD_COMMIT="$(git rev-parse HEAD)" ...',
|
|
33
|
-
...patterns
|
|
42
|
+
...patterns.flatMap(pattern =>
|
|
43
|
+
pattern === SECRET_PATTERNS[0] ? [SECRET_COMMENT, pattern] : [pattern],
|
|
44
|
+
),
|
|
34
45
|
'',
|
|
35
46
|
].join('\n');
|
|
36
47
|
};
|
package/src/doctor/checks.ts
CHANGED
|
@@ -593,9 +593,55 @@ export const checkAgents = (opts: ICheckContext): IViolation[] => {
|
|
|
593
593
|
/** Info only: the Atlas block of AGENTS.md is missing or no longer matches the config. */
|
|
594
594
|
const DOCKERFILE = '.configs/builders/Dockerfile';
|
|
595
595
|
|
|
596
|
-
|
|
596
|
+
const SECRET_LINES = ['**/.env', '**/.env.*', '!**/.env.example'];
|
|
597
|
+
const ADD_SECRET_LINES = `add ${SECRET_LINES[0]}, ${SECRET_LINES[1]} and ${SECRET_LINES[2]} (in that order) to the root .dockerignore`;
|
|
598
|
+
|
|
599
|
+
/** Whether a `.dockerignore` pattern, as Docker reads it, names the file `opts.file` at any depth. */
|
|
600
|
+
const patternNames = (opts: { pattern: string; file: string }): boolean => {
|
|
601
|
+
const bare = opts.pattern.replace(/^\*\*\//, '').replace(/^\//, '');
|
|
602
|
+
|
|
603
|
+
return (
|
|
604
|
+
bare === opts.file ||
|
|
605
|
+
(bare.endsWith('*') && opts.file.startsWith(bare.slice(0, -1)) && bare.startsWith('.env'))
|
|
606
|
+
);
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
/** Whether the last pattern that names `opts.file` excludes it: a later `!` line brings it back. */
|
|
610
|
+
const excludes = (opts: { lines: string[]; file: string }): boolean => {
|
|
611
|
+
let excluded = false;
|
|
612
|
+
|
|
613
|
+
for (const line of opts.lines) {
|
|
614
|
+
const negated = line.startsWith('!');
|
|
615
|
+
|
|
616
|
+
if (patternNames({ pattern: negated ? line.slice(1) : line, file: opts.file })) {
|
|
617
|
+
excluded = !negated;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
return excluded;
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* A Dockerfile is built from the project root. Without a root `.dockerignore` the context carries
|
|
626
|
+
* node_modules, dist, .git and every `.env` (secrets that would land in an image layer a CI cache
|
|
627
|
+
* can keep); with one that does not exclude `.env` and `.env.*` the secrets are still copied.
|
|
628
|
+
* A warning, not a violation: the exit code is unchanged, so a project made before this check
|
|
629
|
+
* does not start failing.
|
|
630
|
+
*/
|
|
597
631
|
export const checkDockerignore = (opts: ICheckContext): IViolation[] => {
|
|
598
|
-
|
|
632
|
+
const file = join(opts.root, '.dockerignore');
|
|
633
|
+
const lines = existsSync(file)
|
|
634
|
+
? readText({ file })
|
|
635
|
+
.split('\n')
|
|
636
|
+
.map(line => line.trim())
|
|
637
|
+
.filter(line => line !== '' && !line.startsWith('#'))
|
|
638
|
+
: undefined;
|
|
639
|
+
|
|
640
|
+
if (
|
|
641
|
+
lines !== undefined &&
|
|
642
|
+
excludes({ lines, file: '.env' }) &&
|
|
643
|
+
excludes({ lines, file: '.env.production' })
|
|
644
|
+
) {
|
|
599
645
|
return [];
|
|
600
646
|
}
|
|
601
647
|
|
|
@@ -607,11 +653,16 @@ export const checkDockerignore = (opts: ICheckContext): IViolation[] => {
|
|
|
607
653
|
return [];
|
|
608
654
|
}
|
|
609
655
|
|
|
656
|
+
const subject = apps.length === 1 ? `app ${apps[0]} has` : `apps ${apps.join(', ')} have`;
|
|
657
|
+
|
|
610
658
|
return [
|
|
611
659
|
createViolation({
|
|
612
660
|
check: DoctorChecks.DOCKERIGNORE,
|
|
613
661
|
file: '.dockerignore',
|
|
614
|
-
message:
|
|
662
|
+
message:
|
|
663
|
+
lines === undefined
|
|
664
|
+
? `${subject} a Dockerfile and the root has no .dockerignore: the build context would carry node_modules, dist, .git and every .env file (secrets) - create it, then ${ADD_SECRET_LINES}`
|
|
665
|
+
: `${subject} a Dockerfile and the root .dockerignore does not exclude .env files, which hold secrets and would land in the image layer: ${ADD_SECRET_LINES}`,
|
|
615
666
|
}),
|
|
616
667
|
];
|
|
617
668
|
};
|
package/src/doctor/runner.ts
CHANGED
|
@@ -76,5 +76,20 @@ export const runDoctorNotes = async (opts: { root: string }): Promise<IViolation
|
|
|
76
76
|
configFile: relative(opts.root, loaded.file),
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
return [...checkAppScripts(context), ...checkAtlasBlock(context)
|
|
79
|
+
return [...checkAppScripts(context), ...checkAtlasBlock(context)];
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/** Warnings: louder than a note, still never a failure - a security gap a project made earlier may carry. */
|
|
83
|
+
export const runDoctorWarnings = async (opts: { root: string }): Promise<IViolation[]> => {
|
|
84
|
+
const loaded = await loadConfig({ root: opts.root });
|
|
85
|
+
|
|
86
|
+
if (!loaded.ok) {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return checkDockerignore({
|
|
91
|
+
root: opts.root,
|
|
92
|
+
config: loaded.config,
|
|
93
|
+
configFile: relative(opts.root, loaded.file),
|
|
94
|
+
});
|
|
80
95
|
};
|