minimaz-cli 0.2.0 → 0.3.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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Minimaz, a Christmas Version 🎄
1
+ # Minimaz CLI 🎄
2
2
 
3
3
  **Minimaz** is a minimal, low-dependency static site builder and project initializer focused on speed, simplicity, and clean output.
4
4
 
@@ -13,6 +13,8 @@
13
13
  * 🊄 Optional path replacements for asset links
14
14
  * ðŸŠķ Lightweight and fast — ideal for small static or utility projects
15
15
  * ðŸ”Ĩ Usable with `minimaz` or its alias `mz`
16
+ * ðŸ’ŧ NPM integration and optional Git repository initialization
17
+ * ⏱ Interactive prompts with 60s timeout
16
18
 
17
19
  ## ðŸ“Ķ Installation
18
20
 
@@ -28,9 +30,9 @@ npx minimaz version
28
30
  Or using the alias:
29
31
 
30
32
  ```bash
31
- npx mz init my-site
32
- npx mz build
33
- npx mz version
33
+ npx mz i my-site
34
+ npx mz b
35
+ npx mz v
34
36
  ```
35
37
 
36
38
  ## 📁 Project Structure
@@ -41,6 +43,8 @@ my-site/
41
43
  ├── public/ # Static assets (images, fonts, etc.)
42
44
  ├── src/ # HTML, CSS, JS, TS files
43
45
  ├── minimaz.config.json
46
+ ├── package.json # Optional, created if npm init is used
47
+ ├── .gitignore # Default gitignore copied from template
44
48
  └── ...
45
49
  ```
46
50
 
@@ -53,6 +57,10 @@ Customize your build using a `minimaz.config.json` file:
53
57
  "src": "src",
54
58
  "dist": "dist",
55
59
  "public": "public",
60
+ "bundling": {
61
+ "css": true,
62
+ "js": true
63
+ },
56
64
  "minify": {
57
65
  "html": true,
58
66
  "css": true,
@@ -65,45 +73,88 @@ Customize your build using a `minimaz.config.json` file:
65
73
  "folders": {
66
74
  "src": "",
67
75
  "public": "public"
68
- }
76
+ },
69
77
  "styles": [
70
- "style.css",
71
- "theme.css"
78
+ "../node_modules/some-package/dist/library.css",
79
+ "C:/Users/YourUser/Desktop/custom.css"
72
80
  ],
73
81
  "scripts": [
74
- "lib.js",
75
- "script.js"
82
+ "../node_modules/some-package/dist/library.js",
83
+ "D:/Scripts/custom.js"
76
84
  ]
77
85
  }
78
86
  ```
79
87
 
80
- * `styles` (optional): array of `.css` files to concatenate and minify into a single `style.css`
81
- * `scripts` (optional): array of `.js` files to concatenate and minify into a single `script.js`
82
- * If omitted, fallback defaults are `style.css` and `script.js`
88
+ * styles (optional): array of .css files to include in the build, can be inside src, node_modules, or any absolute/relative path on your system.
89
+ * scripts (optional): array of .js files to include in the build, can also point outside src.
90
+ * If omitted, fallback defaults are style.css and script.js.
91
+ * `bundling.css` / `bundling.js`: controls whether listed CSS/JS files are concatenated into a single `style.css` / `script.js`.
92
+ * `minify.html`, `minify.css`, `minify.js`, `minify.ts`: enable minification for the corresponding file types. TypeScript files are compiled to JS before minification.
83
93
 
84
- ## 🛠 Commands
94
+ **Tip**: Using external paths is useful for including library CSS/JS without copying them into your project.
85
95
 
86
- ```bash
87
- minimaz build # Build and minify the site (uses config or defaults)
88
- minimaz clear # Clears dist folder
89
- minimaz init <project-name> # Create a new project using global templates
90
- minimaz help # Show help message
91
- minimaz template <path> # Save a new template from specified path (or current dir)
92
- minimaz template -list # List available templates
93
- minimaz template -delete <name> # Delete a saved template
94
- minimaz version # Display Minimaz version
95
- ```
96
+ ## 🛠 Commands
96
97
 
97
- ### Commands Aliases
98
98
  ```bash
99
- mz b # Build and minify the site (uses config or defaults)
100
- mz c # Clears dist folder
101
- mz i <project-name> # Create a new project using global templates
102
- mz h # Show help message
103
- mz t <path> # Save a new template from specified path (or current dir)
104
- mz t -l # List available templates
105
- mz t -d <name> # Delete a saved template
106
- mz v # Display Minimaz version
99
+ # -----------------------------
100
+ # Build
101
+ # -----------------------------
102
+ minimaz build # Build and minify the project
103
+ mz b # alias
104
+
105
+ # -----------------------------
106
+ # Clear
107
+ # -----------------------------
108
+ minimaz clear # Delete the dist folder
109
+ mz c # alias
110
+
111
+ # -----------------------------
112
+ # Init
113
+ # -----------------------------
114
+ minimaz init <project-name> # Initialize a new project with default template
115
+ mz i <project-name> # alias
116
+
117
+ minimaz init <project-name> --template <name> # Use a specific template
118
+ mz i <project-name> -t <name> # alias
119
+
120
+ minimaz init <project-name> --npm # Initialize npm project
121
+ minimaz init <project-name> --git # Initialize git repository
122
+
123
+ # Specify git provider or remote URL
124
+ minimaz init <project-name> --git --gitprovider <provider-or-url>
125
+ mz i <project-name> --git --gitprovider github # alias example
126
+
127
+ # -----------------------------
128
+ # Help
129
+ # -----------------------------
130
+ minimaz help # Show general help
131
+ mz h # alias
132
+ minimaz help <command> # Show help for a specific command
133
+ mz h build # alias example
134
+
135
+ # -----------------------------
136
+ # Template management
137
+ # -----------------------------
138
+ minimaz template <template-path> # Save current folder as a template
139
+ minimaz t <template-path> # alias
140
+
141
+ minimaz template --list # List available global templates
142
+ minimaz t -l # alias
143
+
144
+ minimaz template --delete <template-name> # Delete a saved template
145
+ minimaz t -d <template-name> # alias
146
+
147
+ minimaz template --update <template-name> # Update a specific template from current folder
148
+ minimaz t -u <template-name> # alias
149
+
150
+ minimaz template --update # Update all templates from node_modules
151
+ minimaz t -u # alias
152
+
153
+ # -----------------------------
154
+ # Version
155
+ # -----------------------------
156
+ minimaz version # Show Minimaz CLI version
157
+ mz v # alias
107
158
  ```
108
159
 
109
160
  ## 📂 Templates
@@ -118,4 +169,4 @@ Use them to quickly initialize consistent projects across environments.
118
169
 
119
170
  ## 📄 License
120
171
 
121
- MIT
172
+ MIT
package/bin/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{fileURLToPath as m}from"url";import{dirname as a}from"path";import{build as n}from"../src/commands/build.js";import{init as s}from"../src/commands/init.js";import{help as l}from"../src/commands/help.js";import{template as p}from"../src/commands/template.js";import{log as i}from"../src/utils/logService.js";import{parseArgs as c}from"../src/utils/functions.js";import{clear as d}from"../src/commands/clear.js";import{version as f}from"../src/commands/version.js";const v=m(import.meta.url),z=a(v);async function u(){const e=c(process.argv.slice(2)),t=(e._[0]||"").toLowerCase(),o={build:async()=>n(),clear:()=>d(),help:()=>l(),init:async()=>{await s(e._[1]||"minimaz-project",{template:e.template||e.t||"default"})},template:async()=>{await p(e._[1],{list:e.l||e.list,delete:e.d||e.delete,update:e.u||e.update})},version:()=>f(),b:()=>o.build(),c:()=>o.clear(),h:()=>o.help(),i:()=>o.init(),t:()=>o.template(),v:()=>o.version()};try{o[t]?await o[t]():(i("error",`Unknown command '${t}'. Use 'minimaz help' to see available commands.`),o.help())}catch(r){i("error",r instanceof Error?process.env.DEBUG?r.stack??r.message:r.message:String(r)),process.exit(1)}}u();
2
+ import{fileURLToPath as s}from"url";import{dirname as m}from"path";import{build as l,init as p,help as o,template as c,clear as d,version as g,log as r,parseArgs as u}from"../src/index.js";const f=s(import.meta.url),O=m(f);async function v(){const e=u(process.argv.slice(2)),i=e._[0]||"",a=e._[1];(i==="help"||e.h||e.help)&&(o(a||(e.h||e.help?i:void 0)),process.exit(0));const t={build:async()=>l(),clear:()=>d(),init:async()=>{await p(a||"minimaz-project",{template:e.template||e.t||"default",npm:e.npm,git:e.git,gitremote:e.gitremote,gitprovider:e.gitprovider})},template:async()=>{await c(a,{list:e.l||e.list,delete:e.d||e.delete,update:e.u||e.update})},version:()=>g(),b:()=>t.build(),c:()=>t.clear(),i:()=>t.init(),t:()=>t.template(),v:()=>t.version()};try{t[i]?await t[i]():(r("error",`Unknown command '${i}'. Use 'minimaz help' to see available commands.`),o())}catch(n){r("error",n instanceof Error?process.env.DEBUG?n.stack??n.message:n.message:String(n)),process.exit(1)}}v();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "minimaz-cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Minimal project initializer and builder CLI",
5
5
  "author": "MrZeller",
6
6
  "license": "MIT",
@@ -34,7 +34,7 @@
34
34
  "html-minifier-terser": "^7.2.0",
35
35
  "terser": "^5.44.0"
36
36
  },
37
- "postinstall": "node ./src/utils/postInstall.js",
37
+ "postinstall": "node dist/src/utils/postInstall.js",
38
38
  "bin": {
39
39
  "minimaz": "./bin/cli.js",
40
40
  "mz": "./bin/cli.js"
@@ -1 +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};
1
+ import f from"fs-extra";import m from"path";import j from"clean-css";import{minify as v}from"html-minifier-terser";import{minify as g}from"terser";import{loadConfig as S,log as l,applyReplacements as F,getFile as y,removeDistDir as M}from"../index.js";async function W(){const i=await S(),s=m.resolve(process.cwd(),i.dist||"dist");if(await M(s),await f.ensureDir(s),!i.folders||Object.keys(i.folders).length===0){l("warn","No folders defined in config. Nothing to build.");return}for(const[t,n]of Object.entries(i.folders))l("info",`Building folder: ${t} -> /${n}`),await J(t,n,i,s);l("success",`Build completed. Output saved in /${i.dist}`)}async function J(i,s,t,n){const r=m.resolve(process.cwd(),i),a=m.join(n,s);if(!await f.pathExists(r)){l("warn",`Folder not found: ${i}`);return}const e={css:[],js:[]};await C(r,a,t,e),i===t.src&&await B(e,t,n),l("success",`Processed folder: ${i} -> /${s}`)}async function C(i,s,t,n){await f.ensureDir(s);for(const r of await f.readdir(i)){const a=m.join(i,r),e=m.join(s,r);if((await f.stat(a)).isDirectory()){await C(a,e,t,n);continue}await b(a,e,t,n)}}async function b(i,s,t,n){switch(l("info",`Processing file: ${i}`),m.extname(i).toLowerCase()){case".html":await z(i,s,t);break;case".css":{const a=await y(i,t.replace);if(t.bundling?.css)n.css.push(a);else{let e=a;if(t.minify?.css){const c=new j().minify(a);c.warnings.length&&c.warnings.forEach(o=>l("warn",o)),e=c.styles}await f.outputFile(s,e)}break}case".js":{const a=await y(i,t.replace);if(t.bundling?.js)n.js.push(a);else{let e=a;if(t.minify?.js)try{e=(await g(a)).code??""}catch(c){l("warn",`JS minify failed in ${i}: ${c}`)}await f.outputFile(s,e)}break}default:await f.copy(i,s)}}async function z(i,s,t){let n=await y(i,t.replace);const r=/<script([^>]*)>([\s\S]*?)<\/script>/gi;let a=0,e="",c;for(;(c=r.exec(n))!==null;){const[o,u,d]=c;if(e+=n.slice(a,c.index),a=c.index+o.length,/src=/i.test(u)){e+=o;continue}const p=(u.match(/type=["']([^"']+)["']/i)?.[1]||"").toLowerCase(),$=/module/i.test(p),x=/nomodule/i.test(u);if(p==="application/json")try{const w=JSON.stringify(JSON.parse(d));e+=`<script${u}>${w}</script>`}catch(w){l("warn",`Invalid JSON in ${i}: ${w}`),e+=o}else if(p===""||p==="text/javascript"||$||x)try{const w=await g(d,{format:{semicolons:!0},module:$});e+=`<script${u}>${w.code||""}</script>`}catch(w){l("warn",`JS minify error in ${i}: ${w}`),e+=o}else e+=o}e+=n.slice(a),t.minify?.html&&(e=await v(e,{collapseWhitespace:!0,removeComments:!0,minifyCSS:t.minify.css,minifyJS:!1})),await f.outputFile(s,e)}async function B(i,s,t){await h(s.styles,i.css,s,"css",!!s.bundling?.css,t),await h(s.scripts,i.js,s,"js",!!s.bundling?.js,t),s.bundling?.css&&await E(i.css,s,t),s.bundling?.js&&await N(i.js,s,t)}async function h(i,s,t,n,r,a){if(i?.length)for(const e of i){const c=m.resolve(process.cwd(),e);if(!await f.pathExists(c)){l("warn",`File not found: ${e}`);continue}let o=await f.readFile(c,"utf-8");if(o=F(o,t.replace),r)s.push(o);else{if(n==="css"&&t.minify?.css){const d=new j().minify(o);d.warnings.length&&d.warnings.forEach(p=>l("warn",p)),o=d.styles}else if(n==="js"&&t.minify?.js)try{o=(await g(o)).code??""}catch(d){l("warn",`JS minify failed for external file ${e}: ${d}`)}const u=m.basename(e);await f.outputFile(m.join(a,u),o),l("info",`Copied external ${n} file: ${u}`)}}}async function E(i,s,t){if(!i.length)return;let n=i.join("");if(s.minify?.css){const r=new j().minify(n);r.warnings.length&&r.warnings.forEach(a=>l("warn",a)),n=r.styles}await f.outputFile(m.join(t,"style.css"),n)}async function N(i,s,t){if(!i.length)return;let n=i.join("");if(s.minify?.js)try{n=(await g(n)).code??""}catch(r){l("warn",`JS minify failed: ${r}`)}n&&await f.outputFile(m.join(t,"script.js"),n)}export{W as build,z as processHtml};
@@ -1 +1 @@
1
- import t from"path";import r from"fs-extra";import{loadConfig as e}from"../utils/loadConfig.js";import{log as i}from"../utils/logService.js";async function m(){const s=await e(),o=t.resolve(process.cwd(),s.dist||"dist");if(!r.existsSync(o)){i("info",`No dist folder found: ${o}`);return}r.remove(o),i("success",`Cleared ${o}`)}export{m as clear};
1
+ import{removeDistDir as o}from"../index.js";async function i(){o()}export{i as clear};
@@ -1,2 +1,3 @@
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",""," minimaz clear | c"," Clear the dist folder",""," minimaz version | v"," Show Minimaz version"].join(`
2
- `))}export{t as help};
1
+ import{commands as e}from"../index.js";function i(n){if(n){const o=e[n];if(!o){console.log(`No help found for command: ${n}
2
+ `);return}if(console.log(o.usage),console.log(` ${o.description}`),o.options){console.log(" Options:");for(const[t,s]of Object.entries(o.options))console.log(` ${t} ${s}`)}console.log("");return}console.log(`Usage:
3
+ `);for(const o of Object.values(e)){if(console.log(o.usage),console.log(` ${o.description}`),o.options){console.log(" Options:");for(const[t,s]of Object.entries(o.options))console.log(` ${t} ${s}`)}console.log("")}}export{i as help};
@@ -1 +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};
1
+ import o from"fs-extra";import n from"path";import{log as a,createGlobalDir as f,askQuestion as g,executeCommand as w,createFileFromTemplate as m,pkgTemplate as d,gitIgnoreTemplate as y,initGit as u,getGlobalDirPath as h}from"../index.js";async function I(e,i={}){const r=h(),l=i.template??"default",s=n.join(r,"templates",l),t=n.resolve(process.cwd(),e);if(await o.pathExists(r)||(a("info",`Global folder '${r}' not found. Creating...`),await f()),!await o.pathExists(s))throw new Error(`Template '${l}' not found.`);if(await o.pathExists(t))throw new Error(`Target directory '${t}' already exists.`);const c=i.npm??(await g("Init NPM? [y/n]:","y")).startsWith("y"),p=i.git??(await g("Init Git repository? [y/n]:","y")).startsWith("y");p&&(i.gitprovider=i.gitprovider??await g("Select a provider or paste a url to connect your existing repo (cli tools needed) [local/github/gitlab]:","local")),a("info",`Copying template from '${s}' to '${t}'`),await o.copy(s,t),a("info","Initializing gitignore..."),await m(y,n.join(t,".gitignore")),c&&(a("info","Initializing NPM..."),await m({...d,name:e},n.join(t,"package.json")),await w("npm",["install"],t)),p&&(a("info","Initializing GIT..."),await u(e,t,i.gitprovider)),a("success",`Project '${e}' created using template '${l}'.`)}export{I as init};
@@ -1 +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};
1
+ import i from"fs-extra";import a from"path";import{askQuestion as c,listTemplates as l,getGlobalNodeModulesPath as w,log as n,getGlobalDirPath as u}from"../index.js";async function E(s,e={}){const r=a.join(u(),"templates"),t=e.delete||e.d,o=e.update||e.u;if(t)return await m(r,t);if(e.list||e.l)return await l();if(o!==void 0)return typeof o=="string"&&o.trim()?await p(r,o.trim()):await f(r);await y(r,s)}async function p(s,e){const r=a.resolve(process.cwd()),t=a.join(s,e);if(!await i.pathExists(t))throw new Error(`Template '${e}' not found in ~/.minimaz/templates`);if(!(await c(`Update template '${e}' with current directory? [y/n]:`,"y")).startsWith("y")){n("info","Update cancelled.");return}try{await i.copy(r,t,{overwrite:!0}),n("success",`Template '${e}' updated from current directory.`)}catch{throw new Error(`Failed to update '${e}'`)}}async function f(s){const e=a.join(w(),"src","templates");if(!await i.pathExists(e))throw new Error("'node_modules/minimaz/src/templates' not found.");const r=await i.readdir(e);if(!(await c("Update local templates overwriting them with defaults? [y/n]:","y")).startsWith("y")){n("info","Update cancelled.");return}try{for(const t of r){const o=a.join(e,t),d=a.join(s,t);await i.copy(o,d,{overwrite:!0}),n("success",`Updated '${t}'`)}n("info","\u2728 All templates and files updated successfully.")}catch(t){throw new Error(`Update failed: ${t.message}`)}}async function m(s,e){if(!e)throw new Error("No template name specified to delete.");const r=a.join(s,e);if(!await i.pathExists(r))throw new Error(`Template not found: ${e}`);if(!(await c(`Confirm delete '${e}'? [y/n]:`,"y")).startsWith("y")){n("info","Delete cancelled.");return}try{await i.remove(r),n("success",`Template '${e}' deleted.`)}catch(t){throw new Error(`Delete error: ${t.message}`)}}async function y(s,e){let r=e?a.resolve(process.cwd(),e):process.cwd();if(!await i.pathExists(r))if(n("warn",`Path not found: ${r}`),(await c("Use current directory instead? [y/n]:","y")).startsWith("y"))r=process.cwd();else throw new Error("Operation cancelled.");try{await i.ensureDir(s);const t=a.join(s,a.basename(r));if(await i.pathExists(t)&&!(await c(`Template '${a.basename(t)}' already exists. Overwrite? [y/n]:`,"n")).startsWith("y")){n("info","Save cancelled.");return}await i.copy(r,t,{overwrite:!0}),n("success",`Template saved to ${t}`)}catch(t){throw new Error(`Failed to save template: ${t.message}`)}}export{E as template};
@@ -1 +1 @@
1
- import e from"path";import s from"fs-extra";import{log as n}from"../utils/logService.js";async function c(){try{const o=e.resolve(process.cwd(),"package.json"),{version:r}=await s.readJson(o);if(typeof r!="string")throw new Error("Invalid or missing version in package.json");console.log(r)}catch(o){n("error",`Unable to read package.json: ${o}`),process.exit(1)}}export{c as version};
1
+ import i from"path";import n from"fs-extra";import{log as s}from"../index.js";async function p(){const r=i.resolve(process.cwd(),"package.json"),{version:o}=await n.readJson(r);if(typeof o!="string")throw new Error("Invalid or missing version in package.json");s("info",o)}export{p as version};
package/src/index.js ADDED
@@ -0,0 +1 @@
1
+ import{build as e}from"./commands/build.js";import{init as p}from"./commands/init.js";import{help as f}from"./commands/help.js";import{template as l}from"./commands/template.js";import{clear as a}from"./commands/clear.js";import{version as b}from"./commands/version.js";export*from"./utils/types.js";export*from"./utils/functions.js";export*from"./utils/constants.js";import{log as s}from"./utils/logService.js";export{e as build,a as clear,f as help,p as init,s as log,l as template,b as version};
@@ -0,0 +1,3 @@
1
+ const e={version:"0.0.1",license:"ISC",type:"commonjs",scripts:{build:"mz b",start:"npx mz b && npx serve dist/"},devDependencies:{"minimaz-cli":"latest",serve:"latest"}},t=`dist
2
+ .vscode
3
+ node_modules`,i={src:"src",dist:"dist",public:"public",bundling:{css:!0,js:!0},minify:{html:!0,css:!0,js:!0},replace:{"../public/":"public/"},styles:["style.css","style-2.css"],scripts:["script.js","script-2.js"],folders:{src:"",public:"public"}},s={init:{usage:"minimaz init | i <project-name>",description:'Create a new project (default: "minimaz-site")',options:{"--template | -t <template-name>":'Use a global template (default: "default")'}},build:{usage:"minimaz build | b",description:"Build and minify files into the dist folder"},template:{usage:"minimaz template | t [path]",description:"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"}},help:{usage:"minimaz help | h",description:"Show this help message"},clear:{usage:"minimaz clear | c",description:"Clear the dist folder"},version:{usage:"minimaz version | v",description:"Show Minimaz version"}};export{s as commands,t as gitIgnoreTemplate,i as minimazConfigTemplate,e as pkgTemplate};
@@ -1 +1,4 @@
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};
1
+ import m from"readline";import s from"fs-extra";import a from"path";import d from"os";import{execSync as w,spawn as h}from"child_process";import{log as r,minimazConfigTemplate as y}from"../index.js";function T(i){const t={_:[]};for(let e=0;e<i.length;e++){const n=i[e].toLowerCase();if(!n.startsWith("-")){t._.push(n);continue}if(n.startsWith("--")&&n.includes("=")){const[c,u]=n.slice(2).split("=");t[c]=u;continue}const o=n.replace(/^-+/,""),l=i[e+1];l&&!l.startsWith("-")?(t[o]=l,e++):t[o]=!0}return t}function S(i,t=""){return new Promise(e=>{const n=m.createInterface({input:process.stdin,output:process.stdout}),o=setTimeout(()=>{n.close(),e(t)},6e4);n.question(`\u2753 ${i} `,l=>{clearTimeout(o),n.close(),e(l.trim()||t)}),n.on("SIGINT",()=>{clearTimeout(o),n.close(),process.exit(130)})})}async function A(){const i=a.join(f(),"templates");if(!await s.pathExists(i)){r("info","No templates directory found.");return}const t=await s.readdir(i);if(t.length===0){r("info","No global templates available.");return}r("info","Available global templates:"),t.forEach(e=>r("info",`- ${e}`))}function x(i,t={}){return Object.entries(t).reduce((e,[n,o])=>{const l=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=new RegExp(l,"gi");return e.replace(c,o)},i)}async function D(i,t){try{let e=await s.readFile(i,"utf8");return t&&(e=x(e,t)),e}catch(e){return r("error",`Failed to read file ${i}: ${e.message}`),""}}function p(){try{const i=w("npm config get prefix",{encoding:"utf8"}).trim();if(!i)throw new Error("Empty npm prefix");return process.platform==="win32"?a.join(i,"node_modules","minimaz-cli"):a.join(i,"lib","node_modules","minimaz-cli")}catch{return process.platform==="win32"?a.join(process.env.APPDATA||"","npm","node_modules","minimaz-cli"):"/usr/local/lib/node_modules/minimaz-cli"}}function f(){return a.join(d.homedir(),".minimaz")}async function F(){const i=f(),t=a.join(i,"templates"),e=a.join(p(),"src","templates"),n=a.join(i,"settings.json");try{await s.ensureDir(i),await s.pathExists(n)||(await s.outputJson(n,{createdAt:new Date().toISOString(),templatesPath:t,npmGlobalPath:p()},{spaces:2}),r("success",`Created settings.json at ${n}`));const o=await s.pathExists(t),l=o?(await s.readdir(t)).length===0:!0;if(o||(await s.ensureDir(t),r("success","Created global templates directory.")),!l){r("info","Global templates directory not empty. Skipping copy.");return}for(const c of await s.readdir(e))await s.copy(a.join(e,c),a.join(t,c)),r("success",`Copied template '${c}'.`);r("success","Default templates setup completed.")}catch(o){throw r("error",`Failed to create global templates directory: ${o.message}`),o}}function g(i,t,e){return new Promise((n,o)=>{r("info",`Running: ${i} ${t.join(" ")}`);const l=h(i,t,{cwd:e,stdio:"inherit",shell:!0});l.on("error",c=>{r("error",`Failed to run command: ${c}`),o(c)}),l.on("close",c=>{c===0?n():o(new Error(`${i} exited with code ${c}`))})})}async function _(i,t){const e=typeof i=="string"?i.endsWith(`
2
+ `)?i:i+`
3
+ `:JSON.stringify(i,null,2)+`
4
+ `;try{await s.outputFile(t,e)}catch(n){throw new Error(`Failed to create file at '${t}': ${n.message}`)}}async function I(i,t,e,n="origin"){if(r("info","Initializing Git repository..."),await g("git",["init"],t),e){await b(i,t,e,n),r("success","Git repository initialized.");return}throw new Error("Git remote configuration is invalid.")}async function b(i,t,e,n="origin"){if(console.log(e,n,i,t),/^https?:\/\//.test(e)||e.startsWith("git@")){r("info",`Connecting existing remote '${e}'`),await g("git",["remote","add",n,e],t);return}if(e==="github"){r("info",`Creating GitHub repository '${i}'`),await g("gh",["repo","create",i,"--private","--source=.","--remote",n],t);return}if(e==="gitlab"){r("info",`Creating GitLab repository '${i}'`);const o=process.env.GITLAB_USER;if(!o)throw new Error("GITLAB_USER environment variable not set");await g("glab",["repo","create",i,"--source=."],t),await g("git",["remote","add",n,`git@gitlab.com:${o}/${i}.git`],t);return}throw new Error(`Unsupported git provider or remote: '${e}'`)}async function k(i){const t=i?a.isAbsolute(i)?i:a.resolve(process.cwd(),i):a.resolve(process.cwd(),(await $()).dist??"dist"),e=process.cwd();if(t===e||t.length<=e.length)throw new Error(`Refusing to delete unsafe directory: ${t}`);if(!await s.pathExists(t)){r("info",`No dist folder found: ${t}`);return}await s.remove(t),r("success",`Cleared ${t}`)}async function $(){const i=a.resolve(process.cwd(),"minimaz.config.json");let t;return await s.pathExists(i)?(t=await s.readJson(i),r("info","Loaded config from minimaz.config.json")):(t=JSON.parse(JSON.stringify(y)),r("warn","No minimaz.config.json found. Using default config")),t}export{x as applyReplacements,S as askQuestion,_ as createFileFromTemplate,F as createGlobalDir,g as executeCommand,D as getFile,f as getGlobalDirPath,p as getGlobalNodeModulesPath,I as initGit,A as listTemplates,$ as loadConfig,T as parseArgs,k as removeDistDir};
@@ -1 +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};
1
+ function c(o="log",n){const r={error:"\u274C",warn:"\u26A0\uFE0F",success:"\u2705",info:"\u2139\uFE0F",log:"\u{1F4C1}"};switch(o){case"error":console.error(r[o]," ",n);break;case"warn":console.warn(r[o]," ",n);break;default:console.log(r[o]||r.log," ",n);break}}export{c as log};
@@ -1 +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();
1
+ import{createGlobalDir as s,log as e}from"../index.js";async function a(){try{await s(),e("success","Postinstall: Global templates setup completed.")}catch(t){e("error",`Postinstall setup failed: ${t.message}`)}}a();
File without changes
@@ -1,26 +0,0 @@
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
- }
@@ -1,2 +0,0 @@
1
- dist
2
- .vscode
@@ -1,26 +0,0 @@
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
- }
@@ -1 +0,0 @@
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,ts:!0},replace:{"../public/":"public/"},folders:{src:"",public:"public"}};function e(r,n){const o={...r};for(const i in n)n[i]&&typeof n[i]=="object"&&!Array.isArray(n[i])?o[i]=e(r[i]||{},n[i]):n[i]!==void 0&&(o[i]=n[i]);return o}async function m(){const r=s.resolve(process.cwd(),"minimaz.config.json");let n={};if(await t.pathExists(r))try{n=await t.readJson(r),a("info","Loaded config from minimaz.config.json")}catch(i){throw new Error(`Failed to parse minimaz.config.json: ${i.message}`)}else a("info","No minimaz.config.json found. Using default config");const o=e(f,n);if(!o.src||!o.dist)throw new Error("Invalid configuration: src and dist are required");return o}export{m as loadConfig};