add base for tools and add seed_palette tool
This commit is contained in:
parent
51e13dd4df
commit
613b75edb6
|
@ -0,0 +1,166 @@
|
|||
import { PrismaClient } from "@prisma/client";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
const log = (...msg: any[]) => console.log(...msg);
|
||||
|
||||
async function main() {
|
||||
const palette: { name: string; hex: string }[] = [
|
||||
{
|
||||
name: "White",
|
||||
hex: "FFFFFF",
|
||||
},
|
||||
{
|
||||
name: "Light Grey",
|
||||
hex: "C2CBD4",
|
||||
},
|
||||
{
|
||||
name: "Medium Grey",
|
||||
hex: "858D98",
|
||||
},
|
||||
{
|
||||
name: "Deep Grey",
|
||||
hex: "4B4F58",
|
||||
},
|
||||
{
|
||||
name: "Black",
|
||||
hex: "000000",
|
||||
},
|
||||
{
|
||||
name: "Dark Chocolate",
|
||||
hex: "38271D",
|
||||
},
|
||||
{
|
||||
name: "Chocolate",
|
||||
hex: "6C422C",
|
||||
},
|
||||
{
|
||||
name: "Brown",
|
||||
hex: "BC7541",
|
||||
},
|
||||
{
|
||||
name: "Peach",
|
||||
hex: "FFB27F",
|
||||
},
|
||||
{
|
||||
name: "Beige",
|
||||
hex: "FFD68F",
|
||||
},
|
||||
{
|
||||
name: "Pink",
|
||||
hex: "FEB2D9",
|
||||
},
|
||||
{
|
||||
name: "Magenta",
|
||||
hex: "F854CF",
|
||||
},
|
||||
{
|
||||
name: "Mauve",
|
||||
hex: "C785F3",
|
||||
},
|
||||
{
|
||||
name: "Purple",
|
||||
hex: "9C29BC",
|
||||
},
|
||||
{
|
||||
name: "Dark Purple",
|
||||
hex: "562972",
|
||||
},
|
||||
{
|
||||
name: "Navy",
|
||||
hex: "1E1E5B",
|
||||
},
|
||||
{
|
||||
name: "Blue",
|
||||
hex: "153FA2",
|
||||
},
|
||||
{
|
||||
name: "Azure",
|
||||
hex: "1C95DF",
|
||||
},
|
||||
{
|
||||
name: "Aqua",
|
||||
hex: "A0E8FF",
|
||||
},
|
||||
{
|
||||
name: "Light Teal",
|
||||
hex: "17A8A3",
|
||||
},
|
||||
{
|
||||
name: "Dark Teal",
|
||||
hex: "226677",
|
||||
},
|
||||
{
|
||||
name: "Forest",
|
||||
hex: "094C45",
|
||||
},
|
||||
{
|
||||
name: "Dark Green",
|
||||
hex: "278242",
|
||||
},
|
||||
{
|
||||
name: "Green",
|
||||
hex: "43C91E",
|
||||
},
|
||||
{
|
||||
name: "Lime",
|
||||
hex: "B7F954",
|
||||
},
|
||||
{
|
||||
name: "Pastel Yellow",
|
||||
hex: "FFFFAF",
|
||||
},
|
||||
{
|
||||
name: "Yellow",
|
||||
hex: "FAE70F",
|
||||
},
|
||||
{
|
||||
name: "Orange",
|
||||
hex: "FEA815",
|
||||
},
|
||||
{
|
||||
name: "Rust",
|
||||
hex: "EA5B15",
|
||||
},
|
||||
{
|
||||
name: "Maroon",
|
||||
hex: "5A0400",
|
||||
},
|
||||
{
|
||||
name: "Rose",
|
||||
hex: "990700",
|
||||
},
|
||||
{
|
||||
name: "Red",
|
||||
hex: "D81515",
|
||||
},
|
||||
{
|
||||
name: "Watermelon",
|
||||
hex: "FF635E",
|
||||
},
|
||||
];
|
||||
|
||||
for (const { name, hex } of palette) {
|
||||
log("Ensuring color", { name, hex });
|
||||
await prisma.paletteColor.upsert({
|
||||
where: { hex },
|
||||
update: {},
|
||||
create: {
|
||||
name,
|
||||
hex,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
.then(async () => {
|
||||
await prisma.$disconnect();
|
||||
})
|
||||
.catch(async (e) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(e);
|
||||
await prisma.$disconnect();
|
||||
process.exit(1);
|
||||
});
|
|
@ -0,0 +1,43 @@
|
|||
#!/bin/sh
|
||||
# ^ this needs to be SH instead of bash because of Alpine Linux
|
||||
|
||||
# Utility to use tool depending on environment (using built or dev tooling)
|
||||
|
||||
MY_DIR="$(cd "$(dirname "$0")"; pwd)"
|
||||
cd $MY_DIR
|
||||
|
||||
USE_PROD=false
|
||||
if [ "$NODE_ENV" = "production" ]; then
|
||||
USE_PROD=true
|
||||
fi
|
||||
|
||||
if ! $USE_PROD; then
|
||||
echo "<!> Development environment detected";
|
||||
echo "<!> NODE_ENV is either empty or set to development";
|
||||
echo "<!> Set NODE_ENV to production to use production tools";
|
||||
echo "";
|
||||
fi
|
||||
|
||||
DEV_TOOLS_ROOT=$MY_DIR/src/tools
|
||||
PROD_TOOLS_ROOT=$MY_DIR/dist/tools
|
||||
|
||||
if [ "$1" = "" ]; then
|
||||
echo "Tool argument is empty, specify a filename (without extension) from tools directory";
|
||||
if $USE_PROD; then
|
||||
echo " > Tools Directory: $PROD_TOOLS_ROOT"
|
||||
else
|
||||
echo " > Tools Directory: $DEV_TOOLS_ROOT"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$1" == *"."* ]]; then
|
||||
echo "Tool argument contains a period, do not include extensions while executing tools"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if $USE_PROD; then
|
||||
node $PROD_TOOLS_ROOT/$1.js
|
||||
else
|
||||
npx ts-node --transpile-only $DEV_TOOLS_ROOT/$1.ts
|
||||
fi
|
Loading…
Reference in New Issue