@acta-dev/cli 1.0.0 → 1.1.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.
Files changed (2) hide show
  1. package/dist/index.js +154 -11
  2. package/package.json +3 -2
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // src/index.ts
4
4
  import { realpathSync } from "fs";
5
5
  import { fileURLToPath } from "url";
6
- import { defineCommand as defineCommand9, runMain } from "citty";
6
+ import { defineCommand as defineCommand10, runMain } from "citty";
7
7
 
8
8
  // src/commands/build.ts
9
9
  import { buildArtifacts } from "@acta-dev/core";
@@ -1215,13 +1215,155 @@ function formatShowDate(value) {
1215
1215
  return `${year}-${month}-${day}`;
1216
1216
  }
1217
1217
 
1218
+ // src/commands/site.ts
1219
+ import { spawn } from "child_process";
1220
+ import { createRequire } from "module";
1221
+ import { dirname as dirname2, join as join6, resolve as resolve3 } from "path";
1222
+ import { buildArtifacts as buildArtifacts2 } from "@acta-dev/core";
1223
+ import { defineCommand as defineCommand8 } from "citty";
1224
+ import kleur6 from "kleur";
1225
+ function resolveSiteOptions(config, args, cwd = process.cwd()) {
1226
+ return {
1227
+ outDir: args.out ? resolve3(cwd, args.out) : config.resolvedSite.outDir,
1228
+ base: args.base ?? config.site.base,
1229
+ site: args.site ?? config.site.url
1230
+ };
1231
+ }
1232
+ function buildSiteEnv(config, options) {
1233
+ const env = {
1234
+ ...process.env,
1235
+ ASTRO_TELEMETRY_DISABLED: "1",
1236
+ ACTA_PROJECT_ROOT: config.rootDir,
1237
+ ACTA_DIST_DIR: config.resolvedBuild.outDir,
1238
+ ACTA_SITE_OUT: options.outDir
1239
+ };
1240
+ if (options.base !== void 0) env.ACTA_BASE = options.base;
1241
+ if (options.site !== void 0) env.ACTA_SITE = options.site;
1242
+ return env;
1243
+ }
1244
+ var siteCommand = defineCommand8({
1245
+ meta: {
1246
+ name: "site",
1247
+ description: "Build a deployable static web viewer from your docs into the site output dir"
1248
+ },
1249
+ args: {
1250
+ out: {
1251
+ type: "string",
1252
+ description: "Output directory for the generated site (default: .acta/site)"
1253
+ },
1254
+ base: {
1255
+ type: "string",
1256
+ description: "Base path for hosting under a subpath (e.g. /my-repo for project Pages)"
1257
+ },
1258
+ site: {
1259
+ type: "string",
1260
+ description: "Absolute site URL used for canonical links and sitemaps"
1261
+ },
1262
+ "skip-build": {
1263
+ type: "boolean",
1264
+ description: "Reuse existing artifacts instead of running `acta build` first",
1265
+ default: false
1266
+ },
1267
+ config: {
1268
+ type: "string",
1269
+ alias: "c",
1270
+ description: "Path to acta.config.ts"
1271
+ },
1272
+ json: {
1273
+ type: "boolean",
1274
+ description: "Print the result as JSON",
1275
+ default: false
1276
+ }
1277
+ },
1278
+ async run({ args }) {
1279
+ const { config } = await resolveContext({ config: args.config });
1280
+ const json = Boolean(args.json);
1281
+ let documentCount = 0;
1282
+ if (!args["skip-build"]) {
1283
+ if (!json) printLine("Building artifacts...");
1284
+ const { manifest, validation } = await buildArtifacts2({ config });
1285
+ documentCount = manifest.documentCount;
1286
+ if (validation.errorCount > 0 && !json) {
1287
+ printWarn(
1288
+ `Building site with ${validation.errorCount} validation error${validation.errorCount !== 1 ? "s" : ""}. Run \`acta validate\` for details.`
1289
+ );
1290
+ }
1291
+ }
1292
+ const webDir = resolveWebPackageDir();
1293
+ if (!webDir) {
1294
+ return exitFailure(
1295
+ "Could not locate @acta-dev/web. Install it alongside @acta-dev/cli to use `acta site`."
1296
+ );
1297
+ }
1298
+ const astroBin = resolveAstroBin(webDir);
1299
+ if (!astroBin) {
1300
+ return exitFailure("Could not locate the Astro binary inside @acta-dev/web.");
1301
+ }
1302
+ const options = resolveSiteOptions(config, args);
1303
+ if (!json) printLine("Building static viewer...");
1304
+ const env = buildSiteEnv(config, options);
1305
+ const code = await runAstroBuild(astroBin, webDir, env, json);
1306
+ if (code !== 0) {
1307
+ return exitFailure(`Astro build failed with exit code ${code}.`);
1308
+ }
1309
+ if (json) {
1310
+ printJson({
1311
+ ok: true,
1312
+ outDir: options.outDir,
1313
+ base: options.base ?? null,
1314
+ site: options.site ?? null,
1315
+ documentCount
1316
+ });
1317
+ return;
1318
+ }
1319
+ printLine();
1320
+ printSuccess("Site built");
1321
+ printLine(` ${kleur6.bold("Output:")} ${options.outDir}`);
1322
+ if (options.base) printLine(` ${kleur6.bold("Base:")} ${options.base}`);
1323
+ printLine();
1324
+ printLine(kleur6.dim("Deploy the contents of the output directory to any static host."));
1325
+ }
1326
+ });
1327
+ function resolveWebPackageDir() {
1328
+ const require2 = createRequire(import.meta.url);
1329
+ try {
1330
+ return dirname2(require2.resolve("@acta-dev/web/package.json"));
1331
+ } catch {
1332
+ return void 0;
1333
+ }
1334
+ }
1335
+ function resolveAstroBin(webDir) {
1336
+ const require2 = createRequire(join6(webDir, "package.json"));
1337
+ try {
1338
+ const astroPkgJsonPath = require2.resolve("astro/package.json");
1339
+ const astroPkg = require2("astro/package.json");
1340
+ const binRel = typeof astroPkg.bin === "string" ? astroPkg.bin : astroPkg.bin?.astro;
1341
+ if (!binRel) return void 0;
1342
+ return join6(dirname2(astroPkgJsonPath), binRel);
1343
+ } catch {
1344
+ return void 0;
1345
+ }
1346
+ }
1347
+ function runAstroBuild(astroBin, webDir, env, json) {
1348
+ return new Promise((resolvePromise) => {
1349
+ const child = spawn(process.execPath, [astroBin, "build"], {
1350
+ cwd: webDir,
1351
+ env,
1352
+ // Astro logs go to stderr so JSON on stdout stays clean.
1353
+ stdio: json ? ["ignore", "ignore", "inherit"] : "inherit"
1354
+ });
1355
+ child.on("close", (code) => resolvePromise(code ?? 1));
1356
+ child.on("error", () => resolvePromise(1));
1357
+ });
1358
+ }
1359
+
1218
1360
  // src/commands/validate.ts
1219
1361
  import { mkdir as mkdir2, writeFile as writeFile4 } from "fs/promises";
1220
- import { join as join6 } from "path";
1362
+ import { join as join7 } from "path";
1221
1363
  import { validateLoadedProject } from "@acta-dev/core";
1222
- import { defineCommand as defineCommand8 } from "citty";
1223
- import kleur6 from "kleur";
1224
- var validateCommand = defineCommand8({
1364
+ import { defineCommand as defineCommand9 } from "citty";
1365
+ import kleur7 from "kleur";
1366
+ var validateCommand = defineCommand9({
1225
1367
  meta: {
1226
1368
  name: "validate",
1227
1369
  description: "Validate frontmatter, IDs, links, sections and repository rules"
@@ -1253,16 +1395,16 @@ var validateCommand = defineCommand8({
1253
1395
  }
1254
1396
  if (args.ci) {
1255
1397
  await mkdir2(config.resolvedBuild.outDir, { recursive: true });
1256
- const outPath = join6(config.resolvedBuild.outDir, "validation.json");
1398
+ const outPath = join7(config.resolvedBuild.outDir, "validation.json");
1257
1399
  await writeFile4(outPath, `${JSON.stringify(result, null, 2)}
1258
1400
  `, "utf8");
1259
1401
  if (result.errors.length > 0) {
1260
1402
  for (const issue of result.errors) {
1261
- printLine(`${kleur6.red("error")} ${issue.documentId ?? ""} ${issue.message}`);
1403
+ printLine(`${kleur7.red("error")} ${issue.documentId ?? ""} ${issue.message}`);
1262
1404
  }
1263
1405
  }
1264
1406
  for (const issue of result.warnings) {
1265
- printLine(`${kleur6.yellow("warn")} ${issue.documentId ?? ""} ${issue.message}`);
1407
+ printLine(`${kleur7.yellow("warn")} ${issue.documentId ?? ""} ${issue.message}`);
1266
1408
  }
1267
1409
  printLine(`Written ${outPath}`);
1268
1410
  process.exit(result.valid ? 0 : 1);
@@ -1275,12 +1417,12 @@ var validateCommand = defineCommand8({
1275
1417
  const warnings = result.issues.filter((i) => i.severity === "warning");
1276
1418
  if (errors.length > 0) {
1277
1419
  printLine();
1278
- printLine(kleur6.bold("Errors:"));
1420
+ printLine(kleur7.bold("Errors:"));
1279
1421
  printIssues(errors);
1280
1422
  }
1281
1423
  if (warnings.length > 0) {
1282
1424
  printLine();
1283
- printLine(kleur6.bold("Warnings:"));
1425
+ printLine(kleur7.bold("Warnings:"));
1284
1426
  printIssues(warnings);
1285
1427
  }
1286
1428
  printLine();
@@ -1291,7 +1433,7 @@ var validateCommand = defineCommand8({
1291
1433
  });
1292
1434
 
1293
1435
  // src/index.ts
1294
- var main = defineCommand9({
1436
+ var main = defineCommand10({
1295
1437
  meta: {
1296
1438
  name: "acta",
1297
1439
  version: "0.0.0",
@@ -1305,6 +1447,7 @@ var main = defineCommand9({
1305
1447
  validate: validateCommand,
1306
1448
  graph: graphCommand,
1307
1449
  build: buildCommand,
1450
+ site: siteCommand,
1308
1451
  renumber: renumberCommand
1309
1452
  }
1310
1453
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acta-dev/cli",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Acta CLI — TypeScript-first docs-as-code tooling for ADR and spec documents in Git. Provides the `acta` binary.",
5
5
  "keywords": [
6
6
  "adr",
@@ -45,7 +45,8 @@
45
45
  "citty": "^0.2.2",
46
46
  "kleur": "^4.1.5",
47
47
  "yaml": "^2.8.3",
48
- "@acta-dev/core": "1.0.0"
48
+ "@acta-dev/core": "1.1.0",
49
+ "@acta-dev/web": "1.0.0"
49
50
  },
50
51
  "devDependencies": {
51
52
  "execa": "^9.6.1",