@guchen_0521/create-temp 0.1.1 → 0.1.2

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/bin/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { scaffold } from "../lib/scaffold.js";
3
3
 
4
- const args = process.argv.slice(2);
4
+ const args = process.argv.slice(2).filter((arg) => arg !== "--");
5
5
  const [templateArg, targetArg] = args;
6
6
 
7
7
  try {
package/lib/scaffold.js CHANGED
@@ -90,6 +90,16 @@ function formatTemplateKey(projectRoot, templateDir) {
90
90
  .join("/");
91
91
  }
92
92
 
93
+ function normalizeTemplateKey(templateKey) {
94
+ if (!templateKey) {
95
+ return templateKey;
96
+ }
97
+ return templateKey
98
+ .trim()
99
+ .replaceAll("\\", "/")
100
+ .replace(/^\.\/+/, "");
101
+ }
102
+
93
103
  async function promptSelectTemplate(templates) {
94
104
  const rl = createInterface({ input: process.stdin, output: process.stdout });
95
105
  console.log("Available templates:");
@@ -195,8 +205,9 @@ export async function scaffold({ templateKey, targetDir }) {
195
205
 
196
206
  let selectedTemplate = null;
197
207
  if (templateKey) {
208
+ const normalizedKey = normalizeTemplateKey(templateKey);
198
209
  selectedTemplate = templates.find(
199
- (template) => template.key === templateKey
210
+ (template) => normalizeTemplateKey(template.key) === normalizedKey
200
211
  );
201
212
  if (!selectedTemplate) {
202
213
  const keys = templates.map((template) => template.key).join(", ");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guchen_0521/create-temp",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Project scaffolding CLI (templates pulled from GitHub)",
5
5
  "type": "module",
6
6
  "bin": {