-
Notifications
You must be signed in to change notification settings - Fork 0
TypeScript Rewrite: Build setup #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
d4mation
wants to merge
17
commits into
base/ENG-219/typescript-rewrite
Choose a base branch
from
ENG-219/build-setup
base: base/ENG-219/typescript-rewrite
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
293de18
ENG-219: Add TypeScript build setup
d4mation 686de67
ENG-219: Add lint and test GitHub Actions workflows
d4mation 69dcc4d
ENG-219: Add --passWithNoTests flag to jest script
d4mation 829a32e
ENG-219: Add --no-error-on-unmatched-pattern flag to eslint script
d4mation 48a5e67
ENG-219: Skip typecheck when no TypeScript source files exist
d4mation 98fc424
ENG-219: Add build step before running tests in CI
d4mation 6f8e6c4
ENG-219: Add npm caching to CI workflows
d4mation 986ff48
Revert "ENG-219: Add npm caching to CI workflows"
d4mation df95ee5
Revert "ENG-219: Add build step before running tests in CI"
d4mation cf9fde7
ENG-219: Switch from package-lock.json to bun.lock
d4mation 67488c8
ENG-219: Switch CI workflows from npm/Node to bun
d4mation 6b2cb5b
ENG-219: Fix test command in CI workflow
d4mation 8188393
Apply suggestions from code review
d4mation dc06445
ENG-219: Address PR #29 review feedback
d4mation 03b4edc
ENG-219: Switch bundler from tsup to tsdown
d4mation 1c9f3aa
ENG-219: Use .js extension for tsdown ESM output
d4mation b873683
ENG-219: Target Node 20 instead of Node 24
d4mation File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,11 +1,6 @@ | ||
| # To get started with Dependabot version updates, you'll need to specify which | ||
| # package ecosystems to update and where the package manifests are located. | ||
| # Please see the documentation for all configuration options: | ||
| # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
|
||
| version: 2 | ||
| updates: | ||
| - package-ecosystem: "composer" # See documentation for possible values | ||
| directory: "/" # Location of package manifests | ||
| - package-ecosystem: "npm" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" |
This file contains hidden or 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,17 @@ | ||
| name: Lint & Typecheck | ||
| on: [push, pull_request] | ||
| jobs: | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: oven-sh/setup-bun@v2 | ||
| - run: bun install --frozen-lockfile | ||
| - run: bun run lint | ||
| - name: Typecheck | ||
| run: | | ||
| if ls src/**/*.ts >/dev/null 2>&1; then | ||
| bun run typecheck | ||
| else | ||
| echo "No TypeScript source files found, skipping typecheck" | ||
| fi |
This file contains hidden or 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,10 @@ | ||
| name: Tests | ||
| on: [push, pull_request] | ||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: oven-sh/setup-bun@v2 | ||
| - run: bun install --frozen-lockfile | ||
| - run: bun run test |
This file contains hidden or 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 hidden or 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 @@ | ||
| 20 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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,14 @@ | ||
| import tseslint from 'typescript-eslint'; | ||
|
|
||
| export default [ | ||
| ...tseslint.configs.recommended, | ||
| { | ||
| ignores: ['dist/', 'node_modules/', '*.js', '*.mjs'], | ||
| }, | ||
| { | ||
| rules: { | ||
| '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], | ||
| '@typescript-eslint/no-explicit-any': 'warn', | ||
| }, | ||
| }, | ||
| ]; |
This file contains hidden or 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,25 @@ | ||
| import type { Config } from "@jest/types"; | ||
|
|
||
| const config: Config.InitialOptions = { | ||
| preset: "ts-jest", | ||
| testEnvironment: "node", | ||
| testMatch: ["**/tests/**/*.test.ts"], | ||
| transform: { | ||
| "^.+\\.tsx?$": [ | ||
| "ts-jest", | ||
| { | ||
| tsconfig: "tsconfig.test.json", | ||
| }, | ||
| ], | ||
| }, | ||
| moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"], | ||
| moduleNameMapper: { | ||
| "^(\\.{1,2}/.*)\\.js$": "$1", | ||
| }, | ||
| transformIgnorePatterns: [ | ||
| "node_modules/(?!(execa|strip-final-newline|npm-run-path|path-key|onetime|mimic-fn|human-signals|is-stream|get-stream|signal-exit|picomatch|chalk|ansi-styles|supports-color|simple-git|fs-extra)/)", | ||
| ], | ||
| clearMocks: true, | ||
| }; | ||
|
|
||
| export default config; | ||
This file contains hidden or 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,58 @@ | ||
| { | ||
| "name": "@stellarwp/pup", | ||
| "version": "2.0.0", | ||
| "description": "StellarWP's Project Utilities & Packager", | ||
| "bin": { | ||
| "pup": "./dist/cli.js" | ||
| }, | ||
| "type": "module", | ||
| "engines": { | ||
| "node": ">=20" | ||
| }, | ||
| "files": [ | ||
| "dist/", | ||
| "defaults/", | ||
| "docs/", | ||
| "action.yml" | ||
| ], | ||
| "scripts": { | ||
| "build": "tsdown", | ||
| "dev": "tsdown --watch", | ||
| "test": "TS_NODE_PROJECT=tsconfig.test.json jest --passWithNoTests", | ||
| "lint": "eslint --no-error-on-unmatched-pattern src/ tests/", | ||
| "typecheck": "tsc --noEmit" | ||
| }, | ||
| "keywords": [ | ||
| "stellarwp", | ||
| "wordpress", | ||
| "build", | ||
| "packager", | ||
| "cli" | ||
| ], | ||
| "author": "StellarWP <dev@stellarwp.com>", | ||
| "license": "MIT", | ||
| "dependencies": { | ||
| "archiver": "^7.0.0", | ||
| "chalk": "^5.3.0", | ||
| "commander": "^12.0.0", | ||
| "execa": "^8.0.1", | ||
| "fs-extra": "^11.2.0", | ||
| "picomatch": "^4.0.0", | ||
| "simple-git": "^3.22.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@jest/types": "^30.2.0", | ||
| "@types/archiver": "^6.0.0", | ||
| "@types/fs-extra": "^11.0.0", | ||
| "@types/jest": "^30.0.0", | ||
| "@types/node": "^20.0.0", | ||
| "@types/picomatch": "^3.0.0", | ||
| "eslint": "^9.0.0", | ||
| "jest": "^29.7.0", | ||
| "ts-jest": "^29.1.0", | ||
| "ts-node": "^10.9.2", | ||
| "tsdown": "^0.20.3", | ||
| "typescript": "^5.4.0", | ||
| "typescript-eslint": "^8.0.0" | ||
| } | ||
| } |
This file contains hidden or 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,20 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "target": "ES2022", | ||
| "module": "NodeNext", | ||
| "moduleResolution": "NodeNext", | ||
| "lib": ["ES2022"], | ||
| "outDir": "dist", | ||
| "rootDir": "src", | ||
| "strict": true, | ||
| "esModuleInterop": true, | ||
| "skipLibCheck": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "resolveJsonModule": true, | ||
| "declaration": true, | ||
| "declarationMap": true, | ||
| "sourceMap": true | ||
| }, | ||
| "include": ["src/**/*"], | ||
| "exclude": ["node_modules", "dist", "tests"] | ||
| } |
This file contains hidden or 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,16 @@ | ||
| { | ||
| "extends": "./tsconfig.json", | ||
| "compilerOptions": { | ||
| "rootDir": ".", | ||
| "module": "commonjs", | ||
| "moduleResolution": "node", | ||
| "noEmit": true | ||
| }, | ||
| "include": ["src/**/*", "tests/**/*", "jest.config.ts"], | ||
| "ts-node": { | ||
| "compilerOptions": { | ||
| "module": "commonjs", | ||
| "moduleResolution": "node" | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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,14 @@ | ||
| import { defineConfig } from 'tsdown'; | ||
|
|
||
| export default defineConfig({ | ||
| entry: ['src/cli.ts'], | ||
| format: ['esm'], | ||
| target: 'node20', | ||
| outDir: 'dist', | ||
| fixedExtension: false, | ||
| sourcemap: true, | ||
| dts: false, | ||
| outputOptions: { | ||
| banner: '#!/usr/bin/env node', | ||
| }, | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A more usual pattern is
*.spec.tsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can change this after we get most/all of the Rewrite PRs through. They all have their own tests and we'd have to update every single branch with this change 😅