-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add white bg to error overlay * --overlay and --indicator flags * compartmentalize indicator * compartmentalize overlay * improve client entry * fix: !flag * Critical dependency eats the bowl * fix for proxy issues * maybe fix proxy for the kids * move proxy replacements to preset-wordpress * improve server * fix: bud.server * fix: test * fix: test * improve: logger-ish * fix: unbreak http server
- Loading branch information
1 parent
f9c5302
commit 240c621
Showing
44 changed files
with
698 additions
and
554 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,6 @@ volumes: | |
driver: local | ||
verdaccio: | ||
driver: local | ||
|
||
mocks: | ||
storage: | ||
driver: local | ||
mocks: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
title: Pathing | ||
description: Working with paths | ||
slug: installation | ||
sidebar_label: Paths | ||
sidebar_position: 3 | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,117 +1,42 @@ | ||
import type {Framework} from '@roots/bud-framework' | ||
import {chokidar} from '@roots/bud-support' | ||
import {Connection} from '@roots/bud-framework/src/Server' | ||
import {lodash} from '@roots/bud-support' | ||
|
||
/** | ||
* Input object | ||
* | ||
* @public | ||
*/ | ||
export interface UserRecordInput { | ||
/** | ||
* URL object or url string | ||
* | ||
* @defaultValue URL('http://localhost:3000') | ||
*/ | ||
url?: URL | string | ||
/** | ||
* Path to ssl certificate | ||
* | ||
* @defaultValue undefined | ||
*/ | ||
cert?: string | ||
/** | ||
* Path to ssl key | ||
* | ||
* @defaultValue undefined | ||
*/ | ||
key?: string | ||
/** | ||
* Client options | ||
*/ | ||
client?: { | ||
/** | ||
* Scripts to be injected before application scripts | ||
*/ | ||
scripts: Set<(app: Framework) => string> | ||
} | ||
|
||
/** | ||
* FSWatcher | ||
*/ | ||
watch?: { | ||
/** | ||
* Watched files | ||
*/ | ||
files: Array<string> | ||
/** | ||
* Watcher options | ||
*/ | ||
options?: chokidar.WatchOptions | ||
} | ||
} | ||
|
||
export type UserInput = URL | string | number | UserRecordInput | ||
const {isFunction} = lodash | ||
|
||
export interface method { | ||
(input?: UserInput): Framework | ||
( | ||
url: URL | string, | ||
options?: | ||
| Connection.Options | ||
| ((options: Connection.Options) => Connection.Options), | ||
): Framework | ||
} | ||
|
||
export type facade = method | ||
|
||
export const method: method = function (input) { | ||
const ctx = this as Framework | ||
export const method: method = function (input, options?) { | ||
const app = this as Framework | ||
|
||
if (!app.isDevelopment) return app | ||
|
||
if (!ctx.isDevelopment) return ctx | ||
if (options) { | ||
const unwrapped = isFunction(options) | ||
? options(app.hooks.filter('dev.options') ?? {}) | ||
: options | ||
|
||
if (typeof input === 'number') { | ||
return ctx.hooks.on('dev.url', url => { | ||
url.port = `${input}` | ||
return url | ||
}) | ||
app.hooks.on('dev.options', value => | ||
value ? {...value, ...unwrapped} : unwrapped, | ||
) | ||
} | ||
|
||
if (typeof input === 'string') { | ||
return ctx.hooks.on('dev.url', new URL(input)) | ||
return app.hooks.on('dev.url', new URL(input)) | ||
} | ||
|
||
if (input instanceof URL) { | ||
return ctx.hooks.on('dev.url', input) | ||
return app.hooks.on('dev.url', input) | ||
} | ||
|
||
input.url && | ||
ctx.hooks.on( | ||
'dev.url', | ||
input.url instanceof URL ? input.url : new URL(input.url), | ||
) | ||
|
||
input.key && ctx.hooks.on('dev.ssl.key', input.key) | ||
input.cert && ctx.hooks.on('dev.ssl.cert', input.cert) | ||
|
||
ctx.hooks.filter('dev.ssl.key') && | ||
ctx.hooks.filter('dev.ssl.cert') && | ||
ctx.hooks.on('dev.url', url => { | ||
url.protocol = `https:` | ||
url.port = url.port ?? `443` | ||
return url | ||
}) | ||
|
||
input.watch?.files && | ||
ctx.hooks.on('dev.watch.files', files => { | ||
input.watch.files.forEach(file => files.add(file)) | ||
return files | ||
}) | ||
|
||
input.watch?.options && | ||
ctx.hooks.on('dev.watch.options', options => ({ | ||
...options, | ||
...input.watch.options, | ||
})) | ||
|
||
input.client?.scripts && | ||
ctx.hooks.on('dev.client.scripts', scripts => { | ||
input.client.scripts.forEach(script => scripts.add(script)) | ||
return scripts | ||
}) | ||
|
||
return ctx | ||
return app | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,21 @@ | ||
import type {Framework} from '@roots/bud-framework' | ||
import {chokidar} from '@roots/bud-support' | ||
|
||
export interface watch { | ||
( | ||
/** | ||
* Watched files | ||
*/ | ||
files: Array<string>, | ||
/** | ||
* Watcher options | ||
*/ | ||
options?: chokidar.WatchOptions, | ||
...files: Array<string> | ||
): Framework | ||
} | ||
|
||
export const watch: watch = function (files, options = {}) { | ||
const ctx = this as Framework | ||
|
||
files = Array.isArray(files) ? files : [files] | ||
export const watch: watch = function (...input) { | ||
const app = this as Framework | ||
|
||
ctx.hooks | ||
.on('dev.watch.files', fileSet => { | ||
files.forEach(file => fileSet.add(file)) | ||
return fileSet | ||
}) | ||
.hooks.on('dev.watch.options', hookValue => ({ | ||
...(hookValue ?? {}), | ||
...(options ?? {}), | ||
})) | ||
input = Array.isArray(input) ? input : [input] | ||
app.hooks.on('dev.watch.files', files => | ||
input.reduce((files, file) => files.add(file), files), | ||
) | ||
|
||
return ctx | ||
return app | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.