Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 28
[BREAKING] Change publish cmd to not mutate version#218
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
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import { CommandModule } from "yargs"; | ||
| import { CliGlobalOptions } from "../types"; | ||
| import { defaultDir } from "../params"; | ||
| import { readManifest } from "../utils/manifest"; | ||
| import { Apm } from "../utils/Apm"; | ||
| interface CliCommandOptions extends CliGlobalOptions { | ||
| provider: string; | ||
| tag?: string; | ||
| } | ||
| export const list: CommandModule<CliGlobalOptions, CliCommandOptions> = { | ||
| command: "list [tag]", | ||
| describe: "List package version tags", | ||
| builder: yargs => | ||
| yargs | ||
| .positional("tag", { | ||
| description: "tag to print version of", | ||
| type: "string" | ||
| }) | ||
| .option("provider", { | ||
| description: `Specify an eth provider: "dappnode" (default), "infura", "localhost:8545"`, | ||
| default: "dappnode", | ||
| type: "string" | ||
| }), | ||
| handler: async (args): Promise<void> => { | ||
| const tagsWithVersions = await listHandler(args); | ||
| if (args.tag) { | ||
| // Output result: "0.1.8" | ||
| const version = tagsWithVersions[args.tag]; | ||
| if (!version) { | ||
| throw Error(`Tag ${args.tag} not found`); | ||
| } else { | ||
| console.log(version); | ||
| } | ||
| } else { | ||
| for (const [tag, version] of Object.entries(tagsWithVersions)) { | ||
| // Output result: "latest: 0.1.8" | ||
| console.log(`${tag}: ${version}`); | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| /** | ||
| * Common handler for CLI and programatic usage | ||
| */ | ||
| export async function listHandler({ | ||
| provider, | ||
| dir = defaultDir | ||
| }: CliCommandOptions): Promise<Record<string, string>> { | ||
| const { manifest } = readManifest({ dir }); | ||
| return { | ||
| latest: await new Apm(provider).getLatestVersion(manifest.name) | ||
| }; | ||
| } |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import { CommandModule } from "yargs"; | ||
| import semver from "semver"; | ||
| import { CliGlobalOptions } from "../types"; | ||
| import { defaultComposeFileName, defaultDir } from "../params"; | ||
| import { readManifest, writeManifest } from "../utils/manifest"; | ||
| import { | ||
| readCompose, | ||
| updateComposeImageTags, | ||
| writeCompose | ||
| } from "../utils/compose"; | ||
| interface CliCommandOptions extends CliGlobalOptions { | ||
| type: string; | ||
| } | ||
| export const version: CommandModule<CliGlobalOptions, CliCommandOptions> = { | ||
| command: "version [type]", | ||
| describe: "Bump a package version", | ||
| builder: yargs => | ||
| yargs.positional("type", { | ||
| description: "Semver update type: [ major | minor | patch ]", | ||
| choices: ["major", "minor", "patch"], | ||
| type: "string", | ||
| demandOption: true | ||
| }), | ||
| handler: async (args): Promise<void> => { | ||
| const nextVersion = await versionHandler(args); | ||
| // Output result: "0.1.8" | ||
| console.log(nextVersion); | ||
| } | ||
| }; | ||
| /** | ||
| * Common handler for CLI and programatic usage | ||
| */ | ||
| export async function versionHandler({ | ||
| type, | ||
| dir = defaultDir, | ||
| compose_file_name: composeFileName = defaultComposeFileName | ||
| }: CliCommandOptions): Promise<string> { | ||
| // Load manifest | ||
| const { manifest, format } = readManifest({ dir }); | ||
| // If `type` is a valid `semver.ReleaseType` the version will be bumped, else return null | ||
| const nextVersion = | ||
| semver.inc(manifest.version, type as semver.ReleaseType) || type; | ||
| if (!semver.valid(nextVersion)) { | ||
| throw Error(`Invalid semver bump or version: ${type}`); | ||
| } | ||
| // Mofidy and write the manifest and docker-compose | ||
| manifest.version = nextVersion; | ||
| writeManifest(manifest, format, { dir }); | ||
| const { name, version } = manifest; | ||
| const compose = readCompose({ dir, composeFileName }); | ||
| const newCompose = updateComposeImageTags(compose, { name, version }); | ||
| writeCompose(newCompose, { dir, composeFileName }); | ||
| return nextVersion; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
versionis a name that says nothing, what aboutbumpVersion?