webforai 1.6.0 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +93 -52
- package/dist/types/cli/bin.js.map +1 -1
- package/dist/types/cli/commands/webforai/index.js.map +1 -1
- package/dist/types/cli/commands/webforai/loadHtml.js.map +1 -1
- package/dist/types/cli/utils.d.ts +0 -27
- package/dist/types/cli/utils.js.map +1 -1
- package/package.json +3 -2
- package/dist/cjs/cli/bin.js +0 -33
- package/dist/cjs/cli/commands/webforai/index.js +0 -86
- package/dist/cjs/cli/commands/webforai/loadHtml.js +0 -93
- package/dist/cjs/cli/constants.js +0 -34
- package/dist/cjs/cli/helpers/assertContinue.js +0 -34
- package/dist/cjs/cli/helpers/inputOutputPath.js +0 -89
- package/dist/cjs/cli/helpers/inputSourcePath.js +0 -64
- package/dist/cjs/cli/helpers/selectExtractMode.js +0 -39
- package/dist/cjs/cli/helpers/selectLoader.js +0 -44
- package/dist/cjs/cli/utils.js +0 -89
- package/dist/cli/bin.js +0 -11
- package/dist/cli/commands/webforai/index.js +0 -53
- package/dist/cli/commands/webforai/loadHtml.js +0 -60
- package/dist/cli/constants.js +0 -9
- package/dist/cli/helpers/assertContinue.js +0 -11
- package/dist/cli/helpers/inputOutputPath.js +0 -56
- package/dist/cli/helpers/inputSourcePath.js +0 -31
- package/dist/cli/helpers/selectExtractMode.js +0 -16
- package/dist/cli/helpers/selectLoader.js +0 -21
- package/dist/cli/utils.js +0 -52
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// src/cli/helpers/selectLoader.ts
|
|
2
|
-
import { select } from "@clack/prompts";
|
|
3
|
-
import { LOADERS } from "../constants.js";
|
|
4
|
-
import { assertContinue } from "./assertContinue.js";
|
|
5
|
-
var loadersHint = {
|
|
6
|
-
fetch: "Fetch HTML content from the given URL",
|
|
7
|
-
playwright: "Retrieve HTML content after rendering using Playwright; Playwright must be installed in advance.",
|
|
8
|
-
puppeteer: "Retrieve HTML content after rendering using Puppeteer; Puppeteer must be installed in advance."
|
|
9
|
-
};
|
|
10
|
-
var selectLoader = async () => {
|
|
11
|
-
const result = await select({
|
|
12
|
-
message: "Select loader:",
|
|
13
|
-
initialValue: "fetch",
|
|
14
|
-
options: LOADERS.map((mode) => ({ value: mode, label: mode, hint: loadersHint[mode] || "" }))
|
|
15
|
-
});
|
|
16
|
-
assertContinue(result);
|
|
17
|
-
return result;
|
|
18
|
-
};
|
|
19
|
-
export {
|
|
20
|
-
selectLoader
|
|
21
|
-
};
|
package/dist/cli/utils.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
// src/cli/utils.ts
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
var isUrl = (maybeUrl) => {
|
|
5
|
-
try {
|
|
6
|
-
new URL(maybeUrl);
|
|
7
|
-
return true;
|
|
8
|
-
} catch {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
function changeFileExtension(filePath, newExtension) {
|
|
13
|
-
const parsed = path.parse(filePath);
|
|
14
|
-
const ext = newExtension.startsWith(".") ? newExtension : `.${newExtension}`;
|
|
15
|
-
return path.format({ ...parsed, ext });
|
|
16
|
-
}
|
|
17
|
-
function urlToFilename(url) {
|
|
18
|
-
try {
|
|
19
|
-
const urlObj = new URL(url);
|
|
20
|
-
const hostname = urlObj.hostname.startsWith("www.") ? urlObj.hostname.slice(4) : urlObj.hostname;
|
|
21
|
-
const domainParts = hostname.split(".").slice(-2).join("-");
|
|
22
|
-
const pathParts = urlObj.pathname.split("/").filter(Boolean);
|
|
23
|
-
const relevantPathParts = pathParts.slice(-2).map(decodeURIComponent).join("-");
|
|
24
|
-
let filename = [domainParts, relevantPathParts].filter(Boolean).join("-");
|
|
25
|
-
filename = filename.toLowerCase().replace(/[<>:"/\\|?*\x00-\x1F]/g, "").replace(/[\s.]+/g, "-").replace(/^-+|-+$/g, "");
|
|
26
|
-
return filename || "output";
|
|
27
|
-
} catch {
|
|
28
|
-
return "output";
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
var sourcePathToOutputPath = (sourcePath) => isUrl(sourcePath) ? `${urlToFilename(sourcePath)}.md` : changeFileExtension(sourcePath, "md");
|
|
32
|
-
function getNextAvailableFilePath(filePath) {
|
|
33
|
-
const parsed = path.parse(filePath);
|
|
34
|
-
const dir = parsed.dir;
|
|
35
|
-
const ext = parsed.ext;
|
|
36
|
-
const baseName = parsed.name.replace(/_\d+$/, "");
|
|
37
|
-
const match = parsed.name.match(/_(\d+)$/);
|
|
38
|
-
let counter = match ? Number(match[1]) + 1 : 1;
|
|
39
|
-
let newPath = path.join(dir, `${baseName}_${counter}${ext}`);
|
|
40
|
-
while (fs.existsSync(newPath)) {
|
|
41
|
-
counter++;
|
|
42
|
-
newPath = path.join(dir, `${baseName}_${counter}${ext}`);
|
|
43
|
-
}
|
|
44
|
-
return newPath;
|
|
45
|
-
}
|
|
46
|
-
export {
|
|
47
|
-
changeFileExtension,
|
|
48
|
-
getNextAvailableFilePath,
|
|
49
|
-
isUrl,
|
|
50
|
-
sourcePathToOutputPath,
|
|
51
|
-
urlToFilename
|
|
52
|
-
};
|