Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dealmore/funny

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dealmore/funny - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

6

CHANGELOG.md
# @dealmore/funny
## 0.3.0
### Minor Changes
- 3ede0c9: Adds support for symlinks
## 0.2.1

@@ -4,0 +10,0 @@

70

dist/commands/build.js
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const yazl_1 = require("yazl");
const archiver = require("archiver");
const fs_1 = require("fs");
const path = __importStar(require("path"));
const consola_1 = __importDefault(require("consola"));
const compiler_ncc_1 = __importDefault(require("../lib/compiler-ncc"));
const path = require("path");
const consola = require('consola');
const compiler_ncc_1 = require("../lib/compiler-ncc");
// Creates a production build

@@ -44,29 +25,39 @@ // Files which should be excluded from zip package

}
const buildCommand = ({ entry, outputFile, externals }) => __awaiter(void 0, void 0, void 0, function* () {
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
const buildCommand = async ({ entry, outputFile, externals }) => {
return new Promise(async (resolve, reject) => {
try {
const compiler = compiler_ncc_1.default({ entry, externals });
const { code, assets } = yield compiler.compileFile();
// Create zip archive
const zipfile = new yazl_1.ZipFile();
const { code, assets, symlinks } = await compiler.compileFile();
// Make sure the output dir exists
const outputDir = path.dirname(outputFile);
if (!fs_1.existsSync(outputDir)) {
yield fs_1.promises.mkdir(outputDir, { recursive: true });
await fs_1.promises.mkdir(outputDir, { recursive: true });
}
const output = fs_1.createWriteStream(outputFile);
output.on('end', () => resolve());
zipfile.outputStream.pipe(output);
// Add code
zipfile.addBuffer(Buffer.from(code), 'handler.js');
// Add assets
const archive = archiver('zip', {
zlib: { level: 9 },
});
output.on('close', function () {
resolve();
consola.log(archive.pointer() + ' total bytes');
});
archive.pipe(output);
// Adds handler function
archive.append(Buffer.from(code), { name: 'handler.js' });
// Adds assets
for (const [fileName, asset] of Object.entries(assets || {})) {
if (!isIgnoredFile(fileName)) {
zipfile.addBuffer(Buffer.from(asset.source), fileName);
archive.append(Buffer.from(asset.source), { name: fileName, mode: asset.permissions });
}
else {
consola_1.default.log(`Ignoring file ${fileName}`);
consola.log(`Ignoring file ${fileName}`);
}
}
zipfile.end();
// Adds symlinks
for (const [linkPath, target] of Object.entries(symlinks || {})) {
console.log({ linkPath, target });
archive.symlink(linkPath, target);
}
// Finalize archive
archive.finalize();
}

@@ -76,5 +67,4 @@ catch (err) {

}
}));
});
});
};
exports.default = buildCommand;
//# sourceMappingURL=build.js.map
"use strict";
// Starts the dev server
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const http = __importStar(require("http"));
const consola_1 = __importDefault(require("consola"));
const tmp_1 = __importDefault(require("tmp"));
const http = require("http");
const tmp_1 = require("tmp");
const fs_1 = require("fs");
const path = __importStar(require("path"));
const serve_lambda_1 = __importDefault(require("../lib/serve-lambda"));
const compiler_ncc_1 = __importDefault(require("../lib/compiler-ncc"));
const path = require("path");
const consola = require('consola');
const serveLambda = require("../lib/serve-lambda");
const compiler_ncc_1 = require("../lib/compiler-ncc");
const fun_1 = require("../lib/fun");
function writeAssets(target, assets = {}) {
return __awaiter(this, void 0, void 0, function* () {
const writePromises = Object.keys(assets).map((fileName) => {
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
try {
const dirname = path.dirname(path.join(target, fileName));
if (!fs_1.existsSync(dirname)) {
yield fs_1.promises.mkdir(dirname, { recursive: true });
}
yield fs_1.promises.writeFile(path.join(target, fileName), assets[fileName].source, 'utf-8');
resolve();
async function writeAssets(target, assets = {}) {
const writePromises = Object.keys(assets).map((fileName) => {
return new Promise(async (resolve, reject) => {
try {
const dirname = path.dirname(path.join(target, fileName));
if (!fs_1.existsSync(dirname)) {
await fs_1.promises.mkdir(dirname, { recursive: true });
}
catch (err) {
reject(err);
}
}));
await fs_1.promises.writeFile(path.join(target, fileName), assets[fileName].source, 'utf-8');
resolve();
}
catch (err) {
reject(err);
}
});
return Promise.all(writePromises);
});
return Promise.all(writePromises);
}

@@ -54,7 +33,7 @@ const createDevServer = ({ entry, env = {}, externals }) => {

let compilers = {};
const getHandler = () => __awaiter(void 0, void 0, void 0, function* () {
const getHandler = async () => {
let tmpDir = null;
let compiler = compilers[entry];
let reBuild = true;
consola_1.default.debug('Running entry ', entry);
consola.debug('Running entry ', entry);
const onRebuild = () => {

@@ -64,3 +43,3 @@ reBuild = true;

if (!compiler) {
consola_1.default.debug('Creating compiler for entry ', entry);
consola.debug('Creating compiler for entry ', entry);
// Initialize compiler if none exists

@@ -72,10 +51,10 @@ const internalCompiler = compiler_ncc_1.default({ entry, watch: true, onRebuild, externals });

}
return (event) => __awaiter(void 0, void 0, void 0, function* () {
const { code, assets } = yield compiler.internalCompiler.compileFileWatch();
return async (event) => {
const { code, assets } = await compiler.internalCompiler.compileFileWatch();
if (reBuild) {
reBuild = false;
const newTmpDir = tmp_1.default.dirSync();
const newTmpDir = tmp_1.dirSync();
// Write code to the tmp dir
yield fs_1.promises.writeFile(path.join(newTmpDir.name, 'handler.js'), code, 'utf-8');
yield writeAssets(newTmpDir.name, assets);
await fs_1.promises.writeFile(path.join(newTmpDir.name, 'handler.js'), code, 'utf-8');
await writeAssets(newTmpDir.name, assets);
// Delete old runtime and start a new one

@@ -88,3 +67,3 @@ const runtimePromise = fun_1.createFunction({

const destroyPromise = compiler.fn ? compiler.fn.destroy() : null;
const [runtime] = yield Promise.all([runtimePromise, destroyPromise]);
const [runtime] = await Promise.all([runtimePromise, destroyPromise]);
compilers[entry].fn = runtime;

@@ -98,5 +77,5 @@ // Cleanup tmp dir

return compilers[entry].fn(event);
});
});
return serve_lambda_1.default({ entry }, getHandler);
};
};
return serveLambda({ entry }, getHandler);
};

@@ -109,2 +88,1 @@ exports.createDevServer = createDevServer;

exports.default = devServer;
//# sourceMappingURL=dev.js.map
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const http = __importStar(require("http"));
const http = require("http");
const fun_1 = require("../lib/fun");
const serve_lambda_1 = __importDefault(require("../lib/serve-lambda"));
const serveLambda = require("../lib/serve-lambda");
const createDevServer = ({ entry, env = {} }) => {
const getHandler = () => __awaiter(void 0, void 0, void 0, function* () {
const runtime = yield fun_1.createFunction({
const getHandler = async () => {
const runtime = await fun_1.createFunction({
zipFile: entry,

@@ -32,7 +13,7 @@ handler: 'handler.handler',

});
return (event) => __awaiter(void 0, void 0, void 0, function* () {
return async (event) => {
return runtime(event);
});
});
return serve_lambda_1.default({ entry }, getHandler);
};
};
return serveLambda({ entry }, getHandler);
};

@@ -44,2 +25,1 @@ const devServer = ({ port, entry, env = {} }) => {

exports.default = devServer;
//# sourceMappingURL=test.js.map
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
const path = require('path');

@@ -34,3 +25,3 @@ const dotenv = require('dotenv');

})
.command('build <entry> <output>', 'Builds a production ready zip file', () => { }, ({ entry, output, external }) => __awaiter(void 0, void 0, void 0, function* () {
.command('build <entry> <output>', 'Builds a production ready zip file', () => { }, async ({ entry, output, external }) => {
const buildCommand = require('./commands/build').default;

@@ -41,5 +32,5 @@ const resolvedEntry = path.resolve(process.cwd(), entry);

console.log(chalk.cyan('Starting production build...'));
yield buildCommand({ entry: resolvedEntry, outputFile, externals });
}))
.command('test <entry>', 'Runs a zip file locally', () => { }, ({ entry, env }) => __awaiter(void 0, void 0, void 0, function* () {
await buildCommand({ entry: resolvedEntry, outputFile, externals });
})
.command('test <entry>', 'Runs a zip file locally', () => { }, async ({ entry, env }) => {
const testCommand = require('./commands/test').default;

@@ -54,4 +45,3 @@ const resolvedEntry = path.resolve(process.cwd(), entry);

console.log('Server is listening at ', chalk.cyan(`http://localhost:${port}`));
yield testCommand({ entry: resolvedEntry, env: env_.parsed, port });
})).argv;
//# sourceMappingURL=index.js.map
await testCommand({ entry: resolvedEntry, env: env_.parsed, port });
}).argv;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const ncc_1 = __importDefault(require("@zeit/ncc"));
const ncc = require("@zeit/ncc");
const deferred_1 = require("./deferred");

@@ -32,3 +9,3 @@ function Compiler({ entry, watch = false, onRebuild: _onRebuild, externals, }) {

let close = null;
const compiler = ncc_1.default(entry, {
const compiler = ncc(entry, {
externals,

@@ -38,5 +15,5 @@ watch,

});
const onClose = () => __awaiter(this, void 0, void 0, function* () {
const onClose = async () => {
if (close) {
yield close();
await close();
}

@@ -46,5 +23,4 @@ if (deferred) {

}
});
const onBuild = (_a) => {
var { err } = _a, rest = __rest(_a, ["err"]);
};
const onBuild = ({ err, ...rest }) => {
if (err) {

@@ -79,3 +55,3 @@ return deferred.reject(err);

else {
return Promise.resolve(Object.assign(Object.assign({}, buildResult), { cache: true }));
return Promise.resolve({ ...buildResult, cache: true });
}

@@ -94,2 +70,1 @@ };

exports.default = Compiler;
//# sourceMappingURL=compiler-ncc.js.map

@@ -14,2 +14,1 @@ "use strict";

exports.createDeferred = createDeferred;
//# sourceMappingURL=deferred.js.map

@@ -45,2 +45,1 @@ "use strict";

exports.createFunction = createFunction;
//# sourceMappingURL=fun.js.map
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
/**

@@ -33,3 +24,3 @@ * Lighwight entry for the lambda handler function

req.on('data', (chunk) => (body += chunk));
req.on('end', () => __awaiter(void 0, void 0, void 0, function* () {
req.on('end', async () => {
const urlObject = url.parse(req.url, true);

@@ -64,5 +55,5 @@ const event = {

};
const handler = yield callback(options.entry);
const handler = await callback(options.entry);
try {
const response = yield handler(event, {});
const response = await handler(event, {});
lambdaCallback(null, response);

@@ -73,6 +64,5 @@ }

}
}));
});
};
};
module.exports = createLambda;
//# sourceMappingURL=serve-lambda.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map
{
"name": "@dealmore/funny",
"version": "0.2.1",
"version": "0.3.0",
"main": "index.js",

@@ -16,10 +16,11 @@ "license": "MIT",

"@zeit/ncc": "0.22.2",
"archiver": "^4.0.1",
"chalk": "3.0.0",
"consola": "2.11.3",
"consola": "2.12.1",
"dotenv": "8.2.0",
"tmp": "0.2.0",
"yargs": "15.3.1",
"yazl": "2.5.1"
"yargs": "15.3.1"
},
"devDependencies": {
"@types/archiver": "^3.1.0",
"@types/jest": "^25.2.1",

@@ -29,3 +30,2 @@ "@types/node": "13.9.8",

"@types/tmp": "0.1.0",
"@types/yazl": "2.4.2",
"jest": "25.1.0",

@@ -32,0 +32,0 @@ "supertest": "4.0.2",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc