Skip to content

Commit 09e2f33

Browse files
committed
feat: dynamically fetch Epic Stack version during project initialization
Remove static version workflow and add a function to fetch the latest Epic Stack version when creating a new project
1 parent 4295ac1 commit 09e2f33

File tree

3 files changed

+27
-58
lines changed

3 files changed

+27
-58
lines changed

.github/workflows/version.yml

Lines changed: 0 additions & 54 deletions
This file was deleted.

package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
"private": true,
44
"sideEffects": false,
55
"license": "MIT",
6-
"epic-stack": {
7-
"head": "947f3368d51220173eeff1385fb6ca8a62de5245",
8-
"date": "2025-02-20T16:37:28Z"
9-
},
106
"author": "Kent C. Dodds <[email protected]> (https://kentcdodds.com/)",
117
"type": "module",
128
"imports": {

remix.init/index.mjs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@ const escapeRegExp = (string) =>
1515
const getRandomString = (length) => crypto.randomBytes(length).toString('hex')
1616
const getRandomString32 = () => getRandomString(32)
1717

18+
async function getEpicStackVersion() {
19+
const response = await fetch(
20+
'https://api.github.com/repos/epicweb-dev/epic-stack/commits/main',
21+
)
22+
if (!response.ok) {
23+
throw new Error(
24+
`Failed to fetch Epic Stack version: ${response.status} ${response.statusText}`,
25+
)
26+
}
27+
const data = await response.json()
28+
return {
29+
head: data.sha,
30+
date: data.commit.author.date,
31+
}
32+
}
33+
1834
export default async function main({ rootDirectory }) {
1935
const FLY_TOML_PATH = path.join(rootDirectory, 'fly.toml')
2036
const EXAMPLE_ENV_PATH = path.join(rootDirectory, '.env.example')
@@ -53,6 +69,17 @@ export default async function main({ rootDirectory }) {
5369
delete packageJson.author
5470
delete packageJson.license
5571

72+
// Add Epic Stack version information
73+
try {
74+
const epicStackVersion = await getEpicStackVersion()
75+
packageJson['epic-stack'] = epicStackVersion
76+
} catch (error) {
77+
console.warn(
78+
'Failed to fetch Epic Stack version information. The package.json will not include version details.',
79+
error,
80+
)
81+
}
82+
5683
const fileOperationPromises = [
5784
fs.writeFile(FLY_TOML_PATH, newFlyTomlContent),
5885
fs.writeFile(ENV_PATH, newEnv),

0 commit comments

Comments
 (0)