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

@discoveryjs/cli

Package Overview
Dependencies
Maintainers
3
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@discoveryjs/cli - npm Package Compare versions

Comparing version 2.0.0-beta.3 to 2.0.0-beta.4

4

CHANGELOG.md

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

## 2.0.0-beta.4 (08-02-2021)
- Add `--tmpdir` option to customise a dir for data cache temp files
## 2.0.0-beta.3 (05-02-2021)

@@ -2,0 +6,0 @@

2

lib/build.js

@@ -124,3 +124,3 @@ const path = require('path');

async function build(options, config, configFile) {
const cacheDispatcher = createCacheDispatcher(config.models, { cache: options.cache, cachedir: options.cachedir });
const cacheDispatcher = createCacheDispatcher(config.models, { cache: options.cache, cachedir: options.cachedir, tmpdir: options.tmpdir });
const outputDir = options.output;

@@ -127,0 +127,0 @@ const outputFiles = new Map();

@@ -16,6 +16,7 @@ const fs = require('fs');

// - force – generate cache (ignore existing)
module.exports = bootstrap.model(function getCache(modelConfig, { configFile, cachedir, mode, pretty, hash }) {
module.exports = bootstrap.model(function getCache(modelConfig, { configFile, cachedir, tmpdir, mode, pretty, hash }) {
const cacheDispatcher = createCacheDispatcher([modelConfig], {
configFile,
cachedir,
tmpdir,
prettyData: pretty,

@@ -34,3 +35,3 @@ cachePersistent: hash

const tmpCacheFilename = path.join(os.tmpdir(), path.basename(cacheDispatcher.genModelCacheFilename(slug)));
const tmpCacheFilename = path.join(path.resolve(tmpdir || os.tmpdir()), path.basename(cacheDispatcher.genModelCacheFilename(slug)) + '.tmp');
let startTime = Date.now();

@@ -45,3 +46,3 @@

.on('error', reject)
.pipe(fs.createWriteStream(tmpCacheFilename))
.pipe(fs.createWriteStream(ensureDir(tmpCacheFilename)))
.on('error', reject)

@@ -48,0 +49,0 @@ .on('finish', () => {

@@ -19,2 +19,6 @@ const path = require('path');

],
tmpdir: [
'--tmpdir [dir]',
'Temporary directory for caches'
],
noCache: [

@@ -21,0 +25,0 @@ '--no-cache',

@@ -6,6 +6,7 @@ const fs = require('fs');

const crypto = require('crypto');
const { logSlugMsg, logSlugError, runScript, prettyDuration, serializeErrorForClient } = require('./utils');
const { logError, logSlugMsg, logSlugError, runScript, prettyDuration, serializeErrorForClient } = require('./utils');
const command = require('./commands');
const matchCacheFilename = /(?:^|\/)\.discoveryjs\.(.*?)\.(\d+)\.?([a-f0-9]+)?\.cache$/;
const OBSOLETE_CACHE_CHECK_INTERVAL = 60 * 1000; // 1 min
const TMP_CACHE_CLEAN_INTERVAL = 60 * 60 * 1000;

@@ -117,3 +118,3 @@ function getDataHash(modelConfig) {

function runCacheCommand(slug, { configFile, cachedir, prettyData, hash }) {
function runCacheCommand(slug, { configFile, cachedir, tmpdir, prettyData, hash }) {
const args = [

@@ -132,2 +133,6 @@ '--model', slug,

if (tmpdir) {
args.push('--tmpdir', tmpdir);
}
if (prettyData) {

@@ -144,3 +149,3 @@ args.push('--pretty', JSON.stringify(prettyData));

function createCacheDispatcher(models, { configFile, cache = true, cachedir, bgUpdate, prettyData, cachePersistent }) {
function createCacheDispatcher(models, { configFile, cache = true, cachedir, tmpdir, bgUpdate, prettyData, cachePersistent }) {
const modelSlugs = [];

@@ -302,3 +307,3 @@ const cacheBySlug = new Map();

const startTime = Date.now();
const cache = runCacheCommand(slug, { configFile, cachedir, prettyData, hash: modelCache.hash })
const cache = runCacheCommand(slug, { configFile, cachedir, tmpdir, prettyData, hash: modelCache.hash })
.finally(() => {

@@ -368,2 +373,15 @@ modelCache.write.lastTime = Date.now() - startTime;

const cleanupObsoleteCaches = () => {
// clean *.tmp files
fs.readdir(cachedir, (err, files) => {
for (const file of files) {
const filePath = path.join(cachedir, file);
const { mtime } = fs.statSync(filePath);
if (path.extname(file) === '.tmp' && Date.now() - Date.parse(mtime) > TMP_CACHE_CLEAN_INTERVAL) {
fs.unlink(path.join(cachedir, file), (err) => {
err && logError(err);
});
}
}
});
for (const fsModelCaches of Object.values(getCaches(cachedir, modelSlugs))) {

@@ -370,0 +388,0 @@ for (const { slug, file } of fsModelCaches.slice(2)) {

{
"name": "@discoveryjs/cli",
"version": "2.0.0-beta.3",
"version": "2.0.0-beta.4",
"description": "CLI tools to serve & build projects based on Discovery.js",

@@ -5,0 +5,0 @@ "author": "Roman Dvornov <rdvornov@gmail.com> (https://github.com/lahmatiy)",

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