npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@fishawack/lab-env

v4.38.0

Published

Docker manager for FW

Downloads

351

Readme

Background

What

A command line utility to spin up and manage FW specific docker containers.

Why

To automate the spinning up of our tech stack and to provide a consistent environment for dev and production.

Dependencies

Click on the following links and follow the instructions.

Alternatively you can install via brew or choco depending on your platform.

Mac

Install brew package manager

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install dependencies

brew install node
brew cask install docker

Optionally install git

brew install git

Windows

Install choco package manager.

The install command needs to be run in an administrative powershell terminal.

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

Install dependancies

choco install nodejs
choco install docker-desktop

Optionally install git

choco install git

Getting started

Install

npm install @fishawack/lab-env -g

Basic usage

lab-env setup && lab-env start

Commands

To see the full command list and a description of each command run the following command.

lab-env --help

Troubleshooting

Permission denied when mounting nginx conf (Laravel)

Problem

This happens when your using NodeJs installed into the root filesystem (/usr/local/bin), you may see errors similar to this:

ERROR: for nginx  Cannot start service nginx: OCI runtime create failed: container_linux.go:367: starting container process caused: process_linux.go:495: container init caused: rootfs_linux.go:60: mounting "/usr/local/lib/node_modules/@fishawack/lab-env/laravel/8/nginx/nginx.conf" to rootfs at "/var/lib/docker/overlay2/1ea9b758b732df7b4fe4dd5e1bd57836967bfde1d9a1ae44ca1a5c0d6e95db5c/merged/etc/nginx/conf.d/default.conf" caused: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

Solution

Purge your NodeJs installation and install it via NVM https://github.com/nvm-sh/nvm

No space left

Problem

Docker has 64gb of space by default. If you see the below messages you need to have a spring clean and free up some space or give docker more memory.

npm WARN tar ENOSPC: no space left on device, write

When setting up a new project, one of the package may fail to pull from docker and shows an "invalid signature" or "is not signed" error:

=> ERROR [alpine 3/19] RUN apt-get update
Get:1 http://deb.debian.org/debian bullseye InRelease
W: GPG error: http://deb.debian.org/debian bullseye InRelease: At least one invalid signature was encountered.
E: The repository 'http://deb.debian.org/debian bullseye InRelease' is not signed.

Solution

Clean up your docker.

mySql creds

Problem

When a project is first setup the mysql container will create any tables needed based on whats found in the .env file. If the database details are modified in the .env file after the first run those new tables will not be created resulting in the site not being able to connect to mysql.

Illuminate\Database\QueryException  : SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known (SQL: select * from information_schema.tables where table_schema = fide and table_name = migrations)

Solution

The volume needs removing and re-setting up, the easiest way to do this is to commit everything in and re-setup the project.

# Commit/Stash so you don't lose any work
git stash

lab-env nuke
lab-env setup

git stash pop

Watch / Case sensitive issues

Problem

As of docker desktop 3.2.2, if you cd into a directory without correctly matching the case of the folders in your working tree, then you can run into some strange issues, one of them being laravel mix not triggering a watch on javascript or sass files correctly but still working fine for html/twig/blade files.

Solution

Always match the case as it exists in your directory structure.

// Bad (but will work fine for the most part)
cd /Users/mmellor/sites/boilerplate

// Good (notice the case in the 'Sites' folder name)
cd /Users/mmellor/Sites/boilerplate

Memory limit

By default Docker will assign 64gb of memory for Docker to utilize. After a while of using lab-env and potentially other docker setups you may come close to or exceed that limit. To see how much memory docker is using type the following command.

docker system df -v

If you want a full clean up of docker then running the following command will remove all containers, volumes, images and caches.

docker system prune --all --volumes -f

If you just want to remove the images and containers so they can be built fresh then run the following.

docker system prune --all -f

You can also run the slightly less impactful clean command but this command wouldn't do much if you're only use of docker is through lab-env as this tool doesn't currently persist any containers between runs.

docker system prune -f

If you notice it's mainly the volumes that are taking up all the space then you can either clean out all volumes (this will remove every projects node_modules folder meaning they'll need re-installing).

docker volume rm $(docker volume ls -q)

Or you can target specific node_modules and hand pick which ones to remove. For example:

docker volume rm boilerplate_node_modules

Migrating

2.0.0

Wordpress repo's are now structured slightly differently to better match laravel, drupal and craftcms setups. Follow these steps to upgrade a wordpress build and get lab-env working again.

Reset repository

Before starting this migration ensure all code is committed so you don't run the risk of losing anything afterwhich run one of the following.

fw nuke

# or

Remove / Re-clone repository

wp-content

Move the plugins, themes and uploads folder a new wp-content folder at the root of the project.

# Old way
./themes
./plugins
./uploads

# New way
./wp-content/themes
./wp-content/plugins
./wp-content/uploads

.env.example

Replace the contents of the .env.example with the following.

# Old way
DB_DATABASE=wordpress
DB_USERNAME=wordpress
DB_PASSWORD=password
JWT_SECRET=

# New way
DEBUG=true

DB_DATABASE=wordpress
DB_USERNAME=wordpress
DB_PASSWORD=password
DB_HOST=mysql
DB_CHARSET=utf8
DB_COLLATE=

TABLE_PREFIX=wp_

AUTH_KEY=5c94a709b751faeed445f29b92f8513b8bce1652
SECURE_AUTH=09e370e7bfc34b17fc96d80cda1a281427053afd
LOGGED_IN=405de7e577398c86b6975fc4a8bba1df179666dd
NONCE_KEY=10c232cb86bb257af4c0434a7e3b9f993f18ba11
AUTH_SALT=07a08cb5a6c3318633c505fcf1ffffa4d01ab375
SECURE_AUTH=df11e32128f8d5403a7c681d0e5cc4145be2b2ab
LOGGED_IN=a99860e8150b15e11caada875f56421165659a7d
NONCE_SALT=51c6eba59477027e612fc13e38a53acaa2b73d92

CONFIG_EXTRA="
    define( 'WP_HOME', 'http://localhost:3000' );
    define( 'WP_SITEURL', 'http://localhost:3000' );
"

.gitignore

There's a new more complex gitignore now that takes into account the wordpress files that are reverse mounted back to the host machine.

# Old way
# These are some examples of commonly ignored file patterns.
# You should customize this list as applicable to your project.
# Learn more about .gitignore:
#     https://www.atlassian.com/git/tutorials/saving-changes/gitignore

# Node artifact files
node_modules/
dist/

# Compiled Java class files
*.class

# Compiled Python bytecode
*.py[cod]

# Log files
*.log

# Package files
*.jar

# Maven
target/
dist/

# JetBrains IDE
.idea/

# Unit test reports
TEST*.xml

# Generated by MacOS
.DS_Store

# Generated by Windows
Thumbs.db

# Applications
*.app
*.exe
*.war

# Large media files
*.mp4
*.tiff
*.avi
*.flv
*.mov
*.wmv
.env


.tmp/
generated/
_Zips/
_Pdfs/
coverage/
**/generated/**/*
_Build/**/pulled/**/*
_Output
_Login
_Packages
_Build/content
_Build/media/content
_App
_Electron
_Node/stats
ssh-*
.ftppass
id_rsa
misc.json
.cache/
themes/twenty*
themes/thirty*
themes/*/css
themes/*/js
plugins/akismet
plugins/hello.php
uploads

# New way
# These are some examples of commonly ignored file patterns.
# You should customize this list as applicable to your project.
# Learn more about .gitignore:
#     https://www.atlassian.com/git/tutorials/saving-changes/gitignore

# Node artifact files
node_modules/
dist/

# Compiled Java class files
*.class

# Compiled Python bytecode
*.py[cod]

# Log files
*.log

# Package files
*.jar

# Maven
target/
dist/

# JetBrains IDE
.idea/

# Unit test reports
TEST*.xml

# Generated by Windows
Thumbs.db

# Applications
*.app
*.exe
*.war

# Large media files
*.mp4
*.tiff
*.avi
*.flv
*.mov
*.wmv
.env

.tmp/
generated/
_Zips/
_Pdfs/
coverage/
**/generated/**/*
_Build/**/pulled/**/*
_Output
_Login
_Packages
_Build/content
_Build/media/content
_App
_Electron
_Node/stats
ssh-*
.ftppass
id_rsa
misc.json
.cache/

# Wordpress docker image files
.htaccess
license.txt
readme.html
index.php
xmlrpc.php
wp-*
!wp-content**/*
wp-content/index.php
wp-content/plugins/index.php
wp-content/themes/index.php
wp-content/themes/twenty*
wp-content/themes/thirty*
wp-content/themes/fishawack/css
wp-content/themes/fishawack/js
wp-content/plugins/akismet
wp-content/plugins/hello.php
wp-content/uploads

# Generated by MacOS
.DS_Store

Default theme location

The default root attribute needs updating to take into account the new folder structure.

// Old way
"attributes": {
    "root": "themes/fishawack",
}

// New way
"attributes": {
    "root": "wp-content/themes/fishawack",
}

Deploy files

The deploy paths also need updating to take into account the new folder structure.

// Old way
"paths": [
    {
        "src": "plugins",
        "dest": "wp-content/plugins"
    },
    {
        "src": "themes",
        "dest": "wp-content/themes"
    }
]

// New way
"paths": [
    {
        "src": "wp-content/plugins",
        "dest": "wp-content/plugins"
    },
    {
        "src": "wp-content/themes",
        "dest": "wp-content/themes"
    }
]