Mike
Mike
WWindmill
Created by Mike on 2/22/2024 in #help
Postgres request throws ExecutionErr when trying to get value from field using enum.
thanks for the quick response there
5 replies
WWindmill
Created by Mike on 2/22/2024 in #help
Postgres request throws ExecutionErr when trying to get value from field using enum.
amazing, yes that works!
5 replies
WWindmill
Created by Mike on 2/10/2024 in #help
Trouble committing file to GitHub but only in bun runtime
👍
42 replies
WWindmill
Created by Mike on 2/10/2024 in #help
Trouble committing file to GitHub but only in bun runtime
but I believe that just gives you the base64 string, not the filename and extension right?
42 replies
WWindmill
Created by Mike on 2/10/2024 in #help
Trouble committing file to GitHub but only in bun runtime
im just uploading it like this:
//
export async function main(
fontFile: wmill.Base64,
) {
//
//
export async function main(
fontFile: wmill.Base64,
) {
//
42 replies
WWindmill
Created by Mike on 2/10/2024 in #help
Trouble committing file to GitHub but only in bun runtime
Just one more question, is it possible to get the name and extension of an uploaded file in windmill?
42 replies
WWindmill
Created by Mike on 2/10/2024 in #help
Trouble committing file to GitHub but only in bun runtime
Sorry about that, will have to see if I can solve this myself!
42 replies
WWindmill
Created by Mike on 2/10/2024 in #help
Trouble committing file to GitHub but only in bun runtime
okay I now see that this is not an issue with Windmill, I also got this same result running it locally in bun. Something is messed up with the string when using fontkit to read the font name from the file.
42 replies
WWindmill
Created by Mike on 2/10/2024 in #help
Trouble committing file to GitHub but only in bun runtime
42 replies
WWindmill
Created by Mike on 2/10/2024 in #help
Trouble committing file to GitHub but only in bun runtime
hmm i think it has to do with the encoding of that string. the fontName does have a typeof of string, but i think it's incorrect utf maybe? The string is read from a otf font file. Just logging the name works but when i place it inside an object it shows all those characters.
42 replies
WWindmill
Created by Mike on 2/10/2024 in #help
Trouble committing file to GitHub but only in bun runtime
running it in bun locally, not through Windmill, it does work: this file:
const fontType = "otf";
const fontName = "aaa-test";

console.log({test: `fonts/custom-fonts/${fontType}/${fontName}.${fontType}`});
const fontType = "otf";
const fontName = "aaa-test";

console.log({test: `fonts/custom-fonts/${fontType}/${fontName}.${fontType}`});
Gives me this output:
{
test: "fonts/custom-fonts/otf/aaa-test.otf"
}
{
test: "fonts/custom-fonts/otf/aaa-test.otf"
}
42 replies
WWindmill
Created by Mike on 2/10/2024 in #help
Trouble committing file to GitHub but only in bun runtime
okay im pretty sure template literals inside an object are broken in the Bun runtime on Windmill. This line of code:
console.log({test: `fonts/custom-fonts/${fontType}/${fontName}.${fontType}`});
console.log({test: `fonts/custom-fonts/${fontType}/${fontName}.${fontType}`});
Shows me this output:
{
test: "fonts/custom-fonts/otf/\u0000B\u0000e\u0000a\u0000u\u0000s\u0000i\u0000t\u0000e\u0000C\u0000l\u0000a\u0000s\u0000s\u0000i\u0000c\u0000T\u0000r\u0000i\u0000a\u0000l\u0000-\u0000U\u0000l\u0000t\u0000r\u0000a\u0000l\u0000i\u0000g\u0000h\u0000t.otf",
}
{
test: "fonts/custom-fonts/otf/\u0000B\u0000e\u0000a\u0000u\u0000s\u0000i\u0000t\u0000e\u0000C\u0000l\u0000a\u0000s\u0000s\u0000i\u0000c\u0000T\u0000r\u0000i\u0000a\u0000l\u0000-\u0000U\u0000l\u0000t\u0000r\u0000a\u0000l\u0000i\u0000g\u0000h\u0000t.otf",
}
42 replies
WWindmill
Created by Mike on 2/10/2024 in #help
Trouble committing file to GitHub but only in bun runtime
see the message from 4:33
42 replies
WWindmill
Created by Mike on 2/10/2024 in #help
Trouble committing file to GitHub but only in bun runtime
i did, they are identical.
42 replies
WWindmill
Created by Mike on 2/10/2024 in #help
Trouble committing file to GitHub but only in bun runtime
if (acceptedFileTypes.includes(fontType)) {
try {

// This works
console.log("fonts/custom-fonts/otf/BeausiteClassicTrial-Ultralight.otf");
// Output: fonts/custom-fonts/otf/BeausiteClassicTrial-Ultralight.otf

// This does not work
console.log(`fonts/custom-fonts/${fontType}/${fontName}.${fontType}`);
// Output: fonts/custom-fonts/otf/BeausiteClassicTrial-Ultralight.otf

const result = await octokit.repos.createOrUpdateFileContents({
owner: "OWNER",
repo: "REPO",
path: "fonts/custom-fonts/otf/BeausiteClassicTrial-Ultralight.otf",
// path: `fonts/custom-fonts/${fontType}/${fontName}.${fontType}`,
message: `chore: add font ${fontName}`,
content: fontFile,
});

} catch (error: any) {
console.log(error.status); // This is a 500 error.
// The error message is in html and VERY long. Does not reveal any information, only says something is wrong.
// console.log(error.message);
}

// const res = await fetch(
// "NOTIFY ENDPOINT",
// );

// const responseText = res.text();

return "test"

// return responseText || 500;
} else {
return "error: unsupported file extension, must be otf or ttf.";
}
}
if (acceptedFileTypes.includes(fontType)) {
try {

// This works
console.log("fonts/custom-fonts/otf/BeausiteClassicTrial-Ultralight.otf");
// Output: fonts/custom-fonts/otf/BeausiteClassicTrial-Ultralight.otf

// This does not work
console.log(`fonts/custom-fonts/${fontType}/${fontName}.${fontType}`);
// Output: fonts/custom-fonts/otf/BeausiteClassicTrial-Ultralight.otf

const result = await octokit.repos.createOrUpdateFileContents({
owner: "OWNER",
repo: "REPO",
path: "fonts/custom-fonts/otf/BeausiteClassicTrial-Ultralight.otf",
// path: `fonts/custom-fonts/${fontType}/${fontName}.${fontType}`,
message: `chore: add font ${fontName}`,
content: fontFile,
});

} catch (error: any) {
console.log(error.status); // This is a 500 error.
// The error message is in html and VERY long. Does not reveal any information, only says something is wrong.
// console.log(error.message);
}

// const res = await fetch(
// "NOTIFY ENDPOINT",
// );

// const responseText = res.text();

return "test"

// return responseText || 500;
} else {
return "error: unsupported file extension, must be otf or ttf.";
}
}
42 replies
WWindmill
Created by Mike on 2/10/2024 in #help
Trouble committing file to GitHub but only in bun runtime
complete script for context:
import * as wmill from "windmill-client@1";
import { Octokit } from "@octokit/rest@20.0.2";
let fontkit = require('fontkit');
import { unlink } from "node:fs/promises";

export async function main(
fontFile: wmill.Base64,
fontType: string
) {

const octokit = new Octokit({
auth: "GITHUB-TOKEN-HERE",
});

const tempFileName = "temp";

// Write file
const buffer = Buffer.from(fontFile, 'base64');
const fontFilePath = `${process.cwd()}/${tempFileName}`;
await Bun.write(fontFilePath, buffer);

// Read values
const font = await fontkit.open(fontFilePath);
const fontName = await font.postscriptName.toString();

console.log(fontName.toLowerCase());

// This always seems to read as ttf, just asking type for now.
// const fontType = font.type.toLowerCase();

// Delete file
await unlink(fontFilePath);

const acceptedFileTypes = ["otf", "ttf"];
import * as wmill from "windmill-client@1";
import { Octokit } from "@octokit/rest@20.0.2";
let fontkit = require('fontkit');
import { unlink } from "node:fs/promises";

export async function main(
fontFile: wmill.Base64,
fontType: string
) {

const octokit = new Octokit({
auth: "GITHUB-TOKEN-HERE",
});

const tempFileName = "temp";

// Write file
const buffer = Buffer.from(fontFile, 'base64');
const fontFilePath = `${process.cwd()}/${tempFileName}`;
await Bun.write(fontFilePath, buffer);

// Read values
const font = await fontkit.open(fontFilePath);
const fontName = await font.postscriptName.toString();

console.log(fontName.toLowerCase());

// This always seems to read as ttf, just asking type for now.
// const fontType = font.type.toLowerCase();

// Delete file
await unlink(fontFilePath);

const acceptedFileTypes = ["otf", "ttf"];
42 replies
WWindmill
Created by Mike on 2/10/2024 in #help
Trouble committing file to GitHub but only in bun runtime
// This works
console.log("fonts/custom-fonts/otf/BeausiteClassicTrial-Ultralight.otf");
// Output: fonts/custom-fonts/otf/BeausiteClassicTrial-Ultralight.otf

// This does not work
console.log(`fonts/custom-fonts/${fontType}/${fontName}.${fontType}`);
// Output: fonts/custom-fonts/otf/BeausiteClassicTrial-Ultralight.otf
// This works
console.log("fonts/custom-fonts/otf/BeausiteClassicTrial-Ultralight.otf");
// Output: fonts/custom-fonts/otf/BeausiteClassicTrial-Ultralight.otf

// This does not work
console.log(`fonts/custom-fonts/${fontType}/${fontName}.${fontType}`);
// Output: fonts/custom-fonts/otf/BeausiteClassicTrial-Ultralight.otf
42 replies
WWindmill
Created by Mike on 2/10/2024 in #help
Trouble committing file to GitHub but only in bun runtime
Okay i was able to narrow down the issue to one line of code: inside this request:
const result = await octokit.repos.createOrUpdateFileContents({
owner: "OWNER",
repo: "REPO",
path: "fonts/custom-fonts/otf/BeausiteClassicTrial-Ultralight.otf",
// path: `fonts/custom-fonts/${fontType}/${fontName}.${fontType}`,
message: `chore: add font ${fontName}`,
content: fontFile,
});
const result = await octokit.repos.createOrUpdateFileContents({
owner: "OWNER",
repo: "REPO",
path: "fonts/custom-fonts/otf/BeausiteClassicTrial-Ultralight.otf",
// path: `fonts/custom-fonts/${fontType}/${fontName}.${fontType}`,
message: `chore: add font ${fontName}`,
content: fontFile,
});
if i use the hardcoded path the request works, but if i use the string with template literals it doesn't work, am i missing something obvious here?
42 replies
WWindmill
Created by Mike on 2/10/2024 in #help
Trouble committing file to GitHub but only in bun runtime
just running the project through docker with docker-compose
42 replies
WWindmill
Created by Mike on 2/10/2024 in #help
Trouble committing file to GitHub but only in bun runtime
Also does not work on self hosted, same 500 error on that request.
42 replies