Skip to content

Commit

Permalink
chore: refactor project architecture
Browse files Browse the repository at this point in the history
- closes #651

Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
  • Loading branch information
unicornware committed Nov 1, 2024
1 parent 4495eed commit 484eebf
Show file tree
Hide file tree
Showing 25 changed files with 199 additions and 549 deletions.
8 changes: 6 additions & 2 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
---
codecov:
notify:
after_n_builds: 3
after_n_builds: 2
wait_for_ci: true
require_ci_to_pass: true

comment:
after_n_builds: 3
after_n_builds: 2
behavior: default
layout: header,diff,flags,components,tree,footer
require_base: false
Expand Down Expand Up @@ -80,6 +80,10 @@ coverage:
threshold: 0%

flags:
node23:
carryforward: false
paths:
- src/
node22:
carryforward: false
paths:
Expand Down
1 change: 0 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"failFast": false,
"flagWords": [],
"ignorePaths": [
"!scratch.*",
"**/*.patch",
"**/*.snap",
"**/*.wasm",
Expand Down
1 change: 0 additions & 1 deletion .dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jchen
kaisugi
ksort
lcov
lintstagedrc
mkbuild
mlly
nocheck
Expand Down
6 changes: 3 additions & 3 deletions .dprint.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
"exec": {
"commands": [
{
"command": "node ./dprint/prettier.mjs {{file_path}}",
"command": "node --experimental-strip-types --experimental-transform-types ./dprint/prettier.mts {{file_path}}",
"exts": ["css", "html", "json5", "scss", "yaml", "yml"],
"stdin": true
},
{
"command": "node ./dprint/remark.mjs {{file_path}}",
"command": "node --experimental-strip-types --experimental-transform-types ./dprint/remark.mts {{file_path}}",
"exts": ["md", "mdx"],
"stdin": true
},
{
"command": "node ./dprint/shfmt.mjs {{file_path}}",
"command": "node --experimental-strip-types --experimental-transform-types ./dprint/shfmt.mts {{file_path}}",
"exts": ["sh", "zsh"],
"fileNames": [
".editorconfig",
Expand Down
7 changes: 3 additions & 4 deletions .github/infrastructure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ branches:
- context: lint
- context: spelling
- context: test (22)
- context: typescript (5.0.4)
- context: typescript (5.4.5)
- context: typescript (5.5.4)
- context: typescript (5.6.2)
- context: test (23)
- context: typescript (5.6.3)
- context: typescript (5.7.0-beta)
strict: true
restrictions: null
environments:
Expand Down
25 changes: 18 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,10 @@ jobs:
matrix:
typescript-version:
- ${{ needs.preflight.outputs.version-typescript }}
- 5.5.4
- 5.4.5
- 5.0.4
- 5.6.3
env:
TYPESCRIPT_VERSION: ${{ matrix.typescript-version }}
VITEST_REPORT: ./.vitest-reports/typecheck.blob.json
if: ${{ fromJson(needs.preflight.outputs.typecheck-files) }}
steps:
- id: checkout
Expand All @@ -282,14 +283,21 @@ jobs:
key: ${{ needs.preflight.outputs.cache-key }}
path: ${{ env.CACHE_PATH }}
- id: typescript
name: Install typescript@${{ matrix.typescript-version }}
run: yarn add -D typescript@${{ matrix.typescript-version }}
name: Install typescript@${{ env.TYPESCRIPT_VERSION }}
run: yarn add -D typescript@${{ env.TYPESCRIPT_VERSION }}
- id: print-typescript-version
name: Print TypeScript version
run: jq .devDependencies.typescript package.json -r
- id: typecheck
name: Run typecheck
run: yarn typecheck
- id: report
name: Upload report
uses: actions/upload-artifact@v4.4.3
with:
name: |
${{ format('typecheck-{0}-{1}-{2}.blob.json', env.TYPESCRIPT_VERSION, github.event.repository.name, env.SHA) }}
path: ${{ env.VITEST_REPORT }}
test:
needs:
- commitlint
Expand All @@ -300,9 +308,11 @@ jobs:
fail-fast: false
matrix:
node-version:
- 23
- 22
env:
COVERAGE_SUMMARY: ./coverage/coverage-summary.json
NODE_VERSION: ${{ matrix.node-version }}
PCT: .total.branches.pct + .total.functions.pct + .total.lines.pct + .total.statements.pct
VITEST_REPORT: ./.vitest-reports/test.blob.json
if: ${{ fromJson(needs.preflight.outputs.test-files) }}
Expand Down Expand Up @@ -336,14 +346,15 @@ jobs:
name: Upload report
uses: actions/upload-artifact@v4.4.3
with:
name: ${{ format('vitest-report-{0}-{1}.json', github.event.repository.name, env.SHA) }}
name: |
${{ format('test-{0}-{1}-{2}.blob.json', env.NODE_VERSION, github.event.repository.name, env.SHA) }}
path: ${{ env.VITEST_REPORT }}
- id: coverage-summary
name: Upload coverage summary
uses: actions/upload-artifact@v4.4.3
with:
name: |
${{ format('coverage-summary-{0}-{1}.json', github.event.repository.name, env.SHA) }}
${{ format('coverage-summary-{0}-{1}-{2}.json', env.NODE_VERSION, github.event.repository.name, env.SHA) }}
path: ${{ env.COVERAGE_SUMMARY }}
- id: codecov
name: Upload coverage report to Codecov
Expand Down
11 changes: 0 additions & 11 deletions .husky/pre-commit

This file was deleted.

14 changes: 0 additions & 14 deletions .lintstagedrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
22.9.0
23
2 changes: 0 additions & 2 deletions .remarkrc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ import remarkLintNoUndefinedReferences from 'remark-lint-no-undefined-references
import remarkLintNoUnneededFullReferenceImage from 'remark-lint-no-unneeded-full-reference-image'
import remarkLintNoUnneededFullReferenceLink from 'remark-lint-no-unneeded-full-reference-link'
import remarkLintNoUnusedDefinitions from 'remark-lint-no-unused-definitions'
import remarkLintNoTrailingSlash from 'remark-lint-no-url-trailing-slash'
import remarkLintOrderedListMarkerStyle from 'remark-lint-ordered-list-marker-style'
import remarkLintOrderedListMarkerValue from 'remark-lint-ordered-list-marker-value'
import remarkLintRuleStyle from 'remark-lint-rule-style'
Expand Down Expand Up @@ -130,7 +129,6 @@ const lint = {
remarkLintNoShortcutReferenceLink,
remarkLintNoTableIndentation,
remarkLintNoTabs,
remarkLintNoTrailingSlash,
remarkLintNoUndefinedReferences,
remarkLintNoUnneededFullReferenceImage,
remarkLintNoUnneededFullReferenceLink,
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
"*.log": "log",
"*.snap": "jest-snapshot",
".env.zsh": "shellscript",
"*.map": "json",
".npmrc": "ini",
".remarkignore": "ignore",
"commit-msg": "shellscript",
Expand Down
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ enableTransparentWorkspaces: false

injectEnvironmentFiles:
- .env.repo?
- .env.vars?

nmHoistingLimits: dependencies

Expand Down
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,13 @@ Be sure to use [`it.skip`][vitest-test-skip] or [`it.todo`][vitest-test-todo] wh
#### Running Tests
- `yarn test`
- `yarn test:reports`
- `yarn test:ui`
- `yarn test:cov`
- `yarn test:cov:reports`
- `yarn test:cov:ui`
- `yarn typecheck`
- `yarn typecheck:ui`
#### Code Coverage
Expand Down
10 changes: 4 additions & 6 deletions build.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@
*/

import { defineBuildConfig, type Config } from '@flex-development/mkbuild'
import tsconfig from './tsconfig.build.json' assert { type: 'json' }
import tsconfig from './tsconfig.build.json' with { type: 'json' }

/**
* Build configuration options.
* Build config.
*
* @const {Config} config
* @type {Config}
*/
const config: Config = defineBuildConfig({
export default defineBuildConfig({
charset: 'utf8',
entries: [],
target: ['node18', tsconfig.compilerOptions.target],
tsconfig: 'tsconfig.build.json'
})

export default config
22 changes: 14 additions & 8 deletions dprint/prettier.mjs → dprint/prettier.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
* @module dprint/prettier
*/

import { includes } from '@flex-development/tutils'
import { ok } from 'devlop'
import editorconfig from 'editorconfig'
import { Transform } from 'node:stream'
import * as prettier from 'prettier'

declare module 'editorconfig' {
interface KnownProps {
max_line_length?: number | undefined
single_attribute_per_line?: boolean | undefined
}
}

process.stdin.pipe(new Transform({
/**
* Formats a file using `prettier`.
Expand All @@ -21,8 +28,9 @@ process.stdin.pipe(new Transform({
* @return {Promise<string>}
* Formatted file content
*/
async transform(buffer) {
async transform(buffer: Buffer): Promise<string> {
const [filepath] = process.argv.slice(2)
ok(typeof filepath === 'string', 'expected `filepath`')

const {
end_of_line = 'lf',
Expand All @@ -38,10 +46,9 @@ process.stdin.pipe(new Transform({
/**
* Formatted text.
*
* @type {string}
* @const text
* @const {string} text
*/
const text = await prettier.format(buffer.toString(), {
const text: string = await prettier.format(buffer.toString(), {
arrowParens: 'avoid',
bracketSpacing: spaces_around_brackets === 'inside',
endOfLine: end_of_line === 'unset' ? 'auto' : end_of_line,
Expand All @@ -55,10 +62,9 @@ process.stdin.pipe(new Transform({
singleQuote: quote_type === 'single',
tabWidth: tab_width === 'unset' ? 2 : tab_width,
trailingComma: 'none',
useTabs: includes([indent_size, indent_style], 'tab')
useTabs: [indent_size, indent_style].includes('tab')
})

process.stdout.write(text)
return text
return process.stdout.write(text), text
}
}))
14 changes: 7 additions & 7 deletions dprint/remark.mjs → dprint/remark.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* @module dprint/remark
*/

import { ok } from 'devlop'
import { Transform } from 'node:stream'
import remarkParse from 'remark-parse'
import remarkStringify from 'remark-stringify'
Expand All @@ -23,24 +24,23 @@ process.stdin.pipe(new Transform({
* @return {Promise<string>}
* Formatted file content
*/
async transform(buffer) {
async transform(buffer: Buffer): Promise<string> {
/**
* Virtual file.
*
* @type {VFile}
* @const file
* @const {VFile} file
*/
const file = new VFile(buffer.toString())
const file: VFile = new VFile(buffer.toString())

file.path = process.argv.slice(2)[0]
file.path = process.argv.slice(2)[0]!

await unified()
.use(remarkParse)
.use(remarkPreset)
.use(remarkStringify)
.process(file)

process.stdout.write(file.value)
return file.value
ok(typeof file.value === 'string', 'expected `file.value` to be a string')
return process.stdout.write(file.value), file.value
}
}))
Loading

0 comments on commit 484eebf

Please sign in to comment.