Skip to content

Commit

Permalink
refact: extract father-build, organized with lerna (umijs#33)
Browse files Browse the repository at this point in the history
* refact: extract father-build, organized with lerna

* fix ci

* remove yarn.lock

* try to fix ci

* try to fix ci

* fix ci
  • Loading branch information
sorrycc authored Jun 19, 2019
1 parent 6ffc23f commit 3495fba
Show file tree
Hide file tree
Showing 424 changed files with 2,799 additions and 18,886 deletions.
14 changes: 8 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/node_modules
/lib
/yarn.lock
/coverage
/packages/*/node_modules
/packages/*/yarn.lock
/packages/*/.local
/.local
/src/fixtures/**/node_modules/.cache
# /src/fixtures/**/.docz
/src/fixtures/build/*/dist
/src/fixtures/e2e/normal/.docz
/src/fixtures/e2e/normal/.doc
/packages/*/src/fixtures/**/node_modules/.cache
/packages/father-build/src/fixtures/build/*/dist
/packages/father/src/fixtures/e2e/normal/.doc
/packages/father/src/fixtures/e2e/normal/.docz
8 changes: 5 additions & 3 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/src/fixtures
/packages/*/src/fixtures
/packages/*/node_modules
/packages/*/.local
/packages/**/*.test.ts
/packages/**/*.test.js
/node_modules
/lib
/coverage
/.local
/.idea
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ node_js:

before_script:
- npm run build
- npm run bootstrap

after_success:
- npm run coveralls
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# father

Library toolkit based on rollup and docz.
Library toolkit based on rollup, docz, storybook, jest and eslint.

[![NPM version][image-1]][1]
[![Build Status][image-2]][2]
Expand Down
6 changes: 4 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module.exports = {
testPathIgnorePatterns: [
'/lib/',
'/src/fixtures',
'/packages/father/lib/',
'/packages/father/src/fixtures',
'/packages/father-build/lib/',
'/packages/father-build/src/fixtures',
],
};
23 changes: 23 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"changelog": {
"labels": {
"pr(enhancement)": ":rocket: Enhancement",
"pr(bug)": ":bug: Bug Fix",
"pr(documentation)": ":book: Documentation",
"pr(dependency)": ":deciduous_tree: Dependency",
"pr(chore)": ":turtle: Chore"
},
"repo": "umijs/father",
"cacheDir": ".changelog"
},
"packages": [
"packages/*"
],
"command": {
"version": {
"exact": true
}
},
"npmClient": "yarn",
"version": "independent"
}
121 changes: 8 additions & 113 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,128 +1,23 @@
{
"name": "father",
"version": "2.9.0",
"description": "Library toolkit based on rollup and docz.",
"main": "lib/index.js",
"bin": {
"father": "./bin/father.js"
},
"typings": "./index.d.ts",
"private": true,
"scripts": {
"bootstrap": "lerna bootstrap",
"build": "umi-tools build",
"changelog": "lerna-changelog",
"test": "umi-test --coverage",
"debug": "umi-test",
"coveralls": "cat ./coverage/lcov.info | coveralls",
"prepublishOnly": "npm run build && np --no-cleanup --yolo --no-publish"
},
"dependencies": {
"@babel/core": "7.4.5",
"@babel/plugin-proposal-class-properties": "7.4.4",
"@babel/plugin-proposal-decorators": "7.4.4",
"@babel/plugin-proposal-do-expressions": "7.2.0",
"@babel/plugin-proposal-export-default-from": "7.2.0",
"@babel/plugin-proposal-export-namespace-from": "7.2.0",
"@babel/plugin-syntax-dynamic-import": "7.2.0",
"@babel/plugin-transform-runtime": "7.4.4",
"@babel/preset-env": "7.4.5",
"@babel/preset-react": "7.0.0",
"@babel/preset-typescript": "7.3.3",
"@babel/register": "7.4.4",
"@storybook/addon-a11y": "^4.1.3",
"@storybook/addon-actions": "^4.1.3",
"@storybook/addon-console": "^1.1.0",
"@storybook/addon-info": "^4.1.4",
"@storybook/addon-knobs": "^4.1.3",
"@storybook/addon-links": "^4.1.3",
"@storybook/addon-notes": "^4.1.3",
"@storybook/addon-options": "^4.1.4",
"@storybook/addon-storysource": "^4.1.3",
"@storybook/addon-viewport": "^4.1.3",
"@storybook/addons": "^4.1.3",
"@storybook/cli": "^4.1.3",
"@storybook/react": "^4.1.3",
"@svgr/rollup": "^4.3.0",
"@typescript-eslint/eslint-plugin": "1.10.2",
"@typescript-eslint/parser": "1.10.2",
"@umijs/fabric": "^1.0.5",
"ajv": "6.10.0",
"autoprefixer": "9.6.0",
"babel-plugin-react-require": "3.1.1",
"chalk": "2.4.2",
"chokidar": "3.0.1",
"docz": "1.2.0",
"docz-core": "1.2.0",
"docz-plugin-umi-css": "0.14.0",
"docz-theme-umi": "^2.0.0",
"eslint": "^5.16.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-config-airbnb-typescript": "^4.0.0",
"eslint-config-egg": "^7.1.0",
"eslint-config-prettier": "^4.1.0",
"eslint-formatter-pretty": "^2.1.1",
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-compat": "^3.1.1",
"eslint-plugin-eslint-comments": "^3.1.1",
"eslint-plugin-import": "^2.17.3",
"eslint-plugin-jest": "^22.4.1",
"eslint-plugin-jsx-a11y": "^6.2.0",
"eslint-plugin-markdown": "^1.0.0",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-react": "^7.12.4",
"eslint-plugin-unicorn": "^8.0.1",
"extend2": "1.0.0",
"fs-extra": "^8.0.1",
"gh-pages": "2.0.1",
"glob": "^7.1.4",
"gulp-if": "2.0.2",
"gulp-typescript": "5.0.1",
"less": "3.9.0",
"less-plugin-npm-import": "2.1.0",
"lodash": "4.17.11",
"prettier": "1.18.2",
"rc-source-loader": "^1.0.2",
"react-markdown": "^4.0.8",
"rimraf": "2.6.3",
"rollup": "1.15.1",
"rollup-plugin-babel": "4.3.2",
"rollup-plugin-commonjs": "10.0.0",
"rollup-plugin-json": "4.0.0",
"rollup-plugin-node-resolve": "5.0.1",
"rollup-plugin-postcss-umi": "2.0.3",
"rollup-plugin-replace": "2.2.0",
"rollup-plugin-terser": "5.0.0",
"rollup-plugin-typescript2": "0.21.1",
"signale": "1.4.0",
"slash2": "2.0.0",
"staged-git-files": "^1.2.0",
"storybook-addon-source": "^1.0.7",
"temp-dir": "2.0.0",
"through2": "3.0.1",
"ts-loader": "^6.0.2",
"typescript": "3.5.1",
"umi-test": "^1.5.10",
"update-notifier": "3.0.0",
"vinyl-fs": "3.0.3",
"yargs-parser": "13.1.1"
},
"devDependencies": {
"@types/jest": "^24.0.13",
"coveralls": "3.0.4",
"np": "5.0.2",
"lerna": "^3.6.0",
"lerna-changelog": "^0.8.2",
"puppeteer": "^1.17.0",
"serve-handler": "^6.0.1",
"test-build-result": "^1.1.2",
"umi-tools": "^0.4.0"
},
"repository": {
"type": "git",
"url": "http://github.com/umijs/father"
},
"homepage": "http://github.com/umijs/father",
"bugs": "http://github.com/umijs/father/issues",
"authors": [
"clock157 <[email protected]> (https://github.com/clock157)",
"chencheng <[email protected]> (https://github.com/sorrycc)"
],
"license": "MIT"
"umi-tools": "^0.4.0",
"umi-test": "^1.5.12"
}
}
1 change: 1 addition & 0 deletions packages/father-build/.local
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Used in bin/father.js to determine if it is in the local debug state.
4 changes: 4 additions & 0 deletions packages/father-build/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# father-build

See our [main repo](https://github.com/umijs/father) for more information.

63 changes: 63 additions & 0 deletions packages/father-build/bin/father-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env node

const { existsSync } = require('fs');
const { join } = require('path');
const yParser = require('yargs-parser');
const chalk = require('chalk');
const signale = require('signale');

// print version and @local
const args = yParser(process.argv.slice(2));
if (args.v || args.version) {
console.log(require('../package').version);
if (existsSync(join(__dirname, '../.local'))) {
console.log(chalk.cyan('@local'));
}
process.exit(0);
}

// Notify update when process exits
const updater = require('update-notifier');
const pkg = require('../package.json');
updater({ pkg }).notify({ defer: true });

const cwd = process.cwd();

function stripEmptyKeys(obj) {
Object.keys(obj).forEach((key) => {
if (!obj[key] || (Array.isArray(obj[key]) && !obj[key].length)) {
delete obj[key];
}
});
return obj;
}

function build() {
// Parse buildArgs from cli
const buildArgs = stripEmptyKeys({
esm: args.esm && { type: args.esm === true ? 'rollup' : args.esm },
cjs: args.cjs && { type: args.cjs === true ? 'rollup' : args.cjs },
umd: args.umd && { name: args.umd === true ? undefined : args.umd },
file: args.file,
target: args.target,
entry: args._.slice(1),
});

if (buildArgs.file && buildArgs.entry && buildArgs.entry.length > 1) {
signale.error(new Error(
`Cannot specify file when have multiple entries (${buildArgs.entry.join(', ')})`
));
process.exit(1);
}

require('../lib/build').default({
cwd,
watch: args.w || args.watch,
buildArgs,
}).catch(e => {
signale.error(e);
process.exit(1);
});
}

build();
Loading

0 comments on commit 3495fba

Please sign in to comment.