makepack 1.5.23 → 1.5.24

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 CHANGED
@@ -1,122 +1,122 @@
1
- <p align="center">
2
- <a href="https://github.com/devnax/makepack" rel="noopener" target="_blank"><img src="https://raw.githubusercontent.com/devnax/makepack/main/logo.png" alt="Makepack logo"></a>
3
- </p>
4
-
5
- <h1 align="center">Makepack</h1>
6
-
7
- **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.
8
-
9
-
10
- ## 📥 Installation
11
-
12
- Install `makepack` globally to get started:
13
-
14
- ```sh
15
- npm install -g makepack
16
- ```
17
-
18
- ---
19
-
20
- ## 🎯 Why Choose makepack?
21
- - **Zero-Config Setup** – Instantly scaffold a structured project.
22
- - **TypeScript Support** – Seamlessly work with modern JavaScript.
23
- - **Integrated Dev Server** – Run your package with Vite and Express.
24
- - **Efficient Build System** – Generate optimized ESM and CJS outputs.
25
- - **One-Command Publish** – Deploy your package to npm effortlessly.
26
- ---
27
-
28
- ## 📜 CLI Commands
29
-
30
- ### ✨ `makepack create` – Scaffold a New Project
31
- Quickly initialize a structured package with the following setup:
32
-
33
- ```
34
- src/index.ts or tsx or js or jsx
35
- .gitignore
36
- package.json
37
- README.md
38
- ```
39
-
40
- Run:
41
- ```sh
42
- makepack create
43
- ```
44
- Follow the interactive prompts to configure your project.
45
-
46
- ### 🚀 `makepack start` – Launch the Development Server
47
- Run a Vite + Express server to develop and test your package in real-time.
48
-
49
- ```sh
50
- makepack start
51
- ```
52
-
53
- ### 🏗️ `makepack build` – Compile Your Package
54
- Builds and optimizes your package into the `build` directory.
55
-
56
- ```sh
57
- makepack build
58
- ```
59
-
60
- ### 📦 `makepack publish` – Deploy to NPM
61
- Publish your package to the npm registry in one command.
62
-
63
- ```sh
64
- makepack publish
65
- ```
66
-
67
- ---
68
-
69
- ## ⚙️ Configuration
70
-
71
- Customize your project by creating a `makepack.js` file in the root directory. This file allows full control over the build and dev environment.
72
-
73
- ### 🔧 Default Configuration
74
-
75
- ```js
76
- module.exports = (prevConfig) => ({
77
- build: {
78
- outdir: "build",
79
- types: true,
80
- formatPackageJson: (p) => p,
81
- configs: [
82
- {
83
- entryPoints: "src/**/*.{tsx,ts,js,jsx}",
84
- outdir: "esm",
85
- format: "esm",
86
- sourcemap: true,
87
- jsx: 'automatic',
88
- loader: {
89
- '.ts': 'ts',
90
- '.tsx': 'tsx'
91
- },
92
- },
93
- {
94
- entryPoints: "src/**/*.{tsx,ts,js,jsx}",
95
- outdir: "",
96
- format: "cjs",
97
- sourcemap: true,
98
- jsx: 'automatic',
99
- loader: {
100
- '.ts': 'ts',
101
- '.tsx': 'tsx'
102
- },
103
- }
104
- ]
105
- },
106
- start: {
107
- port: 5000,
108
- entry: "App.tsx",
109
- }
110
- });
111
- ```
112
-
113
- ---
114
-
115
- ## 📜 License
116
-
117
- `makepack` is released under the **MIT License**, allowing free usage in both open-source and commercial projects.
118
-
119
- ---
120
-
121
- 🚀 **Start building your next NPM package with `makepack` today!**
122
-
1
+ <p align="center">
2
+ <a href="https://github.com/devnax/makepack" rel="noopener" target="_blank"><img src="https://raw.githubusercontent.com/devnax/makepack/main/logo.png" alt="Makepack logo"></a>
3
+ </p>
4
+
5
+ <h1 align="center">Makepack</h1>
6
+
7
+ **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.
8
+
9
+
10
+ ## 📥 Installation
11
+
12
+ Install `makepack` globally to get started:
13
+
14
+ ```sh
15
+ npm install -g makepack
16
+ ```
17
+
18
+ ---
19
+
20
+ ## 🎯 Why Choose makepack?
21
+ - **Zero-Config Setup** – Instantly scaffold a structured project.
22
+ - **TypeScript Support** – Seamlessly work with modern JavaScript.
23
+ - **Integrated Dev Server** – Run your package with Vite and Express.
24
+ - **Efficient Build System** – Generate optimized ESM and CJS outputs.
25
+ - **One-Command Publish** – Deploy your package to npm effortlessly.
26
+ ---
27
+
28
+ ## 📜 CLI Commands
29
+
30
+ ### ✨ `makepack create` – Scaffold a New Project
31
+ Quickly initialize a structured package with the following setup:
32
+
33
+ ```
34
+ src/index.ts or tsx or js or jsx
35
+ .gitignore
36
+ package.json
37
+ README.md
38
+ ```
39
+
40
+ Run:
41
+ ```sh
42
+ makepack create
43
+ ```
44
+ Follow the interactive prompts to configure your project.
45
+
46
+ ### 🚀 `makepack start` – Launch the Development Server
47
+ Run a Vite + Express server to develop and test your package in real-time.
48
+
49
+ ```sh
50
+ makepack start
51
+ ```
52
+
53
+ ### 🏗️ `makepack build` – Compile Your Package
54
+ Builds and optimizes your package into the `build` directory.
55
+
56
+ ```sh
57
+ makepack build
58
+ ```
59
+
60
+ ### 📦 `makepack publish` – Deploy to NPM
61
+ Publish your package to the npm registry in one command.
62
+
63
+ ```sh
64
+ makepack publish
65
+ ```
66
+
67
+ ---
68
+
69
+ ## ⚙️ Configuration
70
+
71
+ Customize your project by creating a `makepack.js` file in the root directory. This file allows full control over the build and dev environment.
72
+
73
+ ### 🔧 Default Configuration
74
+
75
+ ```js
76
+ module.exports = (prevConfig) => ({
77
+ build: {
78
+ outdir: "build",
79
+ types: true,
80
+ formatPackageJson: (p) => p,
81
+ configs: [
82
+ {
83
+ entryPoints: "src/**/*.{tsx,ts,js,jsx}",
84
+ outdir: "esm",
85
+ format: "esm",
86
+ sourcemap: true,
87
+ jsx: 'automatic',
88
+ loader: {
89
+ '.ts': 'ts',
90
+ '.tsx': 'tsx'
91
+ },
92
+ },
93
+ {
94
+ entryPoints: "src/**/*.{tsx,ts,js,jsx}",
95
+ outdir: "",
96
+ format: "cjs",
97
+ sourcemap: true,
98
+ jsx: 'automatic',
99
+ loader: {
100
+ '.ts': 'ts',
101
+ '.tsx': 'tsx'
102
+ },
103
+ }
104
+ ]
105
+ },
106
+ start: {
107
+ port: 5000,
108
+ entry: "App.tsx",
109
+ }
110
+ });
111
+ ```
112
+
113
+ ---
114
+
115
+ ## 📜 License
116
+
117
+ `makepack` is released under the **MIT License**, allowing free usage in both open-source and commercial projects.
118
+
119
+ ---
120
+
121
+ 🚀 **Start building your next NPM package with `makepack` today!**
122
+
package/package.json CHANGED
@@ -1,62 +1,62 @@
1
- {
2
- "name": "makepack",
3
- "version": "1.5.23",
4
- "type": "module",
5
- "description": "A CLI tool to create, build, and manage JavaScript, TypeScript, React, and React-TypeScript libraries for npm projects.",
6
- "files": [
7
- "src",
8
- "package.json",
9
- "README.md"
10
- ],
11
- "categories": [
12
- "Other"
13
- ],
14
- "author": {
15
- "name": "Devnax",
16
- "email": "devnaxrul@gmail.com"
17
- },
18
- "bin": "./src/index.js",
19
- "repository": {
20
- "type": "git",
21
- "url": "https://github.com/devnax/makepack"
22
- },
23
- "bugs": {
24
- "url": "https://github.com/devnax/makepack/issues"
25
- },
26
- "homepage": "https://github.com/devnax/makepack#readme",
27
- "scripts": {
28
- "start": "node ./src/index.js start",
29
- "create": "node ./src/index.js create",
30
- "build": "node ./src/index.js build"
31
- },
32
- "dependencies": {
33
- "chalk": "^5.4.1",
34
- "chokidar": "^4.0.3",
35
- "commander": "^12.1.0",
36
- "cosmiconfig": "^9.0.0",
37
- "esbuild": "^0.25.0",
38
- "express": "^4.21.1",
39
- "figlet": "^1.8.0",
40
- "figures": "^6.1.0",
41
- "fs-extra": "^11.2.0",
42
- "glob": "^11.0.0",
43
- "inquirer": "^12.1.0",
44
- "ora": "^8.1.1",
45
- "typescript": "^5.7.2",
46
- "vite": "^6.0.2"
47
- },
48
- "keywords": [
49
- "CLI",
50
- "npm",
51
- "library",
52
- "JavaScript",
53
- "TypeScript",
54
- "React",
55
- "npm-package"
56
- ],
57
- "devDependencies": {
58
- "@types/fs-extra": "^11.0.4",
59
- "react": "^19.0.0",
60
- "react-dom": "^19.0.0"
61
- }
1
+ {
2
+ "name": "makepack",
3
+ "version": "1.5.24",
4
+ "type": "module",
5
+ "description": "A CLI tool to create, build, and manage JavaScript, TypeScript, React, and React-TypeScript libraries for npm projects.",
6
+ "files": [
7
+ "src",
8
+ "package.json",
9
+ "README.md"
10
+ ],
11
+ "categories": [
12
+ "Other"
13
+ ],
14
+ "author": {
15
+ "name": "Devnax",
16
+ "email": "devnaxrul@gmail.com"
17
+ },
18
+ "bin": "./src/index.js",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/devnax/makepack"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/devnax/makepack/issues"
25
+ },
26
+ "homepage": "https://github.com/devnax/makepack#readme",
27
+ "scripts": {
28
+ "start": "node ./src/index.js start",
29
+ "create": "node ./src/index.js create",
30
+ "build": "node ./src/index.js build"
31
+ },
32
+ "dependencies": {
33
+ "chalk": "^5.4.1",
34
+ "chokidar": "^4.0.3",
35
+ "commander": "^12.1.0",
36
+ "cosmiconfig": "^9.0.0",
37
+ "esbuild": "^0.25.0",
38
+ "express": "^4.21.1",
39
+ "figlet": "^1.8.0",
40
+ "figures": "^6.1.0",
41
+ "fs-extra": "^11.2.0",
42
+ "glob": "^11.0.0",
43
+ "inquirer": "^12.1.0",
44
+ "ora": "^8.1.1",
45
+ "typescript": "^5.7.2",
46
+ "vite": "^6.0.2"
47
+ },
48
+ "keywords": [
49
+ "CLI",
50
+ "npm",
51
+ "library",
52
+ "JavaScript",
53
+ "TypeScript",
54
+ "React",
55
+ "npm-package"
56
+ ],
57
+ "devDependencies": {
58
+ "@types/fs-extra": "^11.0.4",
59
+ "react": "^19.0.0",
60
+ "react-dom": "^19.0.0"
61
+ }
62
62
  }
@@ -1,110 +1,110 @@
1
- import esbuild from 'esbuild'
2
- import fs from 'fs-extra'
3
- import path from 'path'
4
- import chalk from 'chalk'
5
- import ora from 'ora'
6
- import { glob } from 'glob'
7
- import ts from 'typescript'
8
- import makepackConfig from '../../makepack-config.js'
9
-
10
- const build = async () => {
11
-
12
- const spinner = ora("Generating a production build for the package...").start();
13
-
14
- try {
15
- const { build } = await makepackConfig()
16
- const configs = build.configs
17
- if (!configs || !configs.length) process.exit("Invalid configuration");
18
- const outdir = path.join(process.cwd(), build.outdir)
19
-
20
- try {
21
- fs.removeSync(outdir);
22
- fs.mkdirSync(outdir);
23
- } catch (err) { }
24
-
25
- const batchSize = 500;
26
- for (let ebconfig of configs) {
27
- const files = await glob(ebconfig.entryPoints) || [];
28
- const entryPoints = files.map(entry => path.join(process.cwd(), entry));
29
- for (let i = 0; i < entryPoints.length; i += batchSize) {
30
- const batch = entryPoints.slice(i, i + batchSize);
31
- await esbuild.build({
32
- ...ebconfig,
33
- entryPoints: batch,
34
- outdir: path.join(outdir, ebconfig.outdir || ''),
35
- });
36
- }
37
- }
38
-
39
- if (build.types) {
40
- const tsconfigPath = path.resolve(process.cwd(), "tsconfig.json");
41
- let tsconfig = {};
42
- if (fs.existsSync(tsconfigPath)) {
43
- const parsedConfig = ts.getParsedCommandLineOfConfigFile(
44
- tsconfigPath,
45
- {},
46
- ts.sys
47
- );
48
-
49
- if (!parsedConfig) {
50
- console.error("❌ Error parsing tsconfig.json");
51
- process.exit(1);
52
- } else {
53
- tsconfig = parsedConfig.options;
54
- }
55
- }
56
-
57
- tsconfig = {
58
- allowJs: true,
59
- target: ts.ScriptTarget.ESNext, // Ensure it's an enum
60
- skipLibCheck: true,
61
- moduleResolution: ts.ModuleResolutionKind.Node10,
62
- ...tsconfig, // Preserve root tsconfig settings
63
- outDir: path.join(outdir, "types"),
64
- declaration: true,
65
- emitDeclarationOnly: true,
66
- noEmit: false,
67
- };
68
-
69
- spinner.text = "Generating TypeScript declarations..."
70
- const files = await glob("src/**/*.{tsx,ts,js,jsx}") || []
71
- const program = ts.createProgram(files, tsconfig);
72
- const emitResult = program.emit();
73
- const diagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
74
-
75
- if (diagnostics.length > 0) {
76
- diagnostics.forEach(diagnostic => {
77
- const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
78
- if (diagnostic.file) {
79
- const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
80
- spinner.fail(`Error at ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
81
- } else {
82
- spinner.fail(`Error: ${message}`);
83
- }
84
- });
85
- } else {
86
- spinner.succeed("TypeScript declaration files generated successfully!")
87
- }
88
- }
89
-
90
- spinner.text = "Copying package.json and readme.md files..."
91
- let packageJson = JSON.parse(fs.readFileSync(path.join(process.cwd(), '/package.json'), 'utf8'));
92
- const formatPackageJson = build.formatPackageJson || ((p) => p)
93
- packageJson = formatPackageJson(packageJson)
94
-
95
- fs.writeFileSync(path.join(process.cwd(), build.outdir, '/package.json'), JSON.stringify(packageJson, null, 2));
96
- fs.copyFileSync(path.join(process.cwd(), '/readme.md'), path.join(process.cwd(), build.outdir, `/readme.md`))
97
- spinner.succeed('Production build generated successfully! The package is ready for deployment.')
98
-
99
- console.log(`\nTo publish your package:`);
100
- console.log(`run: ${chalk.green(`makepack publish`)} to publish the package directly from the current project.`);
101
- console.log(chalk.yellow(`OR`));
102
- console.log(`${chalk.yellow(`Navigate to the ${build.outdir} directory:`)} ${chalk.green(`cd ./${build.outdir}`)} and run ${chalk.green(`npm publish`)}`);
103
-
104
- } catch (error) {
105
- spinner.fail("An error occurred while generating the production build.")
106
- console.error(error);
107
- }
108
- }
109
-
1
+ import esbuild from 'esbuild'
2
+ import fs from 'fs-extra'
3
+ import path from 'path'
4
+ import chalk from 'chalk'
5
+ import ora from 'ora'
6
+ import { glob } from 'glob'
7
+ import ts from 'typescript'
8
+ import makepackConfig from '../../makepack-config.js'
9
+
10
+ const build = async () => {
11
+
12
+ const spinner = ora("Generating a production build for the package...").start();
13
+
14
+ try {
15
+ const { build } = await makepackConfig()
16
+ const configs = build.configs
17
+ if (!configs || !configs.length) process.exit("Invalid configuration");
18
+ const outdir = path.join(process.cwd(), build.outdir)
19
+
20
+ try {
21
+ fs.removeSync(outdir);
22
+ fs.mkdirSync(outdir);
23
+ } catch (err) { }
24
+
25
+ const batchSize = 500;
26
+ for (let ebconfig of configs) {
27
+ const files = await glob(ebconfig.entryPoints) || [];
28
+ const entryPoints = files.map(entry => path.join(process.cwd(), entry));
29
+ for (let i = 0; i < entryPoints.length; i += batchSize) {
30
+ const batch = entryPoints.slice(i, i + batchSize);
31
+ await esbuild.build({
32
+ ...ebconfig,
33
+ entryPoints: batch,
34
+ outdir: path.join(outdir, ebconfig.outdir || ''),
35
+ });
36
+ }
37
+ }
38
+
39
+ if (build.types) {
40
+ const tsconfigPath = path.resolve(process.cwd(), "tsconfig.json");
41
+ let tsconfig = {};
42
+ if (fs.existsSync(tsconfigPath)) {
43
+ const parsedConfig = ts.getParsedCommandLineOfConfigFile(
44
+ tsconfigPath,
45
+ {},
46
+ ts.sys
47
+ );
48
+
49
+ if (!parsedConfig) {
50
+ console.error("❌ Error parsing tsconfig.json");
51
+ process.exit(1);
52
+ } else {
53
+ tsconfig = parsedConfig.options;
54
+ }
55
+ }
56
+
57
+ tsconfig = {
58
+ allowJs: true,
59
+ target: ts.ScriptTarget.ESNext, // Ensure it's an enum
60
+ skipLibCheck: true,
61
+ moduleResolution: ts.ModuleResolutionKind.Node10,
62
+ ...tsconfig, // Preserve root tsconfig settings
63
+ outDir: path.join(outdir, "types"),
64
+ declaration: true,
65
+ emitDeclarationOnly: true,
66
+ noEmit: false,
67
+ };
68
+
69
+ spinner.text = "Generating TypeScript declarations..."
70
+ const files = await glob("src/**/*.{tsx,ts,js,jsx}") || []
71
+ const program = ts.createProgram(files, tsconfig);
72
+ const emitResult = program.emit();
73
+ const diagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
74
+
75
+ if (diagnostics.length > 0) {
76
+ diagnostics.forEach(diagnostic => {
77
+ const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
78
+ if (diagnostic.file) {
79
+ const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
80
+ spinner.fail(`Error at ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
81
+ } else {
82
+ spinner.fail(`Error: ${message}`);
83
+ }
84
+ });
85
+ } else {
86
+ spinner.succeed("TypeScript declaration files generated successfully!")
87
+ }
88
+ }
89
+
90
+ spinner.text = "Copying package.json and readme.md files..."
91
+ let packageJson = JSON.parse(fs.readFileSync(path.join(process.cwd(), '/package.json'), 'utf8'));
92
+ const formatPackageJson = build.formatPackageJson || ((p) => p)
93
+ packageJson = formatPackageJson(packageJson)
94
+
95
+ fs.writeFileSync(path.join(process.cwd(), build.outdir, '/package.json'), JSON.stringify(packageJson, null, 2));
96
+ fs.copyFileSync(path.join(process.cwd(), '/readme.md'), path.join(process.cwd(), build.outdir, `/readme.md`))
97
+ spinner.succeed('Production build generated successfully! The package is ready for deployment.')
98
+
99
+ console.log(`\nTo publish your package:`);
100
+ console.log(`run: ${chalk.green(`makepack publish`)} to publish the package directly from the current project.`);
101
+ console.log(chalk.yellow(`OR`));
102
+ console.log(`${chalk.yellow(`Navigate to the ${build.outdir} directory:`)} ${chalk.green(`cd ./${build.outdir}`)} and run ${chalk.green(`npm publish`)}`);
103
+
104
+ } catch (error) {
105
+ spinner.fail("An error occurred while generating the production build.")
106
+ console.error(error);
107
+ }
108
+ }
109
+
110
110
  export default build