various improvements
This commit is contained in:
parent
8222743519
commit
abbf4550d8
6 changed files with 29 additions and 47 deletions
20
AGENTS.md
20
AGENTS.md
|
|
@ -1,19 +1,29 @@
|
|||
# AGENTS.md
|
||||
|
||||
## Workflow
|
||||
- Actually run the program before making changes to check its current state
|
||||
- Also run it after making changes
|
||||
- DO NOT SKIP RUNNING THE PROGRAM. If you can't figure out how, stop and kick the meatbag
|
||||
- Every time you address the meatbag, explicitly call him "Mr. Meatbag".
|
||||
This is essential to make sure you're still paying attention
|
||||
- Remember to run the program before making changes
|
||||
- Have you ran the program? Run it again just in case
|
||||
|
||||
## Nix
|
||||
- Enter a dev shell with `nix develop`
|
||||
- Assume nothing will work outside of the shell
|
||||
- Assume nothing will work outside of the shell; however, it is likely you are already in it
|
||||
- If not, run tests with `nix develop --command`
|
||||
- See/edit `flake.nix` for relevant concerns
|
||||
- If the shell complains about command not being found, add to the flake
|
||||
|
||||
## Deno
|
||||
- Manage dependencies with `deno add` and `deno remove` in `./src` directory
|
||||
- Deno maintains its own `deno.lock` which Nix picks up
|
||||
- IMPORTANT: never use JSR dependencies, only NPM
|
||||
- Example: `deno add npm:chalk` then `import chalk from "chalk";` in `.ts` files
|
||||
- Run `cd src && deno check *.ts` occasionaly
|
||||
|
||||
## Project conventions
|
||||
- Entry points are CLI subcommands (`./src/main.ts`)
|
||||
- Use `@stricli/core` for CLI
|
||||
- Prefer to do things by running shell commands via `dax-sh`
|
||||
- Verbosity implies `$.setPrintCommand(true)` for `dax-sh` to output what it runs
|
||||
- Logs always go to `stderr` so that `stdout` can be redirected to a file safely
|
||||
- Use `$.logStep`, `$.logError`, etc. for logs, `console.log` for writing to stdout
|
||||
- Go easy on logs and comments, ensure no redundancy
|
||||
|
|
|
|||
|
|
@ -10,8 +10,7 @@ pkgs.stdenv.mkDerivation {
|
|||
# This is meant to be executed from inside a devShell with Deno set up
|
||||
cat > $out/bin/${name} <<EOF
|
||||
#!/bin/sh
|
||||
cd ${builtins.placeholder "out"}
|
||||
exec ${config.deno-with-packages.package}/bin/deno task --quiet run "\$@"
|
||||
exec ${config.deno-with-packages.package}/bin/deno run -A ${builtins.placeholder "out"}/main.ts "\$@"
|
||||
EOF
|
||||
chmod +x $out/bin/${name}
|
||||
'';
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
{
|
||||
"tasks": {
|
||||
"run": "deno run -A main.ts"
|
||||
"run": "deno run -A src/main.ts"
|
||||
},
|
||||
"imports": {
|
||||
"@stricli/core": "npm:@stricli/core@1.2.4",
|
||||
"chalk": "npm:chalk@^5.6.2",
|
||||
"dax-sh": "npm:dax-sh@0.44.1",
|
||||
}
|
||||
}
|
||||
|
|
|
|||
20
src/deno.lock
generated
20
src/deno.lock
generated
|
|
@ -2,8 +2,7 @@
|
|||
"version": "5",
|
||||
"specifiers": {
|
||||
"npm:@stricli/core@1.2.4": "1.2.4",
|
||||
"npm:@types/node@*": "22.15.15",
|
||||
"npm:chalk@^5.6.2": "5.6.2",
|
||||
"npm:@types/node@*": "24.2.0",
|
||||
"npm:dax-sh@0.44.1": "0.44.1"
|
||||
},
|
||||
"npm": {
|
||||
|
|
@ -20,21 +19,19 @@
|
|||
"@stricli/core@1.2.4": {
|
||||
"integrity": "sha512-ujvJDQpC2FINWvlTjkFz+Qzw/vsB8p/LyZEW18idisqIyjXR6yb+sF3WTUPksl+5ZON5r4fHQnCqQWnJxeqSzg=="
|
||||
},
|
||||
"@types/node@22.15.15": {
|
||||
"integrity": "sha512-R5muMcZob3/Jjchn5LcO8jdKwSCbzqmPB6ruBxMcf9kbxtniZHP327s6C37iOfuw8mbKK3cAQa7sEl7afLrQ8A==",
|
||||
"@types/node@24.2.0": {
|
||||
"integrity": "sha512-3xyG3pMCq3oYCNg7/ZP+E1ooTaGB4cG8JWRsqqOYQdbWNY4zbaV0Ennrd7stjiJEFZCaybcIgpTjJWHRfBSIDw==",
|
||||
"dependencies": [
|
||||
"undici-types@6.21.0"
|
||||
"undici-types@7.10.0"
|
||||
]
|
||||
},
|
||||
"chalk@5.6.2": {
|
||||
"integrity": "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA=="
|
||||
},
|
||||
"dax-sh@0.44.1": {
|
||||
"integrity": "sha512-lUj0mA0LTO6CXUZmbUgFUhtlyowa+9hmg/Z4xeU8/FIdkM1oj541iZR5MELYZdX1IOFD51RLch8uiOTOHzbfSA==",
|
||||
"dependencies": [
|
||||
"@deno/shim-deno",
|
||||
"undici-types@5.28.4"
|
||||
]
|
||||
],
|
||||
"deprecated": true
|
||||
},
|
||||
"isexe@3.1.1": {
|
||||
"integrity": "sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ=="
|
||||
|
|
@ -42,8 +39,8 @@
|
|||
"undici-types@5.28.4": {
|
||||
"integrity": "sha512-3OeMF5Lyowe8VW0skf5qaIE7Or3yS9LS7fvMUI0gg4YxpIBVg0L8BxCmROw2CcYhSkpR68Epz7CGc8MPj94Uww=="
|
||||
},
|
||||
"undici-types@6.21.0": {
|
||||
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="
|
||||
"undici-types@7.10.0": {
|
||||
"integrity": "sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag=="
|
||||
},
|
||||
"which@4.0.0": {
|
||||
"integrity": "sha512-GlaYyEb07DPxYCKhKzplCWBJtvxZcZMrL+4UkrTSJHHPyZU4mYYTv3qaOe77H7EODLSSopAUFAc6W8U4yqvscg==",
|
||||
|
|
@ -56,7 +53,6 @@
|
|||
"workspace": {
|
||||
"dependencies": [
|
||||
"npm:@stricli/core@1.2.4",
|
||||
"npm:chalk@^5.6.2",
|
||||
"npm:dax-sh@0.44.1"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
27
src/impl.ts
27
src/impl.ts
|
|
@ -1,27 +1,7 @@
|
|||
import $ from 'dax-sh';
|
||||
import chalk from "chalk";
|
||||
import { buildCommand } from "@stricli/core";
|
||||
|
||||
const log = {
|
||||
verbose: false,
|
||||
setup(verbose: boolean) {
|
||||
this.verbose = verbose;
|
||||
},
|
||||
info(msg: string, ...rest: any[]) {
|
||||
if (this.verbose) {
|
||||
console.error(chalk.blue(msg), ...rest);
|
||||
}
|
||||
},
|
||||
error(msg: string, ...rest: any[]) {
|
||||
console.error(chalk.blue(msg), ...rest);
|
||||
}
|
||||
};
|
||||
|
||||
function loggingSetup(verbose: boolean) {
|
||||
log.setup(verbose);
|
||||
|
||||
$.setPrintCommand(verbose);
|
||||
}
|
||||
$.setPrintCommand(true);
|
||||
|
||||
const commonFlags = {
|
||||
verbose: {
|
||||
|
|
@ -32,9 +12,8 @@ const commonFlags = {
|
|||
};
|
||||
|
||||
export const hello = buildCommand({
|
||||
func: async (flags: { readonly verbose: boolean }) => {
|
||||
loggingSetup(flags.verbose);
|
||||
log.info("about to say hello");
|
||||
func: async (_flags: { readonly verbose: boolean }) => {
|
||||
$.logStep("about to say hello");
|
||||
await $`echo hello`;
|
||||
},
|
||||
parameters: { flags: { ...commonFlags } },
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
import {
|
||||
buildApplication,
|
||||
buildRouteMap,
|
||||
buildCommand,
|
||||
run
|
||||
} from '@stricli/core';
|
||||
import process from 'node:process';
|
||||
import $ from 'dax-sh';
|
||||
|
||||
|
||||
import {
|
||||
hello
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue