Skip to content

Commit

Permalink
Merge pull request #80 from AthennaIO/develop
Browse files Browse the repository at this point in the history
refactor(scripts): use scripts to build code
  • Loading branch information
jlenon7 authored Mar 22, 2023
2 parents 01999a8 + a9dc62c commit cbfaa63
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 92 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,8 @@ 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: Compile code
run: sh scripts/build

- name: Automatic GitHub Release
uses: justincy/[email protected]
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ jobs:
- name: Run tests
run: npm run test:coverage

- name: Test code transpilation
run: npm run build
- name: Test code compilation
run: sh scripts/build

windows:
runs-on: windows-latest
Expand All @@ -65,5 +65,5 @@ jobs:
- name: Run tests
run: npm run test:coverage

- name: Test code transpilation
run: npm run build
- name: Test code compilation
run: sh scripts/build
12 changes: 9 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,15 @@ out
.yarn/install-state.gz
.pnp.*

# Transpiled code path
dist
build
# Compiled code
./dist
./build
*.js
*.d.ts
*.js.map
!tests/Stubs/**/*.js
!tests/Stubs/**/*.d.ts
!tests/Stubs/**/*.js.map

# IDE
.idea
Expand Down
52 changes: 0 additions & 52 deletions bin/build.ts

This file was deleted.

22 changes: 22 additions & 0 deletions node
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# This file is useful for development purposes because
# it allows you to run TypeScript files without having
# to add the --loader option every time.

# Usage:

# ./node --version
# ./node bin/test.ts
# ./node --inspect bin/test.ts

# Usage with "sh" or "bash":

# sh node --version
# sh node bin/test.ts
# sh node --inspect bin/test.ts

# Node.js executable with all arguments required to run the application.
node="node --loader ts-node/esm --experimental-import-meta-resolve --no-warnings"

$node $@
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 17 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/test",
"version": "3.2.2",
"version": "3.2.3",
"description": "The Athenna test runner. Built on top of Japa.",
"license": "MIT",
"author": "João Lenon <[email protected]>",
Expand All @@ -10,39 +10,41 @@
"keywords": [
"esm",
"japa",
"testing",
"test-runner",
"classes",
"decorators",
"athenna"
],
"scripts": {
"node": "cross-env NODE_OPTIONS=\"--experimental-import-meta-resolve\" ts-node",
"build": "npm run node --silent -- bin/build.ts",
"lint:fix": "eslint \"{src,tests}/**/*.ts\" --fix",
"test": "npm run --silent lint:fix && npm run node --silent -- bin/test.ts",
"test:debug": "cross-env DEBUG=api:* npm run node --silent -- bin/test.ts --inspect",
"lint:fix": "eslint \"{bin,src,tests}/**/*.ts\" --fix",
"test": "npm run --silent lint:fix && sh node bin/test.ts",
"test:debug": "cross-env DEBUG=api:* sh node --inspect bin/test.ts",
"test:coverage": "c8 npm run --silent test"
},
"files": [
"build/*.js",
"build/*.d.ts",
"build/**/*.js",
"build/**/*.d.ts",
"templates/**"
"src/*.js",
"src/*.d.ts",
"src/**/*.js",
"src/**/*.d.ts",
"templates"
],
"type": "module",
"main": "./build/index.js",
"types": "./build/index.d.ts",
"main": "./src/index.js",
"types": "./src/index.d.ts",
"exports": {
".": "./build/index.js"
".": "./src/index.js"
},
"imports": {
"#bin/*": "./bin/*.js",
"#bin": "./bin/index.js",
"#src/*": "./src/*.js",
"#src": "./src/index.js",
"#tests/*": "./tests/*.js",
"#tests": "./tests/index.js"
},
"devDependencies": {
"@athenna/common": "^3.3.1",
"@athenna/common": "^3.4.4",
"@japa/assert": "^1.3.6",
"@japa/run-failed-tests": "^1.1.0",
"@japa/runner": "^2.2.2",
Expand Down
5 changes: 5 additions & 0 deletions scripts/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

sh scripts/clean

./node_modules/.bin/tsc --project scripts/tsconfig.build.json
4 changes: 4 additions & 0 deletions scripts/clean
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

find src -name "*.js" -type f -delete
find src -name "*.d.ts" -type f -delete
5 changes: 5 additions & 0 deletions scripts/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "../tsconfig.json",
"include": ["../**/*"],
"exclude": ["../bin", "../build", "../tests", "../scripts", "../node_modules"]
}
15 changes: 11 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@
"compilerOptions": {
"strict": false,
"rootDir": ".",
"outDir": "build",
"module": "ESNext",
"baseUrl": ".",
"outDir": ".",
"module": "NodeNext",
"target": "ESNext",
"declaration": true,
"skipLibCheck": true,
"esModuleInterop": true,
"removeComments": false,
"resolveJsonModule": true,
"experimentalDecorators": true,
"moduleResolution": "NodeNext",
"experimentalDecorators": true
"paths": {
"#bin/*": ["./bin/*.ts"],
"#src/*": ["./src/*.ts"],
"#tests/*": ["./tests/*.ts"]
}
},
"exclude": ["node_modules"]
"include": ["./**/*"],
"exclude": ["build", "node_modules"]
}

0 comments on commit cbfaa63

Please sign in to comment.