@ethlete/cli 2.1.0-next.5 → 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 +30 -0
- package/README.md +22 -2
- package/package.json +1 -1
- package/src/index.js +51 -11
- package/src/index.js.map +1 -1
- package/src/lib/api/api-command.d.ts +2 -1
- 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 +2 -0
- package/src/lib/api/auth-hint.js +15 -1
- package/src/lib/api/auth-hint.js.map +1 -1
- 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/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 +8 -3
- package/src/lib/api/definition.js +28 -4
- package/src/lib/api/definition.js.map +1 -1
- package/src/lib/api/git.d.ts +4 -0
- package/src/lib/api/git.js +14 -2
- package/src/lib/api/git.js.map +1 -1
- package/src/lib/api/help.d.ts +9 -1
- package/src/lib/api/help.js +43 -10
- package/src/lib/api/help.js.map +1 -1
- package/src/lib/api/index.d.ts +5 -0
- package/src/lib/api/index.js +5 -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 +19 -9
- package/src/lib/api/resolve-checkout.js +18 -5
- package/src/lib/api/resolve-checkout.js.map +1 -1
- package/src/lib/api/run.js +240 -57
- 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/doctor/doctor-command.d.ts +2 -1
- package/src/lib/doctor/doctor-command.js +4 -7
- package/src/lib/doctor/doctor-command.js.map +1 -1
- package/src/lib/index.d.ts +2 -0
- package/src/lib/index.js +2 -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/lib/utils.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @ethlete/cli
|
|
2
2
|
|
|
3
|
+
## 2.1.0-next.6
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`a1c489e`](https://github.com/ethlete-io/ethdk/commit/a1c489e0a1da4b479fd6e47743dec4c1bad0152f) Thanks [@TomTomB](https://github.com/TomTomB)! - `et api up` now refuses a port another program holds and prints a per-service state table instead of
|
|
8
|
+
the engine's output. New `et api clear` removes a managed checkout, and offers to take its containers down first.
|
|
9
|
+
|
|
10
|
+
- [`12dcd51`](https://github.com/ethlete-io/ethdk/commit/12dcd5118ca8d2089cc3e9379efe4e9d0502a0f6) Thanks [@TomTomB](https://github.com/TomTomB)! - Every `et api` command now takes a comma-separated list of names, so `et api up hub,platform` starts
|
|
11
|
+
both APIs.
|
|
12
|
+
|
|
13
|
+
- [`0e060b2`](https://github.com/ethlete-io/ethdk/commit/0e060b28436e9444726a35a93264a046242e348e) Thanks [@TomTomB](https://github.com/TomTomB)! - `et api help <name>` now answers for one API: the commands it accepts, what each one runs, its url
|
|
14
|
+
and services, and the state of its checkout. `--help` after a known API name prints the same text.
|
|
15
|
+
|
|
16
|
+
- [`0e060b2`](https://github.com/ethlete-io/ethdk/commit/0e060b28436e9444726a35a93264a046242e348e) Thanks [@TomTomB](https://github.com/TomTomB)! - `et api` now runs an API's `setupCommand` itself: `et api setup <name>` on its own, or as an offer
|
|
17
|
+
when a command finds the `envFile` missing. `--setup` accepts that offer without the question.
|
|
18
|
+
|
|
19
|
+
- [`c3dd7c3`](https://github.com/ethlete-io/ethdk/commit/c3dd7c3d7e0e2a060e081c7fe820f9774537418b) Thanks [@TomTomB](https://github.com/TomTomB)! - `et auth <token>` writes a GitLab token into composer's `auth.json`, which the API containers mount. It asks the host whether the token can download code before it writes anything.
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [`0e060b2`](https://github.com/ethlete-io/ethdk/commit/0e060b28436e9444726a35a93264a046242e348e) Thanks [@TomTomB](https://github.com/TomTomB)! - An unknown API name in `et api` now names the closest match and the APIs there are, in place of the
|
|
24
|
+
whole help text. An unknown command suggests the closest command the same way.
|
|
25
|
+
|
|
26
|
+
- [`c3dd7c3`](https://github.com/ethlete-io/ethdk/commit/c3dd7c3d7e0e2a060e081c7fe820f9774537418b) Thanks [@TomTomB](https://github.com/TomTomB)! - A failing `et api` exec command no longer always blames a private dependency. That hint is kept for a command that installs dependencies; any other one suggests running the install command first.
|
|
27
|
+
|
|
28
|
+
- [`0e060b2`](https://github.com/ethlete-io/ethdk/commit/0e060b28436e9444726a35a93264a046242e348e) Thanks [@TomTomB](https://github.com/TomTomB)! - `et api setup` keeps the setup command's own output back and prints one line for the result. The output is only shown when the command fails, so a checkout's advice about its Makefile no longer competes with the CLI.
|
|
29
|
+
|
|
30
|
+
- [`0e060b2`](https://github.com/ethlete-io/ethdk/commit/0e060b28436e9444726a35a93264a046242e348e) Thanks [@TomTomB](https://github.com/TomTomB)! - Every `et` message now names a command the reader can type, for example `yarn api` or `npx et api`,
|
|
31
|
+
in place of a bare `et`. `et doctor` names the `et api` command that fixes each problem.
|
|
32
|
+
|
|
3
33
|
## 2.1.0-next.5
|
|
4
34
|
|
|
5
35
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -16,13 +16,30 @@ yarn et release
|
|
|
16
16
|
|
|
17
17
|
Turns pending changesets into a tagged, pushed release commit (version → tag → commit → push).
|
|
18
18
|
|
|
19
|
+
## `et auth`
|
|
20
|
+
|
|
21
|
+
Writes a GitLab token into composer's `auth.json`, so a private PHP dependency can be downloaded.
|
|
22
|
+
The compose file of each API mounts `$HOME/.composer` into its container, so this is the token the
|
|
23
|
+
composer inside the container reads.
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
yarn et auth glpat-xxxxxxxxxxxxxxxxxxxx # the host comes from ethlete.apis.js
|
|
27
|
+
yarn et auth gitlab.example.com glpat-xxxxxxxxxxxxxxxxxxxx # name it when more than one is in use
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The token is checked against the host first: once for the token itself, and once by downloading one
|
|
31
|
+
byte of a project archive. A token that can read the API but not fetch code answers `403` there, and
|
|
32
|
+
nothing is written. `--force` writes it anyway.
|
|
33
|
+
|
|
19
34
|
## `et api`
|
|
20
35
|
|
|
21
36
|
Runs the API an app in this repo talks to, from a checkout on your own machine.
|
|
22
37
|
|
|
23
38
|
```bash
|
|
24
39
|
yarn et api --help # the commands, the APIs and what each one accepts
|
|
40
|
+
yarn et api help hub # what hub accepts, and where its checkout is
|
|
25
41
|
yarn et api up hub # start the containers
|
|
42
|
+
yarn et api up hub,platform # the same, for both APIs
|
|
26
43
|
yarn et api down hub # stop them
|
|
27
44
|
yarn et api logs hub # follow the API's log
|
|
28
45
|
yarn et api shell hub # a shell in the API container
|
|
@@ -32,10 +49,13 @@ yarn et api checkout hub # switch the checkout to the branch apiRepoBranc
|
|
|
32
49
|
yarn et api pull hub # fetch and fast-forward the checked-out branch
|
|
33
50
|
yarn et api pull hub --force # the same, discarding local commits and tracked changes
|
|
34
51
|
yarn et api clone hub # clone the API into .ethlete/hub
|
|
52
|
+
yarn et api setup hub # run the API's own setupCommand, which writes its .env
|
|
35
53
|
```
|
|
36
54
|
|
|
37
|
-
|
|
38
|
-
|
|
55
|
+
Every command takes a comma-separated list of names, and acts on each API in turn.
|
|
56
|
+
|
|
57
|
+
`checkout`, `pull` and `setup` act on the checkout itself, so they work before the API has an `.env`
|
|
58
|
+
and need no container engine. `pull` refuses to run on a checkout with uncommitted changes unless you pass
|
|
39
59
|
`--force`. `--force` resets the branch to its remote and throws away local commits and tracked
|
|
40
60
|
changes; it never touches untracked or ignored files, so a `vendor/` directory or a `.env` survives.
|
|
41
61
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -2,14 +2,40 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const lib_1 = require("./lib");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
const USAGE_ROWS = [
|
|
6
|
+
{ subcommand: 'release', args: '', lines: ['Turn pending changesets into a tagged, pushed release commit'] },
|
|
7
|
+
{
|
|
8
|
+
subcommand: 'api',
|
|
9
|
+
args: ' <cmd> <api>',
|
|
10
|
+
lines: [
|
|
11
|
+
"Run an API from this repo's ethlete.apis.js locally",
|
|
12
|
+
"(up, down, logs, shell, setup, plus that API's own exec entries)",
|
|
13
|
+
],
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
subcommand: 'auth',
|
|
17
|
+
args: ' [host] <token>',
|
|
18
|
+
lines: [
|
|
19
|
+
"Write a GitLab token into composer's auth.json, which the",
|
|
20
|
+
'API containers mount, after checking it can download code',
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
subcommand: 'doctor',
|
|
25
|
+
args: '',
|
|
26
|
+
lines: ["Check this machine's ethlete.config.local.json, container engine", 'and every API checkout'],
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
const usage = (root) => {
|
|
30
|
+
const rows = USAGE_ROWS.map((row) => (Object.assign(Object.assign({}, row), { command: `${(0, lib_1.repoInvocation)({ root, subcommand: row.subcommand })}${row.args}` })));
|
|
31
|
+
const width = Math.max(...rows.map((row) => row.command.length));
|
|
32
|
+
return [
|
|
33
|
+
'et — Ethlete repo tooling',
|
|
34
|
+
'',
|
|
35
|
+
...rows.flatMap((row) => row.lines.map((line, index) => ` ${(index === 0 ? row.command : '').padEnd(width)} ${line}`)),
|
|
36
|
+
'',
|
|
37
|
+
].join('\n');
|
|
38
|
+
};
|
|
13
39
|
const cli = (args) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
14
40
|
switch (args[0]) {
|
|
15
41
|
case 'release':
|
|
@@ -18,11 +44,25 @@ const cli = (args) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
|
18
44
|
yield (0, lib_1.release)(args.join('=').split('='));
|
|
19
45
|
return 0;
|
|
20
46
|
case 'api':
|
|
21
|
-
return (0, lib_1.apiCommand)({
|
|
47
|
+
return (0, lib_1.apiCommand)({
|
|
48
|
+
root: process.cwd(),
|
|
49
|
+
argv: args.slice(1),
|
|
50
|
+
invocation: (0, lib_1.repoInvocation)({ root: process.cwd(), subcommand: 'api' }),
|
|
51
|
+
});
|
|
52
|
+
case 'auth':
|
|
53
|
+
return (0, lib_1.authCommand)({
|
|
54
|
+
root: process.cwd(),
|
|
55
|
+
argv: args.slice(1),
|
|
56
|
+
invocation: (0, lib_1.repoInvocation)({ root: process.cwd(), subcommand: 'auth' }),
|
|
57
|
+
});
|
|
22
58
|
case 'doctor':
|
|
23
|
-
|
|
59
|
+
// Every fix it names is an `et api` command, so it needs that script rather than its own.
|
|
60
|
+
return (0, lib_1.doctorCommand)({
|
|
61
|
+
root: process.cwd(),
|
|
62
|
+
apiInvocation: (0, lib_1.repoInvocation)({ root: process.cwd(), subcommand: 'api' }),
|
|
63
|
+
});
|
|
24
64
|
default:
|
|
25
|
-
console.log(
|
|
65
|
+
console.log(usage(process.cwd()));
|
|
26
66
|
return args[0] === undefined || args[0] === '--help' || args[0] === '-h' ? 0 : 1;
|
|
27
67
|
}
|
|
28
68
|
});
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/cli/src/index.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/cli/src/index.ts"],"names":[],"mappings":";;;AAAA,+BAAwF;AAExF,MAAM,UAAU,GAAG;IACjB,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,8DAA8D,CAAC,EAAE;IAC5G;QACE,UAAU,EAAE,KAAK;QACjB,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE;YACL,qDAAqD;YACrD,kEAAkE;SACnE;KACF;IACD;QACE,UAAU,EAAE,MAAM;QAClB,IAAI,EAAE,iBAAiB;QACvB,KAAK,EAAE;YACL,2DAA2D;YAC3D,2DAA2D;SAC5D;KACF;IACD;QACE,UAAU,EAAE,QAAQ;QACpB,IAAI,EAAE,EAAE;QACR,KAAK,EAAE,CAAC,kEAAkE,EAAE,wBAAwB,CAAC;KACtG;CACF,CAAC;AAEF,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EAAE;I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AAC;SACD,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;QACxB,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC9D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.apiCommand = void 0;
|
|
4
4
|
const load_definitions_1 = require("./load-definitions");
|
|
5
5
|
const run_1 = require("./run");
|
|
6
|
-
const apiCommand = ({ root, argv }) => {
|
|
6
|
+
const apiCommand = ({ root, argv, invocation }) => {
|
|
7
7
|
const { found, apis } = (0, load_definitions_1.loadApiDefinitions)(root);
|
|
8
8
|
if (!found) {
|
|
9
9
|
console.error(`No API definitions found. Create ${load_definitions_1.API_DEFINITIONS_FILE_NAMES[0]} in the repo root:\n\n` +
|
|
@@ -21,7 +21,7 @@ const apiCommand = ({ root, argv }) => {
|
|
|
21
21
|
` };`);
|
|
22
22
|
return 1;
|
|
23
23
|
}
|
|
24
|
-
return (0, run_1.runApiCommand)({ apis, argv, root });
|
|
24
|
+
return (0, run_1.runApiCommand)({ apis, argv, root, invocation });
|
|
25
25
|
};
|
|
26
26
|
exports.apiCommand = apiCommand;
|
|
27
27
|
//# sourceMappingURL=api-command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-command.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/api/api-command.ts"],"names":[],"mappings":";;;AAAA,yDAAoF;AACpF,+BAAsC;AAE/B,MAAM,UAAU,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"api-command.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/api/api-command.ts"],"names":[],"mappings":";;;AAAA,yDAAoF;AACpF,+BAAsC;AAE/B,MAAM,UAAU,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAyD,EAAE,EAAE;IAC9G,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAAA,qCAAkB,EAAC,IAAI,CAAC,CAAC;IAEjD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CACX,oCAAoC,6CAA0B,CAAC,CAAC,CAAC,wBAAwB;YACvF,uDAAuD;YACvD,wBAAwB;YACxB,cAAc;YACd,oCAAoC;YACpC,wCAAwC;YACxC,6BAA6B;YAC7B,qBAAqB;YACrB,0BAA0B;YAC1B,qCAAqC;YACrC,qDAAqD;YACrD,UAAU;YACV,MAAM,CACT,CAAC;QAEF,OAAO,CAAC,CAAC;IACX,CAAC;IAED,OAAO,IAAA,mBAAa,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;AACzD,CAAC,CAAC;AAxBW,QAAA,UAAU,cAwBrB"}
|
|
@@ -7,3 +7,5 @@ export declare const printPrivateDependencyHint: (options: {
|
|
|
7
7
|
}) => void;
|
|
8
8
|
/** The host of a git url, for naming it in the hint. Undefined when the url has no host. */
|
|
9
9
|
export declare const gitUrlHost: (repoUrl: string) => string | undefined;
|
|
10
|
+
/** The `group/project` part of a git url, for addressing the project in a host's own API. */
|
|
11
|
+
export declare const gitUrlProjectPath: (repoUrl: string) => string | undefined;
|
package/src/lib/api/auth-hint.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gitUrlHost = exports.printPrivateDependencyHint = void 0;
|
|
3
|
+
exports.gitUrlProjectPath = exports.gitUrlHost = exports.printPrivateDependencyHint = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* A private dependency that will not download is the most common way these commands fail, and git
|
|
6
6
|
* and the package managers report it as a bare 403 or a public-key error. This says what to check.
|
|
@@ -30,4 +30,18 @@ const gitUrlHost = (repoUrl) => {
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
exports.gitUrlHost = gitUrlHost;
|
|
33
|
+
/** The `group/project` part of a git url, for addressing the project in a host's own API. */
|
|
34
|
+
const gitUrlProjectPath = (repoUrl) => {
|
|
35
|
+
var _a;
|
|
36
|
+
const scpLike = /^[^/]+@[^:]+:(.+)$/.exec(repoUrl);
|
|
37
|
+
if (scpLike)
|
|
38
|
+
return ((_a = scpLike[1]) !== null && _a !== void 0 ? _a : '').replace(/\.git$/, '') || undefined;
|
|
39
|
+
try {
|
|
40
|
+
return new URL(repoUrl).pathname.replace(/^\/+/, '').replace(/\.git$/, '') || undefined;
|
|
41
|
+
}
|
|
42
|
+
catch (_b) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
exports.gitUrlProjectPath = gitUrlProjectPath;
|
|
33
47
|
//# sourceMappingURL=auth-hint.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-hint.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/api/auth-hint.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACI,MAAM,0BAA0B,GAAG,CAAC,OAA8B,EAAE,EAAE;;IAC3E,MAAM,IAAI,GAAG,MAAA,OAAO,CAAC,QAAQ,mCAAI,eAAe,CAAC;IAEjD,OAAO,CAAC,KAAK,CACX,wFAAwF;QACtF,sCAAsC;QACtC,oCAAoC,IAAI,sCAAsC;QAC9E,6FAA6F;QAC7F,0CAA0C,IAAI,8CAA8C;QAC5F,0FAA0F;QAC1F,sFAAsF,CACzF,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,0BAA0B,8BAYrC;AAEF,4FAA4F;AACrF,MAAM,UAAU,GAAG,CAAC,OAAe,EAAE,EAAE;IAC5C,MAAM,OAAO,GAAG,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAEhD,IAAI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AEnD,IAAI,OAAO;QAAE,OAAO,CAAC,MAAA,OAAO,CAAC,CAAC,CAAC,mCAAI,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC;IAE1E,IAAI,CAAC;QACH,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC;IAC1F,CAAC;IAAC,WAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC,CAAC;AAVW,QAAA,iBAAiB,qBAU5B"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ApiDefinitions } from './definition';
|
|
2
|
+
export type ApiClearTarget = {
|
|
3
|
+
name: string;
|
|
4
|
+
/** Absolute path that would be removed. */
|
|
5
|
+
repoPath: string;
|
|
6
|
+
/** Directory that holds the compose file. */
|
|
7
|
+
composePath: string;
|
|
8
|
+
/** Whether any container of its compose project still exists. Those are taken down before the removal. */
|
|
9
|
+
hasContainers: boolean;
|
|
10
|
+
/** Why it must stay. Empty when it can be removed. */
|
|
11
|
+
blockers: string[];
|
|
12
|
+
};
|
|
13
|
+
export type ApiClearPlanOptions = {
|
|
14
|
+
apis: ApiDefinitions;
|
|
15
|
+
names: string[];
|
|
16
|
+
root: string;
|
|
17
|
+
invocation: string;
|
|
18
|
+
/** Skips the checks on uncommitted changes and unpushed commits. */
|
|
19
|
+
force: boolean;
|
|
20
|
+
/** Whether any container of the API's compose project exists. */
|
|
21
|
+
hasContainers: (composePath: string) => boolean;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* What `clear` would do to each named API: the path it would remove, and every reason it must stay.
|
|
25
|
+
* An API without a managed checkout is left out, because there is nothing of ours to remove.
|
|
26
|
+
*/
|
|
27
|
+
export declare const planApiClear: (options: ApiClearPlanOptions) => ApiClearTarget[];
|
|
28
|
+
export type ApiClearOptions = ApiClearPlanOptions & {
|
|
29
|
+
/** Takes the containers of one compose project down. False when the compose command failed. */
|
|
30
|
+
takeDown: (composePath: string) => boolean;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Removes the managed checkout of each named API, after one question that defaults to no. It offers to
|
|
34
|
+
* take down the containers that still exist, and refuses an API with work only this checkout holds.
|
|
35
|
+
*/
|
|
36
|
+
export declare const clearApiCheckouts: (options: ApiClearOptions) => Promise<number>;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clearApiCheckouts = exports.planApiClear = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const git_1 = require("./git");
|
|
8
|
+
const resolve_checkout_1 = require("./resolve-checkout");
|
|
9
|
+
const MAX_LISTED = 5;
|
|
10
|
+
/** The first few lines of a git listing, so a refusal shows what stands in the way. */
|
|
11
|
+
const listed = (lines) => [
|
|
12
|
+
...lines.slice(0, MAX_LISTED).map((line) => ` ${line}`),
|
|
13
|
+
...(lines.length > MAX_LISTED ? [` and ${lines.length - MAX_LISTED} more`] : []),
|
|
14
|
+
].join('\n');
|
|
15
|
+
/**
|
|
16
|
+
* What `clear` would do to each named API: the path it would remove, and every reason it must stay.
|
|
17
|
+
* An API without a managed checkout is left out, because there is nothing of ours to remove.
|
|
18
|
+
*/
|
|
19
|
+
const planApiClear = (options) => {
|
|
20
|
+
const { apis, names, root, invocation, force, hasContainers } = options;
|
|
21
|
+
return names.flatMap((name) => {
|
|
22
|
+
const api = apis[name];
|
|
23
|
+
if (!api)
|
|
24
|
+
return [];
|
|
25
|
+
const checkout = (0, resolve_checkout_1.resolveApiCheckout)({ root, name, api, needs: 'repo' });
|
|
26
|
+
if (!checkout.ok)
|
|
27
|
+
return [];
|
|
28
|
+
const { repoPath, composePath } = checkout.checkout;
|
|
29
|
+
const managed = (0, resolve_checkout_1.managedCheckoutPath)(root, name);
|
|
30
|
+
if (repoPath !== managed) {
|
|
31
|
+
return [
|
|
32
|
+
{
|
|
33
|
+
name,
|
|
34
|
+
repoPath,
|
|
35
|
+
composePath,
|
|
36
|
+
hasContainers: false,
|
|
37
|
+
blockers: [
|
|
38
|
+
`${repoPath} is your own checkout, not the one ${invocation} manages. ` +
|
|
39
|
+
`Remove it yourself, or drop apiRepoPaths.${name} first.`,
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
const changes = (0, git_1.uncommittedChanges)(repoPath);
|
|
45
|
+
const unpushed = (0, git_1.unpushedCommits)(repoPath);
|
|
46
|
+
return [
|
|
47
|
+
{
|
|
48
|
+
name,
|
|
49
|
+
repoPath,
|
|
50
|
+
composePath,
|
|
51
|
+
hasContainers: hasContainers(composePath),
|
|
52
|
+
blockers: [
|
|
53
|
+
...(!force && changes.length > 0
|
|
54
|
+
? [
|
|
55
|
+
`${repoPath} has uncommitted changes:\n\n${listed(changes)}\n\n` +
|
|
56
|
+
'Commit them, or pass --force to lose them.',
|
|
57
|
+
]
|
|
58
|
+
: []),
|
|
59
|
+
...(!force && unpushed.length > 0
|
|
60
|
+
? [
|
|
61
|
+
`${repoPath} has commits no remote holds:\n\n${listed(unpushed)}\n\n` +
|
|
62
|
+
'Push them, or pass --force to lose them.',
|
|
63
|
+
]
|
|
64
|
+
: []),
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
exports.planApiClear = planApiClear;
|
|
71
|
+
/**
|
|
72
|
+
* Removes the managed checkout of each named API, after one question that defaults to no. It offers to
|
|
73
|
+
* take down the containers that still exist, and refuses an API with work only this checkout holds.
|
|
74
|
+
*/
|
|
75
|
+
const clearApiCheckouts = (options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
76
|
+
const { names, invocation, takeDown } = options;
|
|
77
|
+
const targets = (0, exports.planApiClear)(options);
|
|
78
|
+
const blocked = targets.filter(({ blockers }) => blockers.length > 0);
|
|
79
|
+
const removable = targets.filter(({ blockers }) => blockers.length === 0);
|
|
80
|
+
for (const { blockers } of blocked) {
|
|
81
|
+
console.error(blockers.join('\n\n'));
|
|
82
|
+
}
|
|
83
|
+
if (blocked.length > 0)
|
|
84
|
+
console.error('');
|
|
85
|
+
if (removable.length === 0) {
|
|
86
|
+
if (blocked.length === 0) {
|
|
87
|
+
console.log(`Nothing to remove. ${names.join(', ')} has no checkout ${invocation} manages.`);
|
|
88
|
+
}
|
|
89
|
+
return blocked.length > 0 ? 1 : 0;
|
|
90
|
+
}
|
|
91
|
+
const paths = removable.map(({ repoPath }) => ` ${repoPath}`).join('\n');
|
|
92
|
+
const running = removable.filter(({ hasContainers }) => hasContainers).map(({ name }) => name);
|
|
93
|
+
const stopped = running.join(', ');
|
|
94
|
+
const checkouts = removable.length === 1 ? 'the checkout' : 'the checkouts';
|
|
95
|
+
const accepted = yield (0, utils_1.confirm)({
|
|
96
|
+
problem: running.length > 0 ? `This takes ${stopped} down, then removes:\n\n${paths}` : `This removes:\n\n${paths}`,
|
|
97
|
+
question: running.length > 0
|
|
98
|
+
? `Take ${stopped} down and remove ${checkouts}?`
|
|
99
|
+
: `Remove ${removable.map(({ name }) => name).join(', ')}?`,
|
|
100
|
+
hint: running.length > 0
|
|
101
|
+
? `Re-run in a terminal to answer the question, or run "${invocation} down ${stopped}" and remove the ` +
|
|
102
|
+
'directories yourself.'
|
|
103
|
+
: 'Re-run in a terminal to answer the question, or remove the directories yourself.',
|
|
104
|
+
defaultsToYes: false,
|
|
105
|
+
});
|
|
106
|
+
if (!accepted)
|
|
107
|
+
return 1;
|
|
108
|
+
let failed = 0;
|
|
109
|
+
for (const { name, repoPath, composePath, hasContainers } of removable) {
|
|
110
|
+
if (hasContainers && !takeDown(composePath)) {
|
|
111
|
+
console.error(`Could not take ${name} down, so ${repoPath} stays.`);
|
|
112
|
+
failed += 1;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
(0, fs_1.rmSync)(repoPath, { recursive: true, force: true });
|
|
116
|
+
console.log(`Removed ${repoPath}. Run "${invocation} clone ${name}" to get it back.`);
|
|
117
|
+
}
|
|
118
|
+
return blocked.length > 0 || failed > 0 ? 1 : 0;
|
|
119
|
+
});
|
|
120
|
+
exports.clearApiCheckouts = clearApiCheckouts;
|
|
121
|
+
//# sourceMappingURL=clear.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clear.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/api/clear.ts"],"names":[],"mappings":";;;;AAAA,2BAA4B;AAC5B,oCAAmC;AAEnC,+BAA4D;AAC5D,yDAA6E;AAc7E,MAAM,UAAU,GAAG,CAAC,CAAC;AAErB,uFAAuF;AACvF,MAAM,MAAM,GAAG,CAAC,KAAe,EAAE,EAAE,CACjC;IACE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC;IACxD,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,CAAC,MAAM,GAAG,UAAU,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;CAClF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAaf;;;GAGG;AACI,MAAM,YAAY,GAAG,CAAC,OAA4B,EAAoB,EAAE;IAC7E,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAExE,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI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,WAAW,EAAE,aAAa,EAAE,IAAI,SAAS,EAAE,CAAC;QACvE,IAAI,aAAa,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YAC5C,OAAO,CAAC,KAAK,CAAC,kBAAkB,IAAI,aAAa,QAAQ,SAAS,CAAC,CAAC;YACpE,MAAM,IAAI,CAAC,CAAC;YAEZ,SAAS;QACX,CAAC;QAED,IAAA,WAAM,EAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,OAAO,CAAC,GAAG,CAAC,WAAW,QAAQ,UAAU,UAAU,UAAU,IAAI,mBAAmB,CAAC,CAAC;IACxF,CAAC;IAED,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClD,CAAC,CAAA,CAAC;AAvDW,QAAA,iBAAiB,qBAuD5B"}
|
package/src/lib/api/compose.d.ts
CHANGED
|
@@ -15,3 +15,32 @@ export declare const engineEnv: (engine: string) => {
|
|
|
15
15
|
export declare const lanAddress: () => string | undefined;
|
|
16
16
|
/** Path of this machine's SSH key, for a compose file that mounts one into the API container. */
|
|
17
17
|
export declare const sshKeyPath: () => string | undefined;
|
|
18
|
+
export type ComposeCall = {
|
|
19
|
+
tool: ComposeTool;
|
|
20
|
+
/** Directory that holds the compose file. */
|
|
21
|
+
cwd: string;
|
|
22
|
+
env?: NodeJS.ProcessEnv;
|
|
23
|
+
};
|
|
24
|
+
/** Runs a compose command and captures its stdout. `undefined` when the tool itself failed. */
|
|
25
|
+
export declare const composeOutput: (options: ComposeCall & {
|
|
26
|
+
args: string[];
|
|
27
|
+
}) => string | undefined;
|
|
28
|
+
/** Container ids of a compose project, or `undefined` when the tool could not answer. */
|
|
29
|
+
export declare const composeContainerIds: (call: ComposeCall) => string[] | undefined;
|
|
30
|
+
export type PortMapping = {
|
|
31
|
+
host: number;
|
|
32
|
+
container: number;
|
|
33
|
+
};
|
|
34
|
+
export type ContainerState = {
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
/** Compose service, empty for a container compose did not start. */
|
|
38
|
+
service: string;
|
|
39
|
+
/** The engine's own words, for example `Up 42 minutes` or `Exited (1) 3 seconds ago`. */
|
|
40
|
+
status: string;
|
|
41
|
+
ports: PortMapping[];
|
|
42
|
+
};
|
|
43
|
+
/** True for a status the engine prints while the container runs. */
|
|
44
|
+
export declare const isRunningStatus: (status: string) => boolean;
|
|
45
|
+
/** Every container the engine knows, with its compose service and published ports. */
|
|
46
|
+
export declare const containerStates: (engine: string) => ContainerState[];
|
package/src/lib/api/compose.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sshKeyPath = exports.lanAddress = exports.engineEnv = exports.composeToolNames = exports.resolveComposeTool = exports.composeBinary = void 0;
|
|
3
|
+
exports.containerStates = exports.isRunningStatus = exports.composeContainerIds = exports.composeOutput = exports.sshKeyPath = exports.lanAddress = exports.engineEnv = exports.composeToolNames = exports.resolveComposeTool = exports.composeBinary = void 0;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
6
|
const os_1 = require("os");
|
|
@@ -55,4 +55,47 @@ exports.lanAddress = lanAddress;
|
|
|
55
55
|
/** Path of this machine's SSH key, for a compose file that mounts one into the API container. */
|
|
56
56
|
const sshKeyPath = () => [(0, path_1.join)((0, os_1.homedir)(), '.ssh/id_ed25519'), (0, path_1.join)((0, os_1.homedir)(), '.ssh/id_rsa')].find((path) => (0, fs_1.existsSync)(path));
|
|
57
57
|
exports.sshKeyPath = sshKeyPath;
|
|
58
|
+
/** Runs a compose command and captures its stdout. `undefined` when the tool itself failed. */
|
|
59
|
+
const composeOutput = (options) => {
|
|
60
|
+
var _a;
|
|
61
|
+
const { tool, cwd, env, args } = options;
|
|
62
|
+
const [binary, ...prefix] = tool.compose;
|
|
63
|
+
const result = (0, child_process_1.spawnSync)(binary, [...prefix, ...args], { cwd, env, encoding: 'utf8' });
|
|
64
|
+
return result.error || result.status !== 0 ? undefined : ((_a = result.stdout) !== null && _a !== void 0 ? _a : '');
|
|
65
|
+
};
|
|
66
|
+
exports.composeOutput = composeOutput;
|
|
67
|
+
/** Container ids of a compose project, or `undefined` when the tool could not answer. */
|
|
68
|
+
const composeContainerIds = (call) => {
|
|
69
|
+
const stdout = (0, exports.composeOutput)(Object.assign(Object.assign({}, call), { args: ['ps', '-q'] }));
|
|
70
|
+
return stdout === undefined ? undefined : stdout.split('\n').filter((id) => id.trim() !== '');
|
|
71
|
+
};
|
|
72
|
+
exports.composeContainerIds = composeContainerIds;
|
|
73
|
+
const PUBLISHED_MAPPING = /(\d+)->(\d+)/g;
|
|
74
|
+
const parsePortMappings = (ports) => [...ports.matchAll(PUBLISHED_MAPPING)].map(([, host, container]) => ({
|
|
75
|
+
host: Number(host),
|
|
76
|
+
container: Number(container),
|
|
77
|
+
}));
|
|
78
|
+
const PS_FORMAT = '{{.ID}}\t{{.Names}}\t{{.Label "com.docker.compose.service"}}\t{{.Status}}\t{{.Ports}}';
|
|
79
|
+
/** True for a status the engine prints while the container runs. */
|
|
80
|
+
const isRunningStatus = (status) => /^up\b/i.test(status);
|
|
81
|
+
exports.isRunningStatus = isRunningStatus;
|
|
82
|
+
/** Every container the engine knows, with its compose service and published ports. */
|
|
83
|
+
const containerStates = (engine) => {
|
|
84
|
+
var _a;
|
|
85
|
+
const result = (0, child_process_1.spawnSync)(engine, ['ps', '-a', '--format', PS_FORMAT], { encoding: 'utf8' });
|
|
86
|
+
if (result.error || result.status !== 0)
|
|
87
|
+
return [];
|
|
88
|
+
return ((_a = result.stdout) !== null && _a !== void 0 ? _a : '')
|
|
89
|
+
.split('\n')
|
|
90
|
+
.map((line) => line.split('\t'))
|
|
91
|
+
.filter((columns) => columns.length >= 5 && columns[0])
|
|
92
|
+
.map(([id, name, service, status, ports]) => ({
|
|
93
|
+
id: id !== null && id !== void 0 ? id : '',
|
|
94
|
+
name: name !== null && name !== void 0 ? name : '',
|
|
95
|
+
service: service !== null && service !== void 0 ? service : '',
|
|
96
|
+
status: status !== null && status !== void 0 ? status : '',
|
|
97
|
+
ports: parsePortMappings(ports !== null && ports !== void 0 ? ports : ''),
|
|
98
|
+
}));
|
|
99
|
+
};
|
|
100
|
+
exports.containerStates = containerStates;
|
|
58
101
|
//# sourceMappingURL=compose.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/api/compose.ts"],"names":[],"mappings":";;;AAAA,iDAA0C;AAC1C,2BAA4D;AAC5D,2BAAwD;AACxD,+BAA4B;AAQ5B;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,CAAC,gDAAgD,CAAC,CAAC;AAE/E,MAAM,aAAa,GAAkB;IACnC,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE;IACpD,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC,EAAE;IAC1D,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,gBAAgB,EAAE,GAAG,mBAAmB,CAAC,EAAE;IACzE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,mBAAmB,CAAC,EAAE;CAC7E,CAAC;AAEF;;;;GAIG;AACH,MAAM,sBAAsB,GAAG,+EAA+E,CAAC;AAE/G,IAAI,wBAA4C,CAAC;AAEjD,MAAM,yBAAyB,GAAG,GAAG,EAAE;IACrC,wBAAwB,aAAxB,wBAAwB,cAAxB,wBAAwB,IAAxB,wBAAwB,GAAK,IAAA,WAAI,EAAC,IAAA,gBA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AAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;QAC5C,EAAE,EAAE,EAAE,aAAF,EAAE,cAAF,EAAE,GAAI,EAAE;QACZ,IAAI,EAAE,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE;QAChB,OAAO,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE;QACtB,MAAM,EAAE,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE;QACpB,KAAK,EAAE,iBAAiB,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC;KACtC,CAAC,CAAC,CAAC;AACR,CAAC,CAAC;AAhBW,QAAA,eAAe,mBAgB1B"}
|
|
@@ -10,7 +10,7 @@ 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;
|
|
@@ -26,7 +26,12 @@ export type ApiDefinition = {
|
|
|
26
26
|
exec?: Record<string, string[]>;
|
|
27
27
|
};
|
|
28
28
|
export type ApiDefinitions = Record<string, ApiDefinition>;
|
|
29
|
-
export declare const BUILT_IN_API_COMMANDS: readonly ["up", "down", "logs", "shell", "clone", "checkout", "pull"];
|
|
30
|
-
/** These act on the checkout itself, so they run before `
|
|
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
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. */
|
|
32
37
|
export declare const apiCommandNames: (api: ApiDefinition) => string[];
|
|
@@ -1,9 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.apiCommandNames = exports.GIT_API_COMMANDS = 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. */
|
|
6
16
|
exports.GIT_API_COMMANDS = ['clone', 'checkout', 'pull'];
|
|
7
|
-
const
|
|
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
|
+
};
|
|
8
32
|
exports.apiCommandNames = apiCommandNames;
|
|
9
33
|
//# sourceMappingURL=definition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/api/definition.ts"],"names":[],"mappings":";;;AA8Ba,QAAA,qBAAqB,GAAG,CAAC,
|
|
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"}
|
package/src/lib/api/git.d.ts
CHANGED
|
@@ -4,7 +4,11 @@ export type GitResult = {
|
|
|
4
4
|
stderr: string;
|
|
5
5
|
};
|
|
6
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[];
|
|
7
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[];
|
|
8
12
|
/** Switches the API checkout to the branch configured for it. Git's own refusal is passed through. */
|
|
9
13
|
export declare const checkoutApiBranch: (options: {
|
|
10
14
|
repoPath: string;
|