Skip to content

Commit

Permalink
chore(init): init project
Browse files Browse the repository at this point in the history
  • Loading branch information
unadlib committed Feb 23, 2024
1 parent 0cf997e commit cf8bc01
Show file tree
Hide file tree
Showing 15 changed files with 5,262 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# EditorConfig is awesome: https://EditorConfig.org
# install EditorConfig for VS Code extension
# top-most EditorConfig file
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 80
trim_trailing_whitespace = true

[*.md]
max_line_length = 0
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/node_modules
67 changes: 67 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"env": {
"browser": true,
"es6": true,
"node": true,
"jest": true
},
"extends": [
"airbnb",
"prettier",
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2019,
"sourceType": "module"
},
"plugins": [
"prettier",
"@typescript-eslint"
],
"rules": {
"no-useless-constructor": 0,
"class-methods-use-this": 0,
"no-underscore-dangle": 0,
"@typescript-eslint/no-non-null-assertion": 0,
"@typescript-eslint/interface-name-prefix": 0,
"@typescript-eslint/explicit-function-return-type": 0,
"max-classes-per-file": 0,
"no-await-in-loop": "off",
"no-restricted-syntax": "off",
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": true
}
],
"import/prefer-default-export": "off",
"prettier/prettier": [
"error"
],
"import/extensions": [
"error",
"ignorePackages",
{
"js": "never",
"ts": "never"
}
]
},
"settings": {
"import/resolver": {
"node": {
"extensions": [
".js",
".ts"
]
}
}
}
}
26 changes: 26 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Node CI

on: [push]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x, 16.x, 18.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: yarn install, build, and test
run: |
yarn install
yarn build
yarn test
env:
CI: true
24 changes: 24 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Publish Package to npmjs
on:
release:
types: [created]
jobs:
publish-npm:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- run: yarn
- run: yarn build
- run: yarn test
- run: npm publish --provenance
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
CI: true

1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "es5"
}
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
# mutability

![Node CI](https://github.com/unadlib/mutability/workflows/Node%20CI/badge.svg)
[![npm version](https://badge.fury.io/js/mutability.svg)](http://badge.fury.io/js/mutability)

A JavaScript library for transactional mutable updates

## Motivation

## Installation

```sh
yarn add mutability
```

## Usage


1 change: 1 addition & 0 deletions global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare var __DEV__: boolean
1 change: 1 addition & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './src';
7 changes: 7 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

if (process.env.NODE_ENV === 'production') {
module.exports = require('../dist/index.cjs.js');
} else {
module.exports = require('../dist/index.cjs.development.js');
}
77 changes: 77 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"name": "mutability",
"version": "0.1.0",
"description": "A JavaScript library for transactional mutable updates",
"main": "lib/index.js",
"unpkg": "dist/index.umd.js",
"types": "dist/index.d.ts",
"scripts": {
"test": "jest",
"clean": "rimraf dist",
"build": "yarn clean && tsc --skipLibCheck && yarn build:prod && yarn build:dev",
"build:prod": "NODE_ENV=production rollup --config --bundleConfigAsCjs",
"build:dev": "NODE_ENV=development rollup --config --bundleConfigAsCjs",
"commit": "yarn git-cz"
},
"repository": {
"type": "git",
"url": "git+https://github.com/unadlib/mutability.git"
},
"author": "unadlib",
"license": "MIT",
"bugs": {
"url": "https://github.com/unadlib/mutability/issues"
},
"homepage": "https://github.com/unadlib/mutability#readme",
"keywords": [
"transactional mutable updates",
"transactional updates",
"mutative"
],
"devDependencies": {
"@rollup/plugin-commonjs": "^24.0.1",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-replace": "^5.0.2",
"@types/jest": "^29.5.0",
"@types/node": "^18.15.5",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"commitizen": "^4.3.0",
"eslint": "^8.36.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"prettier": "^2.8.6",
"rimraf": "^4.4.0",
"rollup": "^3.20.0",
"rollup-plugin-terser": "^7.0.0",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"tslib": "^2.5.0",
"typedoc": "^0.23.28",
"typedoc-plugin-markdown": "^3.14.0",
"typescript": "^5.0.2",
"yargs": "^17.7.1"
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "jsdom",
"globals": {
"__DEV__": false
}
},
"peerDependencies": {
"mutative": "^1.0.3"
},
"dependencies": {
"mutative": "^1.0.3"
}
}
64 changes: 64 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import replace from '@rollup/plugin-replace';
import { terser } from 'rollup-plugin-terser';
import pkg from './package.json';

const isProduction = process.env.NODE_ENV === 'production';
const input = './dist/index.js';

export default isProduction
? {
input,
output: [
{
format: 'cjs',
exports: 'auto',
file: 'dist/index.cjs.js',
sourcemap: true,
},
{
format: 'umd',
name: pkg.name
.split('-')
.map(([s, ...rest]) => [s.toUpperCase(), ...rest].join(''))
.join(''),
file: pkg.unpkg,
sourcemap: true,
globals: {
'data-transport': 'DataTransport',
'broadcast-channel': 'BroadcastChannel',
},
},
],
plugins: [
resolve(),
commonjs(),
replace({
__DEV__: 'false',
preventAssignment: true,
}),
terser(),
],
external: ['data-transport', 'broadcast-channel'],
}
: {
input,
output: [
{
format: 'cjs',
exports: 'auto',
file: 'dist/index.cjs.development.js',
sourcemap: true,
},
],
plugins: [
resolve(),
commonjs(),
replace({
__DEV__: 'true',
preventAssignment: true,
}),
],
external: ['data-transport', 'broadcast-channel'],
};
73 changes: 73 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"compilerOptions": {
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "ES6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
"lib": [
"ES2019",
"DOM"
] /* Specify library files to be included in the compilation. */,
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
"declaration": true /* Generates corresponding '.d.ts' file. */,
"declarationMap": true /* Generates a sourcemap for each corresponding '.d.ts' file. */,
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./dist" /* Redirect output structure to the directory. */,
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
"importHelpers": true /* Import emit helpers from 'tslib'. */,
"downlevelIteration": true /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */,
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */

/* Strict Type-Checking Options */
"strict": true /* Enable all strict type-checking options. */,
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
"alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */,

/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */

/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
"rootDirs": [
"node_modules/@types"
] /* List of root folders whose combined content represents the structure of the project at runtime. */,
// "types": [
// ], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */

/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
"inlineSourceMap": true /* Emit a single file with source maps instead of having a separate file. */,
"inlineSources": true /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */,

/* Experimental Options */
"experimentalDecorators": true /* Enables experimental support for ES7 decorators. */,
"emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */,
"useDefineForClassFields": false,

/* Advanced Options */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
},
"include": ["src/*", "global.d.ts"]
}
Loading

0 comments on commit cf8bc01

Please sign in to comment.