Skip to content

Commit

Permalink
Reformat whole project with trailingComma=all as prettier v3 default
Browse files Browse the repository at this point in the history
  • Loading branch information
szymmis committed Nov 26, 2023
1 parent ed25be6 commit 7acccf2
Show file tree
Hide file tree
Showing 26 changed files with 52 additions and 50 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/publish-cli.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Publish create-vite-express package
on:
on:
push:
tags:
- cli-v*
Expand All @@ -22,8 +22,8 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
registry-url: 'https://registry.npmjs.org'
registry-url: "https://registry.npmjs.org"
node-version: 20
- run: cd create-vite-express && yarn install && yarn build && npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Publish vite-express package
on:
on:
push:
tags:
- v*
Expand All @@ -22,10 +22,10 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
registry-url: 'https://registry.npmjs.org'
registry-url: "https://registry.npmjs.org"
node-version: 20
- run: yarn install
- run: yarn build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ jobs:
node-version: 20
- run: yarn install
- run: yarn test:local

3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"useTabs": false,
"tabWidth": 2,
"semi": true,
"singleQuote": false
"singleQuote": false,
"trailingComma": "all"
}
4 changes: 2 additions & 2 deletions create-vite-express/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function main() {
const templatePath = path.join(__dirname, "..", "templates", templateName);
if (!fs.existsSync(templatePath)) {
console.error(
kolorist.red(`Template ${templateName} at ${templatePath} not found!`)
kolorist.red(`Template ${templateName} at ${templatePath} not found!`),
);
process.exit(1);
}
Expand All @@ -55,7 +55,7 @@ async function main() {
fs.copySync(templatePath, projectPath);
fs.moveSync(
path.join(projectPath, "_gitignore"),
path.join(projectPath, ".gitignore")
path.join(projectPath, ".gitignore"),
);

console.log(`${kolorist.green("✔")} Done! You can start with:`);
Expand Down
2 changes: 1 addition & 1 deletion create-vite-express/templates/react-ts/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion create-vite-express/templates/react-ts/src/client/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ import App from "./App";
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<App />
</React.StrictMode>
</React.StrictMode>,
);
2 changes: 1 addition & 1 deletion create-vite-express/templates/react-ts/src/server/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ app.get("/hello", (_, res) => {
});

ViteExpress.listen(app, 3000, () =>
console.log("Server is listening on port 3000...")
console.log("Server is listening on port 3000..."),
);
2 changes: 1 addition & 1 deletion create-vite-express/templates/react/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
6 changes: 4 additions & 2 deletions create-vite-express/templates/react/src/client/main.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import "./index.css";

import React from "react";
import ReactDOM from "react-dom/client";

import App from "./App";
import "./index.css";

ReactDOM.createRoot(document.getElementById("root")).render(
<React.StrictMode>
<App />
</React.StrictMode>
</React.StrictMode>,
);
2 changes: 1 addition & 1 deletion create-vite-express/templates/react/src/server/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ app.get("/hello", (req, res) => {
});

ViteExpress.listen(app, 3000, () =>
console.log("Server is listening on port 3000...")
console.log("Server is listening on port 3000..."),
);
2 changes: 1 addition & 1 deletion create-vite-express/templates/vanilla-ts/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ app.get("/hello", (_, res) => {
});

ViteExpress.listen(app, 3000, () =>
console.log("Server is listening on port 3000...")
console.log("Server is listening on port 3000..."),
);
2 changes: 1 addition & 1 deletion create-vite-express/templates/vanilla/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion create-vite-express/templates/vanilla/src/server/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ app.get("/hello", (req, res) => {
});

ViteExpress.listen(app, 3000, () =>
console.log("Server is listening on port 3000...")
console.log("Server is listening on port 3000..."),
);
2 changes: 1 addition & 1 deletion create-vite-express/templates/vue-ts/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion create-vite-express/templates/vue-ts/src/server/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ app.get("/hello", (_, res) => {
});

ViteExpress.listen(app, 3000, () =>
console.log("Server is listening on port 3000...")
console.log("Server is listening on port 3000..."),
);
2 changes: 1 addition & 1 deletion create-vite-express/templates/vue/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion create-vite-express/templates/vue/src/server/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ app.get("/hello", (req, res) => {
});

ViteExpress.listen(app, 3000, () =>
console.log("Server is listening on port 3000...")
console.log("Server is listening on port 3000..."),
);
38 changes: 19 additions & 19 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ function info(msg: string) {
const timestamp = new Date().toLocaleString("en-US").split(",")[1].trim();
console.log(
`${pc.dim(timestamp)} ${pc.bold(pc.cyan("[vite-express]"))} ${pc.green(
msg
)}`
msg,
)}`,
);
}

Expand Down Expand Up @@ -72,8 +72,8 @@ async function resolveConfig(): Promise<ViteConfig> {
if (Config.inlineViteConfig) {
info(
`${pc.yellow("Inline config")} detected, ignoring ${pc.yellow(
"Vite config file"
)}`
"Vite config file",
)}`,
);

return {
Expand All @@ -87,17 +87,17 @@ async function resolveConfig(): Promise<ViteConfig> {
try {
const config = await resolveConfig({}, "build");
info(
`Using ${pc.yellow("Vite")} to resolve the ${pc.yellow("config file")}`
`Using ${pc.yellow("Vite")} to resolve the ${pc.yellow("config file")}`,
);
return config;
} catch (e) {
console.error(e);
info(
pc.red(
`Unable to use ${pc.yellow("Vite")}, running in ${pc.yellow(
"viteless"
)} mode`
)
"viteless",
)} mode`,
),
);
}
} catch (e) {
Expand All @@ -122,9 +122,9 @@ async function resolveConfig(): Promise<ViteConfig> {
info(
pc.red(
`Unable to locate ${pc.yellow(
"vite.config.*s file"
)}, using default options`
)
"vite.config.*s file",
)}, using default options`,
),
);

return getDefaultViteConfig();
Expand All @@ -151,8 +151,8 @@ async function serveStatic(): Promise<RequestHandler> {
info(`${pc.red(`Static files at ${pc.gray(distPath)} not found!`)}`);
info(
`${pc.yellow(
`Did you forget to run ${pc.bold(pc.green("vite build"))} command?`
)}`
`Did you forget to run ${pc.bold(pc.green("vite build"))} command?`,
)}`,
);
} else {
info(`${pc.green(`Serving static files from ${pc.gray(distPath)}`)}`);
Expand All @@ -165,13 +165,13 @@ const stubMiddleware: RequestHandler = (req, res, next) => next();

async function injectStaticMiddleware(
app: core.Express,
middleware: RequestHandler
middleware: RequestHandler,
) {
const config = await getViteConfig();
app.use(config.base, middleware);

const stubMiddlewareLayer = app._router.stack.find(
(layer: { handle?: RequestHandler }) => layer.handle === stubMiddleware
(layer: { handle?: RequestHandler }) => layer.handle === stubMiddleware,
);

if (stubMiddlewareLayer !== undefined) {
Expand All @@ -192,7 +192,7 @@ function isIgnoredPath(path: string, req: express.Request) {

function findClosestIndexToRoot(
reqPath: string,
root: string
root: string,
): string | undefined {
const basePath = reqPath.slice(0, reqPath.lastIndexOf("/"));
const dirs = basePath.split("/");
Expand All @@ -209,7 +209,7 @@ function findClosestIndexToRoot(

async function injectViteIndexMiddleware(
app: core.Express,
server: ViteDevServer
server: ViteDevServer,
) {
const config = await getViteConfig();

Expand Down Expand Up @@ -256,7 +256,7 @@ async function startServer(server: http.Server | https.Server) {
clearScreen: false,
appType: "custom",
server: { middlewareMode: true },
})
}),
);

server.on("close", () => vite.close());
Expand All @@ -274,7 +274,7 @@ function config(config: ConfigurationOptions) {
async function bind(
app: core.Express,
server: http.Server | https.Server,
callback?: () => void
callback?: () => void,
) {
info(`Running in ${pc.yellow(Config.mode)} mode`);

Expand Down
2 changes: 1 addition & 1 deletion tests/env/dist/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion tests/env/dist/subpath/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion tests/env/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion tests/env/subpath/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion tests/noIndexEnv/dist/subpath/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion tests/noIndexEnv/subpath/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down

0 comments on commit 7acccf2

Please sign in to comment.