@biznetgio/neo-app 0.4.0 → 0.4.1
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/package.json +1 -1
- package/src/commands/link.js +32 -0
- package/src/index.js +2 -0
package/package.json
CHANGED
package/src/commands/link.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// InstaCloud's `insta project link`. Links the repo to a project (writes .neo-app.json)
|
|
3
3
|
// after validating it against the authenticated account.
|
|
4
4
|
|
|
5
|
+
import { basename } from 'node:path';
|
|
5
6
|
import { resolveConfig } from '../config.js';
|
|
6
7
|
import { getCredential } from '../creds.js';
|
|
7
8
|
import { NeoApi, ApiError } from '../api.js';
|
|
@@ -37,6 +38,37 @@ export async function link(projectId, opts = {}) {
|
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
// createProject makes a new project in the current org and links this repo to it
|
|
42
|
+
// (parity with `insta project create`). Name defaults to the working-directory name.
|
|
43
|
+
export async function createProject(name, opts = {}) {
|
|
44
|
+
const { cfg, api } = apiFor(opts);
|
|
45
|
+
const orgId = await api.resolveOrgId(opts.org);
|
|
46
|
+
const projName = String(name || opts.name || basename(process.cwd())).trim();
|
|
47
|
+
if (!projName) {
|
|
48
|
+
fail('usage: neo-app project create <name>');
|
|
49
|
+
process.exit(2);
|
|
50
|
+
}
|
|
51
|
+
let res;
|
|
52
|
+
try {
|
|
53
|
+
res = await api.post(`/api/v1/orgs/${orgId}/projects`, { name: projName });
|
|
54
|
+
} catch (e) {
|
|
55
|
+
fail(`could not create project '${projName}': ${e.message}`);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
if (res.status === 202 && res.data?.status === 'pending_approval') {
|
|
59
|
+
ok(`create submitted — pending approval (${res.data.approvalId}). An owner/admin must approve.`);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const proj = res.data?.project || res.data || {};
|
|
63
|
+
const environment = cfg.env === 'staging' ? 'staging' : 'production';
|
|
64
|
+
ok(`created project ${proj.name || projName}`);
|
|
65
|
+
if (proj.id) {
|
|
66
|
+
writeLink({ projectId: proj.id, environment, baseUrl: cfg.baseUrl, env: cfg.env, name: proj.name || projName });
|
|
67
|
+
ok(`linked ${proj.name || projName} / ${environment} ${c.dim('(.neo-app.json)')}`);
|
|
68
|
+
}
|
|
69
|
+
return proj;
|
|
70
|
+
}
|
|
71
|
+
|
|
40
72
|
export async function listProjects(opts = {}) {
|
|
41
73
|
const { api } = apiFor(opts);
|
|
42
74
|
const orgId = await api.resolveOrgId(opts.org);
|
package/src/index.js
CHANGED
|
@@ -28,6 +28,7 @@ ${c.bold('Commands')}
|
|
|
28
28
|
login Authenticate with a NEO App API key (kap_...)
|
|
29
29
|
link <project-id> Link this repo to a project (writes .neo-app.json)
|
|
30
30
|
deploy Deploy a web service: --image <ref> or --repo <git-url>
|
|
31
|
+
project create [name] Create a project (defaults to the dir name) and link it
|
|
31
32
|
project list List projects in your organization (find ids to link)
|
|
32
33
|
status | whoami Show connected account, org, environment, linked project
|
|
33
34
|
mcp Run the local stdio MCP server (used by agents)
|
|
@@ -101,6 +102,7 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
101
102
|
if (cmd === 'deploy') return void (await (await import('./commands/deploy.js')).deploy(opts));
|
|
102
103
|
if (cmd === 'link') return void (await (await import('./commands/link.js')).link(sub, opts));
|
|
103
104
|
if (cmd === 'project' && sub === 'link') return void (await (await import('./commands/link.js')).link(positionals[2], opts));
|
|
105
|
+
if (cmd === 'project' && sub === 'create') return void (await (await import('./commands/link.js')).createProject(positionals[2], opts));
|
|
104
106
|
if (cmd === 'project' && (sub === 'list' || sub === 'ls')) return void (await (await import('./commands/link.js')).listProjects(opts));
|
|
105
107
|
if (cmd === 'status' || cmd === 'whoami') return void (await (await import('./commands/status.js')).status(opts));
|
|
106
108
|
if (cmd === 'mcp') return void (await (await import('./mcp/server.js')).runMcpServer());
|