diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 5a36f002..5e88b763 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -2,9 +2,22 @@ ARG VARIANT="3" FROM mcr.microsoft.com/vscode/devcontainers/python:${VARIANT} +ARG NODE_VERSION="20" ARG POETRY_VERSION="1.8.2" ARG POETRY_SRC="https://install.python-poetry.org" +# https://github.com/microsoft/vscode-dev-containers/blob/main/containers/go/.devcontainer/base.Dockerfile +ENV USERNAME=vscode +ENV LIBRARY_SCRIPTS_SRC="https://raw.githubusercontent.com/microsoft/vscode-dev-containers/main/containers/go/.devcontainer/library-scripts/node-debian.sh" +ENV NVM_DIR=/usr/local/share/nvm +ENV NVM_SYMLINK_CURRENT=true \ + PATH=${NVM_DIR}/current/bin:${PATH} +RUN mkdir /tmp/library-scripts \ + && curl -fsSL -o /tmp/library-scripts/node-debian.sh "${LIBRARY_SCRIPTS_SRC}" +RUN bash /tmp/library-scripts/node-debian.sh "${NVM_DIR}" "${NODE_VERSION}" "${USERNAME}" \ + && apt-get clean -y && rm -rf /var/lib/apt/lists/* \ + && rm -rf /tmp/library-scripts + USER vscode WORKDIR /home/vscode diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 1e4e9e73..c502d970 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,6 +4,7 @@ "build": { "dockerfile": "Dockerfile", "args": { + "NODE_VERSION": "20", "POETRY_VERSION": "1.8.2", "VARIANT": "3.12" } @@ -17,6 +18,6 @@ "ms-python.python", "EditorConfig.EditorConfig" ], - "postCreateCommand": "poetry install", + "postCreateCommand": "poetry install && npm install", "remoteUser": "vscode" } diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..93201f0b --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +seami/** linguist-generated diff --git a/.github/actions/setup-node/action.yml b/.github/actions/setup-node/action.yml new file mode 100644 index 00000000..7e60b8aa --- /dev/null +++ b/.github/actions/setup-node/action.yml @@ -0,0 +1,38 @@ +--- +name: Setup Node.js +description: Setup Node.js and install dependencies. + +inputs: + node_version: + description: The Node.js version. + required: false + default: '20' + registry_url: + description: The Node.js package registry URL. + required: false + default: https://registry.npmjs.org + install_dependencies: + description: Install dependencies. + required: false + default: 'true' + +runs: + using: composite + steps: + - name: Setup Node.js + uses: actions/setup-node@v4 + if: inputs.install_dependencies == 'true' + with: + cache: npm + node-version: ${{ inputs.node_version }} + registry-url: ${{ inputs.registry_url }} + - name: Setup Node.js without cache + uses: actions/setup-node@v4 + if: inputs.install_dependencies == 'false' + with: + node-version: ${{ inputs.node_version }} + registry-url: ${{ inputs.registry_url }} + - name: Install dependencies + if: inputs.install_dependencies == 'true' + shell: bash + run: npm ci diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 5fe63514..841c8728 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -29,13 +29,17 @@ jobs: passphrase: ${{ secrets.GPG_PASSPHRASE }} - name: Setup uses: ./.github/actions/setup + - name: Setup Node.js + uses: ./.github/actions/setup-node - name: Format run: make format + - name: Format with Prettier + run: npm run format - name: Commit uses: stefanzweifel/git-auto-commit-action@v5 if: always() with: - commit_message: Run format + commit_message: 'ci: Format code' commit_user_name: ${{ secrets.GIT_USER_NAME }} commit_user_email: ${{ secrets.GIT_USER_EMAIL }} commit_author: ${{ secrets.GIT_USER_NAME }} <${{ secrets.GIT_USER_EMAIL }}> diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 3570eed4..957512f6 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -31,12 +31,20 @@ jobs: uses: ./.github/actions/setup with: install_dependencies: 'false' + - name: Setup Node.js + uses: ./.github/actions/setup-node + with: + install_dependencies: 'false' - name: Normalize poetry.lock run: poetry lock --no-update + - name: Normalize package-lock.json + run: npm install + - name: Generate code + run: npm run generate - name: Commit uses: stefanzweifel/git-auto-commit-action@v5 with: - commit_message: Generate code + commit_message: 'ci: Generate code' commit_user_name: ${{ secrets.GIT_USER_NAME }} commit_user_email: ${{ secrets.GIT_USER_EMAIL }} commit_author: ${{ secrets.GIT_USER_NAME }} <${{ secrets.GIT_USER_EMAIL }}> diff --git a/.gitignore b/.gitignore index d946dc4f..53f08b79 100644 --- a/.gitignore +++ b/.gitignore @@ -171,3 +171,153 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ + +# Build directories +package + +# Environment versions file +.versions + +# Tern +.tern-project +.tern-port + +# npm config +.npmrc + +# Temporary development files +tmp + +# Yarn lockfile (only package-lock.json supported) +yarn.lock + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp +.cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..209e3ef4 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +20 diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 00000000..14c717d7 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,6 @@ +{ + "semi": false, + "singleQuote": true, + "jsxSingleQuote": true, + "endOfLine": "lf" +} diff --git a/README.rst b/README.rst index 73348093..0e95b1f3 100644 --- a/README.rst +++ b/README.rst @@ -67,14 +67,17 @@ Clone the project with Requirements ~~~~~~~~~~~~ -You will need `Python 3`_ and Poetry_. +You will need `Python 3`_ and Poetry_ and Node.js_ with npm_. Install the development dependencies with :: $ poetry install + $ npm install +.. _Node.js: https://nodejs.org/ +.. _npm: https://www.npmjs.com/ .. _Poetry: https://poetry.eustace.io/ .. _Python 3: https://www.python.org/ diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..6adae308 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,28 @@ +{ + "name": "@seamapi/python", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@seamapi/python", + "devDependencies": { + "prettier": "^3.2.5" + } + }, + "node_modules/prettier": { + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", + "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 00000000..2c6f41f4 --- /dev/null +++ b/package.json @@ -0,0 +1,12 @@ +{ + "name": "@seamapi/python", + "private": true, + "type": "module", + "scripts": { + "generate": "true", + "format": "prettier --write --ignore-path .gitignore ." + }, + "devDependencies": { + "prettier": "^3.2.5" + } +} diff --git a/pyproject.toml b/pyproject.toml index c1a4c757..9fab14fc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,3 +25,8 @@ rstcheck = "^6.1.2" [build-system] requires = ["poetry>=1.8"] build-backend = "poetry.masonry.api" + +[tool.pytest.ini_options] +norecursedirs = [ + "node_modules" +]