0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-27 22:19:04 -05:00

parse tag from command

This commit is contained in:
apatel369 2024-11-30 00:21:36 -06:00
parent 4bde0d0d47
commit cfd35f5e84
2 changed files with 6 additions and 4 deletions

View file

@ -34,6 +34,8 @@ export interface Context {
}
export async function getContext(argv: string[]): Promise<Context> {
const packageTag = argv.find((argItem) => /^(astro|create-astro)@/.exec(argItem))?.split('@')[1];
const flags = arg(
{
'--template': String,
@ -76,7 +78,7 @@ export async function getContext(argv: string[]): Promise<Context> {
} = flags;
let projectName = cwd;
const tag = ref === 'next' ? 'beta' : ref;
if (no) {
yes = false;
if (install == undefined) install = false;
@ -94,7 +96,7 @@ export async function getContext(argv: string[]): Promise<Context> {
prompt,
packageManager,
username: getName(),
version: getVersion(packageManager, 'astro', process.env.ASTRO_VERSION, tag),
version: getVersion(packageManager, 'astro', packageTag, process.env.ASTRO_VERSION),
skipHouston,
fancy,
add,

View file

@ -60,10 +60,10 @@ export const getName = () =>
});
});
export const getVersion = (packageManager: string, packageName: string, fallback = '', tag = 'latest') =>
export const getVersion = (packageManager: string, packageName: string, packageTag = 'latest', fallback = '') =>
new Promise<string>(async (resolve) => {
let registry = await getRegistry(packageManager);
const { version } = await fetch(`${registry}/${packageName}/${tag}`, {
const { version } = await fetch(`${registry}/${packageName}/${packageTag}`, {
redirect: 'follow',
})
.then((res) => res.json())