-
-
Notifications
You must be signed in to change notification settings - Fork 1
Stephansama/ste 14 multiple deploy targets #187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f10ff0f
8998467
30e4950
97ded53
718e3b1
0eccd20
4fb6348
f2af774
6b1ac0e
9f58585
f2ea1be
918dba2
06c9938
445c042
d030c4d
ee65ad7
e680b7e
591203b
2897efd
b5118bf
81a90cf
1f30a1c
82d0ecf
4fe48a5
d398211
1cc5dbd
fff59de
3a61577
37623f0
57b983e
cadd823
0991446
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| --- | ||
| "@stephansama/multipublish": major | ||
| --- | ||
|
|
||
| Initial release of `@stephansama/multipublish`, a CLI tool for publishing packages to multiple registries. | ||
|
|
||
| Features: | ||
|
|
||
| - **npm Publishing Strategies**: Supports two strategies for publishing to npm registries: | ||
| - `.npmrc` strategy: Temporarily creates or updates a root-level `.npmrc` file with registry and auth token details. | ||
| - `package.json` strategy: Directly sets the `publishConfig.registry` field in the package's `package.json`. | ||
| - **JSR Support**: Automatically updates the `version` field in `jsr.json` before publishing. | ||
| - **Configuration**: fully configurable via a schema using zod. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |
| "kaomojis", | ||
| "macchiato", | ||
| "manypkg", | ||
| "multipublish", | ||
| "nodemon", | ||
| "nvim", | ||
| "nvmrc", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| "$schema": "../node_modules/@stephansama/multipublish/config/schema.json", | ||
| "platforms": [ | ||
| [ | ||
| "jsr", | ||
| { | ||
| "experimentalUpdateCatalogs": true, | ||
| "experimentalGenerateJSR": true | ||
| } | ||
| ], | ||
| [ | ||
| "npm", | ||
| { | ||
| "registry": "npm.pkg.github.com", | ||
| "tokenEnvironmentKey": "GITHUB_TOKEN" | ||
| } | ||
| ] | ||
| ] | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,173 @@ | ||||||
| # @stephansama/multipublish | ||||||
|
|
||||||
| [](https://github.com/stephansama/packages/tree/main/core/multipublish) | ||||||
| [](https://packages.stephansama.info/api/@stephansama/multipublish) | ||||||
| [](https://www.npmjs.com/package/@stephansama/multipublish) | ||||||
| [](https://www.npmjs.com/package/@stephansama/multipublish) | ||||||
|
|
||||||
| Publish packages to multiple providers easily | ||||||
|
|
||||||
| ##### Table of contents | ||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||
|
|
||||||
| <details><summary>Open Table of contents</summary> | ||||||
|
|
||||||
| - [Installation](#installation) | ||||||
| - [Usage](#usage) | ||||||
| - [Configuration](#configuration) | ||||||
| - [GitHub NPM Registry](#github-npm-registry) | ||||||
| - [JSR Configuration](#jsr-configuration) | ||||||
| - [Changesets](#changesets) | ||||||
| - [JSR](#jsr) | ||||||
| - [Published packages](#published-packages) | ||||||
|
|
||||||
| </details> | ||||||
|
|
||||||
| ## Installation | ||||||
|
|
||||||
| ```sh | ||||||
| pnpm install @stephansama/multipublish | ||||||
| ``` | ||||||
|
|
||||||
| ## Usage | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add usage documentation for the CLI tool. The Usage section is currently empty. Please document the basic commands, configuration options, and examples for users to understand how to use this multipublish CLI tool. Would you like me to help draft initial usage documentation based on the CLI implementation? 🤖 Prompt for AI Agents |
||||||
|
|
||||||
| ### Configuration | ||||||
|
|
||||||
| You can configure `multipublish` by creating a configuration file (or object) in the root of your project. The following file formats are supported: | ||||||
|
|
||||||
| - `package.json` | ||||||
| - `.multipublishrc.cjs` | ||||||
| - `.multipublishrc.js` | ||||||
| - `.multipublishrc.json` | ||||||
| - `.multipublishrc.mjs` | ||||||
| - `.multipublishrc.ts` | ||||||
| - `.multipublishrc.yaml` | ||||||
| - `.multipublishrc.yml` | ||||||
| - `.multipublishrc` | ||||||
| - `.config/.multipublishrc.json` | ||||||
| - `.config/.multipublishrc.yaml` | ||||||
| - `.config/.multipublishrc.yml` | ||||||
| - `.config/.multipublishrc` | ||||||
| - `.config/multipublishrc.cjs` | ||||||
| - `.config/multipublishrc.js` | ||||||
| - `.config/multipublishrc.json` | ||||||
| - `.config/multipublishrc.mjs` | ||||||
| - `.config/multipublishrc.ts` | ||||||
| - `.config/multipublishrc.yaml` | ||||||
| - `.config/multipublishrc.yml` | ||||||
| - `.config/multipublishrc` | ||||||
| - `multipublish.config.cjs` | ||||||
| - `multipublish.config.js` | ||||||
| - `multipublish.config.mjs` | ||||||
| - `multipublish.config.ts` | ||||||
|
|
||||||
| ```json | ||||||
| { | ||||||
| "$schema": "./node_modules/@stephansama/multipublish/config/schema.json", | ||||||
| "platforms": [ | ||||||
| ["jsr", { "experimentalGenerateJSR": true, "defaultExclude": ["!dist"] }], | ||||||
| [ | ||||||
| "npm", | ||||||
| { | ||||||
| "registry": "https://npm.pkg.github.com", | ||||||
| "tokenEnvironmentKey": "GITHUB_TOKEN" | ||||||
| } | ||||||
| ] | ||||||
| ] | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| ### GitHub NPM Registry | ||||||
|
|
||||||
| If publishing to the GitHub NPM registry, you must add `packages` to permissions when using a GitHub token. And allow `write` and `read` permissions for workflows (located in repo settings > actions > general). | ||||||
|
|
||||||
| ```yaml | ||||||
| permissions: | ||||||
| packages: write | ||||||
| ``` | ||||||
|
|
||||||
| ### JSR Configuration | ||||||
|
|
||||||
| When publishing to JSR, you must either have a valid `jsr.json` or `deno.json`, or allow `experimentalGenerateJSR` using the config option. | ||||||
|
|
||||||
| ### Changesets | ||||||
|
|
||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Consider more concise wording. The phrase "In order to use" can be simplified to "To use" for brevity. ✏️ Proposed change-In order to use this with changesets, please update your version script with a preversion script that calls the `multipublish` CLI.
+To use this with changesets, update your version script with a preversion script that calls the `multipublish` CLI.
🧰 Tools🪛 LanguageTool[style] ~91-~91: Consider a more concise word here. (IN_ORDER_TO_PREMIUM) 🤖 Prompt for AI Agents |
||||||
| If you are using jsr this with changesets, please update your version script with a preversion script that calls the `multipublish` CLI in order to update your existing jsr configurations. | ||||||
|
|
||||||
| #### JSR | ||||||
|
|
||||||
| ```json | ||||||
| { | ||||||
| "scripts": { | ||||||
| "preversion": "multipublish --useChangesetStatus --versionJsr", | ||||||
| "version": "changeset version" | ||||||
| } | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| #### Published packages | ||||||
|
|
||||||
| you can run multipublish after a changeset publish like so | ||||||
|
|
||||||
| ```yaml | ||||||
| - if: github.ref_name == 'main' | ||||||
| name: 🦋 Create Changeset Release | ||||||
| uses: changesets/action@v1 | ||||||
| id: changesets | ||||||
| with: | ||||||
| commit: "chore: Update version for release" | ||||||
| title: "chore: Update version for release" | ||||||
| publish: pnpm run publish | ||||||
| createGithubReleases: true | ||||||
| - name: publish to other registries | ||||||
| if: steps.changesets.outputs.published == 'true' | ||||||
| run: | | ||||||
| echo "${{ steps.changesets.outputs.publishedPackages }}" | multipublish | ||||||
| ``` | ||||||
|
|
||||||
| <!-- ZOD path="./src/schema.ts" start --> | ||||||
|
|
||||||
| # Zod Schema | ||||||
|
|
||||||
| ## Config | ||||||
|
|
||||||
| _Object containing the following properties:_ | ||||||
|
|
||||||
| | Property | Type | Default | | ||||||
| | :------------------- | :---------------------- | :----------- | | ||||||
| | **`platforms`** (\*) | [Platforms](#platforms) | | | ||||||
| | `tmpDirectory` | `string` | `'.release'` | | ||||||
| | `useChangesets` | `boolean` | `true` | | ||||||
|
|
||||||
| _(\*) Required._ | ||||||
|
|
||||||
| ## JsrPlatformOptions | ||||||
|
|
||||||
| _Object containing the following properties:_ | ||||||
|
|
||||||
| | Property | Type | Default | | ||||||
| | :--------------------------- | :-------------- | :------ | | ||||||
| | `allowSlowTypes` | `boolean` | `true` | | ||||||
| | `defaultExclude` | `Array<string>` | | | ||||||
| | `defaultInclude` | `Array<string>` | | | ||||||
| | `experimentalGenerateJSR` | `boolean` | `false` | | ||||||
| | `experimentalUpdateCatalogs` | `boolean` | `false` | | ||||||
|
|
||||||
| _All properties are optional._ | ||||||
|
|
||||||
| ## NpmPlatformOptions | ||||||
|
|
||||||
| _Object containing the following properties:_ | ||||||
|
|
||||||
| | Property | Type | Default | | ||||||
| | :-------------------- | :--------------------------- | :------------------------------ | | ||||||
| | `registry` | `string` | `'https://registry.npmjs.org/'` | | ||||||
| | `strategy` | `'.npmrc' \| 'package.json'` | `'.npmrc'` | | ||||||
| | `tokenEnvironmentKey` | `string` | `'NODE_AUTH_TOKEN'` | | ||||||
|
|
||||||
| _All properties are optional._ | ||||||
|
|
||||||
| ## Platforms | ||||||
|
|
||||||
| *Array of `'jsr' | 'npm'` *or\* _Tuple:_<ol><li>`'jsr'`</li><li>[JsrPlatformOptions](#jsrplatformoptions)</li></ol> _or_ _Tuple:_<ol><li>`'npm'`</li><li>[NpmPlatformOptions](#npmplatformoptions)</li></ol> items.\* | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix malformed emphasis markers in generated content. The line contains spaces inside emphasis markers ( 📝 Proposed fix-*Array of `'jsr' | 'npm'` *or\* _Tuple:_<ol><li>`'jsr'`</li><li>[JsrPlatformOptions](#jsrplatformoptions)</li></ol> _or_ _Tuple:_<ol><li>`'npm'`</li><li>[NpmPlatformOptions](#npmplatformoptions)</li></ol> items.\*
+*Array of `'jsr' | 'npm'` or Tuple:*<ol><li>`'jsr'`</li><li>[JsrPlatformOptions](#jsrplatformoptions)</li></ol> *or Tuple:*<ol><li>`'npm'`</li><li>[NpmPlatformOptions](#npmplatformoptions)</li></ol> *items.*📝 Committable suggestion
Suggested change
🧰 Tools🪛 markdownlint-cli2 (0.18.1)147-147: Spaces inside emphasis markers (MD037, no-space-in-emphasis) 🤖 Prompt for AI Agents |
||||||
|
|
||||||
| <!-- ZOD end --> | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import * as fsp from "node:fs/promises"; | ||
| import * as path from "path"; | ||
| import { build as tsdown } from "tsdown"; | ||
| import * as z from "zod"; | ||
|
|
||
| const outDir = path.resolve("./dist"); | ||
| const schemaDir = path.resolve("./config"); | ||
|
|
||
| await build({ attw: false, entry: ["./src/index.ts"] }); | ||
|
|
||
| await build({ dts: true, entry: ["./src/schema.ts"], outDir: schemaDir }); | ||
|
|
||
| const { configSchema } = await import("./config/schema.js"); | ||
|
|
||
| const jsonSchema = z.toJSONSchema(configSchema); | ||
|
|
||
| const jsonString = JSON.stringify(jsonSchema); | ||
|
|
||
| await fsp.writeFile(path.join(schemaDir, "schema.json"), jsonString); | ||
|
|
||
| /** @param {import('tsdown').Options} opts */ | ||
| function build(opts) { | ||
| return tsdown({ | ||
| attw: { excludeEntrypoints: ["schema.json"] }, | ||
| exports: true, | ||
| format: ["esm", "cjs"], | ||
| outDir, | ||
| skipNodeModulesBundle: true, | ||
| target: "esnext", | ||
| ...opts, | ||
| }); | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,5 @@ | ||||||||||||||||||||||||||||||||
| #!/usr/bin/env node | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| "use strict"; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| import("./dist/index.js").then((mod) => mod.run()); | ||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Consider adding error handling for import/run failures. If the build hasn't been run or ♻️ Suggested improvement #!/usr/bin/env node
"use strict";
-import("./dist/index.js").then((mod) => mod.run());
+import("./dist/index.js")
+ .then((mod) => mod.run())
+ .catch((err) => {
+ console.error("multipublish failed:", err.message);
+ process.exitCode = 1;
+ });📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,68 @@ | ||||||||||||||
| { | ||||||||||||||
| "name": "@stephansama/multipublish", | ||||||||||||||
| "version": "0.0.0", | ||||||||||||||
| "description": "Publish packages to multiple providers easily", | ||||||||||||||
| "keywords": [ | ||||||||||||||
| "multipublish" | ||||||||||||||
| ], | ||||||||||||||
| "homepage": "https://packages.stephansama.info/api/@stephansama/multipublish", | ||||||||||||||
| "repository": { | ||||||||||||||
| "type": "git", | ||||||||||||||
| "url": "git+https://github.com/stephansama/packages.git", | ||||||||||||||
| "directory": "core/multipublish" | ||||||||||||||
| }, | ||||||||||||||
| "license": "MIT", | ||||||||||||||
| "author": { | ||||||||||||||
| "name": "Stephan Randle", | ||||||||||||||
| "email": "stephanrandle.dev@gmail.com", | ||||||||||||||
| "url": "https://stephansama.info" | ||||||||||||||
| }, | ||||||||||||||
| "type": "module", | ||||||||||||||
| "exports": { | ||||||||||||||
| ".": { | ||||||||||||||
| "import": "./config/schema.js", | ||||||||||||||
| "require": "./config/schema.cjs" | ||||||||||||||
| }, | ||||||||||||||
| "./package.json": "./package.json" | ||||||||||||||
| }, | ||||||||||||||
| "main": "./config/schema.cjs", | ||||||||||||||
| "module": "./config/schema.js", | ||||||||||||||
| "types": "./config/schema.d.cts", | ||||||||||||||
|
stephansama marked this conversation as resolved.
stephansama marked this conversation as resolved.
|
||||||||||||||
| "bin": "./cli.mjs", | ||||||||||||||
| "files": [ | ||||||||||||||
| "./dist", | ||||||||||||||
| "./config", | ||||||||||||||
| "./cli.mjs" | ||||||||||||||
|
Comment on lines
+33
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Consider removing the While the ♻️ Proposed refactor "files": [
- "./dist",
- "./config",
- "./cli.mjs"
+ "dist",
+ "config",
+ "cli.mjs"
],📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| ], | ||||||||||||||
|
Comment on lines
+32
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Examine build configuration and package.json exports
cd core/multipublish || exit 1
echo "=== package.json exports and files ==="
jq '.exports, .files, .bin' package.json
echo ""
echo "=== build.mjs contents ==="
if [ -f build.mjs ]; then
cat build.mjs
else
echo "build.mjs not found"
fi
echo ""
echo "=== Directory listing ==="
ls -laRepository: stephansama/packages Length of output: 1723 Remove The 🤖 Prompt for AI Agents |
||||||||||||||
| "scripts": { | ||||||||||||||
| "build": "node build.mjs", | ||||||||||||||
| "dev": "node --watch build.mjs", | ||||||||||||||
| "lint": "eslint ./src/ --pass-on-no-patterns --no-error-on-unmatched-pattern" | ||||||||||||||
| }, | ||||||||||||||
| "dependencies": { | ||||||||||||||
| "@manypkg/find-root": "catalog:", | ||||||||||||||
| "@manypkg/get-packages": "catalog:", | ||||||||||||||
| "cosmiconfig": "catalog:cli", | ||||||||||||||
| "dedent": "^1.7.1", | ||||||||||||||
| "fast-glob": "^3.3.3", | ||||||||||||||
| "obug": "catalog:cli", | ||||||||||||||
| "package-manager-detector": "^1.6.0", | ||||||||||||||
| "yaml": "^2.8.2", | ||||||||||||||
| "yargs": "catalog:cli", | ||||||||||||||
| "zod": "catalog:schema" | ||||||||||||||
| }, | ||||||||||||||
| "devDependencies": { | ||||||||||||||
| "@types/yargs": "catalog:", | ||||||||||||||
| "es-toolkit": "catalog:", | ||||||||||||||
| "jsr": "catalog:", | ||||||||||||||
| "tsdown": "catalog:" | ||||||||||||||
| }, | ||||||||||||||
| "peerDependencies": { | ||||||||||||||
| "jsr": ">=0.10" | ||||||||||||||
| }, | ||||||||||||||
|
stephansama marked this conversation as resolved.
|
||||||||||||||
| "packageManager": "pnpm@10.11.0", | ||||||||||||||
| "publishConfig": { | ||||||||||||||
| "access": "public", | ||||||||||||||
| "provenance": true | ||||||||||||||
| } | ||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||||||||||
| } | ||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: stephansama/packages
Length of output: 766
🏁 Script executed:
Repository: stephansama/packages
Length of output: 46
🏁 Script executed:
Repository: stephansama/packages
Length of output: 453
🏁 Script executed:
Repository: stephansama/packages
Length of output: 427
🏁 Script executed:
Repository: stephansama/packages
Length of output: 294
🏁 Script executed:
# Check the config file to understand the structure cat .config/.multipublishrc.jsonRepository: stephansama/packages
Length of output: 384
🏁 Script executed:
Repository: stephansama/packages
Length of output: 95
🏁 Script executed:
Repository: stephansama/packages
Length of output: 234
🏁 Script executed:
Repository: stephansama/packages
Length of output: 387
🏁 Script executed:
# Check the release workflow to see what tokens are configured cat .github/workflows/release.ymlRepository: stephansama/packages
Length of output: 2499
🏁 Script executed:
# Check git history for the config file to see if there's context about GITHUB_TOKEN choice git log --oneline -20 .config/.multipublishrc.jsonRepository: stephansama/packages
Length of output: 127
🏁 Script executed:
Repository: stephansama/packages
Length of output: 1884
🏁 Script executed:
Repository: stephansama/packages
Length of output: 141
🏁 Script executed:
# Check multipublish README for token documentation cat core/multipublish/README.mdRepository: stephansama/packages
Length of output: 4920
🏁 Script executed:
Repository: stephansama/packages
Length of output: 4851
Change
tokenEnvironmentKeyto match the public npm registry authentication.The config uses
GITHUB_TOKENforregistry.npmjs.org, but per the multipublish documentation,GITHUB_TOKENis intended only for the GitHub NPM Registry (npm.pkg.github.com). The public npm registry requiresNODE_AUTH_TOKEN, which is the schema default and matches the workflow setup.🐛 Suggested fix
[ "npm", { "registry": "https://registry.npmjs.org/", - "tokenEnvironmentKey": "GITHUB_TOKEN" + "tokenEnvironmentKey": "NODE_AUTH_TOKEN" } ]📝 Committable suggestion
🤖 Prompt for AI Agents