create-sammi-next 0.0.2 → 1.1.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
- 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:
37
+ You can also directly specify the extension 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:
@@ -40,8 +60,6 @@ Currently supported template presets include:
40
60
  - `minimal-ts`
41
61
  - `minimal-js`
42
62
 
43
- You can use `.` for the project name to scaffold in the current directory.
44
-
45
63
  ## TODO
46
64
  - `react-ts`
47
65
  - `react-js`
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.1.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: [
@@ -850,6 +850,8 @@ const argv = (0, import_lib.default)(process.argv.slice(2), {
850
850
  });
851
851
  const cwd = process.cwd();
852
852
  const helpMessage = `\
853
+ create-sammi-next/${version}
854
+
853
855
  Usage create-sammi-next [OPTION]... [EXTENSION_ID]
854
856
 
855
857
  Create a new SAMMI Next extension project in TypeScript or JavaScript.
@@ -927,11 +929,11 @@ async function init() {
927
929
  defaultValue: defaultExtensionName,
928
930
  placeholder: defaultExtensionName,
929
931
  validate: (value) => {
930
- if (!value || !isValidExtensionName(value)) return "Invalid extension name";
932
+ if (!isValidExtensionName(value.trim())) return "Invalid extension name";
931
933
  }
932
934
  });
933
935
  if (pD(projectName)) return cancel();
934
- extensionName = projectName;
936
+ extensionName = projectName.trim();
935
937
  }
936
938
  const defaultExtensionID = toValidExtensionID(extensionName);
937
939
  let extensionID = argExtensionID;
@@ -1021,19 +1023,27 @@ async function init() {
1021
1023
  fs.mkdirSync(root, { recursive: true });
1022
1024
  M.step(`Scaffolding project in ${root}...`);
1023
1025
  const templateDir = path.resolve(fileURLToPath(import.meta.url), "../..", `template-${template}`);
1024
- const write = (file, content) => {
1025
- const targetPath = path.join(root, renameFiles[file] ?? file);
1026
+ const write = (file, content, rootDir = templateDir) => {
1027
+ const fullPath = path.join(rootDir, file);
1028
+ const stats = fs.statSync(fullPath);
1029
+ const targetPath = rootDir === templateDir ? path.join(root, renameFiles[file] ?? file) : path.join(root, rootDir.substring(templateDir.length), renameFiles[file] ?? file);
1030
+ if (stats.isDirectory()) {
1031
+ fs.mkdirSync(targetPath, { recursive: true });
1032
+ const files$1 = fs.readdirSync(fullPath);
1033
+ for (const file$1 of files$1) write(file$1, void 0, fullPath);
1034
+ return;
1035
+ }
1026
1036
  if (content) {
1027
1037
  fs.writeFileSync(targetPath, content);
1028
1038
  return;
1029
1039
  }
1030
- if (file.endsWith(".html") || file === "README.md" || file.startsWith("sammi.config.")) {
1031
- const templatePath = path.join(templateDir, file);
1040
+ if (file === "external.html" || file === "README.md" || file.startsWith("sammi.config.")) {
1041
+ const templatePath = fullPath;
1032
1042
  const updatedContent = fs.readFileSync(templatePath, "utf-8").replace(/{{EXTENSION_ID}}/g, extensionID).replace(/{{EXTENSION_NAME}}/g, extensionName).replace(/{{CREATE_VERSION}}/g, version);
1033
1043
  fs.writeFileSync(targetPath, updatedContent);
1034
1044
  return;
1035
1045
  }
1036
- copy(path.join(templateDir, file), targetPath);
1046
+ copy(fullPath, targetPath);
1037
1047
  };
1038
1048
  const files = fs.readdirSync(templateDir);
1039
1049
  for (const file of files.filter((f) => f !== "package.json")) write(file);
@@ -1077,7 +1087,7 @@ function emptyDir(dir) {
1077
1087
  }
1078
1088
  }
1079
1089
  function isValidExtensionName(projectName) {
1080
- return /^[a-zA-Z0-9 -_]+$/.test(projectName);
1090
+ return /^[a-zA-Z0-9 -_]*$/.test(projectName);
1081
1091
  }
1082
1092
  function isValidExtensionID(projectName) {
1083
1093
  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.1.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -39,10 +39,6 @@ export default defineConfig([
39
39
  'error',
40
40
  { varsIgnorePattern: '^[A-Z_]' }
41
41
  ],
42
- "@typescript-eslint/no-explicit-any": [
43
- "warn",
44
- { fixToUnknown: true },
45
- ],
46
42
  },
47
43
  },
48
44
  {
@@ -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
  }
@@ -1,4 +1,5 @@
1
- import { defineConfig } from 'sammi-next/config'
1
+ // @ts-check
2
+ import { defineConfig } from 'sammi-next/config';
2
3
 
3
4
  export default defineConfig({
4
5
  id: "{{EXTENSION_ID}}",
@@ -47,7 +47,7 @@ export default defineConfig([
47
47
  {
48
48
  name: "general rules",
49
49
  rules: {
50
- 'no-unused-vars': [
50
+ '@typescript-eslint/no-unused-vars': [
51
51
  'error',
52
52
  { varsIgnorePattern: '^[A-Z_]' }
53
53
  ],
@@ -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
  }
@@ -1,4 +1,4 @@
1
- import { defineConfig } from 'sammi-next/config'
1
+ import { defineConfig } from 'sammi-next/config';
2
2
 
3
3
  export default defineConfig({
4
4
  id: "{{EXTENSION_ID}}",
@@ -39,10 +39,6 @@ export default defineConfig([
39
39
  'error',
40
40
  { varsIgnorePattern: '^[A-Z_]' }
41
41
  ],
42
- "@typescript-eslint/no-explicit-any": [
43
- "warn",
44
- { fixToUnknown: true },
45
- ],
46
42
  },
47
43
  },
48
44
  {
@@ -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
  }
@@ -1,4 +1,5 @@
1
- import { defineConfig } from 'sammi-next/config'
1
+ // @ts-check
2
+ import { defineConfig } from 'sammi-next/config';
2
3
 
3
4
  export default defineConfig({
4
5
  id: "{{EXTENSION_ID}}",
@@ -47,7 +47,7 @@ export default defineConfig([
47
47
  {
48
48
  name: "general rules",
49
49
  rules: {
50
- 'no-unused-vars': [
50
+ '@typescript-eslint/no-unused-vars': [
51
51
  'error',
52
52
  { varsIgnorePattern: '^[A-Z_]' }
53
53
  ],
@@ -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
  }
@@ -1,4 +1,4 @@
1
- import { defineConfig } from 'sammi-next/config'
1
+ import { defineConfig } from 'sammi-next/config';
2
2
 
3
3
  export default defineConfig({
4
4
  id: "{{EXTENSION_ID}}",
@@ -39,10 +39,6 @@ export default defineConfig([
39
39
  'error',
40
40
  { varsIgnorePattern: '^[A-Z_]' }
41
41
  ],
42
- "@typescript-eslint/no-explicit-any": [
43
- "warn",
44
- { fixToUnknown: true },
45
- ],
46
42
  },
47
43
  },
48
44
  {
@@ -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
  }
@@ -1,4 +1,5 @@
1
- import { defineConfig } from 'sammi-next/config'
1
+ // @ts-check
2
+ import { defineConfig } from 'sammi-next/config';
2
3
 
3
4
  export default defineConfig({
4
5
  id: "{{EXTENSION_ID}}",
@@ -47,7 +47,7 @@ export default defineConfig([
47
47
  {
48
48
  name: "general rules",
49
49
  rules: {
50
- 'no-unused-vars': [
50
+ '@typescript-eslint/no-unused-vars': [
51
51
  'error',
52
52
  { varsIgnorePattern: '^[A-Z_]' }
53
53
  ],
@@ -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
  }
@@ -1,4 +1,4 @@
1
- import { defineConfig } from 'sammi-next/config'
1
+ import { defineConfig } from 'sammi-next/config';
2
2
 
3
3
  export default defineConfig({
4
4
  id: "{{EXTENSION_ID}}",