@microlight/core 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/microlight-core.js
CHANGED
|
@@ -7,6 +7,7 @@ import { packageUp } from "package-up";
|
|
|
7
7
|
|
|
8
8
|
import { prepareTasks } from "../dist/scripts/prepareTasks.js";
|
|
9
9
|
import { prepareServer } from "../dist/scripts/prepareServer.js";
|
|
10
|
+
import { prepareEnvVars } from "../dist/scripts/prepareEnvVars.js";
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
|
|
@@ -41,6 +42,9 @@ prepareCommand
|
|
|
41
42
|
|
|
42
43
|
console.log('\n');
|
|
43
44
|
await prepareServer();
|
|
45
|
+
|
|
46
|
+
console.log('\n');
|
|
47
|
+
await prepareEnvVars();
|
|
44
48
|
});
|
|
45
49
|
|
|
46
50
|
prepareCommand
|
|
@@ -66,5 +70,12 @@ prepareCommand
|
|
|
66
70
|
prepareServer();
|
|
67
71
|
});
|
|
68
72
|
|
|
73
|
+
prepareCommand
|
|
74
|
+
.command("env")
|
|
75
|
+
.description("Setup the env vars")
|
|
76
|
+
.action(async () => {
|
|
77
|
+
prepareEnvVars();
|
|
78
|
+
});
|
|
79
|
+
|
|
69
80
|
// Parse CLI arguments
|
|
70
81
|
program.parse(process.argv);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import { copySync } from "fs-extra";
|
|
4
|
+
export async function prepareEnvVars() {
|
|
5
|
+
console.log('preparing environment variables');
|
|
6
|
+
|
|
7
|
+
// Destination path
|
|
8
|
+
const serverDestDir = path.join(process.cwd(), ".microlight", "server");
|
|
9
|
+
|
|
10
|
+
// Copy .env file if it exists
|
|
11
|
+
const envFilePath = path.join(process.cwd(), '.env');
|
|
12
|
+
const envFileDestPath = path.join(serverDestDir, '.env');
|
|
13
|
+
if (fs.existsSync(envFilePath)) {
|
|
14
|
+
copySync(envFilePath, envFileDestPath, {
|
|
15
|
+
overwrite: true
|
|
16
|
+
});
|
|
17
|
+
console.log(".env file copied successfully!");
|
|
18
|
+
}
|
|
19
|
+
}
|