Skip to content

armgit / hypit

Public Imported from GitHub
0

Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.

fix(cli): canonicalize installed launcher before loading TypeScript

kashorin958360959027
diff --git a/bin/hypit.mjs b/bin/hypit.mjs
index a2d1a9e9..abce53c6 100755
--- a/bin/hypit.mjs
+++ b/bin/hypit.mjs
@@ -1,9 +1,8 @@
#!/usr/bin/env node
-import { register } from "tsx/esm/api";
import { readFileSync, realpathSync } from "node:fs";
-import { dirname, resolve } from "node:path";
-import { fileURLToPath } from "node:url";
+import { dirname, resolve, sep } from "node:path";
+import { fileURLToPath, pathToFileURL } from "node:url";
if (process.argv.length === 3 && ["--version", "-v"].includes(process.argv[2])) {
const manifest = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
@@ -19,21 +18,13 @@ process.emitWarning = function hypitWarning(warning, ...args) {
};
// Bootstrap and package activation must agree on the physical Distribution root. Windows short
-// paths can survive Node's ordinary resolution while package lookup expands them through libuv.
+// paths can survive Node's ordinary resolution. Enter the TypeScript host only from the physical
+// path so its loader and every later package import share one file identity.
const distributionRoot = realpathSync.native(resolve(dirname(fileURLToPath(import.meta.url)), ".."));
-register();
-const { installDistributionPackageResolution } =
- await import("#loader/distribution-resolution");
-installDistributionPackageResolution([distributionRoot]);
const args = process.argv.slice(2);
-const { runInstalledCliApplication, runNodeCli } = await import("#cli");
-const { createVideoDistribution } = await import("@hypit/video");
-const videoDistribution = createVideoDistribution({
- packageRoot: distributionRoot,
- launcher: fileURLToPath(import.meta.url),
-});
-await runNodeCli(args, async (argv, io) => await runInstalledCliApplication(argv, io, {
- distribution: videoDistribution,
+const distributionUrl = pathToFileURL(distributionRoot + sep);
+const { runHypit } = await import(new URL("bin/run.mjs", distributionUrl).href);
+await runHypit(args, {
distributionRoot,
- launcher: fileURLToPath(import.meta.url),
-}));
+ launcher: resolve(distributionRoot, "bin", "hypit.mjs"),
+});
diff --git a/bin/run.mjs b/bin/run.mjs
new file mode 100644
index 00000000..0f58ca89
--- /dev/null
+++ b/bin/run.mjs
@@ -0,0 +1,20 @@
+import { register } from "tsx/esm/api";
+
+/** Enter the TypeScript application after the plain-JavaScript launcher has canonicalized itself. */
+export async function runHypit(args, { distributionRoot, launcher }) {
+ register();
+ const { installDistributionPackageResolution } =
+ await import("#loader/distribution-resolution");
+ installDistributionPackageResolution([distributionRoot]);
+ const { runInstalledCliApplication, runNodeCli } = await import("#cli");
+ const { createVideoDistribution } = await import("@hypit/video");
+ const videoDistribution = createVideoDistribution({
+ packageRoot: distributionRoot,
+ launcher,
+ });
+ await runNodeCli(args, async (argv, io) => await runInstalledCliApplication(argv, io, {
+ distribution: videoDistribution,
+ distributionRoot,
+ launcher,
+ }));
+}