Permalink
Browse files

Move all npm packages to @rails scope

Fixes #33083
  • Loading branch information...
javan committed Jan 9, 2019
1 parent 7aaf9b8 commit 86b489e3d6a9efbefbc62e8531d0f5850934d4e1
@@ -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
@@ -504,7 +504,7 @@ WebSocket functionality.
### Installation

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

### Usage
@@ -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')
@@ -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')
@@ -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()
@@ -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",
@@ -1,4 +1,4 @@
import { DirectUpload } from "activestorage"
import { DirectUpload } from "@rails/activestorage"

export class AttachmentUpload {
constructor(attachment, element) {
@@ -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
@@ -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",
@@ -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"
}
}
@@ -1 +1 @@
import "actiontext"
import "@rails/actiontext"

This file was deleted.

Oops, something went wrong.
@@ -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/).

@@ -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()
```

@@ -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",
@@ -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.
@@ -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",
@@ -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()
```
@@ -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()
```

@@ -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]')
@@ -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) {
@@ -2,6 +2,7 @@
"private": true,
"workspaces": [
"actioncable",
"actiontext",
"activestorage",
"actionview",
"tmp/templates/app_template",
@@ -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()
@@ -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] -%>

@@ -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] -%>
@@ -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"
}
@@ -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

@@ -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|

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 86b489e

Please sign in to comment.