Skip to content

Commit

Permalink
feat: download stores from npmjs
Browse files Browse the repository at this point in the history
  • Loading branch information
rharkor committed Sep 13, 2024
1 parent f8bb414 commit d00fc81
Show file tree
Hide file tree
Showing 21 changed files with 348 additions and 821 deletions.
105 changes: 103 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion packages/cli-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"tailwindcss": "^3.4.0"
},
"dependencies": {
"@hookform/resolvers": "^3.9.0",
"@nextui-org/avatar": "^2.0.32",
"@nextui-org/button": "^2.0.37",
"@nextui-org/checkbox": "^2.1.4",
Expand Down Expand Up @@ -64,7 +65,9 @@
"react-toastify": "^10.0.0",
"superjson": "^2.0.0",
"tailwind-merge": "^2.0.0",
"tar": "^7.4.3",
"tsx": "^4.7.0",
"uuid": "^10.0.0"
"uuid": "^10.0.0",
"zod": "^3.23.8"
}
}
4 changes: 2 additions & 2 deletions packages/cli-app/src/api/configuration/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const updateConfiguration = async ({
const configuration = await getConfiguration()

// Merge the new configuration with the old one
setConfiguration({ ...configuration, ..._configuration })
await setConfiguration({ ...configuration, ..._configuration })

const data: z.infer<ReturnType<typeof updateConfigurationResponseSchema>> = { configuration }
return data
Expand All @@ -28,7 +28,7 @@ export const updateConfiguration = async ({
export const resetConfiguration = async ({}: apiInputFromSchema<typeof undefined>) => {
try {
const configuration = await getConfiguration()
setConfiguration({
await setConfiguration({
name: configuration.name,
})

Expand Down
10 changes: 9 additions & 1 deletion packages/cli-app/src/api/configuration/schemas.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import { z } from "zod"

import { fullPluginSchema } from "@/lib/plugins/store"
import { storeNameRegex, storeVersionRegex } from "@next-boilerplate/scripts/utils/template-config/index.js"

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

Expand Down
24 changes: 11 additions & 13 deletions packages/cli-app/src/app/components/project-init.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,21 @@ export default function ProjectInit({ dictionary }: { dictionary: TDictionary<ty
const [variant, setVariant] = useState<string>("welcome")

const utils = trpc.useUtils()
const updateConfigurationMutation = trpc.configuration.updateConfiguration.useMutation()
const updateConfigurationMutation = trpc.configuration.updateConfiguration.useMutation({
onSuccess: async () => {
await utils.configuration.invalidate()
},
})

const [name, setName] = useState<string>("")

const [isPending, setIsPending] = useState(false)
const isPending = updateConfigurationMutation.isPending
const updateConfiguration = async () => {
setIsPending(true)
try {
await updateConfigurationMutation.mutateAsync({
configuration: {
name,
},
})
await utils.configuration.invalidate()
} finally {
setIsPending(false)
}
await updateConfigurationMutation.mutateAsync({
configuration: {
name,
},
})
}

// Set the variant to projectName after 2 seconds
Expand Down
9 changes: 7 additions & 2 deletions packages/cli-app/src/app/stores/content.dr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ export const StoresContentDr = dictionaryRequirements(
stores: true,
search: true,
addStore: true,
storeRemote: true,
storeRemoteExample: true,
storeName: true,
storeNameExample: true,
storeVersion: true,
storeVersionExample: true,
close: true,
save: true,
doNotTrustExternalStores: true,
remove: true,
update: true,
},
HeaderDr
)
Loading

0 comments on commit d00fc81

Please sign in to comment.