@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,496 @@
1
+ import {
2
+ validateLabels
3
+ } from "./chunk-VU2JB66N.mjs";
4
+ import {
5
+ __publicField
6
+ } from "./chunk-QZ7TP4HQ.mjs";
7
+
8
+ // src/config/loader.ts
9
+ var ConfigLoader = class {
10
+ constructor(options = {}) {
11
+ __publicField(this, "strict");
12
+ this.strict = options.strict ?? true;
13
+ }
14
+ /**
15
+ * Load labels from JSON object
16
+ */
17
+ loadFromJSON(data) {
18
+ if (typeof data === "object" && data !== null && "labels" in data && Array.isArray(data.labels)) {
19
+ const labels = data.labels;
20
+ if (labels.length > 0 && "category" in labels[0]) {
21
+ return labels.flatMap((cat) => cat.labels);
22
+ }
23
+ return validateLabels(labels);
24
+ }
25
+ return validateLabels(data);
26
+ }
27
+ /**
28
+ * Load from JSON string
29
+ */
30
+ loadFromString(jsonString) {
31
+ try {
32
+ const data = JSON.parse(jsonString);
33
+ return this.loadFromJSON(data);
34
+ } catch (error) {
35
+ throw new Error(
36
+ `Failed to parse JSON: ${error instanceof Error ? error.message : String(error)}`
37
+ );
38
+ }
39
+ }
40
+ /**
41
+ * Load from registry object
42
+ */
43
+ loadRegistry(registry) {
44
+ return this.loadFromJSON({ labels: registry.labels });
45
+ }
46
+ };
47
+
48
+ // src/config/templates.ts
49
+ var MINIMAL_TEMPLATE = [
50
+ {
51
+ name: "bug",
52
+ color: "ff0000",
53
+ description: "Something is broken"
54
+ },
55
+ {
56
+ name: "feature",
57
+ color: "00ff00",
58
+ description: "New feature or request"
59
+ },
60
+ {
61
+ name: "documentation",
62
+ color: "0000ff",
63
+ description: "Improvements or additions to documentation"
64
+ }
65
+ ];
66
+ var createLabels = (labels) => labels;
67
+ var GITHUB_STANDARD_TEMPLATE = createLabels([
68
+ {
69
+ name: "bug",
70
+ color: "d73a4a",
71
+ description: "Something is broken"
72
+ },
73
+ {
74
+ name: "documentation",
75
+ color: "0075ca",
76
+ description: "Improvements or additions to documentation"
77
+ },
78
+ {
79
+ name: "duplicate",
80
+ color: "cfd3d7",
81
+ description: "This issue or pull request already exists"
82
+ },
83
+ {
84
+ name: "enhancement",
85
+ color: "a2eeef",
86
+ description: "New feature or request"
87
+ },
88
+ {
89
+ name: "good first issue",
90
+ color: "7057ff",
91
+ description: "Good for newcomers"
92
+ },
93
+ {
94
+ name: "help wanted",
95
+ color: "008672",
96
+ description: "Extra attention is needed"
97
+ },
98
+ {
99
+ name: "invalid",
100
+ color: "e4e669",
101
+ description: "This does not seem right"
102
+ },
103
+ {
104
+ name: "question",
105
+ color: "d876e3",
106
+ description: "Further information is requested"
107
+ },
108
+ {
109
+ name: "wontfix",
110
+ color: "ffffff",
111
+ description: "This will not be worked on"
112
+ }
113
+ ]);
114
+ var SDPF_EN_TEMPLATE = createLabels([
115
+ {
116
+ name: "API",
117
+ color: "ffb300",
118
+ description: "API integration and external services"
119
+ },
120
+ {
121
+ name: "BFF",
122
+ color: "7057ff",
123
+ description: "Backend for Frontend integration"
124
+ },
125
+ {
126
+ name: "CI/CD",
127
+ color: "00ced1",
128
+ description: "CI/CD and automation"
129
+ },
130
+ {
131
+ name: "Component",
132
+ color: "008672",
133
+ description: "Component addition and updates"
134
+ },
135
+ {
136
+ name: "Documentation",
137
+ color: "332412",
138
+ description: "Documentation additions and updates"
139
+ },
140
+ {
141
+ name: "Hotfix",
142
+ color: "ff6347",
143
+ description: "Emergency fixes and hotfixes"
144
+ },
145
+ {
146
+ name: "Refactoring",
147
+ color: "a9a9a9",
148
+ description: "Code refactoring and performance optimization"
149
+ },
150
+ {
151
+ name: "Testing",
152
+ color: "08a4d6",
153
+ description: "Testing, E2E, and unit tests"
154
+ },
155
+ {
156
+ name: "Type Definition",
157
+ color: "e91e63",
158
+ description: "TypeScript type definitions and type safety"
159
+ },
160
+ {
161
+ name: "Design",
162
+ color: "d876e3",
163
+ description: "UI/UX design"
164
+ },
165
+ {
166
+ name: "Specification",
167
+ color: "d93f0b",
168
+ description: "Specification changes"
169
+ },
170
+ {
171
+ name: "Feature",
172
+ color: "b3fa11",
173
+ description: "New feature addition"
174
+ },
175
+ {
176
+ name: "Environment",
177
+ color: "c5def5",
178
+ description: "Development environment and package updates"
179
+ },
180
+ {
181
+ name: "Page",
182
+ color: "16c9f5",
183
+ description: "Page additions and updates"
184
+ }
185
+ ]);
186
+ var SDPF_JA_TEMPLATE = createLabels([
187
+ {
188
+ name: "API\u9023\u643A",
189
+ color: "ffb300",
190
+ description: "API\u30FB\u5916\u90E8\u30B5\u30FC\u30D3\u30B9\u9023\u643A"
191
+ },
192
+ {
193
+ name: "BFF",
194
+ color: "7057ff",
195
+ description: "BFF\u30FB\u30D0\u30C3\u30AF\u30A8\u30F3\u30C9\u9023\u643A"
196
+ },
197
+ {
198
+ name: "CI/CD",
199
+ color: "00ced1",
200
+ description: "CI/CD\u30FB\u81EA\u52D5\u5316"
201
+ },
202
+ {
203
+ name: "\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8",
204
+ color: "008672",
205
+ description: "\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u306E\u8FFD\u52A0\u30FB\u66F4\u65B0"
206
+ },
207
+ {
208
+ name: "\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8",
209
+ color: "332412",
210
+ description: "\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u8FFD\u52A0\u30FB\u66F4\u65B0"
211
+ },
212
+ {
213
+ name: "\u7DCA\u6025\u5BFE\u5FDC",
214
+ color: "ff6347",
215
+ description: "\u7DCA\u6025\u4FEE\u6B63\u30FBHotfix"
216
+ },
217
+ {
218
+ name: "\u30EA\u30D5\u30A1\u30AF\u30BF",
219
+ color: "a9a9a9",
220
+ 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"
221
+ },
222
+ {
223
+ name: "\u30C6\u30B9\u30C8",
224
+ color: "08a4d6",
225
+ description: "\u30C6\u30B9\u30C8\u30FBE2E\u30FB\u30E6\u30CB\u30C3\u30C8\u30C6\u30B9\u30C8"
226
+ },
227
+ {
228
+ name: "\u578B\u5B9A\u7FA9",
229
+ color: "e91e63",
230
+ description: "TypeScript\u578B\u5B9A\u7FA9\u30FB\u578B\u5B89\u5168\u6027"
231
+ },
232
+ {
233
+ name: "\u30C7\u30B6\u30A4\u30F3",
234
+ color: "d876e3",
235
+ description: "UIUX\u30C7\u30B6\u30A4\u30F3"
236
+ },
237
+ {
238
+ name: "\u4ED5\u69D8\u5909\u66F4",
239
+ color: "d93f0b",
240
+ description: "\u4ED5\u69D8\u5909\u66F4"
241
+ },
242
+ {
243
+ name: "\u6A5F\u80FD\u8FFD\u52A0",
244
+ color: "b3fa11",
245
+ description: "\u6A5F\u80FD\u8FFD\u52A0"
246
+ },
247
+ {
248
+ name: "\u74B0\u5883\u69CB\u7BC9",
249
+ color: "c5def5",
250
+ description: "\u958B\u767A\u74B0\u5883\u30FB\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u8FFD\u52A0\u30FB\u5909\u66F4\u30FB\u66F4\u65B0"
251
+ },
252
+ {
253
+ name: "\u753B\u9762\u8FFD\u52A0",
254
+ color: "16c9f5",
255
+ description: "\u753B\u9762\u306E\u8FFD\u52A0\u30FB\u66F4\u65B0"
256
+ }
257
+ ]);
258
+ var SDPF_TEMPLATE = SDPF_JA_TEMPLATE;
259
+ var REACT_TEMPLATE = createLabels([
260
+ {
261
+ name: "component",
262
+ color: "61dafb",
263
+ description: "React component development"
264
+ },
265
+ {
266
+ name: "hook",
267
+ color: "20232a",
268
+ description: "Custom hooks implementation"
269
+ },
270
+ {
271
+ name: "state-management",
272
+ color: "764abc",
273
+ description: "Redux, Zustand, Context API"
274
+ },
275
+ {
276
+ name: "performance",
277
+ color: "ffc107",
278
+ description: "Performance optimization, memoization"
279
+ },
280
+ {
281
+ name: "typescript",
282
+ color: "3178c6",
283
+ description: "TypeScript types and interfaces"
284
+ },
285
+ {
286
+ name: "styling",
287
+ color: "ff69b4",
288
+ description: "CSS-in-JS, Tailwind, styled-components"
289
+ },
290
+ {
291
+ name: "testing",
292
+ color: "15c213",
293
+ description: "Unit tests, React Testing Library"
294
+ },
295
+ {
296
+ name: "bug",
297
+ color: "d73a4a",
298
+ description: "Bug fix required"
299
+ },
300
+ {
301
+ name: "refactor",
302
+ color: "fbca04",
303
+ description: "Code refactoring"
304
+ },
305
+ {
306
+ name: "accessibility",
307
+ color: "0e8a16",
308
+ description: "A11y improvements"
309
+ }
310
+ ]);
311
+ var VUE_TEMPLATE = createLabels([
312
+ {
313
+ name: "component",
314
+ color: "42b883",
315
+ description: "Vue component development"
316
+ },
317
+ {
318
+ name: "composable",
319
+ color: "35495e",
320
+ description: "Composition API, composables"
321
+ },
322
+ {
323
+ name: "pinia",
324
+ color: "ffd859",
325
+ description: "Pinia state management"
326
+ },
327
+ {
328
+ name: "vue-router",
329
+ color: "3ba57a",
330
+ description: "Vue Router navigation"
331
+ },
332
+ {
333
+ name: "typescript",
334
+ color: "3178c6",
335
+ description: "TypeScript integration"
336
+ },
337
+ {
338
+ name: "styling",
339
+ color: "ff69b4",
340
+ description: "Scoped CSS, CSS modules"
341
+ },
342
+ {
343
+ name: "testing",
344
+ color: "15c213",
345
+ description: "Vitest, Vue Test Utils"
346
+ },
347
+ {
348
+ name: "bug",
349
+ color: "d73a4a",
350
+ description: "Bug fix required"
351
+ },
352
+ {
353
+ name: "performance",
354
+ color: "ffc107",
355
+ description: "Performance optimization"
356
+ },
357
+ {
358
+ name: "accessibility",
359
+ color: "0e8a16",
360
+ description: "A11y improvements"
361
+ }
362
+ ]);
363
+ var FRONTEND_TEMPLATE = createLabels([
364
+ {
365
+ name: "feature",
366
+ color: "0e8a16",
367
+ description: "New feature implementation"
368
+ },
369
+ {
370
+ name: "bug",
371
+ color: "d73a4a",
372
+ description: "Bug fix required"
373
+ },
374
+ {
375
+ name: "ui",
376
+ color: "ff69b4",
377
+ description: "UI/UX improvements"
378
+ },
379
+ {
380
+ name: "styling",
381
+ color: "c5def5",
382
+ description: "CSS, styling updates"
383
+ },
384
+ {
385
+ name: "responsive",
386
+ color: "1d76db",
387
+ description: "Responsive design, mobile support"
388
+ },
389
+ {
390
+ name: "performance",
391
+ color: "ffc107",
392
+ description: "Performance optimization"
393
+ },
394
+ {
395
+ name: "accessibility",
396
+ color: "0052cc",
397
+ description: "A11y improvements"
398
+ },
399
+ {
400
+ name: "testing",
401
+ color: "15c213",
402
+ description: "Testing, E2E, unit tests"
403
+ },
404
+ {
405
+ name: "dependencies",
406
+ color: "0366d6",
407
+ description: "Dependencies update"
408
+ },
409
+ {
410
+ name: "documentation",
411
+ color: "0075ca",
412
+ description: "Documentation updates"
413
+ },
414
+ {
415
+ name: "build",
416
+ color: "fbca04",
417
+ description: "Build system, bundler"
418
+ },
419
+ {
420
+ name: "seo",
421
+ color: "b60205",
422
+ description: "SEO optimization"
423
+ }
424
+ ]);
425
+ var AGILE_TEMPLATE = createLabels([
426
+ {
427
+ name: "story",
428
+ color: "0e7490",
429
+ description: "User story"
430
+ },
431
+ {
432
+ name: "task",
433
+ color: "4c72a0",
434
+ description: "Implementation task"
435
+ },
436
+ {
437
+ name: "spike",
438
+ color: "ab47bc",
439
+ description: "Research and exploration"
440
+ },
441
+ {
442
+ name: "bug",
443
+ color: "d32f2f",
444
+ description: "Bug fix"
445
+ },
446
+ {
447
+ name: "debt",
448
+ color: "f57c00",
449
+ description: "Technical debt"
450
+ },
451
+ {
452
+ name: "blocked",
453
+ color: "616161",
454
+ description: "Blocked by another issue"
455
+ },
456
+ {
457
+ name: "priority:critical",
458
+ color: "ff0000",
459
+ description: "Critical priority"
460
+ },
461
+ {
462
+ name: "priority:high",
463
+ color: "ff9800",
464
+ description: "High priority"
465
+ },
466
+ {
467
+ name: "priority:medium",
468
+ color: "ffc107",
469
+ description: "Medium priority"
470
+ },
471
+ {
472
+ name: "priority:low",
473
+ color: "cddc39",
474
+ description: "Low priority"
475
+ }
476
+ ]);
477
+ var CONFIG_TEMPLATES = {
478
+ minimal: MINIMAL_TEMPLATE,
479
+ github: GITHUB_STANDARD_TEMPLATE,
480
+ react: REACT_TEMPLATE,
481
+ vue: VUE_TEMPLATE,
482
+ frontend: FRONTEND_TEMPLATE,
483
+ "sdpf-en": SDPF_EN_TEMPLATE,
484
+ "sdpf-ja": SDPF_JA_TEMPLATE,
485
+ sdpf: SDPF_TEMPLATE,
486
+ agile: AGILE_TEMPLATE
487
+ };
488
+ function listTemplates() {
489
+ return Object.keys(CONFIG_TEMPLATES);
490
+ }
491
+
492
+ export {
493
+ ConfigLoader,
494
+ CONFIG_TEMPLATES,
495
+ listTemplates
496
+ };
@@ -0,0 +1,161 @@
1
+ import {
2
+ checkDuplicateNames,
3
+ validateLabels,
4
+ validateWithDetails
5
+ } from "./chunk-VU2JB66N.mjs";
6
+ import {
7
+ __publicField
8
+ } from "./chunk-QZ7TP4HQ.mjs";
9
+
10
+ // src/types.ts
11
+ function isCategorized(labels) {
12
+ return Array.isArray(labels) && labels.length > 0 && "category" in labels[0] && "labels" in labels[0];
13
+ }
14
+ function flattenLabels(labels) {
15
+ if (isCategorized(labels)) {
16
+ return labels.flatMap((cat) => cat.labels);
17
+ }
18
+ return labels;
19
+ }
20
+
21
+ // src/manager.ts
22
+ var LabelManager = class {
23
+ constructor(options = {}) {
24
+ __publicField(this, "labels", /* @__PURE__ */ new Map());
25
+ __publicField(this, "strict", false);
26
+ this.strict = options.strict ?? false;
27
+ if (options.labels) {
28
+ this.loadLabels(options.labels);
29
+ }
30
+ }
31
+ /**
32
+ * Load labels from array
33
+ */
34
+ loadLabels(labels) {
35
+ const validation = validateWithDetails(labels);
36
+ if (!validation.valid && this.strict) {
37
+ throw new Error(`Label validation failed: ${JSON.stringify(validation.errors)}`);
38
+ }
39
+ this.labels.clear();
40
+ validation.labels.forEach((label) => {
41
+ this.labels.set(label.name.toLowerCase(), label);
42
+ });
43
+ }
44
+ /**
45
+ * Load labels from registry object
46
+ */
47
+ loadRegistry(registry) {
48
+ const labels = flattenLabels(registry.labels);
49
+ this.loadLabels(labels);
50
+ }
51
+ /**
52
+ * Add a single label
53
+ */
54
+ addLabel(label) {
55
+ const validation = validateLabels([label]);
56
+ const newLabel = validation[0];
57
+ if (this.labels.has(newLabel.name.toLowerCase())) {
58
+ throw new Error(`Label "${newLabel.name}" already exists`);
59
+ }
60
+ this.labels.set(newLabel.name.toLowerCase(), newLabel);
61
+ }
62
+ /**
63
+ * Update an existing label
64
+ */
65
+ updateLabel(name, updates) {
66
+ const key = name.toLowerCase();
67
+ const existing = this.labels.get(key);
68
+ if (!existing) {
69
+ throw new Error(`Label "${name}" not found`);
70
+ }
71
+ const updated = { ...existing, ...updates };
72
+ const validation = validateLabels([updated]);
73
+ this.labels.set(key, validation[0]);
74
+ }
75
+ /**
76
+ * Remove a label
77
+ */
78
+ removeLabel(name) {
79
+ this.labels.delete(name.toLowerCase());
80
+ }
81
+ /**
82
+ * Get a label by name
83
+ */
84
+ getLabel(name) {
85
+ return this.labels.get(name.toLowerCase());
86
+ }
87
+ /**
88
+ * Check if label exists
89
+ */
90
+ hasLabel(name) {
91
+ return this.labels.has(name.toLowerCase());
92
+ }
93
+ /**
94
+ * Get all labels
95
+ */
96
+ getAllLabels() {
97
+ return Array.from(this.labels.values());
98
+ }
99
+ /**
100
+ * Get labels count
101
+ */
102
+ count() {
103
+ return this.labels.size;
104
+ }
105
+ /**
106
+ * Export labels as array
107
+ */
108
+ export() {
109
+ return this.getAllLabels();
110
+ }
111
+ /**
112
+ * Export as registry object
113
+ */
114
+ exportRegistry(version = "1.0.0", metadata) {
115
+ return {
116
+ version,
117
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
118
+ labels: this.getAllLabels(),
119
+ metadata
120
+ };
121
+ }
122
+ /**
123
+ * Search labels by name or description
124
+ */
125
+ search(query) {
126
+ const lowerQuery = query.toLowerCase();
127
+ return this.getAllLabels().filter(
128
+ (label) => label.name.toLowerCase().includes(lowerQuery) || label.description.toLowerCase().includes(lowerQuery)
129
+ );
130
+ }
131
+ /**
132
+ * Find labels by color
133
+ */
134
+ findByColor(color) {
135
+ const normalizedColor = color.toLowerCase();
136
+ return this.getAllLabels().filter((label) => label.color.toLowerCase() === normalizedColor);
137
+ }
138
+ /**
139
+ * Clear all labels
140
+ */
141
+ clear() {
142
+ this.labels.clear();
143
+ }
144
+ /**
145
+ * Validate current state
146
+ */
147
+ validate() {
148
+ const labels = this.getAllLabels();
149
+ const duplicates = checkDuplicateNames(labels);
150
+ return {
151
+ valid: duplicates.length === 0,
152
+ duplicates
153
+ };
154
+ }
155
+ };
156
+
157
+ export {
158
+ isCategorized,
159
+ flattenLabels,
160
+ LabelManager
161
+ };