Repository navigation
feat(publish): ask for the package license and ship a LICENSE with MIT packages - #14
Conversation
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.
…cribed and licensed fixture
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.
|
🤖 Claiming this PR — starting |
…efault-license # Conflicts: # src/package.ts
|
🤖 |
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
left a comment
There was a problem hiding this comment.
🔍 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
--licensenow follows the module'smetadata.license, ahead of the app's license. A module withlicense: 'MIT'that went out asUNLICENSEDis now MIT. That matches the module's own declaration and the catalog's license check, which reports a mismatch whenpackage.jsonandmetadata.licensedisagree. The CHANGELOG said "without it the license is unchanged" and now names the change, asBACKWARD_COMPATIBILITY.mdrequires for a changed default. - Minor:
--license mitpassed validation, but no LICENSE shipped, because every check compared againstMIT. The package now getsMIT, the text ships, and a test covers it. - Minor:
licenseHolderrannpm whoamiwith a 15 s timeout.CODE_REVIEW.mdkeeps 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: passednpm run lint: passednpm test: 249 tests, 244 passed, 0 failed, 5 skipped (needOPEN_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.
|
🤖
CI pending: the Next: merge #13 first, then this PR. |
|
🤖 |
|
🤖 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 |
|
🤖 Claiming this PR - starting |
…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
left a comment
There was a problem hiding this comment.
🔍 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
metadatain a helper could set the package license to MIT, ship an MITLICENSEand change the prompt suggestion. The merge brings the exported-binding lookup from #13, andlicensenow goes through it like title and description (c3eb71b). Tests cover function, block and arrow helpers for the manifest, theLICENSEfile 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 bysettingLicense,repositoryLicense, the module metadata license andvalidateSettings(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: passednpm run lint: passednpm test: 254 tests, 249 passed, 0 failed, 5 skipped (opt-in framework tests)npm pack --dry-run: passed, 59 filesgit diff --check: clean
CI on 9783878 is still pending; a separate comment will give the result.
|
🤖 |
|
🤖
CI on 9783878 is pending; the result follows in a separate comment. This PR still merges after #13. |
|
🤖 |
|
🤖 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 |
Base:
catalog/metadata· Head:catalog/default-license🎯 What changes
Every module from an app without a
licensefield went to npm asUNLICENSED. 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.metadata.license, then the app's license, then MIT. The suggestion reads only the exportedmetadataof the module; a localmetadatain a helper is ignored.--licenseoption sets it. Without it, publish uses the module'smetadata.licenseand then the app's license. When nothing names one, it warns that the package goes out asUNLICENSEDand names--license MIT.LICENSEnaming the Git author, or else the npm user, as copyright holder. The npm package ships the same file.LICENSEwith exactly the text and holder this tool wrote. ALICENSEthe author wrote is never touched. Under another license,publishwarns that the repository keeps aLICENSEthe npm package does not carry.package.json.publishwarns when--licensenames another one and says to change that field.linkandunlinkkeep the license. Any valid SPDX expression is accepted, nested parentheses included; unbalanced input is refused.initwrites an emptylicensefield next todescriptionin the modulemetadata.💥 Compatibility
--licenseoption and one more wizard question. Nothing removed.UNLICENSED. Scripts without--licensefollow the module'smetadata.license, then the app's license. A module whose metadata names a license is now published under it. When nothing names one, the package staysUNLICENSED, with a warning.LICENSEfile on the next MIT release. The tool replaces or removes only the file it wrote.🧪 Validation
Rebased with
catalog/metadataontomainafter #12, then merged the updatedcatalog/metadata(948c2f2: exportedmetadatabinding,describe --openstderr). 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 needOPEN_MERCATO_ROOT).npm pack --dry-run: passed, 59 files.git diff --check: clean.npm run test:release:localpassed on 25 Oct at 469a73f oncreate-mercato-app@0.9.0with 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 ofcatalog/metadata; license read from the exportedmetadata), 50536b1 (tests for a localmetadatain 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
https://modules.openmercato.com/. They answer from a wildcard host until the Cloudflare deploy goes live.