Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zoubingwu committed Dec 29, 2021
0 parents commit 6d4aac0
Show file tree
Hide file tree
Showing 28 changed files with 2,600 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules/
dist/
fixture/

.idea/
.vscode/

*.log
5 changes: 5 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
singleQuote: true,
arrowParens: 'avoid',
semi: true,
};
5 changes: 5 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.DS_Store
dist
dist-ssr
*.local
13 changes: 13 additions & 0 deletions example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
18 changes: 18 additions & 0 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "example",
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"@vitejs/plugin-react": "^1.0.7",
"vite": "^2.7.2",
"vite-plugin-compile-time": "^0.1.2"
}
}
42 changes: 42 additions & 0 deletions example/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.App {
text-align: center;
}

.App-logo {
height: 40vmin;
pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}

.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}

.App-link {
color: #61dafb;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

button {
font-size: calc(10px + 2vmin);
}
45 changes: 45 additions & 0 deletions example/src/App.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { useState } from 'react'
import logo from './logo.svg'
import './App.css'

function App() {
const [count, setCount] = useState(0)

return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>Hello Vite + React!!!</p>
<p>
<button type="button" onClick={() => setCount((count) => count + 1)}>
count is: {count}
</button>
</p>
<p>
Edit <code>App.jsx</code> and save to test HMR updates.
</p>
<p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
{' | '}
<a
className="App-link"
href="https://vitejs.dev/guide/features.html"
target="_blank"
rel="noopener noreferrer"
>
Vite Docs
</a>
</p>
</header>
</div>
)
}

export default App
5 changes: 5 additions & 0 deletions example/src/code.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default async () => {
return {
code: `count++`,
}
}
15 changes: 15 additions & 0 deletions example/src/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions example/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
7 changes: 7 additions & 0 deletions example/src/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions example/src/main.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react'
import ReactDOM from 'react-dom'
import './index.css'
import App from './App'

if (process.env.NODE_ENV === 'development') {
require('./mock/browser')
}

let count = 0
import.meta.compileTime("./code.ts")

console.log(count)

ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
)
11 changes: 11 additions & 0 deletions example/src/mock/browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { setupWorker, rest } from 'msw'

const handlers = [
// Handles a POST /login request
rest.post('/login', null),
// Handles a GET /user request
rest.get('/user', null),
]

// This configures a Service Worker with the given request handlers.
export const worker = setupWorker(...handlers)
8 changes: 8 additions & 0 deletions example/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import compileTime from "vite-plugin-compile-time"

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), compileTime()]
})
39 changes: 39 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "msw-auto-mock",
"version": "0.1.0",
"description": "",
"main": "dist/cli.js",
"module": "./dist/cli.mjs",
"exports": {
".": {
"require": "./dist/cli.js",
"import": "./dist/cli.mjs",
"types": "./dist/cli.d.ts"
}
},
"scripts": {
"build": "tsup",
"fmt": "prettier src --write",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@apidevtools/swagger-parser": "^10.0.3",
"@openapi-contrib/openapi-schema-to-json-schema": "^3.1.1",
"cac": "^6.7.12",
"faker": "^5.5.3",
"oazapfts": "^3.5.0",
"swagger2openapi": "^7.0.8"
},
"devDependencies": {
"@types/faker": "^5.5.9",
"@types/node": "^17.0.5",
"openapi-types": "^10.0.0",
"prettier": "^2.5.1",
"pretty-quick": "^3.1.3",
"tsup": "^5.11.9",
"typescript": "^4.5.4"
}
}
Loading

0 comments on commit 6d4aac0

Please sign in to comment.