binary-collections 2.0.2 → 2.0.5

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/bin/kill-process CHANGED
@@ -28,4 +28,7 @@ if [ -f ".env" ]; then
28
28
  export $(egrep -v '^#' .env | xargs)
29
29
  fi
30
30
 
31
- ps -W | grep "$1" | awk '{print $1}' | xargs kill -f;
31
+ # ps -W | grep "$1" | awk '{print $1}' | xargs kill -f;
32
+
33
+ set -e;
34
+ ps -aux | grep "$1" | awk '{print $1}' | xargs killall -9;
@@ -0,0 +1,39 @@
1
+ #!/bin/bash -e
2
+
3
+ # token remover from url repo
4
+
5
+ export SCRIPT=$(realpath "$0")
6
+ export ROOT="$(git rev-parse --show-toplevel)"
7
+
8
+ git -C "${REPO_PATH}" config -f .gitmodules --get-regexp '^submodule\..*\.path$' |
9
+ while read -r KEY MODULE_PATH
10
+ do
11
+ # relative module path from root
12
+ RELATIVE_MODULE_PATH="${ROOT}/${MODULE_PATH}"
13
+ # cd git root dir
14
+ cd ${ROOT}
15
+
16
+ NAME="$(echo "${KEY}" | sed 's/^submodule\.\(.*\)\.path$/\1/')"
17
+
18
+ url_key="$(echo "${KEY}" | sed 's/\.path$/.url/')"
19
+ branch_key="$(echo "${KEY}" | sed 's/\.path$/.branch/')"
20
+
21
+ URL="$(git config -f .gitmodules --get "${url_key}")"
22
+ BRANCH="$(git config -f .gitmodules --get "${branch_key}" || echo "master")"
23
+
24
+ repo=${URL#"https://github.com/"}
25
+ NEW_URL="https://github.com/${repo}"
26
+
27
+ # cd and update url
28
+ cd $RELATIVE_MODULE_PATH
29
+ git remote set-url origin "$NEW_URL"
30
+ cd $ROOT
31
+
32
+ GIT_MODULES="${RELATIVE_MODULE_PATH}/.gitmodules"
33
+ if [ -f "${GIT_MODULES}" ];
34
+ then
35
+ echo "${MODULE_PATH} has submodules"
36
+ cd "${RELATIVE_MODULE_PATH}"
37
+ sh "${SCRIPT}" -cwd ${RELATIVE_MODULE_PATH}
38
+ fi
39
+ done
@@ -0,0 +1,19 @@
1
+ const glob = require('glob');
2
+ const { delStream } = require('./utils');
3
+ // process.cwd = () => path.resolve(__dirname + '/../../../Repositories');
4
+
5
+ const globalIgnore = [
6
+ // ignore .git .github folder
7
+ '**/.git*',
8
+ // ignore composer folder
9
+ '**/vendor/**'
10
+ ];
11
+
12
+ console.log('cleaning node_modules in', process.cwd());
13
+
14
+ const g3 = new glob.Glob('**/node_modules', {
15
+ withFileTypes: false,
16
+ cwd: process.cwd(),
17
+ ignore: globalIgnore
18
+ });
19
+ delStream(g3);
@@ -0,0 +1,11 @@
1
+ const glob = require('glob');
2
+ const { delStream } = require('./utils');
3
+ // const path = require('path');
4
+ // process.cwd = () => path.resolve(__dirname + '/../../../Repositories');
5
+
6
+ const g3 = new glob.Glob(['**/.yarn/cache*', '**/.yarn/*.gz'], {
7
+ withFileTypes: false,
8
+ cwd: process.cwd(),
9
+ ignore: ['**/.git*', '**/vendor/**']
10
+ });
11
+ delStream(g3);
@@ -0,0 +1,13 @@
1
+ const glob = require('glob');
2
+ const path = require('path');
3
+ // process.cwd = () => path.resolve(__dirname + '/../../../Repositories');
4
+
5
+ const g3 = new glob.Glob('**/node_modules', {
6
+ withFileTypes: false,
7
+ cwd: process.cwd(),
8
+ ignore: ['**/.git*', '**/vendor/**']
9
+ });
10
+ g3.stream().on('data', (result) => {
11
+ const fullPath = path.resolve(process.cwd(), result);
12
+ console.log(fullPath);
13
+ });
package/lib/utils.js ADDED
@@ -0,0 +1,36 @@
1
+ const { fs, path } = require('sbg-utility');
2
+
3
+ /**
4
+ * glob stream handler
5
+ * @param {glob.Glob} globStream
6
+ */
7
+ function delStream(globStream) {
8
+ globStream.stream().on('data', (result) => {
9
+ const fullPath = path.resolve(process.cwd(), result);
10
+ console.log('deleting', fullPath);
11
+ if (fs.statSync(fullPath).isDirectory()) {
12
+ // delete all files each package directory
13
+ const subdir = fs.readdirSync(fullPath).map((dirPath) => path.resolve(fullPath, dirPath));
14
+ for (let i = 0; i < subdir.length; i++) {
15
+ const dir = subdir[i];
16
+ del(dir);
17
+ }
18
+ }
19
+ del(fullPath);
20
+ });
21
+ }
22
+
23
+ /**
24
+ * delete file recursive
25
+ * @param {string} fullPath
26
+ */
27
+ function del(fullPath) {
28
+ try {
29
+ fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7000 });
30
+ console.log('deleted', fullPath);
31
+ } catch (_) {
32
+ console.log('failed delete', fullPath);
33
+ }
34
+ }
35
+
36
+ module.exports = { del, delStream };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "binary-collections",
3
- "version": "2.0.2",
3
+ "version": "2.0.5",
4
4
  "description": "binary helper collections by L3n4r0x",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -18,30 +18,52 @@
18
18
  "build": "node -r ts-node/register -r dotenv/config build.js && yarn run pack",
19
19
  "test": "cd test && npm install -D file:../ &&",
20
20
  "test:nrs": "npm test -- nrs build:**",
21
- "pack": "node packer.js --yarn --filename=bin"
21
+ "pack": "node packer.js --yarn --filename=bin",
22
+ "update:ncu": "npx npm-check-updates -u -x jsdom,chalk,hexo,deepmerge-ts --enginesNode --root"
22
23
  },
23
24
  "keywords": [],
24
- "author": "",
25
- "license": "ISC",
25
+ "author": {
26
+ "email": "dimaslanjaka@gmail.com",
27
+ "name": "dimaslanjaka",
28
+ "url": "https://webmanajemen.com"
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/dimaslanjaka/bin"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/dimaslanjaka/bin/issues"
36
+ },
37
+ "homepage": "https://www.webmanajemen.com/",
38
+ "license": "MIT",
26
39
  "dependencies": {
27
- "execa": "^7.1.1",
28
- "fs-extra": "^11.1.1",
29
- "glob": "^10.2.2",
30
- "minimatch": "^9.0.0",
40
+ "execa": "^8.0.1",
41
+ "fs-extra": "^11.2.0",
42
+ "glob": "^10.3.10",
43
+ "minimatch": "^9.0.3",
31
44
  "minimist": "^1.2.8",
45
+ "sbg-utility": "^1.1.6",
32
46
  "upath": "^2.0.1",
33
- "yaml": "^2.3.1"
47
+ "yaml": "^2.3.4"
34
48
  },
35
49
  "packageManager": "yarn@3.6.1",
36
50
  "devDependencies": {
51
+ "@types/eslint": "^8",
37
52
  "@types/minimist": "^1",
38
- "@types/node": "^18.16.3",
53
+ "@types/node": "^20.11.16",
54
+ "@types/prettier": "^3",
39
55
  "@types/yargs": "^17",
56
+ "@typescript-eslint/eslint-plugin": "^6.20.0",
57
+ "@typescript-eslint/parser": "^6.20.0",
40
58
  "cross-spawn": "https://github.com/dimaslanjaka/node-cross-spawn/raw/ff4b648/release/cross-spawn.tgz",
41
- "dotenv": "^16.3.1",
42
- "git-command-helper": "^2.0.1",
43
- "ts-node": "^10.9.1",
44
- "typescript": "^5.2.2"
59
+ "dotenv": "^16.4.1",
60
+ "eslint": "^8.56.0",
61
+ "eslint-config-prettier": "^9.1.0",
62
+ "eslint-plugin-prettier": "^5.1.3",
63
+ "git-command-helper": "^2.0.2",
64
+ "prettier": "^3.2.4",
65
+ "ts-node": "^10.9.2",
66
+ "typescript": "^5.3.3"
45
67
  },
46
68
  "optionalDependencies": {
47
69
  "ansi-colors": "^4.1.3"
@@ -49,8 +71,11 @@
49
71
  "bin": {
50
72
  "clean-nodemodule": "bin/clean-nodemodule",
51
73
  "clean-nodemodules": "bin/clean-nodemodules",
74
+ "del-nodemodules": "lib/del-node-modules.js",
75
+ "del-yarncaches": "lib/del-yarn-caches.js",
52
76
  "dev": "bin/dev",
53
77
  "empty": "bin/empty",
78
+ "find-nodemodules": "lib/find-node-modules.js",
54
79
  "git-fix-encoding": "bin/git-fix-encoding",
55
80
  "git-fix-encoding-cmd": "bin/git-fix-encoding.cmd",
56
81
  "git-reduce-size": "bin/git-reduce-size",
@@ -69,6 +94,7 @@
69
94
  "run-series": "lib/npm-run-series.js",
70
95
  "submodule": "bin/submodule",
71
96
  "submodule-install": "bin/submodule-install",
72
- "submodule-remove": "bin/submodule-remove"
97
+ "submodule-remove": "bin/submodule-remove",
98
+ "submodule-token": "bin/submodule-token"
73
99
  }
74
100
  }
package/readme.md CHANGED
@@ -10,6 +10,8 @@ git clone -b master https://github.com/dimaslanjaka/bin bin
10
10
 
11
11
  via npm
12
12
  ```bash
13
+ npm install binary-collections
14
+ # or
13
15
  npm install binary-collections@git+https://github.com/dimaslanjaka/bin.git
14
16
  # or
15
17
  npm install binary-collections@https://github.com/dimaslanjaka/bin/raw/master/releases/bin.tgz
@@ -90,6 +92,22 @@ example: `npm run namescript`
90
92
  }
91
93
  ```
92
94
 
95
+ ## node_modules cleaner
96
+
97
+ ```bash
98
+ del-nodemodules
99
+ ```
100
+
101
+ ![image](https://github.com/dimaslanjaka/bin/assets/12471057/f03e5b51-1808-4e82-a474-0dd3c7eab5fe)
102
+
103
+ ## yarn caches cleaner
104
+
105
+ ```bash
106
+ del-yarncaches
107
+ ```
108
+
109
+ ![image](https://github.com/dimaslanjaka/bin/assets/12471057/2805c54e-28a7-491d-b381-de2593a854b3)
110
+
93
111
  ## troubleshooting
94
112
  ### submodule-install
95
113