-
-
Notifications
You must be signed in to change notification settings - Fork 629
[NEXT]: webpack-cli serve refactor draft #1011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
4ee4d41
fix(cli): missing package, fixed function call
knagaitsev 83a27e7
cli(serve): started working on draft serve cli refactor
knagaitsev 25071ce
fix(serve): add newline at helper end
knagaitsev ab862d2
feat(cli): make serve use webpack cli compiler
knagaitsev ce8f284
fix(cli): await external command execution, fix lint
knagaitsev 46ca4de
feat(serve): add all flags, improve args parsing
knagaitsev 18636c3
fix(serve): fix gitignore, fix lint problems
knagaitsev 4668ea7
feat(serve): pass socket or port if no socket
knagaitsev 5f1cb74
misc(serve): add newlines at end of files
knagaitsev 89f94f5
misc(serve): removed unwanted js files
knagaitsev f6381d1
chore(cli): updated package lock
knagaitsev 28d303b
feat(cli): add helper to check if arg is the command name or alias
knagaitsev 1ddcf4a
chore(serve): update package lock
knagaitsev ed50ac1
misc(serve): change description of command and update snapshot
knagaitsev 786c5c0
cli(dev-server): handle host, port, and socket options and defaults
knagaitsev b29ec8f
chore(serve): updated dev server and fixed newline problem
knagaitsev f580b8f
chore(serve): made dev server optional peer dep
knagaitsev a713c47
misc(serve): change async await and use includes for args
knagaitsev b681514
cli(bootstrap): change helper functions slightly and fix style
knagaitsev c13f05b
misc(serve): moved dev server flags temporarily to lib folder
knagaitsev 9da9db4
chore(cli): fix helper to use includes for dashed flag stripping
knagaitsev 7e38b31
chore(serve): allow js in serve package
knagaitsev 6568984
style(serve): make args to camel case helper hyphen based filename
knagaitsev 4ba468b
style(bootstrap): return early and remove else from helper
knagaitsev 3c92b0a
chore(serve): remove allowjs from tsconfig
knagaitsev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,193 @@ | ||
const CONFIG_GROUP = 'Config options:'; | ||
const ADVANCED_GROUP = 'Advanced options:'; | ||
const DISPLAY_GROUP = 'Stats options:'; | ||
const SSL_GROUP = 'SSL options:'; | ||
const CONNECTION_GROUP = 'Connection options:'; | ||
const RESPONSE_GROUP = 'Response options:'; | ||
const BASIC_GROUP = 'Basic options:'; | ||
|
||
module.exports = { | ||
devServer: [ | ||
{ | ||
name: 'bonjour', | ||
type: Boolean, | ||
describe: 'Broadcasts the server via ZeroConf networking on start', | ||
}, | ||
{ | ||
name: 'lazy', | ||
type: Boolean, | ||
describe: 'Lazy', | ||
}, | ||
{ | ||
name: 'liveReload', | ||
type: Boolean, | ||
defaultValue: true, | ||
describe: 'Enables/Disables live reloading on changing files', | ||
}, | ||
{ | ||
name: 'serveIndex', | ||
type: Boolean, | ||
describe: 'Enables/Disables serveIndex middleware', | ||
defaultValue: true, | ||
}, | ||
{ | ||
name: 'inline', | ||
type: Boolean, | ||
defaultValue: true, | ||
describe: | ||
'Inline mode (set to false to disable including client scripts like livereload)', | ||
}, | ||
{ | ||
name: 'profile', | ||
type: Boolean, | ||
describe: 'Print compilation profile data for progress steps', | ||
}, | ||
{ | ||
name: 'progress', | ||
type: Boolean, | ||
describe: 'Print compilation progress in percentage', | ||
group: BASIC_GROUP, | ||
}, | ||
{ | ||
name: 'hot-only', | ||
type: Boolean, | ||
describe: 'Do not refresh page if HMR fails', | ||
group: ADVANCED_GROUP, | ||
}, | ||
{ | ||
name: 'stdin', | ||
type: Boolean, | ||
describe: 'close when stdin ends', | ||
}, | ||
{ | ||
name: 'open', | ||
type: String, | ||
describe: 'Open the default browser, or optionally specify a browser name', | ||
}, | ||
{ | ||
name: 'useLocalIp', | ||
type: Boolean, | ||
describe: 'Open default browser with local IP', | ||
}, | ||
{ | ||
name: 'open-page', | ||
type: String, | ||
describe: 'Open default browser with the specified page', | ||
}, | ||
{ | ||
name: 'client-log-level', | ||
type: String, | ||
group: DISPLAY_GROUP, | ||
defaultValue: 'info', | ||
describe: | ||
'Log level in the browser (trace, debug, info, warn, error or silent)', | ||
}, | ||
{ | ||
name: 'https', | ||
type: Boolean, | ||
group: SSL_GROUP, | ||
describe: 'HTTPS', | ||
}, | ||
{ | ||
name: 'http2', | ||
type: Boolean, | ||
group: SSL_GROUP, | ||
describe: 'HTTP/2, must be used with HTTPS', | ||
}, | ||
{ | ||
name: 'key', | ||
type: String, | ||
describe: 'Path to a SSL key.', | ||
group: SSL_GROUP, | ||
}, | ||
{ | ||
name: 'cert', | ||
type: String, | ||
describe: 'Path to a SSL certificate.', | ||
group: SSL_GROUP, | ||
}, | ||
{ | ||
name: 'cacert', | ||
type: String, | ||
describe: 'Path to a SSL CA certificate.', | ||
group: SSL_GROUP, | ||
}, | ||
{ | ||
name: 'pfx', | ||
type: String, | ||
describe: 'Path to a SSL pfx file.', | ||
group: SSL_GROUP, | ||
}, | ||
{ | ||
name: 'pfx-passphrase', | ||
type: String, | ||
describe: 'Passphrase for pfx file.', | ||
group: SSL_GROUP, | ||
}, | ||
{ | ||
name: 'content-base', | ||
type: String, | ||
describe: 'A directory or URL to serve HTML content from.', | ||
group: RESPONSE_GROUP, | ||
}, | ||
{ | ||
name: 'watch-content-base', | ||
type: Boolean, | ||
describe: 'Enable live-reloading of the content-base.', | ||
group: RESPONSE_GROUP, | ||
}, | ||
{ | ||
name: 'history-api-fallback', | ||
type: Boolean, | ||
describe: 'Fallback to /index.html for Single Page Applications.', | ||
group: RESPONSE_GROUP, | ||
}, | ||
{ | ||
name: 'compress', | ||
type: Boolean, | ||
describe: 'Enable gzip compression', | ||
group: RESPONSE_GROUP, | ||
}, | ||
// findPort is currently not set up | ||
{ | ||
name: 'port', | ||
type: Number, | ||
describe: 'The port', | ||
group: CONNECTION_GROUP, | ||
}, | ||
{ | ||
name: 'disable-host-check', | ||
type: Boolean, | ||
describe: 'Will not check the host', | ||
group: CONNECTION_GROUP, | ||
}, | ||
{ | ||
name: 'socket', | ||
type: String, | ||
describe: 'Socket to listen', | ||
group: CONNECTION_GROUP, | ||
}, | ||
{ | ||
name: 'public', | ||
type: String, | ||
describe: 'The public hostname/ip address of the server', | ||
group: CONNECTION_GROUP, | ||
}, | ||
{ | ||
name: 'host', | ||
type: String, | ||
describe: 'The hostname/ip address the server will bind to', | ||
group: CONNECTION_GROUP, | ||
}, | ||
// use command-line-args "multiple" option, allowing the usage: --allowed-hosts host1 host2 host3 | ||
// instead of the old, comma-separated syntax: --allowed-hosts host1,host2,host3 | ||
{ | ||
name: 'allowed-hosts', | ||
type: String, | ||
describe: | ||
'A list of hosts that are allowed to access the dev server, separated by spaces', | ||
group: CONNECTION_GROUP, | ||
multiple: true, | ||
}, | ||
], | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. /cc @Loonride it is very very very bad, next PR will change a lot of options, we don't need this do in webpack-cli |
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 +1,2 @@ | ||
*.js.map | ||
*.js |
This file contains hidden or 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,31 @@ | ||
/** | ||
* | ||
* Converts dash-seperated strings to camel case | ||
* | ||
* @param {String} str - the string to convert | ||
* | ||
* @returns {String} - new camel case string | ||
*/ | ||
function dashesToCamelCase(str): string { | ||
return str.replace(/-([a-z])/g, (g): string => g[1].toUpperCase()); | ||
} | ||
|
||
/** | ||
* | ||
* Converts CLI args to camel case from dash-separated words | ||
* | ||
* @param {Object} args - argument object parsed by command-line-args | ||
* | ||
* @returns {Object} - the same args object as passed in, with new keys | ||
*/ | ||
export default function argsToCamelCase(args): object { | ||
Object.keys(args).forEach((key): void => { | ||
const newKey = dashesToCamelCase(key); | ||
if (key !== newKey) { | ||
const arg = args[key]; | ||
delete args[key]; | ||
args[newKey] = arg; | ||
} | ||
}); | ||
return args; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.