Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
style: increase line length
Browse files Browse the repository at this point in the history
  • Loading branch information
Noah authored Aug 25, 2021
1 parent fac6a4e commit 0f96e0f
Show file tree
Hide file tree
Showing 79 changed files with 828 additions and 1,784 deletions.
37 changes: 12 additions & 25 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'prettier'],
extends: [
'plugin:@typescript-eslint/recommended',
'@tophat/eslint-config/base',
'@tophat/eslint-config/jest',
'prettier',
],
extends: ['@tophat/eslint-config/base', '@tophat/eslint-config/jest'],
rules: {
'prettier/prettier': [
'error',
{
printWidth: 100,
tabWidth: 4,
semi: false,
trailingComma: 'all' /* Reduces git diff. */,
singleQuote: true,
arrowParens: 'always', // Reduces character diff when adding Typescript types.
},
],
'@typescript-eslint/no-non-null-assertion': 'off',
'no-empty': ['error', { allowEmptyCatch: true }],
'no-unused-vars': 'off', // covered by typescript eslint
'import/order': [
'error',
{
Expand All @@ -28,22 +31,6 @@ module.exports = {
],
},
],
'jest/no-standalone-expect': [
'error',
{ additionalTestBlockFunctions: ['teste2e'] },
],
},
ignorePatterns: ['**/.*', 'packages/**/*.js', '**/lib', 'gatsby/public'],
settings: {
'import/external-module-folders': ['node_modules', '.yarn'],
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.js'],
},
'import/resolver': {
typescript: {
alwaysTryTypes: true,
},
'@tophat/eslint-import-resolver-require': {},
},
},
}
23 changes: 5 additions & 18 deletions __mocks__/@monodeploy/git.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* eslint-disable @typescript-eslint/no-unused-vars */

import type {
CommitMessage,
MonodeployConfiguration,
YarnContext,
} from '@monodeploy/types'
import type { CommitMessage, MonodeployConfiguration, YarnContext } from '@monodeploy/types'

const actualMonodeployGit = jest.requireActual('@monodeploy/git')

Expand Down Expand Up @@ -69,24 +65,17 @@ const gitDiffTree = async (
const gitLog = async (
from: string,
to: string,
{
cwd,
DELIMITER,
context,
}: { cwd: string; DELIMITER: string; context: YarnContext },
{ cwd, DELIMITER, context }: { cwd: string; DELIMITER: string; context: YarnContext },
): Promise<string> => {
return registry.commits
.map((commit) => `${commit.sha}\n${commit.body}`)
.join(`${DELIMITER}\n`)
return registry.commits.map((commit) => `${commit.sha}\n${commit.body}`).join(`${DELIMITER}\n`)
}

const gitTag = async (
tag: string,
{ cwd, context }: { cwd: string; context: YarnContext },
): Promise<void> => {
registry.tags.push(tag)
registry.lastTaggedCommit =
registry.commits[registry.commits.length - 1]?.sha
registry.lastTaggedCommit = registry.commits[registry.commits.length - 1]?.sha
}

const gitPushTags = async ({
Expand All @@ -98,9 +87,7 @@ const gitPushTags = async ({
remote: string
context: YarnContext
}): Promise<void> => {
registry.pushedTags = Array.from(
new Set([...registry.pushedTags, ...registry.tags]),
)
registry.pushedTags = Array.from(new Set([...registry.pushedTags, ...registry.tags]))
}

const gitPull = async ({
Expand Down
19 changes: 3 additions & 16 deletions __mocks__/@yarnpkg/plugin-npm.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import {
Configuration,
Ident,
MessageName,
ReportError,
structUtils,
} from '@yarnpkg/core'
import { Configuration, Ident, MessageName, ReportError, structUtils } from '@yarnpkg/core'

const actualModule = jest.requireActual('@yarnpkg/plugin-npm')

Expand All @@ -17,11 +11,7 @@ const _reset_ = (): void => {
_registry.tags = {}
}

const _setTag_ = (
pkgName: string,
tagValue: string,
tagKey = 'latest',
): void => {
const _setTag_ = (pkgName: string, tagValue: string, tagKey = 'latest'): void => {
_registry.tags[pkgName] = { ..._registry.tags[pkgName], [tagKey]: tagValue }
}

Expand All @@ -32,10 +22,7 @@ const npmHttpUtilsGet = (
const pkgName = structUtils.stringifyIdent(ident)
const tags = _registry.tags[pkgName]
if (!tags) {
throw new ReportError(
MessageName.AUTHENTICATION_INVALID,
`Cannot access ${pkgName}`,
)
throw new ReportError(MessageName.AUTHENTICATION_INVALID, `Cannot access ${pkgName}`)
}
return tags
}
Expand Down
30 changes: 10 additions & 20 deletions e2e-tests/helpers/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,13 @@ const exec = util.promisify(childProcess.exec)
const isUp = (): Promise<void> =>
new Promise((resolve, reject) => {
try {
http.get(
'http://localhost:4873/-/whoami',
{ timeout: 2000 },
(res) => {
res.resume()
if (res.statusCode === 200) {
return resolve()
}
return reject(new Error('Request failed.'))
},
).on('error', (err) => {
http.get('http://localhost:4873/-/whoami', { timeout: 2000 }, (res) => {
res.resume()
if (res.statusCode === 200) {
return resolve()
}
return reject(new Error('Request failed.'))
}).on('error', (err) => {
reject(err)
})
} catch (err) {
Expand All @@ -39,21 +35,15 @@ export async function waitForRegistry(timeout = 20000): Promise<boolean> {
await new Promise((r) => setTimeout(r, DELAY))
}

throw new Error(
`Registry not started. Timed out after ${Date.now() - startTime} ms.`,
)
throw new Error(`Registry not started. Timed out after ${Date.now() - startTime} ms.`)
}

export async function stopRegistry(): Promise<void> {
const { stderr } = await exec(
`yarn workspace @monodeploy/e2e-tests test:registry:stop`,
)
const { stderr } = await exec('yarn workspace @monodeploy/e2e-tests test:registry:stop')
if (stderr) console.error(stderr)
}

export async function startRegistry(): Promise<void> {
const { stderr } = await exec(
`yarn workspace @monodeploy/e2e-tests test:registry:start`,
)
const { stderr } = await exec('yarn workspace @monodeploy/e2e-tests test:registry:start')
if (stderr) console.error(stderr)
}
8 changes: 1 addition & 7 deletions e2e-tests/helpers/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@ const exec = util.promisify(childProcess.exec)

const scriptPath = require.resolve('monodeploy')

export default async function run({
cwd,
args = '',
}: {
cwd: string
args: string
}): Promise<{
export default async function run({ cwd, args = '' }: { cwd: string; args: string }): Promise<{
stdout: string
stderr: string
error?: ExecException
Expand Down
11 changes: 3 additions & 8 deletions e2e-tests/helpers/setupProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default function setupProject({
await exec('git add . && git commit -n -m "initial commit"', {
cwd: project,
})
await exec(`git push -u origin main`, {
await exec('git push -u origin main', {
cwd: project,
})

Expand All @@ -93,10 +93,7 @@ export default function setupProject({

return run({
cwd: project,
args: [
`--config-file ${configFilename}`,
...(args ? args : []),
].join(' '),
args: [`--config-file ${configFilename}`, ...(args ? args : [])].join(' '),
})
},
readFile: (filename: string) => {
Expand All @@ -111,9 +108,7 @@ export default function setupProject({
},
})
} finally {
await cleanUp(
[project, remotePath].filter((v): v is string => v !== null),
)
await cleanUp([project, remotePath].filter((v): v is string => v !== null))
await stopRegistry()
}
}
Expand Down
Loading

0 comments on commit 0f96e0f

Please sign in to comment.