This repository has been archived by the owner on Mar 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
index.ts
164 lines (147 loc) · 4.9 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import plugin, { StartDataFilesProps, StartDataFile } from '@start/plugin/src'
import sequence from '@start/plugin-sequence/src/'
import parallel from '@start/plugin-parallel/src/'
import xargs from '@start/plugin-xargs/src/'
import assert from '@start/plugin-assert/src/'
import env from '@start/plugin-env/src/'
import find from '@start/plugin-find/src/'
import findGitStaged from '@start/plugin-find-git-staged/src/'
import remove from '@start/plugin-remove/src/'
import read from '@start/plugin-read/src/'
import babel from '@start/plugin-lib-babel/src/'
import rename from '@start/plugin-rename/src/'
import write from '@start/plugin-write/src/'
import overwrite from '@start/plugin-overwrite/src/'
import watch from '@start/plugin-watch/src/'
import eslint from '@start/plugin-lib-eslint/src/'
import { istanbulInstrument, istanbulReport } from '@start/plugin-lib-istanbul/src/'
import tape from '@start/plugin-lib-tape/src/'
import typescriptGenerate from '@start/plugin-lib-typescript-generate/src/'
import typescriptCheck from '@start/plugin-lib-typescript-check/src/'
import codecov from '@start/plugin-lib-codecov/src/'
import {
makeWorkspacesCommit,
buildBumpedPackages,
getWorkspacesPackagesBumps,
publishWorkspacesPrompt,
writeWorkspacesPackagesDependencies,
writeWorkspacesDependenciesCommit,
writeWorkspacesPackageVersions,
writeWorkspacesPublishCommit,
publishWorkspacesPackagesBumps,
pushCommitsAndTags,
writeWorkspacesPublishTags,
makeWorkspacesGithubReleases
} from '@auto/start-plugin'
// @ts-ignore
import tapDiff from 'tap-diff'
export const build = async (packageName: string) => {
const { babelConfigBuild } = await import('./config/babel')
return sequence(
find(`packages/${packageName}/src/**/*.+(js|ts)`),
read,
babel(babelConfigBuild),
rename((file) => file.replace(/\.ts$/, '.js')),
write(`packages/${packageName}/build/`)
)
}
export const dts = (packageName: string) =>
sequence(
find(`packages/${packageName}/src/*.ts`),
typescriptGenerate(`packages/${packageName}/build/`),
find(`packages/${packageName}/build/**/*.d.ts`),
read,
// https://github.com/babel/babel/issues/7749
// babel(babelConfigDts)
plugin('modifyImports', () => ({ files }: StartDataFilesProps) => ({
files: files.map((file): StartDataFile => ({
...file,
data: file.data.replace(/(@.+?)\/src\/?/g, '$1')
}))
})),
write(`packages/${packageName}/build/`)
)
export const pack = (packageName: string) =>
sequence(
assert(packageName, 'package name is required'),
env({ NODE_ENV: 'production' }),
find(`packages/${packageName}/build/`),
remove,
parallel(['build', 'dts'])(packageName)
)
export const packs = xargs('pack')
export const dev = async (packageName: string) => {
const { babelConfigBuild } = await import('./config/babel')
return watch(`packages/${packageName}/src/**/*.ts`)(
sequence(
read,
babel(babelConfigBuild),
rename((file) => file.replace(/\.ts$/, '.js')),
write(`packages/${packageName}/build/`)
)
)
}
export const lint = () =>
sequence(
findGitStaged(['packages/*/+(src|test)/**/*.ts', 'tasks/**/*.ts']),
read,
eslint(),
typescriptCheck()
)
export const lintAll = () =>
sequence(
find(['packages/*/+(src|test)/**/*.+(ts|js)', 'tasks/**/*.ts']),
read,
eslint(),
typescriptCheck()
)
export const fix = () =>
sequence(
find(['packages/*/+(src|test)/**/*.+(js|ts)', 'tasks/**/*.ts']),
read,
eslint({ fix: true }),
overwrite
)
export const test = (packageName: string = '*') =>
sequence(
env({ NODE_ENV: 'test' }),
find(`coverage/`),
remove,
find(`packages/${packageName}/src/**/*.ts`),
istanbulInstrument({ esModules: true }, ['.ts']),
find(`packages/${packageName}/test/**/*.ts`),
tape(tapDiff),
istanbulReport(['lcovonly', 'html', 'text-summary'])
)
export const ci = () =>
sequence(
lintAll(),
test()
)
export const ciCoverage = () =>
sequence(
ci(),
find('coverage/lcov.info'),
read,
codecov
)
export const commit = async () => {
const { prefixes, workspacesOptions } = await import('./config/auto')
return makeWorkspacesCommit(prefixes, workspacesOptions)
}
export const publish = async () => {
const { prefixes, workspacesOptions, gitOptions, bumpOptions, githubOptions } = await import('./config/auto')
return sequence(
getWorkspacesPackagesBumps(prefixes, gitOptions, bumpOptions, workspacesOptions),
publishWorkspacesPrompt(prefixes),
buildBumpedPackages(pack),
writeWorkspacesPackagesDependencies,
writeWorkspacesDependenciesCommit(prefixes),
writeWorkspacesPackageVersions,
writeWorkspacesPublishCommit(prefixes, workspacesOptions),
writeWorkspacesPublishTags(workspacesOptions),
publishWorkspacesPackagesBumps(),
pushCommitsAndTags,
makeWorkspacesGithubReleases(prefixes, workspacesOptions, githubOptions)
)
}