Skip to content

Commit ff2ff0f

Browse files
authored
refactor: use spaces for indentation (#126)
* chore: move over to spaces in editorconfig * chore: move over to spaces in eslint * chore: reformat all files with spaces * chore: fix wrong editorconfig setting * chore: rebuild files
1 parent 1cfa7bb commit ff2ff0f

13 files changed

Lines changed: 913 additions & 922 deletions

File tree

.editorconfig

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@ root = true
33
[*]
44
charset = utf-8
55
end_of_line = lf
6-
indent_style = tab
7-
insert_final_newline = true
8-
trim_trailing_whitespace = true
9-
10-
[*.md]
11-
indent_style = space
12-
trim_trailing_whitespace = false
13-
14-
[*.yml]
156
indent_size = 2
167
indent_style = space
8+
insert_final_newline = true

.eslintrc.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
module.exports = {
2-
ignorePatterns: ['/build/**', 'node_modules/**'],
3-
parser: '@typescript-eslint/parser',
4-
plugins: ['@typescript-eslint', 'jest', 'prettier'],
5-
env: {
6-
es6: true,
7-
'jest/globals': true,
8-
node: true,
9-
},
10-
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
11-
rules: {
12-
'@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
13-
'@typescript-eslint/indent': ['error', 'tab'],
14-
'prettier/prettier': 'error',
15-
},
2+
ignorePatterns: ['/build/**', 'node_modules/**'],
3+
parser: '@typescript-eslint/parser',
4+
plugins: ['@typescript-eslint', 'jest', 'prettier'],
5+
env: {
6+
es6: true,
7+
'jest/globals': true,
8+
node: true,
9+
},
10+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
11+
rules: {
12+
'@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
13+
'prettier/prettier': 'error',
14+
},
1615
};

jest.config.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module.exports = {
2-
verbose: true,
3-
clearMocks: true,
4-
moduleFileExtensions: ['js', 'ts'],
5-
testEnvironment: 'node',
6-
testMatch: ['**/*.test.ts'],
7-
testRunner: 'jest-circus/runner',
8-
transform: {
9-
'^.+\\.ts$': 'ts-jest',
10-
},
2+
verbose: true,
3+
clearMocks: true,
4+
moduleFileExtensions: ['js', 'ts'],
5+
testEnvironment: 'node',
6+
testMatch: ['**/*.test.ts'],
7+
testRunner: 'jest-circus/runner',
8+
transform: {
9+
'^.+\\.ts$': 'ts-jest',
10+
},
1111
};

ncc.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,41 @@ const BUILD_DIR = path.resolve(__dirname, 'build');
77
const ACTION_DIR = path.resolve(__dirname, 'src/actions');
88

99
const options = {
10-
cache: false,
11-
minify: true,
12-
sourceMap: true,
13-
quiet: true,
10+
cache: false,
11+
minify: true,
12+
sourceMap: true,
13+
quiet: true,
1414
};
1515

1616
async function write(file, content) {
17-
await fs.promises.writeFile(file, content, { encoding: 'utf-8' });
17+
await fs.promises.writeFile(file, content, { encoding: 'utf-8' });
1818
}
1919

2020
async function build(file) {
21-
const { code, map, assets } = await ncc(file, options);
22-
const name = path.basename(file, path.extname(file));
23-
const dir = path.resolve(BUILD_DIR, name);
21+
const { code, map, assets } = await ncc(file, options);
22+
const name = path.basename(file, path.extname(file));
23+
const dir = path.resolve(BUILD_DIR, name);
2424

25-
await fs.promises.mkdir(dir, { recursive: true });
25+
await fs.promises.mkdir(dir, { recursive: true });
2626

27-
for (const asset in assets) {
28-
await fs.promises.mkdir(path.join(dir, path.dirname(asset)), { recursive: true });
29-
await write(path.join(dir, asset), assets[asset].source);
30-
}
27+
for (const asset in assets) {
28+
await fs.promises.mkdir(path.join(dir, path.dirname(asset)), { recursive: true });
29+
await write(path.join(dir, asset), assets[asset].source);
30+
}
3131

32-
await write(path.join(dir, 'index.js'), code.replace(/\r\n/g, '\n'));
33-
await write(path.join(dir, 'index.map.js'), map.replace(/\r\n/g, '\n'));
32+
await write(path.join(dir, 'index.js'), code.replace(/\r\n/g, '\n'));
33+
await write(path.join(dir, 'index.map.js'), map.replace(/\r\n/g, '\n'));
3434

35-
console.log(`✓ ${path.relative(__dirname, file)}`);
35+
console.log(`✓ ${path.relative(__dirname, file)}`);
3636
}
3737

3838
async function main() {
39-
const actionPath = path.resolve(__dirname, './src/actions');
40-
const actionFiles = (await fs.promises.readdir(actionPath, { withFileTypes: true }))
41-
.filter(entity => entity.isFile())
42-
.map(entity => path.join(ACTION_DIR, entity.name));
39+
const actionPath = path.resolve(__dirname, './src/actions');
40+
const actionFiles = (await fs.promises.readdir(actionPath, { withFileTypes: true }))
41+
.filter(entity => entity.isFile())
42+
.map(entity => path.join(ACTION_DIR, entity.name));
4343

44-
return Promise.all(actionFiles.map(build));
44+
return Promise.all(actionFiles.map(build));
4545
}
4646

4747
main();

src/actions/setup.ts

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,54 +7,54 @@ import * as tools from '../tools';
77
tools.performAction(setupAction);
88

99
export async function setupAction(): Promise<void> {
10-
const expoVersion = await installCli('expo-cli');
11-
const easVersion = await installCli('eas-cli');
12-
13-
await group('Checking current authenticated account', () =>
14-
tools.maybeAuthenticate({
15-
cli: expoVersion ? 'expo-cli' : easVersion ? 'eas-cli' : undefined,
16-
token: getInput('token') || undefined,
17-
username: getInput('username') || undefined,
18-
password: getInput('password') || undefined,
19-
})
20-
);
21-
22-
if (tools.getBoolean(getInput('patch-watchers'), true)) {
23-
await group('Patching system watchers for the `ENOSPC` error', () => tools.maybePatchWatchers());
24-
}
10+
const expoVersion = await installCli('expo-cli');
11+
const easVersion = await installCli('eas-cli');
12+
13+
await group('Checking current authenticated account', () =>
14+
tools.maybeAuthenticate({
15+
cli: expoVersion ? 'expo-cli' : easVersion ? 'eas-cli' : undefined,
16+
token: getInput('token') || undefined,
17+
username: getInput('username') || undefined,
18+
password: getInput('password') || undefined,
19+
})
20+
);
21+
22+
if (tools.getBoolean(getInput('patch-watchers'), true)) {
23+
await group('Patching system watchers for the `ENOSPC` error', () => tools.maybePatchWatchers());
24+
}
2525
}
2626

2727
async function installCli(name: tools.PackageName): Promise<string | void> {
28-
const shortName = tools.getBinaryName(name);
29-
const inputVersion = getInput(`${shortName}-version`);
30-
const packager = getInput('packager') || 'yarn';
31-
32-
if (!inputVersion) {
33-
return info(`Skipping installation of ${name}, \`${shortName}-version\` not provided.`);
34-
}
35-
36-
const version = await tools.resolveVersion(name, inputVersion);
37-
const cache = tools.getBoolean(getInput(`${shortName}-cache`), false);
38-
39-
try {
40-
const path = await group(
41-
cache
42-
? `Installing ${name} (${version}) from cache or with ${packager}`
43-
: `Installing ${name} (${version}) with ${packager}`,
44-
() =>
45-
install({
46-
packager,
47-
version,
48-
cache,
49-
package: name,
50-
cacheKey: getInput(`${shortName}-cache-key`) || undefined,
51-
})
52-
);
53-
54-
addPath(path);
55-
} catch (error) {
56-
tools.handleError(name, error);
57-
}
58-
59-
return version;
28+
const shortName = tools.getBinaryName(name);
29+
const inputVersion = getInput(`${shortName}-version`);
30+
const packager = getInput('packager') || 'yarn';
31+
32+
if (!inputVersion) {
33+
return info(`Skipping installation of ${name}, \`${shortName}-version\` not provided.`);
34+
}
35+
36+
const version = await tools.resolveVersion(name, inputVersion);
37+
const cache = tools.getBoolean(getInput(`${shortName}-cache`), false);
38+
39+
try {
40+
const path = await group(
41+
cache
42+
? `Installing ${name} (${version}) from cache or with ${packager}`
43+
: `Installing ${name} (${version}) with ${packager}`,
44+
() =>
45+
install({
46+
packager,
47+
version,
48+
cache,
49+
package: name,
50+
cacheKey: getInput(`${shortName}-cache-key`) || undefined,
51+
})
52+
);
53+
54+
addPath(path);
55+
} catch (error) {
56+
tools.handleError(name, error);
57+
}
58+
59+
return version;
6060
}

src/cache.ts

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export type CacheConfig = Omit<InstallConfig, 'cache'>;
1515
* @see https://github.com/actions/toolkit/issues/47
1616
*/
1717
export async function fromLocalCache(config: CacheConfig): Promise<string | undefined> {
18-
return toolCache.find(config.package, config.version);
18+
return toolCache.find(config.package, config.version);
1919
}
2020

2121
/**
@@ -25,52 +25,52 @@ export async function fromLocalCache(config: CacheConfig): Promise<string | unde
2525
* @see https://github.com/actions/toolkit/issues/47
2626
*/
2727
export async function toLocalCache(root: string, config: CacheConfig): Promise<string> {
28-
return toolCache.cacheDir(root, config.package, config.version);
28+
return toolCache.cacheDir(root, config.package, config.version);
2929
}
3030

3131
/**
3232
* Download the remotely stored `expo-cli` from cache, if any.
3333
* Note, this cache is shared between jobs.
3434
*/
3535
export async function fromRemoteCache(config: CacheConfig): Promise<string | undefined> {
36-
// see: https://github.com/actions/toolkit/blob/8a4134761f09d0d97fb15f297705fd8644fef920/packages/tool-cache/src/tool-cache.ts#L401
37-
const target = path.join(process.env['RUNNER_TOOL_CACHE'] || '', config.package, config.version, os.arch());
38-
const cacheKey = config.cacheKey || getRemoteKey(config);
36+
// see: https://github.com/actions/toolkit/blob/8a4134761f09d0d97fb15f297705fd8644fef920/packages/tool-cache/src/tool-cache.ts#L401
37+
const target = path.join(process.env['RUNNER_TOOL_CACHE'] || '', config.package, config.version, os.arch());
38+
const cacheKey = config.cacheKey || getRemoteKey(config);
3939

40-
try {
41-
// When running with nektos/act, or other custom environments, the cache might not be set up.
42-
const hit = await restoreCache([target], cacheKey);
43-
if (hit) {
44-
return target;
45-
}
46-
} catch (error) {
47-
if (!handleRemoteCacheError(error)) {
48-
throw error;
49-
}
50-
}
40+
try {
41+
// When running with nektos/act, or other custom environments, the cache might not be set up.
42+
const hit = await restoreCache([target], cacheKey);
43+
if (hit) {
44+
return target;
45+
}
46+
} catch (error) {
47+
if (!handleRemoteCacheError(error)) {
48+
throw error;
49+
}
50+
}
5151
}
5252

5353
/**
5454
* Store the root of `expo-cli` in the remote cache, for future reuse.
5555
* Note, this cache is shared between jobs.
5656
*/
5757
export async function toRemoteCache(source: string, config: CacheConfig): Promise<void> {
58-
const cacheKey = config.cacheKey || getRemoteKey(config);
58+
const cacheKey = config.cacheKey || getRemoteKey(config);
5959

60-
try {
61-
await saveCache([source], cacheKey);
62-
} catch (error) {
63-
if (!handleRemoteCacheError(error)) {
64-
throw error;
65-
}
66-
}
60+
try {
61+
await saveCache([source], cacheKey);
62+
} catch (error) {
63+
if (!handleRemoteCacheError(error)) {
64+
throw error;
65+
}
66+
}
6767
}
6868

6969
/**
7070
* Get the cache key to use when (re)storing the Expo CLI from remote cache.
7171
*/
7272
function getRemoteKey(config: Omit<CacheConfig, 'cacheKey'>): string {
73-
return `${config.package}-${process.platform}-${os.arch()}-${config.packager}-${config.version}`;
73+
return `${config.package}-${process.platform}-${os.arch()}-${config.packager}-${config.version}`;
7474
}
7575

7676
/**
@@ -81,14 +81,14 @@ function getRemoteKey(config: Omit<CacheConfig, 'cacheKey'>): string {
8181
* @returns If the error was handled properly.
8282
*/
8383
function handleRemoteCacheError(error: Error): boolean {
84-
const isReserveCacheError = error instanceof ReserveCacheError;
85-
const isCacheUnavailable = error.message.toLowerCase().includes('cache service url not found');
84+
const isReserveCacheError = error instanceof ReserveCacheError;
85+
const isCacheUnavailable = error.message.toLowerCase().includes('cache service url not found');
8686

87-
if (isReserveCacheError || isCacheUnavailable) {
88-
core.warning('Skipping remote cache storage, encountered error:');
89-
core.warning(error.message);
90-
return true;
91-
}
87+
if (isReserveCacheError || isCacheUnavailable) {
88+
core.warning('Skipping remote cache storage, encountered error:');
89+
core.warning(error.message);
90+
return true;
91+
}
9292

93-
return false;
93+
return false;
9494
}

0 commit comments

Comments
 (0)