mirror of
https://github.com/withastro/astro.git
synced 2024-12-30 22:03:56 -05:00
Improve default template download speed (#12154)
This commit is contained in:
parent
582f12e1f6
commit
9988dd67e2
10 changed files with 170 additions and 6 deletions
5
.changeset/curvy-bikes-sing.md
Normal file
5
.changeset/curvy-bikes-sing.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'create-astro': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Improves default template download speed by downloading from a branch containing the template only
|
6
.github/workflows/sync-examples.yml
vendored
6
.github/workflows/sync-examples.yml
vendored
|
@ -40,11 +40,13 @@ jobs:
|
||||||
# We only do sync if there are no changesets, so we don't accidentally allow users
|
# We only do sync if there are no changesets, so we don't accidentally allow users
|
||||||
# to clone examples that may rely on unreleased code
|
# to clone examples that may rely on unreleased code
|
||||||
|
|
||||||
- name: Sync from main branch to latest branch
|
- name: Sync from main branch to latest and examples/* branches
|
||||||
if: steps.detect.outputs.has-changesets == 'false' && github.ref == 'refs/heads/main'
|
if: steps.detect.outputs.has-changesets == 'false' && github.ref == 'refs/heads/main'
|
||||||
uses: bluwy/auto-branch-sync-action@v1
|
uses: bluwy/auto-branch-sync-action@v1
|
||||||
with:
|
with:
|
||||||
map: / -> latest
|
map: |
|
||||||
|
/ -> latest
|
||||||
|
/examples/* -> examples/*
|
||||||
skip-unchanged-check: ${{ inputs.skip-unchanged-check == true }}
|
skip-unchanged-check: ${{ inputs.skip-unchanged-check == true }}
|
||||||
dry-run: ${{ inputs.dry-run == true }}
|
dry-run: ${{ inputs.dry-run == true }}
|
||||||
|
|
||||||
|
|
4
examples/hackernews/.gitignore
vendored
4
examples/hackernews/.gitignore
vendored
|
@ -1,6 +1,5 @@
|
||||||
# build output
|
# build output
|
||||||
dist/
|
dist/
|
||||||
.output/
|
|
||||||
# generated types
|
# generated types
|
||||||
.astro/
|
.astro/
|
||||||
|
|
||||||
|
@ -20,3 +19,6 @@ pnpm-debug.log*
|
||||||
|
|
||||||
# macOS-specific files
|
# macOS-specific files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
# jetbrains setting folder
|
||||||
|
.idea/
|
||||||
|
|
24
examples/integration/.gitignore
vendored
Normal file
24
examples/integration/.gitignore
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# build output
|
||||||
|
dist/
|
||||||
|
# generated types
|
||||||
|
.astro/
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# logs
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
|
||||||
|
|
||||||
|
# environment variables
|
||||||
|
.env
|
||||||
|
.env.production
|
||||||
|
|
||||||
|
# macOS-specific files
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# jetbrains setting folder
|
||||||
|
.idea/
|
24
examples/middleware/.gitignore
vendored
Normal file
24
examples/middleware/.gitignore
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# build output
|
||||||
|
dist/
|
||||||
|
# generated types
|
||||||
|
.astro/
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# logs
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
|
||||||
|
|
||||||
|
# environment variables
|
||||||
|
.env
|
||||||
|
.env.production
|
||||||
|
|
||||||
|
# macOS-specific files
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# jetbrains setting folder
|
||||||
|
.idea/
|
24
examples/server-islands/.gitignore
vendored
Normal file
24
examples/server-islands/.gitignore
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# build output
|
||||||
|
dist/
|
||||||
|
# generated types
|
||||||
|
.astro/
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# logs
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
|
||||||
|
|
||||||
|
# environment variables
|
||||||
|
.env
|
||||||
|
.env.production
|
||||||
|
|
||||||
|
# macOS-specific files
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# jetbrains setting folder
|
||||||
|
.idea/
|
24
examples/ssr/.gitignore
vendored
Normal file
24
examples/ssr/.gitignore
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# build output
|
||||||
|
dist/
|
||||||
|
# generated types
|
||||||
|
.astro/
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# logs
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
|
||||||
|
|
||||||
|
# environment variables
|
||||||
|
.env
|
||||||
|
.env.production
|
||||||
|
|
||||||
|
# macOS-specific files
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# jetbrains setting folder
|
||||||
|
.idea/
|
24
examples/starlog/.gitignore
vendored
Normal file
24
examples/starlog/.gitignore
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# build output
|
||||||
|
dist/
|
||||||
|
# generated types
|
||||||
|
.astro/
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# logs
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
|
||||||
|
|
||||||
|
# environment variables
|
||||||
|
.env
|
||||||
|
.env.production
|
||||||
|
|
||||||
|
# macOS-specific files
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# jetbrains setting folder
|
||||||
|
.idea/
|
24
examples/view-transitions/.gitignore
vendored
Normal file
24
examples/view-transitions/.gitignore
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# build output
|
||||||
|
dist/
|
||||||
|
# generated types
|
||||||
|
.astro/
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# logs
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
|
||||||
|
|
||||||
|
# environment variables
|
||||||
|
.env
|
||||||
|
.env.production
|
||||||
|
|
||||||
|
# macOS-specific files
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# jetbrains setting folder
|
||||||
|
.idea/
|
|
@ -72,13 +72,25 @@ const FILES_TO_UPDATE = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getTemplateTarget(tmpl: string, ref = 'latest') {
|
export function getTemplateTarget(tmpl: string, ref = 'latest') {
|
||||||
|
// Handle Starlight templates
|
||||||
if (tmpl.startsWith('starlight')) {
|
if (tmpl.startsWith('starlight')) {
|
||||||
const [, starter = 'basics'] = tmpl.split('/');
|
const [, starter = 'basics'] = tmpl.split('/');
|
||||||
return `withastro/starlight/examples/${starter}`;
|
return `github:withastro/starlight/examples/${starter}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle third-party templates
|
||||||
const isThirdParty = tmpl.includes('/');
|
const isThirdParty = tmpl.includes('/');
|
||||||
if (isThirdParty) return tmpl;
|
if (isThirdParty) return tmpl;
|
||||||
return `github:withastro/astro/examples/${tmpl}#${ref}`;
|
|
||||||
|
// Handle Astro templates
|
||||||
|
if (ref === 'latest') {
|
||||||
|
// `latest` ref is specially handled to route to a branch specifically
|
||||||
|
// to allow faster downloads. Otherwise giget has to download the entire
|
||||||
|
// repo and only copy a sub directory
|
||||||
|
return `github:withastro/astro#examples/${tmpl}`;
|
||||||
|
} else {
|
||||||
|
return `github:withastro/astro/examples/${tmpl}#${ref}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function copyTemplate(tmpl: string, ctx: Context) {
|
export default async function copyTemplate(tmpl: string, ctx: Context) {
|
||||||
|
@ -88,7 +100,6 @@ export default async function copyTemplate(tmpl: string, ctx: Context) {
|
||||||
try {
|
try {
|
||||||
await downloadTemplate(templateTarget, {
|
await downloadTemplate(templateTarget, {
|
||||||
force: true,
|
force: true,
|
||||||
provider: 'github',
|
|
||||||
cwd: ctx.cwd,
|
cwd: ctx.cwd,
|
||||||
dir: '.',
|
dir: '.',
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue