Skip to content

Commit

Permalink
chore: upgrade to deno 1.41, cliffy v1.0 rc3 and std lib to 0.216
Browse files Browse the repository at this point in the history
lots of smaller changes

closes #276
  • Loading branch information
JohannesRudolph committed Mar 25, 2024
1 parent 1a96134 commit ac43645
Show file tree
Hide file tree
Showing 51 changed files with 421 additions and 640 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3
- uses: denoland/setup-deno@main
with:
deno-version: "~1.37"
deno-version: "~1.41"
- uses: actions/cache@v3
with:
path: ~/.cache/deno # see https://deno.land/manual/linking_to_external_code
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
- uses: actions/checkout@v3
- uses: denoland/setup-deno@main
with:
deno-version: "~1.37"
deno-version: "~1.41"
- uses: actions/cache@v3
with:
path: ~/.cache/deno # see https://deno.land/manual/linking_to_external_code
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3
- uses: denoland/setup-deno@main
with:
deno-version: "~1.37"
deno-version: "~1.41"
- uses: actions/cache@v3
with:
path: ~/.cache/deno # see https://deno.land/manual/linking_to_external_code
Expand Down
3 changes: 2 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"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"
"install": "deno install -f -n collie $(deno run --quiet --no-check ./flags.ts) src/main.ts",
"update-lockfile": "deno cache --import-map src/import_map.json --lock-write ./src/main.ts"
}
}
867 changes: 316 additions & 551 deletions deno.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/api/CliApiFacadeFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class CliApiFacadeFactory {
let azure: AzCliFacade = new AzCli(facadeProcessRunner);

// We can only ask the user if we are in a tty terminal.
if (Deno.isatty(Deno.stdout.rid)) {
if (Deno.stdout.isTerminal()) {
azure = new AutoInstallAzModuleAzCliDecorator(azure);
}

Expand Down
12 changes: 12 additions & 0 deletions src/api/CliDetector.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as semver from "std/semver";

import { CliInstallationStatusError } from "../errors.ts";
import { IProcessRunner } from "../process/IProcessRunner.ts";
import { ProcessResultWithOutput } from "../process/ProcessRunnerResult.ts";
Expand Down Expand Up @@ -72,4 +74,14 @@ export abstract class CliDetector {

protected abstract parseVersion(versionCmdOutput: string): string;
protected abstract isSupportedVersion(version: string): boolean;

protected static testSemverSatisfiesRange(
version: string,
range: string,
): boolean {
const sversion = semver.parse(version);
const srange = semver.parseRange(range);

return semver.testRange(sversion, srange);
}
}
2 changes: 1 addition & 1 deletion src/api/aws/AwsCliDetector.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "std/testing/assert";
import { assertEquals } from "std/assert";
import { StubProcessRunner } from "../../process/StubProcessRunner.ts";
import { InstallationStatus } from "../CliInstallationStatus.ts";
import { AwsCliDetector } from "./AwsCliDetector.ts";
Expand Down
3 changes: 1 addition & 2 deletions src/api/aws/AwsCliDetector.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { IProcessRunner } from "../../process/IProcessRunner.ts";
import { ProcessResultWithOutput } from "../../process/ProcessRunnerResult.ts";
import { CliDetector } from "../CliDetector.ts";
import * as semver from "std/semver";

export class AwsCliDetector extends CliDetector {
constructor(runner: IProcessRunner<ProcessResultWithOutput>) {
Expand All @@ -17,6 +16,6 @@ export class AwsCliDetector extends CliDetector {
}

protected isSupportedVersion(version: string): boolean {
return semver.satisfies(version, ">=2.0.0");
return CliDetector.testSemverSatisfiesRange(version, ">=2.0.0");
}
}
2 changes: 1 addition & 1 deletion src/api/aws/AwsMeshAdapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { moment } from "x/deno_moment";
import { MeshPlatform, MeshTenantCost } from "/mesh/MeshTenantModel.ts";
import { AwsCliFacade } from "./AwsCliFacade.ts";
import { AwsMeshAdapter } from "./AwsMeshAdapter.ts";
import { assertEquals } from "std/testing/assert";
import { assertEquals } from "std/assert";
import { MeshTenantChangeDetector } from "/mesh/MeshTenantChangeDetector.ts";
import { StubProcessRunner } from "../../process/StubProcessRunner.ts";

Expand Down
2 changes: 1 addition & 1 deletion src/api/az/AzCliDetector.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "std/testing/assert";
import { assertEquals } from "std/assert";
import { StubProcessRunner } from "../../process/StubProcessRunner.ts";
import { InstallationStatus } from "../CliInstallationStatus.ts";
import { AzCliDetector } from "./AzCliDetector.ts";
Expand Down
3 changes: 1 addition & 2 deletions src/api/az/AzCliDetector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { parseJsonWithLog } from "../../json.ts";
import { IProcessRunner } from "../../process/IProcessRunner.ts";
import { ProcessResultWithOutput } from "../../process/ProcessRunnerResult.ts";
import { CliDetector } from "../CliDetector.ts";
import * as semver from "std/semver";

export class AzCliDetector extends CliDetector {
constructor(runner: IProcessRunner<ProcessResultWithOutput>) {
Expand All @@ -21,6 +20,6 @@ export class AzCliDetector extends CliDetector {
}

protected isSupportedVersion(version: string): boolean {
return semver.satisfies(version, ">2.0.0");
return CliDetector.testSemverSatisfiesRange(version, ">2.0.0");
}
}
2 changes: 1 addition & 1 deletion src/api/az/AzCliResultHandler.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals, assertRejects } from "std/testing/assert";
import { assertEquals, assertRejects } from "std/assert";

import { ProcessResultWithOutput } from "../../process/ProcessRunnerResult.ts";
import { AzCliResultHandler } from "./AzCliResultHandler.ts";
Expand Down
2 changes: 1 addition & 1 deletion src/api/az/AzMeshAdapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AzCliFacade } from "./AzCliFacade.ts";
import { AzMeshAdapter } from "./AzMeshAdapter.ts";
import { RoleAssignment, Subscription } from "./Model.ts";
import { MeshPlatform, MeshTenant } from "/mesh/MeshTenantModel.ts";
import { assertEquals } from "std/testing/assert";
import { assertEquals } from "std/assert";
import {
MeshPrincipalType,
MeshRoleAssignmentSource,
Expand Down
4 changes: 3 additions & 1 deletion src/api/az/AzPlatformSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class AzPlatformSetup extends PlatformSetup<PlatformConfigAzure> {

const subscriptions = await this.az.listSubscriptions();

const subscriptionId = await Select.prompt({
const subscriptionResult = await Select.prompt({
message:
"Select an account to configure AAD Tenant Id and default Subscription id",
options: subscriptions.map((x) => ({
Expand All @@ -32,6 +32,8 @@ export class AzPlatformSetup extends PlatformSetup<PlatformConfigAzure> {
info: true,
});

const subscriptionId = subscriptionResult.value;

const subscription = subscriptions.find((x) => x.id === subscriptionId);
if (!subscription) {
throw new MeshError(
Expand Down
2 changes: 1 addition & 1 deletion src/api/gcloud/GcloudCliDetector.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "std/testing/assert";
import { assertEquals } from "std/assert";
import { StubProcessRunner } from "../../process/StubProcessRunner.ts";
import { InstallationStatus } from "../CliInstallationStatus.ts";
import { GcloudCliDetector } from "./GcloudCliDetector.ts";
Expand Down
3 changes: 1 addition & 2 deletions src/api/gcloud/GcloudCliDetector.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { IProcessRunner } from "../../process/IProcessRunner.ts";
import { ProcessResultWithOutput } from "../../process/ProcessRunnerResult.ts";
import { CliDetector } from "../CliDetector.ts";
import * as semver from "std/semver";

export class GcloudCliDetector extends CliDetector {
constructor(runner: IProcessRunner<ProcessResultWithOutput>) {
Expand All @@ -17,6 +16,6 @@ export class GcloudCliDetector extends CliDetector {
}

protected isSupportedVersion(version: string): boolean {
return semver.satisfies(version, ">200.0.0");
return CliDetector.testSemverSatisfiesRange(version, ">200.0.0");
}
}
8 changes: 5 additions & 3 deletions src/api/gcloud/GcloudPlatformSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export class GcloudPlatformSetup extends PlatformSetup<PlatformConfigGcp> {
info: true,
});

const configuration = configurations.find(
(x) => x.name === configurationName,
const configuration = configurations.find((x) =>
x.name === configurationName
);

if (!configuration) {
Expand All @@ -41,7 +41,7 @@ export class GcloudPlatformSetup extends PlatformSetup<PlatformConfigGcp> {
this.progress("detecting available GCP organizations");
const organizations = await this.gcloud.listOrganizations();

const organizationName = await Select.prompt({
const organizationResult = await Select.prompt({
message: "Select a GCP organization",
options: organizations.map((x) => ({
name: x.displayName,
Expand All @@ -51,6 +51,8 @@ export class GcloudPlatformSetup extends PlatformSetup<PlatformConfigGcp> {
info: true,
});

const organizationName = organizationResult.value;

const organization = organizations.find((x) => x.name === organizationName);
if (!organization) {
throw new MeshError(
Expand Down
2 changes: 1 addition & 1 deletion src/api/git/GitCliDetector.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GitCliDetector } from "./GitCliDetector.ts";
import { StubProcessRunner } from "../../process/StubProcessRunner.ts";
import { assertEquals } from "std/testing/assert";
import { assertEquals } from "std/assert";

Deno.test(
"can parse version numbers",
Expand Down
3 changes: 1 addition & 2 deletions src/api/git/GitCliDetector.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { IProcessRunner } from "../../process/IProcessRunner.ts";
import { ProcessResultWithOutput } from "../../process/ProcessRunnerResult.ts";
import { CliDetector } from "../CliDetector.ts";
import * as semver from "std/semver";

export class GitCliDetector extends CliDetector {
constructor(runner: IProcessRunner<ProcessResultWithOutput>) {
Expand All @@ -19,6 +18,6 @@ export class GitCliDetector extends CliDetector {

protected isSupportedVersion(version: string): boolean {
// a simple lexicographic comparison is sufficient for our needs
return semver.satisfies(version, ">=2.0.0");
return CliDetector.testSemverSatisfiesRange(version, ">=2.0.0");
}
}
2 changes: 1 addition & 1 deletion src/api/npm/NpmCliDetector.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "std/testing/assert";
import { assertEquals } from "std/assert";
import { StubProcessRunner } from "../../process/StubProcessRunner.ts";
import { InstallationStatus } from "../CliInstallationStatus.ts";
import { NpmCliDetector } from "./NpmCliDetector.ts";
Expand Down
3 changes: 1 addition & 2 deletions src/api/npm/NpmCliDetector.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { IProcessRunner } from "../../process/IProcessRunner.ts";
import { ProcessResultWithOutput } from "../../process/ProcessRunnerResult.ts";
import { CliDetector } from "../CliDetector.ts";
import * as semver from "std/semver";

export class NpmCliDetector extends CliDetector {
constructor(runner: IProcessRunner<ProcessResultWithOutput>) {
Expand All @@ -13,6 +12,6 @@ export class NpmCliDetector extends CliDetector {
}

protected isSupportedVersion(version: string): boolean {
return semver.satisfies(version, ">=8.0.0");
return CliDetector.testSemverSatisfiesRange(version, ">=8.0.0");
}
}
3 changes: 1 addition & 2 deletions src/api/terraform-docs/TerraformDocsCliDetector.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { IProcessRunner } from "../../process/IProcessRunner.ts";
import { ProcessResultWithOutput } from "../../process/ProcessRunnerResult.ts";
import { CliDetector } from "../CliDetector.ts";
import * as semver from "std/semver";

export class TerraformDocsCliDetector extends CliDetector {
constructor(runner: IProcessRunner<ProcessResultWithOutput>) {
Expand All @@ -13,6 +12,6 @@ export class TerraformDocsCliDetector extends CliDetector {
}

protected isSupportedVersion(version: string): boolean {
return semver.satisfies(version, ">=0.10.0");
return CliDetector.testSemverSatisfiesRange(version, ">=0.10.0");
}
}
3 changes: 1 addition & 2 deletions src/api/terraform/TerraformCliDetector.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { IProcessRunner } from "../../process/IProcessRunner.ts";
import { ProcessResultWithOutput } from "../../process/ProcessRunnerResult.ts";
import { CliDetector } from "../CliDetector.ts";
import * as semver from "std/semver";

export class TerraformCliDetector extends CliDetector {
constructor(runner: IProcessRunner<ProcessResultWithOutput>) {
Expand All @@ -13,6 +12,6 @@ export class TerraformCliDetector extends CliDetector {
}

protected isSupportedVersion(version: string): boolean {
return semver.satisfies(version, ">=1.0.0");
return CliDetector.testSemverSatisfiesRange(version, ">=1.0.0");
}
}
3 changes: 1 addition & 2 deletions src/api/terragrunt/TerragruntCliDetector.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { IProcessRunner } from "../../process/IProcessRunner.ts";
import { ProcessResultWithOutput } from "../../process/ProcessRunnerResult.ts";
import { CliDetector } from "../CliDetector.ts";
import * as semver from "std/semver";

export class TerragruntCliDetector extends CliDetector {
constructor(runner: IProcessRunner<ProcessResultWithOutput>) {
Expand All @@ -16,6 +15,6 @@ export class TerragruntCliDetector extends CliDetector {

protected isSupportedVersion(version: string): boolean {
// required for "--terragrunt-no-auto-apply" option, see https://github.com/gruntwork-io/terragrunt/pull/2156
return semver.satisfies(version, ">=0.38.1");
return CliDetector.testSemverSatisfiesRange(version, ">=0.38.1");
}
}
2 changes: 1 addition & 1 deletion src/cli/DirectoryGenerator.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from "std/path";
import { assertEquals } from "std/testing/assert";
import { assertEquals } from "std/assert";
import { Dir, DirectoryGenerator, WriteMode } from "./DirectoryGenerator.ts";
import { Logger } from "./Logger.ts";
import { withRestoreCwd, withTempDir } from "./test-util.ts";
Expand Down
15 changes: 11 additions & 4 deletions src/cli/InteractivePrompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export class InteractivePrompts {
`To set a default foundation run`,
`config set-foundation <foundation>"`,
);
return await Select.prompt({

const result = await Select.prompt({
message: "Select a foundation",
options: (
await kit.listFoundations()
Expand All @@ -21,29 +22,35 @@ export class InteractivePrompts {
value: x,
})),
});

return result.value;
}

static async selectPlatform(repo: FoundationRepository): Promise<string> {
return await Select.prompt({
const result = await Select.prompt({
message: "Select a platform",
options: (await repo.platforms).map((x) => ({ name: x.id, value: x.id })),
});

return result.value;
}

static async selectModule(
moduleRepo: KitModuleRepository,
fromWhereDescription = "your repository",
) {
): Promise<string> {
const options = moduleRepo.all.map((x) => ({
value: x.id,
name: `${x.kitModule.name} ${colors.dim(x.id)}`,
}));

return await Select.prompt({
const result = await Select.prompt({
message: "Select a kit module from " + fromWhereDescription,
options,
info: true,
search: !isWindows, // see https://github.com/c4spar/deno-cliffy/issues/272#issuecomment-1262197264
});

return result.value;
}
}
2 changes: 1 addition & 1 deletion src/cli/validation.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { validateIsPrefixedId } from "./validation.ts";
import { assertEquals } from "std/testing/assert";
import { assertEquals } from "std/assert";

Deno.test("non-prefixed ids fail", () => {
const result = validateIsPrefixedId("abc");
Expand Down
2 changes: 1 addition & 1 deletion src/commands/LiteralArgsParser.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "std/testing/assert";
import { assertEquals } from "std/assert";
import { LiteralArgsParser } from "./LiteralArgsParser.ts";

Deno.test("ignores all positional args", () => {
Expand Down
4 changes: 3 additions & 1 deletion src/commands/compliance/import.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ async function promptForComplianceFrameworkId(hubRepoDir: string) {
}
}

return await Select.prompt({
const result = await Select.prompt({
message: "Select available collie hub compliance control framework",
options: dirs.map((x) => ({ name: x, value: x })),
});

return result.value;
}
2 changes: 1 addition & 1 deletion src/commands/foundation/PlatformModuleType.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "std/testing/assert";
import { assertEquals } from "std/assert";
import { PlatformModuleType } from "./PlatformModuleType.ts";
import * as path from "std/path";

Expand Down
2 changes: 1 addition & 1 deletion src/commands/foundation/PlatformModuleType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class PlatformModuleType extends StringType {
}

static parseModuleId(matchedPath: string) {
const components = matchedPath.split(path.SEP);
const components = matchedPath.split(path.SEPARATOR);
const platformIndex = components.lastIndexOf("platforms");

const dropTerragruntHclComponent = -1;
Expand Down
Loading

0 comments on commit ac43645

Please sign in to comment.