-
Notifications
You must be signed in to change notification settings - Fork 53
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
Colin King
committed
Oct 13, 2018
0 parents
commit f1b3a90
Showing
129 changed files
with
28,393 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,69 @@ | ||
version: 2 | ||
jobs: | ||
setup: | ||
working_directory: ~/typewriter | ||
docker: | ||
- image: circleci/node:8.11 | ||
|
||
steps: | ||
- checkout | ||
|
||
# Download and cache dependencies | ||
- restore_cache: | ||
keys: | ||
- v1-dependencies-{{ checksum "yarn.lock" }} | ||
# fallback to using the latest cache if no exact match is found | ||
- v1-dependencies- | ||
- run: yarn install --frozen-lockfile | ||
- save_cache: | ||
paths: | ||
- node_modules | ||
key: v1-dependencies-{{ checksum "yarn.lock" }} | ||
- persist_to_workspace: | ||
root: . | ||
paths: [.] | ||
|
||
build: | ||
docker: | ||
- image: circleci/node:8.11 | ||
steps: | ||
- attach_workspace: { at: . } | ||
- run: yarn build | ||
|
||
snyk: | ||
docker: | ||
- image: circleci/node:8.11 | ||
steps: | ||
- attach_workspace: { at: . } | ||
- run: | ||
name: Snyk Setup | ||
command: curl -sL https://raw.githubusercontent.com/segmentio/snyk_helpers/master/initialization/snyk.sh | sh | ||
|
||
lint: | ||
docker: | ||
- image: circleci/node:8.11 | ||
steps: | ||
- attach_workspace: { at: . } | ||
- run: yarn lint | ||
|
||
test: | ||
docker: | ||
- image: circleci/node:8.11 | ||
steps: | ||
- attach_workspace: { at: . } | ||
- run: yarn test | ||
|
||
workflows: | ||
version: 2 | ||
default: | ||
jobs: | ||
- setup | ||
- build: | ||
requires: [setup] | ||
- snyk: | ||
context: snyk | ||
requires: [setup] | ||
- lint: | ||
requires: [setup] | ||
- test: | ||
requires: [setup] |
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,10 @@ | ||
; 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 |
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,76 @@ | ||
# Contributor Covenant Code of Conduct | ||
|
||
## Our Pledge | ||
|
||
In the interest of fostering an open and welcoming environment, we as | ||
contributors and maintainers pledge to making participation in our project and | ||
our community a harassment-free experience for everyone, regardless of age, body | ||
size, disability, ethnicity, sex characteristics, gender identity and expression, | ||
level of experience, education, socio-economic status, nationality, personal | ||
appearance, race, religion, or sexual identity and orientation. | ||
|
||
## Our Standards | ||
|
||
Examples of behavior that contributes to creating a positive environment | ||
include: | ||
|
||
* Using welcoming and inclusive language | ||
* Being respectful of differing viewpoints and experiences | ||
* Gracefully accepting constructive criticism | ||
* Focusing on what is best for the community | ||
* Showing empathy towards other community members | ||
|
||
Examples of unacceptable behavior by participants include: | ||
|
||
* The use of sexualized language or imagery and unwelcome sexual attention or | ||
advances | ||
* Trolling, insulting/derogatory comments, and personal or political attacks | ||
* Public or private harassment | ||
* Publishing others' private information, such as a physical or electronic | ||
address, without explicit permission | ||
* Other conduct which could reasonably be considered inappropriate in a | ||
professional setting | ||
|
||
## Our Responsibilities | ||
|
||
Project maintainers are responsible for clarifying the standards of acceptable | ||
behavior and are expected to take appropriate and fair corrective action in | ||
response to any instances of unacceptable behavior. | ||
|
||
Project maintainers have the right and responsibility to remove, edit, or | ||
reject comments, commits, code, wiki edits, issues, and other contributions | ||
that are not aligned to this Code of Conduct, or to ban temporarily or | ||
permanently any contributor for other behaviors that they deem inappropriate, | ||
threatening, offensive, or harmful. | ||
|
||
## Scope | ||
|
||
This Code of Conduct applies both within project spaces and in public spaces | ||
when an individual is representing the project or its community. Examples of | ||
representing a project or community include using an official project e-mail | ||
address, posting via an official social media account, or acting as an appointed | ||
representative at an online or offline event. Representation of a project may be | ||
further defined and clarified by project maintainers. | ||
|
||
## Enforcement | ||
|
||
Instances of abusive, harassing, or otherwise unacceptable behavior may be | ||
reported by contacting the project team at [INSERT EMAIL ADDRESS]. All | ||
complaints will be reviewed and investigated and will result in a response that | ||
is deemed necessary and appropriate to the circumstances. The project team is | ||
obligated to maintain confidentiality with regard to the reporter of an incident. | ||
Further details of specific enforcement policies may be posted separately. | ||
|
||
Project maintainers who do not follow or enforce the Code of Conduct in good | ||
faith may face temporary or permanent repercussions as determined by other | ||
members of the project's leadership. | ||
|
||
## Attribution | ||
|
||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, | ||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html | ||
|
||
[homepage]: https://www.contributor-covenant.org | ||
|
||
For answers to common questions about this code of conduct, see | ||
https://www.contributor-covenant.org/faq |
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,87 @@ | ||
# Thanks for taking the time to contribute to Typewriter! | ||
|
||
It is highly appreciated that you take the time to help improve Typewriter. | ||
|
||
Please see our [issue template](ISSUE_TEMPLATE.md) for issues specifically. | ||
|
||
## Issues, Bugfixes and New Language Support | ||
|
||
Have an idea for improving Typewriter? Submit an issue first, and we'll be happy to help | ||
you scope it out and make sure it is a good fit for Typewriter. | ||
|
||
## Developing on Typewriter | ||
|
||
### Build and run locally | ||
|
||
```sh | ||
$ yarn | ||
$ yarn build | ||
|
||
# The build library is now available in ./dist | ||
|
||
# Regenerate the JS example to verify Typewriter is installed correctly | ||
$ node ./dist/index.js gen-js \ | ||
--inputPath ./examples/local-tracking-plans/tracking-plan-web.json \ | ||
--outputPath ./examples/js/pages/generated | ||
``` | ||
|
||
### Running Tests | ||
|
||
```sh | ||
$ yarn test | ||
``` | ||
|
||
### Regenerate Example Clients | ||
|
||
You can regenerate all [example clients](../examples) by running: | ||
|
||
```sh | ||
$ yarn run generate-examples | ||
``` | ||
|
||
### Adding a New Language Target | ||
|
||
1) Create a `gen-{your-lang-here}.ts` file in [`src/commands`](../src/commands) (see existing commands for examples to work from). | ||
|
||
2) Export the variables `command` (the name of the command), `desc` (its description), `builder` (an object that captures the parameters your command takes -- in the majority of cases you can just re-export `builder` in [`src/lib/index.ts`](../src/lib/index.ts)) and `handler` (see below). | ||
|
||
3) The `handler` export is the function that accepts the user-specified parameters and an object that includes the Tracking Plan events. (Keep in mind that you need to wrap your handler function with `getTypedTrackHandler()` which will supply these to you.) This is where you can extract type information and other metadata from the events and use it to format a data payload that can be renderer out as files. | ||
|
||
```typescript | ||
/* | ||
* gen-go.ts | ||
*/ | ||
|
||
export const handler = getTypedTrackHandler( | ||
async (params: Params, { events }) => { | ||
const codeContent = await genGo(events); | ||
return writeFile(`${params.outputPath}/index.go`, codeContent); | ||
} | ||
); | ||
``` | ||
|
||
A single promise must be returned from the handler. In order to render multiple files, use a `Promise.all()` to concurrently render them to disk: | ||
|
||
```typescript | ||
/* | ||
* gen-node.ts | ||
*/ | ||
|
||
const readmeContent = ` | ||
Welcome to Typewriter Node.js! | ||
` | ||
|
||
export const handler = getTypedTrackHandler(async (params: Params, { events }) => { | ||
const indexJS = await genNodeJS(events, params) | ||
|
||
const packageJSON = `{ ... }` | ||
|
||
return Promise.all([ | ||
writeFile(`${params.outputPath}/index.js`, indexJS), | ||
writeFile(`${params.outputPath}/package.json`, packageJSON) | ||
writeFile(`${params.outputPath}/README.md`, readmeContent) | ||
]) | ||
}) | ||
``` | ||
|
||
4) Make sure to include an example application in the [`examples/`](../examples) directory that shows how to use your client library. |
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,39 @@ | ||
# Thanks for taking the time to contribute to Typewriter! | ||
|
||
It is highly appreciated that you take the time to help improve Typewriter. | ||
We appreciate it if you would take the time to write up a bug report or feature request. | ||
|
||
Sadly, if we don't receive enough information, or the issue/feature request doesn't | ||
align well with our roadmap, we might respectfully thank you for your time, and close the issue. | ||
|
||
_Bug fixes and documentation fixes are welcome._ | ||
|
||
## In the case of a bug report 🐞 | ||
|
||
Please consider the following items when filing a bug report: | ||
|
||
* Issue and steps to reproduce. | ||
* Versions. (Typewriter, OS, language, etc.) | ||
* Screenshots. | ||
* Expected. | ||
* Actual. | ||
* Minimal reproducible example. | ||
|
||
## In the case of a feature/language request ✍️ | ||
|
||
Please consider the following items when filing a feature request: | ||
|
||
* **Usage**, including a proposed API, if possible. | ||
* Problem that feature/component addresses. | ||
|
||
See the [contributing guide](CONTRIBUTING.md) for more details. | ||
|
||
## Respect earns Respect 👏 | ||
|
||
Please respect our [Code of Conduct](CODE_OF_CONDUCT.md), in short: | ||
|
||
* Using welcoming and inclusive language. | ||
* Being respectful of differing viewpoints and experiences. | ||
* Gracefully accepting constructive criticism. | ||
* Focusing on what is best for the community. | ||
* Showing empathy towards other community members. |
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,17 @@ | ||
# Thanks for taking the time to contribute to Typewriter! | ||
|
||
It is highly appreciated that you take the time to help improve Typewriter. | ||
We appreciate it if you would take the time to document your Pull Request. | ||
|
||
Sadly, if we don't receive enough information, or the Pull Request doesn't | ||
align well with our roadmap, we might respectfully thank you for your time, and close the issue. | ||
|
||
## Respect earns Respect 👏 | ||
|
||
Please respect our [Code of Conduct](CODE_OF_CONDUCT.md), in short: | ||
|
||
* Using welcoming and inclusive language. | ||
* Being respectful of differing viewpoints and experiences. | ||
* Gracefully accepting constructive criticism. | ||
* Focusing on what is best for the community. | ||
* Showing empathy towards other community members. |
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,72 @@ | ||
# Created by https://www.gitignore.io/api/node | ||
|
||
### Node ### | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Typescript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
|
||
# End of https://www.gitignore.io/api/node | ||
|
||
dist | ||
|
||
.next | ||
|
||
.rpt2_cache | ||
|
||
.DS_Store |
Oops, something went wrong.