Skip to content

Commit

Permalink
feat(cli): upgrade client to latest effect
Browse files Browse the repository at this point in the history
  • Loading branch information
cschroeter committed Nov 29, 2024
1 parent 66c2654 commit 8683822
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 52 deletions.
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion components/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"react": "18.3.1",
"react-dom": "18.3.1",
"storybook": "8.4.4",
"typescript": "5.6.3",
"typescript": "5.7.2",
"vite": "5.4.11",
"vite-tsconfig-paths": "5.1.2"
}
Expand Down
2 changes: 1 addition & 1 deletion components/solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"storybook": "8.4.4",
"storybook-solidjs": "1.0.0-beta.6",
"storybook-solidjs-vite": "1.0.0-beta.6",
"typescript": "5.6.3",
"typescript": "5.7.2",
"vite": "5.4.11",
"vite-plugin-solid": "2.10.2",
"vite-tsconfig-paths": "5.1.2"
Expand Down
2 changes: 1 addition & 1 deletion components/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"histoire": "0.17.17",
"lucide-vue-next": "0.460.0",
"prettier": "3.3.3",
"typescript": "5.6.3",
"typescript": "5.7.2",
"vite": "5.4.11",
"vite-tsconfig-paths": "5.1.2",
"vue": "3.5.13"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
"@types/bun": "1.1.13",
"lefthook": "1.8.4",
"turbo": "2.3.0",
"typescript": "5.6.3",
"typescript": "5.7.2",
"vercel": "39.0.3",
"vercel-submodules": "1.0.10"
},
"packageManager": "[email protected].34",
"packageManager": "[email protected].37",
"trustedDependencies": ["@park-ui/website"]
}
9 changes: 4 additions & 5 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,19 @@
"release-it": "release-it"
},
"dependencies": {
"@effect/schema": "0.75.5",
"@effect/platform": "0.69.24",
"effect": "3.10.15",
"@effect/platform": "0.69.28",
"effect": "3.10.19",
"fs-extra": "11.2.0",
"pkg-dir": "8.0.0",
"yargs": "17.7.2"
},
"devDependencies": {
"@release-it/keep-a-changelog": "5.0.0",
"@types/fs-extra": "11.0.4",
"@types/node": "22.9.0",
"@types/node": "22.10.1",
"@types/yargs": "17.0.33",
"release-it": "17.10.0",
"typescript": "5.6.3"
"typescript": "5.7.2"
},
"peerDependencies": {
"typescript": "^5.0.0"
Expand Down
61 changes: 27 additions & 34 deletions packages/cli/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { HttpClient, HttpClientRequest, HttpClientResponse } from '@effect/platform'
import { Schema } from '@effect/schema'
import { Effect, Schedule } from 'effect'
import { FetchHttpClient, HttpClient, HttpClientResponse } from '@effect/platform'
import { Effect, Schema } from 'effect'
import type { Config } from './get-config'

const API_URL = 'https://park-ui.com/registry/latest'

const Utils = Schema.Array(
Schema.Struct({
filename: Schema.String,
content: Schema.String,
}),
)

const Components = Schema.Array(
Schema.Struct({
id: Schema.String,
Expand All @@ -25,27 +31,18 @@ const Component = Schema.Struct({

export type Component = Schema.Schema.Type<typeof Component>

const Helpers = Schema.Array(
Schema.Struct({
filename: Schema.String,
content: Schema.String,
}),
)

export const fetchComponentById = (id: string, config: Config) =>
HttpClientRequest.get(`${API_URL}/${config.jsFramework}/components/${id}.json`).pipe(
HttpClient.fetchOk,
HttpClientResponse.schemaBodyJsonScoped(Component),
Effect.timeout('1 seconds'),
Effect.retry(Schedule.exponential(200).pipe(Schedule.compose(Schedule.recurs(3)))),
HttpClient.get(`${API_URL}/${config.jsFramework}/components/${id}.json`).pipe(
Effect.flatMap(HttpClientResponse.schemaBodyJson(Component)),
Effect.scoped,
Effect.provide(FetchHttpClient.layer),
)

export const fetchUtils = (config: Config) =>
HttpClientRequest.get(`${API_URL}/${config.jsFramework}/utils/index.json`).pipe(
HttpClient.fetchOk,
HttpClientResponse.schemaBodyJsonScoped(Helpers),
Effect.timeout('1 seconds'),
Effect.retry(Schedule.exponential(200).pipe(Schedule.compose(Schedule.recurs(3)))),
HttpClient.get(`${API_URL}/${config.jsFramework}/utils/index.json`).pipe(
Effect.flatMap(HttpClientResponse.schemaBodyJson(Utils)),
Effect.scoped,
Effect.provide(FetchHttpClient.layer),
)

interface Args {
Expand All @@ -55,18 +52,14 @@ interface Args {

export const fetchComponents = (config: Config, args: Args) =>
args.all
? HttpClientRequest.get(`${API_URL}/${config.jsFramework}/components`)
.pipe(
HttpClient.fetchOk,
HttpClientResponse.schemaBodyJsonScoped(Components),
Effect.timeout('1 seconds'),
Effect.retry(Schedule.exponential(200).pipe(Schedule.compose(Schedule.recurs(3)))),
)
.pipe(
Effect.flatMap((components) =>
Effect.forEach(components, (component) => fetchComponentById(component.id, config), {
concurrency: 10,
}),
),
)
? HttpClient.get(`${API_URL}/${config.jsFramework}/components`).pipe(
Effect.flatMap(HttpClientResponse.schemaBodyJson(Components)),
Effect.scoped,
Effect.provide(FetchHttpClient.layer),
Effect.flatMap((components) =>
Effect.forEach(components, (component) => fetchComponentById(component.id, config), {
concurrency: 10,
}),
),
)
: Effect.forEach(args.components, (id) => fetchComponentById(id, config))
3 changes: 1 addition & 2 deletions packages/cli/src/get-config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import path from 'node:path'
import * as p from '@clack/prompts'
import { Schema } from '@effect/schema'
import { Effect, pipe } from 'effect'
import { Effect, Schema, pipe } from 'effect'
import fs from 'fs-extra'
import { packageDirectorySync } from 'pkg-dir'

Expand Down
2 changes: 1 addition & 1 deletion packages/panda/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"dependencies": {
"@ark-ui/anatomy": "3.5.0",
"effect": "3.10.15"
"effect": "3.10.19"
},
"devDependencies": {
"@pandacss/dev": "0.48.0",
Expand Down
2 changes: 1 addition & 1 deletion scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@types/fs-extra": "11.0.4",
"@types/handlebars-helpers": "0.5.6",
"@types/voca": "1.4.6",
"effect": "3.10.15",
"effect": "3.10.19",
"fs-extra": "11.2.0",
"globby": "14.0.2",
"handlebars": "4.7.8",
Expand Down
8 changes: 4 additions & 4 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@ark-ui/react": "4.4.4",
"@auth/prisma-adapter": "2.7.4",
"@biomejs/biome": "1.9.4",
"@effect/platform": "0.69.24",
"@effect/platform": "0.69.28",
"@effect/schema": "0.75.5",
"@icons-pack/react-simple-icons": "10.1.0",
"@pandacss/dev": "0.48.0",
Expand All @@ -28,11 +28,11 @@
"@types/file-saver": "2.0.7",
"file-saver": "2.0.5",
"jszip": "3.10.1",
"@types/node": "22.9.0",
"@types/node": "22.10.1",
"@types/react": "18.3.12",
"@types/react-dom": "18.3.1",
"@uidotdev/usehooks": "2.4.1",
"effect": "3.10.15",
"effect": "3.10.19",
"globby": "14.0.2",
"lucide-react": "0.460.0",
"next": "15.0.3",
Expand All @@ -48,7 +48,7 @@
"rehype-autolink-headings": "7.1.0",
"rehype-slug": "6.0.0",
"shiki": "1.23.1",
"typescript": "5.6.3",
"typescript": "5.7.2",
"usehooks-ts": "3.1.0",
"velite": "0.2.1",
"zustand": "5.0.1"
Expand Down

0 comments on commit 8683822

Please sign in to comment.