github.com/readium/readium-lcp-server@v0.0.0-20240101192032-6e95190e99f1/frontend/manage/README.md (about)

     1  # see Angular QuickStart Source (github)
     2  
     3  ## Prerequisites
     4  
     5  Node.js and npm are essential to Angular development. 
     6      
     7  <a href="https://docs.npmjs.com/getting-started/installing-node" target="_blank" title="Installing Node.js and updating npm">
     8  Get it now</a> if it's not already installed on your machine.
     9   
    10  **Verify that you are running at least node `v12.13.0` and npm `6.12.0`**
    11  by running `node -v` and `npm -v` in a console window.
    12  Older versions produce errors.
    13  
    14  We recommend [nvm](https://github.com/creationix/nvm) for managing multiple versions of node and npm.
    15  
    16  ## Install npm packages
    17  
    18  > See the npm and nvm version notes above
    19  
    20  Install the npm packages described in the `package.json` and verify that it works:
    21  
    22  from the directory frontend/manage: 
    23  
    24  ```bash
    25  npm install
    26  npm start
    27  ```
    28  
    29  The `npm start` command cleans the distribution folder, compiles the application,
    30  then simultaneously compiles and runs a `lite-server` on port 3000. 
    31  Index.html contains the angular test lcp project.
    32  Both the compiler and the server watch for file changes.
    33  This command is only used during the development phase.
    34  
    35  Shut it down manually with `Ctrl-C`.
    36  
    37  You can then lauch the `frontend` server and call the Angular application from a browser. 
    38  
    39  ## Recompile the app
    40  
    41  If no node module has been updated in package.json, after pulling the updated project, run: 
    42  
    43  ```bash
    44  npm run build
    45  ```
    46  
    47  ### npm scripts
    48  
    49  We've captured many of the most useful commands in npm scripts defined in the `package.json`:
    50  
    51  * `npm start` - cleans the distribution folder, runs the compiler and a lite server at the same time, both in "watch mode".
    52  * `npm run build` - cleans the distribution folder, compiles the application, copies the html and css files to their destination folder.
    53  * `npm run tsc` - runs the TypeScript compiler once.
    54  * `npm run tsc:w` - runs the TypeScript compiler in watch mode; the process keeps running, awaiting changes to TypeScript files and re-compiling when it sees them.
    55  * `npm run lite` - runs the [lite-server](https://www.npmjs.com/package/lite-server), a light-weight, static file server, written and maintained by
    56  [John Papa](https://github.com/johnpapa) and
    57  [Christopher Martin](https://github.com/cgmartin)
    58  with excellent support for Angular apps that use routing.
    59  
    60  Here are the test related scripts:
    61  * `npm test` - compiles, runs and watches the karma unit tests
    62  * `npm run e2e` - run protractor e2e tests, written in JavaScript (*e2e-spec.js)
    63  
    64  ## Testing
    65  
    66  karma/jasmine unit test and protractor end-to-end testing support.
    67  
    68  These tools are configured for specific conventions described below.
    69  
    70  *It is unwise and rarely possible to run the application, the unit tests, and the e2e tests at the same time.
    71  We recommend that you shut down one before starting another.*
    72  
    73  ### Unit Tests
    74  TypeScript unit-tests are usually in the `app` folder. Their filenames must end in `.spec`.
    75  
    76  Look for the example `app/app.component.spec.ts`.
    77  Add more `.spec.ts` files as you wish; we configured karma to find them.
    78  
    79  Run it with `npm test`
    80  
    81  That command first compiles the application, then simultaneously re-compiles and runs the karma test-runner.
    82  Both the compiler and the karma watch for (different) file changes.
    83  
    84  Shut it down manually with `Ctrl-C`.
    85  
    86  Test-runner output appears in the terminal window.
    87  We can update our app and our tests in real-time, keeping a weather eye on the console for broken tests.
    88  Karma is occasionally confused and it is often necessary to shut down its browser or even shut the command down (`Ctrl-C`) and
    89  restart it. No worries; it's pretty quick.
    90  
    91  ### End-to-end (E2E) Tests
    92  
    93  E2E tests are in the `e2e` directory, side by side with the `app` folder.
    94  Their filenames must end in `.e2e-spec.ts`.
    95  
    96  Look for the example `e2e/app.e2e-spec.ts`.
    97  Add more `.e2e-spec.js` files as you wish (although one usually suffices for small projects);
    98  we configured protractor to find them.
    99  
   100  Thereafter, run them with `npm run e2e`.
   101  
   102  That command first compiles, then simultaneously starts the Http-Server at `localhost:8080`
   103  and launches protractor.  
   104  
   105  The pass/fail test results appear at the bottom of the terminal window.
   106  A custom reporter (see `protractor.config.js`) generates a  `./_test-output/protractor-results.txt` file
   107  which is easier to read; this file is excluded from source control.
   108  
   109  Shut it down manually with `Ctrl-C`.
   110  
   111  [travis-badge]: https://travis-ci.org/angular/quickstart.svg?branch=master
   112  [travis-badge-url]: https://travis-ci.org/angular/quickstart