toolz 0.0.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/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # toolz
2
+
3
+ [![npm version](https://img.shields.io/npm/v/toolz.svg)](https://www.npmjs.com/package/toolz)
4
+ [![npm downloads](https://img.shields.io/npm/dm/toolz.svg)](https://www.npmjs.com/package/toolz)
5
+
6
+ Various bash utilities for starting servers.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install -g toolz
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ### `toolz tee <file>`
17
+
18
+ Tee the input to stdout and a file, without ansi escape codes.
19
+
20
+ **Example:**
21
+
22
+ ```bash
23
+ some-command | toolz tee output.log
24
+ ```
25
+
26
+ ### `toolz port <ports>`
27
+
28
+ Get an available port.
29
+
30
+ `<ports>` can be a single port, a range of ports, or a comma-separated list of ports.
31
+
32
+ **Examples:**
33
+
34
+ ```bash
35
+ toolz port 8080
36
+ toolz port 8080-8090
37
+ toolz port 8080,8081,8082
38
+ ```
39
+
40
+ ### `toolz concur <commands...>`
41
+
42
+ Run commands concurrently. This is a wrapper around the `concurrently` package.
43
+
44
+ **Example:**
45
+
46
+ ```bash
47
+ toolz concur "npm run server" "npm run client"
48
+ ```
49
+
50
+ This is equivalent to:
51
+
52
+ ```bash
53
+ concurrently "npm run server" "npm run client"
54
+ ```
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const commander_1 = require("commander");
5
+ commander_1.program
6
+ .name('toolz')
7
+ .description('Bash utilities for starting servers')
8
+ .version('0.0.0');
9
+ commander_1.program
10
+ .command('tee')
11
+ .description(`Tee the input to stdout and a file, without ansi escape codes`)
12
+ .argument('<file>', 'File to write the stripped output to')
13
+ .action(async (file) => void (await Promise.resolve().then(() => require('./tee'))).tee(file));
14
+ commander_1.program
15
+ .command('port')
16
+ .description('Get an available port')
17
+ .argument('<ports>', 'Port or range of ports to check (e.g., 8080, 8080-8090, 8080,8081,8082)')
18
+ .action(async (ports) => {
19
+ let check = [];
20
+ if (ports.includes('-')) {
21
+ const start = parseInt(ports.split('-')[0], 10);
22
+ const end = parseInt(ports.split('-')[1], 10);
23
+ if (start > end)
24
+ throw new Error('Invalid port range');
25
+ if (end - start > 1000)
26
+ throw new Error('Port range too large');
27
+ check = Array.from({ length: end - start + 1 }, (_, i) => i + start);
28
+ }
29
+ else if (ports.includes(','))
30
+ check = ports.split(',').map((p) => parseInt(p, 10));
31
+ else
32
+ check = [parseInt(ports, 10)];
33
+ const port = await (await Promise.resolve().then(() => require('./port'))).port({ check });
34
+ process.stdout.write(`${port}\n`);
35
+ });
36
+ commander_1.program
37
+ .command('concur')
38
+ .description('Run commands concurrently (same as "concurrently" package)')
39
+ .argument('<commands...>', 'commands to run')
40
+ .allowUnknownOption()
41
+ .action(async (commands = []) => {
42
+ const { concur } = await Promise.resolve().then(() => require('./concur'));
43
+ try {
44
+ await concur(commands);
45
+ }
46
+ catch (e) {
47
+ process.exit(1);
48
+ }
49
+ });
50
+ commander_1.program.parse(process.argv);
51
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AAEpC,mBAAO;KACJ,IAAI,CAAC,OAAO,CAAC;KACb,WAAW,CAAC,qCAAqC,CAAC;KAClD,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,mBAAO;KACJ,OAAO,CAAC,KAAK,CAAC;KACd,WAAW,CAAC,+DAA+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,CAAC,CAAC,CAAC;;QAClD,KAAK,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;IACnC,MAAM,IAAI,GAAG,MAAM,CAAC,2CAAa,QAAQ,EAAC,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5D,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;AACpC,CAAC,CAAC,CAAC;AAEL,mBAAO;KACJ,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,4DAA4D,CAAC;KACzE,QAAQ,CAAC,eAAe,EAAE,iBAAiB,CAAC;KAC5C,kBAAkB,EAAE;KACpB,MAAM,CAAC,KAAK,EAAE,WAAqB,EAAE,EAAE,EAAE;IACxC,MAAM,EAAE,MAAM,EAAE,GAAG,2CAAa,UAAU,EAAC,CAAC;IAC5C,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,mBAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const concur: (cmds: string[]) => Promise<void>;
2
+ //# sourceMappingURL=concur.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"concur.d.ts","sourceRoot":"","sources":["../src/concur.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,GAAU,MAAM,MAAM,EAAE,kBAU1C,CAAC"}
package/dist/concur.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.concur = void 0;
4
+ const child_process_1 = require("child_process");
5
+ const concur = async (cmds) => {
6
+ return new Promise((resolve, reject) => {
7
+ const child = (0, child_process_1.spawn)('npx', ['concurrently', ...cmds], { stdio: 'inherit' });
8
+ child.on('close', (code) => {
9
+ if (code === 0)
10
+ resolve();
11
+ else
12
+ reject(new Error(`concurrently exited with code ${code}`));
13
+ });
14
+ child.on('error', reject);
15
+ });
16
+ };
17
+ exports.concur = concur;
18
+ //# sourceMappingURL=concur.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"concur.js","sourceRoot":"","sources":["../src/concur.ts"],"names":[],"mappings":";;;AAAA,iDAAsC;AAE/B,MAAM,MAAM,GAAG,KAAK,EAAE,IAAc,EAAE,EAAE;IAC7C,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,KAAK,GAAG,IAAA,qBAAK,EAAC,KAAK,EAAE,CAAC,cAAc,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAE5E,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YACzB,IAAI,IAAI,KAAK,CAAC;gBAAE,OAAO,EAAE,CAAC;;gBACrB,MAAM,CAAC,IAAI,KAAK,CAAC,iCAAiC,IAAI,EAAE,CAAC,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAVW,QAAA,MAAM,UAUjB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/port.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export declare const port: (o: {
2
+ check: number[];
3
+ } | {
4
+ from: number;
5
+ to: number;
6
+ }) => Promise<number>;
7
+ //# sourceMappingURL=port.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"port.d.ts","sourceRoot":"","sources":["../src/port.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,GACf,GAAG;IAAE,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,oBAItD,CAAC"}
package/dist/port.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.port = void 0;
4
+ const get_port_1 = require("get-port");
5
+ const port = async (o) => {
6
+ const port = 'check' in o ? o.check : (0, get_port_1.portNumbers)(o.from, o.to);
7
+ return await (0, get_port_1.default)({ port });
8
+ };
9
+ exports.port = port;
10
+ //# sourceMappingURL=port.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"port.js","sourceRoot":"","sources":["../src/port.ts"],"names":[],"mappings":";;;AAAA,uCAAgD;AAEzC,MAAM,IAAI,GAAG,KAAK,EACvB,CAAqD,EACrD,EAAE;IACF,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAA,sBAAW,EAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IAChE,OAAO,MAAM,IAAA,kBAAO,EAAC,EAAE,IAAI,EAAE,CAAC,CAAC;AACjC,CAAC,CAAC;AALW,QAAA,IAAI,QAKf"}
package/dist/tee.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare const tee: (file: string) => void;
2
+ //# sourceMappingURL=tee.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tee.d.ts","sourceRoot":"","sources":["../src/tee.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,GAAG,GAAI,MAAM,MAAM,SAQ/B,CAAC"}
package/dist/tee.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tee = void 0;
4
+ const fs_1 = require("fs");
5
+ const util_1 = require("util");
6
+ const tee = (file) => {
7
+ const writeStream = (0, fs_1.createWriteStream)(file);
8
+ process.stdin.on('data', (data) => {
9
+ const str = data.toString('utf8');
10
+ process.stdout.write(str);
11
+ writeStream.write((0, util_1.stripVTControlCharacters)(str));
12
+ });
13
+ process.stdin.on('end', () => writeStream.end());
14
+ };
15
+ exports.tee = tee;
16
+ //# sourceMappingURL=tee.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tee.js","sourceRoot":"","sources":["../src/tee.ts"],"names":[],"mappings":";;;AAAA,2BAAuC;AACvC,+BAAgD;AAEzC,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,EAAE;IAClC,MAAM,WAAW,GAAG,IAAA,sBAAiB,EAAC,IAAI,CAAC,CAAC;IAC5C,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;QAChC,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC1B,WAAW,CAAC,KAAK,CAAC,IAAA,+BAAwB,EAAC,GAAG,CAAC,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC;AACnD,CAAC,CAAC;AARW,QAAA,GAAG,OAQd"}
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "toolz",
3
+ "version": "0.0.0",
4
+ "description": "Various bash utilities for starting servers",
5
+ "scripts": {
6
+ "prepublishOnly": "npm run build && npm test",
7
+ "build": "rm -rf dist && tsc -b",
8
+ "postbuild": "chmod +x dist/cli.js",
9
+ "test": "node --import tsx --test",
10
+ "test:watch": "npm test -- --watch"
11
+ },
12
+ "files": [
13
+ "dist/"
14
+ ],
15
+ "main": "dist/index.js",
16
+ "bin": "dist/cli.js",
17
+ "exports": {
18
+ ".": {
19
+ "import": "./dist/index.js",
20
+ "require": "./dist/index.js",
21
+ "types": "./dist/index.d.ts"
22
+ },
23
+ "./*": {
24
+ "import": "./dist/*.js",
25
+ "require": "./dist/*.js",
26
+ "types": "./dist/*.d.ts"
27
+ }
28
+ },
29
+ "keywords": [],
30
+ "author": "Moshe Kolodny",
31
+ "license": "MIT",
32
+ "type": "commonjs",
33
+ "devDependencies": {
34
+ "@types/node": "^25.0.9",
35
+ "tsx": "^4.21.0",
36
+ "typescript": "^5.9.3"
37
+ },
38
+ "dependencies": {
39
+ "commander": "^14.0.2",
40
+ "concurrently": "^9.2.1",
41
+ "get-port": "^7.1.0",
42
+ "wait-on": "^9.0.3"
43
+ },
44
+ "directories": {
45
+ "test": "test"
46
+ },
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "git+https://github.com/kolodny/toolz.git"
50
+ },
51
+ "types": "./dist/index.d.ts",
52
+ "bugs": {
53
+ "url": "https://github.com/kolodny/toolz/issues"
54
+ },
55
+ "homepage": "https://github.com/kolodny/toolz#readme"
56
+ }