@autoappy/cli 0.1.0-beta.0 → 0.2.0-beta.0

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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Develop and synchronize Auto Appy applications from VS Code.
4
4
 
5
- > Beta contract: the CLI is implemented and locally tested, but app source pull/push requires the matching Auto Appy backend source endpoints before public use.
5
+ The CLI keeps the hosted frontend, managed database schema, and saved APIs synchronized with one Auto Appy app.
6
6
 
7
7
  ## Start a project
8
8
 
@@ -17,6 +17,13 @@ npm run dev
17
17
 
18
18
  The starter keeps credentials in `.env` and non-secret project identity in `autoappy.json`.
19
19
 
20
+ ```dotenv
21
+ AUTOAPPY_BASE_URL=https://api.autoappy.com
22
+ AUTOAPPY_APP_TOKEN=aa_app_your_token
23
+ ```
24
+
25
+ Create the token from the app's **Develop in VS Code** page with `data:read`, `data:write`, `api:manage`, `schema:manage`, `app:read`, and `app:deploy`. The token is limited to the apps selected when it is created. Never commit `.env`.
26
+
20
27
  ## Commands
21
28
 
22
29
  ```text
@@ -35,9 +42,9 @@ autoappy check
35
42
 
36
43
  Database synchronization covers schema only. Customer records are never copied into the project or Git by these commands.
37
44
 
38
- ## Required backend contract
45
+ ## Backend contract
39
46
 
40
- The current Auto Appy development-kit, schema and managed-API endpoints are used directly. Frontend synchronization additionally requires:
47
+ The Auto Appy development-kit, schema, managed-API, and versioned frontend endpoints are used directly:
41
48
 
42
49
  ```text
43
50
  GET /api/v1/platform/organisations/{workspace}/data/apps/{app}/source
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autoappy/cli",
3
- "version": "0.1.0-beta.0",
3
+ "version": "0.2.0-beta.0",
4
4
  "description": "Develop and synchronize Auto Appy applications from VS Code.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/sync.js CHANGED
@@ -30,7 +30,15 @@ export function mergeProjects({ baseline, local, remote }) {
30
30
 
31
31
  export async function pullCode({ root, client }) {
32
32
  const remote = await client.source();
33
- if (!remote?.project || !Number.isInteger(remote.version)) throw new Error('The backend does not yet provide the Auto Appy app-source synchronization contract.');
33
+ if (!remote || !Number.isInteger(remote.version) || (remote.project === undefined)) throw new Error('Auto Appy returned an incomplete app-source response.');
34
+ if (remote.project === null) {
35
+ if (remote.version !== 0 || !remote.source_hash) throw new Error('Auto Appy returned an invalid blank app source.');
36
+ const state = readState(root);
37
+ const local = readLocalProject(root);
38
+ state.code = { version: 0, sourceHash: remote.source_hash, project: null };
39
+ writeState(root, state);
40
+ return { files: local.files.length, preserved: true, blank: true };
41
+ }
34
42
  const project = normalizeViewProject(remote.project);
35
43
  const state = readState(root);
36
44
  const local = readLocalProject(root);
@@ -48,8 +56,19 @@ export async function pullCode({ root, client }) {
48
56
  export async function pushCode({ root, client }) {
49
57
  const local = readLocalProject(root);
50
58
  const remote = await client.source();
51
- if (!remote?.project || !Number.isInteger(remote.version)) throw new Error('The backend does not yet provide the Auto Appy app-source synchronization contract.');
59
+ if (!remote || !Number.isInteger(remote.version) || remote.project === undefined) throw new Error('Auto Appy returned an incomplete app-source response.');
52
60
  const state = readState(root);
61
+ if (remote.project === null) {
62
+ if (remote.version !== 0 || !remote.source_hash) throw new Error('Auto Appy returned an invalid blank app source.');
63
+ if (!state.code || state.code.project !== null || state.code.version !== 0 || state.code.sourceHash !== remote.source_hash) {
64
+ throw new Error('Pull the blank app before its first push so Auto Appy can protect remote changes.');
65
+ }
66
+ const saved = await client.saveSource({ expected_version: 0, source_hash: remote.source_hash, request_id: crypto.randomUUID(), project: local });
67
+ if (!saved || !Number.isInteger(saved.version)) throw new Error('Auto Appy returned an incomplete deployment receipt. Check the app before retrying.');
68
+ state.code = { version: saved.version, sourceHash: saved.source_hash || hash(local), project: local, deploymentId: saved.deployment_id || null };
69
+ writeState(root, state);
70
+ return { changed: true, version: saved.version, files: local.files.length, live: saved.status === 'published' };
71
+ }
53
72
  const remoteProject = normalizeViewProject(remote.project);
54
73
  const baseline = state.code?.project;
55
74
  if (!baseline && hash(local) !== hash(remoteProject)) throw new Error('Pull the app before its first push so Auto Appy can protect remote changes.');
@@ -4,6 +4,7 @@
4
4
  2. Set `AUTOAPPY_BASE_URL` and `AUTOAPPY_APP_TOKEN` in `.env`.
5
5
  3. Run `npm install` and `npm run pull`.
6
6
  4. Develop with `npm run dev`.
7
- 5. Review with `npm run status`, then publish with `npm run push`.
7
+ 5. Review with `npm run status`, then publish the database, APIs, and frontend with `npm run push`.
8
8
 
9
9
  Database commands synchronize schema definitions, not customer records.
10
+ The first pull keeps this starter when the Auto Appy app has no frontend yet. The first push creates and publishes it.
@@ -21,7 +21,7 @@
21
21
  "react-dom": "18.3.1"
22
22
  },
23
23
  "devDependencies": {
24
- "@autoappy/cli": "0.1.0-beta.0",
24
+ "@autoappy/cli": "0.2.0-beta.0",
25
25
  "vite": "6.1.0"
26
26
  },
27
27
  "engines": {