Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-structuring, clean-up, fixes for first 0.2.x release #31

Merged
merged 27 commits into from
Feb 12, 2025
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
679db38
Remove make
dalito Feb 8, 2025
1ad8be5
Remove content in project that can be generated.
dalito Feb 8, 2025
99c2047
Adjust justfile & README for generating project dir contents
dalito Feb 8, 2025
25ac8ab
Make pypi & docs-preview optional via copier config
dalito Feb 9, 2025
29278ea
Remove create_python_classes template variable
dalito Feb 9, 2025
500af6c
Remove github_token_for_pypi_deployment template variable
dalito Feb 9, 2025
09056b6
Add yamllint config to template
dalito Feb 9, 2025
4ba4e83
Make example optional and always using Person class
dalito Feb 9, 2025
7a70ee2
Make docs handling more best-practice conform
dalito Feb 9, 2025
a81de7c
Change directory locations for docs
dalito Feb 9, 2025
d6c15f7
Manage docs in docs-directory the standard mkdocs-way
dalito Feb 10, 2025
16f1170
Add pydantic-generator
dalito Feb 10, 2025
e231abf
Fix slug-generation in copier questions
dalito Feb 10, 2025
0e5c3eb
Don't use just for docs build but only mkdocs
dalito Feb 10, 2025
e06ef9f
Directory rename docs/schema->docs/elements
dalito Feb 11, 2025
cfaf0cc
Fix comments in actions
dalito Feb 11, 2025
c2d9436
Reorganize example/test data locations
dalito Feb 11, 2025
d9e86ad
Add Unlicense as another license option
dalito Feb 11, 2025
e57c72d
Add __init__.py to package root
dalito Feb 11, 2025
653dd07
Improve just command help
dalito Feb 11, 2025
1cec890
Add .py.jinja to .editorconfig
dalito Feb 11, 2025
88fea25
Change to pytest & add test of invalid data
dalito Feb 11, 2025
3eb82d1
Remove example-dir handling from justfile
dalito Feb 11, 2025
70bb258
Improve example project & fix test data
dalito Feb 11, 2025
05c1e45
Prepare watch/rebuild schema docs; add root index.md
dalito Feb 11, 2025
c4e92c8
Add 0.2.0 migration to copier with just recipe
dalito Feb 12, 2025
93b009f
Update README after releasing v0.1.7
dalito Feb 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add 0.2.0 migration to copier with just recipe
dalito committed Feb 12, 2025
commit c4e92c8fc59b6374fe1682f457c9763b5704004b
7 changes: 7 additions & 0 deletions copier.yaml
Original file line number Diff line number Diff line change
@@ -155,6 +155,13 @@ _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"
143 changes: 76 additions & 67 deletions template/justfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# ============ 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, give the path to the executable in the following line.
# If it is not on path, provide 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}'


# 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)
# Set shebang line for cross-platform Python recipes (assumes presence of launcher on Windows)
shebang := if os() == 'windows' {
'py'
} else {
@@ -22,13 +21,11 @@ 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 {
@@ -46,20 +43,80 @@ dest := "project"
pymodel := src / schema_name / "datamodel"
docdir := "docs/elements" # Directory for generated documentation

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

# Run initial setup (run this first)
# Initialize a new project (use this for projects not yet under version control)
[group('project management')]
setup: _check-config _git-init install _gen-project gendoc _git-add _git-commit
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

# 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}}
@@ -70,10 +127,6 @@ _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
@@ -82,15 +135,6 @@ _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 && \
@@ -113,10 +157,6 @@ _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}}
@@ -135,38 +175,14 @@ _test-examples: _ensure_examples_output
--output-directory examples/output \
--schema {{source_schema_path}} > examples/output/README.md

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

# Generate markdown documentation for the schema
gendoc:
# Generate 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
@@ -189,16 +205,9 @@ _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"