-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: working through the refactor
See #43
- Loading branch information
Showing
63 changed files
with
1,433 additions
and
429 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,28 @@ | ||
/// <reference types="vitest" /> | ||
import * as path from 'node:path'; | ||
import { defineConfig } from 'vite'; | ||
import { baseDir } from '../scripts/helpers.js'; | ||
import { loadJsonFile } from 'load-json-file'; | ||
import tsconfigPaths from 'vite-tsconfig-paths'; | ||
|
||
const config = defineConfig(async () => { | ||
return { | ||
test: { | ||
open: true, | ||
// rename `__snapshots__` to `snapshots` | ||
resolveSnapshotPath(testPath, snapExtension) { | ||
return path.join( | ||
path.dirname(testPath), | ||
'snapshots', | ||
`${path.basename(testPath)}${snapExtension}`, | ||
); | ||
}, | ||
const referenceTsConfig = await loadJsonFile<{ references: Array<{ path: string }> }>( | ||
baseDir('tsconfig.json'), | ||
); | ||
|
||
const projects = referenceTsConfig.references.map((reference) => | ||
path.join(reference.path, 'tsconfig.json'), | ||
); | ||
|
||
export default defineConfig({ | ||
plugins: [tsconfigPaths({ projects })], | ||
test: { | ||
// rename `__snapshots__` to `snapshots` | ||
resolveSnapshotPath(testPath, snapExtension) { | ||
return path.join( | ||
path.dirname(testPath), | ||
'snapshots', | ||
`${path.basename(testPath)}${snapExtension}`, | ||
); | ||
}, | ||
}; | ||
}, | ||
}); | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
{ | ||
"extends": "../packages/monots__tsconfig/tsconfig.json", | ||
"compilerOptions": { | ||
"skipLibCheck": true | ||
"skipLibCheck": true, | ||
"allowJs": true, | ||
"checkJs": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { loadConfig, NAME } from '@monots/core'; | ||
import type { CommandContext } from '@monots/types'; | ||
import { getPackageJsonSync } from '@monots/utils'; | ||
import { Builtins, Cli } from 'clipanion'; | ||
|
||
const { version, description = '', name } = getPackageJsonSync(); | ||
|
||
/** | ||
* Loads the `monots` configuration and uses it to register all commands. | ||
*/ | ||
export async function createCli() { | ||
const result = await loadConfig(); | ||
|
||
if (!result) { | ||
throw new Error('No configuration found for `monots`'); | ||
} | ||
|
||
const cli = new Cli<CommandContext>({ | ||
binaryLabel: description, | ||
binaryName: NAME, | ||
binaryVersion: version, | ||
}); | ||
|
||
cli.register(Builtins.HelpCommand); | ||
cli.register(Builtins.VersionCommand); | ||
} | ||
|
||
export const context: CommandContext = { | ||
internal: false, | ||
version, | ||
description, | ||
name, | ||
cwd: process.cwd(), | ||
stdin: process.stdin, | ||
stdout: process.stdout, | ||
stderr: process.stderr, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.