@idealyst/cli 1.2.0 → 1.2.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 (324) hide show
  1. package/dist/commands/add.js +233 -0
  2. package/dist/commands/add.js.map +1 -0
  3. package/dist/commands/index.js +13 -0
  4. package/dist/commands/index.js.map +1 -0
  5. package/dist/commands/info.js +193 -0
  6. package/dist/commands/info.js.map +1 -0
  7. package/dist/commands/init.js +155 -0
  8. package/dist/commands/init.js.map +1 -0
  9. package/dist/constants.js +125 -0
  10. package/dist/constants.js.map +1 -0
  11. package/dist/generators/core/index.js +23 -0
  12. package/dist/generators/core/index.js.map +1 -0
  13. package/dist/generators/core/mobile.js +251 -0
  14. package/dist/generators/core/mobile.js.map +1 -0
  15. package/dist/generators/core/shared.js +474 -0
  16. package/dist/generators/core/shared.js.map +1 -0
  17. package/dist/generators/core/web.js +330 -0
  18. package/dist/generators/core/web.js.map +1 -0
  19. package/dist/generators/extensions/api.js +223 -0
  20. package/dist/generators/extensions/api.js.map +1 -0
  21. package/dist/generators/extensions/devcontainer.js +575 -0
  22. package/dist/generators/extensions/devcontainer.js.map +1 -0
  23. package/dist/generators/extensions/graphql.js +202 -0
  24. package/dist/generators/extensions/graphql.js.map +1 -0
  25. package/dist/generators/extensions/index.js +17 -0
  26. package/dist/generators/extensions/index.js.map +1 -0
  27. package/dist/generators/extensions/prisma.js +249 -0
  28. package/dist/generators/extensions/prisma.js.map +1 -0
  29. package/dist/generators/extensions/trpc.js +258 -0
  30. package/dist/generators/extensions/trpc.js.map +1 -0
  31. package/dist/generators/index.js +122 -4
  32. package/dist/generators/index.js.map +1 -1
  33. package/dist/generators/reactNative.js +253 -0
  34. package/dist/generators/reactNative.js.map +1 -0
  35. package/dist/generators/workspace.js +303 -0
  36. package/dist/generators/workspace.js.map +1 -0
  37. package/dist/identifiers/android.js +75 -0
  38. package/dist/identifiers/android.js.map +1 -0
  39. package/dist/identifiers/index.js +35 -0
  40. package/dist/identifiers/index.js.map +1 -0
  41. package/dist/identifiers/ios.js +65 -0
  42. package/dist/identifiers/ios.js.map +1 -0
  43. package/dist/index.js +41 -319
  44. package/dist/index.js.map +1 -1
  45. package/dist/templates/copier.js +135 -0
  46. package/dist/templates/copier.js.map +1 -0
  47. package/dist/templates/index.js +23 -0
  48. package/dist/templates/index.js.map +1 -0
  49. package/dist/templates/merger.js +113 -0
  50. package/dist/templates/merger.js.map +1 -0
  51. package/dist/templates/processor.js +142 -0
  52. package/dist/templates/processor.js.map +1 -0
  53. package/dist/types/commands/add.d.ts +14 -0
  54. package/dist/types/commands/index.d.ts +6 -0
  55. package/dist/types/commands/info.d.ts +10 -0
  56. package/dist/types/commands/init.d.ts +19 -0
  57. package/dist/types/constants.d.ts +82 -0
  58. package/dist/types/generators/core/index.d.ts +6 -0
  59. package/dist/types/generators/core/mobile.d.ts +14 -0
  60. package/dist/types/generators/core/shared.d.ts +8 -0
  61. package/dist/types/generators/core/web.d.ts +8 -0
  62. package/dist/types/generators/extensions/api.d.ts +8 -0
  63. package/dist/types/generators/extensions/devcontainer.d.ts +15 -0
  64. package/dist/types/generators/extensions/graphql.d.ts +8 -0
  65. package/dist/types/generators/extensions/index.d.ts +8 -0
  66. package/dist/types/generators/extensions/prisma.d.ts +8 -0
  67. package/dist/types/generators/extensions/trpc.d.ts +9 -0
  68. package/dist/types/generators/index.d.ts +11 -3
  69. package/dist/types/generators/reactNative.d.ts +19 -0
  70. package/dist/types/generators/workspace.d.ts +8 -0
  71. package/dist/types/identifiers/android.d.ts +26 -0
  72. package/dist/types/identifiers/index.d.ts +26 -0
  73. package/dist/types/identifiers/ios.d.ts +21 -0
  74. package/dist/types/index.d.ts +3 -0
  75. package/dist/types/templates/copier.d.ts +24 -0
  76. package/dist/types/templates/index.d.ts +6 -0
  77. package/dist/types/templates/merger.d.ts +43 -0
  78. package/dist/types/templates/processor.d.ts +39 -0
  79. package/dist/types/types.d.ts +184 -5
  80. package/dist/types/utils/filesystem.d.ts +56 -0
  81. package/dist/types/utils/index.d.ts +7 -0
  82. package/dist/types/utils/logger.d.ts +64 -0
  83. package/dist/types/utils/shell.d.ts +35 -0
  84. package/dist/types/utils/validation.d.ts +32 -0
  85. package/dist/types/wizard/index.d.ts +20 -0
  86. package/dist/types/wizard/steps/apiExtension.d.ts +5 -0
  87. package/dist/types/wizard/steps/appDisplayName.d.ts +5 -0
  88. package/dist/types/wizard/steps/devcontainerExtension.d.ts +5 -0
  89. package/dist/types/wizard/steps/graphqlExtension.d.ts +5 -0
  90. package/dist/types/wizard/steps/index.d.ts +12 -0
  91. package/dist/types/wizard/steps/orgDomain.d.ts +5 -0
  92. package/dist/types/wizard/steps/prismaExtension.d.ts +5 -0
  93. package/dist/types/wizard/steps/projectName.d.ts +5 -0
  94. package/dist/types/wizard/steps/summary.d.ts +5 -0
  95. package/dist/types/wizard/steps/trpcExtension.d.ts +5 -0
  96. package/dist/types/wizard/validators.d.ts +17 -0
  97. package/dist/types.js +74 -0
  98. package/dist/types.js.map +1 -1
  99. package/dist/utils/filesystem.js +173 -0
  100. package/dist/utils/filesystem.js.map +1 -0
  101. package/dist/utils/index.js +24 -0
  102. package/dist/utils/index.js.map +1 -0
  103. package/dist/utils/logger.js +106 -0
  104. package/dist/utils/logger.js.map +1 -0
  105. package/dist/utils/shell.js +113 -0
  106. package/dist/utils/shell.js.map +1 -0
  107. package/dist/utils/validation.js +196 -0
  108. package/dist/utils/validation.js.map +1 -0
  109. package/dist/wizard/index.js +177 -0
  110. package/dist/wizard/index.js.map +1 -0
  111. package/dist/wizard/steps/apiExtension.js +33 -0
  112. package/dist/wizard/steps/apiExtension.js.map +1 -0
  113. package/dist/wizard/steps/appDisplayName.js +53 -0
  114. package/dist/wizard/steps/appDisplayName.js.map +1 -0
  115. package/dist/wizard/steps/devcontainerExtension.js +131 -0
  116. package/dist/wizard/steps/devcontainerExtension.js.map +1 -0
  117. package/dist/wizard/steps/graphqlExtension.js +37 -0
  118. package/dist/wizard/steps/graphqlExtension.js.map +1 -0
  119. package/dist/wizard/steps/index.js +25 -0
  120. package/dist/wizard/steps/index.js.map +1 -0
  121. package/dist/wizard/steps/orgDomain.js +40 -0
  122. package/dist/wizard/steps/orgDomain.js.map +1 -0
  123. package/dist/wizard/steps/prismaExtension.js +33 -0
  124. package/dist/wizard/steps/prismaExtension.js.map +1 -0
  125. package/dist/wizard/steps/projectName.js +40 -0
  126. package/dist/wizard/steps/projectName.js.map +1 -0
  127. package/dist/wizard/steps/summary.js +119 -0
  128. package/dist/wizard/steps/summary.js.map +1 -0
  129. package/dist/wizard/steps/trpcExtension.js +37 -0
  130. package/dist/wizard/steps/trpcExtension.js.map +1 -0
  131. package/dist/wizard/validators.js +35 -0
  132. package/dist/wizard/validators.js.map +1 -0
  133. package/package.json +6 -19
  134. package/README.md +0 -110
  135. package/dist/generators/init.js +0 -268
  136. package/dist/generators/init.js.map +0 -1
  137. package/dist/generators/utils.js +0 -682
  138. package/dist/generators/utils.js.map +0 -1
  139. package/dist/scripts/configure-react-native-monorepo.js +0 -144
  140. package/dist/scripts/configure-react-native-monorepo.js.map +0 -1
  141. package/dist/template/.devcontainer/Dockerfile +0 -26
  142. package/dist/template/.devcontainer/devcontainer.json +0 -113
  143. package/dist/template/.devcontainer/docker-compose.yml +0 -59
  144. package/dist/template/.devcontainer/figma-mcp.sh +0 -32
  145. package/dist/template/.devcontainer/gitignore.template +0 -2
  146. package/dist/template/.devcontainer/setup.sh +0 -45
  147. package/dist/template/DOCKER.md +0 -0
  148. package/dist/template/Dockerfile +0 -111
  149. package/dist/template/README.md +0 -233
  150. package/dist/template/docker/nginx/prod.conf +0 -238
  151. package/dist/template/docker/nginx.conf +0 -131
  152. package/dist/template/docker/postgres/init.sql +0 -41
  153. package/dist/template/docker/prometheus/prometheus.yml +0 -52
  154. package/dist/template/docker-compose.prod.yml +0 -146
  155. package/dist/template/docker-compose.yml +0 -143
  156. package/dist/template/dockerignore.template +0 -151
  157. package/dist/template/env.example.template +0 -36
  158. package/dist/template/gitignore.template +0 -56
  159. package/dist/template/jest.config.js +0 -20
  160. package/dist/template/mcp.json.template +0 -8
  161. package/dist/template/package.json +0 -45
  162. package/dist/template/packages/api/README.md +0 -510
  163. package/dist/template/packages/api/__tests__/api.test.ts +0 -26
  164. package/dist/template/packages/api/env.example.template +0 -6
  165. package/dist/template/packages/api/gitignore.template +0 -35
  166. package/dist/template/packages/api/jest.config.js +0 -23
  167. package/dist/template/packages/api/jest.setup.js +0 -9
  168. package/dist/template/packages/api/package.json +0 -66
  169. package/dist/template/packages/api/src/context.ts +0 -52
  170. package/dist/template/packages/api/src/controllers/TestController.ts +0 -0
  171. package/dist/template/packages/api/src/graphql/builder.ts +0 -75
  172. package/dist/template/packages/api/src/graphql/generated.ts +0 -64
  173. package/dist/template/packages/api/src/graphql/index.ts +0 -75
  174. package/dist/template/packages/api/src/graphql/types/index.ts +0 -44
  175. package/dist/template/packages/api/src/graphql/types/test.ts +0 -245
  176. package/dist/template/packages/api/src/index.ts +0 -26
  177. package/dist/template/packages/api/src/lib/database.ts +0 -23
  178. package/dist/template/packages/api/src/router/index.ts +0 -163
  179. package/dist/template/packages/api/src/routers/test.ts +0 -161
  180. package/dist/template/packages/api/src/server.ts +0 -68
  181. package/dist/template/packages/api/src/trpc.ts +0 -28
  182. package/dist/template/packages/api/tsconfig.json +0 -44
  183. package/dist/template/packages/database/README.md +0 -162
  184. package/dist/template/packages/database/gitignore.template +0 -41
  185. package/dist/template/packages/database/package.json +0 -49
  186. package/dist/template/packages/database/prisma/seed.ts +0 -64
  187. package/dist/template/packages/database/schema.prisma +0 -107
  188. package/dist/template/packages/database/src/index.ts +0 -15
  189. package/dist/template/packages/database/src/validators.ts +0 -10
  190. package/dist/template/packages/database/tsconfig.json +0 -18
  191. package/dist/template/packages/mobile/README.md +0 -86
  192. package/dist/template/packages/mobile/__tests__/App.test.tsx +0 -156
  193. package/dist/template/packages/mobile/__tests__/components.test.tsx +0 -300
  194. package/dist/template/packages/mobile/app.json +0 -5
  195. package/dist/template/packages/mobile/babel.config.js +0 -10
  196. package/dist/template/packages/mobile/gitignore.template +0 -73
  197. package/dist/template/packages/mobile/index.js +0 -6
  198. package/dist/template/packages/mobile/jest.config.js +0 -21
  199. package/dist/template/packages/mobile/jest.setup.js +0 -12
  200. package/dist/template/packages/mobile/metro.config.js +0 -36
  201. package/dist/template/packages/mobile/package.json +0 -60
  202. package/dist/template/packages/mobile/src/App.tsx +0 -8
  203. package/dist/template/packages/mobile/src/utils/trpc.ts +0 -7
  204. package/dist/template/packages/mobile/tsconfig.json +0 -28
  205. package/dist/template/packages/shared/README.md +0 -135
  206. package/dist/template/packages/shared/__tests__/shared.test.ts +0 -51
  207. package/dist/template/packages/shared/gitignore.template +0 -35
  208. package/dist/template/packages/shared/jest.config.js +0 -22
  209. package/dist/template/packages/shared/package.json +0 -68
  210. package/dist/template/packages/shared/src/components/App.tsx +0 -57
  211. package/dist/template/packages/shared/src/components/HelloWorld.tsx +0 -531
  212. package/dist/template/packages/shared/src/components/index.ts +0 -1
  213. package/dist/template/packages/shared/src/graphql/client.ts +0 -34
  214. package/dist/template/packages/shared/src/index.ts +0 -22
  215. package/dist/template/packages/shared/src/navigation/AppRouter.tsx +0 -565
  216. package/dist/template/packages/shared/src/trpc/client.ts +0 -44
  217. package/dist/template/packages/shared/tsconfig.json +0 -22
  218. package/dist/template/packages/web/README.md +0 -131
  219. package/dist/template/packages/web/__tests__/App.test.tsx +0 -342
  220. package/dist/template/packages/web/__tests__/components.test.tsx +0 -564
  221. package/dist/template/packages/web/gitignore.template +0 -35
  222. package/dist/template/packages/web/index.html +0 -13
  223. package/dist/template/packages/web/jest.config.js +0 -27
  224. package/dist/template/packages/web/jest.setup.js +0 -24
  225. package/dist/template/packages/web/package.json +0 -69
  226. package/dist/template/packages/web/src/App.tsx +0 -14
  227. package/dist/template/packages/web/src/components/TestDemo.tsx +0 -164
  228. package/dist/template/packages/web/src/main.tsx +0 -25
  229. package/dist/template/packages/web/src/utils/trpc.ts +0 -7
  230. package/dist/template/packages/web/tsconfig.json +0 -26
  231. package/dist/template/packages/web/vite.config.ts +0 -98
  232. package/dist/template/setup.sh +0 -30
  233. package/dist/template/tsconfig.json +0 -22
  234. package/dist/template/yarnrc.yml.template +0 -4
  235. package/dist/types/generators/init.d.ts +0 -5
  236. package/dist/types/generators/utils.d.ts +0 -45
  237. package/dist/types/scripts/configure-react-native-monorepo.d.ts +0 -23
  238. package/template/.devcontainer/Dockerfile +0 -26
  239. package/template/.devcontainer/devcontainer.json +0 -113
  240. package/template/.devcontainer/docker-compose.yml +0 -59
  241. package/template/.devcontainer/figma-mcp.sh +0 -32
  242. package/template/.devcontainer/setup.sh +0 -45
  243. package/template/.dockerignore +0 -151
  244. package/template/.env.example +0 -36
  245. package/template/.env.production +0 -56
  246. package/template/DOCKER.md +0 -0
  247. package/template/Dockerfile +0 -111
  248. package/template/README.md +0 -233
  249. package/template/docker/nginx/prod.conf +0 -238
  250. package/template/docker/nginx.conf +0 -131
  251. package/template/docker/postgres/init.sql +0 -41
  252. package/template/docker/prometheus/prometheus.yml +0 -52
  253. package/template/docker-compose.prod.yml +0 -146
  254. package/template/docker-compose.yml +0 -143
  255. package/template/jest.config.js +0 -20
  256. package/template/package.json +0 -45
  257. package/template/packages/api/.env.example +0 -6
  258. package/template/packages/api/README.md +0 -510
  259. package/template/packages/api/__tests__/api.test.ts +0 -26
  260. package/template/packages/api/jest.config.js +0 -23
  261. package/template/packages/api/jest.setup.js +0 -9
  262. package/template/packages/api/package.json +0 -66
  263. package/template/packages/api/src/context.ts +0 -52
  264. package/template/packages/api/src/controllers/TestController.ts +0 -0
  265. package/template/packages/api/src/graphql/builder.ts +0 -75
  266. package/template/packages/api/src/graphql/generated.ts +0 -64
  267. package/template/packages/api/src/graphql/index.ts +0 -75
  268. package/template/packages/api/src/graphql/types/index.ts +0 -44
  269. package/template/packages/api/src/graphql/types/test.ts +0 -245
  270. package/template/packages/api/src/index.ts +0 -26
  271. package/template/packages/api/src/lib/database.ts +0 -23
  272. package/template/packages/api/src/router/index.ts +0 -163
  273. package/template/packages/api/src/routers/test.ts +0 -161
  274. package/template/packages/api/src/server.ts +0 -68
  275. package/template/packages/api/src/trpc.ts +0 -28
  276. package/template/packages/api/tsconfig.json +0 -44
  277. package/template/packages/database/README.md +0 -162
  278. package/template/packages/database/package.json +0 -49
  279. package/template/packages/database/prisma/seed.ts +0 -64
  280. package/template/packages/database/schema.prisma +0 -107
  281. package/template/packages/database/src/index.ts +0 -15
  282. package/template/packages/database/src/validators.ts +0 -10
  283. package/template/packages/database/tsconfig.json +0 -18
  284. package/template/packages/mobile/README.md +0 -86
  285. package/template/packages/mobile/__tests__/App.test.tsx +0 -156
  286. package/template/packages/mobile/__tests__/components.test.tsx +0 -300
  287. package/template/packages/mobile/app.json +0 -5
  288. package/template/packages/mobile/babel.config.js +0 -26
  289. package/template/packages/mobile/index.js +0 -8
  290. package/template/packages/mobile/jest.config.js +0 -21
  291. package/template/packages/mobile/jest.setup.js +0 -12
  292. package/template/packages/mobile/metro.config.js +0 -36
  293. package/template/packages/mobile/package.json +0 -60
  294. package/template/packages/mobile/src/App.tsx +0 -8
  295. package/template/packages/mobile/src/utils/trpc.ts +0 -7
  296. package/template/packages/mobile/tsconfig.json +0 -28
  297. package/template/packages/shared/README.md +0 -135
  298. package/template/packages/shared/__tests__/shared.test.ts +0 -51
  299. package/template/packages/shared/jest.config.js +0 -22
  300. package/template/packages/shared/package.json +0 -68
  301. package/template/packages/shared/src/components/App.tsx +0 -57
  302. package/template/packages/shared/src/components/HelloWorld.tsx +0 -531
  303. package/template/packages/shared/src/components/index.ts +0 -1
  304. package/template/packages/shared/src/graphql/client.ts +0 -34
  305. package/template/packages/shared/src/index.ts +0 -25
  306. package/template/packages/shared/src/navigation/AppRouter.tsx +0 -565
  307. package/template/packages/shared/src/trpc/client.ts +0 -44
  308. package/template/packages/shared/src/unistyles.ts +0 -50
  309. package/template/packages/shared/tsconfig.json +0 -22
  310. package/template/packages/web/README.md +0 -131
  311. package/template/packages/web/__tests__/App.test.tsx +0 -342
  312. package/template/packages/web/__tests__/components.test.tsx +0 -564
  313. package/template/packages/web/index.html +0 -13
  314. package/template/packages/web/jest.config.js +0 -27
  315. package/template/packages/web/jest.setup.js +0 -24
  316. package/template/packages/web/package.json +0 -69
  317. package/template/packages/web/src/App.tsx +0 -14
  318. package/template/packages/web/src/components/TestDemo.tsx +0 -164
  319. package/template/packages/web/src/main.tsx +0 -27
  320. package/template/packages/web/src/utils/trpc.ts +0 -7
  321. package/template/packages/web/tsconfig.json +0 -26
  322. package/template/packages/web/vite.config.ts +0 -114
  323. package/template/setup.sh +0 -30
  324. package/template/tsconfig.json +0 -22
@@ -1,682 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.validateProjectName = validateProjectName;
7
- exports.getTemplatePath = getTemplatePath;
8
- exports.createPackageName = createPackageName;
9
- exports.updateWorkspacePackageJson = updateWorkspacePackageJson;
10
- exports.copyTemplate = copyTemplate;
11
- exports.processTemplateFiles = processTemplateFiles;
12
- exports.processTemplateFile = processTemplateFile;
13
- exports.installDependencies = installDependencies;
14
- exports.runCommand = runCommand;
15
- exports.getTemplateData = getTemplateData;
16
- exports.isWorkspaceRoot = isWorkspaceRoot;
17
- exports.getWorkspaceName = getWorkspaceName;
18
- exports.resolveProjectPath = resolveProjectPath;
19
- exports.initializeReactNativeProject = initializeReactNativeProject;
20
- exports.overlayIdealystFiles = overlayIdealystFiles;
21
- exports.mergePackageJsonDependencies = mergePackageJsonDependencies;
22
- exports.promptForProjectName = promptForProjectName;
23
- exports.promptForProjectType = promptForProjectType;
24
- exports.promptForAppName = promptForAppName;
25
- exports.promptForTrpcIntegration = promptForTrpcIntegration;
26
- exports.copyTrpcFiles = copyTrpcFiles;
27
- exports.copyTrpcAppComponent = copyTrpcAppComponent;
28
- exports.addTrpcDependencies = addTrpcDependencies;
29
- exports.removeTrpcDependencies = removeTrpcDependencies;
30
- exports.configureAndroidVectorIcons = configureAndroidVectorIcons;
31
- const fs_extra_1 = __importDefault(require("fs-extra"));
32
- const path_1 = __importDefault(require("path"));
33
- const child_process_1 = require("child_process");
34
- const chalk_1 = __importDefault(require("chalk"));
35
- const ora_1 = __importDefault(require("ora"));
36
- const validate_npm_package_name_1 = __importDefault(require("validate-npm-package-name"));
37
- const inquirer_1 = __importDefault(require("inquirer"));
38
- /**
39
- * Get the current CLI version from package.json
40
- */
41
- function getCurrentVersion() {
42
- try {
43
- const packageJsonPath = path_1.default.join(__dirname, '../../package.json');
44
- const packageJson = JSON.parse(fs_extra_1.default.readFileSync(packageJsonPath, 'utf8'));
45
- return packageJson.version;
46
- }
47
- catch (error) {
48
- console.warn('Could not read CLI version, using fallback');
49
- return '1.0.67'; // Fallback version
50
- }
51
- }
52
- function validateProjectName(name) {
53
- // Use npm validation as base but add our own restrictions
54
- const npmValidation = (0, validate_npm_package_name_1.default)(name);
55
- if (!npmValidation.validForNewPackages) {
56
- return false;
57
- }
58
- // Additional restrictions for our projects:
59
- // - No underscores (prefer kebab-case)
60
- // - No starting with numbers
61
- // - Only lowercase letters, numbers, and hyphens
62
- const pattern = /^[a-z][a-z0-9-]*$/;
63
- return pattern.test(name);
64
- }
65
- function getTemplatePath(templateName) {
66
- // In tests, use the current directory + templates
67
- // In production, use the built directory + templates
68
- const isTest = process.env.NODE_ENV === 'test' || process.env.JEST_WORKER_ID !== undefined;
69
- if (isTest) {
70
- // During tests, use the templates directory relative to the project root
71
- return path_1.default.join(__dirname, '..', '..', 'templates', templateName);
72
- }
73
- else {
74
- // In production, use the templates directory relative to the dist folder
75
- return path_1.default.join(__dirname, '..', 'templates', templateName);
76
- }
77
- }
78
- function createPackageName(name) {
79
- return name.toLowerCase().replace(/[^a-z0-9-]/g, '-');
80
- }
81
- async function updateWorkspacePackageJson(workspacePath, directory) {
82
- // Look for package.json in the directory to see if we're in a workspace
83
- const packageJsonPath = path_1.default.join(directory, 'package.json');
84
- if (await fs_extra_1.default.pathExists(packageJsonPath)) {
85
- try {
86
- const packageJson = await fs_extra_1.default.readJSON(packageJsonPath);
87
- // Check if this is a workspace (has workspaces property)
88
- if (packageJson.workspaces && Array.isArray(packageJson.workspaces)) {
89
- // Check if workspace already covers this path with a wildcard
90
- const workspaceDir = path_1.default.dirname(workspacePath);
91
- const wildcardPattern = `${workspaceDir}/*`;
92
- const isAlreadyCovered = packageJson.workspaces.some((ws) => ws === wildcardPattern || ws === workspacePath);
93
- // Add the new project to workspaces if not already present or covered
94
- if (!isAlreadyCovered) {
95
- packageJson.workspaces.push(workspacePath);
96
- await fs_extra_1.default.writeJSON(packageJsonPath, packageJson, { spaces: 2 });
97
- console.log(chalk_1.default.green(`✅ Added ${workspacePath} to workspace configuration`));
98
- }
99
- else {
100
- console.log(chalk_1.default.blue(`📦 Project ${workspacePath} already covered by existing workspace configuration`));
101
- }
102
- }
103
- }
104
- catch (error) {
105
- // Silently ignore if we can't read/write package.json
106
- console.log(chalk_1.default.yellow(`⚠️ Could not update workspace configuration: ${error instanceof Error ? error.message : 'Unknown error'}`));
107
- }
108
- }
109
- }
110
- async function copyTemplate(templatePath, destPath, data) {
111
- const spinner = (0, ora_1.default)(`Copying template files...`).start();
112
- try {
113
- await fs_extra_1.default.ensureDir(destPath);
114
- // Copy files with custom handling for .template files
115
- await copyTemplateDirectory(templatePath, destPath);
116
- // Process template files
117
- await processTemplateFiles(destPath, data);
118
- spinner.succeed('Template files copied successfully');
119
- }
120
- catch (error) {
121
- spinner.fail('Failed to copy template files');
122
- throw error;
123
- }
124
- }
125
- /**
126
- * Recursively copy template directory, handling .template file renaming
127
- */
128
- async function copyTemplateDirectory(srcDir, destDir) {
129
- await fs_extra_1.default.ensureDir(destDir);
130
- const files = await fs_extra_1.default.readdir(srcDir);
131
- for (const file of files) {
132
- const srcPath = path_1.default.join(srcDir, file);
133
- // Skip files that shouldn't be copied
134
- if (file === 'node_modules' ||
135
- file === '.git' ||
136
- file === 'App-with-trpc.tsx' ||
137
- file === 'App-with-trpc-and-shared.tsx') {
138
- continue;
139
- }
140
- // Handle .template files (renamed dotfiles from build process)
141
- let destFile = file;
142
- if (file.endsWith('.template')) {
143
- // Rename back to dotfile (e.g., gitignore.template -> .gitignore)
144
- destFile = '.' + file.replace('.template', '');
145
- }
146
- const destPath = path_1.default.join(destDir, destFile);
147
- const stat = await fs_extra_1.default.stat(srcPath);
148
- if (stat.isDirectory()) {
149
- await copyTemplateDirectory(srcPath, destPath);
150
- }
151
- else {
152
- await fs_extra_1.default.copy(srcPath, destPath);
153
- }
154
- }
155
- }
156
- async function processTemplateFiles(dir, data) {
157
- const files = await fs_extra_1.default.readdir(dir);
158
- for (const file of files) {
159
- const filePath = path_1.default.join(dir, file);
160
- const stat = await fs_extra_1.default.stat(filePath);
161
- if (stat.isDirectory()) {
162
- // Skip common directories that shouldn't be processed
163
- if (file === 'node_modules' || file === '.git' || file === 'dist' || file === 'build' || file === '.cache') {
164
- continue;
165
- }
166
- await processTemplateFiles(filePath, data);
167
- }
168
- else if (file.endsWith('.json') || file.endsWith('.js') || file.endsWith('.ts') || file.endsWith('.tsx') || file.endsWith('.md')) {
169
- await processTemplateFile(filePath, data);
170
- }
171
- }
172
- }
173
- async function processTemplateFile(filePath, data) {
174
- try {
175
- let content = await fs_extra_1.default.readFile(filePath, 'utf8');
176
- // Replace template variables
177
- content = content.replace(/\{\{projectName\}\}/g, data.projectName);
178
- content = content.replace(/\{\{packageName\}\}/g, data.packageName);
179
- content = content.replace(/\{\{version\}\}/g, data.version);
180
- content = content.replace(/\{\{description\}\}/g, data.description);
181
- content = content.replace(/\{\{idealystVersion\}\}/g, data.idealystVersion);
182
- // Handle appName (with fallback to projectName if not provided)
183
- const appName = data.appName || data.projectName;
184
- content = content.replace(/\{\{appName\}\}/g, appName);
185
- // Handle workspaceScope (with fallback to projectName if not provided)
186
- const workspaceScope = data.workspaceScope || data.projectName;
187
- content = content.replace(/\{\{workspaceScope\}\}/g, workspaceScope);
188
- await fs_extra_1.default.writeFile(filePath, content);
189
- }
190
- catch (error) {
191
- // Skip files that can't be processed
192
- console.warn(chalk_1.default.yellow(`Warning: Could not process template file ${filePath}`));
193
- }
194
- }
195
- async function installDependencies(projectPath, skipInstall = false) {
196
- if (skipInstall) {
197
- console.log(chalk_1.default.yellow('Skipping dependency installation'));
198
- return;
199
- }
200
- const spinner = (0, ora_1.default)('Installing dependencies...').start();
201
- try {
202
- await runCommand('yarn', ['install'], { cwd: projectPath });
203
- spinner.succeed('Dependencies installed successfully');
204
- }
205
- catch (error) {
206
- spinner.fail('Failed to install dependencies with yarn');
207
- console.log(chalk_1.default.yellow('You can install dependencies manually by running:'));
208
- console.log(chalk_1.default.white(' cd ' + path_1.default.basename(projectPath)));
209
- console.log(chalk_1.default.white(' yarn install'));
210
- console.log(chalk_1.default.white(' # or alternatively:'));
211
- console.log(chalk_1.default.white(' npm install'));
212
- }
213
- }
214
- function runCommand(command, args, options) {
215
- return new Promise((resolve, reject) => {
216
- const timeoutMs = options.timeout || 300000; // 5 minutes default timeout
217
- const process = (0, child_process_1.spawn)(command, args, {
218
- cwd: options.cwd,
219
- stdio: ['pipe', 'inherit', 'inherit'], // Pipe stdin to prevent hanging on prompts
220
- shell: true
221
- });
222
- // Set up timeout
223
- const timeoutId = setTimeout(() => {
224
- process.kill('SIGTERM');
225
- reject(new Error(`Command timed out after ${timeoutMs / 1000} seconds`));
226
- }, timeoutMs);
227
- // Close stdin immediately to prevent hanging on interactive prompts
228
- if (process.stdin) {
229
- process.stdin.end();
230
- }
231
- process.on('close', (code) => {
232
- clearTimeout(timeoutId);
233
- if (code === 0) {
234
- resolve();
235
- }
236
- else {
237
- reject(new Error(`Command failed with code ${code}`));
238
- }
239
- });
240
- process.on('error', (error) => {
241
- clearTimeout(timeoutId);
242
- reject(error);
243
- });
244
- });
245
- }
246
- function getTemplateData(projectName, description, appName, workspaceScope) {
247
- let packageName = createPackageName(projectName);
248
- // If we have a workspace scope, prefix the package name with it
249
- if (workspaceScope) {
250
- packageName = `@${workspaceScope}/${packageName}`;
251
- }
252
- const currentVersion = getCurrentVersion();
253
- return {
254
- projectName,
255
- packageName,
256
- version: currentVersion,
257
- description: description || `A new Idealyst project: ${projectName}`,
258
- appName,
259
- workspaceScope,
260
- idealystVersion: currentVersion
261
- };
262
- }
263
- /**
264
- * Detects if we're in a workspace root directory
265
- */
266
- async function isWorkspaceRoot(directory) {
267
- const packageJsonPath = path_1.default.join(directory, 'package.json');
268
- if (await fs_extra_1.default.pathExists(packageJsonPath)) {
269
- try {
270
- const packageJson = await fs_extra_1.default.readJSON(packageJsonPath);
271
- return !!(packageJson.workspaces && Array.isArray(packageJson.workspaces));
272
- }
273
- catch (error) {
274
- return false;
275
- }
276
- }
277
- return false;
278
- }
279
- /**
280
- * Gets the workspace scope from the workspace root's package.json
281
- * Extracts just the scope name (without @) from scoped package names
282
- */
283
- async function getWorkspaceName(directory) {
284
- const packageJsonPath = path_1.default.join(directory, 'package.json');
285
- if (await fs_extra_1.default.pathExists(packageJsonPath)) {
286
- try {
287
- const packageJson = await fs_extra_1.default.readJSON(packageJsonPath);
288
- const fullName = packageJson.name;
289
- if (!fullName)
290
- return null;
291
- // If it's a scoped package like @scope/name, extract just the scope
292
- if (fullName.startsWith('@')) {
293
- const scopeMatch = fullName.match(/^@([^/]+)/);
294
- return scopeMatch ? scopeMatch[1] : null;
295
- }
296
- // If it's not scoped, return the full name
297
- return fullName;
298
- }
299
- catch (error) {
300
- return null;
301
- }
302
- }
303
- return null;
304
- }
305
- /**
306
- * Resolves the correct project path for individual projects (native, web, shared).
307
- * Individual projects can ONLY be created within an existing workspace.
308
- * This enforces proper monorepo structure and prevents scattered individual projects.
309
- */
310
- async function resolveProjectPath(projectName, directory) {
311
- // Check if we're in a workspace directory
312
- const isWorkspace = await isWorkspaceRoot(directory);
313
- if (!isWorkspace) {
314
- throw new Error(`Individual projects can only be created within a workspace.\n` +
315
- `Please first create a workspace with: idealyst init my-workspace\n` +
316
- `Then navigate to the workspace directory and create your project.`);
317
- }
318
- // Get the workspace name to use as scope
319
- const workspaceScope = await getWorkspaceName(directory);
320
- // Create project in workspace's packages/ folder
321
- const packagesDir = path_1.default.join(directory, 'packages');
322
- await fs_extra_1.default.ensureDir(packagesDir);
323
- return {
324
- projectPath: path_1.default.join(packagesDir, projectName),
325
- workspacePath: `packages/${projectName}`,
326
- workspaceScope
327
- };
328
- }
329
- async function initializeReactNativeProject(projectName, directory, displayName, skipInstall) {
330
- const spinner = (0, ora_1.default)('Initializing React Native project...').start();
331
- try {
332
- // Try the modern approach first
333
- const cliCommand = 'npx';
334
- const args = [
335
- '@react-native-community/cli@latest',
336
- 'init',
337
- projectName,
338
- '--pm', 'yarn',
339
- '--skip-git-init'
340
- ];
341
- // Add title if displayName is provided
342
- if (displayName) {
343
- args.push('--title', displayName);
344
- }
345
- // Skip install if requested (we'll handle it separately for workspace integration)
346
- if (skipInstall) {
347
- args.push('--skip-install');
348
- }
349
- spinner.text = 'Initializing React Native project (this may take a few minutes)...';
350
- // Run React Native initialization with timeout
351
- await runCommand(cliCommand, args, {
352
- cwd: directory,
353
- timeout: 600000 // 10 minutes timeout for React Native init
354
- });
355
- spinner.succeed('React Native project initialized successfully');
356
- }
357
- catch (error) {
358
- spinner.fail('Failed to initialize React Native project with CLI');
359
- // Try fallback to regular react-native init
360
- try {
361
- spinner.start('Trying fallback: react-native@latest init...');
362
- const fallbackArgs = [
363
- 'react-native@latest',
364
- 'init',
365
- projectName,
366
- '--pm', 'yarn',
367
- '--skip-git-init'
368
- ];
369
- if (displayName) {
370
- fallbackArgs.push('--title', displayName);
371
- }
372
- if (skipInstall) {
373
- fallbackArgs.push('--skip-install');
374
- }
375
- await runCommand('npx', fallbackArgs, {
376
- cwd: directory,
377
- timeout: 600000
378
- });
379
- spinner.succeed('React Native project initialized with fallback method');
380
- }
381
- catch (fallbackError) {
382
- spinner.fail('All React Native initialization methods failed');
383
- console.log(chalk_1.default.yellow('\n💡 Alternative approaches:'));
384
- console.log(chalk_1.default.white('1. Try manually creating the project:'));
385
- console.log(chalk_1.default.white(` npx @react-native-community/cli@latest init ${projectName} --pm yarn --skip-git-init`));
386
- console.log(chalk_1.default.white('\n2. Use Expo (recommended for easier setup):'));
387
- console.log(chalk_1.default.white(` npx create-expo-app@latest ${projectName} --template blank-typescript`));
388
- console.log(chalk_1.default.white('\n3. Ensure prerequisites:'));
389
- console.log(chalk_1.default.white(' npm install -g @react-native-community/cli'));
390
- throw fallbackError;
391
- }
392
- }
393
- }
394
- async function overlayIdealystFiles(templatePath, projectPath, data) {
395
- const spinner = (0, ora_1.default)('Applying Idealyst Framework files...').start();
396
- try {
397
- // Copy Idealyst-specific files over the React Native project with .template handling
398
- await overlayTemplateDirectory(templatePath, projectPath);
399
- // Remove the root App.tsx created by React Native CLI since we use src/App.tsx
400
- const rootAppPath = path_1.default.join(projectPath, 'App.tsx');
401
- if (await fs_extra_1.default.pathExists(rootAppPath)) {
402
- await fs_extra_1.default.remove(rootAppPath);
403
- }
404
- // Process template files
405
- await processTemplateFiles(projectPath, data);
406
- // Merge package.json dependencies
407
- // DISABLED: Template package.json is now the source of truth
408
- // await mergePackageJsonDependencies(templatePath, projectPath, data);
409
- spinner.succeed('Idealyst Framework files applied successfully');
410
- }
411
- catch (error) {
412
- spinner.fail('Failed to apply Idealyst Framework files');
413
- throw error;
414
- }
415
- }
416
- /**
417
- * Recursively overlay template directory onto existing directory, handling .template file renaming
418
- */
419
- async function overlayTemplateDirectory(srcDir, destDir) {
420
- await fs_extra_1.default.ensureDir(destDir);
421
- const files = await fs_extra_1.default.readdir(srcDir);
422
- for (const file of files) {
423
- const srcPath = path_1.default.join(srcDir, file);
424
- // Skip files that shouldn't be copied
425
- if (file === 'node_modules' || file === '.git') {
426
- continue;
427
- }
428
- // Handle .template files (renamed dotfiles from build process)
429
- let destFile = file;
430
- if (file.endsWith('.template')) {
431
- // Rename back to dotfile (e.g., gitignore.template -> .gitignore)
432
- destFile = '.' + file.replace('.template', '');
433
- }
434
- const destPath = path_1.default.join(destDir, destFile);
435
- const stat = await fs_extra_1.default.stat(srcPath);
436
- if (stat.isDirectory()) {
437
- await overlayTemplateDirectory(srcPath, destPath);
438
- }
439
- else {
440
- await fs_extra_1.default.copy(srcPath, destPath, { overwrite: true });
441
- }
442
- }
443
- }
444
- async function mergePackageJsonDependencies(templatePath, projectPath, data) {
445
- const templatePackageJsonPath = path_1.default.join(templatePath, 'package.json');
446
- const projectPackageJsonPath = path_1.default.join(projectPath, 'package.json');
447
- try {
448
- // Read both package.json files
449
- const templatePackageJson = await fs_extra_1.default.readJSON(templatePackageJsonPath);
450
- const projectPackageJson = await fs_extra_1.default.readJSON(projectPackageJsonPath);
451
- // Merge dependencies with current version
452
- const idealystDependencies = {
453
- [`@idealyst/components`]: `^${data.idealystVersion}`,
454
- [`@idealyst/navigation`]: `^${data.idealystVersion}`,
455
- [`@idealyst/theme`]: `^${data.idealystVersion}`,
456
- '@react-native-vector-icons/common': '^12.0.1',
457
- '@react-native-vector-icons/material-design-icons': '^12.0.1',
458
- '@react-navigation/bottom-tabs': '^7.4.2',
459
- '@react-navigation/drawer': '^7.5.3',
460
- '@react-navigation/native': '^7.1.14',
461
- '@react-navigation/native-stack': '^7.3.21',
462
- '@tanstack/react-query': '^5.83.0',
463
- '@trpc/client': '^11.5.1',
464
- '@trpc/react-query': '^11.5.1',
465
- '@trpc/server': '^11.5.1',
466
- 'react-native-edge-to-edge': '^1.6.2',
467
- 'react-native-gesture-handler': '^2.27.1',
468
- 'react-native-nitro-modules': '^0.30.0',
469
- 'react-native-reanimated': '^3.18.0',
470
- 'react-native-safe-area-context': '^5.5.1',
471
- 'react-native-screens': '^4.11.1',
472
- 'react-native-svg': '^15.8.0',
473
- 'react-native-unistyles': '^3.0.4',
474
- 'react-native-vector-icons': '^10.2.0'
475
- };
476
- // Add workspace dependencies if workspaceScope is available
477
- if (data.workspaceScope) {
478
- idealystDependencies[`@${data.workspaceScope}/shared`] = 'workspace:*';
479
- idealystDependencies[`@${data.workspaceScope}/database`] = 'workspace:*';
480
- }
481
- // Merge the dependencies
482
- projectPackageJson.dependencies = {
483
- ...projectPackageJson.dependencies,
484
- ...idealystDependencies
485
- };
486
- // Write back the merged package.json
487
- await fs_extra_1.default.writeJSON(projectPackageJsonPath, projectPackageJson, { spaces: 2 });
488
- console.log(chalk_1.default.green('✅ Merged Idealyst dependencies into package.json'));
489
- }
490
- catch (error) {
491
- console.warn(chalk_1.default.yellow('⚠️ Could not merge package.json dependencies'));
492
- throw error;
493
- }
494
- }
495
- async function promptForProjectName() {
496
- const { projectName } = await inquirer_1.default.prompt([
497
- {
498
- type: 'input',
499
- name: 'projectName',
500
- message: 'What is your project name?',
501
- validate: (input) => {
502
- if (!input || input.trim().length === 0) {
503
- return 'Project name is required';
504
- }
505
- const lowerName = input.toLowerCase();
506
- if (!validateProjectName(lowerName)) {
507
- return 'Project name must be a valid npm package name (lowercase, no spaces)';
508
- }
509
- return true;
510
- },
511
- filter: (input) => input.toLowerCase().trim()
512
- }
513
- ]);
514
- return projectName;
515
- }
516
- async function promptForProjectType() {
517
- const { projectType } = await inquirer_1.default.prompt([
518
- {
519
- type: 'list',
520
- name: 'projectType',
521
- message: 'What type of project would you like to create?',
522
- choices: [
523
- { name: 'React Native App', value: 'native' },
524
- { name: 'React Web App', value: 'web' },
525
- { name: 'Shared Library', value: 'shared' },
526
- { name: 'API Server (tRPC + Express)', value: 'api' },
527
- { name: 'Database (Prisma + Zod)', value: 'database' }
528
- ],
529
- default: 'native'
530
- }
531
- ]);
532
- return projectType;
533
- }
534
- async function promptForAppName(projectName) {
535
- const { appName } = await inquirer_1.default.prompt([
536
- {
537
- type: 'input',
538
- name: 'appName',
539
- message: 'What is the display name for your app? (used for native app titles)',
540
- default: projectName.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(' '),
541
- validate: (input) => {
542
- if (!input || input.trim().length === 0) {
543
- return 'App name is required';
544
- }
545
- return true;
546
- },
547
- filter: (input) => input.trim()
548
- }
549
- ]);
550
- return appName;
551
- }
552
- async function promptForTrpcIntegration() {
553
- const { withTrpc } = await inquirer_1.default.prompt([
554
- {
555
- type: 'confirm',
556
- name: 'withTrpc',
557
- message: 'Would you like to include tRPC client setup and boilerplate?',
558
- default: false
559
- }
560
- ]);
561
- return withTrpc;
562
- }
563
- async function copyTrpcFiles(templatePath, projectPath, data) {
564
- const spinner = (0, ora_1.default)('Adding tRPC client utilities...').start();
565
- try {
566
- const trpcUtilsSource = path_1.default.join(templatePath, 'src', 'utils', 'trpc.ts');
567
- const trpcUtilsTarget = path_1.default.join(projectPath, 'src', 'utils', 'trpc.ts');
568
- // Ensure utils directory exists
569
- await fs_extra_1.default.ensureDir(path_1.default.join(projectPath, 'src', 'utils'));
570
- // Copy and process the tRPC utils file
571
- await fs_extra_1.default.copy(trpcUtilsSource, trpcUtilsTarget);
572
- await processTemplateFile(trpcUtilsTarget, data);
573
- spinner.succeed('tRPC client utilities added');
574
- }
575
- catch (error) {
576
- spinner.fail('Failed to add tRPC client utilities');
577
- console.warn(chalk_1.default.yellow('⚠️ tRPC utilities could not be copied, but the project was created successfully'));
578
- }
579
- }
580
- async function copyTrpcAppComponent(templatePath, projectPath, data) {
581
- const spinner = (0, ora_1.default)('Setting up tRPC App component...').start();
582
- try {
583
- // For React Native, do NOT copy App-with-trpc-and-shared.tsx
584
- const isNativeProject = await fs_extra_1.default.pathExists(path_1.default.join(projectPath, 'metro.config.js')) ||
585
- await fs_extra_1.default.pathExists(path_1.default.join(projectPath, 'android')) ||
586
- await fs_extra_1.default.pathExists(path_1.default.join(projectPath, 'ios'));
587
- if (isNativeProject) {
588
- // Use the default App.tsx for native, do not overwrite with shared tRPC App
589
- spinner.succeed('Skipped tRPC App component for native project');
590
- return;
591
- }
592
- // For web, copy App-with-trpc.tsx as App.tsx
593
- const trpcAppSource = path_1.default.join(templatePath, 'src', 'App-with-trpc.tsx');
594
- const appTarget = path_1.default.join(projectPath, 'src', 'App.tsx');
595
- await fs_extra_1.default.copy(trpcAppSource, appTarget, { overwrite: true });
596
- await processTemplateFile(appTarget, data);
597
- spinner.succeed('tRPC App component configured');
598
- }
599
- catch (error) {
600
- spinner.fail('Failed to configure tRPC App component');
601
- console.warn(chalk_1.default.yellow('⚠️ tRPC App component could not be configured, but the project was created successfully'));
602
- }
603
- }
604
- async function addTrpcDependencies(projectPath) {
605
- try {
606
- const packageJsonPath = path_1.default.join(projectPath, 'package.json');
607
- const packageJson = await fs_extra_1.default.readJSON(packageJsonPath);
608
- // Add tRPC-related dependencies
609
- const trpcDeps = {
610
- '@tanstack/react-query': '^5.83.0',
611
- '@trpc/client': '^11.5.1',
612
- '@trpc/react-query': '^11.5.1'
613
- };
614
- // Ensure dependencies object exists
615
- if (!packageJson.dependencies) {
616
- packageJson.dependencies = {};
617
- }
618
- // Add tRPC dependencies
619
- Object.assign(packageJson.dependencies, trpcDeps);
620
- await fs_extra_1.default.writeJSON(packageJsonPath, packageJson, { spaces: 2 });
621
- }
622
- catch (error) {
623
- console.warn(chalk_1.default.yellow('⚠️ Could not add tRPC dependencies to package.json'));
624
- }
625
- }
626
- async function removeTrpcDependencies(projectPath) {
627
- try {
628
- const packageJsonPath = path_1.default.join(projectPath, 'package.json');
629
- const packageJson = await fs_extra_1.default.readJSON(packageJsonPath);
630
- // Remove tRPC-related dependencies
631
- const trpcDeps = [
632
- '@tanstack/react-query',
633
- '@trpc/client',
634
- '@trpc/react-query',
635
- '@trpc/server'
636
- ];
637
- trpcDeps.forEach(dep => {
638
- if (packageJson.dependencies && packageJson.dependencies[dep]) {
639
- delete packageJson.dependencies[dep];
640
- }
641
- });
642
- await fs_extra_1.default.writeJSON(packageJsonPath, packageJson, { spaces: 2 });
643
- }
644
- catch (error) {
645
- console.warn(chalk_1.default.yellow('⚠️ Could not remove tRPC dependencies from package.json'));
646
- }
647
- }
648
- async function configureAndroidVectorIcons(projectPath) {
649
- const buildGradlePath = path_1.default.join(projectPath, 'android', 'app', 'build.gradle');
650
- try {
651
- if (await fs_extra_1.default.pathExists(buildGradlePath)) {
652
- let content = await fs_extra_1.default.readFile(buildGradlePath, 'utf8');
653
- // Check if the vector icons line is already present
654
- if (content.includes('react-native-vector-icons/fonts.gradle')) {
655
- console.log(chalk_1.default.yellow('Vector icons configuration already exists in build.gradle'));
656
- return;
657
- }
658
- // Find the line with jscFlavor definition and add the vector icons line after it
659
- const jscFlavorRegex = /def jscFlavor = ['"][^'"]*['"]/;
660
- const match = content.match(jscFlavorRegex);
661
- if (match) {
662
- const insertionPoint = content.indexOf(match[0]) + match[0].length;
663
- const beforeInsertion = content.substring(0, insertionPoint);
664
- const afterInsertion = content.substring(insertionPoint);
665
- const vectorIconsLine = '\napply from: file("../../node_modules/react-native-vector-icons/fonts.gradle")';
666
- content = beforeInsertion + vectorIconsLine + afterInsertion;
667
- await fs_extra_1.default.writeFile(buildGradlePath, content);
668
- console.log(chalk_1.default.green('✅ Added react-native-vector-icons configuration to Android build.gradle'));
669
- }
670
- else {
671
- console.log(chalk_1.default.yellow('⚠️ Could not find jscFlavor line in build.gradle, vector icons configuration not added'));
672
- }
673
- }
674
- else {
675
- console.log(chalk_1.default.yellow('⚠️ Android build.gradle not found, skipping vector icons configuration'));
676
- }
677
- }
678
- catch (error) {
679
- console.log(chalk_1.default.yellow(`⚠️ Could not configure vector icons in build.gradle: ${error instanceof Error ? error.message : 'Unknown error'}`));
680
- }
681
- }
682
- //# sourceMappingURL=utils.js.map