Skip to content

Commit

Permalink
Merge pull request #34905 from javan/move-npm-packages-to-rails-scope
Browse files Browse the repository at this point in the history
Move all npm packages to @rails scope
  • Loading branch information
javan committed Jan 10, 2019
2 parents 9edc84c + 86b489e commit 2163762
Show file tree
Hide file tree
Showing 21 changed files with 48 additions and 53 deletions.
15 changes: 8 additions & 7 deletions RELEASING_RAILS.md
Expand Up @@ -109,13 +109,14 @@ browser.
This will stop you from looking silly when you push an RC to rubygems.org and
then realize it is broken.

### Release to RubyGems and NPM.

IMPORTANT: The Action Cable client and Action View's UJS adapter are released
as NPM packages, so you must have Node.js installed, have an NPM account
(npmjs.com), and be a package owner for `actioncable` and `rails-ujs` (you can
check this via `npm owner ls actioncable` and `npm owner ls rails-ujs`) in
order to do a full release. Do not release until you're set up with NPM!
### Release to RubyGems and npm.

IMPORTANT: Several gems have JavaScript components that are released as npm
packages, so you must have Node.js installed, have an npm account (npmjs.com),
and be a package owner for `@rails/actioncable`, `@rails/actiontext`,
`@rails/activestorage`, and `@rails/ujs`. You can check this by making sure your
npm user (`npm whoami`) is listed as an owner (`npm owner ls <pkg>`) of each
package. Do not release until you're set up with npm!

The release task will sign the release tag. If you haven't got commit signing
set up, use https://git-scm.com/book/tr/v2/Git-Tools-Signing-Your-Work as a
Expand Down
6 changes: 3 additions & 3 deletions actioncable/README.md
Expand Up @@ -504,7 +504,7 @@ WebSocket functionality.
### Installation

```
npm install actioncable --save
npm install @rails/actioncable --save
```

### Usage
Expand All @@ -516,7 +516,7 @@ provided.
In JavaScript...

```javascript
ActionCable = require('actioncable')
ActionCable = require('@rails/actioncable')

var cable = ActionCable.createConsumer('wss://RAILS-API-PATH.com/cable')

Expand All @@ -528,7 +528,7 @@ cable.subscriptions.create('AppearanceChannel', {
and in CoffeeScript...

```coffeescript
ActionCable = require('actioncable')
ActionCable = require('@rails/actioncable')

cable = ActionCable.createConsumer('wss://RAILS-API-PATH.com/cable')

Expand Down
@@ -1,6 +1,6 @@
// Action Cable provides the framework to deal with WebSockets in Rails.
// You can generate new channels where WebSocket features live using the `rails generate channel` command.

import ActionCable from "actioncable"
import ActionCable from "@rails/actioncable"

export default ActionCable.createConsumer()
2 changes: 1 addition & 1 deletion actioncable/package.json
@@ -1,5 +1,5 @@
{
"name": "actioncable",
"name": "@rails/actioncable",
"version": "6.0.0-alpha",
"description": "WebSocket framework for Ruby on Rails.",
"main": "app/assets/javascripts/action_cable.js",
Expand Down
2 changes: 1 addition & 1 deletion actiontext/app/javascript/actiontext/attachment_upload.js
@@ -1,4 +1,4 @@
import { DirectUpload } from "activestorage"
import { DirectUpload } from "@rails/activestorage"

export class AttachmentUpload {
constructor(attachment, element) {
Expand Down
7 changes: 3 additions & 4 deletions actiontext/lib/templates/installer.rb
Expand Up @@ -8,15 +8,14 @@
copy_file "#{__dir__}/../../app/views/active_storage/blobs/_blob.html.erb",
"app/views/active_storage/blobs/_blob.html.erb"

# FIXME: Replace with release version on release
say "Installing JavaScript dependency"
run "yarn add https://github.com/rails/actiontext"
run "yarn add @rails/actiontext"

APPLICATION_PACK_PATH = "app/javascript/packs/application.js"

if File.exist?(APPLICATION_PACK_PATH) && File.read(APPLICATION_PACK_PATH) !~ /import "actiontext"/
if File.exist?(APPLICATION_PACK_PATH) && File.read(APPLICATION_PACK_PATH) !~ /import "@rails\/actiontext"/
say "Adding import to default JavaScript pack"
append_to_file APPLICATION_PACK_PATH, <<-EOS
import "actiontext"
import "@rails/actiontext"
EOS
end
6 changes: 3 additions & 3 deletions actiontext/package.json
@@ -1,5 +1,5 @@
{
"name": "actiontext",
"name": "@rails/actiontext",
"version": "6.0.0-alpha",
"description": "Edit and display rich text in Rails applications",
"main": "app/javascript/actiontext/index.js",
Expand All @@ -21,7 +21,7 @@
],
"license": "MIT",
"dependencies": {
"trix": ">=1.0.0",
"activestorage": "6.0.0-alpha"
"trix": "^1.0.0",
"@rails/activestorage": "^6.0.0-alpha"
}
}
2 changes: 1 addition & 1 deletion actiontext/test/dummy/app/javascript/packs/application.js
@@ -1 +1 @@
import "actiontext"
import "@rails/actiontext"
11 changes: 0 additions & 11 deletions actiontext/yarn.lock

This file was deleted.

10 changes: 5 additions & 5 deletions actionview/app/assets/javascripts/README.md
Expand Up @@ -17,11 +17,11 @@ Note that the `data` attributes this library adds are a feature of HTML5. If you

### NPM

npm install rails-ujs --save
npm install @rails/ujs --save

### Yarn
yarn add rails-ujs

yarn add @rails/ujs

Ensure that `.yarnclean` does not include `assets` if you use [yarn autoclean](https://yarnpkg.com/lang/en/docs/cli/autoclean/).

Expand All @@ -40,7 +40,7 @@ In a conventional Rails application that uses the asset pipeline, require `rails
If you're using the Webpacker gem or some other JavaScript bundler, add the following to your main JS file:

```javascript
import Rails from 'rails-ujs';
import Rails from "@rails/ujs"
Rails.start()
```

Expand Down
2 changes: 1 addition & 1 deletion actionview/package.json
@@ -1,5 +1,5 @@
{
"name": "rails-ujs",
"name": "@rails/ujs",
"version": "6.0.0-alpha",
"description": "Ruby on Rails unobtrusive scripting adapter",
"main": "lib/assets/compiled/rails-ujs.js",
Expand Down
2 changes: 1 addition & 1 deletion activestorage/README.md
Expand Up @@ -118,7 +118,7 @@ Active Storage, with its included JavaScript library, supports uploading directl
```
Using the npm package:
```js
import * as ActiveStorage from "activestorage"
import * as ActiveStorage from "@rails/activestorage"
ActiveStorage.start()
```
2. Annotate file inputs with the direct upload URL.
Expand Down
2 changes: 1 addition & 1 deletion activestorage/package.json
@@ -1,5 +1,5 @@
{
"name": "activestorage",
"name": "@rails/activestorage",
"version": "6.0.0-alpha",
"description": "Attach cloud and local files in Rails applications",
"main": "app/assets/javascripts/activestorage.js",
Expand Down
2 changes: 1 addition & 1 deletion guides/source/action_cable_overview.md
Expand Up @@ -151,7 +151,7 @@ established using the following JavaScript, which is generated by default by Rai
// Action Cable provides the framework to deal with WebSockets in Rails.
// You can generate new channels where WebSocket features live using the `rails generate channel` command.

import ActionCable from "actioncable"
import ActionCable from "@rails/actioncable"

export default ActionCable.createConsumer()
```
Expand Down
6 changes: 3 additions & 3 deletions guides/source/active_storage_overview.md
Expand Up @@ -489,7 +489,7 @@ directly from the client to the cloud.
Using the npm package:

```js
import * as ActiveStorage from "activestorage"
import * as ActiveStorage from "@rails/activestorage"
ActiveStorage.start()
```

Expand Down Expand Up @@ -616,7 +616,7 @@ of choice, instantiate a DirectUpload and call its create method. Create takes
a callback to invoke when the upload completes.

```js
import { DirectUpload } from "activestorage"
import { DirectUpload } from "@rails/activestorage"

const input = document.querySelector('input[type=file]')

Expand Down Expand Up @@ -664,7 +664,7 @@ will call the object's `directUploadWillStoreFileWithXHR` method. You can then
bind your own progress handler on the XHR.

```js
import { DirectUpload } from "activestorage"
import { DirectUpload } from "@rails/activestorage"

class Uploader {
constructor(file, url) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -2,6 +2,7 @@
"private": true,
"workspaces": [
"actioncable",
"actiontext",
"activestorage",
"actionview",
"tmp/templates/app_template",
Expand Down
@@ -1,6 +1,6 @@
// Action Cable provides the framework to deal with WebSockets in Rails.
// You can generate new channels where WebSocket features live using the `rails generate channel` command.

import ActionCable from "actioncable"
import ActionCable from "@rails/actioncable"

export default ActionCable.createConsumer()
Expand Up @@ -3,7 +3,7 @@
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.

import Rails from "rails-ujs"
import Rails from "@rails/ujs"
Rails.start()
<%- unless options[:skip_turbolinks] -%>

Expand All @@ -12,7 +12,7 @@ Turbolinks.start()
<%- end -%>
<%- unless skip_active_storage? -%>

import * as ActiveStorage from "activestorage"
import * as ActiveStorage from "@rails/activestorage"
ActiveStorage.start()
<%- end -%>
<%- unless options[:skip_action_cable] -%>
Expand Down
Expand Up @@ -2,10 +2,10 @@
"name": "<%= app_name %>",
"private": true,
"dependencies": {
"rails-ujs": ">=5.2.1"<% unless options[:skip_turbolinks] %>,
"turbolinks": "5.1.1"<% end -%><% unless skip_active_storage? %>,
"activestorage": ">=5.2.1"<% end -%><% unless options[:skip_action_cable] %>,
"actioncable": ">=5.2.1"<% end %>
"@rails/ujs": "^6.0.0-alpha"<% unless options[:skip_turbolinks] %>,
"turbolinks": "^5.2.0"<% end -%><% unless skip_active_storage? %>,
"@rails/activestorage": "^6.0.0-alpha"<% end -%><% unless options[:skip_action_cable] %>,
"@rails/actioncable": "^6.0.0-alpha"<% end %>
},
"version": "0.1.0"
}
4 changes: 2 additions & 2 deletions railties/test/generators/shared_generator_tests.rb
Expand Up @@ -206,7 +206,7 @@ def test_generator_for_active_storage

unless generator_class.name == "Rails::Generators::PluginGenerator"
assert_file "#{application_path}/app/javascript/packs/application.js" do |content|
assert_match(/^import \* as ActiveStorage from "activestorage"\nActiveStorage.start\(\)/, content)
assert_match(/^import \* as ActiveStorage from "@rails\/activestorage"\nActiveStorage.start\(\)/, content)
end
end

Expand Down Expand Up @@ -267,7 +267,7 @@ def test_generator_does_not_generate_active_storage_contents_if_skip_active_reco
assert_file "#{application_path}/config/application.rb", /#\s+require\s+["']active_storage\/engine["']/

assert_file "#{application_path}/app/javascript/packs/application.js" do |content|
assert_no_match(/^import * as ActiveStorage from "activestorage"\nActiveStorage.start\(\)/, content)
assert_no_match(/^import * as ActiveStorage from "@rails\/activestorage"\nActiveStorage.start\(\)/, content)
end

assert_file "#{application_path}/config/environments/development.rb" do |content|
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Expand Up @@ -5692,6 +5692,11 @@ trim-right@^1.0.1:
resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003"
integrity sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=

trix@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/trix/-/trix-1.0.0.tgz#e9cc98cf6030c908f8d54e317b5b072f927b0c6b"
integrity sha512-feli9QVXe6gzZOCUfpPGpNDURW9jMciIRVQ5gkDudOctcA1oMtI5K/qEbsL2rFCoGl1rSoeRt+HPhIFGyQscKg==

tslib@^1.9.0:
version "1.9.3"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
Expand Down

0 comments on commit 2163762

Please sign in to comment.