@aiworkbench/vibe-publish 0.0.4 → 0.0.5
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/index.js +51 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,18 +4,56 @@
|
|
|
4
4
|
import { parseArgs } from "node:util";
|
|
5
5
|
|
|
6
6
|
// src/config.ts
|
|
7
|
+
import { readFileSync } from "node:fs";
|
|
8
|
+
import { resolve, parse as parsePath } from "node:path";
|
|
9
|
+
function loadDotenv(startDir = process.cwd()) {
|
|
10
|
+
let dir = resolve(startDir);
|
|
11
|
+
const { root } = parsePath(dir);
|
|
12
|
+
while (dir !== root) {
|
|
13
|
+
try {
|
|
14
|
+
const raw = readFileSync(resolve(dir, ".env"), "utf-8");
|
|
15
|
+
for (const line of raw.split(`
|
|
16
|
+
`)) {
|
|
17
|
+
const trimmed = line.trim();
|
|
18
|
+
if (!trimmed || trimmed.startsWith("#"))
|
|
19
|
+
continue;
|
|
20
|
+
const eqIdx = trimmed.indexOf("=");
|
|
21
|
+
if (eqIdx === -1)
|
|
22
|
+
continue;
|
|
23
|
+
const key = trimmed.slice(0, eqIdx).trim();
|
|
24
|
+
let value = trimmed.slice(eqIdx + 1).trim();
|
|
25
|
+
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
|
|
26
|
+
value = value.slice(1, -1);
|
|
27
|
+
}
|
|
28
|
+
if (process.env[key] === undefined) {
|
|
29
|
+
process.env[key] = value;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return;
|
|
33
|
+
} catch {
|
|
34
|
+
dir = resolve(dir, "..");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function envScoped(key, environment) {
|
|
39
|
+
const scoped = process.env[`${key}_${environment.toUpperCase()}`];
|
|
40
|
+
if (scoped)
|
|
41
|
+
return scoped;
|
|
42
|
+
return process.env[key];
|
|
43
|
+
}
|
|
7
44
|
function loadConfig(overrides = {}) {
|
|
45
|
+
loadDotenv();
|
|
8
46
|
const env = overrides.environment ?? process.env.VIBE_ENVIRONMENT ?? "dev";
|
|
9
47
|
return {
|
|
10
48
|
environment: env,
|
|
11
49
|
directPush: overrides.directPush ?? process.env.VIBE_DIRECT_PUSH === "true",
|
|
12
50
|
storageProvider: overrides.storageProvider ?? process.env.VIBE_STORAGE_PROVIDER ?? "azure-blob",
|
|
13
|
-
azureAccountName: overrides.azureAccountName ??
|
|
14
|
-
azureAccountKey: overrides.azureAccountKey ??
|
|
15
|
-
azureContainerName: overrides.azureContainerName ??
|
|
51
|
+
azureAccountName: overrides.azureAccountName ?? envScoped("VIBE_STORAGE_ACCOUNT_NAME", env),
|
|
52
|
+
azureAccountKey: overrides.azureAccountKey ?? envScoped("VIBE_STORAGE_ACCOUNT_KEY", env),
|
|
53
|
+
azureContainerName: overrides.azureContainerName ?? envScoped("VIBE_STORAGE_CONTAINER_NAME", env),
|
|
16
54
|
gitPlatform: overrides.gitPlatform ?? process.env.VIBE_GIT_PLATFORM ?? "github",
|
|
17
|
-
registryRepo: overrides.registryRepo ??
|
|
18
|
-
registryToken: overrides.registryToken ??
|
|
55
|
+
registryRepo: overrides.registryRepo ?? envScoped("VIBE_REGISTRY_REPO", env),
|
|
56
|
+
registryToken: overrides.registryToken ?? envScoped("VIBE_REGISTRY_TOKEN", env),
|
|
19
57
|
githubApiUrl: overrides.githubApiUrl ?? (process.env.VIBE_GITHUB_API_URL || undefined) ?? (process.env.GITHUB_API_URL || undefined) ?? "https://api.github.com",
|
|
20
58
|
githubServerUrl: overrides.githubServerUrl ?? (process.env.VIBE_GITHUB_SERVER_URL || undefined) ?? (process.env.GITHUB_SERVER_URL || undefined) ?? "https://github.com",
|
|
21
59
|
publishedBy: overrides.publishedBy ?? process.env.GITHUB_ACTOR ?? process.env.USER ?? "unknown"
|
|
@@ -23,8 +61,8 @@ function loadConfig(overrides = {}) {
|
|
|
23
61
|
}
|
|
24
62
|
|
|
25
63
|
// src/publish.ts
|
|
26
|
-
import { readFileSync as
|
|
27
|
-
import { resolve } from "node:path";
|
|
64
|
+
import { readFileSync as readFileSync3 } from "node:fs";
|
|
65
|
+
import { resolve as resolve2 } from "node:path";
|
|
28
66
|
|
|
29
67
|
// src/integrity.ts
|
|
30
68
|
import { createHash } from "node:crypto";
|
|
@@ -202,7 +240,7 @@ function resolveGitPlatform(config) {
|
|
|
202
240
|
}
|
|
203
241
|
|
|
204
242
|
// src/registry.ts
|
|
205
|
-
import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
243
|
+
import { readFileSync as readFileSync2, writeFileSync, mkdirSync } from "node:fs";
|
|
206
244
|
import { join } from "node:path";
|
|
207
245
|
import { tmpdir } from "node:os";
|
|
208
246
|
import { randomBytes } from "node:crypto";
|
|
@@ -214,7 +252,7 @@ async function updateRegistry(opts) {
|
|
|
214
252
|
const appsFile = join(repoDir, environment, "apps.json");
|
|
215
253
|
let apps;
|
|
216
254
|
try {
|
|
217
|
-
apps = JSON.parse(
|
|
255
|
+
apps = JSON.parse(readFileSync2(appsFile, "utf-8"));
|
|
218
256
|
} catch {
|
|
219
257
|
apps = [];
|
|
220
258
|
}
|
|
@@ -261,17 +299,17 @@ async function updateRegistry(opts) {
|
|
|
261
299
|
|
|
262
300
|
// src/publish.ts
|
|
263
301
|
async function publish(appDir, config) {
|
|
264
|
-
const manifestPath =
|
|
265
|
-
const bundlePath =
|
|
302
|
+
const manifestPath = resolve2(appDir, "manifest.json");
|
|
303
|
+
const bundlePath = resolve2(appDir, "dist/index.js");
|
|
266
304
|
let manifest;
|
|
267
305
|
try {
|
|
268
|
-
manifest = JSON.parse(
|
|
306
|
+
manifest = JSON.parse(readFileSync3(manifestPath, "utf-8"));
|
|
269
307
|
} catch {
|
|
270
308
|
throw new Error(`Cannot read manifest.json at ${manifestPath}`);
|
|
271
309
|
}
|
|
272
310
|
let bundleContent;
|
|
273
311
|
try {
|
|
274
|
-
bundleContent =
|
|
312
|
+
bundleContent = readFileSync3(bundlePath);
|
|
275
313
|
} catch {
|
|
276
314
|
throw new Error(`Cannot read dist/index.js at ${bundlePath}. Did you run "bun run build"?`);
|
|
277
315
|
}
|