various improvements

This commit is contained in:
EatThePooh 2026-01-22 18:06:24 +07:00
parent 8222743519
commit abbf4550d8
6 changed files with 29 additions and 47 deletions

View file

@ -1,19 +1,29 @@
# AGENTS.md # 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 ## Nix
- Enter a dev shell with `nix develop` - Assume nothing will work outside of the shell; however, it is likely you are already in it
- Assume nothing will work outside of the shell - If not, run tests with `nix develop --command`
- See/edit `flake.nix` for relevant concerns - See/edit `flake.nix` for relevant concerns
- If the shell complains about command not being found, add to the flake
## Deno ## Deno
- Manage dependencies with `deno add` and `deno remove` in `./src` directory - Manage dependencies with `deno add` and `deno remove` in `./src` directory
- Deno maintains its own `deno.lock` which Nix picks up - Deno maintains its own `deno.lock` which Nix picks up
- IMPORTANT: never use JSR dependencies, only NPM - IMPORTANT: never use JSR dependencies, only NPM
- Example: `deno add npm:chalk` then `import chalk from "chalk";` in `.ts` files - Example: `deno add npm:chalk` then `import chalk from "chalk";` in `.ts` files
- Run `cd src && deno check *.ts` occasionaly
## Project conventions ## Project conventions
- Entry points are CLI subcommands (`./src/main.ts`) - Entry points are CLI subcommands (`./src/main.ts`)
- Use `@stricli/core` for CLI
- Prefer to do things by running shell commands via `dax-sh` - Prefer to do things by running shell commands via `dax-sh`
- Verbosity implies `$.setPrintCommand(true)` for `dax-sh` to output what it runs - Use `$.logStep`, `$.logError`, etc. for logs, `console.log` for writing to stdout
- Logs always go to `stderr` so that `stdout` can be redirected to a file safely - Go easy on logs and comments, ensure no redundancy

View file

@ -10,8 +10,7 @@ pkgs.stdenv.mkDerivation {
# This is meant to be executed from inside a devShell with Deno set up # This is meant to be executed from inside a devShell with Deno set up
cat > $out/bin/${name} <<EOF cat > $out/bin/${name} <<EOF
#!/bin/sh #!/bin/sh
cd ${builtins.placeholder "out"} exec ${config.deno-with-packages.package}/bin/deno run -A ${builtins.placeholder "out"}/main.ts "\$@"
exec ${config.deno-with-packages.package}/bin/deno task --quiet run "\$@"
EOF EOF
chmod +x $out/bin/${name} chmod +x $out/bin/${name}
''; '';

View file

@ -1,10 +1,9 @@
{ {
"tasks": { "tasks": {
"run": "deno run -A main.ts" "run": "deno run -A src/main.ts"
}, },
"imports": { "imports": {
"@stricli/core": "npm:@stricli/core@1.2.4", "@stricli/core": "npm:@stricli/core@1.2.4",
"chalk": "npm:chalk@^5.6.2",
"dax-sh": "npm:dax-sh@0.44.1", "dax-sh": "npm:dax-sh@0.44.1",
} }
} }

20
src/deno.lock generated
View file

@ -2,8 +2,7 @@
"version": "5", "version": "5",
"specifiers": { "specifiers": {
"npm:@stricli/core@1.2.4": "1.2.4", "npm:@stricli/core@1.2.4": "1.2.4",
"npm:@types/node@*": "22.15.15", "npm:@types/node@*": "24.2.0",
"npm:chalk@^5.6.2": "5.6.2",
"npm:dax-sh@0.44.1": "0.44.1" "npm:dax-sh@0.44.1": "0.44.1"
}, },
"npm": { "npm": {
@ -20,21 +19,19 @@
"@stricli/core@1.2.4": { "@stricli/core@1.2.4": {
"integrity": "sha512-ujvJDQpC2FINWvlTjkFz+Qzw/vsB8p/LyZEW18idisqIyjXR6yb+sF3WTUPksl+5ZON5r4fHQnCqQWnJxeqSzg==" "integrity": "sha512-ujvJDQpC2FINWvlTjkFz+Qzw/vsB8p/LyZEW18idisqIyjXR6yb+sF3WTUPksl+5ZON5r4fHQnCqQWnJxeqSzg=="
}, },
"@types/node@22.15.15": { "@types/node@24.2.0": {
"integrity": "sha512-R5muMcZob3/Jjchn5LcO8jdKwSCbzqmPB6ruBxMcf9kbxtniZHP327s6C37iOfuw8mbKK3cAQa7sEl7afLrQ8A==", "integrity": "sha512-3xyG3pMCq3oYCNg7/ZP+E1ooTaGB4cG8JWRsqqOYQdbWNY4zbaV0Ennrd7stjiJEFZCaybcIgpTjJWHRfBSIDw==",
"dependencies": [ "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": { "dax-sh@0.44.1": {
"integrity": "sha512-lUj0mA0LTO6CXUZmbUgFUhtlyowa+9hmg/Z4xeU8/FIdkM1oj541iZR5MELYZdX1IOFD51RLch8uiOTOHzbfSA==", "integrity": "sha512-lUj0mA0LTO6CXUZmbUgFUhtlyowa+9hmg/Z4xeU8/FIdkM1oj541iZR5MELYZdX1IOFD51RLch8uiOTOHzbfSA==",
"dependencies": [ "dependencies": [
"@deno/shim-deno", "@deno/shim-deno",
"undici-types@5.28.4" "undici-types@5.28.4"
] ],
"deprecated": true
}, },
"isexe@3.1.1": { "isexe@3.1.1": {
"integrity": "sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ==" "integrity": "sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ=="
@ -42,8 +39,8 @@
"undici-types@5.28.4": { "undici-types@5.28.4": {
"integrity": "sha512-3OeMF5Lyowe8VW0skf5qaIE7Or3yS9LS7fvMUI0gg4YxpIBVg0L8BxCmROw2CcYhSkpR68Epz7CGc8MPj94Uww==" "integrity": "sha512-3OeMF5Lyowe8VW0skf5qaIE7Or3yS9LS7fvMUI0gg4YxpIBVg0L8BxCmROw2CcYhSkpR68Epz7CGc8MPj94Uww=="
}, },
"undici-types@6.21.0": { "undici-types@7.10.0": {
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==" "integrity": "sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag=="
}, },
"which@4.0.0": { "which@4.0.0": {
"integrity": "sha512-GlaYyEb07DPxYCKhKzplCWBJtvxZcZMrL+4UkrTSJHHPyZU4mYYTv3qaOe77H7EODLSSopAUFAc6W8U4yqvscg==", "integrity": "sha512-GlaYyEb07DPxYCKhKzplCWBJtvxZcZMrL+4UkrTSJHHPyZU4mYYTv3qaOe77H7EODLSSopAUFAc6W8U4yqvscg==",
@ -56,7 +53,6 @@
"workspace": { "workspace": {
"dependencies": [ "dependencies": [
"npm:@stricli/core@1.2.4", "npm:@stricli/core@1.2.4",
"npm:chalk@^5.6.2",
"npm:dax-sh@0.44.1" "npm:dax-sh@0.44.1"
] ]
} }

View file

@ -1,27 +1,7 @@
import $ from 'dax-sh'; import $ from 'dax-sh';
import chalk from "chalk";
import { buildCommand } from "@stricli/core"; import { buildCommand } from "@stricli/core";
const log = { $.setPrintCommand(true);
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);
}
const commonFlags = { const commonFlags = {
verbose: { verbose: {
@ -32,9 +12,8 @@ const commonFlags = {
}; };
export const hello = buildCommand({ export const hello = buildCommand({
func: async (flags: { readonly verbose: boolean }) => { func: async (_flags: { readonly verbose: boolean }) => {
loggingSetup(flags.verbose); $.logStep("about to say hello");
log.info("about to say hello");
await $`echo hello`; await $`echo hello`;
}, },
parameters: { flags: { ...commonFlags } }, parameters: { flags: { ...commonFlags } },

View file

@ -1,11 +1,10 @@
import { import {
buildApplication, buildApplication,
buildRouteMap, buildRouteMap,
buildCommand,
run run
} from '@stricli/core'; } from '@stricli/core';
import process from 'node:process'; import process from 'node:process';
import $ from 'dax-sh';
import { import {
hello hello