create-rstack 1.7.19 → 1.7.21
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/dist/index.d.ts +6 -0
- package/dist/index.js +21 -13
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -89,6 +89,12 @@ declare type ExtraTool = {
|
|
|
89
89
|
* If undefined, the tool will be displayed after built-in tools.
|
|
90
90
|
*/
|
|
91
91
|
order?: 'pre' | 'post';
|
|
92
|
+
/**
|
|
93
|
+
* Condition to determine whether this tool should be displayed.
|
|
94
|
+
* If returns false, the tool will not be shown in the selection.
|
|
95
|
+
* @default () => true
|
|
96
|
+
*/
|
|
97
|
+
when?: (templateName: string) => boolean;
|
|
92
98
|
};
|
|
93
99
|
|
|
94
100
|
/**
|
package/dist/index.js
CHANGED
|
@@ -2112,11 +2112,13 @@ const BUILTIN_TOOLS = [
|
|
|
2112
2112
|
'prettier'
|
|
2113
2113
|
];
|
|
2114
2114
|
function logHelpMessage(name, templates, extraTools) {
|
|
2115
|
-
const extraToolNames = extraTools?.map((tool)=>tool.value) ?? [];
|
|
2116
2115
|
const toolsList = [
|
|
2117
|
-
...BUILTIN_TOOLS
|
|
2118
|
-
|
|
2119
|
-
|
|
2116
|
+
...BUILTIN_TOOLS
|
|
2117
|
+
];
|
|
2118
|
+
if (extraTools) {
|
|
2119
|
+
for (const tool of extraTools)if (tool.value) if ('pre' === tool.order) toolsList.unshift(tool.value);
|
|
2120
|
+
else toolsList.push(tool.value);
|
|
2121
|
+
}
|
|
2120
2122
|
src_logger.log(`
|
|
2121
2123
|
Usage: create-${name} [dir] [options]
|
|
2122
2124
|
|
|
@@ -2125,19 +2127,25 @@ function logHelpMessage(name, templates, extraTools) {
|
|
|
2125
2127
|
-h, --help display help for command
|
|
2126
2128
|
-d, --dir <dir> create project in specified directory
|
|
2127
2129
|
-t, --template <tpl> specify the template to use
|
|
2128
|
-
--tools <tool>
|
|
2130
|
+
--tools <tool> add additional tools, comma separated
|
|
2129
2131
|
--override override files in target directory
|
|
2130
2132
|
--packageName <name> specify the package name
|
|
2131
2133
|
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
+
Available templates:
|
|
2134
2135
|
${templates.join(', ')}
|
|
2136
|
+
|
|
2137
|
+
Optional tools:
|
|
2138
|
+
${toolsList.join(', ')}
|
|
2135
2139
|
`);
|
|
2136
2140
|
}
|
|
2137
|
-
async function getTools({ tools, dir, template }, extraTools) {
|
|
2141
|
+
async function getTools({ tools, dir, template }, extraTools, templateName) {
|
|
2138
2142
|
const parsedTools = parseToolsOption(tools);
|
|
2143
|
+
const filteredExtraTools = extraTools?.filter((tool)=>{
|
|
2144
|
+
const when = tool.when ?? (()=>true);
|
|
2145
|
+
return templateName ? when(templateName) : true;
|
|
2146
|
+
});
|
|
2139
2147
|
if (null !== parsedTools) {
|
|
2140
|
-
const toolsArr = parsedTools.filter((tool)=>BUILTIN_TOOLS.includes(tool) ||
|
|
2148
|
+
const toolsArr = parsedTools.filter((tool)=>BUILTIN_TOOLS.includes(tool) || filteredExtraTools?.some((extraTool)=>extraTool.value === tool));
|
|
2141
2149
|
return toolsArr;
|
|
2142
2150
|
}
|
|
2143
2151
|
if (dir && template) return [];
|
|
@@ -2155,14 +2163,14 @@ async function getTools({ tools, dir, template }, extraTools) {
|
|
|
2155
2163
|
label: 'Prettier - formatting'
|
|
2156
2164
|
}
|
|
2157
2165
|
];
|
|
2158
|
-
if (
|
|
2166
|
+
if (filteredExtraTools) {
|
|
2159
2167
|
const normalize = (tool)=>({
|
|
2160
2168
|
value: tool.value,
|
|
2161
2169
|
label: tool.label,
|
|
2162
2170
|
hint: tool.command
|
|
2163
2171
|
});
|
|
2164
|
-
options.unshift(...
|
|
2165
|
-
options.push(...
|
|
2172
|
+
options.unshift(...filteredExtraTools.filter((tool)=>'pre' === tool.order).map(normalize));
|
|
2173
|
+
options.push(...filteredExtraTools.filter((tool)=>'pre' !== tool.order).map(normalize));
|
|
2166
2174
|
}
|
|
2167
2175
|
return checkCancel(await fe({
|
|
2168
2176
|
message: 'Select additional tools (Use <space> to select, <enter> to continue)',
|
|
@@ -2250,7 +2258,7 @@ async function create({ name, root, templates, skipFiles, getTemplateName, mapES
|
|
|
2250
2258
|
if ('no' === option) cancelAndExit();
|
|
2251
2259
|
}
|
|
2252
2260
|
const templateName = await getTemplateName(argv);
|
|
2253
|
-
const tools = await getTools(argv, extraTools);
|
|
2261
|
+
const tools = await getTools(argv, extraTools, templateName);
|
|
2254
2262
|
const srcFolder = node_path.join(root, `template-${templateName}`);
|
|
2255
2263
|
const commonFolder = node_path.join(root, 'template-common');
|
|
2256
2264
|
if (!external_node_fs_["default"].existsSync(srcFolder)) throw new Error(`Invalid input: template "${templateName}" not found.`);
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-rstack",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.21",
|
|
4
4
|
"description": "Create a new Rstack project",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "https://github.com/
|
|
7
|
+
"url": "https://github.com/rstackjs/create-rstack"
|
|
8
8
|
},
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"type": "module",
|