makepack 1.3.3 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +146 -146
- package/package.json +1 -1
- package/src/actions/create/files/gitignore.js +5 -5
- package/src/actions/create/files/makepack.js +19 -19
- package/src/actions/create/files/package-json.js +42 -42
- package/src/actions/create/files/project-js.js +12 -12
- package/src/actions/create/files/project-jsx.js +50 -50
- package/src/actions/create/files/project-ts.js +10 -10
- package/src/actions/create/files/project-tsx.js +50 -50
- package/src/actions/create/files/readme.md.js +13 -13
- package/src/actions/create/files/serve.js +51 -51
- package/src/actions/create/files/tsconfig.js +32 -32
- package/src/actions/create/index.js +29 -29
- package/src/actions/create/makeFiles.js +64 -64
- package/src/actions/create/makeProjectDirectory.js +41 -41
- package/src/actions/create/makeProjectInformation.js +67 -67
- package/src/actions/pack/index.js +112 -75
- package/src/actions/serve/index.js +106 -106
- package/src/helpers.js +69 -68
- package/src/index.js +30 -30
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
import inquirer from "inquirer"
|
|
2
|
-
import makeProjectDirectory from "./makeProjectDirectory.js"
|
|
3
|
-
import fs from "fs-extra"
|
|
4
|
-
import path from "path"
|
|
5
|
-
const cwd = process.cwd()
|
|
6
|
-
const cwdFolder = cwd.split(path.sep).pop()
|
|
7
|
-
|
|
8
|
-
const makeProjectInformation = async () => {
|
|
9
|
-
const projectDir = await makeProjectDirectory()
|
|
10
|
-
const information = await inquirer.prompt([
|
|
11
|
-
{
|
|
12
|
-
type: 'list',
|
|
13
|
-
name: 'template',
|
|
14
|
-
message: 'Select a template',
|
|
15
|
-
choices: ['typescript', 'javascript', 'react with typescript', 'react with javascript'],
|
|
16
|
-
default: 'typeScript'
|
|
17
|
-
}
|
|
18
|
-
])
|
|
19
|
-
|
|
20
|
-
if (projectDir.dirname !== cwdFolder) {
|
|
21
|
-
fs.removeSync(projectDir.cwd)
|
|
22
|
-
fs.mkdirSync(projectDir.cwd)
|
|
23
|
-
}
|
|
24
|
-
information.entry = "index"
|
|
25
|
-
information.rootdir = "src"
|
|
26
|
-
|
|
27
|
-
switch (information.template) {
|
|
28
|
-
case "typescript":
|
|
29
|
-
information.entry = information.entry + ".ts"
|
|
30
|
-
break;
|
|
31
|
-
case "javascript":
|
|
32
|
-
information.entry = information.entry + ".js"
|
|
33
|
-
break;
|
|
34
|
-
case "react with typescript":
|
|
35
|
-
information.entry = information.entry + ".tsx"
|
|
36
|
-
break;
|
|
37
|
-
case "react with javascript":
|
|
38
|
-
information.entry = information.entry + ".jsx"
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// check if the root directory exists
|
|
43
|
-
if (!fs.existsSync(path.join(projectDir.cwd, information.rootdir))) {
|
|
44
|
-
fs.mkdirSync(path.join(projectDir.cwd, information.rootdir))
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/*
|
|
48
|
-
{
|
|
49
|
-
port: 3000,
|
|
50
|
-
outdir: "pack",
|
|
51
|
-
cwd: 'C:\xampp\htdocs\makepack\asd',
|
|
52
|
-
dirname: 'asd',
|
|
53
|
-
isCurrentDir: false,
|
|
54
|
-
template: 'typescript',
|
|
55
|
-
rootdir: 'src',
|
|
56
|
-
entry: 'index'
|
|
57
|
-
}
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
// port: 3000,
|
|
62
|
-
outdir: "pack",
|
|
63
|
-
...projectDir,
|
|
64
|
-
...information
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
1
|
+
import inquirer from "inquirer"
|
|
2
|
+
import makeProjectDirectory from "./makeProjectDirectory.js"
|
|
3
|
+
import fs from "fs-extra"
|
|
4
|
+
import path from "path"
|
|
5
|
+
const cwd = process.cwd()
|
|
6
|
+
const cwdFolder = cwd.split(path.sep).pop()
|
|
7
|
+
|
|
8
|
+
const makeProjectInformation = async () => {
|
|
9
|
+
const projectDir = await makeProjectDirectory()
|
|
10
|
+
const information = await inquirer.prompt([
|
|
11
|
+
{
|
|
12
|
+
type: 'list',
|
|
13
|
+
name: 'template',
|
|
14
|
+
message: 'Select a template',
|
|
15
|
+
choices: ['typescript', 'javascript', 'react with typescript', 'react with javascript'],
|
|
16
|
+
default: 'typeScript'
|
|
17
|
+
}
|
|
18
|
+
])
|
|
19
|
+
|
|
20
|
+
if (projectDir.dirname !== cwdFolder) {
|
|
21
|
+
fs.removeSync(projectDir.cwd)
|
|
22
|
+
fs.mkdirSync(projectDir.cwd)
|
|
23
|
+
}
|
|
24
|
+
information.entry = "index"
|
|
25
|
+
information.rootdir = "src"
|
|
26
|
+
|
|
27
|
+
switch (information.template) {
|
|
28
|
+
case "typescript":
|
|
29
|
+
information.entry = information.entry + ".ts"
|
|
30
|
+
break;
|
|
31
|
+
case "javascript":
|
|
32
|
+
information.entry = information.entry + ".js"
|
|
33
|
+
break;
|
|
34
|
+
case "react with typescript":
|
|
35
|
+
information.entry = information.entry + ".tsx"
|
|
36
|
+
break;
|
|
37
|
+
case "react with javascript":
|
|
38
|
+
information.entry = information.entry + ".jsx"
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// check if the root directory exists
|
|
43
|
+
if (!fs.existsSync(path.join(projectDir.cwd, information.rootdir))) {
|
|
44
|
+
fs.mkdirSync(path.join(projectDir.cwd, information.rootdir))
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/*
|
|
48
|
+
{
|
|
49
|
+
port: 3000,
|
|
50
|
+
outdir: "pack",
|
|
51
|
+
cwd: 'C:\xampp\htdocs\makepack\asd',
|
|
52
|
+
dirname: 'asd',
|
|
53
|
+
isCurrentDir: false,
|
|
54
|
+
template: 'typescript',
|
|
55
|
+
rootdir: 'src',
|
|
56
|
+
entry: 'index'
|
|
57
|
+
}
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
// port: 3000,
|
|
62
|
+
outdir: "pack",
|
|
63
|
+
...projectDir,
|
|
64
|
+
...information
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
68
|
export default makeProjectInformation
|
|
@@ -1,76 +1,113 @@
|
|
|
1
|
-
import esbuild from 'esbuild';
|
|
2
|
-
import fs from 'fs-extra';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { glob } from 'glob'
|
|
5
|
-
import ts from 'typescript'
|
|
6
|
-
import { execSync, logLoader, loadConfig } from '../../helpers.js';
|
|
7
|
-
|
|
8
|
-
const pack = async (args) => {
|
|
9
|
-
args.outdir = 'pack'
|
|
10
|
-
try {
|
|
11
|
-
fs.removeSync(path.join(process.cwd(), args.outdir));
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
esbuild.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
1
|
+
import esbuild from 'esbuild';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { glob } from 'glob'
|
|
5
|
+
import ts from 'typescript'
|
|
6
|
+
import { execSync, logLoader, loadConfig } from '../../helpers.js';
|
|
7
|
+
|
|
8
|
+
const pack = async (args) => {
|
|
9
|
+
args.outdir = 'pack'
|
|
10
|
+
try {
|
|
11
|
+
fs.removeSync(path.join(process.cwd(), args.outdir));
|
|
12
|
+
fs.mkdirSync(path.join(process.cwd(), args.outdir));
|
|
13
|
+
} catch (err) { }
|
|
14
|
+
|
|
15
|
+
const files = await glob('src/**/*.{tsx,ts,js,jsx}') || []
|
|
16
|
+
const entryPoints = files.map(entry => path.join(process.cwd(), entry))
|
|
17
|
+
let loader = logLoader("Generating a production build for the package...")
|
|
18
|
+
const esbuildConfig = await loadConfig('esbuild.config.js') || {}
|
|
19
|
+
|
|
20
|
+
function build(format) {
|
|
21
|
+
return esbuild.build({
|
|
22
|
+
bundle: true,
|
|
23
|
+
target: ['esnext'],
|
|
24
|
+
// splitting: format === 'esm', // Enable code splitting only for ESM
|
|
25
|
+
sourcemap: true,
|
|
26
|
+
minify: true,
|
|
27
|
+
jsx: 'automatic',
|
|
28
|
+
loader: {
|
|
29
|
+
'.ts': 'ts',
|
|
30
|
+
'.tsx': 'tsx'
|
|
31
|
+
},
|
|
32
|
+
...esbuildConfig,
|
|
33
|
+
format: format, // 'esm' or 'cjs'
|
|
34
|
+
entryPoints,
|
|
35
|
+
outdir: path.join(process.cwd(), args.outdir, format),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
Promise.all([
|
|
40
|
+
build('esm'),
|
|
41
|
+
build('cjs'),
|
|
42
|
+
]).catch(() => process.exit(1));
|
|
43
|
+
|
|
44
|
+
loader.stop()
|
|
45
|
+
loader = logLoader("🔄 Generating TypeScript declarations...")
|
|
46
|
+
const options = {
|
|
47
|
+
declaration: true,
|
|
48
|
+
emitDeclarationOnly: true,
|
|
49
|
+
outDir: path.join(process.cwd(), args.outdir, 'types'),
|
|
50
|
+
strict: true,
|
|
51
|
+
allowJs: true,
|
|
52
|
+
jsx: ts.JsxEmit.React,
|
|
53
|
+
esModuleInterop: true,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const program = ts.createProgram(files, options);
|
|
57
|
+
const emitResult = program.emit();
|
|
58
|
+
const diagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
|
59
|
+
|
|
60
|
+
if (diagnostics.length > 0) {
|
|
61
|
+
diagnostics.forEach(diagnostic => {
|
|
62
|
+
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
|
|
63
|
+
if (diagnostic.file) {
|
|
64
|
+
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
|
65
|
+
console.error(`Error at ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
|
|
66
|
+
} else {
|
|
67
|
+
console.error(`Error: ${message}`);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
} else {
|
|
71
|
+
console.log('✅ TypeScript declaration files generated successfully!');
|
|
72
|
+
}
|
|
73
|
+
loader.stop()
|
|
74
|
+
|
|
75
|
+
let packageJson = JSON.parse(fs.readFileSync(path.join(process.cwd(), '/package.json'), 'utf8'));
|
|
76
|
+
|
|
77
|
+
let name = packageJson.name
|
|
78
|
+
let version = packageJson.version
|
|
79
|
+
let description = packageJson.description
|
|
80
|
+
delete packageJson.name
|
|
81
|
+
delete packageJson.version
|
|
82
|
+
delete packageJson.description
|
|
83
|
+
|
|
84
|
+
packageJson = {
|
|
85
|
+
name,
|
|
86
|
+
version,
|
|
87
|
+
description,
|
|
88
|
+
main: './cjs/index.js',
|
|
89
|
+
module: './esm/index.js',
|
|
90
|
+
types: './types/index.d.ts',
|
|
91
|
+
...packageJson,
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
delete packageJson.type
|
|
95
|
+
|
|
96
|
+
fs.writeFileSync(path.join(process.cwd(), args.outdir, '/package.json'), JSON.stringify(packageJson, null, 2));
|
|
97
|
+
|
|
98
|
+
fs.copyFileSync(path.join(process.cwd(), '/readme.md'), path.join(process.cwd(), args.outdir, `/readme.md`))
|
|
99
|
+
console.log('✅ Production build generated successfully! The package is ready for deployment.');
|
|
100
|
+
|
|
101
|
+
if (args.publish) {
|
|
102
|
+
console.log("Publishing the production build to the npm repository...")
|
|
103
|
+
execSync(`npm publish`, {
|
|
104
|
+
cwd: path.join(process.cwd(), args.outdir)
|
|
105
|
+
})
|
|
106
|
+
} else {
|
|
107
|
+
console.log(`To publish your package:\n1. Navigate to the ${args.outdir} directory:\ncd ./${args.outdir}\n2. Publish the package to npm:\nnpm publish\nYour package is ready to share with the world! 🚀`);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
|
|
76
113
|
export default pack
|
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
import inquirer from 'inquirer'
|
|
2
|
-
import fs from 'fs-extra'
|
|
3
|
-
import path from 'path'
|
|
4
|
-
import { createServer as createViteServer } from 'vite';
|
|
5
|
-
import express from 'express';
|
|
6
|
-
import { glob } from 'glob'
|
|
7
|
-
import { logger, loadConfig } from '../../helpers.js'
|
|
8
|
-
import chalk from 'chalk';
|
|
9
|
-
import figlet from 'figlet';
|
|
10
|
-
import react from '@vitejs/plugin-react'
|
|
11
|
-
|
|
12
|
-
const app = express();
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const serve = async (args) => {
|
|
17
|
-
if (args.root === undefined) {
|
|
18
|
-
const serveFile = await glob('serve.{ts,js,tsx,jsx}', {
|
|
19
|
-
cwd: process.cwd()
|
|
20
|
-
})
|
|
21
|
-
if (!serveFile.length) {
|
|
22
|
-
let { root } = await inquirer.prompt([{
|
|
23
|
-
type: 'input',
|
|
24
|
-
name: 'root',
|
|
25
|
-
message: 'Enter the root file',
|
|
26
|
-
}]);
|
|
27
|
-
|
|
28
|
-
if (!fs.existsSync(path.join(process.cwd(), root))) {
|
|
29
|
-
throw new Error(`invalid root: ${root}`);
|
|
30
|
-
}
|
|
31
|
-
args.root = root;
|
|
32
|
-
} else {
|
|
33
|
-
args.root = serveFile[0];
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
let template = `
|
|
38
|
-
<!doctype html>
|
|
39
|
-
<html lang="en">
|
|
40
|
-
<head>
|
|
41
|
-
<meta charset="UTF-8" />
|
|
42
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
43
|
-
</head>
|
|
44
|
-
<body>
|
|
45
|
-
<div id="root"></div>
|
|
46
|
-
<script type="module" src="${args.root}"></script>
|
|
47
|
-
</body>
|
|
48
|
-
</html>
|
|
49
|
-
`;
|
|
50
|
-
|
|
51
|
-
let viteConfig = await loadConfig('vite.config.js') || {}
|
|
52
|
-
|
|
53
|
-
const vite = await createViteServer({
|
|
54
|
-
...viteConfig,
|
|
55
|
-
root: process.cwd(),
|
|
56
|
-
plugins: [react(), ...(viteConfig.plugins || [])],
|
|
57
|
-
server: {
|
|
58
|
-
middlewareMode: true,
|
|
59
|
-
...(viteConfig.server || {})
|
|
60
|
-
},
|
|
61
|
-
customLogger: {
|
|
62
|
-
info: (msg) => {
|
|
63
|
-
logger.info(msg)
|
|
64
|
-
},
|
|
65
|
-
warn: (msg) => logger.warning(msg),
|
|
66
|
-
error: (msg) => logger.error(msg),
|
|
67
|
-
...(viteConfig.customLogger || {})
|
|
68
|
-
},
|
|
69
|
-
appType: 'custom'
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
app.use(vite.middlewares);
|
|
73
|
-
app.get('/', async (req, res, next) => {
|
|
74
|
-
const url = req.originalUrl;
|
|
75
|
-
try {
|
|
76
|
-
template = await vite.transformIndexHtml(url, template);
|
|
77
|
-
res.status(200).set({
|
|
78
|
-
'Content-Type': 'text/html'
|
|
79
|
-
}).end(template);
|
|
80
|
-
} catch (e) {
|
|
81
|
-
vite.ssrFixStacktrace(e);
|
|
82
|
-
next(e);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
let server = app.listen(args.port, () => {
|
|
87
|
-
figlet("Make Pack", function (err, data) {
|
|
88
|
-
if (err) {
|
|
89
|
-
console.log("Something went wrong...");
|
|
90
|
-
console.dir(err);
|
|
91
|
-
server.close(() => {
|
|
92
|
-
console.log('Server has been stopped.');
|
|
93
|
-
});
|
|
94
|
-
process.exit()
|
|
95
|
-
}
|
|
96
|
-
console.log(data);
|
|
97
|
-
logger.success(`Server is running on ${chalk.blue(chalk.underline(`http://localhost:${args.port}`))}`);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
app.use((err, req, res, next) => {
|
|
102
|
-
logger.error(`Unhandled Error: ${err.message}`);
|
|
103
|
-
res.status(500).send('Internal Server Error');
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
1
|
+
import inquirer from 'inquirer'
|
|
2
|
+
import fs from 'fs-extra'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
import { createServer as createViteServer } from 'vite';
|
|
5
|
+
import express from 'express';
|
|
6
|
+
import { glob } from 'glob'
|
|
7
|
+
import { logger, loadConfig } from '../../helpers.js'
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import figlet from 'figlet';
|
|
10
|
+
import react from '@vitejs/plugin-react'
|
|
11
|
+
|
|
12
|
+
const app = express();
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
const serve = async (args) => {
|
|
17
|
+
if (args.root === undefined) {
|
|
18
|
+
const serveFile = await glob('serve.{ts,js,tsx,jsx}', {
|
|
19
|
+
cwd: process.cwd()
|
|
20
|
+
})
|
|
21
|
+
if (!serveFile.length) {
|
|
22
|
+
let { root } = await inquirer.prompt([{
|
|
23
|
+
type: 'input',
|
|
24
|
+
name: 'root',
|
|
25
|
+
message: 'Enter the root file',
|
|
26
|
+
}]);
|
|
27
|
+
|
|
28
|
+
if (!fs.existsSync(path.join(process.cwd(), root))) {
|
|
29
|
+
throw new Error(`invalid root: ${root}`);
|
|
30
|
+
}
|
|
31
|
+
args.root = root;
|
|
32
|
+
} else {
|
|
33
|
+
args.root = serveFile[0];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let template = `
|
|
38
|
+
<!doctype html>
|
|
39
|
+
<html lang="en">
|
|
40
|
+
<head>
|
|
41
|
+
<meta charset="UTF-8" />
|
|
42
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
43
|
+
</head>
|
|
44
|
+
<body>
|
|
45
|
+
<div id="root"></div>
|
|
46
|
+
<script type="module" src="${args.root}"></script>
|
|
47
|
+
</body>
|
|
48
|
+
</html>
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
let viteConfig = await loadConfig('vite.config.js') || {}
|
|
52
|
+
|
|
53
|
+
const vite = await createViteServer({
|
|
54
|
+
...viteConfig,
|
|
55
|
+
root: process.cwd(),
|
|
56
|
+
plugins: [react(), ...(viteConfig.plugins || [])],
|
|
57
|
+
server: {
|
|
58
|
+
middlewareMode: true,
|
|
59
|
+
...(viteConfig.server || {})
|
|
60
|
+
},
|
|
61
|
+
customLogger: {
|
|
62
|
+
info: (msg) => {
|
|
63
|
+
logger.info(msg)
|
|
64
|
+
},
|
|
65
|
+
warn: (msg) => logger.warning(msg),
|
|
66
|
+
error: (msg) => logger.error(msg),
|
|
67
|
+
...(viteConfig.customLogger || {})
|
|
68
|
+
},
|
|
69
|
+
appType: 'custom'
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
app.use(vite.middlewares);
|
|
73
|
+
app.get('/', async (req, res, next) => {
|
|
74
|
+
const url = req.originalUrl;
|
|
75
|
+
try {
|
|
76
|
+
template = await vite.transformIndexHtml(url, template);
|
|
77
|
+
res.status(200).set({
|
|
78
|
+
'Content-Type': 'text/html'
|
|
79
|
+
}).end(template);
|
|
80
|
+
} catch (e) {
|
|
81
|
+
vite.ssrFixStacktrace(e);
|
|
82
|
+
next(e);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
let server = app.listen(args.port, () => {
|
|
87
|
+
figlet("Make Pack", function (err, data) {
|
|
88
|
+
if (err) {
|
|
89
|
+
console.log("Something went wrong...");
|
|
90
|
+
console.dir(err);
|
|
91
|
+
server.close(() => {
|
|
92
|
+
console.log('Server has been stopped.');
|
|
93
|
+
});
|
|
94
|
+
process.exit()
|
|
95
|
+
}
|
|
96
|
+
console.log(data);
|
|
97
|
+
logger.success(`Server is running on ${chalk.blue(chalk.underline(`http://localhost:${args.port}`))}`);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
app.use((err, req, res, next) => {
|
|
102
|
+
logger.error(`Unhandled Error: ${err.message}`);
|
|
103
|
+
res.status(500).send('Internal Server Error');
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
107
|
export default serve
|