Skip to content

Commit

Permalink
Move from yarn to npm (#52)
Browse files Browse the repository at this point in the history
* Move from yarn to npm

* fix(js): allow pinning importmaps with gem (#51)

Since import maps JSPM and the javascript ecosystem are a mess in their current state, allow import maps to match the assets served by the gem rather than download them from JSPM.

---------

Co-authored-by: Mikael Henriksson <mikael@mhenrixon.com>
  • Loading branch information
hopsoft and mhenrixon authored Feb 12, 2024
1 parent 1e68377 commit 8dad3dc
Show file tree
Hide file tree
Showing 17 changed files with 4,966 additions and 2,697 deletions.
13 changes: 13 additions & 0 deletions .containers.example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
organization:
name: turbo_boost

app:
name: turbo_boost-streams
directory: /path/to/turbo_boost-streams

docker:
directory: /path/to/turbo_boost-streams
compose_files:
- /path/to/turbo_boost-streams/docker-compose.yml
default_service: web
10 changes: 4 additions & 6 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Enable Corepack
run: corepack enable

- name: Setup Node
uses: actions/setup-node@v4
with:
version: '20.x'
cache: 'npm'

- name: Yarn Install
run: 'yarn install --frozen-lockfile'
- name: NPM Install
run: 'npm install --legacy-peer-deps'

- name: Run Prettier
run: 'yarn run prettier --check --fail-on-errors .'
run: 'npx prettier --check --fail-on-errors .'
1 change: 0 additions & 1 deletion .github/workflows/standardrb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
Expand Down
36 changes: 17 additions & 19 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,26 @@ jobs:
ruby-version: ['3.0', '3.1', '3.2', '3.3']

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true

- name: Enable Corepack
run: corepack enable
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'yarn'
- name: NPM Install
run: 'npm install --legacy-peer-deps'

- name: Yarn install
run: yarn install --frozen-lockfile
- name: Install Playwright Browsers
run: 'npx playwright install chromium --with-deps'

- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Tests
run: 'bundle exec rake test'

- name: Run ruby tests
run: bundle exec rake test
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.md
*.yml
builds
test/dummy/vendor
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ sqlite3 \
tzdata

RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
RUN apt-get -y --no-install-recommends install nodejs && \
corepack enable && \
yarn set version stable
RUN apt-get -y --no-install-recommends install nodejs

RUN apt-get clean
RUN gem update --system && gem install bundler
Expand Down
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Be sure to install the same version for each library.

```sh
bundle add "turbo_boost-streams --version VERSION"
yarn add "@turbo-boost/streams@VERSION --exact"
npm install "@turbo-boost/streams@VERSION"
```

## Setup
Expand Down Expand Up @@ -428,19 +428,15 @@ fly deploy
> [!TIP]
> Run these commands on the host machine _(i.e. not inside the dev container)_
> [!TIP]
> Ensure you're using the latest stable version of `yarn`
> `corepack enable && yarn set version stable`

1. Run `yarn upgrade-interactive` and `bundle update` to pick up the latest dependencies
1. Run `npm update` and `bundle update` to pick up the latest dependencies
1. Bump version number at `lib/turbo_boost-streams/version.rb`. Pre-release versions use `.preN`
1. Bump version number at `package.json` _(make sure it matches)_. Pre-release versions use `-preN`
1. Run `bin/standardize`
1. Run `rake build`
1. Run `yarn build`
1. Run `npm run build`
1. Commit and push any changes to GitHub
1. Run `rake release`
1. Run `yarn npm publish --access public`
1. Run `npm publish ???? --access public`
1. Create a new release on GitHub ([here](https://github.com/hopsoft/turbo_boost-streams/releases)) and generate the changelog for the stable release for it
## About TurboBoost
Expand Down
14 changes: 3 additions & 11 deletions bin/docker/run/local
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,9 @@ fi
# ============================================================================================================
# Dependencies
# ============================================================================================================
rm -rf /app/node_modules
ln -s /mnt/external/node_modules /app/node_modules
yarn set version stable
yarn
bundle


# ============================================================================================================
# Playwright Dependencies - SEE: https://playwright.dev
# ============================================================================================================
yarn playwright install --with-deps
npm install
npx playwright install chromium --with-deps
bundle install


# ============================================================================================================
Expand Down
4 changes: 2 additions & 2 deletions bin/docker/run/remote
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ fi
# ============================================================================================================
rm -rf /opt/turbo_boost-streams/node_modules
ln -s /mnt/external/node_modules /opt/turbo_boost-streams/node_modules
yarn
bundle
npm install
bundle install


# ============================================================================================================
Expand Down
2 changes: 1 addition & 1 deletion bin/standardize
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
shopt -s globstar
bundle exec magic_frozen_string_literal
bundle exec standardrb --fix
yarn run prettier --write .
npx prettier --write .
cd test/dummy && bin/rails tailwindcss:clobber tailwindcss:build && cd -
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ networks:

volumes:
external:
node_modules:

x-default-env: &default_env
GEM_HOME: /mnt/external/bundle
Expand All @@ -25,6 +26,7 @@ x-default-app: &default_app
volumes:
- .:/app
- external:/mnt/external
- node_modules:/app/node_modules

services:
## ==========================================================================================================
Expand Down Expand Up @@ -56,7 +58,7 @@ services:
esbuild:
<<: *default_app
container_name: turbo_boost-streams-esbuild
command: /bin/bash -c "yarn build:watch"
command: /bin/bash -c "npm run build -- --watch"
depends_on:
web:
condition: service_healthy
Expand Down
11 changes: 11 additions & 0 deletions lib/turbo_boost/streams/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,20 @@
require_relative "patches"

class TurboBoost::Engine < ::Rails::Engine
config.turbo_boost_streams = ActiveSupport::OrderedOptions.new
config.turbo_boost_streams.precompile_assets = true

config.after_initialize do
::Turbo::Streams::TagBuilder.send :include, TurboBoost::Streams::Patches::TagBuilder
::Turbo::Streams::Broadcasts.send :include, TurboBoost::Streams::Patches::Broadcasts
::Turbo::Broadcastable.send :include, TurboBoost::Streams::Patches::Broadcastable
end

initializer "turbo_boost_streams.asset" do
config.after_initialize do |app|
if app.config.respond_to?(:assets) && app.config.turbo_boost_streams.precompile_assets
app.config.assets.precompile += %w[@turbo-boost/streams.js]
end
end
end
end
Loading

0 comments on commit 8dad3dc

Please sign in to comment.