|
| 1 | +import fs from 'fs' |
| 2 | + |
| 3 | +// 설정 파일 내용 |
| 4 | +const PRETTIERRC_CONTENT = '"@naverpay/prettier-config"' |
| 5 | + |
| 6 | +const STYLELINT_CONTENT = `/** @type {import('stylelint').Config} */ |
| 7 | +const config = { |
| 8 | + extends: ['@naverpay/stylelint-config'], |
| 9 | + defaultSeverity: 'error', |
| 10 | + rules: {}, |
| 11 | +} |
| 12 | +
|
| 13 | +export default config |
| 14 | +` |
| 15 | + |
| 16 | +const MARKDOWNLINT_CONTENT = JSON.stringify( |
| 17 | + { |
| 18 | + extends: '@naverpay/markdown-lint', |
| 19 | + }, |
| 20 | + null, |
| 21 | + 4, |
| 22 | +) |
| 23 | + |
| 24 | +const OXLINTRC_CONTENT = JSON.stringify( |
| 25 | + { |
| 26 | + $schema: './node_modules/oxlint/configuration_schema.json', |
| 27 | + extends: ['./node_modules/@naverpay/oxlint-config/node/.oxlintrc.json'], |
| 28 | + }, |
| 29 | + null, |
| 30 | + 4, |
| 31 | +) |
| 32 | + |
| 33 | +function getBiomeContent() { |
| 34 | + const pkgJson = JSON.parse(fs.readFileSync('package.json', 'utf-8')) |
| 35 | + const version = pkgJson.devDependencies?.['@biomejs/biome']?.replace(/[\^~]/, '') |
| 36 | + if (!version) return null |
| 37 | + return JSON.stringify( |
| 38 | + { |
| 39 | + $schema: `https://biomejs.dev/schemas/${version}/schema.json`, |
| 40 | + extends: ['@naverpay/biome-config'], |
| 41 | + }, |
| 42 | + null, |
| 43 | + 4, |
| 44 | + ) |
| 45 | +} |
| 46 | + |
| 47 | +const OXFMTRC_CONTENT = JSON.stringify( |
| 48 | + { |
| 49 | + $schema: './node_modules/oxfmt/configuration_schema.json', |
| 50 | + singleQuote: true, |
| 51 | + semi: false, |
| 52 | + useTabs: false, |
| 53 | + tabWidth: 4, |
| 54 | + endOfLine: 'lf', |
| 55 | + bracketSpacing: false, |
| 56 | + arrowParens: 'always', |
| 57 | + bracketSameLine: false, |
| 58 | + printWidth: 120, |
| 59 | + trailingComma: 'all', |
| 60 | + }, |
| 61 | + null, |
| 62 | + 4, |
| 63 | +) |
| 64 | + |
| 65 | +// 패키지 목록 |
| 66 | +export const TOOLS = [ |
| 67 | + {value: 'eslint-config', packages: ['@naverpay/eslint-config']}, |
| 68 | + {value: 'eslint-plugin', packages: ['@naverpay/eslint-plugin']}, |
| 69 | + { |
| 70 | + value: 'prettier-config', |
| 71 | + packages: ['@naverpay/prettier-config'], |
| 72 | + configFile: '.prettierrc', |
| 73 | + configContent: PRETTIERRC_CONTENT, |
| 74 | + }, |
| 75 | + { |
| 76 | + value: 'stylelint-config', |
| 77 | + packages: ['@naverpay/stylelint-config', 'stylelint'], |
| 78 | + configFile: 'stylelint.config.mjs', |
| 79 | + configContent: STYLELINT_CONTENT, |
| 80 | + }, |
| 81 | + { |
| 82 | + value: 'markdown-lint', |
| 83 | + packages: ['@naverpay/markdown-lint'], |
| 84 | + configFile: '.markdownlint.jsonc', |
| 85 | + configContent: MARKDOWNLINT_CONTENT, |
| 86 | + }, |
| 87 | + { |
| 88 | + value: 'editorconfig', |
| 89 | + packages: ['@naverpay/editorconfig'], |
| 90 | + configFile: '.editorconfig', |
| 91 | + copyFrom: 'node_modules/@naverpay/editorconfig/.editorconfig', |
| 92 | + }, |
| 93 | + { |
| 94 | + value: 'oxlint-config', |
| 95 | + packages: ['@naverpay/oxlint-config', 'oxlint'], |
| 96 | + configFile: '.oxlintrc.json', |
| 97 | + configContent: OXLINTRC_CONTENT, |
| 98 | + }, |
| 99 | + { |
| 100 | + value: 'biome-config', |
| 101 | + packages: ['@naverpay/biome-config', '@biomejs/biome'], |
| 102 | + configFile: 'biome.json', |
| 103 | + getContent: getBiomeContent, |
| 104 | + }, |
| 105 | + {value: 'oxfmt', packages: ['oxfmt'], configFile: '.oxfmtrc.json', configContent: OXFMTRC_CONTENT}, |
| 106 | +] |
| 107 | + |
| 108 | +export const TOOLS_MAP = Object.fromEntries(TOOLS.map((t) => [t.value, t])) |
| 109 | + |
| 110 | +export const PACKAGE_MANAGERS = { |
| 111 | + npm: {lockFile: 'package-lock.json', installCmd: 'npm install -D'}, |
| 112 | + yarn: {lockFile: 'yarn.lock', installCmd: 'yarn add -D'}, |
| 113 | + pnpm: {lockFile: 'pnpm-lock.yaml', installCmd: 'pnpm add -D'}, |
| 114 | +} |
0 commit comments