1
0
mirror of synced 2025-11-08 21:07:23 +00:00

feat(CLI): add Travis CI and Appveyor CI as extra options

Closes #69
This commit is contained in:
Jason Dreyzehner
2018-03-15 22:55:29 -04:00
parent 74c0900ad9
commit bdaafaaac0
7 changed files with 81 additions and 12 deletions

View File

@@ -14,20 +14,32 @@ export async function checkArgs(): Promise<TypescriptStarterArgsOptions> {
$ npx typescript-starter <project-name> [options]
Options
--appveyor include Appveyor for Windows CI
--description, -d package.json description
--yarn use yarn (default: npm)
--node include node.js type definitions
--dom include DOM type definitions
--node include node.js type definitions
--strict enable stricter type-checking
--travis include Travis CI configuration
--yarn use yarn (default: npm)
--no-circleci don't include CircleCI
--no-immutable don't enable tslint-immutable
--no-install skip yarn/npm install
--strict Enable stricter type-checking
--no-immutable Don't enable tslint-immutable
--no-vscode Don't include VS Code debugging config
--no-vscode don't include VS Code debugging config
Non-Interactive Example
$ npx typescript-starter my-library -d 'do something, better'
`,
{
flags: {
appveyor: {
default: false,
type: 'boolean'
},
circleci: {
default: true,
type: 'boolean'
},
description: {
alias: 'd',
default: 'a typescript-starter project',
@@ -53,6 +65,10 @@ export async function checkArgs(): Promise<TypescriptStarterArgsOptions> {
default: false,
type: 'boolean'
},
travis: {
default: false,
type: 'boolean'
},
vscode: {
default: true,
type: 'boolean'
@@ -98,6 +114,8 @@ export async function checkArgs(): Promise<TypescriptStarterArgsOptions> {
}
return {
appveyor: cli.flags.appveyor,
circleci: cli.flags.circleci,
description: cli.flags.description,
domDefinitions: cli.flags.dom,
immutable: cli.flags.immutable,
@@ -107,6 +125,7 @@ export async function checkArgs(): Promise<TypescriptStarterArgsOptions> {
runner: cli.flags.yarn ? Runner.Yarn : Runner.Npm,
starterVersion: cli.pkg.version,
strict: cli.flags.strict,
travis: cli.flags.travis,
vscode: cli.flags.vscode
};
}

View File

@@ -75,8 +75,11 @@ export async function inquire(): Promise<TypescriptStarterCLIOptions> {
};
enum Extras {
strict = 'strict',
appveyor = 'appveyor',
circleci = 'circleci',
immutable = 'immutable',
strict = 'strict',
travis = 'travis',
vscode = 'vscode'
}
const extrasQuestion: Question = {
@@ -94,6 +97,21 @@ export async function inquire(): Promise<TypescriptStarterCLIOptions> {
checked: true,
name: 'Include VS Code debugging config',
value: Extras.vscode
},
{
checked: true,
name: 'Include CircleCI config',
value: Extras.circleci
},
{
checked: false,
name: 'Include Appveyor (Windows-based CI) config',
value: Extras.appveyor
},
{
checked: false,
name: 'Include Travis CI config',
value: Extras.travis
}
],
message: '🚀 More fun stuff:',
@@ -125,6 +143,8 @@ export async function inquire(): Promise<TypescriptStarterCLIOptions> {
readonly type: ProjectType;
};
return {
appveyor: extras.includes(Extras.appveyor),
circleci: extras.includes(Extras.circleci),
description,
domDefinitions: definitions
? [TypeDefinitions.dom, TypeDefinitions.nodeAndDom].includes(
@@ -141,6 +161,7 @@ export async function inquire(): Promise<TypescriptStarterCLIOptions> {
projectName,
runner,
strict: extras.includes(Extras.strict),
travis: extras.includes(Extras.travis),
vscode: extras.includes(Extras.vscode)
};
});

View File

@@ -194,6 +194,8 @@ export const addInferredOptions = async (
};
return {
...inferredOptions,
appveyor: userOptions.appveyor,
circleci: userOptions.circleci,
description: userOptions.description,
domDefinitions: userOptions.domDefinitions,
immutable: userOptions.immutable,
@@ -202,6 +204,7 @@ export const addInferredOptions = async (
projectName: userOptions.projectName,
runner: userOptions.runner,
strict: userOptions.strict,
travis: userOptions.travis,
vscode: userOptions.vscode
};
};

View File

@@ -424,6 +424,8 @@ test(`${
t.plan(3);
const options = {
...sandboxOptions,
appveyor: false,
circleci: false,
domDefinitions: false,
email: 'email@example.com',
fullName: 'Satoshi Nakamoto',
@@ -433,13 +435,13 @@ test(`${
projectName: TestDirectories.five,
runner: Runner.Npm,
strict: true,
travis: false,
vscode: false
};
silenceConsole(console);
await typescriptStarter(options, sandboxTasks(t, true, true));
const map = await hashAllTheThings(TestDirectories.five, true);
t.deepEqual(map, {
'test-5/.circleci/config.yml': '30cc59229facf29bfca712fc6e2ddade',
'test-5/.github/CONTRIBUTING.md': '5f0dfa7fdf9bf828e3a3aa8fcaeece08',
'test-5/.github/ISSUE_TEMPLATE.md': '82d1b99b29f32d851627b317195e73d2',
'test-5/.github/PULL_REQUEST_TEMPLATE.md':
@@ -465,6 +467,8 @@ test(`${TestDirectories.six}: Sandboxed: yarn, no initial commit`, async t => {
t.plan(2);
const options = {
...sandboxOptions,
appveyor: true,
circleci: true,
domDefinitions: true,
email: Placeholders.email,
fullName: Placeholders.name,
@@ -474,6 +478,7 @@ test(`${TestDirectories.six}: Sandboxed: yarn, no initial commit`, async t => {
projectName: TestDirectories.six,
runner: Runner.Yarn,
strict: false,
travis: true,
vscode: true
};
silenceConsole(console);
@@ -488,10 +493,12 @@ test(`${TestDirectories.six}: Sandboxed: yarn, no initial commit`, async t => {
'test-6/.gitignore': 'a5d12062173e075833f8ca6f754d6d43',
'test-6/.npmignore': 'd32d96087924f360f31b0438bb69d17e',
'test-6/.prettierignore': '1da1ce4fdb868f0939608fafd38f9683',
'test-6/.travis.yml': '8ba04203d5a1c6e0304fef52123a45fc',
'test-6/.vscode/launch.json': '17407a15e4276d088a9bbe9ae886fa65',
'test-6/.vscode/settings.json': '10c634c5fef6ecd298b6e41bf159f2cc',
'test-6/LICENSE': '1dfe8c78c6af40fc14ea3b40133f1fa5',
'test-6/README.md': 'd809bcbf240f44b51b575a3d49936232',
'test-6/appveyor.yml': 'c889f967e607510860d754a031fdf93c',
'test-6/bin/typescript-starter': 'df05a2c6c849f47761f0e24230359d3e',
'test-6/package.json': 'a7a94f6c500a05c90e475049103ba26e',
'test-6/src/index.ts': 'fbc67c2cbf3a7d37e4e02583bf06eec9',

View File

@@ -70,18 +70,23 @@ test('checkArgs returns the right options', async t => {
'path/to/node',
'path/to/typescript-starter',
'example-project',
'--appveyor',
`-description "example description"`,
'--yarn',
'--node',
'--dom',
'--no-install',
'--node',
'--strict',
'--travis',
'--yarn',
'--no-circleci',
'--no-immutable',
'--no-install',
'--no-vscode'
];
const opts = await checkArgs();
const currentVersion = meow('').pkg.version;
t.deepEqual(opts, {
appveyor: true,
circleci: false,
description: '',
domDefinitions: true,
immutable: false,
@@ -91,6 +96,7 @@ test('checkArgs returns the right options', async t => {
runner: Runner.Yarn,
starterVersion: currentVersion,
strict: true,
travis: true,
vscode: false
});
});

View File

@@ -10,6 +10,8 @@ import { Runner, TypescriptStarterOptions } from './utils';
export async function typescriptStarter(
{
appveyor,
circleci,
description,
domDefinitions,
email,
@@ -22,6 +24,7 @@ export async function typescriptStarter(
repoInfo,
runner,
strict,
travis,
vscode,
workingDirectory
}: TypescriptStarterOptions,
@@ -128,11 +131,18 @@ export async function typescriptStarter(
join(projectPath, 'CHANGELOG.md'),
join(projectPath, 'README.md'),
join(projectPath, 'package-lock.json'),
join(projectPath, 'appveyor.yml'),
join(projectPath, '.travis.yml'),
join(projectPath, 'src', 'cli'),
join(projectPath, 'src', 'types', 'cli.d.ts')
]);
if (!appveyor) {
del([join(projectPath, 'appveyor.yml')]);
}
if (!circleci) {
del([join(projectPath, '.circleci')]);
}
if (!travis) {
del([join(projectPath, '.travis.yml')]);
}
if (!vscode) {
del([join(projectPath, '.vscode')]);
}

View File

@@ -8,6 +8,8 @@ export enum Runner {
}
export interface TypescriptStarterCLIOptions {
readonly appveyor: boolean;
readonly circleci: boolean;
readonly description: string;
readonly domDefinitions: boolean;
readonly immutable: boolean;
@@ -16,6 +18,7 @@ export interface TypescriptStarterCLIOptions {
readonly projectName: string;
readonly runner: Runner;
readonly strict: boolean;
readonly travis: boolean;
readonly vscode: boolean;
}