codeworth 1.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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +47 -0
  3. package/index.js +83 -0
  4. package/package.json +18 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 David Weaver
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # Codeworth
2
+
3
+ CLI tool to calculate traditional software valuation based on LOC (Lines of Code).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g codeworth
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Run the tool with the total lines of code:
14
+
15
+ ```bash
16
+ codeworth 26024
17
+ ```
18
+
19
+ ### Options
20
+
21
+ - `--rate <number>`: Override the default rate per line ($10.77).
22
+
23
+ ### Examples
24
+
25
+ ```bash
26
+ # Default valuation
27
+ codeworth 5000
28
+
29
+ # Custom rate
30
+ codeworth 5000 --rate 25
31
+ ```
32
+
33
+ ## Output
34
+
35
+ ```text
36
+ -----------------------------------
37
+ CodeWorth CLI
38
+ -----------------------------------
39
+ Lines of Code: 26,024
40
+ Rate Per Line: $10.77
41
+ Estimated Valuation: $280,000
42
+ -----------------------------------
43
+ ```
44
+
45
+ ## License
46
+
47
+ MIT
package/index.js ADDED
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env node
2
+
3
+ import process from 'node:process';
4
+
5
+ // Configuration
6
+ const DEFAULT_RATE = 10.77;
7
+
8
+ // Helper to format currency
9
+ const formatCurrency = (amount) => {
10
+ return new Intl.NumberFormat('en-US', {
11
+ style: 'currency',
12
+ currency: 'USD',
13
+ maximumFractionDigits: 0
14
+ }).format(amount);
15
+ };
16
+
17
+ // Helper to format numbers
18
+ const formatNumber = (num) => {
19
+ return new Intl.NumberFormat('en-US').format(num);
20
+ };
21
+
22
+ // Main execution
23
+ const main = () => {
24
+ const args = process.argv.slice(2);
25
+
26
+ // Help / Usage
27
+ if (args.length === 0 || args.includes('--help') || args.includes('-h')) {
28
+ console.log(`
29
+ Usage: codeworth <lines-of-code> [options]
30
+
31
+ Arguments:
32
+ <lines-of-code> Total lines of code (numeric)
33
+
34
+ Options:
35
+ --rate <number> Override rate per line (default: ${DEFAULT_RATE})
36
+ --help Show this help message
37
+
38
+ Example:
39
+ codeworth 26024
40
+ codeworth 50000 --rate 15
41
+ `);
42
+ process.exit(args.length === 0 ? 1 : 0);
43
+ }
44
+
45
+ // Parse arguments
46
+ let loc = null;
47
+ let rate = DEFAULT_RATE;
48
+
49
+ for (let i = 0; i < args.length; i++) {
50
+ const arg = args[i];
51
+
52
+ if (arg === '--rate') {
53
+ const nextArg = args[i + 1];
54
+ if (!nextArg || isNaN(parseFloat(nextArg))) {
55
+ console.error('Error: --rate requires a valid number');
56
+ process.exit(1);
57
+ }
58
+ rate = parseFloat(nextArg);
59
+ i++; // Skip next arg
60
+ } else if (!isNaN(parseInt(arg.replace(/,/g, ''), 10)) && loc === null) {
61
+ loc = parseInt(arg.replace(/,/g, ''), 10);
62
+ }
63
+ }
64
+
65
+ if (loc === null) {
66
+ console.error('Error: Please provide a valid number for lines of code.');
67
+ process.exit(1);
68
+ }
69
+
70
+ // Calculate
71
+ const valuation = loc * rate;
72
+
73
+ // Output
74
+ console.log('-----------------------------------');
75
+ console.log('CodeWorth CLI');
76
+ console.log('-----------------------------------');
77
+ console.log(`Lines of Code: ${formatNumber(loc)}`);
78
+ console.log(`Rate Per Line: $${rate.toFixed(2)}`);
79
+ console.log(`Estimated Valuation: ${formatCurrency(valuation)}`);
80
+ console.log('-----------------------------------');
81
+ };
82
+
83
+ main();
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "codeworth",
3
+ "version": "1.0.0",
4
+ "description": "CLI tool to calculate traditional software valuation based on LOC.",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "codeworth": "./index.js"
8
+ },
9
+ "type": "module",
10
+ "license": "MIT",
11
+ "author": "David Weaver",
12
+ "keywords": [
13
+ "valuation",
14
+ "loc",
15
+ "software",
16
+ "cli"
17
+ ]
18
+ }