o
    »¼tf1  ã                	   @   s´  d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZ zd dlZW n e	y1   d dl
ZY nw zd dlmZ W n e	yI   d dlmZ Y nw d dlmZ zd dlZW n eyd   dZeeƒd‚w g d¢Ze d¡Z	d#d	ed
ee deddfdd„ZedkrØd dlZejddZejdddd ejddedd ejdddd e ¡ Z ee j!ƒd Z"e" #¡ rËdZe$ej% &d¡ƒd krÅed!7 Ze'eƒ dS ee j!e j(e j)d"u ƒ dS dS )$é    N)ÚOptional)Úfiles)ÚPathzNPlease install copier; you can use `pip install jupyterlab[upgrade-extension]`)z".github/workflows/binder-on-pr.ymlz.github/workflows/build.ymlz#.github/workflows/check-release.ymlz#.github/workflows/enforce-label.ymlz".github/workflows/prep-release.ymlz%.github/workflows/publish-release.ymlz..github/workflows/update-integration-tests.ymlzbinder/postBuildú.eslintignoreú.eslintrc.jsz
.gitignorez.prettierignoreú.prettierrcú.stylelintrcz
RELEASE.mdzbabel.config.jsúconftest.pyújest.config.jsúpyproject.tomlúsetup.pyztsconfig.jsonztsconfig.test.jsonzui-tests/README.mdz&ui-tests/jupyter_server_test_config.pyzui-tests/package.jsonzui-tests/playwright.config.jsz^jupyter_server([^\w]|$)TÚtargetÚvcs_refÚinteractiveÚreturnc           .      C   s4  t | ƒ ¡ } | d }| d }| d }| ¡ sd| ›}t|ƒ‚t|ƒ}t |¡}W d  ƒ n1 s3w   Y  d}	| ¡ rNt | 	¡ ¡}
|
 
di ¡ 
d¡}	|	du r| ¡ rgtjtjddg| d	 d
¡ ¡ }	n|d }	d|	v ru|	dd… }	|	 dd¡ dd¡}	| d }| ¡ rŒt |¡ | 
dd¡}d}t|tƒr¦| 
dd¡}| 
d|¡}n|}d}| d  ¡ r³d}n| 
di ¡ 
dd¡r¿d}| d  ¡ pÐ| d  ¡ pÐ| d  ¡ }||||d |	| 
dd¡t| 
di ¡ 
d d¡ƒt| d!  ¡ ƒt|ƒ| 
d"i ¡ 
d#d$¡d%œ
}d&}ttj d'¡ƒd(k rtj||||d)d* ntj||||d)d)d+ |d  ¡ }t |¡}W d  ƒ n	1 s8w   Y  | 
d,¡rV|d,  ¡ D ]\}}||d, |< qIn|d,  ¡ |d,< g }|rgtd-ƒnd.}|  ¡  !d/¡r§| "d0¡ | #d1i ¡ |d1  ¡ D ]\}}||d1 |< q‚d2|d1 v rš|d1 d2= d3|d1 v r¦|d1 d3= n| "d4¡ |d d5 |d d5< d6d7d8d9d:œ}| ¡ D ]%\}}||v rå|| ||< | | }| ¡ rå| $¡  | "d;|› ¡ qÁt%dƒ &d<¡}| ¡ }t |¡}W d  ƒ n	1 sw   Y  | #d=i ¡ | #d,i ¡ |d>  ¡ D ]'\}}||d= v r/| d?d@¡|d= |< ||d, v r@| d?d@¡|d, |< qdAD ]}|| rYtt'||  ¡ ƒƒ||< qD||= qD| #dBdC¡ t| 
dD¡t(ƒr{dC|dD vr{|dD  "dC¡ dE|v rŽdC|dE vrŽ|dE  "dC¡ | )tj*|dFdG¡ dH}| +dI¡D ]†}| ,|¡}t-|ƒdkr¯qŸ| .¡ r¶qŸ| | } |  ¡ s×| j/j0d)d)dJ t || ¡ | j1dkrÕd)}qŸ| 2¡ }!|  2¡ }"|!|"kræqŸ| 3¡ t4v rïd.ndK}#|rtdL|›dM|#› dNƒp|#ndK}|  ¡  !d/¡rt || ¡ | j1dkrd)}qŸ| "dO|›¡ qŸ|r	| dP  ¡ r÷zdQdl5}$W n t6yF   dR}t7|ƒ Y n±w t8 9¡ }%| dP  ¡ }&|% :|&¡ W d  ƒ n	1 sbw   Y  | d }t | 	¡ ¡}
|%j
dSdTddU}'|'dur‹t(t;dVdW„ |' <¡ ƒƒ}(ng }(|
d  
d=g ¡|( |
d d=< |% =dX¡rä|% dX¡D ]=\})}*t(t;dYdW„ |* <¡ ƒƒ}+|)|
d  
dZi ¡v rÚ|
d  
dZ¡du rÐi |
d dZ< |
d dZ |) |+ }+|+|
d dZ |)< q¦| )|$ *|
¡¡ | dP  $¡  | "d[¡ | d\ },|, ¡ r	|, $¡  | "d]¡ |D ]}-t7d^|-ƒ qt7d_ƒ dS )`a#  Update an extension to the current JupyterLab

    target: str
        Path to the extension directory containing the extension
    vcs_ref: str [default: None]
        Template vcs_ref to checkout
    interactive: bool [default: true]
        Whether to ask before overwriting content

    zpackage.jsonr   r   zNo package.json exists in NÚprojectÚnamez--name)ÚcwdÚutf8ú@é   ú/Ú_ú-Z_temp_extensionÚauthorz<author_name>Ú ÚemailZfrontendzjupyter-configÚserverZ
jupyterlabZ	themePathÚthemer	   r
   zui-testsÚdescriptionz<description>Z	schemaDirZbinderÚ
repositoryÚurlz<repository)
ÚkindÚauthor_nameÚauthor_emailZlabextension_nameÚpython_nameZproject_short_descriptionZhas_settingsZ
has_binderÚtestr    z0https://github.com/jupyterlab/extension-templateÚ.©Ú8Ú0r*   T)r   ÚdataÚdefaults)r   r+   r,   ÚunsafeÚdevDependenciesz(Overwrite scripts in package.json? [n]: ÚyÚYzUpdated scripts in package.jsonÚscriptszinstall-extÚpreparez-package.json scripts must be updated manuallyZ	outputDirr   r   r   r   )ZeslintConfigZeslintIgnoreZprettierZ	stylelintzDELETED zstaging/package.jsonÚdependenciesÚresolutionsú~ú^)r1   r3   r.   ZstyleModulezstyle/index.jsZsideEffectsr   é   )ÚindentFÚ*)ÚparentsÚexist_okÚnzoverwrite "z"? [z]: zskipped _temp_extension/z	setup.cfgr   z5To update pyproject.toml, you need to install tomli-wÚoptionsZinstall_requires)Úfallbackc                 S   s   | ot  | ¡d u S ©N)ÚJUPYTER_SERVER_REQUIREMENTÚmatch©Úr© rD   úe/var/www/html/software/conda/envs/catlas/lib/python3.10/site-packages/jupyterlab/upgrade_extension.pyÚ<lambda>!  s    z"update_extension.<locals>.<lambda>zoptions.extras_requirec                 S   s   | S r?   rD   rB   rD   rD   rE   rF   /  s    zoptional-dependencieszDELETED setup.cfgzMANIFEST.inzDELETED MANIFEST.inz**z2** Remove _temp_extensions directory when finished)>r   ÚresolveÚexistsÚRuntimeErrorÚopenÚjsonÚloadÚtomllibÚloadsÚ	read_textÚgetÚ
subprocessÚcheck_outputÚsysÚ
executableÚdecodeÚstripÚreplaceÚshutilÚrmtreeÚ
isinstanceÚdictÚboolÚtupleÚcopierÚ__version__ÚsplitZrun_autoZrun_copyÚitemsÚcopyÚinputÚupperÚ
startswithÚappendÚ
setdefaultÚunlinkr   ÚjoinpathÚsortedÚlistÚ
write_textÚdumpsÚrglobÚrelative_toÚstrÚis_dirÚparentÚmkdirr   Ú
read_bytesÚas_posixÚRECOMMENDED_TO_OVERRIDEÚtomli_wÚImportErrorÚprintÚconfigparserÚConfigParserÚ	read_fileÚfilterÚ
splitlinesÚhas_section).r   r   r   Zpackage_fileZpyproject_fileZ
setup_fileÚmsgÚfidr+   r%   Ú	pyprojectÚ
output_dirr   r$   r#   r"   Zhas_testZextra_contextÚtemplateZ	temp_dataÚkeyÚvalueÚwarningsÚchoiceZlintersÚfileZlinter_fileZroot_jlab_packageZroot_jlab_dataZoverride_pyprojectÚpÚrelpathZfile_targetZold_dataZnew_dataÚdefaultrw   ÚconfigZsetup_cfg_fileZrequirements_rawÚrequirementsÚextraZdeps_rawÚdepsZmanifest_inÚwarningrD   rD   rE   Úupdate_extension>   s‚  

ÿ
þú	


ÿ
ý
öÿÿÿ


€
ü

€
ÿ€

 


€
ÿ€ý€þÿ
þÿ
ÿ


r’   Ú__main__zUpgrade a JupyterLab extension)r   z
--no-inputÚ
store_truez!whether to prompt for information)ÚactionÚhelpÚpathÚstorezthe target path)r•   Útyper–   z	--vcs-refzthe template hash to checkout)r–   rŒ   z.copier-answers.ymlzrThis script won't do anything for copier template, instead execute in your extension directory:

    copier updater'   r(   z	 --UNSAFEF)NT)*rz   rK   ÚrerX   rQ   rS   Útypingr   rM   rx   ÚtomliÚimportlib.resourcesr   Zimportlib_resourcesÚpathlibr   r^   ÚModuleNotFoundErrorr€   rI   rv   Úcompiler@   rp   r\   r’   Ú__name__ÚargparseÚArgumentParserÚparserÚadd_argumentÚ
parse_argsÚargsr—   Zanswer_filerH   r]   r_   r`   ry   r   Úno_inputrD   rD   rD   rE   Ú<module>   sj   ÿÿ
þ
ÿÿÿÿ
þ  
ë