Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatter-improvements #70

Merged
merged 2 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ module.exports = {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/consistent-type-imports': 'error',
'no-unused-vars': 'off',
'no-constant-condition': 'off',
'prettier/prettier': [
'error',
{
Expand Down
14 changes: 12 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"tabWidth": 4,
"singleQuote": true,
"trailingComma": "all",
"semi": false,
"printWidth": 100,
"printWidth": 120,
"importOrder": ["^@.*/(.*)$", "^[./]"],
"importOrderSeparation": false,
"importOrderSortSpecifiers": true
"importOrderSortSpecifiers": true,
"plugins": ["@trivago/prettier-plugin-sort-imports"],
"overrides": [
{
"files": ["*.ts"],
"options": {
"importOrderParserPlugins": ["typescript", "decorators-legacy"]
}
}
]
}
125 changes: 125 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^10.0.3",
"@semantic-release/release-notes-generator": "^13.0.0",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/express": "^4.17.21",
"@types/inquirer": "^8.2.6",
"@types/jest": "^29.5.12",
Expand Down
10 changes: 3 additions & 7 deletions src/commands/assets/assets.command.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { Command, CommandRunner } from 'nest-commander'
import { mkdir, readdir, writeFile } from 'node:fs/promises'
import { execPromise } from '@common/utils'
import { CheckUpdateService } from '@services/check-update.service'
import { LoggerService } from '@services/logger.service'
import { Command, CommandRunner } from 'nest-commander'
import { mkdir, readdir, writeFile } from 'node:fs/promises'
import type { AvailableActionIds } from './config/ constants.config'
import {
GIT_PROFILES_TARGET,
HELP_BOX_MESSAGE,
NPM_PROFILES_TARGET,
} from './config/ constants.config'
import { GIT_PROFILES_TARGET, HELP_BOX_MESSAGE, NPM_PROFILES_TARGET } from './config/ constants.config'
import {
ASK_FOR_ARTIFACTORY_KEY_PROMPT,
ASK_FOR_CUSTOM_REGISTRY_AUTH_PROMPT,
Expand Down
1 change: 1 addition & 0 deletions src/commands/assets/config/inputs.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-useless-escape */
import { inquirer } from '@common/inquirer'
import type { AvailableActionIds } from './ constants.config'
import { AVAILABLE_ACTIONS } from './ constants.config'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { resolveBundledAsset } from '@common/utils'
import { readFile } from 'node:fs/promises'
import { resolveBundledAsset } from '@common/utils'
import type { ReplacementTemplate } from './models/replacement.enum'

export async function replaceInTemplate(
Expand Down
2 changes: 1 addition & 1 deletion src/commands/external/external.command.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CheckUpdateService } from '@services/check-update.service'
import { Command, CommandRunner } from 'nest-commander'
import { CheckUpdateService } from '@services/check-update.service'
import { DeleteSubCommand, InstallSubCommand, ListSubCommand } from './sub-commands'

@Command({
Expand Down
4 changes: 2 additions & 2 deletions src/commands/external/sub-commands/delete.sub-command.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CheckUpdateService } from '@services/check-update.service'
import { LoggerService } from '@services/logger.service'
import { CommandRunner, SubCommand } from 'nest-commander'
import { readdir, rm } from 'node:fs/promises'
import { CheckUpdateService } from '@services/check-update.service'
import { LoggerService } from '@services/logger.service'
import { EXTERNAL_REGISTRY_DIR_PATH } from '../config/constants'

@SubCommand({
Expand Down
13 changes: 5 additions & 8 deletions src/commands/external/sub-commands/install.sub-command.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,10 @@ describe('InstallSubCommand', () => {
{ input: 'test.sh-shell.sh', expRes: 'test.sh-shell.sh' },
{ input: 'test.sh-shell', expRes: 'test.sh-shell.sh' },
{ input: 'test-shell', expRes: 'test-shell.sh' },
])(
'should grab the name of the external with the extension of .sh',
({ input, expRes }) => {
// @ts-expect-error
const res = service.parseExternalName(input)
expect(res).toEqual(expRes)
},
)
])('should grab the name of the external with the extension of .sh', ({ input, expRes }) => {
// @ts-expect-error
const res = service.parseExternalName(input)
expect(res).toEqual(expRes)
})
})
})
8 changes: 3 additions & 5 deletions src/commands/external/sub-commands/install.sub-command.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { LoggerService } from '@services/logger.service'
import { CommandRunner, SubCommand } from 'nest-commander'
import { existsSync } from 'node:fs'
import { CheckUpdateService } from '@services/check-update.service'
import { copyFile, readdir } from 'node:fs/promises'
import { CheckUpdateService } from '@services/check-update.service'
import { LoggerService } from '@services/logger.service'
import { EXTERNAL_REGISTRY_DIR_PATH } from '../config/constants'

@SubCommand({
Expand Down Expand Up @@ -53,9 +53,7 @@ export class InstallSubCommand extends CommandRunner {

await copyFile(filePath, `${EXTERNAL_REGISTRY_DIR_PATH}/${parsedExternalName}`)

this.logger.log(
`Installed external shell with name '${parsedExternalName}' successfully`,
)
this.logger.log(`Installed external shell with name '${parsedExternalName}' successfully`)
} catch (error) {
this.logger.error(`Error InstallCommand, error: ${error.stack}`)
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/external/sub-commands/list.sub-command.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CheckUpdateService } from '@services/check-update.service'
import { LoggerService } from '@services/logger.service'
import { CommandRunner, SubCommand } from 'nest-commander'
import { readdir } from 'node:fs/promises'
import { CheckUpdateService } from '@services/check-update.service'
import { LoggerService } from '@services/logger.service'
import { EXTERNAL_REGISTRY_DIR_PATH } from '../config/constants'

@SubCommand({
Expand Down
2 changes: 1 addition & 1 deletion src/commands/init-script/init-script.command.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BASE_PATH } from '@common/constants'
import { access } from 'fs/promises'
import { Command, CommandRunner } from 'nest-commander'
import { BASE_PATH } from '@common/constants'
import { INIT_DYNAMIC_SCRIPT, OPEN_TERMINAL } from './config/init-script.config'

@Command({
Expand Down
15 changes: 6 additions & 9 deletions src/commands/init/init.command.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { BASE_PATH } from '@common/constants'
import { copyBundledAsset, execPromise, resolveBundledAsset } from '@common/utils'
import { CheckUpdateService } from '@services/check-update.service'
import { LoggerService } from '@services/logger.service'
import { Command, CommandRunner } from 'nest-commander'
import { existsSync } from 'node:fs'
import { appendFile, chmod, copyFile, mkdir, readFile, readdir, rename, rm } from 'node:fs/promises'
import { homedir } from 'node:os'
import { resolve } from 'node:path'
import ora from 'ora'
import { BASE_PATH } from '@common/constants'
import { copyBundledAsset, execPromise, resolveBundledAsset } from '@common/utils'
import { CheckUpdateService } from '@services/check-update.service'
import { LoggerService } from '@services/logger.service'
import {
BREW_DIRECTORY,
BREW_INSTALLATION_COMMAND,
Expand Down Expand Up @@ -129,8 +129,7 @@ export class InitCommand extends CommandRunner {
try {
this.logger.debug(`Unpacking bundled assets to ${BASE_PATH}`)

const disabledExtendsFilesMap: Record<string, string> =
await this.getCurrentExtendsDirDisabledFilesMap()
const disabledExtendsFilesMap: Record<string, string> = await this.getCurrentExtendsDirDisabledFilesMap()

await mkdir(`${BASE_PATH}/zsh`, { recursive: true }).catch(() => {})
await rm(`${BASE_PATH}/zsh/extends`, { recursive: true, force: true }).catch(() => {})
Expand Down Expand Up @@ -310,9 +309,7 @@ export class InitCommand extends CommandRunner {
try {
const extendsFiles: string[] = await this.getExtendsFiles()

const disabledFiles = extendsFiles.filter((fileName: string) =>
fileName.endsWith('.disabled'),
)
const disabledFiles = extendsFiles.filter((fileName: string) => fileName.endsWith('.disabled'))

const disabledFilesMap: Record<string, string> = disabledFiles.reduce((acc, curr) => {
const originalName = curr.replace('.disabled', '')
Expand Down
6 changes: 1 addition & 5 deletions src/commands/install/config/apps-groups/cli-apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ export const CLI_APPS: Readonly<IAppSetup[]> = [
group: 'cli-apps',
description: 'MongoDB Community Edition server',
tags: ['engineering', 'devops'],
commands: () => [
BREW_TAP('mongodb/brew'),
BREW_INSTALL('[email protected]'),
'mkdir -p "$HOME/mongodb"',
],
commands: () => [BREW_TAP('mongodb/brew'), BREW_INSTALL('[email protected]'), 'mkdir -p "$HOME/mongodb"'],
fallbackCommands: () => [
BROW_TAP('mongodb/brew'),
BROW_INSTALL('[email protected]'),
Expand Down
3 changes: 1 addition & 2 deletions src/commands/install/config/apps-groups/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ export const NODE_APPS: Readonly<IAppSetup[]> = [
},
{
name: 'DPDM',
description:
'A robust static dependency analyzer for your JavaScript and TypeScript projects',
description: 'A robust static dependency analyzer for your JavaScript and TypeScript projects',
group: 'node',
tags: ['engineering'],
commands: () => [NODE_GLOBAL('dpdm')],
Expand Down
12 changes: 2 additions & 10 deletions src/commands/install/config/apps-groups/terminal.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import type { IAppSetup } from '@models/app-setup.model'
import {
BREW_CASK,
BREW_INSTALL,
BREW_TAP,
BROW_ALIAS,
BROW_INSTALL,
BROW_TAP,
} from '../common-commands'
import { BREW_CASK, BREW_INSTALL, BREW_TAP, BROW_ALIAS, BROW_INSTALL, BROW_TAP } from '../common-commands'

export const TERMINAL_APPS: Readonly<IAppSetup[]> = [
{
Expand All @@ -29,8 +22,7 @@ export const TERMINAL_APPS: Readonly<IAppSetup[]> = [
},
{
name: 'Mcfly',
description:
'Search & execute through your shell history, with context-aware suggestions and neural network.',
description: 'Search & execute through your shell history, with context-aware suggestions and neural network.',
group: 'terminal',
tags: ['engineering', 'devops', 'productivity'],
commands: () => [BREW_TAP('cantino/mcfly'), BREW_INSTALL('cantino/mcfly/mcfly')],
Expand Down
Loading