@vlandoss/localproxy 0.1.4 → 0.1.5-git-b33212e.0

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/bin.mjs CHANGED
@@ -1,10 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import { homedir } from "node:os";
3
- import path from "node:path";
4
- import { fileURLToPath } from "node:url";
5
- import { main } from "./dist/main.mjs";
6
-
7
- main({
8
- binDir: path.dirname(fileURLToPath(import.meta.url)),
9
- installDir: path.join(homedir(), ".localproxy"),
10
- });
2
+ import "./dist/run.mjs";
@@ -1,5 +1,6 @@
1
+ import { homedir } from "node:os";
1
2
  import path from "node:path";
2
- import { createPkgService, createShellService, getVersion, palette } from "@vlandoss/clibuddy";
3
+ import { createPkgService, createShellService, dirnameOf, getVersion, palette } from "@vlandoss/clibuddy";
3
4
  import { createCommand } from "commander";
4
5
  import * as fs$2 from "node:fs";
5
6
  import { createLoggy } from "@vlandoss/loggy";
@@ -380,7 +381,9 @@ const CREDITS_TEXT = `\nAcknowledgment:
380
381
  - hosts: making it easier to manage host file
381
382
  ${palette.link("https://github.com/xwmx/hosts")}`;
382
383
  //#endregion
383
- //#region src/main.ts
384
+ //#region src/run.ts
385
+ const BIN_DIR = path.dirname(dirnameOf(import.meta));
386
+ const INSTALL_DIR = path.join(homedir(), ".localproxy");
384
387
  async function createContext({ binDir, installDir }) {
385
388
  const binPkg = await createPkgService(binDir);
386
389
  if (!binPkg) throw new Error("Could not find bin package.json");
@@ -395,16 +398,17 @@ async function createProgram(options) {
395
398
  const ctx = await createContext(options);
396
399
  return createCommand("localproxy").alias("localp").version(getVersion(ctx.binPkg), "-v, --version").addHelpText("before", BANNER_TEXT).addHelpText("after", CREDITS_TEXT).addCommand(createSetupCommand(ctx)).addCommand(createStatusCommand(ctx)).addCommand(createStartCommand(ctx)).addCommand(createStopCommand(ctx)).addCommand(createCleanCommand(ctx));
397
400
  }
398
- async function main(options) {
399
- try {
400
- await (await createProgram(options)).parseAsync();
401
- } catch (error) {
402
- if (error instanceof Error && error.name === "ExitPromptError") logger.success("👋 cancelled, until next time!");
403
- else {
404
- logger.error(error);
405
- process.exit(1);
406
- }
401
+ try {
402
+ await (await createProgram({
403
+ binDir: BIN_DIR,
404
+ installDir: INSTALL_DIR
405
+ })).parseAsync();
406
+ } catch (error) {
407
+ if (error instanceof Error && error.name === "ExitPromptError") logger.success("👋 cancelled, until next time!");
408
+ else {
409
+ logger.error(error);
410
+ process.exit(1);
407
411
  }
408
412
  }
409
413
  //#endregion
410
- export { main };
414
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vlandoss/localproxy",
3
- "version": "0.1.4",
3
+ "version": "0.1.5-git-b33212e.0",
4
4
  "description": "Simple local development proxy automation",
5
5
  "homepage": "https://github.com/variableland/dx/tree/main/packages/localproxy#readme",
6
6
  "bugs": {
@@ -33,8 +33,8 @@
33
33
  "dependencies": {
34
34
  "@inquirer/prompts": "8.3.0",
35
35
  "commander": "14.0.3",
36
- "@vlandoss/clibuddy": "0.2.0",
37
- "@vlandoss/loggy": "0.1.1"
36
+ "@vlandoss/clibuddy": "0.2.1-git-b33212e.0",
37
+ "@vlandoss/loggy": "0.1.2-git-b33212e.0"
38
38
  },
39
39
  "publishConfig": {
40
40
  "access": "public"
@@ -1,5 +1,6 @@
1
+ import { homedir } from "node:os";
1
2
  import path from "node:path";
2
- import { createPkgService, getVersion } from "@vlandoss/clibuddy";
3
+ import { createPkgService, dirnameOf, getVersion } from "@vlandoss/clibuddy";
3
4
  import { createCommand } from "commander";
4
5
  import { createCleanCommand } from "./commands/clean.ts";
5
6
  import { createSetupCommand } from "./commands/setup.ts";
@@ -10,6 +11,9 @@ import { logger } from "./services/logger.ts";
10
11
  import type { Context, ProgramOptions } from "./types.ts";
11
12
  import { BANNER_TEXT, CREDITS_TEXT } from "./ui.ts";
12
13
 
14
+ const BIN_DIR = path.dirname(dirnameOf(import.meta));
15
+ const INSTALL_DIR = path.join(homedir(), ".localproxy");
16
+
13
17
  async function createContext({ binDir, installDir }: ProgramOptions) {
14
18
  const binPkg = await createPkgService(binDir);
15
19
 
@@ -40,16 +44,14 @@ async function createProgram(options: ProgramOptions) {
40
44
  .addCommand(createCleanCommand(ctx));
41
45
  }
42
46
 
43
- export async function main(options: ProgramOptions) {
44
- try {
45
- const program = await createProgram(options);
46
- await program.parseAsync();
47
- } catch (error) {
48
- if (error instanceof Error && error.name === "ExitPromptError") {
49
- logger.success("👋 cancelled, until next time!");
50
- } else {
51
- logger.error(error);
52
- process.exit(1);
53
- }
47
+ try {
48
+ const program = await createProgram({ binDir: BIN_DIR, installDir: INSTALL_DIR });
49
+ await program.parseAsync();
50
+ } catch (error) {
51
+ if (error instanceof Error && error.name === "ExitPromptError") {
52
+ logger.success("👋 cancelled, until next time!");
53
+ } else {
54
+ logger.error(error);
55
+ process.exit(1);
54
56
  }
55
57
  }