8.3.0 • Published 2 months ago

cozy-scripts v8.3.0

Weekly downloads
169
License
MIT
Repository
github
Last release
2 months ago

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.

8.3.0

2 months ago

8.1.2

6 months ago

8.1.1

9 months ago

8.2.0

4 months ago

8.1.0

9 months ago

8.0.3

1 year ago

8.0.1

1 year ago

8.0.0

1 year ago

8.0.2

1 year ago

7.0.0

1 year ago

7.0.2

1 year ago

7.0.1

1 year ago

6.4.0

1 year ago

6.3.11

1 year ago

6.3.12

1 year ago

6.3.10

2 years ago

6.3.4

2 years ago

6.3.6

2 years ago

6.3.5

2 years ago

6.3.8

2 years ago

6.3.7

2 years ago

6.3.9

2 years ago

6.3.3

2 years ago

6.3.2

2 years ago

6.2.1

2 years ago

6.2.0

2 years ago

6.2.2

2 years ago

6.3.0

2 years ago

6.3.1

2 years ago

6.1.6

2 years ago

6.1.4

2 years ago

6.1.5

2 years ago

6.1.2

2 years ago

6.1.1

2 years ago

6.1.3

2 years ago

6.1.0

2 years ago

6.0.1

2 years ago

5.13.0

3 years ago

5.12.0

3 years ago

5.11.1

3 years ago

6.0.0

3 years ago

5.11.0

3 years ago

5.9.0

3 years ago

5.10.0

3 years ago

5.8.0

3 years ago

5.7.0

3 years ago

5.5.0

3 years ago

5.6.0

3 years ago

5.4.4

3 years ago

5.4.3

3 years ago

5.4.2

3 years ago

5.4.1

3 years ago

5.4.0

3 years ago

5.3.1

3 years ago

5.3.0

3 years ago

5.2.0

3 years ago

5.1.3

3 years ago

5.1.2

3 years ago

5.1.1

4 years ago

5.1.1-beta.1

4 years ago

5.1.0

4 years ago

5.0.2

4 years ago

5.0.1

4 years ago

5.0.0

4 years ago

4.4.0

4 years ago

4.3.3

4 years ago

4.3.2

4 years ago

4.3.1

4 years ago

4.3.0

4 years ago

4.3.0-beta.2

4 years ago

4.3.0-beta.1

4 years ago

4.2.1

4 years ago

4.2.0

4 years ago

4.0.1-beta.4

4 years ago

4.1.0

4 years ago

4.0.0

4 years ago

3.1.0-beta.2

4 years ago

3.1.0-beta.1

4 years ago

3.0.0

4 years ago

1.15.0

4 years ago

1.14.1

4 years ago

1.14.0

4 years ago

2.0.2

5 years ago

1.13.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.13.1

5 years ago

1.12.4

5 years ago

1.12.3

5 years ago

2.0.0-beta.0

5 years ago

1.13.0

5 years ago

1.12.2

5 years ago

1.12.1

5 years ago

1.12.0

5 years ago

1.11.0

5 years ago

1.10.0

5 years ago

1.9.0

5 years ago

1.8.0

5 years ago

1.7.0

5 years ago

1.6.0

5 years ago

1.5.0

5 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

1.0.0-beta.0

6 years ago

0.10.6

6 years ago

0.10.5

6 years ago

0.10.4

6 years ago

0.10.3

6 years ago

0.10.2

6 years ago

0.10.1

6 years ago

0.10.0

6 years ago

0.9.0

6 years ago

0.8.1

6 years ago

0.8.0

6 years ago

0.7.3

6 years ago

0.7.2

6 years ago

0.7.1

6 years ago

0.7.0

6 years ago

0.6.1

6 years ago

0.6.0

6 years ago

0.5.10

6 years ago

0.5.9

6 years ago

0.5.8

6 years ago

0.5.7

6 years ago

0.5.6

6 years ago

0.5.5

6 years ago

0.5.4

6 years ago

0.5.3

6 years ago

0.5.2

6 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.4.5

6 years ago

0.4.4

6 years ago

0.4.3

6 years ago

0.4.2

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.3

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago