@vlandoss/localproxy 0.0.11-git-ebe9fcd.0 → 0.1.1-git-f48b7a0.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/README.md +1 -1
- package/bin.ts +1 -1
- package/dist/bin.mjs +5 -2
- package/package.json +4 -5
- package/src/commands/setup.ts +10 -2
package/README.md
CHANGED
package/bin.ts
CHANGED
package/dist/bin.mjs
CHANGED
|
@@ -298,6 +298,9 @@ var FileService = class {
|
|
|
298
298
|
};
|
|
299
299
|
//#endregion
|
|
300
300
|
//#region src/commands/setup.ts
|
|
301
|
+
async function exists(p) {
|
|
302
|
+
return fs$1.access(p).then(() => true).catch(() => false);
|
|
303
|
+
}
|
|
301
304
|
const debug = logger.subdebug("setup");
|
|
302
305
|
async function checkInternalTools() {
|
|
303
306
|
const { $ } = quietShell;
|
|
@@ -322,11 +325,11 @@ function createSetupCommand({ binDir, installDir, caddyfilePath }) {
|
|
|
322
325
|
return createCommand("setup").description("setup config files").option("--verbose", "verbose mode, show background output", false).action(async function setupAction(options) {
|
|
323
326
|
const { verbose } = options;
|
|
324
327
|
await checkInternalTools();
|
|
325
|
-
if (!await
|
|
328
|
+
if (!await exists(installDir)) await fs$1.mkdir(installDir);
|
|
326
329
|
const exampleCaddyFilePath = path.join(binDir, "config", "Caddyfile.example");
|
|
327
330
|
const fileContent = await editor({
|
|
328
331
|
message: "Caddyfile",
|
|
329
|
-
default: await
|
|
332
|
+
default: await exists(caddyfilePath) ? await fs$1.readFile(caddyfilePath, "utf-8") : await fs$1.readFile(exampleCaddyFilePath, "utf-8")
|
|
330
333
|
});
|
|
331
334
|
await fs$1.writeFile(caddyfilePath, fileContent);
|
|
332
335
|
await new FileService(caddyfilePath).print();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vlandoss/localproxy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1-git-f48b7a0.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,15 +33,14 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@inquirer/prompts": "8.3.0",
|
|
35
35
|
"commander": "14.0.3",
|
|
36
|
-
"@vlandoss/clibuddy": "0.
|
|
37
|
-
"@vlandoss/loggy": "0.
|
|
36
|
+
"@vlandoss/clibuddy": "0.1.1-git-f48b7a0.0",
|
|
37
|
+
"@vlandoss/loggy": "0.1.1-git-f48b7a0.0"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
|
-
"node": ">=20.0.0"
|
|
44
|
-
"bun": ">=1.0.0"
|
|
43
|
+
"node": ">=20.0.0"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
46
|
"@vlandoss/tsdown-config": "^0.0.1"
|
package/src/commands/setup.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import * as fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
async function exists(p: string): Promise<boolean> {
|
|
5
|
+
return fs
|
|
6
|
+
.access(p)
|
|
7
|
+
.then(() => true)
|
|
8
|
+
.catch(() => false);
|
|
9
|
+
}
|
|
10
|
+
|
|
3
11
|
import { editor as editorPrompt } from "@inquirer/prompts";
|
|
4
12
|
import { createCommand } from "commander";
|
|
5
13
|
import { CaddyService } from "#/services/caddy";
|
|
@@ -51,12 +59,12 @@ export function createSetupCommand({ binDir, installDir, caddyfilePath }: Contex
|
|
|
51
59
|
|
|
52
60
|
await checkInternalTools();
|
|
53
61
|
|
|
54
|
-
if (!(await
|
|
62
|
+
if (!(await exists(installDir))) {
|
|
55
63
|
await fs.mkdir(installDir);
|
|
56
64
|
}
|
|
57
65
|
|
|
58
66
|
const exampleCaddyFilePath = path.join(binDir, "config", "Caddyfile.example");
|
|
59
|
-
const defaultContent = (await
|
|
67
|
+
const defaultContent = (await exists(caddyfilePath))
|
|
60
68
|
? await fs.readFile(caddyfilePath, "utf-8")
|
|
61
69
|
: await fs.readFile(exampleCaddyFilePath, "utf-8");
|
|
62
70
|
|