Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
id: fmt
uses: denoland/setup-deno@main
with:
deno-version: "~1.21"
deno-version: "~1.25"
- run: |
deno fmt --check

Expand All @@ -35,7 +35,7 @@ jobs:
id: lint
uses: denoland/setup-deno@main
with:
deno-version: "~1.21"
deno-version: "~1.25"
- run: |
deno lint

Expand All @@ -55,7 +55,7 @@ jobs:
- uses: actions/checkout@v2
- uses: denoland/setup-deno@main
with:
deno-version: "~1.21"
deno-version: "~1.25"
- uses: actions/cache@v2
with:
path: ~/.cache/deno # see https://deno.land/manual/linking_to_external_code
Expand Down
2 changes: 2 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"tasks": {
"run": "deno run $(deno run --quiet --no-check ./flags.ts) ./src/main.ts",
"check": "deno check --import-map src/import_map.json ./src/main.ts",
"bundlesize": "deno bundle --import-map src/import_map.json ./src/main.ts | wc -c | awk '{print $1/1000\"K\"}'",
"info": "deno info --import-map src/import_map.json ./src/main.ts",
"test": "deno test $(deno run --quiet --no-check ./flags.ts) src/",
"install": "deno install -f -n collie $(deno run --quiet --no-check ./flags.ts) src/main.ts"
}
Expand Down
Empty file modified install.sh
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions src/cli/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export class Logger {
readonly fmtUtils: FormatUtils;

constructor(kit: CollieRepository, opts: GlobalCommandOptions) {
this.enableVerbose = opts.verbose;
this.enableDebug = opts.debug;
this.enableVerbose = !!opts.verbose;
this.enableDebug = !!opts.debug;

this.fmtUtils = {
kitPath(dest: string) {
Expand Down
10 changes: 2 additions & 8 deletions src/commands/GlobalCommandOptions.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import { EnumType } from "../deps.ts";
import { OutputFormat } from "../presentation/output-format.ts";

export const OutputFormatType = new EnumType(Object.values(OutputFormat));

export interface GlobalCommandOptions {
debug: boolean;
verbose: boolean;
output: OutputFormat;
debug?: true | undefined;
verbose?: true | undefined;
}
23 changes: 23 additions & 0 deletions src/commands/TopLevelCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Command } from "../deps.ts";
import { FoundationType } from "./FoundationType.ts";
import { PlatformType } from "./PlatformType.ts";

export function makeTopLevelCommand() {
return new Command()
.globalType("foundation", new FoundationType())
.globalType("platform", new PlatformType())
// todo: cliffy 0.24.2 has a nice group options that we could use here
.globalOption(
"--verbose",
"Enable printing verbose info (command execution and results)",
)
.globalOption(
"--debug",
"Enable printing debug info (command output, intermediate results)",
);
}

// cliffy had a breaking change in https://github.com/c4spar/deno-cliffy/releases/tag/v0.23.0
// to make the strict typing API the default - this is not our preferred API on this high-level here
// as the types get in the way, individual commands are free to use strict typings for individual subcommands
export type TopLevelCommand = ReturnType<typeof makeTopLevelCommand>;
9 changes: 5 additions & 4 deletions src/commands/compliance/compliance.command.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Command } from "../../deps.ts";
import { makeTopLevelCommand, TopLevelCommand } from "../TopLevelCommand.ts";
import { registerNewCmd } from "./new.command.ts";
import { registerTreeCmd } from "./tree.command.ts";

export function registerComplianceCommand(program: Command) {
const complianceCommands = new Command();
export function registerComplianceCommand(program: TopLevelCommand) {
const complianceCommands = makeTopLevelCommand();

registerTreeCmd(complianceCommands);
registerNewCmd(complianceCommands);

Expand All @@ -12,5 +13,5 @@ export function registerComplianceCommand(program: Command) {
.description(
"Manage compliance frameworks and audit their implementation in your cloud foundation",
)
.action(complianceCommands.showHelp);
.action(() => complianceCommands.showHelp());
}
5 changes: 3 additions & 2 deletions src/commands/compliance/new.command.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import * as path from "std/path";

import { Command, Input } from "../../deps.ts";
import { Input } from "../../deps.ts";
import { Logger } from "../../cli/Logger.ts";
import { CollieRepository } from "../../model/CollieRepository.ts";
import { MarkdownDocument } from "../../model/MarkdownDocument.ts";
import { GlobalCommandOptions } from "../GlobalCommandOptions.ts";
import { ComplianceControl } from "../../compliance/ComplianceControl.ts";
import { TopLevelCommand } from "../TopLevelCommand.ts";

export function registerNewCmd(program: Command) {
export function registerNewCmd(program: TopLevelCommand) {
program
.command("new <control> [name]")
.description("generate a new compliance control")
Expand Down
4 changes: 2 additions & 2 deletions src/commands/compliance/tree.command.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { jsonTree } from "x/json_tree";
import { Command } from "../../deps.ts";

import { Logger } from "../../cli/Logger.ts";
import { CollieRepository } from "../../model/CollieRepository.ts";
Expand All @@ -11,13 +10,14 @@ import {
AnalyzeResults,
prepareAnalyzeCommand,
} from "../prepareAnalyzeCommand.ts";
import { TopLevelCommand } from "../TopLevelCommand.ts";

const statementExample = `\tcompliance:
\t- control: my/control # id of the control
\t statement: "description how this module implements measures towards this control"
`;

export function registerTreeCmd(program: Command) {
export function registerTreeCmd(program: TopLevelCommand) {
program
.command("tree")
.description("show the compliance control tree with module implementations")
Expand Down
4 changes: 3 additions & 1 deletion src/commands/create-issue.command.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Command, open } from "../deps.ts";
import { CLI, GitHubUrl } from "../info.ts";
import { TopLevelCommand } from "./TopLevelCommand.ts";

export function registerCreateIssueCommand(program: Command) {
export function registerCreateIssueCommand(program: TopLevelCommand) {
const createIssueCommand = new Command()
.description(`Open GitHub to create a new issue for ${CLI}.`)
.action(openNewIssue);

program.command("create-issue", createIssueCommand);
}

Expand Down
4 changes: 3 additions & 1 deletion src/commands/feedback.command.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Command, open } from "../deps.ts";
import { CLI, GitHubUrl } from "../info.ts";
import { TopLevelCommand } from "./TopLevelCommand.ts";

export function registerFeedbackCommand(program: Command) {
export function registerFeedbackCommand(program: TopLevelCommand) {
const feedbackCmd = new Command()
.description(
`Open the ${CLI} CLI feedback board in GitHub Discussions.`,
)
.action(openFeedback);

program.command("feedback", feedbackCmd);
}

Expand Down
4 changes: 2 additions & 2 deletions src/commands/foundation/config.command.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { jsonTree } from "x/json_tree";

import { Command } from "/deps.ts";
import { CollieRepository } from "../../model/CollieRepository.ts";
import { GlobalCommandOptions } from "../GlobalCommandOptions.ts";
import { Logger } from "../../cli/Logger.ts";
import { ModelValidator } from "../../model/schemas/ModelValidator.ts";
import { FoundationRepository } from "../../model/FoundationRepository.ts";
import { FoundationConfigTreeBuilder } from "../../foundation/FoundationConfigTreeBuilder.ts";
import { TopLevelCommand } from "../TopLevelCommand.ts";

export function registerConfigCmd(program: Command) {
export function registerConfigCmd(program: TopLevelCommand) {
program
.command("config")
.description("show cloud foundation config file tree")
Expand Down
20 changes: 12 additions & 8 deletions src/commands/foundation/deploy.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {

import { GlobalCommandOptions } from "../GlobalCommandOptions.ts";
import { CollieRepository } from "../../model/CollieRepository.ts";
import { Command } from "../../deps.ts";
import { Logger } from "../../cli/Logger.ts";
import { FoundationRepository } from "../../model/FoundationRepository.ts";
import { ProgressReporter } from "../../cli/ProgressReporter.ts";
Expand All @@ -15,15 +14,16 @@ import { PlatformDeployer } from "../../foundation/PlatformDeployer.ts";
import { PlatformModuleType } from "./PlatformModuleType.ts";
import { CLI } from "../../info.ts";
import { LiteralArgsParser } from "../LiteralArgsParser.ts";
import { TopLevelCommand } from "../TopLevelCommand.ts";

interface DeployOptions {
platform: string;
bootstrap: boolean;
autoApprove: boolean;
platform?: string;
bootstrap?: boolean;
autoApprove?: boolean;
module?: string;
}

export function registerDeployCmd(program: Command) {
export function registerDeployCmd(program: TopLevelCommand) {
const cmd = program
.command("deploy <foundation:foundation>")
.description(
Expand All @@ -34,7 +34,7 @@ export function registerDeployCmd(program: Command) {
"-p, --platform <platform:platform>", // todo: make optional -> deploy all platforms!
"the platform to deploy",
)
.option("--module [module:module]", "Execute this specific module", {
.option("--module <module:module>", "Execute this specific module", {
conflicts: ["bootstrap"],
})
.option("--bootstrap", "deploy the bootstrap module")
Expand Down Expand Up @@ -130,9 +130,13 @@ async function deployFoundation(
);

if (opts.bootstrap) {
await deployer.deployBootstrapModules(mode, opts.autoApprove);
await deployer.deployBootstrapModules(mode, !!opts.autoApprove);
} else {
await deployer.deployPlatformModules(mode, opts.module, opts.autoApprove);
await deployer.deployPlatformModules(
mode,
opts.module,
!!opts.autoApprove,
);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/commands/foundation/docs.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { DirectoryGenerator, WriteMode } from "../../cli/DirectoryGenerator.ts";
import { Logger } from "../../cli/Logger.ts";
import { ProgressReporter } from "../../cli/ProgressReporter.ts";
import { ComplianceControlRepository } from "../../compliance/ComplianceControlRepository.ts";
import { Command } from "../../deps.ts";
import { ComplianceDocumentationGenerator } from "../../docs/ComplianceDocumentationGenerator.ts";
import { DocumentationGenerator } from "../../docs/DocumentationGenerator.ts";
import { DocumentationRepository } from "../../docs/DocumentationRepository.ts";
Expand All @@ -16,13 +15,14 @@ import { CollieRepository } from "../../model/CollieRepository.ts";
import { FoundationRepository } from "../../model/FoundationRepository.ts";
import { ModelValidator } from "../../model/schemas/ModelValidator.ts";
import { GlobalCommandOptions } from "../GlobalCommandOptions.ts";
import { TopLevelCommand } from "../TopLevelCommand.ts";

interface DocsCommandOptions {
update: boolean;
preview: boolean;
update?: boolean;
preview?: boolean;
}

export function registerDocsCmd(program: Command) {
export function registerDocsCmd(program: TopLevelCommand) {
program
.command("docs <foundation:foundation>")
.description(
Expand Down
8 changes: 4 additions & 4 deletions src/commands/foundation/foundation.command.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Command } from "../../deps.ts";
import { registerDeployCmd } from "./deploy.command.ts";
import { registerConfigCmd } from "./config.command.ts";
import { registerNewCmd } from "./new.command.ts";
import { registerTreeCmd } from "./tree.command.ts";
import { registerDocsCmd } from "./docs.command.ts";
import { makeTopLevelCommand, TopLevelCommand } from "../TopLevelCommand.ts";

export function registerFoundationCommand(program: Command) {
const foundationCommands = new Command();
export function registerFoundationCommand(program: TopLevelCommand) {
const foundationCommands = makeTopLevelCommand();
registerNewCmd(foundationCommands);
registerConfigCmd(foundationCommands);
registerTreeCmd(foundationCommands);
Expand All @@ -18,5 +18,5 @@ export function registerFoundationCommand(program: Command) {
.description(
"Create, list and deploy cloud foundations covering all your cloud platforms",
)
.action(foundationCommands.showHelp);
.action(() => foundationCommands.showHelp());
}
5 changes: 3 additions & 2 deletions src/commands/foundation/new.command.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as colors from "std/fmt/colors";
import { Command, prompt, Select } from "/deps.ts";
import { prompt, Select } from "/deps.ts";
import { Logger } from "../../cli/Logger.ts";
import {
Dir,
Expand All @@ -16,8 +16,9 @@ import { GcloudPlatformSetup } from "../../api/gcloud/GcloudPlatformSetup.ts";
import { PlatformSetup } from "../../api/PlatformSetup.ts";
import { MeshError } from "../../errors.ts";
import { CLI } from "../../info.ts";
import { TopLevelCommand } from "../TopLevelCommand.ts";

export function registerNewCmd(program: Command) {
export function registerNewCmd(program: TopLevelCommand) {
program
.command("new <foundation:foundation>")
.description("generate a new cloud foundation")
Expand Down
4 changes: 2 additions & 2 deletions src/commands/foundation/tree.command.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { jsonTree } from "x/json_tree";

import { Command } from "../../deps.ts";
import { Logger } from "../../cli/Logger.ts";
import { CollieRepository } from "../../model/CollieRepository.ts";
import { GlobalCommandOptions } from "../GlobalCommandOptions.ts";
Expand All @@ -12,8 +11,9 @@ import {
AnalyzeResults,
prepareAnalyzeCommand,
} from "../prepareAnalyzeCommand.ts";
import { TopLevelCommand } from "../TopLevelCommand.ts";

export function registerTreeCmd(program: Command) {
export function registerTreeCmd(program: TopLevelCommand) {
program
.command("tree")
.description("show the foundation tree with module dependencies")
Expand Down
4 changes: 2 additions & 2 deletions src/commands/init.command.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Command } from "../deps.ts";
import { Logger } from "../cli/Logger.ts";
import {
Dir,
Expand All @@ -8,8 +7,9 @@ import {
import { CollieRepository } from "../model/CollieRepository.ts";
import { GlobalCommandOptions } from "./GlobalCommandOptions.ts";
import { CliApiFacadeFactory } from "../api/CliApiFacadeFactory.ts";
import { TopLevelCommand } from "./TopLevelCommand.ts";

export function registerInitCommand(program: Command) {
export function registerInitCommand(program: TopLevelCommand) {
program
.command("init")
.description("initialize a new collie repository in the current directory")
Expand Down
11 changes: 8 additions & 3 deletions src/commands/interactive/interactive.command.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { exploreInteractive } from "./untagged-tenants.ts";
import { listTenantAction } from "../tenant/list.command.ts";
import { listTenantsCostAction } from "../tenant/cost.command.ts";
import { Command, Select } from "../../deps.ts";
import { Select } from "../../deps.ts";
import { OutputFormat } from "../../presentation/output-format.ts";
import { interactiveDate } from "./inputInteractiveDate.ts";
import { CLI } from "../../info.ts";
Expand All @@ -10,9 +10,10 @@ import { CollieRepository } from "../../model/CollieRepository.ts";
import { InteractivePrompts } from "./InteractivePrompts.ts";
import { prepareTenantCommand } from "../tenant/prepareTenantCommand.ts";
import { detailViewTenant } from "./detailViewTenant.ts";
import { TopLevelCommand } from "../TopLevelCommand.ts";
import { isWindows } from "../../os.ts";

export function registerInteractiveCommand(program: Command) {
export function registerInteractiveCommand(program: TopLevelCommand) {
program
.command("interactive")
.description(
Expand Down Expand Up @@ -47,7 +48,11 @@ export async function startInteractiveMode(options: GlobalCommandOptions) {
switch (action) {
case "alltenants": {
console.clear();
await listTenantAction({ ...options, refresh: false }, foundation);
await listTenantAction({
...options,
refresh: false,
output: OutputFormat.TABLE,
}, foundation);
break;
}
case "searchtenant": {
Expand Down
Loading