Skip to content

Commit da1a031

Browse files
committed
Update prettier settings and reformat everything
1 parent 511c3f3 commit da1a031

File tree

8 files changed

+106
-148
lines changed

8 files changed

+106
-148
lines changed

.eslintrc.json

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,52 @@
11
{
2-
"plugins": ["jest", "@typescript-eslint"],
3-
"extends": ["plugin:github/recommended"],
4-
"parser": "@typescript-eslint/parser",
5-
"parserOptions": {
6-
"ecmaVersion": 9,
7-
"sourceType": "module",
8-
"project": "./tsconfig.json"
9-
},
10-
"rules": {
11-
"eslint-comments/no-use": "off",
12-
"import/no-namespace": "off",
13-
"no-unused-vars": "off",
14-
"@typescript-eslint/no-unused-vars": "error",
15-
"@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}],
16-
"@typescript-eslint/no-require-imports": "error",
17-
"@typescript-eslint/array-type": "error",
18-
"@typescript-eslint/await-thenable": "error",
19-
"camelcase": "off",
20-
"@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}],
21-
"@typescript-eslint/func-call-spacing": ["error", "never"],
22-
"@typescript-eslint/no-array-constructor": "error",
23-
"@typescript-eslint/no-empty-interface": "error",
24-
"@typescript-eslint/no-explicit-any": "error",
25-
"@typescript-eslint/no-extraneous-class": "error",
26-
"@typescript-eslint/no-for-in-array": "error",
27-
"@typescript-eslint/no-inferrable-types": "error",
28-
"@typescript-eslint/no-misused-new": "error",
29-
"@typescript-eslint/no-namespace": "error",
30-
"@typescript-eslint/no-non-null-assertion": "warn",
31-
"@typescript-eslint/no-unnecessary-qualifier": "error",
32-
"@typescript-eslint/no-unnecessary-type-assertion": "error",
33-
"@typescript-eslint/no-useless-constructor": "error",
34-
"@typescript-eslint/no-var-requires": "error",
35-
"@typescript-eslint/prefer-for-of": "warn",
36-
"@typescript-eslint/prefer-function-type": "warn",
37-
"@typescript-eslint/prefer-includes": "error",
38-
"@typescript-eslint/prefer-string-starts-ends-with": "error",
39-
"@typescript-eslint/promise-function-async": "error",
40-
"@typescript-eslint/require-array-sort-compare": "error",
41-
"@typescript-eslint/restrict-plus-operands": "error",
42-
"@typescript-eslint/type-annotation-spacing": "error",
43-
"@typescript-eslint/unbound-method": "error",
44-
"github/array-foreach": "off",
45-
"i18n-text/no-en": "off"
46-
},
47-
"env": {
48-
"node": true,
49-
"es6": true,
50-
"jest/globals": true
51-
}
52-
}
2+
"plugins": ["jest", "@typescript-eslint"],
3+
"extends": ["plugin:github/recommended"],
4+
"parser": "@typescript-eslint/parser",
5+
"parserOptions": {
6+
"ecmaVersion": 9,
7+
"sourceType": "module",
8+
"project": "./tsconfig.json"
9+
},
10+
"rules": {
11+
"eslint-comments/no-use": "off",
12+
"import/no-namespace": "off",
13+
"no-unused-vars": "off",
14+
"@typescript-eslint/no-unused-vars": "error",
15+
"@typescript-eslint/explicit-member-accessibility": ["error", { "accessibility": "no-public" }],
16+
"@typescript-eslint/no-require-imports": "error",
17+
"@typescript-eslint/array-type": "error",
18+
"@typescript-eslint/await-thenable": "error",
19+
"camelcase": "off",
20+
"@typescript-eslint/explicit-function-return-type": ["error", { "allowExpressions": true }],
21+
"@typescript-eslint/func-call-spacing": ["error", "never"],
22+
"@typescript-eslint/no-array-constructor": "error",
23+
"@typescript-eslint/no-empty-interface": "error",
24+
"@typescript-eslint/no-explicit-any": "error",
25+
"@typescript-eslint/no-extraneous-class": "error",
26+
"@typescript-eslint/no-for-in-array": "error",
27+
"@typescript-eslint/no-inferrable-types": "error",
28+
"@typescript-eslint/no-misused-new": "error",
29+
"@typescript-eslint/no-namespace": "error",
30+
"@typescript-eslint/no-non-null-assertion": "warn",
31+
"@typescript-eslint/no-unnecessary-qualifier": "error",
32+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
33+
"@typescript-eslint/no-useless-constructor": "error",
34+
"@typescript-eslint/no-var-requires": "error",
35+
"@typescript-eslint/prefer-for-of": "warn",
36+
"@typescript-eslint/prefer-function-type": "warn",
37+
"@typescript-eslint/prefer-includes": "error",
38+
"@typescript-eslint/prefer-string-starts-ends-with": "error",
39+
"@typescript-eslint/promise-function-async": "error",
40+
"@typescript-eslint/require-array-sort-compare": "error",
41+
"@typescript-eslint/restrict-plus-operands": "error",
42+
"@typescript-eslint/type-annotation-spacing": "error",
43+
"@typescript-eslint/unbound-method": "error",
44+
"github/array-foreach": "off",
45+
"i18n-text/no-en": "off"
46+
},
47+
"env": {
48+
"node": true,
49+
"es6": true,
50+
"jest/globals": true
51+
}
52+
}

.prettierrc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"printWidth": 80,
2+
"printWidth": 120,
33
"tabWidth": 2,
44
"useTabs": false,
55
"semi": true,
66
"singleQuote": true,
77
"trailingComma": "es5",
8-
"bracketSpacing": false,
8+
"bracketSpacing": true,
99
"arrowParens": "avoid",
1010
"overrides": [
1111
{

__tests__/main.test.ts

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {execSync} from 'child_process';
1+
import { execSync } from 'child_process';
22
import * as path from 'path';
33
import * as process from 'process';
44
import {
@@ -29,9 +29,7 @@ describe('options', () => {
2929

3030
test('should throw an error when option type is not a boolean', () => {
3131
process.env['INPUT_FINALIZE'] = 'error';
32-
expect(() => getBooleanOption(option, defaultValue)).toThrow(
33-
errorMessage
34-
);
32+
expect(() => getBooleanOption(option, defaultValue)).toThrow(errorMessage);
3533
});
3634

3735
test('should return defaultValue if option is omitted', () => {
@@ -84,8 +82,7 @@ describe('options', () => {
8482
});
8583

8684
describe('getStartedAt', () => {
87-
const errorMessage =
88-
'started_at not in valid format. Unix timestamp or ISO 8601 date expected';
85+
const errorMessage = 'started_at not in valid format. Unix timestamp or ISO 8601 date expected';
8986
afterEach(() => {
9087
delete process.env['INPUT_STARTED_AT'];
9188
});
@@ -121,10 +118,10 @@ describe('options', () => {
121118
});
122119

123120
describe.each([
124-
{release: 'INPUT_RELEASE', prefix: 'INPUT_RELEASE_PREFIX'},
125-
{release: 'INPUT_VERSION', prefix: 'INPUT_VERSION_PREFIX'},
126-
{release: 'INPUT_RELEASE', prefix: 'INPUT_VERSION_PREFIX'},
127-
{release: 'INPUT_VERSION', prefix: 'INPUT_RELEASE_PREFIX'},
121+
{ release: 'INPUT_RELEASE', prefix: 'INPUT_RELEASE_PREFIX' },
122+
{ release: 'INPUT_VERSION', prefix: 'INPUT_VERSION_PREFIX' },
123+
{ release: 'INPUT_RELEASE', prefix: 'INPUT_VERSION_PREFIX' },
124+
{ release: 'INPUT_VERSION', prefix: 'INPUT_RELEASE_PREFIX' },
128125
])(`getRelease`, params => {
129126
const MOCK_VERSION = 'releases propose-version';
130127

@@ -250,9 +247,7 @@ describe('options', () => {
250247
it('gets the working directory url and prefixes it with the `GITHUB_WORKSPACE`', () => {
251248
process.env['GITHUB_WORKSPACE'] = '/repo/root';
252249
process.env['INPUT_WORKING_DIRECTORY'] = '/some/working/directory';
253-
expect(getWorkingDirectory()).toEqual(
254-
'/repo/root/some/working/directory'
255-
);
250+
expect(getWorkingDirectory()).toEqual('/repo/root/some/working/directory');
256251
});
257252

258253
it('should default to `GITHUB_WORKSPACE` even if no direcotry is passed', () => {
@@ -264,19 +259,16 @@ describe('options', () => {
264259

265260
// shows how the runner will run a javascript action with env / stdout protocol
266261
test('test runs', () => {
267-
const output = execSync(
268-
`node ${path.join(__dirname, '..', 'dist', 'index.js')}`,
269-
{
270-
env: {
271-
...process.env,
272-
INPUT_ENVIRONMENT: 'production',
273-
MOCK: 'true',
274-
SENTRY_AUTH_TOKEN: 'test_token',
275-
SENTRY_ORG: 'test_org',
276-
SENTRY_PROJECT: 'test_project',
277-
},
278-
}
279-
);
262+
const output = execSync(`node ${path.join(__dirname, '..', 'dist', 'index.js')}`, {
263+
env: {
264+
...process.env,
265+
INPUT_ENVIRONMENT: 'production',
266+
MOCK: 'true',
267+
SENTRY_AUTH_TOKEN: 'test_token',
268+
SENTRY_ORG: 'test_org',
269+
SENTRY_PROJECT: 'test_project',
270+
},
271+
});
280272

281273
console.log(output.toString());
282274
});

dist/index.js

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -122771,18 +122771,17 @@ const telemetry_1 = __nccwpck_require__(12417);
122771122771
}
122772122772
yield (0, telemetry_1.traceStep)('upload-sourcemaps', () => __awaiter(void 0, void 0, void 0, function* () {
122773122773
core.debug(`Adding sourcemaps`);
122774-
yield Promise.all(projects.map((project) => __awaiter(void 0, void 0, void 0, function* () {
122775-
// upload source maps can only do one project at a time
122776-
const localProjects = [project];
122777-
const sourceMapOptions = {
122778-
include: sourcemaps,
122779-
projects: localProjects,
122780-
dist,
122781-
urlPrefix,
122782-
stripCommonPrefix,
122783-
};
122784-
return (0, cli_1.getCLI)().uploadSourceMaps(release, sourceMapOptions);
122785-
})));
122774+
const sourceMapsOptions = {
122775+
include: sourcemaps,
122776+
projects,
122777+
dist,
122778+
stripCommonPrefix,
122779+
};
122780+
// only set the urlPrefix if it's not empty
122781+
if (urlPrefix) {
122782+
sourceMapsOptions.urlPrefix = urlPrefix;
122783+
}
122784+
yield (0, cli_1.getCLI)().uploadSourceMaps(release, sourceMapsOptions);
122786122785
Sentry.setTag('sourcemaps-uploaded', true);
122787122786
}));
122788122787
}
@@ -123002,11 +123001,7 @@ exports.getSetCommitsOption = getSetCommitsOption;
123002123001
const checkEnvironmentVariables = () => {
123003123002
if (process.env['MOCK']) {
123004123003
// Set environment variables for mock runs if they aren't already
123005-
for (const variable of [
123006-
'SENTRY_AUTH_TOKEN',
123007-
'SENTRY_ORG',
123008-
'SENTRY_PROJECT',
123009-
]) {
123004+
for (const variable of ['SENTRY_AUTH_TOKEN', 'SENTRY_ORG', 'SENTRY_PROJECT']) {
123010123005
if (!(variable in process.env)) {
123011123006
process.env[variable] = variable;
123012123007
}
@@ -123184,7 +123179,7 @@ exports.isSelfHosted = isSelfHosted;
123184123179
* Determine if telemetry should be enabled.
123185123180
*/
123186123181
function isTelemetryEnabled() {
123187-
return (!ciOptions.getBooleanOption('disable_telemetry', false) && !isSelfHosted());
123182+
return !ciOptions.getBooleanOption('disable_telemetry', false) && !isSelfHosted();
123188123183
}
123189123184
exports.isTelemetryEnabled = isTelemetryEnabled;
123190123185

src/cli.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {getTraceData} from '@sentry/node';
2-
import SentryCli, {SentryCliReleases} from '@sentry/cli';
1+
import { getTraceData } from '@sentry/node';
2+
import SentryCli, { SentryCliReleases } from '@sentry/cli';
33
// @ts-ignore
4-
import {version} from '../package.json';
4+
import { version } from '../package.json';
55

66
/**
77
* CLI Singleton

src/main.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import * as Sentry from '@sentry/node';
22
import * as core from '@actions/core';
3-
import {SentryCliUploadSourceMapsOptions} from '@sentry/cli';
4-
import {getCLI} from './cli';
3+
import { SentryCliUploadSourceMapsOptions } from '@sentry/cli';
4+
import { getCLI } from './cli';
55
import * as options from './options';
66
import * as process from 'process';
7-
import {isTelemetryEnabled, traceStep, withTelemetry} from './telemetry';
7+
import { isTelemetryEnabled, traceStep, withTelemetry } from './telemetry';
88

99
withTelemetry(
1010
{
@@ -33,10 +33,7 @@ withTelemetry(
3333
const setCommitsOption = options.getSetCommitsOption();
3434
const projects = options.getProjects();
3535
const urlPrefix = options.getUrlPrefixOption();
36-
const stripCommonPrefix = options.getBooleanOption(
37-
'strip_common_prefix',
38-
false
39-
);
36+
const stripCommonPrefix = options.getBooleanOption('strip_common_prefix', false);
4037
const release = await options.getRelease();
4138

4239
if (projects.length === 1) {
@@ -46,7 +43,7 @@ withTelemetry(
4643
}
4744

4845
core.debug(`Release version is ${release}`);
49-
await getCLI().new(release, {projects});
46+
await getCLI().new(release, { projects });
5047

5148
Sentry.setTag('set-commits', setCommitsOption);
5249

@@ -69,10 +66,7 @@ withTelemetry(
6966
await traceStep('inject-debug-ids', async () => {
7067
core.debug(`Injecting Debug IDs`);
7168
// Unfortunately, @sentry/cli does not yet have an alias for inject
72-
await getCLI().execute(
73-
['sourcemaps', 'inject', ...sourcemaps],
74-
true
75-
);
69+
await getCLI().execute(['sourcemaps', 'inject', ...sourcemaps], true);
7670
});
7771
}
7872

@@ -103,7 +97,7 @@ withTelemetry(
10397
core.debug(`Adding deploy to release`);
10498
await getCLI().newDeploy(release, {
10599
env: environment,
106-
...(deployStartedAtOption && {started: deployStartedAtOption}),
100+
...(deployStartedAtOption && { started: deployStartedAtOption }),
107101
});
108102
});
109103
}

src/options.ts

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as core from '@actions/core';
22
import path from 'path';
3-
import {getCLI} from './cli';
3+
import { getCLI } from './cli';
44

55
/**
66
* Get the release version string from parameter or propose one.
@@ -69,9 +69,7 @@ export const getStartedAt = (): number | null => {
6969
}
7070

7171
if (!outputTimestamp || outputTimestamp < 0) {
72-
throw new Error(
73-
'started_at not in valid format. Unix timestamp or ISO 8601 date expected'
74-
);
72+
throw new Error('started_at not in valid format. Unix timestamp or ISO 8601 date expected');
7573
}
7674

7775
return outputTimestamp;
@@ -109,10 +107,7 @@ export const getDist = (): string | undefined => {
109107
* @param defaultValue boolean
110108
* @returns boolean
111109
*/
112-
export const getBooleanOption = (
113-
input: string,
114-
defaultValue: boolean
115-
): boolean => {
110+
export const getBooleanOption = (input: string, defaultValue: boolean): boolean => {
116111
const option = core.getInput(input);
117112
if (!option) {
118113
return defaultValue;
@@ -156,26 +151,18 @@ export const getSetCommitsOption = (): 'auto' | 'skip' => {
156151
export const checkEnvironmentVariables = (): void => {
157152
if (process.env['MOCK']) {
158153
// Set environment variables for mock runs if they aren't already
159-
for (const variable of [
160-
'SENTRY_AUTH_TOKEN',
161-
'SENTRY_ORG',
162-
'SENTRY_PROJECT',
163-
]) {
154+
for (const variable of ['SENTRY_AUTH_TOKEN', 'SENTRY_ORG', 'SENTRY_PROJECT']) {
164155
if (!(variable in process.env)) {
165156
process.env[variable] = variable;
166157
}
167158
}
168159
}
169160

170161
if (!process.env['SENTRY_ORG']) {
171-
throw Error(
172-
'Environment variable SENTRY_ORG is missing an organization slug'
173-
);
162+
throw Error('Environment variable SENTRY_ORG is missing an organization slug');
174163
}
175164
if (!process.env['SENTRY_AUTH_TOKEN']) {
176-
throw Error(
177-
'Environment variable SENTRY_AUTH_TOKEN is missing an auth token'
178-
);
165+
throw Error('Environment variable SENTRY_AUTH_TOKEN is missing an auth token');
179166
}
180167
};
181168

@@ -205,8 +192,5 @@ export const getWorkingDirectory = (): string => {
205192
// The action runs inside `github.action_path` and as such
206193
// doesn't automatically have access to the user's git
207194
// We prefix all paths with `GITHUB_WORKSPACE` which is at the top of the repo.
208-
return path.join(
209-
process.env.GITHUB_WORKSPACE || '',
210-
core.getInput('working_directory')
211-
);
195+
return path.join(process.env.GITHUB_WORKSPACE || '', core.getInput('working_directory'));
212196
};

0 commit comments

Comments
 (0)