This repository has been archived by the owner on Sep 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ed20680
Showing
28 changed files
with
4,850 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[{package.json,*.yml}] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"env": { | ||
"es6": true, | ||
"node": true, | ||
"jest/globals": true | ||
}, | ||
"extends": [ | ||
"airbnb-base", | ||
"plugin:jest/recommended", | ||
"plugin:prettier/recommended", | ||
"prettier", | ||
"prettier/standard" | ||
], | ||
"plugins": [ | ||
"jest", | ||
"prettier" | ||
], | ||
"rules": { | ||
"arrow-body-style" : [0], | ||
"arrow-parens": [0], | ||
"camelcase": [0], | ||
"class-methods-use-this": [0], | ||
"comma-dangle": [0], | ||
"eqeqeq": [1], | ||
"max-len": [0], | ||
"new-cap": [0], | ||
"no-console": [0], | ||
"no-param-reassign" : [0], | ||
"no-underscore-dangle": [0], | ||
"prefer-arrow-callback": [0], | ||
"prefer-destructuring": [0], | ||
"quotes": [2, "double"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test-collector | ||
node_modules | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Spendesk Collector Template | ||
|
||
This is a scaffolding tool for creating and maintaining Spendesk Collectors. It comes with base directory and file structure, default configuration and documentation files templates. | ||
|
||
## Installation | ||
|
||
Install it as a global node package: | ||
|
||
``` | ||
npm install -g spendesk-collector-template | ||
``` | ||
|
||
Now you can use the `spendesk-collector-template` command to generate or update collector base code. | ||
|
||
## Creating new collector | ||
|
||
``` | ||
spendesk-collector-template [working-path] | ||
``` | ||
|
||
You can execute this command over new directory which will be created, or run it inside an empty, already existing directory. | ||
|
||
When run script will ask you couple of questions interactively to fill in templates with data. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#! /usr/bin/env node | ||
|
||
const argv = require("minimist")(process.argv.slice(2)); | ||
const gulp = require("gulp"); | ||
const conflict = require("gulp-conflict"); | ||
const template = require("gulp-template"); | ||
|
||
const collectorTemplateVersion = require("../package").version; | ||
const promptUser = require("../src/prompt-user"); | ||
const loadJsonFile = require("../src/load-json-file"); | ||
const combineData = require("../src/combine-data"); | ||
|
||
if (argv.v || argv.version) { | ||
console.log("spendesk-collector-template version:", collectorTemplateVersion); | ||
process.exit(0); | ||
} | ||
|
||
const targetPath = argv._[0] || "./"; | ||
|
||
const existingManifestJson = loadJsonFile(targetPath, "manifest.json"); | ||
const existingPackageJson = loadJsonFile(targetPath, "package.json"); | ||
|
||
promptUser(argv, existingManifestJson, existingPackageJson).then( | ||
userAnswers => { | ||
const data = combineData( | ||
argv, | ||
userAnswers, | ||
existingManifestJson, | ||
existingPackageJson | ||
); | ||
|
||
gulp | ||
.src(`${__dirname}/../template/**/*`, { dot: true }) | ||
.pipe(template(data, { interpolate: /<%=([\s\S]+?)%>/g })) | ||
.pipe(conflict(targetPath)) | ||
.pipe(gulp.dest(targetPath)); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module.exports = { | ||
"collectCoverage": true, | ||
"collectCoverageFrom": [ | ||
"src/**/*.{js,jsx}", | ||
"template/**/*.{js,jsx}", | ||
"bin/**/*.{js,jsx}", | ||
], | ||
"coveragePathIgnorePatterns": [ | ||
"/node_modules/", | ||
"/tests/" | ||
], | ||
"coverageThreshold": { | ||
"global": { | ||
"branches": 40, | ||
"functions": 40, | ||
"lines": 40, | ||
"statements": 40 | ||
} | ||
}, | ||
"testEnvironment": "node", | ||
"testMatch": ["<rootDir>/tests/units/**/*.spec.js", "<rootDir>/tests/integrations/**/*.spec.js"], | ||
"transformIgnorePatterns": ["[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"], | ||
"testPathIgnorePatterns": [ | ||
"<rootDir>/(dist|docs|dll|config|flow-typed|node_modules)/" | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"name": "spendesk-collector-template", | ||
"version": "0.0.2", | ||
"description": "Template to develop Spendesk collectors", | ||
"dependencies": { | ||
"child_process": "^1.0.2", | ||
"gulp": "^3.9.1", | ||
"gulp-conflict": "^0.4.0", | ||
"gulp-template": "^5.0.0", | ||
"inquirer": "^5.2.0", | ||
"lodash": "^4.17.5", | ||
"minimist": "^1.2.0" | ||
}, | ||
"engines": { | ||
"node": "8.11.x", | ||
"npm": "5.6.x", | ||
"yarn": "1.6.x" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^5.9.0", | ||
"eslint-config-airbnb-base": "^13.1.0", | ||
"eslint-config-prettier": "^3.3.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-jest": "^22.0.1", | ||
"eslint-plugin-prettier": "^3.0.0", | ||
"jest": "^23.6.0", | ||
"prettier": "^1.15.2" | ||
}, | ||
"scripts": { | ||
"test": "yarn run test:lint && yarn run test:combined", | ||
"test:lint": "eslint bin src", | ||
"test:combined": "NODE_ENV=test jest ./tests", | ||
"test:unit": "NODE_ENV=test jest ./tests/units", | ||
"test:integration": "NODE_ENV=test jest ./tests/integrations" | ||
}, | ||
"bin": { | ||
"spendesk-collector-template": "./bin/collector-template.js" | ||
}, | ||
"main": "bin/collector-template", | ||
"repository": "[email protected]:Spendesk/collect-template.git", | ||
"author": "Auree Aubert <[email protected]>", | ||
"license": "MIT", | ||
"private": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const _ = require("lodash"); | ||
const templateVersion = require("./../package.json").version; | ||
|
||
module.exports = ( | ||
argv, | ||
userAnswers, | ||
existingManifestJson, | ||
existingPackageJson | ||
) => { | ||
const forcedData = { | ||
version: existingPackageJson.version || "0.0.1", | ||
template_version: templateVersion | ||
}; | ||
|
||
if (argv["non-interactive"]) { | ||
userAnswers = { | ||
name: `${_.startCase(_.camelCase(argv.name))}`, | ||
package_name: `spendesk-${_.kebabCase(argv.name)}-collector` | ||
}; | ||
} | ||
|
||
return _.defaults({}, forcedData, userAnswers); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const path = require("path"); | ||
const fs = require("fs"); | ||
|
||
module.exports = (targetPath, fileName) => { | ||
try { | ||
const existingJsonFilePath = path.join(process.cwd(), targetPath, fileName); | ||
if (fs.existsSync(existingJsonFilePath)) { | ||
console.log("Loading: ", existingJsonFilePath); | ||
return require(existingJsonFilePath); // eslint-disable-line | ||
} | ||
return {}; | ||
} catch (e) { | ||
console.log(`Failed to load ${fileName}, exiting`); | ||
return process.exit(1); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const _ = require("lodash"); | ||
const inquirer = require("inquirer"); | ||
|
||
module.exports = (argv, existingManifestJson, existingPackageJson) => { | ||
function showQuestion(answers) { | ||
return !argv["non-interactive"]; | ||
} | ||
|
||
return inquirer.prompt([ | ||
{ | ||
type: "text", | ||
name: "name", | ||
message: "Collector human redable name (e.g. 'LinkedIn Ads')", | ||
validate: input => { | ||
return input.match(/[a-zA-Z][a-zA-Z0-9]+/) !== null; | ||
}, | ||
default: existingManifestJson.name, | ||
when: showQuestion | ||
}, | ||
{ | ||
type: "text", | ||
name: "package_name", | ||
message: "Package name", | ||
default: data => { | ||
return ( | ||
existingPackageJson.name || | ||
`spendesk-${_.kebabCase(data.name)}-collector` | ||
); | ||
}, | ||
when: showQuestion | ||
} | ||
]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
; EditorConfig helps developers define and maintain consistent | ||
; coding styles between different editors and IDEs | ||
; editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"env": { | ||
"es6": true, | ||
"node": true, | ||
"jest/globals": true | ||
}, | ||
"extends": [ | ||
"airbnb-base", | ||
"plugin:jest/recommended", | ||
"plugin:prettier/recommended", | ||
"prettier", | ||
"prettier/standard" | ||
], | ||
"plugins": [ | ||
"jest", | ||
"prettier" | ||
], | ||
"rules": { | ||
"arrow-body-style" : [0], | ||
"arrow-parens": [0], | ||
"camelcase": [0], | ||
"class-methods-use-this": [0], | ||
"comma-dangle": [0], | ||
"eqeqeq": [1], | ||
"max-len": [0], | ||
"new-cap": [0], | ||
"no-console": [0], | ||
"no-param-reassign" : [0], | ||
"no-underscore-dangle": [0], | ||
"prefer-arrow-callback": [0], | ||
"prefer-destructuring": [0], | ||
"quotes": [2, "double"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
coverage | ||
.vscode | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# <%= name %> Collector | ||
TODO: description | ||
|
||
## Getting Started | ||
TODO: getting started and configuration | ||
|
||
## How it works | ||
TODO: general overview | ||
|
||
## Features | ||
TODO: features descriptions | ||
|
||
## FAQ | ||
TODO: limitations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: NODE_ENV=production node app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# <%= name %> Collector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = (req, res) => { | ||
const spendeskCollectClient = req.client; | ||
const spendeskCollectShip = req.ship; | ||
|
||
res.json({ ok: true }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = (req, res) => { | ||
const spendeskCollectClient = req.client; | ||
const spendeskCollectShip = req.ship; | ||
|
||
return res.json({ label: "ok" }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const SpendeskCollect = require("spendesk-collect"); | ||
|
||
const { PORT = 8082 } = process.env; | ||
|
||
const collector = new SpendeskCollect.Collector(PORT); | ||
collector.startApp(); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module.exports = { | ||
"collectCoverage": true, | ||
"collectCoverageFrom": [ | ||
"app/**/*.{js,jsx}" | ||
], | ||
"coveragePathIgnorePatterns": [ | ||
"/node_modules/", | ||
"/tests/" | ||
], | ||
"coverageThreshold": { | ||
"global": { | ||
"branches": 40, | ||
"functions": 40, | ||
"lines": 40, | ||
"statements": 40 | ||
} | ||
}, | ||
"testEnvironment": "node", | ||
"testMatch": ["<rootDir>/tests/units/**/*.spec.js", "<rootDir>/tests/integrations/**/*.spec.js"], | ||
"transformIgnorePatterns": ["[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"], | ||
"testPathIgnorePatterns": [ | ||
"<rootDir>/(dist|docs|dll|config|flow-typed|node_modules)/" | ||
] | ||
}; |
Oops, something went wrong.