makepack 1.0.9 → 1.2.0
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/package.json +12 -6
- package/serve.tsx +25 -0
- package/src/actions/create/index.js +6 -1
- package/src/actions/{serve.js → serve/index.js} +30 -4
- package/src/actions/serve/loger.js +22 -0
- package/src/index.js +1 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "makepack",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A CLI tool to create, build, and manage JavaScript, TypeScript, React, and React-TypeScript libraries for npm projects.",
|
|
6
6
|
"categories": [
|
|
@@ -20,16 +20,18 @@
|
|
|
20
20
|
},
|
|
21
21
|
"homepage": "https://github.com/devnax/makepack#readme",
|
|
22
22
|
"scripts": {},
|
|
23
|
-
"devDependencies": {},
|
|
24
23
|
"dependencies": {
|
|
24
|
+
"chalk": "^5.4.1",
|
|
25
25
|
"commander": "^12.1.0",
|
|
26
|
-
"inquirer": "^12.1.0",
|
|
27
26
|
"esbuild": "^0.24.2",
|
|
28
27
|
"express": "^4.21.1",
|
|
28
|
+
"figlet": "^1.8.0",
|
|
29
|
+
"figures": "^6.1.0",
|
|
29
30
|
"fs-extra": "^11.2.0",
|
|
31
|
+
"glob": "^11.0.0",
|
|
32
|
+
"inquirer": "^12.1.0",
|
|
30
33
|
"typescript": "^5.7.2",
|
|
31
|
-
"vite": "^6.0.2"
|
|
32
|
-
"glob": "^11.0.0"
|
|
34
|
+
"vite": "^6.0.2"
|
|
33
35
|
},
|
|
34
36
|
"keywords": [
|
|
35
37
|
"CLI",
|
|
@@ -39,5 +41,9 @@
|
|
|
39
41
|
"TypeScript",
|
|
40
42
|
"React",
|
|
41
43
|
"npm-package"
|
|
42
|
-
]
|
|
44
|
+
],
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"react": "^19.0.0",
|
|
47
|
+
"react-dom": "^19.0.0"
|
|
48
|
+
}
|
|
43
49
|
}
|
package/serve.tsx
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
|
+
|
|
4
|
+
const App = () => {
|
|
5
|
+
return (
|
|
6
|
+
<div style={{ fontFamily: 'monospace,math, sans-serif', textAlign: 'center', marginTop: '50px' }}>
|
|
7
|
+
<h1>Welcome to makepack CLI!</h1>
|
|
8
|
+
<p>Edit <code></code> and save to reload.</p>
|
|
9
|
+
as
|
|
10
|
+
<a
|
|
11
|
+
href="https://reactjs.org"
|
|
12
|
+
target="_blank"
|
|
13
|
+
rel="noopener noreferrer"
|
|
14
|
+
style={{ color: '#61dafb', textDecoration: 'none' }}
|
|
15
|
+
>
|
|
16
|
+
Learn
|
|
17
|
+
</a>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
const rootEle = document.getElementById('root')
|
|
22
|
+
if (rootEle) {
|
|
23
|
+
const root = createRoot(rootEle);
|
|
24
|
+
root.render(<App />);
|
|
25
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { execSync, logLoader, __dirname } from "../../helpers.js"
|
|
2
2
|
import makeProjectInformation from "./makeProjectInformation.js"
|
|
3
3
|
import makeFiles from "./makeFiles.js"
|
|
4
|
+
import figlet from 'figlet'
|
|
4
5
|
|
|
5
6
|
const create = async () => {
|
|
6
7
|
let info = await makeProjectInformation()
|
|
@@ -20,7 +21,11 @@ const create = async () => {
|
|
|
20
21
|
console.log(`To start working with your project:\n1. Navigate to your project directory:\ncd ${info.dirname}\n2. Run the development server:\nnpm start\nEnjoy your new project! 😊`);
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
figlet("Make Pack CLI", function (err, data) {
|
|
25
|
+
if (!err) {
|
|
26
|
+
console.log(data);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
24
29
|
}
|
|
25
30
|
|
|
26
31
|
export default create
|
|
@@ -4,6 +4,9 @@ import path from 'path'
|
|
|
4
4
|
import { createServer as createViteServer } from 'vite';
|
|
5
5
|
import express from 'express';
|
|
6
6
|
import { glob } from 'glob'
|
|
7
|
+
import logger from './loger.js'
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import figlet from 'figlet';
|
|
7
10
|
|
|
8
11
|
const app = express();
|
|
9
12
|
|
|
@@ -43,11 +46,20 @@ const serve = async (args) => {
|
|
|
43
46
|
</html>
|
|
44
47
|
`;
|
|
45
48
|
|
|
49
|
+
console.log(args.root);
|
|
50
|
+
|
|
46
51
|
const vite = await createViteServer({
|
|
47
52
|
root: process.cwd(),
|
|
48
53
|
// plugins: [react()],
|
|
49
54
|
server: {
|
|
50
|
-
middlewareMode: true
|
|
55
|
+
middlewareMode: true,
|
|
56
|
+
},
|
|
57
|
+
customLogger: {
|
|
58
|
+
info: (msg) => {
|
|
59
|
+
logger.info(msg)
|
|
60
|
+
},
|
|
61
|
+
warn: (msg) => logger.warning(msg),
|
|
62
|
+
error: (msg) => logger.error(msg),
|
|
51
63
|
},
|
|
52
64
|
appType: 'custom'
|
|
53
65
|
});
|
|
@@ -66,11 +78,25 @@ const serve = async (args) => {
|
|
|
66
78
|
}
|
|
67
79
|
});
|
|
68
80
|
|
|
69
|
-
app.
|
|
70
|
-
|
|
81
|
+
let server = app.listen(args.port, () => {
|
|
82
|
+
figlet("Make Pack", function (err, data) {
|
|
83
|
+
if (err) {
|
|
84
|
+
console.log("Something went wrong...");
|
|
85
|
+
console.dir(err);
|
|
86
|
+
server.close(() => {
|
|
87
|
+
console.log('Server has been stopped.');
|
|
88
|
+
});
|
|
89
|
+
process.exit()
|
|
90
|
+
}
|
|
91
|
+
console.log(data);
|
|
92
|
+
logger.success(`Server is running on ${chalk.blue(chalk.underline(`http://localhost:${args.port}`))}`);
|
|
93
|
+
});
|
|
71
94
|
});
|
|
72
95
|
|
|
73
|
-
app.
|
|
96
|
+
app.use((err, req, res, next) => {
|
|
97
|
+
logger.error(`Unhandled Error: ${err.message}`);
|
|
98
|
+
res.status(500).send('Internal Server Error');
|
|
99
|
+
});
|
|
74
100
|
}
|
|
75
101
|
|
|
76
102
|
export default serve
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import figures from 'figures';
|
|
3
|
+
|
|
4
|
+
const logger = {
|
|
5
|
+
info: (message, prefix = 'INFO', icon = true) => {
|
|
6
|
+
console.log(`${icon ? chalk.blue(figures.info) + " " : ""}${chalk.cyan.bold(prefix)} ${message}`);
|
|
7
|
+
},
|
|
8
|
+
success: (message, prefix = 'SUCCESS:', icon = true) => {
|
|
9
|
+
console.log(`${icon ? chalk.green(figures.tick) + " " : ""}${chalk.green.bold(prefix)} ${message}`);
|
|
10
|
+
},
|
|
11
|
+
warning: (message, prefix = 'WARNING:', icon = true) => {
|
|
12
|
+
console.log(`${icon ? chalk.yellow(figures.warning) + " " : ""}${chalk.yellow.bold(prefix)} ${message}`);
|
|
13
|
+
},
|
|
14
|
+
error: (message, prefix = 'ERROR:', icon = true) => {
|
|
15
|
+
console.log(`${icon ? chalk.red(figures.cross) + " " : ""}${chalk.red.bold(prefix)} ${message}`);
|
|
16
|
+
},
|
|
17
|
+
custom: (icon, color, label, message) => {
|
|
18
|
+
console.log(`${chalk[color](icon)} ${chalk[color].bold(`${label}:`)} ${message}`);
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default logger;
|
package/src/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { Command } from "commander";
|
|
4
|
-
import serve from "./actions/serve.js";
|
|
4
|
+
import serve from "./actions/serve/index.js";
|
|
5
5
|
import pack from "./actions/pack.js";
|
|
6
6
|
import create from "./actions/create/index.js";
|
|
7
|
-
import path from 'path'
|
|
8
7
|
|
|
9
8
|
const program = new Command();
|
|
10
9
|
|