@coding-with-hassan/devkit 1.0.0-next.2 → 1.0.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 +18 -5
- package/package.json +1 -1
- package/src/commands/claude.js +9 -1
- package/src/commands/test-cases.js +7 -2
- package/src/core/worktrees.js +3 -1
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# @coding-with-hassan/devkit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The way of working of Hassan's client projects as one versioned package: parallel git worktrees with isolated Docker stacks, the pre-commit chain, a CI job with commit standards and an Nx cache, the Claude Code standards/agents/hooks, and the bilingual acceptance-test workbooks. A project installs it, fills one config block in `package.json`, runs `hassan-devkit init`, and picks up every later standard by bumping the version. Design: `docs/design/way-of-working.md`; decisions: `docs/adr/`.
|
|
4
|
+
|
|
5
|
+
New projects start from [hassan-devkit-template](https://github.com/CodiNG-With-Hassan/hassan-devkit-template), which is exactly what `init` produces on an Nx `apps/*` + `libs/*` pnpm workspace.
|
|
4
6
|
|
|
5
7
|
## Install
|
|
6
8
|
|
|
@@ -38,7 +40,7 @@ Optionally add a `docker.preUp` hook — a shell command `docker:up` runs from t
|
|
|
38
40
|
}
|
|
39
41
|
```
|
|
40
42
|
|
|
41
|
-
## Wire it into your scripts
|
|
43
|
+
## Wire it into your scripts (flat repos; Nx workspaces get this from `init`)
|
|
42
44
|
|
|
43
45
|
```json
|
|
44
46
|
{
|
|
@@ -53,9 +55,9 @@ Optionally add a `docker.preUp` hook — a shell command `docker:up` runs from t
|
|
|
53
55
|
}
|
|
54
56
|
```
|
|
55
57
|
|
|
56
|
-
## The way of working
|
|
58
|
+
## The way of working
|
|
57
59
|
|
|
58
|
-
|
|
60
|
+
Everything below assumes an **Nx `apps/*` + `libs/*` pnpm monorepo** (the template's shape); the `docker:*`, `db:*`, `i18n:check` and `hooks:*` commands further down stay layout-agnostic for the older flat repos. Requires Node ≥ 22.13.
|
|
59
61
|
|
|
60
62
|
### Configure once, derive the rest
|
|
61
63
|
|
|
@@ -168,7 +170,18 @@ import { tc, type Area, type KnownIssue, type Readme } from '@coding-with-hassan
|
|
|
168
170
|
|
|
169
171
|
`hassan-devkit test-cases:generate [--lang xx] [--testers file.json]` writes `test-cases-<suite>-<lang>.xlsx` per suite and language (`testCases.languages`, default `en`, `nl`; workbook UI strings ship for those two) next to the data, plus a personalised copy per tester (Tester column prefilled, credentials in the Read Me sheet). Each workbook has a Read Me, a Summary with per-area counts, one sheet per area with a Pass/Fail/Blocked/Skipped dropdown, and a Known Issues sheet. The workbooks are gitignored artifacts; commit the data files with the feature. The data files are TypeScript loaded through Node's built-in type stripping (Node ≥ 22.13, no `tsx`), which keeps import specifiers verbatim — hence the `type` modifiers above. `testCases.title` sets the project name in the Read Me title. `init` scaffolds a starter `tc-data-app.ts` when the section is configured and the directory is empty.
|
|
170
172
|
|
|
171
|
-
##
|
|
173
|
+
## Upgrading from 0.x
|
|
174
|
+
|
|
175
|
+
- **Node ≥ 22.13** (the acceptance-case generator loads TypeScript data with Node's type stripping).
|
|
176
|
+
- **Config block**: `hassan-devkit.db`, `docker.preUp` and `i18n` keep working; add `worktree`, `tracker`, `commits`, `ci`, `testCases` as needed — `hassan-devkit init --only config` writes the skeleton. Unknown keys are now rejected (`config:check`).
|
|
177
|
+
- **`hooks:install`** no longer runs `husky init` (which rewrote your `prepare` script); it (re)creates husky's per-checkout shims and skips inside container builds (`HUSKY=0`, no `.git`). The hook body gained the `ci:doctor` step for staged workflow files; `i18n:check` stays.
|
|
178
|
+
- **lint-staged**: replace `@coding-with-hassan/lint-staged-config` with `lint-staged.config.mjs` importing `@coding-with-hassan/devkit/lint-staged` (targets derived from the workspace; `init --only hooks` scaffolds it).
|
|
179
|
+
- **`docker:up`** runs `worktree:env` implicitly once `hassan-devkit.worktree` names ports or profiles; a `docker.preUp` hook that only refreshed `.env` can go. Managed `.env` keys are `DEVKIT_SLOT`, `DEVKIT_IMAGE_TAG`, `DEVKIT_BRANCH`, `DEVKIT_PORT_*` — rename them in your compose file.
|
|
180
|
+
- **CI**: `init --only ci --force` writes the thin workflow; delete hand-rolled affected/cache scripts. Commit scopes are derived from the workspace (`commits:show`).
|
|
181
|
+
- **Claude**: `init --only claude,agents` adds the standards import, the stubs, the PR-assignee hook and regenerates `docs/agents`; trim your `CLAUDE.md` to project specifics.
|
|
182
|
+
- Adopt piece by piece with `init --only <part>`; `ci:doctor` reports what is not adopted yet.
|
|
183
|
+
|
|
184
|
+
## Layout-agnostic commands
|
|
172
185
|
|
|
173
186
|
### Docker
|
|
174
187
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coding-with-hassan/devkit",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "CLI for the developer workflow shared across Hassan's client projects: docker compose orchestration, db helpers, and husky hook installation.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Hassan Khousheish",
|
package/src/commands/claude.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
1
3
|
import { loadConfig } from '../core/config.js';
|
|
2
4
|
import { claudePlans } from '../core/claude.js';
|
|
3
5
|
import { applyPlan } from '../core/scaffold.js';
|
|
@@ -8,8 +10,14 @@ import { exitOnFailure } from '../util/run.js';
|
|
|
8
10
|
* standards in CLAUDE.md, the agent/skill stubs and the PR-assignee hook. Idempotent; runs from
|
|
9
11
|
* `prepare` so every checkout has it, and from `init`.
|
|
10
12
|
*/
|
|
11
|
-
export async function installClaude({ cwd = process.cwd(), log = console.log, dryRun = false } = {}) {
|
|
13
|
+
export async function installClaude({ cwd = process.cwd(), env = process.env, log = console.log, dryRun = false } = {}) {
|
|
12
14
|
const { root } = loadConfig({ cwd });
|
|
15
|
+
// Like hooks:install, this runs from `prepare` inside container image builds too (no .git,
|
|
16
|
+
// HUSKY=0): there is no Claude session to serve there, so do not write stubs into the image.
|
|
17
|
+
if (env.HUSKY === '0' || !existsSync(join(root, '.git'))) {
|
|
18
|
+
log('claude layer: no git checkout here (container build or export) — skipping');
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
13
21
|
const summary = applyPlan(root, claudePlans(root), { dryRun, log });
|
|
14
22
|
const touched = summary.created.length + summary.updated.length;
|
|
15
23
|
log(touched ? `claude layer: ${touched} file(s) written` : 'claude layer: up to date');
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { join } from 'node:path';
|
|
1
|
+
import { join, resolve } from 'node:path';
|
|
2
2
|
import { requireConfig, requireSection } from '../core/config.js';
|
|
3
3
|
import { generate } from '../core/test-cases/generate.js';
|
|
4
4
|
import { exitOnFailure } from '../util/run.js';
|
|
5
5
|
|
|
6
|
+
/** Pure: `--testers` accepts a path relative to the cwd or an absolute one. */
|
|
7
|
+
export function resolveTestersPath(cwd, arg) {
|
|
8
|
+
return resolve(cwd, arg);
|
|
9
|
+
}
|
|
10
|
+
|
|
6
11
|
/**
|
|
7
12
|
* `test-cases:generate` — the acceptance-case workbooks from `<testCases.dir>/tc-data-*.ts`.
|
|
8
13
|
* Languages come from `testCases.languages`, the title from `testCases.title` (default: the
|
|
@@ -23,7 +28,7 @@ export function registerTestCases(cli) {
|
|
|
23
28
|
languages: tc.languages,
|
|
24
29
|
project: tc.title ?? loaded.pkg.name ?? loaded.rootName,
|
|
25
30
|
onlyLang: opts.lang ?? null,
|
|
26
|
-
testersFile: opts.testers ?
|
|
31
|
+
testersFile: opts.testers ? resolveTestersPath(process.cwd(), opts.testers) : null,
|
|
27
32
|
});
|
|
28
33
|
}),
|
|
29
34
|
),
|
package/src/core/worktrees.js
CHANGED
|
@@ -303,8 +303,10 @@ export function pruneImages(ctx) {
|
|
|
303
303
|
.filter(Boolean);
|
|
304
304
|
const targets = unreferencedImages(stack.listImages(), { repos: ownedImageRepos(ctx.compose), referencedTags, inUse: stack.imagesInUse() });
|
|
305
305
|
for (const img of targets) {
|
|
306
|
+
// Two checkouts pruning at once race for the same tag: whoever finds it gone stays quiet.
|
|
307
|
+
if (!stack.imageExists(img)) continue;
|
|
306
308
|
if (stack.removeImage(img)) ctx.log(`removed unreferenced dev image ${img}`);
|
|
307
|
-
else ctx.note(`could not remove unreferenced dev image ${img}`);
|
|
309
|
+
else if (stack.imageExists(img)) ctx.note(`could not remove unreferenced dev image ${img}`);
|
|
308
310
|
}
|
|
309
311
|
}
|
|
310
312
|
|