From 3cb702cb7274ee9dd69dbd9631e77a56a7e14d20 Mon Sep 17 00:00:00 2001 From: soridalac Date: Thu, 24 Oct 2024 11:07:42 -0700 Subject: [PATCH 1/7] feat: update new table --- package.json | 2 +- src/commands/org/delete/shape.ts | 16 +- src/commands/org/list/shape.ts | 36 ++--- src/shared/snapshot.ts | 49 ++---- tsconfig.json | 2 + yarn.lock | 263 ++++++++++++++++++++++++++++++- 6 files changed, 302 insertions(+), 66 deletions(-) diff --git a/package.json b/package.json index 2e881854..b1de55f4 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "@oclif/core": "^4", "@salesforce/core": "^8.6.1", "@salesforce/kit": "^3.2.3", - "@salesforce/sf-plugins-core": "^11.3.12", + "@salesforce/sf-plugins-core": "^12.0.7", "change-case": "^5.4.4" }, "devDependencies": { diff --git a/src/commands/org/delete/shape.ts b/src/commands/org/delete/shape.ts index f5e4bc4a..a068a9a1 100644 --- a/src/commands/org/delete/shape.ts +++ b/src/commands/org/delete/shape.ts @@ -21,7 +21,7 @@ const messages = Messages.loadMessages('@salesforce/plugin-signups', 'shape.dele export type OrgShapeDeleteResult = { orgId: string; -} & DeleteAllResult +} & DeleteAllResult; export class OrgShapeDeleteCommand extends SfCommand { public static readonly summary = messages.getMessage('summary'); @@ -72,12 +72,14 @@ export class OrgShapeDeleteCommand extends SfCommand data.alias ?? '', - }, - username: { header: 'USERNAME' }, - orgId: { header: 'ORG ID' }, - status: { header: 'SHAPE STATUS' }, - createdBy: { header: 'CREATED BY' }, - createdDate: { header: 'CREATED DATE' }, -}; - export class OrgShapeListCommand extends SfCommand { public static readonly summary = messages.getMessage('summary'); public static readonly description = messages.getMessage('description'); @@ -51,13 +38,22 @@ export class OrgShapeListCommand extends SfCommand { return orgShapes; } - this.styledHeader('Org Shapes'); - this.table( - orgShapes.map((shape) => - shape.status === 'Active' ? { ...shape, status: StandardColors.success(shape.status) } : shape - ), - orgShapeColumns - ); + this.table({ + data: orgShapes.map((shape) => ({ + ALIAS: shape.alias ?? '', + USERNAME: shape.username, + 'ORG ID': shape.orgId, + 'Shape ID': shape.shapeId, + 'CREATED BY': shape.createdBy, + 'CREATED DATE': shape.createdDate, + ...(shape.status === 'Active' + ? { + STATUS: StandardColors.success(shape.status), + } + : {}), + })), + title: 'Org Shapes', + }); return orgShapes; } } diff --git a/src/shared/snapshot.ts b/src/shared/snapshot.ts index 96af83d5..bd9220f4 100644 --- a/src/shared/snapshot.ts +++ b/src/shared/snapshot.ts @@ -50,27 +50,6 @@ const dateTimeFormatter = (dateString?: string): string => }) : ''; -const rowDateTimeFormatter = (row: OrgSnapshot, field: keyof OrgSnapshot): string => dateTimeFormatter(row[field]); - -const ORG_SNAPSHOT_COLUMNS = { - Id: {}, - SnapshotName: { header: 'Snapshot Name' }, - Status: {}, - SourceOrg: { header: 'Source Org Id' }, - CreatedDate: { - header: 'Created Date', - get: (row: OrgSnapshot): string => rowDateTimeFormatter(row, 'CreatedDate'), - }, - LastModifiedDate: { - header: 'Last Modified Date', - get: (row: OrgSnapshot): string => rowDateTimeFormatter(row, 'LastModifiedDate'), - }, - ExpirationDate: { - header: 'Expiration Date', - get: (row: OrgSnapshot): string => (row.ExpirationDate ? new Date(row.ExpirationDate).toLocaleDateString() : ''), - }, -}; - export const invalidTypeErrorHandler = (e: unknown): never => { if (e instanceof Error && e.name === 'INVALID_TYPE') { e.message = messages.getMessage('snapshotNotEnabled'); @@ -104,8 +83,8 @@ export const queryByNameOrId = async (conn: Connection, nameOrId: string): Promi }; export const printSingleRecordTable = (snapshotRecord: OrgSnapshot): void => { - new Ux().table( - Object.entries(snapshotRecord) + new Ux().table({ + data: Object.entries(snapshotRecord) .filter(([key]) => key !== 'attributes') // remove empty error field .filter(([key, value]) => key !== 'Error' || typeof value === 'string') @@ -117,8 +96,7 @@ export const printSingleRecordTable = (snapshotRecord: OrgSnapshot): void => { })) // null/undefined becomes empty string .map((row) => (row.Value ? row : { ...row, Value: '' })), - { Name: {}, Value: {} } - ); + }); }; export const printRecordTable = (snapshotRecords: OrgSnapshot[]): void => { @@ -126,13 +104,18 @@ export const printRecordTable = (snapshotRecords: OrgSnapshot[]): void => { new Ux().log('No snapshots found'); return; } - - new Ux().table( + new Ux().table({ // we know what columns we want, so filter out the other fields - snapshotRecords.map((s) => - Object.fromEntries(Object.entries(s).filter(([key]) => Object.keys(ORG_SNAPSHOT_COLUMNS).includes(key))) - ), - ORG_SNAPSHOT_COLUMNS, - { title: `Org Snapshots [${snapshotRecords.length}]`, 'no-truncate': true } - ); + data: snapshotRecords.map((s) => ({ + Id: s.Id, + 'Snapshot Name': s.SnapshotName, + Status: s.Status, + 'Source Org Id': s.SourceOrg, + CreatedDate: s.CreatedDate, + 'Last Modified Date': s.LastModifiedDate, + 'Expiration Date': s.ExpirationDate ? new Date(s.ExpirationDate).toLocaleDateString() : '', + })), + title: `Org Snapshots [${snapshotRecords.length}]`, + overflow: 'wrap', + }); }; diff --git a/tsconfig.json b/tsconfig.json index a11534ae..c004ba1b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,6 +2,8 @@ "extends": "@salesforce/dev-config/tsconfig-strict-esm", "compilerOptions": { "outDir": "lib", + "baseUrl": ".", + "skipLibCheck": true, "strictNullChecks": true, "rootDir": "src", "lib": ["es2020"] diff --git a/yarn.lock b/yarn.lock index 7058bed9..8124aa75 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7,6 +7,14 @@ resolved "https://registry.yarnpkg.com/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz#bd9154aec9983f77b3a034ecaa015c2e4201f6cf" integrity sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA== +"@alcalzone/ansi-tokenize@^0.1.3": + version "0.1.3" + resolved "https://registry.yarnpkg.com/@alcalzone/ansi-tokenize/-/ansi-tokenize-0.1.3.tgz#9f89839561325a8e9a0c32360b8d17e48489993f" + integrity sha512-3yWxPTq3UQ/FY9p1ErPxIyfT64elWaMvM9lIHnaqpyft63tkxodF5aUElYHrdisWve5cETkh1+KBw1yJuW0aRw== + dependencies: + ansi-styles "^6.2.1" + is-fullwidth-code-point "^4.0.0" + "@ampproject/remapping@^2.2.0": version "2.3.0" resolved "https://registry.yarnpkg.com/@ampproject/remapping/-/remapping-2.3.0.tgz#ed441b6fa600072520ce18b43d2c8cc8caecc7f4" @@ -1539,6 +1547,22 @@ http-call "^5.2.2" lodash "^4.17.21" +"@oclif/table@^0.2.1": + version "0.2.1" + resolved "https://registry.yarnpkg.com/@oclif/table/-/table-0.2.1.tgz#99462f914638cd70325e6bb9a1510fc5fef4a903" + integrity sha512-RdznMxghWq6AcZQkT0+lvUFYstyThJlyYxlJPJxunTCrPvkJXhcTDh0eUttLmjaNhqhGWaxZHXlgsga5Ecs/AQ== + dependencies: + "@oclif/core" "^4" + "@types/react" "^18.3.11" + change-case "^5.4.4" + cli-truncate "^4.0.0" + ink "^5.0.1" + natural-orderby "^3.0.2" + object-hash "^3.0.0" + react "^18.3.1" + strip-ansi "^7.1.0" + wrap-ansi "^9.0.0" + "@pkgjs/parseargs@^0.11.0": version "0.11.0" resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" @@ -1652,7 +1676,7 @@ resolved "https://registry.yarnpkg.com/@salesforce/schemas/-/schemas-1.9.0.tgz#ba477a112653a20b4edcf989c61c57bdff9aa3ca" integrity sha512-LiN37zG5ODT6z70sL1fxF7BQwtCX9JOWofSU8iliSNIM+WDEeinnoFtVqPInRSNt8I0RiJxIKCrqstsmQRBNvA== -"@salesforce/sf-plugins-core@^11.3.12", "@salesforce/sf-plugins-core@^11.3.5": +"@salesforce/sf-plugins-core@^11.3.5": version "11.3.12" resolved "https://registry.yarnpkg.com/@salesforce/sf-plugins-core/-/sf-plugins-core-11.3.12.tgz#18b3a553688428bcffea9d36abc72847497f06ae" integrity sha512-hi8EcSoRHRxj4sm/V5YDtzq9bPr/cKpM4fC6abo/jRzpXygwizinc2gVQkXfVdhjK7NGMskVRQB1N+0TThG7bA== @@ -1670,6 +1694,25 @@ string-width "^7.2.0" terminal-link "^3.0.0" +"@salesforce/sf-plugins-core@^12.0.7": + version "12.0.8" + resolved "https://registry.yarnpkg.com/@salesforce/sf-plugins-core/-/sf-plugins-core-12.0.8.tgz#c9e2986fd40039c450f1e12934e2dd6eb0d57c2e" + integrity sha512-XALzUHLTO6uPg0MSdbXbHWH+HHi7ebKu8ARDTQXm8bA7Pa+FmZ3xbEe34CTIzMRQ6VqLwVmeX8Yt5oI3F8L0FQ== + dependencies: + "@inquirer/confirm" "^3.1.22" + "@inquirer/password" "^2.2.0" + "@oclif/core" "^4.0.27" + "@oclif/table" "^0.2.1" + "@salesforce/core" "^8.5.1" + "@salesforce/kit" "^3.2.3" + "@salesforce/ts-types" "^2.0.12" + ansis "^3.3.2" + cli-progress "^3.12.0" + natural-orderby "^3.0.2" + slice-ansi "^7.1.0" + string-width "^7.2.0" + terminal-link "^3.0.0" + "@salesforce/ts-types@^2.0.10", "@salesforce/ts-types@^2.0.11", "@salesforce/ts-types@^2.0.12": version "2.0.12" resolved "https://registry.yarnpkg.com/@salesforce/ts-types/-/ts-types-2.0.12.tgz#60420622812a7ec7e46d220667bc29b42dc247ff" @@ -2381,6 +2424,19 @@ resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301" integrity sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw== +"@types/prop-types@*": + version "15.7.13" + resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.13.tgz#2af91918ee12d9d32914feb13f5326658461b451" + integrity sha512-hCZTSvwbzWGvhqxp/RqVqwU999pBf2vp7hzIjiYOsl8wqOmUxkQ6ddw1cV3l8811+kdUFus/q4d1Y3E3SyEifA== + +"@types/react@^18.3.11": + version "18.3.12" + resolved "https://registry.yarnpkg.com/@types/react/-/react-18.3.12.tgz#99419f182ccd69151813b7ee24b792fe08774f60" + integrity sha512-D2wOSq/d6Agt28q7rSI3jhU7G6aiuzljDGZ2hTZHIkrTLUI+AF3WMeKkEZ9nN2fkBAlcktT6vcZjDFiIhMYEQw== + dependencies: + "@types/prop-types" "*" + csstype "^3.0.2" + "@types/semver@^7.5.0": version "7.5.8" resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.8.tgz#8268a8c57a3e4abd25c165ecd36237db7948a55e" @@ -2643,6 +2699,13 @@ ansi-escapes@^5.0.0: dependencies: type-fest "^1.0.2" +ansi-escapes@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-7.0.0.tgz#00fc19f491bbb18e1d481b97868204f92109bfe7" + integrity sha512-GdYO7a61mR0fOlAsvC9/rIHf7L96sBc6dEWzeOu+KAea5bZyQRPIpojrVoI4AXGJS/ycu/fBTdLrUkA4ODrvjw== + dependencies: + environment "^1.0.0" + ansi-regex@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" @@ -2667,7 +2730,7 @@ ansi-styles@^4.0.0, ansi-styles@^4.1.0: dependencies: color-convert "^2.0.1" -ansi-styles@^6.1.0, ansi-styles@^6.2.1: +ansi-styles@^6.0.0, ansi-styles@^6.1.0, ansi-styles@^6.2.1: version "6.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.2.1.tgz#0e62320cf99c21afff3b3012192546aacbfb05c5" integrity sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug== @@ -2829,6 +2892,11 @@ atomic-sleep@^1.0.0: resolved "https://registry.yarnpkg.com/atomic-sleep/-/atomic-sleep-1.0.0.tgz#eb85b77a601fc932cfe432c5acd364a9e2c9075b" integrity sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ== +auto-bind@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/auto-bind/-/auto-bind-5.0.1.tgz#50d8e63ea5a1dddcb5e5e36451c1a8266ffbb2ae" + integrity sha512-ooviqdwwgfIfNmDwo94wlshcdzfO64XV0Cg6oDsDYBJfITDz1EngD2z7DkbvCWn+XIMsIqW27sEVF6qcpJrRcg== + available-typed-arrays@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7" @@ -3135,6 +3203,11 @@ clean-stack@^3.0.1: dependencies: escape-string-regexp "4.0.0" +cli-boxes@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-3.0.0.tgz#71a10c716feeba005e4504f36329ef0b17cf3145" + integrity sha512-/lzGpEWL/8PfI0BmBOPRwp0c/wFNX1RdUML3jK/RcSBA9T8mZDdQpqYBKtCFTOfQbwPqWEOpjqW+Fnayc0969g== + cli-cursor@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-3.1.0.tgz#264305a7ae490d1d03bf0c9ba7c925d1753af307" @@ -3142,6 +3215,13 @@ cli-cursor@^3.1.0: dependencies: restore-cursor "^3.1.0" +cli-cursor@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-4.0.0.tgz#3cecfe3734bf4fe02a8361cbdc0f6fe28c6a57ea" + integrity sha512-VGtlMu3x/4DOtIUwEkRezxUZ2lBacNJCHash0N0WeZDBS+7Ux1dm3XWAgWYxLJFMMdOeXMHXorshEFhbMSGelg== + dependencies: + restore-cursor "^4.0.0" + cli-progress@^3.12.0: version "3.12.0" resolved "https://registry.yarnpkg.com/cli-progress/-/cli-progress-3.12.0.tgz#807ee14b66bcc086258e444ad0f19e7d42577942" @@ -3154,6 +3234,14 @@ cli-spinners@^2.9.2: resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-2.9.2.tgz#1773a8f4b9c4d6ac31563df53b3fc1d79462fe41" integrity sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg== +cli-truncate@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/cli-truncate/-/cli-truncate-4.0.0.tgz#6cc28a2924fee9e25ce91e973db56c7066e6172a" + integrity sha512-nPdaFdQ0h/GEigbPClz11D0v/ZJEwxmeVZGeMo3Z5StPtUTkA9o1lD6QwoirYiSDzbcwn2XcjwmCp68W1IS4TA== + dependencies: + slice-ansi "^5.0.0" + string-width "^7.0.0" + cli-width@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-3.0.0.tgz#a2f48437a2caa9a22436e794bf071ec9e61cedf6" @@ -3191,6 +3279,13 @@ cliui@^8.0.1: strip-ansi "^6.0.1" wrap-ansi "^7.0.0" +code-excerpt@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/code-excerpt/-/code-excerpt-4.0.0.tgz#2de7d46e98514385cb01f7b3b741320115f4c95e" + integrity sha512-xxodCmBen3iy2i0WtAK8FlFNrRzjUqjRsMfho58xT/wvZU1YTM3fCnRjcy1gJPMepaRlgm/0e6w8SpWHpn3/cA== + dependencies: + convert-to-spaces "^2.0.1" + color-convert@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" @@ -3311,6 +3406,11 @@ convert-source-map@^2.0.0: resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-2.0.0.tgz#4b560f649fc4e918dd0ab75cf4961e8bc882d82a" integrity sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg== +convert-to-spaces@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/convert-to-spaces/-/convert-to-spaces-2.0.1.tgz#61a6c98f8aa626c16b296b862a91412a33bceb6b" + integrity sha512-rcQ1bsQO9799wq24uE5AM2tAILy4gXGIK/njFWcVQkGNZ96edlpY+A7bjwvzjYvLDyzmG1MmMLZhpcsb+klNMQ== + core-js-compat@^3.34.0: version "3.36.0" resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.36.0.tgz#087679119bc2fdbdefad0d45d8e5d307d45ba190" @@ -3369,6 +3469,11 @@ csprng@*: dependencies: sequin "*" +csstype@^3.0.2: + version "3.1.3" + resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.3.tgz#d80ff294d114fb0e6ac500fbf85b60137d7eff81" + integrity sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw== + csv-parse@^4.8.2: version "4.16.3" resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-4.16.3.tgz#7ca624d517212ebc520a36873c3478fa66efbaf7" @@ -3621,6 +3726,11 @@ entities@^4.2.0, entities@^4.4.0, entities@^4.5.0: resolved "https://registry.yarnpkg.com/entities/-/entities-4.5.0.tgz#5d268ea5e7113ec74c4d033b79ea5a35a488fb48" integrity sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw== +environment@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/environment/-/environment-1.1.0.tgz#8e86c66b180f363c7ab311787e0259665f45a9f1" + integrity sha512-xUtoPkMggbz0MPyPiIWr1Kp4aeWJjDZ6SMvURhimjdZgsRuDplF5/s9hcgGhyXMhs+6vpnuoiZ2kFiu3FMnS8Q== + error-ex@^1.3.1: version "1.3.2" resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" @@ -3723,6 +3833,11 @@ escape-string-regexp@^1.0.5: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg== +escape-string-regexp@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz#a30304e99daa32e23b2fd20f51babd07cffca344" + integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w== + eslint-config-prettier@^9.1.0: version "9.1.0" resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz#31af3d94578645966c082fcb71a5846d3c94867f" @@ -4716,6 +4831,11 @@ indent-string@^4.0.0: resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-4.0.0.tgz#624f8f4497d619b2d9768531d58f4122854d7251" integrity sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg== +indent-string@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-5.0.0.tgz#4fd2980fccaf8622d14c64d694f4cf33c81951a5" + integrity sha512-m6FAo/spmsW2Ab2fU35JTYwtOKa2yAwXSwgjSv1TJzh4Mh7mC3lzAOVLBprb72XsTrgkEIsl7YrFNAiDiRhIGg== + inflight@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" @@ -4734,6 +4854,36 @@ ini@^1.3.4: resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.8.tgz#a29da425b48806f34767a4efce397269af28432c" integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew== +ink@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/ink/-/ink-5.0.1.tgz#f2ef9796a3911830c3995dedd227ec84ae27de4b" + integrity sha512-ae4AW/t8jlkj/6Ou21H2av0wxTk8vrGzXv+v2v7j4in+bl1M5XRMVbfNghzhBokV++FjF8RBDJvYo+ttR9YVRg== + dependencies: + "@alcalzone/ansi-tokenize" "^0.1.3" + ansi-escapes "^7.0.0" + ansi-styles "^6.2.1" + auto-bind "^5.0.1" + chalk "^5.3.0" + cli-boxes "^3.0.0" + cli-cursor "^4.0.0" + cli-truncate "^4.0.0" + code-excerpt "^4.0.0" + indent-string "^5.0.0" + is-in-ci "^0.1.0" + lodash "^4.17.21" + patch-console "^2.0.0" + react-reconciler "^0.29.0" + scheduler "^0.23.0" + signal-exit "^3.0.7" + slice-ansi "^7.1.0" + stack-utils "^2.0.6" + string-width "^7.0.0" + type-fest "^4.8.3" + widest-line "^5.0.0" + wrap-ansi "^9.0.0" + ws "^8.15.0" + yoga-wasm-web "~0.3.3" + inquirer@^7.0.0: version "7.3.3" resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.3.3.tgz#04d176b2af04afc157a83fd7c100e98ee0aad003" @@ -4849,6 +4999,11 @@ is-fullwidth-code-point@^3.0.0: resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== +is-fullwidth-code-point@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-4.0.0.tgz#fae3167c729e7463f8461ce512b080a49268aa88" + integrity sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ== + is-fullwidth-code-point@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-5.0.0.tgz#9609efced7c2f97da7b60145ef481c787c7ba704" @@ -4863,6 +5018,11 @@ is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3, is-glob@~4.0.1: dependencies: is-extglob "^2.1.1" +is-in-ci@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/is-in-ci/-/is-in-ci-0.1.0.tgz#5e07d6a02ec3a8292d3f590973357efa3fceb0d3" + integrity sha512-d9PXLEY0v1iJ64xLiQMJ51J128EYHAaOR4yZqQi8aHGfw6KgifM3/Viw1oZZ1GCVmb3gBuyhLyHj0HgR2DhSXQ== + is-inside-container@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-inside-container/-/is-inside-container-1.0.0.tgz#e81fba699662eb31dbdaf26766a61d4814717ea4" @@ -5106,7 +5266,7 @@ joycon@^3.1.1: resolved "https://registry.yarnpkg.com/joycon/-/joycon-3.1.1.tgz#bce8596d6ae808f8b68168f5fc69280996894f03" integrity sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw== -js-tokens@^4.0.0: +"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== @@ -5492,6 +5652,13 @@ log-symbols@^4.1.0: chalk "^4.1.0" is-unicode-supported "^0.1.0" +loose-envify@^1.1.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" + integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q== + dependencies: + js-tokens "^3.0.0 || ^4.0.0" + loupe@^2.3.6: version "2.3.6" resolved "https://registry.yarnpkg.com/loupe/-/loupe-2.3.6.tgz#76e4af498103c532d1ecc9be102036a21f787b53" @@ -5901,6 +6068,11 @@ nyc@^17.0.0: test-exclude "^6.0.0" yargs "^15.0.2" +object-hash@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/object-hash/-/object-hash-3.0.0.tgz#73f97f753e7baffc0e2cc9d6e079079744ac82e9" + integrity sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw== + object-inspect@^1.13.1, object-inspect@^1.9.0: version "1.13.1" resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.13.1.tgz#b96c6109324ccfef6b12216a956ca4dc2ff94bc2" @@ -6124,6 +6296,11 @@ pascal-case@^3.1.2: no-case "^3.0.4" tslib "^2.0.3" +patch-console@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/patch-console/-/patch-console-2.0.0.tgz#9023f4665840e66f40e9ce774f904a63167433bb" + integrity sha512-0YNdUceMdaQwoKce1gatDScmMo5pu/tfABfnzEqeG0gtTmd7mh/WcwgUjtAeOU7N8nFFlbQBnFK2gXW5fGvmMA== + path-case@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/path-case/-/path-case-3.0.4.tgz#9168645334eb942658375c56f80b4c0cb5f82c6f" @@ -6378,6 +6555,21 @@ randombytes@^2.1.0: dependencies: safe-buffer "^5.1.0" +react-reconciler@^0.29.0: + version "0.29.2" + resolved "https://registry.yarnpkg.com/react-reconciler/-/react-reconciler-0.29.2.tgz#8ecfafca63549a4f4f3e4c1e049dd5ad9ac3a54f" + integrity sha512-zZQqIiYgDCTP/f1N/mAR10nJGrPD2ZR+jDSEsKWJHYC7Cm2wodlwbR3upZRdC3cjIjSlTLNVyO7Iu0Yy7t2AYg== + dependencies: + loose-envify "^1.1.0" + scheduler "^0.23.2" + +react@^18.3.1: + version "18.3.1" + resolved "https://registry.yarnpkg.com/react/-/react-18.3.1.tgz#49ab892009c53933625bd16b2533fc754cab2891" + integrity sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ== + dependencies: + loose-envify "^1.1.0" + read-pkg-up@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-7.0.1.tgz#f3a6135758459733ae2b95638056e1854e7ef507" @@ -6561,6 +6753,14 @@ restore-cursor@^3.1.0: onetime "^5.1.0" signal-exit "^3.0.2" +restore-cursor@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-4.0.0.tgz#519560a4318975096def6e609d44100edaa4ccb9" + integrity sha512-I9fPXU9geO9bHOt9pHHOhOkYerIMsmVaWB0rA2AI9ERh/+x/i7MV5HKBNrg+ljO5eoPVgCcnFuRjJ9uH6I/3eg== + dependencies: + onetime "^5.1.0" + signal-exit "^3.0.2" + retry@0.13.1: version "0.13.1" resolved "https://registry.yarnpkg.com/retry/-/retry-0.13.1.tgz#185b1587acf67919d63b357349e03537b2484658" @@ -6646,6 +6846,13 @@ sax@>=0.6.0: resolved "https://registry.yarnpkg.com/sax/-/sax-1.3.0.tgz#a5dbe77db3be05c9d1ee7785dbd3ea9de51593d0" integrity sha512-0s+oAmw9zLl1V1cS9BtZN7JAd0cW5e0QH4W3LWEK6a4LaLEA2OTpGYWDY+6XasBLtz6wkm3u1xRw95mRuJ59WA== +scheduler@^0.23.0, scheduler@^0.23.2: + version "0.23.2" + resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.23.2.tgz#414ba64a3b282892e944cf2108ecc078d115cdc3" + integrity sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ== + dependencies: + loose-envify "^1.1.0" + secure-json-parse@^2.4.0: version "2.7.0" resolved "https://registry.yarnpkg.com/secure-json-parse/-/secure-json-parse-2.7.0.tgz#5a5f9cd6ae47df23dba3151edd06855d47e09862" @@ -6766,7 +6973,7 @@ side-channel@^1.0.4: get-intrinsic "^1.0.2" object-inspect "^1.9.0" -signal-exit@^3.0.2, signal-exit@^3.0.3: +signal-exit@^3.0.2, signal-exit@^3.0.3, signal-exit@^3.0.7: version "3.0.7" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== @@ -6815,6 +7022,14 @@ slash@^5.1.0: resolved "https://registry.yarnpkg.com/slash/-/slash-5.1.0.tgz#be3adddcdf09ac38eebe8dcdc7b1a57a75b095ce" integrity sha512-ZA6oR3T/pEyuqwMgAKT0/hAv8oAXckzbkmR0UkUosQ+Mc4RxGoJkRmwHgHufaenlyAgE1Mxgpdcrf75y6XcnDg== +slice-ansi@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-5.0.0.tgz#b73063c57aa96f9cd881654b15294d95d285c42a" + integrity sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ== + dependencies: + ansi-styles "^6.0.0" + is-fullwidth-code-point "^4.0.0" + slice-ansi@^7.1.0: version "7.1.0" resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-7.1.0.tgz#cd6b4655e298a8d1bdeb04250a433094b347b9a9" @@ -6938,6 +7153,13 @@ srcset@^5.0.0: resolved "https://registry.yarnpkg.com/srcset/-/srcset-5.0.0.tgz#9df6c3961b5b44a02532ce6ae4544832609e2e3f" integrity sha512-SqEZaAEhe0A6ETEa9O1IhSPC7MdvehZtCnTR0AftXk3QhY2UNgb+NApFOUPZILXk/YTDfFxMTNJOBpzrJsEdIA== +stack-utils@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-2.0.6.tgz#aaf0748169c02fc33c8232abccf933f54a1cc34f" + integrity sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ== + dependencies: + escape-string-regexp "^2.0.0" + "string-width-cjs@npm:string-width@^4.2.0": version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" @@ -6965,7 +7187,7 @@ string-width@^5.0.1, string-width@^5.1.2: emoji-regex "^9.2.2" strip-ansi "^7.0.1" -string-width@^7.2.0: +string-width@^7.0.0, string-width@^7.2.0: version "7.2.0" resolved "https://registry.yarnpkg.com/string-width/-/string-width-7.2.0.tgz#b5bb8e2165ce275d4d43476dd2700ad9091db6dc" integrity sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ== @@ -7303,6 +7525,11 @@ type-fest@^1.0.2: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-1.4.0.tgz#e9fb813fe3bf1744ec359d55d1affefa76f14be1" integrity sha512-yGSza74xk0UG8k+pLh5oeoYirvIiWo5t0/o3zHHAO2tRDiZcxWP7fywNlXhqb6/r6sWvwi+RsyQMWhVLe4BVuA== +type-fest@^4.8.3: + version "4.26.1" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-4.26.1.tgz#a4a17fa314f976dd3e6d6675ef6c775c16d7955e" + integrity sha512-yOGpmOAL7CkKe/91I5O3gPICmJNLJ1G4zFYVAsRHg7M64biSnPtRj0WNQt++bRkjYOqjWXrhnUw1utzmVErAdg== + typed-array-buffer@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/typed-array-buffer/-/typed-array-buffer-1.0.0.tgz#18de3e7ed7974b0a729d3feecb94338d1472cd60" @@ -7573,6 +7800,13 @@ widest-line@^3.1.0: dependencies: string-width "^4.0.0" +widest-line@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/widest-line/-/widest-line-5.0.0.tgz#b74826a1e480783345f0cd9061b49753c9da70d0" + integrity sha512-c9bZp7b5YtRj2wOe6dlj32MK+Bx/M/d+9VB2SHM1OtsUHR0aV0tdP6DWh/iMt0kWi1t5g1Iudu6hQRNd1A4PVA== + dependencies: + string-width "^7.0.0" + wireit@^0.14.5: version "0.14.5" resolved "https://registry.yarnpkg.com/wireit/-/wireit-0.14.5.tgz#cd1c4136444c8dbe655f34f60fe2454a9e69d430" @@ -7630,6 +7864,15 @@ wrap-ansi@^8.1.0: string-width "^5.0.1" strip-ansi "^7.0.1" +wrap-ansi@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-9.0.0.tgz#1a3dc8b70d85eeb8398ddfb1e4a02cd186e58b3e" + integrity sha512-G8ura3S+3Z2G+mkgNRq8dqaFZAuxfsxpBB8OCTGRTCtp+l/v9nbFNmCUP1BZMts3G1142MsZfn6eeUKrr4PD1Q== + dependencies: + ansi-styles "^6.2.1" + string-width "^7.0.0" + strip-ansi "^7.1.0" + wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" @@ -7645,6 +7888,11 @@ write-file-atomic@^3.0.0: signal-exit "^3.0.2" typedarray-to-buffer "^3.1.5" +ws@^8.15.0: + version "8.18.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.0.tgz#0d7505a6eafe2b0e712d232b42279f53bc289bbc" + integrity sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw== + xml2js@^0.5.0: version "0.5.0" resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.5.0.tgz#d9440631fbb2ed800203fad106f2724f62c493b7" @@ -7781,3 +8029,8 @@ yoctocolors-cjs@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/yoctocolors-cjs/-/yoctocolors-cjs-2.1.2.tgz#f4b905a840a37506813a7acaa28febe97767a242" integrity sha512-cYVsTjKl8b+FrnidjibDWskAv7UKOfcwaVZdp/it9n1s9fU3IkgDbhdIRKCW4JDsAlECJY0ytoVPT3sK6kideA== + +yoga-wasm-web@~0.3.3: + version "0.3.3" + resolved "https://registry.yarnpkg.com/yoga-wasm-web/-/yoga-wasm-web-0.3.3.tgz#eb8e9fcb18e5e651994732f19a220cb885d932ba" + integrity sha512-N+d4UJSJbt/R3wqY7Coqs5pcV0aUj2j9IaQ3rNj9bVCLld8tTGKRa2USARjnvZJWVx1NDmQev8EknoczaOQDOA== From d3afbdb80beda2b59ee9eb893a40b9a0f1c4d5ae Mon Sep 17 00:00:00 2001 From: soridalac Date: Tue, 29 Oct 2024 11:12:09 -0700 Subject: [PATCH 2/7] feat: update table --- src/commands/org/list/shape.ts | 10 +++------- src/shared/snapshot.ts | 14 ++++++++------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/commands/org/list/shape.ts b/src/commands/org/list/shape.ts index adf0276d..2f8275cf 100644 --- a/src/commands/org/list/shape.ts +++ b/src/commands/org/list/shape.ts @@ -40,17 +40,13 @@ export class OrgShapeListCommand extends SfCommand { this.table({ data: orgShapes.map((shape) => ({ - ALIAS: shape.alias ?? '', - USERNAME: shape.username, 'ORG ID': shape.orgId, + USERNAME: shape.username, + ALIAS: shape.alias ?? '', 'Shape ID': shape.shapeId, + 'Shape Status': shape.status === 'Active' ? StandardColors.success(shape.status) : shape.status, 'CREATED BY': shape.createdBy, 'CREATED DATE': shape.createdDate, - ...(shape.status === 'Active' - ? { - STATUS: StandardColors.success(shape.status), - } - : {}), })), title: 'Org Shapes', }); diff --git a/src/shared/snapshot.ts b/src/shared/snapshot.ts index bd9220f4..bb6688f5 100644 --- a/src/shared/snapshot.ts +++ b/src/shared/snapshot.ts @@ -92,10 +92,11 @@ export const printSingleRecordTable = (snapshotRecord: OrgSnapshot): void => { .map(([key, value]: [string, string]) => ({ Name: capitalCase(key), // format the datetime values - Value: ['LastModifiedDate', 'CreatedDate'].includes(key) ? dateTimeFormatter(value) : value, - })) - // null/undefined becomes empty string - .map((row) => (row.Value ? row : { ...row, Value: '' })), + Value: ['LastModifiedDate', 'CreatedDate'].includes(key) ? dateTimeFormatter(value) : value ?? '', + })), + // null/undefined becomes empty string + // .map((row) => (row.Value ? row : { ...row, Value: '' })), + columns: ['Name', 'Value'], }); }; @@ -107,12 +108,13 @@ export const printRecordTable = (snapshotRecords: OrgSnapshot[]): void => { new Ux().table({ // we know what columns we want, so filter out the other fields data: snapshotRecords.map((s) => ({ + // ...Object.fromEntries(Object.entries(s).filter(([key]) => Object.keys(s).includes(key))), Id: s.Id, 'Snapshot Name': s.SnapshotName, Status: s.Status, 'Source Org Id': s.SourceOrg, - CreatedDate: s.CreatedDate, - 'Last Modified Date': s.LastModifiedDate, + 'Created Date': dateTimeFormatter(s.CreatedDate), + 'Last Modified Date': dateTimeFormatter(s.LastModifiedDate), 'Expiration Date': s.ExpirationDate ? new Date(s.ExpirationDate).toLocaleDateString() : '', })), title: `Org Snapshots [${snapshotRecords.length}]`, From 84cf92be6334790e4ce5d94301bb4c27c9fef236 Mon Sep 17 00:00:00 2001 From: soridalac Date: Thu, 31 Oct 2024 10:06:32 -0700 Subject: [PATCH 3/7] fix: update tables --- src/commands/org/delete/shape.ts | 2 +- src/commands/org/list/shape.ts | 11 ++--------- src/shared/snapshot.ts | 8 ++++---- test/shape/delete.test.ts | 10 ++++++---- test/shape/list.test.ts | 12 ++++++------ 5 files changed, 19 insertions(+), 24 deletions(-) diff --git a/src/commands/org/delete/shape.ts b/src/commands/org/delete/shape.ts index a068a9a1..07a33b2a 100644 --- a/src/commands/org/delete/shape.ts +++ b/src/commands/org/delete/shape.ts @@ -72,13 +72,13 @@ export class OrgShapeDeleteCommand extends SfCommand { this.info(messages.getMessage('noOrgShapes')); return orgShapes; } - + this.styledHeader('Org Shapes'); this.table({ data: orgShapes.map((shape) => ({ - 'ORG ID': shape.orgId, - USERNAME: shape.username, - ALIAS: shape.alias ?? '', - 'Shape ID': shape.shapeId, - 'Shape Status': shape.status === 'Active' ? StandardColors.success(shape.status) : shape.status, - 'CREATED BY': shape.createdBy, - 'CREATED DATE': shape.createdDate, + ...(shape.status === 'Active' ? { ...shape, status: StandardColors.success(shape.status) } : shape), })), - title: 'Org Shapes', }); return orgShapes; } diff --git a/src/shared/snapshot.ts b/src/shared/snapshot.ts index bb6688f5..24160b9e 100644 --- a/src/shared/snapshot.ts +++ b/src/shared/snapshot.ts @@ -92,10 +92,10 @@ export const printSingleRecordTable = (snapshotRecord: OrgSnapshot): void => { .map(([key, value]: [string, string]) => ({ Name: capitalCase(key), // format the datetime values - Value: ['LastModifiedDate', 'CreatedDate'].includes(key) ? dateTimeFormatter(value) : value ?? '', - })), - // null/undefined becomes empty string - // .map((row) => (row.Value ? row : { ...row, Value: '' })), + Value: ['LastModifiedDate', 'CreatedDate'].includes(key) ? dateTimeFormatter(value) : value, + })) + // null/undefined becomes empty string + .map((row) => (row.Value ? row : { ...row, Value: '' })), columns: ['Name', 'Value'], }); }; diff --git a/test/shape/delete.test.ts b/test/shape/delete.test.ts index 047a99d7..7ebaa467 100644 --- a/test/shape/delete.test.ts +++ b/test/shape/delete.test.ts @@ -126,10 +126,12 @@ describe('org:shape:delete', () => { expect(uxLogStub.getCalls().some((c) => c.args[0] === 'Successfully deleted org shape for 00D000000000000004.')); expect(uxLogStub.getCalls().some((c) => c.args[0] === '')); expect(uxStyledHeaderStub.secondCall.args[0]).to.equal('Failures'); - expect(uxTableStub.firstCall.args[0]).to.deep.equal([{ shapeId: '3SR000000000124', message: 'MALFORMED ID' }]); - expect(uxTableStub.firstCall.args[1]).to.deep.equal({ - shapeId: { header: 'Shape ID' }, - message: { header: 'Error Message' }, + expect(uxTableStub.firstCall.args[0]).to.deep.equal({ + data: [{ shapeId: '3SR000000000124', message: 'MALFORMED ID' }], + columns: [ + { key: 'shapeId', name: 'Shape ID' }, + { key: 'message', name: 'Error Message' }, + ], }); }); diff --git a/test/shape/list.test.ts b/test/shape/list.test.ts index 5f5bfcb0..e69c366f 100644 --- a/test/shape/list.test.ts +++ b/test/shape/list.test.ts @@ -79,12 +79,12 @@ describe('org:shape:list', () => { await command.run(); expect(uxLogStub.notCalled).to.be.true; expect(uxStyledHeaderStub.firstCall.args[0]).to.equal('Org Shapes'); - expect((uxTableStub.firstCall.args[0] as OrgShapeListResult[]).length).to.equal(2); - expect(uxTableStub.firstCall.args[0]).to.deep.equal( - shapes.map((shape) => - shape.status === 'Active' ? { ...shape, status: StandardColors.success(shape.status) } : shape - ) - ); + expect((uxTableStub.firstCall.args[0] as { data: OrgShapeListResult[] }).data.length).to.equal(2); + expect(uxTableStub.firstCall.args[0]).to.deep.equal({ + data: shapes.map((shape) => ({ + ...(shape.status === 'Active' ? { ...shape, status: StandardColors.success(shape.status) } : shape), + })), + }); }); it('no devhub org', async () => { From e3ce7830cf4457f13583774e6eac9d10571513f5 Mon Sep 17 00:00:00 2001 From: soridalac Date: Thu, 31 Oct 2024 11:41:58 -0700 Subject: [PATCH 4/7] fix: update title table --- src/commands/org/delete/shape.ts | 2 +- src/commands/org/list/shape.ts | 3 ++- test/shape/delete.test.ts | 5 +---- test/shape/list.test.ts | 4 +--- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/commands/org/delete/shape.ts b/src/commands/org/delete/shape.ts index 07a33b2a..37e217af 100644 --- a/src/commands/org/delete/shape.ts +++ b/src/commands/org/delete/shape.ts @@ -69,7 +69,6 @@ export class OrgShapeDeleteCommand extends SfCommand 0) { setExitCode(68); - this.styledHeader('Partial Success'); this.logSuccess(messages.getMessage('humanSuccess', [orgId])); this.log(''); this.styledHeader('Failures'); @@ -79,6 +78,7 @@ export class OrgShapeDeleteCommand extends SfCommand { this.info(messages.getMessage('noOrgShapes')); return orgShapes; } - this.styledHeader('Org Shapes'); + // this.styledHeader('Org Shapes'); this.table({ data: orgShapes.map((shape) => ({ ...(shape.status === 'Active' ? { ...shape, status: StandardColors.success(shape.status) } : shape), })), + title: 'Org Shapes', }); return orgShapes; } diff --git a/test/shape/delete.test.ts b/test/shape/delete.test.ts index 7ebaa467..e6d62c3b 100644 --- a/test/shape/delete.test.ts +++ b/test/shape/delete.test.ts @@ -33,12 +33,10 @@ describe('org:shape:delete', () => { // stubs let uxLogStub: sinon.SinonStub; let uxTableStub: sinon.SinonStub; - let uxStyledHeaderStub: sinon.SinonStub; beforeEach(async () => { await config.load(); uxLogStub = sandbox.stub(SfCommand.prototype, 'log'); - uxStyledHeaderStub = sandbox.stub(SfCommand.prototype, 'styledHeader'); uxTableStub = sandbox.stub(SfCommand.prototype, 'table'); await $$.stubAuths(testOrg); @@ -122,16 +120,15 @@ describe('org:shape:delete', () => { const command = new OrgShapeDeleteCommand(['--noprompt', '--targetusername', testOrg.username], config); await command.run(); - expect(uxStyledHeaderStub.firstCall.args[0]).to.equal('Partial Success'); expect(uxLogStub.getCalls().some((c) => c.args[0] === 'Successfully deleted org shape for 00D000000000000004.')); expect(uxLogStub.getCalls().some((c) => c.args[0] === '')); - expect(uxStyledHeaderStub.secondCall.args[0]).to.equal('Failures'); expect(uxTableStub.firstCall.args[0]).to.deep.equal({ data: [{ shapeId: '3SR000000000124', message: 'MALFORMED ID' }], columns: [ { key: 'shapeId', name: 'Shape ID' }, { key: 'message', name: 'Error Message' }, ], + title: 'Failures', }); }); diff --git a/test/shape/list.test.ts b/test/shape/list.test.ts index e69c366f..bd87c4f4 100644 --- a/test/shape/list.test.ts +++ b/test/shape/list.test.ts @@ -24,7 +24,6 @@ describe('org:shape:list', () => { // stubs let uxLogStub: sinon.SinonStub; let uxTableStub: sinon.SinonStub; - let uxStyledHeaderStub: sinon.SinonStub; const $$ = new TestContext(); const testOrg = new MockTestOrgData(); @@ -33,7 +32,6 @@ describe('org:shape:list', () => { beforeEach(async () => { await config.load(); uxLogStub = sandbox.stub(SfCommand.prototype, 'log'); - uxStyledHeaderStub = sandbox.stub(SfCommand.prototype, 'styledHeader'); uxTableStub = sandbox.stub(SfCommand.prototype, 'table'); }); @@ -78,12 +76,12 @@ describe('org:shape:list', () => { const command = new OrgShapeListCommand([], config); await command.run(); expect(uxLogStub.notCalled).to.be.true; - expect(uxStyledHeaderStub.firstCall.args[0]).to.equal('Org Shapes'); expect((uxTableStub.firstCall.args[0] as { data: OrgShapeListResult[] }).data.length).to.equal(2); expect(uxTableStub.firstCall.args[0]).to.deep.equal({ data: shapes.map((shape) => ({ ...(shape.status === 'Active' ? { ...shape, status: StandardColors.success(shape.status) } : shape), })), + title: 'Org Shapes', }); }); From d69bed8b706ee7b578c7aeb79a398865f2dacf34 Mon Sep 17 00:00:00 2001 From: soridalac Date: Thu, 31 Oct 2024 11:59:42 -0700 Subject: [PATCH 5/7] fix: remove styledheader --- src/commands/org/delete/shape.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/commands/org/delete/shape.ts b/src/commands/org/delete/shape.ts index 37e217af..023b775c 100644 --- a/src/commands/org/delete/shape.ts +++ b/src/commands/org/delete/shape.ts @@ -71,7 +71,6 @@ export class OrgShapeDeleteCommand extends SfCommand Date: Thu, 31 Oct 2024 12:02:18 -0700 Subject: [PATCH 6/7] fix: erase comment out --- src/shared/snapshot.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/shared/snapshot.ts b/src/shared/snapshot.ts index 24160b9e..248c8f0e 100644 --- a/src/shared/snapshot.ts +++ b/src/shared/snapshot.ts @@ -106,9 +106,7 @@ export const printRecordTable = (snapshotRecords: OrgSnapshot[]): void => { return; } new Ux().table({ - // we know what columns we want, so filter out the other fields data: snapshotRecords.map((s) => ({ - // ...Object.fromEntries(Object.entries(s).filter(([key]) => Object.keys(s).includes(key))), Id: s.Id, 'Snapshot Name': s.SnapshotName, Status: s.Status, From e206da75597ec39a97dbb5f6fc78f5f4e788df3f Mon Sep 17 00:00:00 2001 From: soridalac Date: Thu, 31 Oct 2024 13:04:05 -0700 Subject: [PATCH 7/7] fix: update table --- src/commands/org/list/shape.ts | 3 ++- test/shape/list.test.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/commands/org/list/shape.ts b/src/commands/org/list/shape.ts index bffd7190..73a10d31 100644 --- a/src/commands/org/list/shape.ts +++ b/src/commands/org/list/shape.ts @@ -37,12 +37,13 @@ export class OrgShapeListCommand extends SfCommand { this.info(messages.getMessage('noOrgShapes')); return orgShapes; } - // this.styledHeader('Org Shapes'); + this.table({ data: orgShapes.map((shape) => ({ ...(shape.status === 'Active' ? { ...shape, status: StandardColors.success(shape.status) } : shape), })), title: 'Org Shapes', + overflow: 'wrap', }); return orgShapes; } diff --git a/test/shape/list.test.ts b/test/shape/list.test.ts index bd87c4f4..afcde4d6 100644 --- a/test/shape/list.test.ts +++ b/test/shape/list.test.ts @@ -82,6 +82,7 @@ describe('org:shape:list', () => { ...(shape.status === 'Active' ? { ...shape, status: StandardColors.success(shape.status) } : shape), })), title: 'Org Shapes', + overflow: 'wrap', }); });