-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
118 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,65 @@ | ||
#!/usr/bin/env node | ||
|
||
const sh = require('shelljs') | ||
const fs = require('fs-extra') | ||
|
||
sh.set('-ev') | ||
|
||
const {version} = fs.readJSONSync('package.json') | ||
const example = process.env.CIRCLE_JOB | ||
const [, type,, format] = example.split('-') | ||
|
||
console.dir({type, format}) | ||
|
||
const options = format === 'typescript' ? | ||
'--options=typescript,mocha,semantic-release' : | ||
'--options=mocha,semantic-release' | ||
|
||
sh.cd(`examples/${example}`) | ||
sh.exec(`yarn create dxcli ${type} --defaults ${options}`) | ||
sh.exec('git fetch') | ||
sh.exec('git checkout master') | ||
sh.exec('git pull --rebase origin master') | ||
|
||
sh.rm('-rf', [ | ||
'.circleci', | ||
'.editorconfig', | ||
'.eslintignore', | ||
'.eslintrc', | ||
'.gitattributes', | ||
'.gitignore', | ||
'appveyor.yml', | ||
'bin', | ||
'package-scripts.js', | ||
'README.md', | ||
'src', | ||
'test', | ||
'tsconfig.json', | ||
'tslint.json', | ||
'yarn.lock' | ||
].join(' ')) | ||
|
||
const pjson = fs.readJSONSync('package.json') | ||
fs.outputJSONSync('package.json', { | ||
name: `@dxcli/${example}`, | ||
repository: `dxcli/${example}`, | ||
author: pjson.author, | ||
version: pjson.version, | ||
}) | ||
|
||
sh.exec(`yarn create dxcli ${type} --force --defaults ${options}`) | ||
sh.exec('git add .') | ||
sh.exec(`git commit -m "fix: create-dxcli ${version}"`) | ||
sh.exec('git push') | ||
sh.cd('../..') | ||
sh.exec(`git add examples/${example}`) | ||
sh.exec(`git commit -m "chore: ${example} updated [ci-skip]`) | ||
|
||
let retries = 4 | ||
function push() { | ||
try { | ||
sh.exec('git pull --rebase origin master') | ||
sh.exec('git push') | ||
} catch (err) { | ||
retries-- | ||
if (retries > 0) return push() | ||
throw err | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/lib | ||
/tmp | ||
/templates | ||
/examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Command, {flags} from '@dxcli/command' | ||
import {createEnv} from 'yeoman-environment' | ||
|
||
export default abstract class AppCommand extends Command { | ||
static flags: flags.Input = { | ||
defaults: flags.boolean({description: 'use defaults for every setting'}), | ||
options: flags.string({description: '(typescript|semantic-release|mocha)'}), | ||
force: flags.boolean({description: 'overwrite existing files'}), | ||
} | ||
static args = [ | ||
{name: 'path', required: false} | ||
] | ||
|
||
abstract type: string | ||
|
||
async run() { | ||
const env = createEnv() | ||
|
||
env.register( | ||
require.resolve('./generators/app'), | ||
'dxcli:app' | ||
) | ||
|
||
const options = this.flags.options ? this.flags.options.split(',') : [] | ||
|
||
await env.run('dxcli:app', {type: this.type, path: this.args.path, options, defaults: this.flags.defaults, force: this.flags.force}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,5 @@ | ||
import Command, {flags} from '@dxcli/command' | ||
import {createEnv} from 'yeoman-environment' | ||
import AppCommand from '../app_command' | ||
|
||
export default class extends Command { | ||
static flags: flags.Input = { | ||
defaults: flags.boolean({description: 'use defaults for every setting'}), | ||
options: flags.string({description: '(typescript|semantic-release|mocha)'}), | ||
} | ||
static args = [ | ||
{name: 'path', required: false} | ||
] | ||
|
||
async run() { | ||
const env = createEnv() | ||
|
||
env.register( | ||
require.resolve('../generators/app'), | ||
'dxcli:app' | ||
) | ||
|
||
const options = this.flags.options ? this.flags.options.split(',') : [] | ||
|
||
await env.run('dxcli:app', {type: 'base', path: this.args.path, options, defaults: this.flags.defaults}) | ||
} | ||
export default class extends AppCommand { | ||
type = 'base' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,5 @@ | ||
import Command, {flags} from '@dxcli/command' | ||
import {createEnv} from 'yeoman-environment' | ||
import AppCommand from '../app_command' | ||
|
||
export default class extends Command { | ||
static flags: flags.Input = { | ||
defaults: flags.boolean({description: 'use defaults for every setting'}), | ||
options: flags.string({description: '(typescript|semantic-release|mocha)'}), | ||
} | ||
static args = [ | ||
{name: 'path', required: false} | ||
] | ||
|
||
async run() { | ||
const env = createEnv() | ||
|
||
env.register( | ||
require.resolve('../generators/app'), | ||
'dxcli:app' | ||
) | ||
|
||
const options = this.flags.options ? this.flags.options.split(',') : [] | ||
|
||
await env.run('dxcli:app', {type: 'multi', path: this.args.path, options, defaults: this.flags.defaults}) | ||
} | ||
export default class extends AppCommand { | ||
type = 'multi' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,5 @@ | ||
import Command, {flags} from '@dxcli/command' | ||
import {createEnv} from 'yeoman-environment' | ||
import AppCommand from '../app_command' | ||
|
||
export default class extends Command { | ||
static flags: flags.Input = { | ||
defaults: flags.boolean({description: 'use defaults for every setting'}), | ||
options: flags.string({description: '(typescript|semantic-release|mocha)'}), | ||
} | ||
static args = [ | ||
{name: 'path', required: false} | ||
] | ||
|
||
async run() { | ||
const env = createEnv() | ||
|
||
env.register( | ||
require.resolve('../generators/app'), | ||
'dxcli:app' | ||
) | ||
|
||
const options = this.flags.options ? this.flags.options.split(',') : [] | ||
|
||
await env.run('dxcli:app', {type: 'plugin', path: this.args.path, options, defaults: this.flags.defaults}) | ||
} | ||
export default class extends AppCommand { | ||
type = 'plugin' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,5 @@ | ||
import Command, {flags} from '@dxcli/command' | ||
import {createEnv} from 'yeoman-environment' | ||
import AppCommand from '../app_command' | ||
|
||
export default class extends Command { | ||
static flags: flags.Input = { | ||
defaults: flags.boolean({description: 'use defaults for every setting'}), | ||
options: flags.string({description: '(typescript|semantic-release|mocha)'}), | ||
} | ||
static args = [ | ||
{name: 'path', required: false} | ||
] | ||
|
||
async run() { | ||
const env = createEnv() | ||
|
||
env.register( | ||
require.resolve('../generators/app'), | ||
'dxcli:app' | ||
) | ||
|
||
const options = this.flags.options ? this.flags.options.split(',') : [] | ||
|
||
await env.run('dxcli:app', {type: 'single', path: this.args.path, options, defaults: this.flags.defaults}) | ||
} | ||
export default class extends AppCommand { | ||
type = 'single' | ||
} |