Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/ci-cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CI/CD

on:
pull_request:
push:
branches:
- master

jobs:
tests:
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
node: [10, 12, 13, 14]
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Setup Node.js ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test
- name: Upload coverage data
uses: codecov/codecov-action@v1

release:
name: Release
needs: tests
if: "github.event_name == 'push' && !contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# Do not persist the GH token, so that the release step uses its own credentials.
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 14
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
GIT_AUTHOR_NAME: github-actions
GIT_AUTHOR_EMAIL: 44210433+github-actions@users.noreply.github.com
GIT_COMMITTER_NAME: github-actions
GIT_COMMITTER_EMAIL: 44210433+github-actions@users.noreply.github.com
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ These steps will guide you through contributing to this project:
- Fork the repo
- Clone it and install dependencies

git clone https://github.com/YOUR-USERNAME/typescript-library-starter
npm install
git clone https://github.com/YOUR-USERNAME/typescript-library-starter
npm install

Keep in mind that after running `npm install` the git repo is reset. So a good way to cope with this is to have a copy of the folder to push the changes, and the other to try them.

Expand Down
55 changes: 30 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ npm install

### Features

- Zero-setup. After running `npm install` things will setup for you :wink:
- **[RollupJS](https://rollupjs.org/)** for multiple optimized bundles following the [standard convention](http://2ality.com/2017/04/setting-up-multi-platform-packages.html) and [Tree-shaking](https://alexjoverm.github.io/2017/03/06/Tree-shaking-with-Webpack-2-TypeScript-and-Babel/)
- Tests, coverage and interactive watch mode using **[Jest](http://facebook.github.io/jest/)**
- **[Prettier](https://github.com/prettier/prettier)** and **[TSLint](https://palantir.github.io/tslint/)** for code formatting and consistency
- **Docs automatic generation and deployment** to `gh-pages`, using **[TypeDoc](http://typedoc.org/)**
- Automatic types `(*.d.ts)` file generation
- **[Travis](https://travis-ci.org)** integration and **[Coveralls](https://coveralls.io/)** report
- (Optional) **Automatic releases and changelog**, using [Semantic release](https://github.com/semantic-release/semantic-release), [Commitizen](https://github.com/commitizen/cz-cli), [Conventional changelog](https://github.com/conventional-changelog/conventional-changelog) and [Husky](https://github.com/typicode/husky) (for the git hooks)
- Zero-setup. After running `npm install` things will setup for you :wink:
- **[RollupJS](https://rollupjs.org/)** for multiple optimized bundles following the [standard convention](http://2ality.com/2017/04/setting-up-multi-platform-packages.html) and [Tree-shaking](https://alexjoverm.github.io/2017/03/06/Tree-shaking-with-Webpack-2-TypeScript-and-Babel/)
- Tests, coverage and interactive watch mode using **[Jest](http://facebook.github.io/jest/)**
- **[Prettier](https://github.com/prettier/prettier)** and **[TSLint](https://palantir.github.io/tslint/)** for code formatting and consistency
- **Docs automatic generation and deployment** to `gh-pages`, using **[TypeDoc](http://typedoc.org/)**
- Automatic types `(*.d.ts)` file generation
- **[Travis](https://travis-ci.org)** integration and **[Coveralls](https://coveralls.io/)** report
- (Optional) **Automatic releases and changelog**, using [Semantic release](https://github.com/semantic-release/semantic-release), [Commitizen](https://github.com/commitizen/cz-cli), [Conventional changelog](https://github.com/conventional-changelog/conventional-changelog) and [Husky](https://github.com/typicode/husky) (for the git hooks)

### Importing library

Expand All @@ -50,13 +50,13 @@ import something from 'mylib/dist/lib/something'

### NPM scripts

- `npm t`: Run test suite
- `npm start`: Run `npm run build` in watch mode
- `npm run test:watch`: Run test suite in [interactive watch mode](http://facebook.github.io/jest/docs/cli.html#watch)
- `npm run test:prod`: Run linting and generate coverage
- `npm run build`: Generate bundles and typings, create docs
- `npm run lint`: Lints code
- `npm run commit`: Commit using conventional commit style ([husky](https://github.com/typicode/husky) will tell you to use it if you haven't :wink:)
- `npm t`: Run test suite
- `npm start`: Run `npm run build` in watch mode
- `npm run test:watch`: Run test suite in [interactive watch mode](http://facebook.github.io/jest/docs/cli.html#watch)
- `npm run test:prod`: Run linting and generate coverage
- `npm run build`: Generate bundles and typings, create docs
- `npm run lint`: Lints code
- `npm run commit`: Commit using conventional commit style ([husky](https://github.com/typicode/husky) will tell you to use it if you haven't :wink:)

### Excluding peerDependencies

Expand All @@ -67,9 +67,10 @@ Good news: the setup is here for you, you must only include the dependency name
### Automatic releases

_**Prerequisites**: you need to create/login accounts and add your project to:_
- [npm](https://www.npmjs.com/)
- [Travis CI](https://travis-ci.org)
- [Coveralls](https://coveralls.io)

- [npm](https://www.npmjs.com/)
- [Travis CI](https://travis-ci.org)
- [Coveralls](https://coveralls.io)

_**Prerequisite for Windows**: Semantic-release uses
**[node-gyp](https://github.com/nodejs/node-gyp)** so you will need to
Expand Down Expand Up @@ -102,8 +103,9 @@ Automatic releases are possible thanks to [semantic release](https://github.com/
There is already set a `precommit` hook for formatting your code with Prettier :nail_care:

By default, there are two disabled git hooks. They're set up when you run the `npm run semantic-release-prepare` script. They make sure:
- You follow a [conventional commit message](https://github.com/conventional-changelog/conventional-changelog)
- Your build is not going to fail in [Travis](https://travis-ci.org) (or your CI server), since it's runned locally before `git push`

- You follow a [conventional commit message](https://github.com/conventional-changelog/conventional-changelog)
- Your build is not going to fail in [Travis](https://travis-ci.org) (or your CI server), since it's runned locally before `git push`

This makes more sense in combination with [automatic releases](#automatic-releases)

Expand All @@ -125,15 +127,17 @@ import "core-js/fn/promise"
#### What is `npm install` doing on first run?

It runs the script `tools/init` which sets up everything for you. In short, it:
- Configures RollupJS for the build, which creates the bundles
- Configures `package.json` (typings file, main file, etc)
- Renames main src and test files

- Configures RollupJS for the build, which creates the bundles
- Configures `package.json` (typings file, main file, etc)
- Renames main src and test files

#### What if I don't want git-hooks, automatic releases or semantic-release?

Then you may want to:
- Remove `commitmsg`, `postinstall` scripts from `package.json`. That will not use those git hooks to make sure you make a conventional commit
- Remove `npm run semantic-release` from `.travis.yml`

- Remove `commitmsg`, `postinstall` scripts from `package.json`. That will not use those git hooks to make sure you make a conventional commit
- Remove `npm run semantic-release` from `.travis.yml`

#### What if I don't want to use coveralls or report my coverage?

Expand Down Expand Up @@ -164,6 +168,7 @@ Made with :heart: by [@alexjoverm](https://twitter.com/alexjoverm) and all these
| [<img src="https://avatars1.githubusercontent.com/u/618922?v=3" width="100px;"/><br /><sub><b>Steve Lee</b></sub>](http;//opendirective.com)<br />[🔧](#tool-SteveALee "Tools") | [<img src="https://avatars0.githubusercontent.com/u/5127501?v=3" width="100px;"/><br /><sub><b>Flavio Corpa</b></sub>](http://flaviocorpa.com)<br />[💻](https://github.com/alexjoverm/typescript-library-starter/commits?author=kutyel "Code") | [<img src="https://avatars2.githubusercontent.com/u/22561997?v=3" width="100px;"/><br /><sub><b>Dom</b></sub>](https://github.com/foreggs)<br />[🔧](#tool-foreggs "Tools") | [<img src="https://avatars1.githubusercontent.com/u/755?v=4" width="100px;"/><br /><sub><b>Alex Coles</b></sub>](http://alexbcoles.com)<br />[📖](https://github.com/alexjoverm/typescript-library-starter/commits?author=myabc "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/1093738?v=4" width="100px;"/><br /><sub><b>David Khourshid</b></sub>](https://github.com/davidkpiano)<br />[🔧](#tool-davidkpiano "Tools") | [<img src="https://avatars0.githubusercontent.com/u/7225802?v=4" width="100px;"/><br /><sub><b>Aarón García Hervás</b></sub>](https://aarongarciah.com)<br />[📖](https://github.com/alexjoverm/typescript-library-starter/commits?author=aarongarciah "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/13683986?v=4" width="100px;"/><br /><sub><b>Jonathan Hart</b></sub>](https://www.stuajnht.co.uk)<br />[💻](https://github.com/alexjoverm/typescript-library-starter/commits?author=stuajnht "Code") |
| [<img src="https://avatars0.githubusercontent.com/u/13509204?v=4" width="100px;"/><br /><sub><b>Sanjiv Lobo</b></sub>](https://github.com/Xndr7)<br />[📖](https://github.com/alexjoverm/typescript-library-starter/commits?author=Xndr7 "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/7473800?v=4" width="100px;"/><br /><sub><b>Stefan Aleksovski</b></sub>](https://github.com/sAleksovski)<br />[💻](https://github.com/alexjoverm/typescript-library-starter/commits?author=sAleksovski "Code") | [<img src="https://avatars2.githubusercontent.com/u/8853426?v=4" width="100px;"/><br /><sub><b>dev.peerapong</b></sub>](https://github.com/devpeerapong)<br />[💻](https://github.com/alexjoverm/typescript-library-starter/commits?author=devpeerapong "Code") | [<img src="https://avatars0.githubusercontent.com/u/22260722?v=4" width="100px;"/><br /><sub><b>Aaron Groome</b></sub>](http://twitter.com/Racing5372)<br />[📖](https://github.com/alexjoverm/typescript-library-starter/commits?author=Racing5372 "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/180963?v=4" width="100px;"/><br /><sub><b>Aaron Reisman</b></sub>](https://github.com/lifeiscontent)<br />[💻](https://github.com/alexjoverm/typescript-library-starter/commits?author=lifeiscontent "Code") | [<img src="https://avatars1.githubusercontent.com/u/32557482?v=4" width="100px;"/><br /><sub><b>kid-sk</b></sub>](https://github.com/kid-sk)<br />[📖](https://github.com/alexjoverm/typescript-library-starter/commits?author=kid-sk "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/1503089?v=4" width="100px;"/><br /><sub><b>Andrea Gottardi</b></sub>](http://about.me/andreagot)<br />[📖](https://github.com/alexjoverm/typescript-library-starter/commits?author=AndreaGot "Documentation") |
| [<img src="https://avatars3.githubusercontent.com/u/1375860?v=4" width="100px;"/><br /><sub><b>Yogendra Sharma</b></sub>](http://TechiesEyes.com)<br />[📖](https://github.com/alexjoverm/typescript-library-starter/commits?author=Yogendra0Sharma "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/7407177?v=4" width="100px;"/><br /><sub><b>Rayan Salhab</b></sub>](http://linkedin.com/in/rayan-salhab/)<br />[💻](https://github.com/alexjoverm/typescript-library-starter/commits?author=cyphercodes "Code") |

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind are welcome!
1 change: 1 addition & 0 deletions __mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = 'test-file-stub'
1 change: 1 addition & 0 deletions __mocks__/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {}
74 changes: 0 additions & 74 deletions code-of-conduct.md

This file was deleted.

75 changes: 39 additions & 36 deletions examples/basic.html
Original file line number Diff line number Diff line change
@@ -1,46 +1,49 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Alma Widgets basic example</title>
<head>
<meta charset="UTF-8" />
<title>Alma Widgets basic example</title>

<link rel="stylesheet" href="../dist/alma-widgets.umd.css">
<style>
body {
font-family: "Helvetica Neue", Helvetica, Arial, "Segoe UI", sans-serif;
font-size: 15px;
}
</style>
</head>
<body>
<h1>Échéancier</h1>
<link rel="stylesheet" href="../dist/alma-widgets.css" />
<style>
body {
font-family: 'Helvetica Neue', Helvetica, Arial, 'Segoe UI', sans-serif;
font-size: 15px;
}
</style>
</head>
<body>
<h1>Échéancier</h1>

<ul>
<li>Paiement de 150€</li>
<li>Paiement en 3 ou 4 fois</li>
</ul>
<ul>
<li>Paiement de 150€</li>
<li>Paiement en 3 ou 4 fois</li>
</ul>

<div id="payment-plan"></div>
<br><br><br><br><br><br><br><br>
<div id="how-it-works"></div>
<div id="payment-plan"></div>
<br /><br /><br /><br /><br /><br /><br /><br />
<div id="how-it-works"></div>

<script src="../dist/alma-widgets.umd.js"></script>
<script>
(function () {
var widgets = Alma.Widgets.initialize("11gKoO333vEXacMNMUMUSc4c4g68g2Les4", Alma.ApiMode.TEST);
<script src="../dist/alma-widgets.umd.js"></script>
<script>
;(function () {
var widgets = Alma.Widgets.initialize(
'11gKoO333vEXacMNMUMUSc4c4g68g2Les4',
Alma.ApiMode.TEST
)

widgets.create(Alma.Widgets.PaymentPlan, {
container: '#payment-plan',
purchaseAmount: 15000,
installmentsCount: [3, 4, 12]
});
widgets.create(Alma.Widgets.PaymentPlan, {
container: '#payment-plan',
purchaseAmount: 15000,
installmentsCount: [3, 4, 12],
})

widgets.create(Alma.Widgets.HowItWorks, {
container: '#how-it-works',
});
widgets.create(Alma.Widgets.HowItWorks, {
container: '#how-it-works',
})

widgets.render();
})();
</script>
</body>
widgets.render()
})()
</script>
</body>
</html>
42 changes: 42 additions & 0 deletions microbundle.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const image = require('@rollup/plugin-image')

module.exports = {
plugins: {
typescript: function (config) {
// Since imported *.svg will be transformed to ES modules by the image plugin, tell
// TypeScript to process them
return { ...config, include: ['*.ts+(|x)', '**/*.ts+(|x)', '*.s?css', '*.svg', '**/*.svg'] }
},
},

config: function (config, context) {
const {
format,
options: { pkg },
} = context

// Add image plugin right after json plugin
const jsonIdx = config.inputOptions.plugins.findIndex((p) => p.name === 'json')
config.inputOptions.plugins.splice(jsonIdx + 1, 0, image())

// When building browser "standalone" bundles, make sure we inline dependencies
if (format === 'umd') {
const _external = config.inputOptions.external

config.inputOptions.external = (id, ...args) => {
if (id in (pkg.dependencies || {}) || id in (pkg.peerDependencies || {})) {
return false
}
return _external(id, ...args)
}

// Make sure @alma/client is exported on the `Alma` global object, and deactivate cache to
// ensure the lib is indeed inlined into the bundle
// (see https://github.com/rollup/rollup/issues/3874)
config.outputOptions.globals['@alma/client'] = 'Alma'
config.inputOptions.cache = false
}

return config
},
}
Loading