@goqoo/trunks 0.2.0 → 1.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/LICENSE +21 -0
- package/README.ja.md +214 -0
- package/README.md +214 -0
- package/dist/cli.js +8 -1
- package/dist/generate.js +15 -5
- package/dist/types.d.ts +3 -1
- package/package.json +18 -1
- package/.claude/settings.local.json +0 -7
- package/.prettierignore +0 -1
- package/.prettierrc.cjs +0 -6
- package/CLAUDE.md +0 -71
- package/dts/activity-fields.d.ts +0 -25
- package/dts/customer-fields.d.ts +0 -28
- package/jest.config.js +0 -19
- package/src/cli.ts +0 -28
- package/src/config.ts +0 -23
- package/src/generate.ts +0 -273
- package/src/index.ts +0 -14
- package/src/oauth.ts +0 -14
- package/src/types.ts +0 -65
- package/test/config.test.ts +0 -15
- package/test/generate.test.ts +0 -32
- package/test/types.test.ts +0 -116
- package/trunks.config.ts +0 -19
- package/tsconfig.json +0 -16
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 goqoo-on-kintone
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.ja.md
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# trunks
|
|
2
|
+
|
|
3
|
+
[](https://nodejs.org/)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
[English](/README.md) | 日本語
|
|
7
|
+
|
|
8
|
+
[@kintone/dts-gen](https://github.com/kintone/js-sdk/tree/main/packages/dts-gen) のラッパー CLI ツール。設定ファイル1つで複数の kintone アプリの TypeScript 型定義を一括生成します。
|
|
9
|
+
|
|
10
|
+
## 特徴
|
|
11
|
+
|
|
12
|
+
- 1コマンドで複数アプリの型定義を生成
|
|
13
|
+
- TypeScript 設定ファイルで型安全な設定(`trunks.config.ts`)
|
|
14
|
+
- 複数の認証方式に対応(パスワード、API トークン、OAuth)
|
|
15
|
+
- Prettier による自動フォーマット(オプション)
|
|
16
|
+
- プレビュー環境・ゲストスペースに対応
|
|
17
|
+
|
|
18
|
+
## クイックスタート
|
|
19
|
+
|
|
20
|
+
1. プロジェクトルートに設定ファイル `trunks.config.ts` を作成:
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { defineConfig } from '@goqoo/trunks';
|
|
24
|
+
|
|
25
|
+
export default defineConfig({
|
|
26
|
+
host: 'your-subdomain.cybozu.com',
|
|
27
|
+
apps: {
|
|
28
|
+
customer: 123,
|
|
29
|
+
order: 456,
|
|
30
|
+
product: 789,
|
|
31
|
+
},
|
|
32
|
+
auth: { type: 'oauth' },
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
2. コマンドを実行:
|
|
37
|
+
|
|
38
|
+
グローバルインストールあり:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install -g @goqoo/trunks
|
|
42
|
+
trunks
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
グローバルインストールなし:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx @goqoo/trunks
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
3. `dts/` ディレクトリに型定義ファイルが生成されます:
|
|
52
|
+
- `dts/customer-fields.d.ts`
|
|
53
|
+
- `dts/order-fields.d.ts`
|
|
54
|
+
- `dts/product-fields.d.ts`
|
|
55
|
+
|
|
56
|
+
## 設定
|
|
57
|
+
|
|
58
|
+
### 基本設定
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { defineConfig } from '@goqoo/trunks';
|
|
62
|
+
|
|
63
|
+
export default defineConfig({
|
|
64
|
+
// 必須
|
|
65
|
+
host: 'your-subdomain.cybozu.com',
|
|
66
|
+
apps: {
|
|
67
|
+
customer: 123, // { アプリ名: アプリID }
|
|
68
|
+
order: 456,
|
|
69
|
+
},
|
|
70
|
+
auth: { type: 'oauth' },
|
|
71
|
+
|
|
72
|
+
// オプション
|
|
73
|
+
outDir: 'dts', // 出力ディレクトリ(デフォルト: "dts")
|
|
74
|
+
preview: false, // プレビュー環境を使用(デフォルト: false)
|
|
75
|
+
guestSpaceId: 5, // ゲストスペース ID(該当する場合)
|
|
76
|
+
namespace: 'kintone.types', // TypeScript の namespace(デフォルト: "kintone.types")
|
|
77
|
+
format: true, // Prettier でフォーマット(デフォルト: false)
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 認証方式
|
|
82
|
+
|
|
83
|
+
環境変数はプロジェクトルートの `.env` ファイルに設定できます:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# .env
|
|
87
|
+
KINTONE_USERNAME=your-username
|
|
88
|
+
KINTONE_PASSWORD=your-password
|
|
89
|
+
KINTONE_API_TOKEN=your-api-token
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
> **注意**: 設定ファイルに認証情報を直書きする場合は、設定ファイルを `.gitignore` に追加して、バージョン管理に機密情報がコミットされないようにしてください。環境変数(`.env` ファイル)または標準入力の使用を推奨します。
|
|
93
|
+
|
|
94
|
+
#### パスワード
|
|
95
|
+
|
|
96
|
+
認証情報は設定ファイル、環境変数 `KINTONE_USERNAME` と `KINTONE_PASSWORD`、または標準入力から取得します(この優先順位)。
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
auth: { type: 'password' },
|
|
100
|
+
// または直書き(非推奨)
|
|
101
|
+
auth: { type: 'password', username: 'user', password: 'pass' },
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### API トークン
|
|
105
|
+
|
|
106
|
+
トークンは設定ファイル、環境変数 `KINTONE_API_TOKEN`、または標準入力から取得します(この優先順位)。
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
auth: { type: 'api-token' },
|
|
110
|
+
// または直書き(非推奨)
|
|
111
|
+
auth: { type: 'api-token', token: 'your-token' },
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
複数アプリの場合は `.env` でカンマ区切りで指定:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
KINTONE_API_TOKEN=token1,token2,token3
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
#### OAuth
|
|
121
|
+
|
|
122
|
+
[Gyuma](https://github.com/nicecai/gyuma) を使用した OAuth 認証。ブラウザが開いて認証を行います。
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
auth: {
|
|
126
|
+
type: 'oauth',
|
|
127
|
+
scope: 'k:app_settings:read', // オプション: カスタムスコープ
|
|
128
|
+
},
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### その他のオプション
|
|
132
|
+
|
|
133
|
+
#### Basic 認証
|
|
134
|
+
|
|
135
|
+
Basic 認証が必要な環境の場合:
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
basicAuth: {
|
|
139
|
+
username: 'basic-user',
|
|
140
|
+
password: 'basic-password',
|
|
141
|
+
},
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
#### プロキシ
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
proxy: {
|
|
148
|
+
host: 'proxy.example.com',
|
|
149
|
+
port: 8080,
|
|
150
|
+
},
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
#### クライアント証明書(OAuth 用)
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
pfx: {
|
|
157
|
+
filepath: '/path/to/cert.pfx',
|
|
158
|
+
password: 'certificate-password',
|
|
159
|
+
},
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## CLI オプション
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
trunks [options]
|
|
166
|
+
|
|
167
|
+
Options:
|
|
168
|
+
-c, --config <path> 設定ファイルのパス(デフォルト: 自動検出)
|
|
169
|
+
-h, --help ヘルプを表示
|
|
170
|
+
-V, --version バージョンを表示
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## 生成される出力
|
|
174
|
+
|
|
175
|
+
アプリ名 `customer`(ID: 123)の場合、以下のファイルが生成されます:
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
// dts/customer-fields.d.ts
|
|
179
|
+
declare namespace kintone.types {
|
|
180
|
+
interface CustomerFields {
|
|
181
|
+
companyName: kintone.fieldTypes.SingleLineText;
|
|
182
|
+
email: kintone.fieldTypes.Link;
|
|
183
|
+
// ...
|
|
184
|
+
}
|
|
185
|
+
interface SavedCustomerFields extends CustomerFields {
|
|
186
|
+
$id: kintone.fieldTypes.Id;
|
|
187
|
+
$revision: kintone.fieldTypes.Revision;
|
|
188
|
+
// ...
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## 開発
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
# ビルド
|
|
197
|
+
yarn build
|
|
198
|
+
|
|
199
|
+
# テスト
|
|
200
|
+
yarn test
|
|
201
|
+
|
|
202
|
+
# ウォッチモード
|
|
203
|
+
yarn dev
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## 関連プロジェクト
|
|
207
|
+
|
|
208
|
+
- [@kintone/dts-gen](https://github.com/kintone/js-sdk/tree/main/packages/dts-gen) - 型定義生成の本体
|
|
209
|
+
- [Gyuma](https://github.com/nicecai/gyuma) - kintone の OAuth 認証
|
|
210
|
+
- [gotenks](https://github.com/goqoo-on-kintone/gotenks) - kintone TypeScript 型を Go 型に変換
|
|
211
|
+
|
|
212
|
+
## ライセンス
|
|
213
|
+
|
|
214
|
+
MIT License - 詳細は [LICENSE](LICENSE) を参照してください。
|
package/README.md
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# trunks
|
|
2
|
+
|
|
3
|
+
[](https://nodejs.org/)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
English | [日本語](/README.ja.md)
|
|
7
|
+
|
|
8
|
+
A CLI wrapper for [@kintone/dts-gen](https://github.com/kintone/js-sdk/tree/main/packages/dts-gen) that generates TypeScript type definitions for multiple Kintone apps with a single configuration file.
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- Generate type definitions for multiple apps in one command
|
|
13
|
+
- TypeScript configuration file with type safety (`trunks.config.ts`)
|
|
14
|
+
- Multiple authentication methods (Password, API Token, OAuth)
|
|
15
|
+
- Optional Prettier formatting for generated files
|
|
16
|
+
- Support for preview environments and guest spaces
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
1. Create a configuration file `trunks.config.ts` in your project root:
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { defineConfig } from '@goqoo/trunks';
|
|
24
|
+
|
|
25
|
+
export default defineConfig({
|
|
26
|
+
host: 'your-subdomain.cybozu.com',
|
|
27
|
+
apps: {
|
|
28
|
+
customer: 123,
|
|
29
|
+
order: 456,
|
|
30
|
+
product: 789,
|
|
31
|
+
},
|
|
32
|
+
auth: { type: 'oauth' },
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
2. Run the command:
|
|
37
|
+
|
|
38
|
+
With global installation:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install -g @goqoo/trunks
|
|
42
|
+
trunks
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Without global installation:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx @goqoo/trunks
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
3. Type definition files will be generated in the `dts/` directory:
|
|
52
|
+
- `dts/customer-fields.d.ts`
|
|
53
|
+
- `dts/order-fields.d.ts`
|
|
54
|
+
- `dts/product-fields.d.ts`
|
|
55
|
+
|
|
56
|
+
## Configuration
|
|
57
|
+
|
|
58
|
+
### Basic Configuration
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { defineConfig } from '@goqoo/trunks';
|
|
62
|
+
|
|
63
|
+
export default defineConfig({
|
|
64
|
+
// Required
|
|
65
|
+
host: 'your-subdomain.cybozu.com',
|
|
66
|
+
apps: {
|
|
67
|
+
customer: 123, // { appName: appId }
|
|
68
|
+
order: 456,
|
|
69
|
+
},
|
|
70
|
+
auth: { type: 'oauth' },
|
|
71
|
+
|
|
72
|
+
// Optional
|
|
73
|
+
outDir: 'dts', // Output directory (default: "dts")
|
|
74
|
+
preview: false, // Use preview environment (default: false)
|
|
75
|
+
guestSpaceId: 5, // Guest space ID (if applicable)
|
|
76
|
+
namespace: 'kintone.types', // TypeScript namespace (default: "kintone.types")
|
|
77
|
+
format: true, // Format with Prettier (default: false)
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Authentication Methods
|
|
82
|
+
|
|
83
|
+
Environment variables can be set in a `.env` file in your project root:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# .env
|
|
87
|
+
KINTONE_USERNAME=your-username
|
|
88
|
+
KINTONE_PASSWORD=your-password
|
|
89
|
+
KINTONE_API_TOKEN=your-api-token
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
> **Warning**: If you write credentials directly in the config file, make sure to add the config file to `.gitignore` to avoid committing sensitive information to version control. Using environment variables (`.env` file) or stdin prompts is recommended.
|
|
93
|
+
|
|
94
|
+
#### Password
|
|
95
|
+
|
|
96
|
+
Credentials are read from the config file, environment variables `KINTONE_USERNAME` and `KINTONE_PASSWORD`, or prompted via stdin (in that order of priority).
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
auth: { type: 'password' },
|
|
100
|
+
// Or with direct credentials (not recommended)
|
|
101
|
+
auth: { type: 'password', username: 'user', password: 'pass' },
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### API Token
|
|
105
|
+
|
|
106
|
+
Token is read from the config file, environment variable `KINTONE_API_TOKEN`, or prompted via stdin (in that order of priority).
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
auth: { type: 'api-token' },
|
|
110
|
+
// Or with direct token (not recommended)
|
|
111
|
+
auth: { type: 'api-token', token: 'your-token' },
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
For multiple apps, use comma-separated tokens in `.env`:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
KINTONE_API_TOKEN=token1,token2,token3
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
#### OAuth
|
|
121
|
+
|
|
122
|
+
Uses [Gyuma](https://github.com/nicecai/gyuma) for OAuth authentication. A browser window will open for authentication.
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
auth: {
|
|
126
|
+
type: 'oauth',
|
|
127
|
+
scope: 'k:app_settings:read', // Optional: custom scope
|
|
128
|
+
},
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Additional Options
|
|
132
|
+
|
|
133
|
+
#### Basic Authentication
|
|
134
|
+
|
|
135
|
+
For environments that require basic authentication:
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
basicAuth: {
|
|
139
|
+
username: 'basic-user',
|
|
140
|
+
password: 'basic-password',
|
|
141
|
+
},
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
#### Proxy
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
proxy: {
|
|
148
|
+
host: 'proxy.example.com',
|
|
149
|
+
port: 8080,
|
|
150
|
+
},
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
#### Client Certificate (for OAuth)
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
pfx: {
|
|
157
|
+
filepath: '/path/to/cert.pfx',
|
|
158
|
+
password: 'certificate-password',
|
|
159
|
+
},
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## CLI Options
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
trunks [options]
|
|
166
|
+
|
|
167
|
+
Options:
|
|
168
|
+
-c, --config <path> Path to config file (default: auto-detect)
|
|
169
|
+
-h, --help Display help
|
|
170
|
+
-V, --version Display version
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Generated Output
|
|
174
|
+
|
|
175
|
+
For an app named `customer` (ID: 123), the following file is generated:
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
// dts/customer-fields.d.ts
|
|
179
|
+
declare namespace kintone.types {
|
|
180
|
+
interface CustomerFields {
|
|
181
|
+
companyName: kintone.fieldTypes.SingleLineText;
|
|
182
|
+
email: kintone.fieldTypes.Link;
|
|
183
|
+
// ...
|
|
184
|
+
}
|
|
185
|
+
interface SavedCustomerFields extends CustomerFields {
|
|
186
|
+
$id: kintone.fieldTypes.Id;
|
|
187
|
+
$revision: kintone.fieldTypes.Revision;
|
|
188
|
+
// ...
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Development
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
# Build
|
|
197
|
+
yarn build
|
|
198
|
+
|
|
199
|
+
# Test
|
|
200
|
+
yarn test
|
|
201
|
+
|
|
202
|
+
# Watch mode
|
|
203
|
+
yarn dev
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## Related Projects
|
|
207
|
+
|
|
208
|
+
- [@kintone/dts-gen](https://github.com/kintone/js-sdk/tree/main/packages/dts-gen) - The underlying type definition generator
|
|
209
|
+
- [Gyuma](https://github.com/nicecai/gyuma) - OAuth authentication for Kintone
|
|
210
|
+
- [gotenks](https://github.com/goqoo-on-kintone/gotenks) - Convert kintone TypeScript types to Go types
|
|
211
|
+
|
|
212
|
+
## License
|
|
213
|
+
|
|
214
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from 'module';
|
|
3
|
+
import { config as loadEnv } from 'dotenv';
|
|
2
4
|
import { Command } from 'commander';
|
|
3
5
|
import chalk from 'chalk';
|
|
4
6
|
import { loadConfig } from './config.js';
|
|
5
7
|
import { generate } from './generate.js';
|
|
8
|
+
// package.jsonからバージョンを取得
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
10
|
+
const { version } = require('../package.json');
|
|
11
|
+
// .envファイルがあれば環境変数として読み込む
|
|
12
|
+
loadEnv({ quiet: true });
|
|
6
13
|
const program = new Command();
|
|
7
14
|
program
|
|
8
15
|
.name('trunks')
|
|
9
16
|
.description('Generate TypeScript type definitions for multiple Kintone apps')
|
|
10
|
-
.version(
|
|
17
|
+
.version(version);
|
|
11
18
|
program
|
|
12
19
|
.command('generate', { isDefault: true })
|
|
13
20
|
.description('Generate type definitions for all configured apps')
|
package/dist/generate.js
CHANGED
|
@@ -90,9 +90,10 @@ async function buildAuthArgs(config) {
|
|
|
90
90
|
const args = {};
|
|
91
91
|
switch (config.auth.type) {
|
|
92
92
|
case 'password': {
|
|
93
|
-
|
|
94
|
-
let
|
|
95
|
-
|
|
93
|
+
// 設定ファイル → 環境変数 → 標準入力の優先順位
|
|
94
|
+
let username = config.auth.username ?? process.env.KINTONE_USERNAME;
|
|
95
|
+
let password = config.auth.password ?? process.env.KINTONE_PASSWORD;
|
|
96
|
+
// 未設定の場合は標準入力で取得
|
|
96
97
|
if (!username) {
|
|
97
98
|
username = await prompt('Kintone Username: ');
|
|
98
99
|
}
|
|
@@ -116,9 +117,18 @@ async function buildAuthArgs(config) {
|
|
|
116
117
|
args['oauth-token'] = oauthToken;
|
|
117
118
|
break;
|
|
118
119
|
}
|
|
119
|
-
case 'api-token':
|
|
120
|
-
|
|
120
|
+
case 'api-token': {
|
|
121
|
+
// 設定ファイル → 環境変数 → 標準入力の優先順位
|
|
122
|
+
let token = config.auth.token ?? process.env.KINTONE_API_TOKEN;
|
|
123
|
+
if (!token) {
|
|
124
|
+
token = await promptPassword('Kintone API Token: ');
|
|
125
|
+
}
|
|
126
|
+
if (!token) {
|
|
127
|
+
throw new Error('API token is required for api-token auth');
|
|
128
|
+
}
|
|
129
|
+
args['api-token'] = token;
|
|
121
130
|
break;
|
|
131
|
+
}
|
|
122
132
|
}
|
|
123
133
|
// Basic認証
|
|
124
134
|
if (config.basicAuth) {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export type PasswordAuth = {
|
|
2
2
|
type: 'password';
|
|
3
|
+
username?: string;
|
|
4
|
+
password?: string;
|
|
3
5
|
};
|
|
4
6
|
export type OAuthAuth = {
|
|
5
7
|
type: 'oauth';
|
|
@@ -7,7 +9,7 @@ export type OAuthAuth = {
|
|
|
7
9
|
};
|
|
8
10
|
export type ApiTokenAuth = {
|
|
9
11
|
type: 'api-token';
|
|
10
|
-
token
|
|
12
|
+
token?: string;
|
|
11
13
|
};
|
|
12
14
|
export type Auth = PasswordAuth | OAuthAuth | ApiTokenAuth;
|
|
13
15
|
export type ProxyConfig = {
|
package/package.json
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goqoo/trunks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "A CLI wrapper for @kintone/dts-gen that generates type definitions for multiple Kintone apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"package.json"
|
|
17
|
+
],
|
|
7
18
|
"bin": {
|
|
8
19
|
"trunks": "dist/cli.js"
|
|
9
20
|
},
|
|
@@ -21,6 +32,11 @@
|
|
|
21
32
|
],
|
|
22
33
|
"author": "",
|
|
23
34
|
"license": "MIT",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "https://github.com/goqoo-on-kintone/trunks.git"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/goqoo-on-kintone/trunks#readme",
|
|
24
40
|
"engines": {
|
|
25
41
|
"node": ">=20"
|
|
26
42
|
},
|
|
@@ -37,6 +53,7 @@
|
|
|
37
53
|
"chalk": "^5.4.0",
|
|
38
54
|
"change-case": "^5.4.0",
|
|
39
55
|
"commander": "^13.0.0",
|
|
56
|
+
"dotenv": "^17.3.1",
|
|
40
57
|
"gyuma": "^0.6.1",
|
|
41
58
|
"jiti": "^2.4.0"
|
|
42
59
|
}
|
package/.prettierignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
*.md
|
package/.prettierrc.cjs
DELETED
package/CLAUDE.md
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
# CLAUDE.md
|
|
2
|
-
|
|
3
|
-
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
-
|
|
5
|
-
## プロジェクト概要
|
|
6
|
-
|
|
7
|
-
@goqoo/trunks - `@kintone/dts-gen`のラッパーCLIツール。
|
|
8
|
-
|
|
9
|
-
### 背景・目的
|
|
10
|
-
|
|
11
|
-
`@kintone/dts-gen`は優れた型定義ファイルを生成するが、CLIとしての使い勝手に課題がある(特に複数アプリの一括生成ができない)。このツールは設定ファイルベースで複数アプリの型定義を一括生成する。
|
|
12
|
-
|
|
13
|
-
### 参考実装
|
|
14
|
-
|
|
15
|
-
[goqoo/src/generator/dts/index.ts](https://github.com/goqoo-on-kintone/goqoo/blob/main/src/generator/dts/index.ts) の機能を単独抽出したもの。
|
|
16
|
-
|
|
17
|
-
goqooでの処理フロー:
|
|
18
|
-
1. 設定ファイルから対象環境を特定
|
|
19
|
-
2. OAuth or ユーザー名/パスワード認証を設定
|
|
20
|
-
3. `appId`オブジェクトをループして各アプリに対し`npx kintone-dts-gen`を実行
|
|
21
|
-
4. 出力ファイル名はkebab-case、型名はPascalCaseで自動生成
|
|
22
|
-
|
|
23
|
-
### 設定ファイル構造
|
|
24
|
-
|
|
25
|
-
```typescript
|
|
26
|
-
type Config = {
|
|
27
|
-
host: string // Kintone環境のホスト(例: "example.cybozu.com")
|
|
28
|
-
apps: Record<string, number> // { appName: appId }
|
|
29
|
-
auth:
|
|
30
|
-
| { type: 'password' } // 環境変数 KINTONE_USERNAME, KINTONE_PASSWORD
|
|
31
|
-
| { type: 'oauth'; scope?: string } // OAuth認証
|
|
32
|
-
| { type: 'api-token'; token: string } // APIトークン
|
|
33
|
-
proxy?: { host: string; port: number } // プロキシ設定(任意)
|
|
34
|
-
basicAuth?: { username: string; password: string } // Basic認証(任意)
|
|
35
|
-
}
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## 開発コマンド
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
yarn install # パッケージインストール
|
|
42
|
-
yarn build # TypeScriptビルド
|
|
43
|
-
yarn dev # ウォッチモードでビルド
|
|
44
|
-
yarn test # テスト実行(Jest + ESM)
|
|
45
|
-
yarn test:watch # ウォッチモードでテスト
|
|
46
|
-
yarn prettier --write . # コードフォーマット
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## ソース構造
|
|
50
|
-
|
|
51
|
-
```
|
|
52
|
-
src/
|
|
53
|
-
├── cli.ts # CLIエントリーポイント(Commander.js)
|
|
54
|
-
├── config.ts # 設定ファイル読み込み(jiti使用)
|
|
55
|
-
├── generate.ts # dts-gen実行処理
|
|
56
|
-
├── index.ts # エクスポート
|
|
57
|
-
└── types.ts # 型定義・defineConfig
|
|
58
|
-
|
|
59
|
-
test/
|
|
60
|
-
├── config.test.ts # configのテスト
|
|
61
|
-
├── generate.test.ts # generateのテスト
|
|
62
|
-
└── types.test.ts # typesのテスト
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## 技術スタック
|
|
66
|
-
|
|
67
|
-
- **ランタイム:** Node.js >= 20
|
|
68
|
-
- **パッケージマネージャー:** Yarn
|
|
69
|
-
- **主要依存:** @kintone/dts-gen, Commander.js, jiti, change-case, chalk
|
|
70
|
-
- **テスト:** Jest + ts-jest(ESMモード)
|
|
71
|
-
- **フォーマッタ:** Prettier(シングルクォート、120文字/行)
|
package/dts/activity-fields.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
declare namespace kintone.types {
|
|
2
|
-
interface ActivityFields {
|
|
3
|
-
案件No: kintone.fieldTypes.Number;
|
|
4
|
-
顧客No: kintone.fieldTypes.Number;
|
|
5
|
-
タイトル: kintone.fieldTypes.SingleLineText;
|
|
6
|
-
案件名: kintone.fieldTypes.SingleLineText;
|
|
7
|
-
対応日付: kintone.fieldTypes.Date;
|
|
8
|
-
対応種別: kintone.fieldTypes.DropDown;
|
|
9
|
-
内容: kintone.fieldTypes.MultiLineText;
|
|
10
|
-
会社名: kintone.fieldTypes.SingleLineText;
|
|
11
|
-
|
|
12
|
-
対応者: kintone.fieldTypes.UserSelect;
|
|
13
|
-
所属組織: kintone.fieldTypes.OrganizationSelect;
|
|
14
|
-
添付ファイル: kintone.fieldTypes.File;
|
|
15
|
-
}
|
|
16
|
-
interface SavedActivityFields extends ActivityFields {
|
|
17
|
-
$id: kintone.fieldTypes.Id;
|
|
18
|
-
$revision: kintone.fieldTypes.Revision;
|
|
19
|
-
更新者: kintone.fieldTypes.Modifier;
|
|
20
|
-
作成者: kintone.fieldTypes.Creator;
|
|
21
|
-
レコード番号: kintone.fieldTypes.RecordNumber;
|
|
22
|
-
更新日時: kintone.fieldTypes.UpdatedTime;
|
|
23
|
-
作成日時: kintone.fieldTypes.CreatedTime;
|
|
24
|
-
}
|
|
25
|
-
}
|