Skip to content

Commit a502b4b

Browse files
authored
chore: bump lines to 100, standardize linting (#301)
1 parent 88aa99f commit a502b4b

File tree

8 files changed

+30
-76
lines changed

8 files changed

+30
-76
lines changed

.eslintrc.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
*/
1616

1717
module.exports = {
18-
root: true,
19-
parser: '@typescript-eslint/parser',
20-
plugins: ['@typescript-eslint'],
21-
extends: [
22-
'eslint:recommended',
23-
'plugin:@typescript-eslint/eslint-recommended',
24-
'plugin:@typescript-eslint/recommended',
25-
'plugin:prettier/recommended',
26-
],
27-
};
18+
root: true,
19+
parser: '@typescript-eslint/parser',
20+
plugins: ['@typescript-eslint'],
21+
extends: [
22+
'eslint:recommended',
23+
'plugin:@typescript-eslint/eslint-recommended',
24+
'plugin:@typescript-eslint/recommended',
25+
'plugin:prettier/recommended',
26+
],
27+
};

.prettierrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = {
1919
bracketSpacing: true,
2020
endOfLine: 'auto',
2121
jsxSingleQuote: true,
22-
printWidth: 80,
22+
printWidth: 100,
2323
quoteProps: 'consistent',
2424
semi: true,
2525
singleQuote: true,

src/client.ts

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,8 @@ import fs from 'fs';
2020
import * as path from 'path';
2121
import { tmpdir } from 'os';
2222

23-
import {
24-
CredentialBody,
25-
ExternalAccountClientOptions,
26-
GoogleAuth,
27-
} from 'google-auth-library';
28-
import {
29-
errorMessage,
30-
request,
31-
removeFile,
32-
} from '@google-github-actions/actions-utils';
23+
import { CredentialBody, ExternalAccountClientOptions, GoogleAuth } from 'google-auth-library';
24+
import { errorMessage, request, removeFile } from '@google-github-actions/actions-utils';
3325

3426
import { zipDir, ZipOptions } from './util';
3527

@@ -321,10 +313,7 @@ export class CloudFunctionsClient {
321313
*
322314
* @param cf Cloud Function to deploy.
323315
*/
324-
async create(
325-
cf: CloudFunction,
326-
opts?: CreateOptions,
327-
): Promise<CloudFunctionResponse> {
316+
async create(cf: CloudFunction, opts?: CreateOptions): Promise<CloudFunctionResponse> {
328317
const timeout = opts?.timeout || defaultTimeout;
329318

330319
const resourceName = this.fullResourceName(cf.name);
@@ -394,10 +383,7 @@ export class CloudFunctionsClient {
394383
*
395384
* @param cf Cloud Function to patch
396385
*/
397-
async patch(
398-
cf: CloudFunction,
399-
opts?: PatchOptions,
400-
): Promise<CloudFunctionResponse> {
386+
async patch(cf: CloudFunction, opts?: PatchOptions): Promise<CloudFunctionResponse> {
401387
const timeout = opts?.timeout || defaultTimeout;
402388

403389
// fieldMasks are used if we are overwriting only specific fields of the
@@ -555,9 +541,7 @@ export class CloudFunctionsClient {
555541

556542
const projectID = this.#projectID;
557543
if (!projectID) {
558-
throw new Error(
559-
`Failed to get project ID to build resource name. Try setting 'project_id'.`,
560-
);
544+
throw new Error(`Failed to get project ID to build resource name. Try setting 'project_id'.`);
561545
}
562546

563547
const location = this.#location;

src/main.ts

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,7 @@ import {
3737
presence,
3838
} from '@google-github-actions/actions-utils';
3939

40-
import {
41-
CloudFunction,
42-
CloudFunctionsClient,
43-
SecretEnvVar,
44-
SecretVolume,
45-
} from './client';
40+
import { CloudFunction, CloudFunctionsClient, SecretEnvVar, SecretVolume } from './client';
4641
import { SecretName } from './secret';
4742
import { formatEntry } from './util';
4843

@@ -61,17 +56,13 @@ async function run(): Promise<void> {
6156
const entryPoint = presence(getInput('entry_point'));
6257
const sourceDir = presence(getInput('source_dir'));
6358
const vpcConnector = presence(getInput('vpc_connector'));
64-
const vpcConnectorEgressSettings = presence(
65-
getInput('vpc_connector_egress_settings'),
66-
);
59+
const vpcConnectorEgressSettings = presence(getInput('vpc_connector_egress_settings'));
6760
const ingressSettings = presence(getInput('ingress_settings'));
6861
const serviceAccountEmail = presence(getInput('service_account_email'));
6962
const timeout = parseDuration(getInput('timeout'));
7063
const maxInstances = presence(getInput('max_instances'));
7164
const minInstances = presence(getInput('min_instances'));
72-
const httpsTriggerSecurityLevel = presence(
73-
getInput('https_trigger_security_level'),
74-
);
65+
const httpsTriggerSecurityLevel = presence(getInput('https_trigger_security_level'));
7566
const eventTriggerType = presence(getInput('event_trigger_type'));
7667
const eventTriggerResource = presence(getInput('event_trigger_resource'));
7768
const eventTriggerService = presence(getInput('event_trigger_service'));
@@ -80,14 +71,10 @@ async function run(): Promise<void> {
8071
const labels = parseKVString(getInput('labels'));
8172

8273
const buildEnvVars = presence(getInput('build_environment_variables'));
83-
const buildEnvVarsFile = presence(
84-
getInput('build_environment_variables_file'),
85-
);
74+
const buildEnvVarsFile = presence(getInput('build_environment_variables_file'));
8675
const buildWorkerPool = presence(getInput('build_worker_pool'));
8776

88-
const secretEnvVars = parseKVString(
89-
getInput('secret_environment_variables'),
90-
);
77+
const secretEnvVars = parseKVString(getInput('secret_environment_variables'));
9178
const secretVols = parseKVString(getInput('secret_volumes'));
9279

9380
const dockerRepository = presence(getInput('docker_repository'));
@@ -123,8 +110,7 @@ async function run(): Promise<void> {
123110
eventTriggerType
124111
) {
125112
throw new Error(
126-
`Only one of 'https_trigger_security_level' or 'event_trigger_type' ` +
127-
`may be specified.`,
113+
`Only one of 'https_trigger_security_level' or 'event_trigger_type' ` + `may be specified.`,
128114
);
129115
}
130116
if (!sourceDir) {
@@ -147,16 +133,11 @@ async function run(): Promise<void> {
147133
}
148134
}
149135
if (timeout <= 0) {
150-
throw new Error(
151-
`The 'timeout' parameter must be > 0 seconds (got ${timeout})`,
152-
);
136+
throw new Error(`The 'timeout' parameter must be > 0 seconds (got ${timeout})`);
153137
}
154138

155139
// Build environment variables.
156-
const buildEnvironmentVariables = parseKVStringAndFile(
157-
buildEnvVars,
158-
buildEnvVarsFile,
159-
);
140+
const buildEnvironmentVariables = parseKVStringAndFile(buildEnvVars, buildEnvVarsFile);
160141
const environmentVariables = parseKVStringAndFile(envVars, envVarsFile);
161142

162143
// Build secret environment variables.
@@ -241,11 +222,7 @@ async function run(): Promise<void> {
241222
retry: {},
242223
};
243224
}
244-
} else if (
245-
eventTriggerType ||
246-
eventTriggerResource ||
247-
eventTriggerService
248-
) {
225+
} else if (eventTriggerType || eventTriggerResource || eventTriggerService) {
249226
throw new Error(
250227
`Event triggered functions must define 'event_trigger_type' and 'event_trigger_resource'`,
251228
);
@@ -309,9 +286,7 @@ async function run(): Promise<void> {
309286
setOutput('runtime', resp.runtime);
310287
} catch (err) {
311288
const msg = errorMessage(err);
312-
setFailed(
313-
`google-github-actions/deploy-cloud-functions failed with: ${msg}`,
314-
);
289+
setFailed(`google-github-actions/deploy-cloud-functions failed with: ${msg}`);
315290
}
316291
}
317292

src/util.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ export function zipDir(
7373
let gIgnoreF = undefined;
7474
if (getGcloudIgnores(dirPath).length > 0) {
7575
const gIgnore = ignore().add(getGcloudIgnores(dirPath));
76-
gIgnoreF = function (
77-
file: Archiver.EntryData,
78-
): false | Archiver.EntryData {
76+
gIgnoreF = function (file: Archiver.EntryData): false | Archiver.EntryData {
7977
return !gIgnore.ignores(file.name) ? file : false;
8078
};
8179
}

tests/client.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ describe('CloudFunctionsClient', () => {
5454
credentials: credentials,
5555
});
5656

57-
const outputPath = path.join(
58-
os.tmpdir(),
59-
crypto.randomBytes(12).toString('hex'),
60-
);
57+
const outputPath = path.join(os.tmpdir(), crypto.randomBytes(12).toString('hex'));
6158
const zipPath = await zipDir(testNodeFuncDir, outputPath);
6259

6360
// Generate upload URL

tests/env-var-files/test.good.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
KEY1: VALUE1
22
KEY2: VALUE2
33
JSONKEY: '{"bar":"baz"}'
4-

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
{
16+
{
1717
"compilerOptions": {
18+
"alwaysStrict": true,
1819
"target": "es6",
1920
"module": "commonjs",
2021
"lib": [

0 commit comments

Comments
 (0)