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.
- package/CHANGELOG.md +39 -0
- package/README.md +2 -0
- package/dist/cli/add/index.d.ts +1 -1
- package/dist/cli/add/index.js +15 -12
- package/dist/cli/add/tryToInstallPlugins.d.ts +1 -1
- package/dist/cli/add/tryToInstallPlugins.js +11 -8
- package/dist/cli/add/updateStudioCMSConfig.d.ts +1 -1
- package/dist/cli/add/updateStudioCMSConfig.js +4 -4
- package/dist/cli/add/validatePlugins.d.ts +1 -1
- package/dist/cli/add/validatePlugins.js +10 -10
- package/dist/cli/crypto/genJWT/index.js +14 -13
- package/dist/cli/getTurso/index.js +6 -8
- package/dist/cli/index.js +3 -1
- package/dist/cli/init/index.js +54 -57
- package/dist/cli/init/steps/env.d.ts +2 -2
- package/dist/cli/init/steps/env.js +316 -271
- package/dist/cli/init/steps/next.d.ts +2 -1
- package/dist/cli/init/steps/next.js +35 -28
- package/dist/cli/users/index.d.ts +2 -1
- package/dist/cli/users/index.js +83 -80
- package/dist/cli/users/steps/libsql/createUsers.d.ts +2 -0
- package/dist/cli/users/steps/libsql/createUsers.js +151 -0
- package/dist/cli/users/steps/libsql/modifyUsers.d.ts +7 -0
- package/dist/cli/users/steps/libsql/modifyUsers.js +205 -0
- package/dist/cli/users/steps/next.d.ts +2 -1
- package/dist/cli/users/steps/next.js +10 -7
- package/dist/cli/utils/checkRequiredEnvVars.d.ts +17 -1
- package/dist/cli/utils/checkRequiredEnvVars.js +32 -4
- package/dist/cli/utils/context.d.ts +7 -7
- package/dist/cli/utils/context.js +23 -16
- package/dist/cli/utils/effectBoxen.d.ts +1 -2
- package/dist/cli/utils/effectBoxen.js +2 -4
- package/dist/cli/utils/intro.js +2 -3
- package/dist/cli/utils/logger.d.ts +9 -0
- package/dist/cli/utils/logger.js +14 -0
- package/dist/cli/utils/types.d.ts +36 -0
- package/dist/cli/utils/types.js +11 -0
- package/dist/cli/utils/useLibSQLDb.d.ts +20 -262
- package/dist/cli/utils/useLibSQLDb.js +22 -17
- package/dist/cli/utils/user-utils.d.ts +16 -105
- package/dist/cli/utils/user-utils.js +29 -65
- package/dist/components/auth/FallbackCanvas.astro +5 -8
- package/dist/components/auth/ThreeCanvasLoader.astro +1 -8
- package/dist/components/auth/component-scripts/formListener.d.ts +2 -1
- package/dist/components/auth/component-scripts/formListener.js +7 -3
- package/dist/components/dashboard/content-mgmt/CreatePage.astro +11 -3
- package/dist/components/dashboard/content-mgmt/EditPage.astro +1 -1
- package/dist/components/dashboard/content-mgmt/PageHeader.astro +1 -1
- package/dist/components/shared/Code.astro +6 -2
- package/dist/components/shared/SSRUser.astro +2 -0
- package/dist/handlers/routeHandler.js +1 -1
- package/dist/integrations/dynamic-sitemap/index.d.ts +8 -0
- package/dist/integrations/dynamic-sitemap/index.js +4 -1
- package/dist/integrations/dynamic-sitemap/sitemap-index.xml.d.ts +20 -0
- package/dist/integrations/dynamic-sitemap/sitemap-index.xml.js +2 -1
- package/dist/integrations/node-namespace.d.ts +4 -0
- package/dist/integrations/node-namespace.js +14 -10
- package/dist/integrations/robots/core.d.ts +63 -0
- package/dist/integrations/robots/core.js +14 -3
- package/dist/integrations/robots/index.js +2 -0
- package/dist/integrations/webVitals/utils/webVitalsUtils.js +2 -2
- package/dist/integrations/webVitals/webVitalsRouteSummary.d.ts +15 -0
- package/dist/integrations/webVitals/webVitalsRouteSummary.js +4 -1
- package/dist/layouts/AuthLayout.astro +1 -1
- package/dist/middleware/utils.d.ts +5 -3
- package/dist/middleware/utils.js +20 -3
- package/dist/plugins.d.ts +1 -2
- package/dist/routes/api/dashboard/content/page.js +70 -36
- package/dist/routes/firstTimeSetupRoutes/2-next.astro +3 -2
- package/dist/schemas/config/auth.d.ts +12 -0
- package/dist/schemas/config/auth.js +2 -1
- package/dist/schemas/config/sdk.d.ts +39 -5
- package/dist/schemas/config/sdk.js +7 -1
- package/dist/schemas/plugins/index.d.ts +2508 -0
- package/dist/test-utils.d.ts +105 -0
- package/dist/test-utils.js +167 -0
- package/dist/utils/effects/index.d.ts +1 -1
- package/dist/utils/effects/index.js +1 -2
- package/dist/utils/effects/logger.d.ts +6 -17
- package/dist/utils/effects/logger.js +4 -9
- package/dist/virtuals/auth/verify-email.d.ts +3 -3
- package/dist/virtuals/components/CustomImage.astro +4 -0
- package/dist/virtuals/components/FormattedDate.astro +3 -2
- package/dist/virtuals/components/Renderer.astro +4 -0
- package/dist/virtuals/i18n/client.js +2 -0
- package/dist/virtuals/i18n/server.js +8 -2
- package/dist/virtuals/mailer/index.d.ts +2 -2
- package/dist/virtuals/mailer/template.d.ts +1 -1
- package/dist/virtuals/mailer/template.js +2 -1
- package/dist/virtuals/mailer/templates/password-reset.js +2 -4
- package/dist/virtuals/mailer/templates/verify-email.js +1 -2
- package/dist/virtuals/notifier/client.d.ts +1 -2
- package/dist/virtuals/notifier/client.js +2 -1
- package/dist/virtuals/scripts/user-quick-tools.d.ts +16 -16
- package/dist/virtuals/scripts/user-quick-tools.js +19 -0
- package/dist/virtuals/sdk/consts.d.ts +11 -0
- package/dist/virtuals/sdk/consts.js +2 -0
- package/dist/virtuals/sdk/effect/collectors.d.ts +15 -2
- package/dist/virtuals/sdk/effect/collectors.js +5 -23
- package/dist/virtuals/sdk/effect/db.d.ts +5 -88
- package/dist/virtuals/sdk/effect/db.js +6 -98
- package/dist/virtuals/sdk/effect/foldertree.d.ts +3 -3
- package/dist/virtuals/sdk/effect/generators.js +24 -12
- package/dist/virtuals/sdk/effect/lib/jwt-generator.d.ts +23 -0
- package/dist/virtuals/sdk/effect/lib/jwt-generator.js +2 -0
- package/dist/virtuals/sdk/effect/users.js +2 -2
- package/dist/virtuals/sdk/index.d.ts +17 -4
- package/dist/virtuals/sdk/modules/auth.js +17 -17
- package/dist/virtuals/sdk/modules/config-types.d.ts +141 -0
- package/dist/virtuals/sdk/modules/config-types.js +0 -0
- package/dist/virtuals/sdk/modules/config.d.ts +13 -163
- package/dist/virtuals/sdk/modules/config.js +1 -2
- package/dist/virtuals/sdk/modules/delete.js +9 -9
- package/dist/virtuals/sdk/modules/diffTracking.js +9 -9
- package/dist/virtuals/sdk/modules/get.d.ts +12 -12
- package/dist/virtuals/sdk/modules/get.js +16 -16
- package/dist/virtuals/sdk/modules/init.d.ts +1 -1
- package/dist/virtuals/sdk/modules/init.js +1 -1
- package/dist/virtuals/sdk/modules/notificationSettings.d.ts +2 -2
- package/dist/virtuals/sdk/modules/notificationSettings.js +1 -1
- package/dist/virtuals/sdk/modules/plugins.d.ts +9 -9
- package/dist/virtuals/sdk/modules/post.js +10 -10
- package/dist/virtuals/sdk/modules/resetTokenBucket.js +3 -3
- package/dist/virtuals/sdk/modules/rest_api.js +4 -4
- package/dist/virtuals/sdk/modules/update.d.ts +1 -1
- package/dist/virtuals/sdk/modules/update.js +10 -14
- package/dist/virtuals/sdk/sdkCore.d.ts +17 -4
- package/dist/virtuals/sdk/types/index.d.ts +1 -1
- package/package.json +20 -17
- package/src/cli/add/index.ts +15 -13
- package/src/cli/add/tryToInstallPlugins.ts +14 -9
- package/src/cli/add/updateStudioCMSConfig.ts +4 -4
- package/src/cli/add/validatePlugins.ts +10 -10
- package/src/cli/crypto/genJWT/index.ts +14 -13
- package/src/cli/getTurso/index.ts +7 -9
- package/src/cli/index.ts +4 -1
- package/src/cli/init/index.ts +86 -97
- package/src/cli/init/steps/env.ts +361 -303
- package/src/cli/init/steps/next.ts +40 -36
- package/src/cli/users/index.ts +116 -109
- package/src/cli/users/steps/libsql/createUsers.ts +169 -0
- package/src/cli/users/steps/libsql/modifyUsers.ts +229 -0
- package/src/cli/users/steps/next.ts +10 -8
- package/src/cli/utils/checkRequiredEnvVars.ts +53 -3
- package/src/cli/utils/context.ts +28 -20
- package/src/cli/utils/effectBoxen.ts +2 -4
- package/src/cli/utils/intro.ts +2 -3
- package/src/cli/utils/logger.ts +21 -0
- package/src/cli/utils/types.ts +50 -0
- package/src/cli/utils/useLibSQLDb.ts +35 -17
- package/src/cli/utils/user-utils.ts +42 -155
- package/src/components/auth/FallbackCanvas.astro +5 -8
- package/src/components/auth/ThreeCanvasLoader.astro +1 -8
- package/src/components/auth/component-scripts/formListener.ts +14 -3
- package/src/components/dashboard/content-mgmt/CreatePage.astro +11 -3
- package/src/components/dashboard/content-mgmt/EditPage.astro +1 -1
- package/src/components/dashboard/content-mgmt/PageHeader.astro +1 -1
- package/src/components/shared/Code.astro +6 -2
- package/src/components/shared/SSRUser.astro +2 -0
- package/src/consts.ts +2 -0
- package/src/effect.ts +2 -0
- package/src/handlers/routeHandler.ts +1 -1
- package/src/integrations/dynamic-sitemap/index.ts +3 -1
- package/src/integrations/dynamic-sitemap/sitemap-index.xml.ts +1 -1
- package/src/integrations/node-namespace.ts +14 -10
- package/src/integrations/plugins.ts +2 -0
- package/src/integrations/robots/core.ts +9 -7
- package/src/integrations/robots/index.ts +2 -0
- package/src/integrations/webVitals/checkForWebVitalsPlugin.ts +8 -0
- package/src/integrations/webVitals/consts.ts +8 -0
- package/src/integrations/webVitals/utils/buildPageRouteDataObject.ts +2 -0
- package/src/integrations/webVitals/utils/buildPerPageDataObject.ts +4 -0
- package/src/integrations/webVitals/utils/webVitalsUtils.ts +8 -2
- package/src/integrations/webVitals/webVital.ts +9 -0
- package/src/integrations/webVitals/webVitalsRouteSummary.ts +3 -3
- package/src/layouts/AuthLayout.astro +1 -1
- package/src/middleware/index.ts +13 -0
- package/src/middleware/utils.ts +22 -5
- package/src/plugins.ts +4 -11
- package/src/routes/api/dashboard/content/page.ts +99 -37
- package/src/routes/firstTimeSetupRoutes/2-next.astro +3 -2
- package/src/schemas/config/auth.ts +1 -1
- package/src/schemas/config/sdk.ts +8 -6
- package/src/schemas/index.ts +2 -0
- package/src/schemas/plugins/index.ts +7 -0
- package/src/test-utils.ts +229 -0
- package/src/utils/effects/index.ts +1 -1
- package/src/utils/effects/logger.ts +7 -36
- package/src/utils/effects/smtp.ts +6 -0
- package/src/utils/safeString.ts +4 -0
- package/src/virtuals/components/CustomImage.astro +4 -0
- package/src/virtuals/components/FormattedDate.astro +3 -2
- package/src/virtuals/components/Renderer.astro +4 -0
- package/src/virtuals/i18n/client.ts +2 -0
- package/src/virtuals/i18n/server.ts +6 -4
- package/src/virtuals/lib/head.ts +3 -0
- package/src/virtuals/lib/urlGen.ts +3 -0
- package/src/virtuals/mailer/template.ts +1 -1
- package/src/virtuals/mailer/templates/password-reset.ts +2 -4
- package/src/virtuals/mailer/templates/verify-email.ts +1 -2
- package/src/virtuals/notifier/client.ts +1 -1
- package/src/virtuals/scripts/user-quick-tools.ts +42 -18
- package/src/virtuals/sdk/consts.ts +12 -0
- package/src/virtuals/sdk/effect/collectors.ts +7 -31
- package/src/virtuals/sdk/effect/db.ts +7 -249
- package/src/virtuals/sdk/effect/foldertree.ts +12 -17
- package/src/virtuals/sdk/effect/generators.ts +6 -0
- package/src/virtuals/sdk/effect/getVersionFromNPM.ts +3 -0
- package/src/virtuals/sdk/effect/lib/jwt-generator.ts +2 -2
- package/src/virtuals/sdk/effect/users.ts +2 -2
- package/src/virtuals/sdk/modules/auth.ts +17 -17
- package/src/virtuals/sdk/modules/config-types.ts +157 -0
- package/src/virtuals/sdk/modules/config.ts +35 -169
- package/src/virtuals/sdk/modules/delete.ts +9 -18
- package/src/virtuals/sdk/modules/diffTracking.ts +9 -9
- package/src/virtuals/sdk/modules/get.ts +16 -32
- package/src/virtuals/sdk/modules/init.ts +1 -1
- package/src/virtuals/sdk/modules/notificationSettings.ts +1 -1
- package/src/virtuals/sdk/modules/plugins.ts +8 -12
- package/src/virtuals/sdk/modules/post.ts +10 -15
- package/src/virtuals/sdk/modules/resetTokenBucket.ts +3 -3
- package/src/virtuals/sdk/modules/rest_api.ts +4 -8
- package/src/virtuals/sdk/modules/update.ts +10 -24
- package/src/virtuals/sdk/tables.ts +2 -0
- package/src/virtuals/sdk/types/index.ts +1 -1
- package/dist/cli/users/steps/libsqlCreateUsers.d.ts +0 -2
- package/dist/cli/users/steps/libsqlCreateUsers.js +0 -163
- package/dist/cli/users/steps/libsqlModifyUsers.d.ts +0 -7
- package/dist/cli/users/steps/libsqlModifyUsers.js +0 -221
- package/dist/cli/utils/createUserAvatar.d.ts +0 -10
- package/dist/cli/utils/createUserAvatar.js +0 -11
- package/src/cli/users/steps/libsqlCreateUsers.ts +0 -200
- package/src/cli/users/steps/libsqlModifyUsers.ts +0 -271
- package/src/cli/utils/createUserAvatar.ts +0 -23
- /package/dist/routes/api/mailer/{test-email.d.ts → check-email.d.ts} +0 -0
- /package/dist/routes/api/mailer/{test-email.js → check-email.js} +0 -0
- /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
|
|
package/dist/cli/add/index.d.ts
CHANGED
|
@@ -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,
|
|
24
|
+
export declare const addPlugin: Cli.Command.Command<"add", never, Error | Effect.Effect<Error, never, never>, {
|
|
25
25
|
readonly plugin: string[];
|
|
26
26
|
}>;
|
package/dist/cli/add/index.js
CHANGED
|
@@ -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*
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
199
|
+
yield* outro("Configuration up-to-date.");
|
|
197
200
|
break;
|
|
198
201
|
}
|
|
199
202
|
}
|
|
200
|
-
|
|
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
|
-
|
|
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,
|
|
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 {
|
|
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
|
-
|
|
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*
|
|
56
|
-
const
|
|
57
|
-
|
|
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
|
-
|
|
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,
|
|
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/
|
|
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 {
|
|
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
|
-
|
|
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*
|
|
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[],
|
|
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/
|
|
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 {
|
|
10
|
-
const
|
|
11
|
-
|
|
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
|
-
|
|
26
|
+
yield* spin.message(chalk.yellow(firstPartyPkgCheck.message));
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
yield* spin.message(
|
|
29
29
|
chalk.yellow(`${chalk.bold(plugin)} is not an official StudioCMS package.`)
|
|
30
30
|
);
|
|
31
|
-
if (!(yield*
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
62
|
+
const { chalk } = context;
|
|
62
63
|
if (debug2) logger.debug("Init complete, starting...");
|
|
63
|
-
|
|
64
|
-
const
|
|
64
|
+
yield* intro(label("StudioCMS Crypto: Generate JWT", StudioCMSColorwayBg, chalk.bold));
|
|
65
|
+
const spin = yield* spinner();
|
|
65
66
|
try {
|
|
66
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
91
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
107
|
+
yield* log.error("Permission denied: Cannot read the key file.");
|
|
107
108
|
} else {
|
|
108
|
-
|
|
109
|
+
yield* log.error(`Error generating JWT: ${err.message}`);
|
|
109
110
|
}
|
|
110
111
|
} else {
|
|
111
|
-
|
|
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
|
|
2
|
+
import { Cli, Effect } from "../../effect.js";
|
|
3
3
|
const getTurso = Cli.Command.make(
|
|
4
4
|
"get-turso",
|
|
5
5
|
{},
|
|
6
|
-
() =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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/
|
|
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"),
|
package/dist/cli/init/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { StudioCMSColorwayBg } from "@withstudiocms/cli-kit/colors";
|
|
2
2
|
import { label } from "@withstudiocms/cli-kit/messages";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
yield*
|
|
79
|
-
|
|
80
|
-
|
|
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 {
|
|
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:
|
|
7
|
+
export declare const env: EffectStepFn;
|