Skip to content

Commit

Permalink
refactor: spelling fixes (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoref authored Feb 24, 2021
1 parent c94445d commit 2e8d2cb
Show file tree
Hide file tree
Showing 31 changed files with 83 additions and 83 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ npm install --save-dev dripip

![diagram](https://dsc.cloud/661643/dripip.png)

Dripip is a command line interface (CLI) for continuously releasing npm packages. It has support for three kinds of releases: pull-request releases, canary releases, stable releases. It builds on top of Git, Semver, Conventional Commit, and GitHub. Support for alterntive version control systems (e.g. Darcs) and platforms (e.g. GitLab) are not currently supported but they probably could be. The concepts of dripip are relatively general.
Dripip is a command line interface (CLI) for continuously releasing npm packages. It has support for three kinds of releases: pull-request releases, canary releases, stable releases. It builds on top of Git, Semver, Conventional Commit, and GitHub. Support for alternative version control systems (e.g. Darcs) and platforms (e.g. GitLab) are not currently supported but they probably could be. The concepts of dripip are relatively general.

Continuous delivery means that every single meaningful commit to your library will be released. The benefit of this approach is that when you ship value your users get access to it immeditely, and as an author you don't need to manage incoming queries like "when will this be released?". You get to to auto-reply: "It already it! :)".
Continuous delivery means that every single meaningful commit to your library will be released. The benefit of this approach is that when you ship value your users get access to it immediately, and as an author you don't need to manage incoming queries like "when will this be released?". You get to to auto-reply: "It already it! :)".

### Pull-Request Releases

Expand All @@ -63,7 +63,7 @@ The `pr_num` part is the pull-request number. The same one that you see on the G

The `pr_release_num` is a monotonically increasing 1-based (starts from 1, not 0) integer. It serves a few purposes. It provides orientation for humans at a glance, like how many releases has a PR had or where does a given release fall within the PR release set. Its functional purpose is to support correct lexical sorting. Without this little number it would be impossible to sort PR releases without some kind of additional metadata e.g. publish time. Thanks to this, when you run e.g. `npm versions`, you get an accurate ordering.

The `short_sha` is what you see next to commits in much of the GitHub UI, including PR pages. Its primary purpose is to make it easy for you to tie a release back to something in your Git history. For example when looking at a PR page you can copy-paste the sha into search to find the exact commit for that release. Whatever the particular, this is just a convenient piece of information for you. Ultimately we develoeprs pratice many a crude workflow, habbits (console.log vs debugger anyone?).
The `short_sha` is what you see next to commits in much of the GitHub UI, including PR pages. Its primary purpose is to make it easy for you to tie a release back to something in your Git history. For example when looking at a PR page you can copy-paste the sha into search to find the exact commit for that release. Whatever the particular, this is just a convenient piece of information for you. Ultimately we developers practice many a crude workflow, habits (console.log vs debugger anyone?).

When Dripip makes a pr release, it includes an upsert of a dist-tag of pattern `pr.${pr_num}`. This makes it very easy to install the latest published version for a given pull-request.

Expand Down Expand Up @@ -110,7 +110,7 @@ When Dripip makes a canary release, it includes an upsert of a dist-tag called `

### Package.json Version Field

Typically when an npm package is released its package.json `version` field will be updated and committed into version control. This is a bad match for continuous delivery however, because it meanss that, more or less, half of the git history will become meta commits. To solve this, `dripip` takes a novel approach of keeping the version out of version control. It uses Git tags to store that state, and when publishing your package, will set the package.json `version` field right before publishing, and then unset it right after publishing completes. You notice nothing, your users notice nothing, and your git history looks ideal. This is unorthadox, but it works well.
Typically when an npm package is released its package.json `version` field will be updated and committed into version control. This is a bad match for continuous delivery however, because it means that, more or less, half of the git history will become meta commits. To solve this, `dripip` takes a novel approach of keeping the version out of version control. It uses Git tags to store that state, and when publishing your package, will set the package.json `version` field right before publishing, and then unset it right after publishing completes. You notice nothing, your users notice nothing, and your git history looks ideal. This is unorthodox, but it works well.

Having a valid semver value in the `version` field is required by npm. Dripip puts the following value into your project's package.json to satisfy that constraint. This is what you should check into version control.

Expand All @@ -134,7 +134,7 @@ For example checkout what's coming up in dripip right now by visiting https://gi

### Usage inside GitHub Actions

We are interseted in building a `dripip` GitHub Action. Until it ships, here are the things you need to do.
We are interested in building a `dripip` GitHub Action. Until it ships, here are the things you need to do.

1. Have `dripip` installed as a dev dependency
1. Upload an `NPM_TOKEN` to your repo ([gh docs](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets))
Expand Down Expand Up @@ -254,7 +254,7 @@ OPTIONS
-n, --build-num=build-num Force a build number. Should not be needed generally. For exceptional cases.
--skip-npm skip the step of publishing the package to npm

--trunk=trunk State which branch is trunk. Defaults to honuring the "base" branch setting in the GitHub
--trunk=trunk State which branch is trunk. Defaults to honoring the "base" branch setting in the GitHub
repo settings.
```
Expand All @@ -278,7 +278,7 @@ OPTIONS
-j, --json format output as JSON
--skip-npm skip the step of publishing the package to npm

--trunk=trunk State which branch is trunk. Defaults to honuring the "base" branch setting in the GitHub repo
--trunk=trunk State which branch is trunk. Defaults to honoring the "base" branch setting in the GitHub repo
settings.
```
<!-- commandsstop -->
2 changes: 1 addition & 1 deletion src/cli/commands/get-current-commit-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class GetCurrentCommitVersion extends Command {
// Note:
//
// - PR release should not be possible on same commit as stable/preview
// anyways
// anyway
//
// - PR release is much more costly to calculate than others
//
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class Preview extends Command {
trunk: flags.string({
default: '',
description:
'State which branch is trunk. Defaults to honuring the "base" branch setting in the GitHub repo settings.',
'State which branch is trunk. Defaults to honoring the "base" branch setting in the GitHub repo settings.',
}),
['build-num']: flags.integer({
description: 'Force a build number. Should not be needed generally. For exceptional cases.',
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/stable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class Stable extends Command {
trunk: flags.string({
default: '',
description:
'State which branch is trunk. Defaults to honuring the "base" branch setting in the GitHub repo settings.',
'State which branch is trunk. Defaults to honoring the "base" branch setting in the GitHub repo settings.',
}),
'dry-run': flags.boolean({
default: false,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/changelog/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ exports[`.render() with markdown renders release changelog for the current relea
"
`;

exports[`.render() with termimal renders changelog for the current release series 1`] = `
exports[`.render() with terminal renders changelog for the current release series 1`] = `
"BREAKING CHANGES
shasha# a
Expand Down
2 changes: 1 addition & 1 deletion src/lib/changelog/data.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This module deals with building changelogs from serieses.
* This module deals with building changelogs from multiple series.
*/
import { Commit } from '../../utils/release'

Expand Down
2 changes: 1 addition & 1 deletion src/lib/changelog/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('.render() with markdown', () => {
})
})

describe('.render() with termimal', () => {
describe('.render() with terminal', () => {
const render = (...commits: Release.MockCommit[]) => {
return Changelog.render(Changelog.fromSeries(Release.fromMockCommits(commits)), { as: 'plain' })
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/conventional-commit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function calcBumpType(
if (isMinorChange(cc)) {
semverPart = 'minor'
// during initial development breaking changes are permitted without
// having to bump the major. Therefore, we know we won't get a bunmpType
// having to bump the major. Therefore, we know we won't get a bumpType
// higher than this, can short-circuit.
if (isInitialDevelopment) break
else continue
Expand Down
30 changes: 15 additions & 15 deletions src/lib/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ export async function gitInitRepo(git: Simple): Promise<void> {
/**
* Create an empty commit in the repo.
*/
export async function gitCreateEmptyCommit(git: Simple, messge?: string): Promise<void> {
await git.raw(['commit', '--allow-empty', '--message', messge ?? 'Nothing to see here, move along'])
export async function gitCreateEmptyCommit(git: Simple, message?: string): Promise<void> {
await git.raw(['commit', '--allow-empty', '--message', message ?? 'Nothing to see here, move along'])
}

export async function createFixCommit(git: Simple, msg?: string) {
Expand Down Expand Up @@ -160,7 +160,7 @@ export async function gitDeleteAllTagsInRepo(git: Simple): Promise<void> {
// }
// }
//
// const githubRepo = await parseGithubRepoInfoFromGitConfig()
// const githubRepo = await parseGitHubRepoInfoFromGitConfig()

// // TODO Refactor this to have instance passed as arg.
// const octoOps = {} as Octokit.Options
Expand All @@ -174,7 +174,7 @@ export async function gitDeleteAllTagsInRepo(git: Simple): Promise<void> {
// // to trunk branch?", etc.
// //
// // To attain this level of feedback users would need to accept potentially
// // higher levels of latentcy to pagination through all pull-requests.
// // higher levels of latency to pagination through all pull-requests.
// // TODO pagination https://octokit.github.io/rest.js/#pagination
// const pullsRes = await octokit.pulls.list({
// owner: githubRepo.owner,
Expand Down Expand Up @@ -203,8 +203,8 @@ type SyncStatus = 'needs_pull' | 'needs_push' | 'synced' | 'diverged' | 'remote_
export async function checkSyncStatus(git: Simple): Promise<SyncStatus> {
await git.remote(['update'])
const remoteHeads = await git.raw(['ls-remote', '--heads'])
const branchSumamry = await git.branch({})
const branchOnRemoteRE = new RegExp(`.*refs/heads/${branchSumamry.current}$`, 'm')
const branchSummary = await git.branch({})
const branchOnRemoteRE = new RegExp(`.*refs/heads/${branchSummary.current}$`, 'm')

if (remoteHeads.match(branchOnRemoteRE) === null) {
return 'remote_needs_branch'
Expand All @@ -225,7 +225,7 @@ export async function checkSyncStatus(git: Simple): Promise<SyncStatus> {
: 'diverged'
}

export interface BasicGithubRepoInfo {
export interface BasicGitHubRepoInfo {
name: string
owner: string
}
Expand All @@ -234,7 +234,7 @@ export interface BasicGithubRepoInfo {
* Extract the github repo name and owner from the git config. If anything goes
* wrong during extraction a specific error about it will be thrown.
*/
export async function parseGithubRepoInfoFromGitConfig(): Promise<BasicGithubRepoInfo> {
export async function parseGitHubRepoInfoFromGitConfig(): Promise<BasicGitHubRepoInfo> {
// Inspiration from how `$ hub pr show` works
// https://github.com/github/hub/blob/a5fbf29be61a36b86c7f0ff9e9fd21090304c01f/commands/pr.go#L327

Expand Down Expand Up @@ -275,14 +275,14 @@ export async function parseGithubRepoInfoFromGitConfig(): Promise<BasicGithubRep
}

/**
* Determin if the current branch is trunk or not. Currently a simple check
* Determine if the current branch is trunk or not. Currently a simple check
* against if current branch is master or not but TODO in the future will
* account for checking against the remote Git repo for if the so-called `base`
* branch of the repo is set to something else than `master`.
*/
export async function isTrunk(git: Simple): Promise<boolean> {
const branchSumamry = await git.branch({})
return branchSumamry.current === 'master'
const branchSummary = await git.branch({})
return branchSummary.current === 'master'
}

/**
Expand Down Expand Up @@ -353,7 +353,7 @@ export async function log(git: Simple, ops?: { since?: null | string }): Promise
}

const logEntrySeparator = '$@<!____LOG____!>@$'
const logEntryValueSepartaor = '$@<!____PROP____!>@$'
const logEntryValueSeparator = '$@<!____PROP____!>@$'

type CommitDatum = { name: string; code: 'H' | 'D' | 's' | 'b' | 'B' }

Expand All @@ -367,7 +367,7 @@ export const commitDatums: CommitDatum[] = [
const commitDatumNames = commitDatums.map((datum) => datum.name)

export function gitLogFormat(commitDatums: CommitDatum[]): string {
return commitDatums.map((part) => '%' + part.code).join(logEntryValueSepartaor) + logEntrySeparator
return commitDatums.map((part) => '%' + part.code).join(logEntryValueSeparator) + logEntrySeparator
}

export function parseRawLog(rawLog: string): LogEntryWithRefs[] {
Expand All @@ -385,7 +385,7 @@ export function parseRawLogEntry(rawLogEntry: string): LogEntryWithRefs {
// propsRemaining and logParts are guaranteed to be the same length
// TODO should be a zip...
const propsRemaining = [...commitDatumNames]
const logParts = rawLogEntry.split(logEntryValueSepartaor)
const logParts = rawLogEntry.split(logEntryValueSeparator)
while (propsRemaining.length > 0) {
// @ts-ignore
log[propsRemaining.shift()!] = logParts.shift()!.trim()
Expand Down Expand Up @@ -422,7 +422,7 @@ export function parseLogRefs({ refs, ...rest }: LogEntryWithRefs): LogEntry {
*/
export function serializeLog(values: [string, string, string][]): string {
if (values.length === 0) return ''
return values.map((v) => v.join(logEntryValueSepartaor)).join(logEntrySeparator) + logEntrySeparator
return values.map((v) => v.join(logEntryValueSeparator)).join(logEntrySeparator) + logEntrySeparator
}

export async function* streamLog(opts?: { cwd?: string }): AsyncGenerator<LogEntry> {
Expand Down
20 changes: 10 additions & 10 deletions src/lib/github-ci-environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { rootDebug } from './debug'

const debug = rootDebug(__filename)

export interface GithubCIEnvironment {
export interface GitHubCIEnvironment {
runId: number
eventName: 'pull_request'
ref: null | string
Expand All @@ -19,17 +19,17 @@ export interface GithubCIEnvironment {
}

/**
* Parse the Github CI Environment. Returns null if parsing fails which should
* mean it is not a Github CI Environment.
* Parse the GitHub CI Environment. Returns null if parsing fails which should
* mean it is not a GitHub CI Environment.
*
* @remarks
*
* Github docs: https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
* GitHub docs: https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
*/
export function parseGithubCIEnvironment(): null | GithubCIEnvironment {
if (!isGithubCIEnvironment()) return null
export function parseGitHubCIEnvironment(): null | GitHubCIEnvironment {
if (!isGitHubCIEnvironment()) return null

let prNum: GithubCIEnvironment['parsed']['prNum']
let prNum: GitHubCIEnvironment['parsed']['prNum']

if (process.env.GITHUB_REF) {
const match = process.env.GITHUB_REF.match(/refs\/pull\/(\d+)\/merge/)
Expand All @@ -56,7 +56,7 @@ export function parseGithubCIEnvironment(): null | GithubCIEnvironment {

return {
runId: parseInt(process.env.GITHUB_RUN_ID!, 10),
eventName: process.env.GITHUB_EVENT_NAME! as GithubCIEnvironment['eventName'],
eventName: process.env.GITHUB_EVENT_NAME! as GitHubCIEnvironment['eventName'],
ref: process.env.GITHUB_REF ?? null,
headRef: process.env.GITHUB_HEAD_REF ?? null,
repository: process.env.GITHUB_REPOSITORY!,
Expand All @@ -69,8 +69,8 @@ export function parseGithubCIEnvironment(): null | GithubCIEnvironment {
}

/**
* Check if the current process appers to be running in a Github CI environment.
* Check if the current process appears to be running in a GitHub CI environment.
*/
export function isGithubCIEnvironment() {
export function isGitHubCIEnvironment() {
return process.env.GITHUB_RUN_ID !== undefined
}
4 changes: 2 additions & 2 deletions src/lib/npm-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as fs from 'fs-jetpack'
import * as os from 'os'
import * as path from 'path'
import { rootDebug } from './debug'
import { isGithubCIEnvironment } from './github-ci-environment'
import { isGitHubCIEnvironment } from './github-ci-environment'

const debug = rootDebug(__filename)

Expand All @@ -15,7 +15,7 @@ const npmrcFilePath = path.join(os.homedir(), '.npmrc')
* publishing commands.
*/
export function setupNPMAuthfileOnCI(): void {
if (isGithubCIEnvironment() && process.env.NPM_TOKEN) {
if (isGitHubCIEnvironment() && process.env.NPM_TOKEN) {
const authContent = `//registry.npmjs.org/:_authToken=${process.env[TOKEN_ENV_VAR_NAME]}`
debug('writing or appending npm auth token to %s', npmrcFilePath)
fs.append(npmrcFilePath, authContent)
Expand Down
6 changes: 3 additions & 3 deletions src/lib/package-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ type ValidatedPackageJson = PackageJson & { name: string }
*/
function validate(pj: PackageJson | undefined): ValidatedPackageJson {
if (!pj) {
throw new Error('Could not find pacakge.json')
throw new Error('Could not find package.json')
}

if (pj.name === undefined) {
throw new Error('pacakge.json is missing name field')
throw new Error('package.json is missing name field')
}

if (pj.name === '') {
throw new Error('pacakge.json name field is empty')
throw new Error('package.json name field is empty')
}

return pj as ValidatedPackageJson
Expand Down
6 changes: 3 additions & 3 deletions src/lib/pacman.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function detectScriptRunner(): null | 'npm' | 'yarn' {
*
* In the case of yarn, package.json is not touched at all.
*
* Either way, it should not be noticable to the user of this function.
* Either way, it should not be noticeable to the user of this function.
*/
async function publish(manType: PackageManagerType, input: { version: string; tag: string }): Promise<void> {
if (manType === 'yarn') {
Expand Down Expand Up @@ -91,8 +91,8 @@ async function tag(
}
}

export async function create(input: { defualt: PackageManagerType }) {
const packageManagerType = detectScriptRunner() ?? input.defualt
export async function create(input: { default: PackageManagerType }) {
const packageManagerType = detectScriptRunner() ?? input.default
const packageJson = PJ.getPackageJsonSync()
return {
publish: publish.bind(null, packageManagerType),
Expand Down
4 changes: 2 additions & 2 deletions src/lib/proc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type SuccessfulRunResult = {
stdout: null | string // present if stdio using pipe mode
signal: null | string
exitCode: null | number // present if optional (non-throw) mode
error: null | Error // present if optonal (non-throw) mode
error: null | Error // present if optional (non-throw) mode
}

export type RunOptions = SpawnOptions & {
Expand Down Expand Up @@ -157,7 +157,7 @@ function createCommandError({
${exitCode}
This underlying error occured (null = none occured):
This underlying error occurred (null = none occurred):
${underlyingError}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/publish-changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface Input {
octokit: Octokit
repo: Repo
/**
* Uses the release to manage the changelog changes. A preview relese will result
* Uses the release to manage the changelog changes. A preview release will result
* in a pre-release github release. A stable release will result in the
* preview github release being cleared of notes and pointed toward the latest
* stable commit sha.
Expand Down
Loading

0 comments on commit 2e8d2cb

Please sign in to comment.