From 186279d18745c910b3f9f070f4640be5a5b19d3d Mon Sep 17 00:00:00 2001 From: Evan Sosenko Date: Thu, 18 Apr 2024 22:04:16 -0700 Subject: [PATCH] Add Node.js support for generation --- .github/actions/setup-node/action.yml | 38 +++++++ .github/workflows/format.yml | 4 + .github/workflows/generate.yml | 6 ++ .gitignore | 150 ++++++++++++++++++++++++++ .nvmrc | 1 + .prettierrc.json | 6 ++ README.md | 5 +- package-lock.json | 28 +++++ package.json | 11 ++ 9 files changed, 248 insertions(+), 1 deletion(-) create mode 100644 .github/actions/setup-node/action.yml create mode 100644 .nvmrc create mode 100644 .prettierrc.json create mode 100644 package-lock.json create mode 100644 package.json diff --git a/.github/actions/setup-node/action.yml b/.github/actions/setup-node/action.yml new file mode 100644 index 0000000..7e60b8a --- /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 d0bd0b7..779c7f8 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -29,8 +29,12 @@ jobs: passphrase: ${{ secrets.GPG_PASSPHRASE }} - name: Setup uses: ./.github/actions/setup + - name: Setup Node.js + uses: ./.github/actions/setup-node - name: Format run: bundle exec rake format + - name: Format with Prettier + run: npm run format - name: Commit uses: stefanzweifel/git-auto-commit-action@v5 if: always() diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index b38c9d0..02a0204 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -31,8 +31,14 @@ jobs: uses: ./.github/actions/setup with: install_dependencies: 'false' + - name: Setup Node.js + uses: ./.github/actions/setup-node + with: + install_dependencies: 'false' - name: Normalize Gemfile.lock run: bundle install + - name: Normalize package-lock.json + run: npm install - name: Commit uses: stefanzweifel/git-auto-commit-action@v5 with: diff --git a/.gitignore b/.gitignore index e13c32d..a76d92b 100644 --- a/.gitignore +++ b/.gitignore @@ -64,3 +64,153 @@ build-iPhoneSimulator/ # Used by RuboCop. Remote config files pulled in from inherit_from directive. # .rubocop-https?--* + +# 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 0000000..209e3ef --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +20 diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..14c717d --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,6 @@ +{ + "semi": false, + "singleQuote": true, + "jsxSingleQuote": true, + "endOfLine": "lf" +} diff --git a/README.md b/README.md index 2c7ae6d..c39a61d 100644 --- a/README.md +++ b/README.md @@ -64,13 +64,14 @@ $ git clone git@github.com:seamapi/ruby-next.git ### Requirements -You will need [Ruby] with [Bundler]. +You will need [Ruby] with [Bundler] and [Node.js] with [npm]. Be sure that all commands run under the correct Ruby version, e.g., if using [rbenv], install the correct version with ``` $ rbenv install +$ npm install ``` Install the development dependencies with @@ -80,6 +81,8 @@ $ bundle install ``` [bundler]: https://bundler.io/ +[Node.js]: https://nodejs.org/ +[npm]: https://www.npmjs.com/ [ruby]: https://www.ruby-lang.org/ [rbenv]: https://github.com/rbenv/rbenv diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..4307a0f --- /dev/null +++ b/package-lock.json @@ -0,0 +1,28 @@ +{ + "name": "@seamapi/ruby", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@seamapi/ruby", + "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 0000000..8fabdda --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "name": "@seamapi/ruby", + "private": true, + "type": "module", + "scripts": { + "format": "prettier --write --ignore-path .gitignore ." + }, + "devDependencies": { + "prettier": "^3.2.5" + } +}