Add .gitignore to exclude all node packages and lock files
This commit is contained in:
+172
@@ -0,0 +1,172 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getEnvironmentVariables = void 0;
|
||||
const renderer_1 = require("@remotion/renderer");
|
||||
const studio_server_1 = require("@remotion/studio-server");
|
||||
const dotenv_1 = __importDefault(require("dotenv"));
|
||||
const node_fs_1 = __importStar(require("node:fs"));
|
||||
const node_path_1 = __importDefault(require("node:path"));
|
||||
const chalk_1 = require("./chalk");
|
||||
const config_1 = require("./config");
|
||||
const make_link_1 = require("./hyperlinks/make-link");
|
||||
const log_1 = require("./log");
|
||||
const parsed_cli_1 = require("./parsed-cli");
|
||||
function getProcessEnv() {
|
||||
const env = {};
|
||||
const validKeys = Object.keys(process.env).filter((key) => key.startsWith('REMOTION_'));
|
||||
for (const key of validKeys) {
|
||||
env[key] = process.env[key];
|
||||
}
|
||||
return env;
|
||||
}
|
||||
const watchEnvFile = ({ processEnv, envFile, onUpdate, logLevel, }) => {
|
||||
const updateFile = async () => {
|
||||
const file = await node_fs_1.default.promises.readFile(envFile, 'utf-8');
|
||||
onUpdate({
|
||||
...processEnv,
|
||||
...dotenv_1.default.parse(file),
|
||||
});
|
||||
};
|
||||
const { unwatch } = studio_server_1.StudioServerInternals.installFileWatcher({
|
||||
file: envFile,
|
||||
onChange: async (type) => {
|
||||
try {
|
||||
if (type === 'deleted') {
|
||||
log_1.Log.warn({ indent: false, logLevel }, `${envFile} was deleted.`);
|
||||
}
|
||||
else if (type === 'changed') {
|
||||
await updateFile();
|
||||
log_1.Log.info({ indent: false, logLevel }, chalk_1.chalk.blueBright(`Updated env file ${envFile}`));
|
||||
}
|
||||
else if (type === 'created') {
|
||||
await updateFile();
|
||||
log_1.Log.info({ indent: false, logLevel }, chalk_1.chalk.blueBright(`Created env file ${envFile}`));
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
log_1.Log.error({ indent: false, logLevel }, `${envFile} update failed with error ${err.stack}`);
|
||||
}
|
||||
},
|
||||
});
|
||||
return unwatch;
|
||||
};
|
||||
const getEnvForEnvFile = ({ processEnv, envFile, onUpdate, logLevel, indent, }) => {
|
||||
try {
|
||||
const envFileData = (0, node_fs_1.readFileSync)(envFile);
|
||||
if (onUpdate) {
|
||||
if (typeof node_fs_1.default.watchFile === 'undefined') {
|
||||
log_1.Log.warn({ indent: false, logLevel }, 'Unsupported feature (fs.watchFile): .env file will not hot reload.');
|
||||
}
|
||||
else {
|
||||
watchEnvFile({ processEnv, envFile, onUpdate, logLevel });
|
||||
}
|
||||
}
|
||||
const relativeEnvFile = node_path_1.default.relative(process.cwd(), envFile);
|
||||
log_1.Log.verbose({ indent, logLevel }, `Loaded env file from ${(0, make_link_1.makeHyperlink)({ fallback: envFile, text: relativeEnvFile, url: 'file://' + envFile })}.`);
|
||||
return {
|
||||
...processEnv,
|
||||
...dotenv_1.default.parse(envFileData),
|
||||
};
|
||||
}
|
||||
catch (err) {
|
||||
log_1.Log.error({ indent: false, logLevel }, `Your .env file at ${envFile} could not not be parsed.`);
|
||||
log_1.Log.error({ indent: false, logLevel }, err);
|
||||
process.exit(1);
|
||||
}
|
||||
};
|
||||
const findDotEnvFile = (remotionRoot) => {
|
||||
const defaultEnvFile = node_path_1.default.resolve(remotionRoot, '.env');
|
||||
const paths = [defaultEnvFile, node_path_1.default.resolve(remotionRoot, '.env.local')];
|
||||
for (const p of paths) {
|
||||
if (node_fs_1.default.existsSync(p)) {
|
||||
return { found: p, defaultEnvFile };
|
||||
}
|
||||
}
|
||||
return { found: null, defaultEnvFile };
|
||||
};
|
||||
const getEnvironmentVariables = (onUpdate, logLevel, indent) => {
|
||||
const processEnv = getProcessEnv();
|
||||
if (parsed_cli_1.parsedCli['env-file']) {
|
||||
const envFile = node_path_1.default.resolve(process.cwd(), parsed_cli_1.parsedCli['env-file']);
|
||||
if (!node_fs_1.default.existsSync(envFile)) {
|
||||
log_1.Log.error({ indent: false, logLevel }, 'You passed a --env-file but it could not be found.');
|
||||
log_1.Log.error({ indent: false, logLevel }, 'We looked for the file at:', envFile);
|
||||
log_1.Log.error({ indent: false, logLevel }, 'Check that your path is correct and try again.');
|
||||
process.exit(1);
|
||||
}
|
||||
return getEnvForEnvFile({ processEnv, envFile, onUpdate, logLevel, indent });
|
||||
}
|
||||
const remotionRoot = renderer_1.RenderInternals.findRemotionRoot();
|
||||
const configFileSetting = config_1.ConfigInternals.getDotEnvLocation();
|
||||
if (configFileSetting) {
|
||||
const envFile = node_path_1.default.resolve(remotionRoot, configFileSetting);
|
||||
if (!node_fs_1.default.existsSync(envFile)) {
|
||||
log_1.Log.error({ indent: false, logLevel }, 'You specified a custom .env file using `Config.setDotEnvLocation()` in the config file but it could not be found');
|
||||
log_1.Log.error({ indent: false, logLevel }, 'We looked for the file at:', envFile);
|
||||
log_1.Log.error({ indent: false, logLevel }, 'Check that your path is correct and try again.');
|
||||
process.exit(1);
|
||||
}
|
||||
return getEnvForEnvFile({ processEnv, envFile, onUpdate, logLevel, indent });
|
||||
}
|
||||
const { defaultEnvFile, found } = findDotEnvFile(remotionRoot);
|
||||
if (!found) {
|
||||
if (onUpdate) {
|
||||
if (typeof node_fs_1.default.watchFile === 'undefined') {
|
||||
log_1.Log.warn({ indent: false, logLevel }, 'Unsupported Bun feature: .env file will not hot reload.');
|
||||
}
|
||||
else {
|
||||
watchEnvFile({
|
||||
processEnv,
|
||||
envFile: defaultEnvFile,
|
||||
onUpdate,
|
||||
logLevel,
|
||||
});
|
||||
}
|
||||
}
|
||||
return processEnv;
|
||||
}
|
||||
return getEnvForEnvFile({
|
||||
processEnv,
|
||||
envFile: found,
|
||||
onUpdate,
|
||||
logLevel,
|
||||
indent,
|
||||
});
|
||||
};
|
||||
exports.getEnvironmentVariables = getEnvironmentVariables;
|
||||
Reference in New Issue
Block a user