Skip to content

Commit

Permalink
[Release] v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ptkdev committed Jun 12, 2018
1 parent 2e759b8 commit 2392096
Show file tree
Hide file tree
Showing 15 changed files with 289 additions and 5 deletions.
46 changes: 46 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"env":
{
"browser": true,
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions":
{
"sourceType": "module",
"ecmaVersion": 2017
},
"plugins": [
"snakecasejs"
],
"rules":
{
"indent": [
"error",
4,
{
"SwitchCase": 1
}
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"double"
],
"semi": [
"error",
"always"
],
"no-console": [
"warn"
],
"no-constant-condition": [
"warn"
],
"snakecasejs/snakecasejs": "warn"
}
}
4 changes: 4 additions & 0 deletions .foreverignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/**/*.js
log/*
logs/*
*.log
3 changes: 3 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"esversion": 6
}
8 changes: 8 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Patryk Rzucidlo (@ptkdev) support@ptkdev.io
[![https://ptkdev.it](https://ptkdev.it/img/ptkdev_patryk_rzucidlo_avatar_150.png)](https://ptkdev.it)

`Lead Developer - June 12, 2018`
* Portfolio: [https://ptkdev.it](https://ptkdev.it/)
* Blog: [https://blog.ptkdev.it](https://blog.ptkdev.it)
* Twitter: [https://twitter.com/ptkdev](https://twitter.com/ptkdev)
* GitHub: [https://github.com/ptkdev](https://github.com/ptkdev)
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# v1.0.0 (June 12, 2018)

* First Release.
* New: logo from [freepik](https://it.freepik.com/) (premium account)
15 changes: 15 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#### Setup
1. Add dependencies on `package.json`
```
"dependencies": {
"json-token-replace": "^1.0.0",
}
```

2. In your code:
```
const Jtr = require("json-token-replace");
const jtr = new Jtr();
let json_output = jtr.replace("./json_with_tokens.json", "./json.json");
```
39 changes: 39 additions & 0 deletions ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
### Versions

Replace the values below with your own:

- **Version:** v1.0.0
- **Node Version:** v8.9 (Plugin require >= 7.6)
- **Operating System:** Ubuntu 14.04
- **Browser:** Google Chrome 64


### Expected Behavior

Please describe the program's expected behavior.

```
```

### Actual Behavior

Please describe the program's actual behavior. Please include any stack traces
or log output in the back ticks below.

```
```

### Steps to Reproduce

Please include the steps the reproduce the issue, numbered below. Include as
much detail as possible.

1. ...
2. ...
3. ...

### Screenshots (Optional)

If the error is graphical in nature it is helpful to provide a screenshot.
6 changes: 3 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
{one line to give the program's name and a brief idea of what it does.}
Copyright (C) 2017 PTKDev

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

<program> Copyright (C) <year> <name of author>
{project} Copyright (C) 2017 Patryk Rzucidlo
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
Expand Down
54 changes: 52 additions & 2 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,2 +1,52 @@
# json-token-replace
Replace token string {{hello}} in json with value from another json where key is token {"hello":"bye"}
<p align="center"><a href="https://www.npmjs.com/package/json-token-replace" alt="Logo"><img src="https://ptkdev.it/img/github/json-token-replace.png"></a></p>

<p align="center"><h1 align="center">json-token-replace</h1></p>

<p align="center"><a href="#" alt="License"><img src="https://img.shields.io/badge/license-GLPv3-brightgreen.svg"></a>
<a href="https://github.com/ptkdev/json-token-replace/releases" alt="Version"><img src="https://img.shields.io/badge/version-v1.0.0-lightgrey.svg"></a>
<a href="https://slack.ptkdev.io" alt="Slack Chat"><img src="https://img.shields.io/badge/chat%20on-slack-orange.svg"></a>
<a href="http://blog.ptkdev.io" alt="Blog"><img src="https://img.shields.io/badge/blog-medium-2AE176.svg"></a>
<a href="https://twitter.com/ptkdevio" alt="Twitter"><img src="https://img.shields.io/badge/twitter-ptkdevio-2AA3EF.svg"></a>
<a href="mailto:support@ptkdev.io" alt="Support: support@ptkdev.io"><img src="https://img.shields.io/badge/help-support@ptkdev.io-fbbc05.svg"></a></p>
<p align="center"><a href="http://patreon.ptkdev.io" alt="Patreon Backer"><img src="https://img.shields.io/badge/donate-patreon-F87668.svg"></a> <a href="http://paypal.ptkdev.io" alt="Paypale Donate"><img src="https://img.shields.io/badge/donate-paypal-46AFE0.svg"></a></p>

## What does it do
Replace the token string {{hello}} in json with value from another json where key is token {"hello":"bye"}

#### Example:
Json with tokens:
`{ "john":"Alex" }`

Json:
`{ "text": "hello {{john}}"}`

Output:
`{ "text": "hello Alex"}`

## Features
* [] Easy to use

## Fast setup
1. Add dependencies on `package.json`
```
"dependencies": {
"json-token-replace": "^1.0.0",
}
```
2. In your code:
```
const Jtr = require("json-token-replace");
const jtr = new Jtr();
let json_output = jtr.replace("./json_with_tokens.json", "./json.json");
```
3. If work add star :star: at this project :heart:
4. If you want help me: <b><a href="http://paypal.ptkdev.io">donate on paypal</a></b> or become a <b><a href="http://patreon.ptkdev.io">backer on patreon</a></b>.

For advanced configuration see [INSTALL.md](https://github.com/ptkdev/json-token-replace/blob/master/INSTALL.md).

<h1>License</h1>

GNU GENERAL PUBLIC LICENSE

Copyright (c) 2018 Patryk Rzucidło (PTKDev)
2 changes: 2 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Roadmap
Nothing
5 changes: 5 additions & 0 deletions example/json_sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"text1":"i love {{fortnite}}",
"text2":"good{{hello}}",
"text3":"opensource is {{github}}"
}
5 changes: 5 additions & 0 deletions example/json_tokens.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"hello":"bye",
"fortnite":"league of legends",
"github":"microsoft"
}
27 changes: 27 additions & 0 deletions example/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Example and Test
* =====================
* How this utility work
*
* @author: Patryk Rzucidlo [@ptkdev] <support@ptkdev.io> (https://ptkdev.it)
* @license: This code and contributions have 'GNU General Public License v3'
* @version: 0.1
* @changelog: 0.1 initial release
*
*/

// If you use npm repository: require("json-token-replace");
let Jtr = require("../main");
let jtr = new Jtr();

// Import json with token<->value
let json_tokens = require("./json_tokens.json");

// Import full json with token {{test}}
let json_sample = require("./json_sample.json");

// This is where the magic happens
let json_output = jtr.replace(json_tokens, json_sample);

// Test output
console.log(json_output);
27 changes: 27 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Utils: json-token-replace
* =====================
* Replace the token string {{hello}} in json with value from another json where key is token {"hello":"bye"}
*
* @author: Patryk Rzucidlo [@ptkdev] <support@ptkdev.io> (https://ptkdev.it)
* @license: This code and contributions have 'GNU General Public License v3'
* @version: 0.1
* @changelog: 0.1 initial release
*
*/
class Utils {
constructor() {

}

replace(json_tokens, json_input) {
let json_string = JSON.stringify(json_input);
for (var key in json_tokens) {
json_string = json_string.replace("{{" + key + "}}", json_tokens[key]);
}

return JSON.parse(json_string);
}
}

module.exports = Utils;
49 changes: 49 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "json-token-replace",
"version": "1.0.0",
"main": "main.js",
"author": "Patryk Rzucidlo [@ptkdev] <support@ptkdev.io> (https://ptkdev.it)",
"license": "GPL-3.0",
"homepage": "https://ptkdev.io",
"bugs": {
"url": "https://github.com/ptkdev/json-token-replace/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/ptkdev/json-token-replace.git"
},
"scripts": {
"start": "node main.js",
"example": "node example/test.js",
"lint": "eslint ./ --cache --ignore-pattern .gitignore --fix",
"precommit-lint-check": "echo 'Pre-commit lint checks...' && exit 0"
},
"pre-commit": [
"precommit-lint-check",
"lint"
],
"keywords": [
"ptkdev",
"json",
"token",
"webtokens"
],
"dependencies": {
"colors": "^1.2.1",
"eslint": "^4.19.1",
"path": "^0.12.7",
"request": "^2.85.0"
},
"engines": {
"node": ">=7.6.0"
},
"devDependencies": {
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.11.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.7.0",
"eslint-plugin-standard": "^3.1.0",
"eslint-plugin-snakecasejs": "^1.0.0",
"pre-commit": "^1.2.2"
}
}

0 comments on commit 2392096

Please sign in to comment.