prettier / prettier-eslint-cli

CLI for prettier-eslint
https://npm.im/prettier-eslint-cli
MIT License
539 stars 85 forks source link

Add prepare script, to allow installation from Git #424

Closed andersk closed 2 years ago

andersk commented 3 years ago

This fixes npm i prettier/prettier-eslint-cli, which pulls the package from GitHub instead of NPM. Before:

$ npm i prettier/prettier-eslint-cli
npm WARN deprecated messageformat@2.3.0: Package renamed as '@messageformat/core', see messageformat.github.io for more details. 'messageformat' will eventually provide a polyfill for Intl.MessageFormat, once it's been defined by Unicode & ECMA.
npm ERR! code ENOENT
npm ERR! syscall chmod
npm ERR! path /tmp/test/node_modules/prettier-eslint-cli/dist/index.js
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, chmod '/tmp/test/node_modules/prettier-eslint-cli/dist/index.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

After:

$ npm i andersk/prettier-eslint-cli#f836fdbed2acd14d34c3548d9bf085647e05557f
npm WARN deprecated messageformat@2.3.0: Package renamed as '@messageformat/core', see messageformat.github.io for more details. 'messageformat' will eventually provide a polyfill for Intl.MessageFormat, once it's been defined by Unicode & ECMA.

added 196 packages, and audited 197 packages in 48s

8 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

$ npx prettier-eslint-cli --version
0.0.0-development
JounQin commented 2 years ago

Personally, I think installing from Git is not a good practice unless you have to, why are you using this approach instead of using the npm one?

andersk commented 2 years ago

It’s convenient for testing pull requests in the context of another project. The one I wanted to test at the time was #423:

npm i prettier/prettier-eslint-cli#dependabot/npm_and_yarn/prettier-eslint-13.0.0

Nobody’s suggesting this should replace NPM releases; it should just be possible.

JounQin commented 2 years ago

@andersk

Thanks for explaining first.

I know it's not replacing npm, and I'm saying installing from Git should not be encouraged.

And the purpose you want to achieve can be done with other tools like https://ci.codesandbox.io/

andersk commented 2 years ago

Firstly, I don’t want to run it in a cloud sandbox; I want to run locally on my project.

Secondly, even if I wanted to use CodeSandbox, how is CodeSandbox supposed to know that it needs to run nps build, if there’s no prepare script to tell it which build command to run?

JounQin commented 2 years ago

Firstly, I don’t want to run it in a cloud sandbox; I want to run locally on my project.

I don't understand why and what's the difference.

Secondly, even if I wanted to use CodeSandbox, how is CodeSandbox supposed to know that it needs to run nps build, if there’s no prepare script to tell it which build command to run?

It has buildCommand configuration support.

JounQin commented 2 years ago

Codesandbox ci is a tool we need to install as GitHub App in this repository for this case.

andersk commented 2 years ago

I don't understand why and what's the difference.

I am working on some project, say https://github.com/zulip/zulip-mobile, that uses prettier-eslint-cli. The zulip-mobile code is on my computer—I got it with git clone on my computer, set up all its dependencies on my computer, and have been working on it for years using the development tools on my computer. Now I want to test a PR of prettier-eslint-cli within zulip-mobile. I want to run npm i prettier/prettier-eslint-cli#dependabot/npm_and_yarn/prettier-eslint-13.0.0 within my local zulip-mobile checkout, and then run zulip-mobile’s scripts that rely on prettier-eslint-cli (e.g. tools/fmt), and inspect the formatting result with my local editor and tools like git diff.

I’m a little baffled that I should need to explain the difference between running something locally on my computer and running it in a cloud. Perhaps we’re running into a language barrier? Or perhaps you’re someone who does all development work in a cloud and doesn’t even know that developing locally is even possible? I don’t mean to be rude—this concept is so obvious to me that I’m struggling to see how anyone with software development experience would be confused by it.

JounQin commented 2 years ago

@andersk

Sorry, I may have misled you.

There is nothing related to development on cloud.

Take https://github.com/un-ts/prettier/pull/209#issuecomment-1198919254 as an example of codesandbox ci usage, it's a tool to help us test before releasing, that's exactly what you want, actually.

# yarn 1
yarn add https://pkg.csb.dev/un-ts/prettier/commit/4b3eca06/prettier-plugin-pkg https://pkg.csb.dev/un-ts/prettier/commit/4b3eca06/prettier-plugin-sh https://pkg.csb.dev/un-ts/prettier/commit/4b3eca06/prettier-plugin-sql
# yarn 2, 3
yarn add prettier-plugin-pkg@https://pkg.csb.dev/un-ts/prettier/commit/4b3eca06/prettier-plugin-pkg/_pkg.tgz prettier-plugin-sh@https://pkg.csb.dev/un-ts/prettier/commit/4b3eca06/prettier-plugin-sh/_pkg.tgz prettier-plugin-sql@https://pkg.csb.dev/un-ts/prettier/commit/4b3eca06/prettier-plugin-sql/_pkg.tgz
# npm
npm i https://pkg.csb.dev/un-ts/prettier/commit/4b3eca06/prettier-plugin-pkg https://pkg.csb.dev/un-ts/prettier/commit/4b3eca06/prettier-plugin-sh https://pkg.csb.dev/un-ts/prettier/commit/4b3eca06/prettier-plugin-sql

It has not been enabled in this repository, sadly. I'll try to apply to install the GitHub App ASAP.

JounQin commented 2 years ago

CodeSandbox CI has been enabled in this repo, so it can be installed easily for every PR commit.

See https://github.com/prettier/prettier-eslint-cli/pull/437#issuecomment-1213199333

idahogurl commented 2 years ago

@JounQin He didn't want to use CodeSandbox. Instead of pointing to the NPM registry, you can point to a GitHub repository in your package.json. I'll clone this PR and test it out to answer some of my questions.

JounQin commented 2 years ago

@JounQin He didn't want to use CodeSandbox. Instead of pointing to the NPM registry, you can point to a GitHub repository in your package.json. I'll clone this PR and test it out to answer some of my questions.

He misunderstood what I'm proposing. CodeSandbox CI is not cloud development. It seems same as you.

Install from GitHub is a bad idea IMO.

# yarn 1
yarn add https://pkg.csb.dev/prettier/prettier-eslint-cli/commit/eb8e934a/prettier-eslint-cli
# yarn 2, 3
yarn add prettier-eslint-cli@https://pkg.csb.dev/prettier/prettier-eslint-cli/commit/eb8e934a/prettier-eslint-cli/_pkg.tgz
# npm
npm i https://pkg.csb.dev/prettier/prettier-eslint-cli/commit/eb8e934a/prettier-eslint-cli

It is available on your own machine. Not CodeSandbox only.