@blotch/dolan 22.2.2 → 22.2.4

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 (259) hide show
  1. package/dist/commands/add.d.ts +6 -2
  2. package/dist/commands/add.js +41 -11
  3. package/dist/commands/add.js.map +1 -1
  4. package/dist/commands/add.test.js +162 -9
  5. package/dist/commands/add.test.js.map +1 -1
  6. package/dist/commands/diff.d.ts +2 -1
  7. package/dist/commands/diff.js +38 -25
  8. package/dist/commands/diff.js.map +1 -1
  9. package/dist/commands/diff.test.js +72 -11
  10. package/dist/commands/diff.test.js.map +1 -1
  11. package/dist/commands/doctor.js +228 -34
  12. package/dist/commands/doctor.js.map +1 -1
  13. package/dist/commands/doctor.test.js +367 -10
  14. package/dist/commands/doctor.test.js.map +1 -1
  15. package/dist/commands/eject.js +7 -0
  16. package/dist/commands/eject.js.map +1 -1
  17. package/dist/commands/eject.test.js +39 -0
  18. package/dist/commands/eject.test.js.map +1 -1
  19. package/dist/commands/info.js +3 -2
  20. package/dist/commands/info.js.map +1 -1
  21. package/dist/commands/init.d.ts +37 -1
  22. package/dist/commands/init.js +169 -40
  23. package/dist/commands/init.js.map +1 -1
  24. package/dist/commands/init.test.js +392 -27
  25. package/dist/commands/init.test.js.map +1 -1
  26. package/dist/commands/install-packages.d.ts +6 -0
  27. package/dist/commands/install-packages.js +20 -0
  28. package/dist/commands/install-packages.js.map +1 -0
  29. package/dist/commands/install-packages.test.d.ts +1 -0
  30. package/dist/commands/install-packages.test.js +55 -0
  31. package/dist/commands/install-packages.test.js.map +1 -0
  32. package/dist/commands/list.js +21 -14
  33. package/dist/commands/list.js.map +1 -1
  34. package/dist/commands/list.test.js +62 -5
  35. package/dist/commands/list.test.js.map +1 -1
  36. package/dist/commands/outdated.js +11 -10
  37. package/dist/commands/outdated.js.map +1 -1
  38. package/dist/commands/outdated.test.js +20 -5
  39. package/dist/commands/outdated.test.js.map +1 -1
  40. package/dist/commands/remove.d.ts +4 -0
  41. package/dist/commands/remove.js +17 -4
  42. package/dist/commands/remove.js.map +1 -1
  43. package/dist/commands/remove.test.js +53 -2
  44. package/dist/commands/remove.test.js.map +1 -1
  45. package/dist/commands/theme.js +1 -1
  46. package/dist/commands/theme.js.map +1 -1
  47. package/dist/commands/update.d.ts +11 -0
  48. package/dist/commands/update.js +174 -58
  49. package/dist/commands/update.js.map +1 -1
  50. package/dist/commands/update.test.js +587 -33
  51. package/dist/commands/update.test.js.map +1 -1
  52. package/dist/index.js +7 -0
  53. package/dist/index.js.map +1 -1
  54. package/dist/lockfile.d.ts +7 -0
  55. package/dist/lockfile.js +36 -0
  56. package/dist/lockfile.js.map +1 -1
  57. package/dist/lockfile.test.d.ts +1 -0
  58. package/dist/lockfile.test.js +25 -0
  59. package/dist/lockfile.test.js.map +1 -0
  60. package/dist/registry.d.ts +14 -0
  61. package/dist/registry.js +78 -24
  62. package/dist/registry.js.map +1 -1
  63. package/dist/registry.test.js +119 -38
  64. package/dist/registry.test.js.map +1 -1
  65. package/dist/test-utils.d.ts +5 -0
  66. package/dist/test-utils.js +6 -1
  67. package/dist/test-utils.js.map +1 -1
  68. package/dist/testing/fire-lynx-event.d.ts +14 -0
  69. package/dist/testing/fire-lynx-event.js +19 -0
  70. package/dist/testing/fire-lynx-event.js.map +1 -0
  71. package/dist/testing/fire-lynx-event.test.d.ts +1 -0
  72. package/dist/testing/fire-lynx-event.test.js +44 -0
  73. package/dist/testing/fire-lynx-event.test.js.map +1 -0
  74. package/dist/testing/lynx-main-thread.d.ts +22 -0
  75. package/dist/testing/lynx-main-thread.js +11 -0
  76. package/dist/testing/lynx-main-thread.js.map +1 -0
  77. package/dist/testing/lynx-main-thread.test.d.ts +1 -0
  78. package/dist/testing/lynx-main-thread.test.js +24 -0
  79. package/dist/testing/lynx-main-thread.test.js.map +1 -0
  80. package/dist/testing/set-input-signal.d.ts +14 -0
  81. package/dist/testing/set-input-signal.js +21 -0
  82. package/dist/testing/set-input-signal.js.map +1 -0
  83. package/dist/testing/set-input-signal.test.d.ts +1 -0
  84. package/dist/testing/set-input-signal.test.js +20 -0
  85. package/dist/testing/set-input-signal.test.js.map +1 -0
  86. package/dist/ui/components/accordion/accordion.test.ts +158 -144
  87. package/dist/ui/components/accordion/accordion.ts +19 -14
  88. package/dist/ui/components/action-sheet/action-sheet.test.ts +283 -151
  89. package/dist/ui/components/action-sheet/action-sheet.ts +77 -43
  90. package/dist/ui/components/alert/alert.test.ts +67 -19
  91. package/dist/ui/components/alert/alert.ts +14 -16
  92. package/dist/ui/components/alert-dialog/alert-dialog.test.ts +208 -94
  93. package/dist/ui/components/alert-dialog/alert-dialog.ts +75 -38
  94. package/dist/ui/components/area-chart/area-chart.test.ts +134 -119
  95. package/dist/ui/components/area-chart/area-chart.ts +100 -315
  96. package/dist/ui/components/area-chart/index.ts +2 -3
  97. package/dist/ui/components/avatar/avatar.test.ts +89 -45
  98. package/dist/ui/components/badge/badge.test.ts +57 -23
  99. package/dist/ui/components/badge/badge.ts +12 -14
  100. package/dist/ui/components/bar-chart/bar-chart.test.ts +172 -45
  101. package/dist/ui/components/bar-chart/bar-chart.ts +140 -294
  102. package/dist/ui/components/bar-chart/index.ts +3 -3
  103. package/dist/ui/components/bottom-sheet/bottom-sheet.test.ts +386 -128
  104. package/dist/ui/components/bottom-sheet/bottom-sheet.ts +170 -53
  105. package/dist/ui/components/button/button.test.ts +611 -2
  106. package/dist/ui/components/button/button.ts +434 -49
  107. package/dist/ui/components/button/index.ts +2 -0
  108. package/dist/ui/components/button-group/button-group.test.ts +484 -2
  109. package/dist/ui/components/button-group/button-group.ts +380 -68
  110. package/dist/ui/components/button-group/index.ts +3 -0
  111. package/dist/ui/components/candlestick-chart/candlestick-chart.test.ts +183 -58
  112. package/dist/ui/components/candlestick-chart/candlestick-chart.ts +150 -323
  113. package/dist/ui/components/candlestick-chart/index.ts +3 -4
  114. package/dist/ui/components/card/card.test.ts +82 -62
  115. package/dist/ui/components/chart/chart-focus.test.ts +132 -0
  116. package/dist/ui/components/chart/chart-focus.ts +115 -0
  117. package/dist/ui/components/chart/chart-presets.test.ts +335 -0
  118. package/dist/ui/components/chart/chart-presets.ts +278 -0
  119. package/dist/ui/components/chart/chart-scene.test.ts +589 -0
  120. package/dist/ui/components/chart/chart-scene.ts +483 -0
  121. package/dist/ui/components/chart/chart-theme.test.ts +85 -0
  122. package/dist/ui/components/chart/chart-theme.ts +210 -0
  123. package/dist/ui/components/chart/chart-zoom.test.ts +159 -0
  124. package/dist/ui/components/chart/chart-zoom.ts +162 -0
  125. package/dist/ui/components/chart/chart.test.ts +1017 -0
  126. package/dist/ui/components/chart/chart.ts +934 -0
  127. package/dist/ui/components/chart/index.ts +24 -0
  128. package/dist/ui/components/checkbox/checkbox.test.ts +124 -42
  129. package/dist/ui/components/checkbox/checkbox.ts +23 -23
  130. package/dist/ui/components/collapsible/collapsible.test.ts +158 -81
  131. package/dist/ui/components/collapsible/collapsible.ts +19 -14
  132. package/dist/ui/components/context-menu/context-menu.test.ts +224 -0
  133. package/dist/ui/components/context-menu/context-menu.ts +110 -0
  134. package/dist/ui/components/context-menu/index.ts +1 -0
  135. package/dist/ui/components/dialog/dialog.test.ts +213 -108
  136. package/dist/ui/components/dialog/dialog.ts +72 -35
  137. package/dist/ui/components/dock/dock-scroll.test.ts +130 -0
  138. package/dist/ui/components/dock/dock-scroll.ts +133 -0
  139. package/dist/ui/components/dock/dock.test.ts +749 -0
  140. package/dist/ui/components/dock/dock.ts +960 -0
  141. package/dist/ui/components/dock/index.ts +2 -0
  142. package/dist/ui/components/empty-state/empty-state.test.ts +28 -39
  143. package/dist/ui/components/glass/concentric-radius.test.ts +13 -0
  144. package/dist/ui/components/glass/concentric-radius.ts +17 -0
  145. package/dist/ui/components/glass/glass-design.test.ts +78 -0
  146. package/dist/ui/components/glass/glass-design.ts +119 -0
  147. package/dist/ui/components/glass/glass.test.ts +338 -0
  148. package/dist/ui/components/glass/glass.ts +360 -0
  149. package/dist/ui/components/glass/index.ts +18 -0
  150. package/dist/ui/components/icon/icon-theme.test.ts +169 -0
  151. package/dist/ui/components/icon/icon-theme.ts +227 -0
  152. package/dist/ui/components/icon/icon.test.ts +85 -25
  153. package/dist/ui/components/icon/icon.ts +38 -21
  154. package/dist/ui/components/input/input.test.ts +178 -101
  155. package/dist/ui/components/input/input.ts +15 -12
  156. package/dist/ui/components/label/label.test.ts +11 -24
  157. package/dist/ui/components/line-chart/index.ts +2 -3
  158. package/dist/ui/components/line-chart/line-chart.test.ts +149 -56
  159. package/dist/ui/components/line-chart/line-chart.ts +83 -241
  160. package/dist/ui/components/list/list.test.ts +119 -21
  161. package/dist/ui/components/list/list.ts +21 -15
  162. package/dist/ui/components/menu/index.ts +25 -0
  163. package/dist/ui/components/menu/menu-placement.test.ts +153 -0
  164. package/dist/ui/components/menu/menu-placement.ts +159 -0
  165. package/dist/ui/components/menu/menu-popup.test.ts +632 -0
  166. package/dist/ui/components/menu/menu-popup.ts +544 -0
  167. package/dist/ui/components/menu/menu.test.ts +429 -0
  168. package/dist/ui/components/menu/menu.ts +415 -0
  169. package/dist/ui/components/nav-drawer/nav-drawer.test.ts +435 -191
  170. package/dist/ui/components/nav-drawer/nav-drawer.ts +127 -56
  171. package/dist/ui/components/pagination/pagination.test.ts +177 -65
  172. package/dist/ui/components/pagination/pagination.ts +55 -8
  173. package/dist/ui/components/progress/progress.test.ts +102 -46
  174. package/dist/ui/components/progress/progress.ts +52 -54
  175. package/dist/ui/components/radio-group/radio-group.test.ts +128 -83
  176. package/dist/ui/components/radio-group/radio-group.ts +24 -24
  177. package/dist/ui/components/scatter-chart/index.ts +2 -3
  178. package/dist/ui/components/scatter-chart/scatter-chart.test.ts +131 -26
  179. package/dist/ui/components/scatter-chart/scatter-chart.ts +104 -250
  180. package/dist/ui/components/scroll-area/scroll-area.test.ts +95 -24
  181. package/dist/ui/components/scroll-area/scroll-area.ts +8 -8
  182. package/dist/ui/components/select/select.test.ts +138 -78
  183. package/dist/ui/components/select/select.ts +17 -11
  184. package/dist/ui/components/separator/separator.test.ts +18 -17
  185. package/dist/ui/components/sheet/sheet.test.ts +64 -11
  186. package/dist/ui/components/sheet/sheet.ts +9 -1
  187. package/dist/ui/components/skeleton/skeleton.test.ts +24 -7
  188. package/dist/ui/components/skeleton/skeleton.ts +10 -16
  189. package/dist/ui/components/spinner/spinner.test.ts +67 -22
  190. package/dist/ui/components/spinner/spinner.ts +48 -41
  191. package/dist/ui/components/switch/switch.test.ts +116 -46
  192. package/dist/ui/components/switch/switch.ts +8 -13
  193. package/dist/ui/components/tab-bar/index.ts +1 -0
  194. package/dist/ui/components/tab-bar/tab-bar.test.ts +280 -0
  195. package/dist/ui/components/tab-bar/tab-bar.ts +230 -0
  196. package/dist/ui/components/tabs/tabs.test.ts +215 -157
  197. package/dist/ui/components/tabs/tabs.ts +110 -118
  198. package/dist/ui/components/textarea/textarea.test.ts +206 -100
  199. package/dist/ui/components/textarea/textarea.ts +14 -12
  200. package/dist/ui/components/toast/toast.test.ts +436 -315
  201. package/dist/ui/components/toast/toast.ts +62 -55
  202. package/dist/ui/components/toggle/toggle.test.ts +247 -140
  203. package/dist/ui/theme/chart-colors.test.ts +35 -0
  204. package/dist/ui/theme/dark.css +46 -2
  205. package/dist/ui/theme/default.css +63 -7
  206. package/dist/ui/theme/icon-colors.test.ts +35 -0
  207. package/dist/ui/theme/rgb-channels.test.ts +84 -0
  208. package/dist/ui/theme/tailwind-build.test.ts +114 -0
  209. package/dist/ui/theme/tailwind-css.test.ts +83 -0
  210. package/dist/ui/theme/tailwind-plugin.test.ts +42 -2
  211. package/dist/ui/theme/tailwind-plugin.ts +98 -25
  212. package/dist/ui/theme/tailwind.css +113 -0
  213. package/dist/ui/utils/animate.test.ts +13 -1
  214. package/dist/utils/analyze.d.ts +14 -0
  215. package/dist/utils/analyze.js +15 -0
  216. package/dist/utils/analyze.js.map +1 -1
  217. package/dist/utils/analyze.test.js +14 -1
  218. package/dist/utils/analyze.test.js.map +1 -1
  219. package/dist/utils/installed.d.ts +29 -0
  220. package/dist/utils/installed.js +43 -0
  221. package/dist/utils/installed.js.map +1 -0
  222. package/dist/utils/installed.test.d.ts +1 -0
  223. package/dist/utils/installed.test.js +57 -0
  224. package/dist/utils/installed.test.js.map +1 -0
  225. package/dist/utils/interactive.d.ts +9 -0
  226. package/dist/utils/interactive.js +10 -0
  227. package/dist/utils/interactive.js.map +1 -0
  228. package/dist/utils/interactive.test.d.ts +1 -0
  229. package/dist/utils/interactive.test.js +24 -0
  230. package/dist/utils/interactive.test.js.map +1 -0
  231. package/dist/utils/packages.d.ts +36 -0
  232. package/dist/utils/packages.js +70 -0
  233. package/dist/utils/packages.js.map +1 -0
  234. package/dist/utils/packages.test.d.ts +1 -0
  235. package/dist/utils/packages.test.js +89 -0
  236. package/dist/utils/packages.test.js.map +1 -0
  237. package/dist/utils/resolve-paths.d.ts +17 -1
  238. package/dist/utils/resolve-paths.js +21 -3
  239. package/dist/utils/resolve-paths.js.map +1 -1
  240. package/dist/utils/resolve-paths.test.js +38 -2
  241. package/dist/utils/resolve-paths.test.js.map +1 -1
  242. package/dist/utils/tailwind.d.ts +25 -0
  243. package/dist/utils/tailwind.js +51 -0
  244. package/dist/utils/tailwind.js.map +1 -0
  245. package/dist/utils/tailwind.test.d.ts +1 -0
  246. package/dist/utils/tailwind.test.js +71 -0
  247. package/dist/utils/tailwind.test.js.map +1 -0
  248. package/package.json +13 -1
  249. package/dist/ui/components/area-chart/area-chart-render.test.ts +0 -121
  250. package/dist/ui/components/bar-chart/bar-chart-render.test.ts +0 -174
  251. package/dist/ui/components/button/button-render.test.ts +0 -113
  252. package/dist/ui/components/button-group/button-group-render.test.ts +0 -146
  253. package/dist/ui/components/candlestick-chart/candlestick-chart-render.test.ts +0 -174
  254. package/dist/ui/components/cartesian-chart/cartesian-chart-render.test.ts +0 -188
  255. package/dist/ui/components/cartesian-chart/cartesian-chart.test.ts +0 -525
  256. package/dist/ui/components/cartesian-chart/cartesian-chart.ts +0 -1140
  257. package/dist/ui/components/cartesian-chart/index.ts +0 -18
  258. package/dist/ui/components/line-chart/line-chart-render.test.ts +0 -121
  259. package/dist/ui/components/scatter-chart/scatter-chart-render.test.ts +0 -157
@@ -0,0 +1,36 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ /**
3
+ * npm packages a component imports. Components are copied, not installed, but
4
+ * some build on a library (the charts on `@tanstack/charts`), and their copied
5
+ * code can't compile until the project depends on it too. `dolan add` and
6
+ * `dolan update` install what's missing with the project's own package manager.
7
+ */
8
+ export type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun';
9
+ /**
10
+ * The package manager whose lockfile is nearest `cwd`, looking up the tree
11
+ * because in a workspace the lockfile sits at the root. npm when there's none.
12
+ */
13
+ export declare const detectPackageManager: (cwd: string) => PackageManager;
14
+ /** `@scope/name@^1.0.0` → `@scope/name`; `name` stays `name`. */
15
+ export declare const packageName: (spec: string) => string;
16
+ /** The specs whose package the project's package.json doesn't list yet. */
17
+ export declare const missingPackages: (cwd: string, specs: readonly string[]) => string[];
18
+ /** The command that adds `specs` as dependencies, e.g. `npm install a b`. */
19
+ export declare const installCommand: (manager: PackageManager, specs: readonly string[]) => string[];
20
+ /**
21
+ * Installs `specs` in `cwd`. Returns false when the package manager couldn't
22
+ * run or failed, so the caller can show the command to run by hand.
23
+ */
24
+ export declare const installPackages: (cwd: string, specs: readonly string[], run?: typeof spawnSync) => boolean;
25
+ /**
26
+ * The library the components' tests render with. Apps get it from
27
+ * `ng generate @blotch/angular-lynx:add-testing`.
28
+ */
29
+ export declare const TESTING_LIBRARY = "@blotch/angular-lynx-testing-library";
30
+ /**
31
+ * Whether dolan copies components' tests into the project: only when it
32
+ * depends on the testing library, since the tests import it and `ng test`
33
+ * fails to compile them otherwise. Every command asks the same question, so
34
+ * a project without the library never sees the tests as missing or new.
35
+ */
36
+ export declare const copiesTests: (cwd: string) => boolean;
@@ -0,0 +1,70 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ import { existsSync, readFileSync } from 'node:fs';
3
+ import { dirname, join } from 'node:path';
4
+ const LOCK_FILES = [
5
+ ['pnpm-lock.yaml', 'pnpm'],
6
+ ['yarn.lock', 'yarn'],
7
+ ['bun.lock', 'bun'],
8
+ ['bun.lockb', 'bun'],
9
+ ['package-lock.json', 'npm'],
10
+ ];
11
+ /**
12
+ * The package manager whose lockfile is nearest `cwd`, looking up the tree
13
+ * because in a workspace the lockfile sits at the root. npm when there's none.
14
+ */
15
+ export const detectPackageManager = (cwd) => {
16
+ let dir = cwd;
17
+ for (;;) {
18
+ for (const [file, manager] of LOCK_FILES) {
19
+ if (existsSync(join(dir, file)))
20
+ return manager;
21
+ }
22
+ const parent = dirname(dir);
23
+ if (parent === dir)
24
+ return 'npm';
25
+ dir = parent;
26
+ }
27
+ };
28
+ /** `@scope/name@^1.0.0` → `@scope/name`; `name` stays `name`. */
29
+ export const packageName = (spec) => {
30
+ const at = spec.indexOf('@', 1);
31
+ return at === -1 ? spec : spec.slice(0, at);
32
+ };
33
+ /** The specs whose package the project's package.json doesn't list yet. */
34
+ export const missingPackages = (cwd, specs) => {
35
+ const manifestPath = join(cwd, 'package.json');
36
+ const manifest = existsSync(manifestPath)
37
+ ? JSON.parse(readFileSync(manifestPath, 'utf-8'))
38
+ : {};
39
+ const listed = new Set(['dependencies', 'devDependencies', 'peerDependencies'].flatMap((key) => Object.keys(manifest[key] ?? {})));
40
+ return specs.filter((spec) => !listed.has(packageName(spec)));
41
+ };
42
+ /** The command that adds `specs` as dependencies, e.g. `npm install a b`. */
43
+ export const installCommand = (manager, specs) => [manager, manager === 'npm' ? 'install' : 'add', ...specs];
44
+ /**
45
+ * Installs `specs` in `cwd`. Returns false when the package manager couldn't
46
+ * run or failed, so the caller can show the command to run by hand.
47
+ */
48
+ export const installPackages = (cwd, specs, run = spawnSync) => {
49
+ const [command, ...args] = installCommand(detectPackageManager(cwd), specs);
50
+ const result = run(command, args, {
51
+ cwd,
52
+ stdio: 'inherit',
53
+ // Package managers are .cmd shims on Windows, which only a shell runs.
54
+ shell: process.platform === 'win32',
55
+ });
56
+ return result.status === 0;
57
+ };
58
+ /**
59
+ * The library the components' tests render with. Apps get it from
60
+ * `ng generate @blotch/angular-lynx:add-testing`.
61
+ */
62
+ export const TESTING_LIBRARY = '@blotch/angular-lynx-testing-library';
63
+ /**
64
+ * Whether dolan copies components' tests into the project: only when it
65
+ * depends on the testing library, since the tests import it and `ng test`
66
+ * fails to compile them otherwise. Every command asks the same question, so
67
+ * a project without the library never sees the tests as missing or new.
68
+ */
69
+ export const copiesTests = (cwd) => missingPackages(cwd, [TESTING_LIBRARY]).length === 0;
70
+ //# sourceMappingURL=packages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packages.js","sourceRoot":"","sources":["../../src/utils/packages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAW1C,MAAM,UAAU,GAAwC;IACtD,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAC1B,CAAC,WAAW,EAAE,MAAM,CAAC;IACrB,CAAC,UAAU,EAAE,KAAK,CAAC;IACnB,CAAC,WAAW,EAAE,KAAK,CAAC;IACpB,CAAC,mBAAmB,EAAE,KAAK,CAAC;CAC7B,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,GAAW,EAAkB,EAAE;IAClE,IAAI,GAAG,GAAG,GAAG,CAAC;IACd,SAAS,CAAC;QACR,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,UAAU,EAAE,CAAC;YACzC,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;gBAAE,OAAO,OAAO,CAAC;QAClD,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,CA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AAC,OAAO,EAAE,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC,CAAC;AAE1E;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,GAAW,EACX,KAAwB,EACxB,MAAwB,SAAS,EACxB,EAAE;IACX,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,cAAc,CAAC,oBAAoB,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;IAC5E,MAAM,MAAM,GAAG,GAAG,CAAC,OAAQ,EAAE,IAAI,EAAE;QACjC,GAAG;QACH,KAAK,EAAE,SAAS;QAChB,uEAAuE;QACvE,KAAK,EAAE,OAAO,CAAC,QAAQ,KAAK,OAAO;KACpC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC;AAC7B,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,sCAAsC,CAAC;AAEtE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAW,EAAW,EAAE,CAClD,eAAe,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,89 @@
1
+ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
2
+ import { tmpdir } from 'node:os';
3
+ import { join } from 'node:path';
4
+ import { afterEach, describe, expect, it, vi } from 'vitest';
5
+ import { detectPackageManager, installCommand, installPackages, missingPackages, packageName, } from './packages';
6
+ let root;
7
+ const makeRoot = () => {
8
+ root = mkdtempSync(join(tmpdir(), 'dolan-packages-'));
9
+ return root;
10
+ };
11
+ afterEach(() => {
12
+ if (root)
13
+ rmSync(root, { recursive: true, force: true });
14
+ });
15
+ describe('detectPackageManager', () => {
16
+ it.each([
17
+ ['pnpm-lock.yaml', 'pnpm'],
18
+ ['yarn.lock', 'yarn'],
19
+ ['bun.lock', 'bun'],
20
+ ['bun.lockb', 'bun'],
21
+ ['package-lock.json', 'npm'],
22
+ ])('reads %s as %s', (lockfile, manager) => {
23
+ writeFileSync(join(makeRoot(), lockfile), '');
24
+ expect(detectPackageManager(root)).toBe(manager);
25
+ });
26
+ it("finds a workspace root's lockfile above the app", () => {
27
+ writeFileSync(join(makeRoot(), 'pnpm-lock.yaml'), '');
28
+ const app = join(root, 'apps', 'mobile');
29
+ mkdirSync(app, { recursive: true });
30
+ expect(detectPackageManager(app)).toBe('pnpm');
31
+ });
32
+ it('defaults to npm without a lockfile', () => {
33
+ expect(detectPackageManager(makeRoot())).toBe('npm');
34
+ });
35
+ });
36
+ describe('packageName', () => {
37
+ it('strips the version range, keeping a scope', () => {
38
+ expect(packageName('@tanstack/charts@^1.1.0')).toBe('@tanstack/charts');
39
+ expect(packageName('d3-shape@^3.2.0')).toBe('d3-shape');
40
+ expect(packageName('d3-shape')).toBe('d3-shape');
41
+ expect(packageName('@scope/name')).toBe('@scope/name');
42
+ });
43
+ });
44
+ describe('missingPackages', () => {
45
+ it("lists specs the project's package.json doesn't name in any section", () => {
46
+ writeFileSync(join(makeRoot(), 'package.json'), JSON.stringify({
47
+ dependencies: { a: '1' },
48
+ devDependencies: { b: '1' },
49
+ peerDependencies: { c: '1' },
50
+ }));
51
+ expect(missingPackages(root, ['a@^1', 'b', 'c@2', 'd@^4'])).toEqual([
52
+ 'd@^4',
53
+ ]);
54
+ });
55
+ it('treats a missing package.json as listing nothing', () => {
56
+ expect(missingPackages(makeRoot(), ['a'])).toEqual(['a']);
57
+ });
58
+ });
59
+ describe('installCommand', () => {
60
+ it("uses each manager's add verb", () => {
61
+ expect(installCommand('npm', ['a', 'b'])).toEqual([
62
+ 'npm',
63
+ 'install',
64
+ 'a',
65
+ 'b',
66
+ ]);
67
+ expect(installCommand('pnpm', ['a'])).toEqual(['pnpm', 'add', 'a']);
68
+ expect(installCommand('yarn', ['a'])).toEqual(['yarn', 'add', 'a']);
69
+ expect(installCommand('bun', ['a'])).toEqual(['bun', 'add', 'a']);
70
+ });
71
+ });
72
+ describe('installPackages', () => {
73
+ it("runs the project's package manager in the project", () => {
74
+ writeFileSync(join(makeRoot(), 'yarn.lock'), '');
75
+ const run = vi.fn(() => ({ status: 0 }));
76
+ expect(installPackages(root, ['a@1'], run)).toBe(true);
77
+ expect(run).toHaveBeenCalledWith('yarn', ['add', 'a@1'], {
78
+ cwd: root,
79
+ stdio: 'inherit',
80
+ shell: process.platform === 'win32',
81
+ });
82
+ });
83
+ it("reports an install that failed or couldn't start", () => {
84
+ makeRoot();
85
+ expect(installPackages(root, ['a'], (() => ({ status: 1 })))).toBe(false);
86
+ expect(installPackages(root, ['a'], (() => ({ status: null })))).toBe(false);
87
+ });
88
+ });
89
+ //# sourceMappingURL=packages.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packages.test.js","sourceRoot":"","sources":["../../src/utils/packages.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC7D,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,eAAe,EACf,WAAW,GACZ,MAAM,YAAY,CAAC;AAEpB,IAAI,IAAY,CAAC;AACjB,MAAM,QAAQ,GAAG,GAAG,EAAE;IACpB,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,iBAAiB,CAAC,CAAC,CAAC;IACtD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,SAAS,CAAC,GAAG,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M,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE;YACvD,GAAG,EAAE,IAAI;YACT,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,OAAO,CAAC,QAAQ,KAAK,OAAO;SACpC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QAC1D,QAAQ,EAAE,CAAC;QACX,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAU,CAAC,CAAC,CAAC,IAAI,CACzE,KAAK,CACN,CAAC;QACF,MAAM,CACJ,eAAe,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAU,CAAC,CAClE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,6 +1,17 @@
1
1
  export declare const getUiSourceDir: () => string;
2
2
  export declare const getComponentSourceDir: (componentName: string) => string;
3
- export declare const getComponentFiles: (componentName: string) => string[];
3
+ /**
4
+ * The files a component ships: its `.ts` sources and, when `tests` is set,
5
+ * every one of its tests. Together they cover the component fully under an
6
+ * app's `ng test`, so the app can keep the copies in its coverage report
7
+ * (packages/ui runs them the same way, and checks that). Tests render with
8
+ * `@blotch/angular-lynx-testing-library`, so the commands pass
9
+ * `copiesTests(cwd)`: an app without the library would fail to compile them
10
+ * in `ng test`.
11
+ */
12
+ export declare const getComponentFiles: (componentName: string, { tests }: {
13
+ tests: boolean;
14
+ }) => string[];
4
15
  /**
5
16
  * When copying component source files from the bundled @blotch/ui package
6
17
  * into the user's project, relative imports to shared utilities
@@ -8,5 +19,10 @@ export declare const getComponentFiles: (componentName: string) => string[];
8
19
  * package path (`from '@blotch/dolan/utils/cn'`). The relative paths
9
20
  * only work inside the monorepo source tree — in the user's project,
10
21
  * the utils are consumed as package exports from @blotch/dolan.
22
+ *
23
+ * Tests import the library's test helpers the same way
24
+ * (`../../../test-utils/set-input-signal`), and @blotch/dolan ships those
25
+ * too, as `@blotch/dolan/testing/*`. Without the rewrite, a copied test
26
+ * imported a file the app doesn't have and broke its `ng test`.
11
27
  */
12
28
  export declare const rewriteImports: (fileContent: string) => string;
@@ -9,9 +9,18 @@ export const getUiSourceDir = () => {
9
9
  export const getComponentSourceDir = (componentName) => {
10
10
  return join(getUiSourceDir(), 'components', componentName);
11
11
  };
12
- export const getComponentFiles = (componentName) => {
12
+ /**
13
+ * The files a component ships: its `.ts` sources and, when `tests` is set,
14
+ * every one of its tests. Together they cover the component fully under an
15
+ * app's `ng test`, so the app can keep the copies in its coverage report
16
+ * (packages/ui runs them the same way, and checks that). Tests render with
17
+ * `@blotch/angular-lynx-testing-library`, so the commands pass
18
+ * `copiesTests(cwd)`: an app without the library would fail to compile them
19
+ * in `ng test`.
20
+ */
21
+ export const getComponentFiles = (componentName, { tests }) => {
13
22
  const dir = getComponentSourceDir(componentName);
14
- return readdirSync(dir).filter((f) => f.endsWith('.ts'));
23
+ return readdirSync(dir).filter((f) => f.endsWith('.ts') && (tests || !f.endsWith('.test.ts')));
15
24
  };
16
25
  /**
17
26
  * When copying component source files from the bundled @blotch/ui package
@@ -20,10 +29,19 @@ export const getComponentFiles = (componentName) => {
20
29
  * package path (`from '@blotch/dolan/utils/cn'`). The relative paths
21
30
  * only work inside the monorepo source tree — in the user's project,
22
31
  * the utils are consumed as package exports from @blotch/dolan.
32
+ *
33
+ * Tests import the library's test helpers the same way
34
+ * (`../../../test-utils/set-input-signal`), and @blotch/dolan ships those
35
+ * too, as `@blotch/dolan/testing/*`. Without the rewrite, a copied test
36
+ * imported a file the app doesn't have and broke its `ng test`.
23
37
  */
24
38
  export const rewriteImports = (fileContent) => {
25
- return fileContent.replace(/from\s+['"]\.\.\/\.\.\/utils\/([^'"]+)['"];?/g, (_match, utilName) => {
39
+ return fileContent
40
+ .replace(/from\s+['"]\.\.\/\.\.\/utils\/([^'"]+)['"];?/g, (_match, utilName) => {
26
41
  return `from '@blotch/dolan/utils/${utilName}';`;
42
+ })
43
+ .replace(/from\s+['"]\.\.\/\.\.\/\.\.\/test-utils\/([^'"]+)['"];?/g, (_match, helperName) => {
44
+ return `from '@blotch/dolan/testing/${helperName}';`;
27
45
  });
28
46
  };
29
47
  //# sourceMappingURL=resolve-paths.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-paths.js","sourceRoot":"","sources":["../../src/utils/resolve-paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,CAAC,MAAM,cAAc,GAAG,GAAW,EAAE;IACzC,iEAAiE;IACjE,MAAM,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC9E,OAAO,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;AAC5C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,aAAqB,EAAU,EAAE;IACrE,OAAO,IAAI,CAAC,cAAc,EAAE,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;AAC7D,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,aAAqB,EAAY,EAAE;IACnE,MAAM,GAAG,GAAG,qBAAqB,CAAC,aAAa,CAAC,CAAC;IACjD,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,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AC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAC/D,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,WAAmB,EAAU,EAAE;IAC5D,OAAO,WAAW;SACf,OAAO,CACN,+CAA+C,EAC/C,CAAC,MAAM,EAAE,QAAgB,EAAE,EAAE;QAC3B,OAAO,6BAA6B,QAAQ,IAAI,CAAC;IACnD,CAAC,CACF;SACA,OAAO,CACN,0DAA0D,EAC1D,CAAC,MAAM,EAAE,UAAkB,EAAE,EAAE;QAC7B,OAAO,+BAA+B,UAAU,IAAI,CAAC;IACvD,CAAC,CACF,CAAC;AACN,CAAC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect } from 'vitest';
2
- import { readFileSync } from 'node:fs';
2
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
3
3
  import { join } from 'node:path';
4
4
  import { getUiSourceDir, getComponentSourceDir, getComponentFiles, rewriteImports, } from './resolve-paths';
5
5
  // Deliberately unmocked (unlike the command tests, which stub this module out
@@ -24,13 +24,45 @@ describe('getComponentFiles', () => {
24
24
  it('lists only .ts files for a real registry component', () => {
25
25
  // card/ ships card.ts + index.ts alongside no non-.ts files, so this also
26
26
  // pins that non-.ts assets (if any were added later) would be filtered.
27
- const files = getComponentFiles('card');
27
+ const files = getComponentFiles('card', { tests: true });
28
28
  expect(files).toContain('card.ts');
29
29
  expect(files).toContain('index.ts');
30
30
  for (const file of files) {
31
31
  expect(file.endsWith('.ts')).toBe(true);
32
32
  }
33
33
  });
34
+ it('ships every test in the component folder', () => {
35
+ // Together they cover the component, so an app's coverage report can
36
+ // include the copies (packages/ui checks the coverage).
37
+ const components = join(getUiSourceDir(), 'components');
38
+ for (const name of readdirSync(components)) {
39
+ const tests = readdirSync(join(components, name)).filter((file) => file.endsWith('.test.ts'));
40
+ expect(tests, name).not.toEqual([]);
41
+ expect(getComponentFiles(name, { tests: true }), name).toEqual(expect.arrayContaining(tests));
42
+ }
43
+ });
44
+ it('leaves every test behind for an app without the testing library', () => {
45
+ const files = getComponentFiles('line-chart', { tests: false });
46
+ expect(files).toContain('line-chart.ts');
47
+ expect(files.filter((file) => file.endsWith('.test.ts'))).toEqual([]);
48
+ });
49
+ it('ships every test helper the copied tests import', () => {
50
+ // rewriteImports points `../../../test-utils/<name>` at
51
+ // `@blotch/dolan/testing/<name>`, so each one needs a file and an export.
52
+ const exports = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf-8')).exports;
53
+ const components = join(getUiSourceDir(), 'components');
54
+ for (const name of readdirSync(components)) {
55
+ for (const file of getComponentFiles(name, { tests: true })) {
56
+ const source = readFileSync(join(components, name, file), 'utf-8');
57
+ for (const [, helper] of source.matchAll(/from '\.\.\/\.\.\/\.\.\/test-utils\/([^']+)'/g)) {
58
+ expect(exports, `${name}/${file}`).toHaveProperty([
59
+ `./testing/${helper}`,
60
+ ]);
61
+ expect(existsSync(new URL(`../testing/${helper}.ts`, import.meta.url))).toBe(true);
62
+ }
63
+ }
64
+ }
65
+ });
34
66
  });
35
67
  describe('rewriteImports', () => {
36
68
  it('rewrites relative ../../utils/* imports to the published package path', () => {
@@ -44,6 +76,10 @@ describe('rewriteImports', () => {
44
76
  const content = "import { Foo } from './foo';\nexport const x = 1;\n";
45
77
  expect(rewriteImports(content)).toBe(content);
46
78
  });
79
+ it('rewrites the test helpers to the ones @blotch/dolan ships', () => {
80
+ const content = "import { setInputSignal } from '../../../test-utils/set-input-signal';";
81
+ expect(rewriteImports(content)).toBe("import { setInputSignal } from '@blotch/dolan/testing/set-input-signal';");
82
+ });
47
83
  it('rewrites an import with no trailing semicolon', () => {
48
84
  const content = "import { cn } from '../../utils/cn'";
49
85
  expect(rewriteImports(content)).toBe("import { cn } from '@blotch/dolan/utils/cn';");
@@ -1 +1 @@
1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AEH,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,EAAE,CAAC,uEAAuE,EAAE,GAAG,EAAE;QAC/E,MAAM,MAAM,GAAG,YAAY,CACzB,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,EAC9C,OAAO,CACR,CAAC;QACF,MAAM,SAAS,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;QAEzC,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,qCAAqC,CAAC,CAAC;QACnE,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,gCAAgC,CAAC,CAAC;QAC9D,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;QAChE,MAAM,OAAO,GAAG,qDAAqD,CAAC;QACtE,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2DAA2D,EAAE,GAAG,EAAE;QACnE,MAAM,OAAO,GACX,wEAAwE,CAAC;QAC3E,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAClC,0EAA0E,CAC3E,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACvD,MAAM,OAAO,GAAG,qCAAqC,CAAC;QACtD,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAClC,8CAA8C,CAC/C,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,25 @@
1
+ /** The config files Tailwind 3 reads. Tailwind 4 needs none. */
2
+ export declare const TAILWIND_CONFIG_FILES: string[];
3
+ /**
4
+ * Whether the project is set up for Tailwind 4, where the theme's plugin is
5
+ * loaded with `@plugin` in the stylesheet rather than listed in
6
+ * `tailwind.config.ts`: it has no Tailwind config, and depends on Tailwind 4
7
+ * or on its PostCSS plugin, as `ng add @blotch/angular-lynx` and
8
+ * `ng new --style=tailwind` set it up.
9
+ */
10
+ export declare const usesTailwind4: (cwd: string) => boolean;
11
+ /**
12
+ * The theme files a project takes: the colors, and what maps them to
13
+ * Tailwind's utilities, `tailwind.css` for Tailwind 4 (imported in the
14
+ * stylesheet) or `tailwind-plugin.ts` for Tailwind 3 (a config plugin).
15
+ *
16
+ * With `tests`, the plugin comes with its test, for the same reason as a
17
+ * component's (see getComponentFiles): it covers the plugin in the app's
18
+ * coverage report. `tailwind.css` has no code to cover. The theme folder's
19
+ * other tests stay behind: they check the theme in packages/ui with Node,
20
+ * against the components and Tailwind's own builds, which an app's `ng test`
21
+ * can't do.
22
+ */
23
+ export declare const themeFilesFor: (cwd: string, { tests }?: {
24
+ tests?: boolean;
25
+ }) => string[];
@@ -0,0 +1,51 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ /** The config files Tailwind 3 reads. Tailwind 4 needs none. */
4
+ export const TAILWIND_CONFIG_FILES = [
5
+ 'tailwind.config.ts',
6
+ 'tailwind.config.js',
7
+ 'tailwind.config.mjs',
8
+ 'tailwind.config.cjs',
9
+ ];
10
+ /**
11
+ * Whether the project is set up for Tailwind 4, where the theme's plugin is
12
+ * loaded with `@plugin` in the stylesheet rather than listed in
13
+ * `tailwind.config.ts`: it has no Tailwind config, and depends on Tailwind 4
14
+ * or on its PostCSS plugin, as `ng add @blotch/angular-lynx` and
15
+ * `ng new --style=tailwind` set it up.
16
+ */
17
+ export const usesTailwind4 = (cwd) => {
18
+ if (TAILWIND_CONFIG_FILES.some((file) => existsSync(join(cwd, file)))) {
19
+ return false;
20
+ }
21
+ try {
22
+ const { dependencies = {}, devDependencies = {} } = JSON.parse(readFileSync(join(cwd, 'package.json'), 'utf-8'));
23
+ const all = { ...dependencies, ...devDependencies };
24
+ const major = Number(/\d+/.exec(all['tailwindcss'] ?? '')?.[0]);
25
+ return Boolean(all['@tailwindcss/postcss']) || major >= 4;
26
+ }
27
+ catch {
28
+ return false;
29
+ }
30
+ };
31
+ /**
32
+ * The theme files a project takes: the colors, and what maps them to
33
+ * Tailwind's utilities, `tailwind.css` for Tailwind 4 (imported in the
34
+ * stylesheet) or `tailwind-plugin.ts` for Tailwind 3 (a config plugin).
35
+ *
36
+ * With `tests`, the plugin comes with its test, for the same reason as a
37
+ * component's (see getComponentFiles): it covers the plugin in the app's
38
+ * coverage report. `tailwind.css` has no code to cover. The theme folder's
39
+ * other tests stay behind: they check the theme in packages/ui with Node,
40
+ * against the components and Tailwind's own builds, which an app's `ng test`
41
+ * can't do.
42
+ */
43
+ export const themeFilesFor = (cwd, { tests = false } = {}) => usesTailwind4(cwd)
44
+ ? ['default.css', 'dark.css', 'tailwind.css']
45
+ : [
46
+ 'default.css',
47
+ 'dark.css',
48
+ 'tailwind-plugin.ts',
49
+ ...(tests ? ['tailwind-plugin.test.ts'] : []),
50
+ ];
51
+ //# sourceMappingURL=tailwind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailwind.js","sourceRoot":"","sources":["../../src/utils/tailwind.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,gEAAgE;AAChE,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,oBAAoB;IACpB,oBAAoB;IACpB,qBAAqB;IACrB,qBAAqB;CACtB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAW,EAAW,EAAE;IACpD,IAAI,qBAAqB,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QACtE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,CAAC;QACH,MAAM,EAAE,YAAY,GAAG,EAAE,EAAE,eAAe,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,KAAK,CAC5D,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CAIjD,CAAC;QACF,MAAM,GAAG,GAAG,EAAE,GAAG,YAAY,EAAE,GAAG,eAAe,EAAE,CAAC;QACpD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAChE,OAAO,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAC5D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,GAAW,EACX,EAAE,KAAK,GAAG,KAAK,KAA0B,EAAE,EACjC,EAAE,CACZ,aAAa,CAAC,GAAG,CAAC;IAChB,CAAC,CAAC,CAAC,aAAa,EAAE,UAAU,EAAE,cAAc,CAAC;IAC7C,CAAC,CAAC;QACE,aAAa;QACb,UAAU;QACV,oBAAoB;QACpB,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9C,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,71 @@
1
+ import { describe, expect, it, afterEach } from 'vitest';
2
+ import { existsSync, writeFileSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import { createFixture } from '../test-utils';
5
+ import { getUiSourceDir } from './resolve-paths';
6
+ import { themeFilesFor, usesTailwind4 } from './tailwind';
7
+ let fixture;
8
+ afterEach(() => {
9
+ fixture?.cleanup();
10
+ });
11
+ /**
12
+ * A project with these dev dependencies, and these other files.
13
+ */
14
+ const project = (devDependencies, files = {}) => {
15
+ fixture = createFixture({});
16
+ if (devDependencies) {
17
+ writeFileSync(join(fixture.dir, 'package.json'), JSON.stringify({ devDependencies }));
18
+ }
19
+ for (const [file, content] of Object.entries(files)) {
20
+ writeFileSync(join(fixture.dir, file), content);
21
+ }
22
+ return fixture.dir;
23
+ };
24
+ describe('usesTailwind4', () => {
25
+ it('is true for a project on Tailwind 4 without a Tailwind config', () => {
26
+ expect(usesTailwind4(project({ tailwindcss: '^4.3.3' }))).toBe(true);
27
+ expect(usesTailwind4(project({ '@tailwindcss/postcss': '^4.3.3' }))).toBe(true);
28
+ });
29
+ it('is false for Tailwind 3, a Tailwind config, or no Tailwind', () => {
30
+ expect(usesTailwind4(project({ tailwindcss: '^3.4.19' }))).toBe(false);
31
+ expect(usesTailwind4(project({ tailwindcss: '^4.0.0' }, { 'tailwind.config.js': '' }))).toBe(false);
32
+ expect(usesTailwind4(project({}))).toBe(false);
33
+ expect(usesTailwind4(project(undefined))).toBe(false);
34
+ });
35
+ });
36
+ describe('themeFilesFor', () => {
37
+ it('takes tailwind.css on Tailwind 4, and the config plugin on Tailwind 3', () => {
38
+ expect(themeFilesFor(project({ tailwindcss: '^4.3.3' }))).toEqual([
39
+ 'default.css',
40
+ 'dark.css',
41
+ 'tailwind.css',
42
+ ]);
43
+ expect(themeFilesFor(project({ tailwindcss: '^3.4.19' }))).toEqual([
44
+ 'default.css',
45
+ 'dark.css',
46
+ 'tailwind-plugin.ts',
47
+ ]);
48
+ });
49
+ it("adds the Tailwind plugin's test with the components' tests", () => {
50
+ // It covers the plugin in the app's coverage report. Tailwind 4's
51
+ // tailwind.css has no code to cover.
52
+ expect(themeFilesFor(project({ tailwindcss: '^3.4.19' }), { tests: true })).toEqual([
53
+ 'default.css',
54
+ 'dark.css',
55
+ 'tailwind-plugin.ts',
56
+ 'tailwind-plugin.test.ts',
57
+ ]);
58
+ expect(themeFilesFor(project({ tailwindcss: '^4.3.3' }), { tests: true })).toEqual(['default.css', 'dark.css', 'tailwind.css']);
59
+ });
60
+ it('lists only files the theme folder has', () => {
61
+ for (const version of ['^3.4.19', '^4.3.3']) {
62
+ const files = themeFilesFor(project({ tailwindcss: version }), {
63
+ tests: true,
64
+ });
65
+ for (const file of files) {
66
+ expect(existsSync(join(getUiSourceDir(), 'theme', file)), file).toBe(true);
67
+ }
68
+ }
69
+ });
70
+ });
71
+ //# sourceMappingURL=tailwind.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailwind.test.js","sourceRoot":"","sources":["../../src/utils/tailwind.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAgB,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE1D,IAAI,OAAgB,CAAC;AAErB,SAAS,CAAC,GAAG,EAAE;IACb,OAAO,EAAE,OAAO,EAAE,CAAC;AACrB,CAAC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,OAAO,GAAG,CACd,eAAmD,EACnD,QAAgC,EAAE,EAClC,EAAE;IACF,OAAO,GAAG,aAAa,CAAC,EAAE,CAAC,CAAC;IAC5B,IAAI,eAAe,EAAE,CAAC;QACpB,aAAa,CACX,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,cAAc,CAAC,EACjC,IAAI,CAAC,SAAS,CAAC,EAAE,eAAe,EAAE,CAAC,CACpC,CAAC;IACJ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;gBACzB,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,CAClE,IAAI,CACL,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotch/dolan",
3
- "version": "22.2.2",
3
+ "version": "22.2.4",
4
4
  "description": "CLI for adding @blotch/ui components to your project",
5
5
  "homepage": "https://github.com/Blotch-Smart-Frames/AngularLynx#readme",
6
6
  "bugs": {
@@ -27,6 +27,18 @@
27
27
  "./utils/animate": {
28
28
  "types": "./dist/utils/animate.d.ts",
29
29
  "default": "./dist/utils/animate.js"
30
+ },
31
+ "./testing/set-input-signal": {
32
+ "types": "./dist/testing/set-input-signal.d.ts",
33
+ "default": "./dist/testing/set-input-signal.js"
34
+ },
35
+ "./testing/fire-lynx-event": {
36
+ "types": "./dist/testing/fire-lynx-event.d.ts",
37
+ "default": "./dist/testing/fire-lynx-event.js"
38
+ },
39
+ "./testing/lynx-main-thread": {
40
+ "types": "./dist/testing/lynx-main-thread.d.ts",
41
+ "default": "./dist/testing/lynx-main-thread.js"
30
42
  }
31
43
  },
32
44
  "scripts": {