ardent-cli-beta 0.0.8 → 0.0.9
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
CHANGED
|
@@ -11,8 +11,9 @@ API token for CI and automation; `ARDENT_TOKEN` supplies the same flag
|
|
|
11
11
|
non-interactively. `ardent status` and `ardent logout` inspect and remove that
|
|
12
12
|
local session. The CLI always talks to Ardent's production control plane. Oclif
|
|
13
13
|
provides help, version, autocomplete, and native JSON command behavior. Resource
|
|
14
|
-
context is retained from login. Project listing, creation, and local
|
|
15
|
-
switching are implemented; other resource commands are not implemented
|
|
14
|
+
context is retained from login. Project listing, creation, deletion, and local
|
|
15
|
+
context switching are implemented; other resource commands are not implemented
|
|
16
|
+
yet.
|
|
16
17
|
|
|
17
18
|
Set `ARDENT_API_URL` to point the CLI at a development control plane. Without
|
|
18
19
|
it, the CLI uses `https://production.tryardent.com`.
|
|
@@ -26,6 +27,7 @@ npm run build
|
|
|
26
27
|
./bin/run.js project list
|
|
27
28
|
./bin/run.js project create "My project"
|
|
28
29
|
./bin/run.js project switch "My project"
|
|
30
|
+
./bin/run.js project delete "My project"
|
|
29
31
|
ARDENT_API_URL=http://localhost:8080 ./bin/run.js login --token <token>
|
|
30
32
|
```
|
|
31
33
|
|
package/dist/api/client.js
CHANGED
|
@@ -48,6 +48,8 @@ async function requestJSON(path, init) {
|
|
|
48
48
|
}
|
|
49
49
|
throw new APIError(detail.message ?? `Ardent API request failed with HTTP ${response.status}.`, response.status, detail.error);
|
|
50
50
|
}
|
|
51
|
+
if (response.status === 204)
|
|
52
|
+
return undefined;
|
|
51
53
|
try {
|
|
52
54
|
return JSON.parse(text);
|
|
53
55
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ArdentCommand } from '../../command.js';
|
|
2
|
+
export default class ProjectDelete extends ArdentCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static helpGroup: string;
|
|
8
|
+
run(): Promise<{
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { loadSession } from '../../auth/credentials.js';
|
|
3
|
+
import { ArdentCommand } from '../../command.js';
|
|
4
|
+
import { deleteProject, listProjects } from '../../projects/client.js';
|
|
5
|
+
import { replaceProjectCache } from '../../projects/context.js';
|
|
6
|
+
import { terminalText } from '../../terminal.js';
|
|
7
|
+
export default class ProjectDelete extends ArdentCommand {
|
|
8
|
+
static args = {
|
|
9
|
+
name: Args.string({ description: 'Project name', required: true }),
|
|
10
|
+
};
|
|
11
|
+
static description = 'Delete a project by name';
|
|
12
|
+
static helpGroup = 'Projects';
|
|
13
|
+
async run() {
|
|
14
|
+
const { args } = await this.parse(ProjectDelete);
|
|
15
|
+
const name = args.name.trim();
|
|
16
|
+
if (!name)
|
|
17
|
+
this.error('Project name cannot be empty.');
|
|
18
|
+
const session = await loadSession(this.config.configDir);
|
|
19
|
+
if (!session?.organization)
|
|
20
|
+
this.error('You must be logged in to run this command. Run ardent login.');
|
|
21
|
+
const projects = await listProjects(session.token, session.organization.id);
|
|
22
|
+
const project = projects.find((candidate) => candidate.name === name);
|
|
23
|
+
if (!project)
|
|
24
|
+
this.error(`Project ${JSON.stringify(name)} not found.`);
|
|
25
|
+
if (!this.jsonEnabled())
|
|
26
|
+
this.log(`Deleting project ${terminalText(project.name)}...`);
|
|
27
|
+
await deleteProject(session.token, session.organization.id, project.id);
|
|
28
|
+
await replaceProjectCache(this.config.configDir, session, projects.filter(({ id }) => id !== project.id));
|
|
29
|
+
if (!this.jsonEnabled())
|
|
30
|
+
this.log(`✓ Deleted project ${terminalText(project.name)}`);
|
|
31
|
+
return { id: project.id, name: project.name };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -7,3 +7,4 @@ export interface Project {
|
|
|
7
7
|
}
|
|
8
8
|
export declare function listProjects(token: string, organizationID: string): Promise<Project[]>;
|
|
9
9
|
export declare function createProject(token: string, organizationID: string, name: string): Promise<Project>;
|
|
10
|
+
export declare function deleteProject(token: string, organizationID: string, projectID: string): Promise<void>;
|
package/dist/projects/client.js
CHANGED
|
@@ -17,6 +17,12 @@ export async function createProject(token, organizationID, name) {
|
|
|
17
17
|
throw new Error('Ardent API returned an invalid project response.');
|
|
18
18
|
return project;
|
|
19
19
|
}
|
|
20
|
+
export async function deleteProject(token, organizationID, projectID) {
|
|
21
|
+
const response = await request(token, `/projects/${encodeURIComponent(projectID)}?organization_id=${encodeURIComponent(organizationID)}`, { method: 'DELETE' });
|
|
22
|
+
if (response !== undefined) {
|
|
23
|
+
throw new Error('Ardent API did not confirm project deletion. Run ardent project list before retrying.');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
20
26
|
function isProject(value, organizationID) {
|
|
21
27
|
if (typeof value !== 'object' || value === null)
|
|
22
28
|
return false;
|
package/oclif.manifest.json
CHANGED
|
@@ -131,6 +131,42 @@
|
|
|
131
131
|
"create.js"
|
|
132
132
|
]
|
|
133
133
|
},
|
|
134
|
+
"project:delete": {
|
|
135
|
+
"aliases": [],
|
|
136
|
+
"args": {
|
|
137
|
+
"name": {
|
|
138
|
+
"description": "Project name",
|
|
139
|
+
"name": "name",
|
|
140
|
+
"required": true
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
"description": "Delete a project by name",
|
|
144
|
+
"flags": {
|
|
145
|
+
"json": {
|
|
146
|
+
"description": "Format output as json.",
|
|
147
|
+
"helpGroup": "GLOBAL",
|
|
148
|
+
"name": "json",
|
|
149
|
+
"allowNo": false,
|
|
150
|
+
"type": "boolean"
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"hasDynamicHelp": false,
|
|
154
|
+
"hiddenAliases": [],
|
|
155
|
+
"id": "project:delete",
|
|
156
|
+
"pluginAlias": "ardent-cli-beta",
|
|
157
|
+
"pluginName": "ardent-cli-beta",
|
|
158
|
+
"pluginType": "core",
|
|
159
|
+
"strict": true,
|
|
160
|
+
"enableJsonFlag": true,
|
|
161
|
+
"helpGroup": "Projects",
|
|
162
|
+
"isESM": true,
|
|
163
|
+
"relativePath": [
|
|
164
|
+
"dist",
|
|
165
|
+
"commands",
|
|
166
|
+
"project",
|
|
167
|
+
"delete.js"
|
|
168
|
+
]
|
|
169
|
+
},
|
|
134
170
|
"project:list": {
|
|
135
171
|
"aliases": [],
|
|
136
172
|
"args": {},
|
|
@@ -198,5 +234,5 @@
|
|
|
198
234
|
]
|
|
199
235
|
}
|
|
200
236
|
},
|
|
201
|
-
"version": "0.0.
|
|
237
|
+
"version": "0.0.9"
|
|
202
238
|
}
|