Skip to content

Commit

Permalink
feat(svrx): first version of svrx (#2)
Browse files Browse the repository at this point in the history
* chore: first commit

* build: add depency

* v0.0.2

* build(npm): add test framewokr like mocha expect.js nyc etc

* feat(svrx): add middleware basic logic

- add testcase for utility
- add testcase for middleware basic (proxy , serveStatic )
- fix eslint error

* feat(plugin): basic plugin feature privode

- npm install
- system load (contains load inplace)
- system setup
- basic svrx integration usecase

* feat(injector): server side logic provide

- stream replace
- gzip support
- testcase in svrx.injector
- injector client webpack config

* feat(core): implement full logic of plugin system

- support markdown/proxy/serve/livereload/console plugin
- add io logic combine with
- add basic services
- fix proxy with gzip & chunked

* feat(core): add engine-based loader logic

- add semver depend for version compute
- add two-way check: Plugin version and Svrx version

* feat(core): imodel support watcher

all mutations like set,splice,produce will trigger watcher digesting

* feat(logger): add color modifier

* chore: add eslint prettier plugin

* feat(core): basic https support

- add node-easy-cert for simple cert gen
- add https options

* feat(markdown): beautify markdown style

* refactor(util): add svrx-util

* feat(cli): add svrx core installation

* refactor(cli): return svrx instance fix

* feat(cli): print option list help info

* feat(cli): parse options and pass to core

* refactor(cli): modify options passed to core

* feat(core): reformat options from cli and rc file

* refactor(core): fix if plugins not exists in rc file

* feat(core): handle rc file change

* feat(core): add sorted event system to svrx

- Support chainable event transmit
- Refactoring emit to async way
- Fix Some Bugs
- Coverage of events are almost 100% now

* refactor(svrx-plugin-markdown): remove redundancy plugin from main repo

- svrx-plugin-eruda
- svrx-plugin-markdown

* feat(livereload): livereload event support preventDefault

- Refactor event to support ordered emitting
- Fix some style issues
- Refactor io to support easy communication with client
- isolate events with io

* feat(core): fetch plugin props and handle plugin options

* refactor(core): add plugin config getter

* refactor(core): refact config

* fix(core): fix alias handle

* test(core): fix test errors

* feat(svrx-toolkit): add scaffold for toolkit

* perf(cli): set default command serve

* perf(core): enable inline options set

* feat(core): support Plugin get builtin pathes

* refactor(core): watch config and trigger onOptionChange

* feat(svrx-plugin-webpack): basic support webpack

* fix(core): use local pluginConfig

* fix(svrx-plugin-webpack): use $.root to get global rootOC

* refactor(core): watchEvent support builtin and plugin option query

* feat(core): validate options

* refactor(core): change plugin.configs to plugin.configSchema

* refactor(core): enable function option

* feat(serve): add headers and define all configs

* feat(livereload): define all configs

* feat(proxy): use http-proxy-middleware

* feat(cors): replace @koa/cors with koa2-cors

* feat(logger): add logger level and pluginLogger

- add getPluginLogger when inject logger to Plugin
- add setLevel to control logger level global

* test(serve): fix config name change

* refactor(proxy): add boolean type

* refactor(proxy): remove http-proxy-middleware

* feat(proxy): add changeOrigin

* fix(config): add urls.external and urls.local definition

* feat(core): add external link message

- add getExternalIp
- add notify logger level

* feat(logger): optimize logger

- add plugin installed spin
- add plugin list log
- add date formating

* fix(injector): fix style splitter

* feat(serve): support historyApiFallback

* feat(logger): prevent default npm  logger

- add ora for progress message
- add global locked to suppress all message
- fix system logger to suppress npm log
- add testcase 90%

* refactor(serve): historyApiFallback enable only when 404

* feat(serve): add serveIndex config

* refactor(proxy): set request.jar to true

* fix(proxy): set reqeust.followredirect to false

to fix cookie lose after redirect

* refactor(logger): move core logger to svrx-util

* feat(svrx-util): add c2k util for convert connect middle to koa

- monking patching connect2-koa and response for bubble ctx

* feat(webpack): fix webpack serve error

- use svrx-util for convert middleware

* feat(core): remove koa2-connect , add util.c2k

- use util.c2k for convert connect middleware to koa

* fix(core): resolve conflict with proxyw

* ci: modify test script

* feat(proxy): add proxy log

* feat(injector): add function support to injector content

- log error.track for global capture

* feat(svrx-plugin-webpack): fix hot-reloader issue in c2k

- create dummyRes every time
- load webpack local first

* feat(core): support opener

* perf(cli): change default svrx to the latest version installed locally

* fix(core): disable open in testcase

* fix(core): open local typofix

* feat(core): add plugin client wraping

- Refactoring injector.content logic for wraping
- add basic $.config service for client.config

* refactor(util): remove test log

* feat(svrx): add updateNotifier

* feat(cli): add new commands: ls,ls-remote,install

* perf(cli): add more detail to help log

* refactor(svrx): remove duplicated dependency

* refactor: add eslint-config-airbnb, remove prettier

* refactor: eslint auto fix

* refactor(svre): fix lint error in testcase

* fix(open): open.default changeto local

* refactor(cli): fix lint errors

* refactor(util): fix lint errors

* refactor(core): fix some lint errors

* docs(cors): add doc to plugin cors

* refactor(cli): move logger progress to npm install

* refactor(util): set default object value to undefined

* feat: add webpack setting, auto inject webpackConfig

* refactor(core): change serve priority to lowest

* refactor(core): add some progress log

* docs(core): add some description to config list

* feat(proxy): get raw body of post request

* fix(serve): adjust priority of middlewares

* fix(webpack): fix some bug when hot== false

* docs(plugin): add option docs to builtin plugins

* docs(core): add readme docs to builtin configs

* feat(logger): add middleware track in debug mode

* feat(proxy): add secure to enable/disable ssl validate

* refactor(serve): rename serve.serveIndex to serve.directory

* docs(cors): remove detail of cors options

* fix(webpack): webpack-hot-middleware/client resolve error

* fix(logger): remove unnecessary notify

* feat(webpack): add local webpack version validate

* docs(cli): add readme

* refactor: fix some lint errors

* feat(cli): change plugin options insert rule

* refactor(core): move cli helpPrinter to core

* docs: refine readme

* refactor(serve): move historyApiFallback out of serve config

* feat(serve): add index file name config

* feat(proxy): add proxy api and support mock

* feat(core): add scoped plugin package support

* feat(cli): ignore beta versions

* refactor(core): use util/npm.install instead of original one

* refactor(test): remove console

* fix(io): io/client  proxy to eventsObj to support all events feature

* refactor: fix some lint errors

* fix: eslint error

* fix: eslint issue

* build: add some build scripts

* refactor(core): fix configure lint errors

* build: add publish script

* refactor(cli): ignore eslint no-console

* build: set toolkit and ui package private to true

* build: add some lerna config

* chore(release): publish

 - svrx-cli@0.0.3-beta.0
 - svrx-plugin-webpack@0.0.3-beta.0
 - svrx-toolkit@0.0.2-beta.0
 - svrx-ui@0.0.3-beta.0
 - svrx-util@0.0.3-beta.0
 - svrx@0.0.3-beta.0

* fix(test): eslint lint error in __tests__

* fix(test): fix plugin testcase conflict

* fix(core): add requireEnsure to fix module cache

* fix(config): client lint error

* fix(ci): npm ci error, update package-lock.json

* fix(cli): install not-beta version first

* fix(webpack): set svrx version to engines

* fix(cli): move installed dependencies into local directory

* chore(release): publish

 - svrx-cli@0.0.3-beta.1
 - svrx-plugin-webpack@0.0.3-beta.1
 - svrx-toolkit@0.0.2-beta.1
 - svrx-ui@0.0.3-beta.1
 - svrx-util@0.0.3-beta.1
 - svrx@0.0.3-beta.1

* perf(cli): load svrx before print info

* build: add version hook to update package.lock

see lerna/lerna#1415 (comment)

* build: modify build scripts

* refactor(cli): use mkdirp instead of fs.mkdir

* build(webpack): update core version

* chore(release): publish

 - svrx-cli@0.0.3-beta.2
 - svrx-plugin-webpack@0.0.3-beta.2
 - svrx-toolkit@0.0.2-beta.2
 - svrx-ui@0.0.3-beta.2
 - svrx-util@0.0.3-beta.2
 - svrx@0.0.3-beta.2

* feat: add example for mobile debug

* feat(util): npm support registry

* feat(core): use util npm and set registry

* test(util): move npm testcases

* refactor(util): move logger out of util npm

* feat: change svrx-toolkit template

* feat: mv example

* docs(examples): add serve-static-page

* Feature/router (#1)

* feat(router): first support router

* feat(router): support router feature

* feat(config): update config for routing dsl

* feat(injector): support injector.replace

* fix(example): eslint warning disable

* chore(release): publish

 - svrx-cli@0.0.3-beta.3
 - svrx-plugin-webpack@0.0.3-beta.3
 - svrx-toolkit@0.0.2-beta.3
 - svrx-util@0.0.3-beta.3
 - svrx@0.0.3-beta.3

* docs(examples): add proxy example

* feat(cli): add stop events listener

* fix: remove example img

* chore(core,cli): remove useless dependencies
  • Loading branch information
xuchaoying authored and teshoudong committed Jul 7, 2019
1 parent 8789746 commit 162ca05
Show file tree
Hide file tree
Showing 133 changed files with 43,084 additions and 1 deletion.
15 changes: 15 additions & 0 deletions .editorconfig
@@ -0,0 +1,15 @@
# editorconfig.org

root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
5 changes: 5 additions & 0 deletions .eslintignore
@@ -0,0 +1,5 @@
node_modules
packages/**/assets/**/*.js
packages/**/dist/**/*.js
packages/svrx-toolkit/**/*.js
/**/fixture
40 changes: 40 additions & 0 deletions .eslintrc
@@ -0,0 +1,40 @@
{
"env": {
"node": true,
"browser": true,
"mocha": true
},
"extends": [
"airbnb-base"
],
"plugins": [
"import"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly",
"expect": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
"import/no-dynamic-require": "off",
"no-param-reassign": "off",
"no-underscore-dangle": "off",
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": true
}
]
},
"overrides": [
{
"files": "examples/**/*.js",
"rules": {
"no-unused-vars": "off"
}
}
]
}
98 changes: 98 additions & 0 deletions .gitignore
@@ -0,0 +1,98 @@

# Created by https://www.gitignore.io/api/node
# Edit at https://www.gitignore.io/?templates=node

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# End of https://www.gitignore.io/api/node

tmp/

.DS_Store
.changelog
.vscode
.idea

# ignore dist

dist
7 changes: 7 additions & 0 deletions .travis.yml
@@ -0,0 +1,7 @@
language: node_js
node_js:
- "8"
- "10"
cache: npm
script:
- npm test
19 changes: 18 additions & 1 deletion README.md
@@ -1,2 +1,19 @@
> A pluggable frontend server, it just works
# svrx
platform built for efficient front-end development

svrx(server-x) is a platform built for efficient front-end development.

## Documentation

You can read documentation [here](https://github.com/x-orpheus/svrx/wiki/Docuements).

你可以在[这里](https://github.com/x-orpheus/svrx/wiki/%E4%BD%BF%E7%94%A8%E6%96%87%E6%A1%A3)阅读使用文档。

## Contributing

Please see the [contributing guidelines]().

## Providing a new plugin

For contributors planning to write a new plugin, please see the [plugin development guide]().
1 change: 1 addition & 0 deletions commitlint.config.js
@@ -0,0 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] };
14 changes: 14 additions & 0 deletions examples/eruda/README.md
@@ -0,0 +1,14 @@
# svrx-plugin-eruda

The eruda plugin for svrx

```bash
svrx --eruda
```

visit the http://localhost:8000. The eruda 's icon will show up on every page you visited

![](https://user-images.githubusercontent.com/24988831/60713045-df0bce80-9f4a-11e9-801d-1fb4dd79224a.png)



11 changes: 11 additions & 0 deletions examples/portal/README.md
@@ -0,0 +1,11 @@
# svrx-plugin-portal

The portal plugin for svrx. Provide intranet penetration

```bash
svrx --portal
```

visit the url shown in log

![](https://user-images.githubusercontent.com/24988831/60712982-bd124c00-9f4a-11e9-8cf6-aae99772713e.png)
15 changes: 15 additions & 0 deletions examples/proxy/.svrxrc.js
@@ -0,0 +1,15 @@
module.exports = {
serve: {
base: './public',
},
proxy: [
{
context: ['/api', '/same'],
target: 'https://randomuser.me',
changeOrigin: true,
pathRewrite: {
'/same/api': '/api'
}
}
],
};
5 changes: 5 additions & 0 deletions examples/proxy/README.md
@@ -0,0 +1,5 @@
# Set Proxy Rules

Here is an example we porxy `/api` and `/same/api` to the target host `https://randomuser.me`.

Note that we also rewrite `/same/api` to `/api`, so `/same/api` will be proxy to `https://randomuser.me/api`
18 changes: 18 additions & 0 deletions examples/proxy/public/index.html
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Set Proxy Rules</title>
</head>
<body>
<div>
<button onclick="onFetch('/api')">fetch /api</button>
<textarea id="/api" style="width: 300px"></textarea>
</div>
<div>
<button onclick="onFetch('/same/api')">fetch /same/api</button>
<textarea id="/same/api" style="width: 300px"></textarea>
</div>
<script src="./main.js"></script>
</body>
</html>
18 changes: 18 additions & 0 deletions examples/proxy/public/main.js
@@ -0,0 +1,18 @@
function onFetch(url) {
fetch(url)
.then(resp => resp.json())
.then((result) => {
console.log(result);
if (result && result.results) {
const data = result.results[0];
const info = {
name: `${data.name.first} ${data.name.last}`,
email: data.email,
};
const textarea = document.getElementById(url);
textarea.value = Object.keys(info)
.map(key => `${key}: ${info[key]}`)
.join('\n');
}
});
}
5 changes: 5 additions & 0 deletions examples/serve-static-page/.svrxrc.js
@@ -0,0 +1,5 @@
module.exports = {
serve: {
base: './public',
},
};
3 changes: 3 additions & 0 deletions examples/serve-static-page/README.md
@@ -0,0 +1,3 @@
# Serve a static page

To serve a static page, you just need to set `serve.base` to the static directory.
11 changes: 11 additions & 0 deletions examples/serve-static-page/public/index.html
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Your Static Page</title>
</head>
<body>
<p>hello world!</p>
<script src="./main.js"></script>
</body>
</html>
2 changes: 2 additions & 0 deletions examples/serve-static-page/public/main.js
@@ -0,0 +1,2 @@
/* eslint-disable no-alert */
alert('hello!');
17 changes: 17 additions & 0 deletions examples/weinre/README.md
@@ -0,0 +1,17 @@
# svrx-plugin-weinre

The weinre plugin for svrx

```bash
svrx --weinre
```

![](https://user-images.githubusercontent.com/24988831/60713097-f6e35280-9f4a-11e9-9aa5-2796dcc7aae1.png)

visit http://localhost:8001

![](https://user-images.githubusercontent.com/24988831/60713159-1ed2b600-9f4b-11e9-84cc-cd2444d9191c.png)

![](https://user-images.githubusercontent.com/24988831/60713196-2e51ff00-9f4b-11e9-91fe-5a147eee472d.png)


40 changes: 40 additions & 0 deletions lerna.json
@@ -0,0 +1,40 @@
{
"packages": [
"packages/*"
],
"version": "independent",
"npmClient": "npm",
"changelog": {
"repo": "x-orpheus/svrx",
"labels": {
"PR: new feature": ":rocket: New Feature",
"PR: breaking change": ":boom: Breaking Change",
"PR: bug fix": ":bug: Bug Fix",
"PR: enhancement": ":nail_care: Enhancement",
"PR: documentation": ":memo: Documentation",
"PR: internal": ":house: Internal"
},
"cacheDir": ".changelog"
},
"command": {
"version": {
"message": "chore(release): publish",
"allowBranch": [
"master",
"hello-svrx"
]
},
"publish": {
"ignoreChanges": [
"ignored-file",
"*.md",
"*.txt",
"__tests__/**"
],
"allowBranch": [
"master",
"hello-svrx"
]
}
}
}

0 comments on commit 162ca05

Please sign in to comment.