-
-
Notifications
You must be signed in to change notification settings - Fork 305
1228: Process commands with context that might be strings or array of strings #1232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
1228: Process commands with context that might be strings or array of strings #1232
Conversation
Thanks for the PR! Just thinking out loud here (sorry if I'm ahead of myself here), why not options.getInputsFromScripts(['program', 'command '--', '--flag'].join(" ")) |
You mean instead of recursively diving into what ever it is that's in the command? I guess I just assumed that it would be better to leave it in the original form. Is it knip that ends up executing the command? or does it just look at it and say "huh... that's interesting?" Perhaps it's worth understanding what knip does with these commands that are returned from resolveConfig? https://knip.dev/guides/writing-a-plugin#6-resolveconfig
So something worth noting about moonrepo is that a task can describe useful work with either
# yaml-language-server: $schema=./../../.moon/cache/schemas/project.json
fileGroups:
env:
- "${workspaceRoot}/.env"
dockerfiles:
- "core/Dockerfile"
- "base/Dockerfile"
tasks:
build:
options:
runInCI: false
runFromWorkspaceRoot: true
outputStyle: stream
script: |
#!/bin/bash
set -euo pipefail
mise run docker:build \
--dir "$(pwd)" \
--secret type=env,id=MISE_GITHUB_TOKEN,env=MISE_GITHUB_TOKEN \
--file "pkgs/dockerfiles/Dockerfile" \
--image ghcr.io/me/mine \
--version "$(jq -r .version pkgs/dockerfiles/package.json)"
Point 6 says:
But this is not really what the original moonrepo plugin was doing to begin with. If we want to explore doing this properly for the moonrepo plugin we should probably answer these questions of how important that information is. |
side note: if mise allowed for easier merging of task files into a better command structure from throughout a monorepo I'd probably be using mise instead of moonrepo all together tbh. |
It's all pretty much just static analysis here (especially when it comes to YAML/JSON like here in this plugin). Knip definitely does not execute anything. The only "dynamic" thing Knip does is load/import JS/TS config files like
Knip plugins return so-called "inputs", as created with the To extract entry files and dependencies from scripts, Knip provides the Does that help? AMA :) |
Which is why you're suggesting to simplify the problem by squashing the array to one string. Seems good. Do we still want this generic template replacer thing or you want me to just turf it? |
Please remove |
fixes #1228
Provides a recursive string replacer that takes a map of things to replace.
Initially created to solve moonrepo problems... but highly likely other things with commands that allow templating would need this treatment too.