Skip to content

Commit

Permalink
Bulk run prettier on codebase (#643)
Browse files Browse the repository at this point in the history
* Mass format

* Ignore commit in git blame
  • Loading branch information
thdxr committed Aug 4, 2021
1 parent dccc67e commit 1ca2fda
Show file tree
Hide file tree
Showing 49 changed files with 550 additions and 389 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Prettier bulk format
1a2f103016036a9fc99c37f252abc765c2256964
31 changes: 15 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ name: CI

on:
push:
branches: [ master, alpha ]
branches: [master, alpha]
paths-ignore:
- 'www/**'
- 'examples/**'
- "www/**"
- "examples/**"
pull_request:
branches: [ master ]
branches: [master]

jobs:
build:

strategy:
matrix:
os: [ubuntu-latest, windows-latest]
Expand All @@ -23,14 +22,14 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: yarn --frozen-lockfile
- name: Lint
run: yarn run lint
- name: Test
run: yarn run test
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: yarn --frozen-lockfile
- name: Lint
run: yarn run lint
- name: Test
run: yarn run test
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ To cut a release, start by merging the PRs that are going into this release.
```
Pick the version you want (patch/minor/major). This is based on the type of changes in the changelog above.
- `breaking` and major `enhancement` changes are a minor version update
- `bug` and minor `enhancement` changes are a patch version update
Expand All @@ -122,7 +122,7 @@ To cut a release, start by merging the PRs that are going into this release.
Copy the changelog that was generated above and [draft a new release](https://github.com/serverless-stack/serverless-stack/releases/new).
Make necessary edits to the changelog to make it more readable and helpful.
- For `breaking` changes, add a message at the top clearly documenting the change ([example](https://github.com/serverless-stack/serverless-stack/releases/tag/v0.26.0)).
- For major `enhancement` changes, add a code snippet on how to use the feature ([example](https://github.com/serverless-stack/serverless-stack/releases/tag/v0.36.0)).
Expand All @@ -138,7 +138,7 @@ To cut a release, start by merging the PRs that are going into this release.
```
````

5. Publish GitHub release
4. Publish GitHub release

In the **Tag version** of the release draft, select the version that was just published to npm.

Expand Down
4 changes: 1 addition & 3 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"packages": [
"packages/*"
],
"packages": ["packages/*"],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "0.37.0"
Expand Down
8 changes: 6 additions & 2 deletions packages/cli/assets/cdk-wrapper/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ loadDotenv(config.stage);

// Check first and throw an error
if (!fs.existsSync(path.join(__dirname, "lib", "index.js"))) {
console.error(`\nCannot find app handler. There was a problem transpiling the source.\n`);
console.error(
`\nCannot find app handler. There was a problem transpiling the source.\n`
);
process.exit(1);
}

Expand Down Expand Up @@ -79,7 +81,9 @@ const app = new sst.App({
// Run the handler
const handler = require("./lib");
if (!handler.default) {
console.error(`\nCannot find app handler. Make sure "${config.main}" has a default export.\n`);
console.error(
`\nCannot find app handler. Make sure "${config.main}" has a default export.\n`
);
process.exit(1);
}
handler.default(app);
Expand Down
13 changes: 11 additions & 2 deletions packages/cli/scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,11 @@ async function getHandlerFilePath(appPath, srcPath, handler) {
// Check entry path exists
let entryPath;
const entryPathExists = [".ts", ".tsx", ".js", ".jsx"].some((ext) => {
entryPath = path.join(appPath, srcPath, addExtensionToHandler(handler, ext));
entryPath = path.join(
appPath,
srcPath,
addExtensionToHandler(handler, ext)
);
return fs.existsSync(entryPath);
});

Expand Down Expand Up @@ -1112,7 +1116,12 @@ async function onClientMessage(message) {
eventSource === null ? " invoked" : ` invoked by ${eventSource}`;
clientLogger.info(
chalk.grey(
`${context.awsRequestId} REQUEST ${env.AWS_LAMBDA_FUNCTION_NAME} [${getHandlerFullPosixPath(debugSrcPath, debugSrcHandler)}]${eventSourceDesc}`
`${context.awsRequestId} REQUEST ${
env.AWS_LAMBDA_FUNCTION_NAME
} [${getHandlerFullPosixPath(
debugSrcPath,
debugSrcHandler
)}]${eventSourceDesc}`
)
);
clientLogger.debug("Lambda event", JSON.stringify(event));
Expand Down
21 changes: 13 additions & 8 deletions packages/cli/scripts/util/cdkHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,10 @@ function runCdkVersionMatch(packageJson, cliInfo) {
async function loadEsbuildConfigOverrides(configPath) {
// load config
const configFullPath = path.join(paths.appPath, configPath);
if (!await checkFileExists(configFullPath)) {
throw new Error(`Cannot find the esbuild config file at "${configFullPath}"`);
if (!(await checkFileExists(configFullPath))) {
throw new Error(
`Cannot find the esbuild config file at "${configFullPath}"`
);
}
const configOverrides = require(configFullPath);

Expand Down Expand Up @@ -276,7 +278,7 @@ async function transpile(cliInfo, config) {
target: [getEsbuildTarget()],
tsconfig: isTs ? tsconfig : undefined,
color: process.env.NO_COLOR !== "true",
...esbuildConfigOverrides
...esbuildConfigOverrides,
};

try {
Expand Down Expand Up @@ -501,7 +503,7 @@ async function printDeployResults(stackStates) {
paths.appBuildDir,
"static-site-environment-output-keys.json"
);
const environmentData = await checkFileExists(environmentDataPath)
const environmentData = (await checkFileExists(environmentDataPath))
? await fs.readJson(environmentDataPath)
: [];

Expand All @@ -521,10 +523,13 @@ async function printDeployResults(stackStates) {
Object.keys(outputs)
// Do not show React environment outputs under Outputs b/c the output
// name looks long and ugly. We will show them under a separate section.
.filter(outputName =>
!environmentData.find(({ stack, environmentOutputs }) =>
stack === name && Object.values(environmentOutputs).includes(outputName)
)
.filter(
(outputName) =>
!environmentData.find(
({ stack, environmentOutputs }) =>
stack === name &&
Object.values(environmentOutputs).includes(outputName)
)
)
.sort(array.getCaseInsensitiveStringSorter())
.forEach((name) => logger.info(` ${name}: ${outputs[name]}`));
Expand Down
6 changes: 1 addition & 5 deletions packages/cli/test/base-tsx/lambda.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export async function handler(): string {
return (
<>
name: {"Hello World"}
</>
);
return <>name: {"Hello World"}</>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@ afterAll(async () => {
test("config-esbuildconfig-invalid", async () => {
const result = await runBuildCommand(__dirname);

expect(result).toMatch(
/Bad esbuild configuration/
);
expect(result).toMatch(/Bad esbuild configuration/);
});
Original file line number Diff line number Diff line change
@@ -1 +1 @@
throw new Error("Bad esbuild configuration");
throw new Error("Bad esbuild configuration");
8 changes: 4 additions & 4 deletions packages/cli/test/config-esbuildconfig-invalid/sst.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "config-esbuildconfig-invalid",
"stage": "prod",
"region": "us-west-2",
"esbuildConfig": "esbuild-config.js"
"name": "config-esbuildconfig-invalid",
"stage": "prod",
"region": "us-west-2",
"esbuildConfig": "esbuild-config.js"
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,5 @@ test("config-esbuildconfig-non-plugins", async () => {
const result = await runBuildCommand(__dirname);

expect(result).toContain("Esbuild config loaded");
expect(result).toMatch(
/Cannot configure the "dummy" option/
);
expect(result).toMatch(/Cannot configure the "dummy" option/);
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
console.log("Esbuild config loaded");
module.exports = {
dummy: true
dummy: true,
};
8 changes: 4 additions & 4 deletions packages/cli/test/config-esbuildconfig-non-plugins/sst.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "config-esbuildconfig-non-plugins",
"stage": "prod",
"region": "us-west-2",
"esbuildConfig": "esbuild-config.js"
"name": "config-esbuildconfig-non-plugins",
"stage": "prod",
"region": "us-west-2",
"esbuildConfig": "esbuild-config.js"
}
8 changes: 4 additions & 4 deletions packages/cli/test/config-esbuildconfig-not-found/sst.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "config-esbuildconfig-not-found",
"stage": "prod",
"region": "us-west-2",
"esbuildConfig": "file-that-does-not-exist"
"name": "config-esbuildconfig-not-found",
"stage": "prod",
"region": "us-west-2",
"esbuildConfig": "file-that-does-not-exist"
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
console.log("Esbuild config loaded");
module.exports = {};
module.exports = {};
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ class MySampleStack extends sst.Stack {

export default function main(app: sst.App): void {
new MySampleStack(app, "sample");
}
}
6 changes: 3 additions & 3 deletions packages/cli/test/config-esbuildconfig-not-set/sst.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "config-esbuildconfig-not-set",
"stage": "prod",
"region": "us-west-2"
"name": "config-esbuildconfig-not-set",
"stage": "prod",
"region": "us-west-2"
}
2 changes: 1 addition & 1 deletion packages/cli/test/config-esbuildconfig/esbuild-config.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
console.log("Esbuild config loaded");
module.exports = {};
module.exports = {};
2 changes: 1 addition & 1 deletion packages/cli/test/config-esbuildconfig/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ class MySampleStack extends sst.Stack {

export default function main(app: sst.App): void {
new MySampleStack(app, "sample");
}
}
8 changes: 4 additions & 4 deletions packages/cli/test/config-esbuildconfig/sst.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "config-esbuildconfig",
"stage": "prod",
"region": "us-west-2",
"esbuildConfig": "esbuild-config.js"
"name": "config-esbuildconfig",
"stage": "prod",
"region": "us-west-2",
"esbuildConfig": "esbuild-config.js"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ module.exports = {
tsconfigPath: path.resolve(__dirname, "tsconfig.json"),
force: true,
}),
]
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class MySampleStack extends sst.Stack {
new sst.Function(this, "MyFunction", {
handler: "lambda.main",
bundle: {
esbuildConfig: "esbuild-config.js"
}
esbuildConfig: "esbuild-config.js",
},
});
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/cli/test/playground/lib/api-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class MainStack extends sst.Stack {
},
routes: {
"GET /": "src/lambda.main",
"$default": "src/lambda.main",
$default: "src/lambda.main",
},
});

Expand Down
6 changes: 5 additions & 1 deletion packages/cli/test/playground/lib/eventbus-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ export class MainStack extends sst.Stack {

const iBusArn = "arn:aws:events:us-east-1:112245769880:event-bus/default";
const bus = new sst.EventBus(this, "EventBus", {
eventBridgeEventBus: events.EventBus.fromEventBusArn(this, "IBus", iBusArn),
eventBridgeEventBus: events.EventBus.fromEventBusArn(
this,
"IBus",
iBusArn
),
defaultFunctionProps: {
timeout: 10,
},
Expand Down
18 changes: 7 additions & 11 deletions packages/cli/test/playground/src/lambdatsx.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import React from 'react';
import ReactDOMServer from 'react-dom/server';
import React from "react";
import ReactDOMServer from "react-dom/server";

function User(props: Event) {
return (
<>
name: {props.name}
</>
)
return <>name: {props.name}</>;
}
export async function handler(event: Event){
const { name } = event;
export async function handler(event: Event) {
const { name } = event;
const text = ReactDOMServer.renderToStaticMarkup(<User name={name} />);

return {
text
}
text,
};
}
Loading

0 comments on commit 1ca2fda

Please sign in to comment.