Skip to content

Commit 8a17058

Browse files
committed
Initial commit
0 parents  commit 8a17058

File tree

11 files changed

+325
-0
lines changed

11 files changed

+325
-0
lines changed

.babelrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"presets": [
3+
[
4+
"@babel/preset-env",
5+
{
6+
"targets": {
7+
"node": "current"
8+
}
9+
}
10+
],
11+
"@babel/preset-react",
12+
],
13+
"plugins": [
14+
"@babel/plugin-proposal-class-properties"
15+
]
16+
}
17+

.eslintrc.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"extends": ["airbnb", "prettier", "eslint:recommended"],
3+
"settings": {
4+
"import/resolver": {
5+
"node": {
6+
"paths": ["src"]
7+
}
8+
}
9+
},
10+
"parser": "@babel/eslint-parser",
11+
"env": {
12+
"browser": true,
13+
"node": true,
14+
"mocha": true
15+
},
16+
"plugins": ["prettier", "simple-import-sort", "jsdoc"],
17+
"rules": {
18+
"prettier/prettier": "error",
19+
"comma-dangle": ["error", "always-multiline"],
20+
"array-element-newline": ["error", "consistent"],
21+
"no-plusplus": ["error", { "allowForLoopAfterthoughts": true }],
22+
"one-var": ["error", { "uninitialized": "always", "initialized": "never" }],
23+
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
24+
"prefer-template": "off",
25+
"camelcase": "off",
26+
"max-len": "off",
27+
"no-console": "off",
28+
"no-unused-expressions": "warn",
29+
"no-confusing-arrow": "off",
30+
"no-underscore-dangle": "off",
31+
"no-return-assign": "off",
32+
"consistent-return": "off",
33+
"arrow-body-style": "off",
34+
"import/prefer-default-export": "off",
35+
"import/no-named-as-default-member": "warn",
36+
"no-param-reassign": ["warn", { "props": false }],
37+
"max-classes-per-file": "warn",
38+
"simple-import-sort/imports": [
39+
"warn",
40+
{
41+
"groups": [
42+
// Side effect imports.
43+
["^\\u0000"],
44+
// Packages.
45+
// Things that start with a letter (or digit or underscore), or `@` followed by a letter.
46+
["^@?\\w"],
47+
// Absolute imports
48+
[
49+
"^(components|configs|constants|containers|domain|enhancers|hocs|libs|pages|reducers|services|store|modules|dictionaries)(/.*|$)"
50+
],
51+
// Relative imports.
52+
// Anything that starts with a dot.
53+
["^\\."]
54+
]
55+
}
56+
]
57+
}
58+
}
59+

.github/workflows/cicd.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Continuous testing and publication to NPM from 'main'
2+
3+
on: [push]
4+
5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
7+
cancel-in-progress: true
8+
9+
10+
jobs:
11+
12+
run-js-tests:
13+
runs-on: ubuntu-latest
14+
if: github.repository != 'Exabyte-io/template-definitions'
15+
strategy:
16+
matrix:
17+
node-version: [12.x, 14.x, 16.x]
18+
19+
steps:
20+
- name: Checkout this repository
21+
uses: actions/checkout@v2
22+
23+
- name: Checkout actions repository
24+
uses: actions/checkout@v2
25+
with:
26+
repository: Exabyte-io/actions
27+
token: ${{ secrets.BOT_GITHUB_TOKEN }}
28+
path: actions
29+
30+
- name: Run JS tests
31+
uses: ./actions/js/test
32+
with:
33+
node-version: ${{ matrix.node-version }}
34+
35+
publish-js-package:
36+
needs: [run-js-tests]
37+
runs-on: ubuntu-latest
38+
if: (github.repository != 'Exabyte-io/template-definitions') && (github.ref_name == 'main')
39+
40+
steps:
41+
- name: Checkout this repository
42+
uses: actions/checkout@v2
43+
44+
- name: Checkout actions repository
45+
uses: actions/checkout@v2
46+
with:
47+
repository: Exabyte-io/actions
48+
token: ${{ secrets.BOT_GITHUB_TOKEN }}
49+
path: actions
50+
51+
- name: Publish JS release
52+
uses: ./actions/js/publish
53+
with:
54+
node-version: 12.21.x
55+
npm-token: ${{ secrets.NPM_TOKEN }}
56+
github-token: ${{ secrets.BOT_GITHUB_TOKEN }}
57+

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
dist/
2+
build/
3+
node_modules/
4+
.eslintcache
5+
.husky/
6+
.nyc_output/
7+
.idea/
8+

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"singleQuote": false,
3+
"printWidth": 100,
4+
"trailingComma": "all",
5+
"tabWidth": 4
6+
}
7+

LICENSE.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# LICENSE
2+
3+
Copyright 2022 Exabyte Inc.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# template-definitions
2+
3+
Template repository for entity definition libraries in Javascript
4+
5+
See [here](https://docs.github.com/en/github-ae@latest/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template)
6+
for details on how to use this repository.
7+
8+
Included is a simple `template.py` analog to `cookiecutter` which will prompt
9+
the user for some information and then write out templated values in select files.
10+
After usage, the `template.py` file can be removed and the `README.md` and associated
11+
`files` can be committed.
12+

package.json

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"name": "@exabyte-io/PROJECT_NAME",
3+
"version": "0.0.0",
4+
"description": "PROJECT_DESCRIPTION",
5+
"scripts": {
6+
"test": "nyc --reporter=text mocha --recursive --bail --require @babel/register/lib --require tests/setup.js tests",
7+
"lint": "eslint src tests && prettier --write src tests",
8+
"lint:fix": "eslint --fix --cache src tests && prettier --write src tests",
9+
"transpile": "babel --out-dir dist src",
10+
"postinstall": "npm run transpile",
11+
"prepare": "husky install"
12+
},
13+
"repository": {
14+
"type": "git",
15+
"url": "https://github.com/Exabyte-io/PROJECT_NAME.git"
16+
},
17+
"main": "dist/index.js",
18+
"files": [
19+
"/dist",
20+
"/src",
21+
".babelrc"
22+
],
23+
"author": "Exabyte Inc.",
24+
"bugs": {
25+
"url": "https://github.com/Exabyte-io/PROJECT_NAME/issues"
26+
},
27+
"license": "Apache-2.0",
28+
"homepage": "https://github.com/Exabyte-io/PROJECT_NAME",
29+
"dependencies": {
30+
"@babel/cli": "7.16.0",
31+
"@babel/core": "7.16.0",
32+
"@babel/eslint-parser": "7.16.3",
33+
"@babel/plugin-proposal-class-properties": "7.16.0",
34+
"@babel/preset-env": "7.16.4",
35+
"@babel/preset-react": "7.16.7",
36+
"@babel/register": "^7.16.0",
37+
"@babel/runtime-corejs3": "7.16.8"
38+
},
39+
"devDependencies": {
40+
"chai": "^4.3.4",
41+
"eslint": "7.32.0",
42+
"eslint-config-airbnb": "19.0.2",
43+
"eslint-config-prettier": "8.3.0",
44+
"eslint-plugin-import": "2.25.3",
45+
"eslint-plugin-jsdoc": "37.1.0",
46+
"eslint-plugin-jsx-a11y": "6.5.1",
47+
"eslint-plugin-prettier": "4.0.0",
48+
"eslint-plugin-simple-import-sort": "7.0.0",
49+
"husky": "^7.0.4",
50+
"lint-staged": "^12.1.2",
51+
"mocha": "^9.1.3",
52+
"nyc": "^15.1.0"
53+
},
54+
"engines": {
55+
"node": ">=12.0.0"
56+
},
57+
"lint-staged": {
58+
"*.js": "eslint --cache --fix",
59+
"*.{js,css}": "prettier --write"
60+
}
61+
}
62+

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Add exports here

template.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/usr/bin/env python
2+
"""
3+
Safely delete this script and commit edited files after use
4+
"""
5+
6+
files = [
7+
"package.json",
8+
]
9+
10+
params = [
11+
"PROJECT_NAME",
12+
"PROJECT_DESCRIPTION",
13+
]
14+
15+
readme = """\
16+
[![npm version](https://badge.fury.io/js/%40exabyte-io%2FPROJECT_NAME.svg)](https://badge.fury.io/js/%40exabyte-io%2FPROJECT_NAME)
17+
[![License: Apache](https://img.shields.io/badge/License-Apache-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
18+
19+
# PROJECT_NAME
20+
21+
PROJECT_NAME houses entity definitions for use in the Mat3ra platform.
22+
23+
24+
### Installation
25+
26+
For usage within a javascript project:
27+
28+
```bash
29+
npm install @exabyte-io/PROJECT_NAME
30+
```
31+
32+
For development:
33+
34+
```bash
35+
git clone https://github.com/Exabyte-io/PROJECT_NAME.git
36+
```
37+
38+
39+
### Contribution
40+
41+
This repository is an [open-source](LICENSE.md) work-in-progress and we welcome contributions.
42+
43+
We regularly deploy the latest code containing all accepted contributions online as part of the
44+
[Mat3ra.com](https://mat3ra.com) platform, so contributors will see their code in action there.
45+
46+
See [ESSE](https://github.com/Exabyte-io/esse) for additional context regarding the data schemas used here.
47+
48+
Useful commands for development:
49+
50+
```bash
51+
# run linter without persistence
52+
npm run lint
53+
54+
# run linter and save edits
55+
npm run lint:fix
56+
57+
# compile the library
58+
npm run transpile
59+
60+
# run tests
61+
npm run test
62+
```
63+
64+
"""
65+
66+
values = {}
67+
for param in params:
68+
values[param] = input(f"Please provide a value for {param}: ")
69+
70+
71+
def replace(content, values):
72+
for key, val in values.items():
73+
content = content.replace(key, val)
74+
return content
75+
76+
77+
for fl in files:
78+
with open(fl, "r") as f:
79+
content = f.read()
80+
with open(fl, "w") as f:
81+
f.write(replace(content, values))
82+
83+
84+
with open("README.md", "w") as f:
85+
f.write(replace(readme, values))

0 commit comments

Comments
 (0)