makepack 1.0.9 → 1.2.1
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/asd/package-lock.json +2797 -0
- package/asd/package.json +21 -0
- package/asd/readme.md +132 -0
- package/asd/serve.jsx +29 -0
- package/asd/src/index.ts +5 -0
- package/asd/tsconfig.json +28 -0
- package/package.json +12 -6
- package/serve.tsx +25 -0
- package/src/actions/create/files/package-json.js +5 -4
- package/src/actions/create/files/readme.md.js +14 -0
- package/src/actions/create/index.js +6 -1
- package/src/actions/create/makeFiles.js +2 -0
- 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/asd/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "asd",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "makepack serve",
|
|
8
|
+
"pack": "makepack pack",
|
|
9
|
+
"publish:pack": "makepack pack -p"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"makepack": "latest",
|
|
14
|
+
"react": "^19.0.0",
|
|
15
|
+
"react-dom": "^19.0.0",
|
|
16
|
+
"typescript": "^4.4.2",
|
|
17
|
+
"@types/react": "^19.0.2",
|
|
18
|
+
"@types/react-dom": "^19.0.2"
|
|
19
|
+
},
|
|
20
|
+
"keywords": []
|
|
21
|
+
}
|
package/asd/readme.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# MakePack CLI Documentation
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
**MakePack** is a command-line interface (CLI) tool that helps you to quickly set up, build, and manage JavaScript, TypeScript, React, and React-TypeScript libraries for use in npm projects. With just a few simple commands, you can generate your own libraries, start a development server, or build and publish your project to the npm repository.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
To install **MakePack** globally, run the following command:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install -g makepack
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
This will allow you to use the `makepack` command anywhere in your terminal.
|
|
16
|
+
|
|
17
|
+
## Commands
|
|
18
|
+
|
|
19
|
+
### `create`
|
|
20
|
+
|
|
21
|
+
The `create` command is used to create a new library project. It initializes the project structure, configures essential files, and sets up the environment for you to start working on your library.
|
|
22
|
+
|
|
23
|
+
#### Usage
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
makepack create
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
#### Description
|
|
30
|
+
|
|
31
|
+
- Creates a new library project by setting up the necessary configurations and boilerplate files.
|
|
32
|
+
|
|
33
|
+
This command will guide you through the initial setup for your library.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
### `serve`
|
|
38
|
+
|
|
39
|
+
The `serve` command starts a development server for your library, providing you with a live-reload environment where you can test and iterate on your library in real-time.
|
|
40
|
+
|
|
41
|
+
#### Usage
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
makepack serve [options]
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
#### Options
|
|
48
|
+
|
|
49
|
+
- `-p, --port <number>`
|
|
50
|
+
_Port number_ (optional) (default is `5000`).
|
|
51
|
+
|
|
52
|
+
- `-e, --root <file>`
|
|
53
|
+
_Root file_ (optional) (default is `serve.jsx` or `serve.tsx`). The entry point for your application. Specify the main JavaScript/TypeScript file to start the server.
|
|
54
|
+
|
|
55
|
+
#### Description
|
|
56
|
+
|
|
57
|
+
- Starts a local development server for testing and debugging your library.
|
|
58
|
+
|
|
59
|
+
Example:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
makepack serve --port 4000 --root src/index.ts
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
### `pack`
|
|
68
|
+
|
|
69
|
+
The `pack` command is used to build your library and optionally publish it to the npm repository. This command compiles your code into a distributable format and prepares it for sharing with others.
|
|
70
|
+
|
|
71
|
+
#### Usage
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
makepack pack [options]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
#### Options
|
|
78
|
+
|
|
79
|
+
- `-e, --entry <file>`
|
|
80
|
+
_Entry file or directory_ (default is `src/**/*.{tsx,ts,js,jsx}`).
|
|
81
|
+
Specify the entry file or use a glob pattern to select the files to include in your library.
|
|
82
|
+
|
|
83
|
+
- `-p, --publish`
|
|
84
|
+
_Publish the project to the npm repository_ (default is `false`).
|
|
85
|
+
Add this flag if you want to publish the library to npm after building it.
|
|
86
|
+
|
|
87
|
+
#### Description
|
|
88
|
+
|
|
89
|
+
- Builds the project by compiling and bundling your library.
|
|
90
|
+
- Optionally publishes the library to the npm repository.
|
|
91
|
+
|
|
92
|
+
Example:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
makepack pack --entry src/index.ts --publish
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
This will compile the project from `src/index.ts` and then publish the library to npm.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Example Workflow
|
|
103
|
+
|
|
104
|
+
1. Create a new project:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
makepack create
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
2. Start the server for development:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
makepack serve --port 4000 --root index.tsx
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
3. Once you're ready to build and publish your library:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
makepack pack --entry src/**/*.{tsx,ts,js,jsx} --publish
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
This will build your library and publish it to npm.
|
|
123
|
+
|
|
124
|
+
## GitHub Repository
|
|
125
|
+
|
|
126
|
+
For more details, open issues, or contribute to the project, visit the [MakePack GitHub Repository](https://github.com/devnax/makepack).
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## License
|
|
131
|
+
|
|
132
|
+
This project is licensed under the MIT License. See the LICENSE file for more information.
|
package/asd/serve.jsx
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
|
+
import add from './src'
|
|
4
|
+
|
|
5
|
+
const App = () => {
|
|
6
|
+
return (
|
|
7
|
+
<div style={{fontFamily: 'monospace,math, sans-serif', textAlign: 'center', marginTop: '50px' }}>
|
|
8
|
+
<h1>Welcome to makepack CLI!</h1>
|
|
9
|
+
<p>Edit <code>index.tsx</code> and save to reload.</p>
|
|
10
|
+
<a
|
|
11
|
+
href="https://reactjs.org"
|
|
12
|
+
target="_blank"
|
|
13
|
+
rel="noopener noreferrer"
|
|
14
|
+
style={{ color: '#61dafb', textDecoration: 'none' }}
|
|
15
|
+
>
|
|
16
|
+
Learn React
|
|
17
|
+
</a>
|
|
18
|
+
<div style={{marginTop: "50px"}}>
|
|
19
|
+
<code>{add(5,5)}</code>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
const rootEle = document.getElementById('root')
|
|
25
|
+
if (rootEle) {
|
|
26
|
+
const root = createRoot(rootEle);
|
|
27
|
+
root.render(<App />);
|
|
28
|
+
}
|
|
29
|
+
|
package/asd/src/index.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es5",
|
|
4
|
+
"lib": [
|
|
5
|
+
"dom",
|
|
6
|
+
"dom.iterable",
|
|
7
|
+
"esnext"
|
|
8
|
+
],
|
|
9
|
+
"allowJs": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"allowSyntheticDefaultImports": true,
|
|
13
|
+
"strict": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
|
15
|
+
"module": "esnext",
|
|
16
|
+
"moduleResolution": "node",
|
|
17
|
+
"resolveJsonModule": true,
|
|
18
|
+
"isolatedModules": true,
|
|
19
|
+
"noEmit": true,
|
|
20
|
+
"jsx": "react"
|
|
21
|
+
},
|
|
22
|
+
"include": [
|
|
23
|
+
"src"
|
|
24
|
+
],
|
|
25
|
+
"exclude": [
|
|
26
|
+
"node_modules"
|
|
27
|
+
]
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "makepack",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.1",
|
|
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
|
+
}
|
|
@@ -5,10 +5,11 @@ export default (args) => {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
if (args.template.includes("react")) {
|
|
8
|
-
dependencies =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
dependencies["react"] = "^19.0.0"
|
|
9
|
+
dependencies["react-dom"] = "^19.0.0"
|
|
10
|
+
} else {
|
|
11
|
+
devDependencies["react"] = "^19.0.0"
|
|
12
|
+
devDependencies["react-dom"] = "^19.0.0"
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
if (args.template.includes("typescript")) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import fs from 'fs-extra'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import { fileURLToPath } from 'url'
|
|
4
|
+
export const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
5
|
+
|
|
6
|
+
export default (args) => {
|
|
7
|
+
// load readme.md content from rootdir
|
|
8
|
+
const readme = fs.readFileSync(path.resolve(__dirname, '../../../../readme.md'), 'utf-8')
|
|
9
|
+
const content = readme
|
|
10
|
+
return {
|
|
11
|
+
content,
|
|
12
|
+
filename: `readme.md`
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -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
|
|
@@ -10,12 +10,14 @@ import projectTsx from "./files/project-tsx.js";
|
|
|
10
10
|
|
|
11
11
|
import fs from "fs-extra"
|
|
12
12
|
import path from "path"
|
|
13
|
+
import readmeMd from "./files/readme.md.js";
|
|
13
14
|
|
|
14
15
|
export default async (args) => {
|
|
15
16
|
const files = [
|
|
16
17
|
packageJson(args),
|
|
17
18
|
gitignore(args),
|
|
18
19
|
serve(args),
|
|
20
|
+
readmeMd(args)
|
|
19
21
|
];
|
|
20
22
|
|
|
21
23
|
switch (args.template) {
|
|
@@ -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
|
|