@codedrifters/configulator 0.0.242 → 0.0.244

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/lib/index.js CHANGED
@@ -210,6 +210,7 @@ __export(index_exports, {
210
210
  ROOT_CI_TASK_NAME: () => ROOT_CI_TASK_NAME,
211
211
  ROOT_TURBO_TASK_NAME: () => ROOT_TURBO_TASK_NAME,
212
212
  ResetTask: () => ResetTask,
213
+ STARLIGHT_ROLE: () => STARLIGHT_ROLE,
213
214
  StarlightProject: () => StarlightProject,
214
215
  TestRunner: () => TestRunner,
215
216
  TurboRepo: () => TurboRepo,
@@ -229,6 +230,7 @@ __export(index_exports, {
229
230
  bcmWriterBundle: () => bcmWriterBundle,
230
231
  companyProfileBundle: () => companyProfileBundle,
231
232
  formatLayoutViolation: () => formatLayoutViolation,
233
+ formatStarlightSingletonViolation: () => formatStarlightSingletonViolation,
232
234
  getLatestEligibleVersion: () => getLatestEligibleVersion,
233
235
  githubWorkflowBundle: () => githubWorkflowBundle,
234
236
  industryDiscoveryBundle: () => industryDiscoveryBundle,
@@ -244,6 +246,7 @@ __export(index_exports, {
244
246
  requirementsReviewerBundle: () => requirementsReviewerBundle,
245
247
  requirementsWriterBundle: () => requirementsWriterBundle,
246
248
  researchPipelineBundle: () => researchPipelineBundle,
249
+ resolveAstroProjectOutdir: () => resolveAstroProjectOutdir,
247
250
  resolveAwsCdkProjectOutdir: () => resolveAwsCdkProjectOutdir,
248
251
  resolveModelAlias: () => resolveModelAlias,
249
252
  resolveOutdirFromPackageName: () => resolveOutdirFromPackageName,
@@ -254,6 +257,7 @@ __export(index_exports, {
254
257
  turborepoBundle: () => turborepoBundle,
255
258
  typescriptBundle: () => typescriptBundle,
256
259
  validateMonorepoLayout: () => validateMonorepoLayout,
260
+ validateStarlightSingleton: () => validateStarlightSingleton,
257
261
  vitestBundle: () => vitestBundle
258
262
  });
259
263
  module.exports = __toCommonJS(index_exports);
@@ -900,7 +904,12 @@ var baseBundle = {
900
904
  "- The docs site is monorepo-wide. Sub-project documentation belongs",
901
905
  " inside that single site (under `docs/content/`), not in a per-package",
902
906
  " `docs/` folder.",
903
- "- Configulator's `StarlightProject` defaults its `outdir` to `/docs`.",
907
+ "- Configulator's `StarlightProject` defaults its `outdir` to `/docs` and",
908
+ ' its `role` to `"docs"`. A second `StarlightProject` with `role: "docs"`',
909
+ " fails synth \u2014 the singleton rule is enforced at validate time.",
910
+ "- Additional Starlight sites (client-facing, marketing, etc.) must set",
911
+ ' `role: "site"`, which routes them under `sites/<scope>/<name>` just',
912
+ " like a plain `AstroProject`.",
904
913
  "- `/sites` is reserved for end-user-facing web front ends (marketing",
905
914
  " sites, SPAs, client-facing apps). It deliberately does not host the",
906
915
  " dev-docs site.",
@@ -916,7 +925,8 @@ var baseBundle = {
916
925
  "| `TypeScriptProject` | `packages/<scope>/<name>` |",
917
926
  "| `AwsCdkProject` | `apps/<scope>/<name>` |",
918
927
  "| `AstroProject` | `sites/<scope>/<name>` |",
919
- "| `StarlightProject` (role = docs) | `docs/` |",
928
+ "| `StarlightProject` (role = docs, default) | `docs/` |",
929
+ "| `StarlightProject` (role = site) | `sites/<scope>/<name>` |",
920
930
  "",
921
931
  "`<scope>` is parsed from the sub-project's package name (everything",
922
932
  "after `@` and before `/`). `<name>` is the unscoped part of the",
@@ -15637,18 +15647,6 @@ var JsiiFaker = class _JsiiFaker extends import_projen12.Component {
15637
15647
  // src/projects/astro-project.ts
15638
15648
  var import_projen17 = require("projen");
15639
15649
 
15640
- // src/projects/typescript-project.ts
15641
- var import_projen16 = require("projen");
15642
- var import_javascript4 = require("projen/lib/javascript");
15643
- var import_release = require("projen/lib/release");
15644
- var import_ts_deepmerge2 = require("ts-deepmerge");
15645
-
15646
- // src/projects/monorepo-project.ts
15647
- var import_github2 = require("projen/lib/github");
15648
- var import_javascript3 = require("projen/lib/javascript");
15649
- var import_typescript3 = require("projen/lib/typescript");
15650
- var import_ts_deepmerge = require("ts-deepmerge");
15651
-
15652
15650
  // src/projects/monorepo-layout.ts
15653
15651
  var MONOREPO_LAYOUT = {
15654
15652
  DOCS: "docs",
@@ -15672,7 +15670,7 @@ function validateMonorepoLayout(root) {
15672
15670
  const rootOutdir = toPosix(root.outdir);
15673
15671
  for (const sub of root.subprojects) {
15674
15672
  const className = sub.constructor.name;
15675
- const expectedRoot = LAYOUT_ROOT_BY_PROJECT_TYPE[className];
15673
+ const expectedRoot = expectedRootFor(sub, className);
15676
15674
  if (expectedRoot === void 0) {
15677
15675
  continue;
15678
15676
  }
@@ -15688,11 +15686,40 @@ function validateMonorepoLayout(root) {
15688
15686
  }
15689
15687
  return violations;
15690
15688
  }
15689
+ function validateStarlightSingleton(root) {
15690
+ const docsRoleProjects = [];
15691
+ for (const sub of root.subprojects) {
15692
+ if (sub.constructor.name !== "StarlightProject") {
15693
+ continue;
15694
+ }
15695
+ if (getStarlightRole(sub) === "docs") {
15696
+ docsRoleProjects.push(sub.name);
15697
+ }
15698
+ }
15699
+ if (docsRoleProjects.length <= 1) {
15700
+ return void 0;
15701
+ }
15702
+ return { projectNames: docsRoleProjects };
15703
+ }
15704
+ function expectedRootFor(sub, className) {
15705
+ if (className === "StarlightProject") {
15706
+ return getStarlightRole(sub) === "site" ? MONOREPO_LAYOUT.SITES : MONOREPO_LAYOUT.DOCS;
15707
+ }
15708
+ return LAYOUT_ROOT_BY_PROJECT_TYPE[className];
15709
+ }
15710
+ function getStarlightRole(sub) {
15711
+ const role = sub.role;
15712
+ return role === "site" ? "site" : "docs";
15713
+ }
15691
15714
  function formatLayoutViolation(violation) {
15692
15715
  const { projectName, projectType, outdir, expectedRoot } = violation;
15693
15716
  const expectedExample = expectedRoot === MONOREPO_LAYOUT.DOCS ? "docs/" : `${expectedRoot}/<scope>/<name>`;
15694
15717
  return `[monorepo-layout] ${projectType} "${projectName}" has outdir "${outdir}", which is outside the expected root "${expectedRoot}/" (expected e.g. "${expectedExample}"). See docs/requirements/architectural-decisions/ADR-006-monorepo-layout.md.`;
15695
15718
  }
15719
+ function formatStarlightSingletonViolation(violation) {
15720
+ const names = violation.projectNames.map((n) => `"${n}"`).join(", ");
15721
+ return `[monorepo-layout] Multiple StarlightProject instances with role: "docs" found (${names}). ADR-006 allows exactly one docs-role Starlight project per MonorepoProject. Either remove the duplicates or set role: "site" on the additional ones so they land under sites/. See docs/requirements/architectural-decisions/ADR-006-monorepo-layout.md.`;
15722
+ }
15696
15723
  function outdirMatchesRoot(relOutdir, expectedRoot) {
15697
15724
  const segments = relOutdir.split("/").filter((s) => s.length > 0);
15698
15725
  if (segments.length === 0) {
@@ -15720,6 +15747,58 @@ function relativeOutdir(rootOutdir, subOutdir) {
15720
15747
  return subOutdir;
15721
15748
  }
15722
15749
 
15750
+ // src/projects/resolve-outdir.ts
15751
+ function parseScopedName(input) {
15752
+ if (!input.startsWith("@")) {
15753
+ return void 0;
15754
+ }
15755
+ const slashIndex = input.indexOf("/");
15756
+ if (slashIndex < 2) {
15757
+ return void 0;
15758
+ }
15759
+ const scope = input.slice(0, slashIndex);
15760
+ const name = input.slice(slashIndex + 1);
15761
+ if (name.length === 0 || name.includes("/")) {
15762
+ return void 0;
15763
+ }
15764
+ return { scope, name };
15765
+ }
15766
+ function resolveOutdirFromPackageName(packageName, root) {
15767
+ if (packageName === void 0 || packageName.length === 0) {
15768
+ throw new Error(
15769
+ "Cannot derive outdir: packageName (or name) is required when outdir is omitted. Either pass a scoped `packageName` / `name` like `@scope/foo`, or set `outdir` explicitly."
15770
+ );
15771
+ }
15772
+ const parsed = parseScopedName(packageName);
15773
+ if (parsed === void 0) {
15774
+ throw new Error(
15775
+ `Cannot derive outdir from unscoped packageName "${packageName}". Either use a scoped name like \`@scope/foo\`, or set \`outdir\` explicitly. Configulator places sub-projects at "${root}/<scope>/<name>".`
15776
+ );
15777
+ }
15778
+ return `${root}/${parsed.scope}/${parsed.name}`;
15779
+ }
15780
+ function resolveTypeScriptProjectOutdir(packageName) {
15781
+ return resolveOutdirFromPackageName(packageName, MONOREPO_LAYOUT.PACKAGES);
15782
+ }
15783
+ function resolveAwsCdkProjectOutdir(packageName) {
15784
+ return resolveOutdirFromPackageName(packageName, MONOREPO_LAYOUT.APPS);
15785
+ }
15786
+ function resolveAstroProjectOutdir(packageName) {
15787
+ return resolveOutdirFromPackageName(packageName, MONOREPO_LAYOUT.SITES);
15788
+ }
15789
+
15790
+ // src/projects/typescript-project.ts
15791
+ var import_projen16 = require("projen");
15792
+ var import_javascript4 = require("projen/lib/javascript");
15793
+ var import_release = require("projen/lib/release");
15794
+ var import_ts_deepmerge2 = require("ts-deepmerge");
15795
+
15796
+ // src/projects/monorepo-project.ts
15797
+ var import_github2 = require("projen/lib/github");
15798
+ var import_javascript3 = require("projen/lib/javascript");
15799
+ var import_typescript3 = require("projen/lib/typescript");
15800
+ var import_ts_deepmerge = require("ts-deepmerge");
15801
+
15723
15802
  // src/tasks/reset-task.ts
15724
15803
  var import_projen13 = require("projen");
15725
15804
  var ResetTask = class _ResetTask extends import_projen13.Component {
@@ -16446,10 +16525,20 @@ var MonorepoProject = class extends import_typescript3.TypeScriptAppProject {
16446
16525
  * layout contract. Runs in `preSynthesize` so all sub-projects are
16447
16526
  * attached by the time we inspect the tree.
16448
16527
  *
16528
+ * Two checks run in sequence:
16529
+ *
16530
+ * 1. **Outdir-vs-root validation.** Every sub-project's `outdir` must
16531
+ * live under the root expected for its project type (ADR-006 §4).
16532
+ * 2. **Docs-singleton validation.** At most one `StarlightProject`
16533
+ * may carry `role: "docs"` (ADR-006 §3).
16534
+ *
16449
16535
  * Behavior is controlled by `layoutEnforcement`:
16450
- * - `"off"` — skip validation.
16451
- * - `"warn"` — log a `console.warn` per violation; continue.
16452
- * - `"error"` throw on the first violation.
16536
+ * - `"off"` — skip both checks.
16537
+ * - `"warn"` — log a `console.warn` per violation; continue. Singleton
16538
+ * violations also warn in this mode rather than throwing, so all
16539
+ * layout findings are surfaced consistently.
16540
+ * - `"error"` — throw on the first outdir violation, or on the
16541
+ * singleton violation if outdir validation passed.
16453
16542
  */
16454
16543
  preSynthesize() {
16455
16544
  super.preSynthesize();
@@ -16457,15 +16546,22 @@ var MonorepoProject = class extends import_typescript3.TypeScriptAppProject {
16457
16546
  return;
16458
16547
  }
16459
16548
  const violations = validateMonorepoLayout(this);
16460
- if (violations.length === 0) {
16461
- return;
16462
- }
16549
+ const singletonViolation = validateStarlightSingleton(this);
16463
16550
  if (this.layoutEnforcement === LAYOUT_ENFORCEMENT.ERROR) {
16464
- throw new Error(formatLayoutViolation(violations[0]));
16551
+ if (violations.length > 0) {
16552
+ throw new Error(formatLayoutViolation(violations[0]));
16553
+ }
16554
+ if (singletonViolation !== void 0) {
16555
+ throw new Error(formatStarlightSingletonViolation(singletonViolation));
16556
+ }
16557
+ return;
16465
16558
  }
16466
16559
  for (const violation of violations) {
16467
16560
  console.warn(formatLayoutViolation(violation));
16468
16561
  }
16562
+ if (singletonViolation !== void 0) {
16563
+ console.warn(formatStarlightSingletonViolation(singletonViolation));
16564
+ }
16469
16565
  }
16470
16566
  /**
16471
16567
  * Allows a sub project to request installation of dependency at the Monorepo root
@@ -16495,43 +16591,6 @@ var MonorepoProject = class extends import_typescript3.TypeScriptAppProject {
16495
16591
  }
16496
16592
  };
16497
16593
 
16498
- // src/projects/resolve-outdir.ts
16499
- function parseScopedName(input) {
16500
- if (!input.startsWith("@")) {
16501
- return void 0;
16502
- }
16503
- const slashIndex = input.indexOf("/");
16504
- if (slashIndex < 2) {
16505
- return void 0;
16506
- }
16507
- const scope = input.slice(0, slashIndex);
16508
- const name = input.slice(slashIndex + 1);
16509
- if (name.length === 0 || name.includes("/")) {
16510
- return void 0;
16511
- }
16512
- return { scope, name };
16513
- }
16514
- function resolveOutdirFromPackageName(packageName, root) {
16515
- if (packageName === void 0 || packageName.length === 0) {
16516
- throw new Error(
16517
- "Cannot derive outdir: packageName (or name) is required when outdir is omitted. Either pass a scoped `packageName` / `name` like `@scope/foo`, or set `outdir` explicitly."
16518
- );
16519
- }
16520
- const parsed = parseScopedName(packageName);
16521
- if (parsed === void 0) {
16522
- throw new Error(
16523
- `Cannot derive outdir from unscoped packageName "${packageName}". Either use a scoped name like \`@scope/foo\`, or set \`outdir\` explicitly. Configulator places sub-projects at "${root}/<scope>/<name>".`
16524
- );
16525
- }
16526
- return `${root}/${parsed.scope}/${parsed.name}`;
16527
- }
16528
- function resolveTypeScriptProjectOutdir(packageName) {
16529
- return resolveOutdirFromPackageName(packageName, MONOREPO_LAYOUT.PACKAGES);
16530
- }
16531
- function resolveAwsCdkProjectOutdir(packageName) {
16532
- return resolveOutdirFromPackageName(packageName, MONOREPO_LAYOUT.APPS);
16533
- }
16534
-
16535
16594
  // src/projects/typescript-project.ts
16536
16595
  var TestRunner = {
16537
16596
  JEST: "jest",
@@ -16718,9 +16777,11 @@ var TypeScriptProject = class extends import_projen16.typescript.TypeScriptProje
16718
16777
  // src/projects/astro-project.ts
16719
16778
  var AstroProject = class extends TypeScriptProject {
16720
16779
  constructor(userOptions) {
16780
+ const resolvedOutdir = userOptions.outdir ?? resolveAstroProjectOutdir(userOptions.packageName ?? userOptions.name);
16721
16781
  const options = {
16722
16782
  testRunner: TestRunner.VITEST,
16723
16783
  ...userOptions,
16784
+ outdir: resolvedOutdir,
16724
16785
  depsUpgradeOptions: {
16725
16786
  ...userOptions.depsUpgradeOptions,
16726
16787
  exclude: [...userOptions.depsUpgradeOptions?.exclude ?? [], "astro"]
@@ -17497,8 +17558,13 @@ var AwsCdkProject = class extends import_projen20.awscdk.AwsCdkTypeScriptApp {
17497
17558
 
17498
17559
  // src/projects/starlight-project.ts
17499
17560
  var import_projen21 = require("projen");
17561
+ var STARLIGHT_ROLE = {
17562
+ DOCS: "docs",
17563
+ SITE: "site"
17564
+ };
17500
17565
  var StarlightProject = class extends AstroProject {
17501
17566
  constructor(userOptions) {
17567
+ const role = userOptions.role ?? STARLIGHT_ROLE.DOCS;
17502
17568
  const starlightConfig = buildStarlightConfig(userOptions);
17503
17569
  const starlightSpec = {
17504
17570
  name: "starlight",
@@ -17506,8 +17572,10 @@ var StarlightProject = class extends AstroProject {
17506
17572
  defaultImport: true,
17507
17573
  args: JSON.stringify(starlightConfig, null, 2)
17508
17574
  };
17575
+ const resolvedOutdir = userOptions.outdir ?? (role === STARLIGHT_ROLE.DOCS ? MONOREPO_LAYOUT.DOCS : void 0);
17509
17576
  const mergedOptions = {
17510
17577
  ...userOptions,
17578
+ outdir: resolvedOutdir,
17511
17579
  integrations: [starlightSpec, ...userOptions.integrations ?? []],
17512
17580
  depsUpgradeOptions: {
17513
17581
  ...userOptions.depsUpgradeOptions,
@@ -17519,6 +17587,7 @@ var StarlightProject = class extends AstroProject {
17519
17587
  }
17520
17588
  };
17521
17589
  super(mergedOptions);
17590
+ this.role = role;
17522
17591
  const starlightVersion = userOptions.starlightVersion ?? VERSION.STARLIGHT_VERSION;
17523
17592
  const sharpVersion = userOptions.sharpVersion ?? VERSION.SHARP_VERSION;
17524
17593
  this.addDeps(
@@ -17646,6 +17715,7 @@ var TypeScriptConfig = class extends import_projen22.Component {
17646
17715
  ROOT_CI_TASK_NAME,
17647
17716
  ROOT_TURBO_TASK_NAME,
17648
17717
  ResetTask,
17718
+ STARLIGHT_ROLE,
17649
17719
  StarlightProject,
17650
17720
  TestRunner,
17651
17721
  TurboRepo,
@@ -17665,6 +17735,7 @@ var TypeScriptConfig = class extends import_projen22.Component {
17665
17735
  bcmWriterBundle,
17666
17736
  companyProfileBundle,
17667
17737
  formatLayoutViolation,
17738
+ formatStarlightSingletonViolation,
17668
17739
  getLatestEligibleVersion,
17669
17740
  githubWorkflowBundle,
17670
17741
  industryDiscoveryBundle,
@@ -17680,6 +17751,7 @@ var TypeScriptConfig = class extends import_projen22.Component {
17680
17751
  requirementsReviewerBundle,
17681
17752
  requirementsWriterBundle,
17682
17753
  researchPipelineBundle,
17754
+ resolveAstroProjectOutdir,
17683
17755
  resolveAwsCdkProjectOutdir,
17684
17756
  resolveModelAlias,
17685
17757
  resolveOutdirFromPackageName,
@@ -17690,6 +17762,7 @@ var TypeScriptConfig = class extends import_projen22.Component {
17690
17762
  turborepoBundle,
17691
17763
  typescriptBundle,
17692
17764
  validateMonorepoLayout,
17765
+ validateStarlightSingleton,
17693
17766
  vitestBundle
17694
17767
  });
17695
17768
  //# sourceMappingURL=index.js.map