create-rstack 1.7.20 → 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 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
@@ -2138,10 +2138,14 @@ function logHelpMessage(name, templates, extraTools) {
2138
2138
  ${toolsList.join(', ')}
2139
2139
  `);
2140
2140
  }
2141
- async function getTools({ tools, dir, template }, extraTools) {
2141
+ async function getTools({ tools, dir, template }, extraTools, templateName) {
2142
2142
  const parsedTools = parseToolsOption(tools);
2143
+ const filteredExtraTools = extraTools?.filter((tool)=>{
2144
+ const when = tool.when ?? (()=>true);
2145
+ return templateName ? when(templateName) : true;
2146
+ });
2143
2147
  if (null !== parsedTools) {
2144
- const toolsArr = parsedTools.filter((tool)=>BUILTIN_TOOLS.includes(tool) || extraTools?.some((extraTool)=>extraTool.value === tool));
2148
+ const toolsArr = parsedTools.filter((tool)=>BUILTIN_TOOLS.includes(tool) || filteredExtraTools?.some((extraTool)=>extraTool.value === tool));
2145
2149
  return toolsArr;
2146
2150
  }
2147
2151
  if (dir && template) return [];
@@ -2159,14 +2163,14 @@ async function getTools({ tools, dir, template }, extraTools) {
2159
2163
  label: 'Prettier - formatting'
2160
2164
  }
2161
2165
  ];
2162
- if (extraTools) {
2166
+ if (filteredExtraTools) {
2163
2167
  const normalize = (tool)=>({
2164
2168
  value: tool.value,
2165
2169
  label: tool.label,
2166
2170
  hint: tool.command
2167
2171
  });
2168
- options.unshift(...extraTools.filter((tool)=>'pre' === tool.order).map(normalize));
2169
- options.push(...extraTools.filter((tool)=>'pre' !== tool.order).map(normalize));
2172
+ options.unshift(...filteredExtraTools.filter((tool)=>'pre' === tool.order).map(normalize));
2173
+ options.push(...filteredExtraTools.filter((tool)=>'pre' !== tool.order).map(normalize));
2170
2174
  }
2171
2175
  return checkCancel(await fe({
2172
2176
  message: 'Select additional tools (Use <space> to select, <enter> to continue)',
@@ -2254,7 +2258,7 @@ async function create({ name, root, templates, skipFiles, getTemplateName, mapES
2254
2258
  if ('no' === option) cancelAndExit();
2255
2259
  }
2256
2260
  const templateName = await getTemplateName(argv);
2257
- const tools = await getTools(argv, extraTools);
2261
+ const tools = await getTools(argv, extraTools, templateName);
2258
2262
  const srcFolder = node_path.join(root, `template-${templateName}`);
2259
2263
  const commonFolder = node_path.join(root, 'template-common');
2260
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.20",
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/rspack-contrib/create-rstack"
7
+ "url": "https://github.com/rstackjs/create-rstack"
8
8
  },
9
9
  "license": "MIT",
10
10
  "type": "module",