Skip to content

Commit 22feac7

Browse files
[feat] Add support for v1 and v2 in dev scripts (#112)
### TL;DR Improved component build process and added support for v2 template structure. ### What changed? - Added installation of the `build` package for PEP 517 support - Reorganized replay files into v1 and v2 directories - Added a new v2 template replay file for React + TypeScript components ### Why make this change? The reorganization of replay files and addition of v2 template support prepares the codebase for the new component template structure, making it easier to maintain both v1 and v2 templates simultaneously.
1 parent 3cd2371 commit 22feac7

File tree

5 files changed

+26
-6
lines changed

5 files changed

+26
-6
lines changed

.github/actions/build_component_wheels/action.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,21 @@ outputs:
1616
runs:
1717
using: 'composite'
1818
steps:
19+
- name: Install build backend for PEP 517
20+
working-directory: ${{ github.action_path }}/../../../
21+
shell: bash
22+
run: pip install build
23+
1924
- name: Link develop version of streamlit-component-lib
2025
if: inputs.custom_streamlit_component_lib_file != ''
2126
working-directory: ${{ github.action_path }}/../../../
2227
shell: bash
2328
env:
2429
STREAMLIT_COMPONENT_LIB_FILE: ${{ inputs.custom_streamlit_component_lib_file }}
2530
run: |
26-
find examples template template-reactless -name frontend -maxdepth 3 | while IFS= read -r line; do
31+
find examples templates -maxdepth 5 -type d -name frontend -print0 | while IFS= read -r -d '' line; do
2732
(
28-
cd "${line}";
29-
npm install "${STREAMLIT_COMPONENT_LIB_FILE}"
33+
cd "${line}" && npm install "${STREAMLIT_COMPONENT_LIB_FILE}"
3034
)
3135
done
3236
@@ -44,8 +48,7 @@ runs:
4448
working-directory: ${{ github.action_path }}/../../../
4549
shell: bash
4650
run: |
47-
find examples template template-reactless -maxdepth 3 -name '__init__.py' |\
48-
xargs -n 1 sed -i 's/_RELEASE = False/_RELEASE = True/';
51+
grep -Rl "_RELEASE = False" examples templates | xargs -r sed -i 's/_RELEASE = False/_RELEASE = True/';
4952
./dev.py all-python-build-package
5053
5154
- name: Set outputs
File renamed without changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"cookiecutter": {
3+
"author_name": "John Smith",
4+
"author_email": "[email protected]",
5+
"project_name": "Streamlit Component X",
6+
"package_name": "streamlit-custom-component",
7+
"import_name": "my_component",
8+
"description": "Streamlit component that allows you to do X",
9+
"open_source_license": "MIT license",
10+
"framework": "React + Typescript"
11+
}
12+
}

dev.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,14 +339,19 @@ class CookiecutterVariant(typing.NamedTuple):
339339

340340
COOKIECUTTER_VARIANTS = [
341341
CookiecutterVariant(
342-
replay_file=THIS_DIRECTORY / ".github" / "replay-files" / "template.json",
342+
replay_file=THIS_DIRECTORY
343+
/ ".github"
344+
/ "replay-files"
345+
/ "v1"
346+
/ "template.json",
343347
repo_directory=THIS_DIRECTORY / "templates" / "v1" / "template",
344348
cookiecutter_dir=THIS_DIRECTORY / "cookiecutter" / "v1",
345349
),
346350
CookiecutterVariant(
347351
replay_file=THIS_DIRECTORY
348352
/ ".github"
349353
/ "replay-files"
354+
/ "v1"
350355
/ "template-reactless.json",
351356
repo_directory=THIS_DIRECTORY / "templates" / "v1" / "template-reactless",
352357
cookiecutter_dir=THIS_DIRECTORY / "cookiecutter" / "v1",

0 commit comments

Comments
 (0)