cloud-cost-cli 0.1.0 → 0.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/README.md +119 -122
- package/dist/bin/cloud-cost-cli.js +5 -2
- package/dist/src/analyzers/cost-estimator.d.ts +14 -0
- package/dist/src/analyzers/cost-estimator.js +74 -16
- package/dist/src/analyzers/pricing-service.d.ts +38 -0
- package/dist/src/analyzers/pricing-service.js +263 -0
- package/dist/src/commands/scan.d.ts +3 -0
- package/dist/src/commands/scan.js +173 -86
- package/dist/src/providers/aws/client.d.ts +1 -0
- package/dist/src/providers/aws/client.js +60 -1
- package/dist/src/providers/azure/client.d.ts +20 -0
- package/dist/src/providers/azure/client.js +41 -0
- package/dist/src/providers/azure/disks.d.ts +4 -0
- package/dist/src/providers/azure/disks.js +87 -0
- package/dist/src/providers/azure/index.d.ts +6 -0
- package/dist/src/providers/azure/index.js +15 -0
- package/dist/src/providers/azure/public-ips.d.ts +3 -0
- package/dist/src/providers/azure/public-ips.js +47 -0
- package/dist/src/providers/azure/sql.d.ts +4 -0
- package/dist/src/providers/azure/sql.js +134 -0
- package/dist/src/providers/azure/storage.d.ts +8 -0
- package/dist/src/providers/azure/storage.js +100 -0
- package/dist/src/providers/azure/vms.d.ts +4 -0
- package/dist/src/providers/azure/vms.js +164 -0
- package/dist/src/reporters/table.js +3 -1
- package/dist/src/utils/formatter.d.ts +2 -0
- package/dist/src/utils/formatter.js +29 -1
- package/docs/RELEASE.md +14 -22
- package/package.json +12 -2
|
@@ -1,10 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.formatCurrency = formatCurrency;
|
|
4
|
+
exports.formatBytes = formatBytes;
|
|
5
|
+
exports.formatPercent = formatPercent;
|
|
4
6
|
exports.formatDate = formatDate;
|
|
5
7
|
exports.daysSince = daysSince;
|
|
6
8
|
function formatCurrency(amount) {
|
|
7
|
-
|
|
9
|
+
const formatted = new Intl.NumberFormat('en-US', {
|
|
10
|
+
style: 'currency',
|
|
11
|
+
currency: 'USD',
|
|
12
|
+
minimumFractionDigits: 2,
|
|
13
|
+
maximumFractionDigits: 2,
|
|
14
|
+
}).format(amount);
|
|
15
|
+
return formatted;
|
|
16
|
+
}
|
|
17
|
+
function formatBytes(bytes, decimals = 2) {
|
|
18
|
+
if (bytes === 0)
|
|
19
|
+
return '0 B';
|
|
20
|
+
const k = 1024;
|
|
21
|
+
const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
|
|
22
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
23
|
+
// Don't use decimals for bytes
|
|
24
|
+
if (i === 0) {
|
|
25
|
+
return `${bytes} B`;
|
|
26
|
+
}
|
|
27
|
+
const value = bytes / Math.pow(k, i);
|
|
28
|
+
const formatted = decimals === 0
|
|
29
|
+
? Math.round(value).toString()
|
|
30
|
+
: value.toFixed(decimals);
|
|
31
|
+
return `${formatted} ${sizes[i]}`;
|
|
32
|
+
}
|
|
33
|
+
function formatPercent(value, decimals = 1) {
|
|
34
|
+
const percent = value * 100;
|
|
35
|
+
return `${percent.toFixed(decimals)}%`;
|
|
8
36
|
}
|
|
9
37
|
function formatDate(date) {
|
|
10
38
|
return date.toISOString().split('T')[0];
|
package/docs/RELEASE.md
CHANGED
|
@@ -4,28 +4,20 @@ This document describes how to publish a new version of cloud-cost-cli.
|
|
|
4
4
|
|
|
5
5
|
## Prerequisites
|
|
6
6
|
|
|
7
|
-
###
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
### 2. Add Token to GitHub Secrets
|
|
23
|
-
|
|
24
|
-
1. Go to https://github.com/vuhp/cloud-cost-cli/settings/secrets/actions
|
|
25
|
-
2. Click **"New repository secret"**
|
|
26
|
-
3. Name: `NPM_TOKEN`
|
|
27
|
-
4. Value: (paste the `npm_...` token)
|
|
28
|
-
5. Click **"Add secret"**
|
|
7
|
+
### npm Trusted Publishing (OIDC)
|
|
8
|
+
|
|
9
|
+
This project uses **npm trusted publishing** via GitHub Actions. No npm token is required!
|
|
10
|
+
|
|
11
|
+
**Configuration:**
|
|
12
|
+
- Already configured on npm for this package
|
|
13
|
+
- GitHub Actions is set as a trusted publisher
|
|
14
|
+
- Publishing happens automatically via OIDC (OpenID Connect)
|
|
15
|
+
|
|
16
|
+
**Benefits:**
|
|
17
|
+
- ✅ No tokens to rotate or secure
|
|
18
|
+
- ✅ No 2FA required for automation
|
|
19
|
+
- ✅ More secure (GitHub's identity proves authenticity)
|
|
20
|
+
- ✅ Automatic provenance statements
|
|
29
21
|
|
|
30
22
|
## Steps to Release
|
|
31
23
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloud-cost-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Optimize your cloud spend in seconds",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
"dev": "tsx bin/cloud-cost-cli.ts",
|
|
11
11
|
"build": "tsc",
|
|
12
12
|
"test": "vitest",
|
|
13
|
+
"test:ui": "vitest --ui",
|
|
14
|
+
"test:coverage": "vitest --coverage",
|
|
13
15
|
"lint": "eslint src/**/*.ts",
|
|
14
16
|
"format": "prettier --write src/**/*.ts"
|
|
15
17
|
},
|
|
@@ -46,9 +48,16 @@
|
|
|
46
48
|
"@aws-sdk/client-cost-explorer": "^3.712.0",
|
|
47
49
|
"@aws-sdk/client-ec2": "^3.712.0",
|
|
48
50
|
"@aws-sdk/client-elastic-load-balancing-v2": "^3.712.0",
|
|
51
|
+
"@aws-sdk/client-pricing": "^3.980.0",
|
|
49
52
|
"@aws-sdk/client-rds": "^3.712.0",
|
|
50
53
|
"@aws-sdk/client-s3": "^3.712.0",
|
|
51
54
|
"@aws-sdk/credential-providers": "^3.712.0",
|
|
55
|
+
"@azure/arm-compute": "^23.3.0",
|
|
56
|
+
"@azure/arm-monitor": "^7.0.0",
|
|
57
|
+
"@azure/arm-network": "^35.0.0",
|
|
58
|
+
"@azure/arm-sql": "^10.0.0",
|
|
59
|
+
"@azure/arm-storage": "^19.1.0",
|
|
60
|
+
"@azure/identity": "^4.13.0",
|
|
52
61
|
"chalk": "^5.3.0",
|
|
53
62
|
"cli-table3": "^0.6.5",
|
|
54
63
|
"commander": "^12.1.0",
|
|
@@ -60,10 +69,11 @@
|
|
|
60
69
|
"@types/node": "^22.10.5",
|
|
61
70
|
"@typescript-eslint/eslint-plugin": "^8.19.1",
|
|
62
71
|
"@typescript-eslint/parser": "^8.19.1",
|
|
72
|
+
"@vitest/ui": "^1.6.1",
|
|
63
73
|
"eslint": "^8.57.1",
|
|
64
74
|
"prettier": "^3.4.2",
|
|
65
75
|
"tsx": "^4.19.2",
|
|
66
76
|
"typescript": "^5.7.3",
|
|
67
|
-
"vitest": "^1.6.
|
|
77
|
+
"vitest": "^1.6.1"
|
|
68
78
|
}
|
|
69
79
|
}
|