fix(cpa): use proper branch tag (#9141)
The pinned git tag was not being threaded all the way through to where the download was occurring.
This commit is contained in:
@@ -78,15 +78,14 @@ export async function createProject(args: {
|
|||||||
)
|
)
|
||||||
await fse.copy(localTemplate, projectDir)
|
await fse.copy(localTemplate, projectDir)
|
||||||
} else if ('url' in template) {
|
} else if ('url' in template) {
|
||||||
let templateUrl = template.url
|
|
||||||
if (cliArgs['--template-branch']) {
|
if (cliArgs['--template-branch']) {
|
||||||
templateUrl = `${template.url}#${cliArgs['--template-branch']}`
|
template.url = `${template.url.split('#')?.[0]}#${cliArgs['--template-branch']}`
|
||||||
debug(`Using template url: ${templateUrl}`)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await downloadTemplate({
|
await downloadTemplate({
|
||||||
name: template.name,
|
debug: cliArgs['--debug'],
|
||||||
branch: 'beta',
|
|
||||||
projectDir,
|
projectDir,
|
||||||
|
template,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,27 +2,35 @@ import { Readable } from 'node:stream'
|
|||||||
import { pipeline } from 'node:stream/promises'
|
import { pipeline } from 'node:stream/promises'
|
||||||
import { x } from 'tar'
|
import { x } from 'tar'
|
||||||
|
|
||||||
|
import type { ProjectTemplate } from '../types.js'
|
||||||
|
|
||||||
|
import { debug as debugLog } from '../utils/log.js'
|
||||||
|
|
||||||
export async function downloadTemplate({
|
export async function downloadTemplate({
|
||||||
name,
|
debug,
|
||||||
branch,
|
|
||||||
projectDir,
|
projectDir,
|
||||||
|
template,
|
||||||
}: {
|
}: {
|
||||||
branch: string
|
debug?: boolean
|
||||||
/**
|
|
||||||
* The name of the template to download
|
|
||||||
* Must be dir /templates/<name>
|
|
||||||
*/
|
|
||||||
name: string
|
|
||||||
projectDir: string
|
projectDir: string
|
||||||
|
template: ProjectTemplate
|
||||||
}) {
|
}) {
|
||||||
const url = `https://codeload.github.com/payloadcms/payload/tar.gz/${branch}`
|
const branchOrTag = template.url.split('#')?.[1] || 'beta'
|
||||||
const filter = `payload-${branch}/templates/${name}/`
|
const url = `https://codeload.github.com/payloadcms/payload/tar.gz/${branchOrTag}`
|
||||||
|
const filter = `payload-${branchOrTag.replace(/^v/, '')}/templates/${template.name}/`
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
debugLog(`Using template url: ${template.url}`)
|
||||||
|
debugLog(`Codeload url: ${url}`)
|
||||||
|
debugLog(`Filter: ${filter}`)
|
||||||
|
}
|
||||||
|
|
||||||
await pipeline(
|
await pipeline(
|
||||||
await downloadTarStream(url),
|
await downloadTarStream(url),
|
||||||
x({
|
x({
|
||||||
cwd: projectDir,
|
cwd: projectDir,
|
||||||
filter: (p) => p.includes(filter),
|
filter: (p) => p.includes(filter),
|
||||||
strip: 2 + name.split('/').length,
|
strip: 2 + template.name.split('/').length,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ export function validateTemplate(templateName: string): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getValidTemplates(): ProjectTemplate[] {
|
export function getValidTemplates(): ProjectTemplate[] {
|
||||||
|
// Starters _must_ be a valid template name from the templates/ directory
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
name: 'blank',
|
name: 'blank',
|
||||||
@@ -28,37 +29,11 @@ export function getValidTemplates(): ProjectTemplate[] {
|
|||||||
url: `https://github.com/payloadcms/payload/templates/website#v${PACKAGE_VERSION}`,
|
url: `https://github.com/payloadcms/payload/templates/website#v${PACKAGE_VERSION}`,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Remove these until they have been updated for 3.0
|
|
||||||
|
|
||||||
// {
|
|
||||||
// name: 'blank',
|
|
||||||
// type: 'starter',
|
|
||||||
// description: 'Blank Template',
|
|
||||||
// url: 'https://github.com/payloadcms/payload/templates/blank',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// name: 'ecommerce',
|
|
||||||
// type: 'starter',
|
|
||||||
// description: 'E-commerce Template',
|
|
||||||
// url: 'https://github.com/payloadcms/payload/templates/ecommerce',
|
|
||||||
// },
|
|
||||||
// {
|
// {
|
||||||
// name: 'plugin',
|
// name: 'plugin',
|
||||||
// type: 'plugin',
|
// type: 'plugin',
|
||||||
// description: 'Template for creating a Payload plugin',
|
// description: 'Template for creating a Payload plugin',
|
||||||
// url: 'https://github.com/payloadcms/payload-plugin-template#beta',
|
// url: 'https://github.com/payloadcms/plugin-template#beta',
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// name: 'payload-demo',
|
|
||||||
// type: 'starter',
|
|
||||||
// description: 'Payload demo site at https://demo.payloadcms.com',
|
|
||||||
// url: 'https://github.com/payloadcms/public-demo',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// name: 'payload-website',
|
|
||||||
// type: 'starter',
|
|
||||||
// description: 'Payload website CMS at https://payloadcms.com',
|
|
||||||
// url: 'https://github.com/payloadcms/website-cms',
|
|
||||||
// },
|
// },
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ export class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (debugFlag) {
|
if (debugFlag) {
|
||||||
debug(`Using templates from git tag: ${PACKAGE_VERSION}`)
|
debug(`Using templates from git tag: v${PACKAGE_VERSION}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const validTemplates = getValidTemplates()
|
const validTemplates = getValidTemplates()
|
||||||
|
|||||||
Reference in New Issue
Block a user