Skip to content

Commit

Permalink
fix: invalid executeFileName manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
shaffe-fr committed May 23, 2024
1 parent fdcf594 commit 51ea09e
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 71 deletions.
63 changes: 0 additions & 63 deletions build/index.js

This file was deleted.

31 changes: 27 additions & 4 deletions build/api.js → dist/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,32 @@ import path from "node:path";
import process from "node:process";
import * as xml2js from "xml2js";
import { execSync } from "node:child_process";
export function findFileZillaExecutable() {
const envProgramFiles = process.env.ProgramFiles;
const envProgramFilesX86 = process.env["ProgramFiles(x86)"];
const possiblePaths = [];
if (envProgramFiles) {
possiblePaths.push(path.join(envProgramFiles, "FileZilla FTP Client"));
}
if (envProgramFilesX86) {
possiblePaths.push(path.join(envProgramFilesX86, "FileZilla FTP Client"));
}
for (const dir of possiblePaths) {
try {
const files = fs.readdirSync(dir);
const exeFile = files.find((file) => file.toLowerCase().startsWith("filezilla.exe"));
if (exeFile) {
const fullPath = path.join(dir, exeFile);
if (fs.existsSync(fullPath)) {
return fullPath;
}
}
}
catch (err) {
}
}
return null;
}
export function open(executable) {
execSync(`"${executable}"`);
}
Expand All @@ -12,10 +38,7 @@ export function connect(executable, ftpName) {
}
export function query() {
let siteManagerPath;
if (os.platform() == "darwin" || os.platform() == "linux") {
siteManagerPath = path.resolve(process.env.HOME, ".filezilla/sitemanager.xml");
}
else if (os.platform() == "win32") {
if (os.platform() == "win32") {
siteManagerPath = path.resolve(process.env.APPDATA, "FileZilla/sitemanager.xml");
}
else {
Expand Down
1 change: 1 addition & 0 deletions dist/api.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
1 change: 1 addition & 0 deletions dist/helpers.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 68 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { Flow } from "flow-launcher-helper";
import { query, connect, open, findFileZillaExecutable, } from "./api.js";
import MiniSearch from "minisearch";
const { requestParams, showResult, on, run, settings } = new Flow("app.png");
let miniSearch = new MiniSearch({
idField: "title",
fields: ["title", "subtitle"],
searchOptions: {
boost: { title: 3 },
prefix: true,
fuzzy: 0.2,
},
});
on("query", () => {
const fileZillaBinPath = (settings === null || settings === void 0 ? void 0 : settings.binPath) || findFileZillaExecutable();
if (!fileZillaBinPath) {
return showResult({
title: "Error",
subtitle: "FileZilla executable path is not configured in the plugin settings.",
});
}
let searchQuery = requestParams.join(" ");
try {
let sites = query().map((site) => ({
title: site.name,
subtitle: `Host: ${site.host} | User: ${site.user}`,
method: "connect",
params: [fileZillaBinPath, `${site.type}/${site.id}`],
icoPath: "app.png",
}));
miniSearch.addAll(sites);
if (searchQuery.length) {
const results = miniSearch
.search(searchQuery)
.reduce((acc, result) => {
acc[result.id] = result.id;
return acc;
}, {});
sites = sites.filter((item) => item.title in results);
}
else {
sites = [
{
title: "FileZilla",
subtitle: "Launch FileZilla",
method: "open",
params: [fileZillaBinPath],
score: 100,
},
...sites,
];
}
showResult(...sites);
}
catch (error) {
return showResult({
title: "Error",
subtitle: error.message,
});
}
});
on("open", function (params) {
open(params[0]);
});
on("connect", function (params) {
connect(params[0], params[1]);
});
run();
1 change: 1 addition & 0 deletions dist/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"Name": "FileZilla",
"Description": "Launch FileZilla sessions",
"Author": "Karel Faille",
"Version": "1.0.1",
"Version": "1.0.2",
"Language": "typescript",
"ExecuteFileName": "./dist/main.ts",
"ExecuteFileName": "./dist/index.js",
"Website": "https://github.com/shaffe-fr/flow-filezilla",
"UrlDownload": "https://github.com/shaffe-fr/flow-filezilla/releases/download/v1.0.1/Flow.Launcher.Plugin.FileZilla.zip",
"UrlDownload": "https://github.com/shaffe-fr/flow-filezilla/releases/download/v1.0.2/Flow.Launcher.Plugin.FileZilla.zip",
"UrlSourceCode": "https://github.com/shaffe-fr/flow-filezilla/tree/main",
"IcoPath": "https://cdn.jsdelivr.net/gh/shaffe-fr/flow-filezilla/app.png"
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"strict": true,
"skipLibCheck": true,
"removeComments": true,
"outDir": "./build"
"outDir": "./dist"
}
}

0 comments on commit 51ea09e

Please sign in to comment.