Skip to content

Validate app name in templates & add support for validating pear init -y#718

Closed
lejeunerenard wants to merge 125 commits intoholepunchto:pear-nextfrom
lejeunerenard:validate-app-name-in-templates
Closed

Validate app name in templates & add support for validating pear init -y#718
lejeunerenard wants to merge 125 commits intoholepunchto:pear-nextfrom
lejeunerenard:validate-app-name-in-templates

Conversation

@lejeunerenard
Copy link
Contributor

Prevents default name property from being invalid for desktop and terminal type applications. With out the validation there are scenarios where default values can error once a user tries to run a Pear app which throws:

Error: The package.json name / pear.name field must be lowercase and one word, and may contain letters, numbers, hyphens (-), underscores (_), forward slashes (/) and asperands (@).

This revealed an issue with pear-api's processing of params when the --yes flag was set as well. So a full fix depends on holepunchto/pear-api#31

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors CLI commands to use the shared pear-api terminal interface, adds new flags/commands (e.g. --purge, --only, drop, data manifest, gc interfaces), and streamlines outputters to return arrays rather than async generators.

  • Migrate all local iface, errors, parse-link, and constants imports to pear-api
  • Introduce new commands/flags: drop, manifest (data), interfaces (gc), --purge & --only (stage & dump)
  • Refactor outputters to return arrays and add byte-diff support

Reviewed Changes

Copilot reviewed 198 out of 198 changed files in this pull request and generated no comments.

Show a summary per file
File Description
cmd/versions.js Switched import to pear-api/terminal and rewrote outputter to return array of tags
cmd/stage.js Updated imports, added --purge & --only flags, and appended byteDiff tagger
cmd/dump.js Updated imports, added --only & --prune flags, stats tag, and byteDiff tagger
cmd/index.js Extensive command definitions update: new commands, flags, hidden reset, and help text
cmd/gc.js Abstracted common GC logic into #op, added interfaces command
cmd/data.js Added manifest output and command, refactored outputter calls
Comments suppressed due to low confidence (5)

cmd/stage.js:36

  • Tests should be added to cover the new --purge and --only flags to verify that ignored files are removed and path filtering works as expected.
const { dryRun, bare, json, ignore, purge, name, truncate, only } = cmd.flags

cmd/gc.js:32

  • Add unit tests for the new gc interfaces command path (e.g. --age) to confirm it passes the correct data to the IPC layer and formats output properly.
async interfaces (cmd) {

cmd/data.js:42

  • Introduce tests for the data manifest output function to ensure it handles both present and missing manifest data as intended.
const manifestOutput = (manifest) => {

cmd/stage.js:4

  • The byteDiff tagger is added without a matching tag key; you should map it under the 'byte-diff' tag (e.g. { 'byte-diff': byteDiff }) so byte‐diff events are handled correctly.
const { outputter, ansi } = require('pear-api/terminal')

cmd/dump.js:4

  • Similarly, byteDiff must be keyed to the 'byte-diff' tag in the outputter's taggers object; otherwise byte-diff output won't be invoked.
const { outputter, permit, ansi, isTTY, byteSize, byteDiff } = require('pear-api/terminal')

@davidmarkclements davidmarkclements force-pushed the pear-next branch 2 times, most recently from 78fc737 to 3257823 Compare July 23, 2025 10:12
@davidmarkclements davidmarkclements force-pushed the pear-next branch 2 times, most recently from a133af3 to 8abb23f Compare July 28, 2025 19:57
@davidmarkclements davidmarkclements force-pushed the pear-next branch 3 times, most recently from de8fc9e to f88a739 Compare August 8, 2025 12:52
@davidmarkclements davidmarkclements force-pushed the pear-next branch 2 times, most recently from 8e2e85c to d77f928 Compare August 14, 2025 22:08
@davidmarkclements davidmarkclements force-pushed the pear-next branch 4 times, most recently from 83fa8d9 to 594d418 Compare September 2, 2025 12:28
@davidmarkclements davidmarkclements force-pushed the pear-next branch 2 times, most recently from a48eb34 to fb91ce2 Compare September 12, 2025 12:37
@davidmarkclements davidmarkclements force-pushed the pear-next branch 2 times, most recently from c4415b2 to cf21c89 Compare September 18, 2025 16:50
@davidmarkclements davidmarkclements deleted the branch holepunchto:pear-next October 3, 2025 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants