Socket
Socket
Sign inDemoInstall

vercel-deno-dev

Package Overview
Dependencies
25
Maintainers
1
Versions
191
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0-152e59bd0aa0083be60c91ff6cca282d02d03492 to 0.1.0-17a50a519db6a1ff62f38a12958285e04e866dbd

dist/boot/dev.runtime.ts

33

dist/boot/runtime.ts

@@ -52,2 +52,5 @@ import * as base64 from 'https://deno.land/x/base64/mod.ts';

const output = new Deno.Buffer();
output.grow(33554432); // Initialize memory size to 2^25 ~~ 33.5 MB
// Default buffer size: 4096 Bytes.
const req:NowRequest = new ServerRequest();

@@ -59,5 +62,5 @@ req.r = new BufReader(input);

req.url = data.path;
req.proto = 'HTTP/1.1';
req.protoMinor = 1;
req.protoMajor = 1;
req.proto = 'HTTP/2.0';
req.protoMinor = 0;
req.protoMajor = 2;

@@ -89,11 +92,10 @@ for (const [name, value] of Object.entries(data.headers)) {

// The actual output is raw HTTP message,
// so we will parse it
// - Headers ( statuscode default to 200 )
// - Message
const bufr = new BufReader(output);
// TODO: dynamically determine buffer size.
// output.length has a mismatch size of a few hundret bytes compared to boy.bytlength.
// not including size argument will make bufReader use default size 4096 Bytes.
// console.log({outlen:output.length})
const bufr = new BufReader(output,output.length);
const tp = new TextProtoReader(bufr);
const firstLine = await tp.readLine() || 'HTTP/1.1 200 OK'; // e.g. "HTTP/1.1 200 OK"
const firstLine = await tp.readLine() || 'HTTP/2.0 200 OK'; // e.g. "HTTP/1.1 200 OK"
const statuscode = res ? res.status || 200 : parseInt(firstLine.split(' ', 2)[1], 10); // get statuscode either from res or req.

@@ -106,5 +108,10 @@ const headers = await tp.readMIMEHeader() || new Headers();

const body = await bufr.readFull(new Uint8Array(bufr.buffered()));
let buff = new Uint8Array(bufr.size());
const size = await bufr.read(buff)||bufr.size();
const body = buff.slice(0,size);
if (!body) throw new Deno.errors.UnexpectedEof();
// console.log({
// outlen:output.length,
// bodylen:body.byteLength,
// })
await req.finalize();

@@ -128,3 +135,3 @@

console.log("invoke Response")
console.log({result,context})
console.log({result})
const res = await LambdaFetch(`invocation/${context.awsRequestId}/response`, {

@@ -131,0 +138,0 @@ method: 'POST',

@@ -8,3 +8,2 @@ "use strict";

const fs_extra_1 = __importDefault(require("fs-extra"));
const path_1 = __importDefault(require("path"));
const util_1 = require("./util");

@@ -15,16 +14,14 @@ async function build(opts) {

console.log("downloading source files");
const downloadedFiles = await build_utils_1.download(files, path_1.default.join(workPath, "src"), meta);
const downloadedFiles = await build_utils_1.download(files, workPath, meta);
// configure environment variable
const denoFiles = await util_1.getdenoFiles(meta.isDev || false);
const denoFiles = await util_1.getdenoFiles(workPath, meta.isDev || false);
const bootFiles = await util_1.getbootFiles(workPath);
await util_1.CacheEntryPoint(opts, downloadedFiles, bootFiles, denoFiles);
const cacheFiles = await util_1.CacheEntryPoint(opts, downloadedFiles, denoFiles, bootFiles);
// console.log({downloadedFiles, denoFiles,bootFiles,genFiles})
// Files directory:
// - /tmp/
// - .deno
// - /deps
// - /gen
// - /bin/deno
// - *.d.ts
// - src
// - .deno
// - /deps
// - /gen
// - /bin/deno
// - *.d.ts
// - bootstrap

@@ -37,3 +34,5 @@ // - runtime.ts

...downloadedFiles,
...cacheFiles,
...bootFiles,
...denoFiles
},

@@ -40,0 +39,0 @@ environment: {

@@ -11,3 +11,2 @@ "use strict";

const execa_1 = __importDefault(require("execa"));
const denotmpPath = '/tmp/';
function parseDenoVersion(version) {

@@ -25,3 +24,3 @@ if (version === "latest")

exports.parseDenoVersion = parseDenoVersion;
async function getdenoFiles(isdev) {
async function getdenoFiles(workPath, isDev) {
console.log("get deno binary files");

@@ -33,11 +32,16 @@ const DENO_LATEST = "latest";

: `https://github.com/denoland/deno/releases/download/v${DENO_VERSION}/deno-x86_64-unknown-linux-gnu.zip`;
const denobinDir = path_1.join(denotmpPath, '.deno/bin/');
const denobinDir = path_1.join(workPath, '.deno/bin/');
const denozipPath = path_1.join(denobinDir, 'deno.zip');
let denoPath = path_1.join(denobinDir, 'deno');
const denolocalBin = async () => {
let bin = await execa_1.default('command', ['-v', 'deno']);
return bin.stdout;
};
if (!isdev && !(await denolocalBin())) {
let denoPath = '';
// check if local deno binary exists
if (isDev) {
try {
const checklocalDeno = await execa_1.default('which', ['deno'], { stderr: 'ignore' });
denoPath = checklocalDeno.stdout;
}
catch (e) { }
;
}
if (!denoPath) {
try {
console.log(`downloading deno ${DENO_VERSION}`);

@@ -52,2 +56,3 @@ await execa_1.default("curl", ['--location', '--create-dirs', '--output', denozipPath, DOWNLOAD_URL], { stdio: 'pipe' });

await execa_1.default("rm", [denozipPath], { stdio: 'pipe' });
denoPath = path_1.join(denobinDir, 'deno');
}

@@ -59,9 +64,6 @@ catch (err) {

}
else {
// assume it is dev build
else
console.log('using local deno binary');
denoPath = await denolocalBin();
}
return {
"deno": new dist_1.FileFsRef({
".deno/bin/deno": new dist_1.FileFsRef({
mode: 0o755,

@@ -76,6 +78,4 @@ fsPath: denoPath,

const bootstrapPath = path_1.join(__dirname, "../boot/bootstrap");
let globrunfiles = await dist_1.glob("**/*.ts", { cwd: path_1.join(__dirname, '../boot') }, "boot");
// we need to move boot library to the work directory so that
// we can cache the runtime on the same working directory.
let runtimeFiles = await dist_1.download(globrunfiles, path_1.join(workPath, 'boot'));
const runtimeGlobs = await dist_1.glob("boot/*.ts", { cwd: path_1.join(__dirname, "../") });
const runtimeFiles = await dist_1.download(runtimeGlobs, workPath);
return {

@@ -93,3 +93,3 @@ ...runtimeFiles,

*/
async function CacheEntryPoint(opts, downloadedFiles, bootFiles, denoFiles) {
async function CacheEntryPoint(opts, downloadedFiles, denoFiles, bootFiles) {
console.log(`Caching imports for ${opts.entrypoint}`);

@@ -99,4 +99,4 @@ // TODO: create separate function to parse user ENV values

const { workPath, entrypoint } = opts;
const denobinPath = '.deno/bin/deno';
const runtimePath = 'boot/runtime.ts';
const denobinPath = 'deno';
const denobin = denoFiles[denobinPath].fsPath;

@@ -106,4 +106,4 @@ const runtime = bootFiles[runtimePath].fsPath;

if (denobin && runtime) {
await execa_1.default(denobin, ['cache', ...tsconfig, entry, runtime], {
env: { DENO_DIR: path_1.join(denotmpPath, '.deno/') },
await execa_1.default(denobin, ['cache', ...tsconfig, runtime, entry], {
env: { DENO_DIR: path_1.join(workPath, '.deno/') },
stdio: 'ignore',

@@ -115,3 +115,3 @@ });

const workPathUri = `file://${workPath}`;
for await (const file of getGraphFiles(path_1.join(denotmpPath, '.deno/gen/file'))) {
for await (const file of getGraphFiles(path_1.join(workPath, '.deno/gen/file'))) {
let needsWrite = false;

@@ -122,3 +122,3 @@ const graph = JSON.parse(await fs_extra_1.readFile(file, 'utf8'));

if (dep.startsWith(workPathUri)) {
const updated = `file:///var/task${dep.substring(workPathUri.length)}`;
const updated = `file:///var/task/${dep.substring(workPathUri.length)}`;
graph.deps[i] = updated;

@@ -134,6 +134,6 @@ needsWrite = true;

// move generated files to AWS path /var/task
const cwd = path_1.join(denotmpPath, '.deno', 'gen', 'file', workPath);
const aws_task = path_1.join(denotmpPath, '.deno', 'gen', 'file', 'var', 'task');
const cwd = path_1.join(workPath, '.deno', 'gen', 'file', workPath);
const aws_task = path_1.join(workPath, '.deno', 'gen', 'file', 'var', 'task');
await fs_extra_1.move(cwd, aws_task, { overwrite: true });
//return await glob("**/**",{cwd:join(workPath,'.deno'),ignore:['bin/**']}, '.deno');
return await dist_1.glob(".deno/**", workPath);
}

@@ -140,0 +140,0 @@ exports.CacheEntryPoint = CacheEntryPoint;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//import { spawn } from 'child_process';
/// unused.
function prepareCache({ files, entrypoint }) {

@@ -13,11 +13,3 @@ console.log("Execute caching for deno");

console.log({ deno, entry, env });
// if (deno && entry) {
// const ls = spawn(deno,['cache',entry],
// {
// env
// })
// }
// execute caching
// TODO: add cache here
}
exports.default = prepareCache;
{
"name": "vercel-deno-dev",
"version": "0.1.0-152e59bd0aa0083be60c91ff6cca282d02d03492",
"version": "0.1.0-17a50a519db6a1ff62f38a12958285e04e866dbd",
"description": "run deno on vercel",

@@ -9,6 +9,4 @@ "main": "./dist/index",

"dependencies": {
"@vercel/build-utils": "^2.3.1",
"fs-extra": "^9.0.1",
"which": "^2.0.2",
"execa": "4.0.2"
"execa": "4.0.2",
"fs-extra": "^9.0.1"
},

@@ -20,5 +18,5 @@ "files": [

"devDependencies": {
"@vercel/build-utils": "^2.3.1",
"@types/fs-extra": "^9.0.1",
"@types/node": "^14.0.1",
"@types/which": "^1.3.2",
"@vercel/frameworks": "^0.0.14",

@@ -29,5 +27,7 @@ "@vercel/routing-utils": "^1.8.2",

"scripts": {
"build": "tsc && cp -R ./src/boot/ ./dist/boot/",
"test": "rmdir /s /q .\\test\\dist_ress\\ || tsc --project ./test/tsconfig.json && node ./test/dist_ress/test.js"
"clean": "if exist .\\dist\\ ( rmdir /s/q .\\dist\\ )",
"build:win": "tsc && (robocopy .\\src\\boot .\\dist\\boot\\ * /s) ^& IF %ERRORLEVEL% LSS 8 SET ERRORLEVEL = 0",
"build": "tsc && cp -R ./src/boot/. ./dist/boot/",
"publish:win": "npm run clean && npm run build:win"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc