create-sammi-next 0.0.2 → 1.0.0

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 CHANGED
@@ -3,33 +3,53 @@
3
3
  ## Scaffolding Your First SAMMI Next Project
4
4
 
5
5
  With NPM:
6
- `npm create sammi-next@latest`
6
+
7
+ ```bash
8
+ npm create sammi-next@latest
9
+ ```
7
10
 
8
11
  With Yarn:
9
- `yan create vite`
12
+
13
+ ```bash
14
+ yan create vite
15
+ ```
10
16
 
11
17
  With PNPM:
12
- `pnpm create sammi-next`
18
+
19
+ ```bash
20
+ pnpm create sammi-next
21
+ ```
13
22
 
14
23
  With Bun:
15
- `bun create sammi-next`
24
+
25
+ ```bash
26
+ bun create sammi-next
27
+ ```
16
28
 
17
29
  With Deno:
18
- `deno init --npm sammi-next`
30
+
31
+ ```bash
32
+ deno init --npm sammi-next
33
+ ```
19
34
 
20
35
  Then follow the prompts!
21
36
 
22
37
  You can also directly specify the project name and the template you want to use via additional command line options. For example, to scaffold the TypeScript sample extension template, run:
23
38
  ```bash
39
+ # npm
24
40
  npm create sammi-next@latest my-sammi-extension -- --template sample-ts
25
41
 
26
- yarn create sammi-next my-sammi-extension -- --template sample-ts
42
+ # yarn
43
+ yarn create sammi-next my-sammi-extension --template sample-ts
27
44
 
28
- pnpm create sammi-next my-sammi-extension -- --template sample-ts
45
+ # pnpm
46
+ pnpm create sammi-next my-sammi-extension --template sample-ts
29
47
 
30
- bun create sammi-next my-sammi-extension -- --template sample-ts
48
+ # Bun
49
+ bun create sammi-next my-sammi-extension --template sample-ts
31
50
 
32
- deno init --npm sammi-next my-sammi-extension -- --template sample-ts
51
+ # Deno
52
+ deno init --npm sammi-next my-sammi-extension --template sample-ts
33
53
  ```
34
54
 
35
55
  Currently supported template presets include:
package/dist/index.js CHANGED
@@ -832,7 +832,7 @@ ${J}${i.trimStart()}`), r$1 = 3 + stripVTControlCharacters(i.trimStart()).length
832
832
  warning: (t) => x.warn(t),
833
833
  error: (t) => x.message(t, { symbol: import_picocolors.default.red(K) })
834
834
  };
835
- var version = "0.0.2";
835
+ var version = "1.0.0";
836
836
  const { blue, gray, green, magenta, yellow } = import_picocolors.default;
837
837
  const argv = (0, import_lib.default)(process.argv.slice(2), {
838
838
  boolean: [
@@ -927,11 +927,11 @@ async function init() {
927
927
  defaultValue: defaultExtensionName,
928
928
  placeholder: defaultExtensionName,
929
929
  validate: (value) => {
930
- if (!value || !isValidExtensionName(value)) return "Invalid extension name";
930
+ if (!isValidExtensionName(value.trim())) return "Invalid extension name";
931
931
  }
932
932
  });
933
933
  if (pD(projectName)) return cancel();
934
- extensionName = projectName;
934
+ extensionName = projectName.trim();
935
935
  }
936
936
  const defaultExtensionID = toValidExtensionID(extensionName);
937
937
  let extensionID = argExtensionID;
@@ -1021,19 +1021,27 @@ async function init() {
1021
1021
  fs.mkdirSync(root, { recursive: true });
1022
1022
  M.step(`Scaffolding project in ${root}...`);
1023
1023
  const templateDir = path.resolve(fileURLToPath(import.meta.url), "../..", `template-${template}`);
1024
- const write = (file, content) => {
1025
- const targetPath = path.join(root, renameFiles[file] ?? file);
1024
+ const write = (file, content, rootDir = templateDir) => {
1025
+ const fullPath = path.join(rootDir, file);
1026
+ const stats = fs.statSync(fullPath);
1027
+ const targetPath = rootDir === templateDir ? path.join(root, renameFiles[file] ?? file) : path.join(root, rootDir.substring(templateDir.length), renameFiles[file] ?? file);
1028
+ if (stats.isDirectory()) {
1029
+ fs.mkdirSync(targetPath, { recursive: true });
1030
+ const files$1 = fs.readdirSync(fullPath);
1031
+ for (const file$1 of files$1) write(file$1, void 0, fullPath);
1032
+ return;
1033
+ }
1026
1034
  if (content) {
1027
1035
  fs.writeFileSync(targetPath, content);
1028
1036
  return;
1029
1037
  }
1030
- if (file.endsWith(".html") || file === "README.md" || file.startsWith("sammi.config.")) {
1031
- const templatePath = path.join(templateDir, file);
1038
+ if (file === "external.html" || file === "README.md" || file.startsWith("sammi.config.")) {
1039
+ const templatePath = fullPath;
1032
1040
  const updatedContent = fs.readFileSync(templatePath, "utf-8").replace(/{{EXTENSION_ID}}/g, extensionID).replace(/{{EXTENSION_NAME}}/g, extensionName).replace(/{{CREATE_VERSION}}/g, version);
1033
1041
  fs.writeFileSync(targetPath, updatedContent);
1034
1042
  return;
1035
1043
  }
1036
- copy(path.join(templateDir, file), targetPath);
1044
+ copy(fullPath, targetPath);
1037
1045
  };
1038
1046
  const files = fs.readdirSync(templateDir);
1039
1047
  for (const file of files.filter((f) => f !== "package.json")) write(file);
@@ -1077,7 +1085,7 @@ function emptyDir(dir) {
1077
1085
  }
1078
1086
  }
1079
1087
  function isValidExtensionName(projectName) {
1080
- return /^[a-zA-Z0-9 -_]+$/.test(projectName);
1088
+ return /^[a-zA-Z0-9 -_]*$/.test(projectName);
1081
1089
  }
1082
1090
  function isValidExtensionID(projectName) {
1083
1091
  return /^[a-z0-9-_]+$/.test(projectName);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-sammi-next",
3
- "version": "0.0.2",
3
+ "version": "1.0.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -15,6 +15,6 @@
15
15
  },
16
16
  "type": "module",
17
17
  "dependencies": {
18
- "sammi-next": "^1.5.0"
18
+ "sammi-next": "^1.5.4"
19
19
  }
20
20
  }
@@ -16,6 +16,6 @@
16
16
  },
17
17
  "type": "module",
18
18
  "dependencies": {
19
- "sammi-next": "^1.5.0"
19
+ "sammi-next": "^1.5.4"
20
20
  }
21
21
  }
@@ -15,6 +15,6 @@
15
15
  },
16
16
  "type": "module",
17
17
  "dependencies": {
18
- "sammi-next": "^1.5.0"
18
+ "sammi-next": "^1.5.4"
19
19
  }
20
20
  }
@@ -16,6 +16,6 @@
16
16
  },
17
17
  "type": "module",
18
18
  "dependencies": {
19
- "sammi-next": "^1.5.0"
19
+ "sammi-next": "^1.5.4"
20
20
  }
21
21
  }
@@ -15,6 +15,6 @@
15
15
  },
16
16
  "type": "module",
17
17
  "dependencies": {
18
- "sammi-next": "^1.5.0"
18
+ "sammi-next": "^1.5.4"
19
19
  }
20
20
  }
@@ -16,6 +16,6 @@
16
16
  },
17
17
  "type": "module",
18
18
  "dependencies": {
19
- "sammi-next": "^1.5.0"
19
+ "sammi-next": "^1.5.4"
20
20
  }
21
21
  }