Some tooling cleanup

This commit is contained in:
Brahim Hadriche committed 2023-07-05 21:00:10 -04:00
1 parent 80bcd4c870
commit 70d66f874d
17 files changed
+145 -46

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
dist/
out/
node_modules
.vscode/.env
.env
**/roku_modules/**
playlet-lib/src/www
playlet/src/lib/playlet-lib.zip
+2 -2
View File
@@ -4,7 +4,7 @@
{
"type": "brightscript",
"request": "launch",
"envFile": "${workspaceFolder}/.vscode/.env",
"envFile": "${workspaceFolder}/.env",
"host": "${env:ROKU_DEV_TARGET}",
"password": "${env:ROKU_DEVPASSWORD}",
"stopOnEntry": false,
@@ -35,7 +35,7 @@
{
"type": "brightscript",
"request": "launch",
"envFile": "${workspaceFolder}/.vscode/.env",
"envFile": "${workspaceFolder}/.env",
"host": "${env:ROKU_DEV_TARGET}",
"password": "${env:ROKU_DEVPASSWORD}",
"stopOnEntry": false,
+2 -2
View File
@@ -23,8 +23,8 @@
"plugins": [
"roku-log-bsc-plugin",
"@rokucommunity/bslint",
"../tools/asynctask-plugin.ts",
"../tools/manifest-bsconst-debug-plugin.ts"
"../tools/bs-plugins/asynctask-plugin.ts",
"../tools/bs-plugins/manifest-bsconst-debug-plugin.ts"
],
"retainStagingDir": true,
"require": [
+1 -1
View File
@@ -60,7 +60,7 @@ Visual Studio Code is pretty much necessary for development.
Once you have it installed, you probably want to install the recommened plugins for this project, such as [BrightScript Language extension for VSCode](https://marketplace.visualstudio.com/items?itemName=RokuCommunity.brightscript) and [Svelte for VS Code](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode)
Next, create a file in `.vscode/.env` containing the following:
Next, create a file `.env` containing the following:
```makefile
ROKU_DEV_TARGET=INSERT_IP_HERE
+37 -10
View File
@@ -20,6 +20,7 @@
"brighterscript": "^0.65.1",
"brighterscript-formatter": "^1.6.29",
"convert-svg-to-png": "^0.6.4",
"cross-fetch": "^4.0.0",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"ip": "^1.1.8",
@@ -29,9 +30,6 @@
"shelljs": "^0.8.5",
"ts-node": "^10.9.1",
"typescript": "^5.1.3"
},
"engines": {
"node": "<19.0.0"
}
},
"node_modules/@cspotcode/source-map-support": {
@@ -1341,12 +1339,12 @@
"dev": true
},
"node_modules/cross-fetch": {
"version": "3.1.5",
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.5.tgz",
"integrity": "sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==",
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-4.0.0.tgz",
"integrity": "sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==",
"dev": true,
"dependencies": {
"node-fetch": "2.6.7"
"node-fetch": "^2.6.12"
}
},
"node_modules/cross-platform-clear-console": {
@@ -2826,9 +2824,9 @@
}
},
"node_modules/node-fetch": {
"version": "2.6.7",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
"version": "2.6.12",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.12.tgz",
"integrity": "sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g==",
"dev": true,
"dependencies": {
"whatwg-url": "^5.0.0"
@@ -3308,6 +3306,15 @@
"node": ">=10.18.1"
}
},
"node_modules/puppeteer/node_modules/cross-fetch": {
"version": "3.1.5",
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.5.tgz",
"integrity": "sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==",
"dev": true,
"dependencies": {
"node-fetch": "2.6.7"
}
},
"node_modules/puppeteer/node_modules/debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
@@ -3331,6 +3338,26 @@
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
},
"node_modules/puppeteer/node_modules/node-fetch": {
"version": "2.6.7",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
"dev": true,
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/qs": {
"version": "6.11.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz",
+1
View File
@@ -14,6 +14,7 @@
"brighterscript": "^0.65.1",
"brighterscript-formatter": "^1.6.29",
"convert-svg-to-png": "^0.6.4",
"cross-fetch": "^4.0.0",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"ip": "^1.1.8",
+19 -4
View File
@@ -1,8 +1,9 @@
import { defineConfig, UserConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
import { readFileSync, existsSync } from 'fs'
import { parse as dotEnvParse } from 'dotenv'
import ip from 'ip';
import { existsSync, readFileSync } from 'fs'
import { join as joinPath } from 'path'
import { parse as dotEnvParse } from 'dotenv'
const PORT = 5173
@@ -14,8 +15,22 @@ const config: UserConfig = {
}
}
if (existsSync('../.vscode/.env')) {
const envVars = dotEnvParse(readFileSync('../.vscode/.env'))
// TODO: refactor this with the same code in tools/get-env-vars.js
function getEnvVars() {
const envFile = joinPath(__dirname, '../.env');
let envVars = process.env;
if (existsSync(envFile)) {
const envConfig = dotEnvParse(readFileSync(envFile));
envVars = { ...envVars, ...envConfig };
}
return envVars;
}
const envVars = getEnvVars();
if (envVars.ROKU_DEV_TARGET) {
config.server = {
host: true,
port: PORT,
File renamed without changes.
+3
View File
@@ -1,3 +1,6 @@
// Description: Generates images for the project.
// Converts SVGs to PNGs and resizes them to the correct dimensions.
const fs = require('fs');
const path = require('path');
const { convertFile } = require('convert-svg-to-png');
+15 -4
View File
@@ -1,14 +1,25 @@
// Description: Generates the SponsorBlock config for Playlet
const fs = require('fs');
const path = require('path');
const { ArgumentParser } = require('argparse')
if (process.argv.length !== 3) {
console.error("Invalid usage! usage: npm run generate-sponsorblock-config -- sponsorblock_root");
exit(-1);
function getArgumentParser() {
const parser = new ArgumentParser({
description: 'Generate SponsorBlock config'
});
parser.add_argument('--sponsorblock-root', { help: 'Local path to the SponsorBlock repository', required: true });
return parser;
}
const parser = getArgumentParser();
const args = parser.parse_args()
const PLAYLEY_CONFIG_PATH = "./playlet-lib/src/config/sponsorblock_config.json"
const sponsorblockRoot = process.argv[2];
const sponsorblockRoot = args.sponsorblock_root;
const configExamplePath = path.join(sponsorblockRoot, "config.json.example")
const englishLocalePath = path.join(sponsorblockRoot, "public/_locales/en/messages.json")
+13 -4
View File
@@ -1,14 +1,23 @@
const dotenv = require('dotenv');
const fs = require('fs');
const path = require('path');
const envFile = path.join(__dirname, '../.env');
function getEnvVars() {
let envVars = process.env;
if (fs.existsSync('.vscode/.env')) {
const envConfig = dotenv.parse(fs.readFileSync('.vscode/.env'));
if (fs.existsSync(envFile)) {
const envConfig = dotenv.parse(fs.readFileSync(envFile));
envVars = { ...envVars, ...envConfig };
}
return envVars;
}
module.exports = getEnvVars;
if (typeof module !== 'undefined' && module.exports) {
module.exports = getEnvVars;
}
if (typeof exports !== 'undefined') {
exports.getEnvVars = getEnvVars;
}
+20 -13
View File
@@ -1,5 +1,5 @@
// This script reads recommendations, subscriptions, watch later, liked, and history from Youtube
// and imports them into invidious.
// Description: Read recommendations, subscriptions, watch later, liked, and history from Youtube
// and import them into invidious. Requires yt-dlp to be installed.
const { ArgumentParser } = require('argparse')
const fs = require('fs');
@@ -7,6 +7,20 @@ const getEnvVars = require('./get-env-vars');
const spawn = require('child_process').spawn;
const express = require('express')
const ip = require('ip');
const fetch = require('cross-fetch');
function getArgumentParser() {
const parser = new ArgumentParser({
description: 'Sync Youtube profile with Invidious'
});
parser.add_argument('--browser', { help: 'Use cookies from browser' });
parser.add_argument('--invidious', { help: 'Invidious instance to sync to' });
parser.add_argument('--output-file', { help: 'Write profile to Invidious JSON compatible file' });
parser.add_argument('--playlist-limit', { help: 'Maximum playlist video count', default: 500 });
return parser;
}
const config = getEnvVars();
const PLAYLEY_SERVER = `http://${config.ROKU_DEV_TARGET}:8888`;
@@ -167,8 +181,8 @@ async function getInvidiousInstance() {
throw new Error("Playlet not logged in")
}
console.log(`Invidious instance: ${state.invidious.logged_in_instance}`)
return state.invidious.logged_in_instance;
console.log(`Invidious instance: ${state.invidious.current_instance}`)
return state.invidious.current_instance;
}
async function getAccessToken(invidiousInstance) {
@@ -216,16 +230,9 @@ async function deleteAccessToken(invidiousInstance, token) {
let invidiousInstance = undefined
let token = undefined;
try {
const parser = new ArgumentParser({
description: 'Sync Youtube profile with Invidious'
});
const parser = getArgumentParser()
const args = parser.parse_args()
parser.add_argument('--browser', { help: 'Use cookies from browser' });
parser.add_argument('--invidious', { help: 'Invidious instance to sync to' });
parser.add_argument('--output-file', { help: 'Write profile to Invidious JSON compatible file' });
parser.add_argument('--playlist-limit', { help: 'Maximum playlist video count', default: 500 });
let args = parser.parse_args()
invidiousInstance = args.invidious
browser = args.browser
outputFile = args.output_file
+16 -5
View File
@@ -1,14 +1,24 @@
// Description: Take a screenshot of the Roku device
const { ArgumentParser } = require('argparse')
const rokuDeploy = require('roku-deploy');
const fs = require('fs');
const { exit } = require('process');
const getEnvVars = require('./get-env-vars');
if(process.argv.length !== 3) {
console.error("Invalid usage! usage: npm run screenshot -- filename");
exit(-1);
function getArgumentParser() {
const parser = new ArgumentParser({
description: 'Take a screenshot of the Roku device'
});
parser.add_argument('filename', { help: 'Path where the screenshot will be saved (without extension)' });
return parser;
}
const filename = process.argv[2];
const parser = getArgumentParser();
const args = parser.parse_args()
const filename = args.filename;
const config = getEnvVars();
const options = {
@@ -25,5 +35,6 @@ const options = {
}
catch (error) {
console.error(error);
throw error;
}
})();
+7
View File
@@ -1,3 +1,6 @@
// Description: Publish, sign the package and retrieve it from the Roku device
// It expects release/playelt.zip to exist
const getEnvVars = require('./get-env-vars');
const rokuDeploy = require('roku-deploy');
@@ -16,12 +19,16 @@ const options = {
(async () => {
try {
// Sideload playlet.zip
await rokuDeploy.publish(options);
// Sign the package
const remotePkgPath = await rokuDeploy.signExistingPackage(options);
// Retrieve the signed package
const localPkgFilePath = await rokuDeploy.retrieveSignedPackage(remotePkgPath, options);
console.log(`Created signed package: ${localPkgFilePath}`)
}
catch (error) {
console.error(error);
throw error;
}
})();
+4
View File
@@ -1,3 +1,7 @@
// Description: Updates the git commit hash in the manifest files.
// It will update both Playlet and Playlet-lib manifest files.
// It will abort if there are any changes in the working directory.
const fs = require('fs');
const shell = require('shelljs');
+4
View File
@@ -1,3 +1,7 @@
// Description: Updates the version in the manifest files.
// Reads the version from the root package.json and updates the manifest files,
// as well as the package.json files in the playlet-web folder.
const fs = require('fs');
const { execSync } = require("child_process");