-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bundle everything even contains the `node_modules`.
- Loading branch information
Showing
5 changed files
with
184 additions
and
46 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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import cp from "child_process"; | ||
import express from "express"; | ||
|
||
const execute = (command: string): void => { | ||
console.log(`\n$ ${command}\n`); | ||
cp.execSync(command, { stdio: "inherit" }); | ||
}; | ||
|
||
const main = async (): Promise<void> => { | ||
if (!process.argv.some((str) => str === "--skipBuild")) | ||
execute("npm run build:swagger"); | ||
|
||
const docs = await import("../../packages/api/swagger.json" as any); | ||
|
||
const app = express(); | ||
const swaggerUi = require("swagger-ui-express"); | ||
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(docs)); | ||
app.listen(37810); | ||
|
||
console.log("\n"); | ||
console.log("-----------------------------------------------------------"); | ||
console.log("\n Swagger UI Address: http://127.0.0.1:37810/api-docs \n"); | ||
console.log("-----------------------------------------------------------"); | ||
}; | ||
main().catch((exp) => { | ||
console.log(exp); | ||
process.exit(-1); | ||
}); |
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,51 @@ | ||
import { DynamicExecutor } from "@nestia/e2e"; | ||
import cp from "child_process"; | ||
import fs from "fs"; | ||
import { sleep_for } from "tstl"; | ||
|
||
import { MyConfiguration } from "../src/MyConfiguration"; | ||
import MyApi from "../src/api"; | ||
|
||
const webpackTest = async (): Promise<void> => { | ||
if (fs.existsSync(MyConfiguration.ROOT + "/dist/server.js") === false) | ||
throw new Error("Run npm run webpack command first."); | ||
|
||
// START BACKEND SERVER | ||
const backend = cp.fork("server.js", { | ||
cwd: `${MyConfiguration.ROOT}/dist`, | ||
}); | ||
await sleep_for(2_500); | ||
|
||
// DO TEST | ||
const connection: MyApi.IConnection = { | ||
host: `http://127.0.0.1:${MyConfiguration.API_PORT()}`, | ||
}; | ||
const report: DynamicExecutor.IReport = await DynamicExecutor.validate({ | ||
prefix: "test", | ||
parameters: () => [ | ||
{ | ||
host: connection.host, | ||
encryption: connection.encryption, | ||
}, | ||
], | ||
})(__dirname + "/features"); | ||
|
||
backend.kill(); | ||
|
||
// REPORT EXCEPTIONS | ||
const exceptions: Error[] = report.executions | ||
.filter((exec) => exec.error !== null) | ||
.map((exec) => exec.error!); | ||
if (exceptions.length === 0) { | ||
console.log("Success"); | ||
console.log("Elapsed time", report.time.toLocaleString(), `ms`); | ||
} else { | ||
for (const exp of exceptions) console.log(exp); | ||
console.log("Failed"); | ||
console.log("Elapsed time", report.time.toLocaleString(), `ms`); | ||
} | ||
}; | ||
webpackTest().catch((exp) => { | ||
console.log(exp); | ||
process.exit(-1); | ||
}); |
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,82 @@ | ||
const path = require("path"); | ||
|
||
const CopyWebpackPlugin = require("copy-webpack-plugin"); | ||
const WriteFilePlugin = require("write-file-webpack-plugin"); | ||
const { IgnorePlugin } = require("webpack"); | ||
|
||
const lazyImports = [ | ||
"@fastify/static", | ||
"@fastify/view", | ||
"@nestjs/microservices", | ||
"@nestjs/websockets", | ||
"class-transformer", | ||
"class-validator", | ||
]; | ||
|
||
// @reference https://tech-blog.s-yoshiki.com/entry/297 | ||
module.exports = { | ||
// CUSTOMIZE HERE | ||
entry: { | ||
server: "./src/executable/server.ts", | ||
"updator-master": "./src/executable/updator-master.ts", | ||
"updator-slave": "./src/executable/updator-slave.ts", | ||
}, | ||
output: { | ||
path: path.join(__dirname, "dist"), | ||
filename: "[name].js", | ||
}, | ||
optimization: { | ||
minimize: true, | ||
}, | ||
|
||
// JUST KEEP THEM | ||
mode: "production", | ||
target: "node", | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.ts$/, | ||
exclude: /node_modules/, | ||
loader: "ts-loader", | ||
}, | ||
], | ||
}, | ||
resolve: { | ||
extensions: [".tsx", ".ts", ".js"], | ||
}, | ||
plugins: [ | ||
new CopyWebpackPlugin({ | ||
patterns: [ | ||
{ | ||
from: ".env", | ||
to: "[name][ext]", | ||
}, | ||
{ | ||
from: "package.json", | ||
to: "[name][ext]", | ||
}, | ||
{ | ||
from: "./node_modules/.prisma/client/*.node", | ||
to: () => Promise.resolve("[path][name][ext]"), | ||
}, | ||
{ | ||
from: "./node_modules/ws/**/*.*", | ||
to: () => Promise.resolve("[path][name][ext]"), | ||
}, | ||
], | ||
}), | ||
new WriteFilePlugin(), | ||
new IgnorePlugin({ | ||
checkResource: (resource) => { | ||
if (lazyImports.some((modulo) => resource.startsWith(modulo))) { | ||
try { | ||
require.resolve(resource); | ||
} catch (err) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}, | ||
}), | ||
], | ||
}; |