minimaz-cli 0.1.1 → 0.1.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.
package/package.json CHANGED
@@ -1,19 +1,20 @@
1
1
  {
2
2
  "name": "minimaz-cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Minimal project initializer and builder CLI",
5
5
  "author": "MrZeller",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "files": [
9
- "dist/",
9
+ "bin",
10
+ "src",
10
11
  "LICENSE",
11
12
  "README.md",
12
13
  "package.json"
13
14
  ],
14
15
  "repository": {
15
16
  "type": "git",
16
- "url": "https://github.com/zeller-dev/minimaz-cli.git"
17
+ "url": "git+https://github.com/zeller-dev/minimaz-cli.git"
17
18
  },
18
19
  "keywords": [
19
20
  "cli",
@@ -35,7 +36,7 @@
35
36
  },
36
37
  "postinstall": "node ./dist/src/utils/postInstall.js",
37
38
  "bin": {
38
- "minimaz": "./bin/cli.js",
39
- "mz": "./bin/cli.js"
39
+ "minimaz": "dist/bin/cli.js",
40
+ "mz": "dist/bin/cli.js"
40
41
  }
41
42
  }
@@ -0,0 +1 @@
1
+ import s from"fs-extra";import r from"path";import F from"clean-css";import{minify as $}from"html-minifier-terser";import{minify as b}from"terser";import{loadConfig as k}from"../utils/loadConfig.js";import{log as a}from"../utils/logService.js";import{applyReplacements as h,getFile as g}from"../utils/functions.js";async function H(){try{const t=await k(),l=r.resolve(process.cwd(),t.dist||"dist");await s.remove(l),await s.ensureDir(l);async function j(f,m){const w=r.resolve(process.cwd(),f),S=r.join(l,m);if(!await s.pathExists(w)){a("warn",`Folder not found: ${f}`);return}const p=[],u=[];async function y(i,n){await s.ensureDir(n);for(const e of await s.readdir(i)){const c=r.join(i,e),d=r.join(n,e),v=await s.stat(c),C=r.extname(e).toLowerCase();if(v.isDirectory()){await y(c,d);continue}try{switch(C){case".html":{let o=await g(c,t.replace);t.minify?.html&&(o=await $(o,{collapseWhitespace:!0,removeComments:!0,minifyJS:t.minify?.ts,minifyCSS:t.minify?.css})),await s.outputFile(d,o);break}case".css":{const o=await g(c,t.replace);p.push(o);break}case".js":{const o=await g(c,t.replace);u.push(o);break}default:await s.copy(c,d);break}}catch(o){a("error",`Failed to process file: ${c} - ${o.message}`)}}}if(await y(w,S),f===t.src)try{if(t.styles?.length)for(const i of t.styles){const n=r.resolve(process.cwd(),i);if(await s.pathExists(n)){let e=await s.readFile(n,"utf-8");e=h(e,t.replace),p.push(e)}else a("warn",`Style file not found: ${i}`)}if(t.scripts?.length)for(const i of t.scripts){const n=r.resolve(process.cwd(),i);if(await s.pathExists(n)){let e=await s.readFile(n,"utf-8");e=h(e,t.replace),u.push(e)}else a("warn",`Script file not found: ${i}`)}if(p.length>0){let i=p.join("");t.minify?.css&&(i=new F().minify(i).styles),await s.outputFile(r.join(l,"style.css"),i)}if(u.length>0){let i=u.join("");t.minify?.js&&(i=(await b(i)).code??""),i&&await s.outputFile(r.join(l,"script.js"),i)}}catch(i){a("error",`Failed to merge CSS/JS: ${i.message}`)}a("success",`Processed folder: ${f} -> /${m}`)}if(t.folders&&Object.keys(t.folders).length>0)for(const[f,m]of Object.entries(t.folders))await j(f,m);else a("warn","No folders defined in config. Nothing to build.");a("success",`Build completed. Output saved in /${t.dist}`)}catch(t){a("error",`Build failed: ${t.message}`)}}export{H as build};
@@ -0,0 +1,2 @@
1
+ function t(){console.log(["Usage:",""," minimaz init | i <project-name>",' Create a new project (default: "minimaz-site")'," Options:",' --template | -t <template-name> Use a global template (default: "default")',""," minimaz build | b"," Build and minify files into the dist folder",""," minimaz template | t [path]"," Save current folder as a template (no path = current folder)"," Options:"," --list | -l List available global templates"," --delete | -d <template-name> Delete a global template",""," minimaz help | h"," Show this help message"].join(`
2
+ `))}export{t as help};
@@ -0,0 +1 @@
1
+ import t from"fs-extra";import i from"path";import g from"os";import{log as n}from"../utils/logService.js";import{createGlobalDir as p}from"../utils/functions.js";async function j(s,o={}){const e=i.join(g.homedir(),".minimaz");await t.pathExists(e)||(n("info",`Global folder '${e}' not found. Creating...`),await p());const a=i.join(e,"templates",o.template||"default"),m=i.resolve(process.cwd(),s);if(!await t.pathExists(a))throw new Error(`Template '${o.template}' not found.`);try{await t.copy(a,m);const r=i.join(a,"..","gitignore"),c=i.join(m,".gitignore");await t.pathExists(r)&&(await t.copy(r,c),n("info",".gitignore added to project.")),n("success",`Project '${s}' created using template '${o.template}'.`)}catch(r){throw new Error(`Failed to create project: ${r.message}`)}}export{j as init};
@@ -0,0 +1 @@
1
+ import o from"fs-extra";import w from"os";import n from"path";import{log as a}from"../utils/logService.js";import{askQuestion as c,listTemplates as m,getGlobalNodeModulesPath as f}from"../utils/functions.js";async function j(s,e={}){const t=n.join(w.homedir(),".minimaz","templates"),r=e.delete||e.d,i=e.update||e.u;if(r)return await g(t,r);if(e.list||e.l)return await m(t);if(i!==void 0)return typeof i=="string"&&i.trim()?await u(t,i.trim()):await p(t);await y(t,s)}async function u(s,e){const t=n.resolve(process.cwd()),r=n.join(s,e);if(!await o.pathExists(r))throw new Error(`Template '${e}' not found in ~/.minimaz/templates`);const i=await c(`\u2753 Update template '${e}' with current directory? (Y/N) `);if(i!=="y"&&i!==""){a("info","Update cancelled.");return}try{await o.copy(t,r,{overwrite:!0}),a("success",`Template '${e}' updated from current directory.`)}catch(d){throw new Error(`Failed to update '${e}': ${d.message}`)}}async function p(s){const e=n.join(f(),"src","templates");if(!await o.pathExists(e))throw new Error("'node_modules/minimaz/src/templates' not found.");const t=await o.readdir(e),r=await c("\u26A0\uFE0F Update local templates overwriting them with defaults? (Y/N): ");if(r!=="y"&&r!==""){a("info","Update cancelled.");return}try{for(const i of t){const d=n.join(e,i),l=n.join(s,i);await o.copy(d,l,{overwrite:!0}),a("success",`Updated '${i}'`)}a("info","\u2728 All templates and files updated successfully.")}catch(i){throw new Error(`Update failed: ${i.message}`)}}async function g(s,e){if(!e)throw new Error("No template name specified to delete.");const t=n.join(s,e);if(!await o.pathExists(t))throw new Error(`Template not found: ${e}`);if((await c(`\u2753 Confirm delete '${e}'? (Y/N) `)).toLowerCase()!=="y"){a("info","Delete cancelled.");return}try{await o.remove(t),a("success",`Template '${e}' deleted.`)}catch(i){throw new Error(`Delete error: ${i.message}`)}}async function y(s,e){let t=e?n.resolve(process.cwd(),e):process.cwd();if(!await o.pathExists(t)){a("warn",`Path not found: ${t}`);const r=(await c("\u2753 Use current directory instead? (Y/N): ")).trim().toLowerCase();if(r!=="y"&&r!=="")throw new Error("Operation cancelled.");t=process.cwd()}try{await o.ensureDir(s);const r=n.join(s,n.basename(t));await o.copy(t,r),a("success",`Template saved to ${r}`)}catch(r){throw new Error(`Failed to save template: ${r.message}`)}}export{j as template};
@@ -0,0 +1,26 @@
1
+ {
2
+ "src": "src",
3
+ "dist": "dist",
4
+ "public": "public",
5
+ "minify": {
6
+ "html": true,
7
+ "css": true,
8
+ "js": true,
9
+ "ts": true
10
+ },
11
+ "replace": {
12
+ "../public/": "public/"
13
+ },
14
+ "styles": [
15
+ "style.css",
16
+ "style-2.css"
17
+ ],
18
+ "scripts": [
19
+ "script.js",
20
+ "script-2.js"
21
+ ],
22
+ "folders": {
23
+ "src": "",
24
+ "public": "public"
25
+ }
26
+ }
File without changes
@@ -0,0 +1,80 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Welcome to Minimaz</title>
7
+ <link rel="stylesheet" href="style.css" />
8
+ <link rel="icon" href="../public/favicon.ico" type="image/x-icon" />
9
+ </head>
10
+ <body>
11
+ <header>
12
+ <nav>
13
+ <a class="btn active" href="#">Home</a>
14
+ <a class="btn" href="pages/about.html">About</a>
15
+ <a class="btn" href="https://github.com/zeller-dev/minimaz" target="_blank">GitHub</a>
16
+ </nav>
17
+ </header>
18
+
19
+ <main class="container">
20
+ <h1>🚀 Welcome to Minimaz</h1>
21
+ <p><strong>Minimaz</strong> is a minimal static site builder designed for speed and simplicity. It helps you:</p>
22
+ <ul>
23
+ <li>💡 Organize your files with a simple structure</li>
24
+ <li>⚙️ Automatically build and minify HTML, CSS, JS, and TS</li>
25
+ <li>🔄 Customize file inclusion order using <code>minimaz.config.json</code></li>
26
+ </ul>
27
+
28
+ <h2>🔧 Getting Started</h2>
29
+ <p>Install and use Minimaz with the following commands:</p>
30
+ <pre><code># 🔨 Initialize a new project
31
+ npx minimaz init my-site
32
+
33
+ # 🏗️ Build the site
34
+ npx minimaz build
35
+
36
+ # 📦 Save template or list/delete existing ones
37
+ npx minimaz template &lt;path&gt; [--list|-l] [--delete|-d]
38
+
39
+ # 💬 Show help guide
40
+ npx minimaz help</code></pre>
41
+
42
+ <h2>📁 Project Structure</h2>
43
+ <pre><code>my-site/
44
+ ├── src/ # Source files (HTML, CSS, JS, TS)
45
+ ├── public/ # Static assets (images, fonts, etc.)
46
+ ├── dist/ # Output directory (auto-generated)
47
+ └── minimaz.config.json # Configuration file</code></pre>
48
+
49
+ <h2>⚙️ Configuration</h2>
50
+ <pre><code>{
51
+ "src": "src",
52
+ "dist": "dist",
53
+ "public": "public",
54
+ "minify": { "html": true, "css": true, "js": true, "ts": true },
55
+ "replace": { "../public/": "public/" },
56
+ "styles": [ "reset.css", "style.css", "theme.css" ],
57
+ "scripts": [ "libs/jquery.js", "utils.js", "script.js" ]
58
+ }</code></pre>
59
+
60
+ <h2>📤 Production</h2>
61
+ <p>The final output will be generated in the <code>dist/</code> folder, ready for deployment.</p>
62
+
63
+ <h2>❓ Available Commands</h2>
64
+ <ul>
65
+ <li><code>init</code> / <code>i</code> – Initialize a new project</li>
66
+ <li><code>build</code> / <code>b</code> – Build and minify the project</li>
67
+ <li><code>help</code> / <code>h</code> – Show the help message</li>
68
+ <li><code>template</code> / <code>t</code> – Manage templates (with <code>--list</code> and <code>--delete</code> options)</li>
69
+ </ul>
70
+
71
+ <p>You're ready to build fast and clean static websites. Happy coding! 🛠️</p>
72
+ </main>
73
+
74
+ <footer>
75
+ <p>&copy; 2025 Minimaz. All rights reserved.</p>
76
+ </footer>
77
+
78
+ <script src="script.js"></script>
79
+ </body>
80
+ </html>
@@ -0,0 +1,46 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Welcome to Minimaz</title>
8
+ <link rel="stylesheet" href="../style.css" />
9
+ <link rel="shortcut icon" href="../../public/favicon.ico" type="image/x-icon">
10
+
11
+ </head>
12
+
13
+ <body>
14
+ <header>
15
+ <nav>
16
+ <a class='btn' href="../index.html">Home</a>
17
+ <a class='btn active' href="pages/about.html">About</a>
18
+ <a class='btn' target="_blank" href="https://github.com/zeller-dev/minimaz">GitHub</a>
19
+ </nav>
20
+ </header>
21
+ <div class="container">
22
+ <h1>About Minimaz</h1>
23
+ <p><strong>Minimaz</strong> is a minimal build tool that helps you quickly scaffold and minify HTML, CSS, and
24
+ JavaScript projects.</p>
25
+
26
+ <h2>Features</h2>
27
+ <ul>
28
+ <li>Zero-config HTML/CSS/JS minification</li>
29
+ <li>Folder structure based on <code>src</code>, <code>public</code>, and <code>dist</code></li>
30
+ <li>Simple CLI with <code>init</code>, <code>build</code>, and <code>help</code> commands</li>
31
+ </ul>
32
+
33
+ <h2>Getting Started</h2>
34
+ <pre><code>$ minimaz init my-project
35
+ $ cd my-project
36
+ $ minimaz build</code></pre>
37
+
38
+ <p>Learn more or contribute on <a href="#">GitHub</a>.</p>
39
+ </div>
40
+ <footer>
41
+ <p>&copy; 2023 Minimaz. All rights reserved.</p>
42
+ </footer>
43
+ <script src="../script.js"></script>
44
+ </body>
45
+
46
+ </html>
@@ -0,0 +1 @@
1
+ console.log('Minimaz is ready!')
@@ -0,0 +1,99 @@
1
+ :root {
2
+ --primary-color: #338ca8;
3
+ --background-color: #222;
4
+ --foreground-color: #f5f5f5;
5
+ --code-bg: #333;
6
+ --code-text: #eeeeff;
7
+ font-size: 16px;
8
+ }
9
+
10
+ * {
11
+ box-sizing: border-box;
12
+ }
13
+
14
+ header,
15
+ footer {
16
+ background-color: var(--code-bg);
17
+ padding:1rem;
18
+ }
19
+
20
+ body {
21
+ font-family: 'Segoe UI', sans-serif;
22
+ margin: 0;
23
+ background: var(--background-color);
24
+ color: var(--foreground-color);
25
+ line-height: 1.6;
26
+ }
27
+
28
+ .container {
29
+ max-width: 800px;
30
+ margin: auto;
31
+ padding: 1rem;
32
+ }
33
+
34
+ h1,
35
+ h2,
36
+ h3 {
37
+ color: var(--primary-color);
38
+ margin-top: 2rem;
39
+ }
40
+
41
+ p {
42
+ margin: 1rem 0;
43
+ }
44
+
45
+ code {
46
+ background: var(--code-bg);
47
+ color: var(--code-text);
48
+ padding: 0.2rem 0.4rem;
49
+ border-radius: 4px;
50
+ font-family: monospace;
51
+ }
52
+
53
+ pre {
54
+ background: var(--code-bg);
55
+ color: #ddd;
56
+ padding: 1rem;
57
+ overflow-x: auto;
58
+ border-radius: 6px;
59
+ font-family: monospace;
60
+ border-left: 4px solid var(--primary-color);
61
+ }
62
+
63
+ a {
64
+ color: var(--primary-color);
65
+ text-decoration: none;
66
+ }
67
+
68
+ .btn {
69
+ transition: all 0.15s ease-in-out;
70
+ background-color: var(--primary-color);
71
+ border: none;
72
+ color: #fff;
73
+ padding: 10px 20px;
74
+ font-size: 1rem;
75
+ margin: .5rem .2rem;
76
+ cursor: pointer;
77
+ border-radius: 5px;
78
+ display: inline-block;
79
+ text-align: center;
80
+ }
81
+
82
+ .btn:hover {
83
+ opacity: 0.85;
84
+ }
85
+
86
+ .btn.active {
87
+ background-color: var(--code-bg);
88
+ color: #fff;
89
+ pointer-events: none;
90
+ }
91
+
92
+ header {
93
+ font-weight: 600;
94
+ }
95
+
96
+ footer p {
97
+ text-align: center;
98
+ margin: 0;
99
+ }
@@ -0,0 +1,2 @@
1
+ dist
2
+ .vscode
@@ -0,0 +1,26 @@
1
+ {
2
+ "src": "src",
3
+ "dist": "dist",
4
+ "public": "public",
5
+ "minify": {
6
+ "html": true,
7
+ "css": true,
8
+ "js": true,
9
+ "ts": true
10
+ },
11
+ "replace": {
12
+ "../public/": "public/"
13
+ },
14
+ "styles": [
15
+ "style.css",
16
+ "style-2.css"
17
+ ],
18
+ "scripts": [
19
+ "script.js",
20
+ "script-2.js"
21
+ ],
22
+ "folders": {
23
+ "src": "",
24
+ "public": "public"
25
+ }
26
+ }
File without changes
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Welcome to Minimaz</title>
8
+ <link rel="stylesheet" href="style.css" />
9
+ </head>
10
+
11
+ <body>
12
+ <script src="script.js"></script>
13
+ </body>
14
+
15
+ </html>
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Document</title>
7
+ </head>
8
+ <body>
9
+
10
+ </body>
11
+ </html>
@@ -0,0 +1 @@
1
+ console.log('Minimaz is ready!')
File without changes
@@ -0,0 +1 @@
1
+ import f from"readline";import s from"fs-extra";import n from"path";import g from"os";import{log as o}from"./logService.js";import{execSync as u}from"child_process";function P(t){const i={_:[]};for(let e=0;e<t.length;e++){const r=t[e];if(r.startsWith("-")){const a=r.startsWith("--")?r.slice(2):r.slice(1),l=t[e+1],m=!!l&&!l.startsWith("-");i[a]=m?l:!0,m&&e++}else i._.push(r)}return i}function D(t){return new Promise(i=>{const e=f.createInterface({input:process.stdin,output:process.stdout});e.question(t,r=>{e.close(),i(r.trim())})})}async function A(t){if(!await s.pathExists(t)){o("info","No templates directory found.");return}const i=await s.readdir(t);i.length===0?o("info","No global templates available."):(o("info","Available global templates:"),i.forEach(e=>o("info",`- ${e}`)))}function d(t,i={}){for(const[e,r]of Object.entries(i))t=t.split(e).join(r);return t}async function E(t,i){try{let e=await s.readFile(t,"utf-8");return i&&(e=d(e,i)),e}catch(e){return o("error",`Failed to read file ${t}: ${e.message}`),""}}function p(){try{const t=u("npm config get prefix",{encoding:"utf-8"}).trim();if(!t)throw new Error("Empty prefix");return process.platform==="win32"?n.join(t,"node_modules","minimaz-cli"):n.join(t,"lib","node_modules","minimaz-cli")}catch{return process.platform==="win32"?n.join(process.env.APPDATA||"","npm","node_modules","minimaz-cli"):"/usr/local/lib/node_modules/minimaz-cli"}}async function _(){const t=n.join(g.homedir(),".minimaz"),i=n.join(t,"templates"),e=n.join(p(),"src","templates"),r=n.join(t,"settings.json");console.log(e);try{if(await s.ensureDir(t),!await s.pathExists(r)){const c={createdAt:new Date().toISOString(),templatesPath:i,npmGlobalPath:p()};await s.outputJson(r,c,{spaces:2}),o("success",`Created settings.json at ${r}`)}const a=await s.pathExists(i),l=a?(await s.readdir(i)).length===0:!0;if(a||(await s.ensureDir(i),o("success","Created global templates directory.")),!l){o("info","Global templates directory not empty. Skipping copy.");return}const m=await s.readdir(e);console.log(m);for(const c of await s.readdir(e))await s.copy(n.join(e,c),n.join(i,c)),o("success",`Copied template '${c}'.`);o("success","Default templates setup completed.")}catch(a){throw o("error",`Failed to create global templates directory: ${a.message}`),a}}export{d as applyReplacements,D as askQuestion,_ as createGlobalDir,E as getFile,p as getGlobalNodeModulesPath,A as listTemplates,P as parseArgs};
@@ -0,0 +1 @@
1
+ import t from"fs-extra";import s from"path";import{log as a}from"./logService.js";const f={src:"src",dist:"dist",public:"public",minify:{html:!0,css:!0,js:!0},replace:{}};function e(r,i){const o={...r};for(const n in i)i[n]&&typeof i[n]=="object"&&!Array.isArray(i[n])?o[n]=e(r[n]||{},i[n]):i[n]!==void 0&&(o[n]=i[n]);return o}async function g(){const r=s.resolve(process.cwd(),"minimaz.config.json");let i={};if(await t.pathExists(r))try{i=await t.readJson(r),a("info","Loaded config from minimaz.config.tson")}catch(n){throw new Error(`Failed to parse minimaz.config.tson: ${n.message}`)}else a("info","No minimaz.config.tson found. Using default config");const o=e(f,i);if(!o.src||!o.dist)throw new Error("Invalid configuration: src and dist are required");return o}export{g as loadConfig};
@@ -0,0 +1 @@
1
+ function c(o="log",n){const r={error:"\u274C",warn:"\u26A0\uFE0F",success:"\u2705",info:"\u2139\uFE0F",log:"\u{1F4C1}"};o==="error"?console.error(r[o],n):o==="warn"?console.warn(r[o],n):console.log(r[o]||r.log,n)}export{c as log};
@@ -0,0 +1 @@
1
+ import{createGlobalDir as s}from"./functions.js";import{log as e}from"./logService.js";async function a(){try{await s(),e("success","Postinstall: Global templates setup completed.")}catch(t){e("error",`Postinstall setup failed: ${t.message}`)}}a();