@book000/create-ts 0.0.0
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.d.mts +1 -0
- package/dist/index.mjs +543 -0
- package/package.json +50 -0
- package/templates/gitignore/Node.gitignore +147 -0
- package/templates/nodejs/base/package.json +54 -0
- package/templates/nodejs/base/pnpm-lock.yaml +5639 -0
- package/templates/nodejs/base/pnpm-workspace.yaml +5 -0
- package/templates/nodejs/base/src/main.ts +13 -0
- package/templates/nodejs/base/template.json +8 -0
- package/templates/nodejs/base/test/smoke.test.ts +32 -0
- package/templates/nodejs/base/tsconfig.test.json +7 -0
- package/templates/nodejs/common/.depcheckrc.json +3 -0
- package/templates/nodejs/common/.devcontainer/devcontainer.json +9 -0
- package/templates/nodejs/common/.fixpackrc +4 -0
- package/templates/nodejs/common/.prettierrc.yml +7 -0
- package/templates/nodejs/common/Dockerfile +31 -0
- package/templates/nodejs/common/entrypoint.sh +4 -0
- package/templates/nodejs/common/eslint.config.mjs +1 -0
- package/templates/nodejs/common/package.json +29 -0
- package/templates/nodejs/common/pnpm-workspace.yaml +5 -0
- package/templates/nodejs/common/renovate.json +4 -0
- package/templates/nodejs/common/tsconfig.json +22 -0
- package/templates/nodejs/config-batch/package.json +59 -0
- package/templates/nodejs/config-batch/pnpm-lock.yaml +6128 -0
- package/templates/nodejs/config-batch/pnpm-workspace.yaml +5 -0
- package/templates/nodejs/config-batch/src/config.ts +7 -0
- package/templates/nodejs/config-batch/src/main.ts +38 -0
- package/templates/nodejs/config-batch/template.json +11 -0
- package/templates/nodejs/config-batch/test/config.test.ts +76 -0
- package/templates/nodejs/config-batch/tsconfig.test.json +7 -0
- package/templates/nodejs/discord-bot/package.json +60 -0
- package/templates/nodejs/discord-bot/pnpm-lock.yaml +6315 -0
- package/templates/nodejs/discord-bot/pnpm-workspace.yaml +5 -0
- package/templates/nodejs/discord-bot/src/config.ts +8 -0
- package/templates/nodejs/discord-bot/src/discord.ts +35 -0
- package/templates/nodejs/discord-bot/src/main.ts +53 -0
- package/templates/nodejs/discord-bot/template.json +11 -0
- package/templates/nodejs/discord-bot/test/discord.test.ts +68 -0
- package/templates/nodejs/discord-bot/tsconfig.test.json +7 -0
- package/templates/nodejs/fastify/package.json +59 -0
- package/templates/nodejs/fastify/pnpm-lock.yaml +6077 -0
- package/templates/nodejs/fastify/pnpm-workspace.yaml +5 -0
- package/templates/nodejs/fastify/src/main.ts +34 -0
- package/templates/nodejs/fastify/template.json +9 -0
- package/templates/nodejs/fastify/test/app.test.ts +49 -0
- package/templates/nodejs/fastify/tsconfig.test.json +7 -0
- package/templates/workflows/add-reviewer.yml +15 -0
- package/templates/workflows/docker.yml +92 -0
- package/templates/workflows/nodejs-ci-pnpm.yml +79 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* エントリポイント
|
|
3
|
+
*/
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
5
|
+
async function main(): Promise<void> {
|
|
6
|
+
console.log('Hello, World!')
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
main().catch((error: unknown) => {
|
|
10
|
+
console.error(error)
|
|
11
|
+
// eslint-disable-next-line unicorn/no-process-exit
|
|
12
|
+
process.exit(1)
|
|
13
|
+
})
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* base バリアントのスモークテスト
|
|
3
|
+
*
|
|
4
|
+
* TypeScript の基本機能と Node.js 組み込みモジュールの動作を確認する。
|
|
5
|
+
* 外部サービスへの接続は行わない。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
describe('TypeScript 基本機能', () => {
|
|
9
|
+
it('async/await が動作する', async () => {
|
|
10
|
+
const delay = (ms: number): Promise<string> =>
|
|
11
|
+
new Promise((resolve) => setTimeout(() => resolve('ok'), ms))
|
|
12
|
+
|
|
13
|
+
const result = await delay(0)
|
|
14
|
+
expect(result).toBe('ok')
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('ジェネリクスが動作する', () => {
|
|
18
|
+
function identity<T>(value: T): T {
|
|
19
|
+
return value
|
|
20
|
+
}
|
|
21
|
+
expect(identity(42)).toBe(42)
|
|
22
|
+
expect(identity('hello')).toBe('hello')
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('Error のスローと catch が動作する', async () => {
|
|
26
|
+
const failingFn = async (): Promise<never> => {
|
|
27
|
+
throw new Error('test error')
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
await expect(failingFn()).rejects.toThrow('test error')
|
|
31
|
+
})
|
|
32
|
+
})
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
FROM node:24-alpine
|
|
2
|
+
|
|
3
|
+
ENV PNPM_HOME="/pnpm"
|
|
4
|
+
ENV PATH="$PNPM_HOME/bin:$PATH"
|
|
5
|
+
|
|
6
|
+
# hadolint ignore=DL3018
|
|
7
|
+
RUN apk update && \
|
|
8
|
+
apk upgrade && \
|
|
9
|
+
apk add --update --no-cache tzdata && \
|
|
10
|
+
cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime && \
|
|
11
|
+
echo "Asia/Tokyo" > /etc/timezone && \
|
|
12
|
+
apk del tzdata && \
|
|
13
|
+
corepack enable
|
|
14
|
+
|
|
15
|
+
WORKDIR /app
|
|
16
|
+
|
|
17
|
+
COPY pnpm-lock.yaml package.json ./
|
|
18
|
+
|
|
19
|
+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm fetch
|
|
20
|
+
|
|
21
|
+
COPY entrypoint.sh .
|
|
22
|
+
RUN chmod +x entrypoint.sh
|
|
23
|
+
|
|
24
|
+
COPY tsconfig.json ./
|
|
25
|
+
COPY src src
|
|
26
|
+
|
|
27
|
+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile --offline
|
|
28
|
+
|
|
29
|
+
ENV NODE_ENV=production
|
|
30
|
+
|
|
31
|
+
ENTRYPOINT [ "/app/entrypoint.sh" ]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@book000/eslint-config'
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@book000/template",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "book000",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"preinstall": "npx only-allow pnpm",
|
|
9
|
+
"start": "tsx ./src/main.ts",
|
|
10
|
+
"dev": "tsx watch ./src/main.ts",
|
|
11
|
+
"lint": "run-z lint:prettier,lint:eslint,lint:tsc",
|
|
12
|
+
"lint:prettier": "prettier --check src",
|
|
13
|
+
"lint:eslint": "eslint . -c eslint.config.mjs",
|
|
14
|
+
"lint:tsc": "tsc --noEmit",
|
|
15
|
+
"fix": "run-z fix:prettier fix:eslint",
|
|
16
|
+
"fix:eslint": "eslint . -c eslint.config.mjs --fix",
|
|
17
|
+
"fix:prettier": "prettier --write src"
|
|
18
|
+
},
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=24"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/book000/template.git"
|
|
25
|
+
},
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/book000/template/issues"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2020",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"lib": ["ESNext"],
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"removeComments": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"incremental": true,
|
|
11
|
+
"sourceMap": true,
|
|
12
|
+
"strict": true,
|
|
13
|
+
"noUnusedLocals": true,
|
|
14
|
+
"noUnusedParameters": true,
|
|
15
|
+
"noImplicitReturns": true,
|
|
16
|
+
"noFallthroughCasesInSwitch": true,
|
|
17
|
+
"rootDir": ".",
|
|
18
|
+
"types": ["node"],
|
|
19
|
+
"newLine": "LF"
|
|
20
|
+
},
|
|
21
|
+
"include": ["src/**/*"]
|
|
22
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@book000/template",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "book000",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"preinstall": "npx only-allow pnpm",
|
|
9
|
+
"start": "tsx ./src/main.ts",
|
|
10
|
+
"dev": "tsx watch ./src/main.ts",
|
|
11
|
+
"test": "jest --runInBand --passWithNoTests --detectOpenHandles --forceExit",
|
|
12
|
+
"lint": "run-z lint:prettier,lint:eslint,lint:tsc",
|
|
13
|
+
"lint:prettier": "prettier --check src/",
|
|
14
|
+
"lint:eslint": "eslint src/ -c eslint.config.mjs",
|
|
15
|
+
"lint:tsc": "tsc --noEmit",
|
|
16
|
+
"fix": "run-z fix:prettier fix:eslint",
|
|
17
|
+
"fix:eslint": "eslint src/ -c eslint.config.mjs --fix",
|
|
18
|
+
"fix:prettier": "prettier --write src/",
|
|
19
|
+
"generate-schema": "typescript-json-schema --required src/config.ts ConfigInterface -o schema/Configuration.json"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@book000/node-utils": "*"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@book000/eslint-config": "*",
|
|
26
|
+
"@types/jest": "*",
|
|
27
|
+
"@types/node": "*",
|
|
28
|
+
"eslint": "*",
|
|
29
|
+
"jest": "*",
|
|
30
|
+
"prettier": "*",
|
|
31
|
+
"run-z": "*",
|
|
32
|
+
"ts-jest": "*",
|
|
33
|
+
"tsx": "*",
|
|
34
|
+
"typescript": "*",
|
|
35
|
+
"typescript-json-schema": "*"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=24"
|
|
39
|
+
},
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "git+https://github.com/book000/template.git"
|
|
43
|
+
},
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/book000/template/issues"
|
|
46
|
+
},
|
|
47
|
+
"jest": {
|
|
48
|
+
"preset": "ts-jest",
|
|
49
|
+
"testEnvironment": "node",
|
|
50
|
+
"transform": {
|
|
51
|
+
"^.+\\.tsx?$": [
|
|
52
|
+
"ts-jest",
|
|
53
|
+
{
|
|
54
|
+
"tsconfig": "tsconfig.test.json"
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|