@helios-lang/contract-utils 0.1.38 → 0.1.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/hl2ts.js +20 -23
- package/types/hl2ts.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helios-lang/contract-utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.40",
|
|
4
4
|
"description": "Convenience and type-safety utilities for using Helios validators from within Typescript",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@helios-lang/compiler": "*"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@helios-lang/cli-utils": "^0.1.
|
|
38
|
+
"@helios-lang/cli-utils": "^0.1.3",
|
|
39
39
|
"@helios-lang/codec-utils": "^0.1.29",
|
|
40
40
|
"@helios-lang/compiler-utils": "^0.1.21",
|
|
41
41
|
"@helios-lang/ledger": "^0.1.44",
|
package/src/hl2ts.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import {
|
|
4
4
|
existsSync,
|
|
5
5
|
fstat,
|
|
6
|
+
mkdirSync,
|
|
6
7
|
promises,
|
|
7
8
|
readFileSync,
|
|
8
9
|
writeFileSync
|
|
@@ -32,8 +33,10 @@ import { None } from "@helios-lang/type-utils"
|
|
|
32
33
|
* @typedef {"javascript" | "typescript"} FormatKind
|
|
33
34
|
*/
|
|
34
35
|
|
|
36
|
+
const NAME = "hl2ts"
|
|
37
|
+
|
|
35
38
|
async function main() {
|
|
36
|
-
const cli = new Cli({
|
|
39
|
+
const cli = new Cli(NAME, {
|
|
37
40
|
minArgs: 0,
|
|
38
41
|
maxArgs: 0,
|
|
39
42
|
options: {
|
|
@@ -80,7 +83,7 @@ async function mainInternal(_args, { outDir, format }) {
|
|
|
80
83
|
const filePaths = await listFiles(process.cwd(), ".hl")
|
|
81
84
|
const files = readFiles(filePaths)
|
|
82
85
|
|
|
83
|
-
console.log(
|
|
86
|
+
console.log(`${NAME} using Helios compiler v${lib.version}`)
|
|
84
87
|
console.log(` Transpiling ${Object.keys(files).length} inputs:`)
|
|
85
88
|
filePaths.forEach((p) => console.log(` ${p}`))
|
|
86
89
|
|
|
@@ -101,8 +104,12 @@ async function mainInternal(_args, { outDir, format }) {
|
|
|
101
104
|
console.log(` Output:`)
|
|
102
105
|
console.log(` ${tsPath}`)
|
|
103
106
|
} else {
|
|
104
|
-
const
|
|
105
|
-
|
|
107
|
+
const resolvedOutDir = resolve(outDir)
|
|
108
|
+
|
|
109
|
+
mkdirIfNotExists(resolvedOutDir)
|
|
110
|
+
|
|
111
|
+
const jsPath = join(resolvedOutDir, "index.js")
|
|
112
|
+
const dtsPath = join(resolvedOutDir, "index.d.ts")
|
|
106
113
|
|
|
107
114
|
writeFileSync(jsPath, js)
|
|
108
115
|
writeFileSync(dtsPath, dts)
|
|
@@ -115,25 +122,6 @@ async function mainInternal(_args, { outDir, format }) {
|
|
|
115
122
|
|
|
116
123
|
main()
|
|
117
124
|
|
|
118
|
-
/**
|
|
119
|
-
* @param {string[]} args
|
|
120
|
-
* @returns {{outDir: string, isTypescript: boolean}}
|
|
121
|
-
*/
|
|
122
|
-
function parseArgs(args) {
|
|
123
|
-
const isTypescript = args.indexOf("--ts") != -1
|
|
124
|
-
|
|
125
|
-
let i = args.indexOf("-o")
|
|
126
|
-
if (i != -1) {
|
|
127
|
-
if (i == args.length - 1 || args[i + 1].startsWith("-")) {
|
|
128
|
-
throw new Error("expected argument after -o")
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return { outDir: resolve(args[i + 1]), isTypescript }
|
|
132
|
-
} else {
|
|
133
|
-
return { outDir: process.cwd(), isTypescript }
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
125
|
/**
|
|
138
126
|
* @param {string} dir
|
|
139
127
|
* @param {string} ext
|
|
@@ -195,3 +183,12 @@ function findPackageJson(fileName = "package.json") {
|
|
|
195
183
|
return None
|
|
196
184
|
}
|
|
197
185
|
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* @param {string} dir
|
|
189
|
+
*/
|
|
190
|
+
function mkdirIfNotExists(dir) {
|
|
191
|
+
if (!existsSync(dir)) {
|
|
192
|
+
mkdirSync(dir, { recursive: true })
|
|
193
|
+
}
|
|
194
|
+
}
|
package/types/hl2ts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hl2ts.d.ts","sourceRoot":"","sources":["../src/hl2ts.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"hl2ts.d.ts","sourceRoot":"","sources":["../src/hl2ts.js"],"names":[],"mappings":";0BAkBa,OAAO,2BAA2B,EAAE,WAAW;4BAC/C,OAAO,2BAA2B,EAAE,iBAAiB;+BACrD,OAAO,2BAA2B,EAAE,oBAAoB;4BAIxD;IACZ,MAAU,MAAM,CAAA;IAChB,OAAW,EAAE,MAAM,CAAA;IACnB,UAAc,EAAE,MAAM,CAAA;CACnB;yBAIS,YAAY,GAAG,YAAY"}
|