-
Notifications
You must be signed in to change notification settings - Fork 3
/
make.mjs
99 lines (94 loc) · 2.29 KB
/
make.mjs
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
/**
* - Bump version of package
* - Sync versions of all packages
* - Update all dependencies that use the packages
* - Copy files to build folder
* - Extend package.json fields in build folder
* - Publish all packages that changed to npm
*
*/
import dotenv from 'dotenv'
// Will read GITHUB_TOKEN from .env.developemnt
dotenv.config({
path: `.env.${process.env.NODE_ENV || 'development'}`,
})
import yargs from 'yargs'
import { hideBin } from 'yargs/helpers'
import {
releaseCommand,
linkCommand,
listCommand,
syncCommand,
} from '@wheelroom/make/plain'
const packagePositional = (yargs) => {
yargs.positional('package', {
type: 'string',
describe: 'full package name with organisation',
})
}
const pathPositional = (yargs) => {
yargs.positional('path', {
type: 'string',
describe: 'path to npm 7 monorepo',
})
}
yargs(hideBin(process.argv))
.scriptName('make')
.usage('$0 <cmd> [args]')
.command(
'build [package]',
'build a package',
packagePositional,
function (argv) {
releaseCommand({ packageName: argv.package, subCommand: 'build' })
}
)
.command(
'version [package]',
'bumps package and related packages to their new versions',
packagePositional,
function (argv) {
releaseCommand({ packageName: argv.package, subCommand: 'version' })
}
)
.command(
'publish [package]',
'publish package to package repository and commit/push to git repository',
packagePositional,
function (argv) {
releaseCommand({ packageName: argv.package, subCommand: 'publish' })
}
)
.command(
'release [package]',
'run all three: build, version and publish',
packagePositional,
function (argv) {
releaseCommand({ packageName: argv.package })
}
)
.command(
'link [path]',
'create links to monorepo in node_modules',
pathPositional,
function (argv) {
linkCommand({ monoRepoPath: argv.path })
}
)
.command(
'sync [path]',
'sync root package.json values to all packages in monorepo',
function (argv) {
syncCommand({ monoRepoPath: argv.path })
}
)
.command(
'list [path]',
'list packages in monorepo',
pathPositional,
function (argv) {
listCommand({ monoRepoPath: argv.path })
}
)
.demandCommand()
.help().argv