Compare commits
1 Commits
feat/insta
...
fix/gatewa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80f8448a6f |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/cli",
|
"name": "@mosaic/cli",
|
||||||
"version": "0.0.11",
|
"version": "0.0.12",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.mosaicstack.dev/mosaic/mosaic-stack.git",
|
"url": "https://git.mosaicstack.dev/mosaic/mosaic-stack.git",
|
||||||
|
|||||||
@@ -91,24 +91,14 @@ export function resolveGatewayEntry(): string {
|
|||||||
return meta.entryPoint;
|
return meta.entryPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to resolve from globally installed @mosaicstack/gateway
|
// Try to resolve from globally installed @mosaic/gateway
|
||||||
try {
|
|
||||||
const req = createRequire(import.meta.url);
|
|
||||||
const pkgPath = req.resolve('@mosaicstack/gateway/package.json');
|
|
||||||
const mainEntry = join(resolve(pkgPath, '..'), 'dist', 'main.js');
|
|
||||||
if (existsSync(mainEntry)) return mainEntry;
|
|
||||||
} catch {
|
|
||||||
// Not installed globally via @mosaicstack
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try @mosaic/gateway (workspace / dev)
|
|
||||||
try {
|
try {
|
||||||
const req = createRequire(import.meta.url);
|
const req = createRequire(import.meta.url);
|
||||||
const pkgPath = req.resolve('@mosaic/gateway/package.json');
|
const pkgPath = req.resolve('@mosaic/gateway/package.json');
|
||||||
const mainEntry = join(resolve(pkgPath, '..'), 'dist', 'main.js');
|
const mainEntry = join(resolve(pkgPath, '..'), 'dist', 'main.js');
|
||||||
if (existsSync(mainEntry)) return mainEntry;
|
if (existsSync(mainEntry)) return mainEntry;
|
||||||
} catch {
|
} catch {
|
||||||
// Not available
|
// Not installed globally
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error('Cannot find gateway entry point. Run `mosaic gateway install` first.');
|
throw new Error('Cannot find gateway entry point. Run `mosaic gateway install` first.');
|
||||||
@@ -217,9 +207,11 @@ function sleep(ms: number): Promise<void> {
|
|||||||
|
|
||||||
// ─── npm install helper ─────────────────────────────────────────────────────
|
// ─── npm install helper ─────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
const GITEA_REGISTRY = 'https://git.mosaicstack.dev/api/packages/mosaic/npm/';
|
||||||
|
|
||||||
export function installGatewayPackage(): void {
|
export function installGatewayPackage(): void {
|
||||||
console.log('Installing @mosaicstack/gateway...');
|
console.log('Installing @mosaic/gateway from Gitea registry...');
|
||||||
execSync('npm install -g @mosaicstack/gateway@latest', {
|
execSync(`npm install -g @mosaic/gateway@latest --registry=${GITEA_REGISTRY}`, {
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
timeout: 120_000,
|
timeout: 120_000,
|
||||||
});
|
});
|
||||||
@@ -227,7 +219,7 @@ export function installGatewayPackage(): void {
|
|||||||
|
|
||||||
export function uninstallGatewayPackage(): void {
|
export function uninstallGatewayPackage(): void {
|
||||||
try {
|
try {
|
||||||
execSync('npm uninstall -g @mosaicstack/gateway', {
|
execSync('npm uninstall -g @mosaic/gateway', {
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
timeout: 60_000,
|
timeout: 60_000,
|
||||||
});
|
});
|
||||||
@@ -238,15 +230,15 @@ export function uninstallGatewayPackage(): void {
|
|||||||
|
|
||||||
export function getInstalledGatewayVersion(): string | null {
|
export function getInstalledGatewayVersion(): string | null {
|
||||||
try {
|
try {
|
||||||
const output = execSync('npm ls -g @mosaicstack/gateway --json --depth=0', {
|
const output = execSync('npm ls -g @mosaic/gateway --json --depth=0', {
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
timeout: 15_000,
|
timeout: 15_000,
|
||||||
stdio: ['pipe', 'pipe', 'pipe'],
|
stdio: ['pipe', 'pipe', 'pipe'],
|
||||||
});
|
});
|
||||||
const data = JSON.parse(output) as {
|
const data = JSON.parse(output) as {
|
||||||
dependencies?: { '@mosaicstack/gateway'?: { version?: string } };
|
dependencies?: { '@mosaic/gateway'?: { version?: string } };
|
||||||
};
|
};
|
||||||
return data.dependencies?.['@mosaicstack/gateway']?.version ?? null;
|
return data.dependencies?.['@mosaic/gateway']?.version ?? null;
|
||||||
} catch {
|
} catch {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ async function doInstall(rl: ReturnType<typeof createInterface>, opts: InstallOp
|
|||||||
entryPoint = resolveGatewayEntry();
|
entryPoint = resolveGatewayEntry();
|
||||||
} catch {
|
} catch {
|
||||||
console.error('Error: Gateway package not found after install.');
|
console.error('Error: Gateway package not found after install.');
|
||||||
console.error('Check that @mosaicstack/gateway installed correctly.');
|
console.error('Check that @mosaic/gateway installed correctly.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/mosaic",
|
"name": "@mosaic/mosaic",
|
||||||
"version": "0.0.11",
|
"version": "0.0.12",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.mosaicstack.dev/mosaic/mosaic-stack.git",
|
"url": "https://git.mosaicstack.dev/mosaic/mosaic-stack.git",
|
||||||
|
|||||||
Reference in New Issue
Block a user