Skip to content

Commit e3a58a0

Browse files
authored
Merge pull request #3 from fastapi-mvc/update_generator
Update generator
2 parents 23e4ccb + b8538a3 commit e3a58a0

File tree

7 files changed

+151
-49
lines changed

7 files changed

+151
-49
lines changed

.generator.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Changes here will be overwritten by Copier
2-
_commit: 0.2.0
2+
_commit: 0.4.1
33
_src_path: https://github.com/fastapi-mvc/copier-generator
44
copyright_date: 2022
55
generator: controller
66
generator_name: controller
7+
github_actions: true
78
license: MIT
89
nix: true
910
repo_url: https://github.com/fastapi-mvc/copier-controller

.github/dependabot.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "monthly"

.github/workflows/update-flake.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Update flake
2+
on:
3+
workflow_dispatch:
4+
# # runs weekly on Sunday at 00:00
5+
# schedule:
6+
# - cron: '0 0 * * 0'
7+
8+
jobs:
9+
lockfile:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v3
14+
- name: Install Nix
15+
uses: DeterminateSystems/nix-installer-action@v1
16+
- name: Update flake.lock
17+
uses: DeterminateSystems/update-flake-lock@v17
18+
with:
19+
pr-title: "Update flake.lock"
20+
# https://github.com/DeterminateSystems/update-flake-lock#with-a-personal-authentication-token
21+
token: ${{ secrets.API_TOKEN_GITHUB }}
22+
pr-labels: |
23+
dependencies
24+
pr-body: |
25+
Automated changes by the [update-flake-lock](https://github.com/DeterminateSystems/update-flake-lock) GitHub Action.
26+
```
27+
{{ env.GIT_COMMIT_MESSAGE }}
28+
```

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ Copier template for scaffolding new controller upon [fastapi-mvc](https://github
44

55
## Quickstart
66

7+
### Using fastapi-mvc
8+
9+
Prerequisites:
10+
* fastapi-mvc
11+
* Git 2.27 or newer
12+
13+
```shell
14+
git clone "https://github.com/fastapi-mvc/copier-controller.git"
15+
FMVC_PATH="$PWD:$FMVC_PATH" fastapi-mvc generate controller /path/to/your/new/controller
16+
```
17+
18+
### Using copier
19+
720
To use this template outside `fastapi-mvc`:
821

922
Prerequisites:

flake.lock

+69-28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+32-20
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,43 @@
11
{
22
description = "Fastapi-mvc generator flake";
3-
nixConfig.bash-prompt = ''\n\[\033[1;32m\][nix-develop:\w]\$\[\033[0m\] '';
3+
nixConfig = {
4+
bash-prompt = ''\n\[\033[1;32m\][nix-develop:\w]\$\[\033[0m\] '';
5+
extra-trusted-public-keys = [
6+
"fastapi-mvc.cachix.org-1:knQ8Qo41bnhBmOB6Sp0UH10EV76AXW5o69SbAS668Fg="
7+
];
8+
extra-substituters = [
9+
"https://fastapi-mvc.cachix.org"
10+
];
11+
};
412

513
inputs = {
6-
flake-utils.url = "github:numtide/flake-utils";
7-
fastapi-mvc.url = "github:fastapi-mvc/fastapi-mvc?ref=0.25.0";
14+
flake-parts.url = "github:hercules-ci/flake-parts";
15+
fastapi-mvc.url = "github:fastapi-mvc/fastapi-mvc";
816
nixpkgs.follows = "fastapi-mvc/nixpkgs";
917
};
1018

11-
outputs = { self, nixpkgs, flake-utils, fastapi-mvc }:
12-
{
13-
overlays.default = nixpkgs.lib.composeManyExtensions [
14-
fastapi-mvc.overlays.default
15-
];
16-
} // (flake-utils.lib.eachDefaultSystem (system:
17-
let
18-
pkgs = import nixpkgs {
19-
inherit system;
20-
overlays = [ self.overlays.default ];
19+
outputs = { self, nixpkgs, flake-parts, fastapi-mvc }@inputs:
20+
let
21+
mkApp =
22+
{ drv
23+
, name ? drv.pname or drv.name
24+
, exePath ? drv.passthru.exePath or "/bin/${name}"
25+
}:
26+
{
27+
type = "app";
28+
program = "${drv}${exePath}";
2129
};
22-
in
23-
rec {
30+
in
31+
flake-parts.lib.mkFlake { inherit inputs; } {
32+
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
33+
perSystem = { config, self', inputs', pkgs, system, ... }: {
2434
apps = {
25-
fastapi-mvc = flake-utils.lib.mkApp { drv = pkgs.fastapi-mvc; };
35+
fastapi-mvc = mkApp { drv = fastapi-mvc.packages.${system}.default; };
2636
copier = {
2737
type = "app";
2838
program = toString (pkgs.writeScript "copier" ''
2939
export PATH="${pkgs.lib.makeBinPath [
30-
pkgs.fastapi-mvc.dependencyEnv
40+
fastapi-mvc.packages.${system}.default.dependencyEnv
3141
pkgs.git
3242
pkgs.coreutils
3343
]}"
@@ -38,7 +48,7 @@
3848
type = "app";
3949
program = toString (pkgs.writeScript "update" ''
4050
export PATH="${pkgs.lib.makeBinPath [
41-
pkgs.fastapi-mvc.dependencyEnv
51+
fastapi-mvc.packages.${system}.default.dependencyEnv
4252
pkgs.git
4353
pkgs.coreutils
4454
]}"
@@ -49,20 +59,22 @@
4959
-d license=MIT \
5060
-d repo_url=https://github.com/fastapi-mvc/copier-controller \
5161
-d copyright_date=2022 \
62+
-d github_actions=True \
5263
-a .generator.yml \
5364
update ./.
5465
'');
5566
};
5667
};
5768

5869
devShells = {
59-
default = pkgs.fastapi-mvc-dev.env.overrideAttrs (oldAttrs: {
70+
default = fastapi-mvc.packages.${system}.fastapi-mvc-dev.env.overrideAttrs (oldAttrs: {
6071
buildInputs = [
6172
pkgs.git
6273
pkgs.coreutils
6374
pkgs.poetry
6475
];
6576
});
6677
};
67-
}));
78+
};
79+
};
6880
}

update.sh

+1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ copier -x template/** -x copier.yml -x *.py -x CHANGELOG.md \
1515
-d license=MIT \
1616
-d repo_url=https://github.com/fastapi-mvc/copier-controller \
1717
-d copyright_date=2022 \
18+
-d github_actions=True \
1819
-a .generator.yml \
1920
update ./.

0 commit comments

Comments
 (0)