waterui 0.5.1

A modern UI framework for Rust
�

�f�j�%����dZddlZddlZddlZddlZddlmZddlZddlZddl	Z	ej
d��Zd�Zd�Z
d�Zd�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zedkre��dSdS)uZBuild the certified framework manifest (`framework.json`) for a release.

The manifest records the worktree's lockfile hash, the scaffold table the root manifest's `[package.metadata.waterui]` declares, and
that metadata table verbatim. A scaffold package whose
`[workspace.dependencies]` requirement is a git pin (`git` + `rev`) has no
registry release the stable channel could resolve, so a `stable` manifest
withholds its entries from `scaffold` and records the pin under
`experimental-packages` instead; `nightly` carries it in `scaffold` like any
other package. The Rust side derives exactly the same tables for a tree
(`framework_scaffold` in
https://github.com/water-rs/cli/blob/dev/src/project_model/framework.rs) — the
two must not drift, so this script never reads anything from the CLI.

`stable` certifies the framework release tag release-plz published
(`v<version>`), or — under release preflight, where the release does not
exist yet — the candidate revision it will publish. The named revision is
checked out so every recorded fact is read from the released tree.

`nightly` certifies the `dev` revision a green full-matrix run tested, as
the immutable `nightly-<date>-<sha12>` tag `nightly.yml` publishes. It
refuses a revision that is already certified or that does not advance the
newest certification, so the certified line only moves forward.
�N)�Pathznightly-\d{8}-[0-9a-f]{12}c�X�tjdg|�d������S)N�gitT��text)�
subprocess�check_output�strip)�argss �L/Users/lexoliu/Coding/waterui-wt-winui/.github/scripts/framework_manifest.pyrr)s*���"�E�>�D�>��=�=�=�C�C�E�E�E�c��td��}t|��tj|��������iS)z>The dependency lock the CLI verifies a certified tree against.z
Cargo.lock)r�str�hashlib�sha256�
read_bytes�	hexdigest)�locks r�lockfile_hashesr-s@������D���I�I�w�~�d�o�o�&7�&7�8�8�B�B�D�D�E�Er
c�(�|ddd}|dd}i}|dD]�}||}t|t��r|n|d||�d�<t|t��rld	|vrh|�d
��}t|t��rt	jd|��st
d|�d
����|d	||�d�<|||�d�<��|���D]\}}|�d��r|||<� |S)uThe scaffold table the framework manifest itself declares: each
    `scaffold-packages` entry's `[workspace.dependencies]` requirement —
    `{name}-version`, plus `{name}-git` and `{name}-rev` when the requirement
    pins a repository — and every backend coordinate — `{name}-backend-url`,
    plus the `{name}-backend-version` of a backend pinned by release or the
    `{name}-backend-revision` of one pinned by commit — from
    `[package.metadata.waterui]`.
    Identical to `framework_scaffold` in the CLI for the same tree.�package�metadata�waterui�	workspace�dependencieszscaffold-packages�version�-versionr�revz[0-9a-fA-F]{40}zworkspace.dependencies.z# must pin an immutable Git revision�-git�-rev)z-backend-urlz-backend-versionz-backend-revision)	�
isinstancer�dict�get�re�	fullmatch�RuntimeError�items�endswith)	�	frameworkrr�scaffold�name�
dependency�revision�key�values	         r�framework_scaffoldr03s\����#�J�/�	�:�H��+�&�~�6�I��H��,�-�/�/���t�_�
�$�Z��5�5�P�J�J�:�i�;P�	�D�"�"�"�#��j�$�'�'�		/�E�Z�,?�,?�!�~�~�e�,�,�H��h��,�,�
�B�L�"�H�5�5�
�#�W�d�W�W�W����'1��&7�H��]�]�]�#�&.�H��]�]�]�#���n�n�&�&�"�"�
��U��<�<�Q�R�R�	"�!�H�S�M���Or
c�L�t|��}i}|dkr�t|��D]z}|�d��rc|dtd���}|�|�d���|�|�d���|�|�d���d�||<�{||fS)u�The `(scaffold, experimental)` tables `channel`'s manifest records.

    A scaffold package pinned to a git revision has no registry release the
    stable channel could resolve, so `stable` withholds its `{name}-*`
    entries from the scaffold table and records the pin — name, git URL,
    revision and declared version — under `experimental-packages`; `dev` and
    `nightly` distribute it through `scaffold` as always. The split derives
    from the dependency's shape alone: `framework_scaffold` already marks a
    git pin with a `{name}-git` entry, so no second list is maintained. The
    CLI splits the derived table the same way and holds the certification's
    `experimental-packages` to agreement.
    �stablerNrr )rrr)r0�sortedr(�len�pop)r)�channelr*�experimentalr.r+s      r�channel_scaffoldr8Ws���"�)�,�,�H��L��(����(�#�#�	�	�C��|�|�F�#�#�
��>�c�&�k�k�\�>�*��'�|�|�t�,=�,=�,=�>�>�#�<�<�4�
�
�
�6�6�#�<�<�4�
�
�
�6�6�&�&��T�"��
�\�!�!r
c���tjtd�������}|ddd}t	||��\}}d||||ttjd��ttjd��t��|||d�}td	���	tj|d�
��dz��dS)
z4Write `framework.json` for the checked-out revision.z
Cargo.tomlrrr��
GITHUB_RUN_ID�GITHUB_RUN_ATTEMPT)�schema_versionr6�
repositoryr-�tag�run_id�run_attempt�	lockfilesr*zexperimental-packagesrzframework.json)�indent�
N)�tomllib�loadsr�	read_textr8�int�os�environr�
write_text�json�dumps)	r6r?r-r>r)rr*r7�manifests	         r�build_manifestrOrs����
�d�<�0�0�:�:�<�<�=�=�I���#�J�/�	�:�H�-�i��A�A��H�l��� ����b�j��1�2�2��2�:�&:�;�<�<�$�&�&��".��!��H�$	�	���%�%�d�j��!�&D�&D�&D�t�&K�L�L�L�L�Lr
c�&�td|��dS)z�Put the worktree at `revision` so every recorded fact names the tree
    being certified rather than whatever the job happened to check out.�checkoutN)r)r-s rrQrQ�s���
�H�����r
c���tjd}|�*tddd|�d|����td|�d���}t|��t	d|||��dS)	N�GITHUB_REPOSITORY�fetch�originz
refs/tags/z:refs/tags/�	rev-parse�	^{commit}r2)rIrJrrQrO)r?r-r>s   r�prepare_stablerX�sz����/�0�J���	�G�X�A�C�A�A�C�A�A�B�B�B��{�s�$7�$7�$7�8�8���X�����8�S�(�J�7�7�7�7�7r
c	��tjtjddd|�d�ddgd�����}d	�|D��}t	|d
����S)z<Every published (non-draft) nightly prerelease, newest last.�gh�apizrepos/z	/releasesz
--paginatez--slurpTrc�|�g|]9}|D]4}|d�
|d�t�|d���2|��5�:S)�draft�
prerelease�tag_name)�NIGHTLY_TAGr%)�.0�page�releases   r�
<listcomp>z'published_nightlies.<locals>.<listcomp>�sq���������&-��w���$+�L�$9��
�!�!�'�*�"5�6�6������r
c��|dS)N�published_at�)rcs r�<lambda>z%published_nightlies.<locals>.<lambda>�s����0G�r
)r.)rLrFrr	r3)r>�pages�releasess   r�published_nightliesrk�s}���J�z�.��e�3�j�3�3�3�\�9�0�����
�
�E���!����H�
�(� G� G�H�H�H�Hr
c���ttjd���d��5}|���D] \}}|�|�d|�d����!	ddd��n#1swxYwY|ddkrkttjd���d��5}|�|ddz��ddd��dS#1swxYwYdSdS)	N�
GITHUB_OUTPUT�a�=rD�eligible�false�GITHUB_STEP_SUMMARY�reason)rrIrJ�openr'�write)�outputs�outputr.r/�summarys     r�
write_outputsry�sx��	
�b�j��)�	*�	*�	/�	/��	4�	4�-��!�-�-�/�/�	-�	-�J�C���L�L�C�+�+�%�+�+�+�,�,�,�,�	-�-�-�-�-�-�-�-�-�-�-�-����-�-�-�-��z��g�%�%�
�"�*�2�3�
4�
4�
9�
9�#�
>�
>�	4�'��M�M�'�(�+�d�2�3�3�3�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4����	4�	4�	4�	4�	4�	4�&�%s#�6A6�6A:�=A:�?C+�+C/�2C/c���tjd}tdd��}|tjdkrtd���tdddd���d	d
��}d|�d	|dd����t|��}t
�fd
�|D����rtddd���dS|rktd|dd�d���}tj	ddd||g��}|j
dkrtddd���dS|���td�||��td�|d���dS)NrSrV�HEAD�
GITHUB_SHAz3The checkout is not the revision tested by this run�showz-sz--format=%cs�-�znightly-�c3�0�K�|]}|d�kV��dS)r_Nrg)rarcr?s  �r�	<genexpr>z"prepare_nightly.<locals>.<genexpr>�s-�����
>�
>�'�7�:��#�%�
>�
>�
>�
>�
>�
>r
rqz"This revision is already certified)rprs�����r_rWrz
merge-basez
--is-ancestor�z0This run does not advance the certified revision�nightly�true)rpr?r-)
rIrJrr&�replacerk�anyryr�run�
returncode�check_returncoderO)r>r-�daterj�latest�
comparisonr?s      @r�prepare_nightlyr��s������/�0�J��;��'�'�H��2�:�l�+�+�+��P�Q�Q�Q��v�t�^�V�4�4�<�<�S�"�E�E�D�
+�T�
+�
+�H�S�b�S�M�
+�
+�C�"�:�.�.�H�
�
>�
>�
>�
>�X�
>�
>�
>�>�>���7�6Z�[�[�\�\�\����&��[�X�b�\�*�%=�"J�"J�"J�K�K���^�U�L�/�6�S[�$\�]�]�
�� �A�%�%��w�:l�m�m�n�n�n��F��#�#�%�%�%��9�c�8�Z�8�8�8��v�c�x�H�H�I�I�I�I�Ir
c��tjt���}|�dd���}|�dd���}|�ddd	�
��|�dd���|�d
d���|���}|jd
krt��dSt|j
|j��dS)N)�descriptionr6T)�dest�requiredr2z%certify a published framework release)�helpz--tagz&the v<version> tag the release carries)r�r�z
--revisionz�the commit the tag certifies (defaults to resolving the tag; release preflight passes the candidate commit before the tag exists)r�z7certify the dev revision a green full-matrix run tested)�argparse�ArgumentParser�__doc__�add_subparsers�
add_parser�add_argument�
parse_argsr6r�rXr?r-)�parser�commandsr2rs    r�mainr��s
��
�
$��
9�
9�
9�F��$�$�)�d�$�C�C�H�
�
 �
 ��>�!���F�����$�%M���������O�����

����Q����������D��|�y� � ��������t�x���/�/�/�/�/r
�__main__)r�r�rrLrI�pathlibrr$rrE�compiler`rrr0r8rOrQrXrkryr�r��__name__rgr
r�<module>r�sP����0������������	�	�	�	�������	�	�	�	����������b�j�6�7�7��F�F�F�F�F�F�!�!�!�H"�"�"�6M�M�M�4���8�8�8�
I�
I�
I�4�4�4�J�J�J�,0�0�0�0�z����D�F�F�F�F�F��r