Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: store writer framework IDE into project directory instead of ui.json - WF-43 #526

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions alfred/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import os

from writer import audit_and_fix, wf_project

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

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
components = audit_and_fix.fix_components(components)
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": {"expression": true, "binding": "", "reversed": false}}
{"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": {"expression": true, "binding": "", "reversed": false}}
{"id": "ejpasds0o8qyjs1n", "type": "section", "content": {"title": "Section Title"}, "isCodeManaged": false, "position": 1, "parentId": "c0f99a9e-5004-4e75-a6c6-36f17490b134", "handlers": {}, "visible": {"expression": true, "binding": "", "reversed": false}}
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": {"expression": true, "binding": "", "reversed": false}}
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": {"expression": true, "binding": "", "reversed": false}}
{"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": {"expression": true, "binding": "", "reversed": false}}
{"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": {"expression": true, "binding": "", "reversed": false}}
{"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": {"expression": true, "binding": "", "reversed": false}}
{"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": {"expression": true, "binding": "", "reversed": false}}
{"id": "0d05bc9f-1655-4d0b-bc9b-c2f4c71a5117", "type": "horizontalstack", "content": {"contentHAlign": "center"}, "isCodeManaged": false, "position": 0, "parentId": "f3777e75-3659-4d44-8ef7-aeec0d06855b", "handlers": {}, "visible": {"expression": true, "binding": "", "reversed": false}}
{"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": {"expression": true, "binding": "", "reversed": false}}
{"id": "d4a5e62c-c6fe-49c4-80d4-33862af8727d", "type": "columns", "content": {}, "isCodeManaged": false, "position": 0, "parentId": "28d3885b-0fb8-4d41-97c6-978540015431", "handlers": {}, "visible": {"expression": true, "binding": "", "reversed": false}}
{"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": {"expression": true, "binding": "", "reversed": false}}
{"id": "c2519671-9ce7-44e7-ba4e-b0efda9cb20e", "type": "column", "content": {"width": "1"}, "isCodeManaged": false, "position": 0, "parentId": "d4a5e62c-c6fe-49c4-80d4-33862af8727d", "handlers": {}, "visible": {"expression": true, "binding": "", "reversed": false}}
{"id": "d4a71819-7444-4083-a1c7-7995452a7abf", "type": "separator", "content": {}, "isCodeManaged": false, "position": 1, "parentId": "d4a5e62c-c6fe-49c4-80d4-33862af8727d", "handlers": {}, "visible": {"expression": true, "binding": "", "reversed": false}}
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": {"expression": true, "binding": "", "reversed": false}}
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
Loading