Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fa8d223311 | |||
| ab7a43a93f | |||
| d9ee930204 | |||
| abfeea00ec | |||
| b7333cc184 | |||
| 338d2033bb | |||
| ad92cd2899 | |||
| 3a0191a5d6 |
12
Dockerfile
12
Dockerfile
@@ -3,7 +3,7 @@ LABEL maintainer="sombochea@cubetiqs.com"
|
|||||||
|
|
||||||
VOLUME [ "/app/data" ]
|
VOLUME [ "/app/data" ]
|
||||||
|
|
||||||
ENV INPUT_FILE './data/people.xlsx'
|
ENV INPUT_FILE './data/source.xlsx'
|
||||||
ENV OUTPUT_PATH './data/outputs'
|
ENV OUTPUT_PATH './data/outputs'
|
||||||
ENV MAPPER_FILE './data/mapper.json'
|
ENV MAPPER_FILE './data/mapper.json'
|
||||||
|
|
||||||
@@ -11,6 +11,12 @@ WORKDIR /app
|
|||||||
|
|
||||||
COPY . /app
|
COPY . /app
|
||||||
|
|
||||||
RUN yarn
|
RUN npm install
|
||||||
|
|
||||||
CMD [ "node" , "index.js"]
|
RUN npm link
|
||||||
|
|
||||||
|
RUN ln -s $(which excel2json-xlsx) /usr/bin/x2j
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/usr/bin/x2j"]
|
||||||
|
|
||||||
|
CMD [ "--help" ]
|
||||||
2
Makefile
2
Makefile
@@ -9,7 +9,7 @@ run:
|
|||||||
docker run --rm -t ${DOCKER_IMAGE}
|
docker run --rm -t ${DOCKER_IMAGE}
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
@echo "Pubishing docker image..."
|
@echo "Publishing docker image..."
|
||||||
docker push ${DOCKER_IMAGE}
|
docker push ${DOCKER_IMAGE}
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
|
|||||||
20
README.md
20
README.md
@@ -1,11 +1,13 @@
|
|||||||
# excel2json
|
# excel2json
|
||||||
|
|
||||||
[](https://github.com/CUBETIQ/excel2json/actions/workflows/npm-publish.yml)
|
[](https://github.com/CUBETIQ/excel2json/actions/workflows/npm-publish.yml)
|
||||||
[](https://github.com/CUBETIQ/excel2json/actions/workflows/docker-publish.yml)
|
[](https://github.com/CUBETIQ/excel2json/actions/workflows/docker-publish.yml)
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
- Read file excel to json
|
- Read file excel to json
|
||||||
- Custom mapping with custom columns and configs
|
- Custom mapping with custom columns and configs
|
||||||
- Custom props
|
- Custom props
|
||||||
|
- Docker suppport
|
||||||
|
|
||||||
# Install
|
# Install
|
||||||
```shell
|
```shell
|
||||||
@@ -21,7 +23,21 @@ yarn add global excel2json-xlsx
|
|||||||
```
|
```
|
||||||
Usage
|
Usage
|
||||||
```shell
|
```shell
|
||||||
excel2json-xlsx -i people.xlsx -o exported.json
|
excel2json-xlsx -i source.xlsx -o exported.json
|
||||||
|
```
|
||||||
|
OR
|
||||||
|
```shell
|
||||||
|
npx excel2json -i source.xlsx -o exported.json
|
||||||
|
```
|
||||||
|
|
||||||
|
# [Docker Hub](https://hub.docker.com/r/cubetiq/excel2json)
|
||||||
|
***Pulling image***
|
||||||
|
```shell
|
||||||
|
docker pull cubetiq/excel2json
|
||||||
|
```
|
||||||
|
***Run container***
|
||||||
|
```shell
|
||||||
|
docker run --rm -it -v /my/path/data:/app/data cubetiq/excel2json -i ./data/source.xlsx -p true
|
||||||
```
|
```
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
|
|||||||
12
bin/cli.js
12
bin/cli.js
@@ -29,12 +29,18 @@ const options = yargs
|
|||||||
type: "string",
|
type: "string",
|
||||||
demandOption: false,
|
demandOption: false,
|
||||||
})
|
})
|
||||||
.argv;
|
.option("p", {
|
||||||
|
alias: "print",
|
||||||
|
describe: "Print the exported json to console",
|
||||||
|
type: "boolean",
|
||||||
|
demandOption: false,
|
||||||
|
}).argv;
|
||||||
|
|
||||||
const inputFile = options.input;
|
const inputFile = options.input;
|
||||||
const outputFile = options.output;
|
const outputFile = options.output;
|
||||||
const mapperFile = options.mapper;
|
const mapperFile = options.mapper;
|
||||||
const sheetName = options.sheet;
|
const sheetName = options.sheet;
|
||||||
|
const print = options.print;
|
||||||
|
|
||||||
const exported = excel2json({
|
const exported = excel2json({
|
||||||
inputFile: inputFile,
|
inputFile: inputFile,
|
||||||
@@ -42,3 +48,7 @@ const exported = excel2json({
|
|||||||
outputFile: outputFile,
|
outputFile: outputFile,
|
||||||
sheetName: sheetName,
|
sheetName: sheetName,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (print) {
|
||||||
|
console.log(exported);
|
||||||
|
}
|
||||||
|
|||||||
2
index.js
2
index.js
@@ -3,7 +3,7 @@ const excel2json = require("./excel2json");
|
|||||||
|
|
||||||
// called function export excel2json
|
// called function export excel2json
|
||||||
const exported = excel2json({
|
const exported = excel2json({
|
||||||
inputFile: "./data/people.xlsx"
|
inputFile: "./data/source.xlsx"
|
||||||
});
|
});
|
||||||
|
|
||||||
// output data from exported
|
// output data from exported
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "excel2json-xlsx",
|
"name": "excel2json-xlsx",
|
||||||
"version": "1.0.2",
|
"version": "1.0.4",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"excel",
|
"excel",
|
||||||
"json",
|
"json",
|
||||||
|
|||||||
Reference in New Issue
Block a user