studiocms 0.1.0-beta.5

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Astrolicious - StudioCMS - Adam Matthiesen, Jacob Jenkins, Paul Valladares
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,138 @@
1
+ # Introducing AstroStudio CMS: A Community-Driven CMS for Astro Studio
2
+
3
+ As part of our efforts, we're excited to introduce AstroStudio CMS - a dedicated content management system (CMS) built on top of Astro's latest product, [Astro Studio](https://studio.astro.build). This project was developed by [Adam](https://github.com/Adammatthiesen), [Dreyfus](https://github.com/dreyfus92), and [Jumper](https://github.com/jdtjenkins), three passionate members of the Astro community.
4
+
5
+ ## Why another CMS?
6
+
7
+ While Astro's content capabilities are powerful, we recognized a need for a more streamlined and user-friendly CMS solution within the Astro ecosystem. Many Astro users, especially those coming from more traditional CMS backgrounds, have expressed a desire for a dedicated CMS that can seamlessly integrate with Astro projects.
8
+
9
+ AstroStudio CMS was born out of this need, providing a content management platform that is tailor-made for Astro. By building on top of Astro Studio, we're able to offer a CMS experience that feels native to the Astro workflow, making it easier for both developers and content creators to collaborate on Astro-powered projects.
10
+
11
+ ## An Experimental Endeavor
12
+
13
+ It's important to note that AstroStudio CMS is an experimental project that heavily relies on the @astrojs/db package, which is currently in active development and not yet considered stable. As a result, you should expect a significant number of breaking changes as the project continues to evolve.
14
+
15
+ We believe that by building on the cutting-edge features of Astro Studio, we can create a powerful and innovative CMS solution. However, this also means that AstroStudio CMS may not be suitable for mission-critical or production-ready projects at this stage. We encourage you to use caution and thoroughly test the CMS in your own projects before deploying it to a live environment.
16
+
17
+
18
+ ## Leveraging the Power of Astro
19
+
20
+ AstroStudio CMS is built from the ground up to seamlessly integrate with Astro's robust and efficient framework. By harnessing the power of Astro, we've created a CMS solution that aligns perfectly with the Astro ecosystem, providing a solid foundation for building and scaling Astro-powered applications.
21
+
22
+ ## Key Features
23
+
24
+ **Astro Foundation:** Astrolicious leverages Astro's robust and efficient framework, providing a solid base for building and scaling applications.
25
+
26
+ **Enhanced Markdown:** We've incorporated 'Marked' with support for extensions, enriching the markdown experience with greater flexibility and functionality.
27
+
28
+ **Shiki Syntax Highlighting:** Astrolicious offers Shiki-powered syntax highlighting, ensuring your code is both visually appealing and easy to read. This is especially useful in non-Cloudflare environments due to bundle size considerations.
29
+
30
+ **Markdoc Integration:** In addition to 'Marked', Astrolicious provides an alternative with Markdoc, offering users a choice for their markdown processing needs.
31
+
32
+ **Secure Studio Database:** All data is securely housed within the Astro Studio database, ensuring accessibility only to authorized users with studio.astro.build login credentials.
33
+
34
+ **Built-in Authentication:** Astrolicious features built-in authentication with support for multiple platforms, including Local and Github, enhancing security and user management (currently in development).
35
+
36
+ **Unpic Image Service:** Astrolicious includes a free and efficient image service, Unpic, which makes managing external URLs straightforward, with support for major CDNs.
37
+
38
+ ## A Community-Driven Effort
39
+
40
+ At the heart of Astrolicious is a deep commitment to community involvement and collaboration. We believe that the development of AstroStudio CMS should be a collective effort, drawing on the diverse talents and perspectives of the Astro community.
41
+
42
+ To that end, we've handed the repository Astrolicious as an open organization, welcoming contributors of all skill levels to get involved and help shape the future of this CMS. Whether you're a seasoned Astro developer or new to the ecosystem, we encourage you to join our [Discord server](https://chat.astrolicious.dev/) and explore ways to contribute.
43
+
44
+ By fostering a sense of shared ownership and investment, we aim to create a CMS that truly reflects the needs and desires of the Astro community. Your feedback, ideas, and code contributions will be invaluable as we work to build a feature-rich and user-friendly content management solution for Astro.
45
+
46
+ So don't be a stranger - come join us on this journey and help us realize the full potential of AstroStudio CMS!
47
+
48
+ # Installation
49
+
50
+ Start from a clean Astro installation with AstroDB
51
+
52
+ Example with pnpm
53
+
54
+ ```sh
55
+ # create a new project with pnpm
56
+ pnpm create astro@latest
57
+ ```
58
+
59
+ ```sh
60
+ # add astrodb
61
+ pnpm astro add db
62
+ ```
63
+
64
+ ```sh
65
+ # Add Astro-Studio-CMS
66
+ pnpm astro add @astrolicious/studiocms
67
+ ```
68
+
69
+ ## Authentication
70
+
71
+ Lucia Auth - requires two .env tokens to create the connection between Github and your Auth
72
+
73
+ ```
74
+ # credentials for GitHub OAuth App
75
+ CMS_GITHUB_CLIENT_ID=
76
+ CMS_GITHUB_CLIENT_SECRET=
77
+
78
+ # OPTIONALS
79
+ ## Cloudinary Javascript SDK
80
+ CMS_CLOUDINARY_CLOUDNAME="demo"
81
+ ```
82
+
83
+ When you setup the Github Oauth App for these keys use the following for the setup:
84
+
85
+ For Local dev to work:
86
+
87
+ Homepage URL: http://localhost:4321
88
+ Authorization callback URL: http://localhost:4321/dashboard/login/github/callback
89
+
90
+ For going to Production:
91
+
92
+ Homepage URL: https://example.com
93
+ Authorization callback URL: https://example.com/dashboard/login/github/callback
94
+
95
+ ## Configuration
96
+
97
+ Your `astro.config.mjs` should look like the following
98
+
99
+ > Note: Admins are currently defined by their Github Usernames!
100
+
101
+ ```mjs
102
+ import { defineConfig } from "astro/config";
103
+ import studioCMS from "@astrolicious/studiocms";
104
+ import db from '@astrojs/db';
105
+ import node from "@astrojs/node";
106
+
107
+ // https://astro.build/config
108
+ export default defineConfig({
109
+ site: 'https://example.com',
110
+ output: "server",
111
+ adapter: node({ mode: 'standalone' }),
112
+ integrations: [
113
+ db(),
114
+ studioCMS({
115
+ dbStartPage: true // DEFAULT - This injects a start page to setup your DB data.
116
+ })
117
+ ],
118
+ });
119
+ ```
120
+
121
+ ## First Start and setup
122
+
123
+ This project is designed to be setup to a new Studio DB, to get started follow the [Link to Astro Studio](https://docs.astro.build/en/recipes/studio/#create-a-new-studio-project)
124
+
125
+ *Note: `astrojs/db` does not currently maintain all database data without a [seed file](https://docs.astro.build/en/guides/astro-db/#seed-your-database) which would not work with the CMS. Until a local database is persistant between sessions we highly recommend connecting to a remote DB to allow for data to persist*
126
+
127
+ Commands to run:
128
+ - `astro db link` - Link to Astro Studio and Create a new DB for your CMS Installation
129
+ - `astro db push` - Creates the base tables on the remote database.
130
+ - `astro dev --remote` - Starts the Dev server connected to the linked database
131
+
132
+ Once that process completes successfuly you are ready to navigate to http://localhost:4321/start and follow the instructions to get started.
133
+
134
+ It will redirect and ask you to shutdown and change the above mentioned config option `dbStartPage` to `false` at which point that will enable full functionality of the CMS. you can now restart the dev server with `astro dev --remote` to continue viewing your new site!
135
+
136
+ ## Get Involved
137
+
138
+ As members of [Astrolicious](https://github.com/astrolicious) we are a free and open-source project, and we welcome contributions from the Astro community. If you're interested in getting involved, please visit our [GitHub repository](https://github.com/astrolicious/studiocms) and join our [Discord server](https://chat.astrolicious.dev/). Together, let's build an even stronger and more vibrant Astro ecosystem.
package/package.json ADDED
@@ -0,0 +1,99 @@
1
+ {
2
+ "name": "studiocms",
3
+ "version": "0.1.0-beta.5",
4
+ "description": "A dedicated CMS for Astro Studio. Built from the ground up by the Astro community.",
5
+ "author": {
6
+ "name": "Adam Matthiesen | Jacob Jenkins | Paul Valladares",
7
+ "url": "https://astro-studiocms.xyz"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/astrolicious/studiocms.git"
12
+ },
13
+ "contributors": [
14
+ "Adammatthiesen",
15
+ "jdtjenkins",
16
+ "dreyfus92"
17
+ ],
18
+ "license": "MIT",
19
+ "keywords": [
20
+ "astro",
21
+ "astrocms",
22
+ "astrodb",
23
+ "astrolicious",
24
+ "astrostudio",
25
+ "astro-integration",
26
+ "astro-studio",
27
+ "astro-studiocms",
28
+ "cms",
29
+ "studiocms",
30
+ "withastro"
31
+ ],
32
+ "homepage": "https://astro-studiocms.xyz",
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "sideEffects": false,
37
+ "files": [
38
+ "src"
39
+ ],
40
+ "exports": {
41
+ ".": "./src/index.ts",
42
+ "./blog": "./src/blog/index.ts"
43
+ },
44
+ "type": "module",
45
+ "dependencies": {
46
+ "@cloudinary/url-gen": "^1.19.0",
47
+ "@inox-tools/runtime-logger": "^0.3.1",
48
+ "@matthiesenxyz/astrolace": "^0.3.2",
49
+ "@matthiesenxyz/integration-utils": "^0.2.0",
50
+ "@matthiesenxyz/unocss-preset-daisyui": "^0.1.2",
51
+ "@shikijs/transformers": "^1.14.1",
52
+ "@noble/hashes": "^1.4.0",
53
+ "@unpic/astro": "^0.0.46",
54
+ "micromatch": "^4.0.7",
55
+ "lucia": "^3.2.0",
56
+ "arctic": "^1.9.1",
57
+ "@unocss/astro": "^0.62.3",
58
+ "@unocss/reset": "^0.62.3",
59
+ "astro-integration-kit": "^0.16.1",
60
+ "daisyui": "^4.12.10",
61
+ "marked": "^13.0.2",
62
+ "marked-alert": "^2.0.1",
63
+ "marked-emoji": "^1.4.1",
64
+ "marked-footnote": "^1.2.2",
65
+ "marked-shiki": "^1.1.0",
66
+ "marked-smartypants": "^1.1.7",
67
+ "mrmime": "^2.0.0",
68
+ "shiki": "^1.14.1",
69
+ "semver": "^7.6.3",
70
+ "package-json": "^10.0.1",
71
+ "unpic": "^3.18.0",
72
+ "unocss": "^0.62.3",
73
+ "@studiocms/assets": "0.1.0-beta.5",
74
+ "@studiocms/auth": "0.1.0-beta.5",
75
+ "@studiocms/betaresources": "0.1.0-beta.5",
76
+ "@studiocms/core": "0.1.0-beta.5",
77
+ "@studiocms/dashboard": "0.1.0-beta.5",
78
+ "@studiocms/frontend": "0.1.0-beta.5",
79
+ "@studiocms/imagehandler": "0.1.0-beta.5",
80
+ "@studiocms/renderers": "0.1.0-beta.5",
81
+ "@studiocms/robotstxt": "0.1.0-beta.5"
82
+ },
83
+ "peerDependencies": {
84
+ "@astrojs/db": ">=0.14",
85
+ "astro": ">=4.15",
86
+ "@studiocms/blog": "0.1.0-beta.5"
87
+ },
88
+ "peerDependenciesMeta": {
89
+ "@studiocms/blog": {
90
+ "optional": true
91
+ }
92
+ },
93
+ "devDependencies": {
94
+ "vite": "^5.4.2",
95
+ "typescript": "^5.5.4",
96
+ "@types/micromatch": "^4.0.9",
97
+ "@types/semver": "^7.5.8"
98
+ }
99
+ }
@@ -0,0 +1,35 @@
1
+ import studioCMSBlog from '@studiocms/blog';
2
+
3
+ /**
4
+ * # StudioCMS Blog Theme(Integration)
5
+ * *Note: To use this export, you must have `@studiocms/blog` installed in your project dependencies.*
6
+ * #### Powered by [`astro-theme-provider`](https://github.com/astrolicious/astro-theme-provider) by [Bryce Russell](https://github.com/BryceRussell)
7
+ *
8
+ * This theme provides a Blog Index Page and RSS Feed for your StudioCMS Site as well as route handling for Blog Posts.
9
+ *
10
+ * @example
11
+ * import { defineConfig } from 'astro/config';
12
+ * import db from '@astrojs/db';
13
+ * import studioCMS from 'studiocms';
14
+ * import studioCMSBlog from 'studiocms/blog';
15
+ *
16
+ * // https://astro.build/config
17
+ * export default defineConfig({
18
+ * site: "https://example.com",
19
+ * output: "server",
20
+ * adapter: ...
21
+ * integrations: [
22
+ * db(), // REQUIRED - `@astrojs/db` must be included in the integrations list
23
+ * studioCMS(), // REQUIRED - StudioCMS must be included in the integrations list
24
+ * studioCMSBlog({
25
+ * config: {
26
+ * title: "My StudioCMS Blog",
27
+ * description: "A Simple Blog build with Astro, Astrojs/DB, and StudioCMS.".
28
+ * },
29
+ * }),
30
+ * ],
31
+ * });
32
+ */
33
+ const integration = studioCMSBlog;
34
+
35
+ export default integration;
package/src/index.ts ADDED
@@ -0,0 +1,25 @@
1
+ import { defineStudioCMSConfig, defineStudioCMSPlugin } from '@studiocms/core/lib';
2
+ import type { StudioCMSPluginOptions } from '@studiocms/core/types';
3
+ import integration from './integration';
4
+
5
+ /**
6
+ * # Astro Studio CMS Integration
7
+ *
8
+ * A CMS built for Astro by the Astro Community for the Astro Community.
9
+ *
10
+ * Checkout our [GitHub Repo `@astrolicious/studiocms`](https://github.com/astrolicious/studiocms)
11
+ *
12
+ * Check out [Astro-StudioCMS.xyz](https://astro-studiocms.xyz) or the Built-in JSDocs *(Hover Docs like this)* for more information.
13
+ *
14
+ * > **Note: Astro SSR adapters that are configured for Image Optimization will automatically take full control of the Image Optimization Service. Making the `imageService` option in this integration not have any effect.**
15
+ *
16
+ */
17
+ export const studioCMS = integration;
18
+
19
+ export default studioCMS;
20
+
21
+ // Config Utility
22
+ export { defineStudioCMSConfig };
23
+
24
+ // Plugin System
25
+ export { defineStudioCMSPlugin, type StudioCMSPluginOptions };
@@ -0,0 +1,94 @@
1
+ import { addIntegrationArray } from '@matthiesenxyz/integration-utils/aikUtils';
2
+ import {
3
+ integrationLogger,
4
+ nodeNamespaceBuiltinsAstro,
5
+ } from '@matthiesenxyz/integration-utils/astroUtils';
6
+ import studioCMSAuth from '@studiocms/auth';
7
+ import studioCMSCore from '@studiocms/core';
8
+ import { getStudioConfigFileUrl, studioCMSPluginList } from '@studiocms/core/lib';
9
+ import {
10
+ type StudioCMSOptions,
11
+ StudioCMSOptionsSchema as optionsSchema,
12
+ } from '@studiocms/core/schemas';
13
+ import { CoreStrings, robotsTXTPreset } from '@studiocms/core/strings';
14
+ import {
15
+ addIntegrationArrayWithCheck,
16
+ checkAstroConfig,
17
+ configResolver,
18
+ } from '@studiocms/core/utils';
19
+ import studioCMSDashboard from '@studiocms/dashboard';
20
+ import studioCMSFrontend from '@studiocms/frontend';
21
+ import studiocmsImageHandler from '@studiocms/imagehandler';
22
+ import studiocmsRenderers from '@studiocms/renderers';
23
+ import studioCMSRobotsTXT from '@studiocms/robotstxt';
24
+ import { defineIntegration } from 'astro-integration-kit';
25
+ import { name, version } from '../package.json';
26
+ import { updateCheck } from './updateCheck';
27
+
28
+ // Main Integration
29
+ export default defineIntegration({
30
+ name,
31
+ optionsSchema,
32
+ setup({ name, options }) {
33
+ // Register StudioCMS into the StudioCMS Plugin List
34
+ studioCMSPluginList.set(name, { name, label: 'StudioCMS' });
35
+
36
+ // Resolve Options
37
+ let resolvedOptions: StudioCMSOptions;
38
+
39
+ return {
40
+ hooks: {
41
+ // Configure `@astrojs/db` integration to include the StudioCMS Database Tables
42
+ 'astro:db:setup': ({ extendDb }) => {
43
+ extendDb({ configEntrypoint: '@studiocms/core/db/config' });
44
+ },
45
+ 'astro:config:setup': async (params) => {
46
+ // Destructure Params
47
+ const { config: astroConfig, addWatchFile, logger } = params;
48
+
49
+ // Watch the StudioCMS Config File for changes (including creation/deletion)
50
+ addWatchFile(getStudioConfigFileUrl(astroConfig.root));
51
+
52
+ // Resolve Options
53
+ resolvedOptions = await configResolver(params, options);
54
+
55
+ // Setup Logger
56
+ integrationLogger(
57
+ { logger, logLevel: 'info', verbose: resolvedOptions.verbose },
58
+ CoreStrings.Start
59
+ );
60
+
61
+ // Check Astro Config for required settings
62
+ checkAstroConfig(params);
63
+
64
+ // Setup Integrations (Internal)
65
+ addIntegrationArray(params, [
66
+ { integration: nodeNamespaceBuiltinsAstro() },
67
+ { integration: studioCMSCore(resolvedOptions) },
68
+ { integration: studioCMSFrontend(resolvedOptions) },
69
+ { integration: studiocmsImageHandler(resolvedOptions) },
70
+ { integration: studiocmsRenderers() },
71
+ { integration: studioCMSAuth(resolvedOptions) },
72
+ { integration: studioCMSDashboard(resolvedOptions) },
73
+ ]);
74
+
75
+ // Setup Integrations (External / Optional)
76
+ addIntegrationArrayWithCheck(params, [
77
+ {
78
+ enabled: resolvedOptions.includedIntegrations.useAstroRobots,
79
+ knownSimilar: ['astro-robots', 'astro-robots-txt'],
80
+ integration: studioCMSRobotsTXT({
81
+ ...robotsTXTPreset,
82
+ ...resolvedOptions.includedIntegrations.astroRobotsConfig,
83
+ }),
84
+ },
85
+ ]);
86
+ },
87
+ 'astro:server:start': async (params) => {
88
+ // Check for Updates on Development Server Start
89
+ updateCheck(params, name, version);
90
+ },
91
+ },
92
+ };
93
+ },
94
+ });
@@ -0,0 +1,51 @@
1
+ import { defineUtility } from 'astro-integration-kit';
2
+ import packageJson from 'package-json';
3
+ import * as semver from 'semver';
4
+
5
+ /**
6
+ * Fetches the latest version of a package from the npm registry.
7
+ * @param packageName - The name of the package.
8
+ * @returns A promise that resolves to the latest version of the package.
9
+ */
10
+ async function fetchlatestVersion(packageName: string): Promise<string> {
11
+ const { version } = await packageJson(packageName.toLowerCase());
12
+ return version;
13
+ }
14
+
15
+ /**
16
+ * Checks for updates of a specified package on npm registry.
17
+ * @param {import("astro").HookParameters<"astro:config:setup">} params - The Astro parameters object.
18
+ * @param currentVersion - The current version of the package.
19
+ */
20
+ export const updateCheck = defineUtility('astro:server:start')(
21
+ async (params, name: string, currentVersion: string): Promise<void> => {
22
+ const logger = params.logger.fork(`${name}:update-check`);
23
+
24
+ try {
25
+ const latestVersion = await fetchlatestVersion(name);
26
+
27
+ const comparison = semver.compare(currentVersion, latestVersion);
28
+
29
+ if (comparison === -1) {
30
+ logger.warn(
31
+ `A new version of 'studiocms' is available. Please update to ${latestVersion} using your favorite package manager.`
32
+ );
33
+ } else if (comparison === 0) {
34
+ logger.info(`You are using the latest version of '${name}' (${currentVersion})`);
35
+ } else {
36
+ logger.info(
37
+ `You are using a newer version (${currentVersion}) of '${name}' than the latest release (${latestVersion})`
38
+ );
39
+ }
40
+ } catch (error) {
41
+ if (error instanceof Error) {
42
+ logger.error(`Error fetching latest version from npm registry: ${error.message}`);
43
+ } else {
44
+ // Handle the case where error is not an Error object
45
+ logger.error(
46
+ 'An unknown error occurred while fetching the latest version from the npm registry.'
47
+ );
48
+ }
49
+ }
50
+ }
51
+ );