]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
init
authorEduardo San Martin Morote <posva13@gmail.com>
Mon, 18 Nov 2019 19:53:54 +0000 (20:53 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Mon, 18 Nov 2019 19:54:16 +0000 (20:54 +0100)
22 files changed:
.checklist.md [new file with mode: 0644]
.eslintrc.js [new file with mode: 0644]
.github/CODE_OF_CONDUCT.md [new file with mode: 0644]
.github/CONTRIBUTING.md [new file with mode: 0644]
.github/ISSUE_TEMPLATE.md [new file with mode: 0644]
.github/PULL_REQUEST_TEMPLATE.md [new file with mode: 0644]
.github/funding.yml [new file with mode: 0644]
.github/settings.yml [new file with mode: 0644]
.gitignore [new file with mode: 0644]
.prettierrc.js [new file with mode: 0644]
.release-it.json [new file with mode: 0644]
.vscode/settings.json [new file with mode: 0644]
LICENSE [new file with mode: 0644]
README.md [new file with mode: 0644]
__tests__/.eslintrc.js [new file with mode: 0644]
__tests__/index.spec.ts [new file with mode: 0644]
circle.yml [new file with mode: 0644]
jest.config.js [new file with mode: 0644]
package.json [new file with mode: 0644]
rollup.config.js [new file with mode: 0644]
src/index.ts [new file with mode: 0644]
tsconfig.json [new file with mode: 0644]

diff --git a/.checklist.md b/.checklist.md
new file mode 100644 (file)
index 0000000..f0d89e5
--- /dev/null
@@ -0,0 +1,30 @@
+# Checklist of things to do when creating a lib
+
+## Copying the project
+
+- `cp -r lib-boilerplate-ts my-new-lib` (careful copying `node_modules`)
+- `rm -rf .git`
+- `rm .checklist.md`
+- `git init .`
+- `git add .`
+- `git commit -m 'init'`
+- `sed -i '' 's/lib-boilerplate-ts/vue-local-scope/g' README.md package.json`
+
+## circle ci
+
+- Add the project: https://circleci.com/projects/gh/posva
+- Check _Build on forked pull requests_: https://circleci.com/gh/posva/vue-tweezing/edit#advanced-settings
+- Check _Auto cancel redundant build_ (same place)
+
+## Greenkeeper
+
+- Activate it: https://github.com/settings/installations/5583
+- Merge its first pull request
+
+## Beerpay
+
+- Add project: https://beerpay.io/dashboard/projects/add
+
+## Github Settings
+
+- Activate probot/settings: https://github.com/settings/installations/85597
diff --git a/.eslintrc.js b/.eslintrc.js
new file mode 100644 (file)
index 0000000..43e0fca
--- /dev/null
@@ -0,0 +1,20 @@
+module.exports = {
+  parser: '@typescript-eslint/parser',
+  extends: [
+    'plugin:@typescript-eslint/recommended',
+    'prettier/@typescript-eslint',
+    'plugin:prettier/recommended',
+    // "posva"
+  ],
+  parserOptions: {
+    ecmaVersion: 2018,
+    // allows `import`
+    sourceType: 'module',
+  },
+  rules: {
+    '@typescript-eslint/explicit-function-return-type': 'off',
+  },
+  // "env": {
+  //   "jest": true
+  // }
+}
diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md
new file mode 100644 (file)
index 0000000..4ead0e1
--- /dev/null
@@ -0,0 +1,13 @@
+# Contributor Code of Conduct
+
+As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
+
+We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
+
+Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
+
+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. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
+
+This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
new file mode 100644 (file)
index 0000000..6602f31
--- /dev/null
@@ -0,0 +1,26 @@
+# Contributing
+
+Contributions are welcome and will be fully credited!
+
+We accept contributions via Pull Requests on [Github](https://github.com/{{ githubAccount }}/{{ name }}).
+
+## Pull Requests
+
+Here are some guidelines to make the process smoother:
+
+- **Add a test** - New features and bugfixes need tests. If you find it difficult to test, please tell us in the pull request and we will try to help you!
+- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
+- **Run `npm test` locally** - This will allow you to go faster
+- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
+- **Send coherent history** - Make sure your commits message means something
+- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
+
+## Creating issues
+
+### Bug reports
+
+Always try to provide as much information as possible. If you are reporting a bug, try to provide a repro on jsfiddle.net (or anything else) or a stacktrace at the very least. This will help us check the problem quicker.
+
+### Feature requests
+
+Lay out the reasoning behind it and propose an API for it. Ideally, you should have a practical example to prove the utility of the feature you're requesting.
diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
new file mode 100644 (file)
index 0000000..dd1043c
--- /dev/null
@@ -0,0 +1,8 @@
+<!--
+IMPORTANT: Please provide as much information as possible:
+
+    - Reporting a bug: if possible provide a repro on jsfiddle.net or a stacktrace at the very least
+
+    - Feature request: lay out the reasoning behind it and propose an API for it
+
+-->
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644 (file)
index 0000000..efcf371
--- /dev/null
@@ -0,0 +1,35 @@
+<!--
+Please make sure to read the Pull Request Guidelines:
+https://github.com/vuejs/vue/blob/dev/.github/CONTRIBUTING.md#Pull-Request
+-->
+
+<!-- PULL REQUEST TEMPLATE -->
+<!-- (Update "[ ]" to "[x]" to check a box) -->
+
+**What kind of change does this PR introduce?** (check at least one)
+
+- [ ] Bugfix
+- [ ] Feature
+- [ ] Code style update
+- [ ] Refactor
+- [ ] Build-related changes
+- [ ] Other, please describe:
+
+**Does this PR introduce a breaking change?** (check one)
+
+- [ ] Yes
+- [ ] No
+
+If yes, please describe the impact and migration path for existing applications:
+
+**The PR fulfills these requirements:**
+
+- [ ] When resolving a specific issue, it's referenced in the PR's title (e.g. `fix #xxx[,#xxx]`, where "xxx" is the issue number)
+- [ ] All tests are passing
+- [ ] New/updated tests are included
+
+If adding a **new feature**, the PR's description includes:
+
+- [ ] A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)
+
+**Other information:**
diff --git a/.github/funding.yml b/.github/funding.yml
new file mode 100644 (file)
index 0000000..0bd5ac9
--- /dev/null
@@ -0,0 +1,3 @@
+github: posva
+patreon: posva
+custom: https://www.paypal.me/posva
diff --git a/.github/settings.yml b/.github/settings.yml
new file mode 100644 (file)
index 0000000..e99aa7a
--- /dev/null
@@ -0,0 +1,25 @@
+labels:
+  - name: bug
+    color: ee0701
+  - name: contribution welcome
+    color: 0e8a16
+  - name: discussion
+    color: 4935ad
+  - name: docs
+    color: 8be281
+  - name: enhancement
+    color: a2eeef
+  - name: good first issue
+    color: 7057ff
+  - name: help wanted
+    color: 008672
+  - name: question
+    color: d876e3
+  - name: wontfix
+    color: ffffff
+  - name: WIP
+    color: ffffff
+  - name: need repro
+    color: c9581c
+  - name: feature request
+    color: fbca04
diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..2fe38ba
--- /dev/null
@@ -0,0 +1,10 @@
+node_modules
+coverage
+npm-debug.log
+yarn-error.log
+.nyc_output
+coverage.lcov
+dist
+package-lock.json
+yarn.lock
+.DS_Store
diff --git a/.prettierrc.js b/.prettierrc.js
new file mode 100644 (file)
index 0000000..bb79d65
--- /dev/null
@@ -0,0 +1,5 @@
+module.exports = {
+  semi: false,
+  trailingComma: 'es5',
+  singleQuote: true,
+}
diff --git a/.release-it.json b/.release-it.json
new file mode 100644 (file)
index 0000000..56a7b2c
--- /dev/null
@@ -0,0 +1,15 @@
+{
+  "src": {
+    "tagName": "v%s",
+    "commitMessage": "chore(release): %s"
+  },
+  "github": {
+    "release": true,
+    "releaseName": "🚀 Release %s",
+    "tokenRef": "GITHUB_TOKEN"
+  },
+  "npm": {
+    "publish": true
+  },
+  "changelogCommand": "git log --pretty=format:'* %s (%h)' [REV_RANGE]"
+}
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644 (file)
index 0000000..52d6a46
--- /dev/null
@@ -0,0 +1,13 @@
+{
+  "[javascript]": {
+    "editor.formatOnSave": false
+  },
+  "[typescript]": {
+    "editor.formatOnSave": false
+  },
+  "eslint.autoFixOnSave": true,
+  "eslint.validate": [
+    "javascript",
+    { "language": "typescript", "autoFix": true }
+  ]
+}
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..e8c2f18
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2019 Eduardo San Martin Morote
+
+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.
diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..17d9615
--- /dev/null
+++ b/README.md
@@ -0,0 +1,21 @@
+# pinia [![Build Status](https://badgen.net/circleci/github/posva/pinia/master)](https://circleci.com/gh/posva/pinia) [![npm package](https://badgen.net/npm/v/pinia)](https://www.npmjs.com/package/pinia) [![coverage](https://badgen.net/codecov/c/github/posva/pinia/master)](https://codecov.io/github/posva/pinia) [![thanks](https://badgen.net/badge/thanks/♥/pink)](https://github.com/posva/thanks)
+
+> Some awesome description
+
+Demo (TODO link)
+
+## Installation
+
+```sh
+npm install lib-boilerplate
+```
+
+## Usage
+
+## API
+
+## Related
+
+## License
+
+[MIT](http://opensource.org/licenses/MIT)
diff --git a/__tests__/.eslintrc.js b/__tests__/.eslintrc.js
new file mode 100644 (file)
index 0000000..c529c26
--- /dev/null
@@ -0,0 +1,5 @@
+module.exports = {
+  env: {
+    jest: true,
+  },
+}
diff --git a/__tests__/index.spec.ts b/__tests__/index.spec.ts
new file mode 100644 (file)
index 0000000..240f142
--- /dev/null
@@ -0,0 +1,7 @@
+import { mylib } from '../src'
+
+describe('mylib', () => {
+  it('works', () => {
+    expect(mylib()).toBe(true)
+  })
+})
diff --git a/circle.yml b/circle.yml
new file mode 100644 (file)
index 0000000..2543c73
--- /dev/null
@@ -0,0 +1,29 @@
+version: 2
+
+jobs:
+  build:
+    docker:
+      - image: circleci/node:10
+
+    working_directory: ~/repo
+
+    steps:
+      - checkout
+
+      - restore_cache:
+          keys:
+            - dependencies-cache-v1-{{ checksum "yarn.lock" }}
+            - dependencies-cache-v1-
+
+      - run: yarn install
+
+      - save_cache:
+          paths:
+            - node_modules
+          key: dependencies-cache-v1-{{ checksum "yarn.lock" }}
+
+      - run: yarn run test
+
+      - run:
+          name: Send code coverage
+          command: yarn codecov
diff --git a/jest.config.js b/jest.config.js
new file mode 100644 (file)
index 0000000..7ff7112
--- /dev/null
@@ -0,0 +1,14 @@
+module.exports = {
+  preset: 'ts-jest',
+  collectCoverage: true,
+  collectCoverageFrom: ['<rootDir>/src/**/*.ts'],
+  testMatch: ['<rootDir>/__tests__/**/*.spec.ts'],
+  globals: {
+    'ts-jest': {
+      diagnostics: {
+        warnOnly: true,
+      },
+    },
+  },
+  testURL: 'http://localhost/',
+}
diff --git a/package.json b/package.json
new file mode 100644 (file)
index 0000000..01e450a
--- /dev/null
@@ -0,0 +1,62 @@
+{
+  "name": "pinia",
+  "version": "0.0.0",
+  "description": "Some awesome description",
+  "main": "dist/pinia.common.js",
+  "module": "dist/pinia.esm.js",
+  "unpkg": "dist/pinia.js",
+  "browser": "dist/pinia.esm.js",
+  "types": "dist/pinia/src",
+  "sideEffects": false,
+  "author": {
+    "name": "Eduardo San Martin Morote",
+    "email": "posva13@gmail.com"
+  },
+  "scripts": {
+    "lint": "eslint --color --ext=js,html,vue,ts src __tests__ *.js",
+    "lint:fix": "yarn run lint --fix",
+    "unit": "jest",
+    "dev": "yarn run unit --watchAll",
+    "pretest": "yarn run lint",
+    "test": "yarn run unit && yarn run build",
+    "build": "rollup -c rollup.config.js",
+    "prepublishOnly": "yarn run build"
+  },
+  "files": [
+    "dist",
+    "LICENSE",
+    "README.md"
+  ],
+  "keywords": [],
+  "license": "MIT",
+  "devDependencies": {
+    "@rollup/plugin-alias": "^2.2.0",
+    "@rollup/plugin-replace": "^2.2.1",
+    "@types/jest": "^24.0.18",
+    "@typescript-eslint/eslint-plugin": "^2.3.1",
+    "@typescript-eslint/parser": "^2.3.1",
+    "codecov": "^3.6.1",
+    "eslint": "^6.4.0",
+    "eslint-config-prettier": "^6.3.0",
+    "eslint-plugin-prettier": "^3.1.1",
+    "jest": "^24.9.0",
+    "pascalcase": "^1.0.0",
+    "prettier": "^1.18.2",
+    "rimraf": "^3.0.0",
+    "rollup": "^1.21.4",
+    "rollup-plugin-commonjs": "^10.1.0",
+    "rollup-plugin-node-resolve": "^5.2.0",
+    "rollup-plugin-terser": "^5.1.2",
+    "rollup-plugin-typescript2": "^0.25.2",
+    "ts-jest": "^24.1.0",
+    "typescript": "^3.6.3"
+  },
+  "repository": {
+    "type": "git",
+    "url": "git+https://github.com/posva/pinia.git"
+  },
+  "bugs": {
+    "url": "https://github.com/posva/pinia/issues"
+  },
+  "homepage": "https://github.com/posva/pinia#readme"
+}
diff --git a/rollup.config.js b/rollup.config.js
new file mode 100644 (file)
index 0000000..58da42f
--- /dev/null
@@ -0,0 +1,119 @@
+import replace from '@rollup/plugin-replace'
+import resolve from 'rollup-plugin-node-resolve'
+import commonjs from 'rollup-plugin-commonjs'
+import ts from 'rollup-plugin-typescript2'
+import alias from '@rollup/plugin-alias'
+import { terser } from 'rollup-plugin-terser'
+import path from 'path'
+import rimraf from 'rimraf'
+import pascalcase from 'pascalcase'
+
+const cwd = process.cwd()
+// eslint-disable-next-line
+const pkg = require(path.join(cwd, 'package.json'))
+
+rimraf.sync(path.join(cwd, './dist'))
+
+const banner = `/*!
+  * ${pkg.name} v${pkg.version}
+  * (c) ${new Date().getFullYear()} Eduardo San Martin Morote
+  * @license MIT
+  */`
+
+const exportName = pascalcase(pkg.name)
+
+function createEntry(
+  {
+    format, // Rollup format (iife, umd, cjs, es)
+    external, // Rollup external option
+    input = 'src/index.ts', // entry point
+    env = 'development', // NODE_ENV variable
+    minify = false,
+    isBrowser = false, // produce a browser module version or not
+  } = {
+    input: 'src/index.ts',
+    env: 'development',
+    minify: false,
+    isBrowser: false,
+  }
+) {
+  // force production mode when minifying
+  if (minify) env = 'production'
+
+  const config = {
+    input,
+    plugins: [
+      replace({
+        __VERSION__: pkg.version,
+        'process.env.NODE_ENV': `'${env}'`,
+      }),
+      alias({
+        resolve: ['.ts', '.js'],
+        // entries: [{ find: 'firebase', replacement: path.join(__dirname, './stub') }],
+      }),
+    ],
+    output: {
+      banner,
+      file: `dist/${pkg.name}.UNKNOWN.js`,
+      format,
+    },
+  }
+
+  if (format === 'iife') {
+    config.output.file = pkg.unpkg
+    config.output.name = exportName
+  } else if (format === 'es') {
+    config.output.file = isBrowser ? pkg.browser : pkg.module
+  } else if (format === 'cjs') {
+    config.output.file = pkg.main
+  }
+
+  if (!external) {
+    config.plugins.push(resolve(), commonjs())
+  } else {
+    config.external = external
+  }
+
+  config.plugins.push(
+    ts({
+      // only check once, during the es version with browser (it includes external libs)
+      check: format === 'es' && isBrowser && !minify,
+      tsconfigOverride: {
+        exclude: ['__tests__'],
+        compilerOptions: {
+          // same for d.ts files
+          declaration: format === 'es' && isBrowser && !minify,
+          target: format === 'es' && !isBrowser ? 'esnext' : 'es5',
+        },
+      },
+    })
+  )
+
+  if (minify) {
+    config.plugins.push(
+      terser({
+        module: format === 'es',
+        output: {
+          preamble: banner,
+        },
+      })
+    )
+    config.output.file = config.output.file.replace(/\.js$/i, '.min.js')
+  }
+
+  return config
+}
+
+const builds = [
+  createEntry({ format: 'cjs' }),
+  createEntry({ format: 'es', isBrowser: true }),
+]
+
+if (pkg.unpkg)
+  builds.push(
+    createEntry({ format: 'iife' }),
+    createEntry({ format: 'iife', minify: true }),
+    createEntry({ format: 'es', isBrowser: true, minify: true })
+  )
+
+export default builds
diff --git a/src/index.ts b/src/index.ts
new file mode 100644 (file)
index 0000000..c1ac933
--- /dev/null
@@ -0,0 +1,3 @@
+export function mylib() {
+  return true
+}
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644 (file)
index 0000000..f35fd3b
--- /dev/null
@@ -0,0 +1,15 @@
+{
+  "compilerOptions": {
+    "target": "esnext",
+    "module": "esnext",
+    "noEmit": true,
+    "strict": true,
+    "composite": true,
+    "esModuleInterop": true,
+    "moduleResolution": "node",
+
+    "rootDir": ".",
+    "baseUrl": "."
+  },
+  "include": ["src", "__tests__"]
+}