@newly/cli 0.2.139 → 0.2.141
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/README.md +2 -2
- package/dist/commands/ai.js +50 -0
- package/dist/index.js +2 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -175,7 +175,7 @@ For CI, or a dev control plane where no browser is at hand, skip it entirely
|
|
|
175
175
|
|
|
176
176
|
```bash
|
|
177
177
|
newly-dev login \
|
|
178
|
-
--api-url https://
|
|
178
|
+
--api-url https://api-dev.newly.app \
|
|
179
179
|
--token <nl_live_…> \
|
|
180
180
|
--expires-in 86400
|
|
181
181
|
```
|
|
@@ -196,7 +196,7 @@ newly-dev login \
|
|
|
196
196
|
|
|
197
197
|
```bash
|
|
198
198
|
# 1. Log the dev CLI in against the dev control plane.
|
|
199
|
-
NEWLY_AUTH_API_URL=https://
|
|
199
|
+
NEWLY_AUTH_API_URL=https://api-dev.newly.app newly-dev login --email
|
|
200
200
|
|
|
201
201
|
# 2. Use newly-dev the same way as newly.
|
|
202
202
|
newly-dev create my-test
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ApiClient, friendlyApiError } from "../api.js";
|
|
2
|
+
import { requireCredentials, resolveProject } from "../config.js";
|
|
3
|
+
export function registerAi(program) {
|
|
4
|
+
const ai = program
|
|
5
|
+
.command("ai")
|
|
6
|
+
.description("Manage runtime AI for a Newly Backend");
|
|
7
|
+
const client = () => {
|
|
8
|
+
const credentials = requireCredentials();
|
|
9
|
+
return new ApiClient(credentials.apiUrl, credentials.token);
|
|
10
|
+
};
|
|
11
|
+
const path = (project, env) => {
|
|
12
|
+
if (!["dev", "prod"].includes(env))
|
|
13
|
+
throw new Error("--env must be dev or prod");
|
|
14
|
+
return `/projects/${encodeURIComponent(resolveProject(process.cwd(), project))}/ai/${env}`;
|
|
15
|
+
};
|
|
16
|
+
ai.command("status")
|
|
17
|
+
.option("--project <id>")
|
|
18
|
+
.option("--env <environment>", "Backend environment", "dev")
|
|
19
|
+
.action(async (opts) => {
|
|
20
|
+
try {
|
|
21
|
+
console.log(JSON.stringify(await client().get(path(opts.project, opts.env)), null, 2));
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
console.error(friendlyApiError(error));
|
|
25
|
+
process.exitCode = 1;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
ai.command("enable")
|
|
29
|
+
.requiredOption("--models <ids>", "Comma-separated model IDs from ai status")
|
|
30
|
+
.option("--project <id>")
|
|
31
|
+
.option("--env <environment>", "Backend environment", "dev")
|
|
32
|
+
.action(async (opts) => {
|
|
33
|
+
try {
|
|
34
|
+
const api = client();
|
|
35
|
+
const url = path(opts.project, opts.env);
|
|
36
|
+
const models = String(opts.models)
|
|
37
|
+
.split(",")
|
|
38
|
+
.map((s) => s.trim())
|
|
39
|
+
.filter(Boolean);
|
|
40
|
+
await api.put(url, { enabled: true, models });
|
|
41
|
+
console.log("App AI enabled. Run newly deploy --env " +
|
|
42
|
+
opts.env +
|
|
43
|
+
" to connect backend access.");
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
console.error(friendlyApiError(error));
|
|
47
|
+
process.exitCode = 1;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { registerAi } from "./commands/ai.js";
|
|
2
3
|
import { Command } from 'commander';
|
|
3
4
|
import { registerLogin } from './commands/login.js';
|
|
4
5
|
import { registerStatus } from './commands/status.js';
|
|
@@ -33,6 +34,7 @@ registerCreate(program);
|
|
|
33
34
|
registerInit(program);
|
|
34
35
|
registerPull(program);
|
|
35
36
|
registerDeploy(program);
|
|
37
|
+
registerAi(program);
|
|
36
38
|
registerMisc(program);
|
|
37
39
|
registerStack(program);
|
|
38
40
|
registerCreds(program);
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CLI_VERSION = '0.2.
|
|
1
|
+
export const CLI_VERSION = '0.2.141';
|