@book000/create-ts 0.2.76 → 0.2.78

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 (37) 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 +2 -2
  17. package/templates/nodejs/base/package.json +1 -1
  18. package/templates/nodejs/base/pnpm-lock.yaml +5 -5
  19. package/templates/nodejs/base/src/main.ts +1 -1
  20. package/templates/nodejs/base/test/smoke.test.ts +7 -7
  21. package/templates/nodejs/config-batch/package.json +1 -1
  22. package/templates/nodejs/config-batch/pnpm-lock.yaml +5 -5
  23. package/templates/nodejs/config-batch/src/config.ts +2 -2
  24. package/templates/nodejs/config-batch/src/main.ts +6 -6
  25. package/templates/nodejs/config-batch/test/config.test.ts +8 -9
  26. package/templates/nodejs/discord-bot/package.json +1 -1
  27. package/templates/nodejs/discord-bot/pnpm-lock.yaml +5 -5
  28. package/templates/nodejs/discord-bot/src/config.ts +3 -3
  29. package/templates/nodejs/discord-bot/src/discord.ts +6 -6
  30. package/templates/nodejs/discord-bot/src/main.ts +4 -4
  31. package/templates/nodejs/discord-bot/test/discord.test.ts +9 -9
  32. package/templates/nodejs/fastify/package.json +1 -1
  33. package/templates/nodejs/fastify/pnpm-lock.yaml +5 -5
  34. package/templates/nodejs/fastify/src/main.ts +5 -5
  35. package/templates/nodejs/fastify/test/app.test.ts +8 -8
  36. package/templates/workflows/docker.yml +6 -7
  37. package/templates/workflows/nodejs-ci-pnpm.yml +1 -1
@@ -23,7 +23,7 @@
23
23
  "discord.js": "14.28.1"
24
24
  },
25
25
  "devDependencies": {
26
- "@book000/eslint-config": "1.16.118",
26
+ "@book000/eslint-config": "1.16.119",
27
27
  "@types/jest": "30.0.0",
28
28
  "@types/node": "26.6.6",
29
29
  "eslint": "10.14.0",
@@ -16,8 +16,8 @@ importers:
16
16
  version: 14.28.1
17
17
  devDependencies:
18
18
  '@book000/eslint-config':
19
- specifier: 1.16.118
20
- version: 1.16.118(eslint@10.14.0(supports-color@8.1.1))(supports-color@8.1.1)(typescript@6.0.3)
19
+ specifier: 1.16.119
20
+ version: 1.16.119(eslint@10.14.0(supports-color@8.1.1))(supports-color@8.1.1)(typescript@6.0.3)
21
21
  '@types/jest':
22
22
  specifier: 30.0.0
23
23
  version: 30.0.0
@@ -216,8 +216,8 @@ packages:
216
216
  '@bcoe/v8-coverage@0.2.3':
217
217
  resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==}
218
218
 
219
- '@book000/eslint-config@1.16.118':
220
- resolution: {integrity: sha512-H6zNl0hol/bJPB5yQgXZRmgsFCBUdwu+19HQsF4CHaTeQu9eD4BdA6cTD/drnfJlEEyDidBYt8VcXTWjeY1/qQ==}
219
+ '@book000/eslint-config@1.16.119':
220
+ resolution: {integrity: sha512-88ij8dAem4IRrHySoxd7m/Q477jAw7V6lJLefilzxnkD3l7hYME8+hNWnRx9A83GCbrOT1G1G60vgB4zmqC83Q==}
221
221
  peerDependencies:
222
222
  eslint: 10.14.0
223
223
 
@@ -2960,7 +2960,7 @@ snapshots:
2960
2960
 
2961
2961
  '@bcoe/v8-coverage@0.2.3': {}
2962
2962
 
2963
- '@book000/eslint-config@1.16.118(eslint@10.14.0(supports-color@8.1.1))(supports-color@8.1.1)(typescript@6.0.3)':
2963
+ '@book000/eslint-config@1.16.119(eslint@10.14.0(supports-color@8.1.1))(supports-color@8.1.1)(typescript@6.0.3)':
2964
2964
  dependencies:
2965
2965
  '@typescript-eslint/parser': 8.72.1(eslint@10.14.0(supports-color@8.1.1))(supports-color@8.1.1)(typescript@6.0.3)
2966
2966
  eslint: 10.14.0(supports-color@8.1.1)
@@ -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
  }
@@ -3,15 +3,15 @@ import { ConfigFramework } from '@book000/node-utils'
3
3
  import { ConfigInterface } from './config'
4
4
 
5
5
  /**
6
- * Discord Bot のメインクラス
6
+ * Main class of the Discord bot.
7
7
  */
8
8
  export class Discord {
9
9
  private readonly client: Client
10
10
  private readonly config: ConfigFramework<ConfigInterface>
11
11
 
12
12
  /**
13
- * @param client - Discord クライアント
14
- * @param config - 設定フレームワーク
13
+ * @param client - Discord client
14
+ * @param config - Configuration framework
15
15
  */
16
16
  constructor(client: Client, config: ConfigFramework<ConfigInterface>) {
17
17
  this.client = client
@@ -19,17 +19,17 @@ export class Discord {
19
19
  }
20
20
 
21
21
  /**
22
- * 設定フレームワークを返す
22
+ * Returns the configuration framework.
23
23
  */
24
24
  protected getConfig(): ConfigFramework<ConfigInterface> {
25
25
  return this.config
26
26
  }
27
27
 
28
28
  /**
29
- * Bot の準備完了時に呼ばれる
29
+ * Called when the bot is ready.
30
30
  */
31
31
  public onReady(): void {
32
32
  console.log(`Logged in as ${this.client.user?.tag ?? 'unknown'}`)
33
- // TODO: this.getConfig().get('key') で設定値を取得して処理を実装する
33
+ // TODO: read settings with this.getConfig().get('key') and implement the bot's behavior
34
34
  }
35
35
  }
@@ -4,24 +4,24 @@ import { ConfigInterface } from './config'
4
4
  import { Discord } from './discord'
5
5
 
6
6
  /**
7
- * 設定フレームワーク実装
7
+ * Configuration framework implementation.
8
8
  */
9
9
  class Configuration extends ConfigFramework<ConfigInterface> {
10
10
  /**
11
- * バリデーションルールを返す
11
+ * Returns the validation rules.
12
12
  */
13
13
  protected validates(): Record<string, (config: ConfigInterface) => boolean> {
14
14
  return {
15
15
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
16
16
  'token is required': (config) => config.token !== undefined,
17
17
  'token is string': (config) => typeof config.token === 'string',
18
- // TODO: バリデーションルールを追加する
18
+ // TODO: add validation rules
19
19
  }
20
20
  }
21
21
  }
22
22
 
23
23
  /**
24
- * エントリポイント
24
+ * Entry point.
25
25
  */
26
26
  async function main(): Promise<void> {
27
27
  const config = new Configuration('./data/config.json')
@@ -1,8 +1,8 @@
1
1
  /**
2
- * discord-bot バリアントのテスト
2
+ * Tests for the discord-bot variant.
3
3
  *
4
- * discord.js の Client が正しく初期化できること、および Discord クラスの
5
- * 基本動作を確認する。実際のトークンでのログインは行わない。
4
+ * Checks that the discord.js Client can be initialized and the basic behavior of the Discord class.
5
+ * Does not log in with a real token.
6
6
  */
7
7
 
8
8
  import { Client, GatewayIntentBits } from 'discord.js'
@@ -10,7 +10,7 @@ import { Discord } from '../src/discord'
10
10
  import type { ConfigFramework } from '@book000/node-utils'
11
11
  import type { ConfigInterface } from '../src/config'
12
12
 
13
- /** テスト用 ConfigFramework モック */
13
+ /** Mock ConfigFramework for tests. */
14
14
  const createMockConfig = (): ConfigFramework<ConfigInterface> =>
15
15
  ({
16
16
  get: jest.fn(),
@@ -19,7 +19,7 @@ const createMockConfig = (): ConfigFramework<ConfigInterface> =>
19
19
  getValidateFailures: jest.fn().mockReturnValue([]),
20
20
  }) as unknown as ConfigFramework<ConfigInterface>
21
21
 
22
- describe('Discord クラス', () => {
22
+ describe('Discord class', () => {
23
23
  let client: Client
24
24
 
25
25
  beforeEach(() => {
@@ -30,13 +30,13 @@ describe('Discord クラス', () => {
30
30
  client.destroy()
31
31
  })
32
32
 
33
- it('Discord インスタンスを作成できる', () => {
33
+ it('can create a Discord instance', () => {
34
34
  const mockConfig = createMockConfig()
35
35
  const discord = new Discord(client, mockConfig)
36
36
  expect(discord).toBeDefined()
37
37
  })
38
38
 
39
- it('onReady() を呼び出せる', () => {
39
+ it('can call onReady()', () => {
40
40
  const mockConfig = createMockConfig()
41
41
  const discord = new Discord(client, mockConfig)
42
42
  const consoleSpy = jest.spyOn(console, 'log').mockImplementation()
@@ -48,13 +48,13 @@ describe('Discord クラス', () => {
48
48
  })
49
49
 
50
50
  describe('discord.js Client', () => {
51
- it('Client インスタンスを作成できる', () => {
51
+ it('can create a Client instance', () => {
52
52
  const testClient = new Client({ intents: [GatewayIntentBits.Guilds] })
53
53
  expect(testClient).toBeDefined()
54
54
  testClient.destroy()
55
55
  })
56
56
 
57
- it('複数の Intent を設定できる', () => {
57
+ it('can set multiple intents', () => {
58
58
  const testClient = new Client({
59
59
  intents: [
60
60
  GatewayIntentBits.Guilds,
@@ -22,7 +22,7 @@
22
22
  "fastify": "5.12.8"
23
23
  },
24
24
  "devDependencies": {
25
- "@book000/eslint-config": "1.16.118",
25
+ "@book000/eslint-config": "1.16.119",
26
26
  "@types/jest": "30.0.0",
27
27
  "@types/node": "26.6.6",
28
28
  "eslint": "10.14.0",
@@ -16,8 +16,8 @@ importers:
16
16
  version: 5.12.8
17
17
  devDependencies:
18
18
  '@book000/eslint-config':
19
- specifier: 1.16.118
20
- version: 1.16.118(eslint@10.14.0(supports-color@8.1.1))(supports-color@8.1.1)(typescript@6.0.3)
19
+ specifier: 1.16.119
20
+ version: 1.16.119(eslint@10.14.0(supports-color@8.1.1))(supports-color@8.1.1)(typescript@6.0.3)
21
21
  '@types/jest':
22
22
  specifier: 30.0.0
23
23
  version: 30.0.0
@@ -216,8 +216,8 @@ packages:
216
216
  '@bcoe/v8-coverage@0.2.3':
217
217
  resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==}
218
218
 
219
- '@book000/eslint-config@1.16.118':
220
- resolution: {integrity: sha512-H6zNl0hol/bJPB5yQgXZRmgsFCBUdwu+19HQsF4CHaTeQu9eD4BdA6cTD/drnfJlEEyDidBYt8VcXTWjeY1/qQ==}
219
+ '@book000/eslint-config@1.16.119':
220
+ resolution: {integrity: sha512-88ij8dAem4IRrHySoxd7m/Q477jAw7V6lJLefilzxnkD3l7hYME8+hNWnRx9A83GCbrOT1G1G60vgB4zmqC83Q==}
221
221
  peerDependencies:
222
222
  eslint: 10.14.0
223
223
 
@@ -2668,7 +2668,7 @@ snapshots:
2668
2668
 
2669
2669
  '@bcoe/v8-coverage@0.2.3': {}
2670
2670
 
2671
- '@book000/eslint-config@1.16.118(eslint@10.14.0(supports-color@8.1.1))(supports-color@8.1.1)(typescript@6.0.3)':
2671
+ '@book000/eslint-config@1.16.119(eslint@10.14.0(supports-color@8.1.1))(supports-color@8.1.1)(typescript@6.0.3)':
2672
2672
  dependencies:
2673
2673
  '@typescript-eslint/parser': 8.72.1(eslint@10.14.0(supports-color@8.1.1))(supports-color@8.1.1)(typescript@6.0.3)
2674
2674
  eslint: 10.14.0(supports-color@8.1.1)
@@ -1,23 +1,23 @@
1
1
  import Fastify from 'fastify'
2
2
  import cors from '@fastify/cors'
3
- // fastify-raw-body は生の POST ボディが必要な場合に利用する(Webhook 署名検証など)
3
+ // fastify-raw-body is for when the raw POST body is needed (e.g. webhook signature verification)
4
4
  // import fastifyRawBody from 'fastify-raw-body'
5
5
 
6
- /** Fastify インスタンス */
6
+ /** Fastify instance. */
7
7
  const fastify = Fastify({
8
8
  logger: true,
9
9
  })
10
10
 
11
11
  /**
12
- * エントリポイント
12
+ * Entry point.
13
13
  */
14
14
  async function main(): Promise<void> {
15
15
  await fastify.register(cors, {
16
- // TODO: 本番環境では許可するオリジンを明示的に設定すること(例: origin: 'https://example.com')
16
+ // TODO: in production, set the allowed origins explicitly (e.g. origin: 'https://example.com')
17
17
  origin: false,
18
18
  })
19
19
 
20
- // fastify-raw-body を使う場合は以下を有効にする
20
+ // Enable the following to use fastify-raw-body
21
21
  // await fastify.register(fastifyRawBody)
22
22
 
23
23
  fastify.get('/', (): { status: string } => {
@@ -1,28 +1,28 @@
1
1
  /**
2
- * fastify バリアントのテスト
2
+ * Tests for the fastify variant.
3
3
  *
4
- * Fastify + @fastify/cors が正しく動作することを確認する。
5
- * 実際のポートへのバインドは行わず、inject() でリクエストを注入する。
4
+ * Checks that Fastify and @fastify/cors work.
5
+ * Requests are injected with inject() instead of binding a real port.
6
6
  */
7
7
 
8
8
  import Fastify from 'fastify'
9
9
  import cors from '@fastify/cors'
10
10
 
11
- describe('Fastify アプリケーション', () => {
12
- it('Fastify インスタンスを作成できる', () => {
11
+ describe('Fastify application', () => {
12
+ it('can create a Fastify instance', () => {
13
13
  const app = Fastify()
14
14
  expect(app).toBeDefined()
15
15
  void app.close()
16
16
  })
17
17
 
18
- it('@fastify/cors を登録できる', async () => {
18
+ it('can register @fastify/cors', async () => {
19
19
  const app = Fastify()
20
20
  await app.register(cors, { origin: false })
21
21
  expect(app).toBeDefined()
22
22
  await app.close()
23
23
  })
24
24
 
25
- it('GET / が 200 を返す', async () => {
25
+ it('GET / returns 200', async () => {
26
26
  const app = Fastify()
27
27
  await app.register(cors, { origin: false })
28
28
 
@@ -37,7 +37,7 @@ describe('Fastify アプリケーション', () => {
37
37
  await app.close()
38
38
  })
39
39
 
40
- it('存在しないルートが 404 を返す', async () => {
40
+ it('returns 404 for an unknown route', async () => {
41
41
  const app = Fastify()
42
42
  await app.register(cors, { origin: false })
43
43
 
@@ -1,5 +1,5 @@
1
- # 任意のレジストリに Docker image を公開orビルドする。
2
- # プルリクの作成・更新時に動作する。
1
+ # Builds (and publishes) a Docker image to a registry.
2
+ # Runs when a pull request is created or updated.
3
3
 
4
4
  name: Docker
5
5
 
@@ -25,8 +25,7 @@ on:
25
25
  merge_group:
26
26
 
27
27
  concurrency:
28
- # pull_request と pull_request_target が同一グループになると互いをキャンセルしてしまうため
29
- # event_name を含めることで両イベントのキャンセルを独立させる
28
+ # event_name keeps pull_request and pull_request_target from cancelling each other.
30
29
  group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
31
30
  cancel-in-progress: true
32
31
 
@@ -34,7 +33,7 @@ jobs:
34
33
  post-approval-request:
35
34
  name: Post approval request
36
35
  runs-on: ubuntu-latest
37
- # フォーク PR のときのみ承認リクエストを投稿する(closed は不要)
36
+ # Post the approval request only for fork PRs (not needed on closed)
38
37
  if: github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository && github.event.action != 'closed'
39
38
  continue-on-error: true
40
39
  permissions:
@@ -66,9 +65,9 @@ jobs:
66
65
  name: Approval gate
67
66
  runs-on: ubuntu-latest
68
67
  needs: post-approval-request
69
- # post-approval-request の結果に関わらず常に実行する
68
+ # Always run, regardless of the result of post-approval-request
70
69
  if: always()
71
- # フォーク PR かつ closed でない場合のみ Environment で手動承認が必要
70
+ # Manual approval via the Environment is required only for fork PRs that are not closed
72
71
  environment: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository && github.event.action != 'closed' && 'fork-pr-build' || '' }}
73
72
  permissions: {}
74
73
  steps:
@@ -1,4 +1,4 @@
1
- # Node.js でビルド・テストを実行する。バージョンは .node-version に記載されているものを利用する
1
+ # Builds and tests with Node.js. The version is taken from .node-version.
2
2
 
3
3
  name: Node CI
4
4