Fetch the main theme ID from Shopify

@param   env   String  The environment to check against
@return        Promise Reason for abort or the main theme ID
497853
function fetchMainThemeId() {
  _validateEnvValues();

  return new Promise((resolve, reject) => {
    https.get(
      {
        hostname: slateEnv.getStoreValue(),
        path: '/admin/themes.json',
        auth: `:${slateEnv.getPasswordValue}`,
        agent: false,
        headers: {
          'X-Shopify-Access-Token': slateEnv.getPasswordValue(),
        },
      },
      (res) => {
        let body = '';

        res.on('data', (datum) => (body += datum));

        res.on('end', () => {
          const parsed = JSON.parse(body);

          if (parsed.errors) {
            reject(
              new Error(
                `API request to fetch main theme ID failed: \n${JSON.stringify(
                  parsed.errors,
                  null,
                  '\t',
                )}`,
              ),
            );
            return;
          }

          if (!Array.isArray(parsed.themes)) {
            reject(
              new Error(
                `Shopify response for /admin/themes.json is not an array. ${JSON.stringify(
                  parsed,
                  null,
                  '\t',
                )}`,
              ),
            );
            return;
          }

          const mainTheme = parsed.themes.find((t) => t.role === 'main');

          if (!mainTheme) {
            reject(
              new Error(
                `No main theme in response. ${JSON.stringify(
                  parsed.themes,
                  null,
                  '\t',
                )}`,
              ),
            );
            return;
          }

          resolve(mainTheme.id);
        });
      },
    );
  });
}
202572
protected function getPantheonSiteEnv($env = '') {
    $site = getenv('TERMINUS_SITE');

    if (!$env) {
      $env = getenv('TERMINUS_ENV');
    }

    return join('.', [$site, $env]);
  }
510351
def call(env)
      if env[:method] == :get && env[:url].to_s.size > 2000
        env[:request_headers][HEADER] = 'GET'
        env[:request_headers]['Content-Type'] =
          'application/x-www-form-urlencoded'
        env[:body] = env[:url].query
        env[:url].query = nil
        env[:method] = :post
      end

      @app.call(env)
    end
78581
public function get($key, $env = NULL)
    {
        if (!$env) {
            $env = self::$current_env;
        }

        return isset(self::$params[$env][$key]) ? self::$params[$env][$key] : NULL;
    }
580319
function env(environment) {
  environment = environment || {};

  if ('object' === typeof process && 'object' === typeof process.env) {
    env.merge(environment, process.env);
  }

  if ('undefined' !== typeof window) {
    if ('string' === window.name && window.name.length) {
      env.merge(environment, env.parse(window.name));
    }

    if (window.localStorage) {
      try { env.merge(environment, env.parse(window.localStorage.env || window.localStorage.debug)); }
      catch (e) {}
    }

    if (
         'object' === typeof window.location
      && 'string' === typeof window.location.hash
      && window.location.hash.length
    ) {
      env.merge(environment, env.parse(window.location.hash.charAt(0) === '#'
        ? window.location.hash.slice(1)
        : window.location.hash
      ));
    }
  }

  //
  // Also add lower case variants to the object for easy access.
  //
  var key, lower;
  for (key in environment) {
    lower = key.toLowerCase();

    if (!(lower in environment)) {
      environment[lower] = environment[key];
    }
  }

  return environment;
}
17464
function ___GET_ENV_HOSTNAME() {
	try {
		if ( HAS_NODE_BUFFER ) {
			return require( 'os' ).hostname;
		}
		else
		if ( typeof window !== "undefined" ) {
			return window.location.hostname;
		}
		else {
			throw new Error("");
		}
	}
	catch(e) {
		return 'unknown.' + DumpHexStringLE(RandomBytes(32));
	}
}
714077
def get_env(key)
      env = ENV[key.upcase]
      return nil if env.nil?

      # Try to convert it into a boolean value.
      return true if env.casecmp("true").zero?
      return false if env.casecmp("false").zero?

      # Try to convert it into an integer. Otherwise just keep the string.
      begin
        Integer(env)
      rescue ArgumentError
        env
      end
    end
887113
def __get_env_handle(self, root_dir):
        
        env_path = os.path.join(root_dir, '.env')
        gui_path = os.path.join(root_dir, '.gui')
        fh = open(env_path, "w+")
        # .env will source utils.sh if it hasn't already
        fh.write(source_template % (gui_path, gui_path))
        fh.write(source_template % (self.shell_util_path,
                                    self.shell_util_path))
        return (env_path, fh)
1325307
public String getEnvironment(){
        String env = "development";

        if(!blank(System.getenv("ACTIVE_ENV"))){
            env = System.getenv("ACTIVE_ENV");
        }

        if(!blank(System.getProperty("active_env"))){
            env = System.getProperty("active_env");
        }
        return env;
    }
1244570
public static String get() {
		String env = System.getProperty("JOGGER_ENV");
		if (env == null) {
			env = System.getenv("JOGGER_ENV");
		}

		if (env == null) {
			return "dev";
		}

		return env;
	}
519281
function getIfOverriden() {
    var args = process.argv.slice(2);
    var envFlagIndex = args.indexOf('--env');

    // check if environment string passed as argument
    if (!!~envFlagIndex) {
        return args[++envFlagIndex];
    }
    // check if environment is already set
    else if (isset(process.env.NODE_ENV)) {
        return process.env.NODE_ENV;
    } else {
        return false;
    }


}
1177466
def pull_request_url(env)
      url = env["CI_PULL_REQUEST"]

      if url.nil? && !env["CIRCLE_PROJECT_USERNAME"].nil? && !env["CIRCLE_PROJECT_REPONAME"].nil?
        repo_slug = env["CIRCLE_PROJECT_USERNAME"] + "/" + env["CIRCLE_PROJECT_REPONAME"]
        if !env["CIRCLE_PR_NUMBER"].nil?
          host = env["DANGER_GITHUB_HOST"] || "github.com"
          url = "https://" + host + "/" + repo_slug + "/pull/" + env["CIRCLE_PR_NUMBER"]
        else
          token = env["DANGER_CIRCLE_CI_API_TOKEN"]
          url = fetch_pull_request_url(repo_slug, env["CIRCLE_BUILD_NUM"], token)
        end
      end
      url
    end
163859
function(bundle, env) {

            if ( !self.isStandalone ) {
                if ( !bundle && typeof(self.bundle) != 'undefined' ) {
                    var bundle = self.bundle
                }
                return ( typeof(self.envConf) != "undefined" ) ? self.envConf[bundle][env] : null;
            } else {

                if (!bundle) { // if getContext().bundle is lost .. eg.: worker context
                    var model       = (arguments.length == 1) ? bundle : model
                        , file      = ( !/node_modules/.test(__stack[1].getFileName()) ) ?  __stack[1].getFileName() : __stack[2].getFileName()
                        , a         = file.replace('.js', '').split('/')
                        , i         = a.length-1
                        , bundles   = getContext('gina').config.bundles
                        , index     = 0;

                    for (; i >= 0; --i) {
                        index = bundles.indexOf(a[i]);
                        if ( index > -1 ) {
                            bundle = bundles[index];
                            break
                        }
                    }
                }

                if ( typeof(self.envConf) != "undefined" ) {
                    self.envConf[bundle][env].hostname = self.envConf[self.startingApp][env].hostname;
                    self.envConf[bundle][env].content.routing = self.envConf[self.startingApp][env].content.routing;

                    if ( bundle && env ) {
                        return self.envConf[bundle][env]
                    } else if ( bundle && !env ) {
                        return self.envConf[bundle]
                    } else {
                        return self.envConf
                    }
                }

                return null
            }
        }
1026453
public function getEnvCmd(string $env = 'WINDWALKER_MODE', string $value = 'dev'): string
    {
        $prefix = $this->environment->getPlatform()->isWin()
            ? 'set'
            : 'export';

        return sprintf('%s %s=%s', $prefix, $env, $value);
    }
1176584
function EnvLookupError (e) {

    e = e || {};

    var code = e.code || ERR_UNKNOWN;
    var hostname = e.hostname || '';

    this.message = e.message || 'Environment lookup failed: ' + code;
    this.code = code;
    this.hostname = hostname;

}
1111458
public function getlogActivity(string $env):Renderer
    {
        if (!in_array($env, array("dev", "prod"))) {
            throw new Server500(new \ArrayObject(array("explain" => "Bad environment name $env",
                "solution" => "Environment must be 'dev' or 'prod' ")));
        }
        $last = array_values((AbstractServer::getLogs($env)));
        $lastn = array();
        $request = $this->get('request');
        $loglastpos =  $request->get('pos');
        $orderby = 29;
        if ($loglastpos == null) {
            return ((new Renderer())->jsonRenderer(array("code" => 500, "results" => "Cannot get the last position")));
        }
        $loglastpos = (int)$loglastpos;
        $max = $loglastpos + $orderby;
        for ($i = $loglastpos; $i <= $max; $i++) {
            if (!isset($last[$i])) {
                continue;
            }
            $one = $last[$i];
            $last["env"] = strtoupper($env);
            $last[$i]['time'] = strtotime($last[$i]['time']);
            $last[$i]['log_url'] = $this->generateRoute(
                "iumio_manager_logs_manager_get_one",
                array("uidie" => $one['uidie'], "env" => $env)
            );
            array_push($lastn, $last[$i]);
        }
        return ((new Renderer())->jsonRenderer(array("code" => 200, "results" => $lastn)));
    }
1083612
public static String getEnv(){
        if(ENV == null){
            if(!blank(System.getenv("ACTIVE_ENV"))) {
                ENV = System.getenv("ACTIVE_ENV");
            }

            if(!blank(System.getProperty("ACTIVE_ENV"))) {
                ENV = System.getProperty("ACTIVE_ENV");
            }

            if(!blank(System.getProperty("active_env"))) {
                ENV = System.getProperty("active_env");
            }

            if(blank(ENV)){
                ENV = "development";
                LogFilter.log(LOGGER, LogLevel.INFO, "Environment variable ACTIVE_ENV not provided, defaulting to '" + ENV + "'");
            }
        }
        return ENV;
    }