@allohamora/cli
Advanced tools
Comparing version 1.3.0 to 1.4.0
521
bin/cli.js
#!/usr/bin/env node | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var fsp = require('fs/promises'); | ||
@@ -17,2 +19,4 @@ var path = require('path'); | ||
const white = (log) => `\x1b[22m\x1b[1m${log}\x1b[0m`; | ||
const createTypeState = (types) => { | ||
@@ -56,3 +60,3 @@ let type = types[0]; | ||
const existsInRoot = async (name) => { | ||
const isExistsInRoot = async (name) => { | ||
const checkPath = rootPath(name); | ||
@@ -66,3 +70,3 @@ return await fsp__default["default"] | ||
const dirPath = rootPath(name); | ||
if (await existsInRoot(name)) { | ||
if (await isExistsInRoot(name)) { | ||
return; | ||
@@ -80,6 +84,2 @@ } | ||
const runCommand = async (command) => { | ||
const [name, ...args] = command.split(' '); | ||
return await spawnCommand(name, args); | ||
}; | ||
const spawnCommand = async (command, args) => new Promise((res, rej) => { | ||
@@ -90,2 +90,6 @@ const child = child_process.spawn(command, args); | ||
}); | ||
const runCommand = async (command) => { | ||
const [name, ...args] = command.split(' '); | ||
return await spawnCommand(name, args); | ||
}; | ||
@@ -120,6 +124,48 @@ const getPackageJson = async () => { | ||
const defaultConfig$9 = { | ||
rules: '@commitlint/config-conventional', | ||
config: { extends: ['@commitlint/config-conventional'] }, | ||
}; | ||
const [getConfig$9] = jsCategoryState.useConfigState({ | ||
default: defaultConfig$9, | ||
}); | ||
const SCRIPT_NAME$2 = 'commitlint'; | ||
const PACKAGE_NAME$6 = '@commitlint/cli'; | ||
const CONFIG_FILE_NAME$4 = '.commitlintrc.json'; | ||
const CLI_NAME$4 = SCRIPT_NAME$2; | ||
const PACKAGE_NAME$5 = 'husky'; | ||
const HOOK_DIR = `.${PACKAGE_NAME$5}`; | ||
const context = { installing: [] }; | ||
const setInstalling = (scripts) => (context.installing = scripts); | ||
const getInstalling = () => context.installing; | ||
const isInstalling = (scriptName) => { | ||
const installing = getInstalling(); | ||
return installing.includes(scriptName); | ||
}; | ||
const isInstalled = (scriptName, aditionalHandlers = []) => { | ||
const handlers = [async () => isInstalling(scriptName), ...aditionalHandlers]; | ||
const handler = async () => { | ||
for (const handler of handlers) { | ||
if (await handler()) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
return handler; | ||
}; | ||
const isInstalledAndInRootCheck = (scriptName, relativePath, additionalHandlers = []) => { | ||
const handler = async () => isExistsInRoot(relativePath); | ||
return isInstalled(scriptName, [handler, ...additionalHandlers]); | ||
}; | ||
const ADD_HOOK_PLACEHOLDER = 'placeholder'; | ||
const addHook = async (name, script) => { | ||
const huskyPath = `.husky/${name}`; | ||
await spawnCommand('npx', ['husky', 'add', huskyPath, ADD_HOOK_PLACEHOLDER]); | ||
const huskyPath = path__default["default"].join(HOOK_DIR, name); | ||
await spawnCommand('npx', [PACKAGE_NAME$5, 'add', huskyPath, ADD_HOOK_PLACEHOLDER]); | ||
const fileWithPlaceholder = await fsp__default["default"].readFile(huskyPath, { encoding: 'utf-8' }); | ||
@@ -130,31 +176,81 @@ const fileWithScript = fileWithPlaceholder.replace(ADD_HOOK_PLACEHOLDER, script); | ||
}; | ||
const husky = async () => { | ||
await installDevelopmentDependencies('husky'); | ||
await addScripts({ name: 'prepare', script: 'husky install' }); | ||
await runScript('prepare'); | ||
const isHuskyInstalled = isInstalledAndInRootCheck(PACKAGE_NAME$5, HOOK_DIR); | ||
const huskyIntegration$1 = async () => { | ||
if (await isHuskyInstalled()) { | ||
await addHook('commit-msg', `npx --no-install -- ${CLI_NAME$4} --edit "$1"`); | ||
} | ||
}; | ||
const defaultConfig$5 = { | ||
rules: '@commitlint/config-conventional', | ||
config: { extends: ['@commitlint/config-conventional'] }, | ||
}; | ||
const [getConfig$5] = jsCategoryState.useConfigState({ | ||
default: defaultConfig$5, | ||
}); | ||
const commitlint = async () => { | ||
const { config, rules } = getConfig$5(); | ||
await installDevelopmentDependencies('@commitlint/cli', rules); | ||
await addJsonFileToRoot('.commitlintrc.json', config); | ||
await addHook('commit-msg', 'npx --no-install -- commitlint --edit "$1"'); | ||
const { config, rules } = getConfig$9(); | ||
await installDevelopmentDependencies(PACKAGE_NAME$6, rules); | ||
await addJsonFileToRoot(CONFIG_FILE_NAME$4, config); | ||
await huskyIntegration$1(); | ||
}; | ||
const nodeTsConfig$1 = { | ||
dependencies: [ | ||
'@typescript-eslint/eslint-plugin', | ||
'@typescript-eslint/parser', | ||
'eslint-config-prettier', | ||
'eslint-plugin-beautiful-sort', | ||
'eslint-plugin-prettier', | ||
const SCRIPT_NAME$1 = 'jest'; | ||
const PACKAGE_NAME$4 = SCRIPT_NAME$1; | ||
const CLI_NAME$3 = PACKAGE_NAME$4; | ||
const CONFIG_FILE_NAME$3 = 'jest.config.cjs'; | ||
const isJestInstalled = isInstalledAndInRootCheck(SCRIPT_NAME$1, CONFIG_FILE_NAME$3); | ||
const PACKAGE_NAME$3 = 'prettier'; | ||
const CLI_NAME$2 = PACKAGE_NAME$3; | ||
const CONFIG_FILE_NAME$2 = '.prettierrc'; | ||
const CONFIG_IGNORE_FILE_NAME = '.prettierignore'; | ||
const isPrettierInstalled = isInstalledAndInRootCheck(PACKAGE_NAME$3, CONFIG_FILE_NAME$2); | ||
const SCRIPT_NAME = 'eslint'; | ||
const PACKAGE_NAME$2 = SCRIPT_NAME; | ||
const CLI_NAME$1 = PACKAGE_NAME$2; | ||
const CONFIG_FILE_NAME$1 = '.eslintrc.json'; | ||
const prettierMutation$1 = async (config) => { | ||
if (await isPrettierInstalled()) { | ||
addPrettierToConfig(config); | ||
} | ||
}; | ||
const jestMutation$1 = async (config) => { | ||
if (await isJestInstalled()) { | ||
config.eslintConfig.env = { ...config.eslintConfig.env, jest: true }; | ||
} | ||
}; | ||
const addPrettierToConfig = (config) => { | ||
const dependenciesSet = new Set([...config.dependencies, 'eslint-plugin-prettier', 'eslint-config-prettier']); | ||
const dependencies = Array.from(dependenciesSet); | ||
const eslintExtendsSet = new Set([...(config.eslintConfig.extends || []), 'plugin:prettier/recommended']); | ||
const eslintExtends = Array.from(eslintExtendsSet); | ||
config.dependencies = dependencies; | ||
config.eslintConfig.extends = eslintExtends; | ||
}; | ||
const isEslintInstalled = isInstalledAndInRootCheck(SCRIPT_NAME, CONFIG_FILE_NAME$1); | ||
const defaultConfig$8 = { | ||
dependencies: [], | ||
eslintConfig: { | ||
parserOptions: { | ||
ecmaVersion: 'latest', | ||
sourceType: 'module', | ||
}, | ||
env: { | ||
es6: true, | ||
node: true, | ||
browser: true, | ||
}, | ||
root: true, | ||
extends: ['eslint:recommended'], | ||
}, | ||
scripts: [ | ||
{ name: 'lint', script: 'eslint "src/**/*.js"' }, | ||
{ name: 'lint:fix', script: 'eslint "src/**/*.js" --fix' }, | ||
], | ||
config: { | ||
mutations: [prettierMutation$1, jestMutation$1], | ||
}; | ||
const nodeTsConfig$2 = { | ||
dependencies: ['@typescript-eslint/eslint-plugin', '@typescript-eslint/parser', 'eslint-plugin-beautiful-sort'], | ||
eslintConfig: { | ||
parser: '@typescript-eslint/parser', | ||
@@ -166,7 +262,6 @@ parserOptions: { | ||
plugins: ['@typescript-eslint/eslint-plugin', 'beautiful-sort'], | ||
extends: ['plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'], | ||
extends: ['plugin:@typescript-eslint/recommended'], | ||
root: true, | ||
env: { | ||
node: true, | ||
jest: true, | ||
}, | ||
@@ -193,58 +288,104 @@ ignorePatterns: ['.eslintrc.js'], | ||
], | ||
mutations: [prettierMutation$1, jestMutation$1], | ||
}; | ||
const defaultConfig$4 = { | ||
dependencies: ['eslint-plugin-prettier', 'eslint-config-prettier'], | ||
config: { | ||
parserOptions: { | ||
ecmaVersion: 'latest', | ||
sourceType: 'module', | ||
}, | ||
env: { | ||
es6: true, | ||
node: true, | ||
browser: true, | ||
jest: true, | ||
}, | ||
root: true, | ||
extends: ['eslint:recommended', 'plugin:prettier/recommended'], | ||
}, | ||
scripts: [ | ||
{ name: 'lint', script: 'eslint "src/**/*.js"' }, | ||
{ name: 'lint:fix', script: 'eslint "src/**/*.js" --fix' }, | ||
], | ||
const [getConfig$8] = jsCategoryState.useConfigState({ | ||
default: defaultConfig$8, | ||
'node:ts': nodeTsConfig$2, | ||
}); | ||
const applyMutations = async (config, mutations) => { | ||
return await Promise.all(mutations.map(async (mutation) => await Promise.resolve(mutation(config)))); | ||
}; | ||
const [getConfig$4] = jsCategoryState.useConfigState({ | ||
default: defaultConfig$4, | ||
'node:ts': nodeTsConfig$1, | ||
}); | ||
const eslint = async () => { | ||
const { config, dependencies, scripts } = getConfig$4(); | ||
await installDevelopmentDependencies('eslint', ...dependencies); | ||
await addJsonFileToRoot('.eslintrc.json', config); | ||
const config = getConfig$8(); | ||
await applyMutations(config, config.mutations); | ||
const { dependencies, eslintConfig, scripts } = config; | ||
await installDevelopmentDependencies(PACKAGE_NAME$2, ...dependencies); | ||
await addJsonFileToRoot(CONFIG_FILE_NAME$1, eslintConfig); | ||
await addScripts(...scripts); | ||
}; | ||
const defaultConfig$3 = { | ||
config: { | ||
'*.{js,json,yml,md}': 'prettier --write', | ||
const husky = async () => { | ||
await installDevelopmentDependencies(PACKAGE_NAME$5); | ||
await addScripts({ name: 'prepare', script: `${PACKAGE_NAME$5} install` }); | ||
await runScript('prepare'); | ||
}; | ||
const PACKAGE_NAME$1 = 'lint-staged'; | ||
const CLI_NAME = PACKAGE_NAME$1; | ||
const arrayOptionMutation = { | ||
check: (config, key) => Array.isArray(config[key]), | ||
mutate: (config, key, value) => { | ||
config[key] = Array.from(new Set([...config[key], value])); | ||
}, | ||
}; | ||
const nodeTsConfig = { | ||
config: { | ||
'*.ts': 'eslint --fix', | ||
...defaultConfig$3.config, | ||
const stringOptionMutation = { | ||
check: (config, key) => typeof config[key] === 'string', | ||
mutate: (config, key, value) => { | ||
const array = Array.from(new Set([config[key], value])); | ||
config[key] = array.length === 1 ? array[0] : array; | ||
}, | ||
}; | ||
const [getConfig$3] = jsCategoryState.useConfigState({ | ||
default: defaultConfig$3, | ||
'node:ts': nodeTsConfig, | ||
const undefinedOptionMutation = { | ||
check: (config, key) => typeof config[key] === 'undefined', | ||
mutate: (config, key, value) => { | ||
config[key] = value; | ||
}, | ||
}; | ||
const optionMutations = [arrayOptionMutation, stringOptionMutation, undefinedOptionMutation]; | ||
const addOptionToLintStagedConfig = (config, key, value) => { | ||
const finded = optionMutations.find(({ check }) => check(config, key, value)); | ||
if (!finded) { | ||
throw new Error('option mutator is not found!'); | ||
} | ||
finded.mutate(config, key, value); | ||
}; | ||
const huskyIntegration = async () => { | ||
if (await isHuskyInstalled()) { | ||
await addHook('pre-commit', `npx --no-install ${CLI_NAME}`); | ||
} | ||
}; | ||
const jestMutation = (fileExtension) => async (config) => { | ||
if (await isJestInstalled()) { | ||
addOptionToLintStagedConfig(config, fileExtension, `${CLI_NAME$3} --findRelatedTests`); | ||
} | ||
}; | ||
const eslintMutation = (fileExtension) => async (config) => { | ||
if (await isEslintInstalled()) { | ||
addOptionToLintStagedConfig(config, fileExtension, `${CLI_NAME$1} --fix`); | ||
} | ||
}; | ||
const prettierMutation = async (config) => { | ||
if (await isPrettierInstalled()) { | ||
addOptionToLintStagedConfig(config, '*.{js,json,yml,md}', `${CLI_NAME$2} --write`); | ||
} | ||
}; | ||
const defaultConfig$7 = { | ||
config: {}, | ||
mutations: [prettierMutation, eslintMutation('*.js'), jestMutation('*.js')], | ||
}; | ||
const nodeTsConfig$1 = { | ||
config: {}, | ||
mutations: [prettierMutation, eslintMutation('*.ts'), jestMutation('*.ts')], | ||
}; | ||
const [getConfig$7] = jsCategoryState.useConfigState({ | ||
default: defaultConfig$7, | ||
'node:ts': nodeTsConfig$1, | ||
}); | ||
const lintStaged = async () => { | ||
const { config } = getConfig$3(); | ||
await installDevelopmentDependencies('lint-staged'); | ||
await addToPackageJson('lint-staged', config); | ||
await addHook('pre-commit', 'npx --no-install lint-staged'); | ||
const { config, mutations } = getConfig$7(); | ||
await applyMutations(config, mutations); | ||
await installDevelopmentDependencies(PACKAGE_NAME$1); | ||
await addToPackageJson(PACKAGE_NAME$1, config); | ||
await huskyIntegration(); | ||
}; | ||
const defaultConfig$2 = { | ||
const defaultConfig$6 = { | ||
config: { | ||
@@ -271,14 +412,16 @@ semi: true, | ||
}; | ||
const [getConfig$2] = jsCategoryState.useConfigState({ | ||
default: defaultConfig$2, | ||
const [getConfig$6] = jsCategoryState.useConfigState({ | ||
default: defaultConfig$6, | ||
}); | ||
const prettier = async () => { | ||
const { config, ignore, scripts } = getConfig$2(); | ||
await installDevelopmentDependencies('prettier'); | ||
await addJsonFileToRoot('.prettierrc', config); | ||
await addFileToRoot('.prettierignore', ignore.join('\n')); | ||
const { config, ignore, scripts } = getConfig$6(); | ||
await installDevelopmentDependencies(PACKAGE_NAME$3); | ||
await addJsonFileToRoot(CONFIG_FILE_NAME$2, config); | ||
await addFileToRoot(CONFIG_IGNORE_FILE_NAME, ignore.join('\n')); | ||
await addScripts(...scripts); | ||
}; | ||
const defaultConfig$1 = { | ||
const defaultConfig$5 = { | ||
createConfig: (repositoryUrl) => ({ | ||
@@ -308,13 +451,18 @@ types: [ | ||
}; | ||
const [getConfig$1] = jsCategoryState.useConfigState({ | ||
default: defaultConfig$1, | ||
const [getConfig$5] = jsCategoryState.useConfigState({ | ||
default: defaultConfig$5, | ||
}); | ||
const PACKAGE_NAME = 'standard-version'; | ||
const CONFIG_FILE_NAME = '.versionrc.json'; | ||
const standardVersion = async () => { | ||
const { createConfig, packageJsonConfig, scripts } = getConfig$1(); | ||
await installDevelopmentDependencies('standard-version'); | ||
const { createConfig, packageJsonConfig, scripts } = getConfig$5(); | ||
await installDevelopmentDependencies(PACKAGE_NAME); | ||
const packageJson = await getPackageJson(); | ||
const repositoryUrl = packageJson.homepage?.replace(/#.+$/, '') ?? '<repository url>'; | ||
const config = createConfig(repositoryUrl); | ||
await addJsonFileToRoot('.versionrc.json', config); | ||
await addToPackageJson('standard-version', packageJsonConfig); | ||
await addJsonFileToRoot(CONFIG_FILE_NAME, config); | ||
await addToPackageJson(PACKAGE_NAME, packageJsonConfig); | ||
await addScripts(...scripts); | ||
@@ -360,13 +508,13 @@ }; | ||
}; | ||
const buildTemplate = (strings, ...values) => { | ||
const multilineStringBuilder = (strings, ...values) => { | ||
const result = strings.reduce((state, string, index) => { | ||
const value = values[index] ?? ''; | ||
return `${state}${string}${value}`; | ||
}); | ||
}, ''); | ||
return result; | ||
}; | ||
const templateWithFormat = (...funcs) => { | ||
const multilineStringBuilderWithMiddlewares = (...middlewares) => { | ||
return (...params) => { | ||
const builded = buildTemplate(...params); | ||
return compose(...funcs)(builded); | ||
const builded = multilineStringBuilder(...params); | ||
return compose(...middlewares)(builded); | ||
}; | ||
@@ -376,5 +524,5 @@ }; | ||
const trim = (string) => string.trim(); | ||
const readableMultilineString = multilineStringBuilderWithMiddlewares(trim, removeTabOnEachLine); | ||
const format = templateWithFormat(trim, removeTabOnEachLine); | ||
const content = format ` | ||
const content$3 = readableMultilineString ` | ||
name: release | ||
@@ -388,3 +536,3 @@ | ||
jobs: | ||
build: | ||
release: | ||
runs-on: ubuntu-latest | ||
@@ -405,12 +553,167 @@ steps: | ||
`; | ||
const defaultConfig$4 = { | ||
content: content$3, | ||
}; | ||
const [getConfig$4] = jsCategoryState.useConfigState({ | ||
default: defaultConfig$4, | ||
}); | ||
const WORKFLOW_FILENAME$3 = 'release.yml'; | ||
const releaseWorkflow = async () => { | ||
const { content } = getConfig$4(); | ||
await addGithubWorkflow(WORKFLOW_FILENAME$3, content); | ||
}; | ||
const scripts = [ | ||
{ name: 'test', script: 'jest' }, | ||
{ name: 'test:watch', script: 'jest --watch' }, | ||
{ name: 'test:coverage', script: 'jest --coverage' }, | ||
]; | ||
const configFileContent$1 = readableMultilineString ` | ||
module.exports = { | ||
testEnvironment: 'node', | ||
testRegex: '.*\\.(spec|test)\\.js$', | ||
collectCoverageFrom: ['src/**/*.js'], | ||
}; | ||
`; | ||
const defaultConfig$3 = { | ||
devDependencies: ['jest', '@types/jest'], | ||
configFileContent: configFileContent$1, | ||
scripts, | ||
}; | ||
const configFileContent = readableMultilineString ` | ||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
moduleDirectories: ['<rootDir>', 'node_modules'], | ||
testRegex: '.*\\.(spec|test)\\.ts$', | ||
collectCoverageFrom: ['src/**/*.ts'], | ||
}; | ||
`; | ||
const nodeTsConfig = { | ||
devDependencies: ['jest', '@types/jest', 'ts-jest'], | ||
configFileContent, | ||
scripts, | ||
}; | ||
const [getConfig$3] = jsCategoryState.useConfigState({ | ||
default: defaultConfig$3, | ||
'node:ts': nodeTsConfig, | ||
}); | ||
// named jestEntrypoint because in test environment jest name is reserved | ||
const jestEntrypoint = async () => { | ||
const { devDependencies, configFileContent, scripts } = getConfig$3(); | ||
await installDevelopmentDependencies(...devDependencies); | ||
await addFileToRoot(CONFIG_FILE_NAME$3, configFileContent); | ||
await addScripts(...scripts); | ||
}; | ||
const content$2 = readableMultilineString ` | ||
name: test | ||
on: push | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
env: | ||
CI: true | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Install node | ||
uses: actions/setup-node@v2 | ||
with: | ||
cache: "npm" | ||
- name: Install dependencies | ||
run: npm i | ||
- name: Run tests | ||
run: npm run test | ||
`; | ||
const defaultConfig$2 = { | ||
content: content$2, | ||
}; | ||
const [getConfig$2] = jsCategoryState.useConfigState({ | ||
default: defaultConfig$2, | ||
}); | ||
const WORKFLOW_FILENAME$2 = 'test.yml'; | ||
const testWorkflow = async () => { | ||
const { content } = getConfig$2(); | ||
await addGithubWorkflow(WORKFLOW_FILENAME$2, content); | ||
}; | ||
const content$1 = readableMultilineString ` | ||
name: codeql | ||
on: push | ||
jobs: | ||
analyse: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v1 | ||
- name: Run CodeQL analyze | ||
uses: github/codeql-action/analyze@v1 | ||
`; | ||
const defaultConfig$1 = { | ||
content: content$1, | ||
}; | ||
const [getConfig$1] = jsCategoryState.useConfigState({ | ||
default: defaultConfig$1, | ||
}); | ||
const WORKFLOW_FILENAME$1 = 'codeql.yml'; | ||
const codeqlWorkflow = async () => { | ||
const { content } = getConfig$1(); | ||
await addGithubWorkflow(WORKFLOW_FILENAME$1, content); | ||
}; | ||
const content = readableMultilineString ` | ||
name: build | ||
on: push | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
env: | ||
CI: true | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Install node | ||
uses: actions/setup-node@v2 | ||
with: | ||
cache: "npm" | ||
- name: Install dependencies | ||
run: npm i | ||
- name: Run build | ||
run: npm run build | ||
`; | ||
const defaultConfig = { | ||
filename: 'release.yml', | ||
content, | ||
}; | ||
const [getConfig] = jsCategoryState.useConfigState({ | ||
default: defaultConfig, | ||
}); | ||
const releaseWorkflow = async () => { | ||
const { filename, content } = getConfig(); | ||
await addGithubWorkflow(filename, content); | ||
const WORKFLOW_FILENAME = 'build.yml'; | ||
const buildWorkflow = async () => { | ||
const { content } = getConfig(); | ||
await addGithubWorkflow(WORKFLOW_FILENAME, content); | ||
}; | ||
@@ -427,2 +730,7 @@ | ||
releaseWorkflow, | ||
// named jestEntrypoint because in test environment jest name is reserved | ||
jest: jestEntrypoint, | ||
testWorkflow, | ||
codeqlWorkflow, | ||
buildWorkflow, | ||
}; | ||
@@ -447,2 +755,3 @@ var js = { | ||
}; | ||
const miniumOneValidate = (answers) => answers.length !== 0; | ||
const manyOf = async (message, choices) => { | ||
@@ -454,3 +763,3 @@ const res = await inquirer__default["default"].prompt({ | ||
choices, | ||
validate: (answers) => answers.length !== 0, | ||
validate: miniumOneValidate, | ||
}); | ||
@@ -460,4 +769,2 @@ return res[message]; | ||
const white = (log) => `\x1b[22m\x1b[1m${log}\x1b[0m`; | ||
const categoriesKeys = Object.keys(categories); | ||
@@ -482,2 +789,3 @@ const getCategory = async () => { | ||
const spinner = ora__default["default"]('starting install').start(); | ||
setInstalling(keys); | ||
await keys.reduce((chain, key) => { | ||
@@ -492,2 +800,3 @@ return chain.then(async () => { | ||
}; | ||
const main = async () => { | ||
@@ -501,3 +810,7 @@ console.log(white(`Wellcome to Allohamora's cli`)); | ||
}; | ||
main(); | ||
if (require.main) { | ||
main(); | ||
} | ||
exports.main = main; | ||
//# sourceMappingURL=cli.js.map |
{ | ||
"name": "@allohamora/cli", | ||
"version": "1.3.0", | ||
"description": "Command Line Interface with useful installation scripts", | ||
"version": "1.4.0", | ||
"description": "cli to initialize projects and more", | ||
"input": "./src/index.ts", | ||
@@ -11,2 +11,3 @@ "main": "./bin/cli.js", | ||
"build": "rimraf ./bin && rollup -c rollup.config.js", | ||
"prestart": "npm run build", | ||
"start": "npm unlink @allohamora/cli && npm link @allohamora/cli && ./bin/cli.js", | ||
@@ -21,3 +22,6 @@ "prepare": "husky install", | ||
"lint": "eslint \"src/**/*.ts\"", | ||
"lint:fix": "eslint \"src/**/*.ts\" --fix" | ||
"lint:fix": "eslint \"src/**/*.ts\" --fix", | ||
"test": "jest", | ||
"test:watch": "jest --watch", | ||
"test:coverage": "jest --coverage" | ||
}, | ||
@@ -54,9 +58,10 @@ "repository": { | ||
"devDependencies": { | ||
"@commitlint/cli": "^15.0.0", | ||
"@commitlint/config-conventional": "^15.0.0", | ||
"@commitlint/cli": "^16.1.0", | ||
"@commitlint/config-conventional": "^16.0.0", | ||
"@rollup/plugin-commonjs": "^21.0.1", | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@types/inquirer": "^8.1.3", | ||
"@typescript-eslint/eslint-plugin": "^5.8.0", | ||
"@typescript-eslint/parser": "^5.8.0", | ||
"@types/jest": "^27.4.0", | ||
"@typescript-eslint/eslint-plugin": "^5.10.2", | ||
"@typescript-eslint/parser": "^5.10.2", | ||
"eslint": "^8.5.0", | ||
@@ -67,2 +72,3 @@ "eslint-config-prettier": "^8.3.0", | ||
"husky": "^7.0.4", | ||
"jest": "^27.4.7", | ||
"lint-staged": "^12.1.4", | ||
@@ -75,6 +81,8 @@ "prettier": "^2.5.1", | ||
"standard-version": "^9.3.2", | ||
"ts-jest": "^27.1.3", | ||
"ts-node-dev": "^1.1.8", | ||
"tsconfig-paths": "^3.12.0", | ||
"type-fest": "^2.8.0", | ||
"typescript": "^4.5.3" | ||
"typescript": "^4.5.3", | ||
"yaml": "^1.10.2" | ||
}, | ||
@@ -91,5 +99,8 @@ "dependencies": { | ||
"lint-staged": { | ||
"*.ts": "eslint --fix", | ||
"*.ts": [ | ||
"eslint --fix", | ||
"jest --findRelatedTests" | ||
], | ||
"*.{js,json,yml,md}": "prettier --write" | ||
} | ||
} |
@@ -23,12 +23,18 @@ # CLI | ||
- [**js**](/src/categories/js/index.ts) is a category with scripts to initialize js/ts projects, have default and node:ts config options. | ||
- [**commitlint**](/src/categories/js/commitlint.ts) is a script to initialize [commitlint](https://github.com/conventional-changelog/commitlint) with [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) config. | ||
- [**eslint**](/src/categories/js/eslint.ts) is a script to initialize [eslint](https://github.com/eslint/eslint) with [prettier-plugin](https://github.com/prettier/eslint-plugin-prettier), config and lint scripts. | ||
- [**husky**](/src/categories/js/husky.ts) is a script to initialize [husky](https://github.com/typicode/husky). | ||
- [**lint-staged**](/src/categories/js/lint-staged.ts) is a script to initialize [lint-staged](https://github.com/okonet/lint-staged) with [eslint](https://github.com/eslint/eslint) linting, [prettier](https://github.com/prettier/prettier) formating and [husky](https://github.com/typicode/husky) pre-commit hook. | ||
- [**prettier**](/src/categories/js/prettier.ts) is a script to initialize [prettier](https://github.com/prettier/prettier) with config and format scripts. | ||
- [**release-workflow**](/src/categories/js/release-worflow.ts) is script to initialize github release workflow what creates release from [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) CHANGELOG.md when you push tag like \*.\*.\*(1.1.0, 5.0.0, 0.0.0, etc). | ||
- [**standard-version**](/src/categories/js/standard-verstion.ts) is a script to initialize [standard-version](https://github.com/conventional-changelog/standard-version) with [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) config, custom options (like removed "v" tag prefix) and release scripts. | ||
- [**commitlint**](/src/categories/js/commitlint) is a script to initialize [commitlint](https://github.com/conventional-changelog/commitlint) with [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) config. Have [husky](https://github.com/typicode/husky) integration. | ||
- [**eslint**](/src/categories/js/eslint) is a script to initialize [eslint](https://github.com/eslint/eslint) with config and lint scripts. Have [prettier](https://github.com/prettier/prettier) integration. | ||
- [**husky**](/src/categories/js/husky) is a script to initialize [husky](https://github.com/typicode/husky). | ||
- [**lint-staged**](/src/categories/js/lint-staged) is a script to initialize [lint-staged](https://github.com/okonet/lint-staged). Have [husky](https://github.com/typicode/husky), [jest](https://github.com/facebook/jest), [eslint](https://github.com/eslint/eslint), [prettier](https://github.com/prettier/prettier) integrations. | ||
- [**prettier**](/src/categories/js/prettier) is a script to initialize [prettier](https://github.com/prettier/prettier) with config and format scripts. | ||
- [**release-workflow**](/src/categories/js/release-worflow) is script to initialize github release workflow what creates release from [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) CHANGELOG.md when you push tag like \*.\*.\*(1.1.0, 5.0.0, 0.0.0, etc). | ||
- [**standard-version**](/src/categories/js/standard-verstion) is a script to initialize [standard-version](https://github.com/conventional-changelog/standard-version) with [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) config(with repository url if defined or "\<repository url\>" placeholder), custom options(like removed "v" tag prefix) and release scripts. | ||
- [**jest**](/src/categories/js/jest) is a script to initialize [jest](https://github.com/facebook/jest) with config and test scripts. | ||
- [**test-workflow**](/src/categories/js/test-workflow.ts) is a script to initialize github test workflow what runs ```npm run test``` on each push to github. | ||
- [**build-workflow**](/src/categories/js/build-workflow) is a script to initialize github build workflow that runs ```npm run build``` on each push to github. | ||
- [**codeql-workflow**](/src/categories/js/codeql-workflow) is a script to initialize github codeql workflow what runs codeql with default options on each push to github. | ||
\*integrations runs only if package is installing or installed. | ||
## License | ||
CLI is [MIT licensed](/LICENSE). |
Sorry, the diff of this file is not supported yet
91346
710
40
27