Fix deployment #596

Closed
Irev-Dev wants to merge 4 commits from kurt/fix-deployment into release
13 changed files with 173 additions and 140 deletions
Showing only changes of commit c32023c629 - Show all commits

View File

@@ -1,7 +1,7 @@
import { createGraphQLHandler } from '@redwoodjs/graphql-server'
import { createSentryApolloPlugin } from 'src/lib/sentry'
import { logger } from 'src/lib/logger'
import "discord.js"
import 'discord.js'
import directives from 'src/directives/**/*.{js,ts}'
import sdls from 'src/graphql/**/*.sdl.{js,ts}'

View File

@@ -1,34 +1,40 @@
import {Client, Intents, MessageAttachment} from "discord.js"
import { Client, Intents, MessageAttachment } from 'discord.js'
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES]})
const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
})
export async function sendDiscordMessage(text: string, url?: string) {
if (!client.isReady()) {
console.error(`Discord: client is not ready to send message ("${text}")`);
console.error(`Discord: client is not ready to send message ("${text}")`)
} else {
const channel = await client.channels.fetch(process.env.DISCORD_CHANNEL_ID);
const channel = await client.channels.fetch(process.env.DISCORD_CHANNEL_ID)
if (url) {
channel.send({ embeds: [{
title: text,
image: {
url: url,
},
}] });
channel.send({
embeds: [
{
title: text,
image: {
url: url,
},
},
],
})
} else {
channel.send(text)
}
}
}
client.on("ready", async () => {
client.on('ready', async () => {
console.log(`Discord: logged in as ${client.user.tag}`)
})
if (!process.env.DISCORD_TOKEN || !process.env.DISCORD_CHANNEL_ID) {
console.warn("Discord bot not configured - please set process.env.DISCORD_TOKEN and process.env.DISCORD_CHANNEL_ID to send discord chats");
console.warn(
'Discord bot not configured - please set process.env.DISCORD_TOKEN and process.env.DISCORD_CHANNEL_ID to send discord chats'
)
} else {
console.log(`Discord: logging in (token ${process.env.DISCORD_TOKEN})`);
client.login(process.env.DISCORD_TOKEN);
console.log(`Discord: logging in (token ${process.env.DISCORD_TOKEN})`)
client.login(process.env.DISCORD_TOKEN)
}

View File

@@ -14,7 +14,6 @@ import { requireAuth } from 'src/lib/auth'
import { requireOwnership, requireProjectOwnership } from 'src/lib/owner'
import { sendDiscordMessage } from 'src/lib/discord'
export const projects = ({ userName }) => {
if (!userName) {
return db.project.findMany({ where: { deleted: false } })
@@ -249,13 +248,16 @@ export const updateProjectImages = async ({
const { userName } = await db.user.findUnique({
where: { id: project.userId },
})
sendDiscordMessage([
`${userName} just added an image to their ${project.cadPackage} project:`,
` => ${project.title}`,
``,
`Check it out, leave a comment, make them feel welcome!`,
`https://cadhub.xyz/u/${userName}/${project.title}`
].join('\n'), `https://res.cloudinary.com/irevdev/image/upload/c_scale,w_700/v1/${mainImage}`)
sendDiscordMessage(
[
`${userName} just added an image to their ${project.cadPackage} project:`,
` => ${project.title}`,
``,
`Check it out, leave a comment, make them feel welcome!`,
`https://cadhub.xyz/u/${userName}/${project.title}`,
].join('\n'),
`https://res.cloudinary.com/irevdev/image/upload/c_scale,w_700/v1/${mainImage}`
)
return result
})
return updatedProject

View File

@@ -1,6 +1,9 @@
import React from 'react'
import { useRender } from 'src/components/IdeWrapper/useRender'
import { makeStlDownloadHandler, PullTitleFromFirstLine } from 'src/helpers/download_stl'
import {
makeStlDownloadHandler,
PullTitleFromFirstLine,
} from 'src/helpers/download_stl'
import { useSaveCode } from 'src/components/IdeWrapper/useSaveCode'
import { DropdownItem } from './Dropdowns'
import { useShortcutsModalContext } from './AllShortcutsModal'

View File

@@ -1,31 +1,30 @@
import Seo from 'src/components/Seo/Seo'
import IdeViewer from 'src/components/IdeViewer/IdeViewer'
import { useIdeState } from 'src/helpers/hooks/useIdeState'
import type { Project } from 'src/components/EmbedProjectCell/EmbedProjectCell'
import { IdeContext } from 'src/helpers/hooks/useIdeContext'
import { use3dViewerResize } from 'src/helpers/hooks/use3dViewerResize'
import { useEffect } from 'react'
interface Props {
project?: Project
}
const EmbedProject = ({ project }: Props) => {
const [state, thunkDispatch] = useIdeState()
const { viewerDomRef, handleViewerSizeUpdate } = use3dViewerResize()
useEffect(() => {
handleViewerSizeUpdate()
}, [])
return (
<div className="flex flex-col h-screen" ref={viewerDomRef} >
<IdeContext.Provider value={{ state, thunkDispatch, project }}>
<IdeViewer />
</IdeContext.Provider>
</div>
)
}
export default EmbedProject
import Seo from 'src/components/Seo/Seo'
import IdeViewer from 'src/components/IdeViewer/IdeViewer'
import { useIdeState } from 'src/helpers/hooks/useIdeState'
import type { Project } from 'src/components/EmbedProjectCell/EmbedProjectCell'
import { IdeContext } from 'src/helpers/hooks/useIdeContext'
import { use3dViewerResize } from 'src/helpers/hooks/use3dViewerResize'
import { useEffect } from 'react'
interface Props {
project?: Project
}
const EmbedProject = ({ project }: Props) => {
const [state, thunkDispatch] = useIdeState()
const { viewerDomRef, handleViewerSizeUpdate } = use3dViewerResize()
useEffect(() => {
handleViewerSizeUpdate()
}, [])
return (
<div className="flex flex-col h-screen" ref={viewerDomRef}>
<IdeContext.Provider value={{ state, thunkDispatch, project }}>
<IdeViewer />
</IdeContext.Provider>
</div>
)
}
export default EmbedProject

View File

@@ -38,10 +38,9 @@ export const Success = ({
}) => {
const [state, thunkDispatch] = useIdeState()
return (
<IdeContext.Provider value={{ state, thunkDispatch, project }}>
<EmbedViewer project={project} />
</IdeContext.Provider>
<IdeContext.Provider value={{ state, thunkDispatch, project }}>
<EmbedViewer project={project} />
</IdeContext.Provider>
)
}

View File

@@ -7,28 +7,44 @@ import LogoType from '../LogoType/LogoType'
import { Link, routes } from '@redwoodjs/router'
function EmbedViewer() {
const { state, project } = useIdeContext()
useIdeInit(project?.cadPackage, project?.code || state?.code, "viewer")
const { viewerDomRef } = use3dViewerResize()
const { state, project } = useIdeContext()
useIdeInit(project?.cadPackage, project?.code || state?.code, 'viewer')
const { viewerDomRef } = use3dViewerResize()
return (
<div className="relative flex flex-col h-screen group" ref={viewerDomRef}>
<IdeViewer isMinimal={true} />
<div className="absolute top-5 left-5 text-ch-gray-300">
<h1 className="mb-4 text-4xl font-normal capitalize ">
{project?.title.replace(/-/g, ' ')}
</h1>
<h2 className="mb-2 transition-opacity duration-100 group-hover:opacity-0">by @{ project?.user?.userName }</h2>
<h2 className="transition-opacity duration-100 group-hover:opacity-0">built with <div className="inline-block"><CadPackage cadPackage={project?.cadPackage} className="px-3 py-2"/></div></h2>
</div>
<div className="absolute grid items-center grid-flow-col-dense gap-2 bottom-5 right-5 text-ch-gray-300">
View on <Link className="inline-block" to={routes.project({
userName: project?.user?.userName,
projectTitle: project?.title.toString(),
})}><LogoType className="inline-block" wrappedInLink={true}/></Link>
</div>
</div>
)
return (
<div className="relative flex flex-col h-screen group" ref={viewerDomRef}>
<IdeViewer isMinimal={true} />
<div className="absolute top-5 left-5 text-ch-gray-300">
<h1 className="mb-4 text-4xl font-normal capitalize ">
{project?.title.replace(/-/g, ' ')}
</h1>
<h2 className="mb-2 transition-opacity duration-100 group-hover:opacity-0">
by @{project?.user?.userName}
</h2>
<h2 className="transition-opacity duration-100 group-hover:opacity-0">
built with{' '}
<div className="inline-block">
<CadPackage
cadPackage={project?.cadPackage}
className="px-3 py-2"
/>
</div>
</h2>
</div>
<div className="absolute grid items-center grid-flow-col-dense gap-2 bottom-5 right-5 text-ch-gray-300">
View on{' '}
<Link
className="inline-block"
to={routes.project({
userName: project?.user?.userName,
projectTitle: project?.title.toString(),
})}
>
<LogoType className="inline-block" wrappedInLink={true} />
</Link>
</div>
</div>
)
}
export default EmbedViewer

View File

@@ -6,8 +6,8 @@ const IdeViewer = ({
handleOwnCamera = false,
isMinimal = false,
}: {
handleOwnCamera?: boolean,
isMinimal?: boolean,
handleOwnCamera?: boolean
isMinimal?: boolean
}) => {
const { state, thunkDispatch } = useIdeContext()
const dataType = state.objectData?.type
@@ -43,7 +43,7 @@ const IdeViewer = ({
}
})
}
return (
<PureIdeViewer
dataType={dataType}

View File

@@ -2,42 +2,43 @@ import Tooltip from '@material-ui/core/Tooltip'
import { Link, routes } from '@redwoodjs/router'
import Svg from 'src/components/Svg'
export default function LogoType({ className="", wrappedInLink=false }) {
return (
<ul className={"flex items-center " + className}>
<li>
{ (wrappedInLink
? <Link to={routes.home()}>
<div className="ml-2 overflow-hidden rounded-full">
<Svg className="w-10" name="favicon" />
</div>
</Link>
: <div>
<div className="ml-2 overflow-hidden rounded-full">
<Svg className="w-10" name="favicon" />
</div>
</div>
)}
</li>
<li>
<Tooltip title="Very alpha, there's lots of work todo">
<div className="flex ml-4">
{/* Because of how specific these styles are to this heading/logo and it doesn't need to be replicated else where as well as it's very precise with the placement of "pre-alpha" I think it's appropriate. */}
<h2
className="py-1 text-2xl text-indigo-300 md:text-5xl font-ropa-sans md:tracking-wider"
style={{ letterSpacing: '0.3em' }}
>
CadHub
</h2>
<div
className="hidden text-sm font-bold text-pink-400 font-ropa-sans md:block"
style={{ paddingBottom: '2rem', marginLeft: '-1.8rem' }}
>
pre-alpha
</div>
</div>
</Tooltip>
</li>
</ul>
)
}
export default function LogoType({ className = '', wrappedInLink = false }) {
return (
<ul className={'flex items-center ' + className}>
<li>
{wrappedInLink ? (
<Link to={routes.home()}>
<div className="ml-2 overflow-hidden rounded-full">
<Svg className="w-10" name="favicon" />
</div>
</Link>
) : (
<div>
<div className="ml-2 overflow-hidden rounded-full">
<Svg className="w-10" name="favicon" />
</div>
</div>
)}
</li>
<li>
<Tooltip title="Very alpha, there's lots of work todo">
<div className="flex ml-4">
{/* Because of how specific these styles are to this heading/logo and it doesn't need to be replicated else where as well as it's very precise with the placement of "pre-alpha" I think it's appropriate. */}
<h2
className="py-1 text-2xl text-indigo-300 md:text-5xl font-ropa-sans md:tracking-wider"
style={{ letterSpacing: '0.3em' }}
>
CadHub
</h2>
<div
className="hidden text-sm font-bold text-pink-400 font-ropa-sans md:block"
style={{ paddingBottom: '2rem', marginLeft: '-1.8rem' }}
>
pre-alpha
</div>
</div>
</Tooltip>
</li>
</ul>
)
}

View File

@@ -194,13 +194,13 @@ export const Success = ({ userProject, refetch }) => {
})
const onStlDownload = makeStlDownloadHandler({
type: state.objectData?.type,
ideType: state.ideType,
geometry: state.objectData?.data,
quality: state.objectData?.quality,
fileName: `${userProject.Project.title }.stl`,
thunkDispatch,
})
type: state.objectData?.type,
ideType: state.ideType,
geometry: state.objectData?.data,
quality: state.objectData?.quality,
fileName: `${userProject.Project.title}.stl`,
thunkDispatch,
})
return (
<IdeContext.Provider

View File

@@ -103,7 +103,7 @@ const ProjectProfile = ({
<Button
className={getActiveClasses(
'ml-3 hover:bg-opacity-100 bg-ch-pink-800 bg-opacity-30 mt-4 mb-3 text-ch-gray-300',
{ 'bg-indigo-200': currentUser }
{ 'bg-indigo-200': currentUser }
)}
shouldAnimateHover
iconName={'document-download'}

View File

@@ -3,19 +3,24 @@ import { useIdeContext } from 'src/helpers/hooks/useIdeContext'
const StaticImageMessage = () => {
const { state } = useIdeContext()
if ((state.ideType !== 'openscad' && state.ideType !== 'curv') || state.objectData?.type !== 'png') {
if (
(state.ideType !== 'openscad' && state.ideType !== 'curv') ||
state.objectData?.type !== 'png'
) {
return null
}
return state.ideType === 'openscad' ?
return state.ideType === 'openscad' ? (
<OutBound
to="https://learn.cadhub.xyz/docs/general-cadhub/openscad-previews"
className="text-ch-gray-300 border-ch-gray-300 rounded-md mr-12 px-2 py-1 text-xs"
>
Why reload each camera move?
</OutBound>
: <div className="text-ch-gray-300 border-ch-gray-300 rounded-md mr-12 px-2 py-1 text-xs">
Alpha Curv integration, no camera support currently.
</div>
) : (
<div className="text-ch-gray-300 border-ch-gray-300 rounded-md mr-12 px-2 py-1 text-xs">
Alpha Curv integration, no camera support currently.
</div>
)
}
export default StaticImageMessage

View File

@@ -318,9 +318,11 @@ const makeScriptWorker = ({ callback, convertToSolids }) => {
let onInit, main, scriptStats, entities, lastParamsDef
function runMain(params = {}) {
if(lastParamsDef) lastParamsDef.forEach(def=>{
if(!(def.name in params) && 'initial' in def) params[def.name] = def.initial
})
if (lastParamsDef)
lastParamsDef.forEach((def) => {
if (!(def.name in params) && 'initial' in def)
params[def.name] = def.initial
})
let time = Date.now()
let solids
const transfer = []