-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use Init command and service from upstream
This is *almost* a chore, as the templates, supported profiles, etc are all unchanged. However, the upstream command adds support for the "--project-dir" argument, so this is ends up being a feature. Fixes #753
- Loading branch information
Showing
21 changed files
with
344 additions
and
440 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ fileset | |
filesets | ||
filesystem | ||
filesystems | ||
filetree | ||
fs | ||
gc | ||
GiB | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- | ||
# | ||
# Copyright 2024 Canonical Ltd. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License version 3 as | ||
# published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
"""Rockcraft Init Service.""" | ||
import pathlib | ||
from typing import Any | ||
|
||
from craft_application.services import InitService | ||
from craft_cli import emit | ||
from overrides import override # type: ignore[reportUnknownVariableType] | ||
|
||
|
||
class RockcraftInitService(InitService): | ||
"""Rockcraft specialization of the InitService.""" | ||
|
||
@override | ||
def initialise_project( | ||
self, | ||
*, | ||
project_dir: pathlib.Path, | ||
project_name: str, | ||
template_dir: pathlib.Path, | ||
) -> None: | ||
super().initialise_project( | ||
project_dir=project_dir, | ||
project_name=project_name, | ||
template_dir=template_dir, | ||
) | ||
|
||
init_profile = template_dir.name | ||
if init_profile != "simple": | ||
versioned_docs = self._app.versioned_docs_url | ||
reference_docs = f"{versioned_docs}/reference/extensions/{init_profile}" | ||
emit.message( | ||
f"Go to {reference_docs} to read more about the " | ||
f"{init_profile!r} profile." | ||
) | ||
|
||
@override | ||
def _get_context(self, name: str, *, project_dir: pathlib.Path) -> dict[str, Any]: | ||
context = super()._get_context(name, project_dir=project_dir) | ||
context["snake_name"] = context["name"].replace("-", "_").lower() | ||
context["versioned_url"] = self._app.versioned_docs_url | ||
|
||
return context |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: {{name}} | ||
# see {{versioned_url}}/explanation/bases/ | ||
# for more information about bases and using 'bare' bases for chiselled rocks | ||
base: [email protected] # the base environment for this Django application | ||
version: '0.1' # just for humans. Semantic versioning is recommended | ||
summary: A summary of your Django application # 79 char long summary | ||
description: | | ||
This is {{name}}'s description. You have a paragraph or two to tell the | ||
most important story about it. Keep it under 100 words though, | ||
we live in tweetspace and your description wants to look good in the | ||
container registries out there. | ||
# the platforms this rock should be built on and run on. | ||
# you can check your architecture with `dpkg --print-architecture` | ||
platforms: | ||
amd64: | ||
# arm64: | ||
# ppc64el: | ||
# s390x: | ||
|
||
# to ensure the django-framework extension functions properly, your Django project | ||
# should have a structure similar to the following with ./{{snake_name}}/{{snake_name}}/wsgi.py | ||
# being the WSGI entry point and contain an application object. | ||
# +-- {{snake_name}} | ||
# | |-- {{snake_name}} | ||
# | | |-- wsgi.py | ||
# | | +-- ... | ||
# | |-- manage.py | ||
# | |-- migrate.sh | ||
# | +-- some_app | ||
# | |-- views.py | ||
# | +-- ... | ||
# |-- requirements.txt | ||
# +-- rockcraft.yaml | ||
|
||
extensions: | ||
- django-framework | ||
|
||
# uncomment the sections you need and adjust according to your requirements. | ||
# parts: | ||
# django-framework/dependencies: | ||
# stage-packages: | ||
# # list required packages or slices for your Django application below. | ||
# - libpq-dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: {{name}} | ||
# see {{versioned_url}}/explanation/bases/ | ||
# for more information about bases and using 'bare' bases for chiselled rocks | ||
base: [email protected] # the base environment for this FastAPI application | ||
version: '0.1' # just for humans. Semantic versioning is recommended | ||
summary: A summary of your FastAPI application # 79 char long summary | ||
description: | | ||
This is fastapi project's description. You have a paragraph or two to tell the | ||
most important story about it. Keep it under 100 words though, | ||
we live in tweetspace and your description wants to look good in the | ||
container registries out there. | ||
# the platforms this rock should be built on and run on. | ||
# you can check your architecture with `dpkg --print-architecture` | ||
platforms: | ||
amd64: | ||
# arm64: | ||
# ppc64el: | ||
# s390x: | ||
|
||
# to ensure the FastAPI-framework extension works properly, your FastAPI application | ||
# should have an ASGI entrypoint variable named `app`. This variable has to be defined | ||
# in one of the following places: | ||
# 1. `app.py` file in the base directory | ||
# 2. In any of the following directories, the extension will look for the variable | ||
# in the files __init__.py, app.py or main.py: | ||
# a. `app` directory. | ||
# b. `src` directory. | ||
# c. A directory with the same name as the project. | ||
# a `requirements.txt` file with at least the fastapi/starlette package should also | ||
# exist in the base directory. | ||
# see {{versioned_url}}/reference/extensions/fastapi-framework | ||
# for more information. | ||
extensions: | ||
- fastapi-framework | ||
|
||
# uncomment the sections you need and adjust according to your requirements. | ||
# parts: # you need to uncomment this line to add or update any part. | ||
|
||
# fastapi-framework/install-app: | ||
# prime: | ||
# # by default, only the files in app.py, app/, src/, "project name/" templates/, | ||
# # static/, migrate, migrate.sh, migrate.py and main.py are copied into the image. | ||
# # You can modify the list below to override the default list and | ||
# # include or exclude specific files/directories in your project. | ||
# # note: prefix each entry with "app/" followed by the local path. | ||
# - app/app | ||
# - app/templates | ||
# - app/static | ||
|
||
# you may need Ubuntu packages to build a python dependency. Add them here if necessary. | ||
# fastapi-framework/dependencies: | ||
# build-packages: | ||
# # for example, if you need pkg-config and libxmlsec1-dev to build one | ||
# # of your packages: | ||
# - pkg-config | ||
# - libxmlsec1-dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: {{name}} | ||
# see {{versioned_url}}/explanation/bases/ | ||
# for more information about bases and using 'bare' bases for chiselled rocks | ||
base: [email protected] # the base environment for this Flask application | ||
version: '0.1' # just for humans. Semantic versioning is recommended | ||
summary: A summary of your Flask application # 79 char long summary | ||
description: | | ||
This is {{name}}'s description. You have a paragraph or two to tell the | ||
most important story about it. Keep it under 100 words though, | ||
we live in tweetspace and your description wants to look good in the | ||
container registries out there. | ||
# the platforms this rock should be built on and run on. | ||
# you can check your architecture with `dpkg --print-architecture` | ||
platforms: | ||
amd64: | ||
# arm64: | ||
# ppc64el: | ||
# s390x: | ||
|
||
# to ensure the flask-framework extension works properly, your Flask application | ||
# should have an `app.py` file with an `app` object as the WSGI entrypoint. | ||
# a `requirements.txt` file with at least the flask package should also exist. | ||
# see {{versioned_url}}/reference/extensions/flask-framework | ||
# for more information. | ||
extensions: | ||
- flask-framework | ||
|
||
# uncomment the sections you need and adjust according to your requirements. | ||
# parts: # you need to uncomment this line to add or update any part. | ||
|
||
# flask-framework/install-app: | ||
# prime: | ||
# # by default, only the files in app/, templates/, static/, migrate, migrate.sh, | ||
# # migrate.py and app.py are copied into the image. You can modify the list | ||
# # below to override the default list and include or exclude specific | ||
# # files/directories in your project. | ||
# # note: prefix each entry with "flask/app/" followed by the local path. | ||
# - flask/app/.env | ||
# - flask/app/app.py | ||
# - flask/app/webapp | ||
# - flask/app/templates | ||
# - flask/app/static | ||
|
||
# you may need Ubuntu packages to build a python dependency. Add them here if necessary. | ||
# flask-framework/dependencies: | ||
# build-packages: | ||
# # for example, if you need pkg-config and libxmlsec1-dev to build one | ||
# # of your packages: | ||
# - pkg-config | ||
# - libxmlsec1-dev | ||
|
||
# you can add package slices or Debian packages to the image. | ||
# package slices are subsets of Debian packages, which result | ||
# in smaller and more secure images. | ||
# see {{versioned_url}}/explanation/chisel/ | ||
|
||
# add this part if you want to add packages slices to your image. | ||
# you can find a list of packages slices at https://github.com/canonical/chisel-releases | ||
# runtime-slices: | ||
# plugin: nil | ||
# stage-packages: | ||
# # list the required package slices for your flask application below. | ||
# # for example, for the slice libs of libpq5: | ||
# - libpq5_libs | ||
|
||
# if you want to add a Debian package to your image, add the next part | ||
# runtime-debs: | ||
# plugin: nil | ||
# stage-packages: | ||
# # list required Debian packages for your flask application below. | ||
# - libpq5 |
Oops, something went wrong.