# @plastichub/osr-sync

> Package to synchronize OSR, PP and PlasticHub directories and repositories

Latest version **0.3.8** (published 2024-06-18) · 0 weekly downloads

## Install

```sh
npm install @plastichub/osr-sync
pnpm add @plastichub/osr-sync
yarn add @plastichub/osr-sync
bun add @plastichub/osr-sync
```

Provides the command `osr-sync`.

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.8 |
| Published | 2024-06-18 |
| First published | 2020-09-06 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 20 |
| Unpacked size | 172.3 KB |
| Known vulnerabilities | 0 (+3 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | plastichubdev |

## Links

- npm: https://www.npmjs.com/package/@plastichub/osr-sync
- Repository: https://git.osr-plastic.org/osr-plastic/sync
- npm.io page: https://npm.io/package/@plastichub/osr-sync

## Dependencies (20)

- [q](https://npm.io/package/q.md) ^1.4.1
- [jsome](https://npm.io/package/jsome.md) ^2.3.24
- [tslib](https://npm.io/package/tslib.md) ^1.8.1
- [yargs](https://npm.io/package/yargs.md) ^17.0.1
- [globby](https://npm.io/package/globby.md) ^6.1.0
- [lodash](https://npm.io/package/lodash.md) ^4.16.6
- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [pkg-dir](https://npm.io/package/pkg-dir.md) ^2.0.0
- [archiver](https://npm.io/package/archiver.md) ^5.3.1
- [bluebird](https://npm.io/package/bluebird.md) ^3.5.1
- [json2csv](https://npm.io/package/json2csv.md) ^5.0.1
- [showdown](https://npm.io/package/showdown.md) ^1.9.1
- [yargonaut](https://npm.io/package/yargonaut.md) ^1.1.2
- [googleapis](https://npm.io/package/googleapis.md) ^59.0.0
- [typescript](https://npm.io/package/typescript.md) ^4.7.4
- [escape-html](https://npm.io/package/escape-html.md) ^1.0.3
- [@plastichub/fs](https://npm.io/package/@plastichub/fs.md) ^0.13.39
- [markdown-table](https://npm.io/package/markdown-table.md) ^2.0.0
- [@plastichub/core](https://npm.io/package/@plastichub/core.md) ^0.2.6
- [@plastichub/osr-cli-commons](https://npm.io/package/@plastichub/osr-cli-commons.md) ^0.4.9

## Recent versions

- 0.3.8 (latest) — 2024-06-18
- 0.3.7 — 2024-06-11
- 0.3.6 — 2024-05-24
- 0.3.5 — 2024-01-20
- 0.3.4 — 2023-12-02
- 0.3.3 — 2023-09-17
- 0.3.2 — 2023-09-16
- 0.3.1 — 2023-09-12
- 0.2.9 — 2023-09-12
- 0.2.8 — 2023-07-21
- 0.2.7 — 2023-07-20
- 0.2.6 — 2023-07-16
- 0.2.5 — 2023-06-01
- 0.2.4 — 2023-04-09
- 0.2.3 — 2023-04-09
- … 20 more at https://npm.io/package/@plastichub/osr-sync/versions

## README

# Sync folders

## Installation

``` sh
npm install -g @plastichub/osr-sync
```

## Usage

### sync (folder)

``` sh
 osrc-sync --clear=true --source='./products/lydia-v4' --target='../plastic-hub-public/products/lydia-v4_test' --debug=true --profile='./osr-sync.json'
```

where `` `osr-sync.json` `` is

``` json
{
    "debug": false,
    "matching": [
        "*.json",
        "*.md",
        "*.yaml",
        "*.csv",
        "*.xls",
        "cad/**",
        "media/gallery/**",
        "resources/**",
        "drawings/**",
        "vendor/**",
        "resources/**",
        "laser/**",
        "howto/**",
        "renderings/**",
        "!./.git/**",
        "!./node_modules/**",
        "!./_MACOSX/**",
        "!./production/**",
        "!./templates/**",
        "!./.*/**",
        "!./**/*.zip",
        "!./**/*.tar"
    ]
}
```

#### Sync: Rename output nodes

Additionally, output paths can be manipulated specifying the --renamer argument:

``` sh
osr-sync --renamer="./.laser-renamer.js" --clear=true --source='./products/sheetpress-cell' --target='../../rosa/laser_sheetpress' --debug=true --profile="./.osr-sync-laser-sheetpress.json"
```

where ´osr-sync-laser-sheetpress.json´ is:

``` json
{
    "debug": false,
    "matching": [
        "laser/**"
    ]
}
```

and ´./.laser-renamer.js´ is :

``` js
exports.default = function (from, to) {
    return to.replace("Ferro", "Steel").replace("Inox", "Stainless");
}
```

Another example is to read command line arguments

``` js

function getQuantity() {
    for (let i = 0; i < process.argv.length; i++) {
        if (process.argv[i].indexOf('--quantity') !== -1) {
            return process.argv[i].split('=')[1];
        }
    }
}

exports.default = function (from, to) {
    const sets = getQuantity();
    const parts = to.split("_");
    const partsLength = parts.length;
    const qtyToken = parts[partsLength - 3];
    if (qtyToken) {
        let qty = parseInt(qtyToken.replace('x', '')) * sets;
        parts[partsLength - 3] = 'x' + qty;
        return parts.join('_');
    }
    return null;
}
```

In this case, the script renames SP1.0_001_Lower_Rib_1A_**x1**_6.0mm_Ferro.DXF to SP1.0_001_Lower_Rib_1A_**[CLI-Arg --quantity]**_6.0mm_Ferro.DXF
The feature is useful to strip custom filename syntax, or just batch rename stuff.

### Zip

Same as sync, a profile contains glob patterns for includes and excludes. Multiple sources can be hinged together at one root using the cwd argument

``` sh
node ./node_modules/osr-sync/dist/main.js zip --clear=true --source='./products/zoe' --source='./products/components/hal' --cwd="./" --target='../out.zip'  --debug=true --profile='./.osr-sync-zip.json'
```

or when used globally

``` sh
osr-sync zip --clear=true --source='./products/zoe' --source='./products/components/hal' --cwd="./" --target='../out.zip'  --debug=true --profile='./.osr-sync-zip.json'
```


### Todos

 - [-] CLI:Sync: Support component level firmware config patches (overlays)
 - [-] jekyll2mc
 - [-] pack'n go for laser vendor template/renamer (generate folders, by material and thickness)
 - [ ] Shell Extension (OS context menu)
 - [-] Sheets2*: URL, cell transform (using config)
 - [ ] Drive
 - [-] SW Configs => CAD = Laser => Report (@osr-cad & @osr-deploy)
 - [ ] Sync osr-template folder per dist (@osr-templates & @osr-deploy)

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