Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import findCacheDir from 'find-cache-dir';
import open from 'open';
import boxen from 'boxen';
import semver from 'semver';
import dedent from 'ts-dedent';
import Table from 'cli-table3';
import prettyTime from 'pretty-hrtime';
import inquirer from 'inquirer';
import detectFreePort from 'detect-port';
import storybook from './dev-server';
import { getDevCli } from './cli';
const defaultFavIcon = require.resolve('./public/favicon.ico');
const cacheDir = findCacheDir({ name: 'storybook' });
const cache = Cache({
basePath: cacheDir,
ns: 'storybook', // Optional. A grouping namespace for items.
});
const writeStats = async (name, stats) => {
await fs.writeFile(
path.join(cacheDir, `${name}-stats.json`),
JSON.stringify(stats.toJson(), null, 2),
'utf8'
);
};
const getFreePort = port =>
detectFreePort(port).catch(error => {
logger.error(error);
process.exit(-1);
export async function cachedStorybookMetadata() {
const cacheDir = findCacheDir({ name: 'storybook' });
const cache = Cache({
basePath: cacheDir,
ns: 'storybook', // Optional. A grouping namespace for items.
});
const packagePath = await findUp('package.json');
if (!packagePath) {
throw new Error('No package.json');
}
const packageJson = JSON.parse(await fs.readFile(packagePath, 'utf-8'));
const metadataCache = await cache.get('storybookMetadata', {});
const storybookMetadata = await loadStorybookMetadata(packageJson, {
cache: metadataCache,
getPackageJson: async packageName => {
const packageFile = require.resolve(`${packageName}/package.json`);
return JSON.parse(await fs.readFile(packageFile, 'utf8'));
},
(function() {
const Listr = require("listr");
const chalk = require("chalk");
const debug = require("debug")("lint-prepush:index");
const os = require('os');
const Cache = require("file-system-cache").default;
const cache = Cache({
basePath: `${os.homedir()}/.lint-prepush`, // Path where cache files are stored.
ns: process.cwd() // A grouping namespace for items.
});
const success = chalk.keyword("green");
const error = chalk.keyword("red");
const warning = chalk.keyword("yellow");
const { log } = console;
const { userConfig, execSyncProcess } = require("./utils/common");
const resolveMainTask = require("./utils/resolveMainTask");
const fetchGitDiff = require("./utils/fetchGitDiff");
if(!userConfig) {
process.exitCode = 1;