create-make 0.7.1 → 0.7.3
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 +17 -18
- package/dist/index.cjs +131 -4
- package/dist/index.js +131 -4
- package/dist/version.json +3 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -128,17 +128,15 @@ Built-in Templates (TypeScript Category)
|
|
|
128
128
|
| vite-vanilla-ts | Vanilla TypeScript with Vite | Vite + TypeScript |
|
|
129
129
|
| vite-phaser-ts | Game development with Phaser | Vite + Phaser + TypeScript |
|
|
130
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
131
|
| vite-monorepo-ts | Monorepo setup with Vite | Vite + Monorepo + TypeScript |
|
|
133
|
-
| rollup-monorepo-ts | Monorepo setup with Rollup | Rollup + Monorepo + TypeScript |
|
|
134
132
|
|
|
135
133
|
__Pro Tip__: Create an alias for even faster usage! Add this to your shell config:
|
|
136
134
|
```bash
|
|
137
|
-
alias
|
|
135
|
+
alias cm="yarn create make"
|
|
138
136
|
```
|
|
139
137
|
Then use:
|
|
140
138
|
```bash
|
|
141
|
-
|
|
139
|
+
cm my-project -t vite-node-ts
|
|
142
140
|
```
|
|
143
141
|
|
|
144
142
|
## ⚙️ Configuration
|
|
@@ -167,23 +165,21 @@ Create a __config.json__ file to add your custom templates:
|
|
|
167
165
|
"$schema": "./schema.json",
|
|
168
166
|
"categories": {
|
|
169
167
|
"Backend": {
|
|
170
|
-
"
|
|
171
|
-
"
|
|
172
|
-
"
|
|
173
|
-
|
|
174
|
-
"str": "
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
]
|
|
178
|
-
}
|
|
179
|
-
},
|
|
168
|
+
"vite-node-ts": {
|
|
169
|
+
"name": "Vite Node",
|
|
170
|
+
"repo": "https://github.com/z-starter/vite-node-ts",
|
|
171
|
+
"args": [ {
|
|
172
|
+
"str": "vite-node-ts", "value": "projectName"
|
|
173
|
+
} ]
|
|
174
|
+
} },
|
|
180
175
|
"Frontend": {
|
|
181
|
-
"
|
|
182
|
-
"
|
|
176
|
+
"vite-vanilla-ts": {
|
|
177
|
+
"name": "Vite Vanilla",
|
|
178
|
+
"repo": "https://github.com/z-starter/vite-vanilla-ts",
|
|
183
179
|
"args": [
|
|
184
180
|
{
|
|
185
|
-
"str": "
|
|
186
|
-
|
|
181
|
+
"str": "vite-vanilla-ts",
|
|
182
|
+
"value": "projectName"
|
|
187
183
|
}
|
|
188
184
|
]
|
|
189
185
|
}
|
|
@@ -196,6 +192,7 @@ Create a __config.json__ file to add your custom templates:
|
|
|
196
192
|
|
|
197
193
|
| Property | Type | Description |
|
|
198
194
|
|:--------:|:-----------------:|:----:|
|
|
195
|
+
| name | string | Name of the Template |
|
|
199
196
|
| repo | string | Git repository URL to clone |
|
|
200
197
|
| args | array | String replacements in template files |
|
|
201
198
|
| args[].str | string | Text in template files to replace |
|
|
@@ -204,6 +201,7 @@ Create a __config.json__ file to add your custom templates:
|
|
|
204
201
|
|
|
205
202
|
## 🎮 How It Works
|
|
206
203
|
|
|
204
|
+
```mermaid
|
|
207
205
|
graph TD
|
|
208
206
|
A[Start] --> B{Project name provided?}
|
|
209
207
|
B -->|No| C[Prompt for project name]
|
|
@@ -223,6 +221,7 @@ graph TD
|
|
|
223
221
|
N --> O[Create project]
|
|
224
222
|
F --> O
|
|
225
223
|
G --> O
|
|
224
|
+
```
|
|
226
225
|
|
|
227
226
|
|
|
228
227
|
## 🐛 Troubleshooting
|
package/dist/index.cjs
CHANGED
|
@@ -7,16 +7,143 @@ const node_child_process = require('node:child_process');
|
|
|
7
7
|
const node_path = require('node:path');
|
|
8
8
|
const inquirer = require('inquirer');
|
|
9
9
|
|
|
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:{
|
|
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:{"vite-vanilla-ts":{name:"Vanilla",repo:"https://github.com/z-starter/vite-vanilla-ts.git",args:[{str:"vite-vanilla-ts",value:"projectName"}]},"vite-phaser-ts":{name:"Phaser",repo:"https://github.com/z-starter/vite-phaser-ts.git",args:[{str:"vite-phaser-ts",value:"projectName"}]},"vite-node-ts":{name:"Vite Node",repo:"https://github.com/z-starter/vite-node-ts.git",args:[{str:"vite-node-ts",value:"projectName"}]},"vite-monorepo-ts":{name:"Vite Monorepo",repo:"https://github.com/z-starter/vite-monorepo-ts.git",args:[{str:"vite-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 advanced CLI tool for creating projects from GitHub repositories or custom templates with lightning-fast setup.",type:"object",properties:{categories:{type:"object",additionalProperties:{type:"object",additionalProperties:{type:"object",properties:{name:{type:"string",default:"templateName"},repo:{type:"string",default:"repoUrl"},args:{type:"array",items:{type:"object",properties:{str:{type:"string",default:"contentToReplace"},value:{type:"string",default:"projectName"}}}}}}}}}};
|
|
11
11
|
|
|
12
|
-
function asyncGeneratorStep$2(gen,
|
|
12
|
+
function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
13
|
+
try {
|
|
14
|
+
var info = gen[key](arg);
|
|
15
|
+
var value = info.value;
|
|
16
|
+
} catch (error) {
|
|
17
|
+
reject(error);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (info.done) {
|
|
21
|
+
resolve(value);
|
|
22
|
+
} else {
|
|
23
|
+
Promise.resolve(value).then(_next, _throw);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function _async_to_generator$2(fn) {
|
|
27
|
+
return function() {
|
|
28
|
+
var self = this, args = arguments;
|
|
29
|
+
return new Promise(function(resolve, reject) {
|
|
30
|
+
var gen = fn.apply(self, args);
|
|
31
|
+
function _next(value) {
|
|
32
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
|
|
33
|
+
}
|
|
34
|
+
function _throw(err) {
|
|
35
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
36
|
+
}
|
|
37
|
+
_next(void 0);
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function _ts_generator$2(thisArg, body) {
|
|
42
|
+
var f, y, t, _ = { label: 0, sent: function() {
|
|
43
|
+
if (t[0] & 1) throw t[1];
|
|
44
|
+
return t[1];
|
|
45
|
+
}, trys: [], ops: [] }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
46
|
+
return d(g, "next", { value: verb(0) }), d(g, "throw", { value: verb(1) }), d(g, "return", { value: verb(2) }), typeof Symbol === "function" && d(g, Symbol.iterator, { value: function() {
|
|
47
|
+
return this;
|
|
48
|
+
} }), g;
|
|
49
|
+
function verb(n) {
|
|
50
|
+
return function(v) {
|
|
51
|
+
return step([n, v]);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function step(op) {
|
|
55
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
56
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
57
|
+
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;
|
|
58
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
59
|
+
switch (op[0]) {
|
|
60
|
+
case 0:
|
|
61
|
+
case 1:
|
|
62
|
+
t = op;
|
|
63
|
+
break;
|
|
64
|
+
case 4:
|
|
65
|
+
_.label++;
|
|
66
|
+
return { value: op[1], done: false };
|
|
67
|
+
case 5:
|
|
68
|
+
_.label++;
|
|
69
|
+
y = op[1];
|
|
70
|
+
op = [0];
|
|
71
|
+
continue;
|
|
72
|
+
case 7:
|
|
73
|
+
op = _.ops.pop();
|
|
74
|
+
_.trys.pop();
|
|
75
|
+
continue;
|
|
76
|
+
default:
|
|
77
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
78
|
+
_ = 0;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
82
|
+
_.label = op[1];
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
86
|
+
_.label = t[1];
|
|
87
|
+
t = op;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
if (t && _.label < t[2]) {
|
|
91
|
+
_.label = t[2];
|
|
92
|
+
_.ops.push(op);
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
if (t[2]) _.ops.pop();
|
|
96
|
+
_.trys.pop();
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
op = body.call(thisArg, _);
|
|
100
|
+
} catch (e) {
|
|
101
|
+
op = [6, e];
|
|
102
|
+
y = 0;
|
|
103
|
+
} finally {
|
|
104
|
+
f = t = 0;
|
|
105
|
+
}
|
|
106
|
+
if (op[0] & 5) throw op[1];
|
|
107
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
var getCli = function() {
|
|
111
|
+
return _async_to_generator$2(function() {
|
|
112
|
+
var version, yargsInstance, argv, projectName, template, otherTemplate;
|
|
113
|
+
return _ts_generator$2(this, function(_state) {
|
|
114
|
+
switch (_state.label) {
|
|
115
|
+
case 0:
|
|
116
|
+
version = "0.7.3";
|
|
117
|
+
yargsInstance = yargs(helpers.hideBin(process.argv)).scriptName("create-make").usage("Usage: $0 [projectName] [options]").epilogue("\n\u{1F4E6} Create projects in seconds with built-in or custom templates!\n\nQuick Start:\n \u2022 Interactive mode: $0 (Guided setup)\n \u2022 Built-in template: $0 my-app -t vite-vanilla-ts (Skip prompts)\n \u2022 Custom template: $0 my-project -o express-api (Use custom config)\n\n\u{1F4A1} Tips:\n \u2022 When using --template or --other-template, projectName is required\n \u2022 Omit projectName to be prompted for it\n \u2022 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(argv2) {
|
|
118
|
+
if ((argv2.template || argv2["other-template"]) && !argv2._[0]) {
|
|
119
|
+
throw new Error("Project name is required when using --template or --other-template");
|
|
120
|
+
}
|
|
121
|
+
return true;
|
|
122
|
+
}).help("help", "Show this help message").alias("help", "h").version(version).alias("v", "version").demandCommand(0, 1, "Provide at most one project name").strict();
|
|
123
|
+
return [4, yargsInstance.parseAsync()];
|
|
124
|
+
case 1:
|
|
125
|
+
argv = _state.sent();
|
|
126
|
+
projectName = argv._[0];
|
|
127
|
+
template = argv.template;
|
|
128
|
+
otherTemplate = argv.otherTemplate;
|
|
129
|
+
if ((template || otherTemplate) && !projectName) {
|
|
130
|
+
console.error("\u274C Error: Project name is required");
|
|
131
|
+
console.error("\u{1F4D6} Usage: create-make <project-name>");
|
|
132
|
+
console.error("\u{1F4A1} Example: create-make my-project");
|
|
133
|
+
process.exit(2);
|
|
134
|
+
}
|
|
135
|
+
return [2, { projectName, template, otherTemplate }];
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
})();
|
|
139
|
+
};
|
|
13
140
|
|
|
14
141
|
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"});}});};
|
|
15
142
|
|
|
16
143
|
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})};
|
|
17
144
|
|
|
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
|
|
145
|
+
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),d=Object.defineProperty;return d(g,"next",{value:verb(0)}),d(g,"throw",{value:verb(1)}),d(g,"return",{value:verb(2)}),typeof Symbol==="function"&&d(g,Symbol.iterator,{value: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,eMsg,prompt1,defaultCategories,userDefineCategories,_answers1,_projectName,answers1,isUserDefineCategories,templates,tobj,tobj1,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(template);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(template1);if(args1[0].str===cli.otherTemplate)return [2,{category:category1,template:template1,projectName:cli.projectName,args:args1,repo:repo1}]}}eMsg=tStrArr1.length>0?"Available templates:\n"+" • ".concat(tStrArr1.join("\n • "),"\n")+"Please select one of the templates above.":"\nNo custom templates are currently configured.\n"+"Please check your configuration at:\n ".concat(CONFIG_PATH,"\n\n")+"To add templates, edit the configuration file and add template definitions.";console.error('❌ Error: Template "'.concat(cli.otherTemplate,'" was not found.\n').concat(eMsg));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=[];if(isUserDefineCategories)for(var key in config.categories[answers1.category]){tobj=config.categories[answers1.category][key];if(tobj.name)templates.push({name:"".concat(tobj.name,"(").concat(key,")"),value:key});else templates.push({name:key,value:key});}else for(var key1 in config.defaultCategories[answers1.category]){tobj1=config.defaultCategories[answers1.category][key1];if(tobj1.name)templates.push({name:"".concat(tobj1.name,"(").concat(key1,")"),value:key1});else templates.push({name:key1,value:key1});}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]}})})()};
|
|
19
146
|
|
|
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
|
|
147
|
+
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),d=Object.defineProperty;return d(g,"next",{value:verb(0)}),d(g,"throw",{value:verb(1)}),d(g,"return",{value:verb(2)}),typeof Symbol==="function"&&d(g,Symbol.iterator,{value: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]}})})()};
|
|
21
148
|
|
|
22
149
|
module.exports = boot;
|
package/dist/index.js
CHANGED
|
@@ -5,16 +5,143 @@ import { execSync } from 'node:child_process';
|
|
|
5
5
|
import { join } from 'node:path';
|
|
6
6
|
import inquirer from 'inquirer';
|
|
7
7
|
|
|
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:{
|
|
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:{"vite-vanilla-ts":{name:"Vanilla",repo:"https://github.com/z-starter/vite-vanilla-ts.git",args:[{str:"vite-vanilla-ts",value:"projectName"}]},"vite-phaser-ts":{name:"Phaser",repo:"https://github.com/z-starter/vite-phaser-ts.git",args:[{str:"vite-phaser-ts",value:"projectName"}]},"vite-node-ts":{name:"Vite Node",repo:"https://github.com/z-starter/vite-node-ts.git",args:[{str:"vite-node-ts",value:"projectName"}]},"vite-monorepo-ts":{name:"Vite Monorepo",repo:"https://github.com/z-starter/vite-monorepo-ts.git",args:[{str:"vite-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 advanced CLI tool for creating projects from GitHub repositories or custom templates with lightning-fast setup.",type:"object",properties:{categories:{type:"object",additionalProperties:{type:"object",additionalProperties:{type:"object",properties:{name:{type:"string",default:"templateName"},repo:{type:"string",default:"repoUrl"},args:{type:"array",items:{type:"object",properties:{str:{type:"string",default:"contentToReplace"},value:{type:"string",default:"projectName"}}}}}}}}}};
|
|
9
9
|
|
|
10
|
-
function asyncGeneratorStep$2(gen,
|
|
10
|
+
function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
11
|
+
try {
|
|
12
|
+
var info = gen[key](arg);
|
|
13
|
+
var value = info.value;
|
|
14
|
+
} catch (error) {
|
|
15
|
+
reject(error);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (info.done) {
|
|
19
|
+
resolve(value);
|
|
20
|
+
} else {
|
|
21
|
+
Promise.resolve(value).then(_next, _throw);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function _async_to_generator$2(fn) {
|
|
25
|
+
return function() {
|
|
26
|
+
var self = this, args = arguments;
|
|
27
|
+
return new Promise(function(resolve, reject) {
|
|
28
|
+
var gen = fn.apply(self, args);
|
|
29
|
+
function _next(value) {
|
|
30
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
|
|
31
|
+
}
|
|
32
|
+
function _throw(err) {
|
|
33
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
34
|
+
}
|
|
35
|
+
_next(void 0);
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function _ts_generator$2(thisArg, body) {
|
|
40
|
+
var f, y, t, _ = { label: 0, sent: function() {
|
|
41
|
+
if (t[0] & 1) throw t[1];
|
|
42
|
+
return t[1];
|
|
43
|
+
}, trys: [], ops: [] }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
44
|
+
return d(g, "next", { value: verb(0) }), d(g, "throw", { value: verb(1) }), d(g, "return", { value: verb(2) }), typeof Symbol === "function" && d(g, Symbol.iterator, { value: function() {
|
|
45
|
+
return this;
|
|
46
|
+
} }), g;
|
|
47
|
+
function verb(n) {
|
|
48
|
+
return function(v) {
|
|
49
|
+
return step([n, v]);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function step(op) {
|
|
53
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
54
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
55
|
+
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;
|
|
56
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
57
|
+
switch (op[0]) {
|
|
58
|
+
case 0:
|
|
59
|
+
case 1:
|
|
60
|
+
t = op;
|
|
61
|
+
break;
|
|
62
|
+
case 4:
|
|
63
|
+
_.label++;
|
|
64
|
+
return { value: op[1], done: false };
|
|
65
|
+
case 5:
|
|
66
|
+
_.label++;
|
|
67
|
+
y = op[1];
|
|
68
|
+
op = [0];
|
|
69
|
+
continue;
|
|
70
|
+
case 7:
|
|
71
|
+
op = _.ops.pop();
|
|
72
|
+
_.trys.pop();
|
|
73
|
+
continue;
|
|
74
|
+
default:
|
|
75
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
76
|
+
_ = 0;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
80
|
+
_.label = op[1];
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
84
|
+
_.label = t[1];
|
|
85
|
+
t = op;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
if (t && _.label < t[2]) {
|
|
89
|
+
_.label = t[2];
|
|
90
|
+
_.ops.push(op);
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
if (t[2]) _.ops.pop();
|
|
94
|
+
_.trys.pop();
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
op = body.call(thisArg, _);
|
|
98
|
+
} catch (e) {
|
|
99
|
+
op = [6, e];
|
|
100
|
+
y = 0;
|
|
101
|
+
} finally {
|
|
102
|
+
f = t = 0;
|
|
103
|
+
}
|
|
104
|
+
if (op[0] & 5) throw op[1];
|
|
105
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
var getCli = function() {
|
|
109
|
+
return _async_to_generator$2(function() {
|
|
110
|
+
var version, yargsInstance, argv, projectName, template, otherTemplate;
|
|
111
|
+
return _ts_generator$2(this, function(_state) {
|
|
112
|
+
switch (_state.label) {
|
|
113
|
+
case 0:
|
|
114
|
+
version = "0.7.3";
|
|
115
|
+
yargsInstance = yargs(hideBin(process.argv)).scriptName("create-make").usage("Usage: $0 [projectName] [options]").epilogue("\n\u{1F4E6} Create projects in seconds with built-in or custom templates!\n\nQuick Start:\n \u2022 Interactive mode: $0 (Guided setup)\n \u2022 Built-in template: $0 my-app -t vite-vanilla-ts (Skip prompts)\n \u2022 Custom template: $0 my-project -o express-api (Use custom config)\n\n\u{1F4A1} Tips:\n \u2022 When using --template or --other-template, projectName is required\n \u2022 Omit projectName to be prompted for it\n \u2022 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(argv2) {
|
|
116
|
+
if ((argv2.template || argv2["other-template"]) && !argv2._[0]) {
|
|
117
|
+
throw new Error("Project name is required when using --template or --other-template");
|
|
118
|
+
}
|
|
119
|
+
return true;
|
|
120
|
+
}).help("help", "Show this help message").alias("help", "h").version(version).alias("v", "version").demandCommand(0, 1, "Provide at most one project name").strict();
|
|
121
|
+
return [4, yargsInstance.parseAsync()];
|
|
122
|
+
case 1:
|
|
123
|
+
argv = _state.sent();
|
|
124
|
+
projectName = argv._[0];
|
|
125
|
+
template = argv.template;
|
|
126
|
+
otherTemplate = argv.otherTemplate;
|
|
127
|
+
if ((template || otherTemplate) && !projectName) {
|
|
128
|
+
console.error("\u274C Error: Project name is required");
|
|
129
|
+
console.error("\u{1F4D6} Usage: create-make <project-name>");
|
|
130
|
+
console.error("\u{1F4A1} Example: create-make my-project");
|
|
131
|
+
process.exit(2);
|
|
132
|
+
}
|
|
133
|
+
return [2, { projectName, template, otherTemplate }];
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
})();
|
|
137
|
+
};
|
|
11
138
|
|
|
12
139
|
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"});}});};
|
|
13
140
|
|
|
14
141
|
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})};
|
|
15
142
|
|
|
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
|
|
143
|
+
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),d=Object.defineProperty;return d(g,"next",{value:verb(0)}),d(g,"throw",{value:verb(1)}),d(g,"return",{value:verb(2)}),typeof Symbol==="function"&&d(g,Symbol.iterator,{value: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,eMsg,prompt1,defaultCategories,userDefineCategories,_answers1,_projectName,answers1,isUserDefineCategories,templates,tobj,tobj1,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(template);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(template1);if(args1[0].str===cli.otherTemplate)return [2,{category:category1,template:template1,projectName:cli.projectName,args:args1,repo:repo1}]}}eMsg=tStrArr1.length>0?"Available templates:\n"+" • ".concat(tStrArr1.join("\n • "),"\n")+"Please select one of the templates above.":"\nNo custom templates are currently configured.\n"+"Please check your configuration at:\n ".concat(CONFIG_PATH,"\n\n")+"To add templates, edit the configuration file and add template definitions.";console.error('❌ Error: Template "'.concat(cli.otherTemplate,'" was not found.\n').concat(eMsg));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=[];if(isUserDefineCategories)for(var key in config.categories[answers1.category]){tobj=config.categories[answers1.category][key];if(tobj.name)templates.push({name:"".concat(tobj.name,"(").concat(key,")"),value:key});else templates.push({name:key,value:key});}else for(var key1 in config.defaultCategories[answers1.category]){tobj1=config.defaultCategories[answers1.category][key1];if(tobj1.name)templates.push({name:"".concat(tobj1.name,"(").concat(key1,")"),value:key1});else templates.push({name:key1,value:key1});}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]}})})()};
|
|
17
144
|
|
|
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
|
|
145
|
+
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),d=Object.defineProperty;return d(g,"next",{value:verb(0)}),d(g,"throw",{value:verb(1)}),d(g,"return",{value:verb(2)}),typeof Symbol==="function"&&d(g,Symbol.iterator,{value: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]}})})()};
|
|
19
146
|
|
|
20
147
|
export { boot as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-make",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "An advanced CLI tool for creating projects from GitHub repositories or custom templates with lightning-fast setup.",
|
|
5
5
|
"homepage": "https://github.com/z-npm/create-make#readme",
|
|
6
6
|
"docs": "https://github.com/z-npm/create-make#readme",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
],
|
|
52
52
|
"type": "module",
|
|
53
53
|
"main": "bin.js",
|
|
54
|
-
"bin": "
|
|
54
|
+
"bin": "bin.js",
|
|
55
55
|
"files": [
|
|
56
56
|
"dist",
|
|
57
57
|
"bin.js"
|
|
@@ -63,15 +63,15 @@
|
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@types/inquirer": "^9.0.9",
|
|
66
|
-
"@types/node": "^
|
|
66
|
+
"@types/node": "^25.0.3",
|
|
67
67
|
"@types/yargs": "^17.0.35",
|
|
68
|
-
"@z-code/vite-plugin-swc": "^0.5.
|
|
68
|
+
"@z-code/vite-plugin-swc": "^0.5.5",
|
|
69
69
|
"rollup-plugin-node-externals": "^8.1.2",
|
|
70
70
|
"typescript": "^5.9.3",
|
|
71
|
-
"vite": "^7.
|
|
71
|
+
"vite": "^7.3.0"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"inquirer": "^13.0
|
|
74
|
+
"inquirer": "^13.1.0",
|
|
75
75
|
"yargs": "^18.0.0"
|
|
76
76
|
},
|
|
77
77
|
"engines": {
|