madrun 9.1.0 → 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog +7 -0
- package/README.md +6 -1
- package/bin/init.mjs +1 -3
- package/bin/madrun-completion.js +0 -1
- package/bin/madrun.mjs +14 -7
- package/lib/check.js +0 -1
- package/lib/choose.mjs +1 -0
- package/lib/fix.mjs +8 -6
- package/lib/help.js +0 -1
- package/lib/madrun.js +17 -13
- package/lib/validate.js +0 -1
- package/lib/wildcard.js +2 -3
- package/package.json +2 -4
package/ChangeLog
CHANGED
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# 🏎 Madrun [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
|
|
3
5
|
[NPMURL]: https://npmjs.org/package/madrun "npm"
|
|
4
6
|
[NPMIMGURL]: https://img.shields.io/npm/v/madrun.svg?style=flat
|
|
5
7
|
[BuildStatusURL]: https://github.com/coderaiser/madrun/actions?query=workflow%3A%22Node+CI%22 "Build Status"
|
|
@@ -147,7 +149,10 @@ export default {
|
|
|
147
149
|
'lint:env': () => ['putout .', {
|
|
148
150
|
CI: 1,
|
|
149
151
|
}],
|
|
150
|
-
'env:lint': () => [
|
|
152
|
+
'env:lint': () => [
|
|
153
|
+
env,
|
|
154
|
+
'putout .',
|
|
155
|
+
],
|
|
151
156
|
'lint:no-env': async () => await cutEnv('lint:env'),
|
|
152
157
|
};
|
|
153
158
|
```
|
package/bin/init.mjs
CHANGED
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
writeFile,
|
|
5
5
|
access,
|
|
6
6
|
} from 'fs/promises';
|
|
7
|
-
|
|
8
7
|
import tryToCatch from 'try-to-catch';
|
|
9
8
|
import montag from 'montag';
|
|
10
9
|
|
|
@@ -21,7 +20,7 @@ export const createMadrun = async (cwd, info) => {
|
|
|
21
20
|
if (!name) {
|
|
22
21
|
const {scripts = {}} = info;
|
|
23
22
|
|
|
24
|
-
const madrun = montag
|
|
23
|
+
const madrun = montag`
|
|
25
24
|
'use strict';
|
|
26
25
|
|
|
27
26
|
const {
|
|
@@ -82,4 +81,3 @@ async function findMadrun(cwd) {
|
|
|
82
81
|
|
|
83
82
|
return '';
|
|
84
83
|
}
|
|
85
|
-
|
package/bin/madrun-completion.js
CHANGED
package/bin/madrun.mjs
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
2
|
import {createRequire} from 'module';
|
|
4
3
|
import {
|
|
5
4
|
dirname,
|
|
6
5
|
basename,
|
|
7
6
|
} from 'path';
|
|
8
|
-
|
|
9
7
|
import findUp from 'find-up';
|
|
10
8
|
import tryToCatch from 'try-to-catch';
|
|
11
9
|
import yargsParser from 'yargs-parser';
|
|
12
|
-
|
|
13
10
|
import {series} from '../lib/madrun.js';
|
|
14
11
|
import check from '../lib/check.js';
|
|
15
12
|
import {choose} from '../lib/choose.mjs';
|
|
@@ -17,10 +14,12 @@ import {choose} from '../lib/choose.mjs';
|
|
|
17
14
|
const require = createRequire(import.meta.url);
|
|
18
15
|
|
|
19
16
|
const {exit} = process;
|
|
17
|
+
|
|
20
18
|
const {
|
|
21
19
|
MADRUN_PWD,
|
|
22
20
|
MADRUN_NAME,
|
|
23
21
|
} = process.env;
|
|
22
|
+
|
|
24
23
|
const cwd = process.cwd();
|
|
25
24
|
|
|
26
25
|
const args = yargsParser(process.argv.slice(2), {
|
|
@@ -86,7 +85,9 @@ const [dir, scripts] = await getScript();
|
|
|
86
85
|
const problems = check(scripts);
|
|
87
86
|
|
|
88
87
|
if (problems) {
|
|
89
|
-
const result = await putoutMadrun(dir, {
|
|
88
|
+
const result = await putoutMadrun(dir, {
|
|
89
|
+
fix,
|
|
90
|
+
});
|
|
90
91
|
|
|
91
92
|
if (fix) {
|
|
92
93
|
exit();
|
|
@@ -119,7 +120,10 @@ if (e) {
|
|
|
119
120
|
exit(1);
|
|
120
121
|
}
|
|
121
122
|
|
|
122
|
-
console.log(getOutput({
|
|
123
|
+
console.log(getOutput({
|
|
124
|
+
cmd,
|
|
125
|
+
cwd,
|
|
126
|
+
}));
|
|
123
127
|
await execute(cmd);
|
|
124
128
|
|
|
125
129
|
function getOutput({cmd, cwd}) {
|
|
@@ -176,17 +180,20 @@ async function getScript() {
|
|
|
176
180
|
async function putoutMadrun(dir, {fix}) {
|
|
177
181
|
const name = `${dir}/.madrun.js`;
|
|
178
182
|
const {runPutout} = await import('../lib/fix.mjs');
|
|
183
|
+
|
|
179
184
|
const {
|
|
180
185
|
readFile,
|
|
181
186
|
writeFile,
|
|
182
187
|
} = await import('fs/promises');
|
|
183
188
|
|
|
184
189
|
const data = await readFile(name, 'utf8');
|
|
185
|
-
const {
|
|
190
|
+
const {
|
|
191
|
+
places,
|
|
192
|
+
code,
|
|
193
|
+
} = await runPutout(data);
|
|
186
194
|
|
|
187
195
|
if (fix)
|
|
188
196
|
await writeFile(name, code);
|
|
189
197
|
|
|
190
198
|
return places;
|
|
191
199
|
}
|
|
192
|
-
|
package/lib/check.js
CHANGED
package/lib/choose.mjs
CHANGED
package/lib/fix.mjs
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import putout, {
|
|
2
2
|
initReport,
|
|
3
3
|
} from 'putout';
|
|
4
|
-
|
|
5
4
|
import dumpFormatter from '@putout/formatter-dump';
|
|
6
|
-
import madrun from '@putout/plugin-madrun';
|
|
7
5
|
|
|
8
6
|
const report = initReport();
|
|
9
7
|
|
|
10
8
|
export const runPutout = async (data, options) => {
|
|
11
|
-
const {
|
|
9
|
+
const {
|
|
10
|
+
code,
|
|
11
|
+
places,
|
|
12
|
+
} = putout(data, {
|
|
13
|
+
printer: 'putout',
|
|
12
14
|
...options,
|
|
13
|
-
plugins: [
|
|
14
|
-
madrun,
|
|
15
|
-
|
|
15
|
+
plugins: [
|
|
16
|
+
'madrun',
|
|
17
|
+
],
|
|
16
18
|
});
|
|
17
19
|
|
|
18
20
|
return {
|
package/lib/help.js
CHANGED
package/lib/madrun.js
CHANGED
|
@@ -8,7 +8,7 @@ const findUp = require('find-up');
|
|
|
8
8
|
const wildcard = require('./wildcard');
|
|
9
9
|
const check = require('./check');
|
|
10
10
|
const supported = require('../supported');
|
|
11
|
-
|
|
11
|
+
const maybeArray = (a) => isArray(a) ? a : [a];
|
|
12
12
|
const isStr = (a) => typeof a === 'string';
|
|
13
13
|
const {isArray} = Array;
|
|
14
14
|
|
|
@@ -22,12 +22,11 @@ async function getScripts() {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
module.exports.cutEnv = async (names, opts = '', env, scripts) => {
|
|
25
|
-
|
|
26
|
-
names = [names];
|
|
27
|
-
|
|
25
|
+
names = maybeArray(names);
|
|
28
26
|
scripts = scripts || await getScripts();
|
|
29
27
|
|
|
30
28
|
const isParallel = false;
|
|
29
|
+
|
|
31
30
|
const commands = await run(names, opts, scripts, {
|
|
32
31
|
env,
|
|
33
32
|
cutEnv: true,
|
|
@@ -53,12 +52,11 @@ module.exports.run = async (name, opts = '', env, scripts) => {
|
|
|
53
52
|
module.exports.series = series;
|
|
54
53
|
|
|
55
54
|
async function series(names, opts = '', env, scripts) {
|
|
56
|
-
|
|
57
|
-
names = [names];
|
|
58
|
-
|
|
55
|
+
names = maybeArray(names);
|
|
59
56
|
scripts = scripts || await getScripts();
|
|
60
57
|
|
|
61
58
|
const isParallel = false;
|
|
59
|
+
|
|
62
60
|
const commands = await run(names, opts, scripts, {
|
|
63
61
|
env,
|
|
64
62
|
isParallel,
|
|
@@ -71,12 +69,14 @@ async function series(names, opts = '', env, scripts) {
|
|
|
71
69
|
|
|
72
70
|
module.exports.parallel = async (names, opts = '', env, scripts) => {
|
|
73
71
|
scripts = scripts || await getScripts();
|
|
74
|
-
|
|
75
|
-
if (isStr(names))
|
|
76
|
-
names = [names];
|
|
72
|
+
names = maybeArray(names);
|
|
77
73
|
|
|
78
74
|
const isParallel = true;
|
|
79
|
-
|
|
75
|
+
|
|
76
|
+
const commands = await run(names, opts, scripts, {
|
|
77
|
+
env,
|
|
78
|
+
isParallel,
|
|
79
|
+
});
|
|
80
80
|
|
|
81
81
|
return joinByType(commands, {
|
|
82
82
|
isParallel,
|
|
@@ -140,8 +140,13 @@ const parse = async (name, {scripts, opts, env, isParallel, cutEnv}) => {
|
|
|
140
140
|
|
|
141
141
|
const fn = jessy(key, scripts);
|
|
142
142
|
|
|
143
|
-
const {
|
|
143
|
+
const {
|
|
144
|
+
line,
|
|
145
|
+
lineEnv,
|
|
146
|
+
} = await runScriptFn(fn);
|
|
147
|
+
|
|
144
148
|
const cmd = addOpts(line, opts);
|
|
149
|
+
|
|
145
150
|
const cmdEnv = addEnv(cmd, {
|
|
146
151
|
...cutEnv ? {} : lineEnv,
|
|
147
152
|
...env,
|
|
@@ -195,4 +200,3 @@ async function addPrePost(cmd, key, scripts) {
|
|
|
195
200
|
|
|
196
201
|
return cmd;
|
|
197
202
|
}
|
|
198
|
-
|
package/lib/validate.js
CHANGED
package/lib/wildcard.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
module.exports = (str) => {
|
|
4
|
-
const wildcard = '^' + str
|
|
4
|
+
const wildcard = '^' + str
|
|
5
5
|
.replace('.', '\\.')
|
|
6
6
|
.replace('*', '.*')
|
|
7
|
-
.replace('?', '.?') + '$';
|
|
7
|
+
.replace('?', '.?') + '$';
|
|
8
8
|
|
|
9
9
|
return RegExp(wildcard);
|
|
10
10
|
};
|
|
11
|
-
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "madrun",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.2.0",
|
|
4
4
|
"description": "CLI tool to run multiple npm-scripts in a madly comfortable way",
|
|
5
5
|
"main": "lib/madrun.js",
|
|
6
6
|
"type": "commonjs",
|
|
7
|
-
"commitType": "colon",
|
|
8
7
|
"scripts": {
|
|
9
8
|
"lint": "madrun lint",
|
|
10
9
|
"fresh:lint": "madrun fresh:lint",
|
|
@@ -56,7 +55,6 @@
|
|
|
56
55
|
},
|
|
57
56
|
"dependencies": {
|
|
58
57
|
"@putout/formatter-dump": "^4.0.0",
|
|
59
|
-
"@putout/plugin-madrun": "^14.0.0",
|
|
60
58
|
"all-object-keys": "^2.0.0",
|
|
61
59
|
"enquirer": "^2.3.6",
|
|
62
60
|
"find-up": "^5.0.0",
|
|
@@ -75,7 +73,7 @@
|
|
|
75
73
|
"escover": "^2.0.1",
|
|
76
74
|
"eslint": "^8.0.0",
|
|
77
75
|
"eslint-plugin-n": "^15.2.4",
|
|
78
|
-
"eslint-plugin-putout": "^
|
|
76
|
+
"eslint-plugin-putout": "^17.5.1",
|
|
79
77
|
"mock-import": "^3.0.0",
|
|
80
78
|
"mock-require": "^3.0.3",
|
|
81
79
|
"nodemon": "^2.0.0",
|