Skip to content

Commit

Permalink
feat: ignore tenant modules when analyzing dependencies in collie repo
Browse files Browse the repository at this point in the history
This excludes tenant modules from generated documentation.
Tenant modules can still be deployed from "collie foundation deploy"
  • Loading branch information
JohannesRudolph committed Mar 25, 2024
1 parent 5ce2aa9 commit 874e537
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/commands/foundation/TestModuleType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ import { PlatformModuleType } from "./PlatformModuleType.ts";
export class TestModuleType extends StringType {
async complete(): Promise<string[]> {
const repo = await CollieRepository.load();
const excludes = {
testModules: false,
tenantModules: true,
};

const modules = await repo.processFilesGlob(
"foundations/*/platforms/**/*.test/terragrunt.hcl",
(file) => PlatformModuleType.parseModuleId(file.path),
false,
excludes,
);

// I don't know how we could get the foundation name passed to the arg to filter
Expand Down
7 changes: 6 additions & 1 deletion src/foundation/PlatformDeployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,15 @@ export class PlatformDeployer<T extends PlatformConfig> {
}

private async testModuleTerragruntFiles(relativeModulePath: string) {
const excludes = {
testModules: false,
tenantModules: true,
};

const files = await this.repo.processFilesGlob(
`${relativeModulePath}/${TEST_MODULE_GLOB}/terragrunt.hcl`,
(file) => file,
false,
excludes,
);

// a terragrunt stack conists of multiple executable terragrunt files
Expand Down
5 changes: 5 additions & 0 deletions src/kit/KitDependencyAnalyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,14 @@ export class KitDependencyAnalyzer {
this.logger,
);

const excludes = {
tenantModules: true,
testModules: true,
};
const q = await this.collie.processFilesGlob(
`${relativePlatformPath}/**/terragrunt.hcl`,
(file) => this.tryParseDependency(file.path),
excludes,
);

const all = await Promise.all(q);
Expand Down
12 changes: 10 additions & 2 deletions src/model/CollieRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as fs from "std/fs";
import * as path from "std/path";

export const TEST_MODULE_GLOB = "**/*.test";
export const TENANT_MODULE_GLOB = "**/tenants";

export class CollieRepository {
private constructor(private readonly repoDir: string) {
Expand Down Expand Up @@ -52,7 +53,13 @@ export class CollieRepository {
async processFilesGlob<T>(
pattern: string,
process: (file: fs.WalkEntry) => T | undefined,
excludeTestModules = true,
excludes: {
testModules: boolean;
tenantModules: boolean;
} = {
testModules: true,
tenantModules: false,
},
): Promise<T[]> {
const q: T[] = [];
for await (
Expand All @@ -70,7 +77,8 @@ export class CollieRepository {
"kit/**/modules", // exclude sub-modules
"kit/**/template", // exclude template files

...(excludeTestModules ? [TEST_MODULE_GLOB] : []),
...(excludes.testModules ? [TEST_MODULE_GLOB] : []),
...(excludes.tenantModules ? [TENANT_MODULE_GLOB] : []),
],
})
) {
Expand Down

0 comments on commit 874e537

Please sign in to comment.