diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..63187fe --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +# http://editorconfig.org +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +indent_style = space +insert_final_newline = true +max_line_length = 80 +trim_trailing_whitespace = true + +[*.md] +max_line_length = 0 +trim_trailing_whitespace = false diff --git a/src/cli/args.ts b/src/cli/args.ts index c265c1e..3482912 100644 --- a/src/cli/args.ts +++ b/src/cli/args.ts @@ -12,7 +12,7 @@ export async function checkArgs(): Promise { Non-Interactive Usage $ npx typescript-starter [options] - + Options --appveyor include Appveyor for Windows CI --description, -d package.json description @@ -22,7 +22,8 @@ export async function checkArgs(): Promise { --travis include Travis CI configuration --yarn use yarn (default: npm) - --no-circleci don't include CircleCI + --no-circleci don't include CircleCI + --no-editorconfig don't include .editorconfig --no-immutable don't enable tslint-immutable --no-install skip yarn/npm install --no-vscode don't include VS Code debugging config @@ -49,6 +50,10 @@ export async function checkArgs(): Promise { default: false, type: 'boolean' }, + editorconfig: { + default: true, + type: 'boolean' + }, immutable: { default: true, type: 'boolean' @@ -118,6 +123,7 @@ export async function checkArgs(): Promise { circleci: cli.flags.circleci, description: cli.flags.description, domDefinitions: cli.flags.dom, + editorconfig: cli.flags.editorconfig, immutable: cli.flags.immutable, install: cli.flags.install, nodeDefinitions: cli.flags.node, diff --git a/src/cli/inquire.ts b/src/cli/inquire.ts index eb20d65..2bbe85d 100644 --- a/src/cli/inquire.ts +++ b/src/cli/inquire.ts @@ -80,6 +80,7 @@ export async function inquire(): Promise { enum Extras { appveyor = 'appveyor', circleci = 'circleci', + editorconfig = 'editorconfig', immutable = 'immutable', strict = 'strict', travis = 'travis', @@ -97,6 +98,11 @@ export async function inquire(): Promise { name: 'Enable tslint-immutable', value: Extras.immutable }, + { + checked: true, + name: 'Include .editorconfig', + value: Extras.editorconfig + }, { checked: true, name: 'Include VS Code debugging config', @@ -155,6 +161,7 @@ export async function inquire(): Promise { definitions ) : false, + editorconfig: extras.includes(Extras.editorconfig), immutable: extras.includes(Extras.immutable), install: true, nodeDefinitions: definitions diff --git a/src/cli/tasks.ts b/src/cli/tasks.ts index e070470..4f2706e 100644 --- a/src/cli/tasks.ts +++ b/src/cli/tasks.ts @@ -52,7 +52,7 @@ export const cloneRepo = ( if (err.code === 'ENOENT') { throw new Error(` Git is not installed on your PATH. Please install Git and try again. - + For more information, visit: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git `); } else { @@ -206,6 +206,7 @@ export const addInferredOptions = async ( circleci: userOptions.circleci, description: userOptions.description, domDefinitions: userOptions.domDefinitions, + editorconfig: userOptions.editorconfig, immutable: userOptions.immutable, install: userOptions.install, nodeDefinitions: userOptions.nodeDefinitions, diff --git a/src/cli/tests/cli.integration.spec.ts b/src/cli/tests/cli.integration.spec.ts index 5420e4a..2118dcb 100644 --- a/src/cli/tests/cli.integration.spec.ts +++ b/src/cli/tests/cli.integration.spec.ts @@ -176,6 +176,7 @@ test(`${ const map = await hashAllTheThings(TestDirectories.one); t.deepEqual(map, { 'test-1/.circleci/config.yml': '30cc59229facf29bfca712fc6e2ddade', + 'test-1/.editorconfig': '44a3e6c69d9267b0f756986fd970a8f4', 'test-1/.github/CONTRIBUTING.md': '5f0dfa7fdf9bf828e3a3aa8fcaeece08', 'test-1/.github/ISSUE_TEMPLATE.md': '82d1b99b29f32d851627b317195e73d2', 'test-1/.github/PULL_REQUEST_TEMPLATE.md': @@ -222,6 +223,7 @@ test(`${ const map = await hashAllTheThings(TestDirectories.two); t.deepEqual(map, { 'test-2/.circleci/config.yml': '30cc59229facf29bfca712fc6e2ddade', + 'test-2/.editorconfig': '44a3e6c69d9267b0f756986fd970a8f4', 'test-2/.github/CONTRIBUTING.md': '5f0dfa7fdf9bf828e3a3aa8fcaeece08', 'test-2/.github/ISSUE_TEMPLATE.md': '82d1b99b29f32d851627b317195e73d2', 'test-2/.github/PULL_REQUEST_TEMPLATE.md': @@ -336,6 +338,7 @@ test(`${ const map = await hashAllTheThings(TestDirectories.three); t.deepEqual(map, { 'test-3/.circleci/config.yml': '30cc59229facf29bfca712fc6e2ddade', + 'test-3/.editorconfig': '44a3e6c69d9267b0f756986fd970a8f4', 'test-3/.github/CONTRIBUTING.md': '5f0dfa7fdf9bf828e3a3aa8fcaeece08', 'test-3/.github/ISSUE_TEMPLATE.md': '82d1b99b29f32d851627b317195e73d2', 'test-3/.github/PULL_REQUEST_TEMPLATE.md': @@ -376,6 +379,7 @@ test(`${ const map = await hashAllTheThings(TestDirectories.four); t.deepEqual(map, { 'test-4/.circleci/config.yml': '30cc59229facf29bfca712fc6e2ddade', + 'test-4/.editorconfig': '44a3e6c69d9267b0f756986fd970a8f4', 'test-4/.github/CONTRIBUTING.md': '5f0dfa7fdf9bf828e3a3aa8fcaeece08', 'test-4/.github/ISSUE_TEMPLATE.md': '82d1b99b29f32d851627b317195e73d2', 'test-4/.github/PULL_REQUEST_TEMPLATE.md': @@ -441,6 +445,7 @@ test(`${ appveyor: false, circleci: false, domDefinitions: false, + editorconfig: false, email: 'email@example.com', fullName: 'Satoshi Nakamoto', immutable: true, @@ -482,6 +487,7 @@ test(`${TestDirectories.six}: Sandboxed: yarn, no initial commit`, async t => { appveyor: true, circleci: true, domDefinitions: true, + editorconfig: true, email: Placeholders.email, fullName: Placeholders.name, immutable: true, @@ -498,6 +504,7 @@ test(`${TestDirectories.six}: Sandboxed: yarn, no initial commit`, async t => { const map = await hashAllTheThings(TestDirectories.six, true); t.deepEqual(ignorePackageJson(map), { 'test-6/.circleci/config.yml': '30cc59229facf29bfca712fc6e2ddade', + 'test-6/.editorconfig': '44a3e6c69d9267b0f756986fd970a8f4', 'test-6/.github/CONTRIBUTING.md': '5f0dfa7fdf9bf828e3a3aa8fcaeece08', 'test-6/.github/ISSUE_TEMPLATE.md': '82d1b99b29f32d851627b317195e73d2', 'test-6/.github/PULL_REQUEST_TEMPLATE.md': diff --git a/src/cli/tests/cli.unit.spec.ts b/src/cli/tests/cli.unit.spec.ts index 83a0543..df93e5b 100644 --- a/src/cli/tests/cli.unit.spec.ts +++ b/src/cli/tests/cli.unit.spec.ts @@ -78,6 +78,7 @@ test('checkArgs returns the right options', async t => { '--travis', '--yarn', '--no-circleci', + '--no-editorconfig', '--no-immutable', '--no-install', '--no-vscode' @@ -89,6 +90,7 @@ test('checkArgs returns the right options', async t => { circleci: false, description: '', domDefinitions: true, + editorconfig: false, immutable: false, install: false, nodeDefinitions: true, diff --git a/src/cli/typescript-starter.ts b/src/cli/typescript-starter.ts index 47332bf..47a5e7f 100644 --- a/src/cli/typescript-starter.ts +++ b/src/cli/typescript-starter.ts @@ -14,6 +14,7 @@ export async function typescriptStarter( circleci, description, domDefinitions, + editorconfig, email, fullName, githubUsername, @@ -151,6 +152,9 @@ export async function typescriptStarter( if (!travis) { del([join(projectPath, '.travis.yml')]); } + if (!editorconfig) { + del([join(projectPath, '.editorconfig')]); + } if (!vscode) { del([join(projectPath, '.vscode')]); } diff --git a/src/cli/utils.ts b/src/cli/utils.ts index a459975..d660506 100644 --- a/src/cli/utils.ts +++ b/src/cli/utils.ts @@ -12,6 +12,7 @@ export interface TypescriptStarterCLIOptions { readonly circleci: boolean; readonly description: string; readonly domDefinitions: boolean; + readonly editorconfig: boolean; readonly immutable: boolean; readonly install: boolean; readonly nodeDefinitions: boolean; @@ -67,20 +68,20 @@ export function validateName(input: string): true | string { export function getIntro(columns: number | undefined): string { const ascii = ` - _ _ _ _ _ -| |_ _ _ _ __ ___ ___ ___ _ __(_)_ __ | |_ ___| |_ __ _ _ __| |_ ___ _ __ + _ _ _ _ _ +| |_ _ _ _ __ ___ ___ ___ _ __(_)_ __ | |_ ___| |_ __ _ _ __| |_ ___ _ __ | __| | | | '_ \\ / _ \\/ __|/ __| '__| | '_ \\| __|____/ __| __/ _\` | '__| __/ _ \\ '__| -| |_| |_| | |_) | __/\\__ \\ (__| | | | |_) | ||_____\\__ \\ || (_| | | | || __/ | - \\__|\\__, | .__/ \\___||___/\\___|_| |_| .__/ \\__| |___/\\__\\__,_|_| \\__\\___|_| - |___/|_| |_| +| |_| |_| | |_) | __/\\__ \\ (__| | | | |_) | ||_____\\__ \\ || (_| | | | || __/ | + \\__|\\__, | .__/ \\___||___/\\___|_| |_| .__/ \\__| |___/\\__\\__,_|_| \\__\\___|_| + |___/|_| |_| `; const asciiSmaller = ` -_ _ _ _ _ -| |_ _ _ _ __ ___ ___ __ _ _(_)_ __| |_ ___ __| |_ __ _ _ _| |_ ___ _ _ +_ _ _ _ _ +| |_ _ _ _ __ ___ ___ __ _ _(_)_ __| |_ ___ __| |_ __ _ _ _| |_ ___ _ _ | _| || | '_ \\/ -_|_-= 85