Skip to content

sync

Sync command for somesy.

sync

sync(
    input_file: Optional[Path] = typer.Option(
        None,
        "--input-file",
        "-i",
        help="Somesy input file path (default: .somesy.toml)",
        **file_arg_config
    ),
    no_sync_pyproject: Optional[bool] = typer.Option(
        None,
        "--no-sync-pyproject",
        "-P",
        help="Do not sync pyproject.toml file (default: False)",
    ),
    pyproject_file: Optional[List[Path]] = typer.Option(
        None,
        "--pyproject-file",
        "-p",
        help="Existing pyproject.toml file path(s) (default: pyproject.toml)",
        **existing_file_arg_config
    ),
    no_sync_package_json: Optional[bool] = typer.Option(
        None,
        "--no-sync-package-json",
        "-J",
        help="Do not sync package.json file (default: False)",
    ),
    package_json_file: Optional[List[Path]] = typer.Option(
        None,
        "--package-json-file",
        "-j",
        help="Existing package.json file path(s) (default: package.json)",
        **existing_file_arg_config
    ),
    no_sync_julia: Optional[bool] = typer.Option(
        None,
        "--no-sync-julia",
        "-L",
        help="Do not sync Project.toml (Julia) file (default: False)",
    ),
    julia_file: Optional[List[Path]] = typer.Option(
        None,
        "--julia-file",
        "-l",
        help="Custom Project.toml (Julia) file path(s) (default: Project.toml)",
        **existing_file_arg_config
    ),
    no_sync_fortran: Optional[bool] = typer.Option(
        None,
        "--no-sync-fortran",
        "-F",
        help="Do not sync fpm.toml (Fortran) file (default: False)",
    ),
    fortran_file: Optional[List[Path]] = typer.Option(
        None,
        "--fortran-file",
        "-f",
        help="Custom fpm.toml (Fortran) file path(s) (default: fpm.toml)",
        **existing_file_arg_config
    ),
    no_sync_pom_xml: Optional[bool] = typer.Option(
        None,
        "--no-sync-pomxml",
        "-X",
        help="Do not sync pom.xml (Java Maven) file (default: False)",
    ),
    pom_xml_file: Optional[List[Path]] = typer.Option(
        None,
        "--pomxml-file",
        "-x",
        help="Custom pom.xml (Java Maven) file path(s) (default: pom.xml)",
        **existing_file_arg_config
    ),
    no_sync_mkdocs: Optional[bool] = typer.Option(
        None,
        "--no-sync-mkdocs",
        "-D",
        help="Do not sync mkdocs.yml file (default: False)",
    ),
    mkdocs_file: Optional[List[Path]] = typer.Option(
        None,
        "--mkdocs-file",
        "-d",
        help="Custom mkdocs.yml file path(s) (default: mkdocs.yml)",
        **existing_file_arg_config
    ),
    no_sync_rust: Optional[bool] = typer.Option(
        None,
        "--no-sync-rust",
        "-R",
        help="Do not sync Cargo.toml file (default: False)",
    ),
    rust_file: Optional[List[Path]] = typer.Option(
        None,
        "--rust-file",
        "-r",
        help="Custom Cargo.toml file path(s) (default: Cargo.toml)",
        **existing_file_arg_config
    ),
    no_sync_cff: Optional[bool] = typer.Option(
        None,
        "--no-sync-cff",
        "-C",
        help="Do not sync CITATION.cff file (default: False)",
    ),
    cff_file: Optional[List[Path]] = typer.Option(
        None,
        "--cff-file",
        "-c",
        help="CITATION.cff file path(s) (default: CITATION.cff)",
        **file_arg_config
    ),
    no_sync_codemeta: Optional[bool] = typer.Option(
        None,
        "--no-sync-codemeta",
        "-M",
        help="Do not sync codemeta.json file (default: False)",
    ),
    codemeta_file: Optional[List[Path]] = typer.Option(
        None,
        "--codemeta-file",
        "-m",
        help="Custom codemeta.json file path(s) (default: codemeta.json)",
        **file_arg_config
    ),
    merge_codemeta: Optional[bool] = typer.Option(
        False,
        "--merge/--overwrite",
        help="Merge codemeta.json with with an existing codemeta.json file (default: False)",
    ),
    pass_validation: Optional[bool] = typer.Option(
        False,
        "--pass-validation",
        "-P",
        help="Pass validation of metadata files (default: False)",
    ),
    packages: Optional[List[Path]] = typer.Option(
        None,
        "--packages",
        "-k",
        help="Packages (subfolders) for monorepos with their own somesy config.",
        **existing_file_arg_config
    ),
)

Sync project metadata input with metadata files.

Source code in src/somesy/cli/sync.py
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
@app.callback(invoke_without_command=True)
@wrap_exceptions
def sync(
    input_file: Optional[Path] = typer.Option(
        None,
        "--input-file",
        "-i",
        help="Somesy input file path (default: .somesy.toml)",
        **file_arg_config,
    ),
    no_sync_pyproject: Optional[bool] = typer.Option(
        None,
        "--no-sync-pyproject",
        "-P",
        help="Do not sync pyproject.toml file (default: False)",
    ),
    pyproject_file: Optional[List[Path]] = typer.Option(
        None,
        "--pyproject-file",
        "-p",
        help="Existing pyproject.toml file path(s) (default: pyproject.toml)",
        **existing_file_arg_config,
    ),
    no_sync_package_json: Optional[bool] = typer.Option(
        None,
        "--no-sync-package-json",
        "-J",
        help="Do not sync package.json file (default: False)",
    ),
    package_json_file: Optional[List[Path]] = typer.Option(
        None,
        "--package-json-file",
        "-j",
        help="Existing package.json file path(s) (default: package.json)",
        **existing_file_arg_config,
    ),
    no_sync_julia: Optional[bool] = typer.Option(
        None,
        "--no-sync-julia",
        "-L",
        help="Do not sync Project.toml (Julia) file (default: False)",
    ),
    julia_file: Optional[List[Path]] = typer.Option(
        None,
        "--julia-file",
        "-l",
        help="Custom Project.toml (Julia) file path(s) (default: Project.toml)",
        **existing_file_arg_config,
    ),
    no_sync_fortran: Optional[bool] = typer.Option(
        None,
        "--no-sync-fortran",
        "-F",
        help="Do not sync fpm.toml (Fortran) file (default: False)",
    ),
    fortran_file: Optional[List[Path]] = typer.Option(
        None,
        "--fortran-file",
        "-f",
        help="Custom fpm.toml (Fortran) file path(s) (default: fpm.toml)",
        **existing_file_arg_config,
    ),
    no_sync_pom_xml: Optional[bool] = typer.Option(
        None,
        "--no-sync-pomxml",
        "-X",
        help="Do not sync pom.xml (Java Maven) file (default: False)",
    ),
    pom_xml_file: Optional[List[Path]] = typer.Option(
        None,
        "--pomxml-file",
        "-x",
        help="Custom pom.xml (Java Maven) file path(s) (default: pom.xml)",
        **existing_file_arg_config,
    ),
    no_sync_mkdocs: Optional[bool] = typer.Option(
        None,
        "--no-sync-mkdocs",
        "-D",
        help="Do not sync mkdocs.yml file (default: False)",
    ),
    mkdocs_file: Optional[List[Path]] = typer.Option(
        None,
        "--mkdocs-file",
        "-d",
        help="Custom mkdocs.yml file path(s) (default: mkdocs.yml)",
        **existing_file_arg_config,
    ),
    no_sync_rust: Optional[bool] = typer.Option(
        None,
        "--no-sync-rust",
        "-R",
        help="Do not sync Cargo.toml file (default: False)",
    ),
    rust_file: Optional[List[Path]] = typer.Option(
        None,
        "--rust-file",
        "-r",
        help="Custom Cargo.toml file path(s) (default: Cargo.toml)",
        **existing_file_arg_config,
    ),
    no_sync_cff: Optional[bool] = typer.Option(
        None,
        "--no-sync-cff",
        "-C",
        help="Do not sync CITATION.cff file (default: False)",
    ),
    cff_file: Optional[List[Path]] = typer.Option(
        None,
        "--cff-file",
        "-c",
        help="CITATION.cff file path(s) (default: CITATION.cff)",
        **file_arg_config,
    ),
    no_sync_codemeta: Optional[bool] = typer.Option(
        None,
        "--no-sync-codemeta",
        "-M",
        help="Do not sync codemeta.json file (default: False)",
    ),
    codemeta_file: Optional[List[Path]] = typer.Option(
        None,
        "--codemeta-file",
        "-m",
        help="Custom codemeta.json file path(s) (default: codemeta.json)",
        **file_arg_config,
    ),
    merge_codemeta: Optional[bool] = typer.Option(
        False,
        "--merge/--overwrite",
        help="Merge codemeta.json with with an existing codemeta.json file (default: False)",
    ),
    pass_validation: Optional[bool] = typer.Option(
        False,
        "--pass-validation",
        "-P",
        help="Pass validation of metadata files (default: False)",
    ),
    packages: Optional[List[Path]] = typer.Option(
        None,
        "--packages",
        "-k",
        help="Packages (subfolders) for monorepos with their own somesy config.",
        **existing_file_arg_config,
    ),
):
    """Sync project metadata input with metadata files."""
    somesy_input = resolved_somesy_input(
        input_file=input_file,
        no_sync_cff=no_sync_cff,
        cff_file=cff_file,
        no_sync_pyproject=no_sync_pyproject,
        pyproject_file=pyproject_file,
        no_sync_package_json=no_sync_package_json,
        package_json_file=package_json_file,
        no_sync_codemeta=no_sync_codemeta,
        codemeta_file=codemeta_file,
        no_sync_julia=no_sync_julia,
        julia_file=julia_file,
        no_sync_fortran=no_sync_fortran,
        fortran_file=fortran_file,
        no_sync_pom_xml=no_sync_pom_xml,
        pom_xml_file=pom_xml_file,
        no_sync_mkdocs=no_sync_mkdocs,
        mkdocs_file=mkdocs_file,
        no_sync_rust=no_sync_rust,
        rust_file=rust_file,
        merge_codemeta=merge_codemeta,
        pass_validation=pass_validation,
        packages=packages,
    )

    run_sync(somesy_input)

run_sync

run_sync(somesy_input: SomesyInput)

Write log messages and run synchronization based on passed config.

Source code in src/somesy/cli/sync.py
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
def run_sync(somesy_input: SomesyInput):
    """Write log messages and run synchronization based on passed config."""
    conf = somesy_input.config
    logger.info("[bold green]Synchronizing project metadata...[/bold green]")
    logger.info("Files to sync:")
    if not conf.no_sync_pyproject:
        logger.info(
            f"  - [italic]pyproject.toml[/italic]:\t[grey]{conf.pyproject_file}[/grey]"
        )
    if not conf.no_sync_package_json:
        logger.info(
            f"  - [italic]package.json[/italic]:\t[grey]{conf.package_json_file}[/grey]"
        )
    if not conf.no_sync_julia:
        logger.info(
            f"  - [italic]Project.toml[/italic]:\t[grey]{conf.julia_file}[/grey]\n"
        )
    if not conf.no_sync_fortran:
        logger.info(
            f"  - [italic]fpm.toml(fortran)[/italic]:\t[grey]{conf.fortran_file}[/grey]"
        )
    if not conf.no_sync_pom_xml:
        logger.info(
            f"  - [italic]pom.xml[/italic]:\t[grey]{conf.pom_xml_file}[/grey]\n"
        )
    if not conf.no_sync_mkdocs:
        logger.info(
            f"  - [italic]mkdocs.yml[/italic]:\t[grey]{conf.mkdocs_file}[/grey]"
        )
    if not conf.no_sync_rust:
        logger.info(f"  - [italic]Cargo.toml[/italic]:\t[grey]{conf.rust_file}[/grey]")

    if not conf.no_sync_cff:
        logger.info(f"  - [italic]CITATION.cff[/italic]:\t[grey]{conf.cff_file}[/grey]")
    if not conf.no_sync_codemeta:
        logger.info(
            f"  - [italic]codemeta.json[/italic]:\t[grey]{conf.codemeta_file}[/grey]\n"
        )
    # ----
    if conf.pass_validation:
        logger.info("[bold yellow]Passing validation of metadata files.[/bold yellow]")
    sync_command(somesy_input)
    # ----
    logger.info("[bold green]Metadata synchronization completed.[/bold green]")