Skip to content

Commit

Permalink
split packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandru Bereghici committed Oct 12, 2023
1 parent 3bf824d commit d0dbbca
Show file tree
Hide file tree
Showing 230 changed files with 1,157 additions and 2,410 deletions.
3,469 changes: 1,072 additions & 2,397 deletions package-lock.json

Large diffs are not rendered by default.

37 changes: 29 additions & 8 deletions packages/core/binary-command.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
import path from "node:path";
import { fileURLToPath } from "node:url";
import fs from "node:fs";
import { createRequire } from "node:module";

/**
* Get's the file path to a module folder.
* @param {string} moduleEntry
* @param {string} fromFile
*/
const getModuleDir = (moduleEntry: string) => {
const packageName = moduleEntry.includes("/")
? moduleEntry.startsWith("@")
? moduleEntry.split("/").slice(0, 2).join("/")
: moduleEntry.split("/")[0]
: moduleEntry;

const require = createRequire(import.meta.url);
const lookupPaths = require.resolve.paths(moduleEntry)?.map((p) => path.join(p, packageName));
const resolvePath = lookupPaths?.find((p) => fs.existsSync(p));

if (!resolvePath) {
throw new Error("Failed to find the lib");
}

return resolvePath;
};

export interface BinaryCommandOptions {
stdout?: boolean;
Expand Down Expand Up @@ -47,17 +71,14 @@ export class BinaryCommand {
* @returns The path to the v.Nu binary file.
* @throws An error if the platform is not supported.
*/
#getBinPath() {
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

#getBinPath(): string {
switch (this.#platform) {
case "darwin":
return path.join(__dirname, "./lib/darwin/bin/vnu");
return `${getModuleDir("standard-html-darwin-lib")}/bin/vnu`;
case "win32":
return path.join(__dirname, "./lib/win32/bin/vnu.bat");
return `${getModuleDir("standard-html-win-lib")}/bin/vnu.bat`;
case "linux":
return path.join(__dirname, "./lib/linux/bin/vnu");
return `${getModuleDir("standard-html-linux-lib")}/bin/vnu`;
default:
throw new Error(`Unsupported platform: ${process.platform}`);
}
Expand Down
6 changes: 5 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@
"eslint": "8.23.0",
"prettier": "2.7.1",
"rollup": "2.79.0",
"rollup-plugin-copy": "^3.5.0",
"typescript": "4.8.2"
},
"optionalDependencies": {
"standard-html-darwin-lib": "0.0.1",
"standard-html-linux-lib": "0.0.1",
"standard-html-win-lib": "0.0.1"
},
"engines": {
"node": ">=16"
}
Expand Down
4 changes: 0 additions & 4 deletions packages/core/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import nodeResolve from "@rollup/plugin-node-resolve";
import { babel } from "@rollup/plugin-babel";
import terser from "@rollup/plugin-terser";
import copy from "rollup-plugin-copy";

export default {
input: ["validator.ts", "validator.test.ts"],
Expand All @@ -22,9 +21,6 @@ export default {
keep_classnames: true,
},
}),
copy({
targets: [{ src: "lib", dest: "dist" }],
}),
],
output: {
dir: "dist",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions packages/darwin-lib/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "standard-html-darwin-lib",
"version": "0.0.1",
"description": "Check if your HTML is compliant with W3C standards",
"license": "MIT",
"author": "Alexandru Bereghici <[email protected]>",
"os": [
"darwin"
],
"arch": "any",
"main": "bin/vnu",
"files": [
"bin",
"conf",
"lib"
]
}
Loading

0 comments on commit d0dbbca

Please sign in to comment.