Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support Laravel Herd for windows #293

Merged
merged 1 commit into from
May 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -547,7 +547,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 @@ -570,8 +570,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 @@ -602,12 +606,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
Loading