Skip to content

Commit

Permalink
feat: store writer framework IDE into project directory instead of ui…
Browse files Browse the repository at this point in the history
….json

* feat: read file from .wf directory
* feat: create a command to migrate an application
* feat: migrate all the applications
* feat: implement migration process when ui.json is present
  • Loading branch information
FabienArcellier committed Sep 14, 2024
1 parent 1b4e80d commit a4cc175
Show file tree
Hide file tree
Showing 57 changed files with 644 additions and 2,247 deletions.
47 changes: 47 additions & 0 deletions alfred/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import os

import alfred


@alfred.command('apps.update', help='update the apps in the repo to the latest version')
@alfred.option('--app', help='the path of the app to update')
def apps_update(app: str = None):
import writer
from writer.core import (
wf_project_migrate_obsolete_ui_json,
wf_project_read_files,
wf_project_write_files,
)

if app is not None:
apps = [app]
else:
apps = [
'apps/ai-starter',
'apps/default',
'apps/hello',
'apps/pdg-tutorial',
'apps/quickstart',
'apps/text-demo',
'tests/backend/testapp',
'tests/backend/testbasicauth',
'tests/backend/testmultiapp/app1',
'tests/backend/testmultiapp/app2',
]

for app in apps:
abs_path = os.path.realpath(app)
if not os.path.isdir(abs_path):
continue

if os.path.isfile(os.path.join(abs_path, "ui.json")):
print(f'{app} : migrate ui.json')
wf_project_migrate_obsolete_ui_json(abs_path)

metadata, components = wf_project_read_files(abs_path)
if metadata.get('writer_version') == writer.VERSION:
print("The app is already up to date")
else:
metadata['writer_version'] = writer.VERSION
wf_project_write_files(abs_path, metadata, components)
print(f"{app} : app is up to date")
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{"id": "c0f99a9e-5004-4e75-a6c6-36f17490b134", "type": "page", "content": {"pageMode": "compact"}, "isCodeManaged": false, "position": 0, "parentId": "root", "handlers": {}, "visible": true}
{"id": "bebc5fe9-63a7-46a7-b0fa-62303555cfaf", "type": "header", "content": {"text": "@{my_app.title}"}, "isCodeManaged": false, "position": 0, "parentId": "c0f99a9e-5004-4e75-a6c6-36f17490b134", "handlers": {}, "visible": true}
{"id": "ejpasds0o8qyjs1n", "type": "section", "content": {"title": "Section Title"}, "isCodeManaged": false, "position": 1, "parentId": "c0f99a9e-5004-4e75-a6c6-36f17490b134", "handlers": {}, "visible": true}
1 change: 1 addition & 0 deletions apps/ai-starter/.wf/components-root.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "root", "type": "root", "content": {"appName": "AI Starter"}, "isCodeManaged": false, "position": 0, "handlers": {}, "visible": true}
3 changes: 3 additions & 0 deletions apps/ai-starter/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"writer_version": "0.7.0rc2"
}
54 changes: 0 additions & 54 deletions apps/ai-starter/ui.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{"id": "c0f99a9e-5004-4e75-a6c6-36f17490b134", "type": "page", "content": {"pageMode": "compact"}, "isCodeManaged": false, "position": 0, "parentId": "root", "handlers": {}, "visible": true}
{"id": "bebc5fe9-63a7-46a7-b0fa-62303555cfaf", "type": "header", "content": {"text": "@{my_app.title}"}, "isCodeManaged": false, "position": 0, "parentId": "c0f99a9e-5004-4e75-a6c6-36f17490b134", "handlers": {}, "visible": true}
{"id": "28d3885b-0fb8-4d41-97c6-978540015431", "type": "section", "content": {"title": "", "containerShadow": "0px 4px 11px -12px #000000"}, "isCodeManaged": false, "position": 1, "parentId": "c0f99a9e-5004-4e75-a6c6-36f17490b134", "handlers": {}, "visible": true}
{"id": "9556c0e3-8584-4ac9-903f-908a775a33ec", "type": "button", "content": {"text": " Increment", "icon": "arrow_upward"}, "isCodeManaged": false, "position": 1, "parentId": "0d05bc9f-1655-4d0b-bc9b-c2f4c71a5117", "handlers": {"click": "increment"}, "visible": true}
{"id": "51d1554e-1b88-461c-9353-1419cba0053a", "type": "button", "content": {"text": "Decrement", "icon": "arrow_downward"}, "isCodeManaged": false, "position": 0, "parentId": "0d05bc9f-1655-4d0b-bc9b-c2f4c71a5117", "handlers": {"click": "decrement"}, "visible": true}
{"id": "0d05bc9f-1655-4d0b-bc9b-c2f4c71a5117", "type": "horizontalstack", "content": {"contentHAlign": "center"}, "isCodeManaged": false, "position": 0, "parentId": "f3777e75-3659-4d44-8ef7-aeec0d06855b", "handlers": {}, "visible": true}
{"id": "172a14df-f73a-44fa-8fb1-e8648e7d32d2", "type": "metric", "content": {"metricValue": "@{counter}", "note": "@{message}", "name": "Counter"}, "isCodeManaged": false, "position": 0, "parentId": "c2519671-9ce7-44e7-ba4e-b0efda9cb20e", "handlers": {}, "visible": true}
{"id": "d4a5e62c-c6fe-49c4-80d4-33862af8727d", "type": "columns", "content": {}, "isCodeManaged": false, "position": 0, "parentId": "28d3885b-0fb8-4d41-97c6-978540015431", "handlers": {}, "visible": true}
{"id": "f3777e75-3659-4d44-8ef7-aeec0d06855b", "type": "column", "content": {"title": "", "width": "1", "contentHAlign": "center", "contentVAlign": "center"}, "isCodeManaged": false, "position": 2, "parentId": "d4a5e62c-c6fe-49c4-80d4-33862af8727d", "handlers": {}, "visible": true}
{"id": "c2519671-9ce7-44e7-ba4e-b0efda9cb20e", "type": "column", "content": {"width": "1"}, "isCodeManaged": false, "position": 0, "parentId": "d4a5e62c-c6fe-49c4-80d4-33862af8727d", "handlers": {}, "visible": true}
{"id": "d4a71819-7444-4083-a1c7-7995452a7abf", "type": "separator", "content": {}, "isCodeManaged": false, "position": 1, "parentId": "d4a5e62c-c6fe-49c4-80d4-33862af8727d", "handlers": {}, "visible": true}
1 change: 1 addition & 0 deletions apps/default/.wf/components-root.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "root", "type": "root", "content": {"appName": "My App"}, "isCodeManaged": false, "position": 0, "handlers": {}, "visible": true}
3 changes: 3 additions & 0 deletions apps/default/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"writer_version": "0.7.0rc2"
}
146 changes: 0 additions & 146 deletions apps/default/ui.json

This file was deleted.

Loading

0 comments on commit a4cc175

Please sign in to comment.