Skip to content

Commit

Permalink
feat: ✨readme script (#5)
Browse files Browse the repository at this point in the history
* feat: ✨ placeholder support for token snippets

* feat: 🧑‍💻 add readme script

* feat: 🧑‍💻 add husky pre commit git hook

* docs: 📝 generate README.md

* 📝 update README.md

* fix: 🐛 fix bugs in the husky git hook

Co-authored-by: Avneesh Agarwal <avneeshagarwal0612@gmail.com>

* docs: update README.md📝

Co-authored-by: Avneesh Agarwal <avneeshagarwal0612@gmail.com>
  • Loading branch information
0xMukesh and avneesh0612 authored Mar 13, 2022
1 parent 5d89721 commit 97d005b
Show file tree
Hide file tree
Showing 13 changed files with 232 additions and 33 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = crlf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn pre-commit
16 changes: 3 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
# [0.3.0](https://github.com/avneesh0612/thirdweb-snippets/compare/v0.2.0...v0.3.0) (2022-03-13)


### Features

* ✨ add vote collection snippets ([#4](https://github.com/avneesh0612/thirdweb-snippets/issues/4)) ([6fee031](https://github.com/avneesh0612/thirdweb-snippets/commit/6fee031536952bfeae70821c7b5cff9ac6b33aa0))


- ✨ add vote collection snippets ([#4](https://github.com/avneesh0612/thirdweb-snippets/issues/4)) ([6fee031](https://github.com/avneesh0612/thirdweb-snippets/commit/6fee031536952bfeae70821c7b5cff9ac6b33aa0))

# [0.2.0](https://github.com/avneesh0612/thirdweb-snippets/compare/v0.1.0...v0.2.0) (2022-03-13)


### Features

* :sparkles: placeholder support for token snippets ([#2](https://github.com/avneesh0612/thirdweb-snippets/issues/2)) ([87ab37e](https://github.com/avneesh0612/thirdweb-snippets/commit/87ab37e8004d68944365625d7d44a26660c98c8f))


- :sparkles: placeholder support for token snippets ([#2](https://github.com/avneesh0612/thirdweb-snippets/issues/2)) ([87ab37e](https://github.com/avneesh0612/thirdweb-snippets/commit/87ab37e8004d68944365625d7d44a26660c98c8f))

# [0.1.0](https://github.com/avneesh0612/thirdweb-snippets/compare/fda702381fe0aaab3a6df6279d922379a66cd3b6...v0.1.0) (2022-03-13)


### Features

* :sparkles: placeholder support for nft snippets ([#1](https://github.com/avneesh0612/thirdweb-snippets/issues/1)) ([fda7023](https://github.com/avneesh0612/thirdweb-snippets/commit/fda702381fe0aaab3a6df6279d922379a66cd3b6))



- :sparkles: placeholder support for nft snippets ([#1](https://github.com/avneesh0612/thirdweb-snippets/issues/1)) ([fda7023](https://github.com/avneesh0612/thirdweb-snippets/commit/fda702381fe0aaab3a6df6279d922379a66cd3b6))
96 changes: 96 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# thirdweb-snippets

Thirdweb snippets for enhancing your the developer experience while working with thirdweb 🚀!

## Usage

| Prefix | Description | Module |
| --------------------------- | ------------------------------------------------------------------------------------------- | ------------------------ |
| `initModule` | Initialize the bundle module | Bundle Collection module |
| `initSupply` | Get initial supply for a token | Bundle Collection module |
| `initSupplyAddr` | Get initial supply for a token for an address | Bundle Collection module |
| `burnNFT` | Burn NFT by Token ID and amount to burn | Bundle Collection module |
| `burnNFTs` | Burn a Batch of NFTs | Bundle Collection module |
| `burnNFTsAddr` | Burn a Batch of NFTs from an address | Bundle Collection module |
| `burnNFTAddr` | Burn a NFT from an address | Bundle Collection module |
| `createNFT` | Create NFT | Bundle Collection module |
| `createMintNFT` | Create and Mint NFT | Bundle Collection module |
| `createMintNFTs` | Create and Mint a batch of NFTs | Bundle Collection module |
| `createNFTs` | Create a batch of NFTs | Bundle Collection module |
| `createERC-20` | Create with ERC-20 | Bundle Collection module |
| `createERC-721` | Create with ERC-721 | Bundle Collection module |
| `createNFT` | Create with NFT | Bundle Collection module |
| `createTOKEN` | Create with Token | Bundle Collection module |
| `getNFTToken` | Get NFT by token ID | Bundle Collection module |
| `getAllNFTs` | Get All NFTs | Bundle Collection module |
| `getAllNFTsOwned` | Get All NFTs Owned | Bundle Collection module |
| `getRoyaltyPoints` | Get royalty basic Points | Bundle Collection module |
| `getRoyaltyAddr` | Get royalty recipient address | Bundle Collection module |
| `checkIfApproved` | Check if a smart contract is approved to spend on your behalf | Bundle Collection module |
| `checkIfRes` | Check if transfer is Restricted | Bundle Collection module |
| `specifySupply` | Specify supply for a NFT | Bundle Collection module |
| `specifySupplyNFTs` | Specify supply for a Batch of NFTs | Bundle Collection module |
| `specifySupplyNFTsSend` | Specify supply for a Batch of NFTs and send it to an Address | Bundle Collection module |
| `specifySupplyNFTSend` | Specify supply for a NFT and send it to an Address | Bundle Collection module |
| `setApprovalContract` | Set approval for a contract | Bundle Collection module |
| `setMetadata` | Set metadata for the module | Bundle Collection module |
| `setRestrictionTransfer` | Set restriction on transfer | Bundle Collection module |
| `setRoyaltyPoints` | Set royalty basic points | Bundle Collection module |
| `transferToken` | Transfer token to address | Bundle Collection module |
| `transferNFTAddr` | Transfer a specific amount of NFT from an address | Bundle Collection module |
| `unwrapNFT` | Unwrap a NFT | Bundle Collection module |
| `mintNft` | Mint an NFT to your wallet | Nft Collection module |
| `mintNftTo` | Mint an NFT to someone's wallet | Nft Collection module |
| `nftBalance` | Get balance of NFTs of a collection | Nft Collection module |
| `nftBalanceOf` | Get NFT balance of another account | Nft Collection module |
| `burnNft` | Burn an NFT with Token ID | Nft Collection module |
| `genNftSign` | Generate NFT signature for a Mint request | Nft Collection module |
| `getNftbyId` | Get a NFT by it's ID | Nft Collection module |
| `getAllNft` | Get all NFTs of a collection | Nft Collection module |
| `getNftsWithOwner` | Get all NFTs of a collection owned by the owner | Nft Collection module |
| `getNftsWithAddress` | Get all NFTs of a collection owned by a specific address | Nft Collection module |
| `mintNftBatch` | Mint multiple NFTs in a single batch | Nft Collection module |
| `mintNftBatchTo` | Mint multiple NFTs in a single batch to a specific address | Nft Collection module |
| `getNftOwner` | Get the owner of a NFT | Nft Collection module |
| `getNftTotalSupply` | Get the total supply of a NFT collection | Nft Collection module |
| `transferNft` | Transfer an NFT to a specific address | Nft Collection module |
| `tokenBalance` | Get the balance of a token | Token module |
| `tokenBalanceOf` | Get the balance of a token for a specific address | Token module |
| `tokenBurn` | Burn tokens owned by the owner | Token module |
| `tokenBurnFrom` | Burn tokens owned by a specific address | Token module |
| `tokenGet` | Get details about a token module | Token module |
| `tokenGetAllHolderBalances` | Get all the balances of all holders | Token module |
| `tokenGetDelegation` | Get the delegation of a token | Token module |
| `tokenGetDelegationOf` | Get the delegation of a token for a specific address | Token module |
| `tokenGetValue` | Get the value for the specified amount of a token | Token module |
| `getVoteBalance` | Get information of the vote balance for yourself | Token module |
| `getVoteBalanceOf` | Get information about the vote balance for the specified address | Token module |
| `tokenMint` | Mint specific amount of tokens | Token module |
| `tokenMintBatchTo` | Mint specific amount of tokens to multiple addresses in a batch | Token module |
| `tokenMintTo` | Mint specific amount of tokens to a specific address | Token module |
| `tokenTotalSupply` | Get the total supply of a token module | Token module |
| `tokenTransfer` | Transfer specific amount of tokens to a specific address | Token module |
| `tokenTransferBatch` | Transfer specific amounts of tokens to multiple addresses in a batch | Token module |
| `tokenTransferFrom` | Transfer specific amount of tokens from an address to another address | Token module |
| `tokenTransferFromBatch` | Transfer specific amounts of tokens from multiple addresses to another addresses in a batch | Token module |
| `initVote` | Initialize the Vote module | Vote Collection module |
| `getBalanceChain` | Get the balance of the project wallet in the native token of the chain | Vote Collection module |
| `getBalanceERC20` | Get the balance of the project wallet in a particular ERC20 token contract | Vote Collection module |
| `canExecute` | Can execute a proposal | Vote Collection module |
| `executeProposal` | Execute a Proposal | Vote Collection module |
| `getProposal` | Get proposal by Proposal Id | Vote Collection module |
| `getProposals` | Get all the Proposals | Vote Collection module |
| `checkProposalAccStatus` | Check if an account has voted for a proposal | Vote Collection module |
| `createProposal` | Create a Proposal | Vote Collection module |
| `setMetadataModule` | Set metadata for the module | Vote Collection module |
| `getSettings` | Get the settings | Vote Collection module |
| `voteProposal` | Vote for a proposal | Vote Collection module |

## Show your support

Give a ⭐️ if this project helped you!

## 📝 License

Copyright © 2022 [Avneesh Agarwal](https://github.com/avneesh0612).<br />
This project is [GNU](https://github.com/avneesh0612/thirdweb-snippets/blob/main/LICENSE) licensed.
6 changes: 6 additions & 0 deletions data/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const constants = {
snippetsFolder: "snippets",
readmeFile: "README.md",
};

export default constants;
20 changes: 20 additions & 0 deletions data/readmeConstants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const readmeTop = `# thirdweb-snippets
Thirdweb snippets for enhancing your the developer experience while working with thirdweb 🚀!
## Usage
`;

const readmeBottom = `
## Show your support
Give a ⭐️ if this project helped you!
## 📝 License
Copyright © 2022 [Avneesh Agarwal](https://github.com/avneesh0612).<br />
This project is [GNU](https://github.com/avneesh0612/thirdweb-snippets/blob/main/LICENSE) licensed.
`;
export { readmeTop, readmeBottom };
14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "thirdweb-snippets",
"displayName": "Thirdweb Snippets",
"description": "This is an extension for Thirdweb Snippets with Typescript support as well!",
"version": "0.3.0",
"version": "0.1.0",
"type": "module",
"publisher": "AvneeshAgarwal",
"repository": {
"url": "https://github.com/avneesh0612/thirdweb-snippets"
Expand All @@ -15,7 +16,9 @@
"release:minor": "standard-version --release-as minor",
"release:patch": "standard-version --release-as patch",
"release:major": "standard-version --release-as major",
"format": "prettier --write '**/*.{ts,json,md,js}'"
"format": "prettier --write .",
"genReadme": "node scripts/generateReadme.js",
"pre-commit": "yarn genReadme && yarn format && git add -A ."
},
"categories": [
"Snippets"
Expand All @@ -40,8 +43,11 @@
}
]
},
"dependencies": {},
"dependencies": {
"markdown-table": "^3.0.2"
},
"devDependencies": {
"husky": "^7.0.4",
"prettier": "^2.5.1"
}
}
}
50 changes: 50 additions & 0 deletions scripts/generateReadme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import fs from "fs";
import { markdownTable } from "markdown-table";

import convertFileName from "../utils/convertFileName.js";
import { readmeTop, readmeBottom } from "../data/readmeConstants.js";
import constants from "../data/constants.js";

let finalSnippets = [["Prefix", "Description", "Module"]];

fs.readdir(constants["snippetsFolder"], function (err, files) {
files.map((file) => {
// Reading the files in the snippet folder and getting the JSON file
fs.readFile(
`${constants["snippetsFolder"]}/${file}`,
"utf8",
function (err, data) {
const actualData = JSON.parse(data);
// Converting the object to an array
const snippetArray = Object.keys(actualData).map(
(key) => actualData[key]
);
// Adding the snippet to the final array
snippetArray.map((snippet) => {
finalSnippets.push([
`\`${snippet.prefix}\``,
snippet.description,
`${convertFileName(file)} module`,
]);
});
// Generating a markdown table
let snippetTable = markdownTable(finalSnippets);
const snippetDocs = readmeTop + snippetTable + "\n" + readmeBottom;
// Clearing all the content in the README.md file before adding new content
fs.writeFile(constants["readmeFile"], "", function (err) {
if (err) {
console.log(err);
}
});
// Adding the new content to the README.md file
fs.writeFile(constants["readmeFile"], snippetDocs, function (err) {
if (err) {
console.log(err);
}
});
}
);
});
});

// wait duh
7 changes: 0 additions & 7 deletions scripts/readme.js

This file was deleted.

Loading

0 comments on commit 97d005b

Please sign in to comment.