generated from AthennaIO/Template
-
-
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.
Merge pull request #75 from AthennaIO/develop
Move project to TS
- Loading branch information
Showing
78 changed files
with
3,310 additions
and
12,075 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
github: [jlenon7, txsoura] | ||
open_collective: athennaio |
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ on: | |
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-18.04 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
@@ -20,9 +20,20 @@ jobs: | |
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Transpile code | ||
run: npm run build | ||
|
||
- name: Install jq | ||
run: sudo apt-get -y install jq | ||
|
||
- name: Change import aliases to build | ||
run: jq '.imports."#src"="./build/index.js" | .imports."#src/*"="./build/*.js"' package.json > tmp.json && mv tmp.json package.json | ||
|
||
- name: Automatic GitHub Release | ||
uses: justincy/[email protected] | ||
id: release | ||
|
||
- name: Publish to NPM Registry | ||
run: npm publish --access public | ||
if: steps.release.outputs.released == '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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* @athenna/test | ||
* | ||
* (c) João Lenon <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
import { Path, File, Exec } from '@athenna/common' | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| TypeScript build file path | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Where the TypeScript build file will be saved. | ||
*/ | ||
|
||
const path = Path.nodeModules('@athenna/tsconfig.build.json') | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| TypeScript Config | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Create the tsconfig file for building the project. | ||
*/ | ||
|
||
const tsconfig = await new File('../tsconfig.json').getContentAsJson() | ||
|
||
delete tsconfig['ts-node'] | ||
|
||
tsconfig.compilerOptions.rootDir = '../../src' | ||
tsconfig.compilerOptions.outDir = '../../build' | ||
|
||
tsconfig.include = ['../../src'] | ||
tsconfig.exclude = ['../../bin', '../../node_modules', '../../tests'] | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Compilation | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Saving the file in some path, deleting old "build" folder, executing | ||
| compilation and deleting the tsconfig file generated. | ||
*/ | ||
|
||
const file = new File(path, '') | ||
await file.setContent(JSON.stringify(tsconfig)) | ||
await Exec.command(`rimraf ../build && tsc --project ${path}`) | ||
await file.remove() |
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,91 @@ | ||
/** | ||
* @athenna/test | ||
* | ||
* (c) João Lenon <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
import { Importer } from '#src' | ||
import { assert } from '@japa/assert' | ||
import { specReporter } from '@japa/spec-reporter' | ||
import { configure, processCliArgs, run } from '@japa/runner' | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Japa types | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Declare customized japa types. | ||
*/ | ||
|
||
declare module '@japa/assert' { | ||
export interface Assert { | ||
throws(fn: () => any, errType: any, message?: string): void | ||
doesNotThrows(fn: () => any, errType: any, message?: string): void | ||
rejects( | ||
fn: () => any | Promise<any>, | ||
errType: any, | ||
message?: string, | ||
): Promise<any> | ||
doesNotRejects( | ||
fn: () => any | Promise<any>, | ||
errType: any, | ||
message?: string, | ||
): Promise<any> | ||
} | ||
} | ||
|
||
declare module '@japa/runner' { | ||
interface TestContext { | ||
assert: import('@japa/assert').Assert | ||
} | ||
} | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Set IS_TS env. | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Set the IS_TS environement variable to true. Very useful when using the | ||
| Path helper. | ||
*/ | ||
|
||
process.env.IS_TS = 'true' | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Configure tests | ||
|-------------------------------------------------------------------------- | ||
| | ||
| The configure method accepts the configuration to configure the Japa | ||
| tests runner. | ||
| | ||
| The first method call "processCliArgs" process the command line arguments | ||
| and turns them into a config object. Using this method is not mandatory. | ||
| | ||
| Please consult japa.dev/runner-config for the config docs. | ||
*/ | ||
|
||
configure({ | ||
...processCliArgs(process.argv.slice(2)), | ||
...{ | ||
files: ['tests/**/*Test.ts'], | ||
plugins: [assert()], | ||
reporters: [specReporter()], | ||
importer: Importer.import, | ||
}, | ||
timeout: 10000, | ||
}) | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Run tests | ||
|-------------------------------------------------------------------------- | ||
| | ||
| The following "run" method is required to execute all the tests. | ||
| | ||
*/ | ||
|
||
run() |
Oops, something went wrong.