anchor-idl-converter
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "anchor-idl-converter", | ||
"description": "Converter for Anchor IDL, convert your IDL from anchor new version to old version", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"keywords": [ | ||
@@ -30,2 +30,5 @@ "anchor", | ||
], | ||
"bin": { | ||
"anchor-idl-converter": "src/bin.ts" | ||
}, | ||
"homepage": "https://github.com/viandwi24/anchor-idl-converter", | ||
@@ -32,0 +35,0 @@ "license": "ISC", |
@@ -1,30 +0,8 @@ | ||
import path from 'path' | ||
import fs from 'fs' | ||
import { Command } from 'commander' | ||
import { convertTypes1ToTypes2 } from './lib' | ||
export * from './lib' | ||
export { | ||
convertSnakeCaseToCamelCase, | ||
convertType, | ||
anchorIDLConvertNewToOld, | ||
} from './lib' | ||
const program = new Command() | ||
.version('0.0.1') | ||
.description('converter anchor idl') | ||
program.command('to-old') | ||
.requiredOption('-i, --input <path>', 'Input file path') | ||
.requiredOption('-o, --output <path>', 'Output file path') | ||
.action((options) => { | ||
try { | ||
const cwd = process.cwd() | ||
const inputPath = path.resolve(cwd, options.input) | ||
const outputPath = path.resolve(cwd, options.output) | ||
const data = JSON.parse(fs.readFileSync(inputPath, 'utf8')) | ||
// convert | ||
const convertedIDL = convertTypes1ToTypes2(data) | ||
fs.writeFileSync(outputPath, JSON.stringify(convertedIDL, null, 2)) | ||
console.log(`converted types written to: ${outputPath}`) | ||
} catch (error) { | ||
console.error(`error when converting: ${error}`) | ||
} | ||
}) | ||
program.parse(process.argv) | ||
export { type Root as AnchorIDLNew } from './types/anchor_new' | ||
export { type Root as AnchorIDLOld } from './types/anchor_old' |
@@ -61,3 +61,3 @@ import fs from 'fs' | ||
} | ||
export function convertTypes1ToTypes2(data: any): any { | ||
export function anchorIDLConvertNewToOld(data: any): any { | ||
return { | ||
@@ -64,0 +64,0 @@ version: data.metadata.version, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8620
8
258