@hsuite/smart-engines-cli 4.0.0 → 4.0.1
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/README.md +3 -2
- package/dist/_lib/shell-env.d.ts +14 -2
- package/dist/_lib/shell-env.d.ts.map +1 -1
- package/dist/_lib/shell-env.js +31 -4
- package/dist/_lib/shell-env.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -51,8 +51,9 @@ The generated `.env.local`:
|
|
|
51
51
|
APP_ID=smart-app-showcase-local
|
|
52
52
|
APP_NAME=Smart App Showcase (local)
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
HSUITE_NETWORK=testnet
|
|
55
|
+
VALIDATOR_URL=https://gateway.testnet.hsuite.network
|
|
56
|
+
SMART_HOST_URL=https://gateway.testnet.hsuite.network
|
|
56
57
|
|
|
57
58
|
XRPL_NETWORK=testnet
|
|
58
59
|
XRPL_ADDRESS=r...
|
package/dist/_lib/shell-env.d.ts
CHANGED
|
@@ -6,11 +6,23 @@ export declare function shellEnvironment(): Readonly<NodeJS.ProcessEnv>;
|
|
|
6
6
|
* Returns true when it dropped one.
|
|
7
7
|
*/
|
|
8
8
|
export declare function dropFileProvidedSigner(beforeDotenv: string | undefined, processEnv?: NodeJS.ProcessEnv): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Read `.env` in `cwd` and copy each key that `processEnv` does not already hold. Writes nothing
|
|
11
|
+
* to stdout or stderr, whatever either environment says.
|
|
12
|
+
*
|
|
13
|
+
* Why not `dotenv.config({ quiet: true })`: dotenv 17 ORs that option with `DOTENV_CONFIG_QUIET`
|
|
14
|
+
* and `DOTENV_CONFIG_DEBUG`, read from the shell AND re-read after the file is merged, so a `.env`
|
|
15
|
+
* line `DOTENV_CONFIG_QUIET=false` (or `DOTENV_CONFIG_DEBUG=true`) puts its banner back on stdout
|
|
16
|
+
* and breaks every `--json` result. `dotenv.parse` and an option-less `dotenv.populate` never log.
|
|
17
|
+
* A missing or unreadable file is skipped, as `dotenv.config` skips it. `DOTENV_KEY` vault
|
|
18
|
+
* decryption is not supported. Returns the keys it set.
|
|
19
|
+
*/
|
|
20
|
+
export declare function populateDotenvSilently(cwd?: string, processEnv?: NodeJS.ProcessEnv): readonly string[];
|
|
9
21
|
/**
|
|
10
22
|
* Load `.env` from the working directory, keeping the shell's environment apart from it.
|
|
11
23
|
*
|
|
12
|
-
* The ORDER is the guarantee: the snapshot is taken first,
|
|
13
|
-
* `HSUITE_SIGNER`
|
|
24
|
+
* The ORDER is the guarantee: the snapshot is taken first, the file is merged second, and an
|
|
25
|
+
* `HSUITE_SIGNER` it introduced is dropped third. Returns the snapshot.
|
|
14
26
|
*/
|
|
15
27
|
export declare function loadDotenv(warn?: (message: string) => void): Readonly<NodeJS.ProcessEnv>;
|
|
16
28
|
//# sourceMappingURL=shell-env.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell-env.d.ts","sourceRoot":"","sources":["../../src/_lib/shell-env.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shell-env.d.ts","sourceRoot":"","sources":["../../src/_lib/shell-env.ts"],"names":[],"mappings":"AA2BA,uFAAuF;AACvF,wBAAgB,gBAAgB,IAAI,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAE9D;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,UAAU,GAAE,MAAM,CAAC,UAAwB,GAC1C,OAAO,CAKT;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,GAAE,MAAsB,EAC3B,UAAU,GAAE,MAAM,CAAC,UAAwB,GAC1C,SAAS,MAAM,EAAE,CASnB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,IAAI,GAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAA0C,GACpE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAU7B"}
|
package/dist/_lib/shell-env.js
CHANGED
|
@@ -35,11 +35,12 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.shellEnvironment = shellEnvironment;
|
|
37
37
|
exports.dropFileProvidedSigner = dropFileProvidedSigner;
|
|
38
|
+
exports.populateDotenvSilently = populateDotenvSilently;
|
|
38
39
|
exports.loadDotenv = loadDotenv;
|
|
39
40
|
/**
|
|
40
41
|
* The environment the user's SHELL gave the CLI, kept apart from what `dotenv` adds to it.
|
|
41
42
|
*
|
|
42
|
-
*
|
|
43
|
+
* {@link loadDotenv} copies a `.env` in the working directory into `process.env`. That file can
|
|
43
44
|
* come with a cloned repository, so nothing that decides WHAT PROGRAM RUNS, or how it runs, may be
|
|
44
45
|
* read from the merged environment:
|
|
45
46
|
*
|
|
@@ -52,6 +53,8 @@ exports.loadDotenv = loadDotenv;
|
|
|
52
53
|
* {@link loadDotenv} is the CLI's one bootstrap step: snapshot, load, drop. `index.ts` calls it
|
|
53
54
|
* before any command runs.
|
|
54
55
|
*/
|
|
56
|
+
const fs_1 = require("fs");
|
|
57
|
+
const path_1 = require("path");
|
|
55
58
|
const dotenv = __importStar(require("dotenv"));
|
|
56
59
|
/**
|
|
57
60
|
* The shell snapshot. Taken when this module is first loaded, which is before `index.ts` runs
|
|
@@ -77,15 +80,39 @@ function dropFileProvidedSigner(beforeDotenv, processEnv = process.env) {
|
|
|
77
80
|
processEnv.HSUITE_SIGNER = beforeDotenv;
|
|
78
81
|
return true;
|
|
79
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Read `.env` in `cwd` and copy each key that `processEnv` does not already hold. Writes nothing
|
|
85
|
+
* to stdout or stderr, whatever either environment says.
|
|
86
|
+
*
|
|
87
|
+
* Why not `dotenv.config({ quiet: true })`: dotenv 17 ORs that option with `DOTENV_CONFIG_QUIET`
|
|
88
|
+
* and `DOTENV_CONFIG_DEBUG`, read from the shell AND re-read after the file is merged, so a `.env`
|
|
89
|
+
* line `DOTENV_CONFIG_QUIET=false` (or `DOTENV_CONFIG_DEBUG=true`) puts its banner back on stdout
|
|
90
|
+
* and breaks every `--json` result. `dotenv.parse` and an option-less `dotenv.populate` never log.
|
|
91
|
+
* A missing or unreadable file is skipped, as `dotenv.config` skips it. `DOTENV_KEY` vault
|
|
92
|
+
* decryption is not supported. Returns the keys it set.
|
|
93
|
+
*/
|
|
94
|
+
function populateDotenvSilently(cwd = process.cwd(), processEnv = process.env) {
|
|
95
|
+
let source;
|
|
96
|
+
try {
|
|
97
|
+
source = (0, fs_1.readFileSync)((0, path_1.resolve)(cwd, '.env'), { encoding: 'utf8' });
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
const target = processEnv;
|
|
103
|
+
return Object.keys(dotenv.populate(target, dotenv.parse(source)));
|
|
104
|
+
}
|
|
80
105
|
/**
|
|
81
106
|
* Load `.env` from the working directory, keeping the shell's environment apart from it.
|
|
82
107
|
*
|
|
83
|
-
* The ORDER is the guarantee: the snapshot is taken first,
|
|
84
|
-
* `HSUITE_SIGNER`
|
|
108
|
+
* The ORDER is the guarantee: the snapshot is taken first, the file is merged second, and an
|
|
109
|
+
* `HSUITE_SIGNER` it introduced is dropped third. Returns the snapshot.
|
|
85
110
|
*/
|
|
86
111
|
function loadDotenv(warn = (message) => console.error(message)) {
|
|
87
112
|
const before = Object.freeze({ ...process.env });
|
|
88
|
-
dotenv.config()
|
|
113
|
+
// Never `dotenv.config()`: its banner goes to STDOUT and an env var can switch it back on (see
|
|
114
|
+
// populateDotenvSilently), which corrupts every `--json` result a script parses.
|
|
115
|
+
populateDotenvSilently();
|
|
89
116
|
if (dropFileProvidedSigner(before.HSUITE_SIGNER)) {
|
|
90
117
|
warn('hsuite: ignoring HSUITE_SIGNER from .env — it is read from the shell environment only');
|
|
91
118
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell-env.js","sourceRoot":"","sources":["../../src/_lib/shell-env.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"shell-env.js","sourceRoot":"","sources":["../../src/_lib/shell-env.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,4CAEC;AAOD,wDAQC;AAaD,wDAYC;AAQD,gCAYC;AA1FD;;;;;;;;;;;;;;;GAeG;AACH,2BAAkC;AAClC,+BAA+B;AAC/B,+CAAiC;AAEjC;;;;GAIG;AACH,IAAI,KAAK,GAAgC,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;AAE3E,uFAAuF;AACvF,SAAgB,gBAAgB;IAC9B,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,SAAgB,sBAAsB,CACpC,YAAgC,EAChC,aAAgC,OAAO,CAAC,GAAG;IAE3C,IAAI,UAAU,CAAC,aAAa,KAAK,YAAY;QAAE,OAAO,KAAK,CAAC;IAC5D,IAAI,YAAY,KAAK,SAAS;QAAE,OAAO,UAAU,CAAC,aAAa,CAAC;;QAC3D,UAAU,CAAC,aAAa,GAAG,YAAY,CAAC;IAC7C,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,sBAAsB,CACpC,MAAc,OAAO,CAAC,GAAG,EAAE,EAC3B,aAAgC,OAAO,CAAC,GAAG;IAE3C,IAAI,MAAc,CAAC;IACnB,IAAI,CAAC;QACH,MAAM,GAAG,IAAA,iBAAY,EAAC,IAAA,cAAO,EAAC,GAAG,EAAE,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IACpE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,MAAM,GAAG,UAAwC,CAAC;IACxD,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACpE,CAAC;AAED;;;;;GAKG;AACH,SAAgB,UAAU,CACxB,OAAkC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;IAErE,MAAM,MAAM,GAAgC,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAC9E,+FAA+F;IAC/F,iFAAiF;IACjF,sBAAsB,EAAE,CAAC;IACzB,IAAI,sBAAsB,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;QACjD,IAAI,CAAC,uFAAuF,CAAC,CAAC;IAChG,CAAC;IACD,KAAK,GAAG,MAAM,CAAC;IACf,OAAO,MAAM,CAAC;AAChB,CAAC"}
|