From 5cfaba6a1c501bba9b9c2170da7dcacc648baf3e Mon Sep 17 00:00:00 2001 From: Ika Date: Fri, 22 Jun 2018 12:37:52 +0800 Subject: [PATCH] chore(ISSUE_TEMPLATE): add template for integration issue (#4722) Ref: https://blog.github.com/2018-05-02-issue-template-improvements/ ![image](https://user-images.githubusercontent.com/8341033/41692826-e7b98d06-7534-11e8-9b51-54a04c097681.png) So that people would know what kind of info we need to know to understand issues like #4720. --- .github/ISSUE_TEMPLATE.md | 46 ------------------------- .github/ISSUE_TEMPLATE/formatting.md | 46 +++++++++++++++++++++++++ .github/ISSUE_TEMPLATE/integration.md | 32 +++++++++++++++++ scripts/release/steps/update-version.js | 15 ++++---- scripts/release/utils.js | 6 ++++ 5 files changed, 91 insertions(+), 54 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/ISSUE_TEMPLATE/formatting.md create mode 100644 .github/ISSUE_TEMPLATE/integration.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index e61cea106..000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,46 +0,0 @@ - - -**Prettier 1.13.5** -[Playground link](https://prettier.io/playground/#.....) -```sh -# Options (if any): ---single-quote -``` - -**Input:** -```jsx -// code snippet -``` - -**Output:** -```jsx -// code snippet -``` - -**Expected behavior:** diff --git a/.github/ISSUE_TEMPLATE/formatting.md b/.github/ISSUE_TEMPLATE/formatting.md new file mode 100644 index 000000000..b9b787f56 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/formatting.md @@ -0,0 +1,46 @@ +--- +name: ✨ Formatting +about: Issues for ugly or incorrect code +--- + + + +**Prettier 1.13.5** +[Playground link](https://prettier.io/playground/#.....) +```sh +# Options (if any): +--single-quote +``` + +**Input:** +```jsx +// code snippet +``` + +**Output:** +```jsx +// code snippet +``` + +**Expected behavior:** diff --git a/.github/ISSUE_TEMPLATE/integration.md b/.github/ISSUE_TEMPLATE/integration.md new file mode 100644 index 000000000..50686944a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/integration.md @@ -0,0 +1,32 @@ +--- +name: ⚙ Integration +about: Issues for API, CLI, etc. +--- + + + +**Environments:** +- Prettier Version: 1.13.5 +- Running Prettier via: +- Runtime: +- Operating System: + +**Steps to reproduce:** + + +**Expected behavior:** + +**Actual behavior:** diff --git a/scripts/release/steps/update-version.js b/scripts/release/steps/update-version.js index 4777908d3..733ebb771 100644 --- a/scripts/release/steps/update-version.js +++ b/scripts/release/steps/update-version.js @@ -1,20 +1,19 @@ "use strict"; const execa = require("execa"); -const { readFileSync, writeFileSync } = require("fs"); -const { logPromise, readJson, writeJson } = require("../utils"); +const { logPromise, readJson, writeJson, processFile } = require("../utils"); async function bump({ version }) { const pkg = await readJson("package.json"); pkg.version = version; await writeJson("package.json", pkg, { spaces: 2 }); - // Update .github/ISSUE_TEMPLATE.MD - const issueFile = ".github/ISSUE_TEMPLATE.md"; - const issueTempl = readFileSync(issueFile, "utf-8"); - writeFileSync( - issueFile, - issueTempl.replace(/^\*\*Prettier .*?\*\*$/m, `**Prettier ${version}**`) + // Update github issue templates + processFile(".github/ISSUE_TEMPLATE/formatting.md", content => + content.replace(/^(\*\*Prettier ).*?(\*\*)$/m, `$1${version}$2`) + ); + processFile(".github/ISSUE_TEMPLATE/integration.md", content => + content.replace(/^(- Prettier Version: ).*?$/m, `$1${version}`) ); } diff --git a/scripts/release/utils.js b/scripts/release/utils.js index 5b09eea78..55a7d940d 100644 --- a/scripts/release/utils.js +++ b/scripts/release/utils.js @@ -70,9 +70,15 @@ function writeJson(filename, content) { fs.writeFileSync(filename, JSON.stringify(content, null, 2) + "\n"); } +function processFile(filename, fn) { + const content = fs.readFileSync(filename, "utf-8"); + fs.writeFileSync(filename, fn(content)); +} + module.exports = { runYarn, logPromise, + processFile, readJson, writeJson, waitForEnter