@book000/create-ts 0.2.77 → 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.
- package/README.md +85 -0
- package/dist/index.mjs +37 -32
- package/dist/src/generate.d.ts +11 -9
- package/dist/src/generate.js +11 -9
- package/dist/src/index.js +14 -26
- package/dist/src/prompts.d.ts +6 -6
- package/dist/src/prompts.js +10 -11
- package/dist/src/template.d.ts +4 -4
- package/dist/src/template.js +5 -5
- package/dist/src/types.d.ts +5 -5
- package/dist/src/validate.d.ts +8 -8
- package/dist/src/validate.js +8 -8
- package/dist/test/generate.test.js +22 -22
- package/dist/test/validate.test.js +20 -20
- package/dist/tsdown.config.js +2 -2
- package/package.json +1 -1
- package/templates/nodejs/base/src/main.ts +1 -1
- package/templates/nodejs/base/test/smoke.test.ts +7 -7
- package/templates/nodejs/config-batch/src/config.ts +2 -2
- package/templates/nodejs/config-batch/src/main.ts +6 -6
- package/templates/nodejs/config-batch/test/config.test.ts +8 -9
- package/templates/nodejs/discord-bot/src/config.ts +3 -3
- package/templates/nodejs/discord-bot/src/discord.ts +6 -6
- package/templates/nodejs/discord-bot/src/main.ts +4 -4
- package/templates/nodejs/discord-bot/test/discord.test.ts +9 -9
- package/templates/nodejs/fastify/src/main.ts +5 -5
- package/templates/nodejs/fastify/test/app.test.ts +8 -8
- package/templates/workflows/docker.yml +6 -7
- package/templates/workflows/nodejs-ci-pnpm.yml +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* discord-bot
|
|
2
|
+
* Tests for the discord-bot variant.
|
|
3
3
|
*
|
|
4
|
-
* discord.js
|
|
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
|
-
/**
|
|
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('
|
|
57
|
+
it('can set multiple intents', () => {
|
|
58
58
|
const testClient = new Client({
|
|
59
59
|
intents: [
|
|
60
60
|
GatewayIntentBits.Guilds,
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import Fastify from 'fastify'
|
|
2
2
|
import cors from '@fastify/cors'
|
|
3
|
-
// fastify-raw-body
|
|
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:
|
|
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
|
|
5
|
-
*
|
|
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
|
|
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 /
|
|
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('
|
|
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
|
-
#
|
|
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
|
|
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
|
-
#
|
|
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
|
-
#
|
|
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:
|