kit icon indicating copy to clipboard operation
kit copied to clipboard

clear-script-database.js failed with global preview payload?

Open GastroGeek opened this issue 2 years ago • 2 comments

Firstly - great app! The sheer amount of work that has gone into this, is incredible so thanks 🙏


Made a custom 'Application Launcher' script which works well and generates the necessary db file etc...

sidenote: I did this since it looks as though the icons are wrong with the in-built one? could be when custom icons are used... apps effected were 1Password6, VSCode + Insiders, Accessibility Inspector etc etc...

However, when trying to delete the script's DB file using the in-built clear-script-database.js it fails... silently.

Downloaded binary today from: https://www.scriptkit.com/ (non-M1)

Contents of file I see (.js? noticed the repo contains .ts? but looks to be same code...):

// Description: Clear selected script database
let { filePath, command } = await selectScript(`Open database for which script?`);
let dbPath = path.resolve(filePath, "..", "..", "db", `_${command}.json`);
let dbPathExists = await pathExists(dbPath);
if (dbPathExists) {
    let contents = await readFile(dbPath, "utf-8");
    let highlightedContents = await highlight(`
## ${command}
~~~json
${contents}
~~~`);
    let confirm = await arg({
        placeholder: `Delete script data?`,
        hint: `[y]es/[n]o`,
    }, highlightedContents); // THIS APPEARS TO BE THE POINT OF FAILURE?
    if (confirm === "y") {
        await trash(dbPath);
    }
}
else {
    await div(md(`
## No data found for <code>${command}</code>
  `));
}
await mainScript();
export {};

If I remove that line/use alternative code I can get it to work but not with a 'global' preview of the db... only per-option or not-at-all.

I did try slicing the items from the db (down to 1 item) and it still fails so perhaps not related to length but something else?

I would have dug-in to the code, but had problems when executing: yarn webpack-dev as per README and have not had chance to re-visit.

GastroGeek avatar Oct 03 '22 10:10 GastroGeek

Just to update. Confirming it fails on all commands and even for the simplest of scripts

// Name: testing

import '@johnlindquist/kit'

const files = await db([])
files.write()

DB shown on delete confirmation:

{
  "items": []
}

GastroGeek avatar Oct 03 '22 10:10 GastroGeek

Thanks @GastroGeek . I'll dig in and get it sorted.

If you're interested in digging more into the project, we've just set up a Discord and I've helped a few people with the setup process:

https://discord.gg/Hc4guZkm

johnlindquist avatar Oct 03 '22 15:10 johnlindquist