Skip to content

feat: zero new --json envelope with order-independent args#73

Open
gke0op wants to merge 1 commit into
vercel-labs:mainfrom
gke0op:zero-new-json
Open

feat: zero new --json envelope with order-independent args#73
gke0op wants to merge 1 commit into
vercel-labs:mainfrom
gke0op:zero-new-json

Conversation

@gke0op
Copy link
Copy Markdown

@gke0op gke0op commented May 18, 2026

Summary

Adds --json flag to zero new, outputting structured JSON with:

  • schemaVersion, ok, kind, name, path
  • manifest, entry paths
  • nextSteps (lib omits zero run)

Arg parser rewritten to be order-independent:

  • --json can appear before or after positional args
  • --json can appear between kind and name

Plain-text output unchanged.

Testing

  • zero new --json cli mycli → correct JSON envelope
  • zero new lib mylib --json → lib omits run from nextSteps
  • zero new --json package test-pkg → package includes run
  • Plain text output unchanged
  • All 11 CLI tests pass

Closes #22

@vercel
Copy link
Copy Markdown

vercel Bot commented May 18, 2026

@gke0op is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

Comment thread native/zero-c/src/main.c
ZBuf entry_path;
zbuf_init(&entry_path);
zbuf_append(&entry_path, command->input);
zbuf_append(&entry_path, "/src/main.0");
Copy link
Copy Markdown

@vercel vercel Bot May 18, 2026

Choose a reason for hiding this comment

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

The JSON entry field in zero new --json is hardcoded to src/main.0 for all project kinds, but the lib template uses src/lib.0 as its entry point.

Fix on Vercel

Comment thread native/zero-c/src/main.c
Comment on lines +5177 to +5185
zbuf_append(&buf, "\"zero check ");
zbuf_append(&buf, command->input);
zbuf_append(&buf, "\", \"zero test ");
zbuf_append(&buf, command->input);
zbuf_append(&buf, "\"");
if (strcmp(command->kind, "lib") != 0) {
zbuf_append(&buf, ", \"zero run ");
zbuf_append(&buf, command->input);
zbuf_append(&buf, "\"");
Copy link
Copy Markdown

@vercel vercel Bot May 18, 2026

Choose a reason for hiding this comment

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

The nextSteps JSON array values embed command->input (project name) directly into manually-constructed quoted strings without JSON escaping, producing malformed JSON when the project name contains ", \, or control characters.

Fix on Vercel

@gke0op
Copy link
Copy Markdown
Author

gke0op commented May 18, 2026

Rebase complete ✅

Rebased onto latest origin/main (v0.1.2, post borrow-provenance + HTTP client merge). All conflicts resolved. Each branch now has a clean linear history on top of current main.

@gke0op
Copy link
Copy Markdown
Author

gke0op commented May 18, 2026

Rebased onto latest origin/main (v0.1.2). All conflicts resolved. Clean linear history.

Adds --json flag to zero new, outputting structured JSON with:
- schemaVersion, ok, kind, name, path
- manifest, entry paths
- nextSteps (lib omits 'zero run')

Arg parser rewritten to be order-independent:
- --json can appear before or after positional args
- --json can appear between kind and name

Plain-text output unchanged.

Tested:
- zero new --json cli mycli → correct JSON envelope
- zero new lib mylib --json → lib omits run from nextSteps
- zero new --json package test-pkg → package includes run
- Plain text output unchanged
- All 11 CLI tests pass

Closes vercel-labs#22
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.

1 participant