@codedrifters/configulator 0.0.238 → 0.0.239
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.d.mts +103 -1
- package/lib/index.d.ts +104 -2
- package/lib/index.js +113 -0
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +108 -0
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/index.mjs
CHANGED
|
@@ -15487,6 +15487,77 @@ import {
|
|
|
15487
15487
|
} from "projen/lib/typescript";
|
|
15488
15488
|
import { merge } from "ts-deepmerge";
|
|
15489
15489
|
|
|
15490
|
+
// src/projects/monorepo-layout.ts
|
|
15491
|
+
var MONOREPO_LAYOUT = {
|
|
15492
|
+
DOCS: "docs",
|
|
15493
|
+
APPS: "apps",
|
|
15494
|
+
PACKAGES: "packages",
|
|
15495
|
+
SITES: "sites"
|
|
15496
|
+
};
|
|
15497
|
+
var LAYOUT_ENFORCEMENT = {
|
|
15498
|
+
OFF: "off",
|
|
15499
|
+
WARN: "warn",
|
|
15500
|
+
ERROR: "error"
|
|
15501
|
+
};
|
|
15502
|
+
var LAYOUT_ROOT_BY_PROJECT_TYPE = {
|
|
15503
|
+
TypeScriptProject: MONOREPO_LAYOUT.PACKAGES,
|
|
15504
|
+
AwsCdkProject: MONOREPO_LAYOUT.APPS,
|
|
15505
|
+
AstroProject: MONOREPO_LAYOUT.SITES,
|
|
15506
|
+
StarlightProject: MONOREPO_LAYOUT.DOCS
|
|
15507
|
+
};
|
|
15508
|
+
function validateMonorepoLayout(root) {
|
|
15509
|
+
const violations = [];
|
|
15510
|
+
const rootOutdir = toPosix(root.outdir);
|
|
15511
|
+
for (const sub of root.subprojects) {
|
|
15512
|
+
const className = sub.constructor.name;
|
|
15513
|
+
const expectedRoot = LAYOUT_ROOT_BY_PROJECT_TYPE[className];
|
|
15514
|
+
if (expectedRoot === void 0) {
|
|
15515
|
+
continue;
|
|
15516
|
+
}
|
|
15517
|
+
const relOutdir = relativeOutdir(rootOutdir, toPosix(sub.outdir));
|
|
15518
|
+
if (!outdirMatchesRoot(relOutdir, expectedRoot)) {
|
|
15519
|
+
violations.push({
|
|
15520
|
+
projectName: sub.name,
|
|
15521
|
+
projectType: className,
|
|
15522
|
+
outdir: relOutdir,
|
|
15523
|
+
expectedRoot
|
|
15524
|
+
});
|
|
15525
|
+
}
|
|
15526
|
+
}
|
|
15527
|
+
return violations;
|
|
15528
|
+
}
|
|
15529
|
+
function formatLayoutViolation(violation) {
|
|
15530
|
+
const { projectName, projectType, outdir, expectedRoot } = violation;
|
|
15531
|
+
const expectedExample = expectedRoot === MONOREPO_LAYOUT.DOCS ? "docs/" : `${expectedRoot}/<scope>/<name>`;
|
|
15532
|
+
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.`;
|
|
15533
|
+
}
|
|
15534
|
+
function outdirMatchesRoot(relOutdir, expectedRoot) {
|
|
15535
|
+
const segments = relOutdir.split("/").filter((s) => s.length > 0);
|
|
15536
|
+
if (segments.length === 0) {
|
|
15537
|
+
return false;
|
|
15538
|
+
}
|
|
15539
|
+
if (segments[0] !== expectedRoot) {
|
|
15540
|
+
return false;
|
|
15541
|
+
}
|
|
15542
|
+
if (expectedRoot === MONOREPO_LAYOUT.DOCS) {
|
|
15543
|
+
return true;
|
|
15544
|
+
}
|
|
15545
|
+
return segments.length >= 2;
|
|
15546
|
+
}
|
|
15547
|
+
function toPosix(p) {
|
|
15548
|
+
return p.replace(/\\/g, "/");
|
|
15549
|
+
}
|
|
15550
|
+
function relativeOutdir(rootOutdir, subOutdir) {
|
|
15551
|
+
if (subOutdir === rootOutdir) {
|
|
15552
|
+
return "";
|
|
15553
|
+
}
|
|
15554
|
+
const prefix2 = rootOutdir.endsWith("/") ? rootOutdir : `${rootOutdir}/`;
|
|
15555
|
+
if (subOutdir.startsWith(prefix2)) {
|
|
15556
|
+
return subOutdir.slice(prefix2.length);
|
|
15557
|
+
}
|
|
15558
|
+
return subOutdir;
|
|
15559
|
+
}
|
|
15560
|
+
|
|
15490
15561
|
// src/tasks/reset-task.ts
|
|
15491
15562
|
import { Component as Component13 } from "projen";
|
|
15492
15563
|
var ResetTask = class _ResetTask extends Component13 {
|
|
@@ -15995,6 +16066,11 @@ var MonorepoProject = class extends TypeScriptAppProject {
|
|
|
15995
16066
|
* By default treat as a registry consumer (upgrade workflow syncs configulator).
|
|
15996
16067
|
*/
|
|
15997
16068
|
configulatorRegistryConsumer: true,
|
|
16069
|
+
/**
|
|
16070
|
+
* ADR-006 layout enforcement defaults to "warn" during rollout so
|
|
16071
|
+
* legacy outdirs log actionable warnings but do not break synth.
|
|
16072
|
+
*/
|
|
16073
|
+
layoutEnforcement: LAYOUT_ENFORCEMENT.WARN,
|
|
15998
16074
|
/**
|
|
15999
16075
|
* We don't want sample code generated for the root project.
|
|
16000
16076
|
*/
|
|
@@ -16108,6 +16184,7 @@ var MonorepoProject = class extends TypeScriptAppProject {
|
|
|
16108
16184
|
this.tsconfig?.removeInclude(`${this.srcdir}/**/*.ts`);
|
|
16109
16185
|
this.pnpmVersion = options.pnpmVersion;
|
|
16110
16186
|
this.configulatorRegistryConsumer = options.configulatorRegistryConsumer ?? true;
|
|
16187
|
+
this.layoutEnforcement = options.layoutEnforcement ?? LAYOUT_ENFORCEMENT.WARN;
|
|
16111
16188
|
new VSCodeConfig(this);
|
|
16112
16189
|
new PnpmWorkspace(this, options.pnpmOptions?.pnpmWorkspaceOptions);
|
|
16113
16190
|
if (options.turbo) {
|
|
@@ -16202,6 +16279,32 @@ var MonorepoProject = class extends TypeScriptAppProject {
|
|
|
16202
16279
|
);
|
|
16203
16280
|
}
|
|
16204
16281
|
}
|
|
16282
|
+
/**
|
|
16283
|
+
* Validate sub-project `outdir` values against the ADR-006 monorepo
|
|
16284
|
+
* layout contract. Runs in `preSynthesize` so all sub-projects are
|
|
16285
|
+
* attached by the time we inspect the tree.
|
|
16286
|
+
*
|
|
16287
|
+
* Behavior is controlled by `layoutEnforcement`:
|
|
16288
|
+
* - `"off"` — skip validation.
|
|
16289
|
+
* - `"warn"` — log a `console.warn` per violation; continue.
|
|
16290
|
+
* - `"error"` — throw on the first violation.
|
|
16291
|
+
*/
|
|
16292
|
+
preSynthesize() {
|
|
16293
|
+
super.preSynthesize();
|
|
16294
|
+
if (this.layoutEnforcement === LAYOUT_ENFORCEMENT.OFF) {
|
|
16295
|
+
return;
|
|
16296
|
+
}
|
|
16297
|
+
const violations = validateMonorepoLayout(this);
|
|
16298
|
+
if (violations.length === 0) {
|
|
16299
|
+
return;
|
|
16300
|
+
}
|
|
16301
|
+
if (this.layoutEnforcement === LAYOUT_ENFORCEMENT.ERROR) {
|
|
16302
|
+
throw new Error(formatLayoutViolation(violations[0]));
|
|
16303
|
+
}
|
|
16304
|
+
for (const violation of violations) {
|
|
16305
|
+
console.warn(formatLayoutViolation(violation));
|
|
16306
|
+
}
|
|
16307
|
+
}
|
|
16205
16308
|
/**
|
|
16206
16309
|
* Allows a sub project to request installation of dependency at the Monorepo root
|
|
16207
16310
|
* They must provide a function that is executed after dependencies have been installed
|
|
@@ -17322,10 +17425,13 @@ export {
|
|
|
17322
17425
|
DEFAULT_TEARDOWN_BRANCH_PATTERNS,
|
|
17323
17426
|
DEFAULT_TYPE_LABELS,
|
|
17324
17427
|
JsiiFaker,
|
|
17428
|
+
LAYOUT_ENFORCEMENT,
|
|
17429
|
+
LAYOUT_ROOT_BY_PROJECT_TYPE,
|
|
17325
17430
|
MCP_TRANSPORT,
|
|
17326
17431
|
MERGE_METHODS,
|
|
17327
17432
|
MIMIMUM_RELEASE_AGE,
|
|
17328
17433
|
MINIMUM_RELEASE_AGE,
|
|
17434
|
+
MONOREPO_LAYOUT,
|
|
17329
17435
|
MonorepoProject,
|
|
17330
17436
|
PROD_DEPLOY_NAME,
|
|
17331
17437
|
PnpmWorkspace,
|
|
@@ -17352,6 +17458,7 @@ export {
|
|
|
17352
17458
|
baseBundle,
|
|
17353
17459
|
bcmWriterBundle,
|
|
17354
17460
|
companyProfileBundle,
|
|
17461
|
+
formatLayoutViolation,
|
|
17355
17462
|
getLatestEligibleVersion,
|
|
17356
17463
|
githubWorkflowBundle,
|
|
17357
17464
|
industryDiscoveryBundle,
|
|
@@ -17373,6 +17480,7 @@ export {
|
|
|
17373
17480
|
softwareProfileBundle,
|
|
17374
17481
|
turborepoBundle,
|
|
17375
17482
|
typescriptBundle,
|
|
17483
|
+
validateMonorepoLayout,
|
|
17376
17484
|
vitestBundle
|
|
17377
17485
|
};
|
|
17378
17486
|
//# sourceMappingURL=index.mjs.map
|