Skip to content

Commit

Permalink
Merge pull request NationalBankBelgium#2538 from SuperITMan/feature/r…
Browse files Browse the repository at this point in the history
…eformat-stark-code-after-prettier-update

Feature/reformat stark code after prettier update
  • Loading branch information
nicanac committed Mar 10, 2021
2 parents b790662 + 3890784 commit e97fbe3
Show file tree
Hide file tree
Showing 99 changed files with 799 additions and 873 deletions.
300 changes: 150 additions & 150 deletions CONTRIBUTING.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion check-nightly-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ let packageJsonPath = process.argv[2];
let latestVersion = process.argv[3];
let isCorrect = true;

fs.readFile(packageJsonPath, "utf8", function(err, packageJsonData) {
fs.readFile(packageJsonPath, "utf8", function (err, packageJsonData) {
if (err) {
return console.error("Error while reading file => " + err);
}
Expand Down
6 changes: 3 additions & 3 deletions check-stark-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ let packageJsonPath = process.argv[2];
let validVersion = process.argv[3];
let isCorrect = true;

fs.readFile("./modules.txt", "utf8", function(err, modulesData) {
fs.readFile("./modules.txt", "utf8", function (err, modulesData) {
if (err) {
return console.error("Error while reading file => " + err);
}

let starkPackagesArray = modulesData.split(/\s/).filter(value => {
let starkPackagesArray = modulesData.split(/\s/).filter((value) => {
return value !== "";
});

fs.readFile(packageJsonPath, "utf8", function(err, packageJsonData) {
fs.readFile(packageJsonPath, "utf8", function (err, packageJsonData) {
if (err) {
return console.error("Error while reading file => " + err);
}
Expand Down
6 changes: 3 additions & 3 deletions combine-packages-coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const fileNames = [
];

function replaceValuesInFile(fileName, valueReplacements) {
fs.readFile(fileName, "utf8", function(err, data) {
fs.readFile(fileName, "utf8", function (err, data) {
if (err) {
return console.error("Error while reading file => " + err);
}
Expand All @@ -21,7 +21,7 @@ function replaceValuesInFile(fileName, valueReplacements) {
result = result.replace(searchValueRegex, replacement.replaceValue);
}

fs.writeFile(fileName, result, "utf8", function(err) {
fs.writeFile(fileName, result, "utf8", function (err) {
if (err) {
return console.error(err);
} else {
Expand All @@ -33,7 +33,7 @@ function replaceValuesInFile(fileName, valueReplacements) {

let fileIndex = 0;

const nextStream = function() {
const nextStream = function () {
if (fileIndex === fileNames.length) {
return null;
}
Expand Down
46 changes: 23 additions & 23 deletions docs/COMMON_DEV_ERRORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ That's why referenced those common errors here for sharing our solutions.

> Table of contents
- [NGC](#ngcErrors)
- [TypeError: Cannot read property 'module' of undefined](#ngcErrorModuleUndefined)
- [TypeError: Cannot read property 'kind' of undefined](#ngcErrorKindUndefined)
- [Rollup](#rollupErrors)
- [NGC](#ngcErrors)
- [TypeError: Cannot read property 'module' of undefined](#ngcErrorModuleUndefined)
- [TypeError: Cannot read property 'kind' of undefined](#ngcErrorKindUndefined)
- [Rollup](#rollupErrors)

- [(!) Unresolved dependencies detected](#rollupErrorUnresolvedDeps)
- [(!) Unresolved dependencies detected](#rollupErrorUnresolvedDeps)

## <a id="ngcErrors"></a>NGC errors

Expand Down Expand Up @@ -52,26 +52,26 @@ Our mistake was we declared a function inside the decorate which triggered an er
```typescript
// The following code is not working
export class StarkApplicationConfigImpl implements StarkApplicationConfig {
@ValidateIf((appConfig: StarkApplicationConfig) => appConfig.loggingFlushDisabled !== true)
@IsDefined()
@IsString()
@autoserialize
public loggingFlushApplicationId?: string;
@ValidateIf((appConfig: StarkApplicationConfig) => appConfig.loggingFlushDisabled !== true)
@IsDefined()
@IsString()
@autoserialize
public loggingFlushApplicationId?: string;
}

// The following code is working
export class StarkApplicationConfigImpl implements StarkApplicationConfig {
@ValidateIf(StarkApplicationConfigImpl.validateIfLoggingFlushEnabled)
@IsDefined()
@IsString()
@autoserialize
public loggingFlushApplicationId?: string;
@ValidateIf(StarkApplicationConfigImpl.validateIfLoggingFlushEnabled)
@IsDefined()
@IsString()
@autoserialize
public loggingFlushApplicationId?: string;

// ...
// ...

public static validateIfLoggingFlushEnabled(instance: StarkApplicationConfig): boolean {
return instance.loggingFlushDisabled !== true;
}
public static validateIfLoggingFlushEnabled(instance: StarkApplicationConfig): boolean {
return instance.loggingFlushDisabled !== true;
}
}
```

Expand Down Expand Up @@ -108,10 +108,10 @@ You can simply add the missing dependencies as following:
// ...

const globals = {
// ...
"rxjs/observable/timer": "rxjs.observable.timer",
"rxjs/observable/throw": "rxjs.observable.throw"
// ...
// ...
"rxjs/observable/timer": "rxjs.observable.timer",
"rxjs/observable/throw": "rxjs.observable.throw"
// ...
};
```

Expand Down
10 changes: 5 additions & 5 deletions docs/E2E_TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ For more information go to [https://www.browserstack.com/automate](https://www.b

#### Prerequisites

- BrowserStack Account ([https://www.browserstack.com/](https://www.browserstack.com/))
- BrowserStack Account ([https://www.browserstack.com/](https://www.browserstack.com/))

#### Setup

Expand All @@ -66,8 +66,8 @@ _If you want to integrate BrowserStack in your own project you can have a look a

_For more documentation see:_

- _[https://github.com/angular/protractor/blob/master/lib/config.ts](https://github.com/angular/protractor/blob/master/lib/config.ts)_
- _[https://www.browserstack.com/automate/capabilities](https://www.browserstack.com/automate/capabilities)_
- _[https://github.com/angular/protractor/blob/master/lib/config.ts](https://github.com/angular/protractor/blob/master/lib/config.ts)_
- _[https://www.browserstack.com/automate/capabilities](https://www.browserstack.com/automate/capabilities)_

### Integrating BrowserStack with GitHub Actions

Expand All @@ -83,5 +83,5 @@ LocalError: Either another browserstack local client is running on your machine

BrowserStack Local was probably not stopped properly on the last run. You can resolve this by manually terminating it.

- MacOS: `pkill BrowserStack`
- Windows: Find the task in Task Manager and end it.
- MacOS: `pkill BrowserStack`
- Windows: Find the task in Task Manager and end it.
37 changes: 18 additions & 19 deletions docs/GITHUB_ACTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ name: Build and test on Node.js ${{ matrix.node_version }}
runs-on: ubuntu-latest
strategy:
matrix:
node_version: [ "10", "12" ]
node_version: ["10", "12"]

steps:
- name: Use Node.js ${{ matrix.node_version }}
Expand All @@ -37,7 +37,7 @@ All the information about this action can be found on [github.com/marketplace/ac
### actions/cache@v2
This official action can be used to improve performances of build plans.
This official action can be used to improve performances of build plans.
In Stark build plan, we use this action to cache the npm cache thanks to the following config:
```yaml
Expand All @@ -61,7 +61,7 @@ More documentation about this action be found in [GitHub documentation](https://

### actions/upload-artifact@v2 - actions/download-artifact@v2

These official actions can be used to share data between jobs. The uploaded content is available for download after
These official actions can be used to share data between jobs. The uploaded content is available for download after
the job execution.

See the following example to understand how these actions can be used:
Expand All @@ -80,7 +80,7 @@ See the following example to understand how these actions can be used:
path: dist/packages-dist
```
All the information about these actions can be found on [github.com/marketplace/actions/upload-a-build-artifact](https://github.com/marketplace/actions/upload-a-build-artifact)
All the information about these actions can be found on [github.com/marketplace/actions/upload-a-build-artifact](https://github.com/marketplace/actions/upload-a-build-artifact)
and [github.com/marketplace/actions/download-a-build-artifact](https://github.com/marketplace/actions/download-a-build-artifact).
## BrowserStack actions
Expand Down Expand Up @@ -126,7 +126,7 @@ steps:
## Coveralls Action
This action, provided by Coveralls itself, facilitates the usage of Coveralls in a CI plan.
This action, provided by Coveralls itself, facilitates the usage of Coveralls in a CI plan.
It requires a GitHub token to have a read access to the repo and, optionally, a path to lcov files.
In Stark, we have the following configuration:
Expand Down Expand Up @@ -154,7 +154,7 @@ jobs:
first_job:
# ..
if: github.event_name != 'schedule'
steps:
- name: A conditional task
run: npm run lint
Expand All @@ -171,9 +171,9 @@ The full documentation is available on [GitHub Docs](https://docs.github.com/en/

For instance, in `if` condition, the following functions can be used:

| Function name | Description | Example |
| ------------- | ----------- | ------- |
| contains - `contains(search, item)` | Returns `true` if `search` string contains `itemp` string | `contains(github.ref, 'dependabot')` |
| Function name | Description | Example |
| ---------------------------------------------------- | ---------------------------------------------------------- | -------------------------------------- |
| contains - `contains(search, item)` | Returns `true` if `search` string contains `itemp` string | `contains(github.ref, 'dependabot')` |
| startsWith - `startsWith(searchString, searchValue)` | Returns `true` if `searchString` starts with `searchValue` | `startsWith(github.ref, 'refs/tags/')` |

### Share variable in multiple tasks
Expand Down Expand Up @@ -205,16 +205,15 @@ GitHub Actions provide a set of environment variables that can be used in build

In Stark, the following vars are used to build:

| Variable name | Description |
| ------------- | ----------- |
| GITHUB_ACTIONS | Value is `true` when running in GitHub Actions CI |
| GITHUB_EVENT_NAME | Describes event type of the build (ie: `"schedule"`, `"pull_request"`...) |
| GITHUB_SHA | The commit SHA that triggered the workflow |
| GITHUB_REF | The branch or tag ref that triggered the workflow (ie: `refs/heads/feature-branch-1`)|
| GITHUB_REPOSITORY | The repository name for which GitHub Actions are triggered (ie: `NationalBankBelgium/Stark`) |
| GITHUB_ACTOR | The name of the person or app that initiated the workflow |
| secrets.GITHUB_TOKEN | GitHub token of the actor of the commit (used for push action) |

| Variable name | Description |
| -------------------- | -------------------------------------------------------------------------------------------- |
| GITHUB_ACTIONS | Value is `true` when running in GitHub Actions CI |
| GITHUB_EVENT_NAME | Describes event type of the build (ie: `"schedule"`, `"pull_request"`...) |
| GITHUB_SHA | The commit SHA that triggered the workflow |
| GITHUB_REF | The branch or tag ref that triggered the workflow (ie: `refs/heads/feature-branch-1`) |
| GITHUB_REPOSITORY | The repository name for which GitHub Actions are triggered (ie: `NationalBankBelgium/Stark`) |
| GITHUB_ACTOR | The name of the person or app that initiated the workflow |
| secrets.GITHUB_TOKEN | GitHub token of the actor of the commit (used for push action) |

All the information about the environment variables can be found in [official GitHub documentation](https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables).

Expand Down
50 changes: 25 additions & 25 deletions docs/stark-build/NG_CLI_BUILD_CUSTOMIZATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,16 @@ your code and this will be analyzed when your application bundle is being built

The global variables available at compilation time are the following:

- `ENV` which indicates the current environment: `"development"` or `"production"`
- `HMR` which indicates whether the Hot Module Replacement support is enabled (true/false).
- `ENV` which indicates the current environment: `"development"` or `"production"`
- `HMR` which indicates whether the Hot Module Replacement support is enabled (true/false).

Since the DefinePlugin defines those variables as global, you can use them everywhere in your code so you can, for example, determine on which
environment your app is currently running and execute some logic only on that specific environment:

```typescript
// if true, your app is running in development environment
if (ENV === "development") {
/* the code inside this block will be executed only in development */
/* the code inside this block will be executed only in development */
}
```

Expand Down Expand Up @@ -179,7 +179,7 @@ This is why knowing the target environment at compilation time is useful. You ca
// this check is translated to "if (false)" when ENV is "production"
// allowing Webpack to identify it as dead code and so remove it
if (ENV === "development") {
/* the code inside this block will only be included in development */
/* the code inside this block will only be included in development */
}
```

Expand All @@ -194,32 +194,32 @@ that you can access in your template to customize it. For example:

```html
<html lang="en">
<head>
<!-- Use the application name from StarkAppMetadata as the Page title -->
<title><%= htmlWebpackPlugin.options.starkAppMetadata.name %></title>
</head>
<body>
Some content here
</body>
<head>
<!-- Use the application name from StarkAppMetadata as the Page title -->
<title><%= htmlWebpackPlugin.options.starkAppMetadata.name %></title>
</head>
<body>
Some content here
</body>
</html>
```

This is the information from HtmlWebpackPlugin that is accessible in the template:

- **options:** all options that were passed to the plugin including plugin's own options as well as Stark custom data containing the following:
- **metadata:**
- **TITLE:** Default title for Stark based apps: "Stark Application by @NationalBankBelgium"
- **BASE_URL:** The base URL of the current build
- **IS_DEV_SERVER:** Whether the current build is served locally with the development server
- **HMR:** Whether the current build has HMR enabled
- **AOT:** Whether the current build was generated with AOT compilation enabled
- **E2E:** Whether the current build was generated with the E2E configuration
- **WATCH:** Whether the option to rebuild on changes is enabled
- **TS_CONFIG_PATH:** Path to the application's `tsconfig` file as defined in the `angular.json`
- **ENV:** The environment of the current build: `production` or `development`
- **environment:** The specific target used for the current build: `hmr`, `dev`, `e2e.prod` or `prod`
- **starkAppMetadata:** the Stark metadata of the application available in the `src/stark-app-metadata.json` file
- **starkAppConfig:** the Stark specific configuration for the application available in the `src/stark-app-config.json` file
- **options:** all options that were passed to the plugin including plugin's own options as well as Stark custom data containing the following:
- **metadata:**
- **TITLE:** Default title for Stark based apps: "Stark Application by @NationalBankBelgium"
- **BASE_URL:** The base URL of the current build
- **IS_DEV_SERVER:** Whether the current build is served locally with the development server
- **HMR:** Whether the current build has HMR enabled
- **AOT:** Whether the current build was generated with AOT compilation enabled
- **E2E:** Whether the current build was generated with the E2E configuration
- **WATCH:** Whether the option to rebuild on changes is enabled
- **TS_CONFIG_PATH:** Path to the application's `tsconfig` file as defined in the `angular.json`
- **ENV:** The environment of the current build: `production` or `development`
- **environment:** The specific target used for the current build: `hmr`, `dev`, `e2e.prod` or `prod`
- **starkAppMetadata:** the Stark metadata of the application available in the `src/stark-app-metadata.json` file
- **starkAppConfig:** the Stark specific configuration for the application available in the `src/stark-app-config.json` file

#### [BaseHrefWebpackPlugin](https://github.com/dzonatan/base-href-webpack-plugin "BaseHrefWebpackPlugin")

Expand Down
Loading

0 comments on commit e97fbe3

Please sign in to comment.