@book000/create-ts 0.2.77 → 0.2.79

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.
Files changed (33) hide show
  1. package/README.md +85 -0
  2. package/dist/index.mjs +37 -32
  3. package/dist/src/generate.d.ts +11 -9
  4. package/dist/src/generate.js +11 -9
  5. package/dist/src/index.js +14 -26
  6. package/dist/src/prompts.d.ts +6 -6
  7. package/dist/src/prompts.js +10 -11
  8. package/dist/src/template.d.ts +4 -4
  9. package/dist/src/template.js +5 -5
  10. package/dist/src/types.d.ts +5 -5
  11. package/dist/src/validate.d.ts +8 -8
  12. package/dist/src/validate.js +8 -8
  13. package/dist/test/generate.test.js +22 -22
  14. package/dist/test/validate.test.js +20 -20
  15. package/dist/tsdown.config.js +2 -2
  16. package/package.json +1 -1
  17. package/templates/nodejs/base/src/main.ts +1 -1
  18. package/templates/nodejs/base/test/smoke.test.ts +7 -7
  19. package/templates/nodejs/config-batch/package.json +1 -1
  20. package/templates/nodejs/config-batch/pnpm-lock.yaml +5 -5
  21. package/templates/nodejs/config-batch/src/config.ts +2 -2
  22. package/templates/nodejs/config-batch/src/main.ts +6 -6
  23. package/templates/nodejs/config-batch/test/config.test.ts +8 -9
  24. package/templates/nodejs/discord-bot/package.json +1 -1
  25. package/templates/nodejs/discord-bot/pnpm-lock.yaml +5 -5
  26. package/templates/nodejs/discord-bot/src/config.ts +3 -3
  27. package/templates/nodejs/discord-bot/src/discord.ts +6 -6
  28. package/templates/nodejs/discord-bot/src/main.ts +4 -4
  29. package/templates/nodejs/discord-bot/test/discord.test.ts +9 -9
  30. package/templates/nodejs/fastify/src/main.ts +5 -5
  31. package/templates/nodejs/fastify/test/app.test.ts +8 -8
  32. package/templates/workflows/docker.yml +6 -7
  33. package/templates/workflows/nodejs-ci-pnpm.yml +1 -1
@@ -1,11 +1,11 @@
1
1
  import type { TemplateConfig } from './types.js';
2
2
  /**
3
- * バンドルされたテンプレートファイルを文字列として読み込む。
4
- * @param relativePath - テンプレートルートからの相対パス
3
+ * Reads a bundled template file as a string.
4
+ * @param relativePath - Path relative to the templates root
5
5
  */
6
6
  export declare function readTemplate(relativePath: string): string;
7
7
  /**
8
- * バリアントの template.json を読み込んでパースする。
9
- * @param variant - バリアント名
8
+ * Reads and parses a variant's template.json.
9
+ * @param variant - Variant name
10
10
  */
11
11
  export declare function fetchTemplateConfig(variant: string): TemplateConfig;
@@ -2,19 +2,19 @@ import { readFileSync } from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { fileURLToPath } from 'node:url';
4
4
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
5
- /** バンドルされたテンプレートのルートディレクトリ */
5
+ /** Root directory of the bundled templates. */
6
6
  const TEMPLATES_DIR = path.join(__dirname, '../templates');
7
7
  /**
8
- * バンドルされたテンプレートファイルを文字列として読み込む。
9
- * @param relativePath - テンプレートルートからの相対パス
8
+ * Reads a bundled template file as a string.
9
+ * @param relativePath - Path relative to the templates root
10
10
  */
11
11
  export function readTemplate(relativePath) {
12
12
  const filePath = path.join(TEMPLATES_DIR, relativePath);
13
13
  return readFileSync(filePath, 'utf8');
14
14
  }
15
15
  /**
16
- * バリアントの template.json を読み込んでパースする。
17
- * @param variant - バリアント名
16
+ * Reads and parses a variant's template.json.
17
+ * @param variant - Variant name
18
18
  */
19
19
  export function fetchTemplateConfig(variant) {
20
20
  const content = readTemplate(`nodejs/${variant}/template.json`);
@@ -1,6 +1,6 @@
1
- /** サポートされているプロジェクトバリアント */
1
+ /** Supported project variants. */
2
2
  export type Variant = 'base' | 'config-batch' | 'fastify' | 'discord-bot';
3
- /** プロジェクトセットアップの全オプション */
3
+ /** All options for a project setup. */
4
4
  export interface ProjectOptions {
5
5
  name: string;
6
6
  org: string;
@@ -19,15 +19,15 @@ export interface ProjectOptions {
19
19
  overwrite: boolean;
20
20
  outDir: string;
21
21
  }
22
- /** バリアントの template.json スキーマ */
22
+ /** Schema of a variant's template.json. */
23
23
  export interface TemplateConfig {
24
24
  configSchema: boolean;
25
25
  dependencies?: string[];
26
26
  devDependencies?: string[];
27
27
  scripts?: Record<string, string>;
28
28
  depcheckIgnore?: string[];
29
- /** 常にコピーする src ファイルのリスト */
29
+ /** Files always copied (paths relative to the variant directory). */
30
30
  src: string[];
31
- /** --test 有効時のみコピーするテストファイルのリスト */
31
+ /** Files copied only with --test. */
32
32
  testSrc?: string[];
33
33
  }
@@ -1,20 +1,20 @@
1
1
  /**
2
- * プロジェクト名を検証する。
3
- * npm パッケージ名規則: 小文字英数字・ハイフン・アンダースコア・ドット、214 文字以下。
2
+ * Validates a project name (npm package name rule): lowercase alphanumerics, hyphens, underscores and dots, starting with an alphanumeric, at most 214 characters.
3
+ * Returns an error message, or undefined if valid.
4
4
  */
5
5
  export declare function validateProjectName(value: string | undefined): string | undefined;
6
6
  /**
7
- * GitHub 組織 / ユーザー名を検証する。
8
- * 英数字・ハイフン・ドットのみ許容。
7
+ * Validates a GitHub organization / user name: alphanumerics, hyphens and dots, starting with an alphanumeric.
8
+ * Returns an error message, or undefined if valid.
9
9
  */
10
10
  export declare function validateOrgName(value: string | undefined): string | undefined;
11
11
  /**
12
- * リポジトリ名を検証する。
13
- * 英数字・ハイフン・アンダースコア・ドットのみ許容。先頭はアンダースコア可。
12
+ * Validates a repository name: alphanumerics, hyphens, underscores and dots; a leading underscore is allowed.
13
+ * Returns an error message, or undefined if valid.
14
14
  */
15
15
  export declare function validateRepoName(value: string | undefined): string | undefined;
16
16
  /**
17
- * SPDX ライセンス識別子を検証する。
18
- * 英数字・ドット・ハイフンのみ許容。
17
+ * Validates an SPDX license identifier by character set only (alphanumerics, dots and hyphens); it does not check that the identifier exists.
18
+ * Returns an error message, or undefined if valid.
19
19
  */
20
20
  export declare function validateLicense(value: string | undefined): string | undefined;
@@ -1,6 +1,6 @@
1
1
  /**
2
- * プロジェクト名を検証する。
3
- * npm パッケージ名規則: 小文字英数字・ハイフン・アンダースコア・ドット、214 文字以下。
2
+ * Validates a project name (npm package name rule): lowercase alphanumerics, hyphens, underscores and dots, starting with an alphanumeric, at most 214 characters.
3
+ * Returns an error message, or undefined if valid.
4
4
  */
5
5
  export function validateProjectName(value) {
6
6
  if (!value)
@@ -10,8 +10,8 @@ export function validateProjectName(value) {
10
10
  : undefined;
11
11
  }
12
12
  /**
13
- * GitHub 組織 / ユーザー名を検証する。
14
- * 英数字・ハイフン・ドットのみ許容。
13
+ * Validates a GitHub organization / user name: alphanumerics, hyphens and dots, starting with an alphanumeric.
14
+ * Returns an error message, or undefined if valid.
15
15
  */
16
16
  export function validateOrgName(value) {
17
17
  if (!value)
@@ -21,8 +21,8 @@ export function validateOrgName(value) {
21
21
  : '組織 / ユーザー名は英数字・ハイフン・ドットのみ使用できます';
22
22
  }
23
23
  /**
24
- * リポジトリ名を検証する。
25
- * 英数字・ハイフン・アンダースコア・ドットのみ許容。先頭はアンダースコア可。
24
+ * Validates a repository name: alphanumerics, hyphens, underscores and dots; a leading underscore is allowed.
25
+ * Returns an error message, or undefined if valid.
26
26
  */
27
27
  export function validateRepoName(value) {
28
28
  if (!value)
@@ -32,8 +32,8 @@ export function validateRepoName(value) {
32
32
  : 'リポジトリ名は英数字・ハイフン・アンダースコア・ドットのみ使用できます';
33
33
  }
34
34
  /**
35
- * SPDX ライセンス識別子を検証する。
36
- * 英数字・ドット・ハイフンのみ許容。
35
+ * Validates an SPDX license identifier by character set only (alphanumerics, dots and hyphens); it does not check that the identifier exists.
36
+ * Returns an error message, or undefined if valid.
37
37
  */
38
38
  export function validateLicense(value) {
39
39
  if (!value)
@@ -1,7 +1,7 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
  import { generateGitignore, patchDockerWorkflow, patchPackageJson, patchTsConfig, updateDepcheck, } from '../src/generate.js';
3
- // ---- テスト用フィクスチャ ----
4
- /** テンプレートの tsconfig.json に相当するベースオブジェクト */
3
+ // ---- Test fixtures ----
4
+ /** Base object equivalent to the template tsconfig.json. */
5
5
  const BASE_TSCONFIG = {
6
6
  compilerOptions: {
7
7
  target: 'es2020',
@@ -12,7 +12,7 @@ const BASE_TSCONFIG = {
12
12
  },
13
13
  include: ['src/**/*'],
14
14
  };
15
- /** テンプレートの package.json に相当するベースオブジェクト */
15
+ /** Base object equivalent to the template package.json. */
16
16
  const BASE_PACKAGE_JSON = {
17
17
  name: '@book000/template',
18
18
  version: '1.0.0',
@@ -51,58 +51,58 @@ describe('patchPackageJson', () => {
51
51
  esm: false,
52
52
  test: false,
53
53
  };
54
- it('org が大文字でも name が小文字化される', () => {
54
+ it('lowercases the org in name even if it is uppercase', () => {
55
55
  const result = patchPackageJson(BASE_PACKAGE_JSON, { ...baseOptions, org: 'Book000' }, 20);
56
56
  expect(result.name).toBe('@book000/my-app');
57
57
  });
58
- it('--esm: type が "module" になる', () => {
58
+ it('--esm: type becomes "module"', () => {
59
59
  const result = patchPackageJson(BASE_PACKAGE_JSON, { ...baseOptions, esm: true, test: false }, 20);
60
60
  expect(result.type).toBe('module');
61
61
  });
62
- it('--esm --test: jest フィールドが ESM 用設定になる', () => {
62
+ it('--esm --test: the jest field gets the ESM config', () => {
63
63
  const result = patchPackageJson(BASE_PACKAGE_JSON, { ...baseOptions, esm: true, test: true }, 20);
64
64
  expect(result.jest.preset).toBe('ts-jest/presets/default-esm');
65
65
  expect(result.jest.extensionsToTreatAsEsm).toContain('.ts');
66
66
  });
67
- it('--no-test: scripts.test と jest フィールドが削除される', () => {
67
+ it('--no-test: scripts.test and the jest field are removed', () => {
68
68
  const result = patchPackageJson(BASE_PACKAGE_JSON, { ...baseOptions, test: false }, 20);
69
69
  expect(result.scripts.test).toBeUndefined();
70
70
  expect(result.jest).toBeUndefined();
71
71
  });
72
- it('--no-test --esm: jest フィールドが追加されない', () => {
72
+ it('--no-test --esm: the jest field is not added', () => {
73
73
  const result = patchPackageJson(BASE_PACKAGE_JSON, { ...baseOptions, esm: true, test: false }, 20);
74
74
  expect(result.jest).toBeUndefined();
75
75
  });
76
- it('homepage が空文字: homepage フィールドが追加されない', () => {
76
+ it('empty homepage: the homepage field is not added', () => {
77
77
  const result = patchPackageJson(BASE_PACKAGE_JSON, { ...baseOptions, homepage: '' }, 20);
78
78
  expect(result.homepage).toBeUndefined();
79
79
  });
80
- it('homepage が指定済み: homepage フィールドが追加される', () => {
80
+ it('homepage given: the homepage field is added', () => {
81
81
  const result = patchPackageJson(BASE_PACKAGE_JSON, { ...baseOptions, homepage: 'https://example.com' }, 20);
82
82
  expect(result.homepage).toBe('https://example.com');
83
83
  });
84
84
  });
85
85
  // ---- patchTsConfig ----
86
86
  describe('patchTsConfig', () => {
87
- it('CJS(デフォルト): module が "commonjs" のまま', () => {
87
+ it('CJS (default): module stays "commonjs"', () => {
88
88
  const result = patchTsConfig(BASE_TSCONFIG, { esm: false, test: false });
89
89
  const opts = result.compilerOptions;
90
90
  expect(opts.module).toBe('commonjs');
91
91
  expect(opts.moduleResolution).toBe('bundler');
92
92
  });
93
- it('ESM: module が "es2015" になり moduleResolution は "bundler" のまま', () => {
93
+ it('ESM: module becomes "es2015" and moduleResolution stays "bundler"', () => {
94
94
  const result = patchTsConfig(BASE_TSCONFIG, { esm: true, test: false });
95
95
  const opts = result.compilerOptions;
96
96
  expect(opts.module).toBe('es2015');
97
97
  expect(opts.moduleResolution).toBe('bundler');
98
98
  });
99
- it('--test: types に "jest" が追加される', () => {
99
+ it('--test: "jest" is added to types', () => {
100
100
  const result = patchTsConfig(BASE_TSCONFIG, { esm: false, test: true });
101
101
  const types = result.compilerOptions.types;
102
102
  expect(types).toContain('node');
103
103
  expect(types).toContain('jest');
104
104
  });
105
- it('--no-test: types が ["node"] のまま', () => {
105
+ it('--no-test: types stays ["node"]', () => {
106
106
  const result = patchTsConfig(BASE_TSCONFIG, { esm: false, test: false });
107
107
  const types = result.compilerOptions.types;
108
108
  expect(types).toEqual(['node']);
@@ -116,17 +116,17 @@ describe('patchDockerWorkflow', () => {
116
116
  { imageName: "tomacheese/twitter-dm-memo", context: ".", file: "Dockerfile", packageName: "twitter-dm-memo" }
117
117
  ]
118
118
  `.trim();
119
- it('imageName が正しく置換される', () => {
119
+ it('replaces imageName', () => {
120
120
  const result = patchDockerWorkflow(DOCKER_YML, 'book000', 'my-app');
121
121
  expect(result).toContain('book000/my-app');
122
122
  expect(result).not.toContain('tomacheese/twitter-dm-memo');
123
123
  });
124
- it('org が大文字でも GHCR パスが小文字化される', () => {
124
+ it('lowercases the GHCR path even if org is uppercase', () => {
125
125
  const result = patchDockerWorkflow(DOCKER_YML, 'Book000', 'my-app');
126
126
  expect(result).toContain('book000/my-app');
127
127
  expect(result).not.toContain('Book000');
128
128
  });
129
- it('packageName が正しく置換される', () => {
129
+ it('replaces packageName', () => {
130
130
  const result = patchDockerWorkflow(DOCKER_YML, 'book000', 'my-app');
131
131
  expect(result).toContain('packageName: "my-app"');
132
132
  expect(result).not.toContain('packageName: "twitter-dm-memo"');
@@ -134,14 +134,14 @@ describe('patchDockerWorkflow', () => {
134
134
  });
135
135
  // ---- generateGitignore ----
136
136
  describe('generateGitignore', () => {
137
- it('基本: pnpm セクションが含まれる', () => {
137
+ it('basic: includes the pnpm section', () => {
138
138
  const result = generateGitignore(false);
139
139
  expect(result).toContain('node_modules/');
140
140
  expect(result).toContain('# pnpm');
141
141
  expect(result).toContain('pnpm-debug.log*');
142
142
  expect(result).not.toContain('data/');
143
143
  });
144
- it('--ignore-data: さらに data/ セクションが追記される', () => {
144
+ it('--ignore-data: additionally appends the data/ section', () => {
145
145
  const result = generateGitignore(true);
146
146
  expect(result).toContain('# pnpm');
147
147
  expect(result).toContain('# データディレクトリ');
@@ -153,15 +153,15 @@ describe('updateDepcheck', () => {
153
153
  const BASE_DEPCHECK = {
154
154
  ignores: ['@types/node', 'run-z'],
155
155
  };
156
- it('depcheckIgnore のパッケージが ignores に追加される', () => {
156
+ it('adds the depcheckIgnore packages to ignores', () => {
157
157
  const result = updateDepcheck(BASE_DEPCHECK, ['typescript-json-schema'], false);
158
158
  expect(result.ignores).toContain('typescript-json-schema');
159
159
  });
160
- it('--test: @types/jest が ignores に追加される', () => {
160
+ it('--test: adds @types/jest to ignores', () => {
161
161
  const result = updateDepcheck(BASE_DEPCHECK, [], true);
162
162
  expect(result.ignores).toContain('@types/jest');
163
163
  });
164
- it('同一パッケージを 2 回渡しても重複しない', () => {
164
+ it('does not duplicate a package passed twice', () => {
165
165
  const result = updateDepcheck(BASE_DEPCHECK, ['typescript-json-schema', 'typescript-json-schema'], false);
166
166
  const ignores = result.ignores;
167
167
  const count = ignores.filter((i) => i === 'typescript-json-schema').length;
@@ -1,70 +1,70 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
  import { validateLicense, validateOrgName, validateProjectName, validateRepoName, } from '../src/validate.js';
3
3
  describe('validateProjectName', () => {
4
- it('my-app → 有効', () => {
4
+ it('my-app → valid', () => {
5
5
  expect(validateProjectName('my-app')).toBeUndefined();
6
6
  });
7
- it('MyApp → 無効(大文字)', () => {
7
+ it('MyApp → invalid (uppercase)', () => {
8
8
  expect(validateProjectName('MyApp')).toBeDefined();
9
9
  });
10
- it('-bad-start → 無効(ハイフン始まり)', () => {
10
+ it('-bad-start → invalid (starts with a hyphen)', () => {
11
11
  expect(validateProjectName('-bad-start')).toBeDefined();
12
12
  });
13
- it('"has space" → 無効(空白)', () => {
13
+ it('"has space" → invalid (whitespace)', () => {
14
14
  expect(validateProjectName('has space')).toBeDefined();
15
15
  });
16
- it(`${'a'.repeat(215)} → 無効(215 文字)`, () => {
16
+ it(`${'a'.repeat(215)} → invalid (215 characters)`, () => {
17
17
  expect(validateProjectName('a'.repeat(215))).toBeDefined();
18
18
  });
19
- it(`${'a'.repeat(214)} → 有効(214 文字)`, () => {
19
+ it(`${'a'.repeat(214)} → valid (214 characters)`, () => {
20
20
  expect(validateProjectName('a'.repeat(214))).toBeUndefined();
21
21
  });
22
- it('空文字 → 無効(必須)', () => {
22
+ it('empty string → invalid (required)', () => {
23
23
  expect(validateProjectName('')).toBeDefined();
24
24
  });
25
- it('undefined → 無効(必須)', () => {
25
+ it('undefined → invalid (required)', () => {
26
26
  expect(validateProjectName(undefined)).toBeDefined();
27
27
  });
28
28
  });
29
29
  describe('validateOrgName', () => {
30
- it('book000 → 有効', () => {
30
+ it('book000 → valid', () => {
31
31
  expect(validateOrgName('book000')).toBeUndefined();
32
32
  });
33
- it('Book.000 → 有効(大文字・ドット許容)', () => {
33
+ it('Book.000 → valid (uppercase and dots allowed)', () => {
34
34
  expect(validateOrgName('Book.000')).toBeUndefined();
35
35
  });
36
- it('"bad org!" → 無効(空白・記号)', () => {
36
+ it('"bad org!" → invalid (whitespace and symbols)', () => {
37
37
  expect(validateOrgName('bad org!')).toBeDefined();
38
38
  });
39
- it('空文字 → 無効(必須)', () => {
39
+ it('empty string → invalid (required)', () => {
40
40
  expect(validateOrgName('')).toBeDefined();
41
41
  });
42
42
  });
43
43
  describe('validateRepoName', () => {
44
- it('my-repo → 有効', () => {
44
+ it('my-repo → valid', () => {
45
45
  expect(validateRepoName('my-repo')).toBeUndefined();
46
46
  });
47
- it('_private → 有効(アンダースコア始まり)', () => {
47
+ it('_private → valid (leading underscore)', () => {
48
48
  expect(validateRepoName('_private')).toBeUndefined();
49
49
  });
50
- it('-bad → 無効(ハイフン始まり)', () => {
50
+ it('-bad → invalid (starts with a hyphen)', () => {
51
51
  expect(validateRepoName('-bad')).toBeDefined();
52
52
  });
53
- it('空文字 → 無効(必須)', () => {
53
+ it('empty string → invalid (required)', () => {
54
54
  expect(validateRepoName('')).toBeDefined();
55
55
  });
56
56
  });
57
57
  describe('validateLicense', () => {
58
- it('MIT → 有効', () => {
58
+ it('MIT → valid', () => {
59
59
  expect(validateLicense('MIT')).toBeUndefined();
60
60
  });
61
- it('Apache-2.0 → 有効', () => {
61
+ it('Apache-2.0 → valid', () => {
62
62
  expect(validateLicense('Apache-2.0')).toBeUndefined();
63
63
  });
64
- it('"MIT License" → 無効(空白)', () => {
64
+ it('"MIT License" → invalid (whitespace)', () => {
65
65
  expect(validateLicense('MIT License')).toBeDefined();
66
66
  });
67
- it('空文字 → 無効(必須)', () => {
67
+ it('empty string → invalid (required)', () => {
68
68
  expect(validateLicense('')).toBeDefined();
69
69
  });
70
70
  });
@@ -5,5 +5,5 @@ export default defineConfig({
5
5
  target: 'node20',
6
6
  clean: true,
7
7
  });
8
- // 注意: src/index.ts の先頭行に `#!/usr/bin/env node` を記載すること。
9
- // tsdown がシェバンを検出し、出力ファイルへの保持と chmod +x を自動で行う(banner オプション不要)。
8
+ // Keep `#!/usr/bin/env node` as the first line of src/index.ts.
9
+ // tsdown detects the shebang, preserves it in the output and runs chmod +x (no banner option needed).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@book000/create-ts",
3
- "version": "0.2.77",
3
+ "version": "0.2.79",
4
4
  "description": "Create book000-style TypeScript projects",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,5 +1,5 @@
1
1
  /**
2
- * エントリポイント
2
+ * Entry point.
3
3
  */
4
4
  // eslint-disable-next-line @typescript-eslint/require-await
5
5
  async function main(): Promise<void> {
@@ -1,12 +1,12 @@
1
1
  /**
2
- * base バリアントのスモークテスト
2
+ * Smoke tests for the base variant.
3
3
  *
4
- * TypeScript の基本機能と Node.js 組み込みモジュールの動作を確認する。
5
- * 外部サービスへの接続は行わない。
4
+ * Checks basic TypeScript features and Node.js built-in behavior.
5
+ * Does not connect to external services.
6
6
  */
7
7
 
8
- describe('TypeScript 基本機能', () => {
9
- it('async/await が動作する', async () => {
8
+ describe('TypeScript basics', () => {
9
+ it('async/await works', async () => {
10
10
  const delay = (ms: number): Promise<string> =>
11
11
  new Promise((resolve) => setTimeout(() => resolve('ok'), ms))
12
12
 
@@ -14,7 +14,7 @@ describe('TypeScript 基本機能', () => {
14
14
  expect(result).toBe('ok')
15
15
  })
16
16
 
17
- it('ジェネリクスが動作する', () => {
17
+ it('generics work', () => {
18
18
  function identity<T>(value: T): T {
19
19
  return value
20
20
  }
@@ -22,7 +22,7 @@ describe('TypeScript 基本機能', () => {
22
22
  expect(identity('hello')).toBe('hello')
23
23
  })
24
24
 
25
- it('Error のスローと catch が動作する', async () => {
25
+ it('throwing and catching an Error works', async () => {
26
26
  const failingFn = async (): Promise<never> => {
27
27
  throw new Error('test error')
28
28
  }
@@ -19,7 +19,7 @@
19
19
  "generate-schema": "typescript-json-schema --required src/config.ts ConfigInterface -o schema/Configuration.json"
20
20
  },
21
21
  "dependencies": {
22
- "@book000/node-utils": "1.26.9"
22
+ "@book000/node-utils": "1.26.10"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@book000/eslint-config": "1.16.119",
@@ -9,8 +9,8 @@ importers:
9
9
  .:
10
10
  dependencies:
11
11
  '@book000/node-utils':
12
- specifier: 1.26.9
13
- version: 1.26.9
12
+ specifier: 1.26.10
13
+ version: 1.26.10
14
14
  devDependencies:
15
15
  '@book000/eslint-config':
16
16
  specifier: 1.16.119
@@ -218,8 +218,8 @@ packages:
218
218
  peerDependencies:
219
219
  eslint: 10.14.0
220
220
 
221
- '@book000/node-utils@1.26.9':
222
- resolution: {integrity: sha512-B95Oyn3gQtHZRoy7fuTG1ikEMmoBMdifKFmSp4tLp0Pw4V/eZ0Hut/U4MsxbEBt2iA7nssN+uyJtyeQP6sF99w==}
221
+ '@book000/node-utils@1.26.10':
222
+ resolution: {integrity: sha512-0IivH5CilLpiXKAZjGRXwlgq6z2bmxmueeSDc0UuHsVhN2cjONIi0BaGZ8SnnzZY/RKJRd1a/3VD8s7/eJVZlQ==}
223
223
 
224
224
  '@cacheable/memory@2.2.0':
225
225
  resolution: {integrity: sha512-CTLKqLItRCEixEAewD3/j9DB3/o96gpTPD4eJ1v+DGOlxZRZncRQkGYqqnAGCscYd6RNeXfGeiuCphsPtqyIfQ==}
@@ -2886,7 +2886,7 @@ snapshots:
2886
2886
  - ts-declaration-location
2887
2887
  - typescript
2888
2888
 
2889
- '@book000/node-utils@1.26.9':
2889
+ '@book000/node-utils@1.26.10':
2890
2890
  dependencies:
2891
2891
  '@sentry/node': 11.11.0
2892
2892
  cycle: 1.0.3
@@ -1,7 +1,7 @@
1
1
  /**
2
- * 設定インターフェース
2
+ * Configuration interface.
3
3
  */
4
4
  // eslint-disable-next-line @typescript-eslint/no-empty-object-type
5
5
  export interface ConfigInterface {
6
- // TODO: 設定項目を追加する
6
+ // TODO: add configuration items
7
7
  }
@@ -2,22 +2,22 @@ import { ConfigFramework } from '@book000/node-utils'
2
2
  import { ConfigInterface } from './config'
3
3
 
4
4
  /**
5
- * 設定フレームワーク実装
5
+ * Configuration framework implementation.
6
6
  */
7
7
  class Configuration extends ConfigFramework<ConfigInterface> {
8
8
  /**
9
- * バリデーションルールを返す
9
+ * Returns the validation rules.
10
10
  */
11
11
  protected validates(): Record<string, (config: ConfigInterface) => boolean> {
12
12
  return {
13
- // TODO: バリデーションルールを追加する
14
- // 例: 'someKey is required': (config) => config.someKey !== undefined,
13
+ // TODO: add validation rules
14
+ // e.g. 'someKey is required': (config) => config.someKey !== undefined,
15
15
  }
16
16
  }
17
17
  }
18
18
 
19
19
  /**
20
- * エントリポイント
20
+ * Entry point.
21
21
  */
22
22
  // eslint-disable-next-line @typescript-eslint/require-await
23
23
  async function main(): Promise<void> {
@@ -28,7 +28,7 @@ async function main(): Promise<void> {
28
28
  `Configuration validation failed: ${config.getValidateFailures().join(', ')}`
29
29
  )
30
30
  }
31
- // TODO: config.get('key') でアクセスして処理を実装する
31
+ // TODO: read settings with config.get('key') and implement the batch logic
32
32
  }
33
33
 
34
34
  main().catch((error: unknown) => {
@@ -1,9 +1,8 @@
1
1
  /**
2
- * config-batch バリアントのテスト
2
+ * Tests for the config-batch variant.
3
3
  *
4
- * @book000/node-utils の ConfigFramework が正しくサブクラス化できること、
5
- * およびバリデーションロジックが期待通りに動作することを確認する。
6
- * 外部サービスへの接続は行わない。
4
+ * Checks that ConfigFramework from @book000/node-utils can be subclassed and that the validation logic works as expected.
5
+ * Does not connect to external services.
7
6
  */
8
7
 
9
8
  import * as fs from 'node:fs'
@@ -11,13 +10,13 @@ import * as os from 'node:os'
11
10
  import * as path from 'node:path'
12
11
  import { ConfigFramework } from '@book000/node-utils'
13
12
 
14
- /** テスト用の設定インターフェース */
13
+ /** Configuration interface for tests. */
15
14
  interface TestConfig {
16
15
  apiKey: string
17
16
  timeout: number
18
17
  }
19
18
 
20
- /** テスト用の ConfigFramework 実装 */
19
+ /** ConfigFramework implementation for tests. */
21
20
  class TestConfiguration extends ConfigFramework<TestConfig> {
22
21
  protected validates(): Record<string, (config: TestConfig) => boolean> {
23
22
  return {
@@ -45,13 +44,13 @@ describe('ConfigFramework', () => {
45
44
  fs.rmSync(tmpDir, { recursive: true })
46
45
  })
47
46
 
48
- it('サブクラスを定義できる', () => {
47
+ it('can define a subclass', () => {
49
48
  fs.writeFileSync(configPath, JSON.stringify({ apiKey: 'test', timeout: 30 }))
50
49
  const config = new TestConfiguration(configPath)
51
50
  expect(config).toBeDefined()
52
51
  })
53
52
 
54
- it('有効な設定を検証できる', () => {
53
+ it('accepts a valid configuration', () => {
55
54
  fs.writeFileSync(
56
55
  configPath,
57
56
  JSON.stringify({ apiKey: 'test-key', timeout: 30 })
@@ -62,7 +61,7 @@ describe('ConfigFramework', () => {
62
61
  expect(config.getValidateFailures()).toHaveLength(0)
63
62
  })
64
63
 
65
- it('無効な設定を検出できる(負のタイムアウト)', () => {
64
+ it('detects an invalid configuration (negative timeout)', () => {
66
65
  fs.writeFileSync(
67
66
  configPath,
68
67
  JSON.stringify({ apiKey: 'test-key', timeout: -1 })
@@ -19,7 +19,7 @@
19
19
  "generate-schema": "typescript-json-schema --required src/config.ts ConfigInterface -o schema/Configuration.json"
20
20
  },
21
21
  "dependencies": {
22
- "@book000/node-utils": "1.26.9",
22
+ "@book000/node-utils": "1.26.10",
23
23
  "discord.js": "14.28.1"
24
24
  },
25
25
  "devDependencies": {
@@ -9,8 +9,8 @@ importers:
9
9
  .:
10
10
  dependencies:
11
11
  '@book000/node-utils':
12
- specifier: 1.26.9
13
- version: 1.26.9
12
+ specifier: 1.26.10
13
+ version: 1.26.10
14
14
  discord.js:
15
15
  specifier: 14.28.1
16
16
  version: 14.28.1
@@ -221,8 +221,8 @@ packages:
221
221
  peerDependencies:
222
222
  eslint: 10.14.0
223
223
 
224
- '@book000/node-utils@1.26.9':
225
- resolution: {integrity: sha512-B95Oyn3gQtHZRoy7fuTG1ikEMmoBMdifKFmSp4tLp0Pw4V/eZ0Hut/U4MsxbEBt2iA7nssN+uyJtyeQP6sF99w==}
224
+ '@book000/node-utils@1.26.10':
225
+ resolution: {integrity: sha512-0IivH5CilLpiXKAZjGRXwlgq6z2bmxmueeSDc0UuHsVhN2cjONIi0BaGZ8SnnzZY/RKJRd1a/3VD8s7/eJVZlQ==}
226
226
 
227
227
  '@cacheable/memory@2.2.0':
228
228
  resolution: {integrity: sha512-CTLKqLItRCEixEAewD3/j9DB3/o96gpTPD4eJ1v+DGOlxZRZncRQkGYqqnAGCscYd6RNeXfGeiuCphsPtqyIfQ==}
@@ -2974,7 +2974,7 @@ snapshots:
2974
2974
  - ts-declaration-location
2975
2975
  - typescript
2976
2976
 
2977
- '@book000/node-utils@1.26.9':
2977
+ '@book000/node-utils@1.26.10':
2978
2978
  dependencies:
2979
2979
  '@sentry/node': 11.11.0
2980
2980
  cycle: 1.0.3
@@ -1,8 +1,8 @@
1
1
  /**
2
- * 設定インターフェース
2
+ * Configuration interface.
3
3
  */
4
4
  export interface ConfigInterface {
5
- /** Discord Bot のトークン */
5
+ /** Discord bot token. */
6
6
  token: string
7
- // TODO: 設定項目を追加する
7
+ // TODO: add configuration items
8
8
  }