forked from umijs/father
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add create-father for create boilerplate
- Loading branch information
1 parent
41f631e
commit 6010dbf
Showing
19 changed files
with
342 additions
and
102 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env node | ||
|
||
require('../dist/cli'); |
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,33 @@ | ||
{ | ||
"name": "create-father", | ||
"version": "4.0.0-alpha.1", | ||
"description": "Creator for father boilerplate", | ||
"homepage": "https://github.com/umijs/father-next/tree/master/boilerplate#readme", | ||
"bugs": "https://github.com/umijs/father-next/issues", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/umijs/father-next" | ||
}, | ||
"license": "MIT", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"bin": { | ||
"create-father": "bin/create-father.js" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"build": "pnpm tsc", | ||
"dev": "pnpm tsc --watch" | ||
}, | ||
"dependencies": { | ||
"@umijs/utils": "^4.0.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"authors": [ | ||
"PeachScript <[email protected]> (https://github.com/PeachScript)" | ||
] | ||
} |
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,26 @@ | ||
import { chalk, isLocalDev, yParser } from '@umijs/utils'; | ||
|
||
const args = yParser(process.argv.slice(2), { | ||
alias: { | ||
version: ['v'], | ||
help: ['h'], | ||
}, | ||
boolean: ['version'], | ||
}); | ||
|
||
if (args.version && !args._[0]) { | ||
args._[0] = 'version'; | ||
const local = isLocalDev() ? chalk.cyan('@local') : ''; | ||
const { name, version } = require('../package.json'); | ||
console.log(`${name}@${version}${local}`); | ||
} else { | ||
require('./') | ||
.default({ | ||
cwd: process.cwd(), | ||
args, | ||
}) | ||
.catch((err: Error) => { | ||
console.error(`Create failed, ${err.message}`); | ||
console.error(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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { | ||
BaseGenerator, | ||
installWithNpmClient, | ||
prompts, | ||
yParser, | ||
} from '@umijs/utils'; | ||
import { join } from 'path'; | ||
|
||
export default async ({ | ||
cwd, | ||
args, | ||
}: { | ||
cwd: string; | ||
args: yParser.Arguments; | ||
}) => { | ||
const [name] = args._; | ||
const target = name ? join(cwd, name) : cwd; | ||
const registry = 'https://registry.npmjs.org/'; | ||
const { version } = require('../package.json'); | ||
const { npmClient, platform } = await prompts( | ||
[ | ||
{ | ||
type: 'select', | ||
name: 'platform', | ||
message: 'Pick target platform(s)', | ||
choices: [ | ||
{ title: 'Node.js', value: 'node' }, | ||
{ title: 'Browser', value: 'browser' }, | ||
{ title: 'Both', value: 'both' }, | ||
], | ||
initial: 0, | ||
}, | ||
{ | ||
type: 'select', | ||
name: 'npmClient', | ||
message: 'Pick NPM client', | ||
choices: [ | ||
{ title: 'npm', value: 'npm' }, | ||
{ title: 'cnpm', value: 'cnpm' }, | ||
{ title: 'tnpm', value: 'tnpm' }, | ||
{ title: 'yarn', value: 'yarn' }, | ||
{ title: 'pnpm', value: 'pnpm' }, | ||
], | ||
initial: 4, | ||
}, | ||
], | ||
{ | ||
onCancel() { | ||
process.exit(1); | ||
}, | ||
}, | ||
); | ||
|
||
const generator = new BaseGenerator({ | ||
path: join(__dirname, '../template'), | ||
target, | ||
data: { | ||
version: version.includes('-canary.') ? version : `^${version}`, | ||
npmClient, | ||
isNode: platform === 'node', | ||
isBrowser: platform === 'browser', | ||
isBothNodeBrowser: platform === 'both', | ||
registry, | ||
}, | ||
questions: [ | ||
{ | ||
name: 'name', | ||
type: 'text', | ||
message: `Input NPM package name`, | ||
}, | ||
{ | ||
name: 'description', | ||
type: 'text', | ||
message: `Input NPM package description`, | ||
}, | ||
{ | ||
name: 'author', | ||
type: 'text', | ||
message: `Input NPM package author (Name <[email protected]>)`, | ||
}, | ||
], | ||
}); | ||
await generator.run(); | ||
|
||
// install | ||
installWithNpmClient({ npmClient, cwd: target }); | ||
}; |
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,7 @@ | ||
import { defineConfig } from 'father'; | ||
|
||
export default defineConfig({ | ||
{{#isBoth}}esm: { input: 'src/client' }, | ||
cjs: { input: 'src/server' },{{/isBoth}}{{#isNode}}cjs: {},{{/isNode}}{{#isBrowser}}esm: {},{{/isBrowser}} | ||
prebundle: {}, | ||
}); |
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,3 @@ | ||
/node_modules | ||
/dist | ||
.DS_Store |
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,23 @@ | ||
# {{{ name }}} | ||
|
||
[![NPM version](https://img.shields.io/npm/v/{{{ name }}}.svg?style=flat)](https://npmjs.org/package/{{{ name }}}) | ||
[![NPM downloads](http://img.shields.io/npm/dm/{{{ name }}}.svg?style=flat)](https://npmjs.org/package/{{{ name }}}) | ||
|
||
## Install | ||
|
||
```bash | ||
$ {{ npmClient }} install | ||
``` | ||
|
||
```bash | ||
$ npm run dev | ||
$ npm run build | ||
``` | ||
|
||
## Options | ||
|
||
TODO | ||
|
||
## LICENSE | ||
|
||
MIT |
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 @@ | ||
{ | ||
"name": "{{{ name }}}", | ||
"version": "0.0.1", | ||
"description": "{{{ description }}}", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"scripts": { | ||
"dev": "father dev", | ||
"build": "father build", | ||
"build:deps": "father prebundle", | ||
"prepublishOnly": "npm run build" | ||
}, | ||
"keywords": [], | ||
"authors": [{{#author}} | ||
"{{{ author }}}" | ||
{{/author}}], | ||
"license": "MIT", | ||
"files": [ | ||
"dist", | ||
"compiled" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"devDependencies": { | ||
"father": "{{{ version }}}" | ||
} | ||
} |
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 @@ | ||
export default 'Hello father 4!'; |
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,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"declaration": true, | ||
"skipLibCheck": true, | ||
"baseUrl": "./" | ||
} | ||
} |
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,8 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "./dist", | ||
"rootDir": "./src" | ||
}, | ||
"include": ["src"] | ||
} |
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,10 +1,10 @@ | ||
{ | ||
"scripts": { | ||
"build": "../../bin/father.js build", | ||
"build:no-clean": "../../bin/father.js build --no-clean", | ||
"version": "../../bin/father.js version" | ||
"build": "father build", | ||
"build:no-clean": "father build --no-clean", | ||
"version": "father version" | ||
}, | ||
"dependencies": { | ||
"father": "link:..\\.." | ||
"father": "workspace:*" | ||
} | ||
} |
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
Oops, something went wrong.