Skip to content

Commit

Permalink
with retro 3
Browse files Browse the repository at this point in the history
  • Loading branch information
bguerout committed Dec 10, 2023
1 parent 5292385 commit 31985ad
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 22 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ jobs:
- run: npm test
- run: npm run lint
- run: npm run build
- run: tar -czf build.tar.gz build/*
- uses: actions/upload-artifact@v3
with:
name: built-tests
path: dist/test/
name: built-project
path: build.tar.gz

test-legacy-versions:
runs-on: ubuntu-latest
Expand All @@ -31,10 +32,11 @@ jobs:
node-version: ${{ matrix.node-version }}
- uses: actions/download-artifact@v3
with:
name: built-tests
path: built-tests
- run: npm --prefix built-tests install
- run: npm --prefix built-tests test
name: built-project
path: build.tar.gz
- run: tar -xzf build.tar.gz -C build
- run: npm --prefix build install
- run: npm --prefix build test

coverage:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules/
.nyc_output/
.coverage/
.idea/
build/
dist/
21 changes: 12 additions & 9 deletions .tools/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,36 @@
set -euo pipefail

readonly PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.."
readonly BUILD_DIR="${PROJECT_DIR}/build"
readonly DIST_DIR="${PROJECT_DIR}/dist"

rm -rf "${PROJECT_DIR}/dist"
rm -rf "${DIST_DIR}" "${BUILD_DIR}"
mkdir -p "${DIST_DIR}" "${BUILD_DIR}"

cd "${PROJECT_DIR}"

echo "Building oleoduc (esm version)..."
echo "Compiling oleoduc (esm version)..."
tsc -p tsconfig.json
cat >"${PROJECT_DIR}/dist/mjs/package.json" <<!EOF
cat >"${DIST_DIR}/mjs/package.json" <<!EOF
{
"type": "module"
}
!EOF

echo "Building oleoduc (cjs version)..."
echo "Compiling oleoduc (cjs version)..."
tsc -p tsconfig.cjs.json
cat >"${PROJECT_DIR}/dist/cjs/package.json" <<!EOF
cat >"${DIST_DIR}/cjs/package.json" <<!EOF
{
"type": "commonjs"
}
!EOF

echo "Building oleoduc (test version)..."
echo "Building oleoduc for test..."
tsc -p tsconfig.test.json
echo "Patching package.json to be able to run tests against previous versions of nodejs..."
cp "${PROJECT_DIR}/package.json" "${PROJECT_DIR}/dist/test"
npx json -I -f "${PROJECT_DIR}/dist/test/package.json" -e 'this.scripts.test="mocha --recursive --exit test/**/*-test.js"'
npx json -I -f "${PROJECT_DIR}/dist/test/package.json" -e 'this.devDependencies.mocha="9.x"'
cp "${PROJECT_DIR}/package.json" "${BUILD_DIR}"
npx json -I -f "${BUILD_DIR}/package.json" -e 'this.scripts.test="mocha --recursive --exit test/**/*-test.js"'
npx json -I -f "${BUILD_DIR}/package.json" -e 'this.devDependencies.mocha="9.x"'

cd -

1 change: 0 additions & 1 deletion tsconfig.cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"moduleResolution": "node",
"module": "commonjs",
"target": "es2015",
"esModuleInterop": true,
"outDir": "./dist/cjs"
}
}
9 changes: 5 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
"compilerOptions": {
"moduleResolution": "NodeNext",
"module": "NodeNext",
"target": "esnext",
"outDir": "./dist/mjs",
"rootDirs": ["src"],
"types": ["node"],
"lib": ["esnext"],
"allowJs": true,
"strict": false,
"sourceMap": true,
"rootDirs": ["src"],
"target": "esnext",
"lib": ["esnext"],
"types": ["node"]
"esModuleInterop": true
},
"exclude": ["node_modules", "dist"],
"include": ["src"]
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "./tsconfig.cjs.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./dist/test",
"outDir": "./build",
"rootDirs": ["./test"],
"types": ["node", "mocha"]
},
Expand Down

0 comments on commit 31985ad

Please sign in to comment.