create-make 0.6.2 → 0.7.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/LICENSE +1 -1
- package/README.md +215 -16
- package/dist/index.cjs +7 -3
- package/dist/index.js +8 -4
- package/package.json +59 -22
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2026 Zero Red<github.com/zero-red-dev>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,48 +1,188 @@
|
|
|
1
1
|
# create-make
|
|
2
|
-
|
|
2
|
+
[](https://www.npmjs.com/package/create-make) [](https://www.npmjs.com/package/create-make)
|
|
3
|
+
An advanced CLI tool for creating projects from GitHub repositories or custom templates with lightning-fast setup.
|
|
3
4
|
|
|
4
|
-
##
|
|
5
|
-
|
|
5
|
+
## ✨ Features
|
|
6
|
+
- ⚡ Blazing Fast: Clone templates directly from GitHub or local configs
|
|
6
7
|
|
|
8
|
+
- 🎯 Interactive TUI: Beautiful terminal interface for guided project setup
|
|
9
|
+
|
|
10
|
+
- 🔧 Custom Templates: Extend with your own templates via config file
|
|
11
|
+
|
|
12
|
+
- 🚀 Quick Mode: Skip prompts with direct CLI arguments
|
|
13
|
+
|
|
14
|
+
- 📁 Multi-Platform: Works on Windows, macOS, and Linux
|
|
15
|
+
|
|
16
|
+
- 🏗️ Template Variables: Automatic project name replacement in templates
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## 📦 Installation
|
|
20
|
+
### Quick Use (No Installation Required)
|
|
21
|
+
yarn
|
|
22
|
+
```bash
|
|
23
|
+
yarn create make
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
npx
|
|
7
27
|
```bash
|
|
8
28
|
npx create-make
|
|
9
29
|
```
|
|
10
|
-
|
|
30
|
+
|
|
31
|
+
### Global Installation
|
|
32
|
+
yarn
|
|
33
|
+
```bash
|
|
34
|
+
yarn global add create-make
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
npm
|
|
38
|
+
```bash
|
|
39
|
+
npm install -g create-make
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## 🚀 Quick Start
|
|
44
|
+
### Interactive Mode (Guided Setup)
|
|
45
|
+
Simply run:
|
|
11
46
|
```bash
|
|
12
47
|
yarn create make
|
|
13
48
|
```
|
|
14
49
|
|
|
50
|
+
You'll be guided through:
|
|
51
|
+
|
|
52
|
+
1. Project name (if not provided)
|
|
53
|
+
|
|
54
|
+
2. Category selection (Built-in types or custom)
|
|
55
|
+
|
|
56
|
+
3. Template selection from the chosen category
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
### Quick Mode (Skip Prompts)
|
|
60
|
+
Create a project with a built-in template:
|
|
61
|
+
```bash
|
|
62
|
+
yarn create make my-project --template vite-vanilla-ts
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Create a project with a custom template:
|
|
66
|
+
```bash
|
|
67
|
+
yarn create make my-project --other-template my-custom-template
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## 📖 CLI Reference
|
|
71
|
+
### Syntax
|
|
72
|
+
```bash
|
|
73
|
+
yarn create make <projectName> [options]
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
#### Arguments
|
|
77
|
+
|
|
78
|
+
| Argument | Required | Description |
|
|
79
|
+
|:--------:|:----:|:---------------:|
|
|
80
|
+
| projectName | Optional* | Name of your new project |
|
|
81
|
+
* Note: When using --template or --other-template, projectName is mandatory
|
|
82
|
+
|
|
83
|
+
#### Options
|
|
84
|
+
| Option | Alias | Description | Value Required |
|
|
85
|
+
|:--------:|:---:|:---------------------:|:----:|
|
|
86
|
+
| --template | -t | Use a built-in template (skips prompts) | Yes |
|
|
87
|
+
| --other-template | -o | Use a custom template from config (skips to custom selection) | Yes |
|
|
88
|
+
| --version | -v | Show version number | No |
|
|
89
|
+
| --help | -h | Show help information | No |
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
#### Examples
|
|
93
|
+
1. Full Interactive Mode
|
|
94
|
+
```bash
|
|
95
|
+
# You'll be prompted for everything
|
|
96
|
+
yarn create make
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
2. Project Name Only
|
|
100
|
+
```bash
|
|
101
|
+
# You'll choose category and template interactively
|
|
102
|
+
yarn create my-awesome-project
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
3. Quick Creation with Built-in Template
|
|
106
|
+
```bash
|
|
107
|
+
# Skips all prompts, creates immediately
|
|
108
|
+
yarn create my-app --template vite-node-ts
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
4. Quick Creation with Custom Template
|
|
112
|
+
```bash
|
|
113
|
+
# Skips to custom template selection
|
|
114
|
+
yarn create make my-project --other-template my-own-custom-template
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
5. Show Help
|
|
118
|
+
```bash
|
|
119
|
+
yarn create make --help
|
|
120
|
+
```
|
|
121
|
+
|
|
15
122
|
|
|
16
|
-
|
|
123
|
+
#### 🎯 Available Templates
|
|
124
|
+
Built-in Templates (TypeScript Category)
|
|
125
|
+
|
|
126
|
+
| Template | Description | Tech Stack |
|
|
127
|
+
|:--------:|:-----------------:|:----:|
|
|
128
|
+
| vite-vanilla-ts | Vanilla TypeScript with Vite | Vite + TypeScript |
|
|
129
|
+
| vite-phaser-ts | Game development with Phaser | Vite + Phaser + TypeScript |
|
|
130
|
+
| vite-node-ts | Node.js backend with Vite | Vite + Node.js + TypeScript |
|
|
131
|
+
| rollup-node-ts | Node.js with Rollup | Rollup + Node.js + TypeScript |
|
|
132
|
+
| vite-monorepo-ts | Monorepo setup with Vite | Vite + Monorepo + TypeScript |
|
|
133
|
+
| rollup-monorepo-ts | Monorepo setup with Rollup | Rollup + Monorepo + TypeScript |
|
|
134
|
+
|
|
135
|
+
__Pro Tip__: Create an alias for even faster usage! Add this to your shell config:
|
|
136
|
+
```bash
|
|
137
|
+
alias ym="yarn make"
|
|
138
|
+
```
|
|
139
|
+
Then use:
|
|
140
|
+
```bash
|
|
141
|
+
ym my-project -t vite-node-ts
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## ⚙️ Configuration
|
|
145
|
+
### Custom Templates
|
|
146
|
+
Add your own templates via configuration file. Custom templates appear in the "Others" category during interactive selection.
|
|
17
147
|
|
|
18
148
|
Linux:
|
|
19
149
|
```bash
|
|
20
|
-
/home
|
|
150
|
+
/home/[USER]/.local/share/create-make/config.json
|
|
21
151
|
```
|
|
22
152
|
|
|
23
153
|
MacOS:
|
|
24
154
|
```bash
|
|
25
|
-
/Users
|
|
155
|
+
/Users/[USER]/Library/Preferences/create-make/config.json
|
|
26
156
|
```
|
|
27
157
|
|
|
28
158
|
Windows:
|
|
29
159
|
```bash
|
|
30
|
-
C:\Users
|
|
160
|
+
C:\Users\[USER]\AppData\Roaming\create-make\config.json
|
|
31
161
|
```
|
|
32
162
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
163
|
+
#### Config File Format
|
|
164
|
+
Create a __config.json__ file to add your custom templates:
|
|
36
165
|
```json
|
|
37
166
|
{
|
|
38
167
|
"$schema": "./schema.json",
|
|
39
168
|
"categories": {
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"repo": "git
|
|
169
|
+
"Backend": {
|
|
170
|
+
"express-api": {
|
|
171
|
+
"repo": "https://github.com/username/express-template.git",
|
|
43
172
|
"args": [
|
|
44
173
|
{
|
|
45
|
-
"str": "
|
|
174
|
+
"str": "PROJECT_NAME",
|
|
175
|
+
"value": "projectName"
|
|
176
|
+
}
|
|
177
|
+
]
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
"Frontend": {
|
|
181
|
+
"react-ts": {
|
|
182
|
+
"repo": "https://github.com/username/react-typescript-template.git",
|
|
183
|
+
"args": [
|
|
184
|
+
{
|
|
185
|
+
"str": "APP_NAME",
|
|
46
186
|
"value": "projectName"
|
|
47
187
|
}
|
|
48
188
|
]
|
|
@@ -52,4 +192,63 @@ Example of a config.json to use with your own custom template repo for creating
|
|
|
52
192
|
}
|
|
53
193
|
```
|
|
54
194
|
|
|
55
|
-
|
|
195
|
+
#### Configuration Schema
|
|
196
|
+
|
|
197
|
+
| Property | Type | Description |
|
|
198
|
+
|:--------:|:-----------------:|:----:|
|
|
199
|
+
| repo | string | Git repository URL to clone |
|
|
200
|
+
| args | array | String replacements in template files |
|
|
201
|
+
| args[].str | string | Text in template files to replace |
|
|
202
|
+
| args[].value | string | Value to replace with (currently only "projectName" supported) |
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
## 🎮 How It Works
|
|
206
|
+
|
|
207
|
+
graph TD
|
|
208
|
+
A[Start] --> B{Project name provided?}
|
|
209
|
+
B -->|No| C[Prompt for project name]
|
|
210
|
+
B -->|Yes| D[Use provided name]
|
|
211
|
+
C --> D
|
|
212
|
+
D --> E{Template option provided?}
|
|
213
|
+
E -->|--template| F[Use built-in template directly]
|
|
214
|
+
E -->|--other-template| G[Use custom template directly]
|
|
215
|
+
E -->|No| H[Show category selection]
|
|
216
|
+
H --> I{Select category}
|
|
217
|
+
I --> J[Built-in Templates]
|
|
218
|
+
I --> K[Others/Custom]
|
|
219
|
+
J --> L[Show built-in templates]
|
|
220
|
+
K --> M[Show custom categories]
|
|
221
|
+
L --> N[Select template]
|
|
222
|
+
M --> N
|
|
223
|
+
N --> O[Create project]
|
|
224
|
+
F --> O
|
|
225
|
+
G --> O
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
## 🐛 Troubleshooting
|
|
229
|
+
### Common Issues
|
|
230
|
+
#### Q: "Template not found" error
|
|
231
|
+
A: Ensure the template name is spelled correctly. Built-in templates are listed above. For custom templates, check your config.json.
|
|
232
|
+
|
|
233
|
+
#### Q: "Project name is required" error when using --template
|
|
234
|
+
A: When using --template or --other-template, you must provide the project name as the first argument.
|
|
235
|
+
|
|
236
|
+
#### Q: Custom templates not appearing
|
|
237
|
+
A: Verify your config.json file is in the correct location and contains valid JSON syntax.
|
|
238
|
+
|
|
239
|
+
#### Q: Tool won't run
|
|
240
|
+
A: Ensure you have Node.js 18+ installed. Check with node --version.
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
## 🤝 Contributing
|
|
244
|
+
### Adding New Built-in Templates
|
|
245
|
+
1. Fork the repository
|
|
246
|
+
|
|
247
|
+
2. Add your template to the templates directory
|
|
248
|
+
|
|
249
|
+
3. Update the template list in the code
|
|
250
|
+
|
|
251
|
+
4. Submit a pull request
|
|
252
|
+
|
|
253
|
+
## Reporting Issues
|
|
254
|
+
Found a bug or have a feature request? Please open an issue on [GitHub](https://github.com/z-npm/create-make/issues).
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const yargs = require('yargs');
|
|
4
|
+
const helpers = require('yargs/helpers');
|
|
3
5
|
const node_fs = require('node:fs');
|
|
4
6
|
const node_child_process = require('node:child_process');
|
|
5
7
|
const node_path = require('node:path');
|
|
@@ -7,12 +9,14 @@ const inquirer = require('inquirer');
|
|
|
7
9
|
|
|
8
10
|
var OS_NAME=process.platform;var OS_APP_HOME=process.env.APPDATA||(OS_NAME=="darwin"?process.env.HOME+"/Library/Preferences":process.env.HOME+"/.local/share");var APP_PATH="".concat(OS_APP_HOME,"/create-make");var CONFIG_PATH="".concat(APP_PATH,"/config.json");var DEFAULT_CATEGORIES={TypeScript:{Vanilla:{repo:"https://github.com/z-starter/vite-vanilla-ts.git",args:[{str:"vite-vanilla-ts",value:"projectName"}]},Phaser:{repo:"https://github.com/z-starter/vite-phaser-ts.git",args:[{str:"vite-phaser-ts",value:"projectName"}]},"Vite Node":{repo:"https://github.com/z-starter/vite-node-ts.git",args:[{str:"vite-node-ts",value:"projectName"}]},"Rollup Node":{repo:"https://github.com/z-starter/rollup-node-ts.git",args:[{str:"rollup-node-ts",value:"projectName"}]},"Vite Monorepo":{repo:"https://github.com/z-starter/vite-monorepo-ts.git",args:[{str:"vite-monorepo-ts",value:"projectName"}]},"Rollup Monorepo":{repo:"https://github.com/z-starter/rollup-monorepo-ts.git",args:[{str:"rollup-monorepo-ts",value:"projectName"}]}}};var SCHEMA_PATH="".concat(APP_PATH,"/schema.json");var DEFAULT_SCHEMA={$schema:"https://json-schema.org/draft-07/schema",$id:"https://example.com/product.schema.json",title:"Create Make",description:"An advance CLI tools for creating new project from GitHub repository.",type:"object",properties:{categories:{type:"object",additionalProperties:{type:"object",additionalProperties:{type:"object",properties:{repo:{type:"string",default:"repoUrl"},args:{type:"array",items:{type:"object",properties:{str:{type:"string",default:"contentToReplace"},value:{type:"string",default:"projectName"}}}}}}}}}};
|
|
9
11
|
|
|
10
|
-
function
|
|
12
|
+
function asyncGeneratorStep$2(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return}if(info.done){resolve(value);}else {Promise.resolve(value).then(_next,_throw);}}function _async_to_generator$2(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep$2(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep$2(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);})}}function _ts_generator$2(thisArg,body){var f,y,t,_={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},g=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return g.next=verb(0),g["throw"]=verb(1),g["return"]=verb(2),typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return {value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_);}catch(e){op=[6,e];y=0;}finally{f=t=0;}if(op[0]&5)throw op[1];return {value:op[0]?op[1]:void 0,done:true}}}var getCli=function(){return _async_to_generator$2(function(){var yargsInstance,argv,projectName,template,otherTemplate;return _ts_generator$2(this,function(_state){switch(_state.label){case 0:yargsInstance=yargs(helpers.hideBin(process.argv)).scriptName("create-make").usage("Usage: $0 [projectName] [options]").epilogue("\n\uD83D\uDCE6 Create projects in seconds with built-in or custom templates!\n\nQuick Start:\n • Interactive mode: $0 (Guided setup)\n • Built-in template: $0 my-app -t vite-vanilla-ts (Skip prompts)\n • Custom template: $0 my-project -o express-api (Use custom config)\n\n\uD83D\uDCA1 Tips:\n • When using --template or --other-template, projectName is required\n • Omit projectName to be prompted for it\n • Add custom templates via config file at ".concat(CONFIG_PATH,"\n\nFor more information, visit: https://github.com/z-npm/create-make\n")).example("$0","Start interactive mode - guided project setup").example("$0 my-project","Set project name, then choose template interactively").example("$0 my-app --template vite-vanilla-ts","Create Vite web project (skips prompts)").example("$0 my-api -t vite-node-ts","Create Vite Node project (alias, skips prompts)").example("$0 my-project --other-template my-backend","Use custom template from config").example("$0 my-site -o react-starter","Use custom template (alias)").option("template",{alias:"t",type:"string",describe:"Use built-in template (skips category/template selection)",requiresArg:true,conflicts:"other-template"}).option("other-template",{alias:"o",type:"string",describe:"Use custom template from config (skips to custom template selection)",requiresArg:true,conflicts:"template"}).option("help",{alias:"h",type:"boolean",describe:"Show help information"}).check(function(argv){if((argv.template||argv["other-template"])&&!argv._[0]){throw new Error("Project name is required when using --template or --other-template")}return true}).help("help","Show this help message").alias("help","h").version().alias("v","version").demandCommand(0,1,"Provide at most one project name").strict();return [4,yargsInstance.parseAsync()];case 1:argv=_state.sent();projectName=argv._[0];template=argv.template;otherTemplate=argv.otherTemplate;if((template||otherTemplate)&&!projectName){console.error("❌ Error: Project name is required");console.error("\uD83D\uDCD6 Usage: create-make <project-name>");console.error("\uD83D\uDCA1 Example: create-make my-project");process.exit(2);}return [2,{projectName:projectName,template:template,otherTemplate:otherTemplate}]}})})()};
|
|
13
|
+
|
|
14
|
+
function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _array_without_holes(arr){if(Array.isArray(arr))return _array_like_to_array(arr)}function _iterable_to_array(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter)}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _to_consumable_array(arr){return _array_without_holes(arr)||_iterable_to_array(arr)||_unsupported_iterable_to_array(arr)||_non_iterable_spread()}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o==="string")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}var mkdir=function(path){return node_fs.mkdirSync(path,{recursive:true})};var rmRF=function(path){return node_fs.rmSync(path,{recursive:true,force:true})};var pathExists=function(path){return node_fs.existsSync(path)};var readFile=function(path){return node_fs.readFileSync(path,{encoding:"utf8"})};var writeFile=function(path,data){return node_fs.writeFileSync(path,data,{encoding:"utf8"})};var cmd=function(command){var path=arguments.length>1&&arguments[1]!==void 0?arguments[1]:process.cwd();return node_child_process.execSync(command,{stdio:[0,1,2],cwd:path})};var gitClone=function(repo,projectName){return cmd("git clone --depth=1 ".concat(repo," ").concat(projectName))};var findFile=function(dir,fileName){var exclude=arguments.length>2&&arguments[2]!==void 0?arguments[2]:["node_modules",".git"];var finds=[];node_fs.readdirSync(dir).forEach(function(file){var filePath=node_path.join(dir,file);if(!exclude.includes(filePath)){var fileStat=node_fs.statSync(filePath);if(fileStat.isDirectory())finds=_to_consumable_array(finds).concat(_to_consumable_array(findFile(filePath,fileName)));else finds.push(filePath);}});return finds};var filesChangeContent=function(path,oldContent,newContent){findFile(path,true).map(function(item){var content=node_fs.readFileSync(item,{encoding:"utf-8"});if(new RegExp("\\b"+oldContent+"\\b").test(content)){node_fs.writeFileSync(item,content.replaceAll(oldContent,newContent),{encoding:"utf-8"});}});};
|
|
11
15
|
|
|
12
16
|
function _define_property$1(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else {obj[key]=value;}return obj}function _object_spread$1(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}));}ownKeys.forEach(function(key){_define_property$1(target,key,source[key]);});}return target}function ownKeys$1(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);keys.push.apply(keys,symbols);}return keys}function _object_spread_props$1(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source));}else {ownKeys$1(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target}var getConfig=function(){var needInit=false;var config={$schema:"./schema.json",categories:{}};if(pathExists(CONFIG_PATH))config=JSON.parse(readFile(CONFIG_PATH));else needInit=true;if(needInit){mkdir(APP_PATH);writeFile(SCHEMA_PATH,JSON.stringify(DEFAULT_SCHEMA,null,2));writeFile(CONFIG_PATH,JSON.stringify(config,null,2));}return _object_spread_props$1(_object_spread$1({},config),{needInit:needInit,defaultCategories:DEFAULT_CATEGORIES})};
|
|
13
17
|
|
|
14
|
-
function asyncGeneratorStep$1(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return}if(info.done){resolve(value);}else {Promise.resolve(value).then(_next,_throw);}}function _async_to_generator$1(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep$1(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep$1(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);})}}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else {obj[key]=value;}return obj}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}));}ownKeys.forEach(function(key){_define_property(target,key,source[key]);});}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);keys.push.apply(keys,symbols);}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source));}else {ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target}function _ts_generator$1(thisArg,body){var f,y,t,
|
|
18
|
+
function asyncGeneratorStep$1(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return}if(info.done){resolve(value);}else {Promise.resolve(value).then(_next,_throw);}}function _async_to_generator$1(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep$1(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep$1(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);})}}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else {obj[key]=value;}return obj}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}));}ownKeys.forEach(function(key){_define_property(target,key,source[key]);});}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);keys.push.apply(keys,symbols);}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source));}else {ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target}function _ts_generator$1(thisArg,body){var f,y,t,_={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},g=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return g.next=verb(0),g["throw"]=verb(1),g["return"]=verb(2),typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return {value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_);}catch(e){op=[6,e];y=0;}finally{f=t=0;}if(op[0]&5)throw op[1];return {value:op[0]?op[1]:void 0,done:true}}}var projectPrompt=function(cli,config){return _async_to_generator$1(function(){var dcArr,tStrArr,args,repo,ucArr,tStrArr1,args1,repo1,prompt1,defaultCategories,userDefineCategories,_answers1,answers1,_projectName,isUserDefineCategories,templates,answers2,repo2,args2,error;return _ts_generator$1(this,function(_state){switch(_state.label){case 0:if(cli.projectName&&cli.template){dcArr=config.defaultCategories;tStrArr=[];for(var category in dcArr){for(var template in dcArr[category]){args=dcArr[category][template].args;repo=dcArr[category][template].repo;tStrArr.push(args[0].str);if(args[0].str===cli.template)return [2,{category:category,template:template,projectName:cli.projectName,args:args,repo:repo}]}}console.error('❌ Error: Template "'.concat(cli.template,'" was not found.\n')+"Available templates:\n"+" • ".concat(tStrArr.join("\n • "),"\n")+"Please select one of the templates above.");process.exit(2);}if(cli.projectName&&cli.otherTemplate){ucArr=config.categories;tStrArr1=[];for(var category1 in ucArr){for(var template1 in ucArr[category1]){args1=ucArr[category1][template1].args;repo1=ucArr[category1][template1].repo;tStrArr1.push(args1[0].str);if(args1[0].str===cli.otherTemplate)return [2,{category:category1,template:template1,projectName:cli.projectName,args:args1,repo:repo1}]}}console.error('❌ Error: Template "'.concat(cli.otherTemplate,'" was not found.\n')+"Available templates:\n"+" • ".concat(tStrArr1.join("\n • "),"\n")+"Please select one of the templates above.");process.exit(2);}prompt1=[];defaultCategories=Object.keys(config.defaultCategories);userDefineCategories=Object.keys(config.categories);if(userDefineCategories.length>0)defaultCategories.push("Others");if(!cli.projectName)prompt1.push({type:"input",name:"projectName",message:"Project name:",default:"my-project"});prompt1.push({type:"select",name:"category",message:"Select a category:",choices:defaultCategories});_state.label=1;case 1:_state.trys.push([1,6,,7]);return [4,inquirer.prompt(prompt1)];case 2:answers1=_state.sent();(_projectName=(_answers1=answers1).projectName)!==null&&_projectName!==void 0?_projectName:_answers1.projectName=cli.projectName;isUserDefineCategories=answers1.category==="Others";if(!isUserDefineCategories)return [3,4];return [4,inquirer.prompt([{type:"select",name:"category",message:"Select a category:",choices:userDefineCategories}])];case 3:answers1.category=_state.sent().category;_state.label=4;case 4:templates=isUserDefineCategories?Object.keys(config.categories[answers1.category]):Object.keys(config.defaultCategories[answers1.category]);return [4,inquirer.prompt([{type:"select",name:"template",message:"Select a template:",choices:templates}])];case 5:answers2=_state.sent();repo2=isUserDefineCategories?config.categories[answers1.category][answers2.template].repo:config.defaultCategories[answers1.category][answers2.template].repo;args2=isUserDefineCategories?config.categories[answers1.category][answers2.template].args:config.defaultCategories[answers1.category][answers2.template].args;return [2,_object_spread_props(_object_spread({},answers1,answers2),{repo:repo2,args:args2})];case 6:error=_state.sent();if(error.name==="ExitPromptError"){console.log("\nProcess interrupted. Exiting gracefully.");process.exit(0);}else {throw error}return [3,7];case 7:return [2]}})})()};
|
|
15
19
|
|
|
16
|
-
function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return}if(info.done){resolve(value);}else {Promise.resolve(value).then(_next,_throw);}}function _async_to_generator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);})}}function _ts_generator(thisArg,body){var f,y,t,
|
|
20
|
+
function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return}if(info.done){resolve(value);}else {Promise.resolve(value).then(_next,_throw);}}function _async_to_generator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);})}}function _ts_generator(thisArg,body){var f,y,t,_={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},g=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return g.next=verb(0),g["throw"]=verb(1),g["return"]=verb(2),typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return {value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_);}catch(e){op=[6,e];y=0;}finally{f=t=0;}if(op[0]&5)throw op[1];return {value:op[0]?op[1]:void 0,done:true}}}var boot=function(){return _async_to_generator(function(){var config,cli,answer,PROJECT_PATH,PROJECT_GIT_PATH;return _ts_generator(this,function(_state){switch(_state.label){case 0:console.log();config=getConfig();return [4,getCli()];case 1:cli=_state.sent();return [4,projectPrompt(cli,config)];case 2:answer=_state.sent();PROJECT_PATH="".concat(process.cwd(),"/").concat(answer.projectName);PROJECT_GIT_PATH="".concat(PROJECT_PATH,"/.git");if(pathExists(PROJECT_PATH)){console.error('❌ Error: Cannot create project "'.concat(answer.projectName,'".\n')+"A directory with this name already exists.\n"+"Please choose a different name or delete the existing folder.");process.exit(1);}gitClone(answer.repo,answer.projectName);rmRF(PROJECT_GIT_PATH);answer.args.forEach(function(item){var value=item.value==="projectName"?answer.projectName:item.value;filesChangeContent(PROJECT_PATH,item.str,value);});return [2]}})})()};
|
|
17
21
|
|
|
18
22
|
module.exports = boot;
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import yargs from 'yargs';
|
|
2
|
+
import { hideBin } from 'yargs/helpers';
|
|
3
|
+
import { existsSync, rmSync, readFileSync, writeFileSync, readdirSync, statSync, mkdirSync } from 'node:fs';
|
|
2
4
|
import { execSync } from 'node:child_process';
|
|
3
5
|
import { join } from 'node:path';
|
|
4
6
|
import inquirer from 'inquirer';
|
|
5
7
|
|
|
6
8
|
var OS_NAME=process.platform;var OS_APP_HOME=process.env.APPDATA||(OS_NAME=="darwin"?process.env.HOME+"/Library/Preferences":process.env.HOME+"/.local/share");var APP_PATH="".concat(OS_APP_HOME,"/create-make");var CONFIG_PATH="".concat(APP_PATH,"/config.json");var DEFAULT_CATEGORIES={TypeScript:{Vanilla:{repo:"https://github.com/z-starter/vite-vanilla-ts.git",args:[{str:"vite-vanilla-ts",value:"projectName"}]},Phaser:{repo:"https://github.com/z-starter/vite-phaser-ts.git",args:[{str:"vite-phaser-ts",value:"projectName"}]},"Vite Node":{repo:"https://github.com/z-starter/vite-node-ts.git",args:[{str:"vite-node-ts",value:"projectName"}]},"Rollup Node":{repo:"https://github.com/z-starter/rollup-node-ts.git",args:[{str:"rollup-node-ts",value:"projectName"}]},"Vite Monorepo":{repo:"https://github.com/z-starter/vite-monorepo-ts.git",args:[{str:"vite-monorepo-ts",value:"projectName"}]},"Rollup Monorepo":{repo:"https://github.com/z-starter/rollup-monorepo-ts.git",args:[{str:"rollup-monorepo-ts",value:"projectName"}]}}};var SCHEMA_PATH="".concat(APP_PATH,"/schema.json");var DEFAULT_SCHEMA={$schema:"https://json-schema.org/draft-07/schema",$id:"https://example.com/product.schema.json",title:"Create Make",description:"An advance CLI tools for creating new project from GitHub repository.",type:"object",properties:{categories:{type:"object",additionalProperties:{type:"object",additionalProperties:{type:"object",properties:{repo:{type:"string",default:"repoUrl"},args:{type:"array",items:{type:"object",properties:{str:{type:"string",default:"contentToReplace"},value:{type:"string",default:"projectName"}}}}}}}}}};
|
|
7
9
|
|
|
8
|
-
function
|
|
10
|
+
function asyncGeneratorStep$2(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return}if(info.done){resolve(value);}else {Promise.resolve(value).then(_next,_throw);}}function _async_to_generator$2(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep$2(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep$2(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);})}}function _ts_generator$2(thisArg,body){var f,y,t,_={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},g=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return g.next=verb(0),g["throw"]=verb(1),g["return"]=verb(2),typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return {value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_);}catch(e){op=[6,e];y=0;}finally{f=t=0;}if(op[0]&5)throw op[1];return {value:op[0]?op[1]:void 0,done:true}}}var getCli=function(){return _async_to_generator$2(function(){var yargsInstance,argv,projectName,template,otherTemplate;return _ts_generator$2(this,function(_state){switch(_state.label){case 0:yargsInstance=yargs(hideBin(process.argv)).scriptName("create-make").usage("Usage: $0 [projectName] [options]").epilogue("\n\uD83D\uDCE6 Create projects in seconds with built-in or custom templates!\n\nQuick Start:\n • Interactive mode: $0 (Guided setup)\n • Built-in template: $0 my-app -t vite-vanilla-ts (Skip prompts)\n • Custom template: $0 my-project -o express-api (Use custom config)\n\n\uD83D\uDCA1 Tips:\n • When using --template or --other-template, projectName is required\n • Omit projectName to be prompted for it\n • Add custom templates via config file at ".concat(CONFIG_PATH,"\n\nFor more information, visit: https://github.com/z-npm/create-make\n")).example("$0","Start interactive mode - guided project setup").example("$0 my-project","Set project name, then choose template interactively").example("$0 my-app --template vite-vanilla-ts","Create Vite web project (skips prompts)").example("$0 my-api -t vite-node-ts","Create Vite Node project (alias, skips prompts)").example("$0 my-project --other-template my-backend","Use custom template from config").example("$0 my-site -o react-starter","Use custom template (alias)").option("template",{alias:"t",type:"string",describe:"Use built-in template (skips category/template selection)",requiresArg:true,conflicts:"other-template"}).option("other-template",{alias:"o",type:"string",describe:"Use custom template from config (skips to custom template selection)",requiresArg:true,conflicts:"template"}).option("help",{alias:"h",type:"boolean",describe:"Show help information"}).check(function(argv){if((argv.template||argv["other-template"])&&!argv._[0]){throw new Error("Project name is required when using --template or --other-template")}return true}).help("help","Show this help message").alias("help","h").version().alias("v","version").demandCommand(0,1,"Provide at most one project name").strict();return [4,yargsInstance.parseAsync()];case 1:argv=_state.sent();projectName=argv._[0];template=argv.template;otherTemplate=argv.otherTemplate;if((template||otherTemplate)&&!projectName){console.error("❌ Error: Project name is required");console.error("\uD83D\uDCD6 Usage: create-make <project-name>");console.error("\uD83D\uDCA1 Example: create-make my-project");process.exit(2);}return [2,{projectName:projectName,template:template,otherTemplate:otherTemplate}]}})})()};
|
|
11
|
+
|
|
12
|
+
function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _array_without_holes(arr){if(Array.isArray(arr))return _array_like_to_array(arr)}function _iterable_to_array(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter)}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _to_consumable_array(arr){return _array_without_holes(arr)||_iterable_to_array(arr)||_unsupported_iterable_to_array(arr)||_non_iterable_spread()}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o==="string")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}var mkdir=function(path){return mkdirSync(path,{recursive:true})};var rmRF=function(path){return rmSync(path,{recursive:true,force:true})};var pathExists=function(path){return existsSync(path)};var readFile=function(path){return readFileSync(path,{encoding:"utf8"})};var writeFile=function(path,data){return writeFileSync(path,data,{encoding:"utf8"})};var cmd=function(command){var path=arguments.length>1&&arguments[1]!==void 0?arguments[1]:process.cwd();return execSync(command,{stdio:[0,1,2],cwd:path})};var gitClone=function(repo,projectName){return cmd("git clone --depth=1 ".concat(repo," ").concat(projectName))};var findFile=function(dir,fileName){var exclude=arguments.length>2&&arguments[2]!==void 0?arguments[2]:["node_modules",".git"];var finds=[];readdirSync(dir).forEach(function(file){var filePath=join(dir,file);if(!exclude.includes(filePath)){var fileStat=statSync(filePath);if(fileStat.isDirectory())finds=_to_consumable_array(finds).concat(_to_consumable_array(findFile(filePath,fileName)));else finds.push(filePath);}});return finds};var filesChangeContent=function(path,oldContent,newContent){findFile(path,true).map(function(item){var content=readFileSync(item,{encoding:"utf-8"});if(new RegExp("\\b"+oldContent+"\\b").test(content)){writeFileSync(item,content.replaceAll(oldContent,newContent),{encoding:"utf-8"});}});};
|
|
9
13
|
|
|
10
14
|
function _define_property$1(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else {obj[key]=value;}return obj}function _object_spread$1(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}));}ownKeys.forEach(function(key){_define_property$1(target,key,source[key]);});}return target}function ownKeys$1(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);keys.push.apply(keys,symbols);}return keys}function _object_spread_props$1(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source));}else {ownKeys$1(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target}var getConfig=function(){var needInit=false;var config={$schema:"./schema.json",categories:{}};if(pathExists(CONFIG_PATH))config=JSON.parse(readFile(CONFIG_PATH));else needInit=true;if(needInit){mkdir(APP_PATH);writeFile(SCHEMA_PATH,JSON.stringify(DEFAULT_SCHEMA,null,2));writeFile(CONFIG_PATH,JSON.stringify(config,null,2));}return _object_spread_props$1(_object_spread$1({},config),{needInit:needInit,defaultCategories:DEFAULT_CATEGORIES})};
|
|
11
15
|
|
|
12
|
-
function asyncGeneratorStep$1(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return}if(info.done){resolve(value);}else {Promise.resolve(value).then(_next,_throw);}}function _async_to_generator$1(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep$1(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep$1(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);})}}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else {obj[key]=value;}return obj}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}));}ownKeys.forEach(function(key){_define_property(target,key,source[key]);});}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);keys.push.apply(keys,symbols);}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source));}else {ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target}function _ts_generator$1(thisArg,body){var f,y,t,
|
|
16
|
+
function asyncGeneratorStep$1(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return}if(info.done){resolve(value);}else {Promise.resolve(value).then(_next,_throw);}}function _async_to_generator$1(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep$1(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep$1(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);})}}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else {obj[key]=value;}return obj}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}));}ownKeys.forEach(function(key){_define_property(target,key,source[key]);});}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);keys.push.apply(keys,symbols);}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source));}else {ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target}function _ts_generator$1(thisArg,body){var f,y,t,_={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},g=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return g.next=verb(0),g["throw"]=verb(1),g["return"]=verb(2),typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return {value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_);}catch(e){op=[6,e];y=0;}finally{f=t=0;}if(op[0]&5)throw op[1];return {value:op[0]?op[1]:void 0,done:true}}}var projectPrompt=function(cli,config){return _async_to_generator$1(function(){var dcArr,tStrArr,args,repo,ucArr,tStrArr1,args1,repo1,prompt1,defaultCategories,userDefineCategories,_answers1,answers1,_projectName,isUserDefineCategories,templates,answers2,repo2,args2,error;return _ts_generator$1(this,function(_state){switch(_state.label){case 0:if(cli.projectName&&cli.template){dcArr=config.defaultCategories;tStrArr=[];for(var category in dcArr){for(var template in dcArr[category]){args=dcArr[category][template].args;repo=dcArr[category][template].repo;tStrArr.push(args[0].str);if(args[0].str===cli.template)return [2,{category:category,template:template,projectName:cli.projectName,args:args,repo:repo}]}}console.error('❌ Error: Template "'.concat(cli.template,'" was not found.\n')+"Available templates:\n"+" • ".concat(tStrArr.join("\n • "),"\n")+"Please select one of the templates above.");process.exit(2);}if(cli.projectName&&cli.otherTemplate){ucArr=config.categories;tStrArr1=[];for(var category1 in ucArr){for(var template1 in ucArr[category1]){args1=ucArr[category1][template1].args;repo1=ucArr[category1][template1].repo;tStrArr1.push(args1[0].str);if(args1[0].str===cli.otherTemplate)return [2,{category:category1,template:template1,projectName:cli.projectName,args:args1,repo:repo1}]}}console.error('❌ Error: Template "'.concat(cli.otherTemplate,'" was not found.\n')+"Available templates:\n"+" • ".concat(tStrArr1.join("\n • "),"\n")+"Please select one of the templates above.");process.exit(2);}prompt1=[];defaultCategories=Object.keys(config.defaultCategories);userDefineCategories=Object.keys(config.categories);if(userDefineCategories.length>0)defaultCategories.push("Others");if(!cli.projectName)prompt1.push({type:"input",name:"projectName",message:"Project name:",default:"my-project"});prompt1.push({type:"select",name:"category",message:"Select a category:",choices:defaultCategories});_state.label=1;case 1:_state.trys.push([1,6,,7]);return [4,inquirer.prompt(prompt1)];case 2:answers1=_state.sent();(_projectName=(_answers1=answers1).projectName)!==null&&_projectName!==void 0?_projectName:_answers1.projectName=cli.projectName;isUserDefineCategories=answers1.category==="Others";if(!isUserDefineCategories)return [3,4];return [4,inquirer.prompt([{type:"select",name:"category",message:"Select a category:",choices:userDefineCategories}])];case 3:answers1.category=_state.sent().category;_state.label=4;case 4:templates=isUserDefineCategories?Object.keys(config.categories[answers1.category]):Object.keys(config.defaultCategories[answers1.category]);return [4,inquirer.prompt([{type:"select",name:"template",message:"Select a template:",choices:templates}])];case 5:answers2=_state.sent();repo2=isUserDefineCategories?config.categories[answers1.category][answers2.template].repo:config.defaultCategories[answers1.category][answers2.template].repo;args2=isUserDefineCategories?config.categories[answers1.category][answers2.template].args:config.defaultCategories[answers1.category][answers2.template].args;return [2,_object_spread_props(_object_spread({},answers1,answers2),{repo:repo2,args:args2})];case 6:error=_state.sent();if(error.name==="ExitPromptError"){console.log("\nProcess interrupted. Exiting gracefully.");process.exit(0);}else {throw error}return [3,7];case 7:return [2]}})})()};
|
|
13
17
|
|
|
14
|
-
function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return}if(info.done){resolve(value);}else {Promise.resolve(value).then(_next,_throw);}}function _async_to_generator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);})}}function _ts_generator(thisArg,body){var f,y,t,
|
|
18
|
+
function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return}if(info.done){resolve(value);}else {Promise.resolve(value).then(_next,_throw);}}function _async_to_generator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);})}}function _ts_generator(thisArg,body){var f,y,t,_={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},g=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return g.next=verb(0),g["throw"]=verb(1),g["return"]=verb(2),typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return {value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_);}catch(e){op=[6,e];y=0;}finally{f=t=0;}if(op[0]&5)throw op[1];return {value:op[0]?op[1]:void 0,done:true}}}var boot=function(){return _async_to_generator(function(){var config,cli,answer,PROJECT_PATH,PROJECT_GIT_PATH;return _ts_generator(this,function(_state){switch(_state.label){case 0:console.log();config=getConfig();return [4,getCli()];case 1:cli=_state.sent();return [4,projectPrompt(cli,config)];case 2:answer=_state.sent();PROJECT_PATH="".concat(process.cwd(),"/").concat(answer.projectName);PROJECT_GIT_PATH="".concat(PROJECT_PATH,"/.git");if(pathExists(PROJECT_PATH)){console.error('❌ Error: Cannot create project "'.concat(answer.projectName,'".\n')+"A directory with this name already exists.\n"+"Please choose a different name or delete the existing folder.");process.exit(1);}gitClone(answer.repo,answer.projectName);rmRF(PROJECT_GIT_PATH);answer.args.forEach(function(item){var value=item.value==="projectName"?answer.projectName:item.value;filesChangeContent(PROJECT_PATH,item.str,value);});return [2]}})})()};
|
|
15
19
|
|
|
16
20
|
export { boot as default };
|
package/package.json
CHANGED
|
@@ -1,30 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-make",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "An
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
3
|
+
"version": "0.7.1",
|
|
4
|
+
"description": "An advanced CLI tool for creating projects from GitHub repositories or custom templates with lightning-fast setup.",
|
|
5
|
+
"homepage": "https://github.com/z-npm/create-make#readme",
|
|
6
|
+
"docs": "https://github.com/z-npm/create-make#readme",
|
|
7
|
+
"bugs": {
|
|
8
|
+
"url": "https://github.com/z-npm/create-make/issues"
|
|
9
|
+
},
|
|
8
10
|
"repository": {
|
|
9
11
|
"type": "git",
|
|
10
12
|
"url": "git+https://github.com/z-npm/create-make.git"
|
|
11
13
|
},
|
|
12
14
|
"author": {
|
|
13
|
-
"name": "Zero
|
|
15
|
+
"name": "Zero Red",
|
|
16
|
+
"email": "github@zero-red.dev",
|
|
17
|
+
"url": "https://github.com/zero-red-dev"
|
|
14
18
|
},
|
|
19
|
+
"maintainers": [
|
|
20
|
+
{
|
|
21
|
+
"name": "Zero Red",
|
|
22
|
+
"email": "github@zero-red.dev",
|
|
23
|
+
"url": "https://github.com/zero-red-dev"
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"contributors": [],
|
|
15
27
|
"license": "MIT",
|
|
28
|
+
"funding": {
|
|
29
|
+
"type": "github",
|
|
30
|
+
"url": "https://github.com/sponsors/zero-red-dev"
|
|
31
|
+
},
|
|
32
|
+
"social": {
|
|
33
|
+
"tiktok": "@zero.red.dev",
|
|
34
|
+
"github": "zero-red-dev"
|
|
35
|
+
},
|
|
16
36
|
"keywords": [
|
|
17
|
-
"
|
|
18
|
-
"project",
|
|
19
|
-
"scaffold",
|
|
20
|
-
"template",
|
|
21
|
-
"templating",
|
|
22
|
-
"boilerplate",
|
|
37
|
+
"cli",
|
|
23
38
|
"make",
|
|
24
39
|
"starter",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
40
|
+
"scaffolding",
|
|
41
|
+
"generator",
|
|
42
|
+
"project-generator",
|
|
43
|
+
"boilerplate",
|
|
44
|
+
"templates",
|
|
45
|
+
"create-project",
|
|
46
|
+
"vite",
|
|
47
|
+
"typescript",
|
|
48
|
+
"rollup",
|
|
49
|
+
"monorepo",
|
|
50
|
+
"zero-red"
|
|
27
51
|
],
|
|
52
|
+
"type": "module",
|
|
53
|
+
"main": "bin.js",
|
|
54
|
+
"bin": "./bin.js",
|
|
28
55
|
"files": [
|
|
29
56
|
"dist",
|
|
30
57
|
"bin.js"
|
|
@@ -35,15 +62,25 @@
|
|
|
35
62
|
"local": "yarn build && yarn unlink && yarn link && yarn create make"
|
|
36
63
|
},
|
|
37
64
|
"devDependencies": {
|
|
38
|
-
"@types/inquirer": "^9.0.
|
|
39
|
-
"@types/node": "^
|
|
40
|
-
"@
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
65
|
+
"@types/inquirer": "^9.0.9",
|
|
66
|
+
"@types/node": "^24.10.1",
|
|
67
|
+
"@types/yargs": "^17.0.35",
|
|
68
|
+
"@z-code/vite-plugin-swc": "^0.5.4",
|
|
69
|
+
"rollup-plugin-node-externals": "^8.1.2",
|
|
70
|
+
"typescript": "^5.9.3",
|
|
71
|
+
"vite": "^7.2.6"
|
|
44
72
|
},
|
|
45
73
|
"dependencies": {
|
|
46
|
-
"inquirer": "^
|
|
74
|
+
"inquirer": "^13.0.2",
|
|
75
|
+
"yargs": "^18.0.0"
|
|
76
|
+
},
|
|
77
|
+
"engines": {
|
|
78
|
+
"node": ">=18.0.0",
|
|
79
|
+
"npm": ">=8.0.0"
|
|
80
|
+
},
|
|
81
|
+
"publishConfig": {
|
|
82
|
+
"access": "public",
|
|
83
|
+
"registry": "https://registry.npmjs.org/"
|
|
47
84
|
},
|
|
48
|
-
"packageManager": "yarn@4.
|
|
85
|
+
"packageManager": "yarn@4.12.0"
|
|
49
86
|
}
|