@maniumek/suwgate 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +149 -2
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +97 -0
- package/dist/dev/checkoutEnv.d.ts +20 -0
- package/dist/dev/checkoutEnv.js +101 -0
- package/dist/dev/db.d.ts +25 -0
- package/dist/dev/db.js +103 -0
- package/dist/dev/index.d.ts +16 -0
- package/dist/dev/index.js +108 -0
- package/dist/dev/logs.d.ts +15 -0
- package/dist/dev/logs.js +127 -0
- package/dist/dev/process.d.ts +24 -0
- package/dist/dev/process.js +34 -0
- package/dist/dev/server.d.ts +8 -0
- package/dist/dev/server.js +61 -0
- package/dist/dev/settings.d.ts +46 -0
- package/dist/dev/settings.js +160 -0
- package/dist/dev/smoke.d.ts +15 -0
- package/dist/dev/smoke.js +50 -0
- package/dist/dev/testing.d.ts +19 -0
- package/dist/dev/testing.js +18 -0
- package/dist/dev/tmux.d.ts +24 -0
- package/dist/dev/tmux.js +121 -0
- package/dist/eslint/index.d.ts +17 -0
- package/dist/eslint/index.js +91 -0
- package/dist/eslint/noComments.d.ts +2 -0
- package/dist/eslint/noComments.js +27 -0
- package/dist/gate/check.d.ts +13 -0
- package/dist/gate/check.js +49 -0
- package/dist/gate/config.d.ts +34 -0
- package/dist/gate/config.js +170 -0
- package/dist/gate/contract.d.ts +51 -0
- package/dist/gate/contract.js +1 -0
- package/dist/gate/guardsStep.d.ts +14 -0
- package/dist/gate/guardsStep.js +53 -0
- package/dist/gate/plan.d.ts +29 -0
- package/dist/gate/plan.js +86 -0
- package/dist/gate/report.d.ts +15 -0
- package/dist/gate/report.js +65 -0
- package/dist/gate/repository.d.ts +3 -0
- package/dist/gate/repository.js +37 -0
- package/dist/gate/runner.d.ts +10 -0
- package/dist/gate/runner.js +75 -0
- package/dist/guards/comments/csharp.d.ts +3 -0
- package/dist/guards/comments/csharp.js +163 -0
- package/dist/guards/comments/css.d.ts +3 -0
- package/dist/guards/comments/css.js +11 -0
- package/dist/guards/comments/eslint.d.ts +2 -0
- package/dist/guards/comments/eslint.js +81 -0
- package/dist/guards/comments/hash.d.ts +3 -0
- package/dist/guards/comments/hash.js +72 -0
- package/dist/guards/comments/index.d.ts +2 -0
- package/dist/guards/comments/index.js +18 -0
- package/dist/guards/comments/json.d.ts +3 -0
- package/dist/guards/comments/json.js +13 -0
- package/dist/guards/comments/markup.d.ts +3 -0
- package/dist/guards/comments/markup.js +14 -0
- package/dist/guards/comments/scan.d.ts +19 -0
- package/dist/guards/comments/scan.js +84 -0
- package/dist/guards/comments/sql.d.ts +3 -0
- package/dist/guards/comments/sql.js +11 -0
- package/dist/guards/comments/switches.d.ts +3 -0
- package/dist/guards/comments/switches.js +30 -0
- package/dist/guards/criteria/criteriaKinds.d.ts +2 -0
- package/dist/guards/criteria/criteriaKinds.js +45 -0
- package/dist/guards/criteria/index.d.ts +2 -0
- package/dist/guards/criteria/index.js +2 -0
- package/dist/guards/database/connectionHost.d.ts +2 -0
- package/dist/guards/database/connectionHost.js +30 -0
- package/dist/guards/database/index.d.ts +2 -0
- package/dist/guards/database/index.js +3 -0
- package/dist/guards/database/migrationsUnchanged.d.ts +2 -0
- package/dist/guards/database/migrationsUnchanged.js +56 -0
- package/dist/guards/dotnet/appsettingsBound.d.ts +2 -0
- package/dist/guards/dotnet/appsettingsBound.js +43 -0
- package/dist/guards/dotnet/bannedNugetPackages.d.ts +2 -0
- package/dist/guards/dotnet/bannedNugetPackages.js +51 -0
- package/dist/guards/dotnet/index.d.ts +2 -0
- package/dist/guards/dotnet/index.js +4 -0
- package/dist/guards/dotnet/msbuild.d.ts +5 -0
- package/dist/guards/dotnet/msbuild.js +17 -0
- package/dist/guards/dotnet/testContext.d.ts +2 -0
- package/dist/guards/dotnet/testContext.js +12 -0
- package/dist/guards/dotnet/unusedNugetVersions.d.ts +2 -0
- package/dist/guards/dotnet/unusedNugetVersions.js +21 -0
- package/dist/guards/index.d.ts +2 -0
- package/dist/guards/index.js +6 -0
- package/dist/guards/repository/agentsFile.d.ts +3 -0
- package/dist/guards/repository/agentsFile.js +56 -0
- package/dist/guards/repository/bannedNpmPackages.d.ts +2 -0
- package/dist/guards/repository/bannedNpmPackages.js +43 -0
- package/dist/guards/repository/composePorts.d.ts +6 -0
- package/dist/guards/repository/composePorts.js +57 -0
- package/dist/guards/repository/dependencyDirection.d.ts +2 -0
- package/dist/guards/repository/dependencyDirection.js +87 -0
- package/dist/guards/repository/docsPaths.d.ts +2 -0
- package/dist/guards/repository/docsPaths.js +54 -0
- package/dist/guards/repository/forbiddenNames.d.ts +4 -0
- package/dist/guards/repository/forbiddenNames.js +69 -0
- package/dist/guards/repository/hooks.d.ts +3 -0
- package/dist/guards/repository/hooks.js +86 -0
- package/dist/guards/repository/imagePins.d.ts +3 -0
- package/dist/guards/repository/imagePins.js +68 -0
- package/dist/guards/repository/index.d.ts +2 -0
- package/dist/guards/repository/index.js +32 -0
- package/dist/guards/repository/justModules.d.ts +2 -0
- package/dist/guards/repository/justModules.js +36 -0
- package/dist/guards/repository/noRawColors.d.ts +2 -0
- package/dist/guards/repository/noRawColors.js +29 -0
- package/dist/guards/repository/packageManifests.d.ts +13 -0
- package/dist/guards/repository/packageManifests.js +26 -0
- package/dist/guards/repository/repositoryLayout.d.ts +3 -0
- package/dist/guards/repository/repositoryLayout.js +75 -0
- package/dist/guards/repository/requiredFiles.d.ts +6 -0
- package/dist/guards/repository/requiredFiles.js +78 -0
- package/dist/guards/repository/scriptsCalled.d.ts +3 -0
- package/dist/guards/repository/scriptsCalled.js +39 -0
- package/dist/guards/repository/scriptsHelp.d.ts +2 -0
- package/dist/guards/repository/scriptsHelp.js +37 -0
- package/dist/guards/repository/testRepository.d.ts +4 -0
- package/dist/guards/repository/testRepository.js +39 -0
- package/dist/guards/repository/text.d.ts +20 -0
- package/dist/guards/repository/text.js +33 -0
- package/dist/guards/repository/vsCodeSettings.d.ts +3 -0
- package/dist/guards/repository/vsCodeSettings.js +49 -0
- package/dist/profiles/contract.d.ts +5 -0
- package/dist/profiles/contract.js +124 -0
- package/dist/profiles/criteria.d.ts +25 -0
- package/dist/profiles/criteria.js +162 -0
- package/dist/profiles/database.d.ts +4 -0
- package/dist/profiles/database.js +23 -0
- package/dist/profiles/dotnet.d.ts +5 -0
- package/dist/profiles/dotnet.js +56 -0
- package/dist/profiles/everyRepository.d.ts +2 -0
- package/dist/profiles/everyRepository.js +32 -0
- package/dist/profiles/index.d.ts +2 -0
- package/dist/profiles/index.js +21 -0
- package/dist/profiles/library.d.ts +7 -0
- package/dist/profiles/library.js +132 -0
- package/dist/profiles/node.d.ts +5 -0
- package/dist/profiles/node.js +79 -0
- package/dist/profiles/presets/knip.d.ts +11 -0
- package/dist/profiles/presets/knip.js +29 -0
- package/dist/profiles/presets/playwright.d.ts +68 -0
- package/dist/profiles/presets/playwright.js +37 -0
- package/dist/profiles/presets/prettier.d.ts +12 -0
- package/dist/profiles/presets/prettier.js +7 -0
- package/dist/profiles/presets/tsconfig/browser.json +11 -0
- package/dist/profiles/presets/tsconfig/node.json +8 -0
- package/dist/profiles/presets/tsconfig/strict.json +17 -0
- package/dist/profiles/presets/vitest.d.ts +36 -0
- package/dist/profiles/presets/vitest.js +16 -0
- package/dist/profiles/shell.d.ts +10 -0
- package/dist/profiles/shell.js +62 -0
- package/dist/profiles/web.d.ts +2 -0
- package/dist/profiles/web.js +17 -0
- package/dist/session/guardEdit.d.ts +19 -0
- package/dist/session/guardEdit.js +96 -0
- package/dist/session/preCommit.d.ts +16 -0
- package/dist/session/preCommit.js +33 -0
- package/dist/session/stop.d.ts +8 -0
- package/dist/session/stop.js +39 -0
- package/package.json +97 -3
- package/schema/suwgate.schema.json +196 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Manomenu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,150 @@
|
|
|
1
|
-
#
|
|
1
|
+
# suwgate
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
One quality gate for every project: `suwgate check` runs the steps a project's profiles need and the repository guards, configured in `suwgate.yml`. The CLI is the npm package `@maniumek/suwgate`; the .NET guards are the NuGet packages `Suwgate.Architecture` and `Suwgate.Database`.
|
|
4
|
+
|
|
5
|
+
## Use it
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
pnpm add -D @maniumek/suwgate
|
|
9
|
+
pnpm exec suwgate check # the whole gate, the same CI runs
|
|
10
|
+
pnpm exec suwgate check --quick # the guards, and the quick steps for what changed since master
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`suwgate.yml` in the repository root says what the repository is and where it departs from the defaults:
|
|
14
|
+
|
|
15
|
+
```yaml
|
|
16
|
+
profiles: [web, dotnet, database]
|
|
17
|
+
directories:
|
|
18
|
+
web: Myapp.Web
|
|
19
|
+
steps:
|
|
20
|
+
add:
|
|
21
|
+
- name: api-diff
|
|
22
|
+
run: scripts/.internal/api-diff.sh
|
|
23
|
+
after: [dotnet-build]
|
|
24
|
+
skip:
|
|
25
|
+
- step: knip
|
|
26
|
+
reason: the generated API client exports more than the app uses, and knip cannot tell
|
|
27
|
+
exceptions:
|
|
28
|
+
- guard: architecture/interfaces-have-two-implementations
|
|
29
|
+
target: Myapp.Server.Payments.IPaymentGateway
|
|
30
|
+
reason: the payment SDK takes an implementation of this interface; the second one is the SDK's test double
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
- `profiles` (`web`, `library`, `dotnet`, `database`) bring their default steps in their order (the table below). A web-only repository runs nothing of .NET; the database
|
|
34
|
+
guards run only with `database`.
|
|
35
|
+
- `steps.add` runs more (`name`, `run`, optionally `title`, `quick`, `after`, `limitSeconds`); `steps.skip` leaves a step out,
|
|
36
|
+
always with a `reason`.
|
|
37
|
+
- `exceptions` let one target through one guard, always with a `reason`; `suwgate check` counts them in its report, and an
|
|
38
|
+
exception that no longer matches anything fails the gate until it is deleted.
|
|
39
|
+
- The schema is in the package, `schema/suwgate.schema.json`. VS Code checks the file as you type with
|
|
40
|
+
`"yaml.schemas": { "./node_modules/@maniumek/suwgate/schema/suwgate.schema.json": "suwgate.yml" }` in `.vscode/settings.json`.
|
|
41
|
+
- `settings` configure a guard by its id, for example `dependency-direction: { applications: [Myapp.*] }` or
|
|
42
|
+
`agents-file: { acronyms: [NUGET] }`; the schema of each guard's settings is in its source, and `suwgate check` validates them.
|
|
43
|
+
|
|
44
|
+
## Hooks
|
|
45
|
+
|
|
46
|
+
Three lines wire the hooks; `.claude/settings.json`:
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"hooks": {
|
|
51
|
+
"Stop": [
|
|
52
|
+
{ "hooks": [{ "type": "command", "command": "\"${CLAUDE_PROJECT_DIR}/node_modules/.bin/suwgate\" hook stop", "timeout": 600 }] }
|
|
53
|
+
],
|
|
54
|
+
"PreToolUse": [
|
|
55
|
+
{
|
|
56
|
+
"matcher": "Edit|Write|MultiEdit|NotebookEdit",
|
|
57
|
+
"hooks": [{ "type": "command", "command": "\"${CLAUDE_PROJECT_DIR}/node_modules/.bin/suwgate\" hook guard-edit" }]
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
and `.githooks/pre-commit` (`git config core.hooksPath .githooks` enables it):
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
#!/usr/bin/env bash
|
|
68
|
+
exec node_modules/.bin/suwgate hook pre-commit
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
- `hook stop` runs the quick gate after an agent's turn, unless nothing changed since it last passed.
|
|
72
|
+
- `hook guard-edit` refuses an agent's edit of the gate (`suwgate.yml`, the criteria file, the hooks, the workflows, `.editorconfig`,
|
|
73
|
+
and the lint, type and build configs of the repository's profiles, the layers file of a .NET server among them) until the owner starts a session
|
|
74
|
+
with `ALLOW_GATE_EDIT=1`. It always refuses generated files (lockfiles, the API contract and types) with the command that
|
|
75
|
+
regenerates them and an existing migration script, and refuses a recorded characterization test that git tracks. It guards only
|
|
76
|
+
files of its own project (`CLAUDE_PROJECT_DIR`, else the checkout it runs in), so a session never blocks another repository.
|
|
77
|
+
`settings.hooks` adds the repository's own: `protected` (globs), `generated` (`path` and `command`), `recordings`, `migrations`.
|
|
78
|
+
- `hook pre-commit` runs gitleaks on the staged changes, then the quick gate, and refuses the commit if either fails
|
|
79
|
+
([docs/adr/0001-suwgate-hook-pre-commit.md](docs/adr/0001-suwgate-hook-pre-commit.md)).
|
|
80
|
+
- The `hooks` guard checks that these lines are there.
|
|
81
|
+
|
|
82
|
+
### The steps of the profiles
|
|
83
|
+
|
|
84
|
+
Each step looks where its profile lives (`directories`) and passes with nothing to check when the repository has nothing for it.
|
|
85
|
+
|
|
86
|
+
| Profile | Steps |
|
|
87
|
+
| :--------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
88
|
+
| `web`, `library` | `pnpm-install` (only without `node_modules`), `typecheck` (every `tsconfig*.json` but `tsconfig.build.json`), `lint`, `unit-tests` (the Vitest project `unit` when the config names one), `format`, `knip` |
|
|
89
|
+
| `web` | `e2e`: `playwright test -c e2e/playwright.config.ts`, after the build, the database and the .NET tests |
|
|
90
|
+
| `library` | `stories` (with `.storybook/`), `publint`, `attw`, `consumer-app` (packs the library into a copy of `gate/consumer/app`, builds it, runs `gate/consumer/playwright.config.ts`), `visual` (`visual/playwright.config.ts` in the Playwright image of the installed `@playwright/test`), `changeset` |
|
|
91
|
+
| `dotnet` | `dotnet-build`, `dotnet-format`, `dotnet-test` (`--quick`: only the test projects that use `Suwgate.Architecture` or `Suwgate.Database`) |
|
|
92
|
+
| `dotnet`, `web` | with `contract/openapi.json`: `api-contract` (the contract and `src/api/openapi.d.ts` of the web app regenerated from the server's project, the one that references `Microsoft.Extensions.ApiDescription.Server`), `api-version` (oasdiff against master; a break needs a new major version in `contract/package.json`), `contract-pins` (every test tagged `contract <name>@<version>` names a version) |
|
|
93
|
+
| `database` | `database-up`: `docker compose --profile db up -d --wait db`, not in CI |
|
|
94
|
+
| every repository | `compose` (with a compose file), `criteria`, `shellcheck`, `gitleaks` |
|
|
95
|
+
|
|
96
|
+
`criteria` runs `vdoc.py criteria` of the suwagent plugin, pinned by commit and SHA-256: every acceptance criterion of the specs in
|
|
97
|
+
`docs/visual/spec/` is named by a guardrail. The kinds of guardrail come with the profiles; `criteria.json` in the repository root
|
|
98
|
+
adds the repository's own (`{ "kinds": [{ "kind", "paths", "how" }] }`, optionally `specs` and `prose`), and the guard
|
|
99
|
+
`criteria-kinds` asks for a row of each in a table of `README.md` or `docs/development.md`. The default kinds:
|
|
100
|
+
|
|
101
|
+
| Kind | Profile | Where (in the profile's directory) | How the id is written |
|
|
102
|
+
| :------------------------------ | :--------------- | :---------------------------------- | :----------------------------------------- |
|
|
103
|
+
| `test (xunit)` | `dotnet` | every project that references xunit | `[Trait("criterion", "<id>")]` on the test |
|
|
104
|
+
| `lint (.NET analyzer)` | `dotnet` | `.editorconfig` | `# <id>` on its own line above the rule |
|
|
105
|
+
| `banned API` | `dotnet` | `BannedSymbols.txt` | in the message: `P:…;<id> use …` |
|
|
106
|
+
| `build rule` | `dotnet` | `Directory.Build.props` | `<!-- <id> -->` above the property |
|
|
107
|
+
| `e2e test (playwright)` | `web` | `src/**/*.e2e.ts` | in the title: `test("<id>: …")` |
|
|
108
|
+
| `web test (vitest)` | `web` | `src/**/*.test.ts(x)` | in the title: `it("<id>: …")` |
|
|
109
|
+
| `unit test (vitest)` | `library` | `src/**/*.test.ts(x)` | in the title: `it("<id>: …")` |
|
|
110
|
+
| `story test (vitest, Chromium)` | `library` | `src/**/*.stories.tsx` | in the story's name: `name: "<id>: …"` |
|
|
111
|
+
| `visual test (playwright)` | `library` | `visual/*.visual.ts` | in the title: `test("<id>: …")` |
|
|
112
|
+
| `consumer test (playwright)` | `library` | `gate/consumer/*.spec.ts` | in the title: `test("<id>: …")` |
|
|
113
|
+
| `lint (eslint)` | `web`, `library` | `eslint.config.js` | `// <id>` on the line above the rule |
|
|
114
|
+
| `type check (tsc)` | `web`, `library` | `tsconfig*.json` | `// <id>` on the line above the option |
|
|
115
|
+
|
|
116
|
+
### The tool presets
|
|
117
|
+
|
|
118
|
+
The configs of the tools the steps run extend suwgate's, so an application keeps only its own paths:
|
|
119
|
+
|
|
120
|
+
| Tool | The application's file |
|
|
121
|
+
| :--------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
122
|
+
| Prettier | `.prettierrc.json`: `"@maniumek/suwgate/prettier"` (with a plugin: spread it in `prettier.config.js`) |
|
|
123
|
+
| TypeScript | `{ "extends": "@maniumek/suwgate/tsconfig/browser", "include": ["src"] }`; `tsconfig/node` for the configs, scripts and tests run by Node; `tsconfig/strict` for the options alone |
|
|
124
|
+
| knip | `knip.config.ts`: `export { default } from "@maniumek/suwgate/knip"`, or `knip({ entry: [...] })`; it ignores the tools the steps run and the generated API types, and reads the steps' Playwright configs |
|
|
125
|
+
| Vitest | `unitTests({ environment: "jsdom" })` and `storyTests({ plugin, provider })` from `@maniumek/suwgate/vitest`: the projects `unit` and `stories` the steps run |
|
|
126
|
+
| Playwright | `defineConfig(e2eTests({ use: { baseURL }, webServer }))` or `defineConfig(visualTests())` from `@maniumek/suwgate/playwright` |
|
|
127
|
+
|
|
128
|
+
### The .NET guards
|
|
129
|
+
|
|
130
|
+
In the xUnit tests of a .NET application:
|
|
131
|
+
|
|
132
|
+
```csharp
|
|
133
|
+
[Fact]
|
|
134
|
+
public void Every_interface_has_two_implementations() =>
|
|
135
|
+
Guards.Verify(InterfacesHaveTwoImplementations.Of(typeof(ServerApp).Assembly));
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
`Guards.Verify` reads the exceptions of that guard from the nearest `suwgate.yml` above the test's output folder.
|
|
139
|
+
|
|
140
|
+
`suwgate dev db|logs|smoke|server|tmux|checkout-env` runs the local stack of the template (database, logs, smoke test, server, tmux
|
|
141
|
+
session, worktree databases) from a `dev` section of `suwgate.yml`: [docs/dev.md](docs/dev.md).
|
|
142
|
+
|
|
143
|
+
## Work on suwgate
|
|
144
|
+
|
|
145
|
+
[AGENTS.md](AGENTS.md) holds the rules, [docs/development.md](docs/development.md) the setup, [docs/architecture.md](docs/architecture.md)
|
|
146
|
+
the contract of a guard and a step, and [docs/inventory.md](docs/inventory.md) what is still to be moved here from the template and the kits.
|
|
147
|
+
|
|
148
|
+
## Licence
|
|
149
|
+
|
|
150
|
+
MIT, see [LICENSE](LICENSE).
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { parseArgs } from "node:util";
|
|
4
|
+
import { check } from "./gate/check.js";
|
|
5
|
+
import { dev } from "./dev/index.js";
|
|
6
|
+
import { loadConfig } from "./gate/config.js";
|
|
7
|
+
import { PROFILES } from "./gate/contract.js";
|
|
8
|
+
import { repositoryRoot } from "./gate/repository.js";
|
|
9
|
+
import { guards } from "./guards/index.js";
|
|
10
|
+
import { stepsFor } from "./profiles/index.js";
|
|
11
|
+
import { guardEdit } from "./session/guardEdit.js";
|
|
12
|
+
import { preCommit, runTool } from "./session/preCommit.js";
|
|
13
|
+
import { stop } from "./session/stop.js";
|
|
14
|
+
const USAGE = `usage: suwgate check [--quick] [--verbose] | suwgate hook <guard-edit|stop|pre-commit> | suwgate dev <command> | suwgate --help | --version
|
|
15
|
+
suwgate check every step of the repository's profiles (suwgate.yml) and the repository guards
|
|
16
|
+
suwgate check --quick the guards, and the quick steps only for what changed since master; has a time budget
|
|
17
|
+
(SUWGATE_QUICK_LIMIT seconds, default 20) because the Stop hook runs it after every turn
|
|
18
|
+
--verbose list every step with its time, also when all pass
|
|
19
|
+
suwgate hook guard-edit Claude Code PreToolUse hook: refuses an agent's edit of the gate and of generated files
|
|
20
|
+
(ALLOW_GATE_EDIT=1 lifts the gate part for one session); only files of its own project
|
|
21
|
+
(CLAUDE_PROJECT_DIR, else the git checkout it runs in), with the lists of its profiles
|
|
22
|
+
suwgate hook stop Claude Code Stop hook: runs the quick gate unless nothing changed since it last passed
|
|
23
|
+
suwgate hook pre-commit git pre-commit hook: gitleaks on the staged changes, then the quick gate
|
|
24
|
+
suwgate dev <db|logs|smoke|server|tmux|checkout-env>
|
|
25
|
+
the local stack of the repository (the dev section of suwgate.yml); suwgate dev --help
|
|
26
|
+
Every step has a ceiling (SUWGATE_STEP_LIMIT seconds overrides them all). A step whose tool is missing is SKIP,
|
|
27
|
+
and a SKIP fails the gate when CI is set. Exit code: 0 green, 1 red, 2 a usage or suwgate.yml problem.`;
|
|
28
|
+
const catalog = { guards, stepsFor };
|
|
29
|
+
function version() {
|
|
30
|
+
const manifest = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
31
|
+
return manifest.version;
|
|
32
|
+
}
|
|
33
|
+
function editHookProject(root) {
|
|
34
|
+
const loaded = loadConfig(root, catalog);
|
|
35
|
+
if (!("config" in loaded))
|
|
36
|
+
return { root, profiles: PROFILES, settings: {} };
|
|
37
|
+
const settings = loaded.config.settings["hooks"];
|
|
38
|
+
return { root, profiles: loaded.config.profiles, settings: settings ?? {} };
|
|
39
|
+
}
|
|
40
|
+
function readInput() {
|
|
41
|
+
try {
|
|
42
|
+
return readFileSync(0, "utf8");
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return "";
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function main(argv) {
|
|
49
|
+
if (argv[0] === "dev")
|
|
50
|
+
return dev(argv.slice(1));
|
|
51
|
+
const { values, positionals } = parseArgs({
|
|
52
|
+
args: [...argv],
|
|
53
|
+
allowPositionals: true,
|
|
54
|
+
strict: true,
|
|
55
|
+
options: { quick: { type: "boolean" }, verbose: { type: "boolean" }, help: { type: "boolean" }, version: { type: "boolean" } },
|
|
56
|
+
});
|
|
57
|
+
const [command, hook, ...rest] = positionals;
|
|
58
|
+
if (values.help === true) {
|
|
59
|
+
console.log(USAGE);
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
if (values.version === true) {
|
|
63
|
+
console.log(version());
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
const runCheck = (cwd, quick, verbose) => check({ cwd, quick, verbose, env: process.env, catalog });
|
|
67
|
+
if (command === "check" && hook === undefined) {
|
|
68
|
+
const result = await runCheck(process.cwd(), values.quick === true, values.verbose === true);
|
|
69
|
+
(result.exitCode === 0 ? console.log : console.error)(result.text);
|
|
70
|
+
return result.exitCode;
|
|
71
|
+
}
|
|
72
|
+
if (command === "hook" && rest.length === 0 && hook === "pre-commit") {
|
|
73
|
+
const root = repositoryRoot(process.cwd()) ?? process.cwd();
|
|
74
|
+
const verdict = await preCommit(root, runTool, () => runCheck(root, true, false));
|
|
75
|
+
if (verdict.message !== "")
|
|
76
|
+
console.error(verdict.message);
|
|
77
|
+
return verdict.exitCode;
|
|
78
|
+
}
|
|
79
|
+
if (command === "hook" && rest.length === 0 && (hook === "guard-edit" || hook === "stop")) {
|
|
80
|
+
const root = process.env["CLAUDE_PROJECT_DIR"] ?? repositoryRoot(process.cwd()) ?? process.cwd();
|
|
81
|
+
const verdict = hook === "guard-edit"
|
|
82
|
+
? guardEdit(readInput(), editHookProject(root), process.env["ALLOW_GATE_EDIT"] === "1")
|
|
83
|
+
: await stop(readInput(), root, () => runCheck(root, true, false));
|
|
84
|
+
if (verdict.message !== "")
|
|
85
|
+
console.error(verdict.message);
|
|
86
|
+
return verdict.exitCode;
|
|
87
|
+
}
|
|
88
|
+
console.error(USAGE);
|
|
89
|
+
return 2;
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
process.exitCode = await main(process.argv.slice(2));
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
console.error(`suwgate: ${error instanceof Error ? error.message : String(error)}\n\n${USAGE}`);
|
|
96
|
+
process.exitCode = 2;
|
|
97
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Io } from "./process.ts";
|
|
2
|
+
import type { DevSettings } from "./settings.ts";
|
|
3
|
+
export declare const CHECKOUT_ENV_USAGE = "usage: eval \"$(suwgate dev checkout-env)\"\nPrints shell `export` lines, so the shell that evals them has the variables of this checkout: the builds leave no worker\nprocesses behind (MSBUILDDISABLENODEREUSE, DOTNET_CLI_USE_MSBUILD_SERVER), and a linked git worktree gets its own test and\ne2e databases and its own e2e ports, so checkouts that run the gate or the browser tests at the same time do not collide.\nThe main checkout and CI keep the plain names and ports (<database>_e2e, ports dev.ports.e2eServer and e2eWeb). A linked\nworktree takes a suffix from its directory name (lower-case [a-z0-9_], at most 30 chars, and a hash of the name) for the\ndatabase names and a port pair (20000-29999) from the same hash. Nothing is cleaned up afterwards: a worktree's databases\nstay until you drop them. A value already in the environment wins. What it chose goes to stderr.";
|
|
4
|
+
export declare function cksum(text: string): number;
|
|
5
|
+
export declare function suffixOf(name: string): string;
|
|
6
|
+
export interface CheckoutInputs {
|
|
7
|
+
checkoutName: string;
|
|
8
|
+
linked: boolean;
|
|
9
|
+
ci: boolean;
|
|
10
|
+
env: Readonly<Record<string, string | undefined>>;
|
|
11
|
+
settings: DevSettings;
|
|
12
|
+
}
|
|
13
|
+
export interface CheckoutEnv {
|
|
14
|
+
variables: [string, string][];
|
|
15
|
+
notice: string | null;
|
|
16
|
+
}
|
|
17
|
+
export declare function checkoutEnv(inputs: CheckoutInputs): CheckoutEnv;
|
|
18
|
+
export declare function exportLines(variables: readonly (readonly [string, string])[]): string;
|
|
19
|
+
export declare function isLinkedWorktree(root: string): boolean;
|
|
20
|
+
export declare function runCheckoutEnv(args: readonly string[], settings: DevSettings, env: Readonly<Record<string, string | undefined>>, io: Io): number;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { Failure, quoted } from "./process.js";
|
|
4
|
+
export const CHECKOUT_ENV_USAGE = `usage: eval "$(suwgate dev checkout-env)"
|
|
5
|
+
Prints shell \`export\` lines, so the shell that evals them has the variables of this checkout: the builds leave no worker
|
|
6
|
+
processes behind (MSBUILDDISABLENODEREUSE, DOTNET_CLI_USE_MSBUILD_SERVER), and a linked git worktree gets its own test and
|
|
7
|
+
e2e databases and its own e2e ports, so checkouts that run the gate or the browser tests at the same time do not collide.
|
|
8
|
+
The main checkout and CI keep the plain names and ports (<database>_e2e, ports dev.ports.e2eServer and e2eWeb). A linked
|
|
9
|
+
worktree takes a suffix from its directory name (lower-case [a-z0-9_], at most 30 chars, and a hash of the name) for the
|
|
10
|
+
database names and a port pair (20000-29999) from the same hash. Nothing is cleaned up afterwards: a worktree's databases
|
|
11
|
+
stay until you drop them. A value already in the environment wins. What it chose goes to stderr.`;
|
|
12
|
+
const CRC_TABLE = Array.from({ length: 256 }, (_, index) => {
|
|
13
|
+
let value = index << 24;
|
|
14
|
+
for (let bit = 0; bit < 8; bit++)
|
|
15
|
+
value = value & 0x80000000 ? (value << 1) ^ 0x04c11db7 : value << 1;
|
|
16
|
+
return value >>> 0;
|
|
17
|
+
});
|
|
18
|
+
const SUFFIX_NAME_LENGTH = 30;
|
|
19
|
+
const PORT_BASE = 20000;
|
|
20
|
+
const PORT_PAIRS = 5000;
|
|
21
|
+
function step(crc, byte) {
|
|
22
|
+
return ((crc << 8) ^ (CRC_TABLE[((crc >>> 24) ^ byte) & 0xff] ?? 0)) >>> 0;
|
|
23
|
+
}
|
|
24
|
+
export function cksum(text) {
|
|
25
|
+
const bytes = Buffer.from(text, "utf8");
|
|
26
|
+
let crc = 0;
|
|
27
|
+
for (const byte of bytes)
|
|
28
|
+
crc = step(crc, byte);
|
|
29
|
+
for (let length = bytes.length; length > 0; length = Math.floor(length / 256))
|
|
30
|
+
crc = step(crc, length % 256);
|
|
31
|
+
return ~crc >>> 0;
|
|
32
|
+
}
|
|
33
|
+
export function suffixOf(name) {
|
|
34
|
+
const safe = Array.from(Buffer.from(name.toLowerCase(), "utf8"), (byte) => /[a-z0-9_]/.test(String.fromCharCode(byte)) ? String.fromCharCode(byte) : "_").join("");
|
|
35
|
+
return `${safe.slice(0, SUFFIX_NAME_LENGTH)}_${cksum(name)}`;
|
|
36
|
+
}
|
|
37
|
+
export function checkoutEnv(inputs) {
|
|
38
|
+
const { settings, env } = inputs;
|
|
39
|
+
const chosen = (name, fallback) => {
|
|
40
|
+
const set = env[name];
|
|
41
|
+
return set !== undefined && set !== "" ? set : fallback;
|
|
42
|
+
};
|
|
43
|
+
const { database } = settings;
|
|
44
|
+
const isolated = !inputs.ci && inputs.linked;
|
|
45
|
+
const suffix = suffixOf(inputs.checkoutName);
|
|
46
|
+
const base = PORT_BASE + (cksum(inputs.checkoutName) % PORT_PAIRS) * 2;
|
|
47
|
+
const variables = [
|
|
48
|
+
["MSBUILDDISABLENODEREUSE", "1"],
|
|
49
|
+
["DOTNET_CLI_USE_MSBUILD_SERVER", "0"],
|
|
50
|
+
["E2E_DATABASE", chosen("E2E_DATABASE", isolated ? `${database.name}_e2e_${suffix}` : `${database.name}_e2e`)],
|
|
51
|
+
];
|
|
52
|
+
if (isolated) {
|
|
53
|
+
variables.push([
|
|
54
|
+
"TEST_CONNECTION_STRING",
|
|
55
|
+
chosen("TEST_CONNECTION_STRING", `Host=127.0.0.1;Port=${settings.ports.database};Database=${database.name}_test_${suffix};Username=${database.user};Password=${database.password}`),
|
|
56
|
+
]);
|
|
57
|
+
}
|
|
58
|
+
variables.push(["E2E_SERVER_PORT", chosen("E2E_SERVER_PORT", String(isolated ? base : settings.ports.e2eServer))], ["E2E_WEB_PORT", chosen("E2E_WEB_PORT", String(isolated ? base + 1 : settings.ports.e2eWeb))]);
|
|
59
|
+
const value = (name) => variables.find(([key]) => key === name)?.[1] ?? "";
|
|
60
|
+
const notice = isolated
|
|
61
|
+
? `checkout ${inputs.checkoutName}: test database ${database.name}_test_${suffix}, e2e database ${value("E2E_DATABASE")}, e2e ports ${value("E2E_SERVER_PORT")}/${value("E2E_WEB_PORT")}`
|
|
62
|
+
: null;
|
|
63
|
+
return { variables, notice };
|
|
64
|
+
}
|
|
65
|
+
export function exportLines(variables) {
|
|
66
|
+
return variables.map(([name, value]) => `export ${name}=${quoted(value)}`).join("\n");
|
|
67
|
+
}
|
|
68
|
+
function gitPath(root, args) {
|
|
69
|
+
try {
|
|
70
|
+
return execFileSync("git", ["-C", root, ...args], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export function isLinkedWorktree(root) {
|
|
77
|
+
const gitDir = gitPath(root, ["rev-parse", "--absolute-git-dir"]);
|
|
78
|
+
const commonDir = gitPath(root, ["rev-parse", "--path-format=absolute", "--git-common-dir"]);
|
|
79
|
+
if (gitDir === null || commonDir === null) {
|
|
80
|
+
throw new Failure(`suwgate dev checkout-env: ${root} is not a git checkout, so a linked worktree cannot be told from the main one: run it in a cloned repository or worktree`);
|
|
81
|
+
}
|
|
82
|
+
return gitDir !== commonDir;
|
|
83
|
+
}
|
|
84
|
+
export function runCheckoutEnv(args, settings, env, io) {
|
|
85
|
+
if (args.length > 0) {
|
|
86
|
+
io.err(CHECKOUT_ENV_USAGE);
|
|
87
|
+
return 2;
|
|
88
|
+
}
|
|
89
|
+
const ci = (env["CI"] ?? "") !== "";
|
|
90
|
+
const result = checkoutEnv({
|
|
91
|
+
checkoutName: path.basename(settings.root),
|
|
92
|
+
linked: ci ? false : isLinkedWorktree(settings.root),
|
|
93
|
+
ci,
|
|
94
|
+
env,
|
|
95
|
+
settings,
|
|
96
|
+
});
|
|
97
|
+
io.out(exportLines(result.variables));
|
|
98
|
+
if (result.notice !== null)
|
|
99
|
+
io.err(result.notice);
|
|
100
|
+
return 0;
|
|
101
|
+
}
|
package/dist/dev/db.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Exec, type Io } from "./process.ts";
|
|
2
|
+
import type { DevSettings } from "./settings.ts";
|
|
3
|
+
export declare const DB_USAGE = "usage: suwgate dev db up | down | reset [--yes] | psql [psql args] | logs | status\nThe local PostgreSQL for development and tests: the database service of the compose file (dev.compose), published on the\nloopback, its data in a named volume that survives down. Needs docker (on Fedora: podman behind the docker command).\n up start it (and dev.compose.extraServices), or leave it running, and wait until it answers; prints its address\n down stop it, the data stays in the volume\n reset delete the containers and the volume with all the data, after asking (--yes does not ask)\n psql psql in it as its owner in the app's database, e.g. suwgate dev db psql -d postgres -c \"select 1\"\n logs follow its log\n status what runs";
|
|
4
|
+
export type DbCommand = {
|
|
5
|
+
kind: "up" | "down" | "logs" | "status";
|
|
6
|
+
} | {
|
|
7
|
+
kind: "reset";
|
|
8
|
+
yes: boolean;
|
|
9
|
+
} | {
|
|
10
|
+
kind: "psql";
|
|
11
|
+
args: readonly string[];
|
|
12
|
+
};
|
|
13
|
+
export declare function parseDb(args: readonly string[]): DbCommand;
|
|
14
|
+
export declare function composeBase(settings: DevSettings): string[];
|
|
15
|
+
export declare function databaseUrl(settings: DevSettings): string;
|
|
16
|
+
export declare function dbArgv(settings: DevSettings, command: DbCommand, interactive: boolean): string[];
|
|
17
|
+
export interface DbEnvironment {
|
|
18
|
+
settings: DevSettings;
|
|
19
|
+
exec: Exec;
|
|
20
|
+
io: Io;
|
|
21
|
+
interactive: boolean;
|
|
22
|
+
ask: (question: string) => Promise<string>;
|
|
23
|
+
}
|
|
24
|
+
export declare function askOnTerminal(question: string): Promise<string>;
|
|
25
|
+
export declare function runDb(command: DbCommand, environment: DbEnvironment): Promise<number>;
|
package/dist/dev/db.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { createInterface } from "node:readline/promises";
|
|
2
|
+
import { Failure, UsageError } from "./process.js";
|
|
3
|
+
export const DB_USAGE = `usage: suwgate dev db up | down | reset [--yes] | psql [psql args] | logs | status
|
|
4
|
+
The local PostgreSQL for development and tests: the database service of the compose file (dev.compose), published on the
|
|
5
|
+
loopback, its data in a named volume that survives down. Needs docker (on Fedora: podman behind the docker command).
|
|
6
|
+
up start it (and dev.compose.extraServices), or leave it running, and wait until it answers; prints its address
|
|
7
|
+
down stop it, the data stays in the volume
|
|
8
|
+
reset delete the containers and the volume with all the data, after asking (--yes does not ask)
|
|
9
|
+
psql psql in it as its owner in the app's database, e.g. suwgate dev db psql -d postgres -c "select 1"
|
|
10
|
+
logs follow its log
|
|
11
|
+
status what runs`;
|
|
12
|
+
export function parseDb(args) {
|
|
13
|
+
const [command, ...rest] = args;
|
|
14
|
+
switch (command) {
|
|
15
|
+
case "psql":
|
|
16
|
+
return { kind: "psql", args: rest };
|
|
17
|
+
case "reset":
|
|
18
|
+
if (rest.length === 0)
|
|
19
|
+
return { kind: "reset", yes: false };
|
|
20
|
+
if (rest.length === 1 && rest[0] === "--yes")
|
|
21
|
+
return { kind: "reset", yes: true };
|
|
22
|
+
throw new UsageError("suwgate dev db reset takes only --yes");
|
|
23
|
+
case "up":
|
|
24
|
+
case "down":
|
|
25
|
+
case "logs":
|
|
26
|
+
case "status":
|
|
27
|
+
if (rest.length > 0)
|
|
28
|
+
throw new UsageError(`suwgate dev db ${command} takes no arguments`);
|
|
29
|
+
return { kind: command };
|
|
30
|
+
default:
|
|
31
|
+
throw new UsageError(DB_USAGE);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function composeBase(settings) {
|
|
35
|
+
return ["docker", "compose", "-f", `${settings.root}/${settings.compose.file}`, "--profile", settings.compose.profile];
|
|
36
|
+
}
|
|
37
|
+
function databaseServices(settings) {
|
|
38
|
+
return [settings.compose.databaseService, ...settings.compose.extraServices];
|
|
39
|
+
}
|
|
40
|
+
export function databaseUrl(settings) {
|
|
41
|
+
const { user, password, name } = settings.database;
|
|
42
|
+
return `postgresql://${user}:${password}@localhost:${settings.ports.database}/${name}`;
|
|
43
|
+
}
|
|
44
|
+
export function dbArgv(settings, command, interactive) {
|
|
45
|
+
const base = composeBase(settings);
|
|
46
|
+
const service = settings.compose.databaseService;
|
|
47
|
+
switch (command.kind) {
|
|
48
|
+
case "up":
|
|
49
|
+
return [...base, "up", "-d", "--wait", ...databaseServices(settings)];
|
|
50
|
+
case "down":
|
|
51
|
+
return [...base, "stop", ...databaseServices(settings)];
|
|
52
|
+
case "reset":
|
|
53
|
+
return [...base, "down", "--volumes"];
|
|
54
|
+
case "psql":
|
|
55
|
+
return [
|
|
56
|
+
...base,
|
|
57
|
+
"exec",
|
|
58
|
+
...(interactive ? [] : ["-T"]),
|
|
59
|
+
service,
|
|
60
|
+
"psql",
|
|
61
|
+
"-U",
|
|
62
|
+
settings.database.user,
|
|
63
|
+
"-d",
|
|
64
|
+
settings.database.name,
|
|
65
|
+
...command.args,
|
|
66
|
+
];
|
|
67
|
+
case "logs":
|
|
68
|
+
return [...base, "logs", "-f", service];
|
|
69
|
+
case "status":
|
|
70
|
+
return [...base, "ps", "-a", ...databaseServices(settings)];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export function askOnTerminal(question) {
|
|
74
|
+
const lines = createInterface({ input: process.stdin, output: process.stderr });
|
|
75
|
+
return lines.question(question).finally(() => {
|
|
76
|
+
lines.close();
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
export async function runDb(command, environment) {
|
|
80
|
+
const { settings, exec, io } = environment;
|
|
81
|
+
if (command.kind === "reset" && !command.yes) {
|
|
82
|
+
const answer = await environment.ask("Delete the local database with all its data? [y/N] ");
|
|
83
|
+
if (answer.trim() !== "y") {
|
|
84
|
+
io.out("nothing deleted");
|
|
85
|
+
return 1;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const argv = dbArgv(settings, command, environment.interactive);
|
|
89
|
+
if (command.kind === "up") {
|
|
90
|
+
const { status } = await exec(argv, { quiet: true });
|
|
91
|
+
if (status !== 0) {
|
|
92
|
+
throw new Failure(`suwgate dev db: postgres did not start; see: ${composeBase(settings).join(" ")} logs ${settings.compose.databaseService}`);
|
|
93
|
+
}
|
|
94
|
+
io.out(databaseUrl(settings));
|
|
95
|
+
return 0;
|
|
96
|
+
}
|
|
97
|
+
const { status } = await exec(argv);
|
|
98
|
+
if (status === 0 && command.kind === "down")
|
|
99
|
+
io.out("stopped (the data stays in the volume)");
|
|
100
|
+
if (status === 0 && command.kind === "reset")
|
|
101
|
+
io.out("deleted; `suwgate dev db up` starts an empty one");
|
|
102
|
+
return status;
|
|
103
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Exec, type Io } from "./process.ts";
|
|
2
|
+
import { type DevSettings } from "./settings.ts";
|
|
3
|
+
import { type Fetch } from "./smoke.ts";
|
|
4
|
+
export declare const DEV_USAGE = "usage: suwgate dev <db|logs|smoke|server|tmux|checkout-env> [arguments] (every one takes --help)\nThe dev scripts of the template as commands, configured by the dev section of suwgate.yml:\n db the local PostgreSQL of the compose file: up | down | reset | psql | logs | status\n logs why did it fail? the last warnings and errors of the server's JSON log\n smoke read-only requests against a running stack\n server the server under dotnet watch, restarted when it exits\n tmux the whole local stack in one tmux session: start [--restart] | stop\n checkout-env eval \"$(suwgate dev checkout-env)\": own test databases and e2e ports for a linked worktree";
|
|
5
|
+
export interface DevEnvironment {
|
|
6
|
+
cwd: string;
|
|
7
|
+
env: Readonly<Record<string, string | undefined>>;
|
|
8
|
+
io: Io;
|
|
9
|
+
exec: Exec;
|
|
10
|
+
fetch: Fetch;
|
|
11
|
+
self: string;
|
|
12
|
+
interactive: boolean;
|
|
13
|
+
ask: (question: string) => Promise<string>;
|
|
14
|
+
loadSettings: (cwd: string) => DevSettings;
|
|
15
|
+
}
|
|
16
|
+
export declare function dev(argv: readonly string[], environment?: DevEnvironment): Promise<number>;
|