/
examples.ts
89 lines (81 loc) · 2.55 KB
/
examples.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
*/
import { downloadAndExtractRepo, getRepoInfo } from './util/examples'
import chalk from 'chalk'
import { copy } from 'fs-extra'
import path from 'path'
type BaseExample = {
title: string
description?: string
value: string
}
export type InternalExample = BaseExample & {
isInternal: true
}
export type ExternalExample = BaseExample & {
isInternal: false
gitURL: string
}
export type Example = InternalExample | ExternalExample
export const EXAMPLES: Example[] = [
{
title: 'Bare bones starter',
description:
'Stripped down to essentials, this starter is the canvas for pure, unadulterated code creativity.',
value: 'basic',
isInternal: false,
gitURL: 'https://github.com/tinacms/tina-barebones-starter',
},
{
title: '⭐ Tailwind Starter',
description:
'Choosing Tailwind makes you feel like you are god with CSS. You can do anything.',
value: 'tina-cloud-starter',
isInternal: false,
gitURL: 'https://github.com/tinacms/tina-cloud-starter',
},
{
title: 'Hugo Starter',
description:
'With Hugo, you wield the power of lightning-fast site generation, crafting web experiences at the speed of thought.',
value: 'tina-hugo-starter',
isInternal: false,
gitURL: 'https://github.com/tinacms/tina-hugo-starter',
},
{
title: 'Remix Starter',
description:
'Dive into Remix to orchestrate seamless, interactive user journeys like a maestro of the web.',
value: 'tina-remix-starter',
isInternal: false,
gitURL: 'https://github.com/tinacms/tina-remix-starter',
},
{
title: 'Docusaurus Starter',
description:
'Docusaurus empowers you to build and evolve documentation like crafting a living, breathing knowledge repository.',
value: 'tinasaurus',
isInternal: false,
gitURL: 'https://github.com/tinacms/tinasaurus',
},
]
export const downloadExample = async (example: Example, root: string) => {
if (example.isInternal === false) {
// need to download example from github
// Make a github URL
const repoURL = new URL(example.gitURL)
// Download the Repo
const repoInfo = await getRepoInfo(repoURL)
const repoInfo2 = repoInfo
console.log(
`Downloading files from repo ${chalk.cyan(
repoInfo.username + '/' + repoInfo.name
)}. This might take a moment.`
)
await downloadAndExtractRepo(root, repoInfo2)
} else {
// need to copy the example from local file system
const exampleFile = path.join(__dirname, '..', 'examples', example.value)
await copy(`${exampleFile}/`, './')
}
}