for commonjs && fixes

Signed-off-by: Daniel Maricic's avatarDaniel Maricic <[email protected]>
parent 7e6b9806
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"module": "commonjs",
"declaration": true,
"strict": true,
"noImplicitAny": false,
......@@ -28,6 +28,7 @@
"resolveJsonModule": true,
"isolatedModules": true,
"types": ["node"],
"forceConsistentCasingInFileNames": true
"forceConsistentCasingInFileNames": true,
"typeRoots": ["./node_modules/@types"]
}
}
......@@ -19,6 +19,13 @@
"standardx": "5.0.0",
"typescript": "^3.9.3"
},
"dependencies": {
"@polkadot/util": "^2.10.1",
"cids": "^0.8.0",
"exifreader": "^3.11.2",
"imghash": "^0.0.7",
"multihashing-async": "^0.8.1"
},
"standardx": {
"parser": "@typescript-eslint/parser",
"plugins": [
......
......@@ -7,7 +7,7 @@
"license": "MIT",
"private": true,
"scripts": {
"generate": "ts-node ./scripts/gen --package .",
"generate": "ts-node ./scripts/gen.ts",
"clean": "rm -rf src/operations/*"
},
"devDependencies": {
......@@ -15,8 +15,5 @@
"ts-node": "^8.10.1",
"ts-node-dev": "^1.0.0-pre.44",
"typescript": "^3.9.3"
},
"dependencies": {
"exifreader": "^3.11.2"
}
}
import * as fs from 'fs';
import * as path from 'path';
import * as util from '@polkadot/util';
import { hexToString, stringCamelCase } from '@polkadot/util';
import { existsSync, mkdirSync, writeFileSync } from 'fs';
import { resolve } from 'path';
import ops from './ops.json';
function genOpFiles(): void {
......@@ -14,7 +14,7 @@ function genOpFiles(): void {
encoding: { algo: encAlgo, prefix },
},
}) => {
const opName = util.stringCamelCase(util.hexToString(op));
const opName = stringCamelCase(hexToString(op));
const defaultOperation = `
/**
......@@ -23,15 +23,15 @@ function genOpFiles(): void {
export default {
id: '${id}',
data: {
op: '${util.hexToString(op)}',
desc: '${util.hexToString(desc)}',
op: '${hexToString(op)}',
desc: '${hexToString(desc)}',
hashing: {
algo: '${util.hexToString(hashing.algo)}',
algo: '${hexToString(hashing.algo)}',
bits: ${hashing.bits},
skip: ${hashing.skip},
},
encoding: {
algo: '${util.hexToString(encAlgo)}',
algo: '${hexToString(encAlgo)}',
prefix: ${prefix},
},
ops: [],
......@@ -52,19 +52,19 @@ export default async function ${opName}(params): Promise<string> {
}`;
// create new structure
const indexPath = path.resolve(
const indexPath = resolve(
__dirname,
`../src/operations/${opName}/index.ts`,
);
const configPath = path.resolve(
const configPath = resolve(
__dirname,
`../src/operations/${opName}/config.ts`,
);
if (!fs.existsSync(indexPath)) {
fs.mkdirSync(path.resolve(__dirname, `../src/operations/${opName}`));
fs.writeFileSync(configPath, defaultOperation.trim() + '\n');
fs.writeFileSync(indexPath, mainFuncBodyTpl.trim() + '\n');
if (!existsSync(indexPath)) {
mkdirSync(resolve(__dirname, `../src/operations/${opName}`));
writeFileSync(configPath, defaultOperation.trim() + '\n');
writeFileSync(indexPath, mainFuncBodyTpl.trim() + '\n');
}
},
);
......
This diff is collapsed.
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "dist"
"outDir": "dist",
"typeRoots": ["./node_modules/@types", "./typed"]
},
"include": ["scripts"]
"include": ["src", "scripts"]
}
......@@ -162,6 +162,13 @@
dependencies:
regenerator-runtime "^0.13.4"
"@babel/[email protected]^7.9.6":
version "7.9.6"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.9.6.tgz#a9102eb5cadedf3f31d08a9ecf294af7827ea29f"
integrity sha512-64AF1xY3OAkFHqOb9s4jpgk1Mm5vDZ4L3acHvAml+53nO1XbXLuDodsVpO4OIUsmemlUHMxNdYMNJmsvOwLrvQ==
dependencies:
regenerator-runtime "^0.13.4"
"@babel/[email protected]^7.8.3", "@babel/[email protected]^7.8.6":
version "7.8.6"
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.8.6.tgz#86b22af15f828dfb086474f964dcc3e39c43ce2b"
......@@ -1280,6 +1287,18 @@
chalk "^4.0.0"
ip-regex "^4.1.0"
"@polkadot/[email protected]^2.10.1":
version "2.10.1"
resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-2.10.1.tgz#981e19327b49532c8b8d2f2d18e23c3548cbe969"
integrity sha512-DaIvvx3zphDlf3ZywLnlrRTngcjGIl7Dn3lbwsgHlMSyENz07TG6YG+ztr0ztUrb9BqFKAeH6XGNtGPBp0LxwA==
dependencies:
"@babel/runtime" "^7.9.6"
"@types/bn.js" "^4.11.6"
bn.js "^5.1.1"
camelcase "^5.3.1"
chalk "^4.0.0"
ip-regex "^4.1.0"
"@polkadot/[email protected]^1.2.1":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@polkadot/wasm-crypto/-/wasm-crypto-1.2.1.tgz#2189702447acd28d763886359576c87562241767"
......@@ -3710,6 +3729,14 @@ [email protected]^0.0.6:
"@canvas/image" "^1.0.0"
blockhash-core "^0.1.0"
[email protected]^0.0.7:
version "0.0.7"
resolved "https://registry.yarnpkg.com/imghash/-/imghash-0.0.7.tgz#1cce8b2edc0e64aa4b00fc0abbca73b195ecd954"
integrity sha512-9GrMYyHA9GFTpGdptdxq/u726v7UwWPVfkg5Wt0gTQb5OoqjzIxr65T80OBanOYTOllAb7TTNnCPh9/oWeRPOA==
dependencies:
"@canvas/image" "^1.0.0"
blockhash-core "^0.1.0"
[email protected]^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-2.0.0.tgz#d81355c15612d386c61f9ddd3922d4304822a546"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment