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

fbl

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fbl - npm Package Compare versions

Comparing version 0.4.2 to 0.4.3

6

dist/src/services/FlowService.d.ts

@@ -47,2 +47,8 @@ import { ActionHandlersRegistry } from './ActionHandlersRegistry';

private static extractTarball;
/**
* Recursively find index.yml in directory structure
* @param {string} path
* @return {Promise<string>}
*/
recursivelyFindIndexFileInDir(path: string): Promise<string>;
resolveFlowSkipChecks(path: string, wd: string): Promise<string>;

@@ -49,0 +55,0 @@ /**

43

dist/src/services/FlowService.js

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

const ws = fs_1.createWriteStream(tarballFile.path);
let error = false;
try {

@@ -130,3 +129,3 @@ yield new Promise((resolve, reject) => {

stream.pipe(ws);
stream.on('end', resolve);
ws.on('finish', resolve);
stream.on('error', reject);

@@ -136,11 +135,5 @@ });

catch (e) {
error = true;
yield util_1.promisify(fs_1.unlink)(tarballFile.path);
throw e;
}
finally {
ws.close();
if (error) {
yield util_1.promisify(fs_1.unlink)(tarballFile.path);
}
}
return tarballFile.path;

@@ -166,2 +159,32 @@ });

}
/**
* Recursively find index.yml in directory structure
* @param {string} path
* @return {Promise<string>}
*/
recursivelyFindIndexFileInDir(path) {
return __awaiter(this, void 0, void 0, function* () {
let contents = yield util_1.promisify(fs_1.readdir)(path);
// filter all files and folders that start with "."
contents = contents.filter(fileOrDir => !fileOrDir.startsWith('.'));
const match = contents.find(dirOrFile => {
return dirOrFile === 'index.yml' || dirOrFile === 'index.yaml';
});
if (match) {
const dirOrFile = path_1.join(path, match);
const isDir = yield utils_1.FSUtil.isDirectory(dirOrFile);
if (!isDir) {
return dirOrFile;
}
}
if (contents.length === 1) {
const dirOrFile = path_1.join(path, contents[0]);
const isDir = yield utils_1.FSUtil.isDirectory(dirOrFile);
if (isDir) {
return yield this.recursivelyFindIndexFileInDir(dirOrFile);
}
}
throw new Error('Unable to locate index file inside the directory.');
});
}
resolveFlowSkipChecks(path, wd) {

@@ -183,3 +206,3 @@ return __awaiter(this, void 0, void 0, function* () {

if (directory) {
absolutePath = path_1.join(absolutePath, 'index.yml');
absolutePath = yield this.recursivelyFindIndexFileInDir(absolutePath);
this.flowPathCache[path] = absolutePath;

@@ -186,0 +209,0 @@ }

@@ -47,5 +47,3 @@ "use strict";

const fileStream = fs_1.createReadStream(commander.file);
fileStream.on('data', function (data) {
response.write(data);
});
fileStream.pipe(response);
fileStream.on('end', function () {

@@ -52,0 +50,0 @@ response.end();

@@ -136,5 +136,16 @@ "use strict";

assert.strictEqual(result.code, 0);
const report = yield util_1.promisify(fs_1.readFile)(reportFile.path, 'utf8');
assert(report.length > 0);
// TODO: validate options inside the report
const reportJson = yield util_1.promisify(fs_1.readFile)(reportFile.path, 'utf8');
assert(reportJson.length > 0);
const report = JSON.parse(reportJson);
const contextSteps = report.steps.filter((s) => s.type === 'context');
assert.deepStrictEqual(contextSteps[contextSteps.length - 1].payload.ctx, {
ct: 'yes',
custom_ct: 'file1',
test: {
ct: 'yes',
st: 'yes',
custom_ct: 'file1',
custom_st: 'file2'
}
});
});

@@ -297,5 +308,16 @@ }

assert.strictEqual(result.code, 0);
const report = yield util_1.promisify(fs_1.readFile)(reportFile.path, 'utf8');
assert(report.length > 0);
// TODO: validate options inside the report
const reportJson = yield util_1.promisify(fs_1.readFile)(reportFile.path, 'utf8');
assert(reportJson.length > 0);
const report = JSON.parse(reportJson);
const contextSteps = report.steps.filter((s) => s.type === 'context');
assert.deepStrictEqual(contextSteps[contextSteps.length - 1].payload.ctx, {
ct: 'yes',
custom_ct: 'file1',
test: {
ct: 'yes',
st: 'yes',
custom_ct: 'file1',
custom_st: 'file2'
}
});
});

@@ -743,2 +765,98 @@ }

}
static indexFileLookupInsideDirectoryTree(extention) {
return __awaiter(this, void 0, void 0, function* () {
const flow = {
version: '1.0.0',
pipeline: {
ctx: {
'$': {
inline: {
test: true
}
}
}
}
};
const reportFile = yield tmp.file();
const rootDir = yield tmp.dir();
yield utils_1.FSUtil.mkdirp(path_1.join(rootDir.path, 'l1/index.yml/l3'));
const indexPath = path_1.join(rootDir.path, `l1/index.yml/l3/index.${extention}`);
yield util_1.promisify(fs_1.writeFile)(indexPath, js_yaml_1.dump(flow), 'utf8');
const result = yield execCmd('node', [
'dist/src/cli.js',
'-o', reportFile.path,
'-r', 'json',
rootDir.path
]);
assert.strictEqual(result.code, 0);
const reportJson = yield util_1.promisify(fs_1.readFile)(reportFile.path, 'utf8');
assert(reportJson.length > 0);
const report = JSON.parse(reportJson);
const contextSteps = report.steps.filter((s) => s.type === 'context');
assert.deepStrictEqual(contextSteps[contextSteps.length - 1].payload.ctx, {
test: true
});
});
}
indexYmlLookupInsideDirectoryTree() {
return __awaiter(this, void 0, void 0, function* () {
yield CliTestSuite_1.indexFileLookupInsideDirectoryTree('yml');
});
}
indexYamlLookupInsideDirectoryTree() {
return __awaiter(this, void 0, void 0, function* () {
yield CliTestSuite_1.indexFileLookupInsideDirectoryTree('yaml');
});
}
indexFileLookupFailure() {
return __awaiter(this, void 0, void 0, function* () {
const flow = {
version: '1.0.0',
pipeline: {
ctx: {
'$': {
inline: {
test: true
}
}
}
}
};
const rootDir = yield tmp.dir();
yield utils_1.FSUtil.mkdirp(path_1.join(rootDir.path, 'l1/l2/l3'));
const flowPath = path_1.join(rootDir.path, `l1/l2/l3/test.yml`);
yield util_1.promisify(fs_1.writeFile)(flowPath, js_yaml_1.dump(flow), 'utf8');
const result = yield execCmd('node', [
'dist/src/cli.js',
rootDir.path
]);
assert.strictEqual(result.code, 1);
});
}
indexFileLookupFailureDueToMultipleParentDirs() {
return __awaiter(this, void 0, void 0, function* () {
const flow = {
version: '1.0.0',
pipeline: {
ctx: {
'$': {
inline: {
test: true
}
}
}
}
};
const rootDir = yield tmp.dir();
yield utils_1.FSUtil.mkdirp(path_1.join(rootDir.path, 'l1/l2/l3'));
yield utils_1.FSUtil.mkdirp(path_1.join(rootDir.path, 'l1/l2/l4'));
const flowPath = path_1.join(rootDir.path, `l1/l2/l3/index.yml`);
yield util_1.promisify(fs_1.writeFile)(flowPath, js_yaml_1.dump(flow), 'utf8');
const result = yield execCmd('node', [
'dist/src/cli.js',
rootDir.path
]);
assert.strictEqual(result.code, 1);
});
}
};

@@ -865,2 +983,26 @@ __decorate([

], CliTestSuite.prototype, "outputHelp", null);
__decorate([
mocha_typescript_1.test(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], CliTestSuite.prototype, "indexYmlLookupInsideDirectoryTree", null);
__decorate([
mocha_typescript_1.test(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], CliTestSuite.prototype, "indexYamlLookupInsideDirectoryTree", null);
__decorate([
mocha_typescript_1.test(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], CliTestSuite.prototype, "indexFileLookupFailure", null);
__decorate([
mocha_typescript_1.test(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], CliTestSuite.prototype, "indexFileLookupFailureDueToMultipleParentDirs", null);
CliTestSuite = CliTestSuite_1 = __decorate([

@@ -867,0 +1009,0 @@ mocha_typescript_1.suite()

{
"name": "fbl",
"version": "0.4.2",
"version": "0.4.3",
"description": "Command Line tool to automate any kind of work. Originally designed to help with deployments.",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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