How to use the dotenv.error function in dotenv

To help you get started, we’ve selected a few dotenv 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 Innovatube / dtcgen / cli-app / converter.ts View on Github external
import * as fs from "fs-extra";
import * as handlebars from "handlebars";
import * as _ from "lodash";
import * as dotenv from "dotenv";
import * as cp from "child_process";

dotenv.config();
if (dotenv.error) {
  throw dotenv.error;
}

convert();

function convert() {
  const sketchData: any[] = JSON.parse(String(read("result.json")));
  const templateStr: string = String(
    read("./templates/viewController_static.hbs")
  );

  // viewController毎に分割
  const containers: any[] = sketchData.filter(
    element => element.id && element.type && element.type === "Container"
  );
github Innovatube / dtcgen / core / iosPlatform / applications / XcodeProjectGenerator.ts View on Github external
import * as dotenv from 'dotenv';
import * as cp from 'child_process';
import * as path from 'path';
import { PathManager, OutputType } from '../../utilities/Utilities';
import { OSType } from '../../domain/entities/OSType';
import { isString } from 'util';

dotenv.config();
if (dotenv.error) {
  throw dotenv.error;
}

export class XcodeProjectGenator {
  constructor() {
    // generated/ios配下に XcodeGenディレクトリがあるかどうかをチェック
    // XcodeGenディレクトリのパスを取得
    // なければ git clone してきて
  }

  generate(outputDir?: string) {
    const execSync = cp.execSync;
    const pathManager = new PathManager(outputDir);
    const defaultOutputDir = path.isAbsolute(process.env.OUTPUT_PATH)
      ? process.env.OUTPUT_PATH
      : path.resolve(process.cwd(), process.env.OUTPUT_PATH);
    if (!defaultOutputDir || !isString(defaultOutputDir)) {
github Innovatube / dtcgen / __tests__ / sliceImageUseCaseOnFigma.spec.ts View on Github external
beforeAll(() => {
    jest.setTimeout(20000);
    dotenv.config();
    if (dotenv.error) {
      throw dotenv.error;
    }
    OLD_ENV = process.env;

    sliceConfig = new SliceConfig();
    sliceConfig.initWithDtcConfig(DesignToolType.figma);
    sliceConfig.outputDir = outputDir;

    testContainer
      .bind(TYPES.IFigmaConfig)
      .to(FigmaPlatform.FigmaConfigMock);
    testContainer
      .bind(TYPES.IFigmaRepository)
      .to(FigmaPlatform.FigmaRepository);
    testContainer
      .bind(TYPES.ISliceImageUseCase)
github Innovatube / dtcgen / __tests__ / sliceImageUseCaseOnSketch.spec.ts View on Github external
beforeAll(() => {
    jest.setTimeout(20000);
    dotenv.config();
    if (dotenv.error) {
      throw dotenv.error;
    }
    OLD_ENV = process.env;

    sliceConfig = new SliceConfig();
    sliceConfig.initWithDtcConfig(DesignToolType.sketch);
    sliceConfig.inputPath = inputPath;
    sliceConfig.outputDir = outputDir;

    testContainer
      .bind(TYPES.ISketchRepository)
      .to(SketchPlatform.SketchRepository);
    testContainer
      .bind(TYPES.ISliceImageUseCase)
      .to(SketchPlatform.SliceImageUseCase);
    usecase = testContainer.get(
github Innovatube / dtcgen / core / figmaPlatform / entities / FigmaConfigMock.ts View on Github external
import * as dotenv from 'dotenv';
import { injectable } from 'inversify';
import { AssetFormat, SliceConfig } from '../../Domain/Entities';
import { AxiosRequestConfig, Method, ResponseType } from 'axios';
import { IFigmaConfig, GetS3ImageParams } from '../FigmaPlatform';
import { FigmaMockAdapter } from './figmaMockAdapter';
import { GetNodesParams } from './IFigmaConfig';

dotenv.config();
if (dotenv.error) {
  throw dotenv.error;
}

@injectable()
export class FigmaConfigMock implements IFigmaConfig {
  fileKey?: string;
  token?: string;
  sliceConfig?: SliceConfig;
  adapter: FigmaMockAdapter;

  init(sliceConfig?: SliceConfig) {
    this.sliceConfig = sliceConfig;

    this.fileKey = 'RL6HzoX6UeVaQw4OmSsqxr'; //process.env.FIGMA_FILE_KEY;
    if (!this.fileKey) {
      throw new Error('no fileKey found');
github Innovatube / dtcgen / core / figmaPlatform / entities / FigmaConfig.ts View on Github external
import * as dotenv from 'dotenv';
import { injectable } from 'inversify';
import { AssetFormat, SliceConfig } from '../../domain/Entities';
import { AxiosRequestConfig, Method, ResponseType } from 'axios';
import { IFigmaConfig, GetS3ImageParams, GetNodesParams } from './IFigmaConfig';

dotenv.config();
if (dotenv.error) {
  throw dotenv.error;
}

@injectable()
export class FigmaConfig implements IFigmaConfig {
  fileKey?: string;
  token?: string;
  sliceConfig?: SliceConfig;

  init(sliceConfig?: SliceConfig) {
    this.sliceConfig = sliceConfig;

    this.fileKey = process.env.FIGMA_FILE_KEY;
    if (!this.fileKey) {
      throw new Error('no fileKey found');
    }
    this.token = process.env.FIGMA_ACCESS_TOKEN;
github Innovatube / dtcgen / core / iosPlatform / applications / IOSProjectGenerator.ts View on Github external
TreeElement,
  GenerateConfig,
} from '../../domain/Entities';
import {
  PathManager,
  OutputType,
  HandlebarsHelpers,
  HandlebarsPartials,
} from '../../utilities/Utilities';
import { SourceCodeGenerator } from './SourceCodeGenerator';
import { AssetGenerator } from './AssetGenerator';
import { ProjectSettings } from '../entities/ProjectSettings';

dotenv.config();
if (dotenv.error) {
  throw dotenv.error;
}

export class IOSProjectGenerator {
  private pathManager: PathManager;
  private projectTemplateRootDir: string;
  private templateHelpers: HandlebarsHelpers;

  constructor(outputDir?: string) {
    this.pathManager = new PathManager(outputDir);
    this.templateHelpers = new HandlebarsHelpers(this.pathManager);
    const templatePath = path.isAbsolute(process.env.TEMPLATE_DIR)
      ? process.env.TEMPLATE_DIR
      : path.resolve(process.cwd(), process.env.TEMPLATE_DIR);
    this.projectTemplateRootDir = path.join(
      templatePath,
      OSType.ios,
github Innovatube / dtcgen / core / utilities / PathManager.ts View on Github external
import * as fs from 'fs-extra';
import * as path from 'path';
import * as dotenv from 'dotenv';
import { OSType } from '../domain/entities/OSType';
import { isString } from 'util';

dotenv.config();
if (dotenv.error) {
  throw dotenv.error;
}

export enum OutputMidDirName {
  extracted = 'extracted',
  generated = 'generated',
}

export enum OutputType {
  slices,
  images,
  metadata,
  dynamicAttributes,
  tree,
  sourcecodes,
  project,
  figmaTree,
github Innovatube / dtcgen / core / domain / entities / StyleConfig.ts View on Github external
import * as _ from 'lodash';
import * as dotenv from 'dotenv';
import { StyleType } from './StyleType';
import { PathManager } from '../../utilities/PathManager';
import { DesignToolType } from './DesignToolType';
import { ColorStyleConfig } from './ColorStyleConfig';
import { Styles } from './Styles';

dotenv.config();
if (dotenv.error) {
  throw dotenv.error;
}

export class StyleConfig {
  styles?: StyleType[];
  teamId: string;
  inputPath?: string;
  outputDir?: string;
  colorStyleConfig?: ColorStyleConfig;
  outputStyles?: Styles;

  initWithDtcConfig(designToolType: DesignToolType) {
    const pathManager = new PathManager(designToolType);
    const dtcConfig = pathManager.getConfig();
    const defaults = _.get(dtcConfig, `${designToolType}.style`, null);
    if (!defaults) {
      throw new Error('style config is not set on config file.');
github Innovatube / dtcgen / core / sketchPlatform / applications / IOSCodeGenerator.ts View on Github external
import * as fs from 'fs-extra';
import * as dotenv from 'dotenv';
import * as path from 'path';
import * as handlebars from 'handlebars';
import { OSType } from '../../domain/entities/OSType';
import { PathManager, OutputType } from '../../utilities/PathManager';

dotenv.config();
if (dotenv.error) {
  throw dotenv.error;
}

export class IOSCodeGenerator {
  constructor() {}

  generate(metadataJsonPath: string): void {
    if (!metadataJsonPath) {
      throw new Error('cannot find directory: ' + metadataJsonPath);
    }
    const sketchData: any[] = JSON.parse(PathManager.read(metadataJsonPath));
    if (!sketchData) return;

    const vcTemplatePath: string = path.join(
      process.env.TEMPLATE_DIR,
      'viewController.hbs',

dotenv

Loads environment variables from .env file

BSD-2-Clause
Latest version published 9 months ago

Package Health Score

87 / 100
Full package analysis