@youcan/cli-kit 2.8.0 → 2.8.2
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/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/common/string.js +16 -12
- package/dist/index.js +20 -37
- package/dist/internal/node/constants.js +9 -11
- package/dist/internal/node/ui.js +57 -46
- package/dist/node/callback.js +61 -56
- package/dist/node/cli.js +70 -94
- package/dist/node/config.js +25 -23
- package/dist/node/context/helpers.js +12 -5
- package/dist/node/context/local.js +5 -5
- package/dist/node/crypto.js +23 -12
- package/dist/node/env.js +28 -33
- package/dist/node/filesystem.js +111 -105
- package/dist/node/form.js +23 -38
- package/dist/node/git.js +39 -43
- package/dist/node/github.js +12 -9
- package/dist/node/http.js +41 -47
- package/dist/node/path.js +18 -10
- package/dist/node/session.js +80 -99
- package/dist/node/system.js +87 -103
- package/dist/node/tasks.js +30 -35
- package/dist/node/worker.js +37 -53
- package/dist/services/cloudflared.js +159 -200
- package/dist/services/cloudflared.test.js +92 -110
- package/dist/services/index.js +6 -1
- package/dist/ui/components/DevOutput.js +52 -56
- package/dist/ui/components/Error.js +14 -15
- package/dist/ui/components/HotKeys.js +14 -20
- package/dist/ui/components/utils/symbols.js +6 -6
- package/dist/ui/index.js +12 -3
- package/package.json +5 -5
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __exportAll };
|
package/dist/common/string.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { paramCase } from "change-case";
|
|
3
|
+
//#region lib/common/string.ts
|
|
4
|
+
var string_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
hyphenate: () => hyphenate,
|
|
6
|
+
isJson: () => isJson
|
|
7
|
+
});
|
|
3
8
|
function hyphenate(value) {
|
|
4
|
-
|
|
9
|
+
return paramCase(value);
|
|
5
10
|
}
|
|
6
11
|
function isJson(subject) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
12
|
+
try {
|
|
13
|
+
JSON.parse(subject);
|
|
14
|
+
return true;
|
|
15
|
+
} catch (err) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
14
18
|
}
|
|
15
|
-
|
|
16
|
-
export { hyphenate, isJson };
|
|
19
|
+
//#endregion
|
|
20
|
+
export { hyphenate, isJson, string_exports };
|
package/dist/index.js
CHANGED
|
@@ -1,37 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
import
|
|
18
|
-
|
|
19
|
-
import
|
|
20
|
-
export {
|
|
21
|
-
import * as http from './node/http.js';
|
|
22
|
-
export { http as Http };
|
|
23
|
-
import * as path from './node/path.js';
|
|
24
|
-
export { path as Path };
|
|
25
|
-
import * as session from './node/session.js';
|
|
26
|
-
export { session as Session };
|
|
27
|
-
import * as system from './node/system.js';
|
|
28
|
-
export { system as System };
|
|
29
|
-
import * as tasks from './node/tasks.js';
|
|
30
|
-
export { tasks as Tasks };
|
|
31
|
-
import * as worker from './node/worker.js';
|
|
32
|
-
export { worker as Worker };
|
|
33
|
-
import * as index from './services/index.js';
|
|
34
|
-
export { index as Services };
|
|
35
|
-
import * as index$1 from './ui/index.js';
|
|
36
|
-
export { index$1 as UI };
|
|
37
|
-
export { default as Color } from 'kleur';
|
|
1
|
+
import { string_exports } from "./common/string.js";
|
|
2
|
+
import { callback_exports } from "./node/callback.js";
|
|
3
|
+
import { cli_exports } from "./node/cli.js";
|
|
4
|
+
import { config_exports } from "./node/config.js";
|
|
5
|
+
import { crypto_exports } from "./node/crypto.js";
|
|
6
|
+
import { env_exports } from "./node/env.js";
|
|
7
|
+
import { filesystem_exports } from "./node/filesystem.js";
|
|
8
|
+
import { form_exports } from "./node/form.js";
|
|
9
|
+
import { system_exports } from "./node/system.js";
|
|
10
|
+
import { git_exports } from "./node/git.js";
|
|
11
|
+
import { github_exports } from "./node/github.js";
|
|
12
|
+
import { http_exports } from "./node/http.js";
|
|
13
|
+
import { path_exports } from "./node/path.js";
|
|
14
|
+
import { session_exports } from "./node/session.js";
|
|
15
|
+
import { tasks_exports } from "./node/tasks.js";
|
|
16
|
+
import { worker_exports } from "./node/worker.js";
|
|
17
|
+
import { services_exports } from "./services/index.js";
|
|
18
|
+
import { ui_exports } from "./ui/index.js";
|
|
19
|
+
import Color from "kleur";
|
|
20
|
+
export { callback_exports as Callback, cli_exports as Cli, Color, config_exports as Config, crypto_exports as Crypto, env_exports as Env, filesystem_exports as Filesystem, form_exports as Form, git_exports as Git, github_exports as Github, http_exports as Http, path_exports as Path, services_exports as Services, session_exports as Session, string_exports as String, system_exports as System, tasks_exports as Tasks, ui_exports as UI, worker_exports as Worker };
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import process from
|
|
2
|
-
import envpaths from
|
|
3
|
-
|
|
4
|
-
const identifier =
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import envpaths from "env-paths";
|
|
3
|
+
//#region lib/internal/node/constants.ts
|
|
4
|
+
const identifier = "youcan-cli";
|
|
5
5
|
function cachedir() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
return envpaths(identifier).cache;
|
|
6
|
+
if (process.env.XDG_CACHE_HOME) return process.env.XDG_CACHE_HOME;
|
|
7
|
+
return envpaths(identifier).cache;
|
|
10
8
|
}
|
|
11
9
|
const ENV_VARS = {
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
ENV: "YC_CLI_ENV",
|
|
11
|
+
HOST_ENV: "YC_CLI_HOST_ENV"
|
|
14
12
|
};
|
|
15
|
-
|
|
13
|
+
//#endregion
|
|
16
14
|
export { ENV_VARS, cachedir };
|
package/dist/internal/node/ui.js
CHANGED
|
@@ -1,47 +1,58 @@
|
|
|
1
|
-
import process from
|
|
2
|
-
import kleur from
|
|
3
|
-
|
|
4
|
-
class Loader {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import kleur from "kleur";
|
|
3
|
+
//#region lib/internal/node/ui.ts
|
|
4
|
+
var Loader = class Loader {
|
|
5
|
+
message;
|
|
6
|
+
timer;
|
|
7
|
+
constructor(message) {
|
|
8
|
+
this.message = message;
|
|
9
|
+
this.message = message;
|
|
10
|
+
this.timer = null;
|
|
11
|
+
}
|
|
12
|
+
start() {
|
|
13
|
+
process.stdout.write("\x1B[?25l");
|
|
14
|
+
const frames = [
|
|
15
|
+
"⠋",
|
|
16
|
+
"⠙",
|
|
17
|
+
"⠹",
|
|
18
|
+
"⠸",
|
|
19
|
+
"⠼",
|
|
20
|
+
"⠴",
|
|
21
|
+
"⠦",
|
|
22
|
+
"⠧",
|
|
23
|
+
"⠇",
|
|
24
|
+
"⠏"
|
|
25
|
+
];
|
|
26
|
+
let i = 0;
|
|
27
|
+
this.timer = setInterval(() => {
|
|
28
|
+
process.stdout.write(`\r${frames[i = ++i % frames.length]} ${this.message}`);
|
|
29
|
+
}, 100);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
flush() {
|
|
33
|
+
process.stdout.write("\x1B[?25h");
|
|
34
|
+
if (this.timer) {
|
|
35
|
+
clearInterval(this.timer);
|
|
36
|
+
this.timer = null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
stop() {
|
|
40
|
+
this.flush();
|
|
41
|
+
process.stdout.write("\r");
|
|
42
|
+
process.stdout.write(kleur.green(`✔ ${this.message}\n`));
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
error(message = null) {
|
|
46
|
+
this.flush();
|
|
47
|
+
process.stdout.write("\r");
|
|
48
|
+
process.stdout.write(kleur.red(`✖ ${message ?? this.message}\n`));
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
static async exec(message, closure) {
|
|
52
|
+
const loader = new Loader(message).start();
|
|
53
|
+
await closure(loader);
|
|
54
|
+
loader.timer && loader.stop();
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
//#endregion
|
|
47
58
|
export { Loader };
|
package/dist/node/callback.js
CHANGED
|
@@ -1,58 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { createServer } from "node:http";
|
|
3
|
+
//#region lib/node/callback.ts
|
|
4
|
+
var callback_exports = /* @__PURE__ */ __exportAll({ listen: () => listen });
|
|
5
|
+
var CallbackListener = class {
|
|
6
|
+
port;
|
|
7
|
+
host;
|
|
8
|
+
server;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.port = options.port;
|
|
11
|
+
this.host = options.host;
|
|
12
|
+
this.server = this.create(options.callback);
|
|
13
|
+
}
|
|
14
|
+
start() {
|
|
15
|
+
this.server.listen({
|
|
16
|
+
port: this.port,
|
|
17
|
+
host: this.host
|
|
18
|
+
}, () => {});
|
|
19
|
+
}
|
|
20
|
+
stop() {
|
|
21
|
+
this.server.close();
|
|
22
|
+
}
|
|
23
|
+
create(callback) {
|
|
24
|
+
const server = async (request, response) => {
|
|
25
|
+
const respond = async (contents, error, state, code) => {
|
|
26
|
+
response.write(contents);
|
|
27
|
+
response.end();
|
|
28
|
+
return callback(this, error, state, code);
|
|
29
|
+
};
|
|
30
|
+
const query = new URL(request.url, `http://${request.headers.host}`).searchParams;
|
|
31
|
+
if (!query.has("code")) return respond("missing code in authorization callback");
|
|
32
|
+
if (!query.has("state")) return respond("missing state in authorization callback");
|
|
33
|
+
return respond("Successfully authenticated, you can now close this window.", void 0, query.get("code"), query.get("state"));
|
|
34
|
+
};
|
|
35
|
+
return createServer(server);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
37
38
|
async function listen(command, host, port, url) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
39
|
+
return await new Promise((resolve, reject) => {
|
|
40
|
+
const timeout = setTimeout(() => {
|
|
41
|
+
command.output.info("Auto-open timed out, click below to open the login page:");
|
|
42
|
+
command.output.url("Log in to YouCan Partners", url);
|
|
43
|
+
}, 1e4);
|
|
44
|
+
const callback = (listener, error, code, state) => {
|
|
45
|
+
clearTimeout(timeout);
|
|
46
|
+
setTimeout(() => {
|
|
47
|
+
listener.stop();
|
|
48
|
+
if (error) return reject(error);
|
|
49
|
+
return resolve({
|
|
50
|
+
code,
|
|
51
|
+
state
|
|
52
|
+
});
|
|
53
|
+
}, 500);
|
|
54
|
+
};
|
|
55
|
+
new CallbackListener({
|
|
56
|
+
host,
|
|
57
|
+
port,
|
|
58
|
+
callback
|
|
59
|
+
}).start();
|
|
60
|
+
});
|
|
56
61
|
}
|
|
57
|
-
|
|
58
|
-
export { listen };
|
|
62
|
+
//#endregion
|
|
63
|
+
export { callback_exports, listen };
|
package/dist/node/cli.js
CHANGED
|
@@ -1,106 +1,82 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
import 'kleur';
|
|
18
|
-
import 'dayjs';
|
|
19
|
-
import '../ui/components/DevOutput.js';
|
|
20
|
-
import { renderError } from '../ui/components/Error.js';
|
|
21
|
-
import 'react';
|
|
22
|
-
import 'ink';
|
|
23
|
-
import { truthy } from './context/helpers.js';
|
|
24
|
-
import { isDevelopment } from './context/local.js';
|
|
25
|
-
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { truthy } from "./context/helpers.js";
|
|
3
|
+
import { isDevelopment } from "./context/local.js";
|
|
4
|
+
import { renderError } from "../ui/components/Error.js";
|
|
5
|
+
import "../index.js";
|
|
6
|
+
import process from "node:process";
|
|
7
|
+
import { Command as Command$1, Flags, ux } from "@oclif/core";
|
|
8
|
+
import prompts from "prompts";
|
|
9
|
+
//#region lib/node/cli.ts
|
|
10
|
+
var cli_exports = /* @__PURE__ */ __exportAll({
|
|
11
|
+
Command: () => Command,
|
|
12
|
+
CommandError: () => CommandError,
|
|
13
|
+
commonFlags: () => commonFlags,
|
|
14
|
+
exec: () => exec,
|
|
15
|
+
execCreate: () => execCreate
|
|
16
|
+
});
|
|
26
17
|
function setupEnvVars(options) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
if (options.development) {
|
|
31
|
-
process.env.YC_CLI_ENV ??= 'development';
|
|
32
|
-
}
|
|
18
|
+
if (process.argv.includes("--verbose")) process.env.DEBUG = process.env.DEBUG ?? "*";
|
|
19
|
+
if (options.development) process.env.YC_CLI_ENV ??= "development";
|
|
33
20
|
}
|
|
34
21
|
function setupColorMode() {
|
|
35
|
-
|
|
36
|
-
|| truthy(process.env.NO_COLOR)
|
|
37
|
-
|| truthy(process.env.YC_FLAG_NO_COLOR)
|
|
38
|
-
|| process.env.TERM === 'dumb') {
|
|
39
|
-
process.env.FORCE_COLOR = '0';
|
|
40
|
-
}
|
|
22
|
+
if (process.argv.includes("--no-color") || truthy(process.env.NO_COLOR) || truthy(process.env.YC_FLAG_NO_COLOR) || process.env.TERM === "dumb") process.env.FORCE_COLOR = "0";
|
|
41
23
|
}
|
|
42
24
|
function handleError(error) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
25
|
+
let suggestions = [];
|
|
26
|
+
const message = error.message;
|
|
27
|
+
if (error instanceof CommandError && error.suggestions) suggestions = error.suggestions;
|
|
28
|
+
renderError({
|
|
29
|
+
message,
|
|
30
|
+
suggestions
|
|
31
|
+
});
|
|
32
|
+
process.exit(1);
|
|
50
33
|
}
|
|
51
34
|
async function exec(options) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
run(undefined, options.moduleUrl)
|
|
59
|
-
.then(() => flush())
|
|
60
|
-
.catch(handleError);
|
|
35
|
+
setupEnvVars(options);
|
|
36
|
+
setupColorMode();
|
|
37
|
+
const { run, settings, flush } = await import("@oclif/core");
|
|
38
|
+
if (isDevelopment()) settings.debug = true;
|
|
39
|
+
run(void 0, options.moduleUrl).then(() => flush()).catch(handleError);
|
|
61
40
|
}
|
|
62
|
-
process.on(
|
|
41
|
+
process.on("uncaughtException", handleError);
|
|
63
42
|
async function execCreate(cmdlet, options) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
process.argv.splice(initIndex, 0, 'init');
|
|
71
|
-
}
|
|
72
|
-
await exec(options);
|
|
43
|
+
setupEnvVars(options);
|
|
44
|
+
if (process.argv.findIndex((arg) => arg.includes("init")) === -1) {
|
|
45
|
+
const initIndex = process.argv.findIndex((arg) => arg.match(new RegExp(`bin(\\/|\\\\)+(create-${cmdlet}|dev|exec)`))) + 1;
|
|
46
|
+
process.argv.splice(initIndex, 0, "init");
|
|
47
|
+
}
|
|
48
|
+
await exec(options);
|
|
73
49
|
}
|
|
74
50
|
const commonFlags = {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
51
|
+
"no-color": Flags.boolean({
|
|
52
|
+
hidden: false,
|
|
53
|
+
description: "Disable color output.",
|
|
54
|
+
env: "YC_FLAG_NO_COLOR"
|
|
55
|
+
}),
|
|
56
|
+
"verbose": Flags.boolean({
|
|
57
|
+
hidden: false,
|
|
58
|
+
description: "Increase the verbosity of the logs.",
|
|
59
|
+
env: "YC_FLAG_VERBOSE"
|
|
60
|
+
})
|
|
85
61
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export { Command, CommandError, commonFlags, exec, execCreate };
|
|
62
|
+
var Command = class extends Command$1 {
|
|
63
|
+
output = ux;
|
|
64
|
+
prompt = prompts;
|
|
65
|
+
controller = new AbortController();
|
|
66
|
+
clear() {
|
|
67
|
+
console.clear();
|
|
68
|
+
}
|
|
69
|
+
exit(code) {
|
|
70
|
+
this.controller.abort();
|
|
71
|
+
return process.exit(code);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var CommandError = class extends Error {
|
|
75
|
+
suggestions;
|
|
76
|
+
constructor(message, suggestions) {
|
|
77
|
+
super(message);
|
|
78
|
+
this.suggestions = suggestions;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
//#endregion
|
|
82
|
+
export { Command, CommandError, cli_exports, commonFlags, exec, execCreate };
|
package/dist/node/config.js
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import Conf from "conf";
|
|
3
|
+
//#region lib/node/config.ts
|
|
4
|
+
var config_exports = /* @__PURE__ */ __exportAll({ manager: () => manager });
|
|
5
|
+
var Manager = class {
|
|
6
|
+
store;
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.store = new Conf(options);
|
|
9
|
+
}
|
|
10
|
+
get(key) {
|
|
11
|
+
return this.store.get(key);
|
|
12
|
+
}
|
|
13
|
+
set(key, value) {
|
|
14
|
+
this.store.set(key, value);
|
|
15
|
+
}
|
|
16
|
+
delete(key) {
|
|
17
|
+
this.store.delete(key);
|
|
18
|
+
}
|
|
19
|
+
clear() {
|
|
20
|
+
this.store.clear();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
21
23
|
function manager(options) {
|
|
22
|
-
|
|
24
|
+
return new Manager(options);
|
|
23
25
|
}
|
|
24
|
-
|
|
25
|
-
export { manager };
|
|
26
|
+
//#endregion
|
|
27
|
+
export { config_exports, manager };
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
//#region lib/node/context/helpers.ts
|
|
1
2
|
function truthy(val) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
if (!val) return false;
|
|
4
|
+
return [
|
|
5
|
+
"1",
|
|
6
|
+
"true",
|
|
7
|
+
"TRUE",
|
|
8
|
+
"yes",
|
|
9
|
+
"YES",
|
|
10
|
+
"y",
|
|
11
|
+
"Y"
|
|
12
|
+
].includes(val);
|
|
6
13
|
}
|
|
7
|
-
|
|
14
|
+
//#endregion
|
|
8
15
|
export { truthy };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { ENV_VARS } from "../../internal/node/constants.js";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
//#region lib/node/context/local.ts
|
|
4
4
|
function isDevelopment(env = process.env) {
|
|
5
|
-
|
|
5
|
+
return env[ENV_VARS.ENV] === "development";
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
//#endregion
|
|
8
8
|
export { isDevelopment };
|