diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000000..58ea211b70 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,29 @@ +FROM mcr.microsoft.com/devcontainers/base:ubuntu + +USER vscode + +ENV CONDA_DIR=/home/vscode/miniconda +ENV PATH="$CONDA_DIR/bin:$PATH" + +ARG PYTHON_VERSION=3.12 +ARG NODEJS_VERSION=24 + +# Install Miniconda +RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh \ + && bash ~/miniconda.sh -b -p $CONDA_DIR \ + && rm ~/miniconda.sh \ + && conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main \ + && conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r + +# Configure conda environment +RUN eval "$(conda shell.bash hook)" \ + && conda create -n maa python=$PYTHON_VERSION -y \ + && conda activate maa \ + && conda install -y conda-forge::nodejs=$NODEJS_VERSION \ + && pip install pre-commit black \ + && npm install -g pnpm + +# Finalize conda setup +RUN conda init \ + && conda config --set auto_activate false \ + && echo "conda activate maa" >> ~/.bashrc diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e500c55373..2d4e6eeede 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,12 +1,50 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node { - "image": "mcr.microsoft.com/devcontainers/cpp:ubuntu-22.04", - "features": { - "ghcr.io/devcontainers/features/python:1": {}, - "ghcr.io/devcontainers/features/sshd:1": {} + "name": "MAA", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + // "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "build": { + "dockerfile": "Dockerfile" }, + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [3001], + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "bash .devcontainer/post-create.sh", + + // Configure tool-specific properties. "customizations": { "vscode": { - "extensions": ["llvm-vs-code-extensions.vscode-clangd", "DavidAnson.vscode-markdownlint"] + "extensions": [ + "mkxml.vscode-filesize", + "nekosu.maa-support", + "DavidAnson.vscode-markdownlint", + "esbenp.prettier-vscode", + "vue.volar", + "ms-python.python", + "ms-python.black-formatter" + ], + "settings": { + // format + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "[markdown]": { + "editor.defaultFormatter": "DavidAnson.vscode-markdownlint" + }, + "[python]": { + "editor.defaultFormatter": "ms-python.black-formatter" + }, + // python + "python.terminal.launchArgs": ["-u"], + "python.defaultInterpreterPath": "/home/vscode/miniconda/envs/maa/bin/python", + "python.terminal.activateEnvironment": false + } } } + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" } diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh new file mode 100644 index 0000000000..a2aa336b6a --- /dev/null +++ b/.devcontainer/post-create.sh @@ -0,0 +1,21 @@ +#!/bin/bash +WORKSPACE=$(pwd) + +# conda activate maa + +echo "====================" +echo "Setting up git safe.directory for $WORKSPACE and its submodules..." +cd "$WORKSPACE" +git config --global --add safe.directory "$WORKSPACE" +git submodule foreach --recursive 'git config --global --add safe.directory "$toplevel/$path"' + +echo "====================" +cd "$WORKSPACE" +echo "Installing dependencies for python..." +# pip install -r tools/.../requirements.txt +# pip install -r tools/.../requirements-dev.txt + +echo "====================" +echo "Installing dependencies for nodejs..." +cd "$WORKSPACE"/docs +pnpm install --frozen-lockfile diff --git a/.gitignore b/.gitignore index ed20ec245e..b1fd3510dd 100644 --- a/.gitignore +++ b/.gitignore @@ -474,4 +474,7 @@ Thumbs.db # build & install build -install \ No newline at end of file +install + +# pnpm cache +.pnpm-store diff --git a/docs/.vuepress/config.ts b/docs/.vuepress/config.ts index a3f1590452..7eed79b33a 100644 --- a/docs/.vuepress/config.ts +++ b/docs/.vuepress/config.ts @@ -12,6 +12,7 @@ export default defineUserConfig({ lang: 'zh-CN', title: 'MaaAssistantArknights', description: 'MAA', + host: '0.0.0.0', port: 3001, locales: { diff --git a/docs/pnpm-workspace.yaml b/docs/pnpm-workspace.yaml index 4e768febea..ae83bfed23 100644 --- a/docs/pnpm-workspace.yaml +++ b/docs/pnpm-workspace.yaml @@ -1,3 +1,7 @@ +packages: + - . + onlyBuiltDependencies: + - "@parcel/watcher" - esbuild - vue-demi