@ethlete/cli 2.1.0-next.4 → 2.1.0-next.6
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 +45 -0
- package/README.md +49 -8
- package/package.json +1 -1
- package/src/index.js +52 -8
- package/src/index.js.map +1 -1
- package/src/lib/api/api-command.d.ts +3 -2
- package/src/lib/api/api-command.js +2 -2
- package/src/lib/api/api-command.js.map +1 -1
- package/src/lib/api/auth-hint.d.ts +11 -0
- package/src/lib/api/auth-hint.js +47 -0
- package/src/lib/api/auth-hint.js.map +1 -0
- package/src/lib/api/clear.d.ts +36 -0
- package/src/lib/api/clear.js +121 -0
- package/src/lib/api/clear.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 +29 -0
- package/src/lib/api/compose.js +44 -1
- package/src/lib/api/compose.js.map +1 -1
- package/src/lib/api/definition.d.ts +11 -2
- package/src/lib/api/definition.js +29 -3
- package/src/lib/api/definition.js.map +1 -1
- package/src/lib/api/git.d.ts +25 -0
- package/src/lib/api/git.js +71 -0
- package/src/lib/api/git.js.map +1 -0
- package/src/lib/api/help.d.ts +11 -0
- package/src/lib/api/help.js +72 -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 +10 -0
- package/src/lib/api/index.js.map +1 -1
- package/src/lib/api/ports.d.ts +13 -0
- package/src/lib/api/ports.js +98 -0
- package/src/lib/api/ports.js.map +1 -0
- package/src/lib/api/resolve-checkout.d.ts +45 -0
- package/src/lib/api/resolve-checkout.js +91 -0
- package/src/lib/api/resolve-checkout.js.map +1 -0
- package/src/lib/api/run.d.ts +1 -1
- package/src/lib/api/run.js +268 -55
- package/src/lib/api/run.js.map +1 -1
- package/src/lib/api/setup.d.ts +15 -0
- package/src/lib/api/setup.js +41 -0
- package/src/lib/api/setup.js.map +1 -0
- package/src/lib/api/state.d.ts +20 -0
- package/src/lib/api/state.js +33 -0
- package/src/lib/api/state.js.map +1 -0
- package/src/lib/api/suggest.d.ts +7 -0
- package/src/lib/api/suggest.js +35 -0
- package/src/lib/api/suggest.js.map +1 -0
- package/src/lib/auth/auth-command.d.ts +11 -0
- package/src/lib/auth/auth-command.js +137 -0
- package/src/lib/auth/auth-command.js.map +1 -0
- package/src/lib/auth/composer-auth.d.ts +25 -0
- package/src/lib/auth/composer-auth.js +63 -0
- package/src/lib/auth/composer-auth.js.map +1 -0
- package/src/lib/auth/composer-repositories.d.ts +5 -0
- package/src/lib/auth/composer-repositories.js +33 -0
- package/src/lib/auth/composer-repositories.js.map +1 -0
- package/src/lib/auth/gitlab-token.d.ts +43 -0
- package/src/lib/auth/gitlab-token.js +72 -0
- package/src/lib/auth/gitlab-token.js.map +1 -0
- package/src/lib/auth/index.d.ts +4 -0
- package/src/lib/auth/index.js +8 -0
- package/src/lib/auth/index.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 +1 -0
- package/src/lib/config/index.js +1 -0
- package/src/lib/config/index.js.map +1 -1
- package/src/lib/config/local-config.d.ts +13 -0
- package/src/lib/config/local-config.js +13 -6
- package/src/lib/config/local-config.js.map +1 -1
- package/src/lib/doctor/doctor-command.d.ts +5 -0
- package/src/lib/doctor/doctor-command.js +62 -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
- package/src/lib/invocation.d.ts +9 -0
- package/src/lib/invocation.js +47 -0
- package/src/lib/invocation.js.map +1 -0
- package/src/lib/utils.d.ts +14 -0
- package/src/lib/utils.js +14 -1
- package/src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AL,KAAK,GAAI,EAAE,CAAC;KACtC,CAAC,CAAC,CAAC;AACR,CAAC,CAAC;AAhBW,QAAA,eAAe,mBAgB1B"}
|
|
@@ -10,12 +10,14 @@ export type ApiDefinition = {
|
|
|
10
10
|
port: number;
|
|
11
11
|
/** File that must exist in `composeDir` before the API can start, for example `.env`. */
|
|
12
12
|
envFile?: string;
|
|
13
|
-
/** Command that creates `envFile
|
|
13
|
+
/** Command that creates `envFile`, run by `setup` in `composeDir`. */
|
|
14
14
|
setupCommand?: string;
|
|
15
15
|
/** External container network to create before the first `up`. */
|
|
16
16
|
network?: string;
|
|
17
17
|
/** Example path shown in the error that asks the developer to configure this API's checkout. */
|
|
18
18
|
examplePath?: string;
|
|
19
|
+
/** Where to clone this API from when the developer has no checkout of their own. */
|
|
20
|
+
repoUrl?: string;
|
|
19
21
|
/** localStorage key the app reads to pick its API. Printed by `--host`. */
|
|
20
22
|
envKey?: string;
|
|
21
23
|
/** Extra environment for every compose call. An undefined value is dropped rather than passed as "undefined". */
|
|
@@ -24,5 +26,12 @@ export type ApiDefinition = {
|
|
|
24
26
|
exec?: Record<string, string[]>;
|
|
25
27
|
};
|
|
26
28
|
export type ApiDefinitions = Record<string, ApiDefinition>;
|
|
27
|
-
export declare const BUILT_IN_API_COMMANDS: readonly ["up", "down", "logs", "shell"];
|
|
29
|
+
export declare const BUILT_IN_API_COMMANDS: readonly ["up", "down", "logs", "shell", "clone", "clear", "checkout", "pull", "setup"];
|
|
30
|
+
/** These act on the checkout itself, so they run before `setupCommand` and need no container engine. */
|
|
31
|
+
export declare const GIT_API_COMMANDS: string[];
|
|
32
|
+
/** Whether an exec entry downloads dependencies, which is the only failure the private-dependency hint explains. */
|
|
33
|
+
export declare const installsDependencies: (execCommand: readonly string[]) => boolean;
|
|
34
|
+
/** The exec entry that installs dependencies, so a failure in another entry can point at it. */
|
|
35
|
+
export declare const dependencyInstallCommandName: (api: ApiDefinition) => string | undefined;
|
|
36
|
+
/** `setup` is dropped for an API that declares no `setupCommand`, so nothing lists a command it cannot run. */
|
|
28
37
|
export declare const apiCommandNames: (api: ApiDefinition) => string[];
|
|
@@ -1,7 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.apiCommandNames = exports.BUILT_IN_API_COMMANDS = void 0;
|
|
4
|
-
exports.BUILT_IN_API_COMMANDS = [
|
|
5
|
-
|
|
3
|
+
exports.apiCommandNames = exports.dependencyInstallCommandName = exports.installsDependencies = exports.GIT_API_COMMANDS = exports.BUILT_IN_API_COMMANDS = void 0;
|
|
4
|
+
exports.BUILT_IN_API_COMMANDS = [
|
|
5
|
+
'up',
|
|
6
|
+
'down',
|
|
7
|
+
'logs',
|
|
8
|
+
'shell',
|
|
9
|
+
'clone',
|
|
10
|
+
'clear',
|
|
11
|
+
'checkout',
|
|
12
|
+
'pull',
|
|
13
|
+
'setup',
|
|
14
|
+
];
|
|
15
|
+
/** These act on the checkout itself, so they run before `setupCommand` and need no container engine. */
|
|
16
|
+
exports.GIT_API_COMMANDS = ['clone', 'checkout', 'pull'];
|
|
17
|
+
const DEPENDENCY_INSTALLERS = ['composer', 'npm', 'yarn', 'pnpm', 'bun', 'bundle', 'pip', 'pip3'];
|
|
18
|
+
/** Whether an exec entry downloads dependencies, which is the only failure the private-dependency hint explains. */
|
|
19
|
+
const installsDependencies = (execCommand) => { var _a; return DEPENDENCY_INSTALLERS.includes((_a = execCommand[0]) !== null && _a !== void 0 ? _a : ''); };
|
|
20
|
+
exports.installsDependencies = installsDependencies;
|
|
21
|
+
/** The exec entry that installs dependencies, so a failure in another entry can point at it. */
|
|
22
|
+
const dependencyInstallCommandName = (api) => { var _a; return Object.keys((_a = api.exec) !== null && _a !== void 0 ? _a : {}).find((name) => { var _a, _b; return (0, exports.installsDependencies)((_b = (_a = api.exec) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : []); }); };
|
|
23
|
+
exports.dependencyInstallCommandName = dependencyInstallCommandName;
|
|
24
|
+
/** `setup` is dropped for an API that declares no `setupCommand`, so nothing lists a command it cannot run. */
|
|
25
|
+
const apiCommandNames = (api) => {
|
|
26
|
+
var _a;
|
|
27
|
+
return [
|
|
28
|
+
...exports.BUILT_IN_API_COMMANDS.filter((command) => command !== 'setup' || api.setupCommand),
|
|
29
|
+
...Object.keys((_a = api.exec) !== null && _a !== void 0 ? _a : {}),
|
|
30
|
+
];
|
|
31
|
+
};
|
|
6
32
|
exports.apiCommandNames = apiCommandNames;
|
|
7
33
|
//# sourceMappingURL=definition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/api/definition.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/api/definition.ts"],"names":[],"mappings":";;;AA8Ba,QAAA,qBAAqB,GAAG;IACnC,IAAI;IACJ,MAAM;IACN,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,UAAU;IACV,MAAM;IACN,OAAO;CACC,CAAC;AAEX,wGAAwG;AAC3F,QAAA,gBAAgB,GAAa,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;AAExE,MAAM,qBAAqB,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAElG,oHAAoH;AAC7G,MAAM,oBAAoB,GAAG,CAAC,WAA8B,EAAE,EAAE,WACrE,OAAA,qBAAqB,CAAC,QAAQ,CAAC,MAAA,WAAW,CAAC,CAAC,CAAC,mCAAI,EAAE,CAAC,CAAA,EAAA,CAAC;AAD1C,QAAA,oBAAoB,wBACsB;AAEvD,gGAAgG;AACzF,MAAM,4BAA4B,GAAG,CAAC,GAAkB,EAAE,EAAE,WACjE,OAAA,MAAM,CAAC,IAAI,CAAC,MAAA,GAAG,CAAC,IAAI,mCAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,eAAC,OAAA,IAAA,4BAAoB,EAAC,MAAA,MAAA,GAAG,CAAC,IAAI,0CAAG,IAAI,CAAC,mCAAI,EAAE,CAAC,CAAA,EAAA,CAAC,CAAA,EAAA,CAAC;AAD9E,QAAA,4BAA4B,gCACkD;AAE3F,+GAA+G;AACxG,MAAM,eAAe,GAAG,CAAC,GAAkB,EAAE,EAAE;;IAAC,OAAA;QACrD,GAAG,6BAAqB,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,OAAO,IAAI,GAAG,CAAC,YAAY,CAAC;QACrF,GAAG,MAAM,CAAC,IAAI,CAAC,MAAA,GAAG,CAAC,IAAI,mCAAI,EAAE,CAAC;KAC/B,CAAA;CAAA,CAAC;AAHW,QAAA,eAAe,mBAG1B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type GitResult = {
|
|
2
|
+
status: number;
|
|
3
|
+
stdout: string;
|
|
4
|
+
stderr: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const currentBranch: (cwd: string) => string | undefined;
|
|
7
|
+
/** Modified tracked files and untracked files, as git's own porcelain lines. */
|
|
8
|
+
export declare const uncommittedChanges: (cwd: string) => string[];
|
|
9
|
+
export declare const hasUncommittedChanges: (cwd: string) => boolean;
|
|
10
|
+
/** Commits on any local branch that no remote holds, so work is never removed with a checkout. */
|
|
11
|
+
export declare const unpushedCommits: (cwd: string) => string[];
|
|
12
|
+
/** Switches the API checkout to the branch configured for it. Git's own refusal is passed through. */
|
|
13
|
+
export declare const checkoutApiBranch: (options: {
|
|
14
|
+
repoPath: string;
|
|
15
|
+
branch: string;
|
|
16
|
+
}) => number;
|
|
17
|
+
/**
|
|
18
|
+
* Fast-forwards the checked-out branch. `force` throws away local commits and uncommitted tracked
|
|
19
|
+
* changes on it; untracked files such as `vendor/` and `.env` are never touched.
|
|
20
|
+
*/
|
|
21
|
+
export declare const pullApiBranch: (options: {
|
|
22
|
+
repoPath: string;
|
|
23
|
+
expectedBranch?: string;
|
|
24
|
+
force: boolean;
|
|
25
|
+
}) => number;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pullApiBranch = exports.checkoutApiBranch = exports.unpushedCommits = exports.hasUncommittedChanges = exports.uncommittedChanges = exports.currentBranch = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
const git = (cwd, args) => {
|
|
6
|
+
var _a, _b, _c;
|
|
7
|
+
const result = (0, child_process_1.spawnSync)('git', args, { cwd, encoding: 'utf8' });
|
|
8
|
+
return {
|
|
9
|
+
status: (_a = result.status) !== null && _a !== void 0 ? _a : 1,
|
|
10
|
+
stdout: ((_b = result.stdout) !== null && _b !== void 0 ? _b : '').trim(),
|
|
11
|
+
stderr: ((_c = result.stderr) !== null && _c !== void 0 ? _c : '').trim(),
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
const gitInherit = (cwd, args) => { var _a; return (_a = (0, child_process_1.spawnSync)('git', args, { cwd, stdio: 'inherit' }).status) !== null && _a !== void 0 ? _a : 1; };
|
|
15
|
+
const currentBranch = (cwd) => {
|
|
16
|
+
const result = git(cwd, ['rev-parse', '--abbrev-ref', 'HEAD']);
|
|
17
|
+
return result.status === 0 ? result.stdout : undefined;
|
|
18
|
+
};
|
|
19
|
+
exports.currentBranch = currentBranch;
|
|
20
|
+
/** Modified tracked files and untracked files, as git's own porcelain lines. */
|
|
21
|
+
const uncommittedChanges = (cwd) => {
|
|
22
|
+
const { stdout } = git(cwd, ['status', '--porcelain']);
|
|
23
|
+
return stdout.length > 0 ? stdout.split('\n') : [];
|
|
24
|
+
};
|
|
25
|
+
exports.uncommittedChanges = uncommittedChanges;
|
|
26
|
+
const hasUncommittedChanges = (cwd) => (0, exports.uncommittedChanges)(cwd).length > 0;
|
|
27
|
+
exports.hasUncommittedChanges = hasUncommittedChanges;
|
|
28
|
+
/** Commits on any local branch that no remote holds, so work is never removed with a checkout. */
|
|
29
|
+
const unpushedCommits = (cwd) => {
|
|
30
|
+
const { status, stdout } = git(cwd, ['log', '--branches', '--not', '--remotes', '--oneline']);
|
|
31
|
+
return status === 0 && stdout.length > 0 ? stdout.split('\n') : [];
|
|
32
|
+
};
|
|
33
|
+
exports.unpushedCommits = unpushedCommits;
|
|
34
|
+
/** Switches the API checkout to the branch configured for it. Git's own refusal is passed through. */
|
|
35
|
+
const checkoutApiBranch = (options) => {
|
|
36
|
+
const { repoPath, branch } = options;
|
|
37
|
+
if ((0, exports.currentBranch)(repoPath) === branch) {
|
|
38
|
+
console.log(`Already on ${branch}.`);
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
return gitInherit(repoPath, ['checkout', branch]);
|
|
42
|
+
};
|
|
43
|
+
exports.checkoutApiBranch = checkoutApiBranch;
|
|
44
|
+
/**
|
|
45
|
+
* Fast-forwards the checked-out branch. `force` throws away local commits and uncommitted tracked
|
|
46
|
+
* changes on it; untracked files such as `vendor/` and `.env` are never touched.
|
|
47
|
+
*/
|
|
48
|
+
const pullApiBranch = (options) => {
|
|
49
|
+
const { repoPath, expectedBranch, force } = options;
|
|
50
|
+
const branch = (0, exports.currentBranch)(repoPath);
|
|
51
|
+
if (!branch) {
|
|
52
|
+
console.error(`${repoPath} is not a git checkout.`);
|
|
53
|
+
return 1;
|
|
54
|
+
}
|
|
55
|
+
if (expectedBranch && branch !== expectedBranch) {
|
|
56
|
+
console.warn(`On ${branch}, but apiRepoBranches expects ${expectedBranch}. Pulling ${branch}.\n`);
|
|
57
|
+
}
|
|
58
|
+
if (!force && (0, exports.hasUncommittedChanges)(repoPath)) {
|
|
59
|
+
console.error(`${repoPath} has uncommitted changes. Commit or stash them, or pass --force to discard them.`);
|
|
60
|
+
return 1;
|
|
61
|
+
}
|
|
62
|
+
const fetched = gitInherit(repoPath, ['fetch', 'origin', branch]);
|
|
63
|
+
if (fetched !== 0)
|
|
64
|
+
return fetched;
|
|
65
|
+
if (!force)
|
|
66
|
+
return gitInherit(repoPath, ['merge', '--ff-only', `origin/${branch}`]);
|
|
67
|
+
console.log(`Discarding local commits and tracked changes on ${branch}.`);
|
|
68
|
+
return gitInherit(repoPath, ['reset', '--hard', `origin/${branch}`]);
|
|
69
|
+
};
|
|
70
|
+
exports.pullApiBranch = pullApiBranch;
|
|
71
|
+
//# sourceMappingURL=git.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/api/git.ts"],"names":[],"mappings":";;;AAAA,iDAA0C;AAI1C,MAAM,GAAG,GAAG,CAAC,GAAW,EAAE,IAAc,EAAa,EAAE;;IACrD,MAAM,MAAM,GAAG,IAAA,yBAAS,EAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IAEjE,OAAO;QACL,MAAM,EAAE,MAAA,MAAM,CAAC,MAAM,mCAAI,CAAC;QAC1B,MAAM,EAAE,CAAC,MAAA,MAAM,CAAC,MAAM,mCAAI,EAAE,CAAC,CAAC,IAAI,EAAE;QACpC,MAAM,EAAE,CAAC,MAAA,MAAM,CAAC,MAAM,mCAAI,EAAE,CAAC,CAAC,IAAI,EAAE;KACrC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,IAAc,EAAE,EAAE,WAAC,OAAA,MAAA,IAAA,yBAAS,EAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,mCAAI,CAAC,CAAA,EAAA,CAAC;AAE3G,MAAM,aAAa,GAAG,CAAC,GAAW,EAAE,EAAE;IAC3C,MAAM,MAAM,GAAG,GAAG,CAAC,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M,EAAE,CAAC,CAAC,CAAC;IAEpF,OAAO,CAAC,GAAG,CAAC,mDAAmD,MAAM,GAAG,CAAC,CAAC;IAE1E,OAAO,UAAU,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,MAAM,EAAE,CAAC,CAAC,CAAC;AACvE,CAAC,CAAC;AA7BW,QAAA,aAAa,iBA6BxB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ApiDefinition, ApiDefinitions } from './definition';
|
|
2
|
+
/** The help text for `et api`, listing the built-in commands and what each API adds to them. */
|
|
3
|
+
export declare const apiHelp: (apis: ApiDefinitions, invocation: string) => string;
|
|
4
|
+
/** The help text for one API: every command it accepts, what each one runs, and where its files are. */
|
|
5
|
+
export declare const singleApiHelp: (options: {
|
|
6
|
+
name: string;
|
|
7
|
+
api: ApiDefinition;
|
|
8
|
+
invocation: string;
|
|
9
|
+
/** Where the checkout is, or what is wrong with it. */
|
|
10
|
+
checkout?: string;
|
|
11
|
+
}) => string;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.singleApiHelp = exports.apiHelp = void 0;
|
|
4
|
+
const definition_1 = require("./definition");
|
|
5
|
+
const BUILT_IN_DESCRIPTIONS = {
|
|
6
|
+
up: 'Start the containers of the API',
|
|
7
|
+
down: 'Stop them',
|
|
8
|
+
logs: 'Follow the log of the API container, or of a service you name',
|
|
9
|
+
shell: 'Open a shell in the API container, or in a service you name',
|
|
10
|
+
clone: 'Clone the API into .ethlete/<name> from its repoUrl',
|
|
11
|
+
clear: 'Remove the managed checkout in .ethlete/<name>',
|
|
12
|
+
checkout: 'Switch the checkout to the branch apiRepoBranches names',
|
|
13
|
+
pull: 'Fetch and fast-forward the checked-out branch',
|
|
14
|
+
setup: "Run the API's own setupCommand in its compose directory",
|
|
15
|
+
};
|
|
16
|
+
const pad = (text, width) => text.padEnd(width);
|
|
17
|
+
/** The help text for `et api`, listing the built-in commands and what each API adds to them. */
|
|
18
|
+
const apiHelp = (apis, invocation) => {
|
|
19
|
+
const entries = Object.entries(apis);
|
|
20
|
+
const width = Math.max(8, ...entries.map(([name]) => name.length));
|
|
21
|
+
const commandWidth = Math.max(8, ...definition_1.BUILT_IN_API_COMMANDS.map((command) => command.length), ...entries.flatMap(([, api]) => { var _a; return Object.keys((_a = api.exec) !== null && _a !== void 0 ? _a : {}).map((command) => command.length); }));
|
|
22
|
+
const apiLines = entries.map(([name, api]) => ` ${pad(name, width)} ${(0, definition_1.apiCommandNames)(api).join(', ')}`);
|
|
23
|
+
const execNames = [...new Set(entries.flatMap(([, api]) => { var _a; return Object.keys((_a = api.exec) !== null && _a !== void 0 ? _a : {}); }))];
|
|
24
|
+
return [
|
|
25
|
+
`Usage: ${invocation} <command> <api>[,<api>] [--host]`,
|
|
26
|
+
'',
|
|
27
|
+
'Commands',
|
|
28
|
+
...definition_1.BUILT_IN_API_COMMANDS.map((command) => ` ${pad(command, commandWidth)} ${BUILT_IN_DESCRIPTIONS[command]}`),
|
|
29
|
+
...execNames.map((command) => ` ${pad(command, commandWidth)} Declared by the API itself`),
|
|
30
|
+
` ${pad('help', commandWidth)} What one API accepts, and where its checkout is`,
|
|
31
|
+
'',
|
|
32
|
+
'APIs',
|
|
33
|
+
...(apiLines.length > 0 ? apiLines : [' none — declare them in ethlete.apis.js']),
|
|
34
|
+
'',
|
|
35
|
+
'Options',
|
|
36
|
+
` ${pad('--host', commandWidth)} Also print the address another device on this network can use`,
|
|
37
|
+
` ${pad('--force', commandWidth)} With up: start even when a port is taken. With pull or clear: lose local work`,
|
|
38
|
+
` ${pad('--all', commandWidth)} With clear: every API at once`,
|
|
39
|
+
` ${pad('--clone', commandWidth)} Clone a missing checkout without asking first`,
|
|
40
|
+
` ${pad('--setup', commandWidth)} Run the setup command for a missing env file without asking first`,
|
|
41
|
+
` ${pad('--help', commandWidth)} Show this text`,
|
|
42
|
+
].join('\n');
|
|
43
|
+
};
|
|
44
|
+
exports.apiHelp = apiHelp;
|
|
45
|
+
const commandDescription = (api, command) => {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
if (command === 'setup' && api.setupCommand)
|
|
48
|
+
return `Run "${api.setupCommand}" in ${api.composeDir}`;
|
|
49
|
+
const builtIn = definition_1.BUILT_IN_API_COMMANDS.find((candidate) => candidate === command);
|
|
50
|
+
return builtIn ? BUILT_IN_DESCRIPTIONS[builtIn] : ((_b = (_a = api.exec) === null || _a === void 0 ? void 0 : _a[command]) !== null && _b !== void 0 ? _b : []).join(' ');
|
|
51
|
+
};
|
|
52
|
+
/** The help text for one API: every command it accepts, what each one runs, and where its files are. */
|
|
53
|
+
const singleApiHelp = (options) => {
|
|
54
|
+
const { name, api, invocation, checkout } = options;
|
|
55
|
+
const commands = (0, definition_1.apiCommandNames)(api);
|
|
56
|
+
const width = Math.max(8, ...commands.map((command) => command.length));
|
|
57
|
+
return [
|
|
58
|
+
`Usage: ${invocation} <command> ${name} [--host]`,
|
|
59
|
+
'',
|
|
60
|
+
'Commands',
|
|
61
|
+
...commands.map((command) => ` ${pad(command, width)} ${commandDescription(api, command)}`),
|
|
62
|
+
'',
|
|
63
|
+
'This API',
|
|
64
|
+
` ${pad('url', width)} http://localhost:${api.port}`,
|
|
65
|
+
` ${pad('services', width)} ${api.services.join(', ')}`,
|
|
66
|
+
...(api.envFile ? [` ${pad('env file', width)} ${api.composeDir}/${api.envFile}`] : []),
|
|
67
|
+
...(api.envKey ? [` ${pad('envKey', width)} ${api.envKey}`] : []),
|
|
68
|
+
...(checkout ? ['', 'Checkout', ...checkout.split('\n').map((line) => ` ${line}`)] : []),
|
|
69
|
+
].join('\n');
|
|
70
|
+
};
|
|
71
|
+
exports.singleApiHelp = singleApiHelp;
|
|
72
|
+
//# sourceMappingURL=help.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib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,OAAO,CAAC,EAAE,CAAC;QAC7F,EAAE;QACF,UAAU;QACV,KAAK,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,sBAAsB,GAAG,CAAC,IAAI,EAAE;QACtD,KAAK,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,KAAK,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACzD,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,KAAK,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACzF,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACnE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1F,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC,CAAC;AAxBW,QAAA,aAAa,iBAwBxB"}
|
package/src/lib/api/index.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
export * from './api-command';
|
|
2
2
|
export * from './compose';
|
|
3
|
+
export * from './auth-hint';
|
|
4
|
+
export * from './clear';
|
|
5
|
+
export * from './clone';
|
|
3
6
|
export * from './definition';
|
|
7
|
+
export * from './git';
|
|
8
|
+
export * from './help';
|
|
4
9
|
export * from './load-definitions';
|
|
10
|
+
export * from './ports';
|
|
11
|
+
export * from './resolve-checkout';
|
|
5
12
|
export * from './run';
|
|
13
|
+
export * from './setup';
|
|
14
|
+
export * from './state';
|
|
15
|
+
export * from './suggest';
|
package/src/lib/api/index.js
CHANGED
|
@@ -3,7 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./api-command"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./compose"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./auth-hint"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./clear"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./clone"), exports);
|
|
6
9
|
tslib_1.__exportStar(require("./definition"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./git"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./help"), exports);
|
|
7
12
|
tslib_1.__exportStar(require("./load-definitions"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./ports"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./resolve-checkout"), exports);
|
|
8
15
|
tslib_1.__exportStar(require("./run"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./setup"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./state"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./suggest"), exports);
|
|
9
19
|
//# sourceMappingURL=index.js.map
|
package/src/lib/api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/api/index.ts"],"names":[],"mappings":";;;AAAA,wDAA8B;AAC9B,oDAA0B;AAC1B,uDAA6B;AAC7B,6DAAmC;AACnC,gDAAsB"}
|
|
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,kDAAwB;AACxB,uDAA6B;AAC7B,gDAAsB;AACtB,iDAAuB;AACvB,6DAAmC;AACnC,kDAAwB;AACxB,6DAAmC;AACnC,gDAAsB;AACtB,kDAAwB;AACxB,kDAAwB;AACxB,oDAA0B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host ports the named services publish, read from the resolved output of `compose config`. It
|
|
3
|
+
* accepts the short form podman-compose prints and the long form docker compose prints.
|
|
4
|
+
*
|
|
5
|
+
* Only the named services are read. A compose file usually declares more than an app needs, and a
|
|
6
|
+
* service that never starts must not make a port look taken.
|
|
7
|
+
*/
|
|
8
|
+
export declare const publishedPorts: (options: {
|
|
9
|
+
config: string;
|
|
10
|
+
services: readonly string[];
|
|
11
|
+
}) => number[];
|
|
12
|
+
/** The ports nothing else may bind right now, so `up` cannot publish them. */
|
|
13
|
+
export declare const portsInUse: (ports: readonly number[]) => Promise<number[]>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.portsInUse = exports.publishedPorts = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const net_1 = require("net");
|
|
6
|
+
const indentOf = (line) => line.length - line.trimStart().length;
|
|
7
|
+
const PUBLISHED_KEY = /^published:\s*['"]?(\d+)/;
|
|
8
|
+
/**
|
|
9
|
+
* Host port of a short-form entry such as `8040:80`, `127.0.0.1:8040:80` or `[::1]:8040:80/udp`.
|
|
10
|
+
* It is the second-to-last segment, so a bind address of any shape stays out of the way. An entry
|
|
11
|
+
* that names only a container port, or a port range, has no single host port to check.
|
|
12
|
+
*/
|
|
13
|
+
const shortFormHostPort = (entry) => {
|
|
14
|
+
var _a, _b, _c;
|
|
15
|
+
const parts = (_b = (_a = entry.replace(/['"]/g, '').split('/')[0]) === null || _a === void 0 ? void 0 : _a.split(':')) !== null && _b !== void 0 ? _b : [];
|
|
16
|
+
if (parts.length < 2)
|
|
17
|
+
return undefined;
|
|
18
|
+
const host = (_c = parts[parts.length - 2]) !== null && _c !== void 0 ? _c : '';
|
|
19
|
+
return /^\d+$/.test(host) ? Number(host) : undefined;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Host ports the named services publish, read from the resolved output of `compose config`. It
|
|
23
|
+
* accepts the short form podman-compose prints and the long form docker compose prints.
|
|
24
|
+
*
|
|
25
|
+
* Only the named services are read. A compose file usually declares more than an app needs, and a
|
|
26
|
+
* service that never starts must not make a port look taken.
|
|
27
|
+
*/
|
|
28
|
+
const publishedPorts = (options) => {
|
|
29
|
+
var _a;
|
|
30
|
+
const { config, services } = options;
|
|
31
|
+
const wanted = new Set(services);
|
|
32
|
+
const ports = new Set();
|
|
33
|
+
let servicesIndent;
|
|
34
|
+
let serviceIndent;
|
|
35
|
+
let portsIndent;
|
|
36
|
+
let inWantedService = false;
|
|
37
|
+
for (const line of config.split('\n')) {
|
|
38
|
+
const text = line.trim();
|
|
39
|
+
if (text === '' || text.startsWith('#'))
|
|
40
|
+
continue;
|
|
41
|
+
const indent = indentOf(line);
|
|
42
|
+
if (servicesIndent === undefined) {
|
|
43
|
+
if (text === 'services:')
|
|
44
|
+
servicesIndent = indent;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (indent <= servicesIndent && !text.startsWith('-')) {
|
|
48
|
+
servicesIndent = text === 'services:' ? indent : undefined;
|
|
49
|
+
serviceIndent = undefined;
|
|
50
|
+
portsIndent = undefined;
|
|
51
|
+
inWantedService = false;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
serviceIndent !== null && serviceIndent !== void 0 ? serviceIndent : (serviceIndent = indent);
|
|
55
|
+
if (indent === serviceIndent) {
|
|
56
|
+
inWantedService = wanted.has(text.replace(/:$/, ''));
|
|
57
|
+
portsIndent = undefined;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (!inWantedService)
|
|
61
|
+
continue;
|
|
62
|
+
if (text === 'ports:') {
|
|
63
|
+
portsIndent = indent;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (portsIndent === undefined)
|
|
67
|
+
continue;
|
|
68
|
+
if (indent < portsIndent || (indent === portsIndent && !text.startsWith('-'))) {
|
|
69
|
+
portsIndent = undefined;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const published = (_a = PUBLISHED_KEY.exec(text)) === null || _a === void 0 ? void 0 : _a[1];
|
|
73
|
+
if (published !== undefined) {
|
|
74
|
+
ports.add(Number(published));
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (!text.startsWith('-'))
|
|
78
|
+
continue;
|
|
79
|
+
const short = shortFormHostPort(text.slice(1).trim());
|
|
80
|
+
if (short !== undefined)
|
|
81
|
+
ports.add(short);
|
|
82
|
+
}
|
|
83
|
+
return [...ports].sort((a, b) => a - b);
|
|
84
|
+
};
|
|
85
|
+
exports.publishedPorts = publishedPorts;
|
|
86
|
+
const isPortFree = (port) => new Promise((resolve) => {
|
|
87
|
+
const server = (0, net_1.createServer)();
|
|
88
|
+
server.once('error', () => resolve(false));
|
|
89
|
+
server.once('listening', () => server.close(() => resolve(true)));
|
|
90
|
+
server.listen(port, '0.0.0.0');
|
|
91
|
+
});
|
|
92
|
+
/** The ports nothing else may bind right now, so `up` cannot publish them. */
|
|
93
|
+
const portsInUse = (ports) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
94
|
+
const checked = yield Promise.all(ports.map((port) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return ({ port, free: yield isPortFree(port) }); })));
|
|
95
|
+
return checked.filter(({ free }) => !free).map(({ port }) => port);
|
|
96
|
+
});
|
|
97
|
+
exports.portsInUse = portsInUse;
|
|
98
|
+
//# sourceMappingURL=ports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ports.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/api/ports.ts"],"names":[],"mappings":";;;;AAAA,6BAAmC;AAEnC,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AAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA,GAAA,CAAC,CAAC,CAAC;IAEvG,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;AACrE,CAAC,CAAA,CAAC;AAJW,QAAA,UAAU,cAIrB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { CloneRequest } from './clone';
|
|
2
|
+
import { ApiDefinition } from './definition';
|
|
3
|
+
import { SetupRequest } from './setup';
|
|
4
|
+
export type ApiCheckout = {
|
|
5
|
+
repoPath: string;
|
|
6
|
+
/** The directory the compose commands run in. */
|
|
7
|
+
composePath: string;
|
|
8
|
+
};
|
|
9
|
+
export type ApiCheckoutFailure = {
|
|
10
|
+
ok: false;
|
|
11
|
+
problem: string;
|
|
12
|
+
/** Set when the managed directory is empty and the API declares where to clone from. */
|
|
13
|
+
clonable?: CloneRequest;
|
|
14
|
+
/** Set when the env file is missing and the API declares a `setupCommand` that creates it. */
|
|
15
|
+
setupable?: SetupRequest;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* `legacyConfigWarning` is set on failure too. A wrong path is exactly when the developer needs to
|
|
19
|
+
* know which file the value actually came from.
|
|
20
|
+
*/
|
|
21
|
+
export type ApiCheckoutResult = {
|
|
22
|
+
legacyConfigWarning?: string;
|
|
23
|
+
} & ({
|
|
24
|
+
ok: true;
|
|
25
|
+
checkout: ApiCheckout;
|
|
26
|
+
} | ApiCheckoutFailure);
|
|
27
|
+
/** The problem, plus the `et api` command that fixes it, so no message sends the reader to a Makefile. */
|
|
28
|
+
export declare const checkoutProblem: (options: {
|
|
29
|
+
failure: ApiCheckoutFailure;
|
|
30
|
+
name: string;
|
|
31
|
+
invocation: string;
|
|
32
|
+
}) => string;
|
|
33
|
+
/** Where an API's managed checkout goes when the developer configured no path of their own. */
|
|
34
|
+
export declare const managedCheckoutPath: (root: string, name: string) => string;
|
|
35
|
+
/** Resolves where an API's containers live, with the one message that explains each way it can fail. */
|
|
36
|
+
export declare const resolveApiCheckout: (options: {
|
|
37
|
+
root: string;
|
|
38
|
+
name: string;
|
|
39
|
+
api: ApiDefinition;
|
|
40
|
+
/**
|
|
41
|
+
* How much of the checkout the command needs. The git commands act on the checkout itself, and
|
|
42
|
+
* `setup` writes the env file, so neither can demand what it is there to produce.
|
|
43
|
+
*/
|
|
44
|
+
needs?: "repo" | "compose" | "env";
|
|
45
|
+
}) => ApiCheckoutResult;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveApiCheckout = exports.managedCheckoutPath = exports.checkoutProblem = 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
|
+
/** The problem, plus the `et api` command that fixes it, so no message sends the reader to a Makefile. */
|
|
9
|
+
const checkoutProblem = (options) => {
|
|
10
|
+
const { failure, name, invocation } = options;
|
|
11
|
+
if (failure.clonable)
|
|
12
|
+
return `${failure.problem} Run "${invocation} clone ${name}".`;
|
|
13
|
+
if (failure.setupable)
|
|
14
|
+
return `${failure.problem} Run "${invocation} setup ${name}".`;
|
|
15
|
+
return failure.problem;
|
|
16
|
+
};
|
|
17
|
+
exports.checkoutProblem = checkoutProblem;
|
|
18
|
+
const isDirectory = (path) => (0, fs_1.existsSync)(path) && (0, fs_1.statSync)(path).isDirectory();
|
|
19
|
+
const missingPathProblem = (options) => {
|
|
20
|
+
var _a;
|
|
21
|
+
const { name, api, reason } = options;
|
|
22
|
+
return (`${reason}\n\nAdd the path of your ${name} API checkout to ${local_config_1.LOCAL_CONFIG_FILE_NAME} in the repo ` +
|
|
23
|
+
`root. The file is gitignored, so it changes nothing for anyone else:\n\n` +
|
|
24
|
+
` {\n "apiRepoPaths": {\n "${name}": "${(_a = api.examplePath) !== null && _a !== void 0 ? _a : `../${name}-api`}"\n }\n }`);
|
|
25
|
+
};
|
|
26
|
+
/** Where an API's managed checkout goes when the developer configured no path of their own. */
|
|
27
|
+
const managedCheckoutPath = (root, name) => (0, path_1.join)(root, clone_1.DEFAULT_CHECKOUT_DIR, name);
|
|
28
|
+
exports.managedCheckoutPath = managedCheckoutPath;
|
|
29
|
+
/** Resolves where an API's containers live, with the one message that explains each way it can fail. */
|
|
30
|
+
const resolveApiCheckout = (options) => {
|
|
31
|
+
const { root, name, api, needs = 'env' } = options;
|
|
32
|
+
const { config, fileName, isLegacy } = (0, local_config_1.readLocalConfig)(root);
|
|
33
|
+
const configured = (0, local_config_1.configuredApiRepoPath)(config, name);
|
|
34
|
+
const legacyConfigWarning = isLegacy
|
|
35
|
+
? `${local_config_1.LEGACY_LOCAL_CONFIG_FILE_NAME} still holds "apiRepoPaths". Move it to ${local_config_1.LOCAL_CONFIG_FILE_NAME}.`
|
|
36
|
+
: undefined;
|
|
37
|
+
const repoPath = configured ? (0, local_config_1.resolveConfiguredPath)(root, configured) : (0, exports.managedCheckoutPath)(root, name);
|
|
38
|
+
if (!isDirectory(repoPath)) {
|
|
39
|
+
if (configured) {
|
|
40
|
+
return {
|
|
41
|
+
ok: false,
|
|
42
|
+
legacyConfigWarning,
|
|
43
|
+
problem: `apiRepoPaths.${name} points at ${repoPath}, which is not a directory that exists.`,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (!api.repoUrl) {
|
|
47
|
+
return {
|
|
48
|
+
ok: false,
|
|
49
|
+
legacyConfigWarning,
|
|
50
|
+
problem: missingPathProblem({
|
|
51
|
+
name,
|
|
52
|
+
api,
|
|
53
|
+
reason: fileName
|
|
54
|
+
? `${fileName} has no apiRepoPaths entry for "${name}", and the API declares no repoUrl.`
|
|
55
|
+
: `${name} has no checkout, and the API declares no repoUrl.`,
|
|
56
|
+
}),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
ok: false,
|
|
61
|
+
legacyConfigWarning,
|
|
62
|
+
problem: `${name} has no checkout at ${repoPath}.`,
|
|
63
|
+
clonable: {
|
|
64
|
+
repoUrl: api.repoUrl,
|
|
65
|
+
into: repoPath,
|
|
66
|
+
branch: (0, local_config_1.configuredApiRepoBranch)(config, name),
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const composePath = (0, path_1.join)(repoPath, api.composeDir);
|
|
71
|
+
if (needs === 'repo')
|
|
72
|
+
return { ok: true, legacyConfigWarning, checkout: { repoPath, composePath } };
|
|
73
|
+
if (!isDirectory(composePath)) {
|
|
74
|
+
return {
|
|
75
|
+
ok: false,
|
|
76
|
+
legacyConfigWarning,
|
|
77
|
+
problem: `${repoPath} has no ${api.composeDir} directory. Is apiRepoPaths.${name} the right checkout?`,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
if (needs === 'env' && api.envFile && !(0, fs_1.existsSync)((0, path_1.join)(composePath, api.envFile))) {
|
|
81
|
+
return {
|
|
82
|
+
ok: false,
|
|
83
|
+
legacyConfigWarning,
|
|
84
|
+
problem: `Missing ${api.envFile} in ${composePath}.`,
|
|
85
|
+
setupable: api.setupCommand ? { setupCommand: api.setupCommand, composePath, envFile: api.envFile } : undefined,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return { ok: true, legacyConfigWarning, checkout: { repoPath, composePath } };
|
|
89
|
+
};
|
|
90
|
+
exports.resolveApiCheckout = resolveApiCheckout;
|
|
91
|
+
//# sourceMappingURL=resolve-checkout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-checkout.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/api/resolve-checkout.ts"],"names":[],"mappings":";;;AAA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caller is invoked, used in the usage line. */
|
|
8
8
|
invocation?: string;
|
|
9
9
|
};
|
|
10
|
-
export declare const runApiCommand: ({ apis, argv, root, invocation }: RunApiCommandOptions) => number
|
|
10
|
+
export declare const runApiCommand: ({ apis, argv, root, invocation, }: RunApiCommandOptions) => Promise<number>;
|