From 1d98ffd04fb581de6703ad99bf386731206ed1b4 Mon Sep 17 00:00:00 2001 From: Igor Borges Date: Sat, 13 Mar 2021 22:54:11 +0000 Subject: [PATCH 1/3] Add codespaces --- .devcontainer/Dockerfile | 29 ++ .devcontainer/devcontainer.json | 33 ++ .devcontainer/library-scripts/README.md | 5 + .../library-scripts/common-debian.sh | 326 ++++++++++++++++++ 4 files changed, 393 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/library-scripts/README.md create mode 100755 .devcontainer/library-scripts/common-debian.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..6a372109 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,29 @@ +# Update VARIANT in devcontainer.json to pick a Dart version +ARG VARIANT=2 +FROM google/dart:${VARIANT} + +# [Option] Install zsh +ARG INSTALL_ZSH="true" +# [Option] Upgrade OS packages to their latest versions +ARG UPGRADE_PACKAGES="false" + +# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies. +ARG USERNAME=vscode +ARG USER_UID=1000 +ARG USER_GID=$USER_UID +COPY library-scripts/*.sh /tmp/library-scripts/ +RUN apt-get update \ + && /bin/bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" \ + && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts + +# Add bin location to path +ENV PUB_CACHE="/usr/local/share/pub-cache" +ENV PATH="${PATH}:${PUB_CACHE}/bin" +RUN mkdir -p ${PUB_CACHE} \ + && chown ${USERNAME}:root ${PUB_CACHE} \ + && echo "if [ \"\$(stat -c '%U' ${PUB_CACHE})\" != \"${USERNAME}\" ]; then sudo chown -R ${USER_UID}:root ${PUB_CACHE}; fi" \ + | tee -a /root/.bashrc /root/.zshrc /home/${USERNAME}/.bashrc >> /home/${USERNAME}/.zshrc + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..0d2935c3 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,33 @@ +{ + "name": "Dart", + "build": { + "dockerfile": "Dockerfile", + // Update VARIANT to pick a Dart version + "args": { + "VARIANT": "2", + }, + }, + // Set *default* container specific settings.json values on container create. + "settings": { + "editor.formatOnSave": true, + "terminal.integrated.shell.linux": "/usr/bin/zsh", + "editor.fontLigatures": true, + "workbench.colorTheme": "Default Dark+", + "editor.fontFamily": "'Jetbrains Mono', Menlo, Monaco, 'Courier New', monospace", + }, + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "dart-code.dart-code", + "dart-code.flutter", + "redhat.vscode-yaml", + "luanpotter.dart-import", + "jeroen-meijer.pubspec-assist", + "kumar-harsh.graphql-for-vscode", + ], + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "uname -a", + // Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root. + // "remoteUser": "vscode" +} \ No newline at end of file diff --git a/.devcontainer/library-scripts/README.md b/.devcontainer/library-scripts/README.md new file mode 100644 index 00000000..d06dfd1a --- /dev/null +++ b/.devcontainer/library-scripts/README.md @@ -0,0 +1,5 @@ +# Warning: Folder contents may be replaced + +The contents of this folder will be automatically replaced with a file of the same name in the [vscode-dev-containers](https://github.com/microsoft/vscode-dev-containers) repository's [script-library folder](https://github.com/microsoft/vscode-dev-containers/tree/master/script-library) whenever the repository is packaged. + +To retain your edits, move the file to a different location. You may also delete the files if they are not needed. \ No newline at end of file diff --git a/.devcontainer/library-scripts/common-debian.sh b/.devcontainer/library-scripts/common-debian.sh new file mode 100755 index 00000000..88a242c0 --- /dev/null +++ b/.devcontainer/library-scripts/common-debian.sh @@ -0,0 +1,326 @@ +#!/usr/bin/env bash +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- +# +# Docs: https://github.com/microsoft/vscode-dev-containers/blob/master/script-library/docs/common.md +# +# Syntax: ./common-debian.sh [install zsh flag] [username] [user UID] [user GID] [upgrade packages flag] [install Oh My *! flag] + +INSTALL_ZSH=${1:-"true"} +USERNAME=${2:-"automatic"} +USER_UID=${3:-"automatic"} +USER_GID=${4:-"automatic"} +UPGRADE_PACKAGES=${5:-"true"} +INSTALL_OH_MYS=${6:-"true"} + +set -e + +if [ "$(id -u)" -ne 0 ]; then + echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' + exit 1 +fi + +# If in automatic mode, determine if a user already exists, if not use vscode +if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then + USERNAME="" + POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)") + for CURRENT_USER in ${POSSIBLE_USERS[@]}; do + if id -u ${CURRENT_USER} > /dev/null 2>&1; then + USERNAME=${CURRENT_USER} + break + fi + done + if [ "${USERNAME}" = "" ]; then + USERNAME=vscode + fi +elif [ "${USERNAME}" = "none" ]; then + USERNAME=root + USER_UID=0 + USER_GID=0 +fi + +# Load markers to see which steps have already run +MARKER_FILE="/usr/local/etc/vscode-dev-containers/common" +if [ -f "${MARKER_FILE}" ]; then + echo "Marker file found:" + cat "${MARKER_FILE}" + source "${MARKER_FILE}" +fi + +# Ensure apt is in non-interactive to avoid prompts +export DEBIAN_FRONTEND=noninteractive + +# Function to call apt-get if needed +apt-get-update-if-needed() +{ + if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update + else + echo "Skipping apt-get update." + fi +} + +# Run install apt-utils to avoid debconf warning then verify presence of other common developer tools and dependencies +if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then + apt-get-update-if-needed + + PACKAGE_LIST="apt-utils \ + git \ + openssh-client \ + gnupg2 \ + iproute2 \ + procps \ + lsof \ + htop \ + net-tools \ + psmisc \ + curl \ + wget \ + rsync \ + ca-certificates \ + unzip \ + zip \ + nano \ + vim-tiny \ + less \ + jq \ + lsb-release \ + apt-transport-https \ + dialog \ + libc6 \ + libgcc1 \ + libgssapi-krb5-2 \ + libicu[0-9][0-9] \ + liblttng-ust0 \ + libstdc++6 \ + zlib1g \ + locales \ + sudo \ + ncdu \ + man-db" + + # Install libssl1.1 if available + if [[ ! -z $(apt-cache --names-only search ^libssl1.1$) ]]; then + PACKAGE_LIST="${PACKAGE_LIST} libssl1.1" + fi + + # Install appropriate version of libssl1.0.x if available + LIBSSL=$(dpkg-query -f '${db:Status-Abbrev}\t${binary:Package}\n' -W 'libssl1\.0\.?' 2>&1 || echo '') + if [ "$(echo "$LIBSSL" | grep -o 'libssl1\.0\.[0-9]:' | uniq | sort | wc -l)" -eq 0 ]; then + if [[ ! -z $(apt-cache --names-only search ^libssl1.0.2$) ]]; then + # Debian 9 + PACKAGE_LIST="${PACKAGE_LIST} libssl1.0.2" + elif [[ ! -z $(apt-cache --names-only search ^libssl1.0.0$) ]]; then + # Ubuntu 18.04, 16.04, earlier + PACKAGE_LIST="${PACKAGE_LIST} libssl1.0.0" + fi + fi + + echo "Packages to verify are installed: ${PACKAGE_LIST}" + apt-get -y install --no-install-recommends ${PACKAGE_LIST} 2> >( grep -v 'debconf: delaying package configuration, since apt-utils is not installed' >&2 ) + + PACKAGES_ALREADY_INSTALLED="true" +fi + +# Get to latest versions of all packages +if [ "${UPGRADE_PACKAGES}" = "true" ]; then + apt-get-update-if-needed + apt-get -y upgrade --no-install-recommends + apt-get autoremove -y +fi + +# Ensure at least the en_US.UTF-8 UTF-8 locale is available. +# Common need for both applications and things like the agnoster ZSH theme. +if [ "${LOCALE_ALREADY_SET}" != "true" ] && ! grep -o -E '^\s*en_US.UTF-8\s+UTF-8' /etc/locale.gen > /dev/null; then + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen + locale-gen + LOCALE_ALREADY_SET="true" +fi + +# Create or update a non-root user to match UID/GID. +if id -u ${USERNAME} > /dev/null 2>&1; then + # User exists, update if needed + if [ "${USER_GID}" != "automatic" ] && [ "$USER_GID" != "$(id -G $USERNAME)" ]; then + groupmod --gid $USER_GID $USERNAME + usermod --gid $USER_GID $USERNAME + fi + if [ "${USER_UID}" != "automatic" ] && [ "$USER_UID" != "$(id -u $USERNAME)" ]; then + usermod --uid $USER_UID $USERNAME + fi +else + # Create user + if [ "${USER_GID}" = "automatic" ]; then + groupadd $USERNAME + else + groupadd --gid $USER_GID $USERNAME + fi + if [ "${USER_UID}" = "automatic" ]; then + useradd -s /bin/bash --gid $USERNAME -m $USERNAME + else + useradd -s /bin/bash --uid $USER_UID --gid $USERNAME -m $USERNAME + fi +fi + +# Add add sudo support for non-root user +if [ "${USERNAME}" != "root" ] && [ "${EXISTING_NON_ROOT_USER}" != "${USERNAME}" ]; then + echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME + chmod 0440 /etc/sudoers.d/$USERNAME + EXISTING_NON_ROOT_USER="${USERNAME}" +fi + +# ** Shell customization section ** +if [ "${USERNAME}" = "root" ]; then + USER_RC_PATH="/root" +else + USER_RC_PATH="/home/${USERNAME}" +fi + +# .bashrc/.zshrc snippet +RC_SNIPPET="$(cat << EOF +export USER=\$(whoami) + +export PATH=\$PATH:\$HOME/.local/bin +EOF +)" + +# code shim, it fallbacks to code-insiders if code is not available +cat << 'EOF' > /usr/local/bin/code +#!/bin/sh + +get_in_path_except_current() { + which -a "$1" | grep -v "$0" | head -1 +} + +code="$(get_in_path_except_current code)" + +if [ -n "$code" ]; then + exec "$code" "$@" +elif [ "$(command -v code-insiders)" ]; then + exec code-insiders "$@" +else + echo "code or code-insiders is not installed" >&2 + exit 127 +fi +EOF +chmod +x /usr/local/bin/code + +# Codespaces themes - partly inspired by https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/robbyrussell.zsh-theme +CODESPACES_BASH="$(cat \ +<&1 + echo -e "$(cat "${TEMPLATE}")\nDISABLE_AUTO_UPDATE=true\nDISABLE_UPDATE_PROMPT=true" > ${USER_RC_FILE} + if [ "${OH_MY}" = "bash" ]; then + sed -i -e 's/OSH_THEME=.*/OSH_THEME="codespaces"/g' ${USER_RC_FILE} + mkdir -p ${OH_MY_INSTALL_DIR}/custom/themes/codespaces + echo "${CODESPACES_BASH}" > ${OH_MY_INSTALL_DIR}/custom/themes/codespaces/codespaces.theme.sh + else + sed -i -e 's/ZSH_THEME=.*/ZSH_THEME="codespaces"/g' ${USER_RC_FILE} + mkdir -p ${OH_MY_INSTALL_DIR}/custom/themes + echo "${CODESPACES_ZSH}" > ${OH_MY_INSTALL_DIR}/custom/themes/codespaces.zsh-theme + fi + # Shrink git while still enabling updates + cd ${OH_MY_INSTALL_DIR} + git repack -a -d -f --depth=1 --window=1 + + if [ "${USERNAME}" != "root" ]; then + cp -rf ${USER_RC_FILE} ${OH_MY_INSTALL_DIR} /root + chown -R ${USERNAME}:${USERNAME} ${USER_RC_PATH} + fi +} + +if [ "${RC_SNIPPET_ALREADY_ADDED}" != "true" ]; then + echo "${RC_SNIPPET}" >> /etc/bash.bashrc + RC_SNIPPET_ALREADY_ADDED="true" +fi +install-oh-my bash bashrc.osh-template https://github.com/ohmybash/oh-my-bash + +# Optionally install and configure zsh and Oh My Zsh! +if [ "${INSTALL_ZSH}" = "true" ]; then + if ! type zsh > /dev/null 2>&1; then + apt-get-update-if-needed + apt-get install -y zsh + fi + if [ "${ZSH_ALREADY_INSTALLED}" != "true" ]; then + echo "${RC_SNIPPET}" >> /etc/zsh/zshrc + ZSH_ALREADY_INSTALLED="true" + fi + install-oh-my zsh zshrc.zsh-template https://github.com/ohmyzsh/ohmyzsh +fi + +# Write marker file +mkdir -p "$(dirname "${MARKER_FILE}")" +echo -e "\ + PACKAGES_ALREADY_INSTALLED=${PACKAGES_ALREADY_INSTALLED}\n\ + LOCALE_ALREADY_SET=${LOCALE_ALREADY_SET}\n\ + EXISTING_NON_ROOT_USER=${EXISTING_NON_ROOT_USER}\n\ + RC_SNIPPET_ALREADY_ADDED=${RC_SNIPPET_ALREADY_ADDED}\n\ + ZSH_ALREADY_INSTALLED=${ZSH_ALREADY_INSTALLED}" > "${MARKER_FILE}" + +echo "Done!" From b2525f5054f51791339ee57bbea5188cf486d632 Mon Sep 17 00:00:00 2001 From: Igor Borges Date: Sat, 13 Mar 2021 23:14:16 +0000 Subject: [PATCH 2/3] 6.20.1-beta.2 --- CHANGELOG.md | 3 +++ pubspec.yaml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04fa3520..c75ac818 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # CHANGELOG +## 6.20.1-beta.2 +- Add codespaces folder + ## 6.20.1-beta.1 - Allow for auto generated response and inputs to extend JsonSerializable diff --git a/pubspec.yaml b/pubspec.yaml index 796e7f31..a0eed0ed 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: artemis -version: 6.20.1-beta.1 +version: 6.20.1-beta.2 description: Build dart types from GraphQL schemas and queries (using Introspection Query). homepage: https://github.com/comigor/artemis From 3fcb8fc9c5b3eb513fe51d6e4025912be3cc64f3 Mon Sep 17 00:00:00 2001 From: Igor Borges Date: Sun, 14 Mar 2021 00:24:17 +0000 Subject: [PATCH 3/3] Fix warning --- example/github/pubspec.lock | 24 +++++++++---------- example/graphbrainz/pubspec.lock | 24 +++++++++---------- example/hasura/pubspec.lock | 24 +++++++++---------- example/pokemon/pubspec.lock | 24 +++++++++---------- lib/builder.dart | 2 +- lib/generator.dart | 4 ++-- lib/generator/data_printer.dart | 2 +- lib/generator/print_helpers.dart | 37 +++++++++++++++--------------- lib/visitor/generator_visitor.dart | 2 +- 9 files changed, 71 insertions(+), 72 deletions(-) diff --git a/example/github/pubspec.lock b/example/github/pubspec.lock index 3ab5fb1f..bfaa9c18 100644 --- a/example/github/pubspec.lock +++ b/example/github/pubspec.lock @@ -28,7 +28,7 @@ packages: path: "../.." relative: true source: path - version: "6.17.1" + version: "6.20.1-beta.2" async: dependency: transitive description: @@ -49,14 +49,14 @@ packages: name: build url: "https://pub.dartlang.org" source: hosted - version: "1.5.0" + version: "1.6.2" build_config: dependency: transitive description: name: build_config url: "https://pub.dartlang.org" source: hosted - version: "0.4.2" + version: "0.4.5" build_daemon: dependency: transitive description: @@ -70,21 +70,21 @@ packages: name: build_resolvers url: "https://pub.dartlang.org" source: hosted - version: "1.4.3" + version: "1.5.3" build_runner: dependency: "direct dev" description: name: build_runner url: "https://pub.dartlang.org" source: hosted - version: "1.10.4" + version: "1.11.1" build_runner_core: dependency: transitive description: name: build_runner_core url: "https://pub.dartlang.org" source: hosted - version: "6.0.3" + version: "6.1.7" built_collection: dependency: transitive description: @@ -161,7 +161,7 @@ packages: name: dart_style url: "https://pub.dartlang.org" source: hosted - version: "1.3.9" + version: "1.3.10" equatable: dependency: transitive description: @@ -189,7 +189,7 @@ packages: name: gql url: "https://pub.dartlang.org" source: hosted - version: "0.12.3" + version: "0.12.4" gql_code_gen: dependency: transitive description: @@ -273,7 +273,7 @@ packages: name: json_annotation url: "https://pub.dartlang.org" source: hosted - version: "3.1.0" + version: "3.1.1" json_serializable: dependency: "direct dev" description: @@ -301,7 +301,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.2.3" + version: "1.3.0" mime: dependency: transitive description: @@ -427,7 +427,7 @@ packages: name: source_gen url: "https://pub.dartlang.org" source: hosted - version: "0.9.8" + version: "0.9.10+2" source_map_stack_trace: dependency: transitive description: @@ -555,4 +555,4 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=2.10.0 <3.0.0" + dart: ">=2.12.0-0 <3.0.0" diff --git a/example/graphbrainz/pubspec.lock b/example/graphbrainz/pubspec.lock index ed400a58..46c85a87 100644 --- a/example/graphbrainz/pubspec.lock +++ b/example/graphbrainz/pubspec.lock @@ -28,7 +28,7 @@ packages: path: "../.." relative: true source: path - version: "6.17.1" + version: "6.20.1-beta.2" async: dependency: transitive description: @@ -49,14 +49,14 @@ packages: name: build url: "https://pub.dartlang.org" source: hosted - version: "1.5.0" + version: "1.6.2" build_config: dependency: transitive description: name: build_config url: "https://pub.dartlang.org" source: hosted - version: "0.4.2" + version: "0.4.5" build_daemon: dependency: transitive description: @@ -70,21 +70,21 @@ packages: name: build_resolvers url: "https://pub.dartlang.org" source: hosted - version: "1.4.3" + version: "1.5.3" build_runner: dependency: "direct dev" description: name: build_runner url: "https://pub.dartlang.org" source: hosted - version: "1.10.4" + version: "1.11.1" build_runner_core: dependency: transitive description: name: build_runner_core url: "https://pub.dartlang.org" source: hosted - version: "6.0.3" + version: "6.1.7" built_collection: dependency: transitive description: @@ -161,7 +161,7 @@ packages: name: dart_style url: "https://pub.dartlang.org" source: hosted - version: "1.3.9" + version: "1.3.10" equatable: dependency: transitive description: @@ -189,7 +189,7 @@ packages: name: gql url: "https://pub.dartlang.org" source: hosted - version: "0.12.3" + version: "0.12.4" gql_code_gen: dependency: transitive description: @@ -280,7 +280,7 @@ packages: name: json_annotation url: "https://pub.dartlang.org" source: hosted - version: "3.1.0" + version: "3.1.1" json_serializable: dependency: "direct dev" description: @@ -308,7 +308,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.2.3" + version: "1.3.0" mime: dependency: transitive description: @@ -434,7 +434,7 @@ packages: name: source_gen url: "https://pub.dartlang.org" source: hosted - version: "0.9.8" + version: "0.9.10+2" source_map_stack_trace: dependency: transitive description: @@ -562,4 +562,4 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=2.10.0 <3.0.0" + dart: ">=2.12.0-0 <3.0.0" diff --git a/example/hasura/pubspec.lock b/example/hasura/pubspec.lock index 5fe381db..31dd3326 100644 --- a/example/hasura/pubspec.lock +++ b/example/hasura/pubspec.lock @@ -28,7 +28,7 @@ packages: path: "../.." relative: true source: path - version: "6.17.1" + version: "6.20.1-beta.2" async: dependency: transitive description: @@ -49,14 +49,14 @@ packages: name: build url: "https://pub.dartlang.org" source: hosted - version: "1.5.0" + version: "1.6.2" build_config: dependency: transitive description: name: build_config url: "https://pub.dartlang.org" source: hosted - version: "0.4.2" + version: "0.4.5" build_daemon: dependency: transitive description: @@ -70,21 +70,21 @@ packages: name: build_resolvers url: "https://pub.dartlang.org" source: hosted - version: "1.4.3" + version: "1.5.3" build_runner: dependency: "direct dev" description: name: build_runner url: "https://pub.dartlang.org" source: hosted - version: "1.10.4" + version: "1.11.1" build_runner_core: dependency: transitive description: name: build_runner_core url: "https://pub.dartlang.org" source: hosted - version: "6.0.3" + version: "6.1.7" built_collection: dependency: transitive description: @@ -161,7 +161,7 @@ packages: name: dart_style url: "https://pub.dartlang.org" source: hosted - version: "1.3.9" + version: "1.3.10" equatable: dependency: transitive description: @@ -189,7 +189,7 @@ packages: name: gql url: "https://pub.dartlang.org" source: hosted - version: "0.12.4-alpha+1588872921528" + version: "0.12.4" gql_code_gen: dependency: transitive description: @@ -280,7 +280,7 @@ packages: name: json_annotation url: "https://pub.dartlang.org" source: hosted - version: "3.1.0" + version: "3.1.1" json_serializable: dependency: "direct dev" description: @@ -308,7 +308,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.2.3" + version: "1.3.0" mime: dependency: transitive description: @@ -441,7 +441,7 @@ packages: name: source_gen url: "https://pub.dartlang.org" source: hosted - version: "0.9.8" + version: "0.9.10+2" source_map_stack_trace: dependency: transitive description: @@ -583,4 +583,4 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=2.10.0 <3.0.0" + dart: ">=2.12.0-0 <3.0.0" diff --git a/example/pokemon/pubspec.lock b/example/pokemon/pubspec.lock index 3ab5fb1f..bfaa9c18 100644 --- a/example/pokemon/pubspec.lock +++ b/example/pokemon/pubspec.lock @@ -28,7 +28,7 @@ packages: path: "../.." relative: true source: path - version: "6.17.1" + version: "6.20.1-beta.2" async: dependency: transitive description: @@ -49,14 +49,14 @@ packages: name: build url: "https://pub.dartlang.org" source: hosted - version: "1.5.0" + version: "1.6.2" build_config: dependency: transitive description: name: build_config url: "https://pub.dartlang.org" source: hosted - version: "0.4.2" + version: "0.4.5" build_daemon: dependency: transitive description: @@ -70,21 +70,21 @@ packages: name: build_resolvers url: "https://pub.dartlang.org" source: hosted - version: "1.4.3" + version: "1.5.3" build_runner: dependency: "direct dev" description: name: build_runner url: "https://pub.dartlang.org" source: hosted - version: "1.10.4" + version: "1.11.1" build_runner_core: dependency: transitive description: name: build_runner_core url: "https://pub.dartlang.org" source: hosted - version: "6.0.3" + version: "6.1.7" built_collection: dependency: transitive description: @@ -161,7 +161,7 @@ packages: name: dart_style url: "https://pub.dartlang.org" source: hosted - version: "1.3.9" + version: "1.3.10" equatable: dependency: transitive description: @@ -189,7 +189,7 @@ packages: name: gql url: "https://pub.dartlang.org" source: hosted - version: "0.12.3" + version: "0.12.4" gql_code_gen: dependency: transitive description: @@ -273,7 +273,7 @@ packages: name: json_annotation url: "https://pub.dartlang.org" source: hosted - version: "3.1.0" + version: "3.1.1" json_serializable: dependency: "direct dev" description: @@ -301,7 +301,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.2.3" + version: "1.3.0" mime: dependency: transitive description: @@ -427,7 +427,7 @@ packages: name: source_gen url: "https://pub.dartlang.org" source: hosted - version: "0.9.8" + version: "0.9.10+2" source_map_stack_trace: dependency: transitive description: @@ -555,4 +555,4 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=2.10.0 <3.0.0" + dart: ">=2.12.0-0 <3.0.0" diff --git a/lib/builder.dart b/lib/builder.dart index d9620e1e..3886b9ee 100644 --- a/lib/builder.dart +++ b/lib/builder.dart @@ -156,7 +156,7 @@ Make sure that `queries_glob` your build.yaml file include GraphQL queries files throw Exception( '''Schema `${schemaMap.schema}` was not found or doesn't have a proper format! Make sure the file exists and you've typed it correctly on build.yaml. -${e} +$e '''); } diff --git a/lib/generator.dart b/lib/generator.dart index c3f7866c..ba261155 100644 --- a/lib/generator.dart +++ b/lib/generator.dart @@ -317,7 +317,7 @@ Make sure your query is correct and your schema is updated.'''); schema: context.schema); logFn(context, aliasedContext.align + 1, - '${aliasedContext.path}[${aliasedContext.currentType.name.value}][${aliasedContext.currentClassName} ${aliasedContext.currentFieldName}] ${fieldAlias == null ? '' : '(${fieldAlias}) '}-> ${dartTypeName.namePrintable}'); + '${aliasedContext.path}[${aliasedContext.currentType.name.value}][${aliasedContext.currentClassName} ${aliasedContext.currentFieldName}] ${fieldAlias == null ? '' : '($fieldAlias) '}-> ${dartTypeName.namePrintable}'); if ((nextType is ObjectTypeDefinitionNode || nextType is UnionTypeDefinitionNode || @@ -387,7 +387,7 @@ Make sure your query is correct and your schema is updated.'''); final jsonKey = jsonKeyAnnotation.entries .map((e) => '${e.key}: ${e.value}') .join(', '); - annotations.add('JsonKey(${jsonKey})'); + annotations.add('JsonKey($jsonKey)'); } annotations.addAll(proceedDeprecated(fieldDirectives)); diff --git a/lib/generator/data_printer.dart b/lib/generator/data_printer.dart index 647ca04f..e326f9e9 100644 --- a/lib/generator/data_printer.dart +++ b/lib/generator/data_printer.dart @@ -35,6 +35,6 @@ mixin DataPrinter on Equatable { hasValue(e.value) ? '${e.key}:${_formatPrint(e.value)}' : null) .where((o) => o != null) .join(', '); - return '${runtimeType}($params)'; + return '$runtimeType($params)'; } } diff --git a/lib/generator/print_helpers.dart b/lib/generator/print_helpers.dart index 05b288c2..f3e71e8b 100644 --- a/lib/generator/print_helpers.dart +++ b/lib/generator/print_helpers.dart @@ -138,24 +138,23 @@ Spec classDefinitionToSpec( ..implements.addAll(definition.implementations.map((i) => refer(i))) ..constructors.add(Constructor((b) { if (definition.isInput) { - b - ..optionalParameters.addAll(definition.properties - .where((property) => - !property.isOverride && !property.isResolveType) - .map( - (property) => Parameter( - (p) { - p - ..name = property.name.namePrintable - ..named = true - ..toThis = true; - - if (property.isNonNull) { - p.annotations.add(refer('required')); - } - }, - ), - )); + b.optionalParameters.addAll(definition.properties + .where( + (property) => !property.isOverride && !property.isResolveType) + .map( + (property) => Parameter( + (p) { + p + ..name = property.name.namePrintable + ..named = true + ..toThis = true; + + if (property.isNonNull) { + p.annotations.add(refer('required')); + } + }, + ), + )); } })) ..constructors.add(fromJson) @@ -184,7 +183,7 @@ Spec classDefinitionToSpec( Spec fragmentClassDefinitionToSpec(FragmentClassDefinition definition) { final fields = (definition.properties ?? []).map((p) { final lines = []; - lines.addAll(p.annotations.map((e) => '@${e}')); + lines.addAll(p.annotations.map((e) => '@$e')); lines.add('${p.type.namePrintable} ${p.name.namePrintable};'); return lines.join('\n'); }); diff --git a/lib/visitor/generator_visitor.dart b/lib/visitor/generator_visitor.dart index 783ff1ac..70a73c4d 100644 --- a/lib/visitor/generator_visitor.dart +++ b/lib/visitor/generator_visitor.dart @@ -208,7 +208,7 @@ class GeneratorVisitor extends RecursiveVisitor { final jsonKey = jsonKeyAnnotation.entries .map((e) => '${e.key}: ${e.value}') .join(', '); - annotations.add('JsonKey(${jsonKey})'); + annotations.add('JsonKey($jsonKey)'); } context.inputsClasses.add(QueryInput(