@asagiri-design/labels-config 0.2.2

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.
@@ -0,0 +1,554 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
21
+
22
+ // src/config/index.ts
23
+ var config_exports = {};
24
+ __export(config_exports, {
25
+ CONFIG_TEMPLATES: () => CONFIG_TEMPLATES,
26
+ ConfigLoader: () => ConfigLoader
27
+ });
28
+ module.exports = __toCommonJS(config_exports);
29
+
30
+ // src/validation.ts
31
+ var import_zod = require("zod");
32
+
33
+ // src/utils/color.ts
34
+ function normalizeHexColor(input) {
35
+ const color = input.toLowerCase();
36
+ if (color.length === 3) {
37
+ return color.split("").map((c) => c + c).join("");
38
+ }
39
+ return color;
40
+ }
41
+
42
+ // src/validation.ts
43
+ var hexColorSchema = import_zod.z.string().regex(/^[0-9a-fA-F]{6}$|^[0-9a-fA-F]{3}$/, "Invalid hex color format").transform((color) => normalizeHexColor(color));
44
+ var labelConfigSchema = import_zod.z.object({
45
+ name: import_zod.z.string().min(1, "Label name is required").max(50, "Label name must be 50 characters or less").regex(
46
+ /^[a-zA-Z0-9\-\s\/\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF]+$/,
47
+ "Label name contains invalid characters"
48
+ ),
49
+ color: hexColorSchema,
50
+ description: import_zod.z.string().min(1, "Description is required").max(200, "Description must be 200 characters or less")
51
+ });
52
+ var labelCategorySchema = import_zod.z.object({
53
+ category: import_zod.z.string().min(1, "Category name is required").max(50, "Category name must be 50 characters or less"),
54
+ labels: import_zod.z.array(labelConfigSchema)
55
+ });
56
+ var labelRegistrySchema = import_zod.z.object({
57
+ version: import_zod.z.string(),
58
+ timestamp: import_zod.z.string().datetime().optional(),
59
+ labels: import_zod.z.union([
60
+ import_zod.z.array(labelConfigSchema),
61
+ import_zod.z.array(labelCategorySchema)
62
+ ]),
63
+ metadata: import_zod.z.record(import_zod.z.unknown()).optional()
64
+ });
65
+ function validateLabels(labels) {
66
+ const schema = import_zod.z.array(labelConfigSchema);
67
+ return schema.parse(labels);
68
+ }
69
+
70
+ // src/config/loader.ts
71
+ var ConfigLoader = class {
72
+ constructor(options = {}) {
73
+ __publicField(this, "strict");
74
+ this.strict = options.strict ?? true;
75
+ }
76
+ /**
77
+ * Load labels from JSON object
78
+ */
79
+ loadFromJSON(data) {
80
+ if (typeof data === "object" && data !== null && "labels" in data && Array.isArray(data.labels)) {
81
+ const labels = data.labels;
82
+ if (labels.length > 0 && "category" in labels[0]) {
83
+ return labels.flatMap((cat) => cat.labels);
84
+ }
85
+ return validateLabels(labels);
86
+ }
87
+ return validateLabels(data);
88
+ }
89
+ /**
90
+ * Load from JSON string
91
+ */
92
+ loadFromString(jsonString) {
93
+ try {
94
+ const data = JSON.parse(jsonString);
95
+ return this.loadFromJSON(data);
96
+ } catch (error) {
97
+ throw new Error(
98
+ `Failed to parse JSON: ${error instanceof Error ? error.message : String(error)}`
99
+ );
100
+ }
101
+ }
102
+ /**
103
+ * Load from registry object
104
+ */
105
+ loadRegistry(registry) {
106
+ return this.loadFromJSON({ labels: registry.labels });
107
+ }
108
+ };
109
+
110
+ // src/config/templates.ts
111
+ var MINIMAL_TEMPLATE = [
112
+ {
113
+ name: "bug",
114
+ color: "ff0000",
115
+ description: "Something is broken"
116
+ },
117
+ {
118
+ name: "feature",
119
+ color: "00ff00",
120
+ description: "New feature or request"
121
+ },
122
+ {
123
+ name: "documentation",
124
+ color: "0000ff",
125
+ description: "Improvements or additions to documentation"
126
+ }
127
+ ];
128
+ var createLabels = (labels) => labels;
129
+ var GITHUB_STANDARD_TEMPLATE = createLabels([
130
+ {
131
+ name: "bug",
132
+ color: "d73a4a",
133
+ description: "Something is broken"
134
+ },
135
+ {
136
+ name: "documentation",
137
+ color: "0075ca",
138
+ description: "Improvements or additions to documentation"
139
+ },
140
+ {
141
+ name: "duplicate",
142
+ color: "cfd3d7",
143
+ description: "This issue or pull request already exists"
144
+ },
145
+ {
146
+ name: "enhancement",
147
+ color: "a2eeef",
148
+ description: "New feature or request"
149
+ },
150
+ {
151
+ name: "good first issue",
152
+ color: "7057ff",
153
+ description: "Good for newcomers"
154
+ },
155
+ {
156
+ name: "help wanted",
157
+ color: "008672",
158
+ description: "Extra attention is needed"
159
+ },
160
+ {
161
+ name: "invalid",
162
+ color: "e4e669",
163
+ description: "This does not seem right"
164
+ },
165
+ {
166
+ name: "question",
167
+ color: "d876e3",
168
+ description: "Further information is requested"
169
+ },
170
+ {
171
+ name: "wontfix",
172
+ color: "ffffff",
173
+ description: "This will not be worked on"
174
+ }
175
+ ]);
176
+ var PROD_EN_TEMPLATE = createLabels([
177
+ {
178
+ name: "API",
179
+ color: "ffb300",
180
+ description: "API integration and external services"
181
+ },
182
+ {
183
+ name: "BFF",
184
+ color: "7057ff",
185
+ description: "Backend for Frontend integration"
186
+ },
187
+ {
188
+ name: "CI/CD",
189
+ color: "00ced1",
190
+ description: "CI/CD and automation"
191
+ },
192
+ {
193
+ name: "Component",
194
+ color: "008672",
195
+ description: "Component addition and updates"
196
+ },
197
+ {
198
+ name: "Documentation",
199
+ color: "332412",
200
+ description: "Documentation additions and updates"
201
+ },
202
+ {
203
+ name: "Hotfix",
204
+ color: "ff6347",
205
+ description: "Emergency fixes and hotfixes"
206
+ },
207
+ {
208
+ name: "Refactoring",
209
+ color: "a9a9a9",
210
+ description: "Code refactoring and performance optimization"
211
+ },
212
+ {
213
+ name: "Testing",
214
+ color: "08a4d6",
215
+ description: "Testing, E2E, and unit tests"
216
+ },
217
+ {
218
+ name: "Type Definition",
219
+ color: "e91e63",
220
+ description: "TypeScript type definitions and type safety"
221
+ },
222
+ {
223
+ name: "Design",
224
+ color: "d876e3",
225
+ description: "UI/UX design"
226
+ },
227
+ {
228
+ name: "Specification",
229
+ color: "d93f0b",
230
+ description: "Specification changes"
231
+ },
232
+ {
233
+ name: "Feature",
234
+ color: "b3fa11",
235
+ description: "New feature addition"
236
+ },
237
+ {
238
+ name: "Environment",
239
+ color: "c5def5",
240
+ description: "Development environment and package updates"
241
+ },
242
+ {
243
+ name: "Page",
244
+ color: "16c9f5",
245
+ description: "Page additions and updates"
246
+ }
247
+ ]);
248
+ var PROD_JA_TEMPLATE = createLabels([
249
+ {
250
+ name: "API\u9023\u643A",
251
+ color: "ffb300",
252
+ description: "API\u30FB\u5916\u90E8\u30B5\u30FC\u30D3\u30B9\u9023\u643A"
253
+ },
254
+ {
255
+ name: "BFF",
256
+ color: "7057ff",
257
+ description: "BFF\u30FB\u30D0\u30C3\u30AF\u30A8\u30F3\u30C9\u9023\u643A"
258
+ },
259
+ {
260
+ name: "CI/CD",
261
+ color: "00ced1",
262
+ description: "CI/CD\u30FB\u81EA\u52D5\u5316"
263
+ },
264
+ {
265
+ name: "\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8",
266
+ color: "008672",
267
+ description: "\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u306E\u8FFD\u52A0\u30FB\u66F4\u65B0"
268
+ },
269
+ {
270
+ name: "\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8",
271
+ color: "332412",
272
+ description: "\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u8FFD\u52A0\u30FB\u66F4\u65B0"
273
+ },
274
+ {
275
+ name: "\u7DCA\u6025\u5BFE\u5FDC",
276
+ color: "ff6347",
277
+ description: "\u7DCA\u6025\u4FEE\u6B63\u30FBHotfix"
278
+ },
279
+ {
280
+ name: "\u30EA\u30D5\u30A1\u30AF\u30BF",
281
+ color: "a9a9a9",
282
+ description: "\u30EA\u30D5\u30A1\u30AF\u30BF\u30EA\u30F3\u30B0\u30FB\u30D1\u30D5\u30A9\u30FC\u30DE\u30F3\u30B9\u6700\u9069\u5316\u30FB\u30B3\u30FC\u30C9\u6574\u7406"
283
+ },
284
+ {
285
+ name: "\u30C6\u30B9\u30C8",
286
+ color: "08a4d6",
287
+ description: "\u30C6\u30B9\u30C8\u30FBE2E\u30FB\u30E6\u30CB\u30C3\u30C8\u30C6\u30B9\u30C8"
288
+ },
289
+ {
290
+ name: "\u578B\u5B9A\u7FA9",
291
+ color: "e91e63",
292
+ description: "TypeScript\u578B\u5B9A\u7FA9\u30FB\u578B\u5B89\u5168\u6027"
293
+ },
294
+ {
295
+ name: "\u30C7\u30B6\u30A4\u30F3",
296
+ color: "d876e3",
297
+ description: "UIUX\u30C7\u30B6\u30A4\u30F3"
298
+ },
299
+ {
300
+ name: "\u4ED5\u69D8\u5909\u66F4",
301
+ color: "d93f0b",
302
+ description: "\u4ED5\u69D8\u5909\u66F4"
303
+ },
304
+ {
305
+ name: "\u6A5F\u80FD\u8FFD\u52A0",
306
+ color: "b3fa11",
307
+ description: "\u6A5F\u80FD\u8FFD\u52A0"
308
+ },
309
+ {
310
+ name: "\u74B0\u5883\u69CB\u7BC9",
311
+ color: "c5def5",
312
+ description: "\u958B\u767A\u74B0\u5883\u30FB\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u8FFD\u52A0\u30FB\u5909\u66F4\u30FB\u66F4\u65B0"
313
+ },
314
+ {
315
+ name: "\u753B\u9762\u8FFD\u52A0",
316
+ color: "16c9f5",
317
+ description: "\u753B\u9762\u306E\u8FFD\u52A0\u30FB\u66F4\u65B0"
318
+ }
319
+ ]);
320
+ var PROD_TEMPLATE = PROD_JA_TEMPLATE;
321
+ var REACT_TEMPLATE = createLabels([
322
+ {
323
+ name: "component",
324
+ color: "61dafb",
325
+ description: "React component development"
326
+ },
327
+ {
328
+ name: "hook",
329
+ color: "20232a",
330
+ description: "Custom hooks implementation"
331
+ },
332
+ {
333
+ name: "state-management",
334
+ color: "764abc",
335
+ description: "Redux, Zustand, Context API"
336
+ },
337
+ {
338
+ name: "performance",
339
+ color: "ffc107",
340
+ description: "Performance optimization, memoization"
341
+ },
342
+ {
343
+ name: "typescript",
344
+ color: "3178c6",
345
+ description: "TypeScript types and interfaces"
346
+ },
347
+ {
348
+ name: "styling",
349
+ color: "ff69b4",
350
+ description: "CSS-in-JS, Tailwind, styled-components"
351
+ },
352
+ {
353
+ name: "testing",
354
+ color: "15c213",
355
+ description: "Unit tests, React Testing Library"
356
+ },
357
+ {
358
+ name: "bug",
359
+ color: "d73a4a",
360
+ description: "Bug fix required"
361
+ },
362
+ {
363
+ name: "refactor",
364
+ color: "fbca04",
365
+ description: "Code refactoring"
366
+ },
367
+ {
368
+ name: "accessibility",
369
+ color: "0e8a16",
370
+ description: "A11y improvements"
371
+ }
372
+ ]);
373
+ var VUE_TEMPLATE = createLabels([
374
+ {
375
+ name: "component",
376
+ color: "42b883",
377
+ description: "Vue component development"
378
+ },
379
+ {
380
+ name: "composable",
381
+ color: "35495e",
382
+ description: "Composition API, composables"
383
+ },
384
+ {
385
+ name: "pinia",
386
+ color: "ffd859",
387
+ description: "Pinia state management"
388
+ },
389
+ {
390
+ name: "vue-router",
391
+ color: "3ba57a",
392
+ description: "Vue Router navigation"
393
+ },
394
+ {
395
+ name: "typescript",
396
+ color: "3178c6",
397
+ description: "TypeScript integration"
398
+ },
399
+ {
400
+ name: "styling",
401
+ color: "ff69b4",
402
+ description: "Scoped CSS, CSS modules"
403
+ },
404
+ {
405
+ name: "testing",
406
+ color: "15c213",
407
+ description: "Vitest, Vue Test Utils"
408
+ },
409
+ {
410
+ name: "bug",
411
+ color: "d73a4a",
412
+ description: "Bug fix required"
413
+ },
414
+ {
415
+ name: "performance",
416
+ color: "ffc107",
417
+ description: "Performance optimization"
418
+ },
419
+ {
420
+ name: "accessibility",
421
+ color: "0e8a16",
422
+ description: "A11y improvements"
423
+ }
424
+ ]);
425
+ var FRONTEND_TEMPLATE = createLabels([
426
+ {
427
+ name: "feature",
428
+ color: "0e8a16",
429
+ description: "New feature implementation"
430
+ },
431
+ {
432
+ name: "bug",
433
+ color: "d73a4a",
434
+ description: "Bug fix required"
435
+ },
436
+ {
437
+ name: "ui",
438
+ color: "ff69b4",
439
+ description: "UI/UX improvements"
440
+ },
441
+ {
442
+ name: "styling",
443
+ color: "c5def5",
444
+ description: "CSS, styling updates"
445
+ },
446
+ {
447
+ name: "responsive",
448
+ color: "1d76db",
449
+ description: "Responsive design, mobile support"
450
+ },
451
+ {
452
+ name: "performance",
453
+ color: "ffc107",
454
+ description: "Performance optimization"
455
+ },
456
+ {
457
+ name: "accessibility",
458
+ color: "0052cc",
459
+ description: "A11y improvements"
460
+ },
461
+ {
462
+ name: "testing",
463
+ color: "15c213",
464
+ description: "Testing, E2E, unit tests"
465
+ },
466
+ {
467
+ name: "dependencies",
468
+ color: "0366d6",
469
+ description: "Dependencies update"
470
+ },
471
+ {
472
+ name: "documentation",
473
+ color: "0075ca",
474
+ description: "Documentation updates"
475
+ },
476
+ {
477
+ name: "build",
478
+ color: "fbca04",
479
+ description: "Build system, bundler"
480
+ },
481
+ {
482
+ name: "seo",
483
+ color: "b60205",
484
+ description: "SEO optimization"
485
+ }
486
+ ]);
487
+ var AGILE_TEMPLATE = createLabels([
488
+ {
489
+ name: "story",
490
+ color: "0e7490",
491
+ description: "User story"
492
+ },
493
+ {
494
+ name: "task",
495
+ color: "4c72a0",
496
+ description: "Implementation task"
497
+ },
498
+ {
499
+ name: "spike",
500
+ color: "ab47bc",
501
+ description: "Research and exploration"
502
+ },
503
+ {
504
+ name: "bug",
505
+ color: "d32f2f",
506
+ description: "Bug fix"
507
+ },
508
+ {
509
+ name: "debt",
510
+ color: "f57c00",
511
+ description: "Technical debt"
512
+ },
513
+ {
514
+ name: "blocked",
515
+ color: "616161",
516
+ description: "Blocked by another issue"
517
+ },
518
+ {
519
+ name: "priority:critical",
520
+ color: "ff0000",
521
+ description: "Critical priority"
522
+ },
523
+ {
524
+ name: "priority:high",
525
+ color: "ff9800",
526
+ description: "High priority"
527
+ },
528
+ {
529
+ name: "priority:medium",
530
+ color: "ffc107",
531
+ description: "Medium priority"
532
+ },
533
+ {
534
+ name: "priority:low",
535
+ color: "cddc39",
536
+ description: "Low priority"
537
+ }
538
+ ]);
539
+ var CONFIG_TEMPLATES = {
540
+ minimal: MINIMAL_TEMPLATE,
541
+ github: GITHUB_STANDARD_TEMPLATE,
542
+ react: REACT_TEMPLATE,
543
+ vue: VUE_TEMPLATE,
544
+ frontend: FRONTEND_TEMPLATE,
545
+ "prod-en": PROD_EN_TEMPLATE,
546
+ "prod-ja": PROD_JA_TEMPLATE,
547
+ prod: PROD_TEMPLATE,
548
+ agile: AGILE_TEMPLATE
549
+ };
550
+ // Annotate the CommonJS export names for ESM import in node:
551
+ 0 && (module.exports = {
552
+ CONFIG_TEMPLATES,
553
+ ConfigLoader
554
+ });
@@ -0,0 +1,10 @@
1
+ import {
2
+ CONFIG_TEMPLATES,
3
+ ConfigLoader
4
+ } from "../chunk-QJLMZSVA.mjs";
5
+ import "../chunk-VU2JB66N.mjs";
6
+ import "../chunk-QZ7TP4HQ.mjs";
7
+ export {
8
+ CONFIG_TEMPLATES,
9
+ ConfigLoader
10
+ };
@@ -0,0 +1,113 @@
1
+ import { L as LabelConfig } from '../types-CkwsO1Iu.mjs';
2
+
3
+ /**
4
+ * GitHub CLI Client
5
+ * Wrapper around gh CLI for label operations
6
+ * No token required - uses gh CLI authentication
7
+ */
8
+
9
+ interface GitHubClientOptions {
10
+ /** Repository owner */
11
+ owner: string;
12
+ /** Repository name */
13
+ repo: string;
14
+ }
15
+ interface GitHubLabel {
16
+ /** Label name */
17
+ name: string;
18
+ /** Hex color (without #) */
19
+ color: string;
20
+ /** Label description */
21
+ description?: string;
22
+ }
23
+ declare class GitHubClient {
24
+ private owner;
25
+ private repo;
26
+ private repoPath;
27
+ constructor(options: GitHubClientOptions);
28
+ /**
29
+ * Execute gh CLI command
30
+ */
31
+ private exec;
32
+ /**
33
+ * Fetch all labels from repository
34
+ */
35
+ fetchLabels(): Promise<GitHubLabel[]>;
36
+ /**
37
+ * Create a new label
38
+ */
39
+ createLabel(label: LabelConfig): Promise<GitHubLabel>;
40
+ /**
41
+ * Update an existing label
42
+ */
43
+ updateLabel(currentName: string, label: Partial<LabelConfig>): Promise<GitHubLabel>;
44
+ /**
45
+ * Delete a label
46
+ */
47
+ deleteLabel(name: string): Promise<void>;
48
+ /**
49
+ * Check if label exists
50
+ */
51
+ hasLabel(name: string): Promise<boolean>;
52
+ }
53
+
54
+ /**
55
+ * GitHub Label Synchronization
56
+ * Syncs local labels to GitHub repositories
57
+ */
58
+
59
+ interface GitHubSyncOptions extends GitHubClientOptions {
60
+ /** Dry run mode - don't make actual changes */
61
+ dryRun?: boolean;
62
+ /** Delete labels on GitHub that don't exist locally */
63
+ deleteExtra?: boolean;
64
+ /** Verbose logging */
65
+ verbose?: boolean;
66
+ }
67
+ interface SyncResult {
68
+ /** Labels created */
69
+ created: LabelConfig[];
70
+ /** Labels updated */
71
+ updated: LabelConfig[];
72
+ /** Labels deleted */
73
+ deleted: string[];
74
+ /** Labels unchanged */
75
+ unchanged: LabelConfig[];
76
+ /** Errors during sync */
77
+ errors: Array<{
78
+ name: string;
79
+ error: string;
80
+ }>;
81
+ }
82
+ declare class GitHubLabelSync {
83
+ private static readonly BATCH_SIZE;
84
+ private client;
85
+ private options;
86
+ constructor(options: GitHubSyncOptions);
87
+ /**
88
+ * Log message if verbose mode is enabled
89
+ */
90
+ private log;
91
+ /**
92
+ * Sync labels to GitHub repository with batch operations for better performance
93
+ */
94
+ syncLabels(localLabels: LabelConfig[]): Promise<SyncResult>;
95
+ /**
96
+ * Check if label has changes
97
+ */
98
+ private hasChanges;
99
+ /**
100
+ * Fetch labels from GitHub
101
+ */
102
+ fetchLabels(): Promise<LabelConfig[]>;
103
+ /**
104
+ * Delete a single label
105
+ */
106
+ deleteLabel(name: string): Promise<void>;
107
+ /**
108
+ * Update a single label
109
+ */
110
+ updateLabel(name: string, updates: Partial<LabelConfig>): Promise<void>;
111
+ }
112
+
113
+ export { GitHubClient, type GitHubClientOptions, type GitHubLabel, GitHubLabelSync, type GitHubSyncOptions };