Skip to content

Commit

Permalink
Linting and formatting update
Browse files Browse the repository at this point in the history
  • Loading branch information
simonnilsson committed Apr 17, 2024
1 parent b15c0d5 commit 3658ffe
Show file tree
Hide file tree
Showing 8 changed files with 631 additions and 199 deletions.
16 changes: 0 additions & 16 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
### Changed
- Updated dependencies
- Switched from vercel/pkg to yao-pkg/pkg as vercel has deprecated pkg

- Updated to ESLint v9 and added formatting rules using @stylistic/eslint-plugin

## [3.0.0] - 2024-02-24
### Changed
Expand Down
19 changes: 8 additions & 11 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ const { queue } = require('async');
const { Command } = require('commander');
const cliProgress = require('cli-progress');
const prettyBytes = require('pretty-bytes');
const package = require('../package');
const { version, name } = require('../package');

const utility = require('../lib/utility');
const api = require('../lib/index');

const cli = new Command()
.version(package.version, '-v, --version', 'output the current version and exit')
.name(package.name)
.version(version, '-v, --version', 'output the current version and exit')
.name(name)
.usage('-u <username> -p <password> -f <file> [additional-options]')
.helpOption('-h, --help', 'output this help message and exit')
.requiredOption('-u, --username <string>', 'your Apple ID')
Expand All @@ -32,7 +32,6 @@ function formatValue(v, options, type) {
}

async function runUpload(ctx) {

let exitCode = 0;

const progressBar = new cliProgress.Bar({
Expand All @@ -43,7 +42,6 @@ async function runUpload(ctx) {
}, cliProgress.Presets.shades_classic);

try {

// Handle URLs to ipa file.
if (fileUrlRegex.test(ctx.filePath)) {
ctx.originalFilePath = ctx.filePath;
Expand All @@ -52,14 +50,15 @@ async function runUpload(ctx) {
let started = false;
ctx.filePath = await utility.downloadTempFile(ctx.filePath, (current, total) => {
let { speed, eta } = utility.formatSpeedAndEta(current, total, Date.now() - transferStartTime);
!started ? progressBar.start(total, current, { task: 'Downloading', speed, etas: eta })
!started
? progressBar.start(total, current, { task: 'Downloading', speed, etas: eta })
: progressBar.update(current, { speed, etas: eta });
started = true;
});
progressBar.stop();
}
catch (err) {
throw new Error(`Could not download file: ${err.message}`)
throw new Error(`Could not download file: ${err.message}`);
}
ctx.usingTempFile = true;
}
Expand All @@ -77,7 +76,7 @@ async function runUpload(ctx) {
}
catch (err) {
console.error(err.message);
throw new Error('Failed to extract Bundle ID and version, are you supplying a valid IPA-file?')
throw new Error('Failed to extract Bundle ID and version, are you supplying a valid IPA-file?');
}

// Authenticate with Apple.
Expand Down Expand Up @@ -109,7 +108,7 @@ async function runUpload(ctx) {

// Start uploading.
for (let reservation of reservations) {
let tasks = reservation.operations.map(operation => ({ ctx, reservation, operation }));
let tasks = reservation.operations.map((operation) => ({ ctx, reservation, operation }));
q.push(tasks, () => {
let { speed, eta } = utility.formatSpeedAndEta(ctx.bytesSent, ctx.metadataSize + ctx.fileSize, Date.now() - ctx.transferStartTime);
progressBar.update(ctx.bytesSent, { speed, etas: eta });
Expand Down Expand Up @@ -145,7 +144,6 @@ async function runUpload(ctx) {
}

async function run() {

// Parse command line params
cli.parse(process.argv);

Expand All @@ -164,7 +162,6 @@ async function run() {
}

function stop(signal) {

// Fix to make sure cursor gets restored to visible state when exiting mid progress.
process.stderr.write('\u001B[?25h');

Expand Down
32 changes: 32 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const js = require('@eslint/js');
const globals = require('globals');
const stylistic = require('@stylistic/eslint-plugin');
const jsdoc = require('eslint-plugin-jsdoc');

module.exports = [
js.configs.recommended,
stylistic.configs.customize({
indent: 2,
quotes: 'single',
quoteProps: 'as-needed',
arrowParens: true,
semi: true,
}),
{
files: ['**/*.js'],
plugins: {
jsdoc,
},
rules: {
'jsdoc/no-undefined-types': 1,
},
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
globals: {
...globals.node,
...globals.mocha,
},
},
},
];
Loading

0 comments on commit 3658ffe

Please sign in to comment.