Repository navigation
[docs] Document trust confirmation for aspire template source add #1983
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
Closed
aspire-repo-bot
wants to merge
5
commits into
release/17.0
from
docs/pr-21418-40992075783-1-2a379538475e08e0
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ae3f5ca
Document aspire template source add trust confirmation
aspire-repo-bot[bot] d3f28ca
Add aspire template source add to the CLI reference sidebar
davidfowl 0ef4eef
Document both --path modes for aspire template source add
davidfowl 6fee391
Match template source add trust prompt and name rules to aspire main
davidfowl e061986
Align template source add name and path rules with aspire main
davidfowl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
...frontend/src/content/docs/reference/cli/commands/aspire-template-source-add.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| --- | ||
| title: aspire template source add command | ||
| description: Learn about the aspire template source add command and its usage. This command adds a named template source to global configuration after confirming you trust it. | ||
| --- | ||
|
|
||
| import Include from '@components/Include.astro'; | ||
|
|
||
| ## Name | ||
|
|
||
| `aspire template source add` - Add a named template source to global configuration after confirming you trust it. | ||
|
|
||
| ## Synopsis | ||
|
|
||
| ```bash title="Aspire CLI" | ||
| aspire template source add <name> [options] | ||
| ``` | ||
|
|
||
| ## Description | ||
|
|
||
| The `aspire template source add` command adds a named template source to global Aspire configuration. A template source is either a Git repository (`--repository`, optionally with `--path` and `--ref`) or an absolute local directory (`--path` without `--repository`). | ||
|
davidfowl marked this conversation as resolved.
Resolved
davidfowl marked this conversation as resolved.
Resolved
|
||
|
|
||
| Templates can run code, so the command asks you to trust the source before it changes any configuration. After it validates the name and location, it writes the warning "Only use sources you trust. Content from these sources can run code on your machine." to standard error. Then it prompts for confirmation. The prompt shows the source name and its repository URL or local path, and defaults to **No**: | ||
|
|
||
| ```text | ||
| Do you trust template source 'company' (https://example.com/templates)? [y/N]: | ||
| ``` | ||
|
|
||
| If you decline, the command is canceled and configuration isn't changed. To trust the source and skip the prompt, pass `--yes`. | ||
|
davidfowl marked this conversation as resolved.
Resolved
davidfowl marked this conversation as resolved.
Resolved
|
||
|
|
||
| Non-interactive invocations, including invocations where interactive input isn't available, fail unless you pass `--yes`. | ||
|
davidfowl marked this conversation as resolved.
Resolved
|
||
|
|
||
| ## Arguments | ||
|
|
||
| The following arguments are available: | ||
|
|
||
| - **`name`** | ||
|
davidfowl marked this conversation as resolved.
Resolved
|
||
|
|
||
| The name of the template source. The name must be 1-64 ASCII letters, digits, dots (`.`), hyphens (`-`), or underscores (`_`), and must start with a letter or digit. Names are case-insensitive, and the command fails if a template source with the same name already exists. | ||
|
|
||
| ## Options | ||
|
|
||
| The following options are available: | ||
|
|
||
| - **`--path`** | ||
|
|
||
| The template directory. Its meaning depends on whether `--repository` is specified: | ||
|
|
||
| - Without `--repository`, `--path` must be an absolute local directory that contains templates. | ||
|
davidfowl marked this conversation as resolved.
Resolved
|
||
| - With `--repository`, `--path` is a directory relative to the repository root. It can't be an absolute path or use `..` to point outside the repository. It defaults to the repository root (`.`). | ||
|
|
||
| - **`--repository`** | ||
|
|
||
| An HTTPS or SSH Git repository URL that contains templates. | ||
|
davidfowl marked this conversation as resolved.
Resolved
|
||
|
|
||
| - **`--ref`** | ||
|
|
||
| A Git branch, tag, or full commit SHA. Requires `--repository` and defaults to `HEAD`. | ||
|
davidfowl marked this conversation as resolved.
Resolved
|
||
|
|
||
| - **`-y, --yes`** | ||
|
davidfowl marked this conversation as resolved.
Resolved
|
||
|
|
||
| Trust the template source and skip confirmation. | ||
|
|
||
| - <Include relativePath="reference/cli/includes/option-help.md" /> | ||
|
|
||
| - <Include relativePath="reference/cli/includes/option-log-level.md" /> | ||
|
|
||
| - <Include relativePath="reference/cli/includes/option-non-interactive.md" /> | ||
|
|
||
| - <Include relativePath="reference/cli/includes/option-nologo.md" /> | ||
|
|
||
| - <Include relativePath="reference/cli/includes/option-banner.md" /> | ||
|
|
||
| - <Include relativePath="reference/cli/includes/option-wait.md" /> | ||
|
|
||
| ## Examples | ||
|
|
||
| - Add a template source and confirm trust interactively: | ||
|
|
||
| ```bash title="Aspire CLI" | ||
| aspire template source add company --repository https://example.com/templates | ||
|
davidfowl marked this conversation as resolved.
Resolved
|
||
| ``` | ||
|
|
||
| - Add a template source from a subdirectory of a repository at a specific tag: | ||
|
|
||
| ```bash title="Aspire CLI" | ||
| aspire template source add company --repository https://example.com/templates --path templates/web --ref v1.0.0 | ||
|
davidfowl marked this conversation as resolved.
Resolved
|
||
| ``` | ||
|
|
||
| - Add a template source from an absolute local directory: | ||
|
|
||
| ```bash title="Aspire CLI" | ||
| aspire template source add local --path /home/user/templates | ||
|
davidfowl marked this conversation as resolved.
Resolved
|
||
| ``` | ||
|
|
||
| - Add a template source in automation by explicitly trusting it: | ||
|
|
||
| ```bash title="Aspire CLI" | ||
| aspire template source add company --repository https://example.com/templates --non-interactive --yes | ||
|
davidfowl marked this conversation as resolved.
Resolved
|
||
| ``` | ||
45 changes: 45 additions & 0 deletions
45
src/frontend/tests/unit/cli-command-sidebar.vitest.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import { readdirSync } from 'node:fs'; | ||
| import { join } from 'node:path'; | ||
|
|
||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import { referenceTopics } from '../../config/sidebar/reference.topics'; | ||
|
|
||
| const commandsDir = join(process.cwd(), 'src/content/docs/reference/cli/commands'); | ||
|
|
||
| function collectSlugs(items: unknown, slugs: Set<string>): Set<string> { | ||
| if (!Array.isArray(items)) { | ||
| return slugs; | ||
| } | ||
|
|
||
| for (const item of items) { | ||
| if (typeof item === 'string') { | ||
| slugs.add(item); | ||
| } else if (item && typeof item === 'object') { | ||
| const { slug, items: children } = item as { slug?: unknown; items?: unknown }; | ||
| if (typeof slug === 'string') { | ||
| slugs.add(slug); | ||
| } | ||
| collectSlugs(children, slugs); | ||
| } | ||
| } | ||
|
|
||
| return slugs; | ||
| } | ||
|
|
||
| describe('CLI command reference sidebar', () => { | ||
| it('lists every CLI command page so the page resolves to the Reference topic', () => { | ||
| const slugs = collectSlugs(referenceTopics.items, new Set()); | ||
| const missing = readdirSync(commandsDir) | ||
| .filter((file) => /\.mdx?$/.test(file)) | ||
| .map((file) => `reference/cli/commands/${file.replace(/\.mdx?$/, '')}`) | ||
| .filter((slug) => !slugs.has(slug)); | ||
|
|
||
| expect(missing).toEqual([]); | ||
| }); | ||
|
|
||
| it('includes the aspire template source add command', () => { | ||
| const slugs = collectSlugs(referenceTopics.items, new Set()); | ||
| expect(slugs.has('reference/cli/commands/aspire-template-source-add')).toBe(true); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.