bdy 1.25.2-dev → 1.25.2-stage
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/distTs/package.json +1 -1
- package/package.json +1 -1
- package/distTs/README.md +0 -181
- package/distTs/src/autocomplete.js +0 -90
- package/distTs/src/command/autocomplete/install.js +0 -16
- package/distTs/src/command/autocomplete/uninstall.js +0 -16
- package/distTs/src/command/autocomplete.js +0 -14
- package/distTs/src/command/environment/resolve.js +0 -47
- package/distTs/src/command/package/create.js +0 -64
- package/distTs/src/command/package/delete.js +0 -38
- package/distTs/src/command/package/docker/login.js +0 -26
- package/distTs/src/command/package/docker.js +0 -11
- package/distTs/src/command/package/download.js +0 -138
- package/distTs/src/command/package/get.js +0 -36
- package/distTs/src/command/package/list.js +0 -31
- package/distTs/src/command/package/publish.js +0 -241
- package/distTs/src/command/package/version/delete.js +0 -39
- package/distTs/src/command/package/version/get.js +0 -45
- package/distTs/src/command/package/version/list.js +0 -47
- package/distTs/src/command/package/version.js +0 -16
- package/distTs/src/command/package.js +0 -26
- package/distTs/src/command/project/get.js +0 -18
- package/distTs/src/command/project/set.js +0 -31
- package/distTs/src/command/sandbox/get/yaml.js +0 -30
- package/distTs/src/command/scrape/validation.js +0 -154
- package/distTs/src/command/scrape.js +0 -144
- package/distTs/src/command/ut/upload.js +0 -86
- package/distTs/src/command/ut.js +0 -12
- package/distTs/src/command/vt/close.js +0 -27
- package/distTs/src/command/vt/compare/validation.js +0 -46
- package/distTs/src/command/vt/compare.js +0 -100
- package/distTs/src/command/vt/exec.js +0 -82
- package/distTs/src/command/vt/installBrowser.js +0 -20
- package/distTs/src/command/vt/scrape.js +0 -193
- package/distTs/src/command/vt/shared/validation.js +0 -145
- package/distTs/src/command/vt/storybook.js +0 -138
- package/distTs/src/command/vt.js +0 -20
- package/distTs/src/main.js +0 -190
- package/distTs/src/types/options.js +0 -2
- package/distTs/src/types/scrape.js +0 -2
package/distTs/package.json
CHANGED
package/package.json
CHANGED
package/distTs/README.md
DELETED
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
# Buddy CLI (`bdy`)
|
|
2
|
-
|
|
3
|
-
Work seamlessly with [Buddy](https://buddy.works) from the command line.
|
|
4
|
-
|
|
5
|
-
`bdy` is Buddy's official command-line interface for managing CI/CD pipelines, agents, tests, artifacts, sandboxes, distributions, and more — straight from your terminal.
|
|
6
|
-
|
|
7
|
-
📚 Full documentation: https://buddy.works/docs/cli/getting-started
|
|
8
|
-
|
|
9
|
-
## Installation
|
|
10
|
-
|
|
11
|
-
### npm (recommended)
|
|
12
|
-
|
|
13
|
-
Requires Node.js 14+.
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
# macOS / Linux
|
|
17
|
-
sudo npm i -g bdy
|
|
18
|
-
|
|
19
|
-
# Windows
|
|
20
|
-
npm i -g bdy
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
### Homebrew (macOS)
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
brew tap buddy/bdy
|
|
27
|
-
brew install bdy
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### APT (Linux x64 / ARM64)
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
sudo apt-get update && sudo apt-get install -y software-properties-common
|
|
34
|
-
sudo gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/buddy.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys eb39332e766364ca6220e8dc631c5a16310cc0ad
|
|
35
|
-
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/buddy.gpg] https://es.buddy.works/bdy/apt-repo prod main" | sudo tee /etc/apt/sources.list.d/buddy.list > /dev/null
|
|
36
|
-
sudo apt-get update && sudo apt-get install -y bdy
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
> On ARM64, replace `arch=amd64` with `arch=arm64` in the `echo` command above.
|
|
40
|
-
|
|
41
|
-
### Chocolatey (Windows)
|
|
42
|
-
|
|
43
|
-
```powershell
|
|
44
|
-
choco install bdy --pre
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
### Direct download
|
|
48
|
-
|
|
49
|
-
Prebuilt binaries are available for macOS (Apple Silicon), Linux (x64/ARM64), and Windows (x64) on the [installation page](https://buddy.works/docs/cli/getting-started).
|
|
50
|
-
|
|
51
|
-
### Verify & update
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
bdy version # show current and latest version
|
|
55
|
-
sudo npm i -g bdy # update (or use your package manager's upgrade command)
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
## Authentication
|
|
59
|
-
|
|
60
|
-
A [Buddy account](https://buddy.works) is required to use the CLI.
|
|
61
|
-
|
|
62
|
-
Log in interactively:
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
bdy login
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
New to Buddy? Create an account from the CLI:
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
bdy register
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### Linking a project
|
|
75
|
-
|
|
76
|
-
Once logged in, link a directory to a Buddy project:
|
|
77
|
-
|
|
78
|
-
```bash
|
|
79
|
-
mkdir my-proj
|
|
80
|
-
cd my-proj
|
|
81
|
-
bdy proj link
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
After linking, every `bdy` command run from this directory is executed against the linked project — no need to pass the project name each time.
|
|
85
|
-
|
|
86
|
-
Check who you're logged in as, or log out:
|
|
87
|
-
|
|
88
|
-
```bash
|
|
89
|
-
bdy whoami
|
|
90
|
-
bdy logout
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
### Tokens & non-interactive login
|
|
94
|
-
|
|
95
|
-
For CI/CD pipelines and non-browser environments, authenticate with a [personal access token](https://buddy.works/docs/api/getting-started/oauth2/personal-access-token):
|
|
96
|
-
|
|
97
|
-
```bash
|
|
98
|
-
bdy login --token <token>
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
The login command accepts the following options:
|
|
102
|
-
|
|
103
|
-
| Option | Description | Environment variable |
|
|
104
|
-
| --- | --- | --- |
|
|
105
|
-
| `--token <token>` | Personal access token | `BUDDY_TOKEN` |
|
|
106
|
-
| `--api <url>` | API URL for On-Premises installations | `BUDDY_API_ENDPOINT` |
|
|
107
|
-
| `--region <region>` | Region: `us`, `eu`, or `as` | `BUDDY_REGION` |
|
|
108
|
-
| `-w, --workspace <domain>` | Workspace URL handle | `BUDDY_WORKSPACE` |
|
|
109
|
-
|
|
110
|
-
Each option can be supplied as a flag or via its environment variable — handy for pipelines and headless setups:
|
|
111
|
-
|
|
112
|
-
```bash
|
|
113
|
-
export BUDDY_TOKEN=<token>
|
|
114
|
-
export BUDDY_WORKSPACE=<your-workspace>
|
|
115
|
-
bdy login
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
## Agent integration (plugin & skills)
|
|
119
|
-
|
|
120
|
-
The [Buddy Plugin](https://github.com/buddy/buddy-plugin) lets coding agents deploy applications, expose local services, and manage infrastructure on Buddy. It bundles a consolidated skill covering sandboxes, artifacts, tunnels, domains, distributions, and pipelines, plus two commands:
|
|
121
|
-
|
|
122
|
-
- `/deploy [name] [path]` — deploy a static site or server application
|
|
123
|
-
- `/expose [port]` — open a tunnel to a locally running service
|
|
124
|
-
|
|
125
|
-
Make sure the CLI is installed first (`sudo npm install -g bdy`), then:
|
|
126
|
-
|
|
127
|
-
**Claude Code** — install the plugin (commands + skills):
|
|
128
|
-
|
|
129
|
-
```bash
|
|
130
|
-
claude plugin marketplace add buddy/buddy-plugin
|
|
131
|
-
claude plugin install buddy@buddy-plugin
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
**Other agents** — install the skills only:
|
|
135
|
-
|
|
136
|
-
```bash
|
|
137
|
-
npx skills add buddy/buddy-plugin
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
Then authenticate and link your project:
|
|
141
|
-
|
|
142
|
-
```bash
|
|
143
|
-
bdy login
|
|
144
|
-
cd your-project
|
|
145
|
-
bdy proj link
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
The plugin auto-detects your project type: static sites generate versioned artifacts with public URLs, while server applications deploy to sandboxes with HTTPS endpoints. Monorepos can deploy multiple applications, each getting its own URL and endpoint.
|
|
149
|
-
|
|
150
|
-
## Commands
|
|
151
|
-
|
|
152
|
-
| Command | Description |
|
|
153
|
-
| --- | --- |
|
|
154
|
-
| `bdy login` / `sign-in` | Log in to Buddy |
|
|
155
|
-
| `bdy register` / `sign-up` | Register a new Buddy account |
|
|
156
|
-
| `bdy whoami` | Check login information |
|
|
157
|
-
| `bdy logout` | Log out from Buddy |
|
|
158
|
-
| `bdy workspace` / `ws` | Manage workspaces |
|
|
159
|
-
| `bdy project` / `proj` | Manage projects |
|
|
160
|
-
| `bdy pipeline` / `pip` | Interact with the pipeline service |
|
|
161
|
-
| `bdy artifact` / `art` | Interact with the artifact service |
|
|
162
|
-
| `bdy sandbox` / `sb` | Interact with sandboxes |
|
|
163
|
-
| `bdy agent` | Install and run `bdy` as an OS service (Windows, macOS, Linux) |
|
|
164
|
-
| `bdy tunnel` | Manage tunnel configuration |
|
|
165
|
-
| `bdy crawl` | Manage web crawls (Markdown, HTML, PNG/JPEG screenshots; suite linking) |
|
|
166
|
-
| `bdy tests` | Manage unit tests and visual regression (Storybook, URL captures, runners) |
|
|
167
|
-
| `bdy domain` | Manage zones used in distribution routes |
|
|
168
|
-
| `bdy distro` | Manage distributions |
|
|
169
|
-
| `bdy api` | Contact the Buddy API directly |
|
|
170
|
-
| `bdy update` / `version` | Show version and update the CLI |
|
|
171
|
-
|
|
172
|
-
Run any command with `-h` / `--help` for detailed usage:
|
|
173
|
-
|
|
174
|
-
```bash
|
|
175
|
-
bdy --help
|
|
176
|
-
bdy pipeline --help
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
## Feedback
|
|
180
|
-
|
|
181
|
-
Found a bug or have a feature request? Let us know through [Buddy support](https://buddy.works/support) or the [documentation](https://buddy.works/docs/cli/getting-started).
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const logger_1 = __importDefault(require("./logger"));
|
|
7
|
-
class Autocomplete {
|
|
8
|
-
getCommandsMap(command) {
|
|
9
|
-
const commands = {};
|
|
10
|
-
command.commands.forEach((c) => {
|
|
11
|
-
const map = this.getCommandsMap(c);
|
|
12
|
-
const name = c.name() || 'bdy';
|
|
13
|
-
commands[name] = map;
|
|
14
|
-
c.aliases().forEach((a) => {
|
|
15
|
-
commands[a] = map;
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
command.options.forEach((o) => {
|
|
19
|
-
const name = `--${o.name()}`;
|
|
20
|
-
commands[name] = {};
|
|
21
|
-
});
|
|
22
|
-
let lastArg = commands;
|
|
23
|
-
command.registeredArguments.forEach((a) => {
|
|
24
|
-
logger_1.default.info(a);
|
|
25
|
-
let name;
|
|
26
|
-
if (a.required) {
|
|
27
|
-
name = `<${a.name()}>`;
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
name = `[${a.name()}]`;
|
|
31
|
-
}
|
|
32
|
-
name = name.replaceAll(':', '꞉'); // U+A789 MODIFIER LETTER COLON - looks like : but doesn't trigger tabtab delimiter
|
|
33
|
-
lastArg[name] = {};
|
|
34
|
-
lastArg = lastArg[name];
|
|
35
|
-
});
|
|
36
|
-
return commands;
|
|
37
|
-
}
|
|
38
|
-
init(rootCommand) {
|
|
39
|
-
// COMP_LINE is set by all shells (bash natively, zsh/fish via tabtab scripts) when invoking completion
|
|
40
|
-
if (!process.env.COMP_LINE)
|
|
41
|
-
return false;
|
|
42
|
-
const tabtab = require('tabtab');
|
|
43
|
-
const env = tabtab.parseEnv(process.env);
|
|
44
|
-
if (!env.complete)
|
|
45
|
-
return false;
|
|
46
|
-
let map = {
|
|
47
|
-
bdy: this.getCommandsMap(rootCommand)
|
|
48
|
-
};
|
|
49
|
-
const s = (env.partial || '').trim().split(' ').filter((n) => !n.startsWith('--'));
|
|
50
|
-
const last = s[s.length - 1];
|
|
51
|
-
for (let i = 0; i < s.length - 1; i += 1) {
|
|
52
|
-
const name = s[i];
|
|
53
|
-
if (!map[name]) {
|
|
54
|
-
const arg = Object.keys(map).find((k) => k.startsWith('<') || k.startsWith('['));
|
|
55
|
-
if (arg) {
|
|
56
|
-
map = map[arg];
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
map = map[name];
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
if (map[last])
|
|
67
|
-
map = map[last];
|
|
68
|
-
else {
|
|
69
|
-
const arg = Object.keys(map).find((k) => k.startsWith('<') || k.startsWith('['));
|
|
70
|
-
if (arg)
|
|
71
|
-
map = map[arg];
|
|
72
|
-
}
|
|
73
|
-
tabtab.log(Object.keys(map));
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
async install() {
|
|
77
|
-
const tabtab = require('tabtab');
|
|
78
|
-
await tabtab.install({
|
|
79
|
-
name: process.title,
|
|
80
|
-
completer: process.title
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
async uninstall() {
|
|
84
|
-
const tabtab = require('tabtab');
|
|
85
|
-
await tabtab.uninstall({
|
|
86
|
-
name: process.title
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
exports.default = new Autocomplete();
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const utils_1 = require("../../utils");
|
|
7
|
-
const autocomplete_1 = __importDefault(require("../../autocomplete"));
|
|
8
|
-
const texts_1 = require("../../texts");
|
|
9
|
-
const output_1 = __importDefault(require("../../output"));
|
|
10
|
-
const commandAutocompleteInstall = (0, utils_1.newCommand)('install', texts_1.DESC_COMMAND_AUTOCOMPLETE_INSTALL);
|
|
11
|
-
commandAutocompleteInstall.alias('i');
|
|
12
|
-
commandAutocompleteInstall.action(async () => {
|
|
13
|
-
await autocomplete_1.default.install();
|
|
14
|
-
output_1.default.exitSuccess(texts_1.TXT_AUTOCOMPLETE_INSTALLED);
|
|
15
|
-
});
|
|
16
|
-
exports.default = commandAutocompleteInstall;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const utils_1 = require("../../utils");
|
|
7
|
-
const autocomplete_1 = __importDefault(require("../../autocomplete"));
|
|
8
|
-
const texts_1 = require("../../texts");
|
|
9
|
-
const output_1 = __importDefault(require("../../output"));
|
|
10
|
-
const commandAutocompleteUninstall = (0, utils_1.newCommand)('uninstall', texts_1.DESC_COMMAND_AUTOCOMPLETE_UNINSTALL);
|
|
11
|
-
commandAutocompleteUninstall.alias('u');
|
|
12
|
-
commandAutocompleteUninstall.action(async () => {
|
|
13
|
-
await autocomplete_1.default.uninstall();
|
|
14
|
-
output_1.default.exitSuccess(texts_1.TXT_AUTOCOMPLETE_UNINSTALLED);
|
|
15
|
-
});
|
|
16
|
-
exports.default = commandAutocompleteUninstall;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const utils_1 = require("../utils");
|
|
7
|
-
const install_1 = __importDefault(require("./autocomplete/install"));
|
|
8
|
-
const uninstall_1 = __importDefault(require("./autocomplete/uninstall"));
|
|
9
|
-
const texts_1 = require("../texts");
|
|
10
|
-
const commandAutocomplete = (0, utils_1.newCommand)('autocomplete', texts_1.DESC_COMMAND_AUTOCOMPLETE);
|
|
11
|
-
commandAutocomplete.alias('ac');
|
|
12
|
-
commandAutocomplete.addCommand(install_1.default);
|
|
13
|
-
commandAutocomplete.addCommand(uninstall_1.default);
|
|
14
|
-
exports.default = commandAutocomplete;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.resolveEnvironmentId = void 0;
|
|
7
|
-
const texts_1 = require("../../texts");
|
|
8
|
-
const output_1 = __importDefault(require("../../output"));
|
|
9
|
-
const input_1 = __importDefault(require("../../input"));
|
|
10
|
-
// Shared resolve preamble for commands taking an environment identifier:
|
|
11
|
-
// project context from flags/env -> /identifiers -> hash id, exiting on a
|
|
12
|
-
// miss. Without a project the identifier resolves as a workspace
|
|
13
|
-
// environment; with one, along the project line.
|
|
14
|
-
//
|
|
15
|
-
// Since the backend made /identifiers resolve strictly along the requested
|
|
16
|
-
// line, a project param no longer falls back to the workspace environment of
|
|
17
|
-
// the same identifier. Reads keep that fallback by asking a second time
|
|
18
|
-
// without the project - that is how workspace environments stay addressable
|
|
19
|
-
// from inside a project context, which the CLI enters on its own from
|
|
20
|
-
// BUDDY_PROJECT or a linked project.
|
|
21
|
-
//
|
|
22
|
-
// strictProject is for mutating commands (update/delete): an explicit -p is
|
|
23
|
-
// a statement "the environment of this project", so the resolved environment
|
|
24
|
-
// must actually live there - no fallback, and the scope is verified once
|
|
25
|
-
// more in case the API resolves loosely again.
|
|
26
|
-
const resolveEnvironmentId = async (client, workspace, identifier, options, strictProject = false) => {
|
|
27
|
-
const project = input_1.default.restApiProject(options.project, true);
|
|
28
|
-
let resolved = await client.getEnvironmentByIdentifier(workspace, identifier, project);
|
|
29
|
-
if (!resolved.environment_id && project && !strictProject) {
|
|
30
|
-
resolved = await client.getEnvironmentByIdentifier(workspace, identifier);
|
|
31
|
-
}
|
|
32
|
-
// A nonexistent project is rejected by the API client
|
|
33
|
-
// (getResourceByIdentifier); here only the environment itself can miss.
|
|
34
|
-
if (!resolved.environment_id) {
|
|
35
|
-
output_1.default.exitError(texts_1.ERR_ENVIRONMENT_NOT_FOUND);
|
|
36
|
-
}
|
|
37
|
-
if (strictProject && options.project) {
|
|
38
|
-
const environment = await client.getEnvironment(workspace, resolved.environment_id);
|
|
39
|
-
// a workspace environment carries no project, so this also fails the
|
|
40
|
-
// workspace-fallback case
|
|
41
|
-
if (environment.project?.name !== resolved.project_identifier) {
|
|
42
|
-
output_1.default.exitError(texts_1.ERR_ENVIRONMENT_NOT_FOUND);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return resolved.environment_id;
|
|
46
|
-
};
|
|
47
|
-
exports.resolveEnvironmentId = resolveEnvironmentId;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const utils_1 = require("../../utils");
|
|
7
|
-
const texts_1 = require("../../texts");
|
|
8
|
-
const input_1 = __importDefault(require("../../input"));
|
|
9
|
-
const output_1 = __importDefault(require("../../output"));
|
|
10
|
-
const commandPackageCreate = (0, utils_1.newCommand)('create', texts_1.DESC_COMMAND_PACKAGE_CREATE);
|
|
11
|
-
commandPackageCreate.alias('add');
|
|
12
|
-
commandPackageCreate.option('-i, --identifier <identifier>', texts_1.OPT_COMMAND_PACKAGE_CREATE_IDENTIFIER);
|
|
13
|
-
commandPackageCreate.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
14
|
-
commandPackageCreate.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
15
|
-
commandPackageCreate.option('-t, --type <type>', texts_1.OPT_COMMAND_PACKAGE_TYPE, utils_1.PACKAGE_TYPE.FILE);
|
|
16
|
-
commandPackageCreate.option('-b, --buddy', texts_1.OPTION_HTTP_AUTH_BUDDY);
|
|
17
|
-
commandPackageCreate.option('-a, --auth <user:pass>', texts_1.OPTION_HTTP_AUTH);
|
|
18
|
-
commandPackageCreate.argument('[name]', texts_1.OPT_COMMAND_PACKAGE_NAME);
|
|
19
|
-
commandPackageCreate.addHelpText('after', texts_1.EXAMPLE_PACKAGE_CREATE);
|
|
20
|
-
commandPackageCreate.action(async (name, options) => {
|
|
21
|
-
const humanId = require('human-id').default;
|
|
22
|
-
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
23
|
-
const project = input_1.default.restApiProject(options.project, true);
|
|
24
|
-
const client = input_1.default.restApiTokenClient();
|
|
25
|
-
const type = input_1.default.packageType(options.type);
|
|
26
|
-
const scope = input_1.default.packageScope(project);
|
|
27
|
-
if (!name) {
|
|
28
|
-
if (options.identifier)
|
|
29
|
-
name = options.identifier;
|
|
30
|
-
else
|
|
31
|
-
name = humanId({ separator: '-', capitalize: false });
|
|
32
|
-
}
|
|
33
|
-
const data = {
|
|
34
|
-
name,
|
|
35
|
-
type,
|
|
36
|
-
scope,
|
|
37
|
-
authorization: {
|
|
38
|
-
type: utils_1.PACKAGE_AUTH_TYPE.NONE,
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
if (project) {
|
|
42
|
-
data.project = {
|
|
43
|
-
name: project,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
if (options.identifier)
|
|
47
|
-
data.identifier = options.identifier;
|
|
48
|
-
if (options.auth) {
|
|
49
|
-
const { password, login } = input_1.default.auth(options.auth);
|
|
50
|
-
data.authorization = {
|
|
51
|
-
type: utils_1.PACKAGE_AUTH_TYPE.BASIC,
|
|
52
|
-
user: login,
|
|
53
|
-
password,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
else if (options.buddy) {
|
|
57
|
-
data.authorization = {
|
|
58
|
-
type: utils_1.PACKAGE_AUTH_TYPE.BUDDY,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
const result = await client.createPackage(workspace, data);
|
|
62
|
-
output_1.default.exitSuccess((0, texts_1.TXT_PACKAGE_CREATED)(client.baseUrl, workspace, result));
|
|
63
|
-
});
|
|
64
|
-
exports.default = commandPackageCreate;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const utils_1 = require("../../utils");
|
|
7
|
-
const texts_1 = require("../../texts");
|
|
8
|
-
const input_1 = __importDefault(require("../../input"));
|
|
9
|
-
const output_1 = __importDefault(require("../../output"));
|
|
10
|
-
const commandPackageDelete = (0, utils_1.newCommand)('delete', texts_1.DESC_COMMAND_PACKAGE_DELETE);
|
|
11
|
-
commandPackageDelete.alias('rm');
|
|
12
|
-
commandPackageDelete.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
13
|
-
commandPackageDelete.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
14
|
-
commandPackageDelete.option('-f, --force', texts_1.OPTION_CONFIRM_FORCE);
|
|
15
|
-
commandPackageDelete.argument('<identifier>', texts_1.OPT_COMMAND_PACKAGE_IDENTIFIER);
|
|
16
|
-
commandPackageDelete.addHelpText('after', texts_1.EXAMPLE_PACKAGE_DELETE);
|
|
17
|
-
commandPackageDelete.action(async (identifier, options) => {
|
|
18
|
-
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
19
|
-
const project = input_1.default.restApiProject(options.project);
|
|
20
|
-
const client = input_1.default.restApiTokenClient();
|
|
21
|
-
const data = await client.getPackageVersionByIdentifier(workspace, project, identifier);
|
|
22
|
-
if (!data || !data.domain) {
|
|
23
|
-
output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
|
|
24
|
-
}
|
|
25
|
-
if (!data.pkg_id) {
|
|
26
|
-
output_1.default.exitError(texts_1.ERR_PACKAGE_NOT_FOUND);
|
|
27
|
-
}
|
|
28
|
-
const confirmed = options.force ||
|
|
29
|
-
(await output_1.default.confirm((0, texts_1.TXT_PACKAGE_DELETE_CONFIRM)(identifier)));
|
|
30
|
-
if (confirmed) {
|
|
31
|
-
await client.deletePackage(workspace, data.pkg_id);
|
|
32
|
-
output_1.default.exitSuccess(texts_1.TXT_PACKAGE_DELETED);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
output_1.default.exitNormal();
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
exports.default = commandPackageDelete;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const utils_1 = require("../../../utils");
|
|
7
|
-
const texts_1 = require("../../../texts");
|
|
8
|
-
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
-
const input_1 = __importDefault(require("../../../input"));
|
|
10
|
-
const commandPackageDockerLogin = (0, utils_1.newCommand)('login', texts_1.DESC_COMMAND_PACKAGE_DOCKER_LOGIN);
|
|
11
|
-
commandPackageDockerLogin.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
|
|
12
|
-
commandPackageDockerLogin.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
|
|
13
|
-
commandPackageDockerLogin.option('--region <region>', texts_1.OPTION_REST_API_REGION);
|
|
14
|
-
commandPackageDockerLogin.action(async (options) => {
|
|
15
|
-
const client = input_1.default.restApiTokenClient(false, options.api, options.region, options.token);
|
|
16
|
-
await client.getInvoker();
|
|
17
|
-
const host = (0, utils_1.getDockerRegistryHostByApiBaseUrl)(client.baseUrl);
|
|
18
|
-
const output = await (0, utils_1.execLocally)(`docker login ${host} -u buddy -p "${client.token}"`);
|
|
19
|
-
if (/Login\sSucceeded/gi.test(output)) {
|
|
20
|
-
output_1.default.exitSuccess(texts_1.TXT_PACKAGE_DOCKER_LOGIN_SUCCESS);
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
output_1.default.exitError(texts_1.TXT_PACKAGE_DOCKER_LOGIN_FAILED);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
exports.default = commandPackageDockerLogin;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const utils_1 = require("../../utils");
|
|
7
|
-
const texts_1 = require("../../texts");
|
|
8
|
-
const login_1 = __importDefault(require("./docker/login"));
|
|
9
|
-
const commandPackageDocker = (0, utils_1.newCommand)('docker', texts_1.DESC_COMMAND_PACKAGE_DOCKER_LOGIN);
|
|
10
|
-
commandPackageDocker.addCommand(login_1.default);
|
|
11
|
-
exports.default = commandPackageDocker;
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const utils_1 = require("../../utils");
|
|
7
|
-
const texts_1 = require("../../texts");
|
|
8
|
-
const input_1 = __importDefault(require("../../input"));
|
|
9
|
-
const output_1 = __importDefault(require("../../output"));
|
|
10
|
-
const logger_1 = __importDefault(require("../../logger"));
|
|
11
|
-
const path_1 = require("path");
|
|
12
|
-
const fs_1 = __importDefault(require("fs"));
|
|
13
|
-
const promises_1 = __importDefault(require("node:stream/promises"));
|
|
14
|
-
const commandPackageDownload = (0, utils_1.newCommand)('download', texts_1.DESC_COMMAND_PACKAGE_DOWNLOAD);
|
|
15
|
-
commandPackageDownload.alias('dd');
|
|
16
|
-
commandPackageDownload.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
17
|
-
commandPackageDownload.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
18
|
-
commandPackageDownload.option('-m, --merge', texts_1.OPTION_PACKAGE_DOWNLOAD_MERGE);
|
|
19
|
-
commandPackageDownload.option('-r, --replace', texts_1.OPTION_PACKAGE_DOWNLOAD_REPLACE);
|
|
20
|
-
commandPackageDownload.argument('<identifier>', texts_1.OPTION_PACKAGE_ID);
|
|
21
|
-
commandPackageDownload.argument('<directory>', texts_1.OPTION_PACKAGE_DOWNLOAD_PATH);
|
|
22
|
-
commandPackageDownload.addHelpText('after', texts_1.EXAMPLE_PACKAGE_DOWNLOAD);
|
|
23
|
-
commandPackageDownload.action(async (id, path, options) => {
|
|
24
|
-
const { v4 } = require('uuid');
|
|
25
|
-
const ArchiverExtract = require('../../unzipper').default;
|
|
26
|
-
const { UNZIPPER_FORMAT } = require('../../unzipper');
|
|
27
|
-
const client = input_1.default.restApiTokenClient();
|
|
28
|
-
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
29
|
-
const project = input_1.default.restApiProject(options.project, true);
|
|
30
|
-
// eslint-disable-next-line prefer-const
|
|
31
|
-
let { identifier, version } = input_1.default.packageSplitIdentifier(id);
|
|
32
|
-
const data = await client.getPackageVersionByIdentifier(workspace, project, identifier, version);
|
|
33
|
-
if (!data || !data.domain) {
|
|
34
|
-
output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
|
|
35
|
-
}
|
|
36
|
-
if (project && !data.project_identifier) {
|
|
37
|
-
output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
|
|
38
|
-
}
|
|
39
|
-
const packageId = data.pkg_id;
|
|
40
|
-
if (!packageId) {
|
|
41
|
-
output_1.default.exitError(texts_1.ERR_PACKAGE_DOWNLOAD_NOT_FOUND);
|
|
42
|
-
}
|
|
43
|
-
let versionId = data.pkg_version_id;
|
|
44
|
-
if (version && !versionId) {
|
|
45
|
-
output_1.default.exitError(texts_1.ERR_PACKAGE_VERSION_NOT_FOUND);
|
|
46
|
-
}
|
|
47
|
-
if (!version || !versionId) {
|
|
48
|
-
const v = await client.getPackageLatest(workspace, packageId);
|
|
49
|
-
if (!v) {
|
|
50
|
-
output_1.default.exitError(texts_1.ERR_PACKAGE_VERSION_NOT_FOUND);
|
|
51
|
-
}
|
|
52
|
-
version = v.version;
|
|
53
|
-
versionId = v.id;
|
|
54
|
-
}
|
|
55
|
-
const dirPath = (0, path_1.resolve)(path);
|
|
56
|
-
const exists = fs_1.default.existsSync(dirPath);
|
|
57
|
-
if (!exists) {
|
|
58
|
-
try {
|
|
59
|
-
fs_1.default.mkdirSync(dirPath, {
|
|
60
|
-
recursive: true,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
catch (err) {
|
|
64
|
-
logger_1.default.error(err);
|
|
65
|
-
output_1.default.exitError((0, texts_1.ERR_PACKAGE_DOWNLOAD_MKDIR)(dirPath));
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
else if (options.replace) {
|
|
69
|
-
try {
|
|
70
|
-
fs_1.default.rmSync(dirPath, {
|
|
71
|
-
recursive: true,
|
|
72
|
-
force: true,
|
|
73
|
-
});
|
|
74
|
-
fs_1.default.mkdirSync(dirPath, {
|
|
75
|
-
recursive: true,
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
catch (err) {
|
|
79
|
-
logger_1.default.error(err);
|
|
80
|
-
output_1.default.exitError((0, texts_1.ERR_PACKAGE_DOWNLOAD_REPLACE)(dirPath));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
try {
|
|
84
|
-
const stat = fs_1.default.statSync(dirPath);
|
|
85
|
-
if (!stat.isDirectory()) {
|
|
86
|
-
output_1.default.exitError((0, texts_1.ERR_PACKAGE_DOWNLOAD_IS_FILE)(dirPath));
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
catch (err) {
|
|
90
|
-
logger_1.default.error(err);
|
|
91
|
-
output_1.default.exitError(texts_1.ERR_SWW);
|
|
92
|
-
}
|
|
93
|
-
let empty = true;
|
|
94
|
-
try {
|
|
95
|
-
const entries = fs_1.default.readdirSync(dirPath);
|
|
96
|
-
empty = !entries.length;
|
|
97
|
-
}
|
|
98
|
-
catch (err) {
|
|
99
|
-
logger_1.default.error(err);
|
|
100
|
-
output_1.default.exitError((0, texts_1.ERR_PACKAGE_DOWNLOAD_READDIR)(dirPath));
|
|
101
|
-
}
|
|
102
|
-
if (!empty && !options.merge) {
|
|
103
|
-
output_1.default.exitError((0, texts_1.ERR_PACKAGE_DOWNLOAD_NOT_EMPTY_DIR)(dirPath));
|
|
104
|
-
}
|
|
105
|
-
const zipPath = (0, path_1.join)((0, utils_1.getHomeDirectory)(), `${v4()}.zip`);
|
|
106
|
-
const clearZip = () => {
|
|
107
|
-
try {
|
|
108
|
-
fs_1.default.rmSync(zipPath);
|
|
109
|
-
}
|
|
110
|
-
catch {
|
|
111
|
-
// do nothing
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
output_1.default.normal(texts_1.TXT_PACKAGE_DOWNLOADING_ZIP);
|
|
115
|
-
const body = await client.downloadPackageVersion(workspace, packageId, versionId);
|
|
116
|
-
try {
|
|
117
|
-
await promises_1.default.pipeline(body, fs_1.default.createWriteStream(zipPath));
|
|
118
|
-
output_1.default.clearPreviousLine();
|
|
119
|
-
output_1.default.normal(texts_1.TXT_PACKAGE_DOWNLOADED_ZIP);
|
|
120
|
-
output_1.default.normal(texts_1.TXT_PACKAGE_UNZIPPING);
|
|
121
|
-
let count = 0;
|
|
122
|
-
await ArchiverExtract.extract(UNZIPPER_FORMAT.ZIP, zipPath, dirPath, async () => {
|
|
123
|
-
count += 1;
|
|
124
|
-
output_1.default.clearPreviousLine();
|
|
125
|
-
output_1.default.normal((0, texts_1.TXT_PACKAGE_UNZIPPING_COUNT)(count));
|
|
126
|
-
});
|
|
127
|
-
clearZip();
|
|
128
|
-
output_1.default.clearPreviousLine();
|
|
129
|
-
output_1.default.normal(texts_1.TXT_PACKAGE_UNZIPPED);
|
|
130
|
-
}
|
|
131
|
-
catch (err) {
|
|
132
|
-
logger_1.default.error(err);
|
|
133
|
-
clearZip();
|
|
134
|
-
output_1.default.exitError(texts_1.ERR_SWW);
|
|
135
|
-
}
|
|
136
|
-
output_1.default.exitSuccess((0, texts_1.TXT_PACKAGE_DOWNLOADED)(version, dirPath));
|
|
137
|
-
});
|
|
138
|
-
exports.default = commandPackageDownload;
|