Skip to content
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .github/dependabot.yml
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"
17 changes: 17 additions & 0 deletions .github/workflows/lint.yml
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
10 changes: 10 additions & 0 deletions .github/workflows/tests.yml
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ vendor/
tests/_output
tests/_support/_generated
tests/_data/**/.puprc
tests/_data/fake-project-git-repo
tests/_data/fake-project-git-repo
node_modules
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24
1,638 changes: 1,638 additions & 0 deletions bun.lock

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions eslint.config.js
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',
},
},
];
25 changes: 25 additions & 0 deletions jest.config.ts
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"],
Copy link
Member

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.ts

Copy link
Contributor Author

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 😅

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;
58 changes: 58 additions & 0 deletions package.json
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": ">=24"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on how we plan to distribute the tool (as a project dev dependency, as a binary, or via global installation), I think we can be less restrictive here. Maybe something like Gutenberg declares - https://github.com/WordPress/gutenberg/blob/trunk/package.json#L18

Anyway, pup should be able to install and build dependencies for our projects.

Copy link
Contributor Author

@d4mation d4mation Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I had originally set it to 18 for this reason. But @dpanta94 and @defunctl recommended a higher version and I have actually tested this in other codebases (where .nvmrc is set to and even older version!) and it works as expected.

It would seem that since we aren't targeting anything Node 24-specific, it works even in a much older environment (I've tested this both via npx pup and bunx pup to ensure that the bun runtime wasn't making things work differently).

But if that's the case, perhaps we should use an older LTS version to be safe?

Edit: The engines setting would warn on installation, however. So that is something to consider as well. I didn't see that as I'm using bun link to test this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shvlv and I discussed this in Slack. We're going to use Node 20 for the time being to try to strike a balance between ensuring users can install this when they have engine-strict=true on older Node versions and still not tying us to anything too incredibly old. Both Gutenberg and GitHub-hosted runners (until later this year, at least) use Node 20.

If we need to bump this higher, we can discuss it later in another PR (which would make testing it a bit easier, as there's nothing in this branch to actually test 😅). But for now, Node 20 should be good enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added this as a discussion topic in our weekly development meeting next week. That way we can get a broader perspective on what we will want to support here and elsewhere :)

},
"files": [
"dist/",
"defaults/",
"docs/",
"action.yml"
],
"scripts": {
"build": "tsup",
"dev": "tsup --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",
"tsup": "^8.0.0",
"typescript": "^5.4.0",
"typescript-eslint": "^8.0.0"
}
}
20 changes: 20 additions & 0 deletions tsconfig.json
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"]
}
16 changes: 16 additions & 0 deletions tsconfig.test.json
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"
}
}
}
14 changes: 14 additions & 0 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineConfig } from 'tsup';

export default defineConfig({
entry: ['src/cli.ts'],
format: ['esm'],
target: 'node18',
outDir: 'dist',
clean: true,
sourcemap: true,
dts: false,
banner: {
js: '#!/usr/bin/env node',
},
});