@orion-js/core 3.1.9 → 3.1.10
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/lib/build/index.js
CHANGED
|
@@ -17,7 +17,7 @@ async function default_1({ output, envPath }) {
|
|
|
17
17
|
console.log(safe_1.default.bold('Compiling your app...'));
|
|
18
18
|
(0, compile_1.compile)({ output });
|
|
19
19
|
(0, writeIndex_1.default)({ basePath: output });
|
|
20
|
-
(0, writeEnvFile_1.writeEnvFile)({ basePath: output, envPath });
|
|
20
|
+
(0, writeEnvFile_1.writeEnvFile)({ basePath: output, envPath, createDtsFile: false });
|
|
21
21
|
console.log(safe_1.default.bold('Build created'));
|
|
22
22
|
}
|
|
23
23
|
exports.default = default_1;
|
|
@@ -28,7 +28,7 @@ function getHost(runner) {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
(0, writeIndex_1.default)({ basePath: runner.basePath });
|
|
31
|
-
(0, writeEnvFile_1.writeEnvFile)({ basePath: runner.basePath, envPath: runner.envPath });
|
|
31
|
+
(0, writeEnvFile_1.writeEnvFile)({ basePath: runner.basePath, envPath: runner.envPath, createDtsFile: true });
|
|
32
32
|
runner.restart();
|
|
33
33
|
}
|
|
34
34
|
};
|
|
@@ -3,11 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.writeEnvFile = exports.watchEnvFile = void 0;
|
|
6
|
+
exports.writeEnvFile = exports.getDts = exports.watchEnvFile = void 0;
|
|
7
7
|
const getConfig_1 = require("../../env/add/getConfig");
|
|
8
8
|
const writeFile_1 = __importDefault(require("../../helpers/writeFile"));
|
|
9
9
|
const chokidar_1 = __importDefault(require("chokidar"));
|
|
10
10
|
const safe_1 = __importDefault(require("colors/safe"));
|
|
11
|
+
const getFileContents_1 = __importDefault(require("../../helpers/getFileContents"));
|
|
11
12
|
const watchEnvFile = async (runner) => {
|
|
12
13
|
if (!runner.envPath)
|
|
13
14
|
return;
|
|
@@ -15,14 +16,25 @@ const watchEnvFile = async (runner) => {
|
|
|
15
16
|
chokidar_1.default.watch(filePath, { ignoreInitial: true }).on('change', async () => {
|
|
16
17
|
(0, exports.writeEnvFile)({
|
|
17
18
|
envPath: runner.envPath,
|
|
18
|
-
basePath: runner.basePath
|
|
19
|
+
basePath: runner.basePath,
|
|
20
|
+
createDtsFile: true
|
|
19
21
|
});
|
|
20
22
|
console.log(safe_1.default.bold(`=> Environment file changed. Restarting...`));
|
|
21
23
|
runner.restart();
|
|
22
24
|
});
|
|
23
25
|
};
|
|
24
26
|
exports.watchEnvFile = watchEnvFile;
|
|
25
|
-
const
|
|
27
|
+
const getDts = config => {
|
|
28
|
+
const keys = [...Object.keys(config.cleanKeys), ...Object.keys(config.encryptedKeys)];
|
|
29
|
+
return `declare module '@orion-js/env' {
|
|
30
|
+
export const env: {
|
|
31
|
+
${keys.map(key => ` ${key}: string;`).join('\n')}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
};
|
|
36
|
+
exports.getDts = getDts;
|
|
37
|
+
const writeEnvFile = async ({ basePath, envPath, createDtsFile }) => {
|
|
26
38
|
const filePath = `${basePath}/env.js`;
|
|
27
39
|
if (!envPath) {
|
|
28
40
|
(0, writeFile_1.default)(filePath, `global.__orion_env__ = null`);
|
|
@@ -30,6 +42,13 @@ const writeEnvFile = async ({ basePath, envPath }) => {
|
|
|
30
42
|
}
|
|
31
43
|
const config = (0, getConfig_1.getConfig)(envPath);
|
|
32
44
|
const configJSON = JSON.stringify(config, null, 2);
|
|
45
|
+
if (createDtsFile) {
|
|
46
|
+
const currentFile = (0, getFileContents_1.default)('./app/env.d.ts');
|
|
47
|
+
const dts = (0, exports.getDts)(config);
|
|
48
|
+
if (currentFile !== dts) {
|
|
49
|
+
(0, writeFile_1.default)('./app/env.d.ts', dts);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
33
52
|
(0, writeFile_1.default)(filePath, `global.__orion_env__ = ${configJSON}`);
|
|
34
53
|
};
|
|
35
54
|
exports.writeEnvFile = writeEnvFile;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orion-js/core",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.10",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"author": "nicolaslopezj",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"upgrade-interactive": "yarn upgrade-interactive"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@orion-js/crypto": "^3.1.
|
|
19
|
+
"@orion-js/crypto": "^3.1.10",
|
|
20
20
|
"chokidar": "3.5.3",
|
|
21
21
|
"colors": "^1.4.0",
|
|
22
22
|
"commander": "^8.3.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"engines": {
|
|
35
35
|
"node": ">=14.0.0"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "40fa0800303f49ad08890b2bedff2cdadb81360d",
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@shelf/jest-mongodb": "^2.1.0",
|
|
40
40
|
"@types/prompts": "^2.0.14"
|