Skip to content

Commit

Permalink
Merge pull request #1278 from rharkor/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
rharkor authored Sep 3, 2024
2 parents f471846 + b0fbf52 commit 4e0d371
Show file tree
Hide file tree
Showing 61 changed files with 824 additions and 538 deletions.
550 changes: 338 additions & 212 deletions _old/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _old/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@
"turbo": "^2.0.4"
},
"license": "MIT",
"packageManager": "[email protected].2"
"packageManager": "[email protected].3"
}
174 changes: 78 additions & 96 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@
"zx": "^8.1.4"
},
"license": "MIT",
"packageManager": "[email protected].2"
"packageManager": "[email protected].3"
}
7 changes: 6 additions & 1 deletion packages/cli/assets/plugins/app/empty/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@
"$schema": "../../component.d.json",
"name": "Empty app directory",
"description": "Generates an empty app directory",
"suggestedPath": "app"
"paths": [
{
"from": "app",
"to": "app"
}
]
}
19 changes: 17 additions & 2 deletions packages/cli/assets/plugins/component.d.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,29 @@
"description": {
"type": "string"
},
"suggestedPath": {
"source": {
"type": "string"
},
"paths": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"from": {
"type": "string"
},
"to": {
"type": "string"
}
}
}
}
},
"required": [
"$schema",
"name",
"description",
"suggestedPath"
"paths"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "../../component.d.json",
"name": "Git hooks",
"description": "Execute git-conventional-commits on commit",
"paths": [
{
"from": ".git-hooks",
"to": ".git-hooks"
},
{
"from": "git-conventional-commits.yaml",
"to": "git-conventional-commits.yaml"
}
]
}
7 changes: 6 additions & 1 deletion packages/cli/assets/plugins/devcontainer/default/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@
"$schema": "../../component.d.json",
"name": "Default devcontainer configuration",
"description": "Open VS Code in a linux container",
"suggestedPath": ".devcontainer"
"paths": [
{
"from": ".devcontainer",
"to": ".devcontainer"
}
]
}

This file was deleted.

6 changes: 0 additions & 6 deletions packages/cli/assets/plugins/githooks/default/config.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"$schema": "../../../component.d.json",
"name": "Default gitHub issue template",
"description": "",
"suggestedPath": ".github/ISSUE_TEMPLATE"
"description": "FitHub issue template with bug report and feature request",
"paths": [
{
"from": "ISSUE_TEMPLATE",
"to": ".github/ISSUE_TEMPLATE"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@
"$schema": "../../../component.d.json",
"name": "Default gitHub workflows",
"description": "Basic github workflows configuration (check, deploy, release)",
"suggestedPath": ".github/workflows"
"paths": [
{
"from": "workflows",
"to": ".github/workflows"
}
]
}
7 changes: 6 additions & 1 deletion packages/cli/assets/plugins/gitignore/default/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@
"$schema": "../../component.d.json",
"name": "Default gitignore",
"description": "Default gitignore configuration",
"suggestedPath": ".gitignore"
"paths": [
{
"from": ".gitignore",
"to": ".gitignore"
}
]
}
7 changes: 6 additions & 1 deletion packages/cli/assets/plugins/license/default/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@
"$schema": "../../component.d.json",
"name": "MIT License",
"description": "",
"suggestedPath": "LICENSE"
"paths": [
{
"from": "LICENSE",
"to": "LICENSE"
}
]
}
7 changes: 6 additions & 1 deletion packages/cli/assets/plugins/makefile/default/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@
"$schema": "../../component.d.json",
"name": "Default makefile",
"description": "Basic makefile with buildnrun command to start a docker app",
"suggestedPath": "Makefile"
"paths": [
{
"from": "Makefile",
"to": "Makefile"
}
]
}
7 changes: 6 additions & 1 deletion packages/cli/assets/plugins/packages/empty/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@
"$schema": "../../component.d.json",
"name": "Empty packages directory",
"description": "Generates an empty packages directory",
"suggestedPath": "packages"
"paths": [
{
"from": "packages",
"to": "packages"
}
]
}
7 changes: 6 additions & 1 deletion packages/cli/assets/plugins/releaserc/default/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@
"$schema": "../../component.d.json",
"name": "Default semantic-release configuration",
"description": "Automate versioning and package publishing with semantic-release",
"suggestedPath": ".releaserc.json"
"paths": [
{
"from": ".releaserc.json",
"to": ".releaserc.json"
}
]
}
7 changes: 6 additions & 1 deletion packages/cli/assets/plugins/turbo/default/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@
"$schema": "../../component.d.json",
"name": "Default turbo configuration",
"description": "Basic steps configuration for turbo (build, lint, dev, ...)",
"suggestedPath": "turbo.json"
"paths": [
{
"from": "turbo.json",
"to": "turbo.json"
}
]
}
7 changes: 6 additions & 1 deletion packages/cli/assets/plugins/vscode/default/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@
"$schema": "../../component.d.json",
"name": "Default vscode configuration",
"description": "Suggested vscode configuration with format on save",
"suggestedPath": ".vscode"
"paths": [
{
"from": ".vscode",
"to": ".vscode"
}
]
}
3 changes: 1 addition & 2 deletions packages/cli/assets/templates/empty-monorepo/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
"devcontainer/default",
"app/empty",
"packages/empty",
"githooks/default",
"conventional-commits/default",
"vscode/default",
"github/workflows/default",
"github/issue-template/default",
"gitignore/default",
"releaserc/default",
"git-conventional-commits/default",
"license/default",
"makefile/default"
]
Expand Down
1 change: 1 addition & 0 deletions packages/cli/depcheck.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@nextui-org/system",
"@nextui-org/theme",
"@nextui-org/tooltip",
"@nextui-org/divider",
"@react-aria/ssr",
"@react-aria/visually-hidden",
"@tanstack/react-query",
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"@nextui-org/button": "^2.0.37",
"@nextui-org/checkbox": "^2.1.4",
"@nextui-org/chip": "^2.0.32",
"@nextui-org/divider": "^2.0.31",
"@nextui-org/dropdown": "^2.1.29",
"@nextui-org/input": "^2.2.4",
"@nextui-org/link": "^2.0.34",
Expand All @@ -97,7 +98,6 @@
"@react-aria/ssr": "^3.9.5",
"@react-aria/visually-hidden": "^3.8.14",
"@rharkor/logger": "^1.3.1",
"@rharkor/task": "^1.0.1",
"@tanstack/react-query": "^5.39.0",
"@tanstack/react-query-devtools": "^5.39.0",
"@total-typescript/ts-reset": "^0.5.0",
Expand All @@ -115,7 +115,6 @@
"commander": "^12.1.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",
"minimist": "^1.2.8",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scripts": {
"dev": "next dev"
"dev": "next dev --turbo"
},
"depcheck": false
}
4 changes: 3 additions & 1 deletion packages/cli/src/app/src/api/configuration/_router.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { publicProcedure, router } from "@/lib/server/trpc"

import { resetConfiguration, updateConfiguration } from "./mutations"
import { applyConfiguration, resetConfiguration, updateConfiguration } from "./mutations"
import { getConfigurationQuery } from "./queries"
import {
applyConfigurationResponseSchema,
getConfigurationResponseSchema,
resetConfigurationResponseSchema,
updateConfigurationRequestSchema,
Expand All @@ -16,4 +17,5 @@ export const configurationRouter = router({
.output(updateConfigurationResponseSchema())
.mutation(updateConfiguration),
resetConfiguration: publicProcedure.output(resetConfigurationResponseSchema()).mutation(resetConfiguration),
applyConfiguration: publicProcedure.output(applyConfigurationResponseSchema()).mutation(applyConfiguration),
})
21 changes: 21 additions & 0 deletions packages/cli/src/app/src/api/configuration/mutations.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { z } from "zod"

import { getConfiguration, setConfiguration } from "@/lib/configuration"
import { env } from "@/lib/env"
import { pluginsDirectory } 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 { updateConfigurationRequestSchema, updateConfigurationResponseSchema } from "./schemas"

Expand Down Expand Up @@ -35,3 +38,21 @@ export const resetConfiguration = async ({}: apiInputFromSchema<typeof undefined
return handleApiError(error)
}
}

export const applyConfiguration = async ({}: apiInputFromSchema<typeof undefined>) => {
try {
const configuration = await getConfiguration()

//* Apply the configuration
await applyConfigurationTask({
configFileName: "config.json",
pluginsDirectory,
root: env.ROOT_PATH,
})

const data: z.infer<ReturnType<typeof updateConfigurationResponseSchema>> = { configuration }
return data
} catch (error: unknown) {
return handleApiError(error)
}
}
13 changes: 6 additions & 7 deletions packages/cli/src/app/src/api/configuration/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ import { fullPluginSchema } from "@/lib/plugins/store"
export const configurationSchema = () =>
z.object({
name: z.string().optional(),
plugins: z
.array(
fullPluginSchema.extend({
outputPath: z.string().optional(),
})
)
.optional(),
plugins: z.array(fullPluginSchema).optional(),
})
export type TConfiguration = z.infer<ReturnType<typeof configurationSchema>>

Expand All @@ -21,3 +15,8 @@ export const updateConfigurationRequestSchema = () => z.object({ configuration:
export const updateConfigurationResponseSchema = () => z.object({ configuration: configurationSchema() })

export const resetConfigurationResponseSchema = () => z.object({ configuration: configurationSchema() })

export const applyConfigurationResponseSchema = () =>
z.object({
configuration: configurationSchema(),
})
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export const CurrentConfigurationDr = dictionaryRequirements(
outputPath: true,
save: true,
close: true,
pluginSettings: true,
apply: true,
configurationApplied: true,
},
NoConfigurationDr,
HeaderDr
Expand Down
Loading

0 comments on commit 4e0d371

Please sign in to comment.