@adkit/cli 1.13.13 → 1.13.14
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 -1
- package/dist/cli.js +64 -9
- package/package.json +2 -6
package/README.md
CHANGED
package/dist/cli.js
CHANGED
|
@@ -1120,16 +1120,29 @@ function unwrapList(data) {
|
|
|
1120
1120
|
}
|
|
1121
1121
|
|
|
1122
1122
|
// src/commands/projects.ts
|
|
1123
|
+
async function createProject(client, options) {
|
|
1124
|
+
const response = await client.post("/manage/projects", options);
|
|
1125
|
+
if (!isCreateProjectResponse(response)) throw new Error("Unexpected response from AdKit project creation");
|
|
1126
|
+
writeConfig({ selectedProject: response.projectId });
|
|
1127
|
+
return {
|
|
1128
|
+
id: response.projectId,
|
|
1129
|
+
name: response.name,
|
|
1130
|
+
website: response.website,
|
|
1131
|
+
workspaceId: response.workspaceId,
|
|
1132
|
+
current: true
|
|
1133
|
+
};
|
|
1134
|
+
}
|
|
1123
1135
|
async function listProjects(client, options = {}) {
|
|
1124
1136
|
const qs = queryString({ query: options.query, limit: options.limit });
|
|
1125
1137
|
const response = await client.get(`/manage/projects${qs}`);
|
|
1126
1138
|
if (!isProjectsResponse(response)) throw new Error("Unexpected response from AdKit projects");
|
|
1127
1139
|
const config = readConfig() ?? {};
|
|
1128
|
-
|
|
1140
|
+
const projects = response.projects.map((project) => mapProjectEntry(project, config.selectedProject));
|
|
1141
|
+
return { projects, workspaces: response.workspaces ?? [] };
|
|
1129
1142
|
}
|
|
1130
1143
|
async function useProject(client, projectId) {
|
|
1131
|
-
const
|
|
1132
|
-
const project = projects.find((entry) => entry.id === projectId);
|
|
1144
|
+
const result = await listProjects(client, { limit: "50" });
|
|
1145
|
+
const project = result.projects.find((entry) => entry.id === projectId);
|
|
1133
1146
|
if (!project) throw new Error(`Project not found: ${projectId}`);
|
|
1134
1147
|
writeConfig({ selectedProject: projectId });
|
|
1135
1148
|
}
|
|
@@ -1143,13 +1156,20 @@ function isProjectsResponse(value) {
|
|
|
1143
1156
|
if (!("projects" in value)) return false;
|
|
1144
1157
|
return Array.isArray(value.projects);
|
|
1145
1158
|
}
|
|
1159
|
+
function isCreateProjectResponse(value) {
|
|
1160
|
+
if (!value || typeof value !== "object") return false;
|
|
1161
|
+
if (!("projectId" in value) || typeof value.projectId !== "string") return false;
|
|
1162
|
+
if (!("name" in value) || typeof value.name !== "string") return false;
|
|
1163
|
+
return "website" in value && typeof value.website === "string";
|
|
1164
|
+
}
|
|
1146
1165
|
function mapProjectEntry(project, selectedProject) {
|
|
1147
1166
|
const entry = {
|
|
1148
1167
|
id: project.projectId,
|
|
1149
1168
|
name: project.name,
|
|
1150
1169
|
website: project.website,
|
|
1151
1170
|
role: project.role,
|
|
1152
|
-
platforms: project.platforms
|
|
1171
|
+
platforms: project.platforms,
|
|
1172
|
+
workspaceId: project.workspaceId
|
|
1153
1173
|
};
|
|
1154
1174
|
if (selectedProject === project.projectId) entry.current = true;
|
|
1155
1175
|
return entry;
|
|
@@ -4609,7 +4629,7 @@ Commands:
|
|
|
4609
4629
|
library Browse ads and advertisers
|
|
4610
4630
|
studio Create and manage Studio ads
|
|
4611
4631
|
manage Manage ad platforms and drafts
|
|
4612
|
-
projects Manage projects (list, use, current)
|
|
4632
|
+
projects Manage projects (list, create, use, current)
|
|
4613
4633
|
|
|
4614
4634
|
Advanced:
|
|
4615
4635
|
logout Remove stored API key
|
|
@@ -6731,15 +6751,24 @@ Examples:
|
|
|
6731
6751
|
projects: `adkit projects \u2014 Manage projects
|
|
6732
6752
|
|
|
6733
6753
|
list List accessible projects
|
|
6754
|
+
create Create a project and make it active
|
|
6734
6755
|
use <id> Switch active project
|
|
6735
6756
|
current Show active project
|
|
6736
6757
|
|
|
6737
6758
|
Flags:
|
|
6738
6759
|
--query <text> Filter projects by name or website
|
|
6739
6760
|
--limit <n> Max results (default: 20, max: 50)
|
|
6761
|
+
--name <text> Project or business name (create)
|
|
6762
|
+
--website <url> Project website URL or domain (create)
|
|
6763
|
+
--workspace <id> Target workspace ID (create)
|
|
6764
|
+
--description <t> Optional business description (create)
|
|
6765
|
+
--industry <text> Optional business industry (create)
|
|
6766
|
+
--category <text> Optional business category (create)
|
|
6767
|
+
--tags <a,b> Optional comma-separated tags (create)
|
|
6740
6768
|
|
|
6741
6769
|
Examples:
|
|
6742
6770
|
adkit projects list
|
|
6771
|
+
adkit projects create --name "Acme" --website acme.com
|
|
6743
6772
|
adkit projects use proj_abc123`.trim()
|
|
6744
6773
|
};
|
|
6745
6774
|
var STUDIO_GENERATE_HELP_FULL = `adkit studio generate \u2014 Create ad images with AI
|
|
@@ -8705,13 +8734,18 @@ ${pageInfo}`);
|
|
|
8705
8734
|
case void 0: {
|
|
8706
8735
|
const query = typeof flags.query === "string" ? flags.query : void 0;
|
|
8707
8736
|
const limit = typeof flags.limit === "string" ? flags.limit : void 0;
|
|
8708
|
-
const
|
|
8709
|
-
if (
|
|
8737
|
+
const result = await listProjects(client, { query, limit });
|
|
8738
|
+
if (wantsJson(flags)) printResult(result, flags);
|
|
8710
8739
|
else {
|
|
8711
|
-
|
|
8740
|
+
if (result.projects.length === 0) console.log("No projects found.");
|
|
8741
|
+
for (const p of result.projects) {
|
|
8712
8742
|
const marker = p.current ? "* " : " ";
|
|
8713
8743
|
console.log(`${marker}${p.name} (${p.id})`);
|
|
8714
8744
|
}
|
|
8745
|
+
if (result.workspaces.length > 0) {
|
|
8746
|
+
console.log("\nWorkspaces:");
|
|
8747
|
+
for (const workspace of result.workspaces) console.log(` ${workspace.name} (${workspace.workspaceId})`);
|
|
8748
|
+
}
|
|
8715
8749
|
}
|
|
8716
8750
|
break;
|
|
8717
8751
|
}
|
|
@@ -8721,6 +8755,27 @@ ${pageInfo}`);
|
|
|
8721
8755
|
else console.log(`Active project: ${project.id}`);
|
|
8722
8756
|
break;
|
|
8723
8757
|
}
|
|
8758
|
+
case "create": {
|
|
8759
|
+
const name = requireFlag(flags, "name", 'Run: adkit projects create --name "Acme" --website acme.com');
|
|
8760
|
+
const website = requireFlag(flags, "website", 'Run: adkit projects create --name "Acme" --website acme.com');
|
|
8761
|
+
const descriptionValues = collectFlagValues(flags, "description");
|
|
8762
|
+
const description = descriptionValues.length > 0 ? descriptionValues.join(" ") : void 0;
|
|
8763
|
+
const tagsFlag = typeof flags.tags === "string" ? flags.tags : void 0;
|
|
8764
|
+
const tagParts = tagsFlag ? tagsFlag.split(",") : [];
|
|
8765
|
+
const tags = tagParts.map((tag) => tag.trim()).filter(Boolean);
|
|
8766
|
+
const project = await createProject(client, {
|
|
8767
|
+
name,
|
|
8768
|
+
website,
|
|
8769
|
+
description,
|
|
8770
|
+
industry: typeof flags.industry === "string" ? flags.industry : void 0,
|
|
8771
|
+
category: typeof flags.category === "string" ? flags.category : void 0,
|
|
8772
|
+
tags: tags.length > 0 ? tags : void 0,
|
|
8773
|
+
workspaceId: typeof flags.workspace === "string" ? flags.workspace : void 0
|
|
8774
|
+
});
|
|
8775
|
+
if (wantsJson(flags)) printResult(project, flags);
|
|
8776
|
+
else console.log(`Created and selected project: ${project.name} (${project.id})`);
|
|
8777
|
+
break;
|
|
8778
|
+
}
|
|
8724
8779
|
case "use": {
|
|
8725
8780
|
const projectId = args[2];
|
|
8726
8781
|
if (!projectId) throw new CliError("MISSING_ARGUMENT", "Missing required argument: `<project-id>`", "Run: adkit projects use <project-id>");
|
|
@@ -8729,7 +8784,7 @@ ${pageInfo}`);
|
|
|
8729
8784
|
break;
|
|
8730
8785
|
}
|
|
8731
8786
|
default:
|
|
8732
|
-
throw new CliError("UNKNOWN_COMMAND", `Unknown action: projects ${action}`, "Available: list, use, current");
|
|
8787
|
+
throw new CliError("UNKNOWN_COMMAND", `Unknown action: projects ${action}`, "Available: list, create, use, current");
|
|
8733
8788
|
}
|
|
8734
8789
|
return;
|
|
8735
8790
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adkit/cli",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.14",
|
|
4
4
|
"description": "The Ads CLI for AI agents — manage Meta & Google ad campaigns, browse the ad library, and generate creatives from your terminal.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ads cli",
|
|
@@ -18,11 +18,7 @@
|
|
|
18
18
|
"publishConfig": {
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
|
-
"
|
|
22
|
-
"type": "git",
|
|
23
|
-
"url": "git+https://github.com/adkit/adkit-monorepo.git",
|
|
24
|
-
"directory": "packages/cli"
|
|
25
|
-
},
|
|
21
|
+
"homepage": "https://adkit.so",
|
|
26
22
|
"type": "module",
|
|
27
23
|
"bin": {
|
|
28
24
|
"adkit": "dist/cli.js"
|