mirror of
https://github.com/unraid/api.git
synced 2026-02-19 06:28:29 -06:00
@@ -105,7 +105,7 @@ NCHAN=disable \ # Disable nchan polling
|
||||
PATHS_DYNAMIX_CONFIG=$(pwd)/dev/dynamix/dynamix.cfg \ # Dynamix's config file
|
||||
PATHS_MY_SERVERS_CONFIG=$(pwd)/dev/unraid.net/myservers.cfg \ # My servers config file
|
||||
PORT=8500 \ # What port unraid-api should start on (e.g. /var/run/unraid-api.sock or 8000)
|
||||
node dist/cli.cjs --debug # Enable debug logging
|
||||
node dist/cli.js --debug # Enable debug logging
|
||||
```
|
||||
|
||||
## Release
|
||||
|
||||
@@ -9,8 +9,6 @@ import camelCase from 'camelcase';
|
||||
import globby from 'globby';
|
||||
import pIteration from 'p-iteration';
|
||||
import clearModule from 'clear-module';
|
||||
import { dirname } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { coreLogger } from './log';
|
||||
import { paths } from './paths';
|
||||
import { subscribeToNchanEndpoint } from './utils';
|
||||
@@ -35,8 +33,6 @@ const loadingLogger = (namespace: string): void => {
|
||||
coreLogger.debug('Loading %s', namespace);
|
||||
};
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
/**
|
||||
* Register state paths.
|
||||
*/
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
* Copyright 2019-2020 Lime Technology Inc. All rights reserved.
|
||||
* Written by: Alexis Tyler
|
||||
*/
|
||||
import { dirname } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
export interface Paths {
|
||||
core: string;
|
||||
@@ -26,7 +24,6 @@ export interface Paths {
|
||||
'extra-origins': string;
|
||||
}
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const thisDir = __dirname;
|
||||
|
||||
// This will allow `PATHS_` to be set an as env
|
||||
|
||||
@@ -14,14 +14,11 @@ const config = {
|
||||
files: [
|
||||
'./test/**/*'
|
||||
],
|
||||
"extensions": {
|
||||
"ts": "module"
|
||||
},
|
||||
"nonSemVerExperiments": {
|
||||
"configurableModuleFormat": true
|
||||
},
|
||||
"nodeArguments": [
|
||||
"--loader=ts-node/esm"
|
||||
extensions: [
|
||||
'ts'
|
||||
],
|
||||
require: [
|
||||
'ts-node/register/transpile-only'
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
30
package-lock.json
generated
30
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@unraid/api",
|
||||
"version": "2.24.0",
|
||||
"version": "2.23.5",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@@ -1535,10 +1535,16 @@
|
||||
"integrity": "sha512-fZQQafSREFyuZcdWFAExYjBiCL7AUCdgsk80iO0q4yihYYdcIiH28CcuPTGFgLOCC8RlW49GSQxdHwZP+I7CNg==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/nanoajax": {
|
||||
"version": "0.2.30",
|
||||
"resolved": "https://registry.npmjs.org/@types/nanoajax/-/nanoajax-0.2.30.tgz",
|
||||
"integrity": "sha512-gsC1dTR1cC3BVXQ0J3ZSe5Romn4BjdkJF1Q2aLcT+wpmFfYcfcNarn4nmLT+EZUoJcs7tjj7rezxJFgxZ1uT4g==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "16.7.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.7.8.tgz",
|
||||
"integrity": "sha512-8upnoQU0OPzbIkm+ZMM0zCeFCkw2s3mS0IWdx0+AAaWqm4fkBb0UJp8Edl7FVKRamYbpJC/aVsHpKWBIbiC7Zg=="
|
||||
"version": "16.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.0.0.tgz",
|
||||
"integrity": "sha512-TmCW5HoZ2o2/z2EYi109jLqIaPIi9y/lc2LmDCWzuCi35bcaQ+OtUh6nwBiFK7SOu25FAU5+YKdqFZUwtqGSdg=="
|
||||
},
|
||||
"@types/normalize-package-data": {
|
||||
"version": "2.4.0",
|
||||
@@ -1822,9 +1828,8 @@
|
||||
}
|
||||
},
|
||||
"@vmngr/libvirt": {
|
||||
"version": "github:omgimalexis/libvirt#0afc3936c22d1bb20394ba8e9c7526ab9fd279db",
|
||||
"from": "github:omgimalexis/libvirt",
|
||||
"optional": true,
|
||||
"version": "github:OmgImAlexis/libvirt#0afc3936c22d1bb20394ba8e9c7526ab9fd279db",
|
||||
"from": "github:OmgImAlexis/libvirt",
|
||||
"requires": {
|
||||
"bindings": "^1.5.0",
|
||||
"node-addon-api": "^3.2.0",
|
||||
@@ -2777,7 +2782,6 @@
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
|
||||
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"file-uri-to-path": "1.0.0"
|
||||
}
|
||||
@@ -9891,8 +9895,7 @@
|
||||
"node-addon-api": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.2.1.tgz",
|
||||
"integrity": "sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==",
|
||||
"optional": true
|
||||
"integrity": "sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A=="
|
||||
},
|
||||
"node-cache": {
|
||||
"version": "5.1.2",
|
||||
@@ -11530,8 +11533,7 @@
|
||||
"sax": {
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
|
||||
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==",
|
||||
"optional": true
|
||||
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
|
||||
},
|
||||
"scheduler": {
|
||||
"version": "0.19.1",
|
||||
@@ -13736,7 +13738,6 @@
|
||||
"version": "0.4.23",
|
||||
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz",
|
||||
"integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"sax": ">=0.6.0",
|
||||
"xmlbuilder": "~11.0.0"
|
||||
@@ -13745,8 +13746,7 @@
|
||||
"xmlbuilder": {
|
||||
"version": "11.0.1",
|
||||
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz",
|
||||
"integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==",
|
||||
"optional": true
|
||||
"integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA=="
|
||||
},
|
||||
"xss": {
|
||||
"version": "1.0.9",
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
"repository": "git@github.com:unraid/api.git",
|
||||
"author": "Alexis Tyler <xo@wvvw.me> (https://wvvw.me/)",
|
||||
"license": "UNLICENSED",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "npm run build-app && npm run build-cli && npm run copy-schemas",
|
||||
"build-app": "npx tsup ./app/index.ts",
|
||||
"build-cli": "npx tsup ./app/cli.ts",
|
||||
"build-binary-step-1": "nexe ./dist/cli.cjs --make=\"-j$(nproc 2> /dev/null || echo 1)\" -r './dist/**/*' -r './node_modules' && mv ./cli ./unraid-api && echo '✔ Binary built: ./unraid-api'",
|
||||
"build-binary-step-1": "nexe ./dist/cli.js --make=\"-j$(nproc 2> /dev/null || echo 1)\" -r './dist/**/*' -r './node_modules' && mv ./cli ./unraid-api && echo '✔ Binary built: ./unraid-api'",
|
||||
"build-binary-step-2": "rm -rf ./node_modules && rm -rf ./dist && echo '✔ Source files deleted'",
|
||||
"build-binary": "npm run build-binary-step-1 && npm run build-binary-step-2",
|
||||
"copy-schemas": "cpx app/**/*.graphql dist/types",
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
import { promisify } from 'util';
|
||||
import { dirname } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { join as joinPath, resolve as resolvePath } from 'path';
|
||||
import { exec as execWithCallback } from 'child_process';
|
||||
import { writeFileSync, readFileSync } from 'fs';
|
||||
import ava, { TestInterface } from 'ava';
|
||||
import tempy from 'tempy';
|
||||
import ava, { TestInterface } from 'ava';
|
||||
|
||||
const exec = promisify(execWithCallback);
|
||||
|
||||
const test = ava as TestInterface<{ paths: Record<string, string> }>;
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
const stagingEnv = readFileSync(resolvePath(__dirname, '..', '.env.staging'), 'utf-8');
|
||||
const productionEnv = readFileSync(resolvePath(__dirname, '..', '.env.production'), 'utf-8');
|
||||
|
||||
test.beforeEach(async t => {
|
||||
test.beforeEach(t => {
|
||||
t.context = {
|
||||
paths: {
|
||||
PATHS_MYSERVERS_ENV: tempy.file({ name: 'env' }),
|
||||
@@ -36,7 +32,7 @@ test.serial('Loads production when no env is set', async t => {
|
||||
writeFileSync(PATHS_MYSERVERS_ENV, '');
|
||||
|
||||
// Run 'switch-env'
|
||||
const { stdout: output } = await exec(`PATHS_MYSERVERS_ENV=${PATHS_MYSERVERS_ENV} PATHS_UNRAID_API_BASE=${PATHS_UNRAID_API_BASE} ${process.execPath} ./dist/cli.cjs switch-env`);
|
||||
const { stdout: output } = await exec(`PATHS_MYSERVERS_ENV=${PATHS_MYSERVERS_ENV} PATHS_UNRAID_API_BASE=${PATHS_UNRAID_API_BASE} ${process.execPath} ./dist/cli.js switch-env`);
|
||||
|
||||
// Split the lines
|
||||
const lines = output.split('\n');
|
||||
@@ -62,7 +58,7 @@ test.serial('Loads production when switching from staging', async t => {
|
||||
writeFileSync(PATHS_MYSERVERS_ENV, 'env="staging"');
|
||||
|
||||
// Run 'switch-env'
|
||||
const { stdout: output } = await exec(`PATHS_MYSERVERS_ENV=${PATHS_MYSERVERS_ENV} PATHS_UNRAID_API_BASE=${PATHS_UNRAID_API_BASE} ${process.execPath} ./dist/cli.cjs switch-env`);
|
||||
const { stdout: output } = await exec(`PATHS_MYSERVERS_ENV=${PATHS_MYSERVERS_ENV} PATHS_UNRAID_API_BASE=${PATHS_UNRAID_API_BASE} ${process.execPath} ./dist/cli.js switch-env`);
|
||||
|
||||
// Split the lines
|
||||
const lines = output.split('\n');
|
||||
@@ -87,7 +83,7 @@ test.serial('Loads staging when switching from production', async t => {
|
||||
writeFileSync(PATHS_MYSERVERS_ENV, 'env="production"');
|
||||
|
||||
// Run 'switch-env'
|
||||
const { stdout: output } = await exec(`PATHS_MYSERVERS_ENV=${PATHS_MYSERVERS_ENV} PATHS_UNRAID_API_BASE=${PATHS_UNRAID_API_BASE} ${process.execPath} ./dist/cli.cjs switch-env`);
|
||||
const { stdout: output } = await exec(`PATHS_MYSERVERS_ENV=${PATHS_MYSERVERS_ENV} PATHS_UNRAID_API_BASE=${PATHS_UNRAID_API_BASE} ${process.execPath} ./dist/cli.js switch-env`);
|
||||
|
||||
// Split the lines
|
||||
const lines = output.split('\n');
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
"skipLibCheck": true,
|
||||
/* Basic Options */
|
||||
// "incremental": true, /* Enable incremental compilation */
|
||||
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||
"module": "esnext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||
"target": "es2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||
// "lib": [], /* Specify library files to be included in the compilation. */
|
||||
"allowJs": false, /* Allow javascript files to be compiled. */
|
||||
// "checkJs": true, /* Report errors in .js files. */
|
||||
@@ -47,7 +47,7 @@
|
||||
"noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||
|
||||
/* Module Resolution Options */
|
||||
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||
|
||||
Reference in New Issue
Block a user