@kabran-tecnologia/kabran-config 2.1.1 → 2.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/README.md
CHANGED
|
@@ -368,8 +368,9 @@ echo "npx lint-staged" > .husky/pre-commit
|
|
|
368
368
|
# Add commit-msg hook
|
|
369
369
|
echo "npx --no -- commitlint --edit \$1" > .husky/commit-msg
|
|
370
370
|
|
|
371
|
-
# Add pre-push hook (optional)
|
|
372
|
-
|
|
371
|
+
# Add pre-push hook (optional - kept lightweight by design)
|
|
372
|
+
# Full validation runs in CI. Uncomment type-check if desired:
|
|
373
|
+
# echo "npm run type-check" > .husky/pre-push
|
|
373
374
|
```
|
|
374
375
|
|
|
375
376
|
---
|
|
@@ -476,21 +477,14 @@ node node_modules/@kabran-tecnologia/kabran-config/src/scripts/license-check.mjs
|
|
|
476
477
|
}
|
|
477
478
|
```
|
|
478
479
|
|
|
479
|
-
**Usage in CI
|
|
480
|
+
**Usage in CI (recommended):**
|
|
480
481
|
|
|
481
482
|
```yaml
|
|
482
|
-
# .github/workflows/
|
|
483
|
+
# .github/workflows/ci.yml
|
|
483
484
|
- name: License Check
|
|
484
485
|
run: npm run license:check
|
|
485
486
|
```
|
|
486
487
|
|
|
487
|
-
**Usage in Husky:**
|
|
488
|
-
|
|
489
|
-
```bash
|
|
490
|
-
# .husky/pre-push
|
|
491
|
-
npm run license:check
|
|
492
|
-
```
|
|
493
|
-
|
|
494
488
|
**Blocked licenses:** GPL, AGPL, LGPL, EUPL (viral copyleft)
|
|
495
489
|
**Exit code:** 1 if prohibited licenses found, 0 otherwise
|
|
496
490
|
|
|
@@ -607,14 +601,7 @@ node node_modules/@kabran-tecnologia/kabran-config/src/scripts/env-validator.mjs
|
|
|
607
601
|
3. If env vars detected, validates `.env.example` exists
|
|
608
602
|
4. Warns if vars in `.env.example` lack comments/documentation
|
|
609
603
|
|
|
610
|
-
**Usage in
|
|
611
|
-
|
|
612
|
-
```bash
|
|
613
|
-
# .husky/pre-push
|
|
614
|
-
npm run env:validate
|
|
615
|
-
```
|
|
616
|
-
|
|
617
|
-
**Usage in CI/CD:**
|
|
604
|
+
**Usage in CI (recommended):**
|
|
618
605
|
|
|
619
606
|
```yaml
|
|
620
607
|
# .github/workflows/security.yml
|
package/package.json
CHANGED
package/src/scripts/setup.mjs
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* Options:
|
|
13
13
|
* --type=<node|react|base> Project type (default: node)
|
|
14
|
+
* --runner=<github|self-hosted> Runner type (default: github)
|
|
14
15
|
* --skip-husky Don't copy husky hooks
|
|
15
16
|
* --skip-workflows Don't copy workflow files
|
|
16
17
|
* --sync-workflows Overwrite existing workflow files
|
|
@@ -74,6 +75,7 @@ export function logDry(message) {
|
|
|
74
75
|
export function parseArgs(args) {
|
|
75
76
|
const options = {
|
|
76
77
|
type: 'node',
|
|
78
|
+
runner: 'github',
|
|
77
79
|
skipHusky: false,
|
|
78
80
|
skipWorkflows: false,
|
|
79
81
|
skipQualityStandard: false,
|
|
@@ -112,6 +114,14 @@ export function parseArgs(args) {
|
|
|
112
114
|
logError(`Invalid type: ${type}. Valid options: node, react, base`);
|
|
113
115
|
process.exit(1);
|
|
114
116
|
}
|
|
117
|
+
} else if (arg.startsWith('--runner=')) {
|
|
118
|
+
const runner = arg.split('=')[1];
|
|
119
|
+
if (['github', 'self-hosted'].includes(runner)) {
|
|
120
|
+
options.runner = runner;
|
|
121
|
+
} else {
|
|
122
|
+
logError(`Invalid runner: ${runner}. Valid options: github, self-hosted`);
|
|
123
|
+
process.exit(1);
|
|
124
|
+
}
|
|
115
125
|
}
|
|
116
126
|
}
|
|
117
127
|
|
|
@@ -130,6 +140,7 @@ ${colors.yellow}USAGE:${colors.reset}
|
|
|
130
140
|
|
|
131
141
|
${colors.yellow}OPTIONS:${colors.reset}
|
|
132
142
|
--type=<type> Project type: node, react, base (default: node)
|
|
143
|
+
--runner=<runner> Runner type: github, self-hosted (default: github)
|
|
133
144
|
--skip-husky Don't copy husky hooks
|
|
134
145
|
--skip-workflows Don't copy GitHub workflow files
|
|
135
146
|
--skip-quality-standard Don't create quality-standard.md
|
|
@@ -147,9 +158,15 @@ ${colors.yellow}EXAMPLES:${colors.reset}
|
|
|
147
158
|
# Setup React project
|
|
148
159
|
npx kabran-setup --type=react
|
|
149
160
|
|
|
161
|
+
# Setup with self-hosted runners (Kosmos CI)
|
|
162
|
+
npx kabran-setup --runner=self-hosted
|
|
163
|
+
|
|
150
164
|
# Update workflows only
|
|
151
165
|
npx kabran-setup --sync-workflows
|
|
152
166
|
|
|
167
|
+
# Update to self-hosted workflows
|
|
168
|
+
npx kabran-setup --sync-workflows --runner=self-hosted
|
|
169
|
+
|
|
153
170
|
# Generate telemetry .env.example
|
|
154
171
|
npx kabran-setup --telemetry-env
|
|
155
172
|
|
|
@@ -160,6 +177,10 @@ ${colors.yellow}UPDATE STRATEGY:${colors.reset}
|
|
|
160
177
|
- Config files: Re-export from kabran-config (auto-update via npm update)
|
|
161
178
|
- Workflows: Copied once, update with --sync-workflows
|
|
162
179
|
- Husky hooks: Copied once, update with --sync-husky
|
|
180
|
+
|
|
181
|
+
${colors.yellow}RUNNER TYPES:${colors.reset}
|
|
182
|
+
- github: Standard GitHub-hosted runners (ubuntu-latest)
|
|
183
|
+
- self-hosted: Kosmos self-hosted runners [self-hosted, linux, x64, docker]
|
|
163
184
|
`);
|
|
164
185
|
}
|
|
165
186
|
|
|
@@ -282,7 +303,7 @@ export function writeFile(dest, content, options = {}) {
|
|
|
282
303
|
* @returns {object} Results
|
|
283
304
|
*/
|
|
284
305
|
export function setupWorkflows(projectDir, templatesDir, options) {
|
|
285
|
-
const {force = false, dryRun = false, syncWorkflows = false} = options;
|
|
306
|
+
const {force = false, dryRun = false, syncWorkflows = false, runner = 'github'} = options;
|
|
286
307
|
const overwrite = force || syncWorkflows;
|
|
287
308
|
|
|
288
309
|
const results = {
|
|
@@ -291,13 +312,22 @@ export function setupWorkflows(projectDir, templatesDir, options) {
|
|
|
291
312
|
skipped: 0,
|
|
292
313
|
};
|
|
293
314
|
|
|
294
|
-
|
|
315
|
+
// Determine CI workflow file based on runner type
|
|
316
|
+
const ciWorkflowSrc = runner === 'self-hosted' ? 'ci-self-hosted.yml' : 'ci.yml';
|
|
317
|
+
|
|
318
|
+
// Map of source file -> destination file
|
|
319
|
+
const workflowFiles = [
|
|
320
|
+
{src: ciWorkflowSrc, dest: 'ci.yml'},
|
|
321
|
+
{src: 'commitlint.yml', dest: 'commitlint.yml'},
|
|
322
|
+
{src: 'validate-pr-source.yml', dest: 'validate-pr-source.yml'},
|
|
323
|
+
];
|
|
295
324
|
|
|
296
|
-
|
|
325
|
+
const runnerLabel = runner === 'self-hosted' ? 'self-hosted' : 'GitHub-hosted';
|
|
326
|
+
logInfo(`Setting up GitHub workflows (${runnerLabel} runners)...`);
|
|
297
327
|
|
|
298
328
|
for (const file of workflowFiles) {
|
|
299
|
-
const src = join(templatesDir, '.github', 'workflows', file);
|
|
300
|
-
const dest = join(projectDir, '.github', 'workflows', file);
|
|
329
|
+
const src = join(templatesDir, '.github', 'workflows', file.src);
|
|
330
|
+
const dest = join(projectDir, '.github', 'workflows', file.dest);
|
|
301
331
|
|
|
302
332
|
const status = copyFile(src, dest, {overwrite, dryRun});
|
|
303
333
|
|
|
@@ -648,6 +678,7 @@ export function runSetup(projectDir, options) {
|
|
|
648
678
|
console.log('');
|
|
649
679
|
logInfo(`Setting up project at: ${projectDir}`);
|
|
650
680
|
logInfo(`Project type: ${options.type}`);
|
|
681
|
+
logInfo(`Runner type: ${options.runner}`);
|
|
651
682
|
if (options.dryRun) {
|
|
652
683
|
logWarn('DRY-RUN MODE - No files will be modified');
|
|
653
684
|
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Kabran CI Quality Workflow (Self-Hosted Runners)
|
|
2
|
+
#
|
|
3
|
+
# This workflow runs the Kabran CI pipeline on self-hosted runners
|
|
4
|
+
# and posts quality reports to PRs.
|
|
5
|
+
#
|
|
6
|
+
# Runner Labels: [self-hosted, linux, x64, docker]
|
|
7
|
+
#
|
|
8
|
+
# For GitHub-hosted runners, use ci-quality.yml instead.
|
|
9
|
+
#
|
|
10
|
+
# Requirements:
|
|
11
|
+
# - scripts/ci-config.sh with PROJECT_NAME, PM, and ci_steps() defined
|
|
12
|
+
# - @kabran-tecnologia/kabran-config installed as dev dependency
|
|
13
|
+
# - Kosmos CI runners configured for this repository
|
|
14
|
+
|
|
15
|
+
name: CI Quality
|
|
16
|
+
|
|
17
|
+
on:
|
|
18
|
+
push:
|
|
19
|
+
branches: [main]
|
|
20
|
+
pull_request:
|
|
21
|
+
branches: [main]
|
|
22
|
+
|
|
23
|
+
concurrency:
|
|
24
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
25
|
+
cancel-in-progress: true
|
|
26
|
+
|
|
27
|
+
jobs:
|
|
28
|
+
ci:
|
|
29
|
+
name: CI Pipeline
|
|
30
|
+
runs-on: [self-hosted, linux, x64, docker]
|
|
31
|
+
timeout-minutes: 15
|
|
32
|
+
|
|
33
|
+
permissions:
|
|
34
|
+
contents: read
|
|
35
|
+
pull-requests: write
|
|
36
|
+
|
|
37
|
+
steps:
|
|
38
|
+
- name: Checkout
|
|
39
|
+
uses: actions/checkout@v4
|
|
40
|
+
with:
|
|
41
|
+
fetch-depth: 0
|
|
42
|
+
|
|
43
|
+
- name: Setup Node.js
|
|
44
|
+
uses: actions/setup-node@v4
|
|
45
|
+
with:
|
|
46
|
+
node-version: "20"
|
|
47
|
+
cache: "npm"
|
|
48
|
+
|
|
49
|
+
- name: Install dependencies
|
|
50
|
+
run: npm ci
|
|
51
|
+
|
|
52
|
+
- name: Run CI Pipeline
|
|
53
|
+
id: ci
|
|
54
|
+
env:
|
|
55
|
+
CI_USE_V2: "true"
|
|
56
|
+
CI_OUTPUT_FILE_V2: "docs/quality/ci-result.json"
|
|
57
|
+
run: |
|
|
58
|
+
npx kabran-ci || exit_code=$?
|
|
59
|
+
|
|
60
|
+
if [ -f "docs/quality/ci-result.json" ]; then
|
|
61
|
+
echo "ci_result_exists=true" >> $GITHUB_OUTPUT
|
|
62
|
+
else
|
|
63
|
+
echo "ci_result_exists=false" >> $GITHUB_OUTPUT
|
|
64
|
+
fi
|
|
65
|
+
|
|
66
|
+
exit ${exit_code:-0}
|
|
67
|
+
|
|
68
|
+
- name: Generate PR Comment
|
|
69
|
+
if: github.event_name == 'pull_request' && steps.ci.outputs.ci_result_exists == 'true'
|
|
70
|
+
id: comment
|
|
71
|
+
run: |
|
|
72
|
+
npx kabran-pr-comment \
|
|
73
|
+
--current docs/quality/ci-result.json \
|
|
74
|
+
--baseline-branch ${{ github.base_ref }} \
|
|
75
|
+
--output /tmp/pr-comment.md || true
|
|
76
|
+
|
|
77
|
+
if [ -f "/tmp/pr-comment.md" ]; then
|
|
78
|
+
echo "comment_exists=true" >> $GITHUB_OUTPUT
|
|
79
|
+
fi
|
|
80
|
+
|
|
81
|
+
- name: Post PR Comment
|
|
82
|
+
if: github.event_name == 'pull_request' && steps.comment.outputs.comment_exists == 'true'
|
|
83
|
+
uses: marocchino/sticky-pull-request-comment@v2
|
|
84
|
+
with:
|
|
85
|
+
header: kabran-quality
|
|
86
|
+
path: /tmp/pr-comment.md
|
|
87
|
+
|
|
88
|
+
- name: Upload CI Result
|
|
89
|
+
if: always() && steps.ci.outputs.ci_result_exists == 'true'
|
|
90
|
+
uses: actions/upload-artifact@v4
|
|
91
|
+
with:
|
|
92
|
+
name: ci-result
|
|
93
|
+
path: docs/quality/ci-result.json
|
|
94
|
+
retention-days: 30
|
|
95
|
+
|
|
96
|
+
- name: Commit CI Result (main only)
|
|
97
|
+
if: github.ref == 'refs/heads/main' && github.event_name == 'push' && steps.ci.outputs.ci_result_exists == 'true'
|
|
98
|
+
run: |
|
|
99
|
+
git config user.name "github-actions[bot]"
|
|
100
|
+
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
101
|
+
|
|
102
|
+
if git diff --quiet docs/quality/ci-result.json; then
|
|
103
|
+
echo "No changes to ci-result.json"
|
|
104
|
+
else
|
|
105
|
+
git add docs/quality/ci-result.json
|
|
106
|
+
git commit -m "chore(ci): update ci-result.json [skip ci]"
|
|
107
|
+
git push
|
|
108
|
+
fi
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Kabran CI Workflow (Self-Hosted Runners)
|
|
2
|
+
#
|
|
3
|
+
# This workflow runs CI on self-hosted runners with Docker support.
|
|
4
|
+
# Use this when you have Kosmos CI runners configured.
|
|
5
|
+
#
|
|
6
|
+
# Runner Labels: [self-hosted, linux, x64, docker]
|
|
7
|
+
#
|
|
8
|
+
# For GitHub-hosted runners, use ci.yml instead.
|
|
9
|
+
|
|
10
|
+
name: CI
|
|
11
|
+
|
|
12
|
+
on:
|
|
13
|
+
pull_request:
|
|
14
|
+
branches: [main, staging]
|
|
15
|
+
push:
|
|
16
|
+
branches: [main, staging]
|
|
17
|
+
|
|
18
|
+
concurrency:
|
|
19
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
20
|
+
cancel-in-progress: true
|
|
21
|
+
|
|
22
|
+
jobs:
|
|
23
|
+
ci:
|
|
24
|
+
name: CI Pipeline
|
|
25
|
+
runs-on: [self-hosted, linux, x64, docker]
|
|
26
|
+
timeout-minutes: 15
|
|
27
|
+
|
|
28
|
+
steps:
|
|
29
|
+
- name: Checkout
|
|
30
|
+
uses: actions/checkout@v4
|
|
31
|
+
|
|
32
|
+
- name: Setup Node.js
|
|
33
|
+
uses: actions/setup-node@v4
|
|
34
|
+
with:
|
|
35
|
+
node-version: "24"
|
|
36
|
+
cache: "npm"
|
|
37
|
+
|
|
38
|
+
- name: Install dependencies
|
|
39
|
+
run: npm ci
|
|
40
|
+
|
|
41
|
+
- name: Lint
|
|
42
|
+
run: npm run lint
|
|
43
|
+
|
|
44
|
+
- name: Type Check
|
|
45
|
+
run: npm run type-check
|
|
46
|
+
|
|
47
|
+
- name: Build
|
|
48
|
+
run: npm run build
|
|
49
|
+
|
|
50
|
+
- name: Test
|
|
51
|
+
run: npm test
|
|
52
|
+
env:
|
|
53
|
+
CI: true
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
# Pre-push hook - kept lightweight by design
|
|
2
|
+
# Full validation (lint, tests, build) runs in CI asynchronously
|
|
3
|
+
#
|
|
4
|
+
# Uncomment below if you want local type-check before push:
|
|
5
|
+
# npm run type-check
|