Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*.user
*.userosscache
*.sln.docstates
package-lock*

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
Expand Down
60 changes: 60 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
const fs = require('fs');
const path = require('path');

const apiEnvContent = `
APP_TOKEN_KEY=MIGRATION_V2
PORT=5001
`;

const uiEnvContent = `
REACT_APP_WEBSITE_BASE_URL="http://localhost:3000/"
REACT_APP_BASE_API_URL="http://localhost:5001/"
REACT_APP_API_VERSION=v2
REACT_APP_HOST="http://localhost:3000"
REACT_APP_UPLOAD_SERVER="http://localhost:4002/"
REACT_APP_OFFLINE_CMS=true
`;

const uploadAPIEnvContent = `
PORT=4002
NODE_BACKEND_API =http://localhost:5001
`;

const envFilePaths = {
API: path.join(__dirname, 'api', 'production.env'),
UI: path.join(__dirname, 'ui', '.env.local'),
'Upload-API': path.join(__dirname, 'upload-api', '.env'),
};

// Define the contents for each file in an array
const envContents = {
API: apiEnvContent,
UI: uiEnvContent,
'Upload-API': uploadAPIEnvContent,
};

// Function to create env files
const createEnvFiles = () => {
// Loop through each key in the envFilePaths object
Object.keys(envFilePaths).forEach((key) => {
const filePath = envFilePaths[key];
const dir = path.dirname(filePath);

// Ensure the directory exists, if not, create it
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true });
}

// Write the content to the env file corresponding to the key
fs.writeFile(filePath, envContents[key], (err) => {
if (err) {
console.error(`Error creating ${key} file at ${filePath}:`, err);
} else {
console.log(`${key} env file created successfully!`);
}
});
});
};

// Run the function to create the files
createEnvFiles();
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "(cd ./api && npm install --force) ; (cd ./ui && npm install --force) ; (cd ./upload-api && npm install --force)",
"env": "npm start",
"api": "cd ./api && npm run dev",
"upload": "cd ./upload-api && npm start",
"ui": "cd ./ui && npm start"
"ui": "cd ./ui && npm start",
"start": "node index.js"
},
"repository": {
"type": "git",
Expand Down
11 changes: 10 additions & 1 deletion ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion upload-api/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

PORT=4002
NODE_BACKEND_API =http://localhost:5001
NODE_BACKEND_API =http://localhost:5001