-
-
Notifications
You must be signed in to change notification settings - Fork 3
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 24 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,150 @@ | ||||||
| # @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 | ||||||
|
|
||||||
| <details><summary>Open Table of contents</summary> | ||||||
|
|
||||||
| - [Installation](#installation) | ||||||
| - [Usage](#usage) | ||||||
| - [Configuration](#configuration) | ||||||
| - [GitHub NPM Registry](#github-npm-registry) | ||||||
| - [JSR](#jsr) | ||||||
| - [Changesets](#changesets) | ||||||
|
|
||||||
| </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 | ||||||
|
|
||||||
| 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 |
||||||
| In order to use this with changesets, please update your version script with a preversion script that calls the `multipublish` CLI. | ||||||
|
|
||||||
| ```json | ||||||
| { | ||||||
| "scripts": { | ||||||
| "preversion": "multipublish", | ||||||
| "version": "changeset version" | ||||||
| } | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| <!-- 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` | | ||||||
| | `commitJsrVersionUpdate` | `boolean` | `false` | | ||||||
| | `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.
|
||||||||||||||
| } | ||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import { enable } from "obug"; | ||
| import yargs, { type Options } from "yargs"; | ||
| import { hideBin } from "yargs/helpers"; | ||
|
|
||
| import { MODULE_NAME } from "./util"; | ||
|
|
||
| export type Args = Awaited<ReturnType<typeof parseArgs>>; | ||
|
|
||
| let _args: Args | null = null; | ||
|
|
||
| const args = { | ||
| config: { alias: "c", description: "Path to config file", type: "string" }, | ||
| dry: { alias: "d", description: "Perform a dry run", type: "boolean" }, | ||
| released: { | ||
| alias: "r", | ||
| description: "packages that have been updated and require a publish", | ||
| type: "array", | ||
| }, | ||
| releasedFile: { | ||
| alias: "f", | ||
| description: "file denoting which packages have been updated", | ||
| type: "string", | ||
| }, | ||
| useChangesetStatus: { | ||
| alias: "s", | ||
| description: "path to changeset status file used to version release", | ||
| type: "boolean", | ||
| }, | ||
| verbose: { | ||
| alias: "v", | ||
| description: "Enable verbose logging", | ||
| type: "boolean", | ||
| }, | ||
|
Comment on lines
+29
to
+33
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 Potential alias conflict: The 🤖 Prompt for AI Agents |
||
| versionJsr: { | ||
| alias: "j", | ||
| description: "update version jsr configuration files", | ||
| type: "boolean", | ||
| }, | ||
| } satisfies Record<string, Options>; | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| export async function getArgs() { | ||
| return (_args ??= await parseArgs()); | ||
| } | ||
|
|
||
| export async function parseArgs() { | ||
| const yargsInstance = yargs(hideBin(process.argv)) | ||
| .options(args) | ||
| .help("h") | ||
| .alias("h", "help") | ||
| .epilogue(`--> @stephansama open-source ${new Date().getFullYear()}`); | ||
|
|
||
| const parsed = await yargsInstance | ||
| .wrap(yargsInstance.terminalWidth()) | ||
| .parse(); | ||
|
|
||
| if (parsed.verbose) enable(`${MODULE_NAME}*`); | ||
|
|
||
| return parsed; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.