makepack 1.0.8 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "makepack",
3
- "version": "1.0.8",
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
+ }
@@ -21,7 +21,7 @@ export default (args) => {
21
21
  main.pop()
22
22
 
23
23
  const json = {
24
- name: args.diraname,
24
+ name: args.dirname,
25
25
  version: "1.0.0",
26
26
  description: "",
27
27
  main: `./${main.join(".")}.js`,
@@ -1,26 +1,31 @@
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
- let projectInformation = await makeProjectInformation()
7
+ let info = await makeProjectInformation()
7
8
  let loader = logLoader("Creating project...")
8
- await makeFiles(projectInformation)
9
+ await makeFiles(info)
9
10
  loader.stop("")
10
11
 
11
12
  loader = logLoader("Installing dependencies...")
12
13
  execSync("npm install", {
13
- cwd: projectInformation.cwd,
14
+ cwd: info.cwd,
14
15
  })
15
16
 
16
17
  loader.stop("Project setup complete!")
17
- if (projectInformation.isCurrentDir) {
18
+ if (info.isCurrentDir) {
18
19
  console.log(`Run the development server: \nnpm start\nEnjoy your new project! 😊`);
19
20
  } else {
20
- console.log(`To start working with your project:\n1. Navigate to your project directory:\ncd ${projectInformation.dirname}\n2. Run the development server:\nnpm start\nEnjoy your new project! 😊`);
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
@@ -36,7 +36,7 @@ export default async () => {
36
36
 
37
37
  return {
38
38
  cwd: projectDir,
39
- diraname: path.basename(projectDir),
39
+ dirname: projectDirName,
40
40
  isCurrentDir: projectDirName === cwdFolder
41
41
  }
42
42
  }
@@ -17,7 +17,7 @@ const makeProjectInformation = async () => {
17
17
  }
18
18
  ])
19
19
 
20
- if (projectDir.diraname !== cwdFolder) {
20
+ if (projectDir.dirname !== cwdFolder) {
21
21
  fs.removeSync(projectDir.cwd)
22
22
  fs.mkdirSync(projectDir.cwd)
23
23
  }
@@ -46,7 +46,7 @@ const makeProjectInformation = async () => {
46
46
  port: 3000,
47
47
  outdir: "pack",
48
48
  cwd: 'C:\xampp\htdocs\makepack\asd',
49
- diraname: 'asd',
49
+ dirname: 'asd',
50
50
  isCurrentDir: false,
51
51
  template: 'typescript',
52
52
  rootdir: 'src',
@@ -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.use('*', async (_req, res) => {
70
- res.status(404).end("404 page not found");
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.listen(args.port, () => console.log(`http://localhost:${args.port}`));
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