Skip to content
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

fix: fail setup if .prettierrc exists #681

Merged
merged 2 commits into from
Mar 2, 2020

Conversation

heavenshell
Copy link
Contributor

@heavenshell heavenshell commented Feb 29, 2020

Hi,

If .prettierrc contains parser, shipjs setup raised following error.

$ shipjs setup
? What is your base branch?
  This is also called "Default branch".
  You usually merge pull-requests into this branch. master
? What is your release branch?
  If you maintain a branch where you keep latest release, choose the branch.
  If you don't, choose your base branch. master
? Which CI configure? GitHub Actions
? Add manual prepare with issue comment?
  You can create `@shipjs prepare` comment on any issue and then github actions
run `shipjs prepare` Yes
? Schedule your release? No
› Installing Ship.js
› Adding scripts to package.json
{ SyntaxError: ';' expected. (2:9)
  1 | {
> 2 |   "name": "boilerplate",
    |         ^
  3 |   "version": "1.0.0",
  4 |   "main": "index.js",
  5 |   "license": "BSD-3-Clause",
    at t (/tmp/boilerplate/node_modules/prettier/parser-typescript.js:1:285)
    at Object.parse (/tmp/boilerplate/node_modules/prettier/parser-typescript.js:14:180461)
    at Object.parse (/tmp/boilerplate/node_modules/prettier/index.js:9739:19)
    at coreFormat (/tmp/boilerplate/node_modules/prettier/index.js:13252:23)
    at format (/tmp/boilerplate/node_modules/prettier/index.js:13510:73)
    at formatWithCursor (/tmp/boilerplate/node_modules/prettier/index.js:13526:12)
    at /tmp/boilerplate/node_modules/prettier/index.js:44207:15
    at Proxy.format (/tmp/boilerplate/node_modules/prettier/index.js:44226:12)
    at runPrettier (/tmp/boilerplate/node_modules/shipjs/src/helper/runPrettier.js:8:30)
  loc: { start: { line: 2, column: 9 } },
  codeFrame:
   '\u001b[0m \u001b[90m 1 | \u001b[39m{\u001b[0m\n\u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[39m\u001b[90m 2 | \u001b[39m  \u001b[32m"name"\u001b[39m\u001b[33m:\u001b[39m \u001b[32m"boilerplate"\u001b[39m\u001b[33m,\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m   | \u001b[39m        \u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 3 | \u001b[39m  \u001b[32m"version"\u001b[39m\u001b[33m:\u001b[39m \u001b[32m"1.0.0"\u001b[39m\u001b[33m,\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 4 | \u001b[39m  \u001b[32m"main"\u001b[39m\u001b[33m:\u001b[39m \u001b[32m"index.js"\u001b[39m\u001b[33m,\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 5 | \u001b[39m  \u001b[32m"license"\u001b[39m\u001b[33m:\u001b[39m \u001b[32m"BSD-3-Clause"\u001b[39m\u001b[33m,\u001b[39m\u001b[0m' }

I have .prettierrc.

$ cat .prettierrc 
{
  "bracketSpacing": true,
  "parser": "typescript",
  "semi": false,
  "singleQuote": true,
  "tabWidth": 2,
  "trailingComma": "es5",
  "useTabs": false
}

After fix

$ shipjs setup
? What is your base branch?
  This is also called "Default branch".
  You usually merge pull-requests into this branch. master
? What is your release branch?
  If you maintain a branch where you keep latest release, choose the branch.
  If you don't, choose your base branch. master
? Which CI configure? GitHub Actions
? Add manual prepare with issue comment?
  You can create `@shipjs prepare` comment on any issue and then github actions
run `shipjs prepare` Yes
? Schedule your release? No
› Installing Ship.js
› Adding scripts to package.json
› Creating ship.config.js
› Creating GitHub Actions configuration

🎉  FINISHED

✔ Installed shipjs as devDependency.

✔ Added `release:prepare` and `release:trigger` in `scripts` section of `package.json`.

✔ Created `ship.config.js`.
  You can learn more about the configuration.
  > https://community.algolia.com/shipjs/guide/useful-config.html

✔ Created `.github/workflows/shipjs-trigger.yml`.
✔ Created `.github/workflows/shipjs-manual-prepare.yml`.
  You still need to finish setting up GitHub Actions.
  > https://community.algolia.com/shipjs/guide/getting-started.html#setup-github-actions

Could you review this?
Thank you.

...(options || {}),
parser: getParser(filePath),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parser should override config's parser.

@heavenshell heavenshell changed the title Fix fail setup if .prettierrc exists fix: fail setup if .prettierrc exists Feb 29, 2020
Copy link
Contributor

@Haroenv Haroenv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks correct to me, thanks!

@eunjae-lee eunjae-lee merged commit 39b93be into algolia:master Mar 2, 2020
@eunjae-lee
Copy link
Contributor

@heavenshell Thanks for the contribution 🎉
Feel free to open a new PR to add yourself as a contributor.

yarn contributors:add heavenshell code

@heavenshell heavenshell deleted the fix/setup branch March 2, 2020 12:18
@heavenshell
Copy link
Contributor Author

@eunjae-lee Thanks for suggestion.
I just create new PR 🙏
#686

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.

3 participants