Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
hanayashiki committed Apr 17, 2022
0 parents commit 1c7415c
Show file tree
Hide file tree
Showing 26 changed files with 6,018 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.cjs
*.js
dist/
demo
64 changes: 64 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
module.exports = {
extends: ['airbnb', 'airbnb-typescript'],
ignorePatterns: [
"**/generated/**",
],
rules: {
"max-len": ["error", {
code: 140,
tabWidth: 2,
// ignoreComments: true,
ignoreTrailingComments: true,
// ignoreStrings: true,
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true,
}],
"react/react-in-jsx-scope": "off",
"import/prefer-default-export": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"react/jsx-props-no-spreading": "off",
"react/prop-types": "off",
"jsx-a11y/click-events-have-key-events": "off",
"jsx-a11y/no-static-element-interactions": "off",
"jsx-a11y/label-has-associated-control": "off",
"no-console": ["error", { allow: ["warn", "error", "info"] }],
"no-plusplus": "off",
"arrow-body-style": "off",
"react/no-array-index-key": "off",
"react/button-has-type": "off",
"max-classes-per-file": "off",
"global-require": "off",
"jsx-a11y/anchor-is-valid": "off",
"no-await-in-loop": "off",
"no-restricted-syntax": "off",
"import/no-cycle": "off",
"class-methods-use-this": "off",
"linebreak-style": "off",
"quote-props": "off",
"no-lonely-if": "off",
"object-curly-newline": "warn",
"import/order": [
"error",
{
"groups": ["builtin", "external", "internal"],
"pathGroups": [
{
"pattern": "@(react|react-native)",
"group": "external",
"position": "before"
}
],
"pathGroupsExcludedImportTypes": ["react"],
"newlines-between": "always",
"alphabetize": {
"order": "asc",
"caseInsensitive": true
}
}
],
},
parserOptions: {
project: './tsconfig.json',
},
};
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules/
/build/
/lib/
/docs/
.idea/*

.DS_Store
coverage
*.log
20 changes: 20 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/.github/
/.vscode/
/node_modules/
/build/
/tmp/
.idea/*
/docs/

coverage
*.log
.gitlab-ci.yml

package-lock.json
/*.tgz
/tmp*
/mnt/
/package/
/demos/
/demo/
/src/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Chris Hager

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
70 changes: 70 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Monoid TypeScript NPM Boilerplate

A TypeScript NPM boilerplate that suits how we usually write TypeScript.

## Features

1. Outputs modern style typescript package in `dist/{cjs,esm,types}/` using `tsc` and `esbuild`.

1. Respects modern package.json
1. `type` set to `"module"`
1. `main` pointed to `./dist/cjs/index.cjs` for legacy NodeJS in commonjs format.
1. `module` pointed to `./dist/esm/index.mjs` for bundlers in esmodule format.
1. `types` for typescript declarations.
1. `exports` following [Conditional Exports](https://nodejs.org/api/packages.html#conditional-exports) for newer NodeJS to find esmodule format when using `import` and commonjs format when using `require`.

1. Test or demonstrate your package under `demo/{node,browser}/`.

1. Only files under `dist/` will be published to npm.

1. `dist/` will NOT be gitignored by default.

1. `.eslintrc.js` based on [airbnb](https://www.npmjs.com/package/eslint-config-airbnb-typescript).

1. [esmo](https://github.com/antfu/esno) installed to load typescript for node.

## Commands

```bash
yarn build
```

Build the output directory.

```bash
yarn lint
```

Lint the project.

```bash
yarn cli
```

Execute the cli with node.

```bash
yarn ts <file-name>
```

Execute arbitrary typescript file with [esmo](https://github.com/antfu/esno).

## Customization

1. Find `stripe-currency-format`, replace that with your package name.

2. Find `your-cli-name`, replace that with your cli name.

## Usage

1. Degit this repository

```
npx degit https://github.com/MonoidDev/stripe-currency-format
```

2. Use this template

Click the green button `Use this template` on the top-right side of this GitHub repository (https://github.com/MonoidDev/stripe-currency-format).


10 changes: 10 additions & 0 deletions demo/browser/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<html>
<head>
<title>
Test
</title>
</head>
<body>
<script type="module" src="./test.js"></script>
</body>
</html>
3 changes: 3 additions & 0 deletions demo/browser/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { hello } from '../../dist/esm/index.mjs';

console.log(hello);
1 change: 1 addition & 0 deletions demo/node/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
12 changes: 12 additions & 0 deletions demo/node/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"scripts": {
"postinstall": "ln -sf ../../../../dist/cjs/cli.cjs node_modules/.bin/your-cli-name",
"ts": "esno"
},
"dependencies": {
"stripe-currency-format": "link:../../"
},
"devDependencies": {
"esno": "^0.14.1"
}
}
7 changes: 7 additions & 0 deletions demo/node/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { stripeCurrencyFormat } from 'stripe-currency-format';

console.log(stripeCurrencyFormat(10000, 'USD'));

console.log(stripeCurrencyFormat(10000, 'JPY'));

console.log(stripeCurrencyFormat(114514, 'CNY'));
6 changes: 6 additions & 0 deletions demo/node/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"include": [
"**/*.ts"
],
"extends": "../../tsconfig.json"
}
Loading

0 comments on commit 1c7415c

Please sign in to comment.