zard-cli 1.0.0-beta.13 → 1.0.0-beta.130

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 (269) hide show
  1. package/README.md +39 -167
  2. package/commands/add/component-installer.d.ts +5 -1
  3. package/commands/add/component-installer.d.ts.map +1 -1
  4. package/commands/add/component-installer.js +34 -5
  5. package/commands/add/component-installer.js.map +1 -1
  6. package/commands/add/component-selector.d.ts +6 -0
  7. package/commands/add/component-selector.d.ts.map +1 -1
  8. package/commands/add/component-selector.js +9 -27
  9. package/commands/add/component-selector.js.map +1 -1
  10. package/commands/add/dark-mode-setup.d.ts +2 -0
  11. package/commands/add/dark-mode-setup.d.ts.map +1 -1
  12. package/commands/add/dark-mode-setup.js +5 -11
  13. package/commands/add/dark-mode-setup.js.map +1 -1
  14. package/commands/add/dependency-resolver.d.ts +9 -2
  15. package/commands/add/dependency-resolver.d.ts.map +1 -1
  16. package/commands/add/dependency-resolver.js +91 -21
  17. package/commands/add/dependency-resolver.js.map +1 -1
  18. package/commands/add/index.d.ts.map +1 -1
  19. package/commands/add/index.js +140 -86
  20. package/commands/add/index.js.map +1 -1
  21. package/commands/add/stylesheet-setup.d.ts +3 -0
  22. package/commands/add/stylesheet-setup.d.ts.map +1 -0
  23. package/commands/add/stylesheet-setup.js +92 -0
  24. package/commands/add/stylesheet-setup.js.map +1 -0
  25. package/commands/add/wizard.d.ts +35 -0
  26. package/commands/add/wizard.d.ts.map +1 -0
  27. package/commands/add/wizard.js +299 -0
  28. package/commands/add/wizard.js.map +1 -0
  29. package/commands/init/config-prompter.d.ts +67 -56
  30. package/commands/init/config-prompter.d.ts.map +1 -1
  31. package/commands/init/config-prompter.js +92 -74
  32. package/commands/init/config-prompter.js.map +1 -1
  33. package/commands/init/dependencies.d.ts +1 -8
  34. package/commands/init/dependencies.d.ts.map +1 -1
  35. package/commands/init/dependencies.js +51 -23
  36. package/commands/init/dependencies.js.map +1 -1
  37. package/commands/init/index.d.ts.map +1 -1
  38. package/commands/init/index.js +150 -86
  39. package/commands/init/index.js.map +1 -1
  40. package/commands/init/project-kind.d.ts +82 -0
  41. package/commands/init/project-kind.d.ts.map +1 -0
  42. package/commands/init/project-kind.js +166 -0
  43. package/commands/init/project-kind.js.map +1 -0
  44. package/commands/init/steps.d.ts +15 -0
  45. package/commands/init/steps.d.ts.map +1 -0
  46. package/commands/init/steps.js +154 -0
  47. package/commands/init/steps.js.map +1 -0
  48. package/commands/init/tailwind-setup.d.ts +9 -2
  49. package/commands/init/tailwind-setup.d.ts.map +1 -1
  50. package/commands/init/tailwind-setup.js +33 -9
  51. package/commands/init/tailwind-setup.js.map +1 -1
  52. package/commands/init/theme-loader.d.ts.map +1 -1
  53. package/commands/init/theme-loader.js +1 -3
  54. package/commands/init/theme-loader.js.map +1 -1
  55. package/commands/init/tsconfig-updater.d.ts +8 -1
  56. package/commands/init/tsconfig-updater.d.ts.map +1 -1
  57. package/commands/init/tsconfig-updater.js +30 -11
  58. package/commands/init/tsconfig-updater.js.map +1 -1
  59. package/commands/init/update-angular-config.d.ts.map +1 -1
  60. package/commands/init/update-angular-config.js +28 -47
  61. package/commands/init/update-angular-config.js.map +1 -1
  62. package/commands/init/vite-setup.d.ts +11 -0
  63. package/commands/init/vite-setup.d.ts.map +1 -0
  64. package/commands/init/vite-setup.js +61 -0
  65. package/commands/init/vite-setup.js.map +1 -0
  66. package/commands/init/wizard.d.ts +30 -0
  67. package/commands/init/wizard.d.ts.map +1 -0
  68. package/commands/init/wizard.js +560 -0
  69. package/commands/init/wizard.js.map +1 -0
  70. package/constants/app.constants.d.ts +17 -0
  71. package/constants/app.constants.d.ts.map +1 -1
  72. package/constants/app.constants.js +39 -16
  73. package/constants/app.constants.js.map +1 -1
  74. package/core/icons/families.d.ts +38 -0
  75. package/core/icons/families.d.ts.map +1 -0
  76. package/core/icons/families.js +26 -0
  77. package/core/icons/families.js.map +1 -0
  78. package/core/icons/icon-map.d.ts +24 -0
  79. package/core/icons/icon-map.d.ts.map +1 -0
  80. package/core/icons/icon-map.js +141 -0
  81. package/core/icons/icon-map.js.map +1 -0
  82. package/core/icons/index.d.ts +107 -0
  83. package/core/icons/index.d.ts.map +1 -0
  84. package/core/icons/index.js +183 -0
  85. package/core/icons/index.js.map +1 -0
  86. package/core/registry/registry-data.d.ts.map +1 -1
  87. package/core/registry/registry-data.js +861 -108
  88. package/core/registry/registry-data.js.map +1 -1
  89. package/core/themes/theme-definitions.d.ts +5 -5
  90. package/core/themes/theme-definitions.d.ts.map +1 -1
  91. package/core/themes/theme-definitions.js +75 -82
  92. package/core/themes/theme-definitions.js.map +1 -1
  93. package/index.js +41 -4
  94. package/index.js.map +1 -1
  95. package/package.json +9 -14
  96. package/ui/blocks.d.ts +71 -0
  97. package/ui/blocks.d.ts.map +1 -0
  98. package/ui/blocks.js +116 -0
  99. package/ui/blocks.js.map +1 -0
  100. package/ui/brand.d.ts +14 -0
  101. package/ui/brand.d.ts.map +1 -0
  102. package/ui/brand.js +35 -0
  103. package/ui/brand.js.map +1 -0
  104. package/ui/engine/animation/index.d.ts +38 -0
  105. package/ui/engine/animation/index.d.ts.map +1 -0
  106. package/ui/engine/animation/index.js +102 -0
  107. package/ui/engine/animation/index.js.map +1 -0
  108. package/ui/engine/ansi/index.d.ts +51 -0
  109. package/ui/engine/ansi/index.d.ts.map +1 -0
  110. package/ui/engine/ansi/index.js +116 -0
  111. package/ui/engine/ansi/index.js.map +1 -0
  112. package/ui/engine/components/index.d.ts +211 -0
  113. package/ui/engine/components/index.d.ts.map +1 -0
  114. package/ui/engine/components/index.js +109 -0
  115. package/ui/engine/components/index.js.map +1 -0
  116. package/ui/engine/cursor/index.d.ts +16 -0
  117. package/ui/engine/cursor/index.d.ts.map +1 -0
  118. package/ui/engine/cursor/index.js +40 -0
  119. package/ui/engine/cursor/index.js.map +1 -0
  120. package/ui/engine/diff/index.d.ts +26 -0
  121. package/ui/engine/diff/index.d.ts.map +1 -0
  122. package/ui/engine/diff/index.js +56 -0
  123. package/ui/engine/diff/index.js.map +1 -0
  124. package/ui/engine/events/index.d.ts +24 -0
  125. package/ui/engine/events/index.d.ts.map +1 -0
  126. package/ui/engine/events/index.js +60 -0
  127. package/ui/engine/events/index.js.map +1 -0
  128. package/ui/engine/focus/index.d.ts +25 -0
  129. package/ui/engine/focus/index.d.ts.map +1 -0
  130. package/ui/engine/focus/index.js +77 -0
  131. package/ui/engine/focus/index.js.map +1 -0
  132. package/ui/engine/frame/index.d.ts +48 -0
  133. package/ui/engine/frame/index.d.ts.map +1 -0
  134. package/ui/engine/frame/index.js +0 -0
  135. package/ui/engine/frame/index.js.map +1 -0
  136. package/ui/engine/index.d.ts +28 -0
  137. package/ui/engine/index.d.ts.map +1 -0
  138. package/ui/engine/index.js +28 -0
  139. package/ui/engine/index.js.map +1 -0
  140. package/ui/engine/input/index.d.ts +36 -0
  141. package/ui/engine/input/index.d.ts.map +1 -0
  142. package/ui/engine/input/index.js +224 -0
  143. package/ui/engine/input/index.js.map +1 -0
  144. package/ui/engine/layout/index.d.ts +42 -0
  145. package/ui/engine/layout/index.d.ts.map +1 -0
  146. package/ui/engine/layout/index.js +241 -0
  147. package/ui/engine/layout/index.js.map +1 -0
  148. package/ui/engine/renderer/index.d.ts +43 -0
  149. package/ui/engine/renderer/index.d.ts.map +1 -0
  150. package/ui/engine/renderer/index.js +619 -0
  151. package/ui/engine/renderer/index.js.map +1 -0
  152. package/ui/engine/scheduler/index.d.ts +22 -0
  153. package/ui/engine/scheduler/index.d.ts.map +1 -0
  154. package/ui/engine/scheduler/index.js +77 -0
  155. package/ui/engine/scheduler/index.js.map +1 -0
  156. package/ui/engine/screen/index.d.ts +39 -0
  157. package/ui/engine/screen/index.d.ts.map +1 -0
  158. package/ui/engine/screen/index.js +255 -0
  159. package/ui/engine/screen/index.js.map +1 -0
  160. package/ui/engine/terminal/index.d.ts +84 -0
  161. package/ui/engine/terminal/index.d.ts.map +1 -0
  162. package/ui/engine/terminal/index.js +235 -0
  163. package/ui/engine/terminal/index.js.map +1 -0
  164. package/ui/engine/testing/index.d.ts +27 -0
  165. package/ui/engine/testing/index.d.ts.map +1 -0
  166. package/ui/engine/testing/index.js +63 -0
  167. package/ui/engine/testing/index.js.map +1 -0
  168. package/ui/engine/theme/index.d.ts +26 -0
  169. package/ui/engine/theme/index.d.ts.map +1 -0
  170. package/ui/engine/theme/index.js +128 -0
  171. package/ui/engine/theme/index.js.map +1 -0
  172. package/ui/engine/utils/index.d.ts +12 -0
  173. package/ui/engine/utils/index.d.ts.map +1 -0
  174. package/ui/engine/utils/index.js +143 -0
  175. package/ui/engine/utils/index.js.map +1 -0
  176. package/ui/gate.d.ts +19 -0
  177. package/ui/gate.d.ts.map +1 -0
  178. package/ui/gate.js +36 -0
  179. package/ui/gate.js.map +1 -0
  180. package/ui/index.d.ts +18 -0
  181. package/ui/index.d.ts.map +1 -0
  182. package/ui/index.js +18 -0
  183. package/ui/index.js.map +1 -0
  184. package/ui/log-sink.d.ts +24 -0
  185. package/ui/log-sink.d.ts.map +1 -0
  186. package/ui/log-sink.js +35 -0
  187. package/ui/log-sink.js.map +1 -0
  188. package/ui/output.d.ts +14 -0
  189. package/ui/output.d.ts.map +1 -0
  190. package/ui/output.js +28 -0
  191. package/ui/output.js.map +1 -0
  192. package/ui/report.d.ts +30 -0
  193. package/ui/report.d.ts.map +1 -0
  194. package/ui/report.js +45 -0
  195. package/ui/report.js.map +1 -0
  196. package/ui/runner.d.ts +66 -0
  197. package/ui/runner.d.ts.map +1 -0
  198. package/ui/runner.js +135 -0
  199. package/ui/runner.js.map +1 -0
  200. package/ui/style.d.ts +24 -0
  201. package/ui/style.d.ts.map +1 -0
  202. package/ui/style.js +44 -0
  203. package/ui/style.js.map +1 -0
  204. package/ui/testing/fake-tty.d.ts +26 -0
  205. package/ui/testing/fake-tty.d.ts.map +1 -0
  206. package/ui/testing/fake-tty.js +61 -0
  207. package/ui/testing/fake-tty.js.map +1 -0
  208. package/ui/text-input.d.ts +31 -0
  209. package/ui/text-input.d.ts.map +1 -0
  210. package/ui/text-input.js +89 -0
  211. package/ui/text-input.js.map +1 -0
  212. package/ui/theme.d.ts +10 -0
  213. package/ui/theme.d.ts.map +1 -0
  214. package/ui/theme.js +20 -0
  215. package/ui/theme.js.map +1 -0
  216. package/utils/angular-compat.d.ts +21 -0
  217. package/utils/angular-compat.d.ts.map +1 -0
  218. package/utils/angular-compat.js +52 -0
  219. package/utils/angular-compat.js.map +1 -0
  220. package/utils/config.d.ts +55 -69
  221. package/utils/config.d.ts.map +1 -1
  222. package/utils/config.js +66 -9
  223. package/utils/config.js.map +1 -1
  224. package/utils/errors.d.ts +27 -0
  225. package/utils/errors.d.ts.map +1 -0
  226. package/utils/errors.js +45 -0
  227. package/utils/errors.js.map +1 -0
  228. package/utils/get-package-info.js +4 -4
  229. package/utils/get-package-info.js.map +1 -1
  230. package/utils/get-project-info.d.ts +30 -0
  231. package/utils/get-project-info.d.ts.map +1 -1
  232. package/utils/get-project-info.js +195 -6
  233. package/utils/get-project-info.js.map +1 -1
  234. package/utils/http-client.d.ts +8 -0
  235. package/utils/http-client.d.ts.map +1 -0
  236. package/utils/http-client.js +83 -0
  237. package/utils/http-client.js.map +1 -0
  238. package/utils/icon-catalog.d.ts +34 -0
  239. package/utils/icon-catalog.d.ts.map +1 -0
  240. package/utils/icon-catalog.js +63 -0
  241. package/utils/icon-catalog.js.map +1 -0
  242. package/utils/logger.d.ts +16 -1
  243. package/utils/logger.d.ts.map +1 -1
  244. package/utils/logger.js +104 -12
  245. package/utils/logger.js.map +1 -1
  246. package/utils/package-manager.d.ts +44 -1
  247. package/utils/package-manager.d.ts.map +1 -1
  248. package/utils/package-manager.js +210 -14
  249. package/utils/package-manager.js.map +1 -1
  250. package/utils/registry.d.ts +86 -2
  251. package/utils/registry.d.ts.map +1 -1
  252. package/utils/registry.js +147 -31
  253. package/utils/registry.js.map +1 -1
  254. package/utils/schema-version.d.ts +21 -0
  255. package/utils/schema-version.d.ts.map +1 -0
  256. package/utils/schema-version.js +28 -0
  257. package/utils/schema-version.js.map +1 -0
  258. package/utils/source-file.d.ts +40 -0
  259. package/utils/source-file.d.ts.map +1 -0
  260. package/utils/source-file.js +104 -0
  261. package/utils/source-file.js.map +1 -0
  262. package/utils/theme-selector.d.ts +1 -1
  263. package/utils/theme-selector.d.ts.map +1 -1
  264. package/utils/theme-selector.js +6 -6
  265. package/utils/theme-selector.js.map +1 -1
  266. package/utils/fetch-component.d.ts +0 -3
  267. package/utils/fetch-component.d.ts.map +0 -1
  268. package/utils/fetch-component.js +0 -75
  269. package/utils/fetch-component.js.map +0 -1
@@ -1,15 +1,16 @@
1
- import { logger } from '../../utils/logger.js';
2
- import { getAvailableThemes, getThemeDisplayName } from '../../utils/theme-selector.js';
3
- import chalk from 'chalk';
1
+ import { candidateProjects, detectProjectKind, fallbackRootFor, isLibraryKind, libraryBaseUrl, libraryStylesPath, } from '../../commands/init/project-kind.js';
2
+ import { SOURCE_ICON_FAMILY } from '../../core/icons/index.js';
4
3
  import { existsSync } from 'node:fs';
5
4
  import { readFile } from 'node:fs/promises';
6
5
  import * as path from 'node:path';
7
- import prompts from 'prompts';
8
6
  import { z } from 'zod';
9
7
  export const SCHEMA_URL = 'https://zardui.com/schema.json';
10
8
  export const configSchema = z.object({
11
9
  $schema: z.string(),
12
10
  style: z.enum(['css']),
11
+ icons: z.string(),
12
+ rtl: z.boolean(),
13
+ projectType: z.enum(['angular', 'angular-library', 'nx', 'nx-library', 'analog']),
13
14
  appConfigFile: z.string(),
14
15
  packageManager: z.enum(['npm', 'yarn', 'pnpm', 'bun']),
15
16
  tailwind: z.object({
@@ -22,88 +23,105 @@ export const configSchema = z.object({
22
23
  utils: z.string(),
23
24
  core: z.string(),
24
25
  services: z.string(),
26
+ blocks: z.string(),
25
27
  }),
26
28
  });
27
- export async function promptForConfig(cwd, projectInfo, packageManager) {
28
- const highlight = (text) => chalk.cyan(text);
29
- const options = await prompts([
30
- {
31
- type: 'text',
32
- name: 'app.config',
33
- message: `Where is your ${highlight('app.config.ts')} file?`,
34
- initial: projectInfo.hasNx ? 'apps/[app]/src/app/app.config.ts' : 'src/app/app.config.ts',
35
- },
36
- {
37
- type: 'select',
38
- name: 'theme',
39
- message: `Choose a ${highlight('theme')} for your components:`,
40
- choices: getAvailableThemes().map(theme => ({
41
- title: getThemeDisplayName(theme),
42
- value: theme,
43
- })),
44
- initial: 0,
45
- },
46
- {
47
- type: 'text',
48
- name: 'tailwindCss',
49
- message: `Where is your ${highlight('global CSS')} file?`,
50
- initial: projectInfo.hasNx ? 'apps/[app]/src/styles.css' : 'src/styles.css',
51
- },
52
- {
53
- type: 'text',
54
- name: 'components',
55
- message: `Configure the import alias for ${highlight('components')}:`,
56
- initial: '@/shared/components',
57
- },
58
- {
59
- type: 'text',
60
- name: 'utils',
61
- message: `Configure the import alias for ${highlight('utils')}:`,
62
- initial: '@/shared/utils',
63
- },
64
- ]);
65
- await validateCssFile(cwd, options.tailwindCss);
66
- const componentsAlias = options.components;
67
- const utilsAlias = options.utils;
68
- const sharedBase = path.dirname(componentsAlias);
69
- const config = configSchema.parse({
29
+ /**
30
+ * The project the chosen type suggests as the target.
31
+ *
32
+ * When more than one is compatible the wizard asks — but something has to be
33
+ * preselected when the list opens, and the first declared project is the least
34
+ * surprising answer.
35
+ */
36
+ function targetProject(projectInfo, kind, projectRoot) {
37
+ const candidates = candidateProjects(kind, projectInfo);
38
+ return candidates.find(project => project.root === projectRoot) ?? candidates[0];
39
+ }
40
+ /**
41
+ * The paths suggested for the type the user chose.
42
+ *
43
+ * They come from the project declared in the workspace whenever there is one —
44
+ * the build target's `styles` is where the global CSS actually lives, and
45
+ * guessing it was what made init suggest paths that did not exist in monorepo
46
+ * layouts.
47
+ */
48
+ export function defaultAnswers(projectInfo, kind = detectProjectKind(projectInfo), projectRoot) {
49
+ const project = targetProject(projectInfo, kind, projectRoot);
50
+ const root = project?.root ?? fallbackRootFor(kind);
51
+ const shared = {
52
+ kind,
53
+ projectRoot: root,
54
+ theme: 'neutral',
55
+ componentsAlias: '@/shared/components',
56
+ utilsAlias: '@/shared/utils',
57
+ };
58
+ if (isLibraryKind(kind)) {
59
+ return {
60
+ ...shared,
61
+ // A library has no app.config; the field stays empty in components.json.
62
+ appConfig: '',
63
+ globalCss: libraryStylesPath(root),
64
+ };
65
+ }
66
+ const sourceRoot = project?.sourceRoot ?? (root ? `${root}/src` : 'src');
67
+ return {
68
+ ...shared,
69
+ appConfig: `${sourceRoot}/app/app.config.ts`,
70
+ globalCss: project?.styles[0] ?? `${sourceRoot}/styles.css`,
71
+ };
72
+ }
73
+ /**
74
+ * Where the components are written, derived from `app.config.ts`.
75
+ *
76
+ * Hardcoding `src/app` broke every layout that was not a single app at the root:
77
+ * in a workspace the app.config lives in `apps/<app>/src/app`, and the components
78
+ * ended up in a root `src/app` that belongs to no project. The directory holding
79
+ * app.config is exactly the root of the app's code.
80
+ *
81
+ * Separators are normalized before `dirname`, not after: on POSIX `path.dirname`
82
+ * does not treat `\` as a separator, so a Windows-style path collapsed to `.`
83
+ * and silently fell back to `src/app`.
84
+ */
85
+ export function deriveBaseUrl(appConfigFile) {
86
+ const dir = path.posix.dirname(appConfigFile.replace(/\\/g, '/'));
87
+ return dir === '.' ? 'src/app' : dir;
88
+ }
89
+ /** In a library there is no app.config, so the library root decides. */
90
+ function baseUrlFor(answers) {
91
+ return isLibraryKind(answers.kind) ? libraryBaseUrl(answers.projectRoot) : deriveBaseUrl(answers.appConfig);
92
+ }
93
+ export function buildConfig(answers, packageManager) {
94
+ const sharedBase = path.posix.dirname(answers.componentsAlias.replace(/\\/g, '/'));
95
+ return configSchema.parse({
70
96
  $schema: SCHEMA_URL,
71
97
  style: 'css',
72
- appConfigFile: options['app.config'],
98
+ // Neither is asked in the wizard: today there is only one icon family, and
99
+ // RTL does not change what init writes. They go into the file with their
100
+ // default so they can be edited later, which is what makes them configurable.
101
+ icons: SOURCE_ICON_FAMILY,
102
+ rtl: false,
103
+ projectType: answers.kind,
104
+ appConfigFile: answers.appConfig,
73
105
  packageManager,
74
106
  tailwind: {
75
- css: options.tailwindCss,
76
- baseColor: options.theme,
107
+ css: answers.globalCss,
108
+ baseColor: answers.theme,
77
109
  },
78
- baseUrl: 'src/app',
110
+ baseUrl: baseUrlFor(answers),
79
111
  aliases: {
80
- components: componentsAlias,
81
- utils: utilsAlias,
112
+ components: answers.componentsAlias,
113
+ utils: answers.utilsAlias,
82
114
  core: `${sharedBase}/core`,
83
115
  services: `${sharedBase}/services`,
116
+ blocks: `${sharedBase}/blocks`,
84
117
  },
85
118
  });
86
- return config;
87
119
  }
88
- async function validateCssFile(cwd, tailwindCss) {
89
- const cssPath = path.join(cwd, tailwindCss);
90
- if (!existsSync(cssPath)) {
91
- logger.error(`CSS file not found at: ${tailwindCss}`);
92
- logger.error('Please ensure your CSS file exists before continuing.');
93
- process.exit(1);
94
- }
95
- const existingContent = await readFile(cssPath, 'utf8');
96
- if (existingContent.trim().length > 0) {
97
- const { overwrite } = await prompts({
98
- type: 'confirm',
99
- name: 'overwrite',
100
- message: `Your CSS file already has content. This will overwrite everything with ZardUI theme configuration. Continue?`,
101
- initial: true,
102
- });
103
- if (!overwrite) {
104
- logger.info('Installation cancelled.');
105
- process.exit(0);
106
- }
107
- }
120
+ export async function inspectCssFile(cwd, relativePath) {
121
+ const cssPath = path.join(cwd, relativePath);
122
+ if (!existsSync(cssPath))
123
+ return 'missing';
124
+ const content = await readFile(cssPath, 'utf8');
125
+ return content.trim().length > 0 ? 'has-content' : 'empty';
108
126
  }
109
127
  //# sourceMappingURL=config-prompter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config-prompter.js","sourceRoot":"","sources":["../../../src/commands/init/config-prompter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACvF,OAAO,KAAK,MAAM,OAAO,CAAC;A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QACd,QAAQ,EAAE;YACR,GAAG,EAAE,OAAO,CAAC,SAAS;YACtB,SAAS,EAAE,OAAO,CAAC,KAAK;SACzB;QACD,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC;QAC5B,OAAO,EAAE;YACP,UAAU,EAAE,OAAO,CAAC,eAAe;YACnC,KAAK,EAAE,OAAO,CAAC,UAAU;YACzB,IAAI,EAAE,GAAG,UAAU,OAAO;YAC1B,QAAQ,EAAE,GAAG,UAAU,WAAW;YAClC,MAAM,EAAE,GAAG,UAAU,SAAS;SAC/B;KACF,CAAC,CAAC;AACL,CAAC;AAUD,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,GAAW,EAAE,YAAoB;IACpE,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAE7C,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;QAAE,OAAO,SAAS,CAAC;IAE3C,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAChD,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC;AAC7D,CAAC"}
@@ -1,11 +1,4 @@
1
1
  import { type Config } from '../../utils/config.js';
2
- type ProjectInfo = {
3
- framework: string;
4
- hasTypeScript: boolean;
5
- hasTailwind: boolean;
6
- hasNx: boolean;
7
- angularVersion: string | null;
8
- };
2
+ import { type ProjectInfo } from '../../utils/get-project-info.js';
9
3
  export declare function installDependencies(cwd: string, config: Config, projectInfo?: ProjectInfo): Promise<void>;
10
- export {};
11
4
  //# sourceMappingURL=dependencies.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../../src/commands/init/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAKnD,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,OAAO,CAAC;IACf,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC;AAEF,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAiB/G"}
1
+ {"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../../src/commands/init/dependencies.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAKlF,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAwC/G"}
@@ -1,33 +1,61 @@
1
+ import { bundlerFor, isLibraryKind } from '../../commands/init/project-kind.js';
2
+ import { iconPackagesFor } from '../../core/icons/index.js';
3
+ import { pinAllForAngular } from '../../utils/angular-compat.js';
1
4
  import { getProjectInfo } from '../../utils/get-project-info.js';
5
+ import { iconCatalog } from '../../utils/icon-catalog.js';
2
6
  import { logger } from '../../utils/logger.js';
3
- import { installPackages } from '../../utils/package-manager.js';
7
+ import { filterInstalledPackages, installPackagesWithRetry } from '../../utils/package-manager.js';
4
8
  export async function installDependencies(cwd, config, projectInfo) {
5
9
  const info = projectInfo || (await getProjectInfo(cwd));
6
- const cdkVersion = getCdkVersion(info.angularVersion);
7
- const deps = [cdkVersion, 'class-variance-authority', 'clsx', 'tailwind-merge', 'lucide-angular'];
8
- const devDeps = info.hasTailwind ? [] : ['tailwindcss', '@tailwindcss/postcss', 'postcss', 'tailwindcss-animate'];
10
+ // The icon package comes from the family chosen in `components.json`, not from
11
+ // a fixed list: that is what makes `"icons"` mean something the day there is
12
+ // more than one family.
13
+ //
14
+ // Pinned against the project's Angular: the CDK and ng-icons both ship one
15
+ // release per Angular major and peer on `>=` it, so `latest` is the wrong
16
+ // answer for anyone not already on the newest Angular.
17
+ const deps = pinAllForAngular([
18
+ '@angular/cdk',
19
+ 'class-variance-authority',
20
+ 'clsx',
21
+ 'tailwind-merge',
22
+ ...iconPackagesFor(config.icons, iconCatalog()),
23
+ ], info.angularVersion);
24
+ const devDeps = tailwindPackages(config.projectType);
9
25
  if (info.hasTailwind) {
10
- logger.info('Tailwind CSS is already installed. Skipping Tailwind dependencies installation.');
26
+ logger.info('Tailwind CSS is already installed. Only the missing pieces will be added.');
11
27
  }
12
- await installWithRetry(deps, cwd, config.packageManager, false);
13
- if (devDeps.length > 0) {
14
- await installWithRetry(devDeps, cwd, config.packageManager, true);
28
+ // Every batch that comes back empty is a whole manager invocation saved — and
29
+ // that is exactly the common case for a repeated `init`: nothing to install.
30
+ const [missingDeps, missingDevDeps] = await Promise.all([
31
+ filterInstalledPackages(deps, cwd),
32
+ filterInstalledPackages(devDeps, cwd),
33
+ ]);
34
+ if (!missingDeps.length && !missingDevDeps.length) {
35
+ logger.info('All dependencies are already installed.');
36
+ return;
15
37
  }
38
+ await installPackagesWithRetry(missingDeps, cwd, config.packageManager, false);
39
+ await installPackagesWithRetry(missingDevDeps, cwd, config.packageManager, true);
16
40
  }
17
- function getCdkVersion(angularVersion) {
18
- if (!angularVersion) {
19
- return '@angular/cdk';
20
- }
21
- const majorVersion = Number.parseInt(angularVersion.split('.')[0]);
22
- return `@angular/cdk@^${majorVersion}`;
23
- }
24
- async function installWithRetry(packages, cwd, packageManager, isDev) {
25
- try {
26
- await installPackages(packages, cwd, packageManager, isDev);
27
- }
28
- catch {
29
- logger.warn('Installation failed, retrying with --legacy-peer-deps...');
30
- await installPackages(packages, cwd, packageManager, isDev, true);
31
- }
41
+ /**
42
+ * What Tailwind needs to run in that kind of project.
43
+ *
44
+ * The list is always the complete one and the installed-filter decides what is
45
+ * left: checking only for `tailwindcss` missed the case of someone who had it
46
+ * installed but not the bundler adapter, and then the build emitted no
47
+ * utilities at all.
48
+ *
49
+ * A library has no bundler to configure — the consuming application compiles
50
+ * the CSS — but the packages stay because the theme init writes there declares
51
+ * them.
52
+ */
53
+ function tailwindPackages(kind) {
54
+ const shared = ['tailwindcss', 'tailwindcss-animate'];
55
+ if (isLibraryKind(kind))
56
+ return shared;
57
+ return bundlerFor(kind) === 'vite'
58
+ ? [...shared, '@tailwindcss/vite']
59
+ : [...shared, '@tailwindcss/postcss', 'postcss'];
32
60
  }
33
61
  //# sourceMappingURL=dependencies.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../../src/commands/init/dependencies.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAUhE,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,GAAW,EAAE,MAAc,EAAE,WAAyB;IAC9F,MAAM,IAAI,GAAG,WAAW,IAAI,CAAC,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;IAExD,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACtD,MAAM,IAAI,GAAG,CAAC,UAAU,EAAE,0BAA0B,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;IAElG,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,sBAAsB,EAAE,SAAS,EAAE,qBAAqB,CAAC,CAAC;IAElH,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;QACrB,MAAM,C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EAAE,MAAM,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IAC/E,MAAM,wBAAwB,CAAC,cAAc,EAAE,GAAG,EAAE,MAAM,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;AACnF,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAS,gBAAgB,CAAC,IAA2B;IACnD,MAAM,MAAM,GAAG,CAAC,aAAa,EAAE,qBAAqB,CAAC,CAAC;IAEtD,IAAI,aAAa,CAAC,IAAI,CAAC;QAAE,OAAO,MAAM,CAAC;IAEvC,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,MAAM;QAChC,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,mBAAmB,CAAC;QAClC,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAC;AACrD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,eAAO,MAAM,IAAI,SA2Cb,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,eAAO,MAAM,IAAI,SAkEb,CAAC"}
@@ -1,121 +1,185 @@
1
- import { installComponent } from '../../commands/add/component-installer.js';
2
- import { promptForConfig } from '../../commands/init/config-prompter.js';
3
- import { installDependencies } from '../../commands/init/dependencies.js';
4
- import { applyThemeToStyles, createPostCssConfig } from '../../commands/init/tailwind-setup.js';
5
- import { updateTsConfig } from '../../commands/init/tsconfig-updater.js';
6
- import { resolveConfigPaths } from '../../utils/config.js';
1
+ import { buildConfig, defaultAnswers, inspectCssFile } from '../../commands/init/config-prompter.js';
2
+ import { candidateProjects, detectProjectKind, isLibraryKind, PROJECT_KINDS, } from '../../commands/init/project-kind.js';
3
+ import { buildInitSteps } from '../../commands/init/steps.js';
4
+ import { runInitWizard } from '../../commands/init/wizard.js';
5
+ import { isInteractive, printReport, WizardCancelledError } from '../../ui/index.js';
6
+ import { CliError } from '../../utils/errors.js';
7
7
  import { getProjectInfo } from '../../utils/get-project-info.js';
8
+ import { loadIconCatalog } from '../../utils/icon-catalog.js';
8
9
  import { logger, spinner } from '../../utils/logger.js';
9
- import { detectPackageManager } from '../../utils/package-manager.js';
10
- import chalk from 'chalk';
10
+ import { detectPackageManager, suggestedRunner } from '../../utils/package-manager.js';
11
+ import { getRegistryUrl } from '../../utils/registry.js';
11
12
  import { Command } from 'commander';
12
13
  import { existsSync } from 'node:fs';
13
- import { mkdir, writeFile } from 'node:fs/promises';
14
14
  import * as path from 'node:path';
15
- import prompts from 'prompts';
16
- import { updateAngularConfig } from './update-angular-config.js';
17
15
  export const init = new Command()
18
16
  .name('init')
19
17
  .description('initialize your project and install dependencies')
20
18
  .option('-y, --yes', 'skip confirmation prompt.', false)
21
19
  .option('-c, --cwd <cwd>', 'the working directory. defaults to the current directory.', process.cwd())
20
+ .option('-t, --type <type>', `the project type: ${PROJECT_KINDS.map(kind => kind.value).join(', ')}.`)
21
+ .option('-p, --project <name>', 'the workspace project to configure. defaults to the first compatible one.')
22
22
  .action(async (options) => {
23
23
  const cwd = path.resolve(options.cwd);
24
24
  validateWorkingDirectory(cwd);
25
25
  const projectInfo = await getProjectInfo(cwd);
26
26
  validateAngularProject(projectInfo);
27
- const componentsJsonPath = path.resolve(cwd, 'components.json');
28
- const isReInitializing = existsSync(componentsJsonPath);
29
- if (isReInitializing) {
30
- const shouldContinue = await confirmReinitialization();
31
- if (!shouldContinue) {
32
- logger.info('Re-initialization cancelled.');
33
- process.exit(0);
34
- }
27
+ const kind = resolveKind(options.type);
28
+ const projectRoot = resolveProjectRoot(options.project, kind ?? detectProjectKind(projectInfo), projectInfo);
29
+ const isReInitializing = existsSync(path.resolve(cwd, 'components.json'));
30
+ const packageManager = await detectPackageManager(cwd);
31
+ // Before any step: the catalog is what says which icon package to install,
32
+ // and it comes from the registry so it does not depend on the CLI version.
33
+ await loadIconCatalog(getRegistryUrl());
34
+ const buildSteps = (config) => buildInitSteps(cwd, config, projectInfo, isReInitializing);
35
+ if (!isInteractive()) {
36
+ logHeadlessReason();
37
+ await runHeadless({
38
+ cwd,
39
+ projectInfo,
40
+ packageManager,
41
+ isReInitializing,
42
+ buildSteps,
43
+ yes: options.yes,
44
+ kind,
45
+ projectRoot,
46
+ });
47
+ return;
35
48
  }
36
- logger.info(isReInitializing ? 'Re-initializing ZardUI...' : 'Initializing ZardUI...');
37
- logger.break();
38
- const detectedPm = await detectPackageManager();
39
- logger.break();
40
- const config = await promptForConfig(cwd, projectInfo, detectedPm);
41
- if (!options.yes) {
42
- const shouldProceed = await confirmConfiguration();
43
- if (!shouldProceed) {
49
+ try {
50
+ const { config, logs } = await runInitWizard({
51
+ cwd,
52
+ projectInfo,
53
+ packageManager,
54
+ isReInitializing,
55
+ skipConfirmation: options.yes,
56
+ buildSteps,
57
+ presetKind: kind,
58
+ presetProjectRoot: projectRoot,
59
+ });
60
+ reportSuccess(config, buildSteps(config), logs);
61
+ }
62
+ catch (error) {
63
+ if (error instanceof WizardCancelledError) {
64
+ printReport({
65
+ status: 'cancelled',
66
+ headline: error.message,
67
+ notes: ['Nothing was changed in your project.'],
68
+ });
44
69
  process.exit(0);
45
70
  }
71
+ throw error;
46
72
  }
47
- await runInitializationSteps(cwd, config, projectInfo, isReInitializing);
48
- displaySuccessMessage(config);
49
73
  });
74
+ /**
75
+ * Why the full screen was not mounted.
76
+ *
77
+ * The CLI falling back to text mode is, to whoever is watching, indistinguishable
78
+ * from the interface not existing — which is how the degradation on macOS and
79
+ * Linux went unnoticed until it turned into "it never showed up" reports. With
80
+ * `--debug`, the command answers for itself.
81
+ */
82
+ function logHeadlessReason() {
83
+ logger.debug(`No terminal to draw on (stdin TTY: ${Boolean(process.stdin.isTTY)}, ` +
84
+ `stdout TTY: ${Boolean(process.stdout.isTTY)}, controlling terminal: unreachable) — running headless.`);
85
+ }
50
86
  function validateWorkingDirectory(cwd) {
51
87
  if (!existsSync(cwd)) {
52
- logger.error(`The path ${cwd} does not exist. Please try again.`);
53
- process.exit(1);
88
+ throw new CliError(`The path ${cwd} does not exist. Please try again.`, 'INVALID_CWD');
54
89
  }
55
90
  }
56
91
  function validateAngularProject(projectInfo) {
57
92
  if (projectInfo.framework !== 'angular') {
58
- logger.error('This project does not appear to be an Angular project.');
59
- logger.error('Please run this command in an Angular project.');
60
- process.exit(1);
93
+ throw new CliError('This project does not appear to be an Angular project.', 'NOT_ANGULAR');
61
94
  }
62
95
  }
63
- async function confirmReinitialization() {
64
- logger.warn('ZardUI is already initialized in this project.');
65
- const { reinitialize } = await prompts({
66
- type: 'confirm',
67
- name: 'reinitialize',
68
- message: 'Do you want to re-initialize? This will overwrite your existing configuration and utils.',
69
- initial: true,
70
- });
71
- return reinitialize;
96
+ /**
97
+ * The type asked for with `--type`, when there is one.
98
+ *
99
+ * It is the answer to the wizard's first question given up front — which is what
100
+ * makes init usable in CI, where nobody can pick from a menu.
101
+ */
102
+ function resolveKind(value) {
103
+ if (!value)
104
+ return undefined;
105
+ const kind = PROJECT_KINDS.find(option => option.value === value);
106
+ if (!kind) {
107
+ throw new CliError(`Unknown project type "${value}". Expected one of: ${PROJECT_KINDS.map(option => option.value).join(', ')}.`, 'UNKNOWN_PROJECT_TYPE');
108
+ }
109
+ return kind.value;
72
110
  }
73
- async function confirmConfiguration() {
74
- const { proceed } = await prompts({
75
- type: 'confirm',
76
- name: 'proceed',
77
- message: 'Write configuration to components.json?',
78
- initial: true,
79
- });
80
- return proceed;
111
+ /** The root of the project asked for with `--project`, looked up among the compatible ones. */
112
+ function resolveProjectRoot(name, kind, projectInfo) {
113
+ if (!name)
114
+ return undefined;
115
+ const candidates = candidateProjects(kind, projectInfo);
116
+ const project = candidates.find(candidate => candidate.name === name);
117
+ if (!project) {
118
+ const available = candidates.map(candidate => candidate.name).join(', ') || 'none';
119
+ throw new CliError(`Project "${name}" is not a ${kind} project in this workspace. Available: ${available}.`, 'UNKNOWN_PROJECT');
120
+ }
121
+ return project.root;
81
122
  }
82
- async function runInitializationSteps(cwd, config, projectInfo, isReInitializing) {
83
- const initSpinner = spinner('Initializing project...').start();
84
- await writeFile(path.resolve(cwd, 'components.json'), JSON.stringify(config, null, 2), 'utf8');
85
- initSpinner.text = 'Installing dependencies...';
86
- await installDependencies(cwd, config, projectInfo);
87
- initSpinner.text = 'Configuring Angular...';
88
- await updateAngularConfig(cwd, config);
89
- if (!projectInfo.hasTailwind || isReInitializing) {
90
- initSpinner.text = 'Setting up PostCSS...';
91
- await createPostCssConfig(cwd);
123
+ /**
124
+ * The path without a UI — CI, pipes and non-interactive terminals.
125
+ *
126
+ * Nobody can answer anything here, so the defaults apply and `--yes` is
127
+ * required: without it the CLI refuses to overwrite the project's global CSS.
128
+ */
129
+ async function runHeadless(options) {
130
+ if (!options.yes) {
131
+ throw new CliError('Running without an interactive terminal requires --yes, since init overwrites your global CSS.', 'NOT_INTERACTIVE');
132
+ }
133
+ const kind = options.kind ?? detectProjectKind(options.projectInfo);
134
+ const answers = defaultAnswers(options.projectInfo, kind, options.projectRoot);
135
+ const cssState = await inspectCssFile(options.cwd, answers.globalCss);
136
+ // In a library the theme CSS is created by init, so its absence is expected;
137
+ // in an application the file has to be there and wired into the build.
138
+ if (cssState === 'missing' && !isLibraryKind(answers.kind)) {
139
+ throw new CliError(`CSS file not found at: ${answers.globalCss}. Run init in an interactive terminal to choose another path.`, 'CSS_NOT_FOUND');
140
+ }
141
+ const config = buildConfig(answers, options.packageManager);
142
+ const steps = options.buildSteps(config);
143
+ logger.info(options.isReInitializing ? 'Re-initializing zard/ui...' : 'Initializing zard/ui...');
144
+ for (const step of steps) {
145
+ const stepSpinner = spinner(`${step.label} — ${step.note}`).start();
146
+ try {
147
+ await step.run();
148
+ stepSpinner.succeed(step.label);
149
+ }
150
+ catch (error) {
151
+ stepSpinner.fail(`${step.label}: ${error instanceof Error ? error.message : String(error)}`);
152
+ throw error;
153
+ }
92
154
  }
93
- initSpinner.text = 'Applying theme...';
94
- await applyThemeToStyles(cwd, config);
95
- initSpinner.text = 'Updating TypeScript config...';
96
- await updateTsConfig(cwd, config);
97
- initSpinner.text = 'Installing core dependencies...';
98
- await installCoreDependencies(cwd, config);
99
- initSpinner.succeed('Project initialized');
155
+ reportSuccess(config, steps, []);
100
156
  }
101
- async function installCoreDependencies(cwd, config) {
102
- const resolvedConfig = await resolveConfigPaths(cwd, config);
103
- await mkdir(resolvedConfig.resolvedPaths.core, { recursive: true });
104
- await mkdir(resolvedConfig.resolvedPaths.utils, { recursive: true });
105
- await installComponent('core', resolvedConfig.resolvedPaths.core, resolvedConfig);
106
- await installComponent('utils', resolvedConfig.resolvedPaths.utils, resolvedConfig);
157
+ function reportSuccess(config, steps, logs) {
158
+ printReport({
159
+ status: 'success',
160
+ headline: 'zard/ui has been initialized successfully!',
161
+ items: steps.map(step => `${step.label} — ${step.note}`),
162
+ notes: nextStepsFor(config),
163
+ commands: [{ command: `${suggestedRunner(config.packageManager)} zard-cli add`, argument: '[component]' }],
164
+ logs,
165
+ });
107
166
  }
108
- function displaySuccessMessage(config) {
109
- logger.break();
110
- logger.success('ZardUI has been initialized successfully!');
111
- logger.break();
112
- const runCommand = config.packageManager === 'npm'
113
- ? 'npx'
114
- : config.packageManager === 'yarn'
115
- ? 'yarn dlx'
116
- : `${config.packageManager}x`;
117
- logger.info('You can now add components using:');
118
- logger.info(chalk.bold(` ${runCommand} @ngzard/ui add [component]`));
119
- logger.break();
167
+ /**
168
+ * What is still left to do by hand.
169
+ *
170
+ * In a library init has nowhere to register `provideZard()` and no way to import
171
+ * the tokens — both belong to the app consuming the library, and without this
172
+ * notice the user only finds out when the components do not render.
173
+ */
174
+ function nextStepsFor(config) {
175
+ if (!isLibraryKind(config.projectType)) {
176
+ return ['You can now add components using:'];
177
+ }
178
+ return [
179
+ 'The consuming app still needs to register provideZard() in its app.config.ts',
180
+ `and import the theme tokens from this library's ${path.basename(config.tailwind.css)}.`,
181
+ '',
182
+ 'You can now add components using:',
183
+ ];
120
184
  }
121
185
  //# sourceMappingURL=index.js.map