Skip to content

Commit 4ab8452

Browse files
authored
chore(deps): remove dependency on table (#171)
1 parent 2a0da76 commit 4ab8452

File tree

5 files changed

+60
-63
lines changed

5 files changed

+60
-63
lines changed

.changeset/red-jars-smile.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"aws-sdk-js-codemod": patch
3+
---
4+
5+
Remove dependency 'table'

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@
3939
"test": "jest"
4040
},
4141
"dependencies": {
42-
"jscodeshift": "0.14.0",
43-
"table": "6.8.0"
42+
"jscodeshift": "0.14.0"
4443
},
4544
"devDependencies": {
4645
"@changesets/cli": "^2.21.0",

src/utils/getHelpParagraph.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
1-
import { getBorderCharacters, table } from "table";
2-
31
import { AwsSdkJsCodemodTransform } from "../transforms";
2+
import { getTransformDescription } from "./getTransformDescription";
3+
4+
const separator = "-".repeat(95);
45

56
export const getHelpParagraph = (transforms: AwsSdkJsCodemodTransform[]) =>
6-
`----------------------------------------------------------------------------------------------------
7+
`${separator}
78
aws-sdk-js-codemod is a lightweight wrapper over jscodeshift.
89
It processes --help, --version and --transform options before passing them downstream.
910
1011
You can provide names of the custom transforms instead of a local path or url:
1112
12-
${table(
13-
transforms.map(({ name, description }) => [name, description]),
14-
{
15-
border: getBorderCharacters("void"),
16-
columns: [
17-
{ width: 12, alignment: "right" },
18-
{ width: 88, wrapWord: true },
19-
],
20-
}
21-
)}Example: aws-sdk-js-codemod -t v2-to-v3 example.js
13+
${transforms.map((transform) => getTransformDescription(transform).join("\n"))}
14+
15+
Example: aws-sdk-js-codemod -t v2-to-v3 example.js
2216
23-
----------------------------------------------------------------------------------------------------\n\n`;
17+
${separator}\n\n`;

src/utils/getTransformDescription.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { AwsSdkJsCodemodTransform } from "../transforms";
2+
3+
const getWrappedBlocks = (sentence: string, blockLength: number): string[] => {
4+
const words = sentence.split(" ");
5+
const blocks = [];
6+
let currentBlock = "";
7+
8+
// iterate over the words and add them to blocks
9+
for (const word of words) {
10+
// if the current block plus the next word is longer than the block length,
11+
// add the current block to the list of blocks and start a new block
12+
if (currentBlock.length + word.length > blockLength) {
13+
blocks.push(currentBlock);
14+
currentBlock = "";
15+
}
16+
17+
// add the word to the current block
18+
currentBlock += word + " ";
19+
}
20+
21+
// add the final block to the list of blocks
22+
blocks.push(currentBlock);
23+
24+
return blocks;
25+
};
26+
27+
export const getTransformDescription = (transform: AwsSdkJsCodemodTransform): string[] => {
28+
const descriptionArr: string[] = [];
29+
30+
const columnLength = 15;
31+
const borderLength = 2;
32+
33+
descriptionArr[0] =
34+
" ".repeat(columnLength - borderLength - transform.name.length) +
35+
transform.name +
36+
" ".repeat(borderLength);
37+
38+
const wrappedBlocks = getWrappedBlocks(transform.description, 80);
39+
40+
descriptionArr[0] += wrappedBlocks[0];
41+
for (let i = 1; i < wrappedBlocks.length; i++) {
42+
descriptionArr.push(" ".repeat(columnLength) + wrappedBlocks[i]);
43+
}
44+
45+
return descriptionArr;
46+
};

yarn.lock

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,18 +1685,6 @@ __metadata:
16851685
languageName: node
16861686
linkType: hard
16871687

1688-
"ajv@npm:^8.0.1":
1689-
version: 8.11.2
1690-
resolution: "ajv@npm:8.11.2"
1691-
dependencies:
1692-
fast-deep-equal: ^3.1.1
1693-
json-schema-traverse: ^1.0.0
1694-
require-from-string: ^2.0.2
1695-
uri-js: ^4.2.2
1696-
checksum: 53435bf79ee7d1eabba8085962dba4c08d08593334b304db7772887f0b7beebc1b3d957432f7437ed4b60e53b5d966a57b439869890209c50fed610459999e3e
1697-
languageName: node
1698-
linkType: hard
1699-
17001688
"ansi-colors@npm:^4.1.1, ansi-colors@npm:^4.1.3":
17011689
version: 4.1.3
17021690
resolution: "ansi-colors@npm:4.1.3"
@@ -1871,7 +1859,6 @@ __metadata:
18711859
lint-staged: ^13.0.3
18721860
prettier: 2.7.1
18731861
simple-git-hooks: ^2.8.1
1874-
table: 6.8.0
18751862
ts-jest: ^29.0.3
18761863
typescript: ~4.9.4
18771864
bin:
@@ -4387,13 +4374,6 @@ __metadata:
43874374
languageName: node
43884375
linkType: hard
43894376

4390-
"json-schema-traverse@npm:^1.0.0":
4391-
version: 1.0.0
4392-
resolution: "json-schema-traverse@npm:1.0.0"
4393-
checksum: 02f2f466cdb0362558b2f1fd5e15cce82ef55d60cd7f8fa828cf35ba74330f8d767fcae5c5c2adb7851fa811766c694b9405810879bc4e1ddd78a7c0e03658ad
4394-
languageName: node
4395-
linkType: hard
4396-
43974377
"json-stable-stringify-without-jsonify@npm:^1.0.1":
43984378
version: 1.0.1
43994379
resolution: "json-stable-stringify-without-jsonify@npm:1.0.1"
@@ -4579,13 +4559,6 @@ __metadata:
45794559
languageName: node
45804560
linkType: hard
45814561

4582-
"lodash.truncate@npm:^4.4.2":
4583-
version: 4.4.2
4584-
resolution: "lodash.truncate@npm:4.4.2"
4585-
checksum: b463d8a382cfb5f0e71c504dcb6f807a7bd379ff1ea216669aa42c52fc28c54e404bfbd96791aa09e6df0de2c1d7b8f1b7f4b1a61f324d38fe98bc535aeee4f5
4586-
languageName: node
4587-
linkType: hard
4588-
45894562
"log-update@npm:^4.0.0":
45904563
version: 4.0.0
45914564
resolution: "log-update@npm:4.0.0"
@@ -5526,13 +5499,6 @@ __metadata:
55265499
languageName: node
55275500
linkType: hard
55285501

5529-
"require-from-string@npm:^2.0.2":
5530-
version: 2.0.2
5531-
resolution: "require-from-string@npm:2.0.2"
5532-
checksum: a03ef6895445f33a4015300c426699bc66b2b044ba7b670aa238610381b56d3f07c686251740d575e22f4c87531ba662d06937508f0f3c0f1ddc04db3130560b
5533-
languageName: node
5534-
linkType: hard
5535-
55365502
"require-main-filename@npm:^2.0.0":
55375503
version: 2.0.0
55385504
resolution: "require-main-filename@npm:2.0.0"
@@ -6157,19 +6123,6 @@ __metadata:
61576123
languageName: node
61586124
linkType: hard
61596125

6160-
"table@npm:6.8.0":
6161-
version: 6.8.0
6162-
resolution: "table@npm:6.8.0"
6163-
dependencies:
6164-
ajv: ^8.0.1
6165-
lodash.truncate: ^4.4.2
6166-
slice-ansi: ^4.0.0
6167-
string-width: ^4.2.3
6168-
strip-ansi: ^6.0.1
6169-
checksum: 5b07fe462ee03d2e1fac02cbb578efd2e0b55ac07e3d3db2e950aa9570ade5a4a2b8d3c15e9f25c89e4e50b646bc4269934601ee1eef4ca7968ad31960977690
6170-
languageName: node
6171-
linkType: hard
6172-
61736126
"tar@npm:^6.1.11, tar@npm:^6.1.2":
61746127
version: 6.1.12
61756128
resolution: "tar@npm:6.1.12"

0 commit comments

Comments
 (0)