Skip to content

Commit

Permalink
Merge pull request #30 from kyubisation/develop
Browse files Browse the repository at this point in the history
v2.0.0-beta.0
  • Loading branch information
kyubisation authored Mar 10, 2019
2 parents d8413de + d320abf commit dc66ee6
Show file tree
Hide file tree
Showing 111 changed files with 121,403 additions and 3,692 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ deploy:
email: "[email protected]"
api_key: "$NPM_TOKEN"
skip_cleanup: true
# TODO: REMOVE FOR STABLE RELEASE
tag: next
on:
tags: true
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# 2.0.0-beta.0 (2019-03-10)

### Features

* Implemented NG_ENV variant as an alternative for process.env

### Breaking Changes

* Removed deprecated ProcessEnvConfiguration

# 1.3.0 (2019-03-09)

### Features
Expand All @@ -7,7 +17,7 @@

### Deprecation

* EnvironmentVariablesConfiguration has been deprecated. Use ProcessEnvConfiguration instead.
* EnvironmentVariablesConfiguration has been deprecated. Use ProcessEnvConfiguration instead

### Internal Changes

Expand Down
54 changes: 35 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
![](https://img.shields.io/npm/v/angular-server-side-configuration.svg)
![](https://img.shields.io/npm/l/angular-server-side-configuration.svg)

[Documentation](https://github.com/kyubisation/angular-server-side-configuration/blob/master/documentation/README.md)

Configure an angular application at runtime on the server via environment variables.

Expand All @@ -24,7 +23,8 @@ on the host serving the bundled angular files.
By default, this will not work in Module.forRoot or Module.forChild scripts or parameters.
These are build time only due to AoT restrictions.

With `ngssc wrap-aot ng build ...` it is however possible to retain the configuration, by replacing
With `ngssc wrap-aot ng build ...` (or `ngssc wrap-aot --ng-env ng build ...` for NG_ENV)
it is however possible to retain the configuration, by replacing
the environment variables with tokens during the AoT build and reverting afterwards. (See [CLI wrap-aot](#wrap-aot))

## Getting Started
Expand All @@ -33,6 +33,9 @@ npm install --save angular-server-side-configuration
```

### environment.prod.ts
angular-server-side-configuration supports two variants for using environment variables: process.env.* or NG_ENV.*

#### process.env.*
Use process.env.NAME in your environment.prod.ts, where NAME is the
environment variable that should be used.

Expand All @@ -45,6 +48,21 @@ export const environment = {
};
```

#### NG_ENV.*
Import NG_ENV from `angular-server-side-configuration/ng-env`
(or `angular-server-side-configuration/ng4-env` for Angular 4 or 5)
and use NG_ENV.NAME in your environment.prod.ts, where NAME is the
environment variable that should be used.

```typescript
import { NG_ENV } from 'angular-server-side-configuration/ng-env';

export const environment = {
production: NG_ENV.PROD !== 'false',
apiAddress: NG_ENV.API_ADDRESS || 'https://example-api.com'
};
```

### index.html (Optional)
Add `<!--CONFIG-->` to index.html. This will be replaced by the configuration script tag.
This is optional, as the environment variables can simply be inserted somewhere in the head tag.
Expand Down Expand Up @@ -74,6 +92,13 @@ npm install -g angular-server-side-configuration
ngssc insert /path/to/angular/files --search
```

Or if NG_ENV was used:
```bash
npm install -g angular-server-side-configuration
ngssc insert /path/to/angular/files --ng-env --search
```


## CLI
angular-server-side-configuration provides a CLI.

Expand All @@ -94,6 +119,8 @@ Search and replace the placeholder with environment variables (Directory default
| `-p, --placeholder <value>` | Set the placeholder to replace with the environment variables (Defaults to `<!--CONFIG-->`) |
| `-h, --head` | Insert environment variables into the head tag (after title tag, if available, otherwise before closing head tag) |
| `--dry` | Perform the insert without actually inserting the variables |
| `--process-env` | Use process.env for insertion (Default) |
| `--ng-env` | Use NG_ENV for insertion |
| `-h, --help` | output usage information |

### Init
Expand All @@ -106,6 +133,8 @@ Initialize an angular project with angular-server-side-configuration (Directory
| `-ef, --environment-file` | The environment file to initialize (environmentFile defaults to src/environments/environment.prod.ts) |
| `--npm` | Install angular-service-side-configuration via npm (Default) |
| `--yarn` | Install angular-service-side-configuration via yarn |
| `--process-env` | Initialize with process.env variant (Default) |
| `--ng-env` | Initialize with NG_ENV variant |
| `-h, --help` | output usage information |

### Wrap-Aot
Expand All @@ -118,26 +147,13 @@ content of the environment file with tokens. After the inner command completes,
| --- | --- |
| `-ef, --environment-file` | The environment file to prepare for aot-compilation (Defaults to src/environments/environment.prod.ts) |
| `--dist` | The output path of the ng build (Defaults to dist/**) |
| `--process-env` | Use process.env variant (Default) |
| `--ng-env` | Use NG_ENV variant |
| `-h, --help` | output usage information |

## Native CLI
If node.js cannot be used on the target system, it is also possible to compile ngssc to a native CLI with tools like [pkg](https://www.npmjs.com/package/pkg) or [nexe](https://www.npmjs.com/package/nexe).

Create a file named ngssc.js:
```javascript
require('angular-server-side-configuration').cli().parse(process.argv);
```

And then use pkg or nexe to build the native ngssc CLI:
```
npm install pkg -g
pkg ngssc.js
```
```
npm install nexe -g
nexe ngssc.js --target os-of-target-system
```
## API Documentation

[API Documentation](https://github.com/kyubisation/angular-server-side-configuration/blob/master/documentation/angular-server-side-configuration.md)

## License
Apache License, Version 2.0
23 changes: 23 additions & 0 deletions api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/api-extractor.schema.json",
"compiler" : {
"configType": "tsconfig",
"rootFolder": "."
},
"project": {
"entryPointSourceFile": "typings/src/index.d.ts"
},
"apiReviewFile": {
"enabled": false
},
"apiJsonFile": {
"enabled": true
},
"dtsRollup": {
"enabled": true,
"publishFolder": "."
},
"tsdocMetadata": {
"enabled": false
}
}
169 changes: 0 additions & 169 deletions documentation/README.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Home](./index) &gt; [angular-server-side-configuration](./angular-server-side-configuration.md) &gt; [ApplyAndSaveRecursivelyOptions](./angular-server-side-configuration.applyandsaverecursivelyoptions.md) &gt; [directory](./angular-server-side-configuration.applyandsaverecursivelyoptions.directory.md)

## ApplyAndSaveRecursivelyOptions.directory property

The root directory from which to search files. (Defaults to instance directory.)

<b>Signature:</b>

```typescript
directory?: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Home](./index) &gt; [angular-server-side-configuration](./angular-server-side-configuration.md) &gt; [ApplyAndSaveRecursivelyOptions](./angular-server-side-configuration.applyandsaverecursivelyoptions.md) &gt; [filePattern](./angular-server-side-configuration.applyandsaverecursivelyoptions.filepattern.md)

## ApplyAndSaveRecursivelyOptions.filePattern property

The file pattern in which the configuration should be inserted (Defaults to /index.html$/).

<b>Signature:</b>

```typescript
filePattern?: RegExp;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[Home](./index) &gt; [angular-server-side-configuration](./angular-server-side-configuration.md) &gt; [ApplyAndSaveRecursivelyOptions](./angular-server-side-configuration.applyandsaverecursivelyoptions.md)

## ApplyAndSaveRecursivelyOptions interface

Options for applyAndSaveRecursively

<b>Signature:</b>

```typescript
export interface ApplyAndSaveRecursivelyOptions
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [directory](./angular-server-side-configuration.applyandsaverecursivelyoptions.directory.md) | `string` | The root directory from which to search files. (Defaults to instance directory.) |
| [filePattern](./angular-server-side-configuration.applyandsaverecursivelyoptions.filepattern.md) | `RegExp` | The file pattern in which the configuration should be inserted (Defaults to /index.html$/). |

Loading

0 comments on commit dc66ee6

Please sign in to comment.