@@ -15,6 +15,22 @@ const escapeRegExp = (string) =>
1515const getRandomString = ( length ) => crypto . randomBytes ( length ) . toString ( 'hex' )
1616const 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+
1834export 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