Skip to content

feat(publish): ask for the package license and ship a LICENSE with MIT packages - #14

Merged
pkarw merged 19 commits into
catalog/metadatafrom
catalog/default-license
Oct 29, 2026
Merged

pkarw merged 19 commits into
catalog/metadatafrom
catalog/default-license

Conversation

@wojciechszyjka

@wojciechszyjka wojciechszyjka commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Base: catalog/metadata · Head: catalog/default-license

Stacked on #13. Review only the commits after catalog/metadata. When that PR merges, this one retargets to main.

🎯 What changes

Every module from an app without a license field went to npm as UNLICENSED. Open Mercato Modules (open-mercato/modules) checks the license of a submitted package, and people need one to reuse a module. This PR makes the license a choice the author sees.

  • Prompt. The publish wizard asks once for the package license. It suggests the module's metadata.license, then the app's license, then MIT. The suggestion reads only the exported metadata of the module; a local metadata in a helper is ignored.
  • Scripts. The new --license option sets it. Without it, publish uses the module's metadata.license and then the app's license. When nothing names one, it warns that the package goes out as UNLICENSED and names --license MIT.
  • LICENSE file. An MIT package and its dedicated repository get a LICENSE naming the Git author, or else the npm user, as copyright holder. The npm package ships the same file.
  • Author files stay. A later release replaces or removes only a LICENSE with exactly the text and holder this tool wrote. A LICENSE the author wrote is never touched. Under another license, publish warns that the repository keeps a LICENSE the npm package does not carry.
  • Linked releases. The license lives in the repository's package.json. publish warns when --license names another one and says to change that field. link and unlink keep the license. Any valid SPDX expression is accepted, nested parentheses included; unbalanced input is refused.
  • init writes an empty license field next to description in the module metadata.

💥 Compatibility

  • New --license option and one more wizard question. Nothing removed.
  • Packages from apps without a license now default to the suggested license in the wizard instead of UNLICENSED. Scripts without --license follow the module's metadata.license, then the app's license. A module whose metadata names a license is now published under it. When nothing names one, the package stays UNLICENSED, with a warning.
  • Dedicated repositories may gain a LICENSE file on the next MIT release. The tool replaces or removes only the file it wrote.

🧪 Validation

Rebased with catalog/metadata onto main after #12, then merged the updated catalog/metadata (948c2f2: exported metadata binding, describe --open stderr). On Node 24, npm 11.17.0, at 9783878:

  • npm run typecheck: passed.
  • npm run lint: passed.
  • npm test: 254 tests, 249 passed, 0 failed, 5 skipped (the opt-in framework tests that need OPEN_MERCATO_ROOT).
  • npm pack --dry-run: passed, 59 files.
  • git diff --check: clean.
  • npm run test:release:local passed on 25 Oct at 469a73f on create-mercato-app@0.9.0 with Verdaccio and Postgres: all 20 local and 37 consumer stages. Commits after 469a73f: 865a912, 25be438, 810e109, 62a017b (LICENSE handling), cfba46d (lowercase mit ships the MIT LICENSE), c3fb424 (Git identity when only the author is configured), c3eb71b (merge of catalog/metadata; license read from the exported metadata), 50536b1 (tests for a local metadata in a helper), 72eebd5 (SPDX expression check), 9783878 (CHANGELOG and guide). CI's release-checks jobs (npm run test:release:local) passed on c3fb424 for create-mercato-app@0.9.0 and @latest. On 9783878 all 6 CI checks passed in run 40799243813, including both release-checks jobs.

📋 Notes for reviewers

  • Merge order: the metadata PR first, then this one.
  • Catalog links in this PR come from the base branch and use the root of https://modules.openmercato.com/. They answer from a wildcard host until the Cloudflare deploy goes live.

The wizard asks once for an SPDX license and suggests the module metadata
license, then the app license, then MIT; --license sets it for scripts.
Without a choice the earlier default applies, so unattended releases keep
their license. MIT packages and their dedicated repositories get the LICENSE
text, linked releases keep the repository license, and init writes empty
description and license fields into the module metadata.
The publish wizard writes the LICENSE text for MIT only. README and the
guide now say that other licenses set the package.json license field and
that their LICENSE text has to be added to the repository by hand.
The license prompt runs only in the wizard, so publish --yes without
--license, the path an agent takes, released modules of an app without
a license as UNLICENSED with only a one-word summary line. The tool
still does not pick a license for the author, but when no setting,
module metadata, app or linked repository names one, the summary says
"(no license chosen)" and publish and dry runs print a warning that
names --license MIT and how to change the saved choice later.
The MIT LICENSE said "Copyright (c) <year> @scope/package authors",
which names nobody. The holder is now GIT_AUTHOR_NAME or git config
user.name, then the npm user (npm whoami, 15 s at most), and the package
authors only when both are missing.
…o warning

publish now warns when no license was chosen, so the local release
checks pass --license MIT, as the docs tell scripts to do.
A linked repository whose package.json names MIT but has no LICENSE now
ships the generated MIT text, as the README promises. A repository release
that moves an MIT package to another license removes the LICENSE an earlier
release generated, so no MIT grant stays next to the new license; a LICENSE
the author wrote stays.
link rebuilt the saved settings without the license, and unlink saved
nothing of the repository's own, so the first release from the app after
unlink fell back to another license, or to UNLICENSED in scripts, and wrote
it into the repository. link now keeps the saved license, and unlink saves
the license the repository's package.json names, which linked releases used.
generatedMitLicense compared LICENSE files without their Copyright line,
so any standard MIT text counted as generated: a repository release
removed an MIT LICENSE the author wrote when the license changed, and an
MIT release overwrote it. A LICENSE now counts as generated only when it
is exactly the text mitLicense writes for the holder the tool names now,
in any year. The release still adds LICENSE where the repository has
none; every other LICENSE stays. Tests cover the exact match and a
hand-written MIT LICENSE surviving MIT and UNLICENSED releases.
A linked release takes the license in the repository's package.json, so
publish --license and the wizard had no effect on it, silently. publish
now warns when --license names a different license, gives both values and
the package.json to change, and --configure says where the license of a
linked module is set.
A release from the app keeps a LICENSE the author wrote in the dedicated
repository, such as the MIT text for "Fixture Ltd.", but the npm archive
carried the text this tool generates. publish now reads the repository's
LICENSE at the inspected commit before the summary and, when the release
keeps it, packs that file into the archive the summary shows, with a note.
The head check before the push makes sure it is still the same file.
Linked releases already shipped the checkout's LICENSE; a CLI test now
covers that path too.
The previous commit packed the dedicated repository's LICENSE into the npm
archive whatever the package license was, so an UNLICENSED or Apache-2.0
package could carry the MIT grant of "Fixture Ltd." with no warning, and a
release with no license chosen said no LICENSE was added while the archive
had one. Now only an MIT package carries the repository's own LICENSE. For
any other license the archive has no LICENSE, as before, and the summary
warns that the repository keeps one the npm package does not carry and says
to edit or remove it, or publish with the license it grants.
@wojciechszyjka wojciechszyjka self-assigned this Oct 28, 2026
@wojciechszyjka

Copy link
Copy Markdown
Contributor Author

🤖 Claiming this PR — starting om-auto-fix-pr run. Started: 2026-10-28T15:52:06Z.

…efault-license

# Conflicts:
#	src/package.ts
@wojciechszyjka

Copy link
Copy Markdown
Contributor Author

🤖 om-auto-review-pr taking over the chain lock: review with autofix. Started: 2026-10-28T15:57:06Z.

A license given as mit now goes to npm as MIT and ships the LICENSE text.
A linked repository whose package.json says mit keeps its own field and
still gets the MIT text. The copyright holder lookup runs npm whoami with
the default capture timeout, as network commands must. Tests cover control
characters and overlong names in the holder.

The CHANGELOG now says that scripts without --license follow the module's
metadata.license, and the guide no longer says each release rewrites a
LICENSE that an earlier release wrote for another holder.

@wojciechszyjka wojciechszyjka left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🔍 Review: om-auto-review-pr (autofix)

Verdict: no blockers, no open majors. Posted as a comment: this run does not approve.

Reviewed catalog/metadata...catalog/default-license after merging the latest catalog/metadata (fe87a68). The only conflict was in validateSettings in src/package.ts. It was resolved by keeping the license check and the new validateRepositoryName helper.

Fixed in cfba46d

  • Major, now documented: a script with no --license now follows the module's metadata.license, ahead of the app's license. A module with license: 'MIT' that went out as UNLICENSED is now MIT. That matches the module's own declaration and the catalog's license check, which reports a mismatch when package.json and metadata.license disagree. The CHANGELOG said "without it the license is unchanged" and now names the change, as BACKWARD_COMPATIBILITY.md requires for a changed default.
  • Minor: --license mit passed validation, but no LICENSE shipped, because every check compared against MIT. The package now gets MIT, the text ships, and a test covers it.
  • Minor: licenseHolder ran npm whoami with a 15 s timeout. CODE_REVIEW.md keeps the default timeout for captured network commands. A test pins this.
  • Minor: the guide said each release writes the LICENSE again after a holder change. It does not, and the same paragraph says so later. The sentence is fixed.
  • Tests: control characters and overlong names in the copyright holder.

Left for a follow-up (non-blocking)

The SPDX pattern is loose. The holder is not shown in the summary and is looked up more than once. Other items: the year changes on a regenerated LICENSE, an ignored --license is saved on linked releases, and a removed generated LICENSE is not announced. There is no test for a symlinked repository LICENSE.

Validation (cfba46d, Node 24)

  • npm run typecheck: passed
  • npm run lint: passed
  • npm test: 249 tests, 244 passed, 0 failed, 5 skipped (need OPEN_MERCATO_ROOT)
  • npm pack --dry-run: passed, 59 files

The catalogLaunched switch stays false. This PR does not touch it.

CI pending: the workflow run on cfba46d had not finished when this review was posted. Required CI still gates merge.

The guide says to set GIT_AUTHOR_NAME to name the LICENSE holder. With that
variable set and no Git user configured, the author identity resolved but
the committer did not, so the release commit failed with git exit 128.
ensureAuthor now checks both identities before it falls back to the GitHub
user. The LICENSE test runs without a Git configuration, as on CI, and
covers this case.
@wojciechszyjka wojciechszyjka changed the title # feat(publish): ask for the package license and ship a LICENSE with MIT packages feat(publish): ask for the package license and ship a LICENSE with MIT packages Oct 28, 2026
@wojciechszyjka

Copy link
Copy Markdown
Contributor Author

🤖 om-auto-fix-pr: result

  • Merged the latest catalog/metadata (fe87a68) into this branch. There was one trivial conflict in validateSettings. The base stays catalog/metadata.
  • Review: no blockers. The fixes are listed in the review. Non-blocking items are tracked in Follow-ups to the license prompt (#14) #17.
  • CI fix (c3fb424): the LICENSE release test failed on every test job with git exit 128. Cause: with GIT_AUTHOR_NAME set and no Git user configured, ensureAuthor skipped setup and the commit had no committer. Users who follow the guide's advice to set GIT_AUTHOR_NAME hit the same bug. It is now fixed, and the test runs without a Git configuration.
  • Local gate on c3fb424: typecheck, lint, npm test (244 passed, 0 failed, 5 skipped), and npm pack --dry-run all passed.
  • The catalogLaunched switch stays off.

CI pending: the Tests workflow on c3fb424. Required CI still gates merge. A follow-up will report the CI result.

Next: merge #13 first, then this PR.

@wojciechszyjka

Copy link
Copy Markdown
Contributor Author

🤖 om-auto-fix-pr completed: review fixes and the CI fix are pushed. Lock released. CI result follows in a separate comment.

@wojciechszyjka

Copy link
Copy Markdown
Contributor Author

🤖 om-auto-fix-pr: CI result

All 6 checks passed on c3fb424 in run 40723625924. The run is completed, and it is the only workflow run at this SHA. That covers the three test jobs, Tests against Open Mercato and both local release lanes. The PR is mergeable against catalog/metadata. Merge #13 first.

@wojciechszyjka

Copy link
Copy Markdown
Contributor Author

🤖 Claiming this PR - starting om-auto-fix-pr run. Started: 2026-10-29T01:05:33Z.

…efault-license

Brings the exported-metadata fix and the describe --open stderr fix from #13.
moduleInfo now reads title, description and license from the exported
top-level metadata binding only.
…cense

After the merge from catalog/metadata, moduleInfo reads license from the
exported metadata binding only. Cover a function, block and arrow helper with
a local metadata naming MIT while the exported one says UNLICENSED: the
manifest stays UNLICENSED, no LICENSE is written, and the license prompt
suggests UNLICENSED.
The license pattern refused nested expressions such as
((MIT OR Apache-2.0) AND BSD-3-Clause) and accepted unbalanced input such as
(MIT). A linked repository with a nested license then lost it on unlink, and
a scripted publish refused it.

A small recursive-descent check replaces the pattern: license ids, AND, OR,
WITH followed by an exception id, parentheses at any depth, single spaces.
settingLicense, repositoryLicense, the module metadata license and the
publish settings check share it; UNLICENSED and the 100-character cap stay.
@wojciechszyjka

Copy link
Copy Markdown
Contributor Author

🤖 om-auto-review-pr taking over the chain lock: review with autofix. Started: 2026-10-29T01:15:02Z.

@wojciechszyjka wojciechszyjka left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🔍 Re-review: om-auto-review-pr (autofix)

Verdict: no blockers, no open majors. Posted as a comment: this run does not approve.

Reviewed catalog/metadata...catalog/default-license at 9783878, after merging the updated catalog/metadata (948c2f2).

Fixed in this pass

  • Major (Codex P3): a local metadata in a helper could set the package license to MIT, ship an MIT LICENSE and change the prompt suggestion. The merge brings the exported-binding lookup from #13, and license now goes through it like title and description (c3eb71b). Tests cover function, block and arrow helpers for the manifest, the LICENSE file and the prompt default (50536b1).
  • Minor to major (Codex P4): the license pattern refused nested SPDX expressions and accepted (MIT. A recursive-descent check replaces it and is shared by settingLicense, repositoryLicense, the module metadata license and validateSettings (72eebd5). A link then unlink with ((MIT OR Apache-2.0) AND BSD-3-Clause) and no saved license now keeps the license, and the next scripted publish uses it.

Remaining (nit, not blocking)

  • SPDX DocumentRef-...:LicenseRef-... ids (with a colon) are still refused, as they were before. npm packages rarely use them.

🧪 Validation (Node 24, local)

  • npm run typecheck: passed
  • npm run lint: passed
  • npm test: 254 tests, 249 passed, 0 failed, 5 skipped (opt-in framework tests)
  • npm pack --dry-run: passed, 59 files
  • git diff --check: clean

CI on 9783878 is still pending; a separate comment will give the result.

@wojciechszyjka

Copy link
Copy Markdown
Contributor Author

🤖 om-auto-review-pr completed: no blockers (comment, no approval). Lock retained - chain continues.

@wojciechszyjka

Copy link
Copy Markdown
Contributor Author

🤖 om-auto-fix-pr: result

  • Merged the updated catalog/metadata (948c2f2). The license field now comes from the exported metadata, like title and description, so a local metadata in a helper no longer makes a package MIT or changes the prompt suggestion.
  • Replaced the license pattern with a small SPDX expression check: nested parentheses are accepted, unbalanced input is refused. unlink now keeps a nested repository license, and the next scripted publish uses it.
  • Updated the PR body (Scripts, Prompt, Linked releases, Validation), the CHANGELOG and the guide.
  • Local gate: typecheck, lint, 254 tests (249 passed, 5 skipped), pack (59 files), git diff --check clean. Review: comment, no blockers.

CI on 9783878 is pending; the result follows in a separate comment. This PR still merges after #13.

@wojciechszyjka

Copy link
Copy Markdown
Contributor Author

🤖 om-auto-fix-pr completed: fixes are pushed. Lock released. CI result follows in a separate comment.

@wojciechszyjka

Copy link
Copy Markdown
Contributor Author

🤖 om-auto-fix-pr: CI result

All 6 checks passed on 9783878 in run 40799243813: the unit tests on Node 24 (npm 12 and bundled) and Node 26, the tests against Open Mercato, and both release-checks jobs (create-mercato-app@0.9.0 and @latest). Next: merge #13 first, then om-approve-merge-pr 14.

@pkarw
pkarw merged commit b4a7902 into catalog/metadata Oct 29, 2026
7 checks passed
@wojciechszyjka
wojciechszyjka requested a review from pkarw October 29, 2026 15:41
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.

2 participants