Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: dalito/linkml-project-copier
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: a2eb8af1aa650b07201075fc384f758fe2e5f71f
Choose a base ref
..
head repository: dalito/linkml-project-copier
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 05c1e45aca05954a24b27066603dc7ef137be568
Choose a head ref
Showing with 70 additions and 92 deletions.
  1. +3 −5 README.md
  2. +0 −7 copier.yaml
  3. +0 −4 template/examples/README.md.jinja
  4. +67 −76 template/justfile
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -3,10 +3,8 @@
This template uses the code-scaffolding tool [copier](https://copier.readthedocs.io/) to create a [LinkML](https://github.com/linkml/linkml) project.
Copier supports code lifecycle management, allowing you to seamlessly incorporate updates into your project when the template is enhanced.

* Starting from 0.2.x we give up compatibility to introduce new features and to re-organise and clean-up the code.
* Early releases (0.1.x) have maintained backwards compatibility with [linkml-project-cookiecutter](https://github.com/linkml/linkml-project-cookiecutter/).
This facilitates to experiment with the migration of existing cruft/cookiecutter-based projects.
Over time the migration may become more difficult as the cookiecutter template evolves.
* Early releases (0.1.x) maintain backwards compatibility with [linkml-project-cookiecutter](https://github.com/linkml/linkml-project-cookiecutter/). This facilitates to experiment with the migration of existing cruft/cookiecutter-based projects.
* Starting from 0.2.x we give up compatibility to introduce new features and to re-organise and clean-up the code. The migration from 0.1.x to 0.2.x is not too difficult but requires some manual work.

The generated project uses [just](https://github.com/casey/just) as preferred command runner, even in the 0.1.x releases.

@@ -194,7 +192,7 @@ The commands are written to be run at the root of your project.
The command for migrating to a specific tag/release is:

```shell
copier copy --trust --vcs-ref v0.1.7 gh:dalito/linkml-project-copier .
copier copy --trust --vcs-ref v0.1.6 gh:dalito/linkml-project-copier .
```

Look into the `.cruft.json` file to find out which values you chose when you created your original project.
7 changes: 0 additions & 7 deletions copier.yaml
Original file line number Diff line number Diff line change
@@ -155,13 +155,6 @@ _message_after_copy: |
Next step (if you have not previously initialized your project)
run "just setup" in the root of your project directory.
_migrations:
# Migrations are only run on update (not on copy) and only if the update goes
# through or to the specified version.
- version: v0.2.0
command: just _post-upgrade-0.1-to-0.2
when: "{{ _stage == 'after' }}"

# _tasks:
# Commands to execute after generating or updating a project from the template.
# - "git init"
4 changes: 0 additions & 4 deletions template/examples/README.md.jinja
Original file line number Diff line number Diff line change
@@ -3,7 +3,3 @@
This folder contains examples using the datamodel.

The source of the data used in the example is [tests/data](../tests/data/).

The command `just test` creates different representations of the data in [tests/data](../tests/data/) and writes them to the subfolder `output`.
It also generates a markdown documentation of the examples which is not very useful in its current form.
Hence, the `output` sub-folder is git-ignored.
143 changes: 67 additions & 76 deletions template/justfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# ============ Hint for for Windows Users ============

# On Windows the "sh" shell that comes with Git for Windows should be used.
# If it is not on path, provide the path to the executable in the following line.
# If it is not on path, give the path to the executable in the following line.
#set windows-shell := ["C:/Program Files/Git/usr/bin/sh", "-cu"]

# ============ Variables used in recipes ============

# Load environment variables from config.public.mk or specified file
set dotenv-load := true
# set dotenv-filename := env_var_or_default("LINKML_ENVIRONMENT_FILENAME", "config.public.mk")
set dotenv-filename := x'${LINKML_ENVIRONMENT_FILENAME:-config.public.mk}'

# Set shebang line for cross-platform Python recipes (assumes presence of launcher on Windows)

# List all commands as default command. The prefix "_" hides the command.
_default: _status
@just --list

# Set cross-platform Python shebang line (assumes presence of launcher on Windows)
shebang := if os() == 'windows' {
'py'
} else {
@@ -21,11 +22,13 @@ shebang := if os() == 'windows' {
# Environment variables with defaults
schema_name := env_var_or_default("LINKML_SCHEMA_NAME", "")
source_schema_path := env_var_or_default("LINKML_SCHEMA_SOURCE_PATH", "")

use_schemasheets := env_var_or_default("LINKML_USE_SCHEMASHEETS", "No")
sheet_module := env_var_or_default("LINKML_SCHEMA_GOOGLE_SHEET_MODULE", "")
sheet_ID := env_var_or_default("LINKML_SCHEMA_GOOGLE_SHEET_ID", "")
sheet_tabs := env_var_or_default("LINKML_SCHEMA_GOOGLE_SHEET_TABS", "")
sheet_module_path := source_schema_path / sheet_module + ".yaml"

config_yaml := if env_var_or_default("LINKML_GENERATORS_CONFIG_YAML", "") != "" {
"--config-file " + env_var_or_default("LINKML_GENERATORS_CONFIG_YAML", "")
} else {
@@ -43,80 +46,20 @@ dest := "project"
pymodel := src / schema_name / "datamodel"
docdir := "docs/elements" # Directory for generated documentation

# ============== Project recipes ==============
# Show current project status
_status: _check-config
@echo "Project: {{schema_name}}"
@echo "Source: {{source_schema_path}}"

# Initialize a new project (use this for projects not yet under version control)
# Run initial setup (run this first)
[group('project management')]
setup: _check-config
git init
install
git add .
git commit -m "Initialise git with minimal project" -a
_gen-project
_gendoc
git add .
git commit -m "Add generated docs and project artefacts" -a
setup: _check-config _git-init install _gen-project gendoc _git-add _git-commit

# Install project dependencies
[group('project management')]
install:
poetry install

# (Re-)Generate project and documentation locally
[group('model development')]
site: _gen-project _gendoc

# Deploy documentation site to Github Pages
[group('deployment')]
deploy: site
mkd-gh-deploy

# Run all tests
[group('model development')]
test: _test-schema _test-python _test-examples

# Run linting
[group('model development')]
lint:
poetry run linkml-lint {{source_schema_path}}

# Build docs and run test server
[group('model development')]
testdoc: _gendoc _serve

# Updates project template and LinkML package
[group('project management')]
update: _update-template _update-linkml

# Clean all generated files
[group('project management')]
clean: _clean_project
rm -rf tmp
rm -rf {{docdir}}/*

# ============== Migrations recipes for Copier ==============

# Hidden command to adjust the directory layout after upgrading a project
# created with linkml-project-copier v0.1.x to v0.2.0 or newer.
# Use with care! - It may not work for customized projects.
_post-upgrade-0.1-to-0.2:
-mv docs/*.md docs/elements
-git mv src/docs/files docs
-git mv src/docs/templates docs/templates-linkml
-git mv src/data/examples tests/data/
echo "Migration to v0.2.0 completed! Check the changes carefully before committing them."

# ============== Hidden internal recipes ==============

# List all commands as default command. The prefix "_" hides the command.
_default: _status
@just --list

# Show current project status
_status: _check-config
@echo "Project: {{schema_name}}"
@echo "Source: {{source_schema_path}}"

# Check project configuration
_check-config:
#!{{shebang}}
@@ -127,6 +70,10 @@ _check-config:
exit(1)
print('Project-status: Ok')

# Updates project template and LinkML package
[group('project management')]
update: _update-template _update-linkml

# Update project template
_update-template:
copier update --trust --skip-answered --skip-tasks
@@ -135,6 +82,15 @@ _update-template:
_update-linkml:
poetry add -D linkml@latest

# (Re-)Generate project and documentation locally
[group('model development')]
site: _gen-project gendoc

# Deploy documentation site to Github Pages
[group('deployment')]
deploy: site
mkd-gh-deploy

_compile_sheets:
@if [ "{{use_schemasheets}}" != "No" ]; then \
poetry run sheets2linkml --gsheet-id {{sheet_ID}} {{sheet_tabs}} > {{sheet_module_path}}.tmp && \
@@ -157,6 +113,10 @@ _gen-project: _compile_sheets
poetry run gen-typescript {{gen_ts_args}} {{source_schema_path}} > {{dest}}/typescript/{{schema_name}}.ts || true ; \
fi

# Run all tests
[group('model development')]
test: _test-schema _test-python _test-examples

# Test schema generation
_test-schema:
poetry run gen-project {{config_yaml}} -d tmp {{source_schema_path}}
@@ -175,14 +135,38 @@ _test-examples: _ensure_examples_output
--output-directory examples/output \
--schema {{source_schema_path}} > examples/output/README.md

# Generate documentation for the schema
_gendoc:
# Run linting
[group('model development')]
lint:
poetry run linkml-lint {{source_schema_path}}

# Generate markdown documentation for the schema
gendoc:
poetry run gen-doc {{gen_doc_args}} -d {{docdir}} {{source_schema_path}}

# Build docs and run test server
[group('model development')]
testdoc: gendoc _serve

# Run documentation server
_serve:
poetry run mkdocs serve

# Initialize and add everything to git
_git-init-add: _git-init _git-add _git-commit _git-status

# Initialize git repository
_git-init:
git init

# Add files to git
_git-add:
git add .

# Commit files to git
_git-commit:
git commit -m 'chore: just setup was run' -a

# Show git status
_git-status:
git status
@@ -205,9 +189,16 @@ _clean_project:
else:
d.unlink()

# Clean all generated files
[group('project management')]
clean: _clean_project
rm -rf tmp
rm -rf {{docdir}}/*

# Private recipes

_ensure_examples_output:
-mkdir -p examples/output

# ============== Include project-specific recipes ==============

# Include project-specific recipes
import "project.justfile"