Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 94: Added xlsx-renderer-cli #97

Merged
merged 9 commits into from
Dec 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/xlsx-renderer-cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: xlsx-renderer-cli

on: [push, pull_request] # todo path limitation

defaults:
run:
working-directory: ./packages/xlsx-renderer-cli

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
# node-version: [8.x, 9.x, 10.x, 11.x, 12.x, 13.x, 14.x] # version 8 and 9 isn't supported in ExcelJS as default - may I resolve it further (or ignore)
node-version: [10.x, 11.x, 12.x, 13.x, 14.x]

steps:
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # @v2.3.4; Using hash for security purposes
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@c6fd00ceb9747fb23ffdf72987450a2664414867 # @v2.1.2; Using hash for security purposes
with:
node-version: ${{ matrix.node-version }}
- name: npm install
run: npm ci
- name: Check lint
run: npm run lint
- name: Check build
run: npm run build

# @see https://github.com/Siemienik/XToolset/issues/102
# - name: Check unit & integration tests with coverage
# run: npm run test
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@ It allows you to import xlsx spreadsheet file with data into your system with de

### The `xlsx-renderer`

Makes generating excel files as simple as possible - it is enough one line to generate pretty customizable spreadsheet file.
Makes generating spreadsheet files as simple as possible - it is enough one line to generate pretty customizable spreadsheet file.

[Read more :arrow_right:](packages/xlsx-renderer)

### The `xlsx-renderer-cli`

[![NPM](https://img.shields.io/npm/l/xlsx-renderer)![npm](https://img.shields.io/npm/v/sxr)](https://www.npmjs.com/package/sxr) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/siemienik/xtoolset/xlsx-renderer-cli)](https://github.com/Siemienik/xtoolset/actions)

Generate spreadsheets files following by the `template` with `view model` from command line.

[Read more :arrow_right:](packages/xlsx-renderer-cli)

### Samples

Samples are available in a flat structure, and they are named by using : `[package_name]+[technology]` - for instance `xlsx-import+nodejs+ts`.
Expand Down
5 changes: 5 additions & 0 deletions packages/xlsx-renderer-cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
lib/
node_modules/
coverage/
.nyc_output/
.idea/
6 changes: 6 additions & 0 deletions packages/xlsx-renderer-cli/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"printWidth": 120,
"trailingComma": "all",
"singleQuote": true,
"tabWidth": 4
}
21 changes: 21 additions & 0 deletions packages/xlsx-renderer-cli/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Siemienik Paweł

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
93 changes: 93 additions & 0 deletions packages/xlsx-renderer-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
[![NPM](https://img.shields.io/npm/l/xlsx-renderer)![npm](https://img.shields.io/npm/v/sxr)](https://www.npmjs.com/package/sxr) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/siemienik/xtoolset/xlsx-renderer-cli)](https://github.com/Siemienik/xtoolset/actions)

[![Join the chat at https://gitter.im/Siemienik/community](https://badges.gitter.im/Siemienik/community.svg)](https://gitter.im/Siemienik/community)

# XLSX-Renderer-CLI:

Command line of [xlsx-renderer](../xlsx-renderer). Generates spreadsheet files based on the template with view model.

## Global installation

```
# Install globally:

npm i -g sxr

# Usages:

sxr --model vm.json template.xlsx > output.xlsx
```

## Local installation

1. Install package

```
# install globally:
npm i --save sxr

# usages:
node_modules/.bin/sxr --model vm.json template.xlsx > output.xlsx
```

2. Additionally, able to use with packages.json scripts:

`package.json:`
```js
scripts:{
"generate-xlsx":"sxr --model vm.json template.xlsx > output.xlsx"
}
```

bash:
```
npm run generate-xlsx
```

# Examples:

```
cat vm.json | sxr template.xlsx > output.xlsx

sxr template.xlsx "{\"jsonData\":true}" > output.xlsx

sxr --model vm.json template.xlsx > output.xlsx

sxr --model vm.json -o output.xlsx template.xlsx

sxr -o output.xlsx template.xlsx "{\"jsonData\":true}"
```

# Command body:

`sxr [options] <template> [model]`


## Arguments

* `<template>` indicate the template file,
* `[model]` view model as a json used to generate a spreadsheet,

## Options

* `-o --output <filename>` write to filename
* `-m --model <filename>` read filename as a `[model]` (using both is denied)
* `-o --output <filename>` write result into filename

## Output

`sxr` out-of-a-box pushes generated files into `stdout`, to save it into a file please to append ` > filename.xlsx`.

Library allowing also save output into file by using option `-o --output <filename>`

It is also allowed using pipe parameter to forward generated file into another command.

# The template file

The template structure inherit from `xlsx-renderer`. Please use link below for more information:

[**Documentation**](https://github.com/Siemienik/XToolset/tree/master/packages/xlsx-renderer#documentation)

---

[LICENSE](LICENSE)
Loading