How to use the envfile.stringifySync function in envfile

To help you get started, we’ve selected a few envfile 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 hernanjkd / Resume-Builder / deploy-to-github.js View on Github external
Add your remote by doing:
$ git remote add origin 
`);
return;
}
Console.info("The remote was found successfully, starting the deploy from here: "+origin);

//get the repository project name
const repository = gh(origin);

// update the env file
const envPath = './.env';
const env = envfile.parseFileSync(envPath);
env['BASENAME'] = `/${repository["name"]}/`;
Console.info("Updating the .env file with the basename "+repository["name"]);
fs.writeFileSync(envPath, envfile.stringifySync(env));

const compiler = webpack(require(path.resolve(__dirname, 'webpack.prod.js')));
compiler.run((err, stats) => {
    if (err || stats.hasErrors()) {
      console.log(stats.toString({
        colors: true
      }));
      Console.error("There was an error compiling, review above");
      return;
    }
    Console.success("Your code compiled successfully, proceding to deploy...");
    ghpages.publish('public', function(err) {
        if(err){
            console.error(err);
            Console.error("There was an error publishing your website");
            return;
github keystonejs / keystone / cypress / scripts / utils.js View on Github external
// Load the required env vars
  let required = dotEnv.parse(fs.readFileSync(`${directory}/.env.example`));

  // Inject the prefix onto the keys
  required = Object.keys(required).reduce(
    (memo, requiredKey) =>
      Object.assign(memo, {
        [`${ciEnvPrefix}${requiredKey}`]: required[requiredKey],
      }),
    {}
  );

  // write back to a temporary file
  const tmpobj = tmp.fileSync();
  fs.writeFileSync(tmpobj.fd, envfile.stringifySync(required));

  // Use that temporary file as the 'expected env' vars
  const envVars = dotEnvSafe.config({
    example: tmpobj.name,
  });

  if (envVars.error) {
    // TODO: Better error with info on how to set the correct env vars
    throw new Error(envVars.error);
  }

  // The loaded env vars with the prefix removed
  const loadedEnvVars = Object.keys(envVars.parsed)
    .filter(key => key.startsWith(ciEnvPrefix))
    .reduce(
      (memo, key) =>
github MobileTribe / panda-lab / agent / scripts / genEnv.js View on Github external
const envfile = require('envfile');

const config = require("../../.config/config.json");

const apiKey = config.apiKey;
const authDomain = config.authDomain;
const projectId = config.projectId;
const databaseUrl = config.databaseUrl;
const messagingSenderId = config.messagingSenderId;
const storageBucket = config.storageBucket;
const apiUrl = config.apiUrl;
const authProviders = config.authProviders;

const env = envfile.stringifySync({
    VUE_APP_API_KEY: apiKey,
    VUE_APP_AUTH_DOMAIN: authDomain,
    VUE_APP_PROJECT_ID: projectId,
    VUE_APP_DATABASE_URL: databaseUrl,
    VUE_APP_MESSAGING_SENDER_ID: messagingSenderId,
    VUE_APP_STORAGE_BUCKET: storageBucket,
    VUE_APP_API_URL: apiUrl,
    VUE_APP_AUTH_PROVIDERS: authProviders
});

const fs = require('fs');

fs.writeFile(__dirname + "/../.env", env, function(err) {
    if(err) {
        return console.log(err);
    }
github stefanvanherwijnen / quasar-auth-starter / backend / console / configure.js View on Github external
sk.generate().then(() => {
      let b64 = sk.encode() 
      env.PASETO_KEY = b64
      let output = envfile.stringifySync(env)
      fs.writeFileSync(sourcePath, output)
      console.log('New PASETO key has been sucessfully generated.')
    });
  } catch (err) {
github bloom510 / faunadb-nodejs-examples / fauna-bootstrap / index.js View on Github external
);
        console.log('Created server key')
        env.FDB_SERVER_KEY = _server.secret;
    } catch (e) {
        console.log(e)
    }
    try {
        _client = await client.query(
            CreateKey({ database: Database('testdb'), role: 'client' })
        );
        console.log('Created client key')
        env.FDB_CLIENT_KEY = _client.secret;
    } catch (e) {
        console.log(e)
    }
    await fs.writeFile('./.env', envfile.stringifySync(env), () => console.log('Published environmental variables'));
    return { server: _server.secret, client: _client.secret };
}
github EmaSuriano / gatsby-starter-mate / bin / setup.js View on Github external
.then(({ spaceId, deliveryToken, managementToken }) => {
    console.log('Writing config file...');

    const configFilePath = path.resolve(__dirname, '..', '.env');
    const envData = envfile.stringifySync({
      SPACE_ID: spaceId,
      ACCESS_TOKEN: deliveryToken,
    });

    writeFileSync(configFilePath, envData);
    console.log(`Config file ${chalk.yellow(configFilePath)} written`);

    return { spaceId, managementToken };
  })
  .then(({ spaceId, managementToken }) =>
github bloom510 / faunadb-nodejs-examples / auth / fql-auth / bootstrap / index.js View on Github external
);
    console.log("Created server key");
    env.FDB_FQL_SERVER_KEY = _server.secret;
  } catch (e) {
    console.log(e);
  }
  try {
    _client = await client.query(
      CreateKey({ database: Database("testdb"), role: "client" })
    );
    console.log("Created client key");
    env.FDB_FQL_CLIENT_KEY = _client.secret;
  } catch (e) {
    console.log(e);
  }
  await fs.writeFile("./.env", envfile.stringifySync(env), () =>
    console.log("Published environmental variables")
  );
  return { server: _server.secret, client: _client.secret };
};
github ArkEcosystem / core / packages / core / src / commands / env / set.ts View on Github external
public async run(): Promise {
        const { args, paths } = await this.parseWithNetwork(SetCommand);

        const envFile = `${paths.config}/.env`;

        if (!existsSync(envFile)) {
            this.error(`No environment file found at ${envFile}`);
        }

        const env = envfile.parseFileSync(envFile);

        env[args.key] = args.value;

        writeFileSync(envFile, envfile.stringifySync(env));
    }
}
github badassery / laravel-up / src / actions / publish-environment.ts View on Github external
["DB_USERNAME", "root"],
    ["DB_PASSWORD", envConfig.dbRootPassword],
    ["DB_DATABASE", envConfig.dbName],
    ["DB_CONNECTION", envConfig.engine === POSTGRES ? "pgsql" : "mysql"],
    ["DB_PORT", envConfig.engine === POSTGRES ? 5432 : 3306]
  ];

  envOverrides.forEach(([key, value]) => {
    envFileContents[key] = value;
    envExampleFileContents[key] = value;
  });

  fs.writeFileSync(envPath, envfile.stringifySync(envFileContents));
  fs.writeFileSync(
    envExamplePath,
    envfile.stringifySync(envExampleFileContents)
  );
};

envfile

Parse and stringify the environment configuration files and format, also known as .env files and dotenv files

Artistic-2.0
Latest version published 11 months ago

Package Health Score

71 / 100
Full package analysis