Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: esm uplift #162

Merged
merged 5 commits into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 17 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,23 @@ updates:
day: "saturday"
time: "00:00"
commit-message:
prefix: ""
prefix: "chore"
prefix-development: "dev"
include: "scope"
labels:
- "dependencies"
open-pull-requests-limit: 10
pull-request-branch-name:
separator: "-"
rebase-strategy: "auto"
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: "weekly"
day: "saturday"
time: "00:00"
commit-message:
prefix: "ci"
prefix-development: "dev"
include: "scope"
labels:
Expand Down
22 changes: 9 additions & 13 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,23 @@ jobs:
lint:
name: Lint
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['lts/*']
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
node-version-file: .nvmrc
- run: |
npm install
npm i warframe-items@latest
npm i warframe-worldstate-data@latest
npm run lint
test:
name: Test
runs-on: ubuntu-latest
needs: lint
strategy:
matrix:
node-version: [14, 16, 'lts/*']
node-version: ['lts/gallium', 'lts/hydrogen', 'lts/iron', 'lts/*']
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -37,29 +35,27 @@ jobs:
- name: Test
env:
CI: true
TWITCH_CLIENT_ID: ${{ secrets.TWITCH_CLIENT_ID }}
run: |
npm install
npm i warframe-items@latest
npm i warframe-worldstate-data@latest
npm test
coverage:
name: Coverage
runs-on: ubuntu-latest
needs: lint
strategy:
matrix:
node-version: ['lts/*']
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm i warframe-items@latest
node-version-file: '.nvmrc'
- run: |
npm install
npm i warframe-items@latest
npm i warframe-worldstate-data@latest
- run: npm test
env:
CI: true
TWITCH_CLIENT_ID: ${{ secrets.TWITCH_CLIENT_ID }}
- name: Coveralls
uses: coverallsapp/github-action@master
with:
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Install Supplemental Dependencies
run: |
npm i
npm i jsdoc ink-docstrap tsd-jsdoc
- name: Build
uses: andstor/jsdoc-action@v1
with:
output_dir: ./docs
config_file: ./.github/docs/conf.json
front_page: README.md
run: npm run build:docs
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/regression.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14, 16, 'lts/*']
node-version: ['lts/gallium', 'lts/hydrogen', 'lts/iron', 'lts/*']
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -21,9 +21,8 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- name: Test
env:
TWITCH_CLIENT_ID: ${{ secrets.TWITCH_CLIENT_ID }}
run: |
npm ci
npm i warframe-items@latest
npm i warframe-worldstate-data@latest
npm test
11 changes: 4 additions & 7 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,27 @@ jobs:
release:
name: Release
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GH_TOKEN }}
- name: Use Node.js ${{ matrix.node-version }}
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
node-version-file: '.nvmrc'
- name: Test
run: |
npm ci
npm i warframe-items@latest
npm i warframe-worldstate-data@latest
npm run lint
npm test
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
uses: cycjimmy/semantic-release-action@v4
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
with:
semantic_version: 17
branches: |
['main']
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ node_modules
test/data.json
docs/
wfcd-arsenal-parser-*.tgz
!.github/docs
!.github/docs
.jshintignore
.jshintrc
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lts/gallium
lts/hydrogen
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Documentation is available [here](https://wfcd.github.io/arsenal-parser/)
## Example usage

```javascript
const ArsenalData = require('ArsenalParser');
const fetch = require('node-fetch');
import ArsenalData from 'ArsenalParser.js';
import fetch from 'node-fetch.js';

const baseURL = 'https://content.warframe.com/dynamic/twitch/getActiveLoadout.php?account=';

Expand Down
60 changes: 19 additions & 41 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
"main": "src/ArsenalParser.js",
"types": "./types/src/ArsenalParser.d.ts",
"public": true,
"type": "module",
"exports": {
".": {
"import": "./src/ArsenalParser.js",
"types": "./types/src/ArsenalParser.d.ts"
}
},
"files": [
"src",
"LICENSE",
Expand All @@ -13,26 +20,25 @@
],
"devDependencies": {
"@types/chai": "^4.2.16",
"@types/node-fetch": "^2.6.1",
"@wfcd/eslint-config": "^1.1.6",
"@wfcd/eslint-config": "^1.6.1",
"c8": "^9.1.0",
"chai": "^4.3.4",
"chai-json-equal": "^0.0.1",
"coveralls": "^3.1.0",
"install-peerdeps": "2.0.3",
"install-peerdeps": "^3.0.3",
"mocha": "^10.0.0",
"node-fetch": "^2.6.1",
"nyc": "^15.1.0",
"typescript": "^5.0.2"
},
"scripts": {
"test": "nyc mocha",
"test": "c8 mocha",
"coverage": "npm test && nyc report --reporter=text-lcov | coveralls",
"lint": "eslint src/ test/",
"lint:fix": "eslint src/ test/ --fix",
"prepublishOnly": "npm run build:types",
"build:docs": "jsdoc -c .github/docs/conf.json -d docs",
"build:types": "tsc -p tsconfig.declaration.json",
"postinstall": "install-peerdeps @wfcd/eslint-config@^1.1.6 -S"
"postinstall": "install-peerdeps @wfcd/eslint-config@latest -S",
"validate": "npm ls"
},
"keywords": [
"warframe",
Expand All @@ -52,42 +58,13 @@
},
"repository": "https://github.com/wfcd/arsenal-parser",
"engines": {
"node": ">=12.18.3",
"npm": ">=6.14.6"
"node": ">=18.19.0"
},
"eslintConfig": {
"extends": "@wfcd",
"extends": "@wfcd/eslint-config/esm",
"parser": "@babel/eslint-parser",
"parserOptions": {
"sourceType": "script"
},
"rules": {
"valid-jsdoc": [
"error",
{
"requireReturn": false,
"requireReturnDescription": false,
"preferType": {
"String": "string",
"Number": "number",
"Boolean": "boolean",
"Function": "function",
"object": "Object",
"date": "Date",
"error": "Error"
},
"prefer": {
"return": "returns"
}
}
],
"no-underscore-dangle": "off",
"import/no-extraneous-dependencies": [
"error",
{
"peerDependencies": true
}
]
"sourceType": "module"
}
},
"babel": {
Expand All @@ -109,14 +86,15 @@
"exit": true,
"spec": "test/**/*.spec.js"
},
"nyc": {
"c8": {
"reporter": [
"lcov",
"text"
],
"skip-full": true
},
"peerDependencies": {
"warframe-items": "^1.1260.46"
"warframe-items": "^1.1262.0",
"warframe-worldstate-data": "^2.3.1"
}
}
11 changes: 6 additions & 5 deletions src/Archwing.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
'use strict';
import { find, colors } from 'warframe-items/utilities';

const { items, loadMods, mapColors } = require('./utils');
const { findItem, loadMods } = find;
const { mapColors } = colors;

module.exports = class WarframeArchwing {
export default class WarframeArchwing {
constructor(archwing) {
this.archwing = items.find((item) => item.uniqueName === archwing.uniqueName) || archwing;
this.archwing = findItem(archwing.uniqueName) || archwing;
delete this.archwing.components;
delete this.archwing.patchlogs;
this.xp = archwing.xp;
Expand All @@ -16,4 +17,4 @@ module.exports = class WarframeArchwing {
attachments: mapColors(archwing.attcol),
};
}
};
}
24 changes: 11 additions & 13 deletions src/ArsenalParser.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
'use strict';

const Player = require('./Player');
const Warframe = require('./Warframe');
const Weapon = require('./Weapon');
const Archwing = require('./Archwing');
const Parazon = require('./Parazon');
const Amp = require('./OperatorAmp');
const Companion = require('./Companion');
const Mech = require('./Mech');

module.exports = class ArsenalData {
import Player from './Player.js';
import Warframe from './Warframe.js';
import Weapon from './Weapon.js';
import Archwing from './Archwing.js';
import Parazon from './Parazon.js';
import Amp from './OperatorAmp.js';
import Companion from './Companion.js';
import Mech from './Mech.js';

export default class ArsenalData {
constructor(data) {
this.account = new Player(data.account || data.accountInfo);

Expand Down Expand Up @@ -58,4 +56,4 @@ module.exports = class ArsenalData {
if (mechExalted && !mechExalted.hide) this.loadout.mech.exalted = new Weapon(mechExalted);
}
}
};
}
16 changes: 7 additions & 9 deletions src/Companion.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
'use strict';
import { find, colors } from 'warframe-items/utilities';

const { items, loadMods, mapColors } = require('./utils');

module.exports = class WarframeCompanion {
const { findItem, loadMods } = find;
const { mapColors } = colors;
export default class WarframeCompanion {
constructor(companion) {
this.companion = items.find((item) => item.uniqueName === companion.uniqueName) || companion;
this.companion = findItem(companion.uniqueName) || companion;
delete this.companion.patchlogs;
delete this.companion.components;

this.xp = companion.xp;
this.polarized = companion.polarized;
if (companion.skins) {
this.cosmetics = companion.skins.map(
(cosmetic) => items.find((item) => item.uniqueName === cosmetic.uniqueName) || cosmetic
);
this.cosmetics = companion.skins.map((cosmetic) => findItem(cosmetic.uniqueName) || cosmetic);

this.cosmetics.forEach((cosmetic) => {
/* eslint-disable no-param-reassign */
Expand All @@ -35,4 +33,4 @@ module.exports = class WarframeCompanion {
this.type = companion.type;
if (companion.itemName) this.name = companion.itemName;
}
};
}
Loading
Loading