@kb-labs/devkit 1.4.0 → 2.9.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/assets/claude/CLAUDE.md.snippet +30 -0
- package/assets/claude/manifest.json +47 -0
- package/assets/claude/skills/kb-labs-create-plugin/SKILL.md +144 -0
- package/assets/claude/skills/kb-labs-create-product/SKILL.md +144 -0
- package/assets/claude/skills/kb-labs-explore/SKILL.md +119 -0
- package/assets/claude/skills/kb-labs-quickstart/SKILL.md +72 -0
- package/assets/claude/skills/kb-labs-troubleshoot/SKILL.md +150 -0
- package/assets/claude/skills/kb-labs-update/SKILL.md +89 -0
- package/package.json +29 -29
- package/tsconfig/spa.json +7 -0
- package/vitest/node.js +8 -2
- package/vitest/react.js +8 -2
- package/.cursorrules +0 -32
- package/.github/CODEOWNERS +0 -2
- package/.github/actions/setup-node-pnpm/action.yml +0 -47
- package/.github/workflow-templates/ci.yml +0 -13
- package/.github/workflow-templates/deploy.yml +0 -28
- package/.github/workflow-templates/docker-build.yml +0 -25
- package/.github/workflow-templates/drift-check.yml +0 -10
- package/.github/workflow-templates/profiles-validate.yml +0 -16
- package/.github/workflow-templates/release.yml +0 -8
- package/.github/workflows/ci-reusable.yml +0 -131
- package/.github/workflows/deploy-reusable.yml +0 -110
- package/.github/workflows/docker-build-reusable.yml +0 -110
- package/.github/workflows/drift-check-reusable.yml +0 -23
- package/.github/workflows/fixtures.yml +0 -74
- package/.github/workflows/profiles-validate-reusable.yml +0 -67
- package/.github/workflows/release-reusable.yml +0 -50
- package/.vscode/settings.json +0 -23
- package/tsconfig/dist/__tests__/cache.spec.d.ts +0 -6
- package/tsconfig/dist/__tests__/cache.spec.d.ts.map +0 -1
- package/tsconfig/dist/__tests__/cache.spec.js +0 -85
- package/tsconfig/dist/__tests__/cache.spec.js.map +0 -1
- package/tsconfig/dist/__tests__/fs-atomic.spec.d.ts +0 -6
- package/tsconfig/dist/__tests__/fs-atomic.spec.d.ts.map +0 -1
- package/tsconfig/dist/__tests__/fs-atomic.spec.js +0 -153
- package/tsconfig/dist/__tests__/fs-atomic.spec.js.map +0 -1
- package/tsconfig/dist/__tests__/init-workspace.spec.d.ts +0 -6
- package/tsconfig/dist/__tests__/init-workspace.spec.d.ts.map +0 -1
- package/tsconfig/dist/__tests__/init-workspace.spec.js +0 -99
- package/tsconfig/dist/__tests__/init-workspace.spec.js.map +0 -1
- package/tsconfig/dist/__tests__/kb-error.spec.d.ts +0 -6
- package/tsconfig/dist/__tests__/kb-error.spec.d.ts.map +0 -1
- package/tsconfig/dist/__tests__/kb-error.spec.js +0 -190
- package/tsconfig/dist/__tests__/kb-error.spec.js.map +0 -1
- package/tsconfig/dist/__tests__/preset-lockfile.spec.d.ts +0 -6
- package/tsconfig/dist/__tests__/preset-lockfile.spec.d.ts.map +0 -1
- package/tsconfig/dist/__tests__/preset-lockfile.spec.js +0 -142
- package/tsconfig/dist/__tests__/preset-lockfile.spec.js.map +0 -1
- package/tsconfig/dist/__tests__/product-config-profiles.spec.d.ts +0 -6
- package/tsconfig/dist/__tests__/product-config-profiles.spec.d.ts.map +0 -1
- package/tsconfig/dist/__tests__/product-config-profiles.spec.js +0 -100
- package/tsconfig/dist/__tests__/product-config-profiles.spec.js.map +0 -1
- package/tsconfig/dist/__tests__/product-config.spec.d.ts +0 -6
- package/tsconfig/dist/__tests__/product-config.spec.d.ts.map +0 -1
- package/tsconfig/dist/__tests__/product-config.spec.js +0 -298
- package/tsconfig/dist/__tests__/product-config.spec.js.map +0 -1
- package/tsconfig/dist/__tests__/runtime.spec.d.ts +0 -2
- package/tsconfig/dist/__tests__/runtime.spec.d.ts.map +0 -1
- package/tsconfig/dist/__tests__/runtime.spec.js +0 -127
- package/tsconfig/dist/__tests__/runtime.spec.js.map +0 -1
- package/tsconfig/dist/__tests__/upsert-lockfile.spec.d.ts +0 -6
- package/tsconfig/dist/__tests__/upsert-lockfile.spec.d.ts.map +0 -1
- package/tsconfig/dist/__tests__/upsert-lockfile.spec.js +0 -251
- package/tsconfig/dist/__tests__/upsert-lockfile.spec.js.map +0 -1
- package/tsconfig/dist/__tests__/validate-config.spec.d.ts +0 -2
- package/tsconfig/dist/__tests__/validate-config.spec.d.ts.map +0 -1
- package/tsconfig/dist/__tests__/validate-config.spec.js +0 -14
- package/tsconfig/dist/__tests__/validate-config.spec.js.map +0 -1
- package/tsconfig/dist/api/init-workspace.d.ts +0 -10
- package/tsconfig/dist/api/init-workspace.d.ts.map +0 -1
- package/tsconfig/dist/api/init-workspace.js +0 -191
- package/tsconfig/dist/api/init-workspace.js.map +0 -1
- package/tsconfig/dist/api/product-config.d.ts +0 -21
- package/tsconfig/dist/api/product-config.d.ts.map +0 -1
- package/tsconfig/dist/api/product-config.js +0 -192
- package/tsconfig/dist/api/product-config.js.map +0 -1
- package/tsconfig/dist/api/read-config.d.ts +0 -22
- package/tsconfig/dist/api/read-config.d.ts.map +0 -1
- package/tsconfig/dist/api/read-config.js +0 -105
- package/tsconfig/dist/api/read-config.js.map +0 -1
- package/tsconfig/dist/api/upsert-lockfile.d.ts +0 -10
- package/tsconfig/dist/api/upsert-lockfile.d.ts.map +0 -1
- package/tsconfig/dist/api/upsert-lockfile.js +0 -63
- package/tsconfig/dist/api/upsert-lockfile.js.map +0 -1
- package/tsconfig/dist/cache/fs-cache.d.ts +0 -38
- package/tsconfig/dist/cache/fs-cache.d.ts.map +0 -1
- package/tsconfig/dist/cache/fs-cache.js +0 -142
- package/tsconfig/dist/cache/fs-cache.js.map +0 -1
- package/tsconfig/dist/errors/kb-error.d.ts +0 -32
- package/tsconfig/dist/errors/kb-error.d.ts.map +0 -1
- package/tsconfig/dist/errors/kb-error.js +0 -54
- package/tsconfig/dist/errors/kb-error.js.map +0 -1
- package/tsconfig/dist/fs/__tests__/fs.spec.d.ts +0 -2
- package/tsconfig/dist/fs/__tests__/fs.spec.d.ts.map +0 -1
- package/tsconfig/dist/fs/__tests__/fs.spec.js +0 -22
- package/tsconfig/dist/fs/__tests__/fs.spec.js.map +0 -1
- package/tsconfig/dist/fs/fs.d.ts +0 -6
- package/tsconfig/dist/fs/fs.d.ts.map +0 -1
- package/tsconfig/dist/fs/fs.js +0 -12
- package/tsconfig/dist/fs/fs.js.map +0 -1
- package/tsconfig/dist/fs/index.d.ts +0 -2
- package/tsconfig/dist/fs/index.d.ts.map +0 -1
- package/tsconfig/dist/fs/index.js +0 -2
- package/tsconfig/dist/fs/index.js.map +0 -1
- package/tsconfig/dist/hash/config-hash.d.ts +0 -17
- package/tsconfig/dist/hash/config-hash.d.ts.map +0 -1
- package/tsconfig/dist/hash/config-hash.js +0 -55
- package/tsconfig/dist/hash/config-hash.js.map +0 -1
- package/tsconfig/dist/index.d.ts +0 -5
- package/tsconfig/dist/index.d.ts.map +0 -1
- package/tsconfig/dist/index.js +0 -5
- package/tsconfig/dist/index.js.map +0 -1
- package/tsconfig/dist/lockfile/lockfile.d.ts +0 -54
- package/tsconfig/dist/lockfile/lockfile.d.ts.map +0 -1
- package/tsconfig/dist/lockfile/lockfile.js +0 -141
- package/tsconfig/dist/lockfile/lockfile.js.map +0 -1
- package/tsconfig/dist/logging/__tests__/logger.spec.d.ts +0 -2
- package/tsconfig/dist/logging/__tests__/logger.spec.d.ts.map +0 -1
- package/tsconfig/dist/logging/__tests__/logger.spec.js +0 -65
- package/tsconfig/dist/logging/__tests__/logger.spec.js.map +0 -1
- package/tsconfig/dist/logging/__tests__/redaction.spec.d.ts +0 -2
- package/tsconfig/dist/logging/__tests__/redaction.spec.d.ts.map +0 -1
- package/tsconfig/dist/logging/__tests__/redaction.spec.js +0 -34
- package/tsconfig/dist/logging/__tests__/redaction.spec.js.map +0 -1
- package/tsconfig/dist/logging/__tests__/sinks-and-env.spec.d.ts +0 -2
- package/tsconfig/dist/logging/__tests__/sinks-and-env.spec.d.ts.map +0 -1
- package/tsconfig/dist/logging/__tests__/sinks-and-env.spec.js +0 -90
- package/tsconfig/dist/logging/__tests__/sinks-and-env.spec.js.map +0 -1
- package/tsconfig/dist/logging/index.d.ts +0 -6
- package/tsconfig/dist/logging/index.d.ts.map +0 -1
- package/tsconfig/dist/logging/index.js +0 -6
- package/tsconfig/dist/logging/index.js.map +0 -1
- package/tsconfig/dist/logging/logger.d.ts +0 -9
- package/tsconfig/dist/logging/logger.d.ts.map +0 -1
- package/tsconfig/dist/logging/logger.js +0 -101
- package/tsconfig/dist/logging/logger.js.map +0 -1
- package/tsconfig/dist/logging/redaction.d.ts +0 -7
- package/tsconfig/dist/logging/redaction.d.ts.map +0 -1
- package/tsconfig/dist/logging/redaction.js +0 -23
- package/tsconfig/dist/logging/redaction.js.map +0 -1
- package/tsconfig/dist/logging/sinks/json.d.ts +0 -4
- package/tsconfig/dist/logging/sinks/json.d.ts.map +0 -1
- package/tsconfig/dist/logging/sinks/json.js +0 -23
- package/tsconfig/dist/logging/sinks/json.js.map +0 -1
- package/tsconfig/dist/logging/sinks/stdout.d.ts +0 -3
- package/tsconfig/dist/logging/sinks/stdout.d.ts.map +0 -1
- package/tsconfig/dist/logging/sinks/stdout.js +0 -24
- package/tsconfig/dist/logging/sinks/stdout.js.map +0 -1
- package/tsconfig/dist/logging/types/index.d.ts +0 -2
- package/tsconfig/dist/logging/types/index.d.ts.map +0 -1
- package/tsconfig/dist/logging/types/index.js +0 -2
- package/tsconfig/dist/logging/types/index.js.map +0 -1
- package/tsconfig/dist/logging/types/types.d.ts +0 -37
- package/tsconfig/dist/logging/types/types.d.ts.map +0 -1
- package/tsconfig/dist/logging/types/types.js +0 -2
- package/tsconfig/dist/logging/types/types.js.map +0 -1
- package/tsconfig/dist/merge/layered-merge.d.ts +0 -16
- package/tsconfig/dist/merge/layered-merge.d.ts.map +0 -1
- package/tsconfig/dist/merge/layered-merge.js +0 -97
- package/tsconfig/dist/merge/layered-merge.js.map +0 -1
- package/tsconfig/dist/preset/resolve-preset.d.ts +0 -29
- package/tsconfig/dist/preset/resolve-preset.d.ts.map +0 -1
- package/tsconfig/dist/preset/resolve-preset.js +0 -104
- package/tsconfig/dist/preset/resolve-preset.js.map +0 -1
- package/tsconfig/dist/repo/__tests__/repo.spec.d.ts +0 -2
- package/tsconfig/dist/repo/__tests__/repo.spec.d.ts.map +0 -1
- package/tsconfig/dist/repo/__tests__/repo.spec.js +0 -25
- package/tsconfig/dist/repo/__tests__/repo.spec.js.map +0 -1
- package/tsconfig/dist/repo/index.d.ts +0 -2
- package/tsconfig/dist/repo/index.d.ts.map +0 -1
- package/tsconfig/dist/repo/index.js +0 -2
- package/tsconfig/dist/repo/index.js.map +0 -1
- package/tsconfig/dist/repo/repo.d.ts +0 -6
- package/tsconfig/dist/repo/repo.d.ts.map +0 -1
- package/tsconfig/dist/repo/repo.js +0 -25
- package/tsconfig/dist/repo/repo.js.map +0 -1
- package/tsconfig/dist/runtime/index.d.ts +0 -2
- package/tsconfig/dist/runtime/index.d.ts.map +0 -1
- package/tsconfig/dist/runtime/index.js +0 -2
- package/tsconfig/dist/runtime/index.js.map +0 -1
- package/tsconfig/dist/runtime/runtime.d.ts +0 -46
- package/tsconfig/dist/runtime/runtime.d.ts.map +0 -1
- package/tsconfig/dist/runtime/runtime.js +0 -126
- package/tsconfig/dist/runtime/runtime.js.map +0 -1
- package/tsconfig/dist/tsconfig.tools.tsbuildinfo +0 -1
- package/tsconfig/dist/tsconfig.tsbuildinfo +0 -1
- package/tsconfig/dist/types/index.d.ts +0 -2
- package/tsconfig/dist/types/index.d.ts.map +0 -1
- package/tsconfig/dist/types/index.js +0 -2
- package/tsconfig/dist/types/index.js.map +0 -1
- package/tsconfig/dist/types/init.d.ts +0 -34
- package/tsconfig/dist/types/init.d.ts.map +0 -1
- package/tsconfig/dist/types/init.js +0 -6
- package/tsconfig/dist/types/init.js.map +0 -1
- package/tsconfig/dist/types/preset.d.ts +0 -27
- package/tsconfig/dist/types/preset.d.ts.map +0 -1
- package/tsconfig/dist/types/preset.js +0 -6
- package/tsconfig/dist/types/preset.js.map +0 -1
- package/tsconfig/dist/types/types.d.ts +0 -6
- package/tsconfig/dist/types/types.d.ts.map +0 -1
- package/tsconfig/dist/types/types.js +0 -2
- package/tsconfig/dist/types/types.js.map +0 -1
- package/tsconfig/dist/utils/__tests__/env.spec.d.ts +0 -2
- package/tsconfig/dist/utils/__tests__/env.spec.d.ts.map +0 -1
- package/tsconfig/dist/utils/__tests__/env.spec.js +0 -33
- package/tsconfig/dist/utils/__tests__/env.spec.js.map +0 -1
- package/tsconfig/dist/utils/env.d.ts +0 -7
- package/tsconfig/dist/utils/env.d.ts.map +0 -1
- package/tsconfig/dist/utils/env.js +0 -25
- package/tsconfig/dist/utils/env.js.map +0 -1
- package/tsconfig/dist/utils/fs-atomic.d.ts +0 -15
- package/tsconfig/dist/utils/fs-atomic.d.ts.map +0 -1
- package/tsconfig/dist/utils/fs-atomic.js +0 -45
- package/tsconfig/dist/utils/fs-atomic.js.map +0 -1
- package/tsconfig/dist/utils/index.d.ts +0 -3
- package/tsconfig/dist/utils/index.d.ts.map +0 -1
- package/tsconfig/dist/utils/index.js +0 -3
- package/tsconfig/dist/utils/index.js.map +0 -1
- package/tsconfig/dist/utils/paths.d.ts +0 -21
- package/tsconfig/dist/utils/paths.d.ts.map +0 -1
- package/tsconfig/dist/utils/paths.js +0 -32
- package/tsconfig/dist/utils/paths.js.map +0 -1
- package/tsconfig/dist/utils/product-normalize.d.ts +0 -27
- package/tsconfig/dist/utils/product-normalize.d.ts.map +0 -1
- package/tsconfig/dist/utils/product-normalize.js +0 -45
- package/tsconfig/dist/utils/product-normalize.js.map +0 -1
- package/tsconfig/dist/validation/validate-config.d.ts +0 -7
- package/tsconfig/dist/validation/validate-config.d.ts.map +0 -1
- package/tsconfig/dist/validation/validate-config.js +0 -22
- package/tsconfig/dist/validation/validate-config.js.map +0 -1
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
name: reusable-ci
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
workflow_call:
|
|
5
|
-
inputs:
|
|
6
|
-
node-version:
|
|
7
|
-
description: Node.js version
|
|
8
|
-
required: false
|
|
9
|
-
default: '20'
|
|
10
|
-
type: string
|
|
11
|
-
run-coverage:
|
|
12
|
-
description: Run coverage step
|
|
13
|
-
required: false
|
|
14
|
-
default: true
|
|
15
|
-
type: boolean
|
|
16
|
-
enable-drift-check:
|
|
17
|
-
description: Run DevKit drift check (fails on drift)
|
|
18
|
-
required: false
|
|
19
|
-
default: true
|
|
20
|
-
type: boolean
|
|
21
|
-
|
|
22
|
-
jobs:
|
|
23
|
-
drift:
|
|
24
|
-
if: ${{ inputs.enable-drift-check == true }}
|
|
25
|
-
runs-on: ubuntu-latest
|
|
26
|
-
permissions:
|
|
27
|
-
contents: read
|
|
28
|
-
concurrency:
|
|
29
|
-
group: ${{ github.workflow }}-${{ github.ref }}-drift
|
|
30
|
-
cancel-in-progress: true
|
|
31
|
-
steps:
|
|
32
|
-
- uses: actions/checkout@v4
|
|
33
|
-
- uses: KirillBaranov/kb-labs-devkit/.github/actions/setup-node-pnpm@main
|
|
34
|
-
with:
|
|
35
|
-
node-version: ${{ inputs['node-version'] }}
|
|
36
|
-
- name: Install deps
|
|
37
|
-
run: pnpm i --frozen-lockfile
|
|
38
|
-
- name: DevKit drift check
|
|
39
|
-
# Repos are expected to ship a script `devkit:check` that runs the sync tool in check mode
|
|
40
|
-
run: pnpm -s devkit:check
|
|
41
|
-
|
|
42
|
-
validate:
|
|
43
|
-
runs-on: ubuntu-latest
|
|
44
|
-
permissions:
|
|
45
|
-
contents: read
|
|
46
|
-
concurrency:
|
|
47
|
-
group: ${{ github.workflow }}-${{ github.ref }}-validate
|
|
48
|
-
cancel-in-progress: true
|
|
49
|
-
steps:
|
|
50
|
-
- uses: actions/checkout@v4
|
|
51
|
-
- uses: KirillBaranov/kb-labs-devkit/.github/actions/setup-node-pnpm@main
|
|
52
|
-
with:
|
|
53
|
-
node-version: ${{ inputs['node-version'] }}
|
|
54
|
-
- name: Install deps
|
|
55
|
-
run: pnpm i --frozen-lockfile
|
|
56
|
-
- name: Lint
|
|
57
|
-
run: pnpm lint
|
|
58
|
-
- name: Type check
|
|
59
|
-
run: pnpm type-check || true
|
|
60
|
-
|
|
61
|
-
build:
|
|
62
|
-
runs-on: ubuntu-latest
|
|
63
|
-
needs: validate
|
|
64
|
-
permissions:
|
|
65
|
-
contents: read
|
|
66
|
-
steps:
|
|
67
|
-
- uses: actions/checkout@v4
|
|
68
|
-
- uses: KirillBaranov/kb-labs-devkit/.github/actions/setup-node-pnpm@main
|
|
69
|
-
with:
|
|
70
|
-
node-version: ${{ inputs['node-version'] }}
|
|
71
|
-
- name: Install deps
|
|
72
|
-
run: pnpm i --frozen-lockfile
|
|
73
|
-
- name: Build (workspace)
|
|
74
|
-
run: pnpm -r run build || true
|
|
75
|
-
- name: Upload build outputs
|
|
76
|
-
uses: actions/upload-artifact@v4
|
|
77
|
-
with:
|
|
78
|
-
name: build-dist
|
|
79
|
-
path: |
|
|
80
|
-
packages/**/dist/
|
|
81
|
-
dist/
|
|
82
|
-
if-no-files-found: ignore
|
|
83
|
-
|
|
84
|
-
test:
|
|
85
|
-
runs-on: ubuntu-latest
|
|
86
|
-
needs: build
|
|
87
|
-
permissions:
|
|
88
|
-
contents: read
|
|
89
|
-
steps:
|
|
90
|
-
- uses: actions/checkout@v4
|
|
91
|
-
- uses: KirillBaranov/kb-labs-devkit/.github/actions/setup-node-pnpm@main
|
|
92
|
-
with:
|
|
93
|
-
node-version: ${{ inputs['node-version'] }}
|
|
94
|
-
- name: Install deps
|
|
95
|
-
run: pnpm i --frozen-lockfile
|
|
96
|
-
- name: Download build outputs
|
|
97
|
-
uses: actions/download-artifact@v4
|
|
98
|
-
with:
|
|
99
|
-
name: build-dist
|
|
100
|
-
path: .
|
|
101
|
-
- name: Test (no watch)
|
|
102
|
-
run: pnpm test -- --run
|
|
103
|
-
|
|
104
|
-
coverage:
|
|
105
|
-
if: ${{ inputs['run-coverage'] == true }}
|
|
106
|
-
runs-on: ubuntu-latest
|
|
107
|
-
needs: build
|
|
108
|
-
permissions:
|
|
109
|
-
contents: read
|
|
110
|
-
steps:
|
|
111
|
-
- uses: actions/checkout@v4
|
|
112
|
-
- uses: KirillBaranov/kb-labs-devkit/.github/actions/setup-node-pnpm@main
|
|
113
|
-
with:
|
|
114
|
-
node-version: ${{ inputs['node-version'] }}
|
|
115
|
-
- name: Install deps
|
|
116
|
-
run: pnpm i --frozen-lockfile
|
|
117
|
-
- name: Download build outputs
|
|
118
|
-
uses: actions/download-artifact@v4
|
|
119
|
-
with:
|
|
120
|
-
name: build-dist
|
|
121
|
-
path: .
|
|
122
|
-
- name: Coverage
|
|
123
|
-
run: pnpm test:coverage
|
|
124
|
-
- name: Upload coverage (if any)
|
|
125
|
-
uses: actions/upload-artifact@v4
|
|
126
|
-
with:
|
|
127
|
-
name: coverage-html
|
|
128
|
-
path: |
|
|
129
|
-
coverage/
|
|
130
|
-
**/coverage/
|
|
131
|
-
if-no-files-found: ignore
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
name: reusable-deploy
|
|
2
|
-
|
|
3
|
-
# Reusable workflow: deploy to VPS via SSH + docker compose
|
|
4
|
-
#
|
|
5
|
-
# Usage in orchestrator repo (e.g. kb-labs root):
|
|
6
|
-
# jobs:
|
|
7
|
-
# call:
|
|
8
|
-
# uses: KirillBaranov/kb-labs-devkit/.github/workflows/deploy-reusable.yml@main
|
|
9
|
-
# with:
|
|
10
|
-
# image-tag: release-1.0.0
|
|
11
|
-
# compose-file: docker-compose.production.yml
|
|
12
|
-
# secrets: inherit
|
|
13
|
-
#
|
|
14
|
-
# Required secrets in calling repo:
|
|
15
|
-
# VPS_HOST, VPS_USER, VPS_SSH_KEY
|
|
16
|
-
|
|
17
|
-
on:
|
|
18
|
-
workflow_call:
|
|
19
|
-
inputs:
|
|
20
|
-
image-tag:
|
|
21
|
-
description: Docker image tag to deploy (e.g. release-1.0.0)
|
|
22
|
-
required: true
|
|
23
|
-
type: string
|
|
24
|
-
compose-file:
|
|
25
|
-
description: Path to docker-compose file on VPS
|
|
26
|
-
required: false
|
|
27
|
-
default: docker-compose.production.yml
|
|
28
|
-
type: string
|
|
29
|
-
deploy-dir:
|
|
30
|
-
description: Working directory on VPS
|
|
31
|
-
required: false
|
|
32
|
-
default: /opt/kb-labs
|
|
33
|
-
type: string
|
|
34
|
-
registry:
|
|
35
|
-
description: Container registry host
|
|
36
|
-
required: false
|
|
37
|
-
default: ghcr.io
|
|
38
|
-
type: string
|
|
39
|
-
health-check-url:
|
|
40
|
-
description: URL to check after deploy (e.g. http://localhost:5050/api/v1/health)
|
|
41
|
-
required: false
|
|
42
|
-
default: ''
|
|
43
|
-
type: string
|
|
44
|
-
health-check-wait:
|
|
45
|
-
description: Seconds to wait before health check
|
|
46
|
-
required: false
|
|
47
|
-
default: '15'
|
|
48
|
-
type: string
|
|
49
|
-
secrets:
|
|
50
|
-
VPS_HOST:
|
|
51
|
-
required: true
|
|
52
|
-
VPS_USER:
|
|
53
|
-
required: true
|
|
54
|
-
VPS_SSH_KEY:
|
|
55
|
-
required: true
|
|
56
|
-
|
|
57
|
-
jobs:
|
|
58
|
-
deploy:
|
|
59
|
-
name: Deploy to VPS
|
|
60
|
-
runs-on: ubuntu-latest
|
|
61
|
-
environment: production
|
|
62
|
-
|
|
63
|
-
steps:
|
|
64
|
-
- name: Deploy via SSH
|
|
65
|
-
uses: appleboy/ssh-action@v1
|
|
66
|
-
env:
|
|
67
|
-
DEPLOY_TAG: ${{ inputs.image-tag }}
|
|
68
|
-
DEPLOY_REGISTRY: ${{ inputs.registry }}/${{ github.repository_owner }}
|
|
69
|
-
with:
|
|
70
|
-
host: ${{ secrets.VPS_HOST }}
|
|
71
|
-
username: ${{ secrets.VPS_USER }}
|
|
72
|
-
key: ${{ secrets.VPS_SSH_KEY }}
|
|
73
|
-
envs: DEPLOY_TAG,DEPLOY_REGISTRY
|
|
74
|
-
script: |
|
|
75
|
-
set -euo pipefail
|
|
76
|
-
cd ${{ inputs.deploy-dir }}
|
|
77
|
-
|
|
78
|
-
echo "→ Deploying tag: $DEPLOY_TAG"
|
|
79
|
-
echo "→ Registry: $DEPLOY_REGISTRY"
|
|
80
|
-
|
|
81
|
-
# Save current tag for rollback
|
|
82
|
-
[ -f .current-tag ] && cp .current-tag .previous-tag
|
|
83
|
-
echo "$DEPLOY_TAG" > .current-tag
|
|
84
|
-
|
|
85
|
-
# Pull new images
|
|
86
|
-
TAG="$DEPLOY_TAG" REGISTRY="$DEPLOY_REGISTRY" \
|
|
87
|
-
docker compose -f ${{ inputs.compose-file }} pull
|
|
88
|
-
|
|
89
|
-
# Rolling update
|
|
90
|
-
TAG="$DEPLOY_TAG" REGISTRY="$DEPLOY_REGISTRY" \
|
|
91
|
-
docker compose -f ${{ inputs.compose-file }} up -d --remove-orphans
|
|
92
|
-
|
|
93
|
-
echo "→ Containers started, waiting ${{ inputs.health-check-wait }}s..."
|
|
94
|
-
sleep ${{ inputs.health-check-wait }}
|
|
95
|
-
|
|
96
|
-
# Show status
|
|
97
|
-
docker compose -f ${{ inputs.compose-file }} ps
|
|
98
|
-
|
|
99
|
-
# Health check (if URL provided)
|
|
100
|
-
if [ -n "${{ inputs.health-check-url }}" ]; then
|
|
101
|
-
echo "→ Health check: ${{ inputs.health-check-url }}"
|
|
102
|
-
wget -qO- "${{ inputs.health-check-url }}" \
|
|
103
|
-
&& echo "✓ Health check passed" \
|
|
104
|
-
|| { echo "✗ Health check failed!"; exit 1; }
|
|
105
|
-
fi
|
|
106
|
-
|
|
107
|
-
# Cleanup old images
|
|
108
|
-
docker image prune -f > /dev/null 2>&1 || true
|
|
109
|
-
|
|
110
|
-
echo "✓ Deploy complete: $DEPLOY_TAG"
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
name: reusable-docker-build
|
|
2
|
-
|
|
3
|
-
# Reusable workflow: build Docker image and push to ghcr.io
|
|
4
|
-
#
|
|
5
|
-
# Usage in consumer repo:
|
|
6
|
-
# jobs:
|
|
7
|
-
# call:
|
|
8
|
-
# uses: KirillBaranov/kb-labs-devkit/.github/workflows/docker-build-reusable.yml@main
|
|
9
|
-
# with:
|
|
10
|
-
# image-name: kb-labs-rest-api
|
|
11
|
-
# dockerfile: Dockerfile
|
|
12
|
-
# secrets: inherit
|
|
13
|
-
|
|
14
|
-
on:
|
|
15
|
-
workflow_call:
|
|
16
|
-
inputs:
|
|
17
|
-
image-name:
|
|
18
|
-
description: Docker image name (e.g. kb-labs-rest-api)
|
|
19
|
-
required: true
|
|
20
|
-
type: string
|
|
21
|
-
dockerfile:
|
|
22
|
-
description: Path to Dockerfile (relative to context)
|
|
23
|
-
required: false
|
|
24
|
-
default: Dockerfile
|
|
25
|
-
type: string
|
|
26
|
-
context:
|
|
27
|
-
description: Docker build context (default is repo root)
|
|
28
|
-
required: false
|
|
29
|
-
default: .
|
|
30
|
-
type: string
|
|
31
|
-
build-args:
|
|
32
|
-
description: Build args as multiline string (KEY=VALUE per line)
|
|
33
|
-
required: false
|
|
34
|
-
default: ''
|
|
35
|
-
type: string
|
|
36
|
-
platforms:
|
|
37
|
-
description: Target platforms (e.g. linux/amd64,linux/arm64)
|
|
38
|
-
required: false
|
|
39
|
-
default: linux/amd64
|
|
40
|
-
type: string
|
|
41
|
-
registry:
|
|
42
|
-
description: Container registry host
|
|
43
|
-
required: false
|
|
44
|
-
default: ghcr.io
|
|
45
|
-
type: string
|
|
46
|
-
outputs:
|
|
47
|
-
image-tag:
|
|
48
|
-
description: Full image tag that was pushed
|
|
49
|
-
value: ${{ jobs.build.outputs.image-tag }}
|
|
50
|
-
short-sha:
|
|
51
|
-
description: Short commit SHA used as tag
|
|
52
|
-
value: ${{ jobs.build.outputs.short-sha }}
|
|
53
|
-
|
|
54
|
-
jobs:
|
|
55
|
-
build:
|
|
56
|
-
name: Build & Push
|
|
57
|
-
runs-on: ubuntu-latest
|
|
58
|
-
permissions:
|
|
59
|
-
contents: read
|
|
60
|
-
packages: write
|
|
61
|
-
|
|
62
|
-
outputs:
|
|
63
|
-
image-tag: ${{ steps.meta.outputs.version }}
|
|
64
|
-
short-sha: ${{ steps.sha.outputs.short }}
|
|
65
|
-
|
|
66
|
-
steps:
|
|
67
|
-
- name: Checkout
|
|
68
|
-
uses: actions/checkout@v4
|
|
69
|
-
with:
|
|
70
|
-
submodules: recursive
|
|
71
|
-
|
|
72
|
-
- name: Get short SHA
|
|
73
|
-
id: sha
|
|
74
|
-
run: echo "short=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
|
|
75
|
-
|
|
76
|
-
- name: Log in to Container Registry
|
|
77
|
-
uses: docker/login-action@v3
|
|
78
|
-
with:
|
|
79
|
-
registry: ${{ inputs.registry }}
|
|
80
|
-
username: ${{ github.actor }}
|
|
81
|
-
password: ${{ secrets.GITHUB_TOKEN }}
|
|
82
|
-
|
|
83
|
-
- name: Set up Docker Buildx
|
|
84
|
-
uses: docker/setup-buildx-action@v3
|
|
85
|
-
|
|
86
|
-
- name: Docker metadata
|
|
87
|
-
id: meta
|
|
88
|
-
uses: docker/metadata-action@v5
|
|
89
|
-
with:
|
|
90
|
-
images: ${{ inputs.registry }}/${{ github.repository_owner }}/${{ inputs.image-name }}
|
|
91
|
-
tags: |
|
|
92
|
-
# rc branch → rc-<sha>
|
|
93
|
-
type=raw,value=rc-${{ steps.sha.outputs.short }},enable=${{ github.ref == 'refs/heads/rc' }}
|
|
94
|
-
# release tag → release-1.0.0
|
|
95
|
-
type=raw,value=${{ github.ref_name }},enable=${{ startsWith(github.ref, 'refs/tags/release-') }}
|
|
96
|
-
# always tag latest on release
|
|
97
|
-
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/release-') }}
|
|
98
|
-
|
|
99
|
-
- name: Build and push
|
|
100
|
-
uses: docker/build-push-action@v6
|
|
101
|
-
with:
|
|
102
|
-
context: ${{ inputs.context }}
|
|
103
|
-
file: ${{ inputs.dockerfile }}
|
|
104
|
-
platforms: ${{ inputs.platforms }}
|
|
105
|
-
push: true
|
|
106
|
-
tags: ${{ steps.meta.outputs.tags }}
|
|
107
|
-
labels: ${{ steps.meta.outputs.labels }}
|
|
108
|
-
build-args: ${{ inputs.build-args }}
|
|
109
|
-
cache-from: type=gha,scope=${{ inputs.image-name }}
|
|
110
|
-
cache-to: type=gha,mode=max,scope=${{ inputs.image-name }}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
name: reusable-drift-check
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
workflow_call:
|
|
5
|
-
inputs:
|
|
6
|
-
node-version:
|
|
7
|
-
default: '20'
|
|
8
|
-
type: string
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
drift:
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
steps:
|
|
14
|
-
- uses: actions/checkout@v4
|
|
15
|
-
- uses: KirillBaranov/kb-labs-devkit/.github/actions/setup-node-pnpm@main
|
|
16
|
-
with:
|
|
17
|
-
node-version: ${{ inputs.node-version }}
|
|
18
|
-
- run: pnpm i --frozen-lockfile
|
|
19
|
-
- name: DevKit drift check
|
|
20
|
-
run: |
|
|
21
|
-
pnpm -s devkit:check || \
|
|
22
|
-
node scripts/devkit-sync.mjs --check || \
|
|
23
|
-
./node_modules/.bin/kb-devkit-sync --check
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
name: DevKit Fixtures
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [ main ]
|
|
6
|
-
paths-ignore:
|
|
7
|
-
- '**/*.md'
|
|
8
|
-
- '**/.vscode/**'
|
|
9
|
-
- '**/.idea/**'
|
|
10
|
-
pull_request:
|
|
11
|
-
types: [opened, synchronize, reopened]
|
|
12
|
-
workflow_dispatch: {}
|
|
13
|
-
schedule:
|
|
14
|
-
- cron: '0 3 * * 1' # weekly canary (Mon 03:00 UTC)
|
|
15
|
-
|
|
16
|
-
permissions:
|
|
17
|
-
contents: read
|
|
18
|
-
|
|
19
|
-
concurrency:
|
|
20
|
-
group: devkit-fixtures-${{ github.event.pull_request.number || github.sha }}
|
|
21
|
-
cancel-in-progress: true
|
|
22
|
-
|
|
23
|
-
jobs:
|
|
24
|
-
fixtures:
|
|
25
|
-
name: Run fixtures (all)
|
|
26
|
-
runs-on: ubuntu-latest
|
|
27
|
-
env:
|
|
28
|
-
CI: true
|
|
29
|
-
|
|
30
|
-
steps:
|
|
31
|
-
- uses: actions/checkout@v4
|
|
32
|
-
with: { fetch-depth: 0 }
|
|
33
|
-
|
|
34
|
-
- uses: KirillBaranov/kb-labs-devkit/.github/actions/setup-node-pnpm@main
|
|
35
|
-
with:
|
|
36
|
-
node-version: '20'
|
|
37
|
-
|
|
38
|
-
- name: Cache pnpm store
|
|
39
|
-
uses: actions/cache@v4
|
|
40
|
-
with:
|
|
41
|
-
path: ~/.pnpm-store
|
|
42
|
-
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
43
|
-
restore-keys: |
|
|
44
|
-
${{ runner.os }}-pnpm-store-
|
|
45
|
-
|
|
46
|
-
- name: Install DevKit deps
|
|
47
|
-
run: pnpm i --frozen-lockfile
|
|
48
|
-
|
|
49
|
-
- name: Clean fixtures
|
|
50
|
-
run: pnpm fixtures:clean || true
|
|
51
|
-
|
|
52
|
-
- name: Bootstrap fixtures
|
|
53
|
-
run: pnpm fixtures:bootstrap
|
|
54
|
-
|
|
55
|
-
- name: Run fixtures (smart check)
|
|
56
|
-
shell: bash
|
|
57
|
-
run: |
|
|
58
|
-
if [ "${{ github.event_name }}" = "pull_request" ] && [ -n "${{ github.base_ref }}" ]; then
|
|
59
|
-
echo "Running differential fixtures check since origin/${{ github.base_ref }}"
|
|
60
|
-
pnpm fixtures -- --action=check --since=origin/${{ github.base_ref }}
|
|
61
|
-
else
|
|
62
|
-
echo "Running full fixtures check"
|
|
63
|
-
pnpm fixtures:check
|
|
64
|
-
fi
|
|
65
|
-
|
|
66
|
-
- name: Upload artifacts (optional)
|
|
67
|
-
if: always()
|
|
68
|
-
uses: actions/upload-artifact@v4
|
|
69
|
-
with:
|
|
70
|
-
name: fixtures-artifacts
|
|
71
|
-
path: |
|
|
72
|
-
fixtures/**/coverage/**
|
|
73
|
-
fixtures/**/dist/**
|
|
74
|
-
if-no-files-found: ignore
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
name: profiles-validate
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
workflow_call:
|
|
5
|
-
inputs:
|
|
6
|
-
node_version:
|
|
7
|
-
type: string
|
|
8
|
-
default: '20'
|
|
9
|
-
soft_fail:
|
|
10
|
-
type: boolean
|
|
11
|
-
default: true # don't fail, while profiles are in development
|
|
12
|
-
working_directory:
|
|
13
|
-
type: string
|
|
14
|
-
default: '.' # for monorepo — can specify the package path
|
|
15
|
-
log_level:
|
|
16
|
-
type: string
|
|
17
|
-
default: 'info' # debug|info|warn|error
|
|
18
|
-
fixtures_dir:
|
|
19
|
-
type: string
|
|
20
|
-
default: '' # optional, if there are presets/fixtures
|
|
21
|
-
|
|
22
|
-
jobs:
|
|
23
|
-
validate:
|
|
24
|
-
runs-on: ubuntu-latest
|
|
25
|
-
|
|
26
|
-
steps:
|
|
27
|
-
- uses: actions/checkout@v4
|
|
28
|
-
|
|
29
|
-
- name: Detect .kb/profiles
|
|
30
|
-
id: detect
|
|
31
|
-
shell: bash
|
|
32
|
-
run: |
|
|
33
|
-
ROOT="${{ inputs.working_directory }}"
|
|
34
|
-
if [ -d "$ROOT/.kb/profiles" ]; then
|
|
35
|
-
echo "found=true" >> "$GITHUB_OUTPUT"
|
|
36
|
-
echo "[profiles] found at $ROOT/.kb/profiles"
|
|
37
|
-
else
|
|
38
|
-
echo "found=false" >> "$GITHUB_OUTPUT"
|
|
39
|
-
echo "[profiles] not found, skip"
|
|
40
|
-
fi
|
|
41
|
-
|
|
42
|
-
- name: Setup Node & pnpm
|
|
43
|
-
if: steps.detect.outputs.found == 'true'
|
|
44
|
-
uses: KirillBaranov/kb-labs-devkit/.github/actions/setup-node-pnpm@main
|
|
45
|
-
with:
|
|
46
|
-
node-version: ${{ inputs.node_version }}
|
|
47
|
-
|
|
48
|
-
- name: Install deps
|
|
49
|
-
if: steps.detect.outputs.found == 'true'
|
|
50
|
-
run: pnpm i --frozen-lockfile
|
|
51
|
-
working-directory: ${{ inputs.working_directory }}
|
|
52
|
-
|
|
53
|
-
- name: Validate profiles
|
|
54
|
-
if: steps.detect.outputs.found == 'true'
|
|
55
|
-
continue-on-error: ${{ inputs.soft_fail }}
|
|
56
|
-
env:
|
|
57
|
-
LOG_LEVEL: ${{ inputs.log_level }}
|
|
58
|
-
KB_PROFILES_FIXTURES: ${{ inputs.fixtures_dir }}
|
|
59
|
-
shell: bash
|
|
60
|
-
run: |
|
|
61
|
-
# if kb-CLI is available, use it, otherwise use the package schemas
|
|
62
|
-
if pnpm -s kb --help >/dev/null 2>&1; then
|
|
63
|
-
pnpm -s kb profiles validate
|
|
64
|
-
else
|
|
65
|
-
pnpm -F @kb-labs/profile-schemas -s run schemas:check
|
|
66
|
-
fi
|
|
67
|
-
working-directory: ${{ inputs.working_directory }}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
name: reusable-release
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
workflow_call:
|
|
5
|
-
inputs:
|
|
6
|
-
publish:
|
|
7
|
-
description: Publish to npm
|
|
8
|
-
required: false
|
|
9
|
-
default: false
|
|
10
|
-
type: boolean
|
|
11
|
-
node-version:
|
|
12
|
-
default: '20'
|
|
13
|
-
type: string
|
|
14
|
-
secrets:
|
|
15
|
-
NPM_TOKEN:
|
|
16
|
-
required: false
|
|
17
|
-
|
|
18
|
-
jobs:
|
|
19
|
-
release:
|
|
20
|
-
runs-on: ubuntu-latest
|
|
21
|
-
permissions:
|
|
22
|
-
contents: write
|
|
23
|
-
steps:
|
|
24
|
-
- uses: actions/checkout@v4
|
|
25
|
-
|
|
26
|
-
# Composite action: pnpm + Node + cache
|
|
27
|
-
- uses: KirillBaranov/kb-labs-devkit/.github/actions/setup-node-pnpm@main
|
|
28
|
-
with:
|
|
29
|
-
node-version: ${{ inputs['node-version'] }}
|
|
30
|
-
|
|
31
|
-
# Add registry for npm publish (separate step — так надёжнее)
|
|
32
|
-
- uses: actions/setup-node@v4
|
|
33
|
-
with:
|
|
34
|
-
node-version: ${{ inputs['node-version'] }}
|
|
35
|
-
cache: pnpm
|
|
36
|
-
registry-url: 'https://registry.npmjs.org'
|
|
37
|
-
|
|
38
|
-
- run: pnpm i --frozen-lockfile
|
|
39
|
-
- run: pnpm build || true
|
|
40
|
-
|
|
41
|
-
- name: Create GitHub Release
|
|
42
|
-
uses: softprops/action-gh-release@v2
|
|
43
|
-
with:
|
|
44
|
-
generate_release_notes: true
|
|
45
|
-
|
|
46
|
-
- name: Publish to npm
|
|
47
|
-
if: ${{ inputs.publish == true }}
|
|
48
|
-
env:
|
|
49
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
50
|
-
run: pnpm -r publish --access public --no-git-checks
|
package/.vscode/settings.json
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"editor.tabSize": 2,
|
|
3
|
-
"editor.insertSpaces": true,
|
|
4
|
-
"editor.formatOnSave": true,
|
|
5
|
-
"files.eol": "\n",
|
|
6
|
-
// ESLint (flat config)
|
|
7
|
-
"eslint.useFlatConfig": true,
|
|
8
|
-
"eslint.experimental.useFlatConfig": true,
|
|
9
|
-
"eslint.validate": [
|
|
10
|
-
"javascript",
|
|
11
|
-
"javascriptreact",
|
|
12
|
-
"typescript",
|
|
13
|
-
"typescriptreact",
|
|
14
|
-
"vue"
|
|
15
|
-
],
|
|
16
|
-
// Prettier
|
|
17
|
-
"prettier.requireConfig": true,
|
|
18
|
-
// TypeScript: использовать локальную версию в репозитории
|
|
19
|
-
"typescript.tsdk": "node_modules/typescript/lib",
|
|
20
|
-
// Vitest
|
|
21
|
-
"vitest.enable": true,
|
|
22
|
-
"vitest.disableWorkspaceWarning": true
|
|
23
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cache.spec.d.ts","sourceRoot":"","sources":["../../../../kb-labs-core/packages/config/src/__tests__/cache.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module @kb-labs/core/config/__tests__/cache.spec.ts
|
|
3
|
-
* Tests for filesystem cache functionality
|
|
4
|
-
*/
|
|
5
|
-
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
6
|
-
import { promises as fsp } from 'node:fs';
|
|
7
|
-
import path from 'node:path';
|
|
8
|
-
import { tmpdir } from 'node:os';
|
|
9
|
-
import { fsCache, clearCaches } from '../cache/fs-cache';
|
|
10
|
-
import { readConfigFile } from '../api/read-config';
|
|
11
|
-
describe('Filesystem Cache', () => {
|
|
12
|
-
let testDir;
|
|
13
|
-
beforeEach(async () => {
|
|
14
|
-
testDir = path.join(tmpdir(), `kb-labs-cache-test-${Date.now()}`);
|
|
15
|
-
await fsp.mkdir(testDir, { recursive: true });
|
|
16
|
-
clearCaches();
|
|
17
|
-
});
|
|
18
|
-
afterEach(async () => {
|
|
19
|
-
await fsp.rm(testDir, { recursive: true, force: true });
|
|
20
|
-
clearCaches();
|
|
21
|
-
});
|
|
22
|
-
describe('Cache Operations', () => {
|
|
23
|
-
it('should cache file reads', async () => {
|
|
24
|
-
const configPath = path.join(testDir, 'test-config.json');
|
|
25
|
-
const configData = { test: 'value' };
|
|
26
|
-
await fsp.writeFile(configPath, JSON.stringify(configData, null, 2));
|
|
27
|
-
// First read - should not be cached
|
|
28
|
-
const result1 = await readConfigFile(configPath);
|
|
29
|
-
expect(result1.data).toEqual(configData);
|
|
30
|
-
// Second read - should be cached
|
|
31
|
-
const result2 = await readConfigFile(configPath);
|
|
32
|
-
expect(result2.data).toEqual(configData);
|
|
33
|
-
});
|
|
34
|
-
it('should invalidate cache on file change', async () => {
|
|
35
|
-
const configPath = path.join(testDir, 'test-config.json');
|
|
36
|
-
const configData1 = { test: 'value1' };
|
|
37
|
-
const configData2 = { test: 'value2' };
|
|
38
|
-
await fsp.writeFile(configPath, JSON.stringify(configData1, null, 2));
|
|
39
|
-
// First read
|
|
40
|
-
const result1 = await readConfigFile(configPath);
|
|
41
|
-
expect(result1.data).toEqual(configData1);
|
|
42
|
-
// Small delay to ensure mtime changes
|
|
43
|
-
await new Promise(resolve => setTimeout(resolve, 10));
|
|
44
|
-
// Modify file
|
|
45
|
-
await fsp.writeFile(configPath, JSON.stringify(configData2, null, 2));
|
|
46
|
-
// Second read - should get new data
|
|
47
|
-
const result2 = await readConfigFile(configPath);
|
|
48
|
-
expect(result2.data).toEqual(configData2);
|
|
49
|
-
});
|
|
50
|
-
it('should clear caches', async () => {
|
|
51
|
-
const configPath = path.join(testDir, 'test-config.json');
|
|
52
|
-
const configData = { test: 'value' };
|
|
53
|
-
await fsp.writeFile(configPath, JSON.stringify(configData, null, 2));
|
|
54
|
-
// Read to populate cache
|
|
55
|
-
await readConfigFile(configPath);
|
|
56
|
-
// Clear cache
|
|
57
|
-
clearCaches();
|
|
58
|
-
// Verify cache is cleared by checking stats
|
|
59
|
-
const stats = fsCache.getStats();
|
|
60
|
-
expect(stats.size).toBe(0);
|
|
61
|
-
});
|
|
62
|
-
it('should handle YAML files', async () => {
|
|
63
|
-
const configPath = path.join(testDir, 'test-config.yaml');
|
|
64
|
-
const configData = { test: 'value', nested: { key: 'value' } };
|
|
65
|
-
await fsp.writeFile(configPath, `test: value\nnested:\n key: value`);
|
|
66
|
-
const result = await readConfigFile(configPath);
|
|
67
|
-
expect(result.format).toBe('yaml');
|
|
68
|
-
expect(result.data).toEqual(configData);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
describe('Cache Statistics', () => {
|
|
72
|
-
it('should track cache size', async () => {
|
|
73
|
-
const configPath1 = path.join(testDir, 'config1.json');
|
|
74
|
-
const configPath2 = path.join(testDir, 'config2.json');
|
|
75
|
-
await fsp.writeFile(configPath1, JSON.stringify({ test1: 'value1' }));
|
|
76
|
-
await fsp.writeFile(configPath2, JSON.stringify({ test2: 'value2' }));
|
|
77
|
-
// Read both files
|
|
78
|
-
await readConfigFile(configPath1);
|
|
79
|
-
await readConfigFile(configPath2);
|
|
80
|
-
const stats = fsCache.getStats();
|
|
81
|
-
expect(stats.size).toBeGreaterThan(0);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
//# sourceMappingURL=cache.spec.js.map
|