@oribuild/api
Advanced tools
Comparing version 0.0.0-pre-alpha.1-79b581c to 0.0.0-pre-alpha.1-817554f
@@ -5,2 +5,3 @@ import { spawn } from 'child_process'; | ||
import fs from 'fs'; | ||
import { getOriServiceBinaryPath } from './getOriServiceBinaryPath.js'; | ||
let childProcess = undefined; | ||
@@ -17,2 +18,3 @@ let activePort; | ||
oriServicePort = await getPort({ port: [8080, 8090, 8100, 8110] }); | ||
oriServicePath = oriServicePath || (await getOriServiceBinaryPath()); | ||
// Create a resolvable promise which resolves when oriservice is started. | ||
@@ -19,0 +21,0 @@ return new Promise((resolve, reject) => { |
import path from 'path'; | ||
import resolve from 'resolve'; | ||
import { readJson } from './readJson.js'; | ||
import { fileURLToPath } from 'url'; | ||
const currentPath = path.dirname(fileURLToPath(import.meta.url)); | ||
export async function getOriServiceBinaryPath() { | ||
// First resolve the oriservice package. | ||
const oriServicePackagePath = await new Promise((complete) => resolve('oriservice/package.json', (err, value) => complete(value))); | ||
// If oriservice is not installed, don't resolve. | ||
if (!oriServicePackagePath) { | ||
throw new Error(`The package "oriservice" was not found.`); | ||
} | ||
// Then read the package to find all supported binaries. | ||
const oriServicePackage = await readJson(oriServicePackagePath); | ||
if (!oriServicePackage) { | ||
throw new Error(`The package.json for "oriservice" could not be parsed.`); | ||
const oriPackageDefinition = await readJson(path.resolve(currentPath, '../package.json')); | ||
if (!oriPackageDefinition) { | ||
throw new Error(`The package.json for "@oribuild/api" could not be parsed.`); | ||
} | ||
// Iterate through available binaries until we find the one installed. | ||
for (const binaryPackageName of Object.keys(oriServicePackage.optionalDependencies)) { | ||
const binaryPackagePath = await new Promise((complete) => resolve(`${binaryPackageName}/package.json`, (err, value) => complete(value))); | ||
for (const binaryPackageName of Object.keys(oriPackageDefinition.optionalDependencies)) { | ||
const binaryPackagePath = await new Promise((complete) => resolve(`${binaryPackageName}/package.json`, { basedir: currentPath }, (err, value) => complete(value))); | ||
if (binaryPackagePath) { | ||
@@ -20,0 +16,0 @@ const binaryPackage = await readJson(binaryPackagePath); |
@@ -1,4 +0,3 @@ | ||
export { getOriServiceBinaryPath } from './getOriServiceBinaryPath.js'; | ||
export { build } from './build.js'; | ||
export { ensureServiceStarted, stopService, type StartServiceOptions } from './ensureServiceStarted.js'; | ||
export type { AnalyzeMetafileOptions, BuildFailure, BuildIncremental, BuildInvalidate, BuildOptions, BuildResult, Charset, Drop, Format, FormatMessagesOptions, ImportKind, Loader, Location, LogLevel, Message, Metafile, Note, OnLoadArgs, OnLoadOptions, OnLoadResult, OnResolveArgs, OnResolveOptions, OnResolveResult, OnStartResult, OriServiceOptions, OutputFile, PartialMessage, PartialNote, Platform, ResolveOptions, ResolveResult, ServeOnRequestArgs, ServeOptions, ServeResult, StdinOptions, TransformFailure, TransformOptions, TransformResult, WatchMode, } from './types.js'; |
@@ -1,4 +0,3 @@ | ||
export { getOriServiceBinaryPath } from './getOriServiceBinaryPath.js'; | ||
export { build } from './build.js'; | ||
export { ensureServiceStarted, stopService } from './ensureServiceStarted.js'; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@oribuild/api", | ||
"version": "0.0.0-pre-alpha.1-79b581c", | ||
"version": "0.0.0-pre-alpha.1-817554f", | ||
"type": "module", | ||
@@ -16,2 +16,3 @@ "types": "./lib/index.d.ts", | ||
"resolve": "^1.22.0", | ||
"tree-kill": "^1.2.2", | ||
"ws": "^8.5.0" | ||
@@ -27,12 +28,11 @@ }, | ||
"git-root-dir": "^1.0.2", | ||
"tmp": "^0.2.1", | ||
"tree-kill": "^1.2.2" | ||
"tmp": "^0.2.1" | ||
}, | ||
"optionalDependencies": { | ||
"oriservice-darwin-amd64": "0.0.0-pre-alpha.1-79b581c", | ||
"oriservice-darwin-arm64": "0.0.0-pre-alpha.1-79b581c", | ||
"oriservice-linux-amd64": "0.0.0-pre-alpha.1-79b581c", | ||
"oriservice-linux-arm64": "0.0.0-pre-alpha.1-79b581c", | ||
"oriservice-windows-amd64": "0.0.0-pre-alpha.1-79b581c", | ||
"oriservice-windows-arm64": "0.0.0-pre-alpha.1-79b581c" | ||
"oriservice-darwin-amd64": "0.0.0-pre-alpha.1-817554f", | ||
"oriservice-darwin-arm64": "0.0.0-pre-alpha.1-817554f", | ||
"oriservice-linux-amd64": "0.0.0-pre-alpha.1-817554f", | ||
"oriservice-linux-arm64": "0.0.0-pre-alpha.1-817554f", | ||
"oriservice-windows-amd64": "0.0.0-pre-alpha.1-817554f", | ||
"oriservice-windows-arm64": "0.0.0-pre-alpha.1-817554f" | ||
}, | ||
@@ -39,0 +39,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
8
50519
10
838
+ Addedtree-kill@^1.2.2
+ Addedoriservice-darwin-amd64@0.0.0-pre-alpha.1-817554f(transitive)
+ Addedoriservice-darwin-arm64@0.0.0-pre-alpha.1-817554f(transitive)
+ Addedoriservice-linux-amd64@0.0.0-pre-alpha.1-817554f(transitive)
+ Addedoriservice-linux-arm64@0.0.0-pre-alpha.1-817554f(transitive)
+ Addedoriservice-windows-amd64@0.0.0-pre-alpha.1-817554f(transitive)
+ Addedoriservice-windows-arm64@0.0.0-pre-alpha.1-817554f(transitive)
+ Addedtree-kill@1.2.2(transitive)
- Removedoriservice-darwin-amd64@0.0.0-pre-alpha.1-79b581c(transitive)
- Removedoriservice-darwin-arm64@0.0.0-pre-alpha.1-79b581c(transitive)
- Removedoriservice-linux-amd64@0.0.0-pre-alpha.1-79b581c(transitive)
- Removedoriservice-linux-arm64@0.0.0-pre-alpha.1-79b581c(transitive)
- Removedoriservice-windows-amd64@0.0.0-pre-alpha.1-79b581c(transitive)
- Removedoriservice-windows-arm64@0.0.0-pre-alpha.1-79b581c(transitive)