spinframework / spinframework/spin

Naming convention for spin internal template parameters

Open
#1,097 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
6.5k
Forks
310
Avg merge
1d 20h
Merged PRs (30d)
24

Description

Spin provides a number of special internal parameters that can be used in templates:

    async fn special_values(&self) -> HashMap<String, String> {
        let mut values = HashMap::new();

        let authors = crate::environment::get_authors().await.unwrap_or_default();
        values.insert("authors".into(), authors.author);
        values.insert("username".into(), authors.username);
        values.insert("project-name".into(), self.options.name.clone());
        values.insert(
            "output-path".into(),
            self.relative_target_dir().to_string_lossy().to_string(),
        );

        values
    }

There are two possible improvements that could be made to the parameter naming conventions:

  1. A spin-* prefix could be employed to make it clear to template authors that these parameters are provided by the spin framework e.g. spin-authors.
  2. project-name could be improved by being made more general e.g. template-instance-name or item-name. project-name doesn't make sense when spin add is being run b/c you're actually creating a template not an application/project.

Please discuss whether these changes would be useful/worth the effort.

Note: See #1096 for the discussion that spurred this issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the special_values function shown in the issue and review the discussion in #1096. Determine whether a spin-* prefix and a more general replacement for project-name are warranted, then document the agreed naming convention and identify the affected template parameters.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.