Skip to content

Commit

Permalink
Rolled back to cjs for pkg support
Browse files Browse the repository at this point in the history
  • Loading branch information
Inrixia committed Sep 17, 2022
1 parent b654ea5 commit 610599c
Show file tree
Hide file tree
Showing 12 changed files with 4,904 additions and 191 deletions.
5,030 changes: 4,871 additions & 159 deletions package-lock.json

Large diffs are not rendered by default.

15 changes: 7 additions & 8 deletions package.json
Expand Up @@ -2,26 +2,24 @@
"name": "floatplane-plex-downloader",
"version": "5.4.0",
"private": true,
"type": "module",
"scripts": {
"prep": "npm install && npm run build",
"prestart": "tsc",
"start": "node ./dist/float.js",
"startHeadless": "tsc && node ./dist/float.js --headless",
"build": "tsc && pkg ./dist/float.js --out-path=./build -t latest-linux,latest-mac,latest-win --compress GZip",
"buildLinux": "tsc && pkg ./dist/float.js --out-path=./build -t latest-linux",
"buildMac": "tsc && pkg ./dist/float.js --out-path=./build -t latest-mac",
"buildWin": "tsc && pkg ./dist/float.js --out-path=./build -t latest-win"
"build": "tsc && pkg ./dist/float.js --out-path=./build --no-bytecode --public -t latest-linux,latest-mac,latest-win --compress GZip",
"buildLinux": "tsc && pkg ./dist/float.js --no-bytecode --public --out-path=./build -t latest-linux",
"buildMac": "tsc && pkg ./dist/float.js --no-bytecode --public --out-path=./build -t latest-mac",
"buildWin": "tsc && pkg ./dist/float.js --no-bytecode --public --out-path=./build -t latest-win"
},
"dependencies": {
"@ctrl/plex": "^1.5.3",
"@inrixia/db": "^2.0.0",
"@inrixia/db": "1.9.1",
"@inrixia/helpers": "^1.23.4",
"chalk": "^5.0.1",
"default-import": "^1.1.5",
"dotenv": "^16.0.2",
"ffbinaries": "^1.1.4",
"floatplane": "^4.0.0",
"floatplane": "^4.0.2",
"html-to-text": "^8.2.1",
"json5": "^2.2.1",
"multi-progress-bars": "^4.3.1",
Expand Down Expand Up @@ -50,6 +48,7 @@
"@types/tough-cookie-file-store": "^2.0.1",
"@typescript-eslint/eslint-plugin": "^5.37.0",
"@typescript-eslint/parser": "^5.37.0",
"babel-cli": "^7.0.0-beta.3",
"eslint": "^8.23.1",
"eslint-plugin-prettier": "^4.2.1"
}
Expand Down
8 changes: 3 additions & 5 deletions src/float.ts
@@ -1,13 +1,10 @@
import { quickStart, validatePlexSettings } from './quickStart.js';
import { fetchSubscriptions } from './subscriptionFetching.js';
import { settings, fetchFFMPEG } from './lib/helpers.js';
import { settings, fetchFFMPEG, chalk, fApi, esmOverload } from './lib/helpers.js';
import { MyPlexAccount } from '@ctrl/plex';
import { fApi } from './lib/FloatplaneAPI.js';
import { loginFloatplane } from './logins.js';
import Downloader from './Downloader.js';
import { gt, diff } from 'semver';
import { resolve } from 'path';
import chalk from 'chalk';

import type Subscription from './lib/Subscription.js';

Expand Down Expand Up @@ -37,7 +34,8 @@ const fetchNewVideos = async (subscriptions: Array<Subscription>, videoProcessor

// Async start
(async () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
// ESM Hack to make loading async esm modules globally not painful
await esmOverload;
const version: string = require('../package.json').version;
const latest = await fApi
.got('https://raw.githubusercontent.com/Inrixia/Floatplane-Downloader/master/package.json', { resolveBodyOnly: true })
Expand Down
3 changes: 1 addition & 2 deletions src/lib/Channel.ts
@@ -1,8 +1,7 @@
import fs from 'fs/promises';
import chalk from 'chalk';

import db from '@inrixia/db';
import Video from './Video.js';
import { chalk } from '../lib/helpers.js';

import type { BlogPost } from 'floatplane/creator';
import type { ChannelOptions } from './types.js';
Expand Down
6 changes: 0 additions & 6 deletions src/lib/FloatplaneAPI.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/lib/Subscription.ts
@@ -1,5 +1,5 @@
import { BlogPost } from 'floatplane/creator';
import { fApi } from './FloatplaneAPI.js';
import { fApi } from './helpers.js';
import Channel from './Channel.js';
import db from '@inrixia/db';

Expand Down
3 changes: 1 addition & 2 deletions src/lib/Video.ts
Expand Up @@ -5,14 +5,13 @@ import fs from 'fs/promises';

const exec = promisify(execCallback);

import { settings, args } from './helpers.js';
import { settings, args, fApi } from './helpers.js';

import { htmlToText } from 'html-to-text';
import sanitize from 'sanitize-filename';
import builder from 'xmlbuilder';

import { nPad } from '@inrixia/helpers/math';
import { fApi } from './FloatplaneAPI.js';

import type { FilePathFormattingOptions } from './types.js';
import type { BlogPost } from 'floatplane/creator';
Expand Down
18 changes: 16 additions & 2 deletions src/lib/helpers.ts
Expand Up @@ -4,14 +4,28 @@ import { defaultArgs, defaultSettings } from './defaults.js';
import db from '@inrixia/db';
import fs from 'fs';

import { defaultImport } from 'default-import';
const ARGV = defaultImport(await import('process.argv'));
import ARGV from 'process.argv';

import 'dotenv/config';
import { parse } from 'json5';

import type { Args, PartialArgs, Settings } from './types.js';

import { FileCookieStore } from 'tough-cookie-file-store';
import { CookieJar } from 'tough-cookie';
export const cookieJar = new CookieJar(new FileCookieStore('./db/cookies.json'));

// ESM Hack
import type { ChalkInstance } from 'chalk';
export let chalk: ChalkInstance;
import type { Floatplane } from 'floatplane';
export let fApi: Floatplane;

export const esmOverload = (async () => {
chalk = (await eval("import('chalk')")).default;
fApi = new (await eval("import('floatplane')")).Floatplane(cookieJar);
})();

export const settings = db<Settings>('./db/settings.json', { template: defaultSettings, pretty: true, forceCreate: true, updateOnExternalChanges: true });
recursiveUpdate(settings, defaultSettings);

Expand Down
2 changes: 1 addition & 1 deletion src/logins.ts
@@ -1,6 +1,6 @@
import { loopError } from '@inrixia/helpers/object';
import { floatplane, plex } from './lib/prompts/index.js';
import { fApi } from './lib/FloatplaneAPI.js';
import { fApi } from './lib/helpers.js';
import { MyPlexAccount } from '@ctrl/plex';
import { args } from './lib/helpers.js';

Expand Down
3 changes: 1 addition & 2 deletions src/quickStart.ts
@@ -1,8 +1,7 @@
import { loginFloatplane, loginPlex } from './logins.js';
import { defaultResolutions } from './lib/defaults.js';
import { args, settings } from './lib/helpers.js';
import { args, settings, fApi } from './lib/helpers.js';
import { MyPlexAccount } from '@ctrl/plex';
import { fApi } from './lib/FloatplaneAPI.js';
import * as prompts from './lib/prompts/index.js';

import type { Extras } from './lib/types.js';
Expand Down
3 changes: 1 addition & 2 deletions src/subscriptionFetching.ts
@@ -1,7 +1,6 @@
import { defaultSubChannels } from './lib/defaults.js';
import Subscription from './lib/Subscription.js';
import { fApi } from './lib/FloatplaneAPI.js';
import { settings } from './lib/helpers.js';
import { settings, fApi } from './lib/helpers.js';

export const fetchSubscriptions = async (): Promise<Subscription[]> =>
(await fApi.user.subscriptions())
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Expand Up @@ -4,7 +4,7 @@
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "ESNEXT" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
"module": "NodeNext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
"module": "CommonJS" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
"declaration": true /* Generates corresponding '.d.ts' file. */,
"declarationMap": true /* Generates a sourcemap for each corresponding '.d.ts' file. */,
"sourceMap": true /* Generates corresponding '.map' file. */,
Expand Down

0 comments on commit 610599c

Please sign in to comment.