create-glosc 0.2.0 → 0.2.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/README.md CHANGED
@@ -31,8 +31,7 @@ License: MIT
31
31
  ```sh
32
32
 
33
33
  <your-project-name>/
34
- ├── src/ # 源代码目录
35
- │ ├── main.py # MCP Server 入口 (Python, stdio)
34
+ ├── main.py # MCP Server 入口 (Python, stdio)
36
35
  ├── pyproject.toml # 项目配置
37
36
  ├── requirements.txt # 依赖文件
38
37
  ├── config.yml # 配置文件
@@ -59,7 +58,7 @@ Python:
59
58
 
60
59
  ```sh
61
60
  python -m pip install -r requirements.txt
62
- python src/main.py
61
+ python main.py
63
62
  ```
64
63
 
65
64
  TypeScript:
package/dist/index.js CHANGED
@@ -124,6 +124,11 @@ function normalizeMainFileName(language, mainFileNameRaw) {
124
124
  return base;
125
125
  return `${base}${defaultExt}`;
126
126
  }
127
+ function normalizeProjectName(value) {
128
+ return String(value || "")
129
+ .trim()
130
+ .replace(/\s+/g, "-");
131
+ }
127
132
  function getDefaultAuthor() {
128
133
  const candidates = [
129
134
  process.env.GIT_AUTHOR_NAME,
@@ -157,7 +162,7 @@ async function run() {
157
162
  }
158
163
  const language = normalizeLanguage(args.language) || "typescript";
159
164
  const options = {
160
- projectName: String(args.projectName).trim(),
165
+ projectName: normalizeProjectName(args.projectName),
161
166
  description: String(args.description || "A brief description of your project").trim(),
162
167
  author: String(args.author || getDefaultAuthor()).trim(),
163
168
  language,
@@ -254,7 +259,7 @@ async function run() {
254
259
  return;
255
260
  }
256
261
  const options = {
257
- projectName: String(response.projectName).trim(),
262
+ projectName: normalizeProjectName(response.projectName),
258
263
  description: String(response.description || "").trim(),
259
264
  author: String(response.author || "").trim(),
260
265
  language: response.language,
package/dist/templates.js CHANGED
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getProjectFiles = getProjectFiles;
4
+ function entryPath(options) {
5
+ return options.language === "python"
6
+ ? options.mainFileName
7
+ : `src/${options.mainFileName}`;
8
+ }
4
9
  function escapeYamlString(value) {
5
10
  const s = String(value ?? "");
6
11
  const escaped = s.replace(/"/g, '\\"');
@@ -14,7 +19,7 @@ function mitLicenseText({ author }) {
14
19
  function projectReadme(options) {
15
20
  const { projectName, description, author, language, mainFileName } = options;
16
21
  const langLabel = language === "python" ? "Python" : "TypeScript";
17
- const entry = `src/${mainFileName}`;
22
+ const entry = entryPath(options);
18
23
  const runSection = language === "python"
19
24
  ? `## Run (Python)\n\n\n\n1) Install deps\n\n\n\n\`\`\`sh\npython -m pip install -r requirements.txt\n\`\`\`\n\n\n\n2) Run the MCP server (stdio)\n\n\n\n\`\`\`sh\npython ${entry}\n\`\`\`\n\n\n\nThis server speaks MCP over stdio. Connect using an MCP client (e.g. an editor integration).\n`
20
25
  : `## Run (TypeScript)\n\n\n\n1) Install deps\n\n\n\n\`\`\`sh\nnpm install\n\`\`\`\n\n\n\n2) Build\n\n\n\n\`\`\`sh\nnpm run build\n\`\`\`\n\n\n\n3) Run the MCP server (stdio)\n\n\n\n\`\`\`sh\nnpm start\n\`\`\`\n\n\n\nThis server speaks MCP over stdio. Connect using an MCP client (e.g. an editor integration).\n`;
@@ -27,7 +32,7 @@ function configYml(options) {
27
32
  `description: ${escapeYamlString(description)}`,
28
33
  `author: ${escapeYamlString(author)}`,
29
34
  `language: ${escapeYamlString(language)}`,
30
- `entry: ${escapeYamlString(`src/${mainFileName}`)}`,
35
+ `entry: ${escapeYamlString(entryPath(options))}`,
31
36
  "",
32
37
  ].join("\n");
33
38
  }
@@ -110,7 +115,7 @@ function getProjectFiles(options) {
110
115
  }
111
116
  if (options.language === "python") {
112
117
  files.push({
113
- relativePath: `src/${options.mainFileName}`,
118
+ relativePath: options.mainFileName,
114
119
  content: pythonMain(options),
115
120
  });
116
121
  files.push({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-glosc",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Scaffold Glosc projects (Python/TypeScript) via npm create",
5
5
  "author": "glosc-ai",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -129,6 +129,12 @@ function normalizeMainFileName(
129
129
  return `${base}${defaultExt}`;
130
130
  }
131
131
 
132
+ function normalizeProjectName(value: unknown): string {
133
+ return String(value || "")
134
+ .trim()
135
+ .replace(/\s+/g, "-");
136
+ }
137
+
132
138
  function getDefaultAuthor(): string {
133
139
  const candidates = [
134
140
  process.env.GIT_AUTHOR_NAME,
@@ -168,7 +174,7 @@ async function run(): Promise<void> {
168
174
  const language = normalizeLanguage(args.language) || "typescript";
169
175
 
170
176
  const options: ProjectOptions = {
171
- projectName: String(args.projectName).trim(),
177
+ projectName: normalizeProjectName(args.projectName),
172
178
  description: String(
173
179
  args.description || "A brief description of your project"
174
180
  ).trim(),
@@ -276,7 +282,7 @@ async function run(): Promise<void> {
276
282
  }
277
283
 
278
284
  const options: ProjectOptions = {
279
- projectName: String(response.projectName).trim(),
285
+ projectName: normalizeProjectName(response.projectName),
280
286
  description: String(response.description || "").trim(),
281
287
  author: String(response.author || "").trim(),
282
288
  language: response.language as Language,
package/src/templates.ts CHANGED
@@ -15,6 +15,12 @@ export type ProjectFile = {
15
15
  content: string;
16
16
  };
17
17
 
18
+ function entryPath(options: ProjectOptions): string {
19
+ return options.language === "python"
20
+ ? options.mainFileName
21
+ : `src/${options.mainFileName}`;
22
+ }
23
+
18
24
  function escapeYamlString(value: unknown): string {
19
25
  const s = String(value ?? "");
20
26
  const escaped = s.replace(/"/g, '\\"');
@@ -32,7 +38,7 @@ function projectReadme(options: ProjectOptions): string {
32
38
  options;
33
39
  const langLabel = language === "python" ? "Python" : "TypeScript";
34
40
 
35
- const entry = `src/${mainFileName}`;
41
+ const entry = entryPath(options);
36
42
  const runSection =
37
43
  language === "python"
38
44
  ? `## Run (Python)\n\n\n\n1) Install deps\n\n\n\n\`\`\`sh\npython -m pip install -r requirements.txt\n\`\`\`\n\n\n\n2) Run the MCP server (stdio)\n\n\n\n\`\`\`sh\npython ${entry}\n\`\`\`\n\n\n\nThis server speaks MCP over stdio. Connect using an MCP client (e.g. an editor integration).\n`
@@ -51,7 +57,7 @@ function configYml(options: ProjectOptions): string {
51
57
  `description: ${escapeYamlString(description)}`,
52
58
  `author: ${escapeYamlString(author)}`,
53
59
  `language: ${escapeYamlString(language)}`,
54
- `entry: ${escapeYamlString(`src/${mainFileName}`)}`,
60
+ `entry: ${escapeYamlString(entryPath(options))}`,
55
61
  "",
56
62
  ].join("\n");
57
63
  }
@@ -163,7 +169,7 @@ export function getProjectFiles(options: ProjectOptions): ProjectFile[] {
163
169
 
164
170
  if (options.language === "python") {
165
171
  files.push({
166
- relativePath: `src/${options.mainFileName}`,
172
+ relativePath: options.mainFileName,
167
173
  content: pythonMain(options),
168
174
  });
169
175
  files.push({