Skip to content

Commit 80bd595

Browse files
authored
Merge pull request #145 from NaverPayDev/revert-142-feature/141
Revert "[editorconfig, markdown-lint] postinstall 스크립트 제거"
2 parents d8f1315 + a325b8b commit 80bd595

8 files changed

Lines changed: 51 additions & 57 deletions

File tree

.changeset/brave-tigers-fly.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

.changeset/gentle-clouds-march.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

packages/editorconfig/README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44

55
## 설치 방법
66

7-
[`@naverpay/code-style-cli`](../code-style-cli/README.md)를 사용하여 설치하는 것을 권장합니다.
8-
97
```bash
10-
npx @naverpay/code-style-cli
8+
npm install @naverpay/editorconfig -D
119
```
1210

13-
또는 직접 설치 후 설정 파일을 복사할 수 있습니다.
11+
## 주의 사항
1412

15-
```bash
16-
npm install @naverpay/editorconfig -D
17-
cp node_modules/@naverpay/editorconfig/.editorconfig .editorconfig
18-
```
13+
- pnpm 으로 설치 후 `.editorconfig` 파일이 생성되지 않았다면, `node_modules` 를 삭제 후 [side-effects-cache](https://pnpm.io/npmrc#side-effects-cache) 설정을 false로 하고 다시 설치해주세요.
14+
15+
```bash
16+
pnpm install @naverpay/editorconfig -D --side-effects-cache false
17+
```
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env node
2+
/* eslint-disable no-console */
3+
const {execSync} = require('child_process')
4+
const fs = require('fs')
5+
const path = require('path')
6+
7+
const createConfigFile = (dirname, fileName, destFileName = fileName) => {
8+
try {
9+
const source = path.join(dirname, fileName)
10+
const config = fs.readFileSync(source)
11+
12+
const gitRoot = execSync('git rev-parse --show-toplevel').toString().trim()
13+
const dest = path.join(gitRoot, destFileName)
14+
15+
if (fs.existsSync(dest)) {
16+
process.exit(0)
17+
}
18+
fs.writeFileSync(dest, config)
19+
console.log(`${destFileName} is created successfully`)
20+
} catch (error) {
21+
console.log(`Failed to create ${destFileName}`)
22+
console.log(error?.message)
23+
process.exit(0)
24+
}
25+
}
26+
27+
module.exports = {
28+
createConfigFile,
29+
}

packages/editorconfig/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const {createConfigFile} = require('./createConfigFile')
2+
3+
createConfigFile(__dirname, '.editorconfig')

packages/editorconfig/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@
1313
},
1414
"license": "MIT",
1515
"author": "@NaverPayDev/frontend",
16-
"type": "commonjs"
16+
"type": "commonjs",
17+
"scripts": {
18+
"postinstall": "node index.js"
19+
}
1720
}

packages/markdown-lint/README.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,18 @@
33
markdown 파일 검사용 lint 도구입니다.
44
[DavidAnson/markdownlint](https://github.com/DavidAnson/markdownlint)에서 제공하는 패키지와 규칙을 사용하고 있으며, 몇 가지 rule은 커스텀 되어 있습니다.
55

6-
## 설치 방법
6+
## Installation
77

8-
[`@naverpay/code-style-cli`](../code-style-cli/README.md)를 사용하여 설치하는 것을 권장합니다.
9-
10-
```bash
11-
npx @naverpay/code-style-cli
128
```
13-
14-
또는 직접 설치 후 설정 파일을 생성할 수 있습니다.
15-
16-
```bash
17-
npm install @naverpay/markdown-lint -D
18-
echo '{"extends": "@naverpay/markdown-lint"}' > .markdownlint.jsonc
9+
npm i @naverpay/markdown-lint -D
1910
```
2011

2112
## Config
2213

23-
> [markdown-lint config](./.markdownlint.jsonc)[jsonc](https://code.visualstudio.com/docs/languages/json#_json-with-comments) 형식으로 작성되어 있어, 주석을 통해 rule에 대한 설명을 확인할 수 있습니다.
14+
`@naverpay/markdown-lint`를 설치하면 `postinstall`을 통해 자동으로 `.markdownlint.json`이 생성됩니다.
15+
이미 `.markdownlint.json`이 존재한다면 생성되지 않습니다.
16+
17+
> [markdown-lint config](./.markdownlint.jsonc)[jsonc](https://code.visualstudio.com/docs/languages/json#_json-with-comments) 형식으로 작성되어 있어, 주석을 통해 rule에 대한 설명을 확인할 수 있습니다.
2418
> 각 규칙의 명세는 [여기](https://github.com/markdownlint/markdownlint/blob/main/docs/RULES.md)서 확인할 수 있습니다.
2519
2620
## Integrating with IDE

packages/markdown-lint/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
},
2222
"files": [
2323
"cli.js",
24+
"postInstall",
2425
".markdownlint.jsonc"
2526
],
2627
"scripts": {
28+
"postinstall": "node postInstall/index.js",
2729
"test": "jest --config jest.config.js"
2830
},
2931
"dependencies": {

0 commit comments

Comments
 (0)