@ethlete/cli 2.1.0-next.3 → 2.1.0-next.5
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/CHANGELOG.md +22 -0
- package/README.md +103 -6
- package/package.json +1 -1
- package/src/index.d.ts +1 -1
- package/src/index.js +31 -10
- package/src/index.js.map +1 -1
- package/src/lib/api/api-command.d.ts +4 -0
- package/src/lib/api/api-command.js +27 -0
- package/src/lib/api/api-command.js.map +1 -0
- package/src/lib/api/auth-hint.d.ts +9 -0
- package/src/lib/api/auth-hint.js +33 -0
- package/src/lib/api/auth-hint.js.map +1 -0
- package/src/lib/api/clone.d.ts +12 -0
- package/src/lib/api/clone.js +24 -0
- package/src/lib/api/clone.js.map +1 -0
- package/src/lib/api/compose.d.ts +17 -0
- package/src/lib/api/compose.js +58 -0
- package/src/lib/api/compose.js.map +1 -0
- package/src/lib/api/definition.d.ts +32 -0
- package/src/lib/api/definition.js +9 -0
- package/src/lib/api/definition.js.map +1 -0
- package/src/lib/api/git.d.ts +21 -0
- package/src/lib/api/git.js +59 -0
- package/src/lib/api/git.js.map +1 -0
- package/src/lib/api/help.d.ts +3 -0
- package/src/lib/api/help.js +39 -0
- package/src/lib/api/help.js.map +1 -0
- package/src/lib/api/index.d.ts +10 -0
- package/src/lib/api/index.js +14 -0
- package/src/lib/api/index.js.map +1 -0
- package/src/lib/api/load-definitions.d.ts +16 -0
- package/src/lib/api/load-definitions.js +22 -0
- package/src/lib/api/load-definitions.js.map +1 -0
- package/src/lib/api/resolve-checkout.d.ts +35 -0
- package/src/lib/api/resolve-checkout.js +78 -0
- package/src/lib/api/resolve-checkout.js.map +1 -0
- package/src/lib/api/run.d.ts +10 -0
- package/src/lib/api/run.js +149 -0
- package/src/lib/api/run.js.map +1 -0
- package/src/lib/config/diagnose.d.ts +7 -0
- package/src/lib/config/diagnose.js +103 -0
- package/src/lib/config/diagnose.js.map +1 -0
- package/src/lib/config/index.d.ts +2 -0
- package/src/lib/config/index.js +6 -0
- package/src/lib/config/index.js.map +1 -0
- package/src/lib/config/local-config.d.ts +44 -0
- package/src/lib/config/local-config.js +52 -0
- package/src/lib/config/local-config.js.map +1 -0
- package/src/lib/doctor/doctor-command.d.ts +4 -0
- package/src/lib/doctor/doctor-command.js +65 -0
- package/src/lib/doctor/doctor-command.js.map +1 -0
- package/src/lib/doctor/index.d.ts +1 -0
- package/src/lib/doctor/index.js +5 -0
- package/src/lib/doctor/index.js.map +1 -0
- package/src/lib/index.d.ts +3 -0
- package/src/lib/index.js +3 -0
- package/src/lib/index.js.map +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './api-command';
|
|
2
|
+
export * from './compose';
|
|
3
|
+
export * from './auth-hint';
|
|
4
|
+
export * from './clone';
|
|
5
|
+
export * from './definition';
|
|
6
|
+
export * from './git';
|
|
7
|
+
export * from './help';
|
|
8
|
+
export * from './load-definitions';
|
|
9
|
+
export * from './resolve-checkout';
|
|
10
|
+
export * from './run';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./api-command"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./compose"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./auth-hint"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./clone"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./definition"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./git"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./help"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./load-definitions"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./resolve-checkout"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./run"), exports);
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/api/index.ts"],"names":[],"mappings":";;;AAAA,wDAA8B;AAC9B,oDAA0B;AAC1B,sDAA4B;AAC5B,kDAAwB;AACxB,uDAA6B;AAC7B,gDAAsB;AACtB,iDAAuB;AACvB,6DAAmC;AACnC,6DAAmC;AACnC,gDAAsB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ApiDefinitions } from './definition';
|
|
2
|
+
export declare const API_DEFINITIONS_FILE_NAMES: string[];
|
|
3
|
+
export type LoadApiDefinitionsResult = {
|
|
4
|
+
found: true;
|
|
5
|
+
apis: ApiDefinitions;
|
|
6
|
+
fileName: string;
|
|
7
|
+
} | {
|
|
8
|
+
found: false;
|
|
9
|
+
apis?: undefined;
|
|
10
|
+
fileName?: undefined;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Loads the repo's API definitions from `ethlete.apis.js`. The file is a module rather than JSON
|
|
14
|
+
* because a definition's `env` is a function, which JSON cannot hold.
|
|
15
|
+
*/
|
|
16
|
+
export declare const loadApiDefinitions: (root: string) => LoadApiDefinitionsResult;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadApiDefinitions = exports.API_DEFINITIONS_FILE_NAMES = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const module_1 = require("module");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
exports.API_DEFINITIONS_FILE_NAMES = ['ethlete.apis.js', 'ethlete.apis.cjs'];
|
|
8
|
+
/**
|
|
9
|
+
* Loads the repo's API definitions from `ethlete.apis.js`. The file is a module rather than JSON
|
|
10
|
+
* because a definition's `env` is a function, which JSON cannot hold.
|
|
11
|
+
*/
|
|
12
|
+
const loadApiDefinitions = (root) => {
|
|
13
|
+
var _a;
|
|
14
|
+
const fileName = exports.API_DEFINITIONS_FILE_NAMES.find((candidate) => (0, fs_1.existsSync)((0, path_1.join)(root, candidate)));
|
|
15
|
+
if (!fileName)
|
|
16
|
+
return { found: false };
|
|
17
|
+
const loaded = (0, module_1.createRequire)((0, path_1.join)(root, 'package.json'))((0, path_1.join)(root, fileName));
|
|
18
|
+
const apis = (_a = loaded.default) !== null && _a !== void 0 ? _a : loaded;
|
|
19
|
+
return { found: true, apis, fileName };
|
|
20
|
+
};
|
|
21
|
+
exports.loadApiDefinitions = loadApiDefinitions;
|
|
22
|
+
//# sourceMappingURL=load-definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-definitions.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/api/load-definitions.ts"],"names":[],"mappings":";;;AAAA,2BAAgC;AAChC,mCAAuC;AACvC,+BAA4B;AAGf,QAAA,0BAA0B,GAAG,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,CAAC;AAKlF;;;GAGG;AACI,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAA4B,EAAE;;IAC3E,MAAM,QAAQ,GAAG,kCAA0B,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAA,eAAU,EAAC,IAAA,WAAI,EAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IAEnG,IAAI,CAAC,QAAQ;QAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAEvC,MAAM,MAAM,GAAY,IAAA,sBAAa,EAAC,IAAA,WAAI,EAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,IAAA,WAAI,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;IACxF,MAAM,IAAI,GAAG,MAAC,MAAuC,CAAC,OAAO,mCAAK,MAAyB,CAAC;IAE5F,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AACzC,CAAC,CAAC;AATW,QAAA,kBAAkB,sBAS7B"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CloneRequest } from './clone';
|
|
2
|
+
import { ApiDefinition } from './definition';
|
|
3
|
+
export type ApiCheckout = {
|
|
4
|
+
repoPath: string;
|
|
5
|
+
/** The directory the compose commands run in. */
|
|
6
|
+
composePath: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* `legacyConfigWarning` is set on failure too. A wrong path is exactly when the developer needs to
|
|
10
|
+
* know which file the value actually came from.
|
|
11
|
+
*/
|
|
12
|
+
export type ApiCheckoutResult = {
|
|
13
|
+
legacyConfigWarning?: string;
|
|
14
|
+
} & ({
|
|
15
|
+
ok: true;
|
|
16
|
+
checkout: ApiCheckout;
|
|
17
|
+
} | {
|
|
18
|
+
ok: false;
|
|
19
|
+
problem: string;
|
|
20
|
+
/** Set when the managed directory is empty and the API declares where to clone from. */
|
|
21
|
+
clonable?: CloneRequest;
|
|
22
|
+
});
|
|
23
|
+
/** Where an API's managed checkout goes when the developer configured no path of their own. */
|
|
24
|
+
export declare const managedCheckoutPath: (root: string, name: string) => string;
|
|
25
|
+
/** Resolves where an API's containers live, with the one message that explains each way it can fail. */
|
|
26
|
+
export declare const resolveApiCheckout: (options: {
|
|
27
|
+
root: string;
|
|
28
|
+
name: string;
|
|
29
|
+
api: ApiDefinition;
|
|
30
|
+
/**
|
|
31
|
+
* The git commands act on the checkout itself, so they must not demand a compose directory or the
|
|
32
|
+
* output of `setupCommand` — both can legitimately be absent on a checkout that was just cloned.
|
|
33
|
+
*/
|
|
34
|
+
requireCompose?: boolean;
|
|
35
|
+
}) => ApiCheckoutResult;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveApiCheckout = exports.managedCheckoutPath = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const local_config_1 = require("../config/local-config");
|
|
7
|
+
const clone_1 = require("./clone");
|
|
8
|
+
const isDirectory = (path) => (0, fs_1.existsSync)(path) && (0, fs_1.statSync)(path).isDirectory();
|
|
9
|
+
const missingPathProblem = (options) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const { name, api, reason } = options;
|
|
12
|
+
return (`${reason}\n\nAdd the path of your ${name} API checkout to ${local_config_1.LOCAL_CONFIG_FILE_NAME} in the repo ` +
|
|
13
|
+
`root. The file is gitignored, so it changes nothing for anyone else:\n\n` +
|
|
14
|
+
` {\n "apiRepoPaths": {\n "${name}": "${(_a = api.examplePath) !== null && _a !== void 0 ? _a : `../${name}-api`}"\n }\n }`);
|
|
15
|
+
};
|
|
16
|
+
/** Where an API's managed checkout goes when the developer configured no path of their own. */
|
|
17
|
+
const managedCheckoutPath = (root, name) => (0, path_1.join)(root, clone_1.DEFAULT_CHECKOUT_DIR, name);
|
|
18
|
+
exports.managedCheckoutPath = managedCheckoutPath;
|
|
19
|
+
/** Resolves where an API's containers live, with the one message that explains each way it can fail. */
|
|
20
|
+
const resolveApiCheckout = (options) => {
|
|
21
|
+
const { root, name, api, requireCompose = true } = options;
|
|
22
|
+
const { config, fileName, isLegacy } = (0, local_config_1.readLocalConfig)(root);
|
|
23
|
+
const configured = (0, local_config_1.configuredApiRepoPath)(config, name);
|
|
24
|
+
const legacyConfigWarning = isLegacy
|
|
25
|
+
? `${local_config_1.LEGACY_LOCAL_CONFIG_FILE_NAME} still holds "apiRepoPaths". Move it to ${local_config_1.LOCAL_CONFIG_FILE_NAME}.`
|
|
26
|
+
: undefined;
|
|
27
|
+
const repoPath = configured ? (0, local_config_1.resolveConfiguredPath)(root, configured) : (0, exports.managedCheckoutPath)(root, name);
|
|
28
|
+
if (!isDirectory(repoPath)) {
|
|
29
|
+
if (configured) {
|
|
30
|
+
return {
|
|
31
|
+
ok: false,
|
|
32
|
+
legacyConfigWarning,
|
|
33
|
+
problem: `apiRepoPaths.${name} points at ${repoPath}, which is not a directory that exists.`,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if (!api.repoUrl) {
|
|
37
|
+
return {
|
|
38
|
+
ok: false,
|
|
39
|
+
legacyConfigWarning,
|
|
40
|
+
problem: missingPathProblem({
|
|
41
|
+
name,
|
|
42
|
+
api,
|
|
43
|
+
reason: fileName
|
|
44
|
+
? `${fileName} has no apiRepoPaths entry for "${name}", and the API declares no repoUrl.`
|
|
45
|
+
: `${name} has no checkout, and the API declares no repoUrl.`,
|
|
46
|
+
}),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
ok: false,
|
|
51
|
+
legacyConfigWarning,
|
|
52
|
+
problem: `${name} has no checkout at ${repoPath}.`,
|
|
53
|
+
clonable: {
|
|
54
|
+
repoUrl: api.repoUrl,
|
|
55
|
+
into: repoPath,
|
|
56
|
+
branch: (0, local_config_1.configuredApiRepoBranch)(config, name),
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const composePath = (0, path_1.join)(repoPath, api.composeDir);
|
|
61
|
+
if (requireCompose && !isDirectory(composePath)) {
|
|
62
|
+
return {
|
|
63
|
+
ok: false,
|
|
64
|
+
legacyConfigWarning,
|
|
65
|
+
problem: `${repoPath} has no ${api.composeDir} directory. Is apiRepoPaths.${name} the right checkout?`,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (requireCompose && api.envFile && !(0, fs_1.existsSync)((0, path_1.join)(composePath, api.envFile))) {
|
|
69
|
+
return {
|
|
70
|
+
ok: false,
|
|
71
|
+
legacyConfigWarning,
|
|
72
|
+
problem: `Missing ${api.envFile} in ${composePath}.${api.setupCommand ? ` Run "${api.setupCommand}" there first.` : ''}`,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
return { ok: true, legacyConfigWarning, checkout: { repoPath, composePath } };
|
|
76
|
+
};
|
|
77
|
+
exports.resolveApiCheckout = resolveApiCheckout;
|
|
78
|
+
//# sourceMappingURL=resolve-checkout.js.map
|
|
@@ -0,0 +1 @@
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AAQ,WAAW,GAAG,CAAC,UAAU,+BAA+B,IAAI,sBAAsB;SACvG,CAAC;IACJ,CAAC;IAED,IAAI,cAAc,IAAI,GAAG,CAAC,OAAO,IAAI,CAAC,IAAA,eAAU,EAAC,IAAA,WAAI,EAAC,WAAW,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;QACjF,OAAO;YACL,EAAE,EAAE,KAAK;YACT,mBAAmB;YACnB,OAAO,EAAE,WAAW,GAAG,CAAC,OAAO,OAAO,WAAW,IAC/C,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,YAAY,gBAAgB,CAAC,CAAC,CAAC,EACjE,EAAE;SACH,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,CAAC;AAChF,CAAC,CAAC;AA3EW,QAAA,kBAAkB,sBA2E7B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ApiDefinitions } from './definition';
|
|
2
|
+
export type RunApiCommandOptions = {
|
|
3
|
+
apis: ApiDefinitions;
|
|
4
|
+
/** Arguments after the command name, for example `['up', 'hub', '--host']`. */
|
|
5
|
+
argv: string[];
|
|
6
|
+
root?: string;
|
|
7
|
+
/** How the caller is invoked, used in the usage line. */
|
|
8
|
+
invocation?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const runApiCommand: ({ apis, argv, root, invocation, }: RunApiCommandOptions) => Promise<number>;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runApiCommand = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
6
|
+
const compose_1 = require("./compose");
|
|
7
|
+
const definition_1 = require("./definition");
|
|
8
|
+
const git_1 = require("./git");
|
|
9
|
+
const help_1 = require("./help");
|
|
10
|
+
const resolve_checkout_1 = require("./resolve-checkout");
|
|
11
|
+
const clone_1 = require("./clone");
|
|
12
|
+
const auth_hint_1 = require("./auth-hint");
|
|
13
|
+
const utils_1 = require("../utils");
|
|
14
|
+
const local_config_1 = require("../config/local-config");
|
|
15
|
+
const confirmClone = (options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const { problem, repoUrl, into } = options;
|
|
17
|
+
if (!process.stdin.isTTY) {
|
|
18
|
+
console.error(`${problem}\n\nRe-run with --clone to clone ${repoUrl} into ${into}.`);
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const answer = yield (0, utils_1.askQuestion)(`${problem}\n\nClone ${repoUrl}\ninto ${into}? [y/N] `);
|
|
22
|
+
return /^y(es)?$/i.test(answer.trim());
|
|
23
|
+
});
|
|
24
|
+
const definedEntries = (record) => Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined));
|
|
25
|
+
const runApiCommand = (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ apis, argv, root = process.cwd(), invocation = 'et api', }) {
|
|
26
|
+
var _b, _c, _d, _e;
|
|
27
|
+
const exposeOnLan = argv.includes('--host');
|
|
28
|
+
const [command, name] = argv.filter((arg) => !arg.startsWith('--'));
|
|
29
|
+
const api = name === undefined ? undefined : apis[name];
|
|
30
|
+
if (argv.includes('--help') || argv.includes('-h') || command === 'help') {
|
|
31
|
+
console.log((0, help_1.apiHelp)(apis, invocation));
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
if (command === undefined || name === undefined || !api) {
|
|
35
|
+
console.error((0, help_1.apiHelp)(apis, invocation));
|
|
36
|
+
return 1;
|
|
37
|
+
}
|
|
38
|
+
const commands = (0, definition_1.apiCommandNames)(api);
|
|
39
|
+
if (!commands.includes(command)) {
|
|
40
|
+
console.error(`Unknown command "${command}" for the ${name} API.\n\nCommands: ${commands.join(', ')}`);
|
|
41
|
+
return 1;
|
|
42
|
+
}
|
|
43
|
+
const isGitCommand = definition_1.GIT_API_COMMANDS.includes(command);
|
|
44
|
+
const checkout = (0, resolve_checkout_1.resolveApiCheckout)({ root, name, api, requireCompose: !isGitCommand });
|
|
45
|
+
if (checkout.legacyConfigWarning) {
|
|
46
|
+
console.warn(`${checkout.legacyConfigWarning}\n`);
|
|
47
|
+
}
|
|
48
|
+
if (!checkout.ok) {
|
|
49
|
+
if (!checkout.clonable) {
|
|
50
|
+
console.error(checkout.problem);
|
|
51
|
+
return 1;
|
|
52
|
+
}
|
|
53
|
+
const { repoUrl, into, branch } = checkout.clonable;
|
|
54
|
+
const accepted = command === 'clone' ||
|
|
55
|
+
argv.includes('--clone') ||
|
|
56
|
+
(yield confirmClone({ problem: checkout.problem, repoUrl, into }));
|
|
57
|
+
if (!accepted)
|
|
58
|
+
return 1;
|
|
59
|
+
if (!(0, clone_1.isGitIgnored)(root, into)) {
|
|
60
|
+
console.warn(`\n${clone_1.DEFAULT_CHECKOUT_DIR}/ is not gitignored. Add it before you commit anything.\n`);
|
|
61
|
+
}
|
|
62
|
+
const cloned = (0, clone_1.cloneApiRepo)({ repoUrl, into, branch });
|
|
63
|
+
if (cloned !== 0) {
|
|
64
|
+
(0, auth_hint_1.printPrivateDependencyHint)({ repoHost: (0, auth_hint_1.gitUrlHost)(repoUrl) });
|
|
65
|
+
return cloned;
|
|
66
|
+
}
|
|
67
|
+
if (command === 'clone')
|
|
68
|
+
return 0;
|
|
69
|
+
return (0, exports.runApiCommand)({ apis, argv, root, invocation });
|
|
70
|
+
}
|
|
71
|
+
if (command === 'clone') {
|
|
72
|
+
console.log(`${name} already has a checkout at ${checkout.checkout.repoPath}.`);
|
|
73
|
+
return 0;
|
|
74
|
+
}
|
|
75
|
+
const { repoPath, composePath: cwd } = checkout.checkout;
|
|
76
|
+
if (isGitCommand) {
|
|
77
|
+
const expectedBranch = (0, local_config_1.configuredApiRepoBranch)((0, local_config_1.readLocalConfig)(root).config, name);
|
|
78
|
+
if (command === 'checkout') {
|
|
79
|
+
if (!expectedBranch) {
|
|
80
|
+
console.error(`No branch configured for "${name}". Add it to apiRepoBranches:\n\n` +
|
|
81
|
+
` {\n "apiRepoBranches": {\n "${name}": "main"\n }\n }`);
|
|
82
|
+
return 1;
|
|
83
|
+
}
|
|
84
|
+
return (0, git_1.checkoutApiBranch)({ repoPath, branch: expectedBranch });
|
|
85
|
+
}
|
|
86
|
+
return (0, git_1.pullApiBranch)({ repoPath, expectedBranch, force: argv.includes('--force') });
|
|
87
|
+
}
|
|
88
|
+
const tool = (0, compose_1.resolveComposeTool)();
|
|
89
|
+
if (!tool) {
|
|
90
|
+
console.error(`No compose tool found. Tried: ${(0, compose_1.composeToolNames)().join(', ')}.`);
|
|
91
|
+
return 1;
|
|
92
|
+
}
|
|
93
|
+
const { engine, compose } = tool;
|
|
94
|
+
const [binary, ...composePrefix] = compose;
|
|
95
|
+
const env = Object.assign(Object.assign(Object.assign({}, (0, compose_1.engineEnv)(engine)), process.env), definedEntries((_c = (_b = api.env) === null || _b === void 0 ? void 0 : _b.call(api)) !== null && _c !== void 0 ? _c : {}));
|
|
96
|
+
let exitCode = 0;
|
|
97
|
+
const runCompose = (...composeArgs) => {
|
|
98
|
+
var _a;
|
|
99
|
+
const result = (0, child_process_1.spawnSync)(binary, [...composePrefix, ...composeArgs], { cwd, env, stdio: 'inherit' });
|
|
100
|
+
if (result.error) {
|
|
101
|
+
console.error(result.error.message);
|
|
102
|
+
exitCode = 1;
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
exitCode = (_a = result.status) !== null && _a !== void 0 ? _a : 1;
|
|
106
|
+
};
|
|
107
|
+
if (command === 'up') {
|
|
108
|
+
if (api.network) {
|
|
109
|
+
(0, child_process_1.spawnSync)(engine, ['network', 'create', api.network], { stdio: 'ignore' });
|
|
110
|
+
}
|
|
111
|
+
runCompose('up', '-d', ...api.services);
|
|
112
|
+
// podman-compose exits 0 even when it fails to build or pull an image, so the state has to be
|
|
113
|
+
// read back rather than inferred from the exit code.
|
|
114
|
+
console.log(`\n${name} API at http://localhost:${api.port}. State:\n`);
|
|
115
|
+
runCompose('ps');
|
|
116
|
+
if (exposeOnLan) {
|
|
117
|
+
const address = (0, compose_1.lanAddress)();
|
|
118
|
+
if (!address) {
|
|
119
|
+
console.error('\nThis machine has no external IPv4 address, so the API cannot be reached over the network.');
|
|
120
|
+
return 1;
|
|
121
|
+
}
|
|
122
|
+
const envKeyStep = api.envKey
|
|
123
|
+
? `\n 2. Run localStorage.setItem('${api.envKey}', 'http://${address}:${api.port}') on that device.`
|
|
124
|
+
: '';
|
|
125
|
+
console.log(`\nThe published ports already listen on every interface, so the API also answers on\n` +
|
|
126
|
+
`http://${address}:${api.port}. Two more steps make another device use it:\n\n` +
|
|
127
|
+
` 1. Serve the app with a host binding of 0.0.0.0.${envKeyStep}\n\n` +
|
|
128
|
+
`A host firewall can still block port ${api.port}.`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
else if (command === 'down') {
|
|
132
|
+
runCompose('down');
|
|
133
|
+
}
|
|
134
|
+
else if (command === 'logs') {
|
|
135
|
+
runCompose('logs', '-f', api.execService);
|
|
136
|
+
}
|
|
137
|
+
else if (command === 'shell') {
|
|
138
|
+
runCompose('exec', api.execService, 'bash');
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
runCompose('exec', api.execService, ...((_e = (_d = api.exec) === null || _d === void 0 ? void 0 : _d[command]) !== null && _e !== void 0 ? _e : []));
|
|
142
|
+
if (exitCode !== 0) {
|
|
143
|
+
(0, auth_hint_1.printPrivateDependencyHint)({ repoHost: api.repoUrl ? (0, auth_hint_1.gitUrlHost)(api.repoUrl) : undefined });
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return exitCode;
|
|
147
|
+
});
|
|
148
|
+
exports.runApiCommand = runApiCommand;
|
|
149
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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
|
1
|
+
/**
|
|
2
|
+
* Every problem with the repo topology config: a file that cannot be parsed, a key nothing reads, a
|
|
3
|
+
* checkout that is not there, and values still sitting in the file they moved out of.
|
|
4
|
+
*/
|
|
5
|
+
export declare const diagnoseLocalConfig: ({ root }: {
|
|
6
|
+
root: string;
|
|
7
|
+
}) => string[];
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.diagnoseLocalConfig = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const local_config_1 = require("./local-config");
|
|
7
|
+
/** Marks a directory as an `ethlete-sdk` checkout rather than some other folder. */
|
|
8
|
+
const SDK_CHECKOUT_MARKERS = ['libs/components', 'libs/core', 'libs/agent-rules'];
|
|
9
|
+
const quoted = (keys) => keys.map((key) => `"${key}"`).join(', ');
|
|
10
|
+
const describeSdkSourcePath = (options) => {
|
|
11
|
+
const { root, value, fileName } = options;
|
|
12
|
+
if (value === undefined)
|
|
13
|
+
return [];
|
|
14
|
+
if (typeof value !== 'string' || value.trim().length === 0) {
|
|
15
|
+
return [`${fileName} has an invalid "sdkSourcePath" — use a path to an ethlete-sdk checkout.`];
|
|
16
|
+
}
|
|
17
|
+
const absolute = (0, local_config_1.resolveConfiguredPath)(root, value);
|
|
18
|
+
if (!(0, fs_1.existsSync)(absolute)) {
|
|
19
|
+
return [`${fileName} points "sdkSourcePath" at ${absolute}, which does not exist.`];
|
|
20
|
+
}
|
|
21
|
+
if (SDK_CHECKOUT_MARKERS.some((marker) => !(0, fs_1.existsSync)((0, path_1.join)(absolute, marker)))) {
|
|
22
|
+
return [`${fileName} points "sdkSourcePath" at ${absolute}, which is not an ethlete-sdk checkout.`];
|
|
23
|
+
}
|
|
24
|
+
return [];
|
|
25
|
+
};
|
|
26
|
+
const describeApiRepoPaths = (options) => {
|
|
27
|
+
const { root, value, fileName } = options;
|
|
28
|
+
if (value === undefined)
|
|
29
|
+
return [];
|
|
30
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
31
|
+
return [
|
|
32
|
+
`${fileName} has an invalid "apiRepoPaths" value — use an object mapping an app name to its API repo path.`,
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
return Object.entries(value).flatMap(([app, path]) => {
|
|
36
|
+
if (typeof path !== 'string' || path.trim().length === 0) {
|
|
37
|
+
return [`${fileName} has an invalid "apiRepoPaths.${app}" value — use a path to the API repo.`];
|
|
38
|
+
}
|
|
39
|
+
const absolute = (0, local_config_1.resolveConfiguredPath)(root, path);
|
|
40
|
+
if (!(0, fs_1.existsSync)(absolute)) {
|
|
41
|
+
return [`${fileName} points "apiRepoPaths.${app}" at ${absolute}, which does not exist.`];
|
|
42
|
+
}
|
|
43
|
+
if (!(0, fs_1.statSync)(absolute).isDirectory()) {
|
|
44
|
+
return [`${fileName} points "apiRepoPaths.${app}" at ${absolute}, which is not a directory.`];
|
|
45
|
+
}
|
|
46
|
+
return [];
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
const describeApiRepoBranches = (options) => {
|
|
50
|
+
const { value, fileName } = options;
|
|
51
|
+
if (value === undefined)
|
|
52
|
+
return [];
|
|
53
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
54
|
+
return [
|
|
55
|
+
`${fileName} has an invalid "apiRepoBranches" value — use an object mapping an app name to its expected API branch.`,
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
return Object.entries(value).flatMap(([app, branch]) => typeof branch === 'string' && branch.trim().length > 0
|
|
59
|
+
? []
|
|
60
|
+
: [`${fileName} has an invalid "apiRepoBranches.${app}" value — use a non-empty branch name.`]);
|
|
61
|
+
};
|
|
62
|
+
const describeValues = (options) => {
|
|
63
|
+
const { root, config, fileName } = options;
|
|
64
|
+
return [
|
|
65
|
+
...describeSdkSourcePath({ root, value: config.sdkSourcePath, fileName }),
|
|
66
|
+
...describeApiRepoPaths({ root, value: config.apiRepoPaths, fileName }),
|
|
67
|
+
...describeApiRepoBranches({ value: config.apiRepoBranches, fileName }),
|
|
68
|
+
];
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Every problem with the repo topology config: a file that cannot be parsed, a key nothing reads, a
|
|
72
|
+
* checkout that is not there, and values still sitting in the file they moved out of.
|
|
73
|
+
*/
|
|
74
|
+
const diagnoseLocalConfig = ({ root }) => {
|
|
75
|
+
const primary = (0, local_config_1.readLocalConfigFile)((0, path_1.join)(root, local_config_1.LOCAL_CONFIG_FILE_NAME));
|
|
76
|
+
if (primary.status === 'unreadable')
|
|
77
|
+
return [`${local_config_1.LOCAL_CONFIG_FILE_NAME} is not valid JSON.`];
|
|
78
|
+
if (primary.status === 'not-an-object')
|
|
79
|
+
return [`${local_config_1.LOCAL_CONFIG_FILE_NAME} is not a JSON object.`];
|
|
80
|
+
if (primary.status === 'ok') {
|
|
81
|
+
const unknownKeys = Object.keys(primary.config).filter((key) => !local_config_1.LOCAL_CONFIG_KEYS.includes(key));
|
|
82
|
+
return [
|
|
83
|
+
...(unknownKeys.length > 0
|
|
84
|
+
? [
|
|
85
|
+
`${local_config_1.LOCAL_CONFIG_FILE_NAME} contains key(s) nothing reads: ${quoted(unknownKeys)} — it supports ${quoted(local_config_1.LOCAL_CONFIG_KEYS)}.`,
|
|
86
|
+
]
|
|
87
|
+
: []),
|
|
88
|
+
...describeValues({ root, config: primary.config, fileName: local_config_1.LOCAL_CONFIG_FILE_NAME }),
|
|
89
|
+
];
|
|
90
|
+
}
|
|
91
|
+
const legacy = (0, local_config_1.readLocalConfigFile)((0, path_1.join)(root, local_config_1.LEGACY_LOCAL_CONFIG_FILE_NAME));
|
|
92
|
+
if (legacy.status !== 'ok')
|
|
93
|
+
return [];
|
|
94
|
+
const held = local_config_1.LOCAL_CONFIG_KEYS.filter((key) => legacy.config[key] !== undefined);
|
|
95
|
+
if (held.length === 0)
|
|
96
|
+
return [];
|
|
97
|
+
return [
|
|
98
|
+
`${local_config_1.LEGACY_LOCAL_CONFIG_FILE_NAME} still holds ${quoted(held)} — move ${held.length === 1 ? 'it' : 'them'} to ${local_config_1.LOCAL_CONFIG_FILE_NAME}.`,
|
|
99
|
+
...describeValues({ root, config: legacy.config, fileName: local_config_1.LEGACY_LOCAL_CONFIG_FILE_NAME }),
|
|
100
|
+
];
|
|
101
|
+
};
|
|
102
|
+
exports.diagnoseLocalConfig = diagnoseLocalConfig;
|
|
103
|
+
//# sourceMappingURL=diagnose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnose.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/config/diagnose.ts"],"names":[],"mappings":";;;AAAA,2BAA0C;AAC1C,+BAA4B;AAC5B,iDAOwB;AAExB,oFAAoF;AACpF,MAAM,oBAAoB,GAAG,CAAC,iBAAiB,EAAE,WAAW,EAAE,kBAAkB,CAAC,CAAC;AAElF,MAAM,MAAM,GAAG,CAAC,IAAc,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAE5E,MAAM,qBAAqB,GAAG,CAAC,OAA2D,EAAE,EAAE;IAC5F,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAE1C,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IAEnC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3D,OAAO,CAAC,GAAG,QAAQ,0EAA0E,CAAC,CAAC;IACjG,CAAC;IAED,MAAM,QAAQ,GAAG,IAAA,oCAAqB,EAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAEpD,IAAI,CAAC,IAAA,eAAU,EAAC,QAAQ,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C,MAAM,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IAEtC,MAAM,IAAI,GAAG,gCAAiB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,CAAC;IAEjF,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEjC,OAAO;QACL,GAAG,4CAA6B,gBAAgB,MAAM,CAAC,IAAI,CAAC,WAC1D,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAC7B,OAAO,qCAAsB,GAAG;QAChC,GAAG,cAAc,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,4CAA6B,EAAE,CAAC;KAC5F,CAAC;AACJ,CAAC,CAAC;AAtCW,QAAA,mBAAmB,uBAsC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/config/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,yDAA+B"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare const LOCAL_CONFIG_FILE_NAME = "ethlete.config.local.json";
|
|
2
|
+
/**
|
|
3
|
+
* The file these keys lived in before they moved to `ethlete.config.local.json`. Still read as a
|
|
4
|
+
* fallback so an existing checkout keeps working, and reported so the developer can move them.
|
|
5
|
+
*/
|
|
6
|
+
export declare const LEGACY_LOCAL_CONFIG_FILE_NAME = "ethlete-agents.config.local.json";
|
|
7
|
+
/**
|
|
8
|
+
* Machine-local repo topology: where the sibling checkouts this repo works with live. The file is
|
|
9
|
+
* gitignored, so every value is per-machine and never changes what anyone else sees.
|
|
10
|
+
*/
|
|
11
|
+
export type LocalConfig = {
|
|
12
|
+
/** Path to a local `ethlete-sdk` checkout, for reading its source or building it into this repo. */
|
|
13
|
+
sdkSourcePath?: string;
|
|
14
|
+
/** Path to the checkout of the API an app talks to, keyed by app name. `"*"` matches any app. */
|
|
15
|
+
apiRepoPaths?: Record<string, string>;
|
|
16
|
+
/** Branch that represents each API's deployed state, keyed by app name. `"*"` matches any app. */
|
|
17
|
+
apiRepoBranches?: Record<string, string>;
|
|
18
|
+
};
|
|
19
|
+
export declare const LOCAL_CONFIG_KEYS: (keyof LocalConfig)[];
|
|
20
|
+
export type LocalConfigFileState = {
|
|
21
|
+
status: 'absent';
|
|
22
|
+
} | {
|
|
23
|
+
status: 'unreadable';
|
|
24
|
+
} | {
|
|
25
|
+
status: 'not-an-object';
|
|
26
|
+
} | {
|
|
27
|
+
status: 'ok';
|
|
28
|
+
config: LocalConfig;
|
|
29
|
+
};
|
|
30
|
+
export type LocalConfigSource = {
|
|
31
|
+
config: LocalConfig;
|
|
32
|
+
/** The file the values came from, or `undefined` when neither file exists. */
|
|
33
|
+
fileName?: string;
|
|
34
|
+
/** True when the values came from `LEGACY_LOCAL_CONFIG_FILE_NAME`. */
|
|
35
|
+
isLegacy: boolean;
|
|
36
|
+
};
|
|
37
|
+
/** Reads one config file, keeping "not there" apart from "there but broken" for `et doctor`. */
|
|
38
|
+
export declare const readLocalConfigFile: (path: string) => LocalConfigFileState;
|
|
39
|
+
/** Reads the local config, falling back to the file the keys used to live in. */
|
|
40
|
+
export declare const readLocalConfig: (root: string) => LocalConfigSource;
|
|
41
|
+
export declare const configuredApiRepoPath: (config: LocalConfig, api: string) => string | undefined;
|
|
42
|
+
export declare const configuredApiRepoBranch: (config: LocalConfig, api: string) => string | undefined;
|
|
43
|
+
/** Resolves a configured path against the repo root, so a relative path in the file works. */
|
|
44
|
+
export declare const resolveConfiguredPath: (root: string, configured: string) => string;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveConfiguredPath = exports.configuredApiRepoBranch = exports.configuredApiRepoPath = exports.readLocalConfig = exports.readLocalConfigFile = exports.LOCAL_CONFIG_KEYS = exports.LEGACY_LOCAL_CONFIG_FILE_NAME = exports.LOCAL_CONFIG_FILE_NAME = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
exports.LOCAL_CONFIG_FILE_NAME = 'ethlete.config.local.json';
|
|
7
|
+
/**
|
|
8
|
+
* The file these keys lived in before they moved to `ethlete.config.local.json`. Still read as a
|
|
9
|
+
* fallback so an existing checkout keeps working, and reported so the developer can move them.
|
|
10
|
+
*/
|
|
11
|
+
exports.LEGACY_LOCAL_CONFIG_FILE_NAME = 'ethlete-agents.config.local.json';
|
|
12
|
+
exports.LOCAL_CONFIG_KEYS = ['sdkSourcePath', 'apiRepoPaths', 'apiRepoBranches'];
|
|
13
|
+
/** Reads one config file, keeping "not there" apart from "there but broken" for `et doctor`. */
|
|
14
|
+
const readLocalConfigFile = (path) => {
|
|
15
|
+
if (!(0, fs_1.existsSync)(path))
|
|
16
|
+
return { status: 'absent' };
|
|
17
|
+
let parsed;
|
|
18
|
+
try {
|
|
19
|
+
parsed = JSON.parse((0, fs_1.readFileSync)(path, 'utf8'));
|
|
20
|
+
}
|
|
21
|
+
catch (_a) {
|
|
22
|
+
return { status: 'unreadable' };
|
|
23
|
+
}
|
|
24
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed))
|
|
25
|
+
return { status: 'not-an-object' };
|
|
26
|
+
return { status: 'ok', config: parsed };
|
|
27
|
+
};
|
|
28
|
+
exports.readLocalConfigFile = readLocalConfigFile;
|
|
29
|
+
const readJsonObject = (path) => {
|
|
30
|
+
const state = (0, exports.readLocalConfigFile)(path);
|
|
31
|
+
return state.status === 'ok' ? state.config : undefined;
|
|
32
|
+
};
|
|
33
|
+
/** Reads the local config, falling back to the file the keys used to live in. */
|
|
34
|
+
const readLocalConfig = (root) => {
|
|
35
|
+
const current = readJsonObject((0, path_1.join)(root, exports.LOCAL_CONFIG_FILE_NAME));
|
|
36
|
+
if (current)
|
|
37
|
+
return { config: current, fileName: exports.LOCAL_CONFIG_FILE_NAME, isLegacy: false };
|
|
38
|
+
const legacy = readJsonObject((0, path_1.join)(root, exports.LEGACY_LOCAL_CONFIG_FILE_NAME));
|
|
39
|
+
if (legacy)
|
|
40
|
+
return { config: legacy, fileName: exports.LEGACY_LOCAL_CONFIG_FILE_NAME, isLegacy: true };
|
|
41
|
+
return { config: {}, isLegacy: false };
|
|
42
|
+
};
|
|
43
|
+
exports.readLocalConfig = readLocalConfig;
|
|
44
|
+
const entryFor = (record, key) => { var _a; return (_a = record === null || record === void 0 ? void 0 : record[key]) !== null && _a !== void 0 ? _a : record === null || record === void 0 ? void 0 : record['*']; };
|
|
45
|
+
const configuredApiRepoPath = (config, api) => entryFor(config.apiRepoPaths, api);
|
|
46
|
+
exports.configuredApiRepoPath = configuredApiRepoPath;
|
|
47
|
+
const configuredApiRepoBranch = (config, api) => entryFor(config.apiRepoBranches, api);
|
|
48
|
+
exports.configuredApiRepoBranch = configuredApiRepoBranch;
|
|
49
|
+
/** Resolves a configured path against the repo root, so a relative path in the file works. */
|
|
50
|
+
const resolveConfiguredPath = (root, configured) => (0, path_1.isAbsolute)(configured) ? configured : (0, path_1.resolve)(root, configured);
|
|
51
|
+
exports.resolveConfiguredPath = resolveConfiguredPath;
|
|
52
|
+
//# sourceMappingURL=local-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-config.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/config/local-config.ts"],"names":[],"mappings":";;;AAAA,2BAA8C;AAC9C,+BAAiD;AAEpC,QAAA,sBAAsB,GAAG,2BAA2B,CAAC;AAElE;;;GAGG;AACU,QAAA,6BAA6B,GAAG,kCAAkC,CAAC;AAenE,QAAA,iBAAiB,GAA0B,CAAC,eAAe,EAAE,cAAc,EAAE,iBAAiB,CAAC,CAAC;AAa7G,gGAAgG;AACz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