Skip to content

Commit

Permalink
Merge pull request #818 from hashicorp/lint-tsx-files
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielMSchmidt authored Jul 9, 2021
2 parents f587656 + 1def04c commit 354e103
Show file tree
Hide file tree
Showing 14 changed files with 213 additions and 172 deletions.
14 changes: 7 additions & 7 deletions BUGPROCESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ New issues are labeled with `new`. Bugs and feature requests filed by other engi

## [Bugs](https://github.com/hashicorp/terraform-cdk/issues?q=is%3Aissue+is%3Aopen+label%3Abug+label%3Anew)

* Try to reproduce bugs. If they can readily be reproduced, label them `confirmed`. If they can't, ask for information and label them `needs-reproduction` and `waiting-on-answer`.
* For bugs that seem serious and urgent, label them `priority/important-soon` or `priority/critical-urgent` if a key workflow is completely broken. Pull them into the current or next release. Self-assign if you plan to do them, or drop a comment in the team slack channel to coordinate who
* If it's not really a bug, try to explain to the user what to do, consider filing a documentation issue, and close the issue.
* Remove the `new` label
- Try to reproduce bugs. If they can readily be reproduced, label them `confirmed`. If they can't, ask for information and label them `needs-reproduction` and `waiting-on-answer`.
- For bugs that seem serious and urgent, label them `priority/important-soon` or `priority/critical-urgent` if a key workflow is completely broken. Pull them into the current or next release. Self-assign if you plan to do them, or drop a comment in the team slack channel to coordinate who
- If it's not really a bug, try to explain to the user what to do, consider filing a documentation issue, and close the issue.
- Remove the `new` label

## [Enhancement requests](https://github.com/hashicorp/terraform-cdk/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement+label%3Anew+)

* Categorize issues, e.g. `documentation`
* Read and try to understand the request. If it's unclear what the user wants, or why, ask for clarification.
* Remove the `new` label, and try to (subjectively) prioritize using the `priority/` labels. If it's not obvious, label it `needs-priority`.
- Categorize issues, e.g. `documentation`
- Read and try to understand the request. If it's unclear what the user wants, or why, ask for clarification.
- Remove the `new` label, and try to (subjectively) prioritize using the `priority/` labels. If it's not obvious, label it `needs-priority`.

If an issue requires discussion with the user to get it out of this initial state, leave "new" on there and label it `waiting-on-answer` until this phase of triage is done.
2 changes: 1 addition & 1 deletion examples/typescript/google/cdktf.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"language": "typescript",
"app": "npm run --silent compile && node main.js",
"terraformProviders": [
"google@~> 3.0"
"google@~> 3.74.0"
]
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"examples:integration:java": "test/run-against-dist tools/build-examples-sequential.sh java",
"examples:integration:csharp": "test/run-against-dist tools/build-examples.sh csharp",
"examples:integration:python": "test/run-against-dist tools/build-examples.sh python",
"examples:integration:typescript": "test/run-against-dist tools/build-examples.sh typescript",
"examples:integration:typescript": "test/run-against-dist tools/build-examples-sequential.sh typescript",
"examples:integration:go": "test/run-against-dist tools/build-examples-sequential.sh go",
"pretest": "prettier --check .",
"test": "lerna run --scope cdktf* --scope @cdktf* test",
Expand Down Expand Up @@ -69,6 +69,6 @@
"prettier": "^2.3.1"
},
"lint-staged": {
"*.{ts,js,css,md}": "prettier --write"
"*.{ts,tsx,js,css,md}": "prettier --write"
}
}
18 changes: 12 additions & 6 deletions packages/cdktf-cli/bin/cmds/ui/app.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
/* eslint-disable no-control-regex */
import React from "react";
import React, { ReactNode } from "react";
import { TerraformProvider } from "./terraform-context";
import { useTerraformState } from "./terraform-context";
import { useApp } from "ink";

export const TerraformErrors: React.FunctionComponent<{}> = ({
interface TerraformErrorProps {
children: ReactNode;
}

export const TerraformErrors: React.FunctionComponent<TerraformErrorProps> = ({
children,
}): React.ReactElement => {
}: TerraformErrorProps): React.ReactElement => {
const { errors } = useTerraformState();
const { exit } = useApp();

Expand All @@ -19,10 +23,12 @@ export const TerraformErrors: React.FunctionComponent<{}> = ({
return <>{children}</>;
};

// eslint-disable-next-line react/prop-types
export const App: React.FunctionComponent<{}> = ({
interface AppProps {
children?: ReactNode;
}
export const App: React.FunctionComponent<AppProps> = ({
children,
}): React.ReactElement => {
}: AppProps): React.ReactElement => {
return (
<TerraformProvider>
<TerraformErrors>{children}</TerraformErrors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface ResourceNameConfig {
export const ResourceName = ({ name, stackName }: ResourceNameConfig) => {
const prettyName = name.replace(/(_[A-F\d]{8})$/, "");

// eslint-disable-next-line prefer-const
let [resource, resourceName] = prettyName.split(".");
if (stackName != null && resourceName.startsWith(stackName)) {
const [, ...path] = resourceName.split("_");
Expand Down
13 changes: 6 additions & 7 deletions packages/cdktf-cli/bin/cmds/ui/deploy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
TerraformOutput,
PlannedResourceAction,
} from "./models/terraform";
import { useTerraform, Status, useTerraformState } from "./terraform-context";
import { Status, useTerraformState, useRunDeploy } from "./terraform-context";
import { Plan } from "./diff";

interface DeploySummaryConfig {
Expand Down Expand Up @@ -182,17 +182,16 @@ export const Deploy = ({
synthCommand,
autoApprove,
}: DeployConfig): React.ReactElement => {
const { deploy } = useTerraform({
const {
state: { status, currentStack, errors, plan },
confirmation,
isConfirmed,
} = useRunDeploy({
targetDir,
targetStack,
synthCommand,
autoApprove,
});
const {
state: { status, currentStack, errors, plan },
confirmation,
isConfirmed,
} = deploy();

const planStages = [
Status.INITIALIZING,
Expand Down
13 changes: 6 additions & 7 deletions packages/cdktf-cli/bin/cmds/ui/destroy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Spinner from "ink-spinner";
import ConfirmInput from "@skorfmann/ink-confirm-input";
import { DeployingElement } from "./components";
import { DeployingResource, PlannedResourceAction } from "./models/terraform";
import { useTerraform, Status, useTerraformState } from "./terraform-context";
import { Status, useTerraformState, useRunDestroy } from "./terraform-context";
import { Plan } from "./diff";

interface DeploySummaryConfig {
Expand Down Expand Up @@ -127,17 +127,16 @@ export const Destroy = ({
synthCommand,
autoApprove,
}: DestroyConfig): React.ReactElement => {
const { destroy } = useTerraform({
const {
state: { status, currentStack, errors, plan },
confirmation,
isConfirmed,
} = useRunDestroy({
targetDir,
targetStack,
synthCommand,
autoApprove,
});
const {
state: { status, currentStack, errors, plan },
confirmation,
isConfirmed,
} = destroy();

const planStages = [
Status.INITIALIZING,
Expand Down
6 changes: 2 additions & 4 deletions packages/cdktf-cli/bin/cmds/ui/diff.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Text, Box, Static } from "ink";
import Spinner from "ink-spinner";
import { PlannedResource } from "./models/terraform";
import { PlanElement } from "./components";
import { useTerraform, Status, useTerraformState } from "./terraform-context";
import { Status, useTerraformState, useRunDiff } from "./terraform-context";

interface DiffConfig {
targetDir: string;
Expand Down Expand Up @@ -95,15 +95,13 @@ export const Diff = ({
targetStack,
synthCommand,
}: DiffConfig): React.ReactElement => {
const { plan } = useTerraform({
const { status, currentStack, errors } = useRunDiff({
targetDir,
targetStack,
synthCommand,
isSpeculative: true,
});

const { status, currentStack, errors } = plan();

const isPlanning: boolean = status != Status.PLANNED;
const statusText =
currentStack.name === "" ? (
Expand Down
3 changes: 2 additions & 1 deletion packages/cdktf-cli/bin/cmds/ui/get.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export const Get = ({
}
};
get();
}, []); // only once
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []); // only once, we don't expect props to change

const isGenerating: boolean = currentStatus != Status.DONE;
const statusText = `${currentStatus}...`;
Expand Down
5 changes: 2 additions & 3 deletions packages/cdktf-cli/bin/cmds/ui/list.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Fragment } from "react";
import { Text, Box } from "ink";
import Spinner from "ink-spinner";
import { useTerraform, Status } from "./terraform-context";
import { useRunSynth, Status } from "./terraform-context";

interface ListConfig {
targetDir: string;
Expand All @@ -12,8 +12,7 @@ export const List = ({
targetDir,
synthCommand,
}: ListConfig): React.ReactElement => {
const { synth } = useTerraform({ targetDir, synthCommand });
const { status, errors, stacks } = synth();
const { status, errors, stacks } = useRunSynth({ targetDir, synthCommand });

const isSynthesizing: boolean = status != Status.SYNTHESIZED;
const statusText = `${status}...`;
Expand Down
9 changes: 6 additions & 3 deletions packages/cdktf-cli/bin/cmds/ui/synth.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Fragment } from "react";
import { Text, Box } from "ink";
import Spinner from "ink-spinner";
import { useTerraform, Status, useTerraformState } from "./terraform-context";
import { useRunSynth, Status, useTerraformState } from "./terraform-context";

interface CommonSynthConfig {
targetDir: string;
Expand Down Expand Up @@ -42,8 +42,11 @@ export const Synth = ({
synthCommand,
jsonOutput,
}: SynthConfig): React.ReactElement => {
const { synth } = useTerraform({ targetDir, targetStack, synthCommand });
const { status, currentStack, errors } = synth();
const { status, currentStack, errors } = useRunSynth({
targetDir,
targetStack,
synthCommand,
});

const isSynthesizing: boolean = status != Status.SYNTHESIZED;
const statusText =
Expand Down
Loading

0 comments on commit 354e103

Please sign in to comment.