@lovrabet/lovrabet-cli 2.1.17 → 2.1.18-beta.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/lib/cli.d.ts +21 -0
- package/lib/cli.js +1 -1
- package/lib/commands/api-doc/index.d.ts +38 -0
- package/lib/commands/api-doc/index.js +1 -1
- package/lib/commands/app/cache.d.ts +61 -0
- package/lib/commands/app/cache.js +1 -1
- package/lib/commands/app/definitions.d.ts +26 -0
- package/lib/commands/app/definitions.js +1 -1
- package/lib/commands/app/eligibility.d.ts +16 -0
- package/lib/commands/app/eligibility.js +1 -1
- package/lib/commands/app/mock-loader.d.ts +41 -0
- package/lib/commands/app/mock-loader.js +1 -1
- package/lib/commands/app/remote-source.d.ts +66 -0
- package/lib/commands/app/remote-source.js +1 -1
- package/lib/commands/app/shared.d.ts +38 -0
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/get.d.ts +2 -0
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.d.ts +2 -0
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/artifact/index.d.ts +9 -0
- package/lib/commands/artifact/index.js +1 -1
- package/lib/commands/auth/device.d.ts +31 -0
- package/lib/commands/auth/device.js +1 -1
- package/lib/commands/auth/index.d.ts +23 -0
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/auth/prompt.d.ts +33 -0
- package/lib/commands/auth/prompt.js +1 -1
- package/lib/commands/bff/detail.d.ts +8 -0
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/exec.d.ts +19 -0
- package/lib/commands/bff/exec.js +1 -1
- package/lib/commands/bff/index.d.ts +15 -0
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/cli-skill/index.d.ts +9 -0
- package/lib/commands/cli-skill/index.js +1 -1
- package/lib/commands/common/config-policy.d.ts +80 -0
- package/lib/commands/common/config-policy.js +1 -1
- package/lib/commands/common/constraints.d.ts +67 -0
- package/lib/commands/common/constraints.js +1 -1
- package/lib/commands/common/flags.d.ts +41 -0
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/local-file.d.ts +6 -0
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/config/definitions.d.ts +21 -0
- package/lib/commands/config/definitions.js +1 -1
- package/lib/commands/config/shared.d.ts +17 -0
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/data/index.d.ts +27 -0
- package/lib/commands/data/index.js +1 -1
- package/lib/commands/dataset/detail.d.ts +26 -0
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/index.d.ts +10 -0
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.d.ts +18 -0
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/sdk-doc.d.ts +6 -0
- package/lib/commands/dataset/sdk-doc.js +1 -1
- package/lib/commands/doctor.d.ts +23 -0
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/file/index.d.ts +2 -0
- package/lib/commands/file/index.js +1 -1
- package/lib/commands/init.d.ts +32 -0
- package/lib/commands/init.js +1 -1
- package/lib/commands/kb/index.d.ts +8 -0
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/logs/index.d.ts +20 -0
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/ocr/index.d.ts +2 -0
- package/lib/commands/ocr/index.js +1 -1
- package/lib/commands/personal-bff/index.d.ts +5 -0
- package/lib/commands/personal-bff/index.js +1 -1
- package/lib/commands/registry.d.ts +56 -0
- package/lib/commands/registry.js +1 -1
- package/lib/commands/schedule/index.d.ts +2 -0
- package/lib/commands/schedule/index.js +1 -0
- package/lib/commands/schema.d.ts +18 -0
- package/lib/commands/schema.js +1 -1
- package/lib/commands/service/dynamic.d.ts +18 -0
- package/lib/commands/service/dynamic.js +1 -1
- package/lib/commands/service/function-name-adapter.d.ts +13 -0
- package/lib/commands/service/function-name-adapter.js +1 -1
- package/lib/commands/service/index.d.ts +2 -0
- package/lib/commands/service/index.js +1 -1
- package/lib/commands/service/registry.d.ts +102 -0
- package/lib/commands/service/registry.js +1 -1
- package/lib/commands/skill/commands/create.d.ts +2 -0
- package/lib/commands/skill/commands/create.js +1 -1
- package/lib/commands/skill/commands/install.d.ts +2 -0
- package/lib/commands/skill/commands/install.js +1 -1
- package/lib/commands/skill/commands/list.d.ts +2 -0
- package/lib/commands/skill/commands/list.js +1 -1
- package/lib/commands/skill/commands/push.d.ts +2 -0
- package/lib/commands/skill/commands/push.js +1 -1
- package/lib/commands/skill/commands/validate.d.ts +2 -0
- package/lib/commands/skill/commands/validate.js +1 -1
- package/lib/commands/skill/flags.d.ts +13 -0
- package/lib/commands/skill/flags.js +1 -1
- package/lib/commands/skill/index.d.ts +9 -0
- package/lib/commands/skill/index.js +1 -1
- package/lib/commands/skill/manifest-helpers.d.ts +5 -0
- package/lib/commands/skill/manifest-helpers.js +1 -1
- package/lib/commands/skill/push-execute.d.ts +49 -0
- package/lib/commands/skill/push-execute.js +1 -1
- package/lib/commands/skill/push-flow-helpers.d.ts +80 -0
- package/lib/commands/skill/push-flow-helpers.js +1 -1
- package/lib/commands/skill/push-retarget.d.ts +9 -0
- package/lib/commands/skill/push-retarget.js +1 -1
- package/lib/commands/skill/scopes.d.ts +13 -0
- package/lib/commands/skill/scopes.js +1 -1
- package/lib/commands/skill/summary.d.ts +6 -0
- package/lib/commands/skill/summary.js +1 -1
- package/lib/commands/skill/templates.d.ts +23 -0
- package/lib/commands/skill/templates.js +1 -1
- package/lib/commands/skill/validate.d.ts +20 -0
- package/lib/commands/skill/validate.js +1 -1
- package/lib/commands/sql/detail.d.ts +13 -0
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.d.ts +21 -0
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.d.ts +9 -0
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/update.d.ts +10 -0
- package/lib/commands/update.js +1 -1
- package/lib/commands/workspace/index.d.ts +10 -0
- package/lib/commands/workspace/index.js +1 -1
- package/lib/config/schema.d.ts +108 -0
- package/lib/config/schema.js +1 -1
- package/lib/constant/app.d.ts +13 -0
- package/lib/constant/app.js +1 -1
- package/lib/constant/auth-mode.d.ts +28 -0
- package/lib/constant/auth-mode.js +1 -1
- package/lib/constant/cli.d.ts +86 -0
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.d.ts +45 -0
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/distribution.d.ts +12 -0
- package/lib/constant/distribution.js +1 -1
- package/lib/constant/domain.d.ts +57 -0
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.d.ts +56 -0
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.d.ts +13 -0
- package/lib/constant/output.js +1 -1
- package/lib/constant/product.d.ts +79 -0
- package/lib/constant/product.js +1 -1
- package/lib/constant/risk.d.ts +14 -0
- package/lib/constant/risk.js +1 -1
- package/lib/constant/url.d.ts +14 -0
- package/lib/constant/url.js +1 -1
- package/lib/context.d.ts +287 -0
- package/lib/context.js +1 -1
- package/lib/core/api-client.d.ts +451 -0
- package/lib/core/api-client.js +1 -1
- package/lib/core/db-resolver.d.ts +39 -0
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/sdk-client.d.ts +62 -0
- package/lib/core/sdk-client.js +1 -1
- package/lib/errors.d.ts +25 -0
- package/lib/errors.js +1 -1
- package/lib/framework/build-all-flags.d.ts +24 -0
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/dryrun.d.ts +64 -0
- package/lib/framework/dryrun.js +1 -1
- package/lib/framework/flags.d.ts +19 -0
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.d.ts +21 -0
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.d.ts +10 -0
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.d.ts +10 -0
- package/lib/framework/output.js +1 -1
- package/lib/framework/preparse.d.ts +64 -0
- package/lib/framework/preparse.js +1 -1
- package/lib/framework/rate-limit.d.ts +10 -0
- package/lib/framework/rate-limit.js +1 -1
- package/lib/framework/response.d.ts +10 -0
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-confirmation.d.ts +46 -0
- package/lib/framework/runner-confirmation.js +1 -1
- package/lib/framework/runner-error.d.ts +28 -0
- package/lib/framework/runner-error.js +1 -1
- package/lib/framework/runner.d.ts +102 -0
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.d.ts +29 -0
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/service-order.d.ts +4 -0
- package/lib/framework/service-order.js +1 -1
- package/lib/framework/types.d.ts +108 -0
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -0
- package/lib/generated/build-info.js +1 -1
- package/lib/help.d.ts +25 -0
- package/lib/help.js +1 -1
- package/lib/runtime/event.d.ts +16 -0
- package/lib/runtime/event.js +1 -0
- package/lib/runtime/index.d.ts +13 -0
- package/lib/runtime/index.js +1 -0
- package/lib/runtime/queue.d.ts +6 -0
- package/lib/runtime/queue.js +1 -0
- package/lib/runtime/resolve.d.ts +14 -0
- package/lib/runtime/resolve.js +1 -0
- package/lib/runtime/types.d.ts +59 -0
- package/lib/runtime/types.js +1 -0
- package/lib/skills/npx-skills-add.d.ts +42 -0
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/skills/runtime-skill-sync/constants.d.ts +4 -0
- package/lib/skills/runtime-skill-sync/constants.js +1 -1
- package/lib/skills/runtime-skill-sync/fs-utils.d.ts +21 -0
- package/lib/skills/runtime-skill-sync/fs-utils.js +1 -1
- package/lib/skills/runtime-skill-sync/hashing.d.ts +9 -0
- package/lib/skills/runtime-skill-sync/hashing.js +1 -1
- package/lib/skills/runtime-skill-sync/links.d.ts +18 -0
- package/lib/skills/runtime-skill-sync/links.js +1 -1
- package/lib/skills/runtime-skill-sync/list-local.d.ts +3 -0
- package/lib/skills/runtime-skill-sync/list-local.js +1 -1
- package/lib/skills/runtime-skill-sync/local-files.d.ts +25 -0
- package/lib/skills/runtime-skill-sync/local-files.js +1 -1
- package/lib/skills/runtime-skill-sync/materialize.d.ts +11 -0
- package/lib/skills/runtime-skill-sync/materialize.js +1 -1
- package/lib/skills/runtime-skill-sync/metadata.d.ts +7 -0
- package/lib/skills/runtime-skill-sync/metadata.js +1 -1
- package/lib/skills/runtime-skill-sync/paths.d.ts +11 -0
- package/lib/skills/runtime-skill-sync/paths.js +1 -1
- package/lib/skills/runtime-skill-sync/push.d.ts +33 -0
- package/lib/skills/runtime-skill-sync/push.js +1 -1
- package/lib/skills/runtime-skill-sync/scopes.d.ts +5 -0
- package/lib/skills/runtime-skill-sync/scopes.js +1 -1
- package/lib/skills/runtime-skill-sync/types.d.ts +105 -0
- package/lib/skills/runtime-skill-sync/zip-codec.d.ts +9 -0
- package/lib/skills/runtime-skill-sync/zip-codec.js +1 -1
- package/lib/skills/runtime-skill-sync/zip-package.d.ts +15 -0
- package/lib/skills/runtime-skill-sync/zip-package.js +1 -1
- package/lib/skills/runtime-skill-sync.d.ts +15 -0
- package/lib/skills/runtime-skill-sync.js +1 -1
- package/lib/utils/apply-jq-filter.d.ts +25 -0
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/logger.d.ts +73 -0
- package/lib/utils/logger.js +1 -1
- package/lib/utils/lossless-json.d.ts +21 -0
- package/lib/utils/lossless-json.js +1 -1
- package/lib/utils/params.d.ts +65 -0
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.d.ts +17 -0
- package/lib/utils/platform.js +1 -1
- package/lib/utils/update-notice.d.ts +10 -0
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.d.ts +18 -0
- package/lib/utils/version.js +1 -1
- package/lib/utils/write-cli-side-channel.d.ts +6 -0
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +9 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Runtime environment values and helpers.
|
|
3
|
+
*
|
|
4
|
+
* Why a dedicated module: the runtime environment string (`production` / `development` /
|
|
5
|
+
* `daily`) is one of the most frequently evaluated values in the CLI — it controls
|
|
6
|
+
* API domain selection, SDK initialization, and SDK client creation. Keeping it
|
|
7
|
+
* isolated lets us add normalization (e.g. `"online"` → `"production"`) in one place
|
|
8
|
+
* rather than patching each call site.
|
|
9
|
+
*
|
|
10
|
+
* Design decision: environment is stored as a module-level mutable variable (`env`)
|
|
11
|
+
* initialized once at startup. This is simpler than threading `env` through every
|
|
12
|
+
* function, and is safe because the CLI is single-threaded and the environment
|
|
13
|
+
* never changes during a single invocation.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* The three valid runtime environment values.
|
|
17
|
+
* These must match the environment names accepted by the @lovrabet/sdk client.
|
|
18
|
+
*/
|
|
19
|
+
export declare const RUNTIME_ENV_VALUES: readonly ["production", "development", "daily"];
|
|
20
|
+
/**
|
|
21
|
+
* Normalizes a user-supplied environment string to the canonical form.
|
|
22
|
+
*
|
|
23
|
+
* Why normalize `"online"` to `"production"`: older `.lovrabet.json` and
|
|
24
|
+
* `.rabetbase.json` files used `"online"` before the team standardized on
|
|
25
|
+
* `"production"`. Normalizing at the boundary prevents this legacy value from
|
|
26
|
+
* reaching downstream code that only knows the canonical set.
|
|
27
|
+
*
|
|
28
|
+
* @param e - Any string (including legacy aliases).
|
|
29
|
+
* @returns `"production"`, `"development"`, or `"daily"`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function normalizeEnv(e: string): string;
|
|
32
|
+
/** Checks whether the normalized environment is production (or the legacy `"online"` alias). */
|
|
33
|
+
export declare function isProduction(e: string): boolean;
|
|
34
|
+
/** Checks whether the normalized environment is `daily`. */
|
|
35
|
+
export declare function isDaily(e: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Checks whether the normalized environment is development.
|
|
38
|
+
*
|
|
39
|
+
* Why `"dev"` as a fallback: some developers use `"dev"` locally (mirroring the
|
|
40
|
+
* `@lovrabet/sdk` convention). We accept it as an alias for `"development"` so
|
|
41
|
+
* local configs don't need to be changed when migrating.
|
|
42
|
+
*/
|
|
43
|
+
export declare function isDev(e: string): boolean;
|
|
44
|
+
/** Returns the current effective environment. */
|
|
45
|
+
export declare function getEnv(): string;
|
|
46
|
+
/**
|
|
47
|
+
* Updates the effective environment.
|
|
48
|
+
* Called once during `initGlobalEnvironment()` before any domain or SDK usage.
|
|
49
|
+
*
|
|
50
|
+
* Why not just read the environment variable everywhere: env values may come from
|
|
51
|
+
* the config file rather than the environment variable, and
|
|
52
|
+
* the config is authoritative for the current invocation.
|
|
53
|
+
*
|
|
54
|
+
* @param _env - Environment value (already normalized if from config).
|
|
55
|
+
*/
|
|
56
|
+
export declare function initEnv(_env: string): void;
|
package/lib/constant/env.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a70_0x381e(_0x277d0c,_0xe5c559){_0x277d0c=_0x277d0c-0x1c1;const _0xb2794a=a70_0xb279();let _0x381e13=_0xb2794a[_0x277d0c];return _0x381e13;}const a70_0x59c23e=a70_0x381e;(function(_0xef37d9,_0xf05220){const _0x253f75=a70_0x381e,_0x419dd4=_0xef37d9();while(!![]){try{const _0x5d0d6d=-parseInt(_0x253f75(0x1c6))/0x1*(parseInt(_0x253f75(0x1c2))/0x2)+parseInt(_0x253f75(0x1cf))/0x3+parseInt(_0x253f75(0x1cb))/0x4+parseInt(_0x253f75(0x1ca))/0x5*(parseInt(_0x253f75(0x1ce))/0x6)+parseInt(_0x253f75(0x1c3))/0x7+-parseInt(_0x253f75(0x1cc))/0x8+-parseInt(_0x253f75(0x1c9))/0x9*(parseInt(_0x253f75(0x1c4))/0xa);if(_0x5d0d6d===_0xf05220)break;else _0x419dd4['push'](_0x419dd4['shift']());}catch(_0x412f9f){_0x419dd4['push'](_0x419dd4['shift']());}}}(a70_0xb279,0xd3f49));import{productEnv}from'../constant/product.js';export const RUNTIME_ENV_VALUES=[a70_0x59c23e(0x1c1),'development',a70_0x59c23e(0x1c5)];export function normalizeEnv(_0xeb6937){const _0x2ac3b3=a70_0x59c23e;return _0xeb6937===_0x2ac3b3(0x1c8)?'production':_0xeb6937;}export function isProduction(_0x27e254){const _0x290400=a70_0x59c23e;return normalizeEnv(_0x27e254)===_0x290400(0x1c1);}function a70_0xb279(){const _0x2a770d=['3739396xNwHiW','964664QJRfOF','development','762XTiyWU','3159069hiqQuQ','production','2625202idyZnE','985768aytrnL','10EtqZYx','daily','1UeJFZQ','ENV','online','2289996Ceakte','16815zUWmUv'];a70_0xb279=function(){return _0x2a770d;};return a70_0xb279();}export function isDaily(_0x1e8d78){return normalizeEnv(_0x1e8d78)==='daily';}export function isDev(_0x3cf090){const _0x2b0e68=a70_0x59c23e,_0x376bbe=normalizeEnv(_0x3cf090);return _0x376bbe===_0x2b0e68(0x1cd)||_0x376bbe==='dev';}let env=normalizeEnv(productEnv(a70_0x59c23e(0x1c7))||'production');export function getEnv(){return env;}export function initEnv(_0x30bf69){env=normalizeEnv(_0x30bf69);}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Output format enumeration.
|
|
3
|
+
*
|
|
4
|
+
* These values must stay in sync with the `--format` flag enum in `cli.tsx`
|
|
5
|
+
* and the `OutputFormat` type imported from the framework.
|
|
6
|
+
* This module acts as the canonical declaration — callers should import from
|
|
7
|
+
* here rather than repeating the literal array.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Valid values for the `--format` CLI flag and `format` config field.
|
|
11
|
+
* These are re-exported from the framework type `OutputFormat` in `framework/types.ts`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const OUTPUT_FORMAT_VALUES: readonly ["json", "pretty", "compress"];
|
package/lib/constant/output.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a71_0x456b(_0xa407d8,_0x531970){_0xa407d8=_0xa407d8-0x171;const _0x7f05ab=a71_0x7f05();let _0x456b86=_0x7f05ab[_0xa407d8];return _0x456b86;}const a71_0x42894c=a71_0x456b;function a71_0x7f05(){const _0x5d6fd2=['4217337BEFaQR','107385eSjYFC','32792urOMjw','8327784JVzXKW','1828464tRDqac','120FIiBxM','compress','170xjQJEy','16yNzKvM','3103387WaLWcV','16jmaXsc','6KdVvjB','81697cYwsrL'];a71_0x7f05=function(){return _0x5d6fd2;};return a71_0x7f05();}(function(_0x3ef839,_0x2ac304){const _0x1572b7=a71_0x456b,_0x4101e9=_0x3ef839();while(!![]){try{const _0x4bcb15=parseInt(_0x1572b7(0x173))/0x1*(parseInt(_0x1572b7(0x17b))/0x2)+parseInt(_0x1572b7(0x175))/0x3+-parseInt(_0x1572b7(0x176))/0x4*(parseInt(_0x1572b7(0x172))/0x5)+-parseInt(_0x1572b7(0x17c))/0x6*(-parseInt(_0x1572b7(0x17a))/0x7)+parseInt(_0x1572b7(0x179))/0x8*(-parseInt(_0x1572b7(0x171))/0x9)+-parseInt(_0x1572b7(0x178))/0xa*(-parseInt(_0x1572b7(0x17d))/0xb)+parseInt(_0x1572b7(0x174))/0xc;if(_0x4bcb15===_0x2ac304)break;else _0x4101e9['push'](_0x4101e9['shift']());}catch(_0x4c9768){_0x4101e9['push'](_0x4101e9['shift']());}}}(a71_0x7f05,0x873b6));export const OUTPUT_FORMAT_VALUES=['json','pretty',a71_0x42894c(0x177)];
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Product and distribution constants for downstream forks.
|
|
3
|
+
*
|
|
4
|
+
* This is the first file to edit when rebranding or self-hosting Lovrabet
|
|
5
|
+
* Runtime CLI. Other constant modules re-export or derive from these values so
|
|
6
|
+
* command code does not need to know where product identity is defined.
|
|
7
|
+
*
|
|
8
|
+
* Package metadata still lives in `package.json`; keep `name` and `bin` aligned
|
|
9
|
+
* with `npmPackageName` and `cliBinName` when publishing a branded fork.
|
|
10
|
+
*/
|
|
11
|
+
/** Product-level customization surface for branded or self-hosted builds. */
|
|
12
|
+
export declare const PRODUCT_CONFIG: {
|
|
13
|
+
/** Executable binary name in package.json `bin`. */
|
|
14
|
+
readonly cliBinName: "lovrabet";
|
|
15
|
+
/** Human-readable CLI name shown in help, schema, and diagnostics. */
|
|
16
|
+
readonly cliDisplayName: "Lovrabet Runtime CLI";
|
|
17
|
+
/** Published npm package used by `update`. */
|
|
18
|
+
readonly npmPackageName: "@lovrabet/lovrabet-cli";
|
|
19
|
+
/** Published CLI Built-in Skill source consumed by `npx skills add`. */
|
|
20
|
+
readonly skillSource: "lovrabet/lovrabet-cli";
|
|
21
|
+
/** Npm registry base URL used for update dist-tag resolution. */
|
|
22
|
+
readonly npmRegistryBaseUrl: "https://registry.npmjs.org";
|
|
23
|
+
/** Main environment variable prefix, without trailing underscore. */
|
|
24
|
+
readonly envPrefix: "LOVRABET";
|
|
25
|
+
/** Compatibility environment prefixes checked after `envPrefix`. */
|
|
26
|
+
readonly legacyEnvPrefixes: readonly ["RABETBASE"];
|
|
27
|
+
/** Config file names, in lookup order. */
|
|
28
|
+
readonly configFileNames: readonly [".lovrabet.json", ".lovrabetrc"];
|
|
29
|
+
/** Config file name used for new writes. */
|
|
30
|
+
readonly newConfigFileName: ".lovrabet.json";
|
|
31
|
+
/** Per-user home directory name used for caches. */
|
|
32
|
+
readonly homeDirName: ".lovrabet";
|
|
33
|
+
/** Project log file name. */
|
|
34
|
+
readonly logFileName: ".lovrabet-runtime.log";
|
|
35
|
+
/** Request source header value for backend telemetry/rate limiting. */
|
|
36
|
+
readonly invokeSource: "cli:lovrabet-runtime";
|
|
37
|
+
/** Human-readable AccessKey management product name. */
|
|
38
|
+
readonly userCenterDisplayName: "Lovrabet User Center";
|
|
39
|
+
/** Env var suffix for skipping `npx skills add`. */
|
|
40
|
+
readonly skipNpxSkillsEnvSuffix: "SKIP_NPX_SKILLS";
|
|
41
|
+
/** Default service domains. Config file overrides still take precedence. */
|
|
42
|
+
readonly domains: {
|
|
43
|
+
readonly production: {
|
|
44
|
+
readonly user: "https://user.lovrabet.com";
|
|
45
|
+
readonly api: "https://api.lovrabet.com";
|
|
46
|
+
readonly runtime: "https://runtime.lovrabet.com";
|
|
47
|
+
readonly skillhub: "https://skills.lovrabet.com";
|
|
48
|
+
};
|
|
49
|
+
readonly nonProduction: {
|
|
50
|
+
readonly user: "https://user-daily.lovrabet.com";
|
|
51
|
+
readonly api: "https://daily-api.lovrabet.com";
|
|
52
|
+
readonly runtime: "https://daily-runtime.lovrabet.com";
|
|
53
|
+
readonly skillhub: "https://skills-daily.lovrabet.com";
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
/** User center path for creating an AccessKey. */
|
|
57
|
+
readonly accessKeyCreatePath: "/user/ak";
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Returns the environment variable name for this product.
|
|
61
|
+
*
|
|
62
|
+
* @param name - Suffix without prefix, for example `ACCESS_KEY`.
|
|
63
|
+
* @returns Full environment variable name, for example `LOVRABET_ACCESS_KEY`.
|
|
64
|
+
*/
|
|
65
|
+
export declare function productEnvName(name: string): string;
|
|
66
|
+
/**
|
|
67
|
+
* Returns all supported environment variable names for a suffix.
|
|
68
|
+
*
|
|
69
|
+
* @param name - Suffix without prefix, for example `ACCESS_KEY`.
|
|
70
|
+
* @returns Primary env var name followed by compatibility aliases.
|
|
71
|
+
*/
|
|
72
|
+
export declare function productEnvNames(name: string): string[];
|
|
73
|
+
/**
|
|
74
|
+
* Reads a product-scoped environment variable with legacy fallback.
|
|
75
|
+
*
|
|
76
|
+
* @param name - Suffix without prefix, for example `ACCESS_KEY`.
|
|
77
|
+
* @returns First matching environment variable value.
|
|
78
|
+
*/
|
|
79
|
+
export declare function productEnv(name: string): string | undefined;
|
package/lib/constant/product.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
const a72_0x3c9a6e=a72_0x376f;function a72_0x415b(){const _0x5ac13d=['207095qKOLde','12370VEJXcI','13129039cTUkCQ','https://skills-daily.lovrabet.com','1198200TuBfGj','envPrefix','@lovrabet/lovrabet-cli','SKIP_NPX_SKILLS','https://skills.lovrabet.com','10eGfUXA','352AEaMIv','map','lovrabet/lovrabet-cli','187452TNEvYs','1361930kXJOVt','156391pFNuSs','72YKBqTy','https://daily-runtime.lovrabet.com','.lovrabet-runtime.log','https://runtime.lovrabet.com','1935dZtFXk','https://user-daily.lovrabet.com','lovrabet','.lovrabetrc','Lovrabet\x20User\x20Center','https://daily-api.lovrabet.com','Lovrabet\x20Runtime\x20CLI','.lovrabet.json','https://api.lovrabet.com','https://registry.npmjs.org'];a72_0x415b=function(){return _0x5ac13d;};return a72_0x415b();}function a72_0x376f(_0x4d3bb0,_0x72b492){_0x4d3bb0=_0x4d3bb0-0x90;const _0x415b2e=a72_0x415b();let _0x376f3b=_0x415b2e[_0x4d3bb0];return _0x376f3b;}(function(_0x1900fc,_0x24f67b){const _0x5eab90=a72_0x376f,_0x951b19=_0x1900fc();while(!![]){try{const _0x30b484=-parseInt(_0x5eab90(0x97))/0x1+-parseInt(_0x5eab90(0x96))/0x2+-parseInt(_0x5eab90(0x98))/0x3*(-parseInt(_0x5eab90(0x95))/0x4)+-parseInt(_0x5eab90(0x91))/0x5*(-parseInt(_0x5eab90(0xaa))/0x6)+-parseInt(_0x5eab90(0xa6))/0x7*(parseInt(_0x5eab90(0x92))/0x8)+-parseInt(_0x5eab90(0x9c))/0x9*(-parseInt(_0x5eab90(0xa7))/0xa)+parseInt(_0x5eab90(0xa8))/0xb;if(_0x30b484===_0x24f67b)break;else _0x951b19['push'](_0x951b19['shift']());}catch(_0x2f1092){_0x951b19['push'](_0x951b19['shift']());}}}(a72_0x415b,0xce2e8));export const PRODUCT_CONFIG={'cliBinName':a72_0x3c9a6e(0x9e),'cliDisplayName':a72_0x3c9a6e(0xa2),'npmPackageName':a72_0x3c9a6e(0xac),'skillSource':a72_0x3c9a6e(0x94),'npmRegistryBaseUrl':a72_0x3c9a6e(0xa5),'envPrefix':'LOVRABET','legacyEnvPrefixes':['RABETBASE'],'configFileNames':['.lovrabet.json',a72_0x3c9a6e(0x9f)],'newConfigFileName':a72_0x3c9a6e(0xa3),'homeDirName':'.lovrabet','logFileName':a72_0x3c9a6e(0x9a),'invokeSource':'cli:lovrabet-runtime','userCenterDisplayName':a72_0x3c9a6e(0xa0),'skipNpxSkillsEnvSuffix':a72_0x3c9a6e(0xad),'domains':{'production':{'user':'https://user.lovrabet.com','api':a72_0x3c9a6e(0xa4),'runtime':a72_0x3c9a6e(0x9b),'skillhub':a72_0x3c9a6e(0x90)},'nonProduction':{'user':a72_0x3c9a6e(0x9d),'api':a72_0x3c9a6e(0xa1),'runtime':a72_0x3c9a6e(0x99),'skillhub':a72_0x3c9a6e(0xa9)}},'accessKeyCreatePath':'/user/ak'};export function productEnvName(_0xa98dc0){const _0x365ab3=a72_0x3c9a6e;return PRODUCT_CONFIG[_0x365ab3(0xab)]+'_'+_0xa98dc0;}export function productEnvNames(_0x4f1c45){const _0x2ada52=a72_0x3c9a6e;return[productEnvName(_0x4f1c45),...PRODUCT_CONFIG['legacyEnvPrefixes'][_0x2ada52(0x93)](_0x17cbdb=>_0x17cbdb+'_'+_0x4f1c45)];}export function productEnv(_0x543d80){for(const _0x57e23a of productEnvNames(_0x543d80)){const _0x59d723=process.env[_0x57e23a];if(_0x59d723!==undefined)return _0x59d723;}return undefined;}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Risk level enumeration.
|
|
3
|
+
*
|
|
4
|
+
* These values are the legal values for the `riskLevel` config field and must
|
|
5
|
+
* match the `Risk` type from `@lovrabet/cli-framework`. This module is the
|
|
6
|
+
* canonical declaration site so callers don't scatter the literal values.
|
|
7
|
+
*
|
|
8
|
+
* Why `as const` makes a difference: using `as const` creates a `readonly`
|
|
9
|
+
* tuple type for `RISK_LEVEL_VALUES`, which TypeScript uses to infer the exact
|
|
10
|
+
* type `readonly ["read", "write", "high-risk-write"]`. Any downstream code
|
|
11
|
+
* that types a field as `(typeof RISK_LEVEL_VALUES)[number]` gets the precise
|
|
12
|
+
* union type rather than `string`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const RISK_LEVEL_VALUES: readonly ["read", "write", "high-risk-write"];
|
package/lib/constant/risk.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a73_0x10f0(){const _0x18784f=['high-risk-write','17553701IOvbsX','340728QRhkFR','3671180tkfMez','1420869AleuaO','write','5595568Uiwrww','10kfEBtI','515007MqqulI','56wxcUix','597065CWrDQj','42ilfmdF','22WSOSrX'];a73_0x10f0=function(){return _0x18784f;};return a73_0x10f0();}const a73_0x56e55=a73_0x1f93;function a73_0x1f93(_0x2ecfab,_0x3011a0){_0x2ecfab=_0x2ecfab-0xd8;const _0x10f0e7=a73_0x10f0();let _0x1f9330=_0x10f0e7[_0x2ecfab];return _0x1f9330;}(function(_0x55dcb7,_0x96f39e){const _0x25b061=a73_0x1f93,_0x289eb6=_0x55dcb7();while(!![]){try{const _0x513eb7=parseInt(_0x25b061(0xe2))/0x1+-parseInt(_0x25b061(0xdd))/0x2*(parseInt(_0x25b061(0xe0))/0x3)+parseInt(_0x25b061(0xe4))/0x4+parseInt(_0x25b061(0xe1))/0x5+-parseInt(_0x25b061(0xdc))/0x6*(-parseInt(_0x25b061(0xdb))/0x7)+parseInt(_0x25b061(0xda))/0x8*(-parseInt(_0x25b061(0xd9))/0x9)+parseInt(_0x25b061(0xd8))/0xa*(-parseInt(_0x25b061(0xdf))/0xb);if(_0x513eb7===_0x96f39e)break;else _0x289eb6['push'](_0x289eb6['shift']());}catch(_0x1d7365){_0x289eb6['push'](_0x289eb6['shift']());}}}(a73_0x10f0,0xdd09e));export const RISK_LEVEL_VALUES=['read',a73_0x56e55(0xe3),a73_0x56e55(0xde)];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Stable external URLs referenced by the CLI.
|
|
3
|
+
*
|
|
4
|
+
* Why centralize URLs here: user-facing links can appear in prompts, help text,
|
|
5
|
+
* and diagnostics. Keeping them in one module prevents drift when the same URL
|
|
6
|
+
* is reused across multiple commands.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Self-service page where users can create an AccessKey.
|
|
10
|
+
*
|
|
11
|
+
* Why this stays production-scoped: AccessKey creation is managed in the main
|
|
12
|
+
* user center rather than the runtime environment-specific backends.
|
|
13
|
+
*/
|
|
14
|
+
export declare const USER_ACCESS_KEY_CREATE_URL: string;
|
package/lib/constant/url.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a74_0x2099a8=a74_0x4972;(function(_0x464106,_0x36dbf1){const _0x71a417=a74_0x4972,_0x3ba3b0=_0x464106();while(!![]){try{const _0x4d6f55=-parseInt(_0x71a417(0x200))/0x1*(parseInt(_0x71a417(0x1f5))/0x2)+-parseInt(_0x71a417(0x1fe))/0x3+parseInt(_0x71a417(0x1f8))/0x4+parseInt(_0x71a417(0x1fc))/0x5*(parseInt(_0x71a417(0x1f7))/0x6)+parseInt(_0x71a417(0x1f6))/0x7*(-parseInt(_0x71a417(0x1f3))/0x8)+parseInt(_0x71a417(0x1f9))/0x9+-parseInt(_0x71a417(0x1fb))/0xa*(-parseInt(_0x71a417(0x1fa))/0xb);if(_0x4d6f55===_0x36dbf1)break;else _0x3ba3b0['push'](_0x3ba3b0['shift']());}catch(_0x321f0f){_0x3ba3b0['push'](_0x3ba3b0['shift']());}}}(a74_0x11cd,0x944a3));import{PRODUCT_CONFIG}from'../constant/product.js';function a74_0x4972(_0x500fa9,_0x3880cd){_0x500fa9=_0x500fa9-0x1f3;const _0x11cd7b=a74_0x11cd();let _0x497228=_0x11cd7b[_0x500fa9];return _0x497228;}function a74_0x11cd(){const _0x5495b5=['2246408AvebpB','1045961Yyuhfm','1762686txiSZR','4435020eAVUDa','497583UnTnBf','9908646XyLREX','20rmIaAd','10edXITM','user','2778117ctqcDi','production','1XNtqAx','48SwXTkd','domains'];a74_0x11cd=function(){return _0x5495b5;};return a74_0x11cd();}export const USER_ACCESS_KEY_CREATE_URL=''+PRODUCT_CONFIG[a74_0x2099a8(0x1f4)][a74_0x2099a8(0x1ff)][a74_0x2099a8(0x1fd)]+PRODUCT_CONFIG['accessKeyCreatePath'];
|
package/lib/context.d.ts
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Shared runtime context — config loading, merging, and writing.
|
|
3
|
+
*
|
|
4
|
+
* This module is the central authority on everything configuration:
|
|
5
|
+
* - Reading raw config files (global + project) without merging
|
|
6
|
+
* - Merging global + project configs with documented precedence rules
|
|
7
|
+
* - Resolving effective values (appCode, env, format, riskLevel, etc.)
|
|
8
|
+
* - Writing scoped configs (global vs. project) atomically
|
|
9
|
+
*
|
|
10
|
+
* Why a dedicated context module: configuration is read at startup, written by
|
|
11
|
+
* `init`, `app use`, and `config set`, and consulted by every command via
|
|
12
|
+
* `buildConfig()`. Centralizing all config operations here means:
|
|
13
|
+
* 1. The merge algorithm is defined once and applied consistently everywhere.
|
|
14
|
+
* 2. Adding a new config field only requires updating `buildConfig()`.
|
|
15
|
+
* 3. Tests can mock `readRawConfig` to simulate different config states.
|
|
16
|
+
*
|
|
17
|
+
* Key design decisions:
|
|
18
|
+
* - `inherit: false` in a project config disables global merging entirely,
|
|
19
|
+
* isolating the project from accidental global config pollution.
|
|
20
|
+
* - `appCode` is resolved from explicit flags, top-level config, or the cached
|
|
21
|
+
* remote app directory via `defaultApp`. Local app profiles are legacy-only.
|
|
22
|
+
* - Atomic writes (temp file + rename) prevent config corruption on crashes.
|
|
23
|
+
* - `migrateOnlineEnv()` silently upgrades old `"online"` env values to
|
|
24
|
+
* `"production"` so old config files continue to work.
|
|
25
|
+
*/
|
|
26
|
+
import { logger } from "./utils/logger.js";
|
|
27
|
+
import type { OutputFormat, Risk } from "./framework/types.js";
|
|
28
|
+
export type { AuthMode } from "./constant/auth-mode.js";
|
|
29
|
+
export { AUTH_MODE, isAuthMode } from "./constant/auth-mode.js";
|
|
30
|
+
/**
|
|
31
|
+
* Legacy app profile shape from older `.lovrabet.json` files.
|
|
32
|
+
* Kept only for compatibility reads; new writes do not create these blocks.
|
|
33
|
+
*/
|
|
34
|
+
export interface AppProfile {
|
|
35
|
+
appcode: string;
|
|
36
|
+
env?: "production" | "development" | "daily";
|
|
37
|
+
cookie?: string;
|
|
38
|
+
accessKey?: string;
|
|
39
|
+
format?: OutputFormat;
|
|
40
|
+
pageSize?: number;
|
|
41
|
+
riskLevel?: Risk;
|
|
42
|
+
locale?: string;
|
|
43
|
+
description?: string;
|
|
44
|
+
remoteDescription?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Fully resolved CLI configuration used by the runner and all commands.
|
|
48
|
+
*
|
|
49
|
+
* Why `appCode` can be undefined: `buildConfig()` is called even for commands
|
|
50
|
+
* that don't need an appCode (e.g. `init`, `help`). Commands that require it
|
|
51
|
+
* must check `config.appCode` and throw via `CliErrors.configMissing()`.
|
|
52
|
+
*
|
|
53
|
+
* Why `riskLevel` defaults to `"write"` (not `"read"`): Lovrabet Runtime CLI's
|
|
54
|
+
* primary purpose is data manipulation. Defaulting to `"write"` avoids forcing
|
|
55
|
+
* users to configure a risk ceiling before performing routine operations.
|
|
56
|
+
*/
|
|
57
|
+
export interface CLIConfig {
|
|
58
|
+
appCode: string | undefined;
|
|
59
|
+
/** Source used to resolve `appCode`, useful for async revalidation of `--app`. */
|
|
60
|
+
appCodeSource: "explicit" | "env" | "local-alias" | "cache" | "top-level" | undefined;
|
|
61
|
+
env: "production" | "development" | "daily";
|
|
62
|
+
locale: string;
|
|
63
|
+
cookie: string | undefined;
|
|
64
|
+
accessKey: string | undefined;
|
|
65
|
+
format: OutputFormat | undefined;
|
|
66
|
+
pageSize: number | undefined;
|
|
67
|
+
riskLevel: Risk;
|
|
68
|
+
verbose: boolean;
|
|
69
|
+
/** Default app name used to resolve appCode from the remote app cache. */
|
|
70
|
+
defaultApp: string | undefined;
|
|
71
|
+
/** Active app name: explicit `--app` flag > `defaultApp` > undefined. */
|
|
72
|
+
currentApp: string | undefined;
|
|
73
|
+
/** The raw merged JSON (used by doctor and config commands). */
|
|
74
|
+
raw: Record<string, any>;
|
|
75
|
+
}
|
|
76
|
+
/** Stub auth object used by the runtime CLI (AK auth, no session). */
|
|
77
|
+
export interface CLIAuth {
|
|
78
|
+
cookie: string;
|
|
79
|
+
isLoggedIn: boolean;
|
|
80
|
+
getOrLogin(): Promise<string>;
|
|
81
|
+
}
|
|
82
|
+
/** Domain URLs resolved from env and config. */
|
|
83
|
+
export interface CLIEnv {
|
|
84
|
+
apiDomain: string;
|
|
85
|
+
userDomain: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The top-level context object assembled during CLI startup.
|
|
89
|
+
* Includes config, auth, logger, environment, and interactivity state.
|
|
90
|
+
*
|
|
91
|
+
* Why `auth.isLoggedIn` is always `true` in runtime CLI: we use AK auth which
|
|
92
|
+
* is validated at config load time. Unlike session-based auth, there is no
|
|
93
|
+
* "logged out" state to model — if AK is absent, commands throw `authRequired`.
|
|
94
|
+
*/
|
|
95
|
+
export interface CLIContext {
|
|
96
|
+
config: CLIConfig;
|
|
97
|
+
auth: CLIAuth;
|
|
98
|
+
logger: typeof logger;
|
|
99
|
+
env: CLIEnv;
|
|
100
|
+
nonInteractive: boolean;
|
|
101
|
+
}
|
|
102
|
+
/** File name used when creating a new config file. */
|
|
103
|
+
export declare const NEW_CONFIG_NAME: ".lovrabet.json";
|
|
104
|
+
/** Local app alias profile stored under `apps.<alias>` in `.lovrabet.json`. */
|
|
105
|
+
export interface LocalAppAliasProfile {
|
|
106
|
+
/** Runtime app code resolved from this local alias. */
|
|
107
|
+
appcode?: unknown;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Determines the write target for a scoped config operation.
|
|
111
|
+
*
|
|
112
|
+
* Why this strategy: if the user already has a config file (either old or new name),
|
|
113
|
+
* we update it in place rather than creating a second file. Only if no file exists
|
|
114
|
+
* do we create the new name. This avoids littering `~` with `.lovrabetrc` and
|
|
115
|
+
* `.lovrabet.json` side by side.
|
|
116
|
+
*/
|
|
117
|
+
export declare function resolveWriteConfigPath(scope: "project" | "global"): string;
|
|
118
|
+
/**
|
|
119
|
+
* Reads and parses a single config file without any merging.
|
|
120
|
+
*
|
|
121
|
+
* Why no merging here: merging is done by `readRawConfig()` using `mergeRawConfigLayers()`.
|
|
122
|
+
* Keeping reads simple means tests can mock `readConfigFile` without worrying about
|
|
123
|
+
* the merge logic.
|
|
124
|
+
*
|
|
125
|
+
* Why it migrates `env: "online"` silently: older `.rabetbase.json` files used
|
|
126
|
+
* `"online"` before the team standardized on `"production"`. Detecting and
|
|
127
|
+
* migrating this at read time avoids patching every call site.
|
|
128
|
+
*/
|
|
129
|
+
export declare function readConfigFile(filePath: string): Record<string, any>;
|
|
130
|
+
/**
|
|
131
|
+
* Atomically writes a config file to avoid corruption on crash.
|
|
132
|
+
*
|
|
133
|
+
* Why atomic: if the process crashes mid-write, a non-atomic write could leave
|
|
134
|
+
* a truncated or partially written file. Using a temp file + rename ensures the
|
|
135
|
+
* rename is atomic on POSIX systems (and on Windows, which doesn't guarantee
|
|
136
|
+
* atomic rename, we fall back to direct write and handle the error gracefully).
|
|
137
|
+
*/
|
|
138
|
+
export declare function writeConfigFile(filePath: string, data: Record<string, any>): void;
|
|
139
|
+
/**
|
|
140
|
+
* Detects whether the current session is non-interactive.
|
|
141
|
+
*
|
|
142
|
+
* Why multiple signals: no single check is sufficient on its own.
|
|
143
|
+
* - `CI` plus product-scoped `CI` env vars cover CI systems.
|
|
144
|
+
* - `--non-interactive` / `--ci` flags are explicit user choices.
|
|
145
|
+
* - `!process.stdout.isTTY` catches non-TTY environments (pipes, redirects).
|
|
146
|
+
* - `isStdinRawModeSupported()` is a heuristic: if stdin cannot enter raw mode,
|
|
147
|
+
* the session is unlikely to be interactive.
|
|
148
|
+
*
|
|
149
|
+
* This is a convenience wrapper; commands that need a definitive answer should
|
|
150
|
+
* also respect the explicit `--non-interactive` flag.
|
|
151
|
+
*/
|
|
152
|
+
export declare function isNonInteractiveMode(flags: Record<string, any>): boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Assembles the full `CLIContext` from raw CLI flags.
|
|
155
|
+
*
|
|
156
|
+
* This is the primary entry point called from `cli.tsx`. It:
|
|
157
|
+
* 1. Reads and merges config files.
|
|
158
|
+
* 2. Builds the resolved `CLIConfig`.
|
|
159
|
+
* 3. Initializes the global environment (env, domains).
|
|
160
|
+
* 4. Sets up auth.
|
|
161
|
+
* 5. Configures the logger with the current directory.
|
|
162
|
+
*
|
|
163
|
+
* Why async: `initGlobalEnvironment` currently does only synchronous work,
|
|
164
|
+
* but making it async leaves room for future async initialization (e.g. keychain
|
|
165
|
+
* lookups) without changing the call site.
|
|
166
|
+
*/
|
|
167
|
+
export declare function createContext(flags: Record<string, any>): Promise<CLIContext>;
|
|
168
|
+
/** Convenience wrapper: builds CLIConfig from flags without creating the full context. */
|
|
169
|
+
export declare function buildConfigFromFlags(flags: Record<string, any>): CLIConfig;
|
|
170
|
+
/**
|
|
171
|
+
* Returns local app alias profiles from a raw config object.
|
|
172
|
+
*
|
|
173
|
+
* @param raw - Raw merged config object.
|
|
174
|
+
* @returns Local alias profile map, or an empty object when absent.
|
|
175
|
+
*/
|
|
176
|
+
export declare function getLocalAppAliases(raw: Record<string, any>): Record<string, LocalAppAliasProfile>;
|
|
177
|
+
/**
|
|
178
|
+
* Resolves an app code from a local app alias.
|
|
179
|
+
*
|
|
180
|
+
* @param raw - Raw merged config object.
|
|
181
|
+
* @param name - Alias name selected by `defaultApp` or `--app`.
|
|
182
|
+
* @returns App code from `apps.<name>.appcode`, or undefined when not configured.
|
|
183
|
+
*/
|
|
184
|
+
export declare function resolveLocalAppAliasCode(raw: Record<string, any>, name: string | undefined): string | undefined;
|
|
185
|
+
/**
|
|
186
|
+
* Reads the appCode from the config file (fallback path, used when no flag is provided).
|
|
187
|
+
*
|
|
188
|
+
* Resolution order:
|
|
189
|
+
* 1. Top-level `appcode` or `app` field
|
|
190
|
+
* 2. `defaultApp` local alias profile's `appcode`
|
|
191
|
+
* 3. Cached remote app list (resolved by app name)
|
|
192
|
+
* 4. First local alias profile's `appcode`
|
|
193
|
+
*
|
|
194
|
+
* Why this fallback exists: commands that don't receive `--appcode` can still
|
|
195
|
+
* resolve it from the config. This enables the "just run `lovrabet dataset list`"
|
|
196
|
+
* UX where the active app is implied by the config.
|
|
197
|
+
*/
|
|
198
|
+
export declare function readAppCodeFromConfig(): string | undefined;
|
|
199
|
+
/**
|
|
200
|
+
* Reads the config file for a specific scope (global or project).
|
|
201
|
+
* Used by `app list`, `app use`, and `config get/set` commands.
|
|
202
|
+
*
|
|
203
|
+
* Why `flags.global` controls scope: this is consistent with how `--global`
|
|
204
|
+
* is used throughout the CLI. Commands that accept `--global` can use this
|
|
205
|
+
* function directly.
|
|
206
|
+
*/
|
|
207
|
+
export declare function readScopedConfig(flags: Record<string, any>): Record<string, any>;
|
|
208
|
+
/** Writes the config to the appropriate scope file. */
|
|
209
|
+
export declare function writeScopedConfig(config: Record<string, any>, flags: Record<string, any>): void;
|
|
210
|
+
/**
|
|
211
|
+
* Initializes the global runtime environment from the resolved config.
|
|
212
|
+
*
|
|
213
|
+
* Why this exists: `initEnv()` sets the module-level env variable in `constant/env.ts`,
|
|
214
|
+
* and `initDomains()` sets the domain overrides in `constant/domain.ts`. These are
|
|
215
|
+
* separate modules that both need to be initialized from the same config. Previously,
|
|
216
|
+
* `cli.tsx` called both functions separately, creating a risk that one would be
|
|
217
|
+
* forgotten when the config resolution changed. Centralizing the call here ensures
|
|
218
|
+
* both are always updated together.
|
|
219
|
+
*/
|
|
220
|
+
export declare function initGlobalEnvironment(config: CLIConfig): Promise<void>;
|
|
221
|
+
/** Returns the project config path if inside a project, otherwise undefined. */
|
|
222
|
+
export declare function getProjectConfigPath(): string | undefined;
|
|
223
|
+
/** Returns the global config path in the home directory, or undefined if none exists. */
|
|
224
|
+
export declare function getGlobalConfigPath(): string | undefined;
|
|
225
|
+
/**
|
|
226
|
+
* Result of inspecting a single config file path.
|
|
227
|
+
*
|
|
228
|
+
* Why four states: "missing", "empty", "ok", and "error" are all meaningful
|
|
229
|
+
* to the `doctor` command, which shows users exactly why their config isn't working.
|
|
230
|
+
*/
|
|
231
|
+
export type CliConfigJsonInspect = {
|
|
232
|
+
status: "missing";
|
|
233
|
+
} | {
|
|
234
|
+
status: "empty";
|
|
235
|
+
} | {
|
|
236
|
+
status: "ok";
|
|
237
|
+
data: Record<string, any>;
|
|
238
|
+
} | {
|
|
239
|
+
status: "error";
|
|
240
|
+
message: string;
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* Inspects a single config file for `doctor` output.
|
|
244
|
+
* Silently catches errors (doesn't print to stderr) so the doctor can
|
|
245
|
+
* report them nicely.
|
|
246
|
+
*/
|
|
247
|
+
export declare function inspectCliConfigJsonFile(filePath: string): CliConfigJsonInspect;
|
|
248
|
+
/**
|
|
249
|
+
* The two-layer config structure: global and project.
|
|
250
|
+
*/
|
|
251
|
+
export interface RawConfigLayers {
|
|
252
|
+
globalPath: string | undefined;
|
|
253
|
+
projectPath: string | undefined;
|
|
254
|
+
globalConfig: Record<string, any>;
|
|
255
|
+
projectConfig: Record<string, any>;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Reads both config files as-is (no merging).
|
|
259
|
+
*
|
|
260
|
+
* Why not return the merged config: `app list` needs to know per-layer membership
|
|
261
|
+
* (which apps are in global vs. project). If we only returned the merged result,
|
|
262
|
+
* we'd lose that information. The caller can call `mergeRawConfigLayers()` if needed.
|
|
263
|
+
*/
|
|
264
|
+
export declare function loadRawConfigLayers(projectRoot?: string): RawConfigLayers;
|
|
265
|
+
/** @returns true if the current directory is inside a project with a config file. */
|
|
266
|
+
export declare function isInProject(): boolean;
|
|
267
|
+
/**
|
|
268
|
+
* Reads and merges both config layers.
|
|
269
|
+
* This is the canonical "read config" function used by `buildConfig()`.
|
|
270
|
+
*/
|
|
271
|
+
export declare function readRawConfig(projectRoot?: string): Record<string, any>;
|
|
272
|
+
/**
|
|
273
|
+
* Returns the merged config AND the raw layers.
|
|
274
|
+
* Used by `app list` and `app use` which need both the merged view and
|
|
275
|
+
* the per-layer information for display.
|
|
276
|
+
*/
|
|
277
|
+
export declare function readRawConfigWithLayers(projectRoot?: string): {
|
|
278
|
+
config: Record<string, any>;
|
|
279
|
+
layers: RawConfigLayers;
|
|
280
|
+
};
|
|
281
|
+
/**
|
|
282
|
+
* Reports where the effective `defaultApp` comes from.
|
|
283
|
+
*
|
|
284
|
+
* Why needed: `app list` needs to annotate the fallback app candidate with
|
|
285
|
+
* "(project)" or "(global)" so users understand why it is available.
|
|
286
|
+
*/
|
|
287
|
+
export declare function resolveDefaultAppSource(layers: RawConfigLayers): "project" | "global" | null;
|
package/lib/context.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a74_0x43ff2c=a74_0x418d;(function(_0x19a7ff,_0x48c490){const _0x402f9c=a74_0x418d,_0x47d41b=_0x19a7ff();while(!![]){try{const _0x5ccf70=-parseInt(_0x402f9c(0x1e3))/0x1+parseInt(_0x402f9c(0x20e))/0x2+-parseInt(_0x402f9c(0x1f8))/0x3+-parseInt(_0x402f9c(0x220))/0x4+-parseInt(_0x402f9c(0x213))/0x5+-parseInt(_0x402f9c(0x1e8))/0x6*(parseInt(_0x402f9c(0x226))/0x7)+parseInt(_0x402f9c(0x21d))/0x8;if(_0x5ccf70===_0x48c490)break;else _0x47d41b['push'](_0x47d41b['shift']());}catch(_0x1f1afb){_0x47d41b['push'](_0x47d41b['shift']());}}}(a74_0x3ea9,0x92dc5));import{readFileSync,existsSync,mkdirSync,renameSync,unlinkSync,writeFileSync}from'node:fs';import{resolve,dirname}from'node:path';import{homedir}from'node:os';import{logger}from'./utils/logger.js';import{CliErrors}from'./errors.js';import{CLI_BIN_NAME}from'./constant/cli.js';import{PRODUCT_CONFIG,productEnv,productEnvNames}from'./constant/product.js';import{DEFAULT_CONFIG_VALUES}from'./constant/defaults.js';import{normalizeEnv,isDaily,isDev}from'./constant/env.js';import{normalizeLegacyOutputFormat}from'./framework/types.js';import{resolveCachedAppCode}from'./commands/app/cache.js';export{AUTH_MODE,isAuthMode}from'./constant/auth-mode.js';const CONFIG_NAMES=PRODUCT_CONFIG[a74_0x43ff2c(0x209)];export const NEW_CONFIG_NAME=PRODUCT_CONFIG[a74_0x43ff2c(0x224)];function resolveConfigPath(_0x469f73){for(const _0x1dfd28 of CONFIG_NAMES){const _0x423c00=resolve(_0x469f73,_0x1dfd28);if(existsSync(_0x423c00))return _0x423c00;}return undefined;}export function resolveWriteConfigPath(_0x37acee){const _0x5e46a4=a74_0x43ff2c,_0x32cf7a=_0x37acee===_0x5e46a4(0x21e)?process['cwd']():homedir(),_0x4c34eb=resolveConfigPath(_0x32cf7a);return _0x4c34eb??resolve(_0x32cf7a,NEW_CONFIG_NAME);}export function readConfigFile(_0x1d8a65){const _0x316afc=a74_0x43ff2c;try{if(existsSync(_0x1d8a65)){const _0x357074=readFileSync(_0x1d8a65,{'encoding':_0x316afc(0x207)});if(_0x357074){const _0x187e05=JSON['parse'](_0x357074);return migrateOnlineEnv(_0x1d8a65,_0x187e05),_0x187e05;}}}catch{}return{};}function migrateOnlineEnv(_0xc889dc,_0x242f07){const _0x180fda=a74_0x43ff2c;let _0x2271a0=![];_0x242f07[_0x180fda(0x20b)]===_0x180fda(0x229)&&(_0x242f07[_0x180fda(0x20b)]=_0x180fda(0x221),_0x2271a0=!![]);if(_0x242f07[_0x180fda(0x222)]&&typeof _0x242f07[_0x180fda(0x222)]===_0x180fda(0x206))for(const _0x192a33 of Object[_0x180fda(0x1ef)](_0x242f07[_0x180fda(0x222)])){_0x192a33&&_0x192a33[_0x180fda(0x20b)]===_0x180fda(0x229)&&(_0x192a33[_0x180fda(0x20b)]=_0x180fda(0x221),_0x2271a0=!![]);}if(_0x2271a0)try{writeConfigFile(_0xc889dc,_0x242f07);}catch{}}export function writeConfigFile(_0x257933,_0x43439a){const _0x54b347=a74_0x43ff2c,_0x363f14=dirname(_0x257933);!existsSync(_0x363f14)&&mkdirSync(_0x363f14,{'recursive':!![]});const _0x587510=_0x257933+_0x54b347(0x20c);try{writeFileSync(_0x587510,JSON[_0x54b347(0x21c)](_0x43439a,null,0x2)+'\x0a',{'encoding':_0x54b347(0x207),'mode':0x180});try{renameSync(_0x587510,_0x257933);}catch(_0x4ad3b9){if(_0x4ad3b9[_0x54b347(0x1ed)]===_0x54b347(0x20d)||_0x4ad3b9[_0x54b347(0x1ed)]==='EXDEV'||_0x4ad3b9[_0x54b347(0x1ed)]===_0x54b347(0x217)){writeFileSync(_0x257933,JSON[_0x54b347(0x21c)](_0x43439a,null,0x2)+'\x0a',{'encoding':_0x54b347(0x207)});try{unlinkSync(_0x587510);}catch{}}else throw _0x4ad3b9;}}catch(_0x4ca591){try{unlinkSync(_0x587510);}catch{}throw _0x4ca591;}}export function isNonInteractiveMode(_0x14f51e){const _0x22ed9b=a74_0x43ff2c;return!!(_0x14f51e['nonInteractive']||_0x14f51e['ci']||productEnvNames('CI')[_0x22ed9b(0x1fc)](_0xc3ef9=>process.env[_0xc3ef9]===_0x22ed9b(0x1eb))||process.env.CI===_0x22ed9b(0x1eb)||!process[_0x22ed9b(0x20a)][_0x22ed9b(0x202)]||!isStdinRawModeSupported());}function isStdinRawModeSupported(){const _0x3bec61=a74_0x43ff2c;if(!process['stdin'][_0x3bec61(0x202)])return![];try{const _0x29b6ab=process['stdin'][_0x3bec61(0x22a)];return process['stdin'][_0x3bec61(0x1ea)](!![]),process['stdin'][_0x3bec61(0x1ea)](_0x29b6ab??![]),!![];}catch{return![];}}export async function createContext(_0x290e4f){const _0x1587a7=a74_0x43ff2c,_0x5e4c8a=readRawConfig(),_0x3b1cb9=buildConfig(_0x5e4c8a,_0x290e4f);await initGlobalEnvironment(_0x3b1cb9);const {getUserDomain:_0x4f813d,getApiDomain:_0x5c6220}=await import(_0x1587a7(0x1fa)),_0x5196b9={'apiDomain':_0x5c6220(),'userDomain':_0x4f813d()},_0x1b92e0=await buildAuth(_0x3b1cb9);logger[_0x1587a7(0x216)](process[_0x1587a7(0x223)]());const _0x20966e=(CLI_BIN_NAME+'\x20'+process[_0x1587a7(0x201)][_0x1587a7(0x1f4)](0x2)[_0x1587a7(0x1ec)]('\x20'))[_0x1587a7(0x21a)]();logger[_0x1587a7(0x214)](_0x20966e);const _0x5c986e=isNonInteractiveMode(_0x290e4f);return{'config':_0x3b1cb9,'auth':_0x1b92e0,'logger':logger,'env':_0x5196b9,'nonInteractive':_0x5c986e};}export function buildConfigFromFlags(_0x5a0e40){return buildConfig(readRawConfig(),_0x5a0e40);}export function getLocalAppAliases(_0x1b620d){const _0x2fb886=a74_0x43ff2c;return _0x1b620d[_0x2fb886(0x222)]&&typeof _0x1b620d[_0x2fb886(0x222)]===_0x2fb886(0x206)?_0x1b620d['apps']:{};}export function resolveLocalAppAliasCode(_0x366cc7,_0x25dee0){const _0xcc198e=a74_0x43ff2c;if(!_0x25dee0)return undefined;const _0x17b2e2=getLocalAppAliases(_0x366cc7)[_0x25dee0],_0x32a3e7=_0x17b2e2?.[_0xcc198e(0x228)];return typeof _0x32a3e7===_0xcc198e(0x1f1)&&_0x32a3e7['trim']()?_0x32a3e7[_0xcc198e(0x21a)]():undefined;}function a74_0x3ea9(){const _0x33c0d1=['online','isRaw','608175pqsAUb','skillHubDomain','pageSize','FORMAT','ACCESS_KEY','6368178nBehZg','write','setRawMode','true','join','code','development','values','global','string','PAGE_SIZE','./constant/env.js','slice','ENV','userDomain','format','686379rmTqCA','locale','./constant/domain.js','raw','some','authRequired','globalConfig','APPCODE','parse','argv','isTTY','explicit','empty','accessKey','object','utf8','local-alias','configFileNames','stdout','env','.tmp','EPERM','806408QpdVuQ','missing','message','defaultApp','projectConfig','2722470SXsTpG','setRawCommand','cache','setLogPath','EACCES','inherit','error','trim','app','stringify','28427880BxYvJW','project','daily','3649292bkhuCX','production','apps','cwd','newConfigFileName','high-risk-write','7LUCwnF','top-level','appcode'];a74_0x3ea9=function(){return _0x33c0d1;};return a74_0x3ea9();}export function readAppCodeFromConfig(){const _0x8b265b=a74_0x43ff2c,_0x17112b=readRawConfig(),_0x37b80e=_0x17112b[_0x8b265b(0x228)]??_0x17112b[_0x8b265b(0x21b)];if(typeof _0x37b80e===_0x8b265b(0x1f1)&&_0x37b80e[_0x8b265b(0x21a)]())return _0x37b80e[_0x8b265b(0x21a)]();const _0xfe6508=resolveLocalAppAliasCode(_0x17112b,typeof _0x17112b[_0x8b265b(0x211)]===_0x8b265b(0x1f1)?_0x17112b['defaultApp']:undefined);if(_0xfe6508)return _0xfe6508;const _0x56c1f1=normalizeEnv(String(_0x17112b['env']||_0x8b265b(0x221))),_0x179e09=isDaily(_0x56c1f1)?_0x8b265b(0x21f):isDev(_0x56c1f1)?_0x8b265b(0x1ee):_0x8b265b(0x221),_0x5b8148=resolveCachedAppCode(typeof _0x17112b[_0x8b265b(0x211)]==='string'?_0x17112b[_0x8b265b(0x211)]:undefined,_0x179e09,typeof _0x17112b[_0x8b265b(0x205)]===_0x8b265b(0x1f1)?_0x17112b['accessKey']:undefined);if(_0x5b8148)return _0x5b8148;const _0x24c85b=Object['values'](getLocalAppAliases(_0x17112b))['find'](_0x44804a=>_0x44804a?.['appcode']);return typeof _0x24c85b?.[_0x8b265b(0x228)]===_0x8b265b(0x1f1)&&_0x24c85b[_0x8b265b(0x228)][_0x8b265b(0x21a)]()?_0x24c85b['appcode'][_0x8b265b(0x21a)]():undefined;}export function readScopedConfig(_0x3b58c5){const _0x721295=a74_0x43ff2c,_0x18335b=_0x3b58c5['global']?_0x721295(0x1f0):_0x721295(0x21e);return readConfigFile(resolveWriteConfigPath(_0x18335b));}export function writeScopedConfig(_0x46cd83,_0x469d9f){const _0x237029=a74_0x43ff2c,_0x2521e7=_0x469d9f[_0x237029(0x1f0)]?_0x237029(0x1f0):_0x237029(0x21e);writeConfigFile(resolveWriteConfigPath(_0x2521e7),_0x46cd83);}export async function initGlobalEnvironment(_0x598fad){const _0x556929=a74_0x43ff2c,{initEnv:_0x352c26}=await import(_0x556929(0x1f3));_0x352c26(_0x598fad['env']);const {initDomains:_0x34d710}=await import(_0x556929(0x1fa));_0x34d710({'apiDomain':_0x598fad[_0x556929(0x1fb)]['apiDomain']||_0x598fad['raw']['host']||undefined,'userDomain':_0x598fad['raw'][_0x556929(0x1f6)]||undefined,'runtimeDomain':_0x598fad['raw']['runtimeDomain']||undefined,'skillHubDomain':_0x598fad['raw'][_0x556929(0x1e4)]||undefined});}export function getProjectConfigPath(){const _0x585fdf=a74_0x43ff2c;return resolveConfigPath(process[_0x585fdf(0x223)]());}export function getGlobalConfigPath(){return resolveConfigPath(homedir());}export function inspectCliConfigJsonFile(_0x190f8a){const _0x164851=a74_0x43ff2c;if(!existsSync(_0x190f8a))return{'status':_0x164851(0x20f)};try{const _0x572d2e=readFileSync(_0x190f8a,{'encoding':'utf8'});if(!_0x572d2e?.[_0x164851(0x21a)]())return{'status':_0x164851(0x204)};const _0x494aef=JSON['parse'](_0x572d2e);return{'status':'ok','data':_0x494aef};}catch(_0x28fb28){return{'status':_0x164851(0x219),'message':_0x28fb28 instanceof Error?_0x28fb28[_0x164851(0x210)]:String(_0x28fb28)};}}export function loadRawConfigLayers(_0x5582b0){const _0x12e5df=a74_0x43ff2c;let _0x155300={},_0xe87dd4={},_0x85b520,_0x4c19fa;try{_0x85b520=resolveConfigPath(homedir());if(_0x85b520){const _0x4a1349=readFileSync(_0x85b520,{'encoding':_0x12e5df(0x207)});if(_0x4a1349)_0x155300=JSON[_0x12e5df(0x200)](_0x4a1349);}}catch{}try{const _0xe72ea4=_0x5582b0||process[_0x12e5df(0x223)]();_0x4c19fa=resolveConfigPath(_0xe72ea4);if(_0x4c19fa){const _0xf76da8=readFileSync(_0x4c19fa,{'encoding':'utf8'});if(_0xf76da8)_0xe87dd4=JSON[_0x12e5df(0x200)](_0xf76da8);}}catch{}return{'globalPath':_0x85b520,'projectPath':_0x4c19fa,'globalConfig':_0x155300,'projectConfig':_0xe87dd4};}function mergeRawConfigLayers(_0x2350c2){const _0xc253fe=a74_0x43ff2c,{globalConfig:_0x28de3c,projectConfig:_0x3751e3}=_0x2350c2;if(_0x3751e3['inherit']===![]){const _0x42d2e={..._0x3751e3};return delete _0x42d2e[_0xc253fe(0x218)],_0x42d2e;}const _0x3d2e32={..._0x28de3c,..._0x3751e3};if(_0xc253fe(0x211)in _0x3751e3)_0x3d2e32[_0xc253fe(0x211)]=_0x3751e3['defaultApp'];else _0x28de3c[_0xc253fe(0x211)]&&(_0x3d2e32[_0xc253fe(0x211)]=_0x28de3c[_0xc253fe(0x211)]);return _0x3d2e32;}export function isInProject(){return!!getProjectConfigPath();}export function readRawConfig(_0x11dbe2){return mergeRawConfigLayers(loadRawConfigLayers(_0x11dbe2));}export function readRawConfigWithLayers(_0x6938a){const _0x391a5e=loadRawConfigLayers(_0x6938a);return{'config':mergeRawConfigLayers(_0x391a5e),'layers':_0x391a5e};}function a74_0x418d(_0x3c0d48,_0x2bec70){_0x3c0d48=_0x3c0d48-0x1e3;const _0x3ea953=a74_0x3ea9();let _0x418d34=_0x3ea953[_0x3c0d48];return _0x418d34;}export function resolveDefaultAppSource(_0x32ee49){const _0x388545=a74_0x43ff2c;if('defaultApp'in _0x32ee49['projectConfig'])return'project';if(_0x32ee49[_0x388545(0x212)][_0x388545(0x218)]===![])return null;if(_0x32ee49[_0x388545(0x1fe)]['defaultApp'])return _0x388545(0x1f0);return null;}function buildConfig(_0x17140f,_0x435bda){const _0x233c25=a74_0x43ff2c,_0x233a55=_0x17140f[_0x233c25(0x211)]||undefined,_0x8a0858=_0x435bda[_0x233c25(0x21b)]||env('APP')||undefined,_0x1a4b93=_0x8a0858||_0x233a55||undefined,_0x47c527=env(_0x233c25(0x1e7))||_0x17140f[_0x233c25(0x205)]||undefined,_0x496c38=_0x435bda[_0x233c25(0x20b)]||env(_0x233c25(0x1f5))||_0x17140f[_0x233c25(0x20b)]||DEFAULT_CONFIG_VALUES[_0x233c25(0x20b)],_0x268f0a=normalizeEnv(String(_0x496c38)),_0x39e797=isDaily(_0x268f0a)?_0x233c25(0x21f):isDev(_0x268f0a)?_0x233c25(0x1ee):'production',_0x5c0266=typeof _0x435bda[_0x233c25(0x228)]===_0x233c25(0x1f1)?_0x435bda[_0x233c25(0x228)]:undefined,_0x29816a=env(_0x233c25(0x1ff)),_0x19877e=_0x8a0858?undefined:_0x17140f[_0x233c25(0x228)]||_0x17140f['app']||undefined,_0x71eb79=_0x8a0858||(_0x19877e?undefined:_0x233a55),_0x3bb76b=resolveLocalAppAliasCode(_0x17140f,_0x71eb79),_0x310951=resolveCachedAppCode(_0x71eb79,_0x39e797,_0x47c527),_0x13c23f=_0x5c0266||_0x29816a||_0x19877e||_0x3bb76b||_0x310951||undefined,_0xf7d0be=_0x5c0266?_0x233c25(0x203):_0x29816a?_0x233c25(0x20b):_0x19877e?_0x233c25(0x227):_0x3bb76b?_0x233c25(0x208):_0x310951?_0x233c25(0x215):undefined,_0x39937d=_0x17140f[_0x233c25(0x1f9)]||DEFAULT_CONFIG_VALUES[_0x233c25(0x1f9)],_0x3afabe=undefined,_0x1575fb=_0x435bda['format']||env(_0x233c25(0x1e6))||_0x17140f[_0x233c25(0x1f7)],_0x33ec55=normalizeLegacyOutputFormat(_0x1575fb),_0x5514a6=env(_0x233c25(0x1f2))||_0x17140f[_0x233c25(0x1e5)],_0x1bf454=_0x5514a6?Number(_0x5514a6)||undefined:undefined,_0x4051ee=_0x17140f['riskLevel']||_0x17140f['maxRisk'],_0x4d87a0=_0x4051ee==='read'||_0x4051ee===_0x233c25(0x1e9)||_0x4051ee===_0x233c25(0x225)?_0x4051ee:DEFAULT_CONFIG_VALUES['riskLevel'],_0x252a94=env('VERBOSE'),_0x266717=_0x252a94==='1'||_0x252a94===_0x233c25(0x1eb);return{'appCode':typeof _0x13c23f===_0x233c25(0x1f1)&&_0x13c23f['trim']()?_0x13c23f[_0x233c25(0x21a)]():undefined,'appCodeSource':_0xf7d0be,'env':_0x39e797,'locale':_0x39937d,'cookie':_0x3afabe,'accessKey':_0x47c527,'format':_0x33ec55,'pageSize':_0x1bf454,'riskLevel':_0x4d87a0,'verbose':_0x266717,'defaultApp':_0x233a55,'currentApp':typeof _0x1a4b93===_0x233c25(0x1f1)?_0x1a4b93:undefined,'raw':_0x17140f};}function env(_0x150faa){return productEnv(_0x150faa);}async function buildAuth(_0x4401ed){const _0x4a6d9f=a74_0x43ff2c,_0x59e654='',_0x314511=!!_0x4401ed[_0x4a6d9f(0x205)];return{'cookie':_0x59e654,'isLoggedIn':_0x314511,async 'getOrLogin'(){const _0x29eb83=_0x4a6d9f;if(_0x314511)return _0x59e654;throw CliErrors[_0x29eb83(0x1fd)]();}};}
|
|
1
|
+
const a75_0x14c7fe=a75_0x48f0;(function(_0x43bafb,_0x1082ac){const _0x458ab5=a75_0x48f0,_0x2eaf3e=_0x43bafb();while(!![]){try{const _0x22b4c4=parseInt(_0x458ab5(0x11f))/0x1+parseInt(_0x458ab5(0x11d))/0x2+parseInt(_0x458ab5(0x118))/0x3+parseInt(_0x458ab5(0xf9))/0x4+-parseInt(_0x458ab5(0xfb))/0x5+-parseInt(_0x458ab5(0x109))/0x6+-parseInt(_0x458ab5(0xfd))/0x7;if(_0x22b4c4===_0x1082ac)break;else _0x2eaf3e['push'](_0x2eaf3e['shift']());}catch(_0x5b6140){_0x2eaf3e['push'](_0x2eaf3e['shift']());}}}(a75_0x3ba7,0xd2990));import{readFileSync,existsSync,mkdirSync,renameSync,unlinkSync,writeFileSync}from'node:fs';import{resolve,dirname}from'node:path';import{homedir}from'node:os';import{logger}from'./utils/logger.js';import{CliErrors}from'./errors.js';import{CLI_BIN_NAME}from'./constant/cli.js';import{PRODUCT_CONFIG,productEnv,productEnvNames}from'./constant/product.js';import{DEFAULT_CONFIG_VALUES}from'./constant/defaults.js';import{normalizeEnv,isDaily,isDev}from'./constant/env.js';function a75_0x3ba7(){const _0x4ec459=['local-alias','PAGE_SIZE','message','cache','stdin','format','4446172otHPdd','authRequired','7986020YzXqsZ','app','1863876eUhyFA','explicit','locale','cwd','pageSize','setRawMode','APP','.tmp','top-level','read','env','project','9398022EVHBNe','missing','nonInteractive','find','code','daily','error','./constant/env.js','values','defaultApp','string','online','setRawCommand','global','trim','2739639XAOhSX','true','write','accessKey','production','1808890WQnjJn','skillHubDomain','1363216GRStTz','development','userDomain','./constant/domain.js','EXDEV','parse','apiDomain','newConfigFileName','globalConfig','object','utf8','isRaw','stringify','argv','raw','host','projectConfig','APPCODE','ACCESS_KEY','high-risk-write','setLogPath','apps','runtimeDomain','riskLevel','EPERM','appcode','join','isTTY','maxRisk','some','inherit'];a75_0x3ba7=function(){return _0x4ec459;};return a75_0x3ba7();}import{normalizeLegacyOutputFormat}from'./framework/types.js';import{resolveCachedAppCode}from'./commands/app/cache.js';export{AUTH_MODE,isAuthMode}from'./constant/auth-mode.js';const CONFIG_NAMES=PRODUCT_CONFIG['configFileNames'];export const NEW_CONFIG_NAME=PRODUCT_CONFIG[a75_0x14c7fe(0x126)];function resolveConfigPath(_0x152fed){for(const _0x384e63 of CONFIG_NAMES){const _0x35b836=resolve(_0x152fed,_0x384e63);if(existsSync(_0x35b836))return _0x35b836;}return undefined;}export function resolveWriteConfigPath(_0x812901){const _0x1afd55=a75_0x14c7fe,_0x306580=_0x812901===_0x1afd55(0x108)?process[_0x1afd55(0x100)]():homedir(),_0x2ac8b3=resolveConfigPath(_0x306580);return _0x2ac8b3??resolve(_0x306580,NEW_CONFIG_NAME);}export function readConfigFile(_0x571288){try{if(existsSync(_0x571288)){const _0x3fe23c=readFileSync(_0x571288,{'encoding':'utf8'});if(_0x3fe23c){const _0x255f32=JSON['parse'](_0x3fe23c);return migrateOnlineEnv(_0x571288,_0x255f32),_0x255f32;}}}catch{}return{};}function migrateOnlineEnv(_0x2e5465,_0x2cd94c){const _0x9ccc41=a75_0x14c7fe;let _0x30a67d=![];_0x2cd94c[_0x9ccc41(0x107)]===_0x9ccc41(0x114)&&(_0x2cd94c[_0x9ccc41(0x107)]=_0x9ccc41(0x11c),_0x30a67d=!![]);if(_0x2cd94c[_0x9ccc41(0xe9)]&&typeof _0x2cd94c[_0x9ccc41(0xe9)]==='object')for(const _0x3ebc27 of Object[_0x9ccc41(0x111)](_0x2cd94c[_0x9ccc41(0xe9)])){_0x3ebc27&&_0x3ebc27[_0x9ccc41(0x107)]===_0x9ccc41(0x114)&&(_0x3ebc27[_0x9ccc41(0x107)]=_0x9ccc41(0x11c),_0x30a67d=!![]);}if(_0x30a67d)try{writeConfigFile(_0x2e5465,_0x2cd94c);}catch{}}export function writeConfigFile(_0x20dd5c,_0x15ce8c){const _0x14de98=a75_0x14c7fe,_0x2d0057=dirname(_0x20dd5c);!existsSync(_0x2d0057)&&mkdirSync(_0x2d0057,{'recursive':!![]});const _0x30d272=_0x20dd5c+_0x14de98(0x104);try{writeFileSync(_0x30d272,JSON[_0x14de98(0xe0)](_0x15ce8c,null,0x2)+'\x0a',{'encoding':_0x14de98(0xde),'mode':0x180});try{renameSync(_0x30d272,_0x20dd5c);}catch(_0xae710e){if(_0xae710e[_0x14de98(0x10d)]===_0x14de98(0xec)||_0xae710e[_0x14de98(0x10d)]===_0x14de98(0x123)||_0xae710e[_0x14de98(0x10d)]==='EACCES'){writeFileSync(_0x20dd5c,JSON[_0x14de98(0xe0)](_0x15ce8c,null,0x2)+'\x0a',{'encoding':_0x14de98(0xde)});try{unlinkSync(_0x30d272);}catch{}}else throw _0xae710e;}}catch(_0x14d296){try{unlinkSync(_0x30d272);}catch{}throw _0x14d296;}}export function isNonInteractiveMode(_0x1d4325){const _0x531693=a75_0x14c7fe;return!!(_0x1d4325[_0x531693(0x10b)]||_0x1d4325['ci']||productEnvNames('CI')[_0x531693(0xf1)](_0x4d804b=>process.env[_0x4d804b]===_0x531693(0x119))||process.env.CI===_0x531693(0x119)||!process['stdout'][_0x531693(0xef)]||!isStdinRawModeSupported());}function isStdinRawModeSupported(){const _0x589904=a75_0x14c7fe;if(!process[_0x589904(0xf7)][_0x589904(0xef)])return![];try{const _0x466f63=process[_0x589904(0xf7)][_0x589904(0xdf)];return process[_0x589904(0xf7)][_0x589904(0x102)](!![]),process[_0x589904(0xf7)][_0x589904(0x102)](_0x466f63??![]),!![];}catch{return![];}}export async function createContext(_0x572027){const _0xd4aabb=a75_0x14c7fe,_0x2f07bc=readRawConfig(),_0x11ddfe=buildConfig(_0x2f07bc,_0x572027);await initGlobalEnvironment(_0x11ddfe);const {getUserDomain:_0x5da4f4,getApiDomain:_0x550127}=await import('./constant/domain.js'),_0x10c61b={'apiDomain':_0x550127(),'userDomain':_0x5da4f4()},_0x50f3f3=await buildAuth(_0x11ddfe);logger[_0xd4aabb(0xe8)](process[_0xd4aabb(0x100)]());const _0xfb8b07=(CLI_BIN_NAME+'\x20'+process[_0xd4aabb(0xe1)]['slice'](0x2)[_0xd4aabb(0xee)]('\x20'))[_0xd4aabb(0x117)]();logger[_0xd4aabb(0x115)](_0xfb8b07);const _0x471b9c=isNonInteractiveMode(_0x572027);return{'config':_0x11ddfe,'auth':_0x50f3f3,'logger':logger,'env':_0x10c61b,'nonInteractive':_0x471b9c};}export function buildConfigFromFlags(_0x16988f){return buildConfig(readRawConfig(),_0x16988f);}export function getLocalAppAliases(_0x2021ab){const _0x421076=a75_0x14c7fe;return _0x2021ab[_0x421076(0xe9)]&&typeof _0x2021ab['apps']===_0x421076(0xdd)?_0x2021ab['apps']:{};}export function resolveLocalAppAliasCode(_0xc82f8,_0x3310cc){const _0x785df8=a75_0x14c7fe;if(!_0x3310cc)return undefined;const _0x2a5016=getLocalAppAliases(_0xc82f8)[_0x3310cc],_0x28de89=_0x2a5016?.['appcode'];return typeof _0x28de89===_0x785df8(0x113)&&_0x28de89[_0x785df8(0x117)]()?_0x28de89['trim']():undefined;}export function readAppCodeFromConfig(){const _0x2fae28=a75_0x14c7fe,_0x407ba3=readRawConfig(),_0x130730=_0x407ba3['appcode']??_0x407ba3['app'];if(typeof _0x130730===_0x2fae28(0x113)&&_0x130730['trim']())return _0x130730[_0x2fae28(0x117)]();const _0x30cddb=resolveLocalAppAliasCode(_0x407ba3,typeof _0x407ba3[_0x2fae28(0x112)]==='string'?_0x407ba3[_0x2fae28(0x112)]:undefined);if(_0x30cddb)return _0x30cddb;const _0x62fb7e=normalizeEnv(String(_0x407ba3[_0x2fae28(0x107)]||'production')),_0xee8e58=isDaily(_0x62fb7e)?_0x2fae28(0x10e):isDev(_0x62fb7e)?'development':_0x2fae28(0x11c),_0x1f9ccd=resolveCachedAppCode(typeof _0x407ba3['defaultApp']===_0x2fae28(0x113)?_0x407ba3[_0x2fae28(0x112)]:undefined,_0xee8e58,typeof _0x407ba3[_0x2fae28(0x11b)]==='string'?_0x407ba3[_0x2fae28(0x11b)]:undefined);if(_0x1f9ccd)return _0x1f9ccd;const _0x3ae434=Object[_0x2fae28(0x111)](getLocalAppAliases(_0x407ba3))[_0x2fae28(0x10c)](_0x39ab18=>_0x39ab18?.[_0x2fae28(0xed)]);return typeof _0x3ae434?.[_0x2fae28(0xed)]===_0x2fae28(0x113)&&_0x3ae434[_0x2fae28(0xed)][_0x2fae28(0x117)]()?_0x3ae434[_0x2fae28(0xed)][_0x2fae28(0x117)]():undefined;}export function readScopedConfig(_0x52f124){const _0x5bb73c=a75_0x14c7fe,_0x58061f=_0x52f124[_0x5bb73c(0x116)]?'global':_0x5bb73c(0x108);return readConfigFile(resolveWriteConfigPath(_0x58061f));}export function writeScopedConfig(_0x57cbc5,_0x299435){const _0x3eccfb=a75_0x14c7fe,_0x3094ec=_0x299435[_0x3eccfb(0x116)]?_0x3eccfb(0x116):'project';writeConfigFile(resolveWriteConfigPath(_0x3094ec),_0x57cbc5);}export async function initGlobalEnvironment(_0x421366){const _0x9637b6=a75_0x14c7fe,{initEnv:_0x1a197d}=await import(_0x9637b6(0x110));_0x1a197d(_0x421366[_0x9637b6(0x107)]);const {initDomains:_0x53429f}=await import(_0x9637b6(0x122));_0x53429f({'apiDomain':_0x421366[_0x9637b6(0xe2)][_0x9637b6(0x125)]||_0x421366['raw'][_0x9637b6(0xe3)]||undefined,'userDomain':_0x421366[_0x9637b6(0xe2)][_0x9637b6(0x121)]||undefined,'runtimeDomain':_0x421366[_0x9637b6(0xe2)][_0x9637b6(0xea)]||undefined,'skillHubDomain':_0x421366['raw'][_0x9637b6(0x11e)]||undefined});}export function getProjectConfigPath(){const _0x3e0cfb=a75_0x14c7fe;return resolveConfigPath(process[_0x3e0cfb(0x100)]());}export function getGlobalConfigPath(){return resolveConfigPath(homedir());}export function inspectCliConfigJsonFile(_0x5ab1da){const _0x2978d0=a75_0x14c7fe;if(!existsSync(_0x5ab1da))return{'status':_0x2978d0(0x10a)};try{const _0x20d72a=readFileSync(_0x5ab1da,{'encoding':'utf8'});if(!_0x20d72a?.[_0x2978d0(0x117)]())return{'status':'empty'};const _0x2d6c55=JSON[_0x2978d0(0x124)](_0x20d72a);return{'status':'ok','data':_0x2d6c55};}catch(_0x4ba04e){return{'status':_0x2978d0(0x10f),'message':_0x4ba04e instanceof Error?_0x4ba04e[_0x2978d0(0xf5)]:String(_0x4ba04e)};}}export function loadRawConfigLayers(_0x37dd28){const _0x38708b=a75_0x14c7fe;let _0x4293a4={},_0x4956ea={},_0xe0fc1f,_0x30eacd;try{_0xe0fc1f=resolveConfigPath(homedir());if(_0xe0fc1f){const _0x47940f=readFileSync(_0xe0fc1f,{'encoding':_0x38708b(0xde)});if(_0x47940f)_0x4293a4=JSON[_0x38708b(0x124)](_0x47940f);}}catch{}try{const _0x3884bf=_0x37dd28||process['cwd']();_0x30eacd=resolveConfigPath(_0x3884bf);if(_0x30eacd){const _0x650533=readFileSync(_0x30eacd,{'encoding':_0x38708b(0xde)});if(_0x650533)_0x4956ea=JSON[_0x38708b(0x124)](_0x650533);}}catch{}return{'globalPath':_0xe0fc1f,'projectPath':_0x30eacd,'globalConfig':_0x4293a4,'projectConfig':_0x4956ea};}function mergeRawConfigLayers(_0x57cfe8){const _0x4cec67=a75_0x14c7fe,{globalConfig:_0x6fac9a,projectConfig:_0x2e7730}=_0x57cfe8;if(_0x2e7730['inherit']===![]){const _0xd341a7={..._0x2e7730};return delete _0xd341a7[_0x4cec67(0xf2)],_0xd341a7;}const _0x5b1b6e={..._0x6fac9a,..._0x2e7730};if(_0x4cec67(0x112)in _0x2e7730)_0x5b1b6e['defaultApp']=_0x2e7730['defaultApp'];else _0x6fac9a[_0x4cec67(0x112)]&&(_0x5b1b6e[_0x4cec67(0x112)]=_0x6fac9a['defaultApp']);return _0x5b1b6e;}export function isInProject(){return!!getProjectConfigPath();}export function readRawConfig(_0x3eaad1){return mergeRawConfigLayers(loadRawConfigLayers(_0x3eaad1));}export function readRawConfigWithLayers(_0x38a734){const _0x973797=loadRawConfigLayers(_0x38a734);return{'config':mergeRawConfigLayers(_0x973797),'layers':_0x973797};}export function resolveDefaultAppSource(_0x26bf6f){const _0x364fd9=a75_0x14c7fe;if(_0x364fd9(0x112)in _0x26bf6f[_0x364fd9(0xe4)])return _0x364fd9(0x108);if(_0x26bf6f[_0x364fd9(0xe4)]['inherit']===![])return null;if(_0x26bf6f[_0x364fd9(0x127)]['defaultApp'])return _0x364fd9(0x116);return null;}function buildConfig(_0x4a7a02,_0x5793b9){const _0x323ccb=a75_0x14c7fe,_0x5c6975=_0x4a7a02[_0x323ccb(0x112)]||undefined,_0x499247=_0x5793b9[_0x323ccb(0xfc)]||env(_0x323ccb(0x103))||undefined,_0x3bd542=_0x499247||_0x5c6975||undefined,_0x547c95=env(_0x323ccb(0xe6))||_0x4a7a02['accessKey']||undefined,_0x436575=_0x5793b9[_0x323ccb(0x107)]||env('ENV')||_0x4a7a02[_0x323ccb(0x107)]||DEFAULT_CONFIG_VALUES[_0x323ccb(0x107)],_0x523062=normalizeEnv(String(_0x436575)),_0x221904=isDaily(_0x523062)?_0x323ccb(0x10e):isDev(_0x523062)?_0x323ccb(0x120):_0x323ccb(0x11c),_0x2cc163=typeof _0x5793b9[_0x323ccb(0xed)]==='string'?_0x5793b9[_0x323ccb(0xed)]:undefined,_0x337058=env(_0x323ccb(0xe5)),_0x2fb30d=_0x499247?undefined:_0x4a7a02[_0x323ccb(0xed)]||_0x4a7a02[_0x323ccb(0xfc)]||undefined,_0x2b17db=_0x499247||(_0x2fb30d?undefined:_0x5c6975),_0x46be0d=resolveLocalAppAliasCode(_0x4a7a02,_0x2b17db),_0x77196e=resolveCachedAppCode(_0x2b17db,_0x221904,_0x547c95),_0x3f251a=_0x2cc163||_0x337058||_0x2fb30d||_0x46be0d||_0x77196e||undefined,_0x3f8899=_0x2cc163?_0x323ccb(0xfe):_0x337058?_0x323ccb(0x107):_0x2fb30d?_0x323ccb(0x105):_0x46be0d?_0x323ccb(0xf3):_0x77196e?_0x323ccb(0xf6):undefined,_0x433a84=_0x4a7a02[_0x323ccb(0xff)]||DEFAULT_CONFIG_VALUES['locale'],_0x1892f9=undefined,_0x12734b=_0x5793b9[_0x323ccb(0xf8)]||env('FORMAT')||_0x4a7a02[_0x323ccb(0xf8)],_0x32bb8b=normalizeLegacyOutputFormat(_0x12734b),_0x1e365d=env(_0x323ccb(0xf4))||_0x4a7a02[_0x323ccb(0x101)],_0x5bf931=_0x1e365d?Number(_0x1e365d)||undefined:undefined,_0x5998c8=_0x4a7a02[_0x323ccb(0xeb)]||_0x4a7a02[_0x323ccb(0xf0)],_0x472d63=_0x5998c8===_0x323ccb(0x106)||_0x5998c8===_0x323ccb(0x11a)||_0x5998c8===_0x323ccb(0xe7)?_0x5998c8:DEFAULT_CONFIG_VALUES[_0x323ccb(0xeb)],_0x22f075=env('VERBOSE'),_0x1974af=_0x22f075==='1'||_0x22f075===_0x323ccb(0x119);return{'appCode':typeof _0x3f251a==='string'&&_0x3f251a[_0x323ccb(0x117)]()?_0x3f251a[_0x323ccb(0x117)]():undefined,'appCodeSource':_0x3f8899,'env':_0x221904,'locale':_0x433a84,'cookie':_0x1892f9,'accessKey':_0x547c95,'format':_0x32bb8b,'pageSize':_0x5bf931,'riskLevel':_0x472d63,'verbose':_0x1974af,'defaultApp':_0x5c6975,'currentApp':typeof _0x3bd542===_0x323ccb(0x113)?_0x3bd542:undefined,'raw':_0x4a7a02};}function env(_0x5da0ee){return productEnv(_0x5da0ee);}function a75_0x48f0(_0xbcf39c,_0xffea25){_0xbcf39c=_0xbcf39c-0xdd;const _0x3ba709=a75_0x3ba7();let _0x48f09a=_0x3ba709[_0xbcf39c];return _0x48f09a;}async function buildAuth(_0x267b62){const _0xe162dc=a75_0x14c7fe,_0x34d2e1='',_0x1ef96c=!!_0x267b62[_0xe162dc(0x11b)];return{'cookie':_0x34d2e1,'isLoggedIn':_0x1ef96c,async 'getOrLogin'(){const _0x528820=_0xe162dc;if(_0x1ef96c)return _0x34d2e1;throw CliErrors[_0x528820(0xfa)]();}};}
|