Skip to content

Commit

Permalink
refactor: imports paths to avoid ../../ hell
Browse files Browse the repository at this point in the history
  • Loading branch information
theoludwig committed Nov 14, 2023
1 parent c9e25a8 commit e0ca31b
Show file tree
Hide file tree
Showing 34 changed files with 103 additions and 103 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,3 @@ jobs:

- name: 'Build'
run: 'npm run build'

- run: 'npm run build:typescript'
2 changes: 0 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ jobs:
- name: 'Build'
run: 'npm run build'

- run: 'npm run build:typescript'

- name: 'Verify the integrity of provenance attestations and registry signatures for installed dependencies'
run: 'npm audit signatures'

Expand Down
1 change: 0 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@

npm run lint:staged
npm run build
npm run build:typescript
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@
"!**/*.test.js",
"!**/*.map"
],
"imports": {
"#src/*": "./build/*"
},
"main": "build/index.js",
"bin": {
"leon": "build/index.js"
},
"scripts": {
"build": "rimraf ./build && swc ./src --out-dir ./build",
"build": "rimraf ./build && swc ./src --out-dir ./build && tsc",
"build:dev": "swc ./src --out-dir ./build --watch",
"build:typescript": "tsc",
"start": "node --enable-source-maps build/index.js",
"lint:commit": "commitlint",
"lint:editorconfig": "editorconfig-checker",
Expand Down
20 changes: 10 additions & 10 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Builtins, Cli } from 'clipanion'

import { Leon } from './services/Leon.js'
import { packageJSON } from './packageJSON.js'
import { CreateBirthCommand } from './commands/create/birth.js'
import { CheckCommand } from './commands/check.js'
import { HelpCommand } from './commands/help.js'
import { InfoCommand } from './commands/info.js'
import { DeleteCommand } from './commands/delete.js'
import { RunCommand } from './commands/run.js'
import { StartCommand } from './commands/start.js'
import { UpdateCommand } from './commands/update.js'
import { Leon } from '#src/services/Leon.js'
import { packageJSON } from '#src/packageJSON.js'
import { CreateBirthCommand } from '#src/commands/create/birth.js'
import { CheckCommand } from '#src/commands/check.js'
import { HelpCommand } from '#src/commands/help.js'
import { InfoCommand } from '#src/commands/info.js'
import { DeleteCommand } from '#src/commands/delete.js'
import { RunCommand } from '#src/commands/run.js'
import { StartCommand } from '#src/commands/start.js'
import { UpdateCommand } from '#src/commands/update.js'

export const cli = new Cli({
binaryLabel: Leon.NAME,
Expand Down
4 changes: 2 additions & 2 deletions src/commands/__test__/check.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import test from 'node:test'
import assert from 'node:assert/strict'

import { cli } from '../../cli.js'
import { CheckCommand } from '../check.js'
import { cli } from '#src/cli.js'
import { CheckCommand } from '#src/commands/check.js'

await test('leon check', async (t) => {
await t.test('should be instance of the command', async () => {
Expand Down
16 changes: 8 additions & 8 deletions src/commands/__test__/delete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import sinon from 'sinon'
import fsMock from 'mock-fs'
import chalk from 'chalk'

import { cli } from '../../cli.js'
import { DeleteCommand } from '../delete.js'
import type { ConfigData } from '../../services/Config.js'
import { config } from '../../services/Config.js'
import type { LeonInstanceOptions } from '../../services/LeonInstance.js'
import { LeonInstance } from '../../services/LeonInstance.js'
import { isExistingPath } from '../../utils/isExistingPath.js'
import { Log } from '../../services/Log.js'
import { cli } from '#src/cli.js'
import { DeleteCommand } from '#src/commands/delete.js'
import type { ConfigData } from '#src/services/Config.js'
import { config } from '#src/services/Config.js'
import type { LeonInstanceOptions } from '#src/services/LeonInstance.js'
import { LeonInstance } from '#src/services/LeonInstance.js'
import { isExistingPath } from '#src/utils/isExistingPath.js'
import { Log } from '#src/services/Log.js'

await test('leon delete', async (t) => {
t.afterEach(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/__test__/help.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import test from 'node:test'
import assert from 'node:assert/strict'

import { HelpCommand } from '../help.js'
import { cli } from '../../cli.js'
import { HelpCommand } from '#src/commands/help.js'
import { cli } from '#src/cli.js'

await test('leon help', async (t) => {
await t.test('should be instance of the command', async () => {
Expand Down
16 changes: 8 additions & 8 deletions src/commands/__test__/info.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import chalk from 'chalk'
import { table } from 'table'
import date from 'date-and-time'

import { cli } from '../../cli.js'
import { InfoCommand } from '../info.js'
import type { ConfigData } from '../../services/Config.js'
import { config } from '../../services/Config.js'
import type { LeonInstanceOptions } from '../../services/LeonInstance.js'
import { LeonInstance } from '../../services/LeonInstance.js'
import { Log } from '../../services/Log.js'
import { isExistingPath } from '../../utils/isExistingPath.js'
import { cli } from '#src/cli.js'
import { InfoCommand } from '#src/commands/info.js'
import type { ConfigData } from '#src/services/Config.js'
import { config } from '#src/services/Config.js'
import type { LeonInstanceOptions } from '#src/services/LeonInstance.js'
import { LeonInstance } from '#src/services/LeonInstance.js'
import { Log } from '#src/services/Log.js'
import { isExistingPath } from '#src/utils/isExistingPath.js'

const leonInstanceOptions: LeonInstanceOptions = {
name: 'random-name',
Expand Down
4 changes: 2 additions & 2 deletions src/commands/__test__/run.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import test from 'node:test'
import assert from 'node:assert/strict'

import { RunCommand } from '../run.js'
import { cli } from '../../cli.js'
import { RunCommand } from '#src/commands/run.js'
import { cli } from '#src/cli.js'

await test('leon run', async (t) => {
await t.test('should be instance of the command', async () => {
Expand Down
14 changes: 7 additions & 7 deletions src/commands/__test__/start.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import sinon from 'sinon'
import fsMock from 'mock-fs'
import chalk from 'chalk'

import { StartCommand } from '../start.js'
import { cli } from '../../cli.js'
import type { ConfigData } from '../../services/Config.js'
import { config } from '../../services/Config.js'
import type { LeonInstanceOptions } from '../../services/LeonInstance.js'
import { LeonInstance } from '../../services/LeonInstance.js'
import { isExistingPath } from '../../utils/isExistingPath.js'
import { StartCommand } from '#src/commands/start.js'
import { cli } from '#src/cli.js'
import type { ConfigData } from '#src/services/Config.js'
import { config } from '#src/services/Config.js'
import type { LeonInstanceOptions } from '#src/services/LeonInstance.js'
import { LeonInstance } from '#src/services/LeonInstance.js'
import { isExistingPath } from '#src/utils/isExistingPath.js'

const leonInstanceOptions: LeonInstanceOptions = {
name: 'random-name',
Expand Down
4 changes: 2 additions & 2 deletions src/commands/__test__/update.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import test from 'node:test'
import assert from 'node:assert/strict'

import { UpdateCommand } from '../update.js'
import { cli } from '../../cli.js'
import { UpdateCommand } from '#src/commands/update.js'
import { cli } from '#src/cli.js'

await test('leon update', async (t) => {
await t.test('should be instance of the command', async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/check.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Command, Option } from 'clipanion'

import { LeonInstance } from '../services/LeonInstance.js'
import { Log } from '../services/Log.js'
import { LeonInstance } from '#src/services/LeonInstance.js'
import { Log } from '#src/services/Log.js'

export class CheckCommand extends Command {
public static override paths = [['check']]
Expand Down
4 changes: 2 additions & 2 deletions src/commands/create/__test__/birth.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import test from 'node:test'
import assert from 'node:assert/strict'

import { cli } from '../../../cli.js'
import { CreateBirthCommand } from '../birth.js'
import { cli } from '#src/cli.js'
import { CreateBirthCommand } from '#src/commands/create/birth.js'

await test('leon create birth', async (t) => {
await t.test('should be instance of the command', async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/create/birth.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Command, Option } from 'clipanion'
import chalk from 'chalk'

import { Leon } from '../../services/Leon.js'
import { Log } from '../../services/Log.js'
import { Leon } from '#src/services/Leon.js'
import { Log } from '#src/services/Log.js'

export class CreateBirthCommand extends Command {
public static override paths = [['create', 'birth']]
Expand Down
6 changes: 3 additions & 3 deletions src/commands/delete.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Command, Option } from 'clipanion'

import { LeonInstance } from '../services/LeonInstance.js'
import { Log } from '../services/Log.js'
import { Prompt } from '../services/Prompt.js'
import { LeonInstance } from '#src/services/LeonInstance.js'
import { Log } from '#src/services/Log.js'
import { Prompt } from '#src/services/Prompt.js'

export class DeleteCommand extends Command {
public static override paths = [['delete']]
Expand Down
6 changes: 3 additions & 3 deletions src/commands/info.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Command, Option } from 'clipanion'
import chalk from 'chalk'

import { config } from '../services/Config.js'
import { LeonInstance } from '../services/LeonInstance.js'
import { Log } from '../services/Log.js'
import { config } from '#src/services/Config.js'
import { LeonInstance } from '#src/services/LeonInstance.js'
import { Log } from '#src/services/Log.js'

export class InfoCommand extends Command {
public static override paths = [['info']]
Expand Down
8 changes: 4 additions & 4 deletions src/commands/run.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Command, Option } from 'clipanion'
import { execaCommand } from 'execa'

import { LeonInstance } from '../services/LeonInstance.js'
import { Log } from '../services/Log.js'
import { CheckCommand } from './check.js'
import { StartCommand } from './start.js'
import { LeonInstance } from '#src/services/LeonInstance.js'
import { Log } from '#src/services/Log.js'
import { CheckCommand } from '#src/commands/check.js'
import { StartCommand } from '#src/commands/start.js'

interface Builtin {
[key: string]: (leonInstance: LeonInstance) => Promise<void>
Expand Down
4 changes: 2 additions & 2 deletions src/commands/start.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as typanion from 'typanion'
import { Command, Option } from 'clipanion'

import { LeonInstance } from '../services/LeonInstance.js'
import { Log } from '../services/Log.js'
import { LeonInstance } from '#src/services/LeonInstance.js'
import { Log } from '#src/services/Log.js'

export class StartCommand extends Command {
public static override paths = [['start']]
Expand Down
6 changes: 3 additions & 3 deletions src/commands/update.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Command, Option } from 'clipanion'
import chalk from 'chalk'

import { Leon } from '../services/Leon.js'
import { LeonInstance } from '../services/LeonInstance.js'
import { Log } from '../services/Log.js'
import { Leon } from '#src/services/Leon.js'
import { LeonInstance } from '#src/services/LeonInstance.js'
import { Log } from '#src/services/Log.js'

export class UpdateCommand extends Command {
public static override paths = [['update']]
Expand Down
10 changes: 5 additions & 5 deletions src/e2e/classic.test.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { test1CreateBirth } from './tests/1-create-birth.js'
import { test2Update } from './tests/2-update.js'
import { test3Start } from './tests/3-start.js'
import { test4Check } from './tests/4-check.js'
import { test5Run } from './tests/5-run.js'
import { test1CreateBirth } from '#src/e2e/tests/1-create-birth.js'
import { test2Update } from '#src/e2e/tests/2-update.js'
import { test3Start } from '#src/e2e/tests/3-start.js'
import { test4Check } from '#src/e2e/tests/4-check.js'
import { test5Run } from '#src/e2e/tests/5-run.js'

await test1CreateBirth()
await test2Update()
Expand Down
8 changes: 4 additions & 4 deletions src/e2e/docker.test.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test1CreateBirth } from './tests/1-create-birth.js'
import { test2Update } from './tests/2-update.js'
import { test3Start } from './tests/3-start.js'
import { test4Check } from './tests/4-check.js'
import { test1CreateBirth } from '#src/e2e/tests/1-create-birth.js'
import { test2Update } from '#src/e2e/tests/2-update.js'
import { test3Start } from '#src/e2e/tests/3-start.js'
import { test4Check } from '#src/e2e/tests/4-check.js'

await test1CreateBirth({ useDocker: true })
await test2Update()
Expand Down
4 changes: 2 additions & 2 deletions src/e2e/tests/1-create-birth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import path from 'node:path'

import { execa } from 'execa'

import { Leon } from '../../services/Leon.js'
import { isExistingPath } from '../../utils/isExistingPath.js'
import { Leon } from '#src/services/Leon.js'
import { isExistingPath } from '#src/utils/isExistingPath.js'

interface Options {
useDocker?: boolean
Expand Down
2 changes: 1 addition & 1 deletion src/e2e/tests/2-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import path from 'node:path'

import { execa } from 'execa'

import { LeonInstance } from '../../services/LeonInstance.js'
import { LeonInstance } from '#src/services/LeonInstance.js'

const TWENTY_MINUTES = 20 * 60 * 1000

Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import { Cli } from 'clipanion'
import updateNotifier from 'update-notifier'

import { cli } from './cli.js'
import { packageJSON } from './packageJSON.js'
import { cli } from '#src/cli.js'
import { packageJSON } from '#src/packageJSON.js'

const [, , ...arguments_] = process.argv

Expand Down
2 changes: 1 addition & 1 deletion src/services/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Conf from 'conf'
import type { Static } from '@sinclair/typebox'
import { Type } from '@sinclair/typebox'

import { packageJSON } from '../packageJSON.js'
import { packageJSON } from '#src/packageJSON.js'

export const instanceModes = [Type.Literal('classic'), Type.Literal('docker')]

Expand Down
10 changes: 5 additions & 5 deletions src/services/Leon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import ora from 'ora'
import { simpleGit, CheckRepoActions } from 'simple-git'
import { readPackage } from 'read-pkg'

import { isExistingPath } from '../utils/isExistingPath.js'
import { LeonInstance } from './LeonInstance.js'
import { LogError } from '../utils/LogError.js'
import { Requirements } from './Requirements.js'
import { config } from './Config.js'
import { isExistingPath } from '#src/utils/isExistingPath.js'
import { LeonInstance } from '#src/services/LeonInstance.js'
import { LogError } from '#src/utils/LogError.js'
import { Requirements } from '#src/services/Requirements.js'
import { config } from '#src/services/Config.js'

export interface LeonOptions {
useDevelopGitBranch?: boolean
Expand Down
8 changes: 4 additions & 4 deletions src/services/LeonInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { readPackage } from 'read-pkg'
import { table } from 'table'
import chalk from 'chalk'

import { config } from './Config.js'
import { LogError } from '../utils/LogError.js'
import { isExistingPath } from '../utils/isExistingPath.js'
import type { Leon } from './Leon.js'
import { config } from '#src/services/Config.js'
import { LogError } from '#src/utils/LogError.js'
import { isExistingPath } from '#src/utils/isExistingPath.js'
import type { Leon } from '#src/services/Leon.js'

export type InstanceType = 'classic' | 'docker'

Expand Down
4 changes: 2 additions & 2 deletions src/services/Log.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Conf from 'conf'
import chalk from 'chalk'

import { LogError } from '../utils/LogError.js'
import { Leon } from './Leon.js'
import { LogError } from '#src/utils/LogError.js'
import { Leon } from '#src/services/Leon.js'
import { packageJSON } from '../packageJSON.js'

interface LogErrorOptions {
Expand Down
8 changes: 4 additions & 4 deletions src/services/__test__/LeonInstance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import assert from 'node:assert/strict'

import fsMock from 'mock-fs'

import type { ConfigData } from '../Config.js'
import { config } from '../Config.js'
import type { LeonInstanceOptions } from '../LeonInstance.js'
import { LeonInstance } from '../LeonInstance.js'
import type { ConfigData } from '#src/services/Config.js'
import { config } from '#src/services/Config.js'
import type { LeonInstanceOptions } from '#src/services/LeonInstance.js'
import { LeonInstance } from '#src/services/LeonInstance.js'

const leonInstanceOptions: LeonInstanceOptions = {
name: 'random-name',
Expand Down
Loading

0 comments on commit e0ca31b

Please sign in to comment.