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 +30 -12
- package/dist/index.js +19 -9
- package/package.json +1 -1
- package/template-minimal-js/eslint.config.mjs +0 -4
- package/template-minimal-js/package.json +1 -1
- package/template-minimal-js/sammi.config.js +2 -1
- package/template-minimal-ts/eslint.config.mjs +1 -1
- package/template-minimal-ts/package.json +1 -1
- package/template-minimal-ts/sammi.config.ts +1 -1
- package/template-sample-js/eslint.config.mjs +0 -4
- package/template-sample-js/package.json +1 -1
- package/template-sample-js/sammi.config.js +2 -1
- package/template-sample-ts/eslint.config.mjs +1 -1
- package/template-sample-ts/package.json +1 -1
- package/template-sample-ts/sammi.config.ts +1 -1
- package/template-vanilla-js/eslint.config.mjs +0 -4
- package/template-vanilla-js/package.json +1 -1
- package/template-vanilla-js/sammi.config.js +2 -1
- package/template-vanilla-ts/eslint.config.mjs +1 -1
- package/template-vanilla-ts/package.json +1 -1
- package/template-vanilla-ts/sammi.config.ts +1 -1
package/README.md
CHANGED
|
@@ -3,33 +3,53 @@
|
|
|
3
3
|
## Scaffolding Your First SAMMI Next Project
|
|
4
4
|
|
|
5
5
|
With NPM:
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm create sammi-next@latest
|
|
9
|
+
```
|
|
7
10
|
|
|
8
11
|
With Yarn:
|
|
9
|
-
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
yan create vite
|
|
15
|
+
```
|
|
10
16
|
|
|
11
17
|
With PNPM:
|
|
12
|
-
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pnpm create sammi-next
|
|
21
|
+
```
|
|
13
22
|
|
|
14
23
|
With Bun:
|
|
15
|
-
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
bun create sammi-next
|
|
27
|
+
```
|
|
16
28
|
|
|
17
29
|
With Deno:
|
|
18
|
-
|
|
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
|
|
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
|
|
42
|
+
# yarn
|
|
43
|
+
yarn create sammi-next my-sammi-extension --template sample-ts
|
|
27
44
|
|
|
28
|
-
pnpm
|
|
45
|
+
# pnpm
|
|
46
|
+
pnpm create sammi-next my-sammi-extension --template sample-ts
|
|
29
47
|
|
|
30
|
-
|
|
48
|
+
# Bun
|
|
49
|
+
bun create sammi-next my-sammi-extension --template sample-ts
|
|
31
50
|
|
|
32
|
-
|
|
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 = "
|
|
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 (!
|
|
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
|
|
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
|
|
1031
|
-
const templatePath =
|
|
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(
|
|
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 -_]
|
|
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