UNPKG

@installdoc/ansible-gas-station

Version:

An Ansible playbook that provisions your network with software from GitHub Awesome lists, developed with disaster recovery in mind ⛽🔥🤤

104 lines (94 loc) 4.15 kB
--- version: '3' vars: DEVCONTAINER_CONFIG: .devcontainer/devcontainer.json EXTENSIONS_FILE: .vscode/extensions.json EXTENSIONS_URL: https://gitlab.com/megabyte-labs/gas-station/-/raw/master/environments/prod/group_vars/desktop/vscode-extensions.yml TASKS_FILE: .vscode/tasks.json tasks: extensions: deps: - :install:npm:prettier - :install:software:jq - :install:software:yq summary: | # Generates the `{{.EXTENSIONS_FILE}}` file for VS Code auto plugin recommendations This task generates the `{{.EXTENSIONS_FILE}}` file which is used to automatically have VS Code show a popup with a link that leads to a list of plugins that the project recommends. This list is populated by converting the list of VS Code plugins installed by default by [Gas Station](https://gitlab.com/megabyte-labs/gas-station) into VS Code syntax. log: error: Failed to generate `{{.EXTENSIONS_FILE}}` start: Generating `{{.EXTENSIONS_FILE}}` success: Generated `{{.EXTENSIONS_FILE}}` cmds: - mkdir -p .vscode - | TMP="$(mktemp)" curl -s {{.EXTENSIONS_URL}} > "$TMP" TMP_YQ="$(mktemp)" yq e '.vscode_extensions[].name' - < "$TMP" > "$TMP_YQ" TMP_JQ="$(mktemp)" jq -cRrs 'split("\n") | "{ \"recommendations\": \(.) }"' < "$TMP_YQ" > "$TMP_JQ" sed 's/,""//' < "$TMP_JQ" > '{{.EXTENSIONS_FILE}}' - | {{.NPX_HANDLE}}prettier --write '{{.EXTENSIONS_FILE}}' > /dev/null extensions:devcontainer: deps: - :install:npm:prettier - :install:software:jq summary: | # Inject `devcontainer.json` with Extensions This task synchronizes the extensions from `.vscode/extensions.json` into the `.devcontainer/devcontainer.json` extensions field. log: error: Failed to inject `{{.EXTENSIONS_FILE}}` `recommendations` into `{{.DEVCONTAINER_CONFIG}}` start: Injecting `{{.EXTENSIONS_FILE}}` `recommendations` into `{{.DEVCONTAINER_CONFIG}}` success: Successfully injected `{{.EXTENSIONS_FILE}}` `recommendations` into `{{.DEVCONTAINER_CONFIG}}` cmds: - | TMP="$(mktemp)" jq --arg recommendations "$(jq '.recommendations' {{.EXTENSIONS_FILE}})" '.extensions = ($recommendations | fromjson)' {{.DEVCONTAINER_CONFIG}} > "$TMP" mv "$TMP" {{.DEVCONTAINER_CONFIG}} - | {{.NPX_HANDLE}}prettier --write '{{.DEVCONTAINER_CONFIG}}' > /dev/null generate: deps: - extensions - tasks cmds: - task: extensions:devcontainer tasks: deps: - :install:npm:prettier - :install:software:jq summary: | # Populate the `.vscode/tasks.json` file This task populates the `.vscode/tasks.json` file with tasks that are viewable by running `task --list`. With the file generated using the output from `tasks --list`, the user can then easily run any of the tasks from within VS Code. This is a simple implementation. There are many features provided by VS Code that we can potentially leverage to make our `tasks.json` better and more useful to developers. run: when_changed log: error: Failed to generate `{{.EXTENSIONS_FILE}}` start: Generating `.vscode/tasks.json` success: Generated `{{.EXTENSIONS_FILE}}` cmds: - | TMP="$(mktemp)" echo '{"version": "2.0.0"}' > "$TMP" TASKS='[' while read LINE; do if [[ "${LINE:0:1}" == '*' ]]; then TASK_NAME=$(echo "$LINE" | sed 's/^\*.\([^\ ]*\):\(.*\)$/\1/g' | xargs) TASK_DESC=$(echo "$LINE" | sed 's/^\*.\([^\ ]*\):\(.*\)$/\2/g' | xargs) LABEL="($TASK_NAME): $TASK_DESC" TYPE="shell" COMMAND="bash .config/scripts/start.sh && task $TASK_NAME" TASKS+="{\"label\": \"$LABEL\", \"type\": \"$TYPE\", \"command\": \"$COMMAND\"}," fi done <<< "$(task --list)" jq --arg tasks "${TASKS%?}]" '.tasks = ($tasks | fromjson)' "$TMP" > '{{.TASKS_FILE}}' - | {{.NPX_HANDLE}}prettier --write '{{.TASKS_FILE}}' > /dev/null