@klarocards/cli 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.
Files changed (166) hide show
  1. package/README.md +125 -0
  2. package/dist/commands/cheatsheet.d.ts +3 -0
  3. package/dist/commands/cheatsheet.d.ts.map +1 -0
  4. package/dist/commands/cheatsheet.js +80 -0
  5. package/dist/commands/cheatsheet.js.map +1 -0
  6. package/dist/commands/completion.d.ts +3 -0
  7. package/dist/commands/completion.d.ts.map +1 -0
  8. package/dist/commands/completion.js +191 -0
  9. package/dist/commands/completion.js.map +1 -0
  10. package/dist/commands/config.d.ts +3 -0
  11. package/dist/commands/config.d.ts.map +1 -0
  12. package/dist/commands/config.js +77 -0
  13. package/dist/commands/config.js.map +1 -0
  14. package/dist/commands/create.d.ts +3 -0
  15. package/dist/commands/create.d.ts.map +1 -0
  16. package/dist/commands/create.js +121 -0
  17. package/dist/commands/create.js.map +1 -0
  18. package/dist/commands/del.d.ts +3 -0
  19. package/dist/commands/del.d.ts.map +1 -0
  20. package/dist/commands/del.js +49 -0
  21. package/dist/commands/del.js.map +1 -0
  22. package/dist/commands/describe.d.ts +3 -0
  23. package/dist/commands/describe.d.ts.map +1 -0
  24. package/dist/commands/describe.js +105 -0
  25. package/dist/commands/describe.js.map +1 -0
  26. package/dist/commands/edit.d.ts +3 -0
  27. package/dist/commands/edit.d.ts.map +1 -0
  28. package/dist/commands/edit.js +91 -0
  29. package/dist/commands/edit.js.map +1 -0
  30. package/dist/commands/fetch.d.ts +3 -0
  31. package/dist/commands/fetch.d.ts.map +1 -0
  32. package/dist/commands/fetch.js +129 -0
  33. package/dist/commands/fetch.js.map +1 -0
  34. package/dist/commands/init.d.ts +3 -0
  35. package/dist/commands/init.d.ts.map +1 -0
  36. package/dist/commands/init.js +122 -0
  37. package/dist/commands/init.js.map +1 -0
  38. package/dist/commands/login.d.ts +7 -0
  39. package/dist/commands/login.d.ts.map +1 -0
  40. package/dist/commands/login.js +101 -0
  41. package/dist/commands/login.js.map +1 -0
  42. package/dist/commands/logout.d.ts +3 -0
  43. package/dist/commands/logout.d.ts.map +1 -0
  44. package/dist/commands/logout.js +34 -0
  45. package/dist/commands/logout.js.map +1 -0
  46. package/dist/commands/ls.d.ts +3 -0
  47. package/dist/commands/ls.d.ts.map +1 -0
  48. package/dist/commands/ls.js +174 -0
  49. package/dist/commands/ls.js.map +1 -0
  50. package/dist/commands/read.d.ts +3 -0
  51. package/dist/commands/read.d.ts.map +1 -0
  52. package/dist/commands/read.js +64 -0
  53. package/dist/commands/read.js.map +1 -0
  54. package/dist/commands/set.d.ts +3 -0
  55. package/dist/commands/set.d.ts.map +1 -0
  56. package/dist/commands/set.js +61 -0
  57. package/dist/commands/set.js.map +1 -0
  58. package/dist/commands/sync.d.ts +3 -0
  59. package/dist/commands/sync.d.ts.map +1 -0
  60. package/dist/commands/sync.js +157 -0
  61. package/dist/commands/sync.js.map +1 -0
  62. package/dist/commands/update.d.ts +4 -0
  63. package/dist/commands/update.d.ts.map +1 -0
  64. package/dist/commands/update.js +68 -0
  65. package/dist/commands/update.js.map +1 -0
  66. package/dist/commands/use.d.ts +3 -0
  67. package/dist/commands/use.d.ts.map +1 -0
  68. package/dist/commands/use.js +29 -0
  69. package/dist/commands/use.js.map +1 -0
  70. package/dist/commands/whoami.d.ts +3 -0
  71. package/dist/commands/whoami.d.ts.map +1 -0
  72. package/dist/commands/whoami.js +30 -0
  73. package/dist/commands/whoami.js.map +1 -0
  74. package/dist/completions/bash.d.ts +2 -0
  75. package/dist/completions/bash.d.ts.map +1 -0
  76. package/dist/completions/bash.js +134 -0
  77. package/dist/completions/bash.js.map +1 -0
  78. package/dist/completions/commands.d.ts +18 -0
  79. package/dist/completions/commands.d.ts.map +1 -0
  80. package/dist/completions/commands.js +173 -0
  81. package/dist/completions/commands.js.map +1 -0
  82. package/dist/completions/fish.d.ts +2 -0
  83. package/dist/completions/fish.d.ts.map +1 -0
  84. package/dist/completions/fish.js +84 -0
  85. package/dist/completions/fish.js.map +1 -0
  86. package/dist/completions/zsh.d.ts +2 -0
  87. package/dist/completions/zsh.d.ts.map +1 -0
  88. package/dist/completions/zsh.js +113 -0
  89. package/dist/completions/zsh.js.map +1 -0
  90. package/dist/index.d.ts +3 -0
  91. package/dist/index.d.ts.map +1 -0
  92. package/dist/index.js +158 -0
  93. package/dist/index.js.map +1 -0
  94. package/dist/lib/api.d.ts +34 -0
  95. package/dist/lib/api.d.ts.map +1 -0
  96. package/dist/lib/api.js +146 -0
  97. package/dist/lib/api.js.map +1 -0
  98. package/dist/lib/completion-cache.d.ts +34 -0
  99. package/dist/lib/completion-cache.d.ts.map +1 -0
  100. package/dist/lib/completion-cache.js +99 -0
  101. package/dist/lib/completion-cache.js.map +1 -0
  102. package/dist/lib/config.d.ts +12 -0
  103. package/dist/lib/config.d.ts.map +1 -0
  104. package/dist/lib/config.js +111 -0
  105. package/dist/lib/config.js.map +1 -0
  106. package/dist/lib/connector.d.ts +17 -0
  107. package/dist/lib/connector.d.ts.map +1 -0
  108. package/dist/lib/connector.js +2 -0
  109. package/dist/lib/connector.js.map +1 -0
  110. package/dist/lib/defaults.d.ts +9 -0
  111. package/dist/lib/defaults.d.ts.map +1 -0
  112. package/dist/lib/defaults.js +58 -0
  113. package/dist/lib/defaults.js.map +1 -0
  114. package/dist/lib/trace.d.ts +4 -0
  115. package/dist/lib/trace.d.ts.map +1 -0
  116. package/dist/lib/trace.js +13 -0
  117. package/dist/lib/trace.js.map +1 -0
  118. package/dist/lib/types.d.ts +70 -0
  119. package/dist/lib/types.d.ts.map +1 -0
  120. package/dist/lib/types.js +2 -0
  121. package/dist/lib/types.js.map +1 -0
  122. package/dist/utils/content.d.ts +26 -0
  123. package/dist/utils/content.d.ts.map +1 -0
  124. package/dist/utils/content.js +52 -0
  125. package/dist/utils/content.js.map +1 -0
  126. package/dist/utils/dimensions.d.ts +17 -0
  127. package/dist/utils/dimensions.d.ts.map +1 -0
  128. package/dist/utils/dimensions.js +41 -0
  129. package/dist/utils/dimensions.js.map +1 -0
  130. package/dist/utils/editor.d.ts +14 -0
  131. package/dist/utils/editor.d.ts.map +1 -0
  132. package/dist/utils/editor.js +56 -0
  133. package/dist/utils/editor.js.map +1 -0
  134. package/dist/utils/format.d.ts +17 -0
  135. package/dist/utils/format.d.ts.map +1 -0
  136. package/dist/utils/format.js +27 -0
  137. package/dist/utils/format.js.map +1 -0
  138. package/dist/utils/markdown.d.ts +24 -0
  139. package/dist/utils/markdown.d.ts.map +1 -0
  140. package/dist/utils/markdown.js +50 -0
  141. package/dist/utils/markdown.js.map +1 -0
  142. package/dist/utils/objects.d.ts +12 -0
  143. package/dist/utils/objects.d.ts.map +1 -0
  144. package/dist/utils/objects.js +31 -0
  145. package/dist/utils/objects.js.map +1 -0
  146. package/dist/utils/slugify.d.ts +10 -0
  147. package/dist/utils/slugify.d.ts.map +1 -0
  148. package/dist/utils/slugify.js +18 -0
  149. package/dist/utils/slugify.js.map +1 -0
  150. package/dist/utils/story-editor.d.ts +15 -0
  151. package/dist/utils/story-editor.d.ts.map +1 -0
  152. package/dist/utils/story-editor.js +43 -0
  153. package/dist/utils/story-editor.js.map +1 -0
  154. package/dist/utils/story-markdown.d.ts +36 -0
  155. package/dist/utils/story-markdown.d.ts.map +1 -0
  156. package/dist/utils/story-markdown.js +114 -0
  157. package/dist/utils/story-markdown.js.map +1 -0
  158. package/dist/utils/table.d.ts +18 -0
  159. package/dist/utils/table.d.ts.map +1 -0
  160. package/dist/utils/table.js +57 -0
  161. package/dist/utils/table.js.map +1 -0
  162. package/dist/utils/validation.d.ts +8 -0
  163. package/dist/utils/validation.d.ts.map +1 -0
  164. package/dist/utils/validation.js +17 -0
  165. package/dist/utils/validation.js.map +1 -0
  166. package/package.json +45 -0
@@ -0,0 +1,114 @@
1
+ import { stringify, parse } from 'yaml';
2
+ /**
3
+ * Format a story as markdown output.
4
+ *
5
+ * - toptitle: first line of the title
6
+ * - summary: remaining lines of the title (if any)
7
+ * - description: the specification field
8
+ * - dimensions: optional array of dimension names to include as YAML frontmatter
9
+ */
10
+ export function formatStoryMarkdown(story, dimensions) {
11
+ const lines = [];
12
+ // Add YAML frontmatter if dimensions are specified
13
+ if (dimensions && dimensions.length > 0) {
14
+ const frontmatter = {};
15
+ for (const dim of dimensions) {
16
+ if (dim in story) {
17
+ frontmatter[dim] = story[dim];
18
+ }
19
+ }
20
+ if (Object.keys(frontmatter).length > 0) {
21
+ lines.push('---');
22
+ lines.push(stringify(frontmatter).trim());
23
+ lines.push('---');
24
+ lines.push('');
25
+ }
26
+ }
27
+ // Split title into toptitle and summary
28
+ const titleLines = story.title.split('\n');
29
+ const toptitle = titleLines[0];
30
+ const summary = titleLines.slice(1).join('\n').trim();
31
+ // Header with toptitle
32
+ lines.push(`# ${toptitle}`);
33
+ lines.push('');
34
+ // Summary if present
35
+ if (summary) {
36
+ lines.push(summary);
37
+ lines.push('');
38
+ }
39
+ // Description (specification)
40
+ if (story.specification) {
41
+ lines.push(story.specification);
42
+ }
43
+ return lines.join('\n');
44
+ }
45
+ /**
46
+ * Parse markdown back into story fields.
47
+ *
48
+ * Format expected:
49
+ * ```
50
+ * ---
51
+ * dimension: value
52
+ * ---
53
+ *
54
+ * # toptitle
55
+ *
56
+ * [summary - optional]
57
+ *
58
+ * [description - optional]
59
+ * ```
60
+ *
61
+ * If two content blocks exist (separated by blank line), first is summary, second is description.
62
+ * If only one content block exists, it's treated as description.
63
+ */
64
+ export function parseStoryMarkdown(markdown) {
65
+ let content = markdown;
66
+ let dimensions;
67
+ // Check for YAML frontmatter
68
+ if (content.startsWith('---')) {
69
+ const endIndex = content.indexOf('---', 3);
70
+ if (endIndex !== -1) {
71
+ const yamlContent = content.slice(3, endIndex).trim();
72
+ if (yamlContent) {
73
+ dimensions = parse(yamlContent);
74
+ }
75
+ content = content.slice(endIndex + 3).trim();
76
+ }
77
+ }
78
+ const lines = content.split('\n');
79
+ // Extract toptitle from first line
80
+ const firstLine = lines[0] || '';
81
+ if (!firstLine.startsWith('# ')) {
82
+ throw new Error('Invalid format: first line must be a heading (# title)');
83
+ }
84
+ const toptitle = firstLine.slice(2).trim();
85
+ // Skip the title line and find content blocks
86
+ const rest = lines.slice(1).join('\n').trim();
87
+ if (!rest) {
88
+ // Title only
89
+ return { title: toptitle, dimensions };
90
+ }
91
+ // Split by double newlines to find content blocks
92
+ const blocks = rest.split(/\n\n+/).filter(b => b.trim());
93
+ if (blocks.length === 0) {
94
+ return { title: toptitle, dimensions };
95
+ }
96
+ if (blocks.length === 1) {
97
+ // Single block is treated as description
98
+ return {
99
+ title: toptitle,
100
+ specification: blocks[0].trim(),
101
+ dimensions,
102
+ };
103
+ }
104
+ // Multiple blocks: first is summary (part of title), rest is description
105
+ const summary = blocks[0].trim();
106
+ const description = blocks.slice(1).join('\n\n').trim();
107
+ const title = summary ? `${toptitle}\n${summary}` : toptitle;
108
+ return {
109
+ title,
110
+ specification: description || undefined,
111
+ dimensions,
112
+ };
113
+ }
114
+ //# sourceMappingURL=story-markdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"story-markdown.js","sourceRoot":"","sources":["../../src/utils/story-markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AASxC;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAY,EAAE,UAAqB;IACrE,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,mDAAmD;IACnD,IAAI,UAAU,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxC,MAAM,WAAW,GAA4B,EAAE,CAAC;QAChD,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;YAC7B,IAAI,GAAG,IAAI,KAAK,EAAE,CAAC;gBACjB,WAAW,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;QACD,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW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AAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;IACzC,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,yCAAyC;QACzC,OAAO;YACL,KAAK,EAAE,QAAQ;YACf,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;YAC/B,UAAU;SACX,CAAC;IACJ,CAAC;IAED,yEAAyE;IACzE,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACjC,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;IAExD,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,QAAQ,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;IAE7D,OAAO;QACL,KAAK;QACL,aAAa,EAAE,WAAW,IAAI,SAAS;QACvC,UAAU;KACX,CAAC;AACJ,CAAC"}
@@ -0,0 +1,18 @@
1
+ type Tuple = Record<string, unknown>;
2
+ /**
3
+ * Format an array of tuples as a table string with rounded borders.
4
+ *
5
+ * @param data - Array of objects to display
6
+ * @param columns - Column names to include in output
7
+ * @returns Formatted table string
8
+ */
9
+ export declare function formatTable(data: Tuple[], columns: string[]): string;
10
+ /**
11
+ * Print an array of tuples as a formatted table with rounded borders.
12
+ *
13
+ * @param data - Array of objects to display
14
+ * @param columns - Column names to include in output
15
+ */
16
+ export declare function printTable(data: Tuple[], columns: string[]): void;
17
+ export {};
18
+ //# sourceMappingURL=table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/utils/table.ts"],"names":[],"mappings":"AAGA,KAAK,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AA4CrC;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAGpE;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAEjE"}
@@ -0,0 +1,57 @@
1
+ import { Bmg } from '@enspirit/bmg-js';
2
+ import { truncate } from './format.js';
3
+ const BORDER_OVERHEAD = 4; // "│ " + " │" for outer borders
4
+ const COLUMN_SEPARATOR = 3; // " │ " between columns
5
+ const MIN_TITLE_WIDTH = 20;
6
+ const DEFAULT_TERMINAL_WIDTH = 80;
7
+ /**
8
+ * Calculate the maximum width available for the title column.
9
+ */
10
+ function calculateTitleWidth(data, columns) {
11
+ const terminalWidth = process.stdout.columns || DEFAULT_TERMINAL_WIDTH;
12
+ // Calculate width needed for non-title columns
13
+ let usedWidth = BORDER_OVERHEAD;
14
+ for (const col of columns) {
15
+ if (col === 'title')
16
+ continue;
17
+ const maxValueLen = Math.max(col.length, ...data.map(row => String(row[col] ?? '').length));
18
+ usedWidth += maxValueLen + COLUMN_SEPARATOR;
19
+ }
20
+ // Title column header is 5 chars
21
+ const titleHeaderWidth = 'title'.length;
22
+ const availableWidth = terminalWidth - usedWidth - COLUMN_SEPARATOR;
23
+ return Math.max(MIN_TITLE_WIDTH, titleHeaderWidth, availableWidth);
24
+ }
25
+ /**
26
+ * Truncate title fields to fit terminal width.
27
+ */
28
+ function fitToTerminal(data, columns) {
29
+ if (!columns.includes('title'))
30
+ return data;
31
+ const titleWidth = calculateTitleWidth(data, columns);
32
+ return data.map(row => ({
33
+ ...row,
34
+ title: truncate(String(row.title ?? ''), titleWidth),
35
+ }));
36
+ }
37
+ /**
38
+ * Format an array of tuples as a table string with rounded borders.
39
+ *
40
+ * @param data - Array of objects to display
41
+ * @param columns - Column names to include in output
42
+ * @returns Formatted table string
43
+ */
44
+ export function formatTable(data, columns) {
45
+ const fitted = fitToTerminal(data, columns);
46
+ return Bmg(fitted).project(columns).toText({ border: 'rounded' });
47
+ }
48
+ /**
49
+ * Print an array of tuples as a formatted table with rounded borders.
50
+ *
51
+ * @param data - Array of objects to display
52
+ * @param columns - Column names to include in output
53
+ */
54
+ export function printTable(data, columns) {
55
+ console.log(formatTable(data, columns));
56
+ }
57
+ //# sourceMappingURL=table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.js","sourceRoot":"","sources":["../../src/utils/table.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAIvC,MAAM,eAAe,GAAG,CAAC,CAAC,CAAC,gCAAgC;AAC3D,MAAM,gBAAgB,GAAG,CAAC,CAAC,CAAC,wBAAwB;AACpD,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAElC;;GAEG;AACH,SAAS,mBAAmB,CAAC,IAAa,EAAE,OAAiB;IAC3D,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,IAAI,sBAAsB,CAAC;IAEvE,+CAA+C;IAC/C,IAAI,SAAS,GAAG,eAAe,CAAC;IAChC,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QAC1B,IAAI,GAAG,KAAK,OAAO;YAAE,SAAS;QAC9B,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAC1B,GAAG,CAAC,MAAM,EACV,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAClD,CAAC;QACF,SAAS,IAAI,WAAW,GAAG,gBAAgB,CAAC;IAC9C,CAAC;IAED,iCAAiC;IACjC,MAAM,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;IACxC,MAAM,cAAc,GAAG,aAAa,GAAG,SAAS,GAAG,gBAAgB,CAAC;IAEpE,OAAO,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,gBAAgB,EAAE,cAAc,CAAC,CAAC;AACrE,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CAAC,IAAa,EAAE,OAAiB;IACrD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IAE5C,MAAM,UAAU,GAAG,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACtD,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACtB,GAAG,GAAG;QACN,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,UAAU,CAAC;KACrD,CAAC,CAAC,CAAC;AACN,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,IAAa,EAAE,OAAiB;IAC1D,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC5C,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;AACpE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,IAAa,EAAE,OAAiB;IACzD,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Validate a subdomain format.
3
+ * @param subdomain - The subdomain to validate
4
+ * @returns true if valid
5
+ * @throws Error if the subdomain format is invalid
6
+ */
7
+ export declare function validateSubdomain(subdomain: string): true;
8
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAWzD"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Validate a subdomain format.
3
+ * @param subdomain - The subdomain to validate
4
+ * @returns true if valid
5
+ * @throws Error if the subdomain format is invalid
6
+ */
7
+ export function validateSubdomain(subdomain) {
8
+ if (!subdomain) {
9
+ throw new Error('Subdomain is required.');
10
+ }
11
+ // Subdomain should be alphanumeric with hyphens
12
+ if (!/^[a-z0-9-]+$/i.test(subdomain)) {
13
+ throw new Error('Invalid subdomain format. Use only letters, numbers, and hyphens.');
14
+ }
15
+ return true;
16
+ }
17
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAiB;IACjD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5C,CAAC;IAED,gDAAgD;IAChD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;IACvF,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@klarocards/cli",
3
+ "version": "1.0.0",
4
+ "description": "Command-line interface for Klaro Cards",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "bin": {
8
+ "klaro": "./dist/index.js"
9
+ },
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "dev": "tsc --watch",
13
+ "test": "vitest run",
14
+ "test:watch": "vitest",
15
+ "prepublishOnly": "npm run build"
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "keywords": [
21
+ "klaro",
22
+ "klaro-cards",
23
+ "cli",
24
+ "project-management"
25
+ ],
26
+ "author": "",
27
+ "license": "MIT",
28
+ "engines": {
29
+ "node": ">=18.0.0"
30
+ },
31
+ "dependencies": {
32
+ "@enspirit/bmg-js": "^1.1.1",
33
+ "chalk": "^5.6.2",
34
+ "commander": "^12.1.0",
35
+ "marked": "^15.0.12",
36
+ "marked-terminal": "^7.3.0",
37
+ "yaml": "^2.8.2"
38
+ },
39
+ "devDependencies": {
40
+ "@types/marked-terminal": "^6.1.1",
41
+ "@types/node": "^20.11.0",
42
+ "typescript": "^5.3.0",
43
+ "vitest": "^1.2.0"
44
+ }
45
+ }