Skip to content

Commit

Permalink
chore: migrate to yarn berry with node linker (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
cirocfc committed Feb 19, 2023
1 parent 830f8d3 commit ff5060a
Show file tree
Hide file tree
Showing 17 changed files with 11,959 additions and 8,168 deletions.
14 changes: 7 additions & 7 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# EditorConfig helps developers define and maintain
# consistent coding styles between different editors and IDEs.

root = true

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

[*.md]
trim_trailing_whitespace = false
53 changes: 3 additions & 50 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,60 +1,13 @@
{
"extends": ["prettier"],
"plugins": ["prettier"],
"parserOptions": {
"sourceType": "module"
},
"env": {
"es6": true,
"browser": true,
"node": true,
"jasmine": true
},
"extends": ["prettier"],
"globals": {
"require": true,
"creditcard": true,
"CREDIT_CARDS": true,
"INVALID_CREDIT_CARD": true,
"VALID_CREDIT_CARD": true,
"luhn": true,
"list": true
},
"rules": {
"camelcase": 2,
"comma-dangle": [2, {
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "never"
}],
"comma-spacing": 2,
"comma-style": [2, "last"],
"eol-last": 2,
"eqeqeq": 2,
"indent": [2, 2],
"linebreak-style": [2, "unix"],
"max-nested-callbacks": [2, 3],
"no-dupe-keys": 2,
"no-eq-null": 2,
"no-extra-semi": 2,
"no-lonely-if": 2,
"no-multi-spaces": 0,
"no-multiple-empty-lines": [2, {"max": 2}],
"no-nested-ternary": 2,
"no-param-reassign": 2,
"no-self-compare": 2,
"no-throw-literal": 2,
"no-trailing-spaces": 2,
"no-undef": 2,
"no-underscore-dangle": 0,
"no-void": 2,
"one-var": [2, "never"],
"prettier/prettier": "error",
"quotes": [2, "single"],
"semi": [2, "always"],
"keyword-spacing": 2,
"space-before-function-paren": [2, "never"],
"space-in-parens": [2, "never"]
"parserOptions": {
"sourceType": "module"
}
}
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: '14.x'
node-version: '18.x'

- name: Install dependencies
run: yarn
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14.x'
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'

# Cache dependencies
Expand Down
74 changes: 71 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,72 @@
# OS
.DS_Store

# IDEs
.idea

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# node-waf configuration
.lock-wscript

# Dependency directories
node_modules/
jspm_packages/

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Yarn
.yarn/*
!.yarn/releases
!.yarn/plugins
.pnp.*
.yarn-integrity

# npm
.npm
package-lock.json

# dotenv environment variables file
.env
.env.test

# Cache
.cache

# Build
build
dist
node_modules
npm-debug.log
.coverage

# Other
*.tgz
*.iml
*.map
3 changes: 0 additions & 3 deletions .npmignore

This file was deleted.

1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
12 changes: 10 additions & 2 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
module.exports = {
printWidth: 80,
arrowParens: 'avoid',
bracketSameLine: true,
bracketSpacing: true,
endOfLine: 'lf',
printWidth: 120,
quoteProps: 'as-needed',
semi: true,
singleQuote: true,
trailingComma: 'es5'
tabWidth: 2,
trailingComma: 'all',
useTabs: false,
};
9 changes: 9 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-engines.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable */
//prettier-ignore
module.exports = {
name: "@yarnpkg/plugin-engines",
factory: function (require) {
var plugin=(()=>{var P=Object.create,f=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty;var b=n=>f(n,"__esModule",{value:!0});var i=n=>{if(typeof require!="undefined")return require(n);throw new Error('Dynamic require of "'+n+'" is not supported')};var T=(n,e)=>{for(var r in e)f(n,r,{get:e[r],enumerable:!0})},V=(n,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of N(e))!Y.call(n,t)&&t!=="default"&&f(n,t,{get:()=>e[t],enumerable:!(r=R(e,t))||r.enumerable});return n},s=n=>V(b(f(n!=null?P(j(n)):{},"default",n&&n.__esModule&&"default"in n?{get:()=>n.default,enumerable:!0}:{value:n,enumerable:!0})),n);var U={};T(U,{default:()=>q});var o=s(i("@yarnpkg/core")),c;(function(r){r.Yarn="Yarn",r.Console="Console"})(c||(c={}));var h=class{constructor(e){this.throwWrongEngineError=(e,r)=>{let t=this.formatErrorMessage(e,r);this.throwError(t)};this.throwError=e=>{switch(this.errorReporter){case c.Yarn:this.reportYarnError(e);break;case c.Console:default:this.reportConsoleError(e);break}};this.reportYarnError=e=>{throw new o.ReportError(o.MessageName.UNNAMED,e)};this.reportConsoleError=e=>{console.error(e),process.exit(1)};this.formatErrorMessage=(e,r)=>{let{configuration:t}=this.project,p=o.formatUtils.applyStyle(t,o.formatUtils.pretty(t,this.engine,"green"),2),g=o.formatUtils.pretty(t,e,"cyan"),d=o.formatUtils.pretty(t,r,"cyan"),w=`The current ${p} version ${g} does not satisfy the required version ${d}.`;return o.formatUtils.pretty(t,w,"red")};this.project=e.project,this.errorReporter=e.errorReporter}};var m=s(i("fs")),y=s(i("path")),l=s(i("semver")),k=s(i("@yarnpkg/fslib")),a=s(i("@yarnpkg/core"));var v=class extends h{constructor(){super(...arguments);this.resolveNvmRequiredVersion=()=>{let{configuration:e,cwd:r}=this.project,t=(0,y.resolve)(k.npath.fromPortablePath(r),".nvmrc"),p=a.formatUtils.applyStyle(e,a.formatUtils.pretty(e,this.engine,"green"),2);if(!(0,m.existsSync)(t)){this.throwError(a.formatUtils.pretty(e,`Unable to verify the ${p} version. The .nvmrc file does not exist.`,"red"));return}let g=(0,m.readFileSync)(t,"utf-8").trim();if((0,l.validRange)(g))return g;let d=a.formatUtils.pretty(e,".nvmrc","yellow");this.throwError(a.formatUtils.pretty(e,`Unable to verify the ${p} version. The ${d} file contains an invalid semver range.`,"red"))}}get engine(){return"Node"}verifyEngine(e){let r=e.node;r!=null&&(r===".nvmrc"&&(r=this.resolveNvmRequiredVersion()),(0,l.satisfies)(process.version,r,{includePrerelease:!0})||this.throwWrongEngineError(process.version.replace(/^v/i,""),r.replace(/^v/i,"")))}};var x=s(i("semver")),E=s(i("@yarnpkg/core"));var u=class extends h{get engine(){return"Yarn"}verifyEngine(e){let r=e.yarn;r!=null&&((0,x.satisfies)(E.YarnVersion,r,{includePrerelease:!0})||this.throwWrongEngineError(E.YarnVersion,r))}};var C=n=>e=>{if(process.env.PLUGIN_YARN_ENGINES_DISABLE!=null)return;let{engines:r={}}=e.getWorkspaceByCwd(e.cwd).manifest.raw,t={project:e,errorReporter:n};[new v(t),new u(t)].forEach(g=>g.verifyEngine(r))},S={hooks:{validateProject:C(c.Yarn),setupScriptEnvironment:C(c.Console)}},q=S;return U;})();
return plugin;
}
};
873 changes: 873 additions & 0 deletions .yarn/releases/yarn-3.4.1.cjs

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
nodeLinker: 'node-modules'

npmAuthToken: '${{ NPM_TOKEN }}'

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-engines.cjs
spec: 'https://raw.githubusercontent.com/devoto13/yarn-plugin-engines/main/bundles/%40yarnpkg/plugin-engines.js'

yarnPath: .yarn/releases/yarn-3.4.1.cjs
83 changes: 0 additions & 83 deletions CHANGELOG.md

This file was deleted.

15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,19 @@ creditcard.js is available as a NPM package. You can install through Yarn or NPM
### Yarn

```sh
$ yarn add creditcard.js
yarn add creditcard.js
```

### NPM

```sh
$ npm install creditcard.js
npm install creditcard.js
```

## Usage

```javascript
import {
isValid,
isExpirationDateValid,
isSecurityCodeValid,
getCreditCardNameByNumber,
} from 'creditcard.js';
import { isValid, isExpirationDateValid, isSecurityCodeValid, getCreditCardNameByNumber } from 'creditcard.js';

isValid('4916108926268679'); // returns true
isExpirationDateValid('02', '2020'); // returns true
Expand Down Expand Up @@ -92,7 +87,7 @@ Type: `string`

### `getCreditCardNameByNumber(number)` -> `string`

Returns the credit card type from the card number. _(See the full list of [currently supported cards](#suportted-credit-card-types))_
Returns the credit card type from the card number. _(See the full list of [currently supported cards](#supported-credit-card-types))_

**number**

Expand All @@ -101,7 +96,7 @@ Type: `string`

---

## Suportted credit card types
## Supported credit card types

- American Express
- Aura
Expand Down
6 changes: 2 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
module.exports = {
coverageDirectory: '.coverage',
collectCoverageFrom: [
'src/**/*.js',
],
collectCoverageFrom: ['src/**/*.js'],
coverageReporters: ['html', 'lcovonly'],
coverageThreshold: {
global: {
statements: 100,
branches: 100,
functions: 100,
lines: 100
lines: 100,
},
},
};
Loading

0 comments on commit ff5060a

Please sign in to comment.