Skip to content

Commit

Permalink
Merge branch 'dev' into rec
Browse files Browse the repository at this point in the history
  • Loading branch information
rharkor committed Sep 17, 2024
2 parents d760c69 + ccfd78c commit 89271ee
Show file tree
Hide file tree
Showing 55 changed files with 1,223 additions and 4,000 deletions.
7 changes: 7 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
"pkgRoot": "packages/cli"
}
],
[
"@semantic-release/npm",
{
"npmPublish": true,
"pkgRoot": "packages/cli-helpers"
}
],
[
"@semantic-release/commit-analyzer",
{
Expand Down
3,557 changes: 209 additions & 3,348 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions packages/cli-app/depcheck.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"ignoreMatches": [
"@babel/core",
"eslint",
"postcss",
"autoprefixer",
"client-only"
]
}
16 changes: 8 additions & 8 deletions packages/cli-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"prettier": "prettier --check \"**/*.{js,jsx,ts,tsx}\"",
"prettier:fix": "prettier --write \"**/*.{js,jsx,ts,tsx}\""
},
"depcheck": false,
"devDependencies": {
"@babel/core": "^7.22.17",
"@formatjs/intl-localematcher": "^0.5.0",
Expand All @@ -21,6 +20,9 @@
},
"dependencies": {
"@hookform/resolvers": "^3.9.0",
"@next-boilerplate/cli-helpers": "*",
"@next-boilerplate/prettier": "*",
"@next-boilerplate/tsconfig": "*",
"@nextui-org/avatar": "^2.0.32",
"@nextui-org/button": "^2.0.37",
"@nextui-org/checkbox": "^2.1.4",
Expand All @@ -39,8 +41,8 @@
"@nextui-org/tooltip": "^2.0.39",
"@react-aria/ssr": "^3.9.5",
"@react-aria/visually-hidden": "^3.8.14",
"@rharkor/logger": "^1.3.1",
"@tanstack/react-query": "^5.56.2",
"@tanstack/react-query-devtools": "^5.39.0",
"@total-typescript/ts-reset": "^0.5.0",
"@trpc/client": "^11.0.0-rc.502",
"@trpc/react-query": "^11.0.0-rc.502",
Expand All @@ -53,23 +55,21 @@
"base32-encode": "^2.0.0",
"client-only": "^0.0.1",
"clsx": "^2.0.0",
"cross-env": "^7.0.3",
"framer-motion": "^11.0.0",
"fs-extra": "^11.2.0",
"globby": "^14.0.2",
"lucide-react": "^0.408.0",
"negotiator": "^0.6.3",
"next": "^14.2.4",
"next": "^14.2.11",
"next-themes": "^0.3.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-dropzone": "^14.2.3",
"react-hook-form": "^7.45.4",
"react-toastify": "^10.0.0",
"server-only": "^0.0.1",
"superjson": "^2.0.0",
"tailwind-merge": "^2.0.0",
"tar": "^7.4.3",
"tsx": "^4.7.0",
"uuid": "^10.0.0",
"zod": "^3.23.8"
}
}
}
7 changes: 3 additions & 4 deletions packages/cli-app/src/api/configuration/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { z } from "zod"

import { getConfiguration, setConfiguration } from "@/lib/configuration"
import { env } from "@/lib/env"
import { rootPluginsDirectory } from "@/lib/plugins"
import { rootAssetsDirectory } from "@/lib/plugins"
import { handleApiError } from "@/lib/utils/server-utils"
import { apiInputFromSchema } from "@/types"
import { applyConfigurationTask } from "@next-boilerplate/scripts/utils/template-config/apply.js"
import { applyConfigurationTask } from "@next-boilerplate/cli-helpers/apply"

import { updateConfigurationRequestSchema, updateConfigurationResponseSchema } from "./schemas"

Expand Down Expand Up @@ -45,8 +45,7 @@ export const applyConfiguration = async ({}: apiInputFromSchema<typeof undefined

//* Apply the configuration
await applyConfigurationTask({
configFileName: "config.json",
pluginsDirectory: rootPluginsDirectory,
assetsDirectory: rootAssetsDirectory,
root: env.ROOT_PATH,
noTask: true,
})
Expand Down
26 changes: 25 additions & 1 deletion packages/cli-app/src/api/configuration/queries.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,38 @@
import { z } from "zod"

import { getConfiguration } from "@/lib/configuration"
import { getPlugins } from "@/lib/plugins"
import { handleApiError } from "@/lib/utils/server-utils"
import { apiInputFromSchema } from "@/types"
import { getStoreUID } from "@next-boilerplate/cli-helpers/stores"
import { TRPCError } from "@trpc/server"

import { getConfigurationResponseSchema } from "./schemas"

export const getConfigurationQuery = async ({}: apiInputFromSchema<typeof undefined>) => {
try {
const configuration = await getConfiguration()
const _configuration = await getConfiguration()
const plugins = await getPlugins()

const configuration = {
..._configuration,
plugins: _configuration.plugins?.map((plugin) => {
const foundPlugin = plugins.find(
(p) => p.sourcePath === plugin.sourcePath && getStoreUID(p.store) === getStoreUID(plugin.store)
)
if (!foundPlugin) {
throw new TRPCError({
message: `The plugin ${plugin.sourcePath} was not found (store: ${plugin.store.name}@${plugin.store.version}). Currently available plugins: ${plugins.map((p) => p.sourcePath).join(", ")}`,
code: "INTERNAL_SERVER_ERROR",
})
}

return {
...plugin,
remotePlugin: foundPlugin,
}
}),
}

const data: z.infer<ReturnType<typeof getConfigurationResponseSchema>> = { configuration }
return data
Expand Down
27 changes: 17 additions & 10 deletions packages/cli-app/src/api/configuration/schemas.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
import { z } from "zod"

import { fullPluginSchema } from "@/lib/plugins/types"
import { storeNameRegex, storeVersionRegex } from "@next-boilerplate/scripts/utils/template-config/index.js"
import { pluginSchema } from "@next-boilerplate/cli-helpers/plugins"
import { storeSchema } from "@next-boilerplate/cli-helpers/stores"

export const configurationSchema = () =>
z.object({
name: z.string().optional(),
plugins: z.array(fullPluginSchema).optional(),
stores: z
.array(
z.object({
name: z.string().regex(storeNameRegex),
version: z.string().regex(storeVersionRegex),
})
)
.optional(),
stores: z.array(storeSchema).optional(),
})
export type TConfiguration = z.infer<ReturnType<typeof configurationSchema>>

export const getConfigurationResponseSchema = () => z.object({ configuration: configurationSchema() })
export const getConfigurationResponseSchema = () =>
z.object({
configuration: configurationSchema()
.omit({ plugins: true })
.extend({
plugins: z
.array(
fullPluginSchema.extend({
remotePlugin: pluginSchema,
})
)
.optional(),
}),
})

export const updateConfigurationRequestSchema = () => z.object({ configuration: configurationSchema() })
export const updateConfigurationResponseSchema = () => z.object({ configuration: configurationSchema() })
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-app/src/api/plugins/schemas.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { z } from "zod"

import { fullPluginSchema, singlePluginSchema } from "@/lib/plugins/types"
import { storeConfigSchema } from "@next-boilerplate/scripts/utils/template-config/index.js"
import { storeConfigSchema } from "@next-boilerplate/cli-helpers/stores"

export const getPluginsSchema = () =>
z.object({
Expand Down
20 changes: 14 additions & 6 deletions packages/cli-app/src/api/stores/mutations.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { z } from "zod"

import { getConfiguration, setConfiguration } from "@/lib/configuration"
import { handleDeleteStore, handleDownloadStore } from "@/lib/stores"
import { assetsDirectory, getConfiguration, setConfiguration } from "@/lib/configuration"
import { handleApiError } from "@/lib/utils/server-utils"
import { apiInputFromSchema } from "@/types"
import { getStoreUID } from "@next-boilerplate/cli-helpers/stores"
import { handleDeleteStore, handleDownloadStore } from "@next-boilerplate/cli-helpers/stores-helpers"

import {
deleteStoreRequestSchema,
Expand All @@ -16,7 +17,11 @@ export const installOrUpdateStore = async ({
input: { store },
}: apiInputFromSchema<typeof installOrUpdateStoreRequestSchema>) => {
try {
await handleDownloadStore(store, true)
await handleDownloadStore({
override: true,
assetsDirectory,
store,
})

const data: z.infer<ReturnType<typeof installOrUpdateStoreResponseSchema>> = { success: true }
return data
Expand All @@ -32,12 +37,15 @@ export const deleteStore = async ({ input: { store } }: apiInputFromSchema<typeo
// Remove store from configuration
await setConfiguration({
...configuration,
plugins: configuration.plugins?.filter((p) => p.name !== store.name),
stores: configuration.stores?.filter((s) => s.name !== store.name),
plugins: configuration.plugins?.filter((p) => getStoreUID(p.store) !== getStoreUID(store)),
stores: configuration.stores?.filter((s) => getStoreUID(s) !== getStoreUID(store)),
})

// Delete form store folder
await handleDeleteStore(store)
await handleDeleteStore({
assetsDirectory,
store,
})

const data: z.infer<ReturnType<typeof deleteStoreResponseSchema>> = { success: true }
return data
Expand Down
5 changes: 3 additions & 2 deletions packages/cli-app/src/api/stores/queries.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { z } from "zod"

import { getStores } from "@/lib/stores"
import { assetsDirectory } from "@/lib/configuration"
import { handleApiError } from "@/lib/utils/server-utils"
import { apiInputFromSchema } from "@/types"
import { getStores } from "@next-boilerplate/cli-helpers/stores-helpers"

import { getStoresResponseSchema } from "./schemas"

export const getStoresQuery = async ({}: apiInputFromSchema<typeof undefined>) => {
try {
const stores = await getStores()
const stores = await getStores({ assetsDirectory })

const data: z.infer<ReturnType<typeof getStoresResponseSchema>> = { stores }
return data
Expand Down
3 changes: 1 addition & 2 deletions packages/cli-app/src/api/stores/schemas.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { z } from "zod"

import { fullStoreSchema } from "@/lib/stores"
import { storeConfigSchema } from "@next-boilerplate/scripts/utils/template-config/index.js"
import { fullStoreSchema, storeConfigSchema } from "@next-boilerplate/cli-helpers/stores"

export const getStoresResponseSchema = () => z.object({ stores: z.array(fullStoreSchema) })

Expand Down
2 changes: 1 addition & 1 deletion packages/cli-app/src/api/templates/schemas.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { z } from "zod"

import { fullTemplateSchema, singleTemplateSchema } from "@/lib/templates/types"
import { storeConfigSchema } from "@next-boilerplate/scripts/utils/template-config/index.js"
import { storeConfigSchema } from "@next-boilerplate/cli-helpers/stores"

export const getTemplatesSchema = () =>
z.object({
Expand Down
Loading

0 comments on commit 89271ee

Please sign in to comment.