-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #588 from writer/dev
chore: Merge for release
- Loading branch information
Showing
189 changed files
with
5,531 additions
and
4,014 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: doc-notify | ||
|
||
on: | ||
pull_request_target: | ||
types: [closed] | ||
branches: | ||
- dev | ||
|
||
jobs: | ||
notify: | ||
if: github.event.pull_request.merged == true | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install poetry | ||
run: pipx install poetry | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.12" | ||
cache: 'poetry' | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20.x" | ||
cache: npm | ||
|
||
- name: install python3 environment | ||
run: poetry install --with build | ||
|
||
- name: notify slack channel | ||
run: poetry run alfred github.notify-changes-doc --slack-webhook $SLACK_WEBHOOK_DOC | ||
env: | ||
SLACK_WEBHOOK_DOC: ${{ secrets.SLACK_WEBHOOK_DOC }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
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', | ||
'tests/e2e/presets/2columns', | ||
'tests/e2e/presets/2pages', | ||
'tests/e2e/presets/empty_page', | ||
'tests/e2e/presets/jsonviewer', | ||
'tests/e2e/presets/low_code', | ||
'tests/e2e/presets/section', | ||
'tests/e2e/presets/state', | ||
] | ||
|
||
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) | ||
|
||
if not os.path.isfile(os.path.join(abs_path, ".wf", 'components-workflows_root.jsonl')): | ||
wf_project.create_default_workflows_root(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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
import json | ||
import logging | ||
import os.path | ||
from typing import Any, List, Tuple | ||
|
||
import requests | ||
|
||
import alfred | ||
|
||
|
||
@alfred.command("github.notify-changes-doc") | ||
@alfred.option("--remote", default="origin") | ||
@alfred.option("--branch", default="dev") | ||
@alfred.option("--commit", default="HEAD") | ||
@alfred.option("--dry", is_flag=True) | ||
@alfred.option("--slack-webhook", default=None) | ||
def notify_doc_changes(remote: str, branch: str, commit: str, dry: bool, slack_webhook: str = None): | ||
logger = logging.getLogger("alfred") | ||
logger.setLevel(logging.INFO) | ||
logger.info(f"remote: {remote}, branch: {branch}, commit: {commit}, dry: {dry}") | ||
|
||
sections = { | ||
'components': [ | ||
'src/components/core/content', | ||
'src/components/core/embed', | ||
'src/components/core/input', | ||
'src/components/core/layout', | ||
'src/components/core/other', | ||
'src/components/core/root', | ||
], | ||
'documentation': [ | ||
'docs/framework', | ||
], | ||
} | ||
|
||
if commit == "HEAD": | ||
_, stdout, _ = alfred.run("git rev-parse HEAD") | ||
commit = stdout.strip() | ||
|
||
all_change_types = ['A', 'M', 'D'] | ||
|
||
file_changes: List[Tuple[str, str]] = [] | ||
component_added: List[Tuple[str, str]] = [] | ||
documentation_changes: List[Tuple[str, str]] = [] | ||
|
||
_, stdout, _ = alfred.run("git rev-parse --is-shallow-repository") | ||
if stdout.strip() == "true": | ||
alfred.run(f"git fetch --unshallow {remote} {branch}") | ||
else: | ||
alfred.run(f"git fetch {remote} {branch}") | ||
|
||
for change in all_change_types: | ||
_, stdout, _ = alfred.run(f"git diff --name-only --diff-filter={change} {commit}^ {commit}") | ||
file_changes += [(f, change) for f in stdout.splitlines() if f.strip() != ""] | ||
|
||
file_changes = sorted(file_changes, key=lambda x: x[0]) | ||
for change in all_change_types: | ||
for f in [f for f, _change in file_changes if _change == change]: | ||
for path in sections['documentation']: | ||
if f.startswith(path): | ||
documentation_changes.append((f, change)) | ||
|
||
for change in ['A']: | ||
for f in [f for f, _change in file_changes if _change == change]: | ||
for path in sections['components']: | ||
if f.startswith(path): | ||
component_added.append((f, 'A')) | ||
|
||
logger.info(f"Documentation changes: {documentation_changes}") | ||
logger.info(f"Component added: {component_added} - not used yet") | ||
|
||
if dry is None: | ||
message_documentations = _build_slack_message_documentation(documentation_changes, commit) | ||
if len(message_documentations) > 0: | ||
msg = {} | ||
msg['blocks'] = [] | ||
msg['blocks'] += message_documentations | ||
response = requests.post( | ||
slack_webhook, data=json.dumps(msg), | ||
headers={'Content-Type': 'application/json'} | ||
) | ||
|
||
if response.status_code == 200: | ||
print('Message sent successfully') | ||
else: | ||
print(f'Failed to send message. Error code : {response.status_code}') | ||
else: | ||
print('No documentation changes to notify') | ||
else: | ||
print(json.dumps(documentation_changes, indent=2)) | ||
|
||
|
||
def _build_slack_message_documentation(changes: List[Tuple[str, str]], commit: str) -> List[Any]: | ||
if len(changes) == 0: | ||
return [] | ||
|
||
message: List[Any] = [] | ||
message.append({ | ||
"type": "section", | ||
"text": { | ||
"type": "plain_text", | ||
"text": "Writer framework | Documentation changes", | ||
} | ||
}) | ||
|
||
workflows = [ | ||
('A', 'added page', 'Open'), | ||
('M', 'modified page', 'Compare'), | ||
('D', 'deleted page', 'Open'), | ||
] | ||
|
||
for workflow in workflows: | ||
changes_modified = [f for f, change in changes if change == workflow[0]] | ||
if len(changes_modified) > 0: | ||
message.append({ | ||
"type": "context", | ||
"elements": [ | ||
{ | ||
"type": "mrkdwn", | ||
"text": workflow[1] | ||
} | ||
] | ||
}) | ||
|
||
for file in changes_modified: | ||
message.append({ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": f"`{file}`" | ||
}, | ||
"accessory": { | ||
"type": "button", | ||
"text": { | ||
"type": "plain_text", | ||
"text": workflow[2], | ||
}, | ||
"url": f"https://github.com/writer/writer-framework/commit/{commit}/{file}", | ||
} | ||
}) | ||
|
||
return message | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
apps/ai-starter/.wf/components-page-0-c0f99a9e-5004-4e75-a6c6-36f17490b134.jsonl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}, "handlers": {}, "isCodeManaged": false, "parentId": "root", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} | ||
{"id": "bebc5fe9-63a7-46a7-b0fa-62303555cfaf", "type": "header", "content": {"text": "@{my_app.title}"}, "handlers": {}, "isCodeManaged": false, "parentId": "c0f99a9e-5004-4e75-a6c6-36f17490b134", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} | ||
{"id": "ejpasds0o8qyjs1n", "type": "section", "content": {"title": "Section Title"}, "handlers": {}, "isCodeManaged": false, "parentId": "c0f99a9e-5004-4e75-a6c6-36f17490b134", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"id": "root", "type": "root", "content": {"appName": "AI Starter"}, "handlers": {}, "isCodeManaged": false, "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"id": "workflows_root", "type": "workflows_root", "content": {}, "handlers": {}, "isCodeManaged": false, "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"writer_version": "0.7.0rc2" | ||
} |
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
apps/default/.wf/components-page-0-c0f99a9e-5004-4e75-a6c6-36f17490b134.jsonl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}, "handlers": {}, "isCodeManaged": false, "parentId": "root", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} | ||
{"id": "bebc5fe9-63a7-46a7-b0fa-62303555cfaf", "type": "header", "content": {"text": "@{my_app.title}"}, "handlers": {}, "isCodeManaged": false, "parentId": "c0f99a9e-5004-4e75-a6c6-36f17490b134", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} | ||
{"id": "28d3885b-0fb8-4d41-97c6-978540015431", "type": "section", "content": {"containerShadow": "0px 4px 11px -12px #000000", "title": ""}, "handlers": {}, "isCodeManaged": false, "parentId": "c0f99a9e-5004-4e75-a6c6-36f17490b134", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}} | ||
{"id": "d4a5e62c-c6fe-49c4-80d4-33862af8727d", "type": "columns", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "28d3885b-0fb8-4d41-97c6-978540015431", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} | ||
{"id": "c2519671-9ce7-44e7-ba4e-b0efda9cb20e", "type": "column", "content": {"width": "1"}, "handlers": {}, "isCodeManaged": false, "parentId": "d4a5e62c-c6fe-49c4-80d4-33862af8727d", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} | ||
{"id": "172a14df-f73a-44fa-8fb1-e8648e7d32d2", "type": "metric", "content": {"metricValue": "@{counter}", "name": "Counter", "note": "@{message}"}, "handlers": {}, "isCodeManaged": false, "parentId": "c2519671-9ce7-44e7-ba4e-b0efda9cb20e", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} | ||
{"id": "d4a71819-7444-4083-a1c7-7995452a7abf", "type": "separator", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "d4a5e62c-c6fe-49c4-80d4-33862af8727d", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}} | ||
{"id": "f3777e75-3659-4d44-8ef7-aeec0d06855b", "type": "column", "content": {"contentHAlign": "center", "contentVAlign": "center", "title": "", "width": "1"}, "handlers": {}, "isCodeManaged": false, "parentId": "d4a5e62c-c6fe-49c4-80d4-33862af8727d", "position": 2, "visible": {"binding": "", "expression": true, "reversed": false}} | ||
{"id": "0d05bc9f-1655-4d0b-bc9b-c2f4c71a5117", "type": "horizontalstack", "content": {"contentHAlign": "center"}, "handlers": {}, "isCodeManaged": false, "parentId": "f3777e75-3659-4d44-8ef7-aeec0d06855b", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} | ||
{"id": "51d1554e-1b88-461c-9353-1419cba0053a", "type": "button", "content": {"icon": "arrow_downward", "text": "Decrement"}, "handlers": {"click": "decrement"}, "isCodeManaged": false, "parentId": "0d05bc9f-1655-4d0b-bc9b-c2f4c71a5117", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} | ||
{"id": "9556c0e3-8584-4ac9-903f-908a775a33ec", "type": "button", "content": {"icon": "arrow_upward", "text": " Increment"}, "handlers": {"click": "increment"}, "isCodeManaged": false, "parentId": "0d05bc9f-1655-4d0b-bc9b-c2f4c71a5117", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"id": "root", "type": "root", "content": {"appName": "My App"}, "handlers": {}, "isCodeManaged": false, "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"id": "workflows_root", "type": "workflows_root", "content": {}, "handlers": {}, "isCodeManaged": false, "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"writer_version": "0.7.0rc2" | ||
} |
Oops, something went wrong.