@stacksjs/buddy 0.66.0 → 0.68.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. package/dist/add.d.ts +4 -0
  2. package/dist/build.d.ts +4 -0
  3. package/dist/changelog.d.ts +3 -0
  4. package/dist/chunk-06g79v9j.js +2 -0
  5. package/dist/chunk-08bm2xax.js +2 -0
  6. package/dist/chunk-0enrsn65.js +978 -0
  7. package/dist/chunk-0m218zhk.js +2 -0
  8. package/dist/chunk-0q0jn0kk.js +6 -0
  9. package/dist/chunk-0yyhz107.js +2 -0
  10. package/dist/chunk-11vhe2za.js +2 -0
  11. package/dist/chunk-13143jmy.js +3 -0
  12. package/dist/chunk-1agj4qty.js +2 -0
  13. package/dist/chunk-1c4yywmn.js +9 -0
  14. package/dist/chunk-1e2f0z80.js +2 -0
  15. package/dist/chunk-1v13dkfw.js +2 -0
  16. package/dist/chunk-20e0mpcw.js +9 -0
  17. package/dist/chunk-25nxsybw.js +2 -0
  18. package/dist/chunk-27ksm11g.js +2 -0
  19. package/dist/chunk-2mhj5ght.js +2 -0
  20. package/dist/chunk-2wrs9p57.js +1 -0
  21. package/dist/chunk-2yj4j69j.js +2 -0
  22. package/dist/chunk-2ymn50ck.js +2 -0
  23. package/dist/chunk-3vjfkr7v.js +978 -0
  24. package/dist/{chunk-3zx3yk1m.js → chunk-3wpw5xgd.js} +1 -4
  25. package/dist/chunk-3y0gapf6.js +2 -0
  26. package/dist/chunk-4rb5r88h.js +978 -0
  27. package/dist/chunk-4wb68jfr.js +2 -0
  28. package/dist/chunk-5ewcj9vd.js +2 -0
  29. package/dist/chunk-5fm9mfqs.js +2 -0
  30. package/dist/chunk-5jhkn5by.js +2 -0
  31. package/dist/chunk-5m9xts4v.js +2 -0
  32. package/dist/chunk-6sqy7049.js +2 -0
  33. package/dist/chunk-6yazdvb4.js +2 -0
  34. package/dist/chunk-746p83dw.js +2 -0
  35. package/dist/chunk-76g7tr80.js +2 -0
  36. package/dist/chunk-7fz1p8p3.js +10 -0
  37. package/dist/chunk-814adsn3.js +2 -0
  38. package/dist/chunk-831wk0b3.js +2 -0
  39. package/dist/chunk-833tanrb.js +2 -0
  40. package/dist/chunk-8cx90pvv.js +2 -0
  41. package/dist/chunk-8gx9at51.js +1 -0
  42. package/dist/chunk-91pnyybg.js +9 -0
  43. package/dist/chunk-99syj1p0.js +2 -0
  44. package/dist/chunk-9bxh78vd.js +5 -0
  45. package/dist/chunk-9jaqey2q.js +2 -0
  46. package/dist/chunk-9tyaew40.js +2 -0
  47. package/dist/chunk-9zcyq5gh.js +2 -0
  48. package/dist/chunk-a4g1e1n0.js +2 -0
  49. package/dist/chunk-a6g2jk1y.js +2 -0
  50. package/dist/chunk-aaqd43t5.js +2 -0
  51. package/dist/chunk-adswb3gq.js +2 -0
  52. package/dist/chunk-atnw2cq3.js +2 -0
  53. package/dist/chunk-avdharmq.js +2 -0
  54. package/dist/chunk-b13gbfg3.js +2 -0
  55. package/dist/chunk-b3wr7cpk.js +2 -0
  56. package/dist/chunk-bngyck4v.js +2 -0
  57. package/dist/chunk-brb5zthb.js +1 -0
  58. package/dist/chunk-bx2vf8g7.js +5 -0
  59. package/dist/chunk-c343n0yt.js +2 -0
  60. package/dist/chunk-cdwpqzrw.js +2 -0
  61. package/dist/chunk-cm7bwdk9.js +2 -0
  62. package/dist/chunk-cs5k02gt.js +1 -0
  63. package/dist/chunk-cv8f2v27.js +2 -0
  64. package/dist/chunk-d2dbhn2h.js +2 -0
  65. package/dist/chunk-d3awsfqm.js +9 -0
  66. package/dist/chunk-d9q17hb8.js +2 -0
  67. package/dist/chunk-dw62d69f.js +2 -0
  68. package/dist/chunk-e8p8v7ca.js +978 -0
  69. package/dist/chunk-ehhrhkwe.js +9 -0
  70. package/dist/chunk-enhf12a1.js +2 -0
  71. package/dist/chunk-f0ksrase.js +8 -0
  72. package/dist/chunk-f2d9w3nr.js +2 -0
  73. package/dist/chunk-f3y73e4b.js +6 -0
  74. package/dist/chunk-fe3xb8z9.js +2 -0
  75. package/dist/chunk-fg5gh4dn.js +2 -0
  76. package/dist/chunk-fh4rw8kr.js +5 -0
  77. package/dist/chunk-fxsv4p5c.js +8 -0
  78. package/dist/chunk-gg80s18j.js +2 -0
  79. package/dist/chunk-h5saw32v.js +2 -0
  80. package/dist/chunk-ha75r57f.js +8 -0
  81. package/dist/chunk-hgrs6wcy.js +2 -0
  82. package/dist/chunk-hrsat16n.js +8 -0
  83. package/dist/chunk-hxy5t7tm.js +10 -0
  84. package/dist/chunk-hzfqtj82.js +2 -0
  85. package/dist/chunk-j2n86dsz.js +2 -0
  86. package/dist/chunk-jg68fsnk.js +10 -0
  87. package/dist/chunk-jhvjhf1j.js +2 -0
  88. package/dist/chunk-jr4naxsv.js +2 -0
  89. package/dist/chunk-jtax0mpm.js +2 -0
  90. package/dist/chunk-k59kbbvm.js +2 -0
  91. package/dist/chunk-kanz993c.js +2 -0
  92. package/dist/chunk-kg9abatp.js +2 -0
  93. package/dist/chunk-kvghsjg7.js +5 -0
  94. package/dist/chunk-ky8p46ae.js +5 -0
  95. package/dist/chunk-kzm498bh.js +2 -0
  96. package/dist/chunk-m4gwjnfh.js +6 -0
  97. package/dist/chunk-msv6dcc2.js +2 -0
  98. package/dist/chunk-mxdajhb4.js +10 -0
  99. package/dist/chunk-mxzjn2gs.js +978 -0
  100. package/dist/chunk-n1bqkqk7.js +10 -0
  101. package/dist/chunk-njtyervf.js +1 -0
  102. package/dist/chunk-nx1598yr.js +2 -0
  103. package/dist/chunk-p18kqenr.js +1 -0
  104. package/dist/chunk-p23aswbf.js +2 -0
  105. package/dist/chunk-p55ntqj0.js +2 -0
  106. package/dist/chunk-p5va3trj.js +2 -0
  107. package/dist/chunk-p88bsqtc.js +10 -0
  108. package/dist/chunk-p9z7f8c8.js +2 -0
  109. package/dist/chunk-ppkzf21q.js +8 -0
  110. package/dist/chunk-prqq5zw2.js +2 -0
  111. package/dist/chunk-pv6hp18q.js +10 -0
  112. package/dist/chunk-q9ycfthp.js +2 -0
  113. package/dist/chunk-qhcx6dmf.js +2 -0
  114. package/dist/chunk-qma4ysd8.js +9 -0
  115. package/dist/chunk-qqp394c2.js +2 -0
  116. package/dist/chunk-ra5sfgg4.js +2 -0
  117. package/dist/chunk-rfd43z7p.js +5 -0
  118. package/dist/chunk-s2n3hw0a.js +2 -0
  119. package/dist/chunk-sm7vvfqf.js +2 -0
  120. package/dist/chunk-sqbdav33.js +2 -0
  121. package/dist/chunk-sy4d4hnx.js +2 -0
  122. package/dist/chunk-t0b356bb.js +978 -0
  123. package/dist/chunk-t9wdnzz4.js +6 -0
  124. package/dist/chunk-v25g7h01.js +2 -0
  125. package/dist/chunk-v7zy7xda.js +1 -0
  126. package/dist/chunk-vg4vfkzk.js +6 -0
  127. package/dist/chunk-vgcre8jy.js +2 -0
  128. package/dist/chunk-vqyngnj0.js +9 -0
  129. package/dist/chunk-w17d2rbd.js +6 -0
  130. package/dist/chunk-x22v9kvb.js +2 -0
  131. package/dist/chunk-xacjs4ar.js +6 -0
  132. package/dist/chunk-xmdbxa8w.js +1 -0
  133. package/dist/chunk-xy6hjazn.js +978 -0
  134. package/dist/chunk-y0m35t3m.js +2 -0
  135. package/dist/chunk-y1tre8v8.js +8 -0
  136. package/dist/chunk-y50mc7dt.js +2 -0
  137. package/dist/chunk-y93ke5m6.js +2 -0
  138. package/dist/chunk-yktee4wv.js +1 -0
  139. package/dist/chunk-yvmyw2r2.js +2 -0
  140. package/dist/chunk-z1h35hsa.js +2 -0
  141. package/dist/chunk-z6xydw90.js +2 -0
  142. package/dist/chunk-zak32nab.js +2 -0
  143. package/dist/clean.d.ts +3 -0
  144. package/dist/cli.d.ts +4 -1
  145. package/dist/cli.js +1 -4
  146. package/dist/cloud.d.ts +3 -0
  147. package/dist/commit.d.ts +3 -0
  148. package/dist/configure.d.ts +4 -0
  149. package/dist/create.d.ts +8 -0
  150. package/dist/custom-cli.d.ts +1 -1
  151. package/dist/deploy.d.ts +7 -0
  152. package/dist/{commands/dev.d.ts → dev.d.ts} +3 -1
  153. package/dist/dns.d.ts +18 -0
  154. package/dist/domains.d.ts +3 -0
  155. package/dist/fresh.d.ts +3 -0
  156. package/dist/generate.d.ts +3 -0
  157. package/dist/http.d.ts +6 -0
  158. package/dist/index.d.ts +1 -1
  159. package/dist/index.js +1 -4
  160. package/dist/install.d.ts +3 -0
  161. package/dist/key.d.ts +3 -0
  162. package/dist/lint.d.ts +3 -0
  163. package/dist/list.d.ts +3 -0
  164. package/dist/make.d.ts +1 -0
  165. package/dist/migrate.d.ts +3 -0
  166. package/dist/outdated.d.ts +3 -0
  167. package/dist/ports.d.ts +7 -0
  168. package/dist/prepublish.d.ts +3 -0
  169. package/dist/projects.d.ts +3 -0
  170. package/dist/release.d.ts +9 -0
  171. package/dist/route.d.ts +3 -0
  172. package/dist/saas.d.ts +3 -0
  173. package/dist/seed.d.ts +3 -0
  174. package/dist/setup.d.ts +8 -0
  175. package/dist/stacks +0 -0
  176. package/dist/test.d.ts +3 -0
  177. package/dist/tinker.d.ts +3 -0
  178. package/dist/types.d.ts +3 -0
  179. package/dist/upgrade.d.ts +4 -0
  180. package/dist/version.d.ts +3 -0
  181. package/package.json +48 -49
  182. package/dist/chunk-3cfvbq6w.js +0 -5
  183. package/dist/chunk-3cfvbq6w.js.map +0 -32
  184. package/dist/chunk-3v3h2zkp.js +0 -5
  185. package/dist/chunk-3v3h2zkp.js.map +0 -46
  186. package/dist/chunk-3zx3yk1m.js.map +0 -15
  187. package/dist/chunk-8a487snn.js +0 -5
  188. package/dist/chunk-8a487snn.js.map +0 -9
  189. package/dist/chunk-9kkf5maz.js +0 -5
  190. package/dist/chunk-9kkf5maz.js.map +0 -23
  191. package/dist/chunk-9qba8jdt.js +0 -12
  192. package/dist/chunk-9qba8jdt.js.map +0 -11
  193. package/dist/chunk-cvpb67bs.js +0 -5
  194. package/dist/chunk-cvpb67bs.js.map +0 -10
  195. package/dist/chunk-eqwfdbyk.js +0 -5
  196. package/dist/chunk-eqwfdbyk.js.map +0 -17
  197. package/dist/chunk-f41k7dpa.js +0 -5
  198. package/dist/chunk-f41k7dpa.js.map +0 -11
  199. package/dist/chunk-fx1zxxxa.js +0 -9
  200. package/dist/chunk-fx1zxxxa.js.map +0 -13
  201. package/dist/chunk-get5gzkc.js +0 -11
  202. package/dist/chunk-get5gzkc.js.map +0 -10
  203. package/dist/chunk-m43npkjw.js +0 -5
  204. package/dist/chunk-m43npkjw.js.map +0 -12
  205. package/dist/chunk-mrrgcavv.js +0 -831
  206. package/dist/chunk-mrrgcavv.js.map +0 -240
  207. package/dist/chunk-n5y0mrsg.js +0 -15
  208. package/dist/chunk-n5y0mrsg.js.map +0 -173
  209. package/dist/chunk-qebxvzqz.js +0 -5
  210. package/dist/chunk-qebxvzqz.js.map +0 -26
  211. package/dist/chunk-qj2v5psd.js +0 -5
  212. package/dist/chunk-qj2v5psd.js.map +0 -20
  213. package/dist/chunk-rh4brnzh.js +0 -5
  214. package/dist/chunk-rh4brnzh.js.map +0 -16
  215. package/dist/chunk-w2vwjv6k.js +0 -6
  216. package/dist/chunk-w2vwjv6k.js.map +0 -57
  217. package/dist/chunk-w81rbh65.js +0 -5
  218. package/dist/chunk-w81rbh65.js.map +0 -10
  219. package/dist/chunk-wayp5kn2.js +0 -5
  220. package/dist/chunk-wayp5kn2.js.map +0 -22
  221. package/dist/chunk-x5c5ngpb.js +0 -4
  222. package/dist/chunk-x5c5ngpb.js.map +0 -23
  223. package/dist/cli.js.map +0 -10
  224. package/dist/commands/add.d.ts +0 -2
  225. package/dist/commands/build.d.ts +0 -2
  226. package/dist/commands/changelog.d.ts +0 -2
  227. package/dist/commands/clean.d.ts +0 -2
  228. package/dist/commands/cloud.d.ts +0 -2
  229. package/dist/commands/commit.d.ts +0 -2
  230. package/dist/commands/configure.d.ts +0 -2
  231. package/dist/commands/create.d.ts +0 -2
  232. package/dist/commands/deploy.d.ts +0 -2
  233. package/dist/commands/dns.d.ts +0 -2
  234. package/dist/commands/domains.d.ts +0 -2
  235. package/dist/commands/fresh.d.ts +0 -2
  236. package/dist/commands/generate.d.ts +0 -2
  237. package/dist/commands/http.d.ts +0 -2
  238. package/dist/commands/index.d.ts +0 -33
  239. package/dist/commands/install.d.ts +0 -2
  240. package/dist/commands/key.d.ts +0 -2
  241. package/dist/commands/lint.d.ts +0 -2
  242. package/dist/commands/list.d.ts +0 -2
  243. package/dist/commands/make.d.ts +0 -2
  244. package/dist/commands/migrate.d.ts +0 -2
  245. package/dist/commands/outdated.d.ts +0 -2
  246. package/dist/commands/ports.d.ts +0 -2
  247. package/dist/commands/prepublish.d.ts +0 -2
  248. package/dist/commands/projects.d.ts +0 -2
  249. package/dist/commands/release.d.ts +0 -2
  250. package/dist/commands/route.d.ts +0 -2
  251. package/dist/commands/seed.d.ts +0 -2
  252. package/dist/commands/setup.d.ts +0 -4
  253. package/dist/commands/test.d.ts +0 -2
  254. package/dist/commands/tinker.d.ts +0 -2
  255. package/dist/commands/types.d.ts +0 -2
  256. package/dist/commands/upgrade.d.ts +0 -2
  257. package/dist/commands/version.d.ts +0 -2
  258. package/dist/index.js.map +0 -9
  259. package/src/cli.ts +0 -105
  260. package/src/commands/add.ts +0 -71
  261. package/src/commands/build.ts +0 -299
  262. package/src/commands/changelog.ts +0 -52
  263. package/src/commands/clean.ts +0 -46
  264. package/src/commands/cloud.ts +0 -553
  265. package/src/commands/commit.ts +0 -26
  266. package/src/commands/configure.ts +0 -84
  267. package/src/commands/create.ts +0 -143
  268. package/src/commands/deploy.ts +0 -194
  269. package/src/commands/dev.ts +0 -292
  270. package/src/commands/dns.ts +0 -86
  271. package/src/commands/domains.ts +0 -255
  272. package/src/commands/fresh.ts +0 -48
  273. package/src/commands/generate.ts +0 -202
  274. package/src/commands/http.ts +0 -57
  275. package/src/commands/index.ts +0 -33
  276. package/src/commands/install.ts +0 -30
  277. package/src/commands/key.ts +0 -36
  278. package/src/commands/lint.ts +0 -54
  279. package/src/commands/list.ts +0 -42
  280. package/src/commands/make.ts +0 -352
  281. package/src/commands/migrate.ts +0 -105
  282. package/src/commands/outdated.ts +0 -31
  283. package/src/commands/ports.ts +0 -188
  284. package/src/commands/prepublish.ts +0 -28
  285. package/src/commands/projects.ts +0 -54
  286. package/src/commands/release.ts +0 -47
  287. package/src/commands/route.ts +0 -39
  288. package/src/commands/seed.ts +0 -47
  289. package/src/commands/setup.ts +0 -145
  290. package/src/commands/test.ts +0 -214
  291. package/src/commands/tinker.ts +0 -42
  292. package/src/commands/types.ts +0 -35
  293. package/src/commands/upgrade.ts +0 -200
  294. package/src/commands/version.ts +0 -29
  295. package/src/custom-cli.ts +0 -35
  296. package/src/index.ts +0 -1
@@ -1,188 +0,0 @@
1
- import type { CLI, Ports, PortsOptions } from '@stacksjs/types'
2
- import { $ } from 'bun'
3
- import process from 'node:process'
4
- import { intro, italic, outro } from '@stacksjs/cli'
5
- import { ports as projectPorts } from '@stacksjs/config'
6
- import { log } from '@stacksjs/logging'
7
- import { findProjectPath, path as p, projectPath } from '@stacksjs/path'
8
- import { ExitCode } from '@stacksjs/types'
9
- import { findStacksProjects } from '@stacksjs/utils'
10
-
11
- export function ports(buddy: CLI): void {
12
- const descriptions = {
13
- command: 'Let buddy check your project for potential issues and misconfigurations',
14
- ports: 'Check if the ports are available',
15
- project: 'Target a specific project',
16
- verbose: 'Enable verbose output',
17
- }
18
-
19
- buddy
20
- .command('ports', descriptions.command)
21
- .option('-l, --list', 'List the used ports', { default: true })
22
- .option('-c, --check', 'Check if the ports are available', {
23
- default: false,
24
- })
25
- .option('-p, --project [name]', descriptions.project, {
26
- default: undefined,
27
- })
28
- .option('-q, --quiet', 'Use minimal output', { default: false })
29
- .option('--verbose', descriptions.verbose, { default: false })
30
- .action(async (options: PortsOptions) => {
31
- log.debug('Running `buddy ports` ...', options)
32
-
33
- let perf
34
- if (!options.quiet)
35
- perf = await intro('buddy ports')
36
-
37
- if (options.project) {
38
- const path = await findProjectPath(options.project)
39
- log.debug(`Path: ${path}`)
40
-
41
- const ports = await getPortsForProjectPath(path, options)
42
- log.debug(`./buddy ports --quiet response for ${projectPath}`, ports)
43
-
44
- outputPorts(ports, options)
45
- }
46
-
47
- // use the user config ports
48
- else {
49
- outputPorts(projectPorts, options)
50
- }
51
-
52
- if (!options.quiet)
53
- await outro('Exited', { startTime: perf, useSeconds: false })
54
-
55
- process.exit(ExitCode.Success)
56
- })
57
-
58
- buddy
59
- .command('ports:list', descriptions.ports)
60
- .option('-p, --project [name]', descriptions.project, {
61
- default: undefined,
62
- })
63
- .option('-q, --quiet', 'Use minimal output', { default: false })
64
- .option('--verbose', descriptions.verbose, { default: false })
65
- .action(async (options: PortsOptions) => {
66
- log.debug('Running `buddy ports:list` ...', options)
67
-
68
- let perf
69
- if (!options.quiet)
70
- perf = await intro('buddy ports:list')
71
-
72
- // return the ports for the project
73
- if (options.project) {
74
- if (!options.quiet)
75
- log.info(`Listing ports for project: ${italic(options.project)}`)
76
-
77
- const path = await findProjectPath(options.project)
78
-
79
- log.debug(`Path: ${path}`)
80
-
81
- const ports = await getPortsForProjectPath(path, options)
82
-
83
- outputPorts(ports, options)
84
- }
85
- // return the used ports for all projects
86
- else {
87
- outputPorts(projectPorts, options)
88
- }
89
-
90
- if (!options.quiet)
91
- await outro('Exited', { startTime: perf, useSeconds: false })
92
-
93
- process.exit(ExitCode.Success)
94
- })
95
-
96
- buddy
97
- .command('ports:check', descriptions.ports)
98
- .option('-p, --project [name]', descriptions.project, {
99
- default: projectPath(),
100
- })
101
- .option('-q, --quiet', 'Use minimal output', { default: false })
102
- .option('--verbose', descriptions.verbose, { default: false })
103
- .action(async (options: PortsOptions) => {
104
- log.debug('Running `buddy ports:check` ...', options)
105
-
106
- let perf
107
- if (!options.quiet)
108
- perf = await intro('buddy ports:check')
109
-
110
- const projects = await findStacksProjects(undefined, { quiet: true })
111
-
112
- log.debug('Running `buddy ports`')
113
- log.debug(`Found ${projects.length} projects`)
114
- log.debug('Projects:', projects)
115
-
116
- // need to loop over the projects and then trigger `buddy ports` for each project (which returns a list of ports)
117
- const projectsPorts: { [project: string]: Ports } = {}
118
- for (const project of projects) projectsPorts[project] = await getPortsForProjectPath(project, options)
119
-
120
- log.info('ProjectsPorts:', projectsPorts)
121
-
122
- if (!options.quiet)
123
- await outro('Exited', { startTime: perf, useSeconds: false })
124
-
125
- process.exit(ExitCode.Success)
126
- })
127
-
128
- buddy.on('ports:*', () => {
129
- console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
130
- process.exit(1)
131
- })
132
- }
133
-
134
- async function getPortsForProjectPath(path: string, options: PortsOptions) {
135
- if (!options.quiet)
136
- log.info(`Checking ports for project: ${italic(path)}`)
137
-
138
- $.cwd(path)
139
- // load the .env file for the project
140
- $.env(await import(`${path}/.env`))
141
-
142
- const projectList = await $`./buddy projects:list --quiet`.text()
143
- log.debug('ProjectListResponse', projectList)
144
-
145
- // get the list of all Stacks project paths (on the system)
146
- const projects = projectList
147
- .split('\n')
148
- .filter(line => line.startsWith(' - '))
149
- .map(line => line.trim().substring(4))
150
- log.debug('Projects:', projects)
151
-
152
- // since we are targeting a specific project, find its path
153
- const ppath = options.project ?? p.projectPath()
154
- let projectPath = projects.find(project => project.includes(ppath))
155
-
156
- log.debug(`Checking ports for project: ${projectPath}`)
157
- if (projectPath === '' || !projectPath)
158
- // default to the current project
159
- projectPath = p.projectPath()
160
-
161
- log.debug(`$ Running: ./buddy ports:list --quiet via ${projectPath}`)
162
- const response = await $`./buddy ports:list --quiet`.json()
163
-
164
- log.debug(`Response for ./buddy ports:list --quiet via ${projectPath}`, response)
165
-
166
- // Step 1: Add double quotes around keys
167
- let validJsonString = response.replace(/(\w+)(?=\s*:)/g, '"$1"')
168
-
169
- // Step 2: Remove potential trailing commas before closing braces
170
- validJsonString = validJsonString.replace(/,(\s*\})/g, '$1')
171
-
172
- // Now we can parse it into an object
173
- const ports = JSON.parse(validJsonString) as Ports
174
-
175
- log.debug(`Ports for ${projectPath}`, ports)
176
-
177
- return ports
178
- }
179
-
180
- function outputPorts(ports: Ports, options: PortsOptions) {
181
- if (!options.quiet)
182
- console.log('')
183
-
184
- console.log(ports)
185
-
186
- if (!options.quiet)
187
- console.log('')
188
- }
@@ -1,28 +0,0 @@
1
- import type { CLI, PrepublishOptions } from '@stacksjs/types'
2
- import process from 'node:process'
3
- import { runAction } from '@stacksjs/actions'
4
- import { Action } from '@stacksjs/enums'
5
- import { log } from '@stacksjs/logging'
6
-
7
- export function prepublish(buddy: CLI): void {
8
- const descriptions = {
9
- command: 'Run your prepublish script',
10
- project: 'Target a specific project',
11
- verbose: 'Enable verbose output',
12
- }
13
-
14
- buddy
15
- .command('prepublish', descriptions.command)
16
- .option('-p, --project [project]', descriptions.project, { default: false })
17
- .option('--verbose', descriptions.verbose, { default: false })
18
- .action(async (options: PrepublishOptions) => {
19
- log.debug('Running `buddy prepublish` ...', options)
20
-
21
- await runAction(Action.Prepublish, options)
22
- })
23
-
24
- buddy.on('prepublish:*', () => {
25
- console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
26
- process.exit(1)
27
- })
28
- }
@@ -1,54 +0,0 @@
1
- import type { CLI, ProjectsOptions } from '@stacksjs/types'
2
- import process from 'node:process'
3
- import { intro, log } from '@stacksjs/cli'
4
- import { ExitCode } from '@stacksjs/types'
5
- import { findStacksProjects } from '@stacksjs/utils'
6
-
7
- export function projects(buddy: CLI): void {
8
- const descriptions = {
9
- projects: 'Find all Stacks projects on your system',
10
- verbose: 'Enable verbose output',
11
- }
12
-
13
- buddy
14
- .command('projects', descriptions.projects)
15
- .option('-q, --quiet', 'Use minimal output', { default: false })
16
- .option('-l, --list', 'List all local Stacks projects', { default: false })
17
- .option('--verbose', descriptions.verbose, { default: false })
18
- .action(async (options: ProjectsOptions) => {
19
- log.debug('Running `buddy projects` ...', options)
20
-
21
- if (!options.quiet)
22
- await intro('buddy projects')
23
-
24
- const projects = await findStacksProjects(undefined, options)
25
-
26
- for (const project of projects) console.log(' - ', project)
27
-
28
- process.exit(ExitCode.Success)
29
- })
30
-
31
- buddy
32
- .command('projects:list', descriptions.projects)
33
- .option('-q, --quiet', 'Use minimal output', { default: false })
34
- .option('-l, --list', 'List all local Stacks projects', { default: true })
35
- .option('--verbose', descriptions.verbose, { default: false })
36
- .action(async (options: ProjectsOptions) => {
37
- log.debug('Running `buddy projects` ...', options)
38
-
39
- if (!options.quiet)
40
- await intro('buddy projects:list')
41
-
42
- // uses os.homedir() as the default path
43
- const projects = await findStacksProjects(undefined, options)
44
-
45
- for (const project of projects) console.log(' - ', project)
46
-
47
- process.exit(ExitCode.Success)
48
- })
49
-
50
- buddy.on('projects:*', () => {
51
- console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
52
- process.exit(1)
53
- })
54
- }
@@ -1,47 +0,0 @@
1
- import type { CLI, ReleaseOptions } from '@stacksjs/types'
2
- import process from 'node:process'
3
- import { runAction } from '@stacksjs/actions'
4
- import { intro, italic, log, outro } from '@stacksjs/cli'
5
- import { Action } from '@stacksjs/enums'
6
- import { ExitCode } from '@stacksjs/types'
7
-
8
- const descriptions = {
9
- release: 'Release a new version of your libraries/packages',
10
- project: 'Target a specific project',
11
- dryRun: 'Run the release without actually releasing',
12
- verbose: 'Enable verbose output',
13
- }
14
-
15
- export function release(buddy: CLI): void {
16
- buddy
17
- .command('release', descriptions.release)
18
- .option('--dry-run', descriptions.dryRun, { default: false })
19
- .option('-p, --project [project]', descriptions.project, { default: false })
20
- .option('--verbose', descriptions.verbose, { default: false })
21
- .action(async (options: ReleaseOptions) => {
22
- log.debug('Running `buddy release` ...', options)
23
-
24
- if (options.dryRun)
25
- log.warn('Dry run enabled. No changes will be made or committed.')
26
-
27
- const startTime = await intro('buddy release')
28
- const result = await runAction(Action.Release, options)
29
-
30
- if (result.isErr()) {
31
- log.error('Failed to release', result.error)
32
- process.exit(ExitCode.FatalError)
33
- }
34
-
35
- await outro('Triggered CI/CD Release via GitHub Actions', {
36
- startTime,
37
- useSeconds: true,
38
- })
39
-
40
- log.info(`Follow along: ${italic('https://github.com/stacksjs/stacks/actions')}`)
41
- })
42
-
43
- buddy.on('release:*', () => {
44
- console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
45
- process.exit(1)
46
- })
47
- }
@@ -1,39 +0,0 @@
1
- import type { CLI, MigrateOptions } from '@stacksjs/types'
2
- import process from 'node:process'
3
- import { runAction } from '@stacksjs/actions'
4
- import { intro, outro } from '@stacksjs/cli'
5
- import { Action } from '@stacksjs/enums'
6
- import { ExitCode } from '@stacksjs/types'
7
-
8
- export function route(buddy: CLI): void {
9
- const descriptions = {
10
- route: 'Lists your routes',
11
- verbose: 'Enable verbose output',
12
- }
13
-
14
- buddy
15
- .command('route:list', descriptions.route)
16
- .option('--verbose', descriptions.verbose, { default: false })
17
- .action(async (options: MigrateOptions) => {
18
- const perf = await intro('buddy route:list')
19
- const result = await runAction(Action.RouteList, options)
20
-
21
- if (result.isErr()) {
22
- await outro(
23
- 'While running the migrate command, there was an issue',
24
- { startTime: perf, useSeconds: true },
25
- result.error,
26
- )
27
- process.exit()
28
- }
29
-
30
- await outro(`Successfully listed routes`)
31
-
32
- process.exit(ExitCode.Success)
33
- })
34
-
35
- buddy.on('route:*', () => {
36
- console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
37
- process.exit(1)
38
- })
39
- }
@@ -1,47 +0,0 @@
1
- import type { CLI, SeedOptions } from '@stacksjs/types'
2
- import process from 'node:process'
3
- import { runAction } from '@stacksjs/actions'
4
- import { intro, log, outro } from '@stacksjs/cli'
5
- import { Action } from '@stacksjs/enums'
6
- import { ExitCode } from '@stacksjs/types'
7
-
8
- export function seed(buddy: CLI): void {
9
- const descriptions = {
10
- seed: 'Seed your database',
11
- project: 'Target a specific project',
12
- verbose: 'Enable verbose output',
13
- }
14
-
15
- buddy
16
- .command('seed', descriptions.seed)
17
- .option('-p, --project [project]', descriptions.project, { default: false })
18
- .option('--verbose', descriptions.verbose, { default: false })
19
- .action(async (options: SeedOptions) => {
20
- log.debug('Running `buddy seed` ...', options)
21
-
22
- const perf = await intro('buddy seed')
23
- const result = await runAction(Action.Seed, options)
24
-
25
- if (result.isErr()) {
26
- await outro(
27
- 'While running the seed command, there was an issue',
28
- { startTime: perf, useSeconds: true },
29
- result.error,
30
- )
31
- process.exit(ExitCode.FatalError)
32
- }
33
-
34
- const APP_ENV = process.env.APP_ENV || 'local'
35
-
36
- await outro(`Seeded your ${APP_ENV} database.`, {
37
- startTime: perf,
38
- useSeconds: true,
39
- })
40
- process.exit(ExitCode.Success)
41
- })
42
-
43
- buddy.on('seed:*', () => {
44
- console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
45
- process.exit(1)
46
- })
47
- }
@@ -1,145 +0,0 @@
1
- import type { CLI, CliOptions } from '@stacksjs/types'
2
- import process from 'node:process'
3
- import { runAction } from '@stacksjs/actions'
4
- import { log, runCommand } from '@stacksjs/cli'
5
- import { Action } from '@stacksjs/enums'
6
- import { handleError } from '@stacksjs/error-handling'
7
- import { path as p } from '@stacksjs/path'
8
- import { storage } from '@stacksjs/storage'
9
- import { ExitCode } from '@stacksjs/types'
10
-
11
- export function setup(buddy: CLI): void {
12
- const descriptions = {
13
- setup: 'This command ensures your project is setup correctly',
14
- ohMyZsh: 'Enable Oh My Zsh',
15
- aws: 'Ensures AWS is connected to the project',
16
- project: 'Target a specific project',
17
- verbose: 'Enable verbose output',
18
- }
19
-
20
- buddy
21
- .command('setup', descriptions.setup)
22
- .alias('ensure')
23
- .option('-p, --project [project]', descriptions.project, { default: false })
24
- .option('--verbose', descriptions.verbose, { default: false })
25
- .action(async (options: CliOptions) => {
26
- log.debug('Running `buddy setup` ...', options)
27
-
28
- if (!(await isPkgxInstalled()))
29
- await installPkgx()
30
-
31
- // ensure the minimal amount of deps are written to ./pkgx.yaml
32
- await optimizePkgxDeps()
33
-
34
- // TODO: optimizeConfigDir()
35
- // TODO: optimizeAddDir()
36
-
37
- await initializeProject(options)
38
- })
39
-
40
- buddy
41
- .command('setup:oh-my-zsh', descriptions.ohMyZsh) // if triggered multiple times, it will update the plugin
42
- .alias('upgrade:oh-my-zsh')
43
- .option('--verbose', descriptions.verbose, { default: false })
44
- .action(async (_options?: CliOptions) => {
45
- log.debug('Running `buddy setup:oh-my-zsh` ...', _options)
46
- const result = await runAction(Action.UpgradeShell)
47
-
48
- if (result.isErr()) {
49
- log.error(result.error)
50
- process.exit(ExitCode.FatalError)
51
- }
52
- })
53
-
54
- buddy.on('setup:*', () => {
55
- console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
56
- process.exit(ExitCode.FatalError)
57
- })
58
- }
59
-
60
- async function isPkgxInstalled(): Promise<boolean> {
61
- const result = await runCommand('pkgx --version', { silent: true })
62
-
63
- if (result.isOk())
64
- return true
65
-
66
- return false
67
- }
68
-
69
- async function installPkgx(): Promise<void> {
70
- const result = await runCommand(p.frameworkPath('scripts/pkgx-install'))
71
-
72
- if (result.isOk())
73
- return
74
-
75
- handleError(result.error)
76
- process.exit(ExitCode.FatalError)
77
- }
78
-
79
- async function initializeProject(options: CliOptions): Promise<void> {
80
- log.info('Installing dependencies...')
81
-
82
- const result = await runCommand('bun install', {
83
- cwd: options.cwd || p.projectPath(),
84
- })
85
-
86
- if (result.isErr()) {
87
- handleError(result.error)
88
- process.exit(ExitCode.FatalError)
89
- }
90
-
91
- log.success('Installed node_modules')
92
-
93
- ensureEnvIsSet(options)
94
-
95
- const keyResult = await runCommand('buddy key:generate', {
96
- cwd: options.cwd || p.projectPath(),
97
- })
98
-
99
- if (keyResult.isErr()) {
100
- handleError(keyResult.error)
101
- process.exit(ExitCode.FatalError)
102
- }
103
-
104
- log.info('Ensuring AWS is connected...')
105
-
106
- const awsResult = await runCommand('buddy configure:aws', {
107
- cwd: options.cwd || p.projectPath(),
108
- })
109
-
110
- if (awsResult.isErr()) {
111
- handleError(awsResult.error)
112
- process.exit(ExitCode.FatalError)
113
- }
114
-
115
- log.success('Configured AWS')
116
-
117
- // TODO: ensure the IDE is setup by making sure .vscode etc exists, and if not, copy them over
118
-
119
- log.success('Project is setup')
120
- log.info('Happy coding! 💙')
121
- }
122
-
123
- export async function optimizePkgxDeps(): Promise<void> {
124
- return new Promise(resolve => setTimeout(resolve, 300))
125
- }
126
-
127
- export async function ensureEnvIsSet(options: CliOptions): Promise<void> {
128
- log.info('Ensuring .env exists...')
129
-
130
- if (storage.doesNotExist(p.projectPath('.env'))) {
131
- const envResult = await runCommand('cp .env.example .env', {
132
- cwd: options.cwd || p.projectPath(),
133
- })
134
-
135
- if (envResult.isErr()) {
136
- handleError(envResult.error)
137
- process.exit(ExitCode.FatalError)
138
- }
139
-
140
- log.success('.env created')
141
- }
142
- else {
143
- log.success('.env existed')
144
- }
145
- }