How to use the @storybook/node-logger.logger.warn function in @storybook/node-logger

To help you get started, we’ve selected a few @storybook/node-logger examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github storybookjs / storybook / lib / core / src / server / build-dev.js View on Github external
}
  } catch (error) {
    // this is a weird bugfix, somehow 'node-pre-gyp' is polluting the npmLog header
    npmLog.heading = '';

    if (error instanceof Error) {
      if (error.error) {
        logger.error(error.error);
      } else if (error.stats && error.stats.compilation.errors) {
        error.stats.compilation.errors.forEach(e => logger.plain(e));
      } else {
        logger.error(error);
      }
    }
    logger.line();
    logger.warn(
      error.close
        ? dedent`
            FATAL broken build!, will close the process,
            Fix the error below and restart storybook.
          `
        : dedent`
            Broken build, fix the error above.
            You may need to refresh the browser.
          `
    );
    logger.line();

    if (options.smokeTest || (error && error.close)) {
      process.exit(1);
    }
  }
github storybookjs / storybook / app / angular / src / server / angular-cli_config.ts View on Github external
export function applyAngularCliWebpackConfig(baseConfig: any, cliWebpackConfigOptions: any) {
  if (!cliWebpackConfigOptions) {
    return baseConfig;
  }

  if (!isBuildAngularInstalled()) {
    logger.info('=> Using base config because @angular-devkit/build-angular is not installed.');
    return baseConfig;
  }

  const cliParts = getAngularCliParts(cliWebpackConfigOptions);

  if (!cliParts) {
    logger.warn('=> Failed to get angular-cli webpack config.');
    return baseConfig;
  }

  logger.info('=> Get angular-cli webpack config.');

  const { cliCommonConfig, cliStyleConfig } = cliParts;

  // Don't use storybooks styling rules because we have to use rules created by @angular-devkit/build-angular
  // because @angular-devkit/build-angular created rules have include/exclude for global style files.
  const rulesExcludingStyles = filterOutStylingRules(baseConfig);

  // cliStyleConfig.entry adds global style files to the webpack context
  // todo add type for acc
  const entry = [
    ...baseConfig.entry,
    ...Object.values(cliStyleConfig.entry).reduce((acc: any, item) => acc.concat(item), []),
github storybookjs / storybook / lib / server / src / index.ts View on Github external
const start = async ({ configFiles, callOptions, cliOptions: cliOptionsRaw }: StartOptions) => {
  logger.warn('experimental mono config mode enabled');

  setTitle('storybook');

  // filter the env options
  const envOptions = cleanEnvOptions(process.env);

  // filter the cli options
  const cliOptions = cleanCliOptions(cliOptionsRaw);

  const manager = builder.create(
    {
      command: 'watch',
      type: 'manager',
    },
    {
      envOptions,
github storybookjs / storybook / app / react / src / server / cra-config.js View on Github external
if (pathIsNotResolved) {
      const content = fs.readFileSync(reactScriptsScriptPath, 'utf8');
      const packagePathMatch = content.match(
        /"\$basedir[\\/]([^\s]+?[\\/]bin[\\/]react-scripts\.js")/i
      );

      if (packagePathMatch && packagePathMatch.length > 1) {
        reactScriptsScriptPath = path.join(
          appDirectory,
          '/node_modules/.bin/',
          packagePathMatch[1]
        );
      }
    }
  } catch (e) {
    logger.warn(`Error occured during react-scripts package path resolving: ${e}`);
  }

  reactScriptsPath = path.join(reactScriptsScriptPath, '../..');
  const scriptsPkgJson = path.join(reactScriptsPath, 'package.json');

  if (!fs.existsSync(scriptsPkgJson)) {
    reactScriptsPath = 'react-scripts';
  }

  return reactScriptsPath;
}
github storybookjs / storybook / lib / core / src / server / dev-server.js View on Github external
(err, stats) => {
          managerTotalTime = process.hrtime(startTime);
          if (!resolved && (err || stats.hasErrors())) {
            const error = new Error('Manager build is broken');
            error.error = err;
            error.close = true;
            error.stats = stats;
            logger.line();
            logger.line();
            try {
              previewReject(error);
              previewProcess.close();
              logger.warn('force closed preview build');
            } catch (e) {
              logger.warn('Unable to close preview build!');
            }
            logger.line();
            reject(error);
          } else {
            resolve(stats);
          }
        }
      );
github storybookjs / storybook / lib / core / src / server / presets.js View on Github external
preset: rest,
          options: presetOptions,
        },
      ];
    }

    throw new Error(dedent`
      ${input} is not a valid preset
    `);
  } catch (e) {
    const warning =
      level > 0
        ? `  Failed to load preset: ${JSON.stringify(input)} on level ${level}`
        : `  Failed to load preset: ${JSON.stringify(input)}`;

    logger.warn(warning);
    logger.error(e);

    return [];
  }
}
github storybookjs / storybook / lib / core / src / server / build-static.js View on Github external
      stats.toJson(managerConfig.stats).warnings.forEach(e => logger.warn(e));
github storybookjs / storybook / lib / config / src / presets.ts View on Github external
export async function getProperties(
  preset: P.PresetFn | P.PresetRef | P.Preset
): Promise {
  switch (typeof preset) {
    case 'string': {
      return import(preset);
    }
    case 'function': {
      return preset();
    }
    case 'object': {
      return preset;
    }
    default: {
      logger.warn(`
        preset should be a string (P.PresetRef), function (P.PresetFn), or an object (P.Preset). 
        The provided value did not match, therefore it was skipped.
      `);
      return {};
    }
  }
}