alpic 0.0.0-dev.dc08ff3 → 0.0.0-dev.dc158a8
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/dist/__tests__/deploy.e2e.test.d.ts +1 -0
- package/dist/__tests__/deploy.e2e.test.js +267 -0
- package/dist/__tests__/deploy.e2e.test.js.map +1 -0
- package/dist/__tests__/fixtures/demo-project/index.d.ts +1 -0
- package/dist/__tests__/fixtures/demo-project/index.js +4 -0
- package/dist/__tests__/fixtures/demo-project/index.js.map +1 -0
- package/dist/__tests__/mock-server.d.ts +22 -0
- package/dist/__tests__/mock-server.js +312 -0
- package/dist/__tests__/mock-server.js.map +1 -0
- package/dist/__tests__/utils.d.ts +29 -0
- package/dist/__tests__/utils.js +88 -0
- package/dist/__tests__/utils.js.map +1 -0
- package/dist/api.d.ts +3 -16
- package/dist/api.js +11 -61
- package/dist/api.js.map +1 -1
- package/dist/commands/deploy.js +4 -4
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/telemetry/disable.d.ts +5 -0
- package/dist/commands/telemetry/disable.js +14 -0
- package/dist/commands/telemetry/disable.js.map +1 -0
- package/dist/commands/telemetry/enable.d.ts +5 -0
- package/dist/commands/telemetry/enable.js +13 -0
- package/dist/commands/telemetry/enable.js.map +1 -0
- package/dist/commands/telemetry/status.d.ts +5 -0
- package/dist/commands/telemetry/status.js +19 -0
- package/dist/commands/telemetry/status.js.map +1 -0
- package/dist/lib/deployment.d.ts +13 -3
- package/dist/lib/deployment.js +3 -2
- package/dist/lib/deployment.js.map +1 -1
- package/dist/lib/global-config.d.ts +9 -0
- package/dist/lib/global-config.js +48 -0
- package/dist/lib/global-config.js.map +1 -0
- package/dist/lib/project.d.ts +58 -3
- package/dist/lib/project.js +3 -3
- package/dist/lib/project.js.map +1 -1
- package/dist/lib/telemetry.d.ts +7 -0
- package/dist/lib/telemetry.js +66 -0
- package/dist/lib/telemetry.js.map +1 -0
- package/dist/posthog.d.ts +3 -0
- package/dist/posthog.js +10 -0
- package/dist/posthog.js.map +1 -0
- package/dist/types.d.ts +0 -54
- package/package.json +34 -5
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
type Expectable = string | RegExp;
|
|
2
|
+
export type CliSessionOptions = {
|
|
3
|
+
cwd?: string;
|
|
4
|
+
env?: Record<string, string | undefined>;
|
|
5
|
+
cols?: number;
|
|
6
|
+
rows?: number;
|
|
7
|
+
timeoutMs?: number;
|
|
8
|
+
};
|
|
9
|
+
export type CliController = {
|
|
10
|
+
/** Wait until stdout/stderr contains a string or matches a regex */
|
|
11
|
+
expect: (pattern: Expectable, opts?: {
|
|
12
|
+
timeoutMs?: number;
|
|
13
|
+
}) => Promise<void>;
|
|
14
|
+
/** Send a line (adds newline) */
|
|
15
|
+
send: (line: string) => Promise<void>;
|
|
16
|
+
/** Send raw data (no newline) */
|
|
17
|
+
write: (data: string) => void;
|
|
18
|
+
/** Current accumulated output */
|
|
19
|
+
output: () => string;
|
|
20
|
+
/** Clear accumulated output (handy between phases) */
|
|
21
|
+
clear: () => void;
|
|
22
|
+
/** End session (SIGTERM) */
|
|
23
|
+
stop: () => void;
|
|
24
|
+
};
|
|
25
|
+
export declare function cliSession(cmd: string, args: string[], options: CliSessionOptions, fn: (cli: CliController) => Promise<void>): Promise<{
|
|
26
|
+
exitCode: number | null;
|
|
27
|
+
output: string;
|
|
28
|
+
}>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// cliSession.ts
|
|
2
|
+
import pty from "node-pty";
|
|
3
|
+
import { expect } from "vitest";
|
|
4
|
+
export async function cliSession(cmd, args, options, fn) {
|
|
5
|
+
const { cwd, env, cols = 100, rows = 30, timeoutMs = 8000 } = options;
|
|
6
|
+
const mergedEnv = {
|
|
7
|
+
...process.env,
|
|
8
|
+
NO_COLOR: "1",
|
|
9
|
+
...Object.fromEntries(Object.entries(env ?? {}).filter(([, v]) => v !== undefined)),
|
|
10
|
+
};
|
|
11
|
+
for (const [k, v] of Object.entries(mergedEnv)) {
|
|
12
|
+
if (typeof v !== "string") {
|
|
13
|
+
console.error("[pty] bad env entry:", k, v, typeof v);
|
|
14
|
+
throw new Error(`env value for ${k} is not a string`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const term = pty.spawn(cmd, args, {
|
|
18
|
+
cwd,
|
|
19
|
+
env: mergedEnv,
|
|
20
|
+
name: "xterm-256color",
|
|
21
|
+
cols,
|
|
22
|
+
rows,
|
|
23
|
+
});
|
|
24
|
+
let buf = "";
|
|
25
|
+
const append = (data) => {
|
|
26
|
+
buf += data;
|
|
27
|
+
};
|
|
28
|
+
term.onData(append);
|
|
29
|
+
let exitCode = null;
|
|
30
|
+
const exitPromise = new Promise((resolve) => {
|
|
31
|
+
term.onExit((e) => {
|
|
32
|
+
exitCode = e.exitCode ?? null;
|
|
33
|
+
resolve();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
const controller = {
|
|
37
|
+
expect: (pattern, opts) => waitFor(() => matches(buf, pattern), opts?.timeoutMs ?? timeoutMs, () => buf, pattern),
|
|
38
|
+
send: async (line) => {
|
|
39
|
+
term.write(line + "\r");
|
|
40
|
+
},
|
|
41
|
+
write: (data) => term.write(data),
|
|
42
|
+
output: () => buf,
|
|
43
|
+
clear: () => {
|
|
44
|
+
buf = "";
|
|
45
|
+
},
|
|
46
|
+
stop: () => {
|
|
47
|
+
try {
|
|
48
|
+
term.kill();
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// ignore
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
try {
|
|
56
|
+
await fn(controller);
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
controller.stop();
|
|
60
|
+
await Promise.race([exitPromise, sleep(200)]);
|
|
61
|
+
}
|
|
62
|
+
return { exitCode, output: buf };
|
|
63
|
+
}
|
|
64
|
+
function matches(text, pattern) {
|
|
65
|
+
if (typeof pattern === "string")
|
|
66
|
+
return text.includes(pattern);
|
|
67
|
+
return pattern.test(text);
|
|
68
|
+
}
|
|
69
|
+
async function waitFor(predicate, timeoutMs, getOutput, pattern) {
|
|
70
|
+
const start = Date.now();
|
|
71
|
+
while (true) {
|
|
72
|
+
if (predicate())
|
|
73
|
+
return;
|
|
74
|
+
if (Date.now() - start > timeoutMs) {
|
|
75
|
+
const out = getOutput();
|
|
76
|
+
throw new Error(`Timed out after ${timeoutMs}ms waiting for: ${patternToString(pattern)}\n\n` +
|
|
77
|
+
`--- current output ---\n${out}\n--- end output ---\n`);
|
|
78
|
+
}
|
|
79
|
+
await sleep(20);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function patternToString(p) {
|
|
83
|
+
return typeof p === "string" ? JSON.stringify(p) : `/${p.source}/${p.flags}`;
|
|
84
|
+
}
|
|
85
|
+
function sleep(ms) {
|
|
86
|
+
return new Promise((r) => setTimeout(r, ms));
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/__tests__/utils.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AA6BhC,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,GAAW,EACX,IAAc,EACd,OAA0B,EAC1B,EAAyC;IAEzC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,GAAG,GAAG,EAAE,IAAI,GAAG,EAAE,EAAE,SAAS,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAEtE,MAAM,SAAS,GAA2B;QACxC,GAAG,OAAO,CAAC,GAAG;QACd,QAAQ,EAAE,GAAG;QACb,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,MAA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AAE;YAAE,OAAO;QACxB,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,SAAS,EAAE,CAAC;YACnC,MAAM,GAAG,GAAG,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CACb,mBAAmB,SAAS,mBAAmB,eAAe,CAAC,OAAO,CAAC,MAAM;gBAC3E,2BAA2B,GAAG,wBAAwB,CACzD,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,CAAa;IACpC,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;AAC/E,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAC/C,CAAC"}
|
package/dist/api.d.ts
CHANGED
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
readonly statusCode: number;
|
|
4
|
-
constructor(message: string, statusCode: number);
|
|
5
|
-
}
|
|
1
|
+
import type { ContractRouterClient } from "@orpc/contract";
|
|
2
|
+
import { contract } from "@alpic-ai/api";
|
|
6
3
|
export declare function getFrontendBaseUrl(): string;
|
|
7
|
-
export declare const api:
|
|
8
|
-
listProjects: () => Promise<ApiProject[]>;
|
|
9
|
-
getProject: (projectId: string) => Promise<ApiProject>;
|
|
10
|
-
createProject: (input: CreateProjectInput) => Promise<ApiCreateProjectOutput>;
|
|
11
|
-
getPresignedUploadUrl: () => Promise<PresignedUploadResponse>;
|
|
12
|
-
deployEnvironment: (environmentId: string, body?: {
|
|
13
|
-
token?: string;
|
|
14
|
-
}) => Promise<ApiDeployment>;
|
|
15
|
-
getDeployment: (deploymentId: string) => Promise<ApiDeployment>;
|
|
16
|
-
getEnvironment: (environmentId: string) => Promise<ApiEnvironment>;
|
|
17
|
-
};
|
|
4
|
+
export declare const api: ContractRouterClient<typeof contract>;
|
package/dist/api.js
CHANGED
|
@@ -1,69 +1,19 @@
|
|
|
1
|
-
import {} from "
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
super(message);
|
|
6
|
-
this.statusCode = statusCode;
|
|
7
|
-
this.name = "ApiError";
|
|
8
|
-
Object.setPrototypeOf(this, ApiError.prototype);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
1
|
+
import { createORPCClient } from "@orpc/client";
|
|
2
|
+
import { ResponseValidationPlugin } from "@orpc/contract/plugins";
|
|
3
|
+
import { OpenAPILink } from "@orpc/openapi-client/fetch";
|
|
4
|
+
import { contract } from "@alpic-ai/api";
|
|
11
5
|
function getApiBaseUrl() {
|
|
12
6
|
return process.env.ALPIC_API_BASE_URL ?? "https://api.alpic.ai";
|
|
13
7
|
}
|
|
14
8
|
export function getFrontendBaseUrl() {
|
|
15
9
|
return process.env.ALPIC_FRONTEND_BASE_URL ?? "https://app.alpic.ai";
|
|
16
10
|
}
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
Authorization: `Bearer ${process.env.ALPIC_API_KEY}`,
|
|
22
|
-
...options.headers,
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
if (!res.ok) {
|
|
26
|
-
try {
|
|
27
|
-
const body = await res.json();
|
|
28
|
-
throw new ApiError(`${res.status} ${res.statusText}: ${body.message}`, res.status);
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
if (error instanceof ApiError)
|
|
32
|
-
throw error;
|
|
33
|
-
throw new ApiError(res.statusText, res.status);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return res.json();
|
|
37
|
-
};
|
|
38
|
-
export const api = {
|
|
39
|
-
listProjects: async () => {
|
|
40
|
-
return doFetch("/v1/projects", { method: "GET" });
|
|
41
|
-
},
|
|
42
|
-
getProject: async (projectId) => {
|
|
43
|
-
return doFetch(`/v1/projects/${projectId}`, { method: "GET" });
|
|
44
|
-
},
|
|
45
|
-
createProject: async (input) => {
|
|
46
|
-
return doFetch("/v1/projects", {
|
|
47
|
-
method: "POST",
|
|
48
|
-
body: JSON.stringify(input),
|
|
49
|
-
headers: { "Content-Type": "application/json" },
|
|
50
|
-
});
|
|
51
|
-
},
|
|
52
|
-
getPresignedUploadUrl: async () => {
|
|
53
|
-
return doFetch("/v1/deployments/upload", { method: "POST" });
|
|
54
|
-
},
|
|
55
|
-
deployEnvironment: async (environmentId, body) => {
|
|
56
|
-
return doFetch(`/v1/environments/${environmentId}/deploy`, {
|
|
57
|
-
method: "POST",
|
|
58
|
-
body: JSON.stringify(body ?? {}),
|
|
59
|
-
headers: { "Content-Type": "application/json" },
|
|
60
|
-
});
|
|
61
|
-
},
|
|
62
|
-
getDeployment: async (deploymentId) => {
|
|
63
|
-
return doFetch(`/v1/deployments/${deploymentId}`, { method: "GET" });
|
|
64
|
-
},
|
|
65
|
-
getEnvironment: async (environmentId) => {
|
|
66
|
-
return doFetch(`/v1/environments/${environmentId}`, { method: "GET" });
|
|
11
|
+
const link = new OpenAPILink(contract, {
|
|
12
|
+
url: getApiBaseUrl(),
|
|
13
|
+
headers: {
|
|
14
|
+
Authorization: `Bearer ${process.env.ALPIC_API_KEY}`,
|
|
67
15
|
},
|
|
68
|
-
|
|
16
|
+
plugins: [new ResponseValidationPlugin(contract)],
|
|
17
|
+
});
|
|
18
|
+
export const api = createORPCClient(link);
|
|
69
19
|
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,SAAS,aAAa;IACpB,OAAO,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,sBAAsB,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,OAAO,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,sBAAsB,CAAC;AACvE,CAAC;AAED,MAAM,IAAI,GAAG,IAAI,WAAW,CAAC,QAAQ,EAAE;IACrC,GAAG,EAAE,aAAa,EAAE;IACpB,OAAO,EAAE;QACP,aAAa,EAAE,UAAU,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE;KACrD;IACD,OAAO,EAAE,CAAC,IAAI,wBAAwB,CAAC,QAAQ,CAAC,CAAC;CAClD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,GAAG,GAA0C,gBAAgB,CAAC,IAAI,CAAC,CAAC"}
|
package/dist/commands/deploy.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as p from "@clack/prompts";
|
|
|
2
2
|
import { Args, Command } from "@oclif/core";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import { readFileSync, rmSync } from "node:fs";
|
|
5
|
-
import { api
|
|
5
|
+
import { api } from "../api.js";
|
|
6
6
|
import { createTarArchive, getFilesToPack } from "../lib/archive.js";
|
|
7
7
|
import { deployAndWait, formatElapsed } from "../lib/deployment.js";
|
|
8
8
|
import { resolveDeployDir, resolveProjectForDeploy } from "../lib/project.js";
|
|
@@ -41,14 +41,14 @@ export class Deploy extends Command {
|
|
|
41
41
|
const result = await createTarArchive(files, deployDir);
|
|
42
42
|
tmpDir = result.tmpDir;
|
|
43
43
|
const archivePath = result.archivePath;
|
|
44
|
-
const { uploadUrl, token } = await api.
|
|
44
|
+
const { uploadUrl, token } = await api.deployments.uploadArtifact.v1();
|
|
45
45
|
spinner.start("Uploading source...");
|
|
46
46
|
const buffer = readFileSync(archivePath);
|
|
47
47
|
await uploadToPresignedUrl(uploadUrl, buffer);
|
|
48
48
|
spinner.stop("Upload complete");
|
|
49
49
|
spinner.start("Triggering deployment...");
|
|
50
50
|
const deployStartedAt = Date.now();
|
|
51
|
-
const initialDeployment = await api.
|
|
51
|
+
const initialDeployment = await api.environments.deploy.v1({ environmentId: config.environmentId, token });
|
|
52
52
|
spinner.stop("Deployment started");
|
|
53
53
|
const { deployment, elapsedMs } = await deployAndWait({
|
|
54
54
|
initial: initialDeployment,
|
|
@@ -60,7 +60,7 @@ export class Deploy extends Command {
|
|
|
60
60
|
if (deployment.status !== "deployed") {
|
|
61
61
|
throw new Error("Deployment failed");
|
|
62
62
|
}
|
|
63
|
-
const environment = await api.
|
|
63
|
+
const environment = await api.environments.get.v1({ environmentId: config.environmentId });
|
|
64
64
|
const urls = environment.mcpServerUrl ? [environment.mcpServerUrl] : environment.domains;
|
|
65
65
|
p.box([...urls.map((url) => chalk.bold(`🔗 ${url}`)), "", `Completed in ${elapsedStr}`].join("\n"), "Deployment summary:", {
|
|
66
66
|
contentAlign: "center",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAE/C,OAAO,EAAE,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],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,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,CAAC,CAAC,MAAM,CAAC,UAAU,OAAO,EAAE,CAAC,CAAC;YAC9B,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACf,CAAC;gBAAS,CAAC;YACT,IAAI,MAAM,EAAE,CAAC;gBACX,MAAM,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;IACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { setEnabled } from "../../lib/telemetry.js";
|
|
4
|
+
export default class TelemetryDisable extends Command {
|
|
5
|
+
static description = "Disable Alpic telemetry on this machine";
|
|
6
|
+
async run() {
|
|
7
|
+
await this.parse(TelemetryDisable);
|
|
8
|
+
setEnabled(false);
|
|
9
|
+
console.log(chalk.yellow("✓"), "Telemetry has been", chalk.yellow.bold("disabled"));
|
|
10
|
+
console.log(chalk.gray("Config saved to ~/.alpic/config.json"));
|
|
11
|
+
console.log(chalk.gray("Alpic never collects Personally Identifiable Information (PII). If you'd like to help us improve Alpic by allowing anonymous CLI usage data, please re-enable telemetry with: alpic telemetry enable"));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=disable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disable.js","sourceRoot":"","sources":["../../../src/commands/telemetry/disable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,OAAO;IACnD,MAAM,CAAU,WAAW,GAAG,yCAAyC,CAAC;IAExE,KAAK,CAAC,GAAG;QACP,MAAM,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACnC,UAAU,CAAC,KAAK,CAAC,CAAC;QAClB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,oBAAoB,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QACpF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC,CAAC;QAChE,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,IAAI,CACR,sMAAsM,CACvM,CACF,CAAC;IACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { setEnabled } from "../../lib/telemetry.js";
|
|
4
|
+
export default class TelemetryEnable extends Command {
|
|
5
|
+
static description = "Enable Alpic telemetry on this machine";
|
|
6
|
+
async run() {
|
|
7
|
+
await this.parse(TelemetryEnable);
|
|
8
|
+
setEnabled(true);
|
|
9
|
+
console.log(chalk.green("✓"), "Telemetry has been", chalk.green.bold("enabled"));
|
|
10
|
+
console.log(chalk.gray("Config saved to ~/.alpic/config.json"));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=enable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enable.js","sourceRoot":"","sources":["../../../src/commands/telemetry/enable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,OAAO;IAClD,MAAM,CAAU,WAAW,GAAG,wCAAwC,CAAC;IAEvE,KAAK,CAAC,GAAG;QACP,MAAM,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAClC,UAAU,CAAC,IAAI,CAAC,CAAC;QACjB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,oBAAoB,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;QACjF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC,CAAC;IAClE,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { getMachineId, isEnabled } from "../../lib/telemetry.js";
|
|
4
|
+
export default class TelemetryStatus extends Command {
|
|
5
|
+
static description = "Show Alpic telemetry settings for this machine";
|
|
6
|
+
async run() {
|
|
7
|
+
await this.parse(TelemetryStatus);
|
|
8
|
+
const enabled = isEnabled();
|
|
9
|
+
console.log(chalk.bold.underline("Alpic Telemetry"));
|
|
10
|
+
console.log();
|
|
11
|
+
console.log("Status:", enabled ? chalk.green.bold("Enabled") : chalk.yellow.bold("Disabled"));
|
|
12
|
+
console.log(chalk.gray("Machine ID:"), getMachineId());
|
|
13
|
+
console.log();
|
|
14
|
+
console.log(chalk.gray("To opt out, run: alpic telemetry disable"));
|
|
15
|
+
console.log(chalk.gray("Or set: ALPIC_TELEMETRY_DISABLED=1"));
|
|
16
|
+
console.log(chalk.gray("Debug mode: ALPIC_TELEMETRY_DEBUG=1"));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/commands/telemetry/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEjE,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,OAAO;IAClD,MAAM,CAAU,WAAW,GAAG,gDAAgD,CAAC;IAE/E,KAAK,CAAC,GAAG;QACP,MAAM,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAClC,MAAM,OAAO,GAAG,SAAS,EAAE,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAAC;QACrD,OAAO,CAAC,GAAG,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QAC9F,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC;QACvD,OAAO,CAAC,GAAG,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAC,CAAC;QACpE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC,CAAC;QAC9D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC,CAAC;IACjE,CAAC"}
|
package/dist/lib/deployment.d.ts
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RouterOutput } from "@alpic-ai/api";
|
|
2
2
|
export declare function formatElapsed(ms: number): string;
|
|
3
3
|
export declare function deployAndWait({ initial, startedAt, teamId, projectId, }: {
|
|
4
|
-
initial:
|
|
4
|
+
initial: RouterOutput["deployments"]["get"]["v1"];
|
|
5
5
|
startedAt: number;
|
|
6
6
|
teamId: string;
|
|
7
7
|
projectId: string;
|
|
8
8
|
}): Promise<{
|
|
9
|
-
deployment:
|
|
9
|
+
deployment: {
|
|
10
|
+
id: string;
|
|
11
|
+
status: "ongoing" | "deployed" | "failed" | "canceled";
|
|
12
|
+
sourceRef: string | null;
|
|
13
|
+
sourceCommitId: string | null;
|
|
14
|
+
sourceCommitMessage: string | null;
|
|
15
|
+
authorUsername: string | null;
|
|
16
|
+
authorAvatarUrl: string | null;
|
|
17
|
+
startedAt: Date | null;
|
|
18
|
+
completedAt: Date | null;
|
|
19
|
+
};
|
|
10
20
|
elapsedMs: number;
|
|
11
21
|
}>;
|
package/dist/lib/deployment.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as p from "@clack/prompts";
|
|
2
2
|
import chalk from "chalk";
|
|
3
3
|
import { api, getFrontendBaseUrl } from "../api.js";
|
|
4
|
+
const POLL_INTERVAL = Number(process.env.ALPIC_POLL_INTERVAL) || 10_000;
|
|
4
5
|
export function formatElapsed(ms) {
|
|
5
6
|
const totalSeconds = Math.floor(ms / 1000);
|
|
6
7
|
const minutes = Math.floor(totalSeconds / 60);
|
|
@@ -24,8 +25,8 @@ export async function deployAndWait({ initial, startedAt, teamId, projectId, })
|
|
|
24
25
|
if (elapsedMs >= timeoutMs) {
|
|
25
26
|
throw new Error(`Deployment aborted after 15 minutes. View status: ${deploymentPageUrl}`);
|
|
26
27
|
}
|
|
27
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
28
|
-
deployment = await api.
|
|
28
|
+
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL));
|
|
29
|
+
deployment = await api.deployments.get.v1({ deploymentId: deployment.id });
|
|
29
30
|
}
|
|
30
31
|
return { deployment, elapsedMs: Date.now() - startedAt };
|
|
31
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deployment.js","sourceRoot":"","sources":["../../src/lib/deployment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"deployment.js","sourceRoot":"","sources":["../../src/lib/deployment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,GAAG,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEpD,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,MAAM,CAAC;AAExE,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;IAC3C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,EAAE,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAG,YAAY,GAAG,EAAE,CAAC;IAClC,OAAO,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,KAAK,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,GAAG,CAAC;AACjE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,EAClC,OAAO,EACP,SAAS,EACT,MAAM,EACN,SAAS,GAMV;IACC,MAAM,OAAO,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;IAE5B,OAAO,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAExC,MAAM,iBAAiB,GAAG,GAAG,kBAAkB,EAAE,SAAS,MAAM,YAAY,SAAS,gBAAgB,OAAO,CAAC,EAAE,EAAE,CAAC;IAClH,CAAC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AC;QACtB,aAAa,CAAC,eAAe,CAAC,CAAC;IACjC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const GLOBAL_CONFIG_FILE: string;
|
|
2
|
+
export interface GlobalConfig {
|
|
3
|
+
machineId: string;
|
|
4
|
+
telemetry: {
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export declare function getGlobalConfig(): GlobalConfig;
|
|
9
|
+
export declare function saveGlobalConfig(config: GlobalConfig): void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
const GLOBAL_CONFIG_DIR = join(homedir(), ".alpic");
|
|
6
|
+
export const GLOBAL_CONFIG_FILE = join(GLOBAL_CONFIG_DIR, "config.json");
|
|
7
|
+
function readJsonFile(filePath) {
|
|
8
|
+
try {
|
|
9
|
+
if (existsSync(filePath)) {
|
|
10
|
+
const content = readFileSync(filePath, "utf-8");
|
|
11
|
+
return JSON.parse(content);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
// Ignore errors reading config
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
function writeJsonFile(filePath, data) {
|
|
20
|
+
try {
|
|
21
|
+
const dir = join(filePath, "..");
|
|
22
|
+
if (!existsSync(dir)) {
|
|
23
|
+
mkdirSync(dir, { recursive: true });
|
|
24
|
+
}
|
|
25
|
+
writeFileSync(filePath, JSON.stringify(data, null, 2), "utf-8");
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
// Ignore errors writing config
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function getGlobalConfig() {
|
|
32
|
+
const existing = readJsonFile(GLOBAL_CONFIG_FILE);
|
|
33
|
+
if (existing?.machineId && existing?.telemetry !== undefined) {
|
|
34
|
+
return existing;
|
|
35
|
+
}
|
|
36
|
+
const config = {
|
|
37
|
+
machineId: existing?.machineId ?? crypto.randomUUID(),
|
|
38
|
+
telemetry: {
|
|
39
|
+
enabled: existing?.telemetry?.enabled ?? true,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
writeJsonFile(GLOBAL_CONFIG_FILE, config);
|
|
43
|
+
return config;
|
|
44
|
+
}
|
|
45
|
+
export function saveGlobalConfig(config) {
|
|
46
|
+
writeJsonFile(GLOBAL_CONFIG_FILE, config);
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=global-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-config.js","sourceRoot":"","sources":["../../src/lib/global-config.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,CAAC;AACpD,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;AASzE,SAAS,YAAY,CAAI,QAAgB;IACvC,IAAI,CAAC;QACH,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YACzB,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAChD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAM,CAAC;QAClC,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,+BAA+B;IACjC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,aAAa,CAAC,QAAgB,EAAE,IAAa;IACpD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACrB,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACtC,CAAC;QACD,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAClE,CAAC;IAAC,MAAM,CAAC;QACP,+BAA+B;IACjC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,MAAM,QAAQ,GAAG,YAAY,CAAe,kBAAkB,CAAC,CAAC;IAChE,IAAI,QAAQ,EAAE,SAAS,IAAI,QAAQ,EAAE,SAAS,KAAK,SAAS,EAAE,CAAC;QAC7D,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,MAAM,MAAM,GAAiB;QAC3B,SAAS,EAAE,QAAQ,EAAE,SAAS,IAAI,MAAM,CAAC,UAAU,EAAE;QACrD,SAAS,EAAE;YACT,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,IAAI,IAAI;SAC9C;KACF,CAAC;IACF,aAAa,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;IAC1C,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAoB;IACnD,aAAa,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;AAC5C,CAAC"}
|
package/dist/lib/project.d.ts
CHANGED
|
@@ -1,11 +1,66 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RouterOutput } from "@alpic-ai/api";
|
|
2
|
+
import type { ProjectConfig } from "../types.js";
|
|
2
3
|
export declare function resolveDeployDir(raw: string | undefined): string;
|
|
3
4
|
export declare function confirmDeployWithExistingConfig(existingConfig: ProjectConfig): Promise<boolean | null>;
|
|
4
|
-
export declare function selectEnvironmentFromList(environments:
|
|
5
|
+
export declare function selectEnvironmentFromList(environments: RouterOutput["projects"]["get"]["v1"]["environments"]): Promise<{
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
sourceBranch: string | null;
|
|
9
|
+
mcpServerUrl: string;
|
|
10
|
+
createdAt: Date;
|
|
11
|
+
projectId: string;
|
|
12
|
+
latestDeployment: {
|
|
13
|
+
id: string;
|
|
14
|
+
status: "ongoing" | "deployed" | "failed" | "canceled";
|
|
15
|
+
sourceCommitId: string | null;
|
|
16
|
+
sourceCommitMessage: string | null;
|
|
17
|
+
completedAt: Date | null;
|
|
18
|
+
} | null;
|
|
19
|
+
} | null>;
|
|
5
20
|
export declare function confirmDeployDirectory(deployDir: string): Promise<boolean>;
|
|
6
21
|
export declare function confirmLinkExisting(): Promise<boolean>;
|
|
7
22
|
export declare function confirmLinkToAnotherProject(): Promise<boolean>;
|
|
8
|
-
export declare function selectProjectFromList(projects:
|
|
23
|
+
export declare function selectProjectFromList(projects: RouterOutput["projects"]["list"]["v1"]): Promise<{
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
teamId: string;
|
|
27
|
+
sourceRepository: string | null;
|
|
28
|
+
runtime: "python3.13" | "python3.14" | "node22" | "node24";
|
|
29
|
+
transport: "stdio" | "sse" | "streamablehttp" | null;
|
|
30
|
+
rootDirectory: string | null;
|
|
31
|
+
buildCommand: string | null;
|
|
32
|
+
buildOutputDir: string | null;
|
|
33
|
+
installCommand: string | null;
|
|
34
|
+
startCommand: string | null;
|
|
35
|
+
createdAt: Date;
|
|
36
|
+
productionEnvironment: {
|
|
37
|
+
id: string;
|
|
38
|
+
name: string;
|
|
39
|
+
mcpServerUrl: string;
|
|
40
|
+
latestDeployment: {
|
|
41
|
+
id: string;
|
|
42
|
+
status: "ongoing" | "deployed" | "failed" | "canceled";
|
|
43
|
+
sourceCommitId: string | null;
|
|
44
|
+
sourceCommitMessage: string | null;
|
|
45
|
+
completedAt: Date | null;
|
|
46
|
+
} | null;
|
|
47
|
+
} | null;
|
|
48
|
+
environments: {
|
|
49
|
+
id: string;
|
|
50
|
+
name: string;
|
|
51
|
+
sourceBranch: string | null;
|
|
52
|
+
mcpServerUrl: string;
|
|
53
|
+
createdAt: Date;
|
|
54
|
+
projectId: string;
|
|
55
|
+
latestDeployment: {
|
|
56
|
+
id: string;
|
|
57
|
+
status: "ongoing" | "deployed" | "failed" | "canceled";
|
|
58
|
+
sourceCommitId: string | null;
|
|
59
|
+
sourceCommitMessage: string | null;
|
|
60
|
+
completedAt: Date | null;
|
|
61
|
+
} | null;
|
|
62
|
+
}[];
|
|
63
|
+
} | null>;
|
|
9
64
|
export declare function promptRootDirectory(deployDir: string): Promise<string | null | undefined>;
|
|
10
65
|
export declare function resolveProjectForDeploy(deployDir: string): Promise<(ProjectConfig & {
|
|
11
66
|
environmentId: string;
|
package/dist/lib/project.js
CHANGED
|
@@ -110,7 +110,7 @@ export async function promptRootDirectory(deployDir) {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
async function resolveEnvironmentForProject(projectId) {
|
|
113
|
-
const project = await api.
|
|
113
|
+
const project = await api.projects.get.v1({ projectId });
|
|
114
114
|
const environments = project.environments ?? [];
|
|
115
115
|
if (environments.length === 0) {
|
|
116
116
|
throw new Error("No environments found for this project.");
|
|
@@ -209,7 +209,7 @@ async function runCreateProjectFlow(deployDir) {
|
|
|
209
209
|
if (rootDirectory) {
|
|
210
210
|
projectInput.rootDirectory = rootDirectory;
|
|
211
211
|
}
|
|
212
|
-
const created = await api.
|
|
212
|
+
const created = await api.projects.create.v1(projectInput);
|
|
213
213
|
spin.stop("Project created.");
|
|
214
214
|
const productionEnv = created.productionEnvironment;
|
|
215
215
|
if (!productionEnv) {
|
|
@@ -231,7 +231,7 @@ async function runCreateProjectFlow(deployDir) {
|
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
233
|
async function runLinkingFlow(deployDir) {
|
|
234
|
-
const projects = await api.
|
|
234
|
+
const projects = await api.projects.list.v1();
|
|
235
235
|
if (projects.length === 0) {
|
|
236
236
|
throw new Error("No projects found. Create a project in the Alpic dashboard first.");
|
|
237
237
|
}
|