Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat!: refactor to use execa & add git check working tree#27

Open
fratzinger wants to merge 4 commits intomainfeathersdev/pinion:mainfrom
feat/execa-gitfeathersdev/pinion:feat/execa-gitCopy head branch name to clipboard
Open

feat!: refactor to use execa & add git check working tree#27
fratzinger wants to merge 4 commits intomainfeathersdev/pinion:mainfrom
feat/execa-gitfeathersdev/pinion:feat/execa-gitCopy head branch name to clipboard

Conversation

@fratzinger
Copy link
Collaborator

@fratzinger fratzinger commented Sep 23, 2022

This is a hot take. Multiple things are going on.

Breaking:

context.pinion.exec runs https://github.com/sindresorhus/execa instead of child_process. I know it's another dependency, but it's sooo much nicer to use (Promises)!
The breaking change is: context.pinion.exec does not return Promise<number> anymore but Promise<ExecaChildProcess>. That we can access stdout easily, which is needed for a lot of operations (e.g. npm, git, yarn, npx npm-check-updates, you name it). Having that at your fingertips with context.pinion.exec is really nice! I think it's worth the breaking change.

Feat:

import { PinionContext, generator, confirmGitIsWorkingTreeClean } from '@feathershq/pinion'

export const generate = (context: Context) => generator(context)
  .then(confirmGitIsWorkingTreeClean())
  .then(/* whatever needs to be done */)

I consider this to be a core functionality. It checks if cwd is a git repository and if the working tree is clean. It shows a prompt to confirm, if the working tree is not clean.

Discussion:

I've added public utilities: utilExec, utilGitHasProjectGit. Imo they should be publicly available so developers can use them to get thing started easily. There are several problems with these utils, that are meant to be used in generators, but aren't generators:

  1. It get's confusing. What is a util, what is a generator operation?
  2. if exported globally the global @feathershq/pinion gets polluted very fast with every new util.
  3. The current naming convention utilExec and utilGitHasProjectGit help with 1. but not really with 2.. I think the best approach is to publish them under a separate folder or even package. Maybe this:
// In a separate folder:
import { exec } from '@feathershq/pinion/utils'
// would require a more complex build/compile step

// In a separate package (living in this mono-repo):
import { exec, hasProjectGit, isWorkingTreeClean } from '@feathershq/pinion-utils'

I think having a good set of common utils is a key factor to a fast adoption.

What do you think @daffl? Is @feathershq/pinion-utils the way to go? @pinion/utils would be nicer though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.