Setup NPM with an empty package.json file

Note that, even if we're excluding the `node_modules/` folder from
version control, we aren't adding it to Capistrano's shared folders
because, when `node_modules` is a symbolic link, NPM removes it when
running `npm install`.
This commit is contained in:
Javi Martín
2023-07-22 03:22:08 +02:00
parent ed4f8ad6d9
commit ad166fba4c
9 changed files with 26 additions and 0 deletions

View File

@@ -24,6 +24,7 @@ public/tenants/*/sitemap.xml
public/assets/
public/machine_learning/data/
public/tenants/*/machine_learning/data/
node_modules/
# Bundler config, cache and gemsets
**/.bundle/

View File

@@ -42,7 +42,10 @@ jobs:
- name: Setup NPM
uses: actions/setup-node@v3
with:
cache: "npm"
node-version-file: ".node-version"
- name: Install node packages
run: npm clean-install
- name: Copy secrets and database files
run: for i in config/*.example; do cp "$i" "${i/.example}"; done
- name: Setup database

1
.gitignore vendored
View File

@@ -26,6 +26,7 @@ tmp/
/public/assets/
/public/machine_learning/data/
/public/tenants/*/machine_learning/data/
/node_modules/
# Bundler config, cache and gemsets
.bundle/

View File

@@ -23,6 +23,7 @@ tests:
- bundle --without development
- bundle exec rake db:setup
- bundle exec rake assets:precompile > /dev/null 2>&1
- npm clean-install
- bin/knapsack_pro_rspec
artifacts:
when: on_failure

View File

@@ -51,6 +51,9 @@ RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz
COPY Gemfile* ./
RUN bundle install
COPY package* ./
RUN npm install
# Copy the Rails application into place
COPY . .

View File

@@ -17,6 +17,9 @@ FileUtils.chdir APP_ROOT do
system! "gem install bundler --conservative"
system("bundle check") || system!("bundle install")
# Install JavaScript dependencies
system!("npm install")
puts "\n== Copying sample files =="
unless File.exist?("config/database.yml")
FileUtils.cp "config/database.yml.example", "config/database.yml"

View File

@@ -117,6 +117,7 @@ module Consul
config.assets.paths << Rails.root.join("app", "assets", "fonts")
config.assets.paths << Rails.root.join("vendor", "assets", "fonts")
config.assets.paths << Rails.root.join("node_modules")
# Add lib to the autoload path
config.autoload_paths << Rails.root.join("lib")

10
package-lock.json generated Normal file
View File

@@ -0,0 +1,10 @@
{
"name": "consuldemocracy",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "consuldemocracy"
}
}
}

3
package.json Normal file
View File

@@ -0,0 +1,3 @@
{
"name": "consuldemocracy"
}