@forge/cli
12.14.0-next.212.14.0-next.8-experimental-e5e0b64
out/command-line/utils.jsout/command-line/utils.js+29−1
Index: package/out/command-line/utils.js
===================================================================
--- package/out/command-line/utils.js
+++ package/out/command-line/utils.js
@@ -1,7 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
-exports.getAcceptableSlug = exports.filterSlug = exports.slugify = void 0;
+exports.formatMemory = exports.formatCpu = exports.getAcceptableSlug = exports.filterSlug = exports.slugify = void 0;
const slugify = (value) => {
return value
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '')
@@ -27,5 +27,33 @@
const slug = (0, exports.slugify)(value);
return (0, exports.filterSlug)(slug);
};
exports.getAcceptableSlug = getAcceptableSlug;
+const formatCpu = (cpuValue) => {
+ if (cpuValue === undefined || cpuValue === null || cpuValue === '') {
+ return '-';
+ }
+ const numStr = cpuValue.replace(/n$/, '');
+ const nanocores = parseFloat(numStr);
+ if (isNaN(nanocores)) {
+ return '-';
+ }
+ const millicores = nanocores / 1000000;
+ const millicoresStr = Number(millicores.toFixed(2));
+ return `${millicoresStr}m`;
+};
+exports.formatCpu = formatCpu;
+const formatMemory = (memoryValue) => {
+ if (memoryValue === undefined || memoryValue === null || memoryValue === '') {
+ return '-';
+ }
+ const numStr = memoryValue.replace(/Ki$/, '');
+ const kibibytes = parseFloat(numStr);
+ if (isNaN(kibibytes)) {
+ return '-';
+ }
+ const mebibytes = kibibytes / 1024;
+ const mebibytesStr = Number(mebibytes.toFixed(2));
+ return `${mebibytesStr}MiB`;
+};
+exports.formatMemory = formatMemory;
//# sourceMappingURL=utils.js.map
\ No newline at end of file