Fix deployment #596

Closed
Irev-Dev wants to merge 4 commits from kurt/fix-deployment into release
17 changed files with 2531 additions and 3297 deletions

View File

@@ -9,7 +9,7 @@
"axios": "^0.21.1",
"cloudinary": "^1.23.0",
"cors": "^2.8.5",
"discord.js": "^13.5.1",
"discord.js": "^13.6.0",
"express": "^4.17.1",
"human-id": "^2.0.1",
"middy": "^0.36.0",

View File

@@ -1,6 +1,7 @@
import { createGraphQLHandler } from '@redwoodjs/graphql-server'
import { createSentryApolloPlugin } from 'src/lib/sentry'
import { logger } from 'src/lib/logger'
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: [{
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([
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}`)
`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

@@ -2,6 +2,7 @@
command = "yarn rw deploy netlify"
publish = "web/dist"
functions = "api/dist/functions"
ignore = "false"
[dev]
# To use [Netlify Dev](https://www.netlify.com/products/dev/),

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

@@ -6,7 +6,6 @@ import { IdeContext } from 'src/helpers/hooks/useIdeContext'
import { use3dViewerResize } from 'src/helpers/hooks/use3dViewerResize'
import { useEffect } from 'react'
interface Props {
project?: Project
}
@@ -20,7 +19,7 @@ const EmbedProject = ({ project }: Props) => {
}, [])
return (
<div className="flex flex-col h-screen" ref={viewerDomRef} >
<div className="flex flex-col h-screen" ref={viewerDomRef}>
<IdeContext.Provider value={{ state, thunkDispatch, project }}>
<IdeViewer />
</IdeContext.Provider>

View File

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

View File

@@ -8,7 +8,7 @@ import { Link, routes } from '@redwoodjs/router'
function EmbedViewer() {
const { state, project } = useIdeContext()
useIdeInit(project?.cadPackage, project?.code || state?.code, "viewer")
useIdeInit(project?.cadPackage, project?.code || state?.code, 'viewer')
const { viewerDomRef } = use3dViewerResize()
return (
@@ -18,14 +18,30 @@ function EmbedViewer() {
<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>
<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({
View on{' '}
<Link
className="inline-block"
to={routes.project({
userName: project?.user?.userName,
projectTitle: project?.title.toString(),
})}><LogoType className="inline-block" wrappedInLink={true}/></Link>
})}
>
<LogoType className="inline-block" wrappedInLink={true} />
</Link>
</div>
</div>
)

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

View File

@@ -2,17 +2,18 @@ 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 }) {
export default function LogoType({ className = '', wrappedInLink = false }) {
return (
<ul className={"flex items-center " + className}>
<ul className={'flex items-center ' + className}>
<li>
{ (wrappedInLink
? <Link to={routes.home()}>
{wrappedInLink ? (
<Link to={routes.home()}>
<div className="ml-2 overflow-hidden rounded-full">
<Svg className="w-10" name="favicon" />
</div>
</Link>
: <div>
) : (
<div>
<div className="ml-2 overflow-hidden rounded-full">
<Svg className="w-10" name="favicon" />
</div>

View File

@@ -198,7 +198,7 @@ export const Success = ({ userProject, refetch }) => {
ideType: state.ideType,
geometry: state.objectData?.data,
quality: state.objectData?.quality,
fileName: `${userProject.Project.title }.stl`,
fileName: `${userProject.Project.title}.stl`,
thunkDispatch,
})

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">
) : (
<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,8 +318,10 @@ 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

File diff suppressed because it is too large Load Diff