@book000/create-ts 0.1.257 → 0.1.259

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/dist/index.mjs CHANGED
@@ -108,7 +108,7 @@ function updateDepcheck(depcheckJson, depcheckIgnore, test) {
108
108
  */
109
109
  function validateProjectName(value) {
110
110
  if (!value) return "プロジェクト名は必須です";
111
- if (value.length > 214 || !/^[a-z0-9][a-z0-9\-_.]*$/.test(value)) return "プロジェクト名は小文字英数字・ハイフン・アンダースコア・ドットのみ使用できます(最大 214 文字)";
111
+ return value.length > 214 || !/^[a-z0-9][a-z0-9\-_.]*$/.test(value) ? "プロジェクト名は小文字英数字・ハイフン・アンダースコア・ドットのみ使用できます(最大 214 文字)" : void 0;
112
112
  }
113
113
  /**
114
114
  * GitHub 組織 / ユーザー名を検証する。
@@ -116,7 +116,7 @@ function validateProjectName(value) {
116
116
  */
117
117
  function validateOrgName(value) {
118
118
  if (!value) return "組織 / ユーザー名は必須です";
119
- if (!/^[a-zA-Z0-9][a-zA-Z0-9\-.]*$/.test(value)) return "組織 / ユーザー名は英数字・ハイフン・ドットのみ使用できます";
119
+ return /^[a-zA-Z0-9][a-zA-Z0-9\-.]*$/.test(value) ? void 0 : "組織 / ユーザー名は英数字・ハイフン・ドットのみ使用できます";
120
120
  }
121
121
  /**
122
122
  * リポジトリ名を検証する。
@@ -124,7 +124,7 @@ function validateOrgName(value) {
124
124
  */
125
125
  function validateRepoName(value) {
126
126
  if (!value) return "リポジトリ名は必須です";
127
- if (!/^[a-zA-Z0-9_][a-zA-Z0-9\-_.]*$/.test(value)) return "リポジトリ名は英数字・ハイフン・アンダースコア・ドットのみ使用できます";
127
+ return /^[a-zA-Z0-9_][a-zA-Z0-9\-_.]*$/.test(value) ? void 0 : "リポジトリ名は英数字・ハイフン・アンダースコア・ドットのみ使用できます";
128
128
  }
129
129
  /**
130
130
  * SPDX ライセンス識別子を検証する。
@@ -132,7 +132,7 @@ function validateRepoName(value) {
132
132
  */
133
133
  function validateLicense(value) {
134
134
  if (!value) return "ライセンス識別子は必須です";
135
- if (!/^[a-zA-Z0-9.-]+$/.test(value)) return "ライセンス識別子は英数字・ドット・ハイフンのみ使用できます(例: MIT, Apache-2.0)";
135
+ return /^[a-zA-Z0-9.-]+$/.test(value) ? void 0 : "ライセンス識別子は英数字・ドット・ハイフンのみ使用できます(例: MIT, Apache-2.0)";
136
136
  }
137
137
  //#endregion
138
138
  //#region src/prompts.ts
@@ -175,10 +175,9 @@ function validateCliFlags(flags) {
175
175
  process.exit(1);
176
176
  }
177
177
  }
178
- if (flags.variant !== void 0 && !VALID_VARIANTS.includes(flags.variant)) {
179
- log.error(`Invalid --variant: "${flags.variant}". Must be one of: ${VALID_VARIANTS.join(", ")}`);
180
- process.exit(1);
181
- }
178
+ if (flags.variant === void 0 || VALID_VARIANTS.includes(flags.variant)) return;
179
+ log.error(`Invalid --variant: "${flags.variant}". Must be one of: ${VALID_VARIANTS.join(", ")}`);
180
+ process.exit(1);
182
181
  }
183
182
  /**
184
183
  * 対話プロンプトで ProjectOptions を収集する。
@@ -327,10 +326,9 @@ function displaySummary(options) {
327
326
  */
328
327
  async function confirmOverwrite(outDir) {
329
328
  const confirmed = await confirm({ message: `${outDir} に既存のファイルがあります。上書きしますか?` });
330
- if (!confirmed || isCancel(confirmed)) {
331
- cancel("セットアップを中断しました");
332
- process.exit(0);
333
- }
329
+ if (confirmed && !isCancel(confirmed)) return;
330
+ cancel("セットアップを中断しました");
331
+ process.exit(0);
334
332
  }
335
333
  //#endregion
336
334
  //#region src/index.ts
@@ -374,7 +372,7 @@ async function main() {
374
372
  /** CLI で明示的に指定されたかどうか確認して boolean | undefined を返す */
375
373
  const getCLIBoolFlag = (name) => {
376
374
  const source = program.getOptionValueSource(name);
377
- if (source === "cli" || source === "env") return opts[name];
375
+ return source === "cli" || source === "env" ? opts[name] : void 0;
378
376
  };
379
377
  intro("create-ts");
380
378
  const s = spinner();
@@ -415,17 +413,16 @@ async function main() {
415
413
  ".depcheckrc.json",
416
414
  ".fixpackrc",
417
415
  "pnpm-workspace.yaml",
418
- ".devcontainer/devcontainer.json"
416
+ ".devcontainer/devcontainer.json",
417
+ ...options.docker ? ["Dockerfile", "entrypoint.sh"] : []
419
418
  ];
420
- if (options.docker) commonFiles.push("Dockerfile", "entrypoint.sh");
421
419
  s.start("共通ファイルをコピーしています...");
422
420
  for (const file of commonFiles) {
423
421
  const content = readTemplate(`nodejs/common/${file}`);
424
422
  writeFile(path.join(outDir, file), content);
425
423
  }
426
424
  s.stop(`共通ファイルをコピーしました (${commonFiles.length} ファイル)`);
427
- const filesToCopy = [...templateConfig.src];
428
- if (options.test && templateConfig.testSrc) filesToCopy.push(...templateConfig.testSrc);
425
+ const filesToCopy = [...templateConfig.src, ...options.test && templateConfig.testSrc ? templateConfig.testSrc : []];
429
426
  s.start("src ファイルをコピーしています...");
430
427
  for (const srcFile of filesToCopy) {
431
428
  const content = readTemplate(`nodejs/${options.variant}/${srcFile}`);
package/dist/src/index.js CHANGED
@@ -76,10 +76,9 @@ async function main() {
76
76
  /** CLI で明示的に指定されたかどうか確認して boolean | undefined を返す */
77
77
  const getCLIBoolFlag = (name) => {
78
78
  const source = program.getOptionValueSource(name);
79
- if (source === 'cli' || source === 'env') {
80
- return opts[name];
81
- }
82
- return undefined;
79
+ return source === 'cli' || source === 'env'
80
+ ? opts[name]
81
+ : undefined;
83
82
  };
84
83
  intro('create-ts');
85
84
  // ステップ 1: 前提チェック
@@ -135,10 +134,8 @@ async function main() {
135
134
  '.fixpackrc',
136
135
  'pnpm-workspace.yaml',
137
136
  '.devcontainer/devcontainer.json',
137
+ ...(options.docker ? ['Dockerfile', 'entrypoint.sh'] : []),
138
138
  ];
139
- if (options.docker) {
140
- commonFiles.push('Dockerfile', 'entrypoint.sh');
141
- }
142
139
  s.start('共通ファイルをコピーしています...');
143
140
  for (const file of commonFiles) {
144
141
  const content = readTemplate(`nodejs/common/${file}`);
@@ -146,10 +143,10 @@ async function main() {
146
143
  }
147
144
  s.stop(`共通ファイルをコピーしました (${commonFiles.length} ファイル)`);
148
145
  // ステップ 4: バリアント src ファイルのコピー
149
- const filesToCopy = [...templateConfig.src];
150
- if (options.test && templateConfig.testSrc) {
151
- filesToCopy.push(...templateConfig.testSrc);
152
- }
146
+ const filesToCopy = [
147
+ ...templateConfig.src,
148
+ ...(options.test && templateConfig.testSrc ? templateConfig.testSrc : []),
149
+ ];
153
150
  s.start('src ファイルをコピーしています...');
154
151
  for (const srcFile of filesToCopy) {
155
152
  const content = readTemplate(`nodejs/${options.variant}/${srcFile}`);
@@ -39,11 +39,12 @@ function validateCliFlags(flags) {
39
39
  process.exit(1);
40
40
  }
41
41
  }
42
- if (flags.variant !== undefined && !VALID_VARIANTS.includes(flags.variant)) {
43
- log.error(`Invalid --variant: "${flags.variant}". Must be one of: ${VALID_VARIANTS.join(', ')}`);
44
- // eslint-disable-next-line unicorn/no-process-exit
45
- process.exit(1);
42
+ if (flags.variant === undefined || VALID_VARIANTS.includes(flags.variant)) {
43
+ return;
46
44
  }
45
+ log.error(`Invalid --variant: "${flags.variant}". Must be one of: ${VALID_VARIANTS.join(', ')}`);
46
+ // eslint-disable-next-line unicorn/no-process-exit
47
+ process.exit(1);
47
48
  }
48
49
  /**
49
50
  * 対話プロンプトで ProjectOptions を収集する。
@@ -227,9 +228,10 @@ export async function confirmOverwrite(outDir) {
227
228
  const confirmed = await confirm({
228
229
  message: `${outDir} に既存のファイルがあります。上書きしますか?`,
229
230
  });
230
- if (!confirmed || isCancel(confirmed)) {
231
- cancel('セットアップを中断しました');
232
- // eslint-disable-next-line unicorn/no-process-exit
233
- process.exit(0);
231
+ if (confirmed && !isCancel(confirmed)) {
232
+ return;
234
233
  }
234
+ cancel('セットアップを中断しました');
235
+ // eslint-disable-next-line unicorn/no-process-exit
236
+ process.exit(0);
235
237
  }
@@ -5,10 +5,9 @@
5
5
  export function validateProjectName(value) {
6
6
  if (!value)
7
7
  return 'プロジェクト名は必須です';
8
- if (value.length > 214 || !/^[a-z0-9][a-z0-9\-_.]*$/.test(value)) {
9
- return 'プロジェクト名は小文字英数字・ハイフン・アンダースコア・ドットのみ使用できます(最大 214 文字)';
10
- }
11
- return undefined;
8
+ return value.length > 214 || !/^[a-z0-9][a-z0-9\-_.]*$/.test(value)
9
+ ? 'プロジェクト名は小文字英数字・ハイフン・アンダースコア・ドットのみ使用できます(最大 214 文字)'
10
+ : undefined;
12
11
  }
13
12
  /**
14
13
  * GitHub 組織 / ユーザー名を検証する。
@@ -17,10 +16,9 @@ export function validateProjectName(value) {
17
16
  export function validateOrgName(value) {
18
17
  if (!value)
19
18
  return '組織 / ユーザー名は必須です';
20
- if (!/^[a-zA-Z0-9][a-zA-Z0-9\-.]*$/.test(value)) {
21
- return '組織 / ユーザー名は英数字・ハイフン・ドットのみ使用できます';
22
- }
23
- return undefined;
19
+ return /^[a-zA-Z0-9][a-zA-Z0-9\-.]*$/.test(value)
20
+ ? undefined
21
+ : '組織 / ユーザー名は英数字・ハイフン・ドットのみ使用できます';
24
22
  }
25
23
  /**
26
24
  * リポジトリ名を検証する。
@@ -29,10 +27,9 @@ export function validateOrgName(value) {
29
27
  export function validateRepoName(value) {
30
28
  if (!value)
31
29
  return 'リポジトリ名は必須です';
32
- if (!/^[a-zA-Z0-9_][a-zA-Z0-9\-_.]*$/.test(value)) {
33
- return 'リポジトリ名は英数字・ハイフン・アンダースコア・ドットのみ使用できます';
34
- }
35
- return undefined;
30
+ return /^[a-zA-Z0-9_][a-zA-Z0-9\-_.]*$/.test(value)
31
+ ? undefined
32
+ : 'リポジトリ名は英数字・ハイフン・アンダースコア・ドットのみ使用できます';
36
33
  }
37
34
  /**
38
35
  * SPDX ライセンス識別子を検証する。
@@ -41,8 +38,7 @@ export function validateRepoName(value) {
41
38
  export function validateLicense(value) {
42
39
  if (!value)
43
40
  return 'ライセンス識別子は必須です';
44
- if (!/^[a-zA-Z0-9.-]+$/.test(value)) {
45
- return 'ライセンス識別子は英数字・ドット・ハイフンのみ使用できます(例: MIT, Apache-2.0)';
46
- }
47
- return undefined;
41
+ return /^[a-zA-Z0-9.-]+$/.test(value)
42
+ ? undefined
43
+ : 'ライセンス識別子は英数字・ドット・ハイフンのみ使用できます(例: MIT, Apache-2.0)';
48
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@book000/create-ts",
3
- "version": "0.1.257",
3
+ "version": "0.1.259",
4
4
  "description": "Create book000-style TypeScript projects",
5
5
  "repository": {
6
6
  "type": "git",
@@ -29,7 +29,7 @@
29
29
  "execa": "10.0.1"
30
30
  },
31
31
  "devDependencies": {
32
- "@book000/eslint-config": "1.16.66",
32
+ "@book000/eslint-config": "1.16.68",
33
33
  "@types/node": "25.9.7",
34
34
  "eslint": "10.10.0",
35
35
  "prettier": "3.9.8",
@@ -18,7 +18,7 @@
18
18
  "fix:prettier": "prettier --write src/"
19
19
  },
20
20
  "devDependencies": {
21
- "@book000/eslint-config": "1.16.66",
21
+ "@book000/eslint-config": "1.16.68",
22
22
  "@types/jest": "30.0.0",
23
23
  "@types/node": "25.9.7",
24
24
  "eslint": "10.10.0",
@@ -22,7 +22,7 @@
22
22
  "@book000/node-utils": "1.25.115"
23
23
  },
24
24
  "devDependencies": {
25
- "@book000/eslint-config": "1.16.66",
25
+ "@book000/eslint-config": "1.16.68",
26
26
  "@types/jest": "30.0.0",
27
27
  "@types/node": "25.9.7",
28
28
  "eslint": "10.10.0",
@@ -23,7 +23,7 @@
23
23
  "discord.js": "14.27.0"
24
24
  },
25
25
  "devDependencies": {
26
- "@book000/eslint-config": "1.16.66",
26
+ "@book000/eslint-config": "1.16.68",
27
27
  "@types/jest": "30.0.0",
28
28
  "@types/node": "25.9.7",
29
29
  "eslint": "10.10.0",
@@ -22,7 +22,7 @@
22
22
  "fastify": "5.12.5"
23
23
  },
24
24
  "devDependencies": {
25
- "@book000/eslint-config": "1.16.66",
25
+ "@book000/eslint-config": "1.16.68",
26
26
  "@types/jest": "30.0.0",
27
27
  "@types/node": "25.9.7",
28
28
  "eslint": "10.10.0",