makepack 1.2.0 → 1.2.2

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.
@@ -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
+
@@ -0,0 +1,5 @@
1
+
2
+ function add(a: number, b: number): number {
3
+ return a + b;
4
+ }
5
+ export default add
@@ -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.2.0",
3
+ "version": "1.2.2",
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": [
@@ -5,10 +5,11 @@ export default (args) => {
5
5
  }
6
6
 
7
7
  if (args.template.includes("react")) {
8
- dependencies = {
9
- "react": "^19.0.0",
10
- "react-dom": "^19.0.0"
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
+ }
@@ -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) {
@@ -39,6 +41,21 @@ export default async (args) => {
39
41
  }
40
42
 
41
43
  for (let file of files) {
44
+ // check if the file exists
45
+ if (fs.existsSync(path.join(args.cwd, file.filename))) {
46
+ const { overwrite } = await inquirer.prompt([
47
+ {
48
+ type: "confirm",
49
+ name: 'overwrite',
50
+ message: `The file ${file.filename} already exists, do you want to overwrite it?`,
51
+ default: false
52
+ }
53
+ ])
54
+ if (!overwrite) {
55
+ continue
56
+ }
57
+ }
58
+
42
59
  fs.writeFileSync(path.join(args.cwd, file.filename), file.content)
43
60
  }
44
61
  }
@@ -39,7 +39,10 @@ const makeProjectInformation = async () => {
39
39
  break;
40
40
  }
41
41
 
42
- fs.mkdirSync(path.join(projectDir.cwd, information.rootdir))
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
+ }
43
46
 
44
47
  /*
45
48
  {