-
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
Showing
11 changed files
with
324 additions
and
1 deletion.
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,17 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"targets": { | ||
"node": "current" | ||
} | ||
} | ||
], | ||
"@babel/preset-react", | ||
], | ||
"plugins": [ | ||
"@babel/plugin-proposal-class-properties" | ||
] | ||
} | ||
|
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,59 @@ | ||
{ | ||
"extends": ["airbnb", "prettier", "eslint:recommended"], | ||
"settings": { | ||
"import/resolver": { | ||
"node": { | ||
"paths": ["src"] | ||
} | ||
} | ||
}, | ||
"parser": "@babel/eslint-parser", | ||
"env": { | ||
"browser": true, | ||
"node": true, | ||
"mocha": true | ||
}, | ||
"plugins": ["prettier", "simple-import-sort", "jsdoc"], | ||
"rules": { | ||
"prettier/prettier": "error", | ||
"comma-dangle": ["error", "always-multiline"], | ||
"array-element-newline": ["error", "consistent"], | ||
"no-plusplus": ["error", { "allowForLoopAfterthoughts": true }], | ||
"one-var": ["error", { "uninitialized": "always", "initialized": "never" }], | ||
"brace-style": ["error", "1tbs", { "allowSingleLine": true }], | ||
"prefer-template": "off", | ||
"camelcase": "off", | ||
"max-len": "off", | ||
"no-console": "off", | ||
"no-unused-expressions": "warn", | ||
"no-confusing-arrow": "off", | ||
"no-underscore-dangle": "off", | ||
"no-return-assign": "off", | ||
"consistent-return": "off", | ||
"arrow-body-style": "off", | ||
"import/prefer-default-export": "off", | ||
"import/no-named-as-default-member": "warn", | ||
"no-param-reassign": ["warn", { "props": false }], | ||
"max-classes-per-file": "warn", | ||
"simple-import-sort/imports": [ | ||
"warn", | ||
{ | ||
"groups": [ | ||
// Side effect imports. | ||
["^\\u0000"], | ||
// Packages. | ||
// Things that start with a letter (or digit or underscore), or `@` followed by a letter. | ||
["^@?\\w"], | ||
// Absolute imports | ||
[ | ||
"^(components|configs|constants|containers|domain|enhancers|hocs|libs|pages|reducers|services|store|modules|dictionaries)(/.*|$)" | ||
], | ||
// Relative imports. | ||
// Anything that starts with a dot. | ||
["^\\."] | ||
] | ||
} | ||
] | ||
} | ||
} | ||
|
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,57 @@ | ||
name: Continuous testing and publication to NPM from 'main' | ||
|
||
on: [push] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
|
||
jobs: | ||
|
||
run-js-tests: | ||
runs-on: ubuntu-latest | ||
if: github.repository != 'Exabyte-io/template-definitions' | ||
strategy: | ||
matrix: | ||
node-version: [12.x, 14.x, 16.x] | ||
|
||
steps: | ||
- name: Checkout this repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Checkout actions repository | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: Exabyte-io/actions | ||
token: ${{ secrets.BOT_GITHUB_TOKEN }} | ||
path: actions | ||
|
||
- name: Run JS tests | ||
uses: ./actions/js/test | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
publish-js-package: | ||
needs: [run-js-tests] | ||
runs-on: ubuntu-latest | ||
if: (github.repository != 'Exabyte-io/template-definitions') && (github.ref_name == 'main') | ||
|
||
steps: | ||
- name: Checkout this repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Checkout actions repository | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: Exabyte-io/actions | ||
token: ${{ secrets.BOT_GITHUB_TOKEN }} | ||
path: actions | ||
|
||
- name: Publish JS release | ||
uses: ./actions/js/publish | ||
with: | ||
node-version: 12.21.x | ||
npm-token: ${{ secrets.NPM_TOKEN }} | ||
github-token: ${{ secrets.BOT_GITHUB_TOKEN }} | ||
|
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,8 @@ | ||
dist/ | ||
build/ | ||
node_modules/ | ||
.eslintcache | ||
.husky/ | ||
.nyc_output/ | ||
.idea/ | ||
|
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,7 @@ | ||
{ | ||
"singleQuote": false, | ||
"printWidth": 100, | ||
"trailingComma": "all", | ||
"tabWidth": 4 | ||
} | ||
|
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,15 @@ | ||
# LICENSE | ||
|
||
Copyright 2022 Exabyte Inc. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
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 |
---|---|---|
@@ -1,2 +1,12 @@ | ||
# template-definitions | ||
Template repository for entity definition libraries | ||
|
||
Template repository for entity definition libraries in Javascript | ||
|
||
See [here](https://docs.github.com/en/github-ae@latest/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template) | ||
for details on how to use this repository. | ||
|
||
Included is a simple `template.py` analog to `cookiecutter` which will prompt | ||
the user for some information and then write out templated values in select files. | ||
After usage, the `template.py` file can be removed and the `README.md` and associated | ||
`files` can be committed. | ||
|
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,62 @@ | ||
{ | ||
"name": "@exabyte-io/PROJECT_NAME", | ||
"version": "0.0.0", | ||
"description": "PROJECT_DESCRIPTION", | ||
"scripts": { | ||
"test": "nyc --reporter=text mocha --recursive --bail --require @babel/register/lib --require tests/setup.js tests", | ||
"lint": "eslint src tests && prettier --write src tests", | ||
"lint:fix": "eslint --fix --cache src tests && prettier --write src tests", | ||
"transpile": "babel --out-dir dist src", | ||
"postinstall": "npm run transpile", | ||
"prepare": "husky install" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Exabyte-io/PROJECT_NAME.git" | ||
}, | ||
"main": "dist/index.js", | ||
"files": [ | ||
"/dist", | ||
"/src", | ||
".babelrc" | ||
], | ||
"author": "Exabyte Inc.", | ||
"bugs": { | ||
"url": "https://github.com/Exabyte-io/PROJECT_NAME/issues" | ||
}, | ||
"license": "Apache-2.0", | ||
"homepage": "https://github.com/Exabyte-io/PROJECT_NAME", | ||
"dependencies": { | ||
"@babel/cli": "7.16.0", | ||
"@babel/core": "7.16.0", | ||
"@babel/eslint-parser": "7.16.3", | ||
"@babel/plugin-proposal-class-properties": "7.16.0", | ||
"@babel/preset-env": "7.16.4", | ||
"@babel/preset-react": "7.16.7", | ||
"@babel/register": "^7.16.0", | ||
"@babel/runtime-corejs3": "7.16.8" | ||
}, | ||
"devDependencies": { | ||
"chai": "^4.3.4", | ||
"eslint": "7.32.0", | ||
"eslint-config-airbnb": "19.0.2", | ||
"eslint-config-prettier": "8.3.0", | ||
"eslint-plugin-import": "2.25.3", | ||
"eslint-plugin-jsdoc": "37.1.0", | ||
"eslint-plugin-jsx-a11y": "6.5.1", | ||
"eslint-plugin-prettier": "4.0.0", | ||
"eslint-plugin-simple-import-sort": "7.0.0", | ||
"husky": "^7.0.4", | ||
"lint-staged": "^12.1.2", | ||
"mocha": "^9.1.3", | ||
"nyc": "^15.1.0" | ||
}, | ||
"engines": { | ||
"node": ">=12.0.0" | ||
}, | ||
"lint-staged": { | ||
"*.js": "eslint --cache --fix", | ||
"*.{js,css}": "prettier --write" | ||
} | ||
} | ||
|
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 @@ | ||
// Add exports here |
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,85 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Safely delete this script and commit edited files after use | ||
""" | ||
|
||
files = [ | ||
"package.json", | ||
] | ||
|
||
params = [ | ||
"PROJECT_NAME", | ||
"PROJECT_DESCRIPTION", | ||
] | ||
|
||
readme = """\ | ||
[](https://badge.fury.io/js/%40exabyte-io%2FPROJECT_NAME) | ||
[](https://www.apache.org/licenses/LICENSE-2.0) | ||
# PROJECT_NAME | ||
PROJECT_NAME houses entity definitions for use in the Mat3ra platform. | ||
### Installation | ||
For usage within a javascript project: | ||
```bash | ||
npm install @exabyte-io/PROJECT_NAME | ||
``` | ||
For development: | ||
```bash | ||
git clone https://github.com/Exabyte-io/PROJECT_NAME.git | ||
``` | ||
### Contribution | ||
This repository is an [open-source](LICENSE.md) work-in-progress and we welcome contributions. | ||
We regularly deploy the latest code containing all accepted contributions online as part of the | ||
[Mat3ra.com](https://mat3ra.com) platform, so contributors will see their code in action there. | ||
See [ESSE](https://github.com/Exabyte-io/esse) for additional context regarding the data schemas used here. | ||
Useful commands for development: | ||
```bash | ||
# run linter without persistence | ||
npm run lint | ||
# run linter and save edits | ||
npm run lint:fix | ||
# compile the library | ||
npm run transpile | ||
# run tests | ||
npm run test | ||
``` | ||
""" | ||
|
||
values = {} | ||
for param in params: | ||
values[param] = input(f"Please provide a value for {param}: ") | ||
|
||
|
||
def replace(content, values): | ||
for key, val in values.items(): | ||
content = content.replace(key, val) | ||
return content | ||
|
||
|
||
for fl in files: | ||
with open(fl, "r") as f: | ||
content = f.read() | ||
with open(fl, "w") as f: | ||
f.write(replace(content, values)) | ||
|
||
|
||
with open("README.md", "w") as f: | ||
f.write(replace(readme, values)) |
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,2 @@ | ||
import chai from "chai"; | ||
|