Skip to content

Commit

Permalink
Work with web scrobbler v3 (#9)
Browse files Browse the repository at this point in the history
* Work with web scrobbler v3

* Remove requirejs
  • Loading branch information
yayuyokitano authored Apr 3, 2023
1 parent 30762ee commit f12df61
Show file tree
Hide file tree
Showing 4 changed files with 2,004 additions and 332 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
run: npm install

- name: Fetch resources
run: node ./index.js $VERSION
run: npx tsx ./index.ts $VERSION

- name: Update resources
uses: test-room-7/action-update-file@v1
Expand Down
17 changes: 8 additions & 9 deletions index.js → index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
'use strict';

require('node-define');
const fs = require('fs');
const util = require('util');
const fetch = require('node-fetch');
import fs from 'fs';
import util from 'util';
import fetch from 'node-fetch';

const mkdir = util.promisify(fs.mkdir);
const writeFile = util.promisify(fs.writeFile);
Expand All @@ -14,11 +13,11 @@ const repo = 'web-scrobbler';
const rawContentUrl = `https://github.com/raw/${owner}/${repo}`;

const resDir = 'resources';
const moduleFile = 'connectors.js';
const moduleFile = 'connectors.ts';
const listFile = `${resDir}/connectors.json`;

async function main(args) {
const latestTag = args[2];
async function main(args:string[]) {
const latestTag = args.at(-1);

if (!latestTag) {
console.error('You must provide version as an argument')
Expand Down Expand Up @@ -54,7 +53,7 @@ async function downloadModule(tagName) {
}

async function dumpConnectors() {
const connectors = require(`./${moduleFile}`);
const connectors = (await import(`./${moduleFile}`)).default as any[];

const labelArray = connectors.map((entry) => entry.label);
const contents = JSON.stringify(labelArray, null, 2);
Expand All @@ -68,7 +67,7 @@ async function dumpConnectors() {
}

function getModuleUrl(tagName) {
return `${rawContentUrl}/${tagName}/src/core/connectors.js`;
return `${rawContentUrl}/${tagName}/src/core/connectors.ts`;
}

main(process.argv);
Loading

0 comments on commit f12df61

Please sign in to comment.