studiocms 0.1.0-beta.26 → 0.1.0-beta.27

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 (237) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +2 -0
  3. package/dist/cli/add/index.d.ts +1 -1
  4. package/dist/cli/add/index.js +15 -12
  5. package/dist/cli/add/tryToInstallPlugins.d.ts +1 -1
  6. package/dist/cli/add/tryToInstallPlugins.js +11 -8
  7. package/dist/cli/add/updateStudioCMSConfig.d.ts +1 -1
  8. package/dist/cli/add/updateStudioCMSConfig.js +4 -4
  9. package/dist/cli/add/validatePlugins.d.ts +1 -1
  10. package/dist/cli/add/validatePlugins.js +10 -10
  11. package/dist/cli/crypto/genJWT/index.js +14 -13
  12. package/dist/cli/getTurso/index.js +6 -8
  13. package/dist/cli/index.js +3 -1
  14. package/dist/cli/init/index.js +54 -57
  15. package/dist/cli/init/steps/env.d.ts +2 -2
  16. package/dist/cli/init/steps/env.js +316 -271
  17. package/dist/cli/init/steps/next.d.ts +2 -1
  18. package/dist/cli/init/steps/next.js +35 -28
  19. package/dist/cli/users/index.d.ts +2 -1
  20. package/dist/cli/users/index.js +83 -80
  21. package/dist/cli/users/steps/libsql/createUsers.d.ts +2 -0
  22. package/dist/cli/users/steps/libsql/createUsers.js +151 -0
  23. package/dist/cli/users/steps/libsql/modifyUsers.d.ts +7 -0
  24. package/dist/cli/users/steps/libsql/modifyUsers.js +205 -0
  25. package/dist/cli/users/steps/next.d.ts +2 -1
  26. package/dist/cli/users/steps/next.js +10 -7
  27. package/dist/cli/utils/checkRequiredEnvVars.d.ts +17 -1
  28. package/dist/cli/utils/checkRequiredEnvVars.js +32 -4
  29. package/dist/cli/utils/context.d.ts +7 -7
  30. package/dist/cli/utils/context.js +23 -16
  31. package/dist/cli/utils/effectBoxen.d.ts +1 -2
  32. package/dist/cli/utils/effectBoxen.js +2 -4
  33. package/dist/cli/utils/intro.js +2 -3
  34. package/dist/cli/utils/logger.d.ts +9 -0
  35. package/dist/cli/utils/logger.js +14 -0
  36. package/dist/cli/utils/types.d.ts +36 -0
  37. package/dist/cli/utils/types.js +11 -0
  38. package/dist/cli/utils/useLibSQLDb.d.ts +20 -262
  39. package/dist/cli/utils/useLibSQLDb.js +22 -17
  40. package/dist/cli/utils/user-utils.d.ts +16 -105
  41. package/dist/cli/utils/user-utils.js +29 -65
  42. package/dist/components/auth/FallbackCanvas.astro +5 -8
  43. package/dist/components/auth/ThreeCanvasLoader.astro +1 -8
  44. package/dist/components/auth/component-scripts/formListener.d.ts +2 -1
  45. package/dist/components/auth/component-scripts/formListener.js +7 -3
  46. package/dist/components/dashboard/content-mgmt/CreatePage.astro +11 -3
  47. package/dist/components/dashboard/content-mgmt/EditPage.astro +1 -1
  48. package/dist/components/dashboard/content-mgmt/PageHeader.astro +1 -1
  49. package/dist/components/shared/Code.astro +6 -2
  50. package/dist/components/shared/SSRUser.astro +2 -0
  51. package/dist/handlers/routeHandler.js +1 -1
  52. package/dist/integrations/dynamic-sitemap/index.d.ts +8 -0
  53. package/dist/integrations/dynamic-sitemap/index.js +4 -1
  54. package/dist/integrations/dynamic-sitemap/sitemap-index.xml.d.ts +20 -0
  55. package/dist/integrations/dynamic-sitemap/sitemap-index.xml.js +2 -1
  56. package/dist/integrations/node-namespace.d.ts +4 -0
  57. package/dist/integrations/node-namespace.js +14 -10
  58. package/dist/integrations/robots/core.d.ts +63 -0
  59. package/dist/integrations/robots/core.js +14 -3
  60. package/dist/integrations/robots/index.js +2 -0
  61. package/dist/integrations/webVitals/utils/webVitalsUtils.js +2 -2
  62. package/dist/integrations/webVitals/webVitalsRouteSummary.d.ts +15 -0
  63. package/dist/integrations/webVitals/webVitalsRouteSummary.js +4 -1
  64. package/dist/layouts/AuthLayout.astro +1 -1
  65. package/dist/middleware/utils.d.ts +5 -3
  66. package/dist/middleware/utils.js +20 -3
  67. package/dist/plugins.d.ts +1 -2
  68. package/dist/routes/api/dashboard/content/page.js +70 -36
  69. package/dist/routes/firstTimeSetupRoutes/2-next.astro +3 -2
  70. package/dist/schemas/config/auth.d.ts +12 -0
  71. package/dist/schemas/config/auth.js +2 -1
  72. package/dist/schemas/config/sdk.d.ts +39 -5
  73. package/dist/schemas/config/sdk.js +7 -1
  74. package/dist/schemas/plugins/index.d.ts +2508 -0
  75. package/dist/test-utils.d.ts +105 -0
  76. package/dist/test-utils.js +167 -0
  77. package/dist/utils/effects/index.d.ts +1 -1
  78. package/dist/utils/effects/index.js +1 -2
  79. package/dist/utils/effects/logger.d.ts +6 -17
  80. package/dist/utils/effects/logger.js +4 -9
  81. package/dist/virtuals/auth/verify-email.d.ts +3 -3
  82. package/dist/virtuals/components/CustomImage.astro +4 -0
  83. package/dist/virtuals/components/FormattedDate.astro +3 -2
  84. package/dist/virtuals/components/Renderer.astro +4 -0
  85. package/dist/virtuals/i18n/client.js +2 -0
  86. package/dist/virtuals/i18n/server.js +8 -2
  87. package/dist/virtuals/mailer/index.d.ts +2 -2
  88. package/dist/virtuals/mailer/template.d.ts +1 -1
  89. package/dist/virtuals/mailer/template.js +2 -1
  90. package/dist/virtuals/mailer/templates/password-reset.js +2 -4
  91. package/dist/virtuals/mailer/templates/verify-email.js +1 -2
  92. package/dist/virtuals/notifier/client.d.ts +1 -2
  93. package/dist/virtuals/notifier/client.js +2 -1
  94. package/dist/virtuals/scripts/user-quick-tools.d.ts +16 -16
  95. package/dist/virtuals/scripts/user-quick-tools.js +19 -0
  96. package/dist/virtuals/sdk/consts.d.ts +11 -0
  97. package/dist/virtuals/sdk/consts.js +2 -0
  98. package/dist/virtuals/sdk/effect/collectors.d.ts +15 -2
  99. package/dist/virtuals/sdk/effect/collectors.js +5 -23
  100. package/dist/virtuals/sdk/effect/db.d.ts +5 -88
  101. package/dist/virtuals/sdk/effect/db.js +6 -98
  102. package/dist/virtuals/sdk/effect/foldertree.d.ts +3 -3
  103. package/dist/virtuals/sdk/effect/generators.js +24 -12
  104. package/dist/virtuals/sdk/effect/lib/jwt-generator.d.ts +23 -0
  105. package/dist/virtuals/sdk/effect/lib/jwt-generator.js +2 -0
  106. package/dist/virtuals/sdk/effect/users.js +2 -2
  107. package/dist/virtuals/sdk/index.d.ts +17 -4
  108. package/dist/virtuals/sdk/modules/auth.js +17 -17
  109. package/dist/virtuals/sdk/modules/config-types.d.ts +141 -0
  110. package/dist/virtuals/sdk/modules/config-types.js +0 -0
  111. package/dist/virtuals/sdk/modules/config.d.ts +13 -163
  112. package/dist/virtuals/sdk/modules/config.js +1 -2
  113. package/dist/virtuals/sdk/modules/delete.js +9 -9
  114. package/dist/virtuals/sdk/modules/diffTracking.js +9 -9
  115. package/dist/virtuals/sdk/modules/get.d.ts +12 -12
  116. package/dist/virtuals/sdk/modules/get.js +16 -16
  117. package/dist/virtuals/sdk/modules/init.d.ts +1 -1
  118. package/dist/virtuals/sdk/modules/init.js +1 -1
  119. package/dist/virtuals/sdk/modules/notificationSettings.d.ts +2 -2
  120. package/dist/virtuals/sdk/modules/notificationSettings.js +1 -1
  121. package/dist/virtuals/sdk/modules/plugins.d.ts +9 -9
  122. package/dist/virtuals/sdk/modules/post.js +10 -10
  123. package/dist/virtuals/sdk/modules/resetTokenBucket.js +3 -3
  124. package/dist/virtuals/sdk/modules/rest_api.js +4 -4
  125. package/dist/virtuals/sdk/modules/update.d.ts +1 -1
  126. package/dist/virtuals/sdk/modules/update.js +10 -14
  127. package/dist/virtuals/sdk/sdkCore.d.ts +17 -4
  128. package/dist/virtuals/sdk/types/index.d.ts +1 -1
  129. package/package.json +20 -17
  130. package/src/cli/add/index.ts +15 -13
  131. package/src/cli/add/tryToInstallPlugins.ts +14 -9
  132. package/src/cli/add/updateStudioCMSConfig.ts +4 -4
  133. package/src/cli/add/validatePlugins.ts +10 -10
  134. package/src/cli/crypto/genJWT/index.ts +14 -13
  135. package/src/cli/getTurso/index.ts +7 -9
  136. package/src/cli/index.ts +4 -1
  137. package/src/cli/init/index.ts +86 -97
  138. package/src/cli/init/steps/env.ts +361 -303
  139. package/src/cli/init/steps/next.ts +40 -36
  140. package/src/cli/users/index.ts +116 -109
  141. package/src/cli/users/steps/libsql/createUsers.ts +169 -0
  142. package/src/cli/users/steps/libsql/modifyUsers.ts +229 -0
  143. package/src/cli/users/steps/next.ts +10 -8
  144. package/src/cli/utils/checkRequiredEnvVars.ts +53 -3
  145. package/src/cli/utils/context.ts +28 -20
  146. package/src/cli/utils/effectBoxen.ts +2 -4
  147. package/src/cli/utils/intro.ts +2 -3
  148. package/src/cli/utils/logger.ts +21 -0
  149. package/src/cli/utils/types.ts +50 -0
  150. package/src/cli/utils/useLibSQLDb.ts +35 -17
  151. package/src/cli/utils/user-utils.ts +42 -155
  152. package/src/components/auth/FallbackCanvas.astro +5 -8
  153. package/src/components/auth/ThreeCanvasLoader.astro +1 -8
  154. package/src/components/auth/component-scripts/formListener.ts +14 -3
  155. package/src/components/dashboard/content-mgmt/CreatePage.astro +11 -3
  156. package/src/components/dashboard/content-mgmt/EditPage.astro +1 -1
  157. package/src/components/dashboard/content-mgmt/PageHeader.astro +1 -1
  158. package/src/components/shared/Code.astro +6 -2
  159. package/src/components/shared/SSRUser.astro +2 -0
  160. package/src/consts.ts +2 -0
  161. package/src/effect.ts +2 -0
  162. package/src/handlers/routeHandler.ts +1 -1
  163. package/src/integrations/dynamic-sitemap/index.ts +3 -1
  164. package/src/integrations/dynamic-sitemap/sitemap-index.xml.ts +1 -1
  165. package/src/integrations/node-namespace.ts +14 -10
  166. package/src/integrations/plugins.ts +2 -0
  167. package/src/integrations/robots/core.ts +9 -7
  168. package/src/integrations/robots/index.ts +2 -0
  169. package/src/integrations/webVitals/checkForWebVitalsPlugin.ts +8 -0
  170. package/src/integrations/webVitals/consts.ts +8 -0
  171. package/src/integrations/webVitals/utils/buildPageRouteDataObject.ts +2 -0
  172. package/src/integrations/webVitals/utils/buildPerPageDataObject.ts +4 -0
  173. package/src/integrations/webVitals/utils/webVitalsUtils.ts +8 -2
  174. package/src/integrations/webVitals/webVital.ts +9 -0
  175. package/src/integrations/webVitals/webVitalsRouteSummary.ts +3 -3
  176. package/src/layouts/AuthLayout.astro +1 -1
  177. package/src/middleware/index.ts +13 -0
  178. package/src/middleware/utils.ts +22 -5
  179. package/src/plugins.ts +4 -11
  180. package/src/routes/api/dashboard/content/page.ts +99 -37
  181. package/src/routes/firstTimeSetupRoutes/2-next.astro +3 -2
  182. package/src/schemas/config/auth.ts +1 -1
  183. package/src/schemas/config/sdk.ts +8 -6
  184. package/src/schemas/index.ts +2 -0
  185. package/src/schemas/plugins/index.ts +7 -0
  186. package/src/test-utils.ts +229 -0
  187. package/src/utils/effects/index.ts +1 -1
  188. package/src/utils/effects/logger.ts +7 -36
  189. package/src/utils/effects/smtp.ts +6 -0
  190. package/src/utils/safeString.ts +4 -0
  191. package/src/virtuals/components/CustomImage.astro +4 -0
  192. package/src/virtuals/components/FormattedDate.astro +3 -2
  193. package/src/virtuals/components/Renderer.astro +4 -0
  194. package/src/virtuals/i18n/client.ts +2 -0
  195. package/src/virtuals/i18n/server.ts +6 -4
  196. package/src/virtuals/lib/head.ts +3 -0
  197. package/src/virtuals/lib/urlGen.ts +3 -0
  198. package/src/virtuals/mailer/template.ts +1 -1
  199. package/src/virtuals/mailer/templates/password-reset.ts +2 -4
  200. package/src/virtuals/mailer/templates/verify-email.ts +1 -2
  201. package/src/virtuals/notifier/client.ts +1 -1
  202. package/src/virtuals/scripts/user-quick-tools.ts +42 -18
  203. package/src/virtuals/sdk/consts.ts +12 -0
  204. package/src/virtuals/sdk/effect/collectors.ts +7 -31
  205. package/src/virtuals/sdk/effect/db.ts +7 -249
  206. package/src/virtuals/sdk/effect/foldertree.ts +12 -17
  207. package/src/virtuals/sdk/effect/generators.ts +6 -0
  208. package/src/virtuals/sdk/effect/getVersionFromNPM.ts +3 -0
  209. package/src/virtuals/sdk/effect/lib/jwt-generator.ts +2 -2
  210. package/src/virtuals/sdk/effect/users.ts +2 -2
  211. package/src/virtuals/sdk/modules/auth.ts +17 -17
  212. package/src/virtuals/sdk/modules/config-types.ts +157 -0
  213. package/src/virtuals/sdk/modules/config.ts +35 -169
  214. package/src/virtuals/sdk/modules/delete.ts +9 -18
  215. package/src/virtuals/sdk/modules/diffTracking.ts +9 -9
  216. package/src/virtuals/sdk/modules/get.ts +16 -32
  217. package/src/virtuals/sdk/modules/init.ts +1 -1
  218. package/src/virtuals/sdk/modules/notificationSettings.ts +1 -1
  219. package/src/virtuals/sdk/modules/plugins.ts +8 -12
  220. package/src/virtuals/sdk/modules/post.ts +10 -15
  221. package/src/virtuals/sdk/modules/resetTokenBucket.ts +3 -3
  222. package/src/virtuals/sdk/modules/rest_api.ts +4 -8
  223. package/src/virtuals/sdk/modules/update.ts +10 -24
  224. package/src/virtuals/sdk/tables.ts +2 -0
  225. package/src/virtuals/sdk/types/index.ts +1 -1
  226. package/dist/cli/users/steps/libsqlCreateUsers.d.ts +0 -2
  227. package/dist/cli/users/steps/libsqlCreateUsers.js +0 -163
  228. package/dist/cli/users/steps/libsqlModifyUsers.d.ts +0 -7
  229. package/dist/cli/users/steps/libsqlModifyUsers.js +0 -221
  230. package/dist/cli/utils/createUserAvatar.d.ts +0 -10
  231. package/dist/cli/utils/createUserAvatar.js +0 -11
  232. package/src/cli/users/steps/libsqlCreateUsers.ts +0 -200
  233. package/src/cli/users/steps/libsqlModifyUsers.ts +0 -271
  234. package/src/cli/utils/createUserAvatar.ts +0 -23
  235. /package/dist/routes/api/mailer/{test-email.d.ts → check-email.d.ts} +0 -0
  236. /package/dist/routes/api/mailer/{test-email.js → check-email.js} +0 -0
  237. /package/src/routes/api/mailer/{test-email.ts → check-email.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # studiocms
2
2
 
3
+ ## 0.1.0-beta.27
4
+
5
+ ### Patch Changes
6
+
7
+ - [#807](https://github.com/withstudiocms/studiocms/pull/807) [`6833a1d`](https://github.com/withstudiocms/studiocms/commit/6833a1dd46b34914c087dc57cffc28950d038911) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Enable the "Draft" toggle on the Edit Page for all pages (including the `index` page) so the `draft` field is submitted with the form. Previously the disabled control omitted this field from the payload, preventing changes to draft status.
8
+
9
+ - [#852](https://github.com/withstudiocms/studiocms/pull/852) [`ce2f95c`](https://github.com/withstudiocms/studiocms/commit/ce2f95c4c78778cdb0ce867012de05c8f1e3dc67) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - fix: Ensure slug is not an empty string, or an invalid slug.
10
+
11
+ - [#804](https://github.com/withstudiocms/studiocms/pull/804) [`82cd1bf`](https://github.com/withstudiocms/studiocms/commit/82cd1bfd1a442015c266df733988f29fdaafaaf4) Thanks [@renovate](https://github.com/apps/renovate)! - fix(deps): update dependency @iconify-json/simple-icons to ^1.2.51
12
+
13
+ - [#810](https://github.com/withstudiocms/studiocms/pull/810) [`3d4c4ea`](https://github.com/withstudiocms/studiocms/commit/3d4c4eae4b425db1f0dde5712177faa68d3c9712) Thanks [@renovate](https://github.com/apps/renovate)! - fix(deps): update dependency @iconify-json/simple-icons to ^1.2.52
14
+
15
+ - [#841](https://github.com/withstudiocms/studiocms/pull/841) [`c661a9f`](https://github.com/withstudiocms/studiocms/commit/c661a9f7f4deb1f1ec695bbb8702c5d570dc4c20) Thanks [@renovate](https://github.com/apps/renovate)! - fix(deps): update dependency dompurify to ^3.2.7
16
+
17
+ - [#813](https://github.com/withstudiocms/studiocms/pull/813) [`e1f531f`](https://github.com/withstudiocms/studiocms/commit/e1f531f7bd3705a988fe67205ce6bd2665d7d33d) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Create new test export for helping aid in CI testing
18
+
19
+ - [#772](https://github.com/withstudiocms/studiocms/pull/772) [`ecc664c`](https://github.com/withstudiocms/studiocms/commit/ecc664cbb560f03db2078dc8d23135f9e966a7d4) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Deduplicate CLI utilities and unify avatar URL generation (Libravatar)
20
+
21
+ - [#809](https://github.com/withstudiocms/studiocms/pull/809) [`15854f2`](https://github.com/withstudiocms/studiocms/commit/15854f2bf620d3ea83da5af6a1651b31e9c433f6) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Integrate new effect helper for drizzle libsql db client
22
+
23
+ - [#774](https://github.com/withstudiocms/studiocms/pull/774) [`3b59fcf`](https://github.com/withstudiocms/studiocms/commit/3b59fcf7885d5c4952bd30279fa8ea2e2f0f5eaa) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Refactor CLI to utilize new Effect-ful clack module from `@withstudiocms/effect`
24
+
25
+ - [#770](https://github.com/withstudiocms/studiocms/pull/770) [`67d8973`](https://github.com/withstudiocms/studiocms/commit/67d8973cd703f6d3a5c50e31d3f051ef8f938548) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Migrate CLI to new authkit package
26
+
27
+ - [#781](https://github.com/withstudiocms/studiocms/pull/781) [`1848b0c`](https://github.com/withstudiocms/studiocms/commit/1848b0ce4d8bbb908a3207079fbbeeda446e3cb7) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Cleans CLI to utilize fully Effect-TS based code instead of raw JS/TS, allowing better error handling and code maintainability.
28
+
29
+ - [#823](https://github.com/withstudiocms/studiocms/pull/823) [`6c65ddb`](https://github.com/withstudiocms/studiocms/commit/6c65ddb94a15997801ebee43ac90d3f380248a86) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Setup initial testing for StudioCMS
30
+
31
+ - [#785](https://github.com/withstudiocms/studiocms/pull/785) [`c86f4f4`](https://github.com/withstudiocms/studiocms/commit/c86f4f4ab0873c29246582a8dbcab645057d146c) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - rename internal file to avoid confusion with tests during dev
32
+
33
+ - [#789](https://github.com/withstudiocms/studiocms/pull/789) [`5713f15`](https://github.com/withstudiocms/studiocms/commit/5713f154eb15aad8d2c2c8a5a5c13611ff03dee8) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Correct parameter in CLI add command.
34
+
35
+ - Updated dependencies [[`71d8948`](https://github.com/withstudiocms/studiocms/commit/71d894899a417e3a249c5f47e527223ade38b4fc), [`9d3784c`](https://github.com/withstudiocms/studiocms/commit/9d3784c1de98a4bc7bb913742c3977e16c87cc1b), [`726e07a`](https://github.com/withstudiocms/studiocms/commit/726e07a458fff9e50d4c02b80e0312f52f05e730), [`bf15ff6`](https://github.com/withstudiocms/studiocms/commit/bf15ff65a5f4ba6c2e4cd616d3c45ba0da784a1a), [`627119b`](https://github.com/withstudiocms/studiocms/commit/627119bfde88e9c2ea74a29817d91fb6afbab33d), [`3b59fcf`](https://github.com/withstudiocms/studiocms/commit/3b59fcf7885d5c4952bd30279fa8ea2e2f0f5eaa), [`3d3612d`](https://github.com/withstudiocms/studiocms/commit/3d3612d510f4827acfb4de364d39e835a693818f), [`c2c2b73`](https://github.com/withstudiocms/studiocms/commit/c2c2b73a71009769e38ea4b30ae4010f6f0fdd14), [`67d8973`](https://github.com/withstudiocms/studiocms/commit/67d8973cd703f6d3a5c50e31d3f051ef8f938548), [`47a2fed`](https://github.com/withstudiocms/studiocms/commit/47a2fedd8ed1c751def929058772ea78532e8d7d), [`c478f2d`](https://github.com/withstudiocms/studiocms/commit/c478f2dba7fb5cc923e0dbf0367fa2a050fcdc2d), [`fbb9ad1`](https://github.com/withstudiocms/studiocms/commit/fbb9ad10555f26c8e6261cd71a7650ab4aeb64f9), [`faf2a70`](https://github.com/withstudiocms/studiocms/commit/faf2a70ae57d136a9ccbbdebad70897e42c14c64), [`55885eb`](https://github.com/withstudiocms/studiocms/commit/55885eba617d8ec790e68ed0985f8530628140d8), [`0e8e280`](https://github.com/withstudiocms/studiocms/commit/0e8e280c4a2a7552d3b78b370600019e49f5a459), [`9b85861`](https://github.com/withstudiocms/studiocms/commit/9b85861b20ca9eb2aa2c434b225ff85399bb04f0)]:
36
+ - @withstudiocms/auth-kit@0.1.0-beta.2
37
+ - @withstudiocms/component-registry@0.1.0-beta.3
38
+ - @withstudiocms/internal_helpers@0.1.0-beta.2
39
+ - @withstudiocms/config-utils@0.1.0-beta.4
40
+ - @withstudiocms/effect@0.1.0-beta.3
41
+
3
42
  ## 0.1.0-beta.26
4
43
 
5
44
  ### Patch Changes
package/README.md CHANGED
@@ -4,6 +4,8 @@ StudioCMS is a dedicated Astro native content management system (CMS) built on t
4
4
 
5
5
  > [!IMPORTANT]
6
6
  > This project is still in early development and it is not yet ready for production use. If you encounter any issues or have ideas for new features, please let us know by [opening an issue](https://github.com/withstudiocms/studiocms/issues/new/choose) on our GitHub repository.
7
+ >
8
+ > During our `0.1.0-beta.x` phase, breaking changes may ship in patch releases.
7
9
 
8
10
  ## Sponsor
9
11
 
@@ -21,6 +21,6 @@ export declare const createPrettyError: (err: Error) => Effect.Effect<Error, nev
21
21
  export declare const resolveConfigPath: (root: URL) => Effect.Effect<URL | undefined, import("effect/Cause").UnknownException, never>;
22
22
  export declare function appendForwardSlash(path: string): string;
23
23
  export declare const plugin: Cli.Args.Args<string[]>;
24
- export declare const addPlugin: Cli.Command.Command<"add", never, import("astro/errors").AstroError | import("effect/Cause").UnknownException | Effect.Effect<Error, never, never>, {
24
+ export declare const addPlugin: Cli.Command.Command<"add", never, Error | Effect.Effect<Error, never, never>, {
25
25
  readonly plugin: string[];
26
26
  }>;
@@ -2,6 +2,7 @@ import { existsSync, promises as fs } from "node:fs";
2
2
  import { fileURLToPath } from "node:url";
3
3
  import { cancelled, success } from "@withstudiocms/cli-kit/messages";
4
4
  import { exists, pathToFileURL, resolveRoot } from "@withstudiocms/cli-kit/utils";
5
+ import { intro, note, outro } from "@withstudiocms/effect/clack";
5
6
  import { builders, loadFile } from "magicast";
6
7
  import { getDefaultExportOptions } from "magicast/helpers";
7
8
  import { Cli, Console, Effect, genLogger, Layer } from "../../effect.js";
@@ -129,12 +130,14 @@ const addPlugin = Cli.Command.make(
129
130
  plugin
130
131
  },
131
132
  ({ plugin: plugin2 }) => Effect.gen(function* () {
132
- const validator = yield* ValidatePlugins;
133
- const installer = yield* TryToInstallPlugins;
134
- const updater = yield* UpdateStudioCMSConfig;
135
- const context = yield* genContext;
136
- const { cwd, prompts, chalk } = context;
137
- prompts.intro("StudioCMS CLI Utilities (add)");
133
+ const [validator, installer, updater, context] = yield* Effect.all([
134
+ ValidatePlugins,
135
+ TryToInstallPlugins,
136
+ UpdateStudioCMSConfig,
137
+ genContext
138
+ ]);
139
+ const { cwd, chalk } = context;
140
+ yield* intro("StudioCMS CLI Utilities (add)");
138
141
  const pluginNames = plugin2.map((name) => {
139
142
  const aliasName = ALIASES.get(name);
140
143
  if (!aliasName) return name;
@@ -150,7 +153,7 @@ const addPlugin = Cli.Command.make(
150
153
  break;
151
154
  }
152
155
  case 2 /* cancelled */: {
153
- prompts.note(
156
+ yield* note(
154
157
  cancelled(
155
158
  `Dependencies ${chalk.bold("NOT")} installed.`,
156
159
  "Be sure to install them manually before continuing!"
@@ -164,7 +167,7 @@ const addPlugin = Cli.Command.make(
164
167
  case 0 /* none */:
165
168
  break;
166
169
  }
167
- const configURL = yield* resolveOrCreateConfig(new URL(rootPath));
170
+ const configURL = yield* resolveOrCreateConfig(root);
168
171
  yield* Console.debug(`found config at ${configURL}`);
169
172
  const mod = yield* loadConfigModule(configURL, validatedPlugins);
170
173
  let configResult;
@@ -179,7 +182,7 @@ const addPlugin = Cli.Command.make(
179
182
  }
180
183
  switch (configResult) {
181
184
  case 2 /* cancelled */: {
182
- prompts.outro(cancelled(`Your configuration has ${chalk.bold("NOT")} been updated.`));
185
+ yield* outro(cancelled(`Your configuration has ${chalk.bold("NOT")} been updated.`));
183
186
  break;
184
187
  }
185
188
  case 0 /* none */: {
@@ -193,11 +196,11 @@ const addPlugin = Cli.Command.make(
193
196
  (plugin3) => !deps.includes(plugin3.packageName)
194
197
  );
195
198
  if (missingDeps.length === 0) {
196
- prompts.outro("Configuration up-to-date.");
199
+ yield* outro("Configuration up-to-date.");
197
200
  break;
198
201
  }
199
202
  }
200
- prompts.outro("Configuration up-to-date.");
203
+ yield* outro("Configuration up-to-date.");
201
204
  break;
202
205
  }
203
206
  // NOTE: failure shouldn't happen in practice because `updateAstroConfig` doesn't return that.
@@ -206,7 +209,7 @@ const addPlugin = Cli.Command.make(
206
209
  case 1 /* updated */:
207
210
  case void 0: {
208
211
  const list = validatedPlugins.map((plugin3) => ` - ${plugin3.pluginName}`).join("\n");
209
- prompts.outro(
212
+ yield* outro(
210
213
  success(
211
214
  `Added the following plugin${validatedPlugins.length === 1 ? "" : "s"} to your project:
212
215
  ${list}`
@@ -3,7 +3,7 @@ import { CliContext } from '../utils/context.js';
3
3
  import { type PluginInfo, UpdateResult } from './index.js';
4
4
  declare const TryToInstallPlugins_base: Effect.Service.Class<TryToInstallPlugins, "TryToInstallPlugins", {
5
5
  readonly effect: Effect.Effect<{
6
- run: (plugins: PluginInfo[]) => Effect.Effect<UpdateResult, import("astro/errors").AstroError | import("effect/Cause").UnknownException, CliContext>;
6
+ run: (plugins: PluginInfo[]) => Effect.Effect<UpdateResult, Error, CliContext>;
7
7
  }, never, never>;
8
8
  }>;
9
9
  export declare class TryToInstallPlugins extends TryToInstallPlugins_base {
@@ -1,5 +1,5 @@
1
- import { askToContinue } from "@withstudiocms/cli-kit/messages";
2
1
  import { exec } from "@withstudiocms/cli-kit/utils";
2
+ import { askToContinue, note, spinner } from "@withstudiocms/effect/clack";
3
3
  import { detect, resolveCommand } from "package-manager-detector";
4
4
  import { Console, Effect, genLogger } from "../../effect.js";
5
5
  import { CliContext } from "../utils/context.js";
@@ -11,7 +11,7 @@ class TryToInstallPlugins extends Effect.Service()(
11
11
  {
12
12
  effect: genLogger("studiocms/cli/add/validatePlugins/TryToInstallPlugins.effect")(function* () {
13
13
  const run = (plugins) => genLogger("studiocms/cli/add/validatePlugins/TryToInstallPlugins.effect.run")(function* () {
14
- const { prompts, chalk, cwd } = yield* CliContext;
14
+ const { chalk, cwd } = yield* CliContext;
15
15
  const packageManager = yield* Effect.tryPromise(
16
16
  () => detect({
17
17
  cwd,
@@ -47,14 +47,14 @@ class TryToInstallPlugins extends Effect.Service()(
47
47
  const message = `
48
48
  ${boxenMessage}
49
49
  `;
50
- prompts.note(
50
+ yield* note(
51
51
  `${chalk.magenta("StudioCMS will run the following command:")}
52
52
  ${chalk.dim("If you skip this step, you can always run it yourself later")}
53
53
  ${message}`
54
54
  );
55
- if (yield* Effect.tryPromise(() => askToContinue(prompts))) {
56
- const spinner = prompts.spinner();
57
- spinner.start("Installing dependencies...");
55
+ if (yield* askToContinue()) {
56
+ const spin = yield* spinner();
57
+ yield* spin.start("Installing dependencies...");
58
58
  const response = yield* Effect.tryPromise({
59
59
  try: async () => {
60
60
  await exec(installCommand.command, [...installCommand.args, ...installSpecifiers], {
@@ -63,13 +63,16 @@ ${message}`
63
63
  env: { NODE_ENV: void 0 }
64
64
  }
65
65
  });
66
- spinner.stop("Dependencies installed.");
67
66
  return UpdateResult.updated;
68
67
  },
69
68
  catch: (err) => err
70
69
  }).pipe(Effect.catchAll((err) => Effect.succeed(err)));
70
+ if (response === UpdateResult.updated) {
71
+ yield* spin.stop("Dependencies installed!");
72
+ return response;
73
+ }
71
74
  if (response instanceof Error || response && typeof response === "object" && "message" in response) {
72
- spinner.stop("Error installing dependencies");
75
+ yield* spin.stop("Error installing dependencies");
73
76
  yield* Console.debug(`[add]: Error installing dependencies ${response}`);
74
77
  yield* Console.error(`
75
78
  ${response.stdout || response.message}
@@ -4,7 +4,7 @@ import { CliContext } from '../utils/context.js';
4
4
  import { UpdateResult } from './index.js';
5
5
  declare const UpdateStudioCMSConfig_base: Effect.Service.Class<UpdateStudioCMSConfig, "UpdateStudioCMSConfig", {
6
6
  readonly effect: Effect.Effect<{
7
- run: (configURL: URL, mod: ProxifiedModule<any>) => Effect.Effect<UpdateResult.none | UpdateResult.updated | UpdateResult.cancelled, import("astro/errors").AstroError | import("effect/Cause").UnknownException, CliContext>;
7
+ run: (configURL: URL, mod: ProxifiedModule<any>) => Effect.Effect<UpdateResult.none | UpdateResult.updated | UpdateResult.cancelled, Error, CliContext>;
8
8
  }, never, never>;
9
9
  }>;
10
10
  export declare class UpdateStudioCMSConfig extends UpdateStudioCMSConfig_base {
@@ -1,6 +1,6 @@
1
1
  import { promises as fs } from "node:fs";
2
2
  import { fileURLToPath } from "node:url";
3
- import { askToContinue } from "@withstudiocms/cli-kit/messages";
3
+ import { askToContinue, note } from "@withstudiocms/effect/clack";
4
4
  import { diffWords } from "diff";
5
5
  import { generateCode } from "magicast";
6
6
  import { Console, Effect, genLogger } from "../../effect.js";
@@ -15,7 +15,7 @@ class UpdateStudioCMSConfig extends Effect.Service()(
15
15
  const run = (configURL, mod) => genLogger("studiocms/cli/add/updateStudioCMSConfig/UpdateStudioCMSConfig.effect.run")(
16
16
  function* () {
17
17
  const context = yield* CliContext;
18
- const { prompts, chalk } = context;
18
+ const { chalk } = context;
19
19
  const input = yield* Effect.tryPromise(
20
20
  () => fs.readFile(fileURLToPath(configURL), { encoding: "utf-8" })
21
21
  );
@@ -44,12 +44,12 @@ class UpdateStudioCMSConfig extends Effect.Service()(
44
44
  const message = `
45
45
  ${boxenMessage}
46
46
  `;
47
- prompts.note(
47
+ yield* note(
48
48
  `
49
49
  ${chalk.magenta("StudioCMS will make the following changes to your config file:")}
50
50
  ${message}`
51
51
  );
52
- if (yield* Effect.tryPromise(() => askToContinue(prompts))) {
52
+ if (yield* askToContinue()) {
53
53
  yield* Effect.tryPromise(
54
54
  () => fs.writeFile(fileURLToPath(configURL), output, { encoding: "utf-8" })
55
55
  );
@@ -3,7 +3,7 @@ import { CliContext } from '../utils/context.js';
3
3
  import { type PluginInfo } from './index.js';
4
4
  declare const ValidatePlugins_base: Effect.Service.Class<ValidatePlugins, "ValidatePlugins", {
5
5
  readonly effect: Effect.Effect<{
6
- run: (names: string[]) => Effect.Effect<PluginInfo[], import("effect/Cause").UnknownException, CliContext>;
6
+ run: (names: string[]) => Effect.Effect<PluginInfo[], Error, CliContext>;
7
7
  }, never, never>;
8
8
  }>;
9
9
  export declare class ValidatePlugins extends ValidatePlugins_base {
@@ -1,4 +1,4 @@
1
- import { askToContinue } from "@withstudiocms/cli-kit/messages";
1
+ import { askToContinue, spinner } from "@withstudiocms/effect/clack";
2
2
  import { Effect, genLogger } from "../../effect.js";
3
3
  import { CliContext } from "../utils/context.js";
4
4
  import { StudioCMSScopes } from "./index.js";
@@ -6,9 +6,9 @@ import { fetchPackageJson, parsePluginName } from "./npm-utils.js";
6
6
  class ValidatePlugins extends Effect.Service()("ValidatePlugins", {
7
7
  effect: genLogger("studiocms/cli/add/validatePlugins/ValidatePlugins.effect")(function* () {
8
8
  const run = (names) => genLogger("studiocms/cli/add/validatePlugins/ValidatePlugins.effect.run")(function* () {
9
- const { prompts, chalk } = yield* CliContext;
10
- const spinner = yield* Effect.try(() => prompts.spinner());
11
- spinner.start("Resolving packages...");
9
+ const { chalk } = yield* CliContext;
10
+ const spin = yield* spinner();
11
+ yield* spin.start("Resolving packages...");
12
12
  const entries = [];
13
13
  for (const plugin of names) {
14
14
  const parsed = yield* parsePluginName(plugin);
@@ -23,17 +23,17 @@ class ValidatePlugins extends Effect.Service()("ValidatePlugins", {
23
23
  const firstPartyPkgCheck = yield* fetchPackageJson(scope, name, tag);
24
24
  if (firstPartyPkgCheck instanceof Error) {
25
25
  if (firstPartyPkgCheck.message) {
26
- spinner.message(chalk.yellow(firstPartyPkgCheck.message));
26
+ yield* spin.message(chalk.yellow(firstPartyPkgCheck.message));
27
27
  }
28
- spinner.message(
28
+ yield* spin.message(
29
29
  chalk.yellow(`${chalk.bold(plugin)} is not an official StudioCMS package.`)
30
30
  );
31
- if (!(yield* Effect.tryPromise(() => askToContinue(prompts)))) {
31
+ if (!(yield* askToContinue())) {
32
32
  throw new Error(
33
33
  `No problem! Find our official plugins at ${chalk.magenta("https://docs.studiocms.dev")}`
34
34
  );
35
35
  }
36
- spinner.start("Resolving with third party packages...");
36
+ yield* spin.start("Resolving with third party packages...");
37
37
  pkgType = "third-party";
38
38
  } else {
39
39
  pkgType = "first-party";
@@ -44,7 +44,7 @@ class ValidatePlugins extends Effect.Service()("ValidatePlugins", {
44
44
  const thirdPartyPkgCheck = yield* fetchPackageJson(scope, name, tag);
45
45
  if (thirdPartyPkgCheck instanceof Error) {
46
46
  if (thirdPartyPkgCheck.message) {
47
- spinner.message(chalk.yellow(thirdPartyPkgCheck.message));
47
+ yield* spin.message(chalk.yellow(thirdPartyPkgCheck.message));
48
48
  }
49
49
  throw new Error(`Unable to fetch ${chalk.bold(plugin)}. Does the package exist?`);
50
50
  }
@@ -77,7 +77,7 @@ class ValidatePlugins extends Effect.Service()("ValidatePlugins", {
77
77
  pluginName
78
78
  });
79
79
  }
80
- spinner.stop("Packages Resolved.");
80
+ yield* spin.stop("Packages Resolved.");
81
81
  return entries;
82
82
  });
83
83
  return { run };
@@ -5,6 +5,7 @@ import {
5
5
  StudioCMSColorwayInfoBg
6
6
  } from "@withstudiocms/cli-kit/colors";
7
7
  import { boxen, label } from "@withstudiocms/cli-kit/messages";
8
+ import { intro, log, outro, spinner } from "@withstudiocms/effect/clack";
8
9
  import { SignJWT } from "jose";
9
10
  import { importPKCS8 } from "jose/key/import";
10
11
  import { Cli, Effect, genLogger } from "../../../effect.js";
@@ -58,19 +59,19 @@ const genJWT = Cli.Command.make(
58
59
  }
59
60
  if (debug2) logger.debug("Getting context");
60
61
  const context = yield* genContext;
61
- const { prompts, chalk } = context;
62
+ const { chalk } = context;
62
63
  if (debug2) logger.debug("Init complete, starting...");
63
- prompts.intro(label("StudioCMS Crypto: Generate JWT", StudioCMSColorwayBg, chalk.bold));
64
- const spinner = prompts.spinner();
64
+ yield* intro(label("StudioCMS Crypto: Generate JWT", StudioCMSColorwayBg, chalk.bold));
65
+ const spin = yield* spinner();
65
66
  try {
66
- spinner.start("Getting Key from keyFile");
67
+ yield* spin.start("Getting Key from keyFile");
67
68
  if (debug2) logger.debug(`Key file path: ${keyFile2}`);
68
69
  if (debug2) logger.debug(`Key file exists: ${fs.existsSync(keyFile2)}`);
69
70
  if (debug2) logger.debug(`Key file is a file: ${fs.statSync(keyFile2).isFile()}`);
70
71
  const keyString = yield* Effect.try(() => fs.readFileSync(keyFile2, "utf8"));
71
72
  if (debug2) logger.debug(`Key string: ${keyString}`);
72
73
  if (!keyString) {
73
- spinner.stop("Key not found, or invalid");
74
+ yield* spin.stop("Key not found, or invalid");
74
75
  return yield* Effect.fail(new Error("Key not found, or invalid"));
75
76
  }
76
77
  const alg = "EdDSA";
@@ -78,7 +79,7 @@ const genJWT = Cli.Command.make(
78
79
  try {
79
80
  privateKey = yield* Effect.tryPromise(() => importPKCS8(keyString, alg));
80
81
  } catch (_e) {
81
- spinner.stop("Invalid or unsupported private key");
82
+ yield* spin.stop("Invalid or unsupported private key");
82
83
  return yield* Effect.fail(new Error("Invalid or unsupported private key"));
83
84
  }
84
85
  const NOW = /* @__PURE__ */ new Date();
@@ -87,28 +88,28 @@ const genJWT = Cli.Command.make(
87
88
  () => new SignJWT({ sub: "libsql-client" }).setProtectedHeader({ alg }).setIssuedAt(NOW).setExpirationTime(expirationDate).setIssuer("admin").sign(privateKey)
88
89
  );
89
90
  const base64UrlJwt = yield* convertJwtToBase64Url(jwt);
90
- spinner.stop("Token Generated.");
91
- prompts.log.success(
91
+ yield* spin.stop("Token Generated.");
92
+ yield* log.success(
92
93
  boxen(chalk.bold(`${label("Token Generated!", StudioCMSColorwayInfoBg, chalk.bold)}`), {
93
94
  ln1: "Your new Token has been generated successfully:",
94
95
  ln3: `Token: ${chalk.magenta(jwt)}`,
95
96
  ln5: `Base64Url Token: ${chalk.blue(base64UrlJwt)}`
96
97
  })
97
98
  );
98
- prompts.outro(
99
+ yield* outro(
99
100
  `${label("You can now use this token where needed.", StudioCMSColorwayBg, chalk.bold)} Stuck? Join us on Discord at ${StudioCMSColorway.bold.underline("https://chat.studiocms.dev")}`
100
101
  );
101
102
  } catch (err) {
102
103
  if (err instanceof Error) {
103
104
  if (err.message.includes("ENOENT")) {
104
- prompts.log.error("Key file not found: Please check the file path and try again.");
105
+ yield* log.error("Key file not found: Please check the file path and try again.");
105
106
  } else if (err.message.includes("permission")) {
106
- prompts.log.error("Permission denied: Cannot read the key file.");
107
+ yield* log.error("Permission denied: Cannot read the key file.");
107
108
  } else {
108
- prompts.log.error(`Error generating JWT: ${err.message}`);
109
+ yield* log.error(`Error generating JWT: ${err.message}`);
109
110
  }
110
111
  } else {
111
- prompts.log.error(`Unexpected error generating JWT: ${err}`);
112
+ yield* log.error(`Unexpected error generating JWT: ${err}`);
112
113
  }
113
114
  return yield* Effect.fail(new Error("JWT ERROR: Unknown"));
114
115
  }
@@ -1,15 +1,13 @@
1
1
  import { runInteractiveCommand } from "@withstudiocms/cli-kit/utils";
2
- import { Cli, Effect, genLogger } from "../../effect.js";
2
+ import { Cli, Effect } from "../../effect.js";
3
3
  const getTurso = Cli.Command.make(
4
4
  "get-turso",
5
5
  {},
6
- () => genLogger("studiocms/cli/getTurso")(function* () {
7
- yield* Effect.tryPromise({
8
- try: () => runInteractiveCommand("curl -sSfL https://get.tur.so/install.sh | bash").then(
9
- () => console.log("Turso CLI install command completed.")
10
- ),
11
- catch: (error) => console.error(`Failed to run Turso install: ${error.message}`)
12
- });
6
+ () => Effect.tryPromise({
7
+ try: () => runInteractiveCommand("curl -sSfL https://get.tur.so/install.sh | bash").then(
8
+ () => console.log("Turso CLI install command completed.")
9
+ ),
10
+ catch: (error) => console.error(`Failed to run Turso install: ${error.message}`)
13
11
  })
14
12
  ).pipe(Cli.Command.withDescription("Install the Turso CLI"));
15
13
  export {
package/dist/cli/index.js CHANGED
@@ -1,10 +1,12 @@
1
- import { readJson } from "@withstudiocms/cli-kit/utils";
1
+ import { readJson } from "@withstudiocms/internal_helpers/utils";
2
+ import dotenv from "dotenv";
2
3
  import { Cli, Effect, Layer, PlatformNode } from "../effect.js";
3
4
  import { addPlugin } from "./add/index.js";
4
5
  import { cryptoCMD } from "./crypto/index.js";
5
6
  import { getTurso } from "./getTurso/index.js";
6
7
  import { initCMD } from "./init/index.js";
7
8
  import { usersCMD } from "./users/index.js";
9
+ dotenv.config({ quiet: true });
8
10
  const pkgJson = readJson(new URL("../../package.json", import.meta.url));
9
11
  const command = Cli.Command.make("studiocms").pipe(
10
12
  Cli.Command.withDescription("StudioCMS CLI Utility Toolkit"),
@@ -1,9 +1,11 @@
1
1
  import { StudioCMSColorwayBg } from "@withstudiocms/cli-kit/colors";
2
2
  import { label } from "@withstudiocms/cli-kit/messages";
3
- import { Cli, Console, Effect, genLogger } from "../../effect.js";
4
- import { CliContext, genContext } from "../utils/context.js";
5
- import { intro } from "../utils/intro.js";
6
- import { logger } from "../utils/logger.js";
3
+ import { intro, log, multiselect, tasks } from "@withstudiocms/effect/clack";
4
+ import { Cli, Effect, genLogger } from "../../effect.js";
5
+ import { CliContext, genContext, parseDebug } from "../utils/context.js";
6
+ import { intro as SCMS_Intro } from "../utils/intro.js";
7
+ import { buildDebugLogger } from "../utils/logger.js";
8
+ import { appendOptionsToSteps } from "../utils/types.js";
7
9
  import { env } from "./steps/env.js";
8
10
  import { next } from "./steps/next.js";
9
11
  const debug = Cli.Options.boolean("debug").pipe(
@@ -16,68 +18,63 @@ const dryRun = Cli.Options.boolean("dry-run").pipe(
16
18
  Cli.Options.withAlias("d"),
17
19
  Cli.Options.withDescription("Dry run mode")
18
20
  );
21
+ const exitIfEmpty = Effect.fn(function* (context, items, itemType) {
22
+ if (items.length === 0) {
23
+ yield* log.error(`No ${itemType} selected, exiting...`);
24
+ yield* context.exit(0);
25
+ }
26
+ });
27
+ const OptionToStepMap = {
28
+ env
29
+ };
19
30
  const initCMD = Cli.Command.make(
20
31
  "init",
21
32
  { debug, dryRun },
22
- ({ debug: _debug, dryRun: dryRun2 }) => genLogger("studiocms/cli/init")(function* () {
23
- let debug2;
24
- if (typeof _debug !== "boolean") {
25
- debug2 = yield* _debug;
26
- } else {
27
- debug2 = _debug;
28
- }
29
- const dry = yield* dryRun2;
30
- const context = yield* genContext;
31
- const { prompts, chalk } = context;
32
- yield* Console.log("Starting interactive CLI...");
33
- debug2 && logger.debug(`Options: ${JSON.stringify({ debug: debug2, dry }, null, 2)}`);
34
- debug2 && logger.debug(`Context: ${JSON.stringify(context, null, 2)}`);
35
- yield* Console.log("");
36
- prompts.intro(
37
- `${label("StudioCMS", StudioCMSColorwayBg, chalk.black)} Interactive CLI - initializing...`
38
- );
39
- yield* intro(debug2).pipe(CliContext.makeProvide(context));
33
+ ({ debug: rawDebug, dryRun: rawDryRun }) => genLogger("studiocms/cli/init")(function* () {
34
+ const [dry, context, debug2] = yield* Effect.all([
35
+ rawDryRun,
36
+ genContext,
37
+ parseDebug(rawDebug)
38
+ ]);
39
+ const debugLogger = yield* buildDebugLogger(debug2);
40
+ const cliContext = CliContext.makeProvide(context);
41
+ yield* Effect.all([
42
+ debugLogger("Starting interactive CLI..."),
43
+ debugLogger(`Options: ${JSON.stringify({ debug: debug2, dry }, null, 2)}`),
44
+ debugLogger(`Context: ${JSON.stringify(context, null, 2)}`),
45
+ intro(
46
+ `${label("StudioCMS", StudioCMSColorwayBg, context.chalk.black)} Interactive CLI - initializing...`
47
+ )
48
+ ]);
49
+ yield* SCMS_Intro(debug2).pipe(cliContext);
40
50
  const steps = [];
41
- debug2 && logger.debug("Running Option selection...");
42
- const options = yield* Effect.tryPromise(
43
- () => prompts.multiselect({
51
+ const [_dropOptionLog, options] = yield* Effect.all([
52
+ debugLogger("Running Option selection..."),
53
+ multiselect({
44
54
  message: "What would you like to do? (Select all that apply)",
45
55
  options: [{ value: "env", label: "Setup Environment File", hint: "Create a .env file" }]
46
56
  })
47
- );
57
+ ]);
48
58
  if (typeof options === "symbol") {
49
- context.pCancel(options);
50
- } else {
51
- options.includes("env") && steps.push(env);
52
- }
53
- if (steps.length === 0) {
54
- prompts.log.error("No steps selected, exiting...");
55
- context.exit(1);
56
- }
57
- debug2 && logger.debug("Running steps...");
58
- for (const step of steps) {
59
- yield* Effect.tryPromise({
60
- try: () => step(context, debug2, dry),
61
- catch: (error) => {
62
- prompts.log.error(
63
- `Step execution failed: ${error instanceof Error ? error.message : String(error)}`
64
- );
65
- return new Error(
66
- `Step execution failed: ${error instanceof Error ? error.message : String(error)}`
67
- );
68
- }
69
- });
70
- }
71
- debug2 && logger.debug("Running tasks...");
72
- if (context.tasks.length === 0) {
73
- prompts.log.error("No tasks selected, exiting...");
74
- context.exit(0);
59
+ return yield* context.pCancel(options);
75
60
  }
76
- yield* Effect.tryPromise(() => prompts.tasks(context.tasks));
77
- debug2 && logger.debug("Running next steps...");
78
- yield* next(debug2).pipe(CliContext.makeProvide(context));
79
- debug2 && logger.debug("Interactive CLI completed, exiting...");
80
- context.exit(0);
61
+ appendOptionsToSteps(options, steps, OptionToStepMap);
62
+ yield* exitIfEmpty(context, steps, "steps");
63
+ yield* Effect.all([
64
+ debugLogger("Running steps..."),
65
+ Effect.forEach(steps, (step) => step(context, debug2, dry))
66
+ ]);
67
+ yield* exitIfEmpty(context, context.tasks, "tasks");
68
+ yield* Effect.all([
69
+ debugLogger(`Tasks to run: ${context.tasks.length}`),
70
+ debugLogger("Running tasks..."),
71
+ tasks(context.tasks)
72
+ ]);
73
+ yield* Effect.all([
74
+ debugLogger("Tasks complete, running next steps..."),
75
+ next(debug2).pipe(cliContext)
76
+ ]);
77
+ yield* Effect.all([debugLogger("Interactive CLI completed, exiting..."), context.exit(0)]);
81
78
  })
82
79
  ).pipe(Cli.Command.withDescription("Initialize the StudioCMS project after new installation."));
83
80
  export {
@@ -1,7 +1,7 @@
1
- import type { StepFn } from '../../utils/types.js';
1
+ import type { EffectStepFn } from '../../utils/types.js';
2
2
  export declare enum EnvBuilderAction {
3
3
  builder = "builder",
4
4
  example = "example",
5
5
  none = "none"
6
6
  }
7
- export declare const env: StepFn;
7
+ export declare const env: EffectStepFn;