Skip to content

Commit 9365892

Browse files
committed
move tasks out from builder
1 parent 85512fb commit 9365892

12 files changed

+299
-260
lines changed

.flowconfig

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ untyped-type-import=error
1111
./node_modules/@babel/types/lib/index.js.flow
1212

1313
[version]
14-
>=0.87.0
14+
>=0.94.0
1515

1616
[include]
1717

@@ -39,6 +39,7 @@ module.name_mapper='^chalk$' -> '<PROJECT_ROOT>/flow/chalk'
3939
module.name_mapper='^redux$' -> '<PROJECT_ROOT>/flow/redux'
4040
module.name_mapper='^shelljs$' -> '<PROJECT_ROOT>/flow/shelljs'
4141
module.name_mapper='^effector/\(.+\)$' -> '<PROJECT_ROOT>/src/\1'
42+
module.name_mapper='^Builder\(.*\)$' -> '<PROJECT_ROOT>/tools/builder\1'
4243
module.name_mapper='^effector/flags$' -> '<PROJECT_ROOT>/src/flags.dev'
4344
module.name_mapper='^effector$' -> '<PROJECT_ROOT>/packages/effector'
4445
module.name_mapper='^effector-react$' -> '<PROJECT_ROOT>/packages/effector-react'

babel.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const aliases = {
1919
invariant: 'invariant',
2020
'effector-react': 'react',
2121
'effector-vue': 'vue',
22+
Builder: '../tools/builder',
2223
}
2324

2425
module.exports = api => {
@@ -32,7 +33,7 @@ module.exports = api => {
3233
}
3334
const plugins = [
3435
'./src/babel/get-step',
35-
'./src/babel/stats-plugin',
36+
// './src/babel/stats-plugin',
3637
'@babel/plugin-proposal-export-namespace-from',
3738
'@babel/plugin-proposal-optional-chaining',
3839
'@babel/plugin-proposal-nullish-coalescing-operator',

modules.png

112 KB
Loading

tasks/babelPlugins.js

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//@flow
2+
3+
import {outputPackageJSON, massCopy, publishScript} from 'Builder/utils'
4+
import {rollupBabel} from 'Builder/rollup'
5+
import packages from 'Builder/packages.config'
6+
7+
export default {
8+
'@effector/babel-plugin': [
9+
() =>
10+
outputPackageJSON(
11+
'packages/@effector/babel-plugin/package.json',
12+
packages['@effector/babel-plugin'],
13+
),
14+
() => massCopy('.', 'npm/@effector/babel-plugin', ['LICENSE']),
15+
() =>
16+
massCopy(
17+
'packages/@effector/babel-plugin',
18+
'npm/@effector/babel-plugin',
19+
['package.json', 'README.md'],
20+
),
21+
() => rollupBabel('@effector/babel-plugin', 'src/babel/babel-plugin'),
22+
publishScript('@effector/babel-plugin'),
23+
],
24+
'@effector/babel-plugin-react': [
25+
() =>
26+
outputPackageJSON(
27+
'packages/@effector/babel-plugin-react/package.json',
28+
packages['@effector/babel-plugin-react'],
29+
),
30+
() => massCopy('.', 'npm/@effector/babel-plugin-react', ['LICENSE']),
31+
() =>
32+
massCopy(
33+
'packages/@effector/babel-plugin-react',
34+
'npm/@effector/babel-plugin-react',
35+
['package.json', 'README.md'],
36+
),
37+
() =>
38+
rollupBabel(
39+
'@effector/babel-plugin-react',
40+
'src/babel/babel-plugin-react',
41+
),
42+
publishScript('@effector/babel-plugin-react'),
43+
],
44+
}

tasks/bs/index.js

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//@flow
2+
import * as fs from 'fs-extra'
3+
import {outputPackageJSON, massCopy, publishScript} from 'Builder/utils'
4+
import packages from 'Builder/packages.config'
5+
import bsconfigs from './packages.config'
6+
7+
export default {
8+
'bs-effector': [
9+
() =>
10+
outputPackageJSON(
11+
'packages/bs-effector/package.json',
12+
packages['bs-effector'],
13+
),
14+
() =>
15+
fs.outputJSON(
16+
'packages/bs-effector/bsconfig.json',
17+
bsconfigs['bs-effector'],
18+
{spaces: 2},
19+
),
20+
() => massCopy('.', 'npm/bs-effector', ['LICENSE']),
21+
() =>
22+
massCopy('src/reason', 'npm/bs-effector', [
23+
['Effector.re', 'src/Effector.re'],
24+
]),
25+
() =>
26+
massCopy('packages/bs-effector', 'npm/bs-effector', [
27+
'README.md',
28+
'package.json',
29+
'bsconfig.json',
30+
]),
31+
publishScript('bs-effector'),
32+
],
33+
'bs-effector-react': [
34+
() =>
35+
outputPackageJSON(
36+
'packages/bs-effector-react/package.json',
37+
packages['bs-effector-react'],
38+
),
39+
() =>
40+
fs.outputJSON(
41+
'packages/bs-effector-react/bsconfig.json',
42+
bsconfigs['bs-effector-react'],
43+
{spaces: 2},
44+
),
45+
() => massCopy('.', 'npm/bs-effector-react', ['LICENSE']),
46+
() =>
47+
massCopy('src/reason', 'npm/bs-effector-react', [
48+
['EffectorReact.re', 'src/EffectorReact.re'],
49+
]),
50+
() =>
51+
massCopy('packages/bs-effector-react', 'npm/bs-effector-react', [
52+
'README.md',
53+
'package.json',
54+
'bsconfig.json',
55+
]),
56+
publishScript('bs-effector-react'),
57+
],
58+
}
File renamed without changes.

tasks/effector/index.js

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
//@flow
2+
3+
import {outputPackageJSON, massCopy, publishScript} from 'Builder/utils'
4+
import {
5+
rollupEffector,
6+
rollupEffectorReact,
7+
rollupEffectorVue,
8+
} from 'Builder/rollup'
9+
import packages from 'Builder/packages.config'
10+
import renderModulesGraph from 'Builder/moduleGraphGenerator'
11+
12+
export default {
13+
effector: [
14+
() =>
15+
outputPackageJSON('packages/effector/package.json', packages.effector),
16+
() => massCopy('.', 'npm/effector', ['LICENSE', 'README.md']),
17+
() =>
18+
massCopy('packages/effector', 'npm/effector', [
19+
'index.d.ts',
20+
'package.json',
21+
[
22+
'index.js.flow',
23+
[
24+
'index.js.flow',
25+
'effector.cjs.js.flow',
26+
'effector.es.js.flow',
27+
'effector.umd.js.flow',
28+
],
29+
],
30+
]),
31+
rollupEffector,
32+
renderModulesGraph,
33+
publishScript('effector'),
34+
],
35+
'effector-react': [
36+
() =>
37+
outputPackageJSON(
38+
'packages/effector-react/package.json',
39+
packages['effector-react'],
40+
),
41+
() => massCopy('.', 'npm/effector-react', ['LICENSE']),
42+
() =>
43+
massCopy('packages/effector-react', 'npm/effector-react', [
44+
'index.d.ts',
45+
'README.md',
46+
'package.json',
47+
[
48+
'index.js.flow',
49+
[
50+
'index.js.flow',
51+
'effector-react.cjs.js.flow',
52+
'effector-react.es.js.flow',
53+
'effector-react.umd.js.flow',
54+
],
55+
],
56+
]),
57+
rollupEffectorReact,
58+
publishScript('effector-react'),
59+
],
60+
'effector-vue': [
61+
() =>
62+
outputPackageJSON(
63+
'packages/effector-vue/package.json',
64+
packages['effector-vue'],
65+
),
66+
() => massCopy('.', 'npm/effector-vue', ['LICENSE']),
67+
() =>
68+
massCopy('packages/effector-vue', 'npm/effector-vue', [
69+
'index.d.ts',
70+
'README.md',
71+
'package.json',
72+
[
73+
'index.js.flow',
74+
[
75+
'index.js.flow',
76+
'effector-vue.cjs.js.flow',
77+
'effector-vue.es.js.flow',
78+
'effector-vue.umd.js.flow',
79+
],
80+
],
81+
]),
82+
rollupEffectorVue,
83+
publishScript('effector-vue'),
84+
],
85+
}

tasks/hooks.js

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
//@flow
2+
/* eslint-disable max-len */
3+
import * as fs from 'fs-extra'
4+
import {load} from 'js-yaml'
5+
import {validateConfig, loadYaml, cliArgs} from 'Builder/utils'
6+
import {setConfig} from 'Builder/taskList'
7+
import table from 'markdown-table'
8+
9+
export default {
10+
beforeAll: [
11+
() => fs.emptyDir(`${process.cwd()}/npm`),
12+
async() => {
13+
process.env.IS_BUILD = 'true'
14+
},
15+
async() => {
16+
if (cliArgs.current.length < 1) return
17+
const argRaw = cliArgs.current[0]
18+
let body
19+
try {
20+
body = load(argRaw)
21+
} catch {
22+
return
23+
}
24+
if (typeof body !== 'object' || body === null) return
25+
cliArgs.current.splice(0, 1)
26+
for (const field in body) {
27+
//$todo
28+
setConfig(field, body[field])
29+
}
30+
},
31+
async() => {
32+
const configRaw = await loadYaml('packages.yml')
33+
const config = validateConfig(configRaw)
34+
const packagesByCategory = new Map()
35+
for (const pkg of config.packages) {
36+
if (!packagesByCategory.has(pkg.category)) {
37+
packagesByCategory.set(pkg.category, [pkg])
38+
} else {
39+
packagesByCategory.set(pkg.category, [
40+
//$todo
41+
...packagesByCategory.get(pkg.category),
42+
pkg,
43+
])
44+
}
45+
}
46+
47+
const npmVersionBadge = name =>
48+
`[![npm](https://img.shields.io/npm/v/${name}.svg?maxAge=3600)](https://www.npmjs.com/package/${name})`
49+
const npmDepsBadge = name =>
50+
`[![Dependency Status](https://david-dm.org/zerobias/effector.svg?path=packages/${name})](https://david-dm.org/zerobias/effector?path=packages/${name})`
51+
const markdown = `
52+
# Monorepo
53+
${config.categories
54+
.map(({name, description}) => {
55+
const mdHeader = `### ${description}`
56+
const data = packagesByCategory.get(name) || []
57+
const rawTable = [
58+
['Package', 'Version', 'Dependencies'],
59+
...data.map(pkg => [
60+
`[\`${pkg.name}\`](${pkg.name})`,
61+
npmVersionBadge(pkg.name),
62+
npmDepsBadge(pkg.name),
63+
]),
64+
]
65+
const mdTable = table(rawTable, {align: 'c'})
66+
return `
67+
68+
${mdHeader}
69+
70+
${mdTable}
71+
`
72+
})
73+
.join('\n')}
74+
`
75+
await fs.outputFile('./packages/README.md', markdown)
76+
},
77+
],
78+
}

tasks/index.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//@flow
2+
3+
import bs from './bs'
4+
import babel from './babelPlugins'
5+
import effector from './effector'
6+
7+
import hooks from './hooks'
8+
9+
export default {
10+
tasks: {
11+
...effector,
12+
...babel,
13+
...bs,
14+
},
15+
hooks,
16+
}

0 commit comments

Comments
 (0)