New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@fabernovel/heart-greenit

Package Overview
Dependencies
Maintainers
5
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fabernovel/heart-greenit - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

6

lib/api/Client.d.ts

@@ -1,3 +0,3 @@

import { Config } from '../config/Config';
import { Result } from './model/Result';
export declare function runAnalysis(conf: Config): Promise<Result>;
import { GreenITConfig } from "../config/Config";
import { Result } from "./model/Result";
export declare function runAnalysis(conf: GreenITConfig): Promise<Result>;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -39,26 +16,42 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

exports.runAnalysis = void 0;
const fs_1 = require("fs");
const analysis_1 = require("greenit-cli/cli-core/analysis");
const puppeteer_1 = __importDefault(require("puppeteer"));
const DEFAULT_OPTIONS = {
device: "desktop",
max_tab: 3,
retry: 2,
timeout: 3000,
};
function runAnalysis(conf) {
var _a, _b, _c;
return __awaiter(this, void 0, void 0, function* () {
const DEFAULT_OPTIONS = {
max_tab: 3,
timeout: 3000,
retry: 2,
};
const browser = yield puppeteer_1.default.launch({
headless: true,
args: [
'--no-sandbox',
'--disable-setuid-sandbox', // but security issues
"--no-sandbox",
"--disable-setuid-sandbox", // but security issues
],
// Keep gpu horsepower in headless
ignoreDefaultArgs: ['--disable-gpu'],
ignoreDefaultArgs: ["--disable-gpu"],
});
const page = Object.assign({}, (conf.url && { url: conf.url }));
const options = Object.assign(Object.assign(Object.assign({}, (conf.timeout && { timeout: conf.timeout })), (conf.retry && { retry: conf.retry })), (conf.device && { device: conf.device }));
const options = {
ci: true,
device: (_a = conf.device) !== null && _a !== void 0 ? _a : DEFAULT_OPTIONS.device,
max_tab: DEFAULT_OPTIONS.max_tab,
retry: (_b = conf.retry) !== null && _b !== void 0 ? _b : DEFAULT_OPTIONS.retry,
timeout: (_c = conf.timeout) !== null && _c !== void 0 ? _c : DEFAULT_OPTIONS.timeout,
};
const reports = new Array();
// As the createJsonReports use console.* functions to display progress info and errors and do not send back these information,
// we need to disable the console.* functions during this operation to properly handle the output
const consoleLog = console.log;
const consoleError = console.error;
try {
const results = yield (0, analysis_1.createJsonReports)(browser, [page], Object.assign(Object.assign({}, DEFAULT_OPTIONS), options));
const firstResult = yield Promise.resolve().then(() => __importStar(require(results[0].path)));
return firstResult;
// eslint-disable-next-line @typescript-eslint/no-empty-function
console.log = () => { };
// eslint-disable-next-line @typescript-eslint/no-empty-function
console.error = () => { };
const r = yield (0, analysis_1.createJsonReports)(browser, [{ url: conf.url }], options);
reports.push(...r);
}

@@ -69,2 +62,4 @@ catch (error) {

finally {
console.log = consoleLog;
console.error = consoleError;
const pages = yield browser.pages();

@@ -74,5 +69,11 @@ yield Promise.all(pages.map((_) => _.close()));

}
if (0 === reports.length) {
return Promise.reject("No report has been generated");
}
else {
const result = JSON.parse((0, fs_1.readFileSync)(reports[0].path, { encoding: "utf-8" }));
return result.success ? result : Promise.reject("Error during GreenIT analysis");
}
});
}
exports.runAnalysis = runAnalysis;
//# sourceMappingURL=Client.js.map

@@ -8,3 +8,2 @@ /**

success: boolean;
date: string;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=Result.js.map

@@ -1,6 +0,5 @@

import { Options } from 'greenit-cli/cli-core/analysis';
export interface PageInfos {
import { Config } from "@fabernovel/heart-core";
import { Options } from "greenit-cli/cli-core/analysis";
export declare type GreenITConfig = Config & Options & {
url: string;
}
export interface Config extends PageInfos, Options {
}
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=Config.js.map

@@ -1,7 +0,8 @@

import { Module, ModuleAnalysisInterface, ModuleInterface, Report } from '@fabernovel/heart-core';
import { Config } from './config/Config';
export default class GreenITModule extends Module implements ModuleAnalysisInterface {
constructor(module: Partial<ModuleInterface>);
startAnalysis(conf: Config): Promise<Report>;
import { Module, ModuleAnalysisInterface, ModuleInterface, Report } from "@fabernovel/heart-core";
import { GreenITConfig } from "./config/Config";
export declare class GreenITModule extends Module implements ModuleAnalysisInterface<GreenITConfig> {
private threshold?;
constructor(module: Omit<ModuleInterface, "id">);
startAnalysis(conf: GreenITConfig, threshold?: number): Promise<Report>;
private handleResults;
}

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.GreenITModule = void 0;
const heart_core_1 = require("@fabernovel/heart-core");

@@ -19,16 +20,7 @@ const Client_1 = require("./api/Client");

}
startAnalysis(conf) {
startAnalysis(conf, threshold) {
return __awaiter(this, void 0, void 0, function* () {
try {
const result = yield (0, Client_1.runAnalysis)(conf);
if (!result.success) {
throw new Error('Error during GreenIT analysis');
}
else {
return this.handleResults(result);
}
}
catch (error) {
throw new Error(error.message);
}
this.threshold = threshold;
const result = yield (0, Client_1.runAnalysis)(conf);
return this.handleResults(result);
});

@@ -39,9 +31,9 @@ }

analyzedUrl: results.url,
date: new Date(results.date),
date: new Date(),
note: results.ecoIndex.toString(),
service: this.service,
threshold: this.threshold,
});
}
}
exports.default = GreenITModule;
//# sourceMappingURL=GreenITModule.js.map
exports.GreenITModule = GreenITModule;

@@ -1,3 +0,3 @@

import GreenITModule from './GreenITModule';
import { GreenITModule } from "./GreenITModule";
declare const _default: GreenITModule;
export default _default;
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const GreenITModule_1 = __importDefault(require("./GreenITModule"));
exports.default = new GreenITModule_1.default({
name: 'Heart GreenIT',
const GreenITModule_1 = require("./GreenITModule");
exports.default = new GreenITModule_1.GreenITModule({
name: "Heart GreenIT",
service: {
name: 'GreenIT Analysis',
logo: 'https://gitlab.com/fabernovel/heart/raw/master/assets/images/logos/GreenIT.png'
}
name: "GreenIT Analysis",
logo: "https://gitlab.com/fabernovel/heart/raw/master/assets/images/logos/GreenIT.png",
},
});
//# sourceMappingURL=index.js.map
{
"name": "@fabernovel/heart-greenit",
"version": "3.0.0",
"version": "3.1.0",
"description": "Analysis module of Heart, which analyses URLs with GreenIT",
"homepage": "https://gitlab.com/fabernovel/heart",
"keywords": [
"greenit",
"ecoindex",
"ecometer"
],
"homepage": "https://heart.fabernovel.com",
"bugs": {

@@ -19,5 +24,2 @@ "url": "https://gitlab.com/fabernovel/heart/issues"

],
"files": [
"lib/**/*"
],
"main": "lib/index.js",

@@ -28,9 +30,10 @@ "types": "lib/index.d.ts",

},
"keywords": [
"greenit",
"ecoindex",
"ecometer"
"files": [
"lib/**/*"
],
"engines": {
"node": ">=14.17.0"
"dependencies": {
"@fabernovel/heart-core": "^3.3.0",
"greenit-cli": "github:cnumr/GreenIT-Analysis-cli#a4363a9bcf7630e4a5a4cd264a7da9ec6f34b571",
"puppeteer": "^5.5.0",
"rimraf": "^3.0.2"
},

@@ -40,24 +43,23 @@ "devDependencies": {

"@types/node": "^10.14.10",
"jest": "^27.5.1",
"ts-jest": "^27.1.3",
"typescript": "^4.0.0",
"@types/puppeteer": "^5.4.6",
"@typescript-eslint/eslint-plugin": "^5.32.0",
"@typescript-eslint/parser": "^5.32.0",
"eslint": "^8.16.0",
"@typescript-eslint/parser": "^5.26.0",
"@typescript-eslint/eslint-plugin": "^5.26.0"
"jest": "^28.1.0",
"jest-mock": "^28.1.1",
"ts-jest": "^28.0.2",
"typescript": "^4.6.4"
},
"peerDependencies": {
"@fabernovel/heart-cli": "^3.2.0"
"@fabernovel/heart-cli": "^3.3.0"
},
"dependencies": {
"@fabernovel/heart-core": "^3.1.2",
"greenit-cli": "github:cnumr/GreenIT-Analysis-cli#a4363a9bcf7630e4a5a4cd264a7da9ec6f34b571",
"puppeteer": "^5.5.0"
"engines": {
"node": ">=14.17.0"
},
"scripts": {
"build": "tsc",
"build-watch": "tsc -w",
"build": "rimraf lib && tsc --project tsconfig.build.json",
"build:watch": "npm run build --watch",
"lint": "eslint .",
"outdated": "npm outdated",
"test": "jest --silent"
}
}

@@ -5,3 +5,3 @@ # Heart GreenIT

Read more about [the purpose, design and general installation of _Heart_](https://www.fabernovel.com/en/clients/cases/heart-a-tool-for-automating-web-quality-metrics).
Read more about [the purpose, design and general installation of _Heart_](https://gitlab.com/fabernovel/heart/-/blob/master/README.md).

@@ -34,3 +34,3 @@ # Package manager

{
"url": "https://www.heart.fabernovel.com/",
"url": "https://www.fabernovel.com/",
// optional - default: 3000

@@ -48,6 +48,8 @@ "timeout": 1000,

Using _[Heart CLI](https://www.npmjs.com/package/@fabernovel/heart-cli)_, starting a _GreenIT_ analysis of https://heart.fabernovel.com could look like that:
> Using _[Heart CLI](https://www.npmjs.com/package/@fabernovel/heart-cli)_
>
> You want to analyse the https://www.fabernovel.com URL and check that the rating is at least 90
```shell
npx heart greenit --inline '{"url":"https://heart.fabernovel.com"}'
npx heart greenit --inline '{"url":"https://www.fabernovel.com"}' --threshold 90
```

@@ -54,0 +56,0 @@

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