Move and update documentation

Also remove yarn.lock to simplify getting started.
This commit is contained in:
Lars Karlitski 2017-10-18 10:41:43 +02:00
parent 8ff4b33bb5
commit cb97059e2e
3 changed files with 20 additions and 2608 deletions

View file

@ -2,4 +2,23 @@
Scaffolding for a [Cockpit](http://www.cockpit-project.org) module.
See [docs/build-notes.md](docs/build-notes.md) for more information on how to build and install this package.
# Building
Run `npm install` to install dependencies and `make` to build the package. It
builds into the `dist` directory. Link or copy that to a location were
`cockpit-bridge` looks for packages.
`make install` compiles and installs the package in `/usr/share/cockpit/`. The
convenience targets `srpm` and `rpm` build the source and binary rpms,
respectively. Both of these make use of the `dist-gzip` target, which is used
to generate the distribution tarball. In `production` mode, source files are
automatically minified and compressed. Set `NODE_ENV=production` if you want to
duplicate this behavior.
# Vagrant
This directory contains a Vagrantfile that installs and starts cockpit on a
Fedora 26 cloud image. Run `vagrant up` to start it and `vagrant rsync` to
synchronize the `dist` directory to `/usr/local/share/cockit/starter-kit`. Use
`vagrant rsync-auto` to automatically sync when contents of the `dist`
directory change.

View file

@ -1,83 +0,0 @@
# Building the plugin
These are some basic notes on building the plugin
## yarn
The starter kit plugin for cockpit is built using webpack 2.x. Although npm can be used to install the various
dependencies, it is recommended to install [yarn][-yarnpkg] and use it instead:
```
yarn install
```
After this command finishes, all the node_modules will be installed.
## babel
The .babelrc file contains the settings for the various things babel can do, namely transform es6 to es5 code, and to
transform react jsx code to regular javascript. When building, the webpack.config.js setting will output a bundled file
in ./build/bundle.js. It will run the babel-loader plugin to transform es6 to es5
**TODO**: Figure out how to configure babelrc to transform jsx code
## index.js
This is the entry point for webpack, and will most likely contain the main parent react component.
## Directory layout
The main package files are located in the [src](src) directory. These are processed during compilation and
packaging.
## Building
You can use `make` to compile to code or `make install` to compile and install in `/usr/share/cockpit/`.
The convenience make targets `srpm` and `rpm` build the source and binary rpms, respectively. Both of these make
use of the `dist-gzip` target, which is used to generate the distribution tarball. In `production` mode, source files
are automatically minified and compressed. Set `NODE_ENV=production` if you want to duplicate this behavior.
Optionally, you can use `yarn` or `npm` to run the build, both of which in turn call `webpack`:
```
yarn run build
```
or alternatively if you didn't install yarn:
```
npm run build
```
This works because the package.json file has a scripts object, and the build key tells us to run the webpack command
with the build option.
Why do it this way instead of just doing `npm install -g webpack` and then `webpack build`? By doing that, different
users trying to build the plugin might have different versions of webpack installed. By installing webpack as a dev
dependency, and then using yarn or npm to run a command, it will use the webpack version installed locally.
[-yarnpkg]: https://yarnpkg.com
## Hacking with webpack
A fairly simple workflow for development uses webpack directly and doesn't require root privileges.
First, ensure that all dependencies are met and the code compiles:
```
npm install
make
```
Then, link the `dist` directory in a place where cockpit can find it, without installing to the system directory.
Call the following script from the git checkout:
```
ln -s ./dist starter
```
Then use webpack to monitor the filesystem for changes, also from the git checkout:
```
webpack --watch
```
After logging into Cockpit, you can refresh the page to load the newly built code after each change to the source files.

2524
yarn.lock

File diff suppressed because it is too large Load diff