build: combine build-pkgs*.sh into build.nu (#6231)
* build: combine build-pkgs* into build.nu Signed-off-by: pyranota <pyra@duck.com> * nit refactor Signed-off-by: pyranota <pyra@duck.com> --------- Signed-off-by: pyranota <pyra@duck.com>
This commit is contained in:
@@ -64,7 +64,7 @@ await build({
|
||||
"nu",
|
||||
"ts",
|
||||
"regex",
|
||||
"python",
|
||||
"py",
|
||||
"go",
|
||||
"php",
|
||||
"rust",
|
||||
|
||||
@@ -523,7 +523,7 @@ export async function inferSchema(
|
||||
let inferedSchema: any;
|
||||
if (language === "python3") {
|
||||
const { parse_python } = await import(
|
||||
"./wasm/python/windmill_parser_wasm.js"
|
||||
"./wasm/py/windmill_parser_wasm.js"
|
||||
);
|
||||
inferedSchema = JSON.parse(parse_python(content));
|
||||
} else if (language === "nativets") {
|
||||
|
||||
13
cli/test.nu
13
cli/test.nu
@@ -22,7 +22,7 @@ const languages = [
|
||||
"graphql",
|
||||
"bash",
|
||||
"powershell",
|
||||
# "php",
|
||||
"php",
|
||||
"rust",
|
||||
"csharp",
|
||||
"nu",
|
||||
@@ -37,29 +37,36 @@ def main [] {
|
||||
|
||||
def 'main test deno' [] {
|
||||
main clean;
|
||||
print $"Testing Deno"
|
||||
$languages | each { |l|
|
||||
print $"+ ($l)"
|
||||
deno run -A ../cli/main.ts script bootstrap $"f/tests/(random uuid)" $l
|
||||
}
|
||||
deno run -A ../cli/main.ts script generate-metadata
|
||||
print $"\nDeno has passed!\n"
|
||||
}
|
||||
|
||||
def 'main test node' [] {
|
||||
# TODO: Use node
|
||||
main clean;
|
||||
print $"Testing Node"
|
||||
$languages | each { |l|
|
||||
print $"+ ($l)"
|
||||
node ../cli/npm/esm/main.js script bootstrap $"f/tests/(random uuid)" $l
|
||||
}
|
||||
node ../cli/npm/esm/main.js script generate-metadata
|
||||
print $"\nNode has passed!\n"
|
||||
}
|
||||
|
||||
def 'main clean' [] {
|
||||
print $"Cleaning"
|
||||
rm -rf f/tests/*
|
||||
mkdir f/tests
|
||||
}
|
||||
|
||||
def 'main build' [] {
|
||||
../cli/build.sh
|
||||
print $"Building..."
|
||||
cd ../cli; ./build.sh
|
||||
cd ../local
|
||||
}
|
||||
|
||||
# def main [] {
|
||||
|
||||
4
cli/wasm/py/windmill_parser_wasm.d.ts
vendored
Normal file
4
cli/wasm/py/windmill_parser_wasm.d.ts
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export function parse_python(code: string, main_override?: string | null): string;
|
||||
export function parse_assets_py(code: string): string;
|
||||
147
cli/wasm/py/windmill_parser_wasm.js
Normal file
147
cli/wasm/py/windmill_parser_wasm.js
Normal file
@@ -0,0 +1,147 @@
|
||||
|
||||
|
||||
let WASM_VECTOR_LEN = 0;
|
||||
|
||||
let cachedUint8ArrayMemory0 = null;
|
||||
|
||||
function getUint8ArrayMemory0() {
|
||||
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
||||
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachedUint8ArrayMemory0;
|
||||
}
|
||||
|
||||
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
||||
|
||||
const encodeString = function (arg, view) {
|
||||
return cachedTextEncoder.encodeInto(arg, view);
|
||||
};
|
||||
|
||||
function passStringToWasm0(arg, malloc, realloc) {
|
||||
|
||||
if (realloc === undefined) {
|
||||
const buf = cachedTextEncoder.encode(arg);
|
||||
const ptr = malloc(buf.length, 1) >>> 0;
|
||||
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
||||
WASM_VECTOR_LEN = buf.length;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
let len = arg.length;
|
||||
let ptr = malloc(len, 1) >>> 0;
|
||||
|
||||
const mem = getUint8ArrayMemory0();
|
||||
|
||||
let offset = 0;
|
||||
|
||||
for (; offset < len; offset++) {
|
||||
const code = arg.charCodeAt(offset);
|
||||
if (code > 0x7F) break;
|
||||
mem[ptr + offset] = code;
|
||||
}
|
||||
|
||||
if (offset !== len) {
|
||||
if (offset !== 0) {
|
||||
arg = arg.slice(offset);
|
||||
}
|
||||
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
||||
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
||||
const ret = encodeString(arg, view);
|
||||
|
||||
offset += ret.written;
|
||||
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
||||
}
|
||||
|
||||
WASM_VECTOR_LEN = offset;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
function isLikeNone(x) {
|
||||
return x === undefined || x === null;
|
||||
}
|
||||
|
||||
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
||||
|
||||
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
||||
|
||||
function getStringFromWasm0(ptr, len) {
|
||||
ptr = ptr >>> 0;
|
||||
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
||||
}
|
||||
/**
|
||||
* @param {string} code
|
||||
* @param {string | null} [main_override]
|
||||
* @returns {string}
|
||||
*/
|
||||
export function parse_python(code, main_override) {
|
||||
let deferred3_0;
|
||||
let deferred3_1;
|
||||
try {
|
||||
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
var ptr1 = isLikeNone(main_override) ? 0 : passStringToWasm0(main_override, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
var len1 = WASM_VECTOR_LEN;
|
||||
const ret = wasm.parse_python(ptr0, len0, ptr1, len1);
|
||||
deferred3_0 = ret[0];
|
||||
deferred3_1 = ret[1];
|
||||
return getStringFromWasm0(ret[0], ret[1]);
|
||||
} finally {
|
||||
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} code
|
||||
* @returns {string}
|
||||
*/
|
||||
export function parse_assets_py(code) {
|
||||
let deferred2_0;
|
||||
let deferred2_1;
|
||||
try {
|
||||
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
const ret = wasm.parse_assets_py(ptr0, len0);
|
||||
deferred2_0 = ret[0];
|
||||
deferred2_1 = ret[1];
|
||||
return getStringFromWasm0(ret[0], ret[1]);
|
||||
} finally {
|
||||
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
const imports = {
|
||||
__wbindgen_placeholder__: {
|
||||
__wbindgen_init_externref_table: function() {
|
||||
const table = wasm.__wbindgen_export_0;
|
||||
const offset = table.grow(4);
|
||||
table.set(0, undefined);
|
||||
table.set(offset + 0, undefined);
|
||||
table.set(offset + 1, null);
|
||||
table.set(offset + 2, true);
|
||||
table.set(offset + 3, false);
|
||||
;
|
||||
},
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
const wasm_url = new URL('windmill_parser_wasm_bg.wasm', import.meta.url);
|
||||
let wasmCode = '';
|
||||
switch (wasm_url.protocol) {
|
||||
case 'file:':
|
||||
wasmCode = await Deno.readFile(wasm_url);
|
||||
break
|
||||
case 'https:':
|
||||
case 'http:':
|
||||
wasmCode = await (await fetch(wasm_url)).arrayBuffer();
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported protocol: ${wasm_url.protocol}`);
|
||||
}
|
||||
|
||||
const wasmInstance = (await WebAssembly.instantiate(wasmCode, imports)).instance;
|
||||
const wasm = wasmInstance.exports;
|
||||
export const __wasm = wasm;
|
||||
|
||||
wasm.__wbindgen_start();
|
||||
|
||||
BIN
cli/wasm/py/windmill_parser_wasm_bg.wasm
Normal file
BIN
cli/wasm/py/windmill_parser_wasm_bg.wasm
Normal file
Binary file not shown.
10
cli/wasm/py/windmill_parser_wasm_bg.wasm.d.ts
vendored
Normal file
10
cli/wasm/py/windmill_parser_wasm_bg.wasm.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const memory: WebAssembly.Memory;
|
||||
export const parse_python: (a: number, b: number, c: number, d: number) => [number, number];
|
||||
export const parse_assets_py: (a: number, b: number) => [number, number];
|
||||
export const __wbindgen_export_0: WebAssembly.Table;
|
||||
export const __wbindgen_malloc: (a: number, b: number) => number;
|
||||
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
||||
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
||||
export const __wbindgen_start: () => void;
|
||||
Reference in New Issue
Block a user