From ddd9065007bd51c1c69e83c4dd752ef94c7d9423 Mon Sep 17 00:00:00 2001 From: osdevisnot Date: Mon, 10 Aug 2020 17:08:13 -0700 Subject: [PATCH] docs: reformat inline docs --- .gitignore | 5 ++++- src/init-create.js | 3 +-- src/init.js | 17 +++++------------ src/klap.js | 3 +-- src/plugins.js | 4 +++- 5 files changed, 14 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 91172c8..4948771 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ node_modules -dist/ +dist +coverage .idea +*.log +yarn.lock package-lock.json diff --git a/src/init-create.js b/src/init-create.js index 2161b3e..787aec4 100644 --- a/src/init-create.js +++ b/src/init-create.js @@ -51,8 +51,7 @@ const createTsConfig = () => `{ } }` -const createReadme = (name) => `# ${name} -` +const createReadme = (name) => `# ${name}` export const getDefaults = (pkg, template) => [ diff --git a/src/init.js b/src/init.js index 5159a00..e2cf2dd 100644 --- a/src/init.js +++ b/src/init.js @@ -72,16 +72,13 @@ const writePackage = async (template, { user, email }) => { } /** - * Write boilerplate scripts and common files such as LICENSE and .gitignore to - * user's directories. + * Write boilerplate scripts and common files such as LICENSE and .gitignore to user's directories. */ const writeFiles = async (pkg, template) => { - // An array of objects each having `file`, `content`, & optionally - // `extensions` properties + // An array of objects each having `file`, `content`, & optionally `extensions` properties const files = [...getDefaults(pkg, template), ...getTemplates(pkg, template)] - // Write files. - // Only write files that don't already exist. + // Write files, that do not already exist. for (const { file, content, extensions } of files) { let existing = false // If there's a range of possible extensions, check them all. @@ -102,17 +99,13 @@ const writeFiles = async (pkg, template) => { * The main function exported by this module. */ export const init = async () => { - const template = process.argv[3] || 'js' // js, jsx, ts, tsx + const template = process.argv[3] || 'js' if (!['js', 'ts', 'jsx', 'tsx'].includes(template)) { error('Invalid init template. Try one of js, jsx, ts, tsx') return } + const pkg = await writePackage(template, gitInfo()) await writeFiles(pkg, template) - - if (!process.argv[3]) { - log('\nWant to use typescript with klap?') - info('Initialize your package with `klap init ts`\n') - } } diff --git a/src/klap.js b/src/klap.js index 8836316..143d679 100644 --- a/src/klap.js +++ b/src/klap.js @@ -3,9 +3,8 @@ import { dirname, basename } from 'path' import { rollup, watch } from 'rollup' import { error, info, log } from './logger' import { getOptions } from './options' -import { plugins } from './plugins' +import { plugins, dts } from './plugins' import { exists, read } from './utils' -import dts from 'rollup-plugin-dts' const defaultInputOptions = { inlineDynamicImports: true } const defaultOutputOptions = { esModule: false, strict: false, freeze: false } diff --git a/src/plugins.js b/src/plugins.js index 08d7a75..e44b173 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -6,6 +6,8 @@ import replace from '@rollup/plugin-replace' import nodeGlobals from 'rollup-plugin-node-globals' import babel from '@rollup/plugin-babel' +import dts from 'rollup-plugin-dts' + import { terser } from './packages/terser' import { sizeme } from './packages/sizeme' import { servor } from './packages/servor' @@ -43,4 +45,4 @@ const plugins = (command, pkg, options) => { ].filter(Boolean) } -export { plugins } +export { plugins, dts }