2
2
3
3
import process from 'node:process'
4
4
import { type AddressInfo } from 'node:net'
5
- import { type CliOptions , type Manifest , type NpmScript , type StacksError , type Subprocess } from '@stacksjs/types'
5
+ import type { CliOptions , Manifest , NpmScript , StacksError , Subprocess } from '@stacksjs/types'
6
+ import { Action } from '@stacksjs/types'
6
7
import { frameworkPath , projectPath } from '@stacksjs/path'
7
8
import { parse } from 'yaml'
9
+ import { runAction } from '@stacksjs/actions'
8
10
import { italic , log , runCommand } from '@stacksjs/cli'
9
11
import * as storage from '@stacksjs/storage'
10
12
import { readPackageJson } from '@stacksjs/storage'
11
- import { type Result } from '@stacksjs/error-handling'
12
- import { err } from '@stacksjs/error-handling'
13
+ import type { Result } from '@stacksjs/error-handling'
14
+ import { err , ok } from '@stacksjs/error-handling'
13
15
import { semver } from './versions'
14
16
import ui from '~/config/ui'
15
17
import dependencies from '~/config/deps'
@@ -21,7 +23,7 @@ export async function packageManager() {
21
23
}
22
24
23
25
export async function initProject ( ) : Promise < Result < Subprocess , StacksError > > {
24
- if ( env . APP_ENV !== 'production' )
26
+ if ( app . env !== 'production' )
25
27
log . info ( 'Project not yet initialized, generating application key...' )
26
28
else
27
29
handleError ( new Error ( 'Please run `buddy key:generate` to generate an application key' ) )
@@ -40,10 +42,11 @@ export async function isProjectInitialized() {
40
42
if ( storage . isFile ( '.env' ) )
41
43
return await isAppKeySet ( )
42
44
43
- // TODO: need to re-enable this
44
- // copy the .env.example to become the .env file
45
- // if (storage.isFile('.env.example'))
46
- // await spawn('cp .env.example .env', { stdio: 'inherit', cwd: projectPath() })
45
+ // copy the .env.example file to .env
46
+ if ( storage . isFile ( '.env.example' ) )
47
+ await runCommand ( 'cp .env.example .env' , { cwd : projectPath ( ) } )
48
+ else
49
+ console . error ( 'no .env.example file found' )
47
50
48
51
return await isAppKeySet ( )
49
52
}
0 commit comments