Chore: Upgrade to AIK & Massive Overhaul to internal processing #78

Merged
Adammatthiesen merged 46 commits from issue-77-Chore_Upgrade_to_utilize_AIK_&_Massive_integration_overhaul into main 2024-03-07 12:08:19 +00:00
Adammatthiesen commented 2024-03-03 19:46:03 +00:00 (Migrated from github.com)

This PR is described under Issue #77

This PR is described under Issue #77
changeset-bot[bot] commented 2024-03-03 19:46:06 +00:00 (Migrated from github.com)

🦋 Changeset detected

Latest commit: b6ba6fedc1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@matthiesenxyz/create-astro-ghostcms Minor
@matthiesenxyz/astro-ghostcms Minor
@matthiesenxyz/starlight-ghostcms Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

### 🦋 Changeset detected Latest commit: b6ba6fedc18e8090925b147c7d856e30a484dea7 **The changes in this PR will be included in the next version bump.** <details><summary>This PR includes changesets to release 3 packages</summary> | Name | Type | | ------------------------------------ | ----- | | @matthiesenxyz/create-astro-ghostcms | Minor | | @matthiesenxyz/astro-ghostcms | Minor | | @matthiesenxyz/starlight-ghostcms | Minor | </details> Not sure what this means? [Click here to learn what changesets are](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md). [Click here if you're a maintainer who wants to add another changeset to this PR](https://github.com/MatthiesenXYZ/astro-ghostcms/new/issue-77-Chore_Upgrade_to_utilize_AIK_&_Massive_integration_overhaul?filename=.changeset/thin-trainers-draw.md&value=---%0A%22%40matthiesenxyz%2Fastro-ghostcms%22%3A%20patch%0A---%0A%0AChore%3A%20Upgrade%20to%20%60AIK%60%20%26%20Massive%20Overhaul%20to%20internal%20processing%0A)
Adammatthiesen commented 2024-03-03 21:18:36 +00:00 (Migrated from github.com)

@florian-lefebvre

Just a note, this PR is really only about packages/astro-ghostcms the 2 other packages just got Linted at the same time 😂 so no worry's about the other ones only the main one.

@florian-lefebvre Just a note, this PR is really only about `packages/astro-ghostcms` the 2 other packages just got Linted at the same time 😂 so no worry's about the other ones only the main one.
florian-lefebvre (Migrated from github.com) reviewed 2024-03-04 13:22:06 +00:00
florian-lefebvre (Migrated from github.com) left a comment

the astro-ghostcms integration looks good! the only reviews i left are for minor things, nothing critical. btw I think you should create some little utility functions for the redundant tasks, like adding an integration and warning if verbose

the `astro-ghostcms` integration looks good! the only reviews i left are for minor things, nothing critical. btw I think you should create some little utility functions for the redundant tasks, like adding an integration and warning if verbose
@ -63,0 +64,4 @@
// Config Options
ghostURL: "http://example.com", // Recommended to set here, Can also set in .env as CONTENT_API_URL
ThemeProvider: { // Allows you to pass config options to our ThemeProvider if enabled.
disableThemeProvider: false, // OPTIONAL - Default False
florian-lefebvre (Migrated from github.com) commented 2024-03-04 13:13:43 +00:00

a matter of preferences i guess but i'd expect any property in the options to follow camelCase

a matter of preferences i guess but i'd expect any property in the options to follow `camelCase`
@ -0,0 +19,4 @@
const ghostUrl = CONF_URL || CONTENT_API_URL || "";
const version = "v5.0";
const api = new TSGhostContentAPI(ghostUrl, ghostApiKey, version);
florian-lefebvre (Migrated from github.com) commented 2024-03-04 13:15:38 +00:00

idk if you type this using a .d.ts file currently but fyi that's a nice dx improvement

idk if you type this using a `.d.ts` file currently but fyi that's a nice dx improvement
florian-lefebvre (Migrated from github.com) commented 2024-03-04 13:18:08 +00:00
				} else if (verbose) {
					GhostIntegrationLogger.info(c.gray("Theme Provider is disabled"));
				}
```suggestion } else if (verbose) { GhostIntegrationLogger.info(c.gray("Theme Provider is disabled")); } ```
florian-lefebvre (Migrated from github.com) commented 2024-03-04 13:18:25 +00:00

same here

same here
florian-lefebvre (Migrated from github.com) commented 2024-03-04 13:18:38 +00:00

same here

same here
florian-lefebvre (Migrated from github.com) commented 2024-03-04 13:18:54 +00:00

same here

same here
florian-lefebvre (Migrated from github.com) commented 2024-03-04 13:20:35 +00:00

is there a reason for not importing it at the top of the file? if yes, I think you can use resolve from createResolver for the path

is there a reason for not importing it at the top of the file? if yes, I think you can use `resolve` from `createResolver` for the path
Adammatthiesen (Migrated from github.com) reviewed 2024-03-04 16:00:44 +00:00
Adammatthiesen (Migrated from github.com) commented 2024-03-04 16:00:44 +00:00

This is simply to display any new version during dev-mode only... There is a check for latest version and it compares the local version :D

This is simply to display any new version during dev-mode only... There is a check for latest version and it compares the local version :D
florian-lefebvre (Migrated from github.com) reviewed 2024-03-04 16:13:10 +00:00
florian-lefebvre (Migrated from github.com) commented 2024-03-04 16:13:10 +00:00

ah this pulls the version from the user's project?

ah this pulls the version from the user's project?
Adammatthiesen (Migrated from github.com) reviewed 2024-03-04 16:52:41 +00:00
@ -63,0 +64,4 @@
// Config Options
ghostURL: "http://example.com", // Recommended to set here, Can also set in .env as CONTENT_API_URL
ThemeProvider: { // Allows you to pass config options to our ThemeProvider if enabled.
disableThemeProvider: false, // OPTIONAL - Default False
Adammatthiesen (Migrated from github.com) commented 2024-03-04 16:52:40 +00:00

"The first letter may or may not be capitalized in CamelCase. This difference is called UpperCamelCase and lowerCamelCase. PascalCase always has the first letter capitalized."

According the camelCase this convention is acceptable. I mainly switched to UpperCamelCase for the Arrays that handle multiple different things, such as the Integations Options that passes through to the internal integrations and the ThemeProvider which is going to become a much bigger internal entity to control how the theme system is going to work, the goal being to expand to more options for being able to add to an already built astro project or use a pre-built.

"The first letter may or may not be capitalized in CamelCase. This difference is called UpperCamelCase and [lowerCamelCase](https://www.techtarget.com/whatis/definition/lowerCamelCase). PascalCase always has the first letter capitalized." According the `camelCase` this convention is acceptable. I mainly switched to UpperCamelCase for the Arrays that handle multiple different things, such as the `Integations` Options that passes through to the internal integrations and the `ThemeProvider` which is going to become a much bigger internal entity to control how the theme system is going to work, the goal being to expand to more options for being able to add to an already built astro project or use a pre-built.
Adammatthiesen (Migrated from github.com) reviewed 2024-03-04 16:56:02 +00:00
@ -0,0 +19,4 @@
const ghostUrl = CONF_URL || CONTENT_API_URL || "";
const version = "v5.0";
const api = new TSGhostContentAPI(ghostUrl, ghostApiKey, version);
Adammatthiesen (Migrated from github.com) commented 2024-03-04 16:56:02 +00:00

Virtual config is just the first step(And yeah, I'm using a virtual.d.ts to keep track of types locally XD) , the New Theme Provider will have an entire virtual component system like how astro-blog works(Future Plan), giving more flexibility on top of being able to do full theme takeover like current function

Virtual config is just the first step(And yeah, I'm using a `virtual.d.ts` to keep track of types locally XD) , the New Theme Provider will have an entire virtual component system like how `astro-blog` works(Future Plan), giving more flexibility on top of being able to do full theme takeover like current function
Adammatthiesen (Migrated from github.com) reviewed 2024-03-04 16:57:04 +00:00
Adammatthiesen (Migrated from github.com) commented 2024-03-04 16:57:03 +00:00

I ALWAYS FORGET YOU CAN DO else if vscode should complain if you do an else { if() lol

I ALWAYS FORGET YOU CAN DO `else if` vscode should complain if you do an `else { if()` lol
florian-lefebvre (Migrated from github.com) reviewed 2024-03-04 17:07:22 +00:00
@ -63,0 +64,4 @@
// Config Options
ghostURL: "http://example.com", // Recommended to set here, Can also set in .env as CONTENT_API_URL
ThemeProvider: { // Allows you to pass config options to our ThemeProvider if enabled.
disableThemeProvider: false, // OPTIONAL - Default False
florian-lefebvre (Migrated from github.com) commented 2024-03-04 17:07:22 +00:00

as i said, only a matter of preferences!

as i said, only a matter of preferences!
florian-lefebvre (Migrated from github.com) reviewed 2024-03-04 17:07:49 +00:00
florian-lefebvre (Migrated from github.com) commented 2024-03-04 17:07:49 +00:00

i think if you have eslint you can enable such a rule

i think if you have eslint you can enable such a rule
Adammatthiesen (Migrated from github.com) reviewed 2024-03-04 17:16:19 +00:00
Adammatthiesen (Migrated from github.com) commented 2024-03-04 17:16:19 +00:00

grabs the current installed one from astro-ghostcms local version and compares to the latestversion from NPM :P I did actually try to use the resolve() util but that just grabbed the playgrounds package.json ironically...

grabs the current installed one from `astro-ghostcms` local version and compares to the latestversion from NPM :P I did actually try to use the `resolve()` util but that just grabbed the playgrounds package.json ironically...
jdtjenkins (Migrated from github.com) requested changes 2024-03-04 17:56:05 +00:00
jdtjenkins (Migrated from github.com) commented 2024-03-04 17:44:48 +00:00

This could be called something like verbose or logLevel or something. Most devs would search for verbose for verbose logging

This could be called something like `verbose` or `logLevel` or something. Most devs would search for `verbose` for verbose logging
jdtjenkins (Migrated from github.com) commented 2024-03-04 17:55:58 +00:00

Instead of all these manual checks for verbose you'd probably be better off with a util function which checks it instead.

const log = message => {
  if (verbose) {
    console.log(...)
  }
}

Or could be a Florian special and return a console log function:

const createLogger = verbose => message => {
  if (verbose) {
    console.log(...)
  }
}

const log = createLogger(options.verbose)

log(whatever) // now you don't have to check everywhere
Instead of all these manual checks for `verbose` you'd probably be better off with a util function which checks it instead. ```ts const log = message => { if (verbose) { console.log(...) } } ``` Or could be a Florian special and return a console log function: ```ts const createLogger = verbose => message => { if (verbose) { console.log(...) } } const log = createLogger(options.verbose) log(whatever) // now you don't have to check everywhere ```
Adammatthiesen (Migrated from github.com) reviewed 2024-03-04 18:25:55 +00:00
Adammatthiesen (Migrated from github.com) commented 2024-03-04 18:25:55 +00:00

added in new commit, since im not using console.log had to modify it for my usage a little

added in new commit, since im not using console.log had to modify it for my usage a little
Adammatthiesen (Migrated from github.com) reviewed 2024-03-04 18:28:10 +00:00
Adammatthiesen (Migrated from github.com) commented 2024-03-04 18:28:10 +00:00

updated to verbose... i really don't know why i didn't call it that from the first place XD

updated to verbose... i really don't know why i didn't call it that from the first place XD
Adammatthiesen commented 2024-03-04 19:12:51 +00:00 (Migrated from github.com)

the astro-ghostcms integration looks good! the only reviews i left are for minor things, nothing critical. btw I think you should create some little utility functions for the redundant tasks, like adding an integration and warning if verbose

image
lol there ya go... kind of shocked that worked as easily as it did

> the `astro-ghostcms` integration looks good! the only reviews i left are for minor things, nothing critical. btw I think you should create some little utility functions for the redundant tasks, like adding an integration and warning if verbose ![image](https://github.com/MatthiesenXYZ/astro-ghostcms/assets/30383579/2f136025-a2a8-46b8-9172-35d94b2a8956) lol there ya go... kind of shocked that worked as easily as it did
Adammatthiesen (Migrated from github.com) reviewed 2024-03-04 20:50:42 +00:00
Adammatthiesen (Migrated from github.com) commented 2024-03-04 20:50:42 +00:00

Okay i fixed that issue. Now using resolve() properly 😄

Okay i fixed that issue. Now using `resolve()` properly 😄
florian-lefebvre (Migrated from github.com) approved these changes 2024-03-05 07:42:33 +00:00
jdtjenkins (Migrated from github.com) requested changes 2024-03-05 08:54:44 +00:00
@ -0,0 +40,4 @@
"https://ghost.org",
"1efedd9db174adee2d23d982:4b74dca0219bad629852191af326a45037346c2231240e0f7aec1f9371cc14e8",
// @ts-expect-error
"v4.0",
jdtjenkins (Migrated from github.com) commented 2024-03-05 08:42:34 +00:00

Are these live keys?? Might not want to commit these!

Are these live keys?? Might not want to commit these!
jdtjenkins (Migrated from github.com) commented 2024-03-05 08:46:45 +00:00

This logging function could also be extracted

const formattedMessage = message => `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue(message)}`
This logging function could also be extracted ```ts const formattedMessage = message => `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue(message)}` ```
jdtjenkins (Migrated from github.com) commented 2024-03-05 08:50:58 +00:00

Not a huge fan of this not being camel cased

Not a huge fan of this not being camel cased
jdtjenkins (Migrated from github.com) commented 2024-03-05 08:52:19 +00:00

You can probably resolve these paths instead of exporting it from your package?

You can probably resolve these paths instead of exporting it from your package?
@ -0,0 +22,4 @@
watchIntegration(resolve());
const SatoriLogger = logger.fork(
`${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue(
jdtjenkins (Migrated from github.com) commented 2024-03-05 08:54:08 +00:00

I'd love to see this string as a helper function too

I'd love to see this string as a helper function too
jdtjenkins (Migrated from github.com) commented 2024-03-05 08:54:41 +00:00

Also might be good to have a different name in this package's logs instead of "Astro-GhostCMS". Just then if there's more specific errors for this package the user can pick those up much easier

Also might be good to have a different name in this package's logs instead of "Astro-GhostCMS". Just then if there's more specific errors for this package the user can pick those up much easier
Adammatthiesen (Migrated from github.com) reviewed 2024-03-05 08:58:03 +00:00
@ -0,0 +40,4 @@
"https://ghost.org",
"1efedd9db174adee2d23d982:4b74dca0219bad629852191af326a45037346c2231240e0f7aec1f9371cc14e8",
// @ts-expect-error
"v4.0",
Adammatthiesen (Migrated from github.com) commented 2024-03-05 08:58:02 +00:00

These are Ghosts public demo keys that ghost provides for testing purposes

These are Ghosts public demo keys that ghost provides for testing purposes
Adammatthiesen (Migrated from github.com) reviewed 2024-03-05 08:59:55 +00:00
@ -0,0 +22,4 @@
watchIntegration(resolve());
const SatoriLogger = logger.fork(
`${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue(
Adammatthiesen (Migrated from github.com) commented 2024-03-05 08:59:55 +00:00
`${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue(
						"SatoriOG",
					)}`,

The full snippet actually includes a second name... so it appears in the log as [Astro-GhostCMS/SatoriOG]

```ts `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue( "SatoriOG", )}`, ``` The full snippet actually includes a second name... so it appears in the log as `[Astro-GhostCMS/SatoriOG]`
Adammatthiesen (Migrated from github.com) reviewed 2024-03-05 09:00:35 +00:00
Adammatthiesen (Migrated from github.com) commented 2024-03-05 09:00:35 +00:00

I was told that any Injected route had to be from an export.... I'd be interested in that alternative...

I was told that any Injected route had to be from an export.... I'd be interested in that alternative...
Adammatthiesen (Migrated from github.com) reviewed 2024-03-05 09:02:17 +00:00
Adammatthiesen (Migrated from github.com) commented 2024-03-05 09:02:16 +00:00

fixed... idk how that even happened... lol that must have been done by VSCode when i changed the name of the file 🤣

fixed... idk how that even happened... lol that must have been done by VSCode when i changed the name of the file 🤣
jdtjenkins (Migrated from github.com) reviewed 2024-03-05 09:04:42 +00:00
jdtjenkins (Migrated from github.com) commented 2024-03-05 09:04:42 +00:00

They did in the old days before createResolver ❤️ it just can't be a virtual module

They did in the old days before `createResolver` ❤️ it just can't be a virtual module
Adammatthiesen (Migrated from github.com) reviewed 2024-03-05 09:16:09 +00:00
Adammatthiesen (Migrated from github.com) commented 2024-03-05 09:16:09 +00:00

Updated...


				// Configure Loggers
				const GhostLogger = logger.fork(c.bold(c.blue("👻 Astro-GhostCMS")));

				const loggerTagged = (message: string) => {
					return logger.fork(`${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue(message)}`)
				}

				// Configure ENV Logger
				const GhostENVLogger = loggerTagged("ENV Check");

				// Configure Integration Loggers & verbose logging
				const GhostIntegrationLogger = loggerTagged("Integrations");

				// Configure Route Logger & verbose logging
				const GhostRouteLogger = loggerTagged("Router");
Updated... ```ts // Configure Loggers const GhostLogger = logger.fork(c.bold(c.blue("👻 Astro-GhostCMS"))); const loggerTagged = (message: string) => { return logger.fork(`${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue(message)}`) } // Configure ENV Logger const GhostENVLogger = loggerTagged("ENV Check"); // Configure Integration Loggers & verbose logging const GhostIntegrationLogger = loggerTagged("Integrations"); // Configure Route Logger & verbose logging const GhostRouteLogger = loggerTagged("Router"); ```
Adammatthiesen (Migrated from github.com) reviewed 2024-03-05 09:30:57 +00:00
Adammatthiesen (Migrated from github.com) commented 2024-03-05 09:30:57 +00:00

Yeah.... Thats updated now across the board... and those exports for /rss-routes and /open-graph are now moved to resolve()

Yeah.... Thats updated now across the board... and those exports for `/rss-routes` and `/open-graph` are now moved to `resolve()`
jdtjenkins (Migrated from github.com) reviewed 2024-03-05 09:40:23 +00:00
@ -0,0 +19,4 @@
expect(result.errors).toBeDefined();
expect(result.errors).toHaveLength(1);
} else {
expect(result.data).toBeDefined();
jdtjenkins (Migrated from github.com) commented 2024-03-05 09:40:20 +00:00

You can also use expect({}).toEqual({]) to deep check object equality

You can also use `expect({}).toEqual({])` to deep check object equality
@ -0,0 +1,4 @@
declare module "virtual:@matthiesenxyz/astro-ghostcms/config" {
const Config: import("./src/schemas/userconfig").GhostUserConfig;
export default Config;
jdtjenkins (Migrated from github.com) commented 2024-03-05 09:38:27 +00:00

Is this virtual file one that's copied to the user's project? Or is this an internal dev one? If it gets copied with like injectDts just make sure this relative path is ok

Is this virtual file one that's copied to the user's project? Or is this an internal dev one? If it gets copied with like `injectDts` just make sure this relative path is ok
Adammatthiesen (Migrated from github.com) reviewed 2024-03-05 09:41:53 +00:00
@ -0,0 +1,4 @@
declare module "virtual:@matthiesenxyz/astro-ghostcms/config" {
const Config: import("./src/schemas/userconfig").GhostUserConfig;
export default Config;
Adammatthiesen (Migrated from github.com) commented 2024-03-05 09:41:53 +00:00

internal dev. the virtual for config is not used for anything aside from grabbing the ghostURL for the API :P

internal dev. the virtual for config is not used for anything aside from grabbing the ghostURL for the API :P
Adammatthiesen (Migrated from github.com) reviewed 2024-03-05 09:44:03 +00:00
@ -0,0 +19,4 @@
expect(result.errors).toBeDefined();
expect(result.errors).toHaveLength(1);
} else {
expect(result.data).toBeDefined();
Adammatthiesen (Migrated from github.com) commented 2024-03-05 09:44:03 +00:00

The API Schemas are actually copied from the ts-ghost ones for local dev typing I just copied his tests over for sanity purposes... they succeed... thats about all i know about those ones

The API Schemas are actually copied from the `ts-ghost` ones for local dev typing I just copied his tests over for sanity purposes... they succeed... thats about all i know about those ones
jdtjenkins (Migrated from github.com) approved these changes 2024-03-07 11:47:26 +00:00
jdtjenkins (Migrated from github.com) left a comment

There 100% will be stuff that I've missed! But the integrations themselves look really nice, very clean. Seems to integrate with Starlight well and is generally using AIK to it's fullest!

I haven't tested anything works! But the code looks good 😂

There 100% will be stuff that I've missed! But the integrations themselves look really nice, very clean. Seems to integrate with Starlight well and is generally using AIK to it's fullest! I haven't tested anything works! But the code looks good 😂
jdtjenkins (Migrated from github.com) approved these changes 2024-03-07 12:07:54 +00:00
@ -0,0 +32,4 @@
prerender: true,
});
};
const sanitisedRoute = options.route
jdtjenkins (Migrated from github.com) commented 2024-03-07 12:07:50 +00:00

Guhuhuhuhu it's so beautiful 😭 It's the best fucking line in this PR hands down. I can't believe how beautiful it is!

Guhuhuhuhu it's so beautiful 😭 It's the best fucking line in this PR hands down. I can't believe how beautiful it is!
Sign in to join this conversation.
No description provided.