diff --git a/apps/supplement-stack/CHANGELOG.md b/apps/supplement-stack/CHANGELOG.md index 94f9c0d2..53cfbfdf 100644 --- a/apps/supplement-stack/CHANGELOG.md +++ b/apps/supplement-stack/CHANGELOG.md @@ -1,5 +1,17 @@ # supplement-stack +## 0.0.8 + +### Patch Changes + +- Updated dependencies + - zemble-plugin-auth-otp@0.0.10 + - @zemble/core@0.0.8 + - @zemble/graphql@0.0.12 + - zemble-plugin-apple-app-site-association@0.0.6 + - zemble-plugin-bull@0.0.10 + - zemble-plugin-todo@0.0.8 + ## 0.0.7 ### Patch Changes diff --git a/apps/supplement-stack/package.json b/apps/supplement-stack/package.json index 97efbe1a..bdee7bd6 100644 --- a/apps/supplement-stack/package.json +++ b/apps/supplement-stack/package.json @@ -1,6 +1,6 @@ { "name": "supplement-stack", - "version": "0.0.7", + "version": "0.0.8", "description": "", "main": "app.ts", "private": true, diff --git a/apps/todo-app-with-auth-backend/CHANGELOG.md b/apps/todo-app-with-auth-backend/CHANGELOG.md index b74b7dd5..96483eec 100644 --- a/apps/todo-app-with-auth-backend/CHANGELOG.md +++ b/apps/todo-app-with-auth-backend/CHANGELOG.md @@ -1,5 +1,17 @@ # todo-app-with-auth-backend +## 0.0.8 + +### Patch Changes + +- Updated dependencies + - @zemble/core@0.0.8 + - @zemble/graphql@0.0.12 + - zemble-plugin-apple-app-site-association@0.0.6 + - zemble-plugin-auth-anonymous@0.0.8 + - zemble-plugin-bull@0.0.10 + - zemble-plugin-todo@0.0.8 + ## 0.0.7 ### Patch Changes diff --git a/apps/todo-app-with-auth-backend/package.json b/apps/todo-app-with-auth-backend/package.json index 7ee902a6..4ce687ba 100644 --- a/apps/todo-app-with-auth-backend/package.json +++ b/apps/todo-app-with-auth-backend/package.json @@ -1,6 +1,6 @@ { "name": "todo-app-with-auth-backend", - "version": "0.0.7", + "version": "0.0.8", "description": "", "private": true, "main": "app.ts", diff --git a/packages/apple-app-site-association/CHANGELOG.md b/packages/apple-app-site-association/CHANGELOG.md index 86738193..d16fc1da 100644 --- a/packages/apple-app-site-association/CHANGELOG.md +++ b/packages/apple-app-site-association/CHANGELOG.md @@ -1,5 +1,12 @@ # zemble-plugin-apple-app-site-association +## 0.0.6 + +### Patch Changes + +- Updated dependencies + - @zemble/core@0.0.8 + ## 0.0.5 ### Patch Changes diff --git a/packages/apple-app-site-association/package.json b/packages/apple-app-site-association/package.json index 48f0c83d..8c8fc009 100644 --- a/packages/apple-app-site-association/package.json +++ b/packages/apple-app-site-association/package.json @@ -1,6 +1,6 @@ { "name": "zemble-plugin-apple-app-site-association", - "version": "0.0.5", + "version": "0.0.6", "description": "", "private": true, "main": "plugin.ts", diff --git a/packages/auth-anonymous/CHANGELOG.md b/packages/auth-anonymous/CHANGELOG.md index f9d99306..84ded5ef 100644 --- a/packages/auth-anonymous/CHANGELOG.md +++ b/packages/auth-anonymous/CHANGELOG.md @@ -1,5 +1,14 @@ # zemble-plugin-auth-anonymous +## 0.0.8 + +### Patch Changes + +- Updated dependencies + - @zemble/core@0.0.8 + - @zemble/graphql@0.0.12 + - zemble-plugin-auth@0.0.10 + ## 0.0.7 ### Patch Changes diff --git a/packages/auth-anonymous/package.json b/packages/auth-anonymous/package.json index 0120f289..178d26a8 100644 --- a/packages/auth-anonymous/package.json +++ b/packages/auth-anonymous/package.json @@ -1,6 +1,6 @@ { "name": "zemble-plugin-auth-anonymous", - "version": "0.0.7", + "version": "0.0.8", "description": "", "main": "plugin.ts", "scripts": { diff --git a/packages/auth-api-token/CHANGELOG.md b/packages/auth-api-token/CHANGELOG.md index 9c7bf135..f5f5c9c3 100644 --- a/packages/auth-api-token/CHANGELOG.md +++ b/packages/auth-api-token/CHANGELOG.md @@ -1,5 +1,14 @@ # zemble-plugin-auth-api-token +## 0.0.10 + +### Patch Changes + +- Updated dependencies + - @zemble/core@0.0.8 + - @zemble/graphql@0.0.12 + - zemble-plugin-auth@0.0.10 + ## 0.0.9 ### Patch Changes diff --git a/packages/auth-api-token/package.json b/packages/auth-api-token/package.json index 67affae8..eb647316 100644 --- a/packages/auth-api-token/package.json +++ b/packages/auth-api-token/package.json @@ -1,6 +1,6 @@ { "name": "zemble-plugin-auth-api-token", - "version": "0.0.9", + "version": "0.0.10", "description": "", "main": "plugin.ts", "scripts": { diff --git a/packages/auth-otp/CHANGELOG.md b/packages/auth-otp/CHANGELOG.md index 26105b87..5a848ebf 100644 --- a/packages/auth-otp/CHANGELOG.md +++ b/packages/auth-otp/CHANGELOG.md @@ -1,5 +1,16 @@ # zemble-plugin-auth-otp +## 0.0.10 + +### Patch Changes + +- Fix dependency resolution +- Updated dependencies + - @zemble/core@0.0.8 + - @zemble/graphql@0.0.12 + - zemble-plugin-kv@0.0.10 + - zemble-plugin-auth@0.0.10 + ## 0.0.9 ### Patch Changes diff --git a/packages/auth-otp/package.json b/packages/auth-otp/package.json index b4eeac55..ba39a55c 100644 --- a/packages/auth-otp/package.json +++ b/packages/auth-otp/package.json @@ -1,6 +1,6 @@ { "name": "zemble-plugin-auth-otp", - "version": "0.0.9", + "version": "0.0.10", "description": "", "main": "plugin.ts", "scripts": { diff --git a/packages/auth-otp/plugin.ts b/packages/auth-otp/plugin.ts index 5288d0fc..9cc4eb56 100644 --- a/packages/auth-otp/plugin.ts +++ b/packages/auth-otp/plugin.ts @@ -96,7 +96,7 @@ const plugin = new Plugin(__dirname, { devConfig: { handleAuthRequest: ({ email }, code, { logger }) => { logger.log(`handleAuthRequest for ${email}`, code) }, generateTokenContents, - from: { email: 'noreply@Zemble.com' }, + from: { email: 'noreply@zemble.com' }, }, }) diff --git a/packages/auth/CHANGELOG.md b/packages/auth/CHANGELOG.md index 21e87915..4b7f66f3 100644 --- a/packages/auth/CHANGELOG.md +++ b/packages/auth/CHANGELOG.md @@ -1,5 +1,13 @@ # zemble-plugin-auth +## 0.0.10 + +### Patch Changes + +- Updated dependencies + - @zemble/core@0.0.8 + - @zemble/graphql@0.0.12 + ## 0.0.9 ### Patch Changes diff --git a/packages/auth/package.json b/packages/auth/package.json index 82798cec..92e8ba1f 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "zemble-plugin-auth", - "version": "0.0.9", + "version": "0.0.10", "description": "", "main": "plugin.ts", "bin": { diff --git a/packages/bull/CHANGELOG.md b/packages/bull/CHANGELOG.md index 490a87b1..cf3cd80a 100644 --- a/packages/bull/CHANGELOG.md +++ b/packages/bull/CHANGELOG.md @@ -1,5 +1,14 @@ # zemble-plugin-bull +## 0.0.10 + +### Patch Changes + +- Updated dependencies + - @zemble/core@0.0.8 + - @zemble/graphql@0.0.12 + - zemble-plugin-auth@0.0.10 + ## 0.0.9 ### Patch Changes diff --git a/packages/bull/package.json b/packages/bull/package.json index 1cf48f42..8c99db05 100644 --- a/packages/bull/package.json +++ b/packages/bull/package.json @@ -1,6 +1,6 @@ { "name": "zemble-plugin-bull", - "version": "0.0.9", + "version": "0.0.10", "description": "", "main": "plugin.ts", "scripts": { diff --git a/packages/cms-users/CHANGELOG.md b/packages/cms-users/CHANGELOG.md index 04b22593..77a12223 100644 --- a/packages/cms-users/CHANGELOG.md +++ b/packages/cms-users/CHANGELOG.md @@ -1,5 +1,17 @@ # zemble-plugin-cms-users +## 0.0.8 + +### Patch Changes + +- Updated dependencies + - zemble-plugin-auth-otp@0.0.10 + - @zemble/core@0.0.8 + - @zemble/graphql@0.0.12 + - zemble-plugin-kv@0.0.10 + - zemble-plugin-auth@0.0.10 + - zemble-plugin-cms@0.0.8 + ## 0.0.7 ### Patch Changes diff --git a/packages/cms-users/package.json b/packages/cms-users/package.json index 6193b4e7..0e7e3c2e 100644 --- a/packages/cms-users/package.json +++ b/packages/cms-users/package.json @@ -1,6 +1,6 @@ { "name": "zemble-plugin-cms-users", - "version": "0.0.7", + "version": "0.0.8", "description": "", "main": "plugin.ts", "private": true, diff --git a/packages/cms/CHANGELOG.md b/packages/cms/CHANGELOG.md index c34182eb..79d56798 100644 --- a/packages/cms/CHANGELOG.md +++ b/packages/cms/CHANGELOG.md @@ -1,5 +1,14 @@ # zemble-plugin-cms +## 0.0.8 + +### Patch Changes + +- Updated dependencies + - @zemble/core@0.0.8 + - @zemble/graphql@0.0.12 + - zemble-plugin-auth@0.0.10 + ## 0.0.7 ### Patch Changes diff --git a/packages/cms/package.json b/packages/cms/package.json index 77d13d3b..aefa7f8e 100644 --- a/packages/cms/package.json +++ b/packages/cms/package.json @@ -1,6 +1,6 @@ { "name": "zemble-plugin-cms", - "version": "0.0.7", + "version": "0.0.8", "description": "", "main": "plugin.ts", "private": true, diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 3d38f7bd..855cd254 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,11 @@ # @zemble/core +## 0.0.8 + +### Patch Changes + +- Fix dependency resolution + ## 0.0.7 ### Patch Changes diff --git a/packages/core/Plugin.ts b/packages/core/Plugin.ts index 1e57312c..874a8d21 100644 --- a/packages/core/Plugin.ts +++ b/packages/core/Plugin.ts @@ -4,9 +4,8 @@ import { createApp } from './server' import mergeDeep from './utils/mergeDeep' import { readPackageJson } from './utils/readPackageJson' -import type PluginWithMiddleware from './PluginWithMiddleware' import type { ZembleApp } from './server' -import type { DependenciesResolver, Dependency, PluginOpts } from './types' +import type { Dependency, PluginOpts } from './types' // initialize dotenv before any plugins are loaded/configured configDotenv() @@ -21,7 +20,7 @@ export class Plugin< readonly #devConfig?: TConfig - readonly #dependencies: DependenciesResolver> + readonly dependencies: readonly Plugin[] readonly pluginPath: string @@ -37,8 +36,16 @@ export class Plugin< this.pluginPath = __dirname this.#config = (opts?.defaultConfig ?? {}) as TResolvedConfig this.#devConfig = opts?.devConfig - // @ts-expect-error not the most important - this.#dependencies = opts?.dependencies ?? [] + const deps = opts?.dependencies ?? [] + + const allDeps = (typeof deps === 'function') ? deps(this) : deps + + const filteredDeps = allDeps.filter(this.#filterDevDependencies.bind(this)) + + const resolvedDeps = filteredDeps + .map(({ plugin, config }) => plugin.configure(config)) + + this.dependencies = resolvedDeps if (this.#isPluginDevMode) { void this.#devApp().then((app) => app.start()) @@ -101,28 +108,13 @@ export class Plugin< return this.#config } - get dependencies() { - const allDeps = Promise.resolve((typeof this.#dependencies === 'function') ? this.#dependencies(this) : this.#dependencies) - - return allDeps.then(async (allDeps) => { - const filteredDeps = allDeps.filter(this.#filterDevDependencies.bind(this)) - - const resolvedDeps: Promise = Promise.all(filteredDeps - .map(({ plugin, config }) => plugin.configure(config)) - .flatMap(async (dep) => [dep, ...await dep.dependencies])) - .then((deps) => deps.flat()) - - return resolvedDeps - }) - } - async #devApp(): Promise { const resolved = this.configure(this.#devConfig) return createApp({ plugins: [ - ...await this.dependencies, + ...this.dependencies, resolved, - ] as readonly (Plugin | PluginWithMiddleware)[], + ], }) } diff --git a/packages/core/package.json b/packages/core/package.json index 604e611b..d7aa4f02 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@zemble/core", - "version": "0.0.7", + "version": "0.0.8", "description": "", "main": "index.ts", "scripts": { diff --git a/packages/core/server.ts b/packages/core/server.ts index 6b9bd143..fdf8039f 100644 --- a/packages/core/server.ts +++ b/packages/core/server.ts @@ -54,17 +54,15 @@ export const createApp = async ({ plugins: pluginsBeforeResolvingDeps }: Configu app.use('*', cors()) - const resolved = await Promise.all( - pluginsBeforeResolvingDeps.flatMap(async (plugin) => [...await plugin.dependencies, plugin]), - ).then((plugins) => plugins.flat()) + const resolved = pluginsBeforeResolvingDeps.flatMap((plugin) => [...plugin.dependencies, plugin]) const plugins = resolved.reduce((prev, plugin) => { const existingPlugin = prev.find(({ pluginName }) => pluginName === plugin.pluginName) if (existingPlugin) { - if (existingPlugin.config !== plugin.config) { + if (existingPlugin !== plugin) { // in some situation we can end up with two instances of the same plugin (dependeing on package manager and // other factors). In those cases we use the latest version of the plugin, but try to merge the config - const pluginToUse = existingPlugin.pluginVersion > plugin.pluginVersion + const pluginToUse = existingPlugin.pluginVersion >= plugin.pluginVersion ? existingPlugin.configure(plugin.config) : plugin.configure(existingPlugin.config) diff --git a/packages/core/types.ts b/packages/core/types.ts index 782e9fd7..298d92e3 100644 --- a/packages/core/types.ts +++ b/packages/core/types.ts @@ -110,7 +110,7 @@ export type Dependency = readonly Dependency[] | Promise | ((self: TSelf) => readonly Dependency[]) | ((self: TSelf) => Promise) +export type DependenciesResolver = readonly Dependency[] | ((self: TSelf) => readonly Dependency[]) export type PluginOpts = { /** diff --git a/packages/email-sendgrid/CHANGELOG.md b/packages/email-sendgrid/CHANGELOG.md index f5ff2c17..f5a081ca 100644 --- a/packages/email-sendgrid/CHANGELOG.md +++ b/packages/email-sendgrid/CHANGELOG.md @@ -1,5 +1,14 @@ # zemble-plugin-email-sendgrid +## 0.0.10 + +### Patch Changes + +- Updated dependencies + - @zemble/core@0.0.8 + - @zemble/graphql@0.0.12 + - zemble-plugin-kv@0.0.10 + ## 0.0.9 ### Patch Changes diff --git a/packages/email-sendgrid/package.json b/packages/email-sendgrid/package.json index 3be92eaf..14ea9a19 100644 --- a/packages/email-sendgrid/package.json +++ b/packages/email-sendgrid/package.json @@ -1,6 +1,6 @@ { "name": "zemble-plugin-email-sendgrid", - "version": "0.0.9", + "version": "0.0.10", "description": "", "main": "plugin.ts", "scripts": { diff --git a/packages/graphql-yoga/CHANGELOG.md b/packages/graphql-yoga/CHANGELOG.md index 0a7f8976..60da08c7 100644 --- a/packages/graphql-yoga/CHANGELOG.md +++ b/packages/graphql-yoga/CHANGELOG.md @@ -1,5 +1,13 @@ # @zemble/graphql +## 0.0.12 + +### Patch Changes + +- Fix dependency resolution +- Updated dependencies + - @zemble/core@0.0.8 + ## 0.0.11 ### Patch Changes diff --git a/packages/graphql-yoga/middleware.ts b/packages/graphql-yoga/middleware.ts index ffbb5cb3..3100c4f3 100644 --- a/packages/graphql-yoga/middleware.ts +++ b/packages/graphql-yoga/middleware.ts @@ -135,7 +135,7 @@ const buildMergedSchema = async ( ...await processPluginSchema(pluginPath, { transforms: graphqlSchemaTransforms ?? [], scalars: config.scalars || {}, - skipGraphQLValidation: true, // skip validation so we don't need to provide root queries for plugins where it doesn't make sense + // skipGraphQLValidation: true, // skip validation so we don't need to provide root queries for plugins where it doesn't make sense }), ] @@ -207,15 +207,15 @@ export const middleware: Middleware = (config) => ( }, // eslint-disable-next-line no-nested-ternary context: () => { - const context = (config.yoga?.context - ? (typeof config.yoga.context === 'function' + if (config.yoga?.context) { + const ctx = typeof config.yoga.context === 'function' ? config.yoga.context(globalContext) - : { ...globalContext, ...(config.yoga.context as object) }) - : globalContext) + : { ...globalContext, ...(config.yoga.context as object) } - console.log('CTXXXXXXX', context) + return ctx + } - return context + return globalContext } , }, diff --git a/packages/graphql-yoga/package.json b/packages/graphql-yoga/package.json index 973f5b4d..5879ffec 100644 --- a/packages/graphql-yoga/package.json +++ b/packages/graphql-yoga/package.json @@ -1,6 +1,6 @@ { "name": "@zemble/graphql", - "version": "0.0.11", + "version": "0.0.12", "description": "", "main": "plugin.ts", "scripts": { diff --git a/packages/kv/CHANGELOG.md b/packages/kv/CHANGELOG.md index 2910629d..bf0ff46c 100644 --- a/packages/kv/CHANGELOG.md +++ b/packages/kv/CHANGELOG.md @@ -1,5 +1,14 @@ # zemble-plugin-kv +## 0.0.10 + +### Patch Changes + +- Fix dependency resolution +- Updated dependencies + - @zemble/core@0.0.8 + - @zemble/graphql@0.0.12 + ## 0.0.9 ### Patch Changes diff --git a/packages/kv/package.json b/packages/kv/package.json index a24d38fb..85f05a92 100644 --- a/packages/kv/package.json +++ b/packages/kv/package.json @@ -1,6 +1,6 @@ { "name": "zemble-plugin-kv", - "version": "0.0.9", + "version": "0.0.10", "description": "", "main": "plugin.ts", "scripts": { diff --git a/packages/kv/plugin.ts b/packages/kv/plugin.ts index a6c2df54..bab3a720 100644 --- a/packages/kv/plugin.ts +++ b/packages/kv/plugin.ts @@ -61,6 +61,10 @@ const plugin = new Plugin(__dirname, { useExtendContext((ctx: Zemble.GraphQLContext) => { // eslint-disable-next-line functional/immutable-data ctx.kv = kv + + return { + kv, + } }), ], }, diff --git a/packages/logger-graphql/CHANGELOG.md b/packages/logger-graphql/CHANGELOG.md index 0b619e9f..28be155f 100644 --- a/packages/logger-graphql/CHANGELOG.md +++ b/packages/logger-graphql/CHANGELOG.md @@ -1,5 +1,13 @@ # zemble-plugin-logger-graphql +## 0.0.8 + +### Patch Changes + +- Updated dependencies + - @zemble/core@0.0.8 + - @zemble/graphql@0.0.12 + ## 0.0.7 ### Patch Changes diff --git a/packages/logger-graphql/package.json b/packages/logger-graphql/package.json index 168ab907..a1779e68 100644 --- a/packages/logger-graphql/package.json +++ b/packages/logger-graphql/package.json @@ -1,6 +1,6 @@ { "name": "zemble-plugin-logger-graphql", - "version": "0.0.7", + "version": "0.0.8", "description": "", "main": "plugin.ts", "private": true, diff --git a/packages/todo/CHANGELOG.md b/packages/todo/CHANGELOG.md index 3a85b9d0..093d61f3 100644 --- a/packages/todo/CHANGELOG.md +++ b/packages/todo/CHANGELOG.md @@ -1,5 +1,16 @@ # zemble-plugin-todo +## 0.0.8 + +### Patch Changes + +- Updated dependencies + - @zemble/core@0.0.8 + - @zemble/graphql@0.0.12 + - zemble-plugin-kv@0.0.10 + - zemble-plugin-auth@0.0.10 + - zemble-plugin-auth-anonymous@0.0.8 + ## 0.0.7 ### Patch Changes diff --git a/packages/todo/package.json b/packages/todo/package.json index d17ca297..90d9f76a 100644 --- a/packages/todo/package.json +++ b/packages/todo/package.json @@ -1,6 +1,6 @@ { "name": "zemble-plugin-todo", - "version": "0.0.7", + "version": "0.0.8", "description": "", "main": "plugin.ts", "private": true,