-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
48db048
commit 942b2e0
Showing
13 changed files
with
1,463 additions
and
925 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Check | ||
|
||
on: | ||
push: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.sha }}-${{ github.event_name }} | ||
cancel-in-progress: true | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
name: Check | ||
steps: | ||
- name: 'Fetch all required Git history' | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: Setup PNPM | ||
uses: pnpm/action-setup@v4 | ||
with: | ||
package_json_file: package.json | ||
|
||
- name: Setup Node.js environment | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: package.json | ||
cache: pnpm | ||
cache-dependency-path: pnpm-lock.yaml | ||
|
||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Check formatting | ||
run: pnpm run formatter:check | ||
|
||
- name: Run unit tests | ||
run: pnpm run test |
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,3 +1,4 @@ | ||
node_modules | ||
coverage | ||
dist | ||
.*cache |
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,4 @@ | ||
node_modules | ||
coverage | ||
dist | ||
.*cache |
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,21 @@ | ||
{ | ||
"printWidth": 120, | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"semi": true, | ||
"singleQuote": true, | ||
"quoteProps": "as-needed", | ||
"jsxSingleQuote": true, | ||
"trailingComma": "none", | ||
"bracketSpacing": true, | ||
"bracketSameLine": false, | ||
"arrowParens": "always", | ||
"requirePragma": false, | ||
"insertPragma": false, | ||
"proseWrap": "always", | ||
"htmlWhitespaceSensitivity": "css", | ||
"vueIndentScriptAndStyle": false, | ||
"endOfLine": "lf", | ||
"embeddedLanguageFormatting": "auto", | ||
"singleAttributePerLine": 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,85 @@ | ||
import { resolve } from "path"; | ||
import { build, LibraryOptions, resolveConfig, ResolvedConfig } from "vite"; | ||
import { resolve } from 'path'; | ||
import { build, LibraryOptions, resolveConfig, ResolvedConfig } from 'vite'; | ||
|
||
import { PackageJSON } from "@npm/types"; | ||
import { access, cp, readFile, writeFile } from "fs/promises"; | ||
import { PackageJSON } from '@npm/types'; | ||
import { access, cp, readFile, writeFile } from 'fs/promises'; | ||
|
||
const encoding: "utf-8" = "utf-8"; | ||
const encoding: 'utf-8' = 'utf-8'; | ||
const packageJsonKeysToKeep: Set<string | number> = new Set<keyof PackageJSON>([ | ||
"author", | ||
"bugs", | ||
"bundleDependencies", | ||
"bundledDependencies", | ||
"contributors", | ||
"dependencies", | ||
"description", | ||
"files", | ||
"funding", | ||
"homepage", | ||
"keywords", | ||
"license", | ||
"main", | ||
"man", | ||
"name", | ||
"optionalDependencies", | ||
"peerDependencies", | ||
"peerDependenciesMeta", | ||
"repository", | ||
"types", | ||
"version", | ||
'author', | ||
'bugs', | ||
'bundleDependencies', | ||
'bundledDependencies', | ||
'contributors', | ||
'dependencies', | ||
'description', | ||
'files', | ||
'funding', | ||
'homepage', | ||
'keywords', | ||
'license', | ||
'main', | ||
'man', | ||
'name', | ||
'optionalDependencies', | ||
'peerDependencies', | ||
'peerDependenciesMeta', | ||
'repository', | ||
'types', | ||
'version' | ||
]); | ||
|
||
(async () => { | ||
const configFile: string = resolve(__dirname, "vite.config.ts"); | ||
const configFile: string = resolve(__dirname, 'vite.config.ts'); | ||
await access(configFile); | ||
|
||
await build({ | ||
configFile, | ||
configFile | ||
}); | ||
|
||
const { | ||
build: { outDir, lib }, | ||
build: { outDir, lib } | ||
}: ResolvedConfig = await resolveConfig( | ||
{ | ||
configFile, | ||
configFile | ||
}, | ||
"build" | ||
'build' | ||
); | ||
if (typeof lib === "boolean") { | ||
throw new Error( | ||
"Vite config / build / lib is expected to be LibraryOptions" | ||
); | ||
if (typeof lib === 'boolean') { | ||
throw new Error('Vite config / build / lib is expected to be LibraryOptions'); | ||
} | ||
const { fileName }: LibraryOptions = lib; | ||
|
||
const licenseFileName: string = "LICENSE.md"; | ||
const licenseFileName: string = 'LICENSE.md'; | ||
const licenseFile: string = resolve(__dirname, licenseFileName); | ||
await access(licenseFile); | ||
await cp(licenseFile, resolve(__dirname, outDir, licenseFileName)); | ||
|
||
const readMeFileName: string = "README.md"; | ||
const readMeFileName: string = 'README.md'; | ||
const readMeFile: string = resolve(__dirname, readMeFileName); | ||
await access(readMeFile); | ||
await cp(readMeFile, resolve(__dirname, outDir, readMeFileName)); | ||
|
||
const packageJsonFile: string = resolve(__dirname, "package.json"); | ||
const packageJsonFile: string = resolve(__dirname, 'package.json'); | ||
const packageJson: PackageJSON = JSON.parse( | ||
await readFile(packageJsonFile, { | ||
encoding, | ||
encoding | ||
}) | ||
); | ||
const modifiedPackageJson: Record<string, unknown> = Object.fromEntries( | ||
Object.entries(packageJson).filter(([key]) => | ||
packageJsonKeysToKeep.has(key) | ||
) | ||
Object.entries(packageJson).filter(([key]) => packageJsonKeysToKeep.has(key)) | ||
); | ||
await writeFile( | ||
resolve(__dirname, outDir, "package.json"), | ||
resolve(__dirname, outDir, 'package.json'), | ||
JSON.stringify({ | ||
...modifiedPackageJson, | ||
main: `${fileName}.mjs`, | ||
browser: `${fileName}.mjs`, | ||
types: `${fileName}.d.ts`, | ||
license: "MIT", | ||
license: 'MIT' | ||
} satisfies Partial<PackageJSON>), | ||
{ | ||
encoding, | ||
encoding | ||
} | ||
); | ||
})(); |
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,18 +1,18 @@ | ||
import { createDefaultPreset, JestConfigWithTsJest } from "ts-jest"; | ||
import { createDefaultPreset, JestConfigWithTsJest } from 'ts-jest'; | ||
|
||
module.exports = { | ||
...createDefaultPreset({ | ||
tsconfig: "<rootDir>/tsconfig.test.json", | ||
tsconfig: '<rootDir>/tsconfig.test.json' | ||
}), | ||
roots: ["<rootDir>"], | ||
testEnvironment: "jsdom", | ||
roots: ['<rootDir>'], | ||
testEnvironment: 'jsdom', | ||
collectCoverage: true, | ||
coverageThreshold: { | ||
global: { | ||
branches: 100, | ||
functions: 100, | ||
lines: 100, | ||
statements: 100, | ||
}, | ||
}, | ||
statements: 100 | ||
} | ||
} | ||
} satisfies JestConfigWithTsJest; |
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.