UNPKG

@cocalc/project

Version:
50 lines 1.89 kB
"use strict"; /* Responsible for creating the info.json file that's in the temporary store (e.g., ~/.smc) for the project. It is used by various scripts and programs to get basic information about the project. */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.INFO = void 0; const os_1 = require("os"); const fs_1 = require("fs"); const awaiting_1 = require("awaiting"); const logger_1 = require("./logger"); const data_1 = require("./data"); const init_program_1 = require("./init-program"); const base_path_1 = __importDefault(require("@cocalc/backend/base-path")); let INFO; exports.INFO = INFO; async function init() { const winston = (0, logger_1.getLogger)("info-json init"); winston.info("initializing the info.json file..."); let host; if (process.env.HOST != null) { host = process.env.HOST; } else if (init_program_1.options.kucalc) { // what we want for the Google Compute engine deployment // earlier, there was eth0, but newer Ubuntu's on GCP have ens4 const nics = (0, os_1.networkInterfaces)(); const mynic = nics.eth0 ?? nics.ens4; host = mynic?.[0].address ?? "localhost"; } else { // for a single machine (e.g., cocalc-docker) host = "localhost"; } exports.INFO = INFO = { project_id: data_1.project_id, location: { host, username: data_1.username }, base_path: base_path_1.default, base_url: base_path_1.default, // for backwards compat userspace code }; await (0, awaiting_1.callback)(fs_1.writeFile, data_1.infoJson, JSON.stringify(INFO)); winston.info(`Successfully wrote "${data_1.infoJson}"`); } exports.default = init; //# sourceMappingURL=info-json.js.map