Comments (9)
Fixed via #2370 - thank you @thesuhas
from spin.
I marked this as a good first issue, before realizing it might have a few implications for the template system.
@itowlson -- what do you think about this one?
from spin.
@radu-matei YOLO
Er
Yeah I think that's okay. It has I think two or three touch points, but there is already technology in there for skipping files, so hopefully nothing too onerous.
from spin.
@thesuhas — would you be interested in contributing this feature?
from spin.
@radu-matei I would! Although I have no idea where to get started. It would be great if you could point me in the right direction
from spin.
@thesuhas Thanks for stepping up! Regarding pointing you in the right direction: here are the things I'd be thinking about and the areas of the code I'd be looking at:
-
Decide if this is a per-template prompt or a built-in command-line option. We can discuss that on this issue.
a. If it's a built-in command-line option, you would add it insrc/commands/new.rs
and pass it through in thespin_template::RunOptions
(https://github.com/fermyon/spin/blob/main/src/commands/new.rs#L176).
b. If it's a template prompt then we need the template engine to understand parameter semantics, which is a new concept but way more flexible in the long run. -
Determine how to identify which files to exclude. This might need some design (and might depend on the outcome of option 1). Alternative ideas:
a. Have the template engine understand.gitignore
as a special file that is conditionally excluded.
b. Use a naming convention for files that may be conditionally excluded.
c. List files to be conditionally excluded in the template metadata. -
Implement conditionally excluding a file (or set of files). The set of files to copy is determined in
crates/templates/src/template.rs
, in theTemplate::included_files()
files function. This is currently fairly static, so either you need to modify it to accept dynamic decisions, or you need to post-process it inRun::included_files()
(inrun.rs
) - either way, you should have all the info you need at the call site.
a. My inclination here is to do the evaluation insideTemplate::included_files()
and avoid complicatingRun::included_files()
(which is more interested in taking snapshots of the files already deemed included). This opens up some nice abstraction opportunities where only theTemplate
needs to care about how abstract options like "no VCS" map to concrete files in its own particular case.
To be clear, I say this not to tell you what to do, but to support you figuring out how you want to approach this! I hope it doesn't come across as micro-managing. Please feel free to ping me if you want to discuss further or need more pointers - I'm very happy to help and support you.
from spin.
Hi,
Sorry for the extremely long delay.
I've added the option as an optional command line flag in TemplateNewCommandCore
. I am using this flag in RunOptions
in crates/templates/src/run.rs
. This is being accessed in included_files
and I am conditionally filtering out the all_content_files
based on the value of this flag.
I've tested it locally and it works but the tests are failing. This is due to a build issue in crates/templates/src/manager.rs
where RunOptions
is being initialised in multiple tests.
I was just wondering if it could be provided as false
for all of these tests and if that would be fine?
Additionally, would it be okay if I added a test case in crates/templates/src/test_built_ins/mod.rs
to verify that the .gitignore
file is being conditionally created or not?
from spin.
Yes, setting the new flag to false
in existing tests is fine.
For testing the flag, it would be preferable to do it in the manager
tests, which have come to include the run
behaviour tests. But if that turns out to be painful then test_built_ins
would be okay.
Thanks for the update and for staying with this!
from spin.
Hi,
I opened a pull request: #2370
from spin.
Related Issues (20)
- Templates: support Cargo workspaces
- Upcoming Security Release of Spin (GHSA-f3h7-gpjj-wcvh) HOT 1
- Support exporting application logs through OTel HOT 3
- spin-v2.4.3-macos-amd64.tar.gz contains the wrong architecture HOT 4
- Template install and upgrade commands use different option for Git/URL.
- Dynamically set service name for OTel resource
- `files` manifest option should warn when `destination` does not appear to be a directory HOT 3
- Consider using `http-acl` for enforcing `allowed-outbound-hosts`
- Enhance React application performance to run on embedded devices. HOT 4
- Received runtime error that should be thrown at component build time HOT 1
- Raspberry Pico HOT 1
- [OTel]: Spans produced by `spin_sdk::key_value::Store::set` don't have a parent assigned HOT 3
- Provide multiple entries as a variable for lists in 'spin.toml' HOT 17
- Add escape syntax to variables expansion syntax (`spin-expressions`) HOT 5
- Provide the ability to import manifest and runtime-config as wasm modules (components) HOT 10
- oci loader related problems with spinkube HOT 3
- Push component to registry HOT 1
- Handle redirects in outbound HTTP Requests
- Adding a trailling slash `/` to a domain name in `allow_outbound_hosts` fails HOT 1
- Move to badgen badge for discord in README
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spin.