Skip to content

Commit

Permalink
feat: export libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
0xShaito committed Aug 8, 2024
1 parent f4db6ae commit 0184048
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Solidity Exporter Action automates the process of extracting TypeScript interfac
| out | path to the `out` folder containing the compiled contracts | out | |
| interfaces | path to the interfaces directory | src/interfaces | |
| contracts | path to the contracts directory | src/contracts | |
| libraries | path to the libraries directory | src/libs | |
| export_type | `interface` for exporting only the interfaces and their ABIs, `contracts` for exporting the contracts, interfaces and their ABIs as well | interfaces | interfaces, contracts |

## Action Outputs
Expand Down Expand Up @@ -71,6 +72,7 @@ jobs:
out: 'out'
interfaces: 'solidity/interfaces'
contracts: 'solidity/contracts'
libs: 'solidity/libs'
export_type: '${{ matrix.export_type }}'

- name: Publish
Expand Down
11 changes: 7 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions src/createPackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const createPackage = (
outDir: string,
interfacesDir: string,
contractsDir: string,
libDir: string,
packageName: string,
exportType: ExportType,
) => {
Expand All @@ -35,8 +36,11 @@ export const createPackage = (
// Copy the interfaces and their ABIs
copySolidityFiles(outDir, interfacesDir, destinationDir);

// Copy the contracts only if the export type is contracts
if (exportType === ExportType.CONTRACTS) copySolidityFiles(outDir, contractsDir, destinationDir);
// Copy the contracts and libraries only if the export type is contracts
if (exportType === ExportType.CONTRACTS) {
copySolidityFiles(outDir, contractsDir, destinationDir);
copySolidityFiles(outDir, libDir, destinationDir);
}

createReadmeAndLicense(packageJson.name, exportType, destinationDir);
console.log(`Created README and LICENSE`);
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ async function run(): Promise<void> {
const outDir = core.getInput('out');
const interfacesDir = core.getInput('interfaces');
const contractsDir = core.getInput('contracts') || '';
const libsDir = core.getInput('libs') || '';
const exportType = core.getInput('export_type') as ExportType;

if (!Object.values(ExportType).includes(exportType)) {
throw new Error(`Invalid input for export_type. Valid inputs are: ${Object.values(ExportType).join(', ')}`);
}

core.debug(`Creating package`);
createPackage(outDir, interfacesDir, contractsDir, packageName, exportType);
createPackage(outDir, interfacesDir, contractsDir, libsDir, packageName, exportType);
core.setOutput('passed', true);
} catch (e) {
const error = e as Error;
Expand Down

0 comments on commit 0184048

Please sign in to comment.