From 370b5f1b562133b2ce381fb3c3c59f6df25e805b Mon Sep 17 00:00:00 2001 From: YDKK Date: Sat, 7 May 2022 22:33:51 +0900 Subject: [PATCH 1/5] Update util.ts --- src/util.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util.ts b/src/util.ts index 8614a3e..99be856 100644 --- a/src/util.ts +++ b/src/util.ts @@ -19,7 +19,7 @@ const debug = createDebug('cli'); export const paths = getPaths('nxapi'); -export const dir = path.resolve(import.meta.url.substr(7), '..', '..'); +export const dir = path.resolve(import.meta.url.substr(process.platform === 'win32' ? 8 : 7), '..', '..'); export const pkg = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf-8')); export const version = pkg.version; export const git = (() => { From 355cefe3823b0f68cbc7d799dcaccb851f3c9a6b Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Sat, 7 May 2022 23:02:43 +0100 Subject: [PATCH 2/5] Fix running from a path with spaces --- src/util.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util.ts b/src/util.ts index 99be856..df9280f 100644 --- a/src/util.ts +++ b/src/util.ts @@ -19,7 +19,7 @@ const debug = createDebug('cli'); export const paths = getPaths('nxapi'); -export const dir = path.resolve(import.meta.url.substr(process.platform === 'win32' ? 8 : 7), '..', '..'); +export const dir = path.resolve(decodeURI(import.meta.url.substr(process.platform === 'win32' ? 8 : 7)), '..', '..'); export const pkg = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf-8')); export const version = pkg.version; export const git = (() => { From 2dbd394cd9c6a24bf559fc333098194d7a0d5a79 Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Sat, 7 May 2022 23:07:37 +0100 Subject: [PATCH 3/5] Use Node.js v17 in CI npm install fails with Node.js v18 as there's no prebuilt Frida bindings. --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 92d2914..0223349 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: node:latest +image: node:17 cache: paths: From e46e1e46fb85670cdcdff21ecddaa191d519977c Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Sat, 7 May 2022 23:18:23 +0100 Subject: [PATCH 4/5] Always get package root directory from src/util.ts --- src/app/main/index.ts | 5 ++--- src/cli/android-znca-api-server-frida.ts | 4 ++-- src/cli/update.ts | 4 +--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/app/main/index.ts b/src/app/main/index.ts index fb10785..9c39ed1 100644 --- a/src/app/main/index.ts +++ b/src/app/main/index.ts @@ -6,7 +6,7 @@ import * as persist from 'node-persist'; import fetch from 'node-fetch'; import dotenv from 'dotenv'; import dotenvExpand from 'dotenv-expand'; -import { dev, getToken, initStorage, LoopResult, paths } from '../../util.js'; +import { dev, dir, getToken, initStorage, LoopResult, paths } from '../../util.js'; import MenuApp from './menu.js'; import { ZncDiscordPresence } from '../../cli/nso/presence.js'; import { WebServiceIpc } from './webservices.js'; @@ -16,8 +16,7 @@ import { ErrorResponse } from '../../api/util.js'; const debug = createDebug('app:main'); -const __dirname = path.join(import.meta.url.substr(7), '..'); -export const bundlepath = path.join(import.meta.url.substr(7), '..', '..', 'bundle'); +export const bundlepath = path.resolve(dir, 'dist', 'bundle'); function createWindow() { // Create the browser window. diff --git a/src/cli/android-znca-api-server-frida.ts b/src/cli/android-znca-api-server-frida.ts index bde0842..cb7927d 100644 --- a/src/cli/android-znca-api-server-frida.ts +++ b/src/cli/android-znca-api-server-frida.ts @@ -6,7 +6,7 @@ import frida, { Session } from 'frida'; import express from 'express'; import bodyParser from 'body-parser'; import type { Arguments as ParentArguments } from '../cli.js'; -import { ArgumentsCamelCase, Argv, getJwks, initStorage, YargsArguments } from '../util.js'; +import { ArgumentsCamelCase, Argv, dir, getJwks, initStorage, YargsArguments } from '../util.js'; import { Jwt } from '../api/util.js'; import { NintendoAccountIdTokenJwtPayload } from '../api/na.js'; import { ZNCA_CLIENT_ID, ZncJwtPayload } from '../api/znc.js'; @@ -271,7 +271,7 @@ async function setup(argv: ArgumentsCamelCase) { '-s', argv.device, 'push', - path.join(import.meta.url.substr(7), '..', '..', '..', 'resources', 'android-znca-api-server.sh'), + path.join(dir, 'resources', 'android-znca-api-server.sh'), '/data/local/tmp/android-znca-api-server.sh', ], { stdio: 'inherit', diff --git a/src/cli/update.ts b/src/cli/update.ts index e4d7853..c9cfa12 100644 --- a/src/cli/update.ts +++ b/src/cli/update.ts @@ -3,15 +3,13 @@ import * as fs from 'fs/promises'; import fetch from 'node-fetch'; import createDebug from 'debug'; import mkdirp from 'mkdirp'; -import { paths, version } from '../util.js'; +import { dir, paths, version } from '../util.js'; const debug = createDebug('cli:update'); const RELEASES_URL = 'https://api.github.com/repos/samuelthomas2774/nxapi/releases'; export async function checkUpdates() { - const dir = path.resolve(import.meta.url.substr(7), '..', '..', '..'); - try { await fs.stat(path.join(dir, '.git')); From 7ba59ac3545d9fdf745aec5c243783b0543865f4 Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Sat, 7 May 2022 23:18:30 +0100 Subject: [PATCH 5/5] v0.2.1 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index a5cdcf9..9561e29 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "nxapi", - "version": "0.2.0", + "version": "0.2.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "nxapi", - "version": "0.2.0", + "version": "0.2.1", "dependencies": { "body-parser": "^1.19.2", "cli-table": "^0.3.11", diff --git a/package.json b/package.json index ff09a93..035b38a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nxapi", - "version": "0.2.0", + "version": "0.2.1", "description": "", "author": "Samuel Elliott", "main": "dist/index.js",