gipity 1.1.22 → 1.1.24
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 +33 -15
- package/dist/adopt-cwd.js +2 -2
- package/dist/commands/brand.js +1 -1
- package/dist/commands/deploy.js +57 -16
- package/dist/commands/env.js +168 -0
- package/dist/commands/file.js +6 -2
- package/dist/commands/fn.js +1 -1
- package/dist/commands/init.js +66 -24
- package/dist/commands/job.js +18 -2
- package/dist/commands/login.js +31 -14
- package/dist/commands/logout.js +7 -6
- package/dist/commands/push.js +11 -3
- package/dist/commands/rbac.js +2 -1
- package/dist/commands/realtime.js +6 -0
- package/dist/commands/records.js +22 -4
- package/dist/commands/service.js +2 -2
- package/dist/commands/status.js +3 -0
- package/dist/commands/test.js +6 -6
- package/dist/commands/uninstall.js +53 -30
- package/dist/commands/update.js +17 -2
- package/dist/config.js +34 -3
- package/dist/helpers/sync.js +4 -1
- package/dist/index.js +593 -169
- package/dist/knowledge.js +19 -15
- package/dist/login-flow.js +9 -7
- package/dist/prompts.js +2 -2
- package/dist/provider-docs.js +1 -1
- package/dist/setup.js +52 -7
- package/dist/sync.js +72 -10
- package/dist/template-vars.js +1 -1
- package/dist/utils.js +5 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ The cloud backend for your coding agent.
|
|
|
4
4
|
|
|
5
5
|
[Gipity](https://gipity.ai) is the backend your coding agent gets by installing one CLI and one skill: hosting, databases, serverless functions, file storage, a code sandbox, CPU/GPU jobs, AI models and media services, workflows, and a quick LLM call (`gipity ask`), plus templates and kits that give you a running start.
|
|
6
6
|
|
|
7
|
-
This CLI connects your coding agent ([Claude Code](https://claude.ai/claude-code), Codex, Grok, or opencode) to Gipity: deploy, query the database, call functions, test pages in a real browser, generate images and audio, and keep your local files in sync with your Gipity project.
|
|
7
|
+
This CLI connects your coding agent ([Claude Code](https://claude.ai/claude-code), Codex, Grok, Antigravity, or opencode) to Gipity: deploy, query the database, call functions, test pages in a real browser, generate images and audio, and keep your local files in sync with your Gipity project.
|
|
8
8
|
|
|
9
9
|
## Getting Started
|
|
10
10
|
|
|
@@ -23,11 +23,11 @@ irm https://gipity.ai/install.ps1 | iex
|
|
|
23
23
|
| You want to... | Run |
|
|
24
24
|
|----------------|-----|
|
|
25
25
|
| Start building right now, from anywhere | `gipity build` |
|
|
26
|
-
| Use your own workflow in your own directory | `gipity init`, then `claude` / `codex` / `grok` / `opencode` |
|
|
26
|
+
| Use your own workflow in your own directory | `gipity init`, then `claude` / `codex` / `grok` / `agy` / `opencode` |
|
|
27
27
|
|
|
28
28
|
### `gipity build` - start from anywhere
|
|
29
29
|
|
|
30
|
-
One command does everything: logs you in (6-digit email code), lets you pick or create a project, lets you pick your coding agent (Claude Code, Codex, or
|
|
30
|
+
One command does everything: logs you in (6-digit email code), lets you pick or create a project, lets you pick your coding agent (Claude Code, Codex, Grok, Antigravity, or opencode - it installs the agent where it can), and launches it with the whole Gipity stack wired up.
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
33
|
gipity build
|
|
@@ -39,10 +39,10 @@ Prefer launching your agent yourself? From any project directory:
|
|
|
39
39
|
|
|
40
40
|
```bash
|
|
41
41
|
gipity init
|
|
42
|
-
claude # or codex, grok, or opencode - whatever you use
|
|
42
|
+
claude # or codex, grok, agy, or opencode - whatever you use
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
`init` links the directory to a Gipity project, writes CLAUDE.md/AGENTS.md primers so your agent understands Gipity, and installs the Gipity skills + file-sync hooks into the agent CLIs found on your machine (Claude Code, Codex, Grok; Cursor and
|
|
45
|
+
`init` links the directory to a Gipity project, writes CLAUDE.md/AGENTS.md primers so your agent understands Gipity, and installs the Gipity skills + file-sync hooks into the agent CLIs found on your machine (Claude Code, Codex, Grok, Antigravity, opencode; Cursor, Gemini CLI and GitHub Copilot get primer files too).
|
|
46
46
|
|
|
47
47
|
### Prefer npm
|
|
48
48
|
|
|
@@ -90,6 +90,8 @@ To opt out: `export DISABLE_AUTOUPDATER=1` (matches Claude Code), or set `{ "aut
|
|
|
90
90
|
1. Claude Code (Anthropic)
|
|
91
91
|
2. Codex (OpenAI)
|
|
92
92
|
3. Grok (xAI)
|
|
93
|
+
4. Antigravity (Google)
|
|
94
|
+
5. opencode (Anomaly)
|
|
93
95
|
|
|
94
96
|
Launching Claude Code, powered by Gipity.
|
|
95
97
|
```
|
|
@@ -115,12 +117,12 @@ gipity login --email you@example.com
|
|
|
115
117
|
gipity login --code 123456
|
|
116
118
|
cd my-project
|
|
117
119
|
gipity init
|
|
118
|
-
claude # or codex, grok, or opencode
|
|
120
|
+
claude # or codex, grok, agy, or opencode
|
|
119
121
|
```
|
|
120
122
|
|
|
121
123
|
## Coding Agent Integration
|
|
122
124
|
|
|
123
|
-
This is the good part. When you run `gipity init` (or `gipity build`) in a project, it wires two hooks into your agent (Claude Code, Codex, and
|
|
125
|
+
This is the good part. When you run `gipity init` (or `gipity build`) in a project, it wires two hooks into your agent (Claude Code, Codex, Grok, Antigravity, and opencode all get them):
|
|
124
126
|
|
|
125
127
|
**Auto-push** - Every time your agent writes or edits a file, it gets pushed to Gipity in the background. No extra steps.
|
|
126
128
|
|
|
@@ -133,7 +135,7 @@ Session recording is off by default. To keep your Claude Code sessions in your G
|
|
|
133
135
|
```
|
|
134
136
|
.gipity.json # Project config (which project)
|
|
135
137
|
.gipity/ # Local sync state (gitignored)
|
|
136
|
-
.claude/settings.json # Hooks for auto-push and auto-pull (per-agent equivalents for
|
|
138
|
+
.claude/settings.json # Hooks for auto-push and auto-pull (per-agent equivalents for the other agents)
|
|
137
139
|
CLAUDE.md / AGENTS.md # Gipity commands reference for your agent
|
|
138
140
|
```
|
|
139
141
|
|
|
@@ -158,13 +160,20 @@ gipity push <file> # Push one or more files
|
|
|
158
160
|
| `gipity skill list` / `skill read <name>` | Task docs: read the matching skill before building |
|
|
159
161
|
| `gipity project` | List, create, switch, rename, or delete projects |
|
|
160
162
|
| `gipity add <template\|kit>` | Add a template (web-simple, web-fullstack, api, 2d-game, 3d-world, ...) or a kit (realtime, stripe, i18n, ...) |
|
|
161
|
-
| `gipity
|
|
163
|
+
| `gipity remove <kit>` | Remove a kit |
|
|
164
|
+
| `gipity brand` | Show or set the app's icon, accent color, and share card |
|
|
165
|
+
| `gipity save` / `gipity load` | Export the app as a portable `.gip` bundle / create a new app from a bundle or GitHub repo |
|
|
166
|
+
| `gipity github` | Connect GitHub for repo imports |
|
|
167
|
+
| `gipity deploy [prod\|<env>]` | Deploy to prod, or to an isolated environment like `dev` |
|
|
168
|
+
| `gipity env` | List, create, reset, or delete app environments |
|
|
162
169
|
| `gipity page inspect\|eval\|screenshot <url>` | Check a page in a real browser: console errors, failed resources, DOM, screenshots |
|
|
163
170
|
| `gipity test` | Run project tests in sandboxed containers |
|
|
164
171
|
| `gipity db` | Query, list, create, or drop project databases |
|
|
165
172
|
| `gipity fn` | List, call, and delete serverless functions |
|
|
166
173
|
| `gipity logs fn <name>` / `logs app` | Function logs / recent app activity and errors |
|
|
167
174
|
| `gipity secrets` | Manage app secrets (encrypted, never echoed back) |
|
|
175
|
+
| `gipity key` | Project API keys for scripts and agents (`X-Api-Key`) |
|
|
176
|
+
| `gipity token` | Agent API tokens for headless/CI use (`GIPITY_TOKEN`) |
|
|
168
177
|
| `gipity job` | Run long CPU/GPU jobs |
|
|
169
178
|
| `gipity workflow` | Create, run, and schedule workflows |
|
|
170
179
|
| `gipity approval` | List, create, answer, or cancel pending approvals |
|
|
@@ -172,29 +181,38 @@ gipity push <file> # Push one or more files
|
|
|
172
181
|
| `gipity ask "<question>"` | Ask a model one question and print the answer |
|
|
173
182
|
| `gipity generate` | Generate images, video, speech, sound effects, or music |
|
|
174
183
|
| `gipity service` | Call an app service (llm, tts, image, transcribe, ...) |
|
|
184
|
+
| `gipity notify` | Send a test web push notification, count or remove subscriptions |
|
|
185
|
+
| `gipity payments` | Connect Stripe to charge your users |
|
|
186
|
+
| `gipity realtime` | Manage realtime rooms, benchmark a room |
|
|
187
|
+
| `gipity location` | IP geolocation and reverse geocoding (`<ip>`, `<lat> <lng>`) |
|
|
188
|
+
| `gipity gmail` | Search, read, send, and reply with your own Gmail |
|
|
189
|
+
| `gipity text analyze` | Deterministic letter/word counts and lookups (local, no network) |
|
|
175
190
|
| `gipity sandbox run` | Execute code in a sandboxed container |
|
|
176
191
|
| `gipity records` | Query and manage Records API tables |
|
|
177
192
|
| `gipity rbac` / `gipity audit` | Access policies / audit logs |
|
|
178
193
|
| `gipity file` | Browse remote files, versions, and rollbacks |
|
|
179
194
|
| `gipity sync` / `gipity push` | Sync files between local and Gipity |
|
|
180
195
|
| `gipity upload <file>` | Upload a file and print a durable public URL |
|
|
196
|
+
| `gipity storage` | Storage usage and version-retention settings |
|
|
181
197
|
| `gipity domain` | Manage custom domains for deployed apps |
|
|
182
198
|
| `gipity email` | Test and inspect your app's `email()` sends (`email test`, `email log`) |
|
|
183
199
|
| `gipity credits` | Check your plan, balance, and usage |
|
|
184
200
|
| `gipity doctor` | Check install + environment health |
|
|
201
|
+
| `gipity bug` | Report Gipity platform bugs or friction, list or retract reports |
|
|
202
|
+
| `gipity update` / `gipity uninstall` | Update the CLI now / remove Gipity |
|
|
185
203
|
|
|
186
204
|
Run `gipity --help` for the full list, and `gipity <command> --help` for details.
|
|
187
205
|
|
|
188
|
-
|
|
206
|
+
All commands support `--json` for scripted/programmatic use, except `gipity build`, which hands the terminal to your coding agent.
|
|
189
207
|
|
|
190
208
|
### deploy
|
|
191
209
|
|
|
192
210
|
```bash
|
|
193
|
-
gipity deploy
|
|
194
|
-
gipity deploy prod # Deploy to production
|
|
211
|
+
gipity deploy dev # Deploy the isolated dev environment (created on first use)
|
|
212
|
+
gipity deploy prod # Deploy to production
|
|
195
213
|
```
|
|
196
214
|
|
|
197
|
-
|
|
215
|
+
Prod lives at `https://app.gipity.ai/{account}/{project}/` and `dev` at `https://dev.gipity.ai/{account}/{project}/`. A new app has only prod, so a bare `gipity deploy` deploys prod; once the app has an environment, name the target every time. Other commands take `--env <name>` to act on an environment.
|
|
198
216
|
|
|
199
217
|
### ask
|
|
200
218
|
|
|
@@ -246,7 +264,7 @@ gipity sandbox run --file scripts/report.py
|
|
|
246
264
|
|
|
247
265
|
```bash
|
|
248
266
|
gipity workflow # List workflows
|
|
249
|
-
gipity workflow create workflows/daily_report.yaml
|
|
267
|
+
gipity workflow create --from workflows/daily_report.yaml
|
|
250
268
|
gipity workflow run daily_report # Run now and print each step's output
|
|
251
269
|
gipity workflow enable daily_report # Turn on its schedule
|
|
252
270
|
gipity workflow runs daily_report # View recent runs
|
|
@@ -269,7 +287,7 @@ Created by `gipity init`. Links your local directory to a Gipity project.
|
|
|
269
287
|
|
|
270
288
|
```json
|
|
271
289
|
{
|
|
272
|
-
"projectGuid": "
|
|
290
|
+
"projectGuid": "p_a1b2c3d4",
|
|
273
291
|
"projectSlug": "my-app",
|
|
274
292
|
"accountSlug": "steve",
|
|
275
293
|
"apiBase": "https://a.gipity.ai",
|
package/dist/adopt-cwd.js
CHANGED
|
@@ -41,7 +41,7 @@ export function scanForAdoption(cwd) {
|
|
|
41
41
|
for (const name of entries) {
|
|
42
42
|
if (truncated)
|
|
43
43
|
return;
|
|
44
|
-
if (isSyncIgnored(name))
|
|
44
|
+
if (isSyncIgnored(name, { nested: dir !== cwd }))
|
|
45
45
|
continue;
|
|
46
46
|
const full = join(dir, name);
|
|
47
47
|
let st;
|
|
@@ -86,7 +86,7 @@ export function isLikelyEmpty(cwd) {
|
|
|
86
86
|
catch {
|
|
87
87
|
return true;
|
|
88
88
|
}
|
|
89
|
-
return entries.every(isSyncIgnored);
|
|
89
|
+
return entries.every((name) => isSyncIgnored(name));
|
|
90
90
|
}
|
|
91
91
|
/** Hide-list for "Use this directory" - places where adopting cwd as a
|
|
92
92
|
* project is obviously wrong. Exact-match only; subdirectories are fine
|
package/dist/commands/brand.js
CHANGED
|
@@ -27,7 +27,7 @@ function printBrand(d) {
|
|
|
27
27
|
if (d.branding.tagline)
|
|
28
28
|
console.log(`${bold('Tagline:')} ${d.branding.tagline}`);
|
|
29
29
|
}
|
|
30
|
-
const DEPLOY_HINT = 'Deploy to publish the new assets: gipity deploy
|
|
30
|
+
const DEPLOY_HINT = 'Deploy to publish the new assets: gipity deploy';
|
|
31
31
|
export const brandCommand = new Command('brand')
|
|
32
32
|
.description("The app's generated icons + share card (favicons, iOS icon, og-image)")
|
|
33
33
|
.addHelpText('after', `
|
package/dist/commands/deploy.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import { post } from '../api.js';
|
|
3
|
-
import { requireConfig, resolveApiBase } from '../config.js';
|
|
2
|
+
import { get, post } from '../api.js';
|
|
3
|
+
import { requireConfig, resolveApiBase, getEnvOption } from '../config.js';
|
|
4
4
|
import { formatSize } from '../utils.js';
|
|
5
5
|
import { success, error as clrError, warning, muted, bold, brand } from '../colors.js';
|
|
6
6
|
import { run, syncBeforeAction } from '../helpers/index.js';
|
|
@@ -16,10 +16,39 @@ function statusIcon(status) {
|
|
|
16
16
|
return warning('⚠');
|
|
17
17
|
return muted('→');
|
|
18
18
|
}
|
|
19
|
+
async function printPlan(appGuid, env, json) {
|
|
20
|
+
const res = await get(`/projects/${appGuid}/envs/${encodeURIComponent(env)}/plan`);
|
|
21
|
+
const p = res.data;
|
|
22
|
+
if (json) {
|
|
23
|
+
console.log(JSON.stringify(p));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
console.log(brand(bold(`Deploy plan for ${p.env}`)));
|
|
27
|
+
console.log(muted('─'.repeat(40)));
|
|
28
|
+
if (p.pending.length === 0) {
|
|
29
|
+
console.log(success(`✓ No pending migrations: ${p.env}'s database is up to date.`));
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
for (const m of p.pending) {
|
|
33
|
+
const where = m.ranOn.length
|
|
34
|
+
? muted(`ran on ${m.ranOn.map((r) => `${r.env} ${new Date(r.appliedAt).toLocaleDateString()}`).join(', ')}`)
|
|
35
|
+
: warning('has not run anywhere yet');
|
|
36
|
+
const edited = p.changed.includes(m.file) ? muted(' (edited since it ran here; runs again)') : '';
|
|
37
|
+
console.log(`${m.destructive.length ? clrError('!') : muted('→')} ${bold(m.file)} ${where}${edited}`);
|
|
38
|
+
for (const d of m.destructive)
|
|
39
|
+
console.log(` ${clrError(d)}`);
|
|
40
|
+
}
|
|
41
|
+
if (p.env === 'prod' && p.pending.some((m) => m.destructive.length)) {
|
|
42
|
+
console.log('');
|
|
43
|
+
console.log(warning('A prod deploy stops on the destructive statements above until you pass --yes-destructive.'));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
19
46
|
// ── Main Deploy Command ────────────────────────────────────────────────
|
|
20
47
|
export const deployCommand = new Command('deploy')
|
|
21
|
-
.description('Deploy to
|
|
22
|
-
.argument('[
|
|
48
|
+
.description('Deploy the app to prod, or to an environment (created on first deploy)')
|
|
49
|
+
.argument('[env]', 'prod, or an environment name (dev, staging, ...). Omitted: prod while the app has no environments; once it has any, name one')
|
|
50
|
+
.option('--yes-destructive', 'Allow pending prod migrations that destroy data (DROP TABLE/COLUMN, TRUNCATE, DELETE without WHERE, column type changes)')
|
|
51
|
+
.option('--plan', 'Show the pending migrations this deploy would run (and where each already ran), without deploying')
|
|
23
52
|
.option('--source-dir <dir>', 'Source directory to deploy from')
|
|
24
53
|
.option('--only <phases>', 'Run only specific phases, comma-separated, matched by gipity.yaml phase name or type: files/static, database/sql, functions, workflows, services, jobs, records, realtime, env, auth_branding')
|
|
25
54
|
.option('--force', 'Re-run all phases (ignore checksums) and bypass the sync bulk-deletion guard')
|
|
@@ -35,10 +64,12 @@ export const deployCommand = new Command('deploy')
|
|
|
35
64
|
.option('--wait <ms>', 'With --inspect: sleep this many ms before capturing (max 30000)')
|
|
36
65
|
.option('--wait-for <selector>', "With --inspect: wait until this CSS selector appears before capturing (deterministic; the app's own ready signal)")
|
|
37
66
|
.option('--wait-timeout <ms>', 'With --inspect: max ms to wait for --wait-for before giving up', '5000')
|
|
38
|
-
.action((
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
67
|
+
.action((envArg, opts) => run('Deploy', async () => {
|
|
68
|
+
// `gipity deploy staging` and `gipity deploy --env staging` are the same.
|
|
69
|
+
const env = envArg ?? getEnvOption();
|
|
70
|
+
if (opts.plan) {
|
|
71
|
+
await printPlan(requireConfig().projectGuid, env ?? 'prod', !!opts.json);
|
|
72
|
+
return;
|
|
42
73
|
}
|
|
43
74
|
// A settle flag only means one thing on a deploy: "verify the page once it's
|
|
44
75
|
// up, and give it time to come up." Asking for it without --inspect is not an
|
|
@@ -49,7 +80,8 @@ export const deployCommand = new Command('deploy')
|
|
|
49
80
|
const config = requireConfig();
|
|
50
81
|
await syncBeforeAction(opts);
|
|
51
82
|
const doDeploy = () => post(`/projects/${config.projectGuid}/deploy`, {
|
|
52
|
-
|
|
83
|
+
...(env ? { env } : {}),
|
|
84
|
+
...(opts.yesDestructive ? { yesDestructive: true } : {}),
|
|
53
85
|
sourceDir: opts.sourceDir,
|
|
54
86
|
optimize: opts.optimize,
|
|
55
87
|
force: opts.force,
|
|
@@ -57,8 +89,9 @@ export const deployCommand = new Command('deploy')
|
|
|
57
89
|
});
|
|
58
90
|
const res = opts.json
|
|
59
91
|
? await doDeploy()
|
|
60
|
-
: await withSpinner(`Deploying to ${
|
|
92
|
+
: await withSpinner(env ? `Deploying to ${env}...` : 'Deploying...', doDeploy, { done: null });
|
|
61
93
|
const d = res.data;
|
|
94
|
+
const where = d.env ?? d.target;
|
|
62
95
|
// Deploy + verify in one command: after a successful deploy, run the
|
|
63
96
|
// same inspect pipeline `page inspect` uses against the live URL. An
|
|
64
97
|
// inspect failure is reported but never turns a successful deploy into
|
|
@@ -88,13 +121,17 @@ export const deployCommand = new Command('deploy')
|
|
|
88
121
|
if (opts.json) {
|
|
89
122
|
console.log(JSON.stringify(d));
|
|
90
123
|
const failedJson = d.phases?.some(p => p.status === 'failed');
|
|
91
|
-
|
|
92
|
-
|
|
124
|
+
// The exit code carries the outcome too, so a script reading --json
|
|
125
|
+
// can't mistake a failed deploy (e.g. a refused destructive migration)
|
|
126
|
+
// for a good one.
|
|
127
|
+
if (failedJson)
|
|
128
|
+
process.exit(1);
|
|
129
|
+
await inspectAfter();
|
|
93
130
|
return;
|
|
94
131
|
}
|
|
95
132
|
// Format output
|
|
96
133
|
const batchLabel = d.batch ? muted(` (batch ${d.batch})`) : '';
|
|
97
|
-
console.log(brand(bold(`Deploy to ${
|
|
134
|
+
console.log(brand(bold(`Deploy to ${where}`)) + batchLabel + (d.created ? muted(' (new environment)') : ''));
|
|
98
135
|
console.log(muted('─'.repeat(40)));
|
|
99
136
|
if (d.phases && d.phases.length > 0) {
|
|
100
137
|
for (const phase of d.phases) {
|
|
@@ -140,7 +177,7 @@ export const deployCommand = new Command('deploy')
|
|
|
140
177
|
process.exit(1);
|
|
141
178
|
}
|
|
142
179
|
else {
|
|
143
|
-
console.log(success(`✓ Deployed to ${
|
|
180
|
+
console.log(success(`✓ Deployed to ${where}`) + muted(` (${d.elapsedMs}ms)`));
|
|
144
181
|
// The live URL is the one thing the caller (often an agent) needs next
|
|
145
182
|
// - to open it, inspect it, or report it. Always surface it so nobody
|
|
146
183
|
// has to reconstruct the URL convention or guess a subdomain.
|
|
@@ -154,9 +191,13 @@ export const deployCommand = new Command('deploy')
|
|
|
154
191
|
// --api-base flag and GIPITY_API_BASE env), not the raw stored
|
|
155
192
|
// config.apiBase - otherwise on any override we'd advertise a host we
|
|
156
193
|
// didn't deploy to and send the caller probing the wrong instance.
|
|
157
|
-
console.log(`${muted('Functions:')} POST ${brand(`${resolveApiBase()}/api/${config.projectGuid}/fn/<name>`)}`);
|
|
158
|
-
|
|
194
|
+
console.log(`${muted('Functions:')} POST ${brand(`${resolveApiBase()}/api/${d.appGuid ?? config.projectGuid}/fn/<name>`)}`);
|
|
195
|
+
// Each environment has its own functions at its own address.
|
|
196
|
+
const envFlag = d.env && d.env !== 'prod' ? ` --env ${d.env}` : '';
|
|
197
|
+
console.log(muted(` (names: gipity fn list${envFlag}; verify the public path: gipity fn call <name>${envFlag} --anon)`));
|
|
159
198
|
}
|
|
199
|
+
for (const hint of d.hints ?? [])
|
|
200
|
+
console.log(muted(hint));
|
|
160
201
|
await inspectAfter();
|
|
161
202
|
}
|
|
162
203
|
}));
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { get, post, patch, del } from '../api.js';
|
|
3
|
+
import { requireConfig, PROD_ENV } from '../config.js';
|
|
4
|
+
import { formatSize } from '../utils.js';
|
|
5
|
+
import { success, error as clrError, muted, bold, brand } from '../colors.js';
|
|
6
|
+
import { run } from '../helpers/index.js';
|
|
7
|
+
import { confirm } from '../utils.js';
|
|
8
|
+
import { withSpinner } from '../progress.js';
|
|
9
|
+
/** The app's guid: env commands always act on the app, whatever --env says. */
|
|
10
|
+
function appGuid() {
|
|
11
|
+
return requireConfig().projectGuid;
|
|
12
|
+
}
|
|
13
|
+
export const envCommand = new Command('env')
|
|
14
|
+
.description('App environments: prod plus any number of isolated copies (dev, staging, ...), each with its own database, functions and URL')
|
|
15
|
+
.addHelpText('after', `
|
|
16
|
+
An environment is created the first time you deploy to it:
|
|
17
|
+
gipity deploy dev # creates "dev" (own DB from migrations, own functions), deploys
|
|
18
|
+
gipity deploy prod # the live app
|
|
19
|
+
|
|
20
|
+
Run any project command against one with --env:
|
|
21
|
+
gipity db query "SELECT count(*) FROM orders" --env dev
|
|
22
|
+
gipity fn call checkout --env staging
|
|
23
|
+
gipity logs fn checkout --env dev
|
|
24
|
+
|
|
25
|
+
Envs share the app's secrets (an env can override one: gipity secrets set NAME value --env staging),
|
|
26
|
+
members and players. Cron workflows are off in an env until: gipity env set <name> --schedules on.
|
|
27
|
+
Email from an env reaches only the app owner and members; payments run in prod only.`);
|
|
28
|
+
envCommand
|
|
29
|
+
.command('list', { isDefault: true })
|
|
30
|
+
.description('List the app\'s environments')
|
|
31
|
+
.option('--json', 'Output as JSON')
|
|
32
|
+
.action((opts) => run('Env', async () => {
|
|
33
|
+
const res = await get(`/projects/${appGuid()}/envs`);
|
|
34
|
+
const d = res.data;
|
|
35
|
+
if (opts.json) {
|
|
36
|
+
console.log(JSON.stringify(d));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
console.log(`${bold('prod')} ${brand(d.prod.url)}`);
|
|
40
|
+
if (d.envs.length === 0) {
|
|
41
|
+
console.log(muted('No environments yet. `gipity deploy dev` creates one.'));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
for (const e of d.envs) {
|
|
45
|
+
const deployed = e.lastDeploy ? `deployed ${new Date(e.lastDeploy).toLocaleString()}` : 'never deployed';
|
|
46
|
+
const parts = [deployed, `DB ${formatSize(e.dbBytes)}`, e.schedules ? 'schedules on' : 'schedules off'];
|
|
47
|
+
if (e.customDomains.length)
|
|
48
|
+
parts.push(e.customDomains.join(', '));
|
|
49
|
+
console.log(`${bold(e.name)} ${brand(e.url)} ${muted(parts.join(' · '))}`);
|
|
50
|
+
}
|
|
51
|
+
}));
|
|
52
|
+
function printCopy(copy) {
|
|
53
|
+
if (!copy)
|
|
54
|
+
return;
|
|
55
|
+
for (const d of copy.databases) {
|
|
56
|
+
console.log(muted(`Copied ${d.rows} rows (${d.tables} tables) from ${copy.from}'s ${d.database} database`));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
envCommand
|
|
60
|
+
.command('create <name>')
|
|
61
|
+
.description('Create an environment and deploy the app to it (`gipity deploy <name>` does the same, without --data)')
|
|
62
|
+
.option('--data', 'Copy the rows of prod (or --from) into it, to try a change against real data')
|
|
63
|
+
.option('--from <env>', 'With --data: the environment to copy from (default prod)')
|
|
64
|
+
.option('--json', 'Output as JSON')
|
|
65
|
+
.action((name, opts) => run('Env', async () => {
|
|
66
|
+
if (name === PROD_ENV) {
|
|
67
|
+
console.error(clrError('prod is the app itself. Deploy it with: gipity deploy prod'));
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
if (opts.from && !opts.data) {
|
|
71
|
+
console.error(clrError('--from goes with --data'));
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
const create = () => post(`/projects/${appGuid()}/envs`, { name, ...(opts.data ? { data: true } : {}), ...(opts.from ? { from: opts.from } : {}) });
|
|
75
|
+
const res = opts.json ? await create() : await withSpinner(`Creating ${name}...`, create, { done: null });
|
|
76
|
+
if (opts.json) {
|
|
77
|
+
console.log(JSON.stringify(res.data));
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const failed = res.data.phases.filter((p) => p.status === 'failed');
|
|
81
|
+
for (const p of failed)
|
|
82
|
+
console.log(`${clrError('✗')} ${bold(p.name)}: ${p.summary}`);
|
|
83
|
+
if (failed.length > 0) {
|
|
84
|
+
console.log(clrError(`Created ${name}, but its first deploy failed. Fix it and run: gipity deploy ${name}`));
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
console.log(success(`✓ Created ${name}`));
|
|
88
|
+
printCopy(res.data.data);
|
|
89
|
+
console.log(`${muted('Live:')} ${brand(res.data.url)}`);
|
|
90
|
+
}));
|
|
91
|
+
envCommand
|
|
92
|
+
.command('reset <name>')
|
|
93
|
+
.description('Start an environment over: drop its database, rerun every migration from zero, redeploy')
|
|
94
|
+
.option('--data', 'Then copy the rows of prod (or --from) into it')
|
|
95
|
+
.option('--from <env>', 'With --data: the environment to copy from (default prod)')
|
|
96
|
+
.option('--json', 'Output as JSON')
|
|
97
|
+
.action((name, opts) => run('Env', async () => {
|
|
98
|
+
if (name === PROD_ENV) {
|
|
99
|
+
console.error(clrError('prod can\'t be reset.'));
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
if (opts.from && !opts.data) {
|
|
103
|
+
console.error(clrError('--from goes with --data'));
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
const ok = await confirm(`Reset ${bold(name)}? Its database is dropped and rebuilt${opts.data ? ` from ${opts.from ?? 'prod'}'s data` : ' empty'}.`, { default: 'no' });
|
|
107
|
+
if (!ok) {
|
|
108
|
+
console.log(muted('Aborted.'));
|
|
109
|
+
process.exit(1);
|
|
110
|
+
}
|
|
111
|
+
const reset = () => post(`/projects/${appGuid()}/envs/${encodeURIComponent(name)}/reset`, { ...(opts.data ? { data: true } : {}), ...(opts.from ? { from: opts.from } : {}) });
|
|
112
|
+
const res = opts.json ? await reset() : await withSpinner(`Resetting ${name}...`, reset, { done: null });
|
|
113
|
+
if (opts.json) {
|
|
114
|
+
console.log(JSON.stringify(res.data));
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const failed = res.data.phases.filter((p) => p.status === 'failed');
|
|
118
|
+
for (const p of failed)
|
|
119
|
+
console.log(`${clrError('✗')} ${bold(p.name)}: ${p.summary}`);
|
|
120
|
+
if (failed.length > 0) {
|
|
121
|
+
console.log(clrError(`Reset ${name}, but its deploy failed.`));
|
|
122
|
+
process.exit(1);
|
|
123
|
+
}
|
|
124
|
+
console.log(success(`✓ Reset ${name}`));
|
|
125
|
+
printCopy(res.data.data);
|
|
126
|
+
if (res.data.url)
|
|
127
|
+
console.log(`${muted('Live:')} ${brand(res.data.url)}`);
|
|
128
|
+
}));
|
|
129
|
+
envCommand
|
|
130
|
+
.command('set <name>')
|
|
131
|
+
.description('Change an environment\'s settings')
|
|
132
|
+
.requiredOption('--schedules <on|off>', 'Turn the environment\'s cron workflows on or off')
|
|
133
|
+
.option('--json', 'Output as JSON')
|
|
134
|
+
.action((name, opts) => run('Env', async () => {
|
|
135
|
+
const value = String(opts.schedules).toLowerCase();
|
|
136
|
+
if (value !== 'on' && value !== 'off') {
|
|
137
|
+
console.error(clrError('--schedules takes on or off'));
|
|
138
|
+
process.exit(1);
|
|
139
|
+
}
|
|
140
|
+
const res = await patch(`/projects/${appGuid()}/envs/${encodeURIComponent(name)}`, { schedules: value === 'on' });
|
|
141
|
+
if (opts.json) {
|
|
142
|
+
console.log(JSON.stringify(res.data));
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
console.log(success(`✓ Schedules ${value} in ${name}`));
|
|
146
|
+
}));
|
|
147
|
+
envCommand
|
|
148
|
+
.command('delete <name>')
|
|
149
|
+
.description('Delete an environment: its database, functions, files and custom domains (never prod)')
|
|
150
|
+
.option('--json', 'Output as JSON')
|
|
151
|
+
.action((name, opts) => run('Env', async () => {
|
|
152
|
+
if (name === PROD_ENV) {
|
|
153
|
+
console.error(clrError('prod is the app itself and can\'t be deleted as an environment.'));
|
|
154
|
+
process.exit(1);
|
|
155
|
+
}
|
|
156
|
+
const ok = await confirm(`Delete the ${bold(name)} environment and its database?`, { default: 'no' });
|
|
157
|
+
if (!ok) {
|
|
158
|
+
console.log(muted('Aborted.'));
|
|
159
|
+
process.exit(1);
|
|
160
|
+
}
|
|
161
|
+
const res = await del(`/projects/${appGuid()}/envs/${encodeURIComponent(name)}`);
|
|
162
|
+
if (opts.json) {
|
|
163
|
+
console.log(JSON.stringify(res.data));
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
console.log(success(`✓ Deleted ${name}`));
|
|
167
|
+
}));
|
|
168
|
+
//# sourceMappingURL=env.js.map
|
package/dist/commands/file.js
CHANGED
|
@@ -62,8 +62,12 @@ fileCommand
|
|
|
62
62
|
.option('--json', 'Output as JSON')
|
|
63
63
|
.action((path, opts) => run('Tree', async () => {
|
|
64
64
|
const { config } = await resolveProjectContext();
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
// A listing shows everything, app runtime uploads included (sync leaves
|
|
66
|
+
// those out; they stay in Gipity Storage).
|
|
67
|
+
const qs = new URLSearchParams({ include: 'app_uploads' });
|
|
68
|
+
if (path)
|
|
69
|
+
qs.set('path', path);
|
|
70
|
+
const res = await get(`/projects/${config.projectGuid}/files/tree?${qs.toString()}`);
|
|
67
71
|
printList(res.data, opts, '(empty)', f => {
|
|
68
72
|
const size = f.type === 'dir' ? '' : ` (${formatSize(Number(f.size))})`;
|
|
69
73
|
return `${f.path}${size}`;
|
package/dist/commands/fn.js
CHANGED
|
@@ -21,7 +21,7 @@ fnCommand
|
|
|
21
21
|
// The callable address is the deliverable for API-only apps - name it here
|
|
22
22
|
// rather than leaving it to be inferred from a template comment.
|
|
23
23
|
if (!opts.json && res.data.length > 0) {
|
|
24
|
-
console.log(muted(`Endpoint: POST ${resolveApiBase()}/api/${config.projectGuid}/fn/<name> (
|
|
24
|
+
console.log(muted(`Endpoint: POST ${resolveApiBase()}/api/${config.projectGuid}/fn/<name> (this is ${config.env ? `the ${config.env.name} environment` : 'prod'}; each environment has its own address, see --env; public path: gipity fn call <name> --anon)`));
|
|
25
25
|
}
|
|
26
26
|
}));
|
|
27
27
|
fnCommand
|