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

feat: enable sync between new versions of inception and existing repos #60

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 23 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Top-most EditorConfig
root = true

[*]
# Unix-style newlines with a newline ending every file
end_of_line = lf
insert_final_newline = true
# Be gentle!
charset = utf-8
trim_trailing_whitespace = true

[Makefile]
indent_style = tab

[*.{js,json}]
indent_style = space
indent_size = 2

[{{_copier_conf.answers_file}}.jinja]
insert_final_newline = false

[.copier-answers.yml]
insert_final_newline = false
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,4 @@ pyrightconfig.json
# End of https://www.toptal.com/developers/gitignore/api/python,direnv

.devenv.flake.nix
.pre-commit-config.yaml
.pre-commit-config.yaml
38 changes: 21 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,24 @@ decision and help us to improve them.
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc -->
**Table of Contents**

- [Inception](#inception)
- [In Action](#in-action)
- [Features](#features)
- [Detailed Features](#detailed-features)
- [Detailed Features](#detailed-features)
- [How to Use](#how-to-use)
- [Prerequisites](#prerequisites)
- [Initialize a New Project](#initialize-a-new-project)
- [Prerequisites](#prerequisites)
- [Initialize a New Project](#initialize-a-new-project)
- [Resources](#resources)
- [Contributing](#contributing)
- [License](#license)
- [Acknowledgments](#acknowledgments)

<!-- markdown-toc end -->


# In Action
## In Action

[![asciicast](https://asciinema.org/a/Mp4w76BgrVcu4hvUR9nbb8EIL.svg)](https://asciinema.org/a/Mp4w76BgrVcu4hvUR9nbb8EIL)

# Features
## Features

1. **Opinionated Configuration**: Reduces decision fatigue by
providing fewer, well-chosen options.
Expand All @@ -51,7 +49,7 @@ decision and help us to improve them.
6. **Comprehensive .gitignore**: Includes a well-crafted `.gitignore`
file.

## Detailed Features
### Detailed Features

| Feature | Python | Node.js | Go | Rust |
| ------------------------- | ------ | ------- | --- | ---- |
Expand All @@ -71,9 +69,9 @@ decision and help us to improve them.
| difftastic | ✅ | ✅ | ✅ | ✅ |
| dotenv | ✅ | ✅ | ✅ | ✅ |

# How to Use
## How to Use

## Prerequisites
### Prerequisites

To start working with Inception, you need:

Expand All @@ -86,8 +84,8 @@ To start working with Inception, you need:
>
> 1. Use your own shell configuration in `devenv` session.
> 2. Automatically integrated with your IDE (VSCode and Intellij support
> it out of the box, and for Emacs and Vim you can use suggested
> plugins below).
> it out of the box, and for Emacs and Vim you can use suggested
> plugins below).
>
> For more information on how to enable it you can refer to [this wiki
> entry](https://github.com/DataChefHQ/inception/wiki/How-to-enable-direnv%3F).
Expand All @@ -105,7 +103,13 @@ To start working with Inception, you need:
> - [Add user to the trusted user list](https://github.com/DataChefHQ/inception/wiki/MacOS:-add-user-to-the-trusted-user-list)
> - [Trusting git directory](https://github.com/DataChefHQ/inception/wiki/Trusting-git-directory)

## Initialize a New Project
### Initialize a New Project

First, create a project folder and cd into it.

```bash
mkdir awesome-project && cd awesome-project
```

Using pipx:

Expand All @@ -119,22 +123,22 @@ If you have copier installed locally, use:
copier copy --trust gh:DataChefHQ/Inception .
```

# Resources
## Resources

- [Devenv Docs](https://devenv.sh/getting-started/)
- [Nix in 100 Seconds](https://www.youtube.com/watch?v=FJVFXsNzYZQ)

# Contributing
## Contributing

We welcome contributions! Please check out our [contributing
guidelines](CONTRIBUTING.md) to get started.

# License
## License

This project is licensed under the MIT License - see the
[LICENSE](LICENSE) file for details.

# Acknowledgments
## Acknowledgments

- Thanks to the open-source community for their invaluable
contributions to projects which we are building on:
Expand Down
30 changes: 17 additions & 13 deletions copier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,34 +52,38 @@ author_email:
type: str
help: "Author Email"

_subdirectory: template
_subdirectory: template/{{ language }}

# Execute these commands on destination after copy
_tasks:
- command: |
devenv shell nixfmt .
git init
git add .
git commit -am 'This is the Inception 🎉'
working_directory: "{{ project_name }}"
- devenv shell nixfmt .
- git init
- git add .
- git commit -am 'This is the Inception 🎉'

_message_before_copy: |
Welcome to Incption 🎉, the gateway to your next big project!

Your next adventure starts here. Answer a few quick questions, and
I'll create a project tailored just for you!
Welcome to Inception 🎉, the gateway to your next big project!

Your next adventure starts here. Answer a few quick questions,
and I'll create a project tailored just for you!

Let's create something amazing! 🚀✨

_message_after_copy: |

🎉 {{project_name}} Created Successfully! 🎉

Your tailored project is ready and waiting for you. Next steps:
Your tailored project is ready and waiting for you. Next steps

1. Change directory to the project root:
1. Allow direnv to load your project environment

$ cd {{ _copier_conf.dst_path }}/{{ project_name }}
$ direnv allow

2. Let's hack 🧑🏻‍💻

Good Luck, DataChef 🧑‍🍳

_message_after_update: |

🎉 Project updated to latest Inception version! 🎉
1 change: 1 addition & 0 deletions devenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ in
yamllint = {
enable = true;
settings.preset = "relaxed";
excludes = [ ".copier-answers.yml" ];
};
pyright.enable = true;
editorconfig-checker.enable = true;
Expand Down
1 change: 1 addition & 0 deletions includes/.copier-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ _copier_answers|to_nice_yaml -}}
2 changes: 1 addition & 1 deletion includes/README.release.md.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ After the script finished successfully, you need to:

If you want to have a release on your source control system, Github or
Gitlab, you can do it dependent to the system, using the published
tags.
tags.
37 changes: 36 additions & 1 deletion includes/base.nix.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,36 @@
scripts = {
hello.exec = "echo $GREET";
cat.exec = "bat $@";
check-inception-updates.exec = ''
GREEN="\033[0;32m";
NC="\033[0m";

latest_tag=$(curl -s -L -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/DataChefHQ/inception/releases/latest | jq --raw-output '.tag_name')
current_commit=$(yq '.["_commit"]' .copier-answers.yml)

if [[ "$(printf '%s\n' "$current_commit" "$latest_tag" | sort -V | head -n 1)" != "$latest_tag" ]]; then
echo
echo "🎉 There's an update available for Inception!"
echo
echo -e " Your version: $current_commit"
echo -e " Latest version: $latest_tag"
echo
echo -e To update, run "$GREEN"inception-update"$NC" in your shell.
echo
echo "⚠️ WARNING"
echo
echo " Sometimes it's impossible to know what to do with a diff code hunk."
echo " In that case, the conflicting file is updated with conflict markers,"
echo " and you'll have to choose which version to keep."
echo
echo " More info at: https://copier.readthedocs.io/en/stable/updating/"
fi
'';

inception-update = {
description = "Sync this project with the latest version of Inception.";
exec = "pipx run copier update --defaults -T --trust";
};

show = {
# Prints scripts that have a description
Expand Down Expand Up @@ -51,7 +81,9 @@
nixfmt-rfc-style
bat
jq
yq-go
tealdeer
pipx # to use copier in projects
{%- block packages %}{% endblock -%}
];

Expand All @@ -62,6 +94,8 @@
enterShell = ''
hello
show
check-inception-updates

{%- block enter_shell %}{% endblock -%}
'';

Expand All @@ -77,6 +111,7 @@
enable = true;
settings.preset = "relaxed";
};
check-merge-conflicts.enable = true;
{%- block hooks %}{% endblock -%}
};

Expand All @@ -88,4 +123,4 @@

# https://devenv.sh/integrations/codespaces-devcontainer/
devcontainer.enable = true;
}
}
2 changes: 1 addition & 1 deletion includes/go.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
# vendor/

# Go workspace file
go.work
go.work
2 changes: 1 addition & 1 deletion includes/node.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@ dist
# Optional stylelint cache

# SvelteKit build / generate output
.svelte-kit
.svelte-kit
2 changes: 1 addition & 1 deletion includes/python.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,4 @@ poetry.toml
.ruff_cache/

# LSP config files
pyrightconfig.json
pyrightconfig.json
2 changes: 1 addition & 1 deletion includes/rust.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ Cargo.lock
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
*.pdb
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

{% block languages %}
go.enable = true;
{% endblock %}
{% endblock %}
2 changes: 2 additions & 0 deletions template/Go/{{_copier_conf.answers_file}}.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
{% include pathjoin("includes", ".copier-answers.yml") %}
File renamed without changes.
2 changes: 2 additions & 0 deletions template/Node.js/{{_copier_conf.answers_file}}.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
{% include pathjoin("includes", ".copier-answers.yml") %}
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions template/Python/{{_copier_conf.answers_file}}.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
{% include pathjoin("includes", ".copier-answers.yml") %}
File renamed without changes.
2 changes: 2 additions & 0 deletions template/Rust/{{_copier_conf.answers_file}}.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
{% include pathjoin("includes", ".copier-answers.yml") %}
Loading