untitledui 0.1.2 → 0.1.3

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 (56) hide show
  1. package/dist/index.mjs +19 -0
  2. package/package.json +10 -8
  3. package/templates/default/package.json +20 -21
  4. package/templates/default/src/app/home-screen.tsx +2 -3
  5. package/templates/default/src/app/layout.tsx +5 -13
  6. package/templates/default/src/components/marketing/header-navigation/dropdown-header-navigation.tsx +1 -1
  7. package/templates/default/src/components/shared/buttons/button.tsx +2 -1
  8. package/templates/default/src/components/shared/dropdown/dropdown.tsx +27 -18
  9. package/templates/default/src/components/shared/form/hook-form.tsx +75 -0
  10. package/templates/default/src/components/shared/{inputs/input → input}/index.tsx +3 -3
  11. package/templates/default/src/components/shared/{inputs/input → input}/input-payment.tsx +4 -4
  12. package/templates/default/src/components/shared/{inputs/input → input}/input-with-button.tsx +4 -4
  13. package/templates/default/src/components/shared/{inputs/input → input}/input-with-dropdown.tsx +4 -4
  14. package/templates/default/src/components/shared/{inputs/input → input}/input-with-prefix.tsx +4 -4
  15. package/templates/default/src/components/shared/progress-indicators/progress-indicators.tsx +2 -2
  16. package/templates/default/src/components/shared/{input-dropdown → select}/combobox.tsx +9 -9
  17. package/templates/default/src/components/shared/{input-dropdown → select}/multi-select.tsx +166 -166
  18. package/templates/default/src/components/shared/{input-dropdown → select}/popover.tsx +2 -2
  19. package/templates/default/src/components/shared/select/select-item.tsx +70 -0
  20. package/templates/default/src/components/shared/{input-dropdown/select.tsx → select/select-native.tsx} +2 -2
  21. package/templates/default/src/components/shared/select/select.tsx +143 -0
  22. package/templates/default/src/components/shared/slider/slider.tsx +2 -2
  23. package/templates/default/src/components/shared/{inputs/textarea → textarea}/textarea.tsx +2 -2
  24. package/templates/default/src/providers/theme.tsx +1 -1
  25. package/templates/default/src/styles/globals.css +3 -1
  26. package/templates/default/src/styles/theme.css +392 -380
  27. package/templates/default/src/styles/typography.css +20 -20
  28. package/dist/commands/add.js +0 -339
  29. package/dist/commands/init.js +0 -436
  30. package/dist/helper/download-tar-api.js +0 -129
  31. package/dist/helper/download-tar.js +0 -81
  32. package/dist/helper/find-css-file.js +0 -19
  33. package/dist/helper/formatText.js +0 -37
  34. package/dist/helper/get-components-api.js +0 -47
  35. package/dist/helper/get-components-list.js +0 -62
  36. package/dist/helper/get-components.js +0 -19
  37. package/dist/helper/get-config.js +0 -163
  38. package/dist/helper/get-package-info.js +0 -99
  39. package/dist/helper/get-pkg-manager.js +0 -16
  40. package/dist/helper/get-project.js +0 -176
  41. package/dist/helper/install-template.js +0 -29
  42. package/dist/helper/match-color-css.js +0 -82
  43. package/dist/helper/update-color-css.js +0 -134
  44. package/dist/index.js +0 -25
  45. package/dist/package.json +0 -50
  46. package/dist/res/components.json +0 -520
  47. package/dist/res/config.json +0 -3
  48. package/templates/default/src/components/shared/input-dropdown/dropdown-item.tsx +0 -98
  49. package/templates/default/src/components/shared/input-dropdown/input-dropdown.tsx +0 -172
  50. package/templates/default/src/fonts/GeistMonoVF.woff +0 -0
  51. package/templates/default/src/fonts/GeistVF.woff +0 -0
  52. package/templates/default/src/styles/colors.css +0 -805
  53. /package/templates/default/src/components/shared/{inputs → file-upload-trigger}/file-upload-trigger.tsx +0 -0
  54. /package/templates/default/src/components/shared/{inputs/form → form}/form.tsx +0 -0
  55. /package/templates/default/src/components/shared/{inputs → input}/hint-text.tsx +0 -0
  56. /package/templates/default/src/components/shared/{inputs → input}/label.tsx +0 -0
@@ -10,22 +10,22 @@
10
10
  --tw-prose-quotes: var(--color-text-primary);
11
11
  --tw-prose-quote-borders: var(--color-fg-brand-primary_alt);
12
12
  --tw-prose-captions: var(--color-text-tertiary);
13
- /* // --tw-prose-kbd: color.gray[900]; */
14
- /* // --tw-prose-kbd-shadows: hexToRgb(color.gray[900]); */
13
+ /* --tw-prose-kbd: color.gray[900]; */
14
+ /* --tw-prose-kbd-shadows: hexToRgb(color.gray[900]); */
15
15
  --tw-prose-code: var(--color-text-primary);
16
16
  --tw-prose-pre-code: var(--color-text-tertiary);
17
17
  --tw-prose-pre-bg: var(--color-bg-primary);
18
18
  --tw-prose-th-borders: var(--color-border-primary);
19
19
  --tw-prose-td-borders: var(--color-border-secondary);
20
20
 
21
- /* // Base */
21
+ /* Base */
22
22
  color: var(--tw-prose-body);
23
23
  font-size: var(--text-md);
24
24
  line-height: var(--leading-md);
25
25
  }
26
26
 
27
27
  .prose :not(:where([class~="not-prose"], [class~="not-prose"] *)) {
28
- /* // Text */
28
+ /* Text */
29
29
  &:where(p) {
30
30
  margin-top: calc(var(--spacing) * 4);
31
31
  margin-bottom: calc(var(--spacing) * 4);
@@ -38,7 +38,7 @@
38
38
  margin-bottom: 1.2em;
39
39
  }
40
40
 
41
- /* // Lists */
41
+ /* Lists */
42
42
  &:where(ol) {
43
43
  liststyletype: decimal;
44
44
 
@@ -68,13 +68,13 @@
68
68
  margin-bottom: 0;
69
69
  }
70
70
 
71
- /* // Horizontal rules */
71
+ /* Horizontal rules */
72
72
  &:where(hr) {
73
73
  margin-top: calc(var(--spacing) * 8);
74
74
  margin-bottom: calc(var(--spacing) * 8);
75
75
  }
76
76
 
77
- /* // Quotes */
77
+ /* Quotes */
78
78
  &:where(blockquote) {
79
79
  color: var(--tw-prose-quotes);
80
80
 
@@ -100,7 +100,7 @@
100
100
  content: close-quote;
101
101
  }
102
102
 
103
- /* // Headings */
103
+ /* Headings */
104
104
  &:where(h1) {
105
105
  color: var(--tw-prose-headings);
106
106
  font-weight: 600;
@@ -165,7 +165,7 @@
165
165
  color: inherit;
166
166
  }
167
167
 
168
- /* // Media */
168
+ /* Media */
169
169
 
170
170
  &:where(img) {
171
171
  border-radius: var(--radius-xl);
@@ -215,7 +215,7 @@
215
215
  font-style: normal;
216
216
  }
217
217
 
218
- /* // Inline elements */
218
+ /* Inline elements */
219
219
  &:where(a:not(h1 a, h2 a, h3 a, h4 a, h5 a, h6 a)) {
220
220
  font-weight: 400;
221
221
  text-decoration: underline;
@@ -233,7 +233,7 @@
233
233
  text-decoration: none;
234
234
  }
235
235
 
236
- /* // Inline code element */
236
+ /* Inline code element */
237
237
  &:where(code:not(pre code)) {
238
238
  font-weight: 600;
239
239
  border-radius: 4px;
@@ -277,7 +277,7 @@
277
277
 
278
278
  .prose.md\:prose-lg:not(:where([class~="not-prose"], [class~="not-prose"] *)) {
279
279
  @media (width >= 48rem /* 768px */) {
280
- /* // Base */
280
+ /* Base */
281
281
  font-size: var(--text-lg);
282
282
  line-height: var(--leading-lg);
283
283
  }
@@ -285,7 +285,7 @@
285
285
 
286
286
  .prose.md\:prose-lg :not(:where([class~="not-prose"], [class~="not-prose"] *)) {
287
287
  @media (width >= 48rem /* 768px */) {
288
- /* // Text */
288
+ /* Text */
289
289
  &:where(p) {
290
290
  margin-top: calc(var(--spacing) * 4.5);
291
291
  margin-bottom: calc(var(--spacing) * 4.5);
@@ -298,7 +298,7 @@
298
298
  margin-bottom: 1.09em;
299
299
  }
300
300
 
301
- /* // Lists */
301
+ /* Lists */
302
302
  &:where(ol) {
303
303
  margin-top: calc(var(--spacing) * 4.5);
304
304
  margin-bottom: calc(var(--spacing) * 4.5);
@@ -321,13 +321,13 @@
321
321
  margin-bottom: 0;
322
322
  }
323
323
 
324
- /* // Horizontal rules */
324
+ /* Horizontal rules */
325
325
  &:where(hr) {
326
326
  margin-top: calc(var(--spacing) * 8);
327
327
  margin-bottom: calc(var(--spacing) * 8);
328
328
  }
329
329
 
330
- /* // Quotes */
330
+ /* Quotes */
331
331
  &:where(blockquote) {
332
332
  padding-inline-start: 0;
333
333
  margin-top: calc(var(--spacing) * 12);
@@ -340,7 +340,7 @@
340
340
  line-height: var(--leading-display-xs);
341
341
  }
342
342
 
343
- /* // Headings */
343
+ /* Headings */
344
344
  &:where(h1) {
345
345
  font-size: var(--text-display-md);
346
346
  line-height: var(--leading-display-md);
@@ -395,7 +395,7 @@
395
395
  margin-top: calc(var(--spacing) * 4);
396
396
  }
397
397
 
398
- /* // Inline elements */
398
+ /* Inline elements */
399
399
  &:where(a:not(h1 a, h2 a, h3 a, h4 a, h5 a, h6 a)) {
400
400
  font-weight: 400;
401
401
  text-decoration: underline;
@@ -407,7 +407,7 @@
407
407
  text-decoration: none;
408
408
  }
409
409
 
410
- /* // Inline code element */
410
+ /* Inline code element */
411
411
  &:where(code:not(pre code)) {
412
412
  font-weight: 600;
413
413
  border-radius: 4px;
@@ -419,7 +419,7 @@
419
419
  }
420
420
  }
421
421
 
422
- /* // Remove top margin from first element */
422
+ /* Remove top margin from first element */
423
423
  .prose > :first-child:not(:where([class~="not-prose"], [class~="not-prose"] *)) {
424
424
  margin-top: 0;
425
425
  }
@@ -1,339 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || (function () {
20
- var ownKeys = function(o) {
21
- ownKeys = Object.getOwnPropertyNames || function (o) {
22
- var ar = [];
23
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
- return ar;
25
- };
26
- return ownKeys(o);
27
- };
28
- return function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
35
- })();
36
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
- return new (P || (P = Promise))(function (resolve, reject) {
39
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
- step((generator = generator.apply(thisArg, _arguments || [])).next());
43
- });
44
- };
45
- var __importDefault = (this && this.__importDefault) || function (mod) {
46
- return (mod && mod.__esModule) ? mod : { "default": mod };
47
- };
48
- Object.defineProperty(exports, "__esModule", { value: true });
49
- exports.program = void 0;
50
- const chalk_1 = __importDefault(require("chalk"));
51
- const commander_1 = require("commander");
52
- const execa_1 = require("execa");
53
- const fs = __importStar(require("fs"));
54
- const ora_1 = __importDefault(require("ora"));
55
- const os_1 = __importDefault(require("os"));
56
- const path = __importStar(require("path"));
57
- const prompts_1 = __importDefault(require("prompts"));
58
- const ts_morph_1 = require("ts-morph");
59
- const download_tar_api_1 = require("../helper/download-tar-api");
60
- const get_components_api_1 = require("../helper/get-components-api");
61
- const get_components_list_1 = require("../helper/get-components-list");
62
- const get_config_1 = require("../helper/get-config");
63
- const get_package_info_1 = require("../helper/get-package-info");
64
- const get_pkg_manager_1 = require("../helper/get-pkg-manager");
65
- const get_project_1 = require("../helper/get-project");
66
- const CONFIG_DIR = path.join(os_1.default.homedir(), ".untitledui");
67
- const CONFIG_PATH = path.join(CONFIG_DIR, "config.json");
68
- let promptOptions = {
69
- components: [],
70
- path: "",
71
- type: undefined,
72
- license: "",
73
- };
74
- if (fs.existsSync(CONFIG_PATH)) {
75
- const config = JSON.parse(fs.readFileSync(CONFIG_PATH, "utf-8"));
76
- promptOptions.license = config.license;
77
- }
78
- const onPromptState = (state) => {
79
- if (state.aborted) {
80
- // If we don't re-enable the terminal cursor before exiting
81
- // the program, the cursor will remain hidden
82
- process.stdout.write("\x1B[?25h");
83
- process.stdout.write("\n");
84
- process.exit(1);
85
- }
86
- };
87
- exports.program = new commander_1.Command()
88
- .name("add")
89
- .description("add a component to your project")
90
- .argument("[components...]", "the components to add")
91
- .option("-o, --overwrite", "overwrite existing files.", false)
92
- .option("-a, --all", "add all available components", false)
93
- .option("-p, --path <path>", "the path to add the component to.")
94
- .option("-t, --type <shared|marketing|shared-assets|application|foundations>", "the type of the component to add.")
95
- .option("-l, --license <license-key>", "Add a license key for adding components.")
96
- .action((components, options) => __awaiter(void 0, void 0, void 0, function* () {
97
- if (components) {
98
- promptOptions.components = components;
99
- }
100
- if (options) {
101
- promptOptions.overwrite = options.overwrite;
102
- promptOptions.all = options.all;
103
- promptOptions.path = options.path;
104
- promptOptions.license = options.license || promptOptions.license;
105
- }
106
- try {
107
- yield run(promptOptions);
108
- }
109
- catch (e) {
110
- console.error(chalk_1.default.red(e));
111
- }
112
- }));
113
- function run(opts) {
114
- return __awaiter(this, void 0, void 0, function* () {
115
- var _a, _b;
116
- const spinner = (0, ora_1.default)().start();
117
- const cwd = process.cwd();
118
- // Check if the current directory is a existing project
119
- const isExistingProject = fs.existsSync(path.resolve(cwd, "package.json"));
120
- if (!isExistingProject) {
121
- spinner.warn("This command should be run in a project directory.");
122
- process.exit(0);
123
- }
124
- // Get the project configuration
125
- const info = yield (0, get_project_1.getNextjsProjectConfig)(cwd);
126
- if (promptOptions.license) {
127
- const isValidKey = yield (0, download_tar_api_1.checkLicenseKey)(promptOptions.license);
128
- if (!isValidKey) {
129
- spinner.fail("Invalid license key");
130
- process.exit(0);
131
- }
132
- // Save the license key to the config file
133
- if (!fs.existsSync(CONFIG_PATH)) {
134
- const dirs = path.dirname(CONFIG_PATH);
135
- fs.mkdirSync(dirs, { recursive: true });
136
- fs.writeFileSync(CONFIG_PATH, JSON.stringify({ license: promptOptions.license }, null, 2));
137
- }
138
- const config = JSON.parse(fs.readFileSync(CONFIG_PATH, "utf-8"));
139
- if (config.license !== promptOptions.license) {
140
- fs.writeFileSync(CONFIG_PATH, JSON.stringify({ license: promptOptions.license }, null, 2));
141
- }
142
- }
143
- spinner.stop();
144
- // If user didn't provide any options, prompt them
145
- if (!(promptOptions === null || promptOptions === void 0 ? void 0 : promptOptions.type) && !(promptOptions === null || promptOptions === void 0 ? void 0 : promptOptions.components.length)) {
146
- const typesList = yield (0, get_components_list_1.getComponentTypes)(promptOptions.license);
147
- if (!typesList) {
148
- console.log("No component types found");
149
- process.exit(0);
150
- }
151
- const res = yield (0, prompts_1.default)({
152
- type: "select",
153
- name: "type",
154
- onState: onPromptState,
155
- message: `What type of ${chalk_1.default.cyan("component")} are you adding?`,
156
- choices: typesList === null || typesList === void 0 ? void 0 : typesList.types.map((type) => ({
157
- title: type,
158
- value: type,
159
- })),
160
- });
161
- promptOptions.type = res.type;
162
- }
163
- // Components path where user wants to add the components
164
- // by default it's `components` directory
165
- if (!(promptOptions === null || promptOptions === void 0 ? void 0 : promptOptions.path)) {
166
- const res = yield (0, prompts_1.default)({
167
- type: "text",
168
- name: "path",
169
- onState: onPromptState,
170
- message: `Where would you like to add the ${chalk_1.default.cyan("components")}?`,
171
- initial: "components",
172
- });
173
- promptOptions.path = res.path;
174
- }
175
- // If current project does not provide alias prefix, ask user to provide one
176
- // by default it's `@/*`
177
- if (info && !(info === null || info === void 0 ? void 0 : info.aliasPrefix)) {
178
- const importAliasPattern = /^[^*"]+\/\*\s*$/;
179
- const res = yield (0, prompts_1.default)({
180
- type: "text",
181
- name: "aliasPrefix",
182
- onState: onPromptState,
183
- initial: "@/*",
184
- message: `What is the ${chalk_1.default.cyan("import alias")} for your project?`,
185
- validate: (value) => (importAliasPattern.test(value) ? true : "Import alias must follow the pattern <prefix>/*"),
186
- });
187
- // Update the tsconfig file with the alias prefix
188
- info.aliasPrefix = yield (0, get_config_1.updateTsConfig)(cwd, info === null || info === void 0 ? void 0 : info.isSrcDir, res === null || res === void 0 ? void 0 : res.aliasPrefix);
189
- }
190
- if (!(promptOptions === null || promptOptions === void 0 ? void 0 : promptOptions.components.length)) {
191
- // Get all component names based on the type
192
- const componentNames = yield (0, get_components_list_1.getComponentsList)(promptOptions === null || promptOptions === void 0 ? void 0 : promptOptions.type, promptOptions.license);
193
- if (!componentNames) {
194
- console.log("No components found");
195
- process.exit(0);
196
- }
197
- // Show components list to user
198
- const res = yield (0, prompts_1.default)({
199
- type: "multiselect",
200
- name: "components",
201
- onState: onPromptState,
202
- message: `Which ${chalk_1.default.cyan("components")} would you like to add?`,
203
- choices: (_a = componentNames === null || componentNames === void 0 ? void 0 : componentNames.components) === null || _a === void 0 ? void 0 : _a.map((component) => ({
204
- title: component || "example",
205
- value: component || "example",
206
- selected: promptOptions.components.includes(component),
207
- })),
208
- instructions: false,
209
- hint: "- Space to select. Return to submit",
210
- });
211
- promptOptions.components = res.components;
212
- // If user didn't select any component, exit
213
- if (!res.components || res.components.length === 0) {
214
- console.log("No option selected. Exiting...");
215
- process.exit(0);
216
- }
217
- }
218
- // If user didn't select any component, exit
219
- if (!((_b = promptOptions.components) === null || _b === void 0 ? void 0 : _b.length)) {
220
- spinner.warn("No components selected. Exiting.");
221
- process.exit(0);
222
- }
223
- if (!promptOptions.overwrite) {
224
- const res = yield (0, prompts_1.default)({
225
- type: "confirm",
226
- name: "overwrite",
227
- message: "You are about to add new components to your project. Do you want to overwrite the existing files?",
228
- initial: true,
229
- });
230
- promptOptions.overwrite = res.overwrite;
231
- }
232
- // Src directory of the main project
233
- const srcDir = path.join(path.resolve(__dirname, "../../../../"));
234
- // Get the configuration file paths of the project
235
- // tailwind.config.ts, tsconfig.json, layout.tsx, _app.tsx, globals.css
236
- // package.json, etc
237
- const configFiles = yield (0, get_config_1.resolveConfigPaths)(cwd);
238
- const existingFiles = [];
239
- // Create a new project instance with the tsconfig file
240
- const project = new ts_morph_1.Project({
241
- tsConfigFilePath: configFiles === null || configFiles === void 0 ? void 0 : configFiles.tsConfig,
242
- });
243
- // Spinner for adding component
244
- const componentSpinner = (0, ora_1.default)("Adding component\n").start();
245
- // Get the components data from the API
246
- const data = yield (0, get_components_api_1.getComponents)(promptOptions.type, promptOptions.components, promptOptions.license);
247
- if (!data) {
248
- console.log("No components found");
249
- process.exit(0);
250
- }
251
- // Add the components to the project
252
- data.components.forEach((component) => __awaiter(this, void 0, void 0, function* () {
253
- var _a;
254
- // Get all files that are used in the component from the components.json file
255
- const files = component.files;
256
- // Get dependencies of the component
257
- const dependencies = component.dependencies;
258
- // Get devDependencies of the component
259
- const devDependencies = component.devDependencies;
260
- // Get dependencies from the package.json file in the main repo
261
- // and with the specified versions
262
- const packages = (0, get_package_info_1.getDependenciesFromPackageJson)({
263
- cwd: srcDir,
264
- dependencies,
265
- devDependencies,
266
- });
267
- // Get the package manager of the project
268
- // npm, yarn, pnpm or bun
269
- const pkgManager = (0, get_pkg_manager_1.getPkgManager)();
270
- const dependencySpinner = (0, ora_1.default)("Installing dependencies\n").start();
271
- try {
272
- // Add the component files to the project
273
- files === null || files === void 0 ? void 0 : files.forEach((_a) => __awaiter(this, [_a], void 0, function* ({ path: file, code }) {
274
- // Remove the components/ prefix from the file path
275
- // to replace it with the user provided path
276
- const relativePath = file.replace("components/", "");
277
- // Target file path where the component will be added
278
- const targetFilePath = path.join(process.cwd(), `${(info === null || info === void 0 ? void 0 : info.isSrcDir) && "src"}`, file.replace(/components\//, promptOptions.path + "/"));
279
- // Get the folders of the target file path
280
- const folders = path.dirname(targetFilePath);
281
- // Check if the file already exists in the project directory
282
- if (fs.existsSync(targetFilePath) && !promptOptions.overwrite) {
283
- existingFiles.push(relativePath);
284
- }
285
- else {
286
- // Create the directory if it doesn't exist
287
- fs.mkdirSync(folders, { recursive: true });
288
- // Create an empty file
289
- fs.writeFileSync(targetFilePath, code);
290
- // Get the source file from the project
291
- const sourceFile = project.addSourceFileAtPath(path.resolve(targetFilePath));
292
- sourceFile.getImportDeclarations().forEach((importDeclaration) => {
293
- // Get the module specifier value of the import declaration
294
- const moduleSpecifier = importDeclaration.getModuleSpecifierValue();
295
- // Update the module specifier value with the alias prefix
296
- importDeclaration.setModuleSpecifier((0, get_config_1.updateImportAliases)(moduleSpecifier, info === null || info === void 0 ? void 0 : info.aliasPrefix, promptOptions.path));
297
- });
298
- // Save the source file
299
- yield sourceFile.save();
300
- }
301
- }));
302
- // If the files already exist in the project directory, show the user
303
- // which files exist
304
- if (existingFiles.length && !(promptOptions === null || promptOptions === void 0 ? void 0 : promptOptions.overwrite)) {
305
- console.log("\n");
306
- componentSpinner.fail(`Following files already exist in the directory. Use ${chalk_1.default.cyan("--overwrite")} or ${chalk_1.default.cyan("-o")} to overwrite existing files, or refer to the documentation ${chalk_1.default.cyan("https://untitled.xyz/docs")} for manual installation. The rest of the files are added.`);
307
- existingFiles.forEach((file) => {
308
- console.log(`- ${chalk_1.default.green(file)}`);
309
- });
310
- process.exit(0);
311
- }
312
- // Install dependencies from the package.json file in the main repo
313
- if (!packages) {
314
- dependencySpinner.fail("Failed to get dependencies from package.json\n");
315
- process.exit(0);
316
- }
317
- // Run the package manager install command to install the dependencies
318
- // and devDependencies
319
- if ((_a = packages === null || packages === void 0 ? void 0 : packages.dependencies) === null || _a === void 0 ? void 0 : _a.length) {
320
- yield (0, execa_1.execa)(pkgManager, [pkgManager === "npm" ? "install" : "add", ...packages.dependencies]);
321
- dependencySpinner.succeed("Dependencies are installed\n");
322
- }
323
- // if (devDependencies?.length) {
324
- // await execa(pkgManager, [pkgManager === "npm" ? "install" : "add", ...packages.devDependencies]);
325
- // dependencySpinner.succeed("DevDependencies are installed\n");
326
- // }
327
- componentSpinner.succeed("Component is added\n");
328
- // Exit the process with a success status code
329
- process.exit(1);
330
- }
331
- catch (e) {
332
- dependencySpinner.fail("\nFailed to install dependencies");
333
- componentSpinner.fail("\nFailed to add component");
334
- console.error(chalk_1.default.red(e));
335
- process.exit(0);
336
- }
337
- }));
338
- });
339
- }