# @personio/scripts

> A set of node scripts to auto-generate files. Currently, the library includes two: **request** and **translations**. See more information bellow.

Latest version **7.2.7** (published 2023-07-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install @personio/scripts
pnpm add @personio/scripts
yarn add @personio/scripts
bun add @personio/scripts
```

Provides the command `personio-scripts`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 7.2.7 |
| Published | 2023-07-12 |
| First published | 2020-10-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 64.5 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | personio-npm-ci, shovanco, riain-personio, remipersonio, personio_ci, rishatfrompersonio, rodrigopagnuzzi |

## Links

- npm: https://www.npmjs.com/package/@personio/scripts
- npm.io page: https://npm.io/package/@personio/scripts

## Dependencies (9)

- [axios](https://npm.io/package/axios.md) ^0.27.2
- [yargs](https://npm.io/package/yargs.md) ^16.2.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [js-yaml](https://npm.io/package/js-yaml.md) ^3.14.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^10.0.0
- [jsonpath](https://npm.io/package/jsonpath.md) ^1.1.1
- [commander](https://npm.io/package/commander.md) ^6.1.0
- [quicktype-core](https://npm.io/package/quicktype-core.md) ^6.0.70
- [@manifoldco/swagger-to-ts](https://npm.io/package/@manifoldco/swagger-to-ts.md) ^2.1.0

## Recent versions

- 7.2.7 (latest) — 2023-07-12
- 7.2.6 — 2023-07-06
- 7.2.5 — 2023-07-03
- 7.2.4 — 2023-02-14
- 7.2.3 — 2022-08-22
- 7.2.2 — 2022-08-19
- 7.2.1 — 2022-08-18
- 7.2.0 — 2022-08-18
- 7.1.2 — 2022-07-20
- 7.0.2 — 2022-07-12
- 7.0.1 — 2022-06-28
- 7.0.0 — 2022-06-28
- 6.2.5 — 2022-05-20
- 6.2.4 — 2022-05-18
- 6.2.3 — 2022-05-18
- … 30 more at https://npm.io/package/@personio/scripts/versions

## README

# @personio/scripts

A set of node scripts to auto-generate files. Currently, the library includes
two: **request** and **translations**. See more information bellow.

## Installation

Run

```bash
yarn add -D @personio/scripts
```

## CLI options

```
-s, --script <script>        // *Required. The script you want to run. Can be either translations or request.

-o, --outputDir <directory>  // *Only valid for the request script. The path of the directory you want to generate the request helper files.
                             //  The default is src/helpers/request,

-i, --inputFile <type>       // *Only valid for the request script. The path of your openapi.yaml file.
                             //  The default is openapi.yaml

-n, --requestName <name>     // *Only valid for the request script. Create the request helper naming based on this options.
                             //  It accepts three variants: operationId, summary or url, Default is operationId.

--noResponseMocks            // *Only valid for the request script.
                             //  Disable the creation of the response mocks.

--pact                       // Only valid for the request script.
                            // Use to generate pact file

--retrieveDataFromResponse   // Only valid for the request script.
                             // Use if your project is using the retrieveDataFromResponse parameter in the @personio/requests config

-d, --domain <domain>        // *Required. Only valid for the translations script.
                             //  Your teams domain, where we can find the translations.json file.

--fromLocalPhraseServer      // *Only valid for the translations script.
                             //  Retrieves the translations from http://localhost:9800 instead of production.
                             //  Don't forget to run the synchronisation pipeline before going to production!

--fromLocalTranslationsFile <filepath> // *Only valid for the translations script.
                                       //  [DANGEROUS] Retrieves the translations from a local JSON file (in i18next format) instead of production.
                                       //  The usage of the `--fromLocalTranslationsFile` is dangerous since PhraseApp might
                                       //  not contain the keys provided in the input file. It's supposed to be used only by the tooling
                                       //  that ensures that all keys are in place (e.g. VSCode Personio Extension).
```

## Description

As mentioned, we have two different scripts included in the library:

- translations
- request

### translations

This script generates four files:

- `__mocks__/translationsMock.ts` file including all the english translations to
  be injected into your test configuration.
- `config/translations.json` file including the english translations in JSON
  format. It can be served locally for your i18n configuration to speed up
  development.
- `translations.ts` file including the types from the translations of your
  team's domain.
- `react18next-resources.d.ts` file that declares your `react18next` resource
  types to enforce type safety on the translation key usage. **Note :** This
  will only works for `react-18next` version `11` and upwards.

#### Example

```bash
 personio-scripts -s translations -d recruiting
```

- After running the script, you can check the generated files in the path
  `src/translations.ts` and the `src/__mocks__/translationsMock.ts`

### request

This script generates three files, all based on the `openApi.yaml`.

- `types.ts` file, which includes:
  - query keys `enum` for using with `react-query`
  - the types from your request responses
- `requestHelper.ts` file with functions wrapped in the @personio/request
  library based on the APIs URL.
- `responseMocks.ts` file with all the response examples provided. **NOTE**:
  Double check the name of all your examples as it's required to have a valid
  javascript syntax otherwise the script will fail.

#### Example

```bash
 personio-scripts -s request -n summary
```

- After running the script and you haven't changed the output directory, you can
  check the generated files in the path `src/helper/request/requestHelper.ts`
  and the `src/helper/request/types.ts`.

  **Note:**

- The `-n, --requestName <name>` option accepts three variants: **operationId**,
  **summary** or **url**.
  - **operationId**: Takes this property as is. If you intend to use it, you
    should make sure this is a valid function name for javascript. For instance,
    the property is already in _camelCase_.
  - **summary**: Takes the summary property, remove the spacing and prepends the
    http method. Eg:
    - ```yaml
      get:
        summary: Preferences settings
      ```
    - the function will be called: `getPreferencesSettings`
  - **url**: Takes the url, split based on the `/` ,takes the last 3 names and
    prepends the http method. Eg:
    - ```yaml
      /api/v1/preferences:
        get: ...
      ```
    - the function will be called: `getApiV1Preferences`

---
_Source: https://npm.io/package/@personio/scripts · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
