-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move include/exclude files lists to projects (CODE_DIR/.autopilot/.env) #164
Comments
🤖 This is my suggestion: File: README.md
File: modules/fsInput.js
const targetCodeDir = process.env.CODE_DIR;
require('dotenv').config({ path: path.join(targetCodeDir, '.autopilot', '.env') }); Make sure to add
const ignoreList = process.env.IGNORE_LIST.split(',');
const fileExtensionsToProcess = process.env.FILE_EXTENSIONS_TO_PROCESS.split(','); After making these changes, the fsInput.js file should now read the new environment variables from the target code directory's .env file. File: .env.template .env.template
File: modules/init.js
const os = require('os');
function createEnvFile(codeBaseAutopilotDirectory) {
const envFilePath = path.join(codeBaseAutopilotDirectory, '.env');
if (!fs.existsSync(envFilePath)) {
const defaultEnvContent = [
'FILE_EXTENSIONS_TO_PROCESS=.js,.tsx,.ts,.jsx',
'IGNORE_LIST=node_modules,coverage,public,__tests__',
].join(os.EOL);
fs.writeFileSync(envFilePath, defaultEnvContent);
}
}
async function initCodeBase(codeBaseDirectory, interactive) {
// ...
if (!fs.existsSync(codeBaseAutopilotDirectory)) {
fs.mkdirSync(codeBaseAutopilotDirectory);
}
// Create .env file in the target code directory
createEnvFile(codeBaseAutopilotDirectory);
// ...
} After these changes, the const path = require('path');
const { createDB } = require('./db');
const fs = require('fs');
const os = require('os');
const { codeBaseFullIndex, codeBaseFullIndexInteractive } = require('./codeBase');
const { getCodeBaseAutopilotDirectory } = require('./autopilotConfig');
function createEnvFile(codeBaseAutopilotDirectory) {
const envFilePath = path.join(codeBaseAutopilotDirectory, '.env');
if (!fs.existsSync(envFilePath)) {
const defaultEnvContent = [
'FILE_EXTENSIONS_TO_PROCESS=.js,.tsx,.ts,.jsx',
'IGNORE_LIST=node_modules,coverage,public,__tests__',
].join(os.EOL);
fs.writeFileSync(envFilePath, defaultEnvContent);
}
}
/**
*
* @param {string} codeBaseDirectory
*/
async function initCodeBase(codeBaseDirectory, interactive) {
model = process.env.INDEXER_MODEL;
// Create directory `__CODEBASE__/.autopilot`
codeBaseAutopilotDirectory = getCodeBaseAutopilotDirectory(codeBaseDirectory);
if (!fs.existsSync(codeBaseAutopilotDirectory)) {
fs.mkdirSync(codeBaseAutopilotDirectory);
}
// Create .env file in the target code directory
createEnvFile(codeBaseAutopilotDirectory);
// Create config file `__CODEBASE__/.autopilot/config.json`
// TODO: Refactor include/exclude lists into codebase config file
const { getDBFilePath } = require('./db');
// Bootstrap DB
if (!fs.existsSync(getDBFilePath(codeBaseDirectory))) {
createDB(codeBaseDirectory);
// Trigger codeBase indexing
if (interactive) {
await codeBaseFullIndexInteractive(codeBaseDirectory, model);
} else {
await codeBaseFullIndex(codeBaseDirectory);
}
}
}
module.exports = { initCodeBase }; |
Background story explaining the current situation:
We currently have the environment variables:
Inside the .env file that sits inside the autopilot code directory
Desired new situation:
The above variables should be read from the target code directory (CODE_DIR/.autopilot/.env)
Implementation details:
Move include/exclude files lists to projects (CODE_DIR/.autopilot/.env)
Bootstrap such a file under our
init
function.Read said file, including other environment variables.
Validate these env variables are set.
re: #86
re: #76
re: #163
The text was updated successfully, but these errors were encountered: