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

cozy-scripts

v8.3.0

Published

<a href="https://www.npmjs.com/package/cozy-scripts"> <img src="https://img.shields.io/npm/v/cozy-scripts.svg" alt="npm version" /> </a> <a href="https://github.com/CPatchane/create-cozy-app/blob/master/packages/cozy-scripts/LICENSE"> <img src="https:

Downloads

2,025

Readme

Cozy Scripts

What's cozy-scripts?

cozy-scripts contains

  • common commands used by Cozy developers during application development
  • common webpack configs

Installation

yarn add cozy-scripts

After installation, the cozy-scripts is available.

CLI commands

cozy-scripts has commands to be used inside your application (used by default in applications created from create-cozy-app):

- cozy-scripts --show-config

Outputs the webpack config computed according your current global variable NODE_ENV. By default, the application will have yarn scripts (in the package.json) to show the configurations according to different environments (dev, browser, mobile, prod...).

- cozy-scripts build

Runs webpack for production builds. Built files (destined to the Cozy) will be in the build/ directory.

A --debug option is available if you want to ouput more information about webpack building in your console.

- cozy-scripts start

Launches the application for development. Its runs webpack in watch mode with a server (webpack-dev-server) to serve application assets. Then, it will launch a Cozy stack using Docker (the image cozy/cozy-app-dev) to serve your application inside it. This is the preferred method to build a Cozy app during development.

Your application will be available at http://<MY_APP_SLUG>.cozy.tools:8080.

:warning: If you want to build a service, you should use cozy-scripts watch (see below).

In this mode HMR (Hot Module Replacement) is available to help you with the application development.

- cozy-scripts watch

Run webpack in watch mode: each time you modify a file, a new build will be triggered. This is only recommended for service build. The built files (destined to the Cozy) will be in build/.

A --debug options is available if you want to ouput more information about webpack building in your console.

Common flags for build / watch / start

--production / --development

Configures the build mode.

This mode will be overwritten by process.env.NODE_ENV (ex: browser:development for development usage with browser target).

--browser / --mobile

Configures the build target.

This target will be overwritten by process.env.NODE_ENV (ex: browser:development for development usage with browser target).

--analyzer

Use this option if you want to analyze your builds content using the webpack plugin webpack-bundle-analyzer. It will open you browser with an interactive treemap visualization of the contents of all your bundles.

--src-dir, --build-dir, --manifest

Use these options if you want to build/watch/start your application with custom paths. These paths must be relative to the application root directory:

  • --src-dir: the src directory, the source files of your application
  • --build-dir: the directory to put the application build files into
  • --manifest: the path of your manifest file manifest.webapp (the .webapp extension must be provided)

- cozy-scripts test

Runs the application tests using Jest. This command handles all parameters than Jest does, like --watch for the watch mode or -u to update snapshots for example.

- cozy-scripts publish

Fetches and runs the latest version of the cozy-app-publish CLI to publish your application on a Cozy registry (by default the official and main Cozy Cloud applications registry on https://apps-registry.cozycloud.cc). The options and arguments are the same than in the cozy-app-publish package documentation.

- cozy-scripts release

Releases a new version of the application. The first step is to start the release using cozy-scripts release start. It will create a new release branch according to your current version and it will bump the version on your master branch. Then you can release new versions (on your release branch) using cozy-scripts release patch|beta|stable according to your needs.

By default, this script will push on the origin remote but you can change by passing it to your script after the action name: cozy-scripts release start cozy to use the remote named cozy.

You can find more informations about this library and how to use it in cozy-release documentation

:warning: BE VERY CAREFUL using this script since it will push directly to your remote repository. A prompt will warn you before starting the release.

Webpack configurations

cozy-scripts is designed to use a default webpack configuration for a basic React/Redux application which uses cozy-ui and cozy-client-js. But you can override or use your custom configuration files by creating a new app.config.js file in your application root folder. Here is an example to overload the default bundle config with a custom one:

// myapp/app.config.js
module.exports = [
  // default for React/Redux
  require('cozy-scripts/config/webpack.bundle.default.js'),
  require('./config/webpack.myconfig.js')
]

TypeScript

TypeScript is lightly supported: type checking and linting are disabled, but files can be compiled. In order to use this feature your application needs to have @babel/preset-env and @babel/preset-typescript installed. Your babel config also needs to declare those presets, for instance:

// myapp/babel.config.js
module.exports = {
  presets: ['cozy-app', '@babel/typescript', '@babel/env']
}

cozy-flags

cozy-scripts works well with cozy-flags. You can specify a few flags on build time :

COZY_FLAGS=flag1,flag2 yarn build
import flag from 'cozy-flags'
 
if (flag('flag1') || flag('flag2')) {
  enableMyFeature()
}

cozy-bar

cozy-scripts works by default with cozy-bar version 7.0. If you want to use version 8.0, you need to add on your cozy-scripts command yarn build --barV7 false or COZY_BAR_V7=false yarn build

You can find more information about webpack configuration files available via cozy-scripts in the dedicated webpack configs documentation.

If you need more custom configurations and need to use the webpack-merge smart mode or merge strategies, you can also find more information about in the dedicated merge strategies documentation.

:warning: cozy-scripts internally uses Webpack v4, be sure to use Webpack 4 compatible configurations if you want to provide custom configurations in the app.config.js

Community

What's Cozy?

Cozy is a platform that brings all your web services in the same private space. With it, your webapps and your devices can share data easily, providing you with a new experience. You can install Cozy on your own hardware where no one's tracking you.

Get in touch

You can reach the Cozy Community by:

License

cozy-scripts is distributed under the MIT license.