@tscircuit/fake-snippets 0.0.80 → 0.0.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bun-tests/fake-snippets-api/routes/package_releases/create.test.ts +6 -0
- package/bun-tests/fake-snippets-api/routes/package_releases/update.test.ts +3 -0
- package/bun.lock +24 -18
- package/dist/bundle.js +25 -9
- package/dist/index.d.ts +10 -0
- package/dist/index.js +4 -1
- package/dist/schema.d.ts +16 -0
- package/dist/schema.js +4 -1
- package/fake-snippets-api/lib/db/schema.ts +4 -0
- package/fake-snippets-api/routes/api/package_releases/update.ts +14 -1
- package/fake-snippets-api/routes/api/packages/generate_from_jlcpcb.ts +3 -3
- package/package.json +5 -5
- package/src/components/JLCPCBImportDialog.tsx +164 -62
- package/src/components/PackageBuildsPage/LogContent.tsx +12 -5
- package/src/components/PackageBuildsPage/PackageBuildDetailsPage.tsx +8 -7
- package/src/components/PackageBuildsPage/build-preview-content.tsx +1 -1
- package/src/components/PackageBuildsPage/collapsible-section.tsx +14 -46
- package/src/components/PackageBuildsPage/package-build-details-panel.tsx +28 -10
- package/src/components/PackageBuildsPage/package-build-header.tsx +14 -2
- package/src/components/ViewPackagePage/components/build-status.tsx +24 -85
- package/src/components/ViewPackagePage/components/important-files-view.tsx +65 -2
- package/src/components/ViewPackagePage/components/repo-page-content.tsx +13 -0
- package/src/components/ViewPackagePage/components/sidebar-releases-section.tsx +28 -5
- package/src/components/package-port/CodeAndPreview.tsx +7 -1
- package/src/components/package-port/CodeEditor.tsx +9 -1
- package/src/hooks/use-current-package-release.ts +4 -2
- package/src/hooks/use-now.ts +12 -0
- package/src/hooks/use-package-release.ts +3 -2
- package/src/hooks/use-rebuild-package-release-mutation.ts +41 -0
- package/src/hooks/use-request-ai-review-mutation.ts +45 -0
- package/src/hooks/useFileManagement.ts +1 -2
- package/src/lib/codemirror/basic-setup.ts +17 -1
- package/src/pages/dashboard.tsx +3 -1
- package/src/pages/editor.tsx +5 -1
- package/src/pages/user-profile.tsx +9 -2
- package/src/pages/view-package.tsx +1 -0
- package/.github/workflows/formatbot.yml +0 -63
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { PackageRelease } from "fake-snippets-api/lib/db/schema"
|
|
2
|
+
import { useMutation, useQueryClient } from "react-query"
|
|
3
|
+
import { useAxios } from "./use-axios"
|
|
4
|
+
import { useToast } from "./use-toast"
|
|
5
|
+
|
|
6
|
+
export const useRebuildPackageReleaseMutation = ({
|
|
7
|
+
onSuccess,
|
|
8
|
+
}: { onSuccess?: (packageRelease: PackageRelease) => void } = {}) => {
|
|
9
|
+
const axios = useAxios()
|
|
10
|
+
const { toast } = useToast()
|
|
11
|
+
const queryClient = useQueryClient()
|
|
12
|
+
|
|
13
|
+
return useMutation(
|
|
14
|
+
async ({ package_release_id }: { package_release_id: string }) => {
|
|
15
|
+
const { data } = await axios.post("/package_releases/rebuild", {
|
|
16
|
+
package_release_id,
|
|
17
|
+
})
|
|
18
|
+
return data.package_release as PackageRelease
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
onSuccess: (pkgRelease) => {
|
|
22
|
+
toast({
|
|
23
|
+
title: "Rebuild triggered",
|
|
24
|
+
description: "The package build has been queued for rebuild.",
|
|
25
|
+
})
|
|
26
|
+
queryClient.invalidateQueries(["packageRelease"])
|
|
27
|
+
onSuccess?.(pkgRelease)
|
|
28
|
+
},
|
|
29
|
+
onError: (error: any) => {
|
|
30
|
+
toast({
|
|
31
|
+
title: "Error",
|
|
32
|
+
description:
|
|
33
|
+
error?.response?.data?.message ||
|
|
34
|
+
error?.data?.message ||
|
|
35
|
+
"Failed to rebuild package.",
|
|
36
|
+
variant: "destructive",
|
|
37
|
+
})
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
)
|
|
41
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useMutation, useQueryClient } from "react-query"
|
|
2
|
+
import { useAxios } from "./use-axios"
|
|
3
|
+
import { useToast } from "./use-toast"
|
|
4
|
+
import type { PackageRelease } from "fake-snippets-api/lib/db/schema"
|
|
5
|
+
|
|
6
|
+
export const useRequestAiReviewMutation = ({
|
|
7
|
+
onSuccess,
|
|
8
|
+
}: { onSuccess?: (packageRelease: PackageRelease) => void } = {}) => {
|
|
9
|
+
const axios = useAxios()
|
|
10
|
+
const { toast } = useToast()
|
|
11
|
+
const queryClient = useQueryClient()
|
|
12
|
+
|
|
13
|
+
return useMutation(
|
|
14
|
+
async ({ package_release_id }: { package_release_id: string }) => {
|
|
15
|
+
await axios.post("/package_releases/update", {
|
|
16
|
+
package_release_id,
|
|
17
|
+
ai_review_requested: true,
|
|
18
|
+
})
|
|
19
|
+
const { data } = await axios.post("/package_releases/get", {
|
|
20
|
+
package_release_id,
|
|
21
|
+
})
|
|
22
|
+
return data.package_release as PackageRelease
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
onSuccess: (packageRelease) => {
|
|
26
|
+
toast({
|
|
27
|
+
title: "AI review requested",
|
|
28
|
+
description: "An AI review has been generated.",
|
|
29
|
+
})
|
|
30
|
+
queryClient.invalidateQueries(["packageRelease"])
|
|
31
|
+
onSuccess?.(packageRelease)
|
|
32
|
+
},
|
|
33
|
+
onError: (error: any) => {
|
|
34
|
+
toast({
|
|
35
|
+
title: "Error",
|
|
36
|
+
description:
|
|
37
|
+
error?.response?.data?.message ||
|
|
38
|
+
error?.data?.message ||
|
|
39
|
+
"Failed to request AI review.",
|
|
40
|
+
variant: "destructive",
|
|
41
|
+
})
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
)
|
|
45
|
+
}
|
|
@@ -65,8 +65,7 @@ export function useFileManagement({
|
|
|
65
65
|
const initialCodeContent = useMemo(() => {
|
|
66
66
|
return (
|
|
67
67
|
templateCode ??
|
|
68
|
-
decodeUrlHashToText(window.location.toString())
|
|
69
|
-
DEFAULT_CODE
|
|
68
|
+
(decodeUrlHashToText(window.location.toString()) || DEFAULT_CODE)
|
|
70
69
|
)
|
|
71
70
|
}, [templateCode, currentPackage])
|
|
72
71
|
const manualEditsFileContent = useMemo(() => {
|
|
@@ -18,7 +18,13 @@ import {
|
|
|
18
18
|
foldGutter,
|
|
19
19
|
foldKeymap,
|
|
20
20
|
} from "@codemirror/language"
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
defaultKeymap,
|
|
23
|
+
history,
|
|
24
|
+
historyKeymap,
|
|
25
|
+
toggleLineComment,
|
|
26
|
+
toggleBlockComment,
|
|
27
|
+
} from "@codemirror/commands"
|
|
22
28
|
import { searchKeymap, highlightSelectionMatches } from "@codemirror/search"
|
|
23
29
|
import { autocompletion, completionKeymap } from "@codemirror/autocomplete"
|
|
24
30
|
import { lintKeymap } from "@codemirror/lint"
|
|
@@ -47,5 +53,15 @@ export const basicSetup: Extension = (() => [
|
|
|
47
53
|
...foldKeymap,
|
|
48
54
|
...completionKeymap,
|
|
49
55
|
...lintKeymap,
|
|
56
|
+
{
|
|
57
|
+
key: "Mod-/",
|
|
58
|
+
run: toggleLineComment,
|
|
59
|
+
preventDefault: true,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
key: "Mod-Shift-/",
|
|
63
|
+
run: toggleBlockComment,
|
|
64
|
+
preventDefault: true,
|
|
65
|
+
},
|
|
50
66
|
]),
|
|
51
67
|
])()
|
package/src/pages/dashboard.tsx
CHANGED
|
@@ -34,8 +34,9 @@ export const DashboardPage = () => {
|
|
|
34
34
|
data: myPackages,
|
|
35
35
|
isLoading,
|
|
36
36
|
error,
|
|
37
|
+
refetch: refetchUserPackages,
|
|
37
38
|
} = useQuery<Package[]>(
|
|
38
|
-
"userPackages",
|
|
39
|
+
["userPackages", currentUser],
|
|
39
40
|
async () => {
|
|
40
41
|
const response = await axios.post(`/packages/list`, {
|
|
41
42
|
owner_github_username: currentUser,
|
|
@@ -195,6 +196,7 @@ export const DashboardPage = () => {
|
|
|
195
196
|
packageId={packageToDelete.package_id}
|
|
196
197
|
packageName={packageToDelete.unscoped_name}
|
|
197
198
|
packageOwner={packageToDelete.owner_github_username ?? ""}
|
|
199
|
+
refetchUserPackages={refetchUserPackages}
|
|
198
200
|
/>
|
|
199
201
|
)}
|
|
200
202
|
</div>
|
package/src/pages/editor.tsx
CHANGED
|
@@ -9,6 +9,10 @@ export const EditorPage = () => {
|
|
|
9
9
|
const { packageId } = useCurrentPackageId()
|
|
10
10
|
const { data: pkg, isLoading, error } = usePackage(packageId)
|
|
11
11
|
|
|
12
|
+
const projectUrl = pkg
|
|
13
|
+
? `https://tscircuit.com/${pkg.owner_github_username}/${pkg.unscoped_name}`
|
|
14
|
+
: undefined
|
|
15
|
+
|
|
12
16
|
return (
|
|
13
17
|
<div className="overflow-x-hidden">
|
|
14
18
|
<Helmet>
|
|
@@ -34,7 +38,7 @@ export const EditorPage = () => {
|
|
|
34
38
|
)}
|
|
35
39
|
</Helmet>
|
|
36
40
|
<Header />
|
|
37
|
-
{!error && <CodeAndPreview pkg={pkg} />}
|
|
41
|
+
{!error && <CodeAndPreview pkg={pkg} projectUrl={projectUrl} />}
|
|
38
42
|
{error && error.status === 404 && (
|
|
39
43
|
<div className="w-full h-[calc(100vh-20rem)] text-xl text-center flex justify-center items-center">
|
|
40
44
|
Package not found
|
|
@@ -48,7 +48,10 @@ export const UserProfilePage = () => {
|
|
|
48
48
|
})
|
|
49
49
|
return response.data
|
|
50
50
|
},
|
|
51
|
-
{
|
|
51
|
+
{
|
|
52
|
+
retry: false,
|
|
53
|
+
refetchOnWindowFocus: false,
|
|
54
|
+
},
|
|
52
55
|
)
|
|
53
56
|
|
|
54
57
|
// use the username stored in the database so the correct case is displayed
|
|
@@ -71,7 +74,10 @@ export const UserProfilePage = () => {
|
|
|
71
74
|
})
|
|
72
75
|
return response.data.packages
|
|
73
76
|
},
|
|
74
|
-
{
|
|
77
|
+
{
|
|
78
|
+
enabled: Boolean(githubUsername),
|
|
79
|
+
refetchOnWindowFocus: false,
|
|
80
|
+
},
|
|
75
81
|
)
|
|
76
82
|
|
|
77
83
|
const { data: starredPackages, isLoading: isLoadingStarredPackages } =
|
|
@@ -85,6 +91,7 @@ export const UserProfilePage = () => {
|
|
|
85
91
|
},
|
|
86
92
|
{
|
|
87
93
|
enabled: activeTab === "starred" && Boolean(githubUsername),
|
|
94
|
+
refetchOnWindowFocus: false,
|
|
88
95
|
},
|
|
89
96
|
)
|
|
90
97
|
|
|
@@ -46,6 +46,7 @@ export const ViewPackagePage = () => {
|
|
|
46
46
|
<RepoPageContent
|
|
47
47
|
packageFiles={packageFiles as any}
|
|
48
48
|
packageInfo={packageInfo as any}
|
|
49
|
+
packageRelease={packageRelease as any}
|
|
49
50
|
importantFilePaths={["README.md", "LICENSE", "package.json"]}
|
|
50
51
|
onFileClicked={(file) => {
|
|
51
52
|
setLocation(
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
name: Format PR
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
pull_request:
|
|
5
|
-
types: [opened, synchronize, reopened, ready_for_review]
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
format:
|
|
9
|
-
name: Format code
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
if: github.event.pull_request.draft == false
|
|
12
|
-
|
|
13
|
-
steps:
|
|
14
|
-
- name: Determine if fork
|
|
15
|
-
id: check_fork
|
|
16
|
-
run: |
|
|
17
|
-
if [ "${{ github.event.pull_request.head.repo.full_name }}" = "${{ github.repository }}" ]; then
|
|
18
|
-
echo "is_fork=false" >> $GITHUB_OUTPUT
|
|
19
|
-
else
|
|
20
|
-
echo "is_fork=true" >> $GITHUB_OUTPUT
|
|
21
|
-
fi
|
|
22
|
-
|
|
23
|
-
- name: Checkout code
|
|
24
|
-
uses: actions/checkout@v4
|
|
25
|
-
with:
|
|
26
|
-
token: ${{ steps.check_fork.outputs.is_fork == 'true' && secrets.GITHUB_TOKEN || secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }}
|
|
27
|
-
|
|
28
|
-
- name: Setup bun
|
|
29
|
-
uses: oven-sh/setup-bun@v2
|
|
30
|
-
with:
|
|
31
|
-
bun-version: latest
|
|
32
|
-
|
|
33
|
-
- name: Get @biomejs/biome version
|
|
34
|
-
id: get-biome-version
|
|
35
|
-
run: echo "BIOME_VERSION=$(node -p "require('./package.json').devDependencies['@biomejs/biome']")" >> $GITHUB_OUTPUT
|
|
36
|
-
|
|
37
|
-
- name: Install @biomejs/biome
|
|
38
|
-
run: bun install @biomejs/biome@${{ steps.get-biome-version.outputs.BIOME_VERSION }}
|
|
39
|
-
|
|
40
|
-
- name: Run Formatter and autofix
|
|
41
|
-
if: steps.check_fork.outputs.is_fork == 'false'
|
|
42
|
-
run: npx @biomejs/biome format . --write
|
|
43
|
-
|
|
44
|
-
- name: Format Check (cannot autofix against forks)
|
|
45
|
-
if: steps.check_fork.outputs.is_fork == 'true'
|
|
46
|
-
run: npx @biomejs/biome format .
|
|
47
|
-
|
|
48
|
-
- name: Restore lock files
|
|
49
|
-
if: steps.check_fork.outputs.is_fork == 'false'
|
|
50
|
-
run: |
|
|
51
|
-
git checkout -- *lock.json || true
|
|
52
|
-
git checkout -- *.lock || true
|
|
53
|
-
git checkout -- *.lockb || true
|
|
54
|
-
|
|
55
|
-
- name: Commit changes
|
|
56
|
-
if: steps.check_fork.outputs.is_fork == 'false'
|
|
57
|
-
uses: stefanzweifel/git-auto-commit-action@v4
|
|
58
|
-
with:
|
|
59
|
-
commit_message: "formatbot: Automatically format code"
|
|
60
|
-
branch: ${{ github.head_ref }}
|
|
61
|
-
commit_user_name: tscircuitbot
|
|
62
|
-
commit_user_email: tscircuitbot@users.noreply.github.com
|
|
63
|
-
commit_author: tscircuitbot <tscircuitbot@users.noreply.github.com>
|