@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 +10 -3
- package/package.json +1 -1
- package/src/sync.js +21 -2
- package/templates/hosted-app/README.md +2 -1
- package/templates/hosted-app/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Develop and synchronize Auto Appy applications from VS Code.
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
##
|
|
45
|
+
## Backend contract
|
|
39
46
|
|
|
40
|
-
The
|
|
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
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
|
|
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
|
|
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.
|