binary-collections 1.0.1 → 1.0.3
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/lib/npm-run-series.js +36 -35
- package/package.json +18 -18
- package/readme.md +61 -1
- package/releases/bin +0 -0
package/lib/npm-run-series.js
CHANGED
|
@@ -1,43 +1,44 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const fs = require(
|
|
4
|
-
const path = require(
|
|
5
|
-
const { Minimatch } = require(
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { Minimatch } = require('minimatch');
|
|
6
6
|
|
|
7
|
-
const args = require(
|
|
7
|
+
const args = require('minimist')(process.argv.slice(2));
|
|
8
8
|
const cwd = process.cwd();
|
|
9
|
-
const packagejson = path.join(cwd,
|
|
10
|
-
const verbose = args[
|
|
9
|
+
const packagejson = path.join(cwd, 'package.json');
|
|
10
|
+
const verbose = args['v'] || args['verbose'];
|
|
11
|
+
const usingYarn = args['yarn'];
|
|
11
12
|
|
|
12
13
|
(async function npmRunSeries() {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
const { execa } = await import('execa');
|
|
15
|
+
if (fs.existsSync(packagejson)) {
|
|
16
|
+
/**
|
|
17
|
+
* @type {import('../package.json')}
|
|
18
|
+
*/
|
|
19
|
+
const parse = JSON.parse(fs.readFileSync(packagejson, 'utf-8'));
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
21
|
+
if (parse !== null && typeof parse === 'object') {
|
|
22
|
+
if ('scripts' in parse) {
|
|
23
|
+
const patterns = args._;
|
|
24
|
+
const scripts = parse.scripts;
|
|
25
|
+
const scriptNames = Object.keys(scripts);
|
|
26
|
+
for (let i = 0; i < patterns.length; i++) {
|
|
27
|
+
const pattern = patterns[i];
|
|
28
|
+
const matcher = new Minimatch(pattern, { nonegate: true });
|
|
29
|
+
for (let ii = 0; ii < scriptNames.length; ii++) {
|
|
30
|
+
const scriptName = scriptNames[ii];
|
|
31
|
+
const match = matcher.match(scriptName);
|
|
32
|
+
if (verbose) console.log({ pattern, scriptName, match });
|
|
33
|
+
if (match === true) {
|
|
34
|
+
await execa(usingYarn ? 'yarn' : 'npm', ['run', scriptName], {
|
|
35
|
+
cwd,
|
|
36
|
+
stdio: 'inherit'
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
43
44
|
})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "binary-collections",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "binary helper collections by L3n4r0x",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"minimist": "^1.2.8",
|
|
32
32
|
"upath": "^2.0.1"
|
|
33
33
|
},
|
|
34
|
-
"packageManager": "yarn@3.5.
|
|
34
|
+
"packageManager": "yarn@3.5.1",
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/minimist": "^1",
|
|
37
37
|
"@types/node": "^18.16.3",
|
|
@@ -41,25 +41,25 @@
|
|
|
41
41
|
"ansi-colors": "^4.1.3"
|
|
42
42
|
},
|
|
43
43
|
"bin": {
|
|
44
|
+
"clean-nodemodule": "bin/clean-nodemodule",
|
|
45
|
+
"clean-nodemodules": "bin/clean-nodemodules",
|
|
46
|
+
"dev": "bin/dev",
|
|
47
|
+
"empty": "bin/empty",
|
|
48
|
+
"git-fix-encoding": "bin/git-fix-encoding",
|
|
49
|
+
"git-fix-encoding.cmd": "bin/git-fix-encoding.cmd",
|
|
50
|
+
"git-reduce-size": "bin/git-reduce-size",
|
|
51
|
+
"kill-process": "bin/kill-process",
|
|
52
|
+
"nodekill": "bin/nodekill",
|
|
53
|
+
"nodekill.cmd": "bin/nodekill.cmd",
|
|
54
|
+
"nodekill.ps1": "bin/nodekill.ps1",
|
|
55
|
+
"npm-run-series": "lib/npm-run-series.js",
|
|
44
56
|
"nrs": "lib/npm-run-series.js",
|
|
57
|
+
"prod": "bin/prod",
|
|
58
|
+
"rmfind": "bin/rmfind",
|
|
59
|
+
"rmpath": "bin/rmpath",
|
|
45
60
|
"run-s": "lib/npm-run-series.js",
|
|
46
61
|
"run-series": "lib/npm-run-series.js",
|
|
47
|
-
"npm-run-series": "lib/npm-run-series.js",
|
|
48
|
-
"submodule-remove": "bin/submodule-remove",
|
|
49
62
|
"submodule-install": "bin/submodule-install",
|
|
50
|
-
"
|
|
51
|
-
"rmfind": "bin/rmfind",
|
|
52
|
-
"prod": "bin/prod",
|
|
53
|
-
"nodekill.ps1": "bin/nodekill.ps1",
|
|
54
|
-
"nodekill.cmd": "bin/nodekill.cmd",
|
|
55
|
-
"nodekill": "bin/nodekill",
|
|
56
|
-
"kill-process": "bin/kill-process",
|
|
57
|
-
"git-reduce-size": "bin/git-reduce-size",
|
|
58
|
-
"git-fix-encoding.cmd": "bin/git-fix-encoding.cmd",
|
|
59
|
-
"git-fix-encoding": "bin/git-fix-encoding",
|
|
60
|
-
"empty": "bin/empty",
|
|
61
|
-
"dev": "bin/dev",
|
|
62
|
-
"clean-nodemodules": "bin/clean-nodemodules",
|
|
63
|
-
"clean-nodemodule": "bin/clean-nodemodule"
|
|
63
|
+
"submodule-remove": "bin/submodule-remove"
|
|
64
64
|
}
|
|
65
65
|
}
|
package/readme.md
CHANGED
|
@@ -10,7 +10,7 @@ git clone -b master https://github.com/dimaslanjaka/bin bin
|
|
|
10
10
|
|
|
11
11
|
via npm
|
|
12
12
|
```bash
|
|
13
|
-
npm install binary-collections@https://github.com/dimaslanjaka/bin
|
|
13
|
+
npm install binary-collections@git+https://github.com/dimaslanjaka/bin.git
|
|
14
14
|
# or
|
|
15
15
|
npm install binary-collections@https://github.com/dimaslanjaka/bin/raw/master/releases/bin.tgz
|
|
16
16
|
```
|
|
@@ -55,3 +55,63 @@ create `.vscode/settings.json`
|
|
|
55
55
|
"terminal.integrated.defaultProfile.windows": "Command Prompt",
|
|
56
56
|
}
|
|
57
57
|
```
|
|
58
|
+
|
|
59
|
+
## Usages
|
|
60
|
+
|
|
61
|
+
see all binary at
|
|
62
|
+
- https://github.com/dimaslanjaka/bin/tree/master/bin
|
|
63
|
+
- https://github.com/dimaslanjaka/bin/tree/master/lib
|
|
64
|
+
- https://github.com/dimaslanjaka/bin/blob/master/package.json
|
|
65
|
+
|
|
66
|
+
### npm scripts runner
|
|
67
|
+
|
|
68
|
+
> binaries: `nrs`, `run-s`, `run-series`
|
|
69
|
+
|
|
70
|
+
| arg | description |
|
|
71
|
+
| :--- | :--- |
|
|
72
|
+
| `--yarn` | using `yarn run <script-name>` |
|
|
73
|
+
| `--verbose` `-v` | using `yarn run <script-name>` |
|
|
74
|
+
|
|
75
|
+
example: `npm run namescript`
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"name": "package-name",
|
|
80
|
+
"version": "0.0.0",
|
|
81
|
+
"private": true,
|
|
82
|
+
"scripts": {
|
|
83
|
+
"namescript:xx": "echo xx",
|
|
84
|
+
"namescript:xxx": "echo xxx",
|
|
85
|
+
"namescript:xxxx": "echo xxxx",
|
|
86
|
+
"namescript:xxxxx": "echo xxxxx",
|
|
87
|
+
"namescript": "nrs --yarn=true --verbose=true 'namescript:**'"
|
|
88
|
+
},
|
|
89
|
+
"license": "ISC"
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## troubleshooting
|
|
94
|
+
### submodule-install
|
|
95
|
+
|
|
96
|
+
when you're facing error like
|
|
97
|
+
```log
|
|
98
|
+
fatal: 'origin/<branch>' is not a commit and a branch '<branch>' cannot be created from it
|
|
99
|
+
fatal: unable to checkout submodule '<folder>/<submodule>'
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
solution: deleting `.git/modules` before execute `submodule-install`.
|
|
103
|
+
|
|
104
|
+
example single execution:
|
|
105
|
+
```bash
|
|
106
|
+
echo "init submodules"
|
|
107
|
+
git submodule init
|
|
108
|
+
git submodule foreach "git submodule init"
|
|
109
|
+
echo "sync submodules"
|
|
110
|
+
git submodule sync
|
|
111
|
+
git submodule foreach "git submodule sync"
|
|
112
|
+
echo "update submodules"
|
|
113
|
+
mkdir -p bin >/dev/null 2>&1
|
|
114
|
+
curl -L https://github.com/dimaslanjaka/bin/raw/master/bin/submodule-install > bin/submodule-install
|
|
115
|
+
rm -rf .git/modules
|
|
116
|
+
bash ./bin/submodule-install
|
|
117
|
+
```
|
package/releases/bin
DELETED
|
Binary file
|