@allohamora/cli
Advanced tools
Comparing version 1.19.0 to 1.20.0
@@ -44,3 +44,2 @@ #!/usr/bin/env node | ||
const ROOT_PATH = process.cwd(); | ||
const PACKAGE_JSON_PATH = path.join(ROOT_PATH, 'package.json'); | ||
const rootPath = (...paths) => path.join(ROOT_PATH, ...paths); | ||
@@ -68,3 +67,3 @@ | ||
const filePath = rootPath(name); | ||
await fsp.writeFile(filePath, content, { encoding: 'utf-8' }); | ||
await fsp.writeFile(filePath, `${content}\n`, { encoding: 'utf-8' }); | ||
}; | ||
@@ -94,2 +93,4 @@ const addJsonFileToRoot = async (name, content) => { | ||
const PACKAGE_JSON_NAME = 'package.json'; | ||
const PACKAGE_JSON_PATH = rootPath(PACKAGE_JSON_NAME); | ||
const getPackageJson = async () => { | ||
@@ -100,4 +101,3 @@ const json = await fsp.readFile(PACKAGE_JSON_PATH, { encoding: 'utf-8' }); | ||
const setPackageJson = async (packageJson) => { | ||
const string = stringify(packageJson); | ||
await fsp.writeFile(PACKAGE_JSON_PATH, string, { encoding: 'utf-8' }); | ||
await addJsonFileToRoot(PACKAGE_JSON_NAME, packageJson); | ||
}; | ||
@@ -170,4 +170,4 @@ const addToPackageJson = async (name, value) => { | ||
const addHook = async (name, script) => { | ||
const hookPath = path.join(ROOT_PATH, HOOK_DIR, name); | ||
await fsp.writeFile(hookPath, script, { encoding: 'utf-8' }); | ||
const hookPath = path.join(HOOK_DIR, name); | ||
await addFileToRoot(hookPath, script); | ||
}; | ||
@@ -239,2 +239,3 @@ const isHuskyInstalled = isInstalledAndInRootCheck(PACKAGE_NAME$6, HOOK_DIR); | ||
eslintConfig: { | ||
files: ['**/*.{js,mjs,cjs}'], | ||
languageOptions: { | ||
@@ -253,2 +254,51 @@ globals: ['node'], | ||
const nodeTsConfig$2 = { | ||
dependencies: ['globals', '@eslint/js', 'typescript-eslint', 'eslint-plugin-beautiful-sort'], | ||
imports: [ | ||
`import globals from 'globals'`, | ||
`import eslint from '@eslint/js'`, | ||
`import tseslint from 'typescript-eslint'`, | ||
`import beautifulSort from 'eslint-plugin-beautiful-sort'`, | ||
], | ||
configs: ['eslint.configs.recommended', '...tseslint.configs.recommended'], | ||
eslintConfig: { | ||
files: ['**/*.ts'], | ||
languageOptions: { | ||
globals: ['node'], | ||
parserOptions: { | ||
project: true, | ||
}, | ||
}, | ||
ignores: ['node_modules', 'dist'], | ||
plugins: { | ||
'beautiful-sort': 'beautifulSort', | ||
}, | ||
rules: { | ||
'no-use-before-define': 'error', | ||
'object-shorthand': 'warn', | ||
'no-async-promise-executor': 'warn', | ||
'@typescript-eslint/consistent-type-definitions': ['error', 'type'], | ||
'@typescript-eslint/interface-name-prefix': 'off', | ||
'@typescript-eslint/explicit-function-return-type': 'off', | ||
'@typescript-eslint/explicit-module-boundary-types': 'off', | ||
'@typescript-eslint/no-explicit-any': 'warn', | ||
'@typescript-eslint/no-misused-promises': 'warn', | ||
'@typescript-eslint/no-deprecated': 'error', | ||
'beautiful-sort/import': [ | ||
'error', | ||
{ | ||
special: [], | ||
order: ['special', 'namespace', 'default', 'defaultObj', 'obj', 'none'], | ||
}, | ||
], | ||
}, | ||
}, | ||
typescript: true, | ||
scripts: [ | ||
{ name: 'lint', script: 'eslint "**/*.ts"' }, | ||
{ name: 'lint:fix', script: 'eslint "**/*.ts" --fix' }, | ||
], | ||
mutations: [prettierMutation$2, jestMutation$1], | ||
}; | ||
const reactTsConfig$3 = { | ||
dependencies: [ | ||
@@ -258,4 +308,4 @@ 'globals', | ||
'typescript-eslint', | ||
'@typescript-eslint/eslint-plugin', | ||
'@typescript-eslint/parser', | ||
'eslint-plugin-react', | ||
'eslint-plugin-jsx-a11y', | ||
'eslint-plugin-beautiful-sort', | ||
@@ -267,11 +317,16 @@ ], | ||
`import tseslint from 'typescript-eslint'`, | ||
`import tsPlugin from '@typescript-eslint/eslint-plugin'`, | ||
`import pluginReact from 'eslint-plugin-react'`, | ||
`import pluginJsxA11y from 'eslint-plugin-jsx-a11y'`, | ||
`import beautifulSort from 'eslint-plugin-beautiful-sort'`, | ||
`import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'`, | ||
], | ||
configs: ['eslint.configs.recommended', '...tseslint.configs.recommended'], | ||
configs: [ | ||
'eslint.configs.recommended', | ||
'...tseslint.configs.recommended', | ||
`pluginReact.configs.flat['jsx-runtime']`, | ||
'pluginJsxA11y.flatConfigs.recommended', | ||
], | ||
eslintConfig: { | ||
files: ['**/*.ts'], | ||
files: ['**/*.{ts,tsx}'], | ||
languageOptions: { | ||
globals: ['node'], | ||
globals: ['browser'], | ||
parserOptions: { | ||
@@ -283,3 +338,2 @@ project: true, | ||
plugins: { | ||
'@typescript-eslint': 'tsPlugin', | ||
'beautiful-sort': 'beautifulSort', | ||
@@ -309,4 +363,4 @@ }, | ||
scripts: [ | ||
{ name: 'lint', script: 'eslint "**/*.ts"' }, | ||
{ name: 'lint:fix', script: 'eslint "**/*.ts" --fix' }, | ||
{ name: 'lint', script: 'eslint "**/*.{ts,tsx}"' }, | ||
{ name: 'lint:fix', script: 'eslint "**/*.{ts,tsx}" --fix' }, | ||
], | ||
@@ -319,2 +373,3 @@ mutations: [prettierMutation$2, jestMutation$1], | ||
'node:ts': nodeTsConfig$2, | ||
'react:ts': reactTsConfig$3, | ||
}); | ||
@@ -330,3 +385,3 @@ | ||
const exportEnd = config.typescript ? `);` : `];`; | ||
const imports = `${start}${config.imports.join(';\n')}${config.imports.length ? '\n' : ''}`; | ||
const imports = `${start}${config.imports.join(';\n')}${config.imports.length ? ';\n' : ''}`; | ||
const configs = config.configs.map((item) => ` ${item},`).join('\n'); | ||
@@ -444,3 +499,3 @@ const files = config.eslintConfig.files | ||
if (await isPrettierInstalled()) { | ||
addOptionToLintStagedConfig(config, '*.{js,json,yml,md}', `${CLI_NAME$3} --write`); | ||
addOptionToLintStagedConfig(config, '*.{js,cjs,mjs,json,yml,md}', `${CLI_NAME$3} --write`); | ||
} | ||
@@ -838,3 +893,3 @@ }; | ||
- name: Get release notes from CHANGELOG.md | ||
uses: yashanand1910/standard-release-notes@v1.4.0 | ||
uses: yashanand1910/standard-release-notes@v1.5.0 | ||
id: get_release_notes | ||
@@ -875,3 +930,3 @@ with: | ||
runs-on: ubuntu-latest | ||
env: | ||
env: | ||
CI: true | ||
@@ -916,3 +971,3 @@ steps: | ||
runs-on: ubuntu-latest | ||
env: | ||
env: | ||
CI: true | ||
@@ -919,0 +974,0 @@ steps: |
{ | ||
"name": "@allohamora/cli", | ||
"version": "1.19.0", | ||
"version": "1.20.0", | ||
"description": "cli to initialize projects and more", | ||
@@ -63,4 +63,2 @@ "input": "./src/index.ts", | ||
"@types/jest": "^29.5.13", | ||
"@typescript-eslint/eslint-plugin": "^8.6.0", | ||
"@typescript-eslint/parser": "^8.6.0", | ||
"eslint": "^9.11.0", | ||
@@ -96,4 +94,4 @@ "eslint-config-prettier": "^9.1.0", | ||
], | ||
"*.{js,mjs,json,yml,md}": "prettier --write" | ||
"*.{js,cjs,mjs,json,yml,md}": "prettier --write" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
129573
26
1039