Skip to content

Commit

Permalink
Support Laravel Herd for windows (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
mozex committed May 9, 2024
1 parent fcd76b5 commit eb66feb
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ function resolveLaravelPlugin(pluginConfig: Required<PluginConfig>): LaravelPlug
server.config.logger.info(` ${colors.green('➜')} ${colors.bold('APP_URL')}: ${colors.cyan(appUrl.replace(/:(\d+)/, (_, port) => `:${colors.bold(port)}`))}`)

if (typeof resolvedConfig.server.https === 'object' && typeof resolvedConfig.server.https.key === 'string') {
if (resolvedConfig.server.https.key.startsWith(herdConfigPath())) {
if (resolvedConfig.server.https.key.startsWith(herdMacConfigPath()) || resolvedConfig.server.https.key.startsWith(herdWindowsConfigPath())) {
server.config.logger.info(` ${colors.green('➜')} Using Herd certificate to secure Vite.`)
}

Expand Down Expand Up @@ -548,7 +548,7 @@ function resolveDevelopmentEnvironmentServerConfig(host: string|boolean|null): {
return
}

if (configPath === herdConfigPath()) {
if (configPath === herdMacConfigPath() || configPath === herdWindowsConfigPath()) {
throw Error(`Unable to find certificate files for your host [${resolvedHost}] in the [${configPath}/Certificates] directory. Ensure you have secured the site via the Herd UI.`)
} else if (typeof host === 'string') {
throw Error(`Unable to find certificate files for your host [${resolvedHost}] in the [${configPath}/Certificates] directory. Ensure you have secured the site by running \`valet secure ${host}\`.`)
Expand All @@ -571,8 +571,12 @@ function resolveDevelopmentEnvironmentServerConfig(host: string|boolean|null): {
* Resolve the path to the Herd or Valet configuration directory.
*/
function determineDevelopmentEnvironmentConfigPath(): string|undefined {
if (fs.existsSync(herdConfigPath())) {
return herdConfigPath()
if (fs.existsSync(herdMacConfigPath())) {
return herdMacConfigPath()
}

if (fs.existsSync(herdWindowsConfigPath())) {
return herdWindowsConfigPath()
}

if (fs.existsSync(valetConfigPath())) {
Expand Down Expand Up @@ -603,12 +607,19 @@ function dirname(): string {
}

/**
* Herd's configuration directory.
* Herd's Mac configuration directory.
*/
function herdConfigPath(): string {
function herdMacConfigPath(): string {
return path.resolve(os.homedir(), 'Library', 'Application Support', 'Herd', 'config', 'valet')
}

/**
* Herd's Windows configuration directory.
*/
function herdWindowsConfigPath(): string {
return path.resolve(os.homedir(), ".config", "herd", "config", "valet")
}

/**
* Valet's configuration directory.
*/
Expand Down

0 comments on commit eb66feb

Please sign in to comment.