fix: simplify updater to @mosaic/mosaic only, add explicit tea repo/login flags (#388)
This commit was merged in pull request #388.
This commit is contained in:
@@ -88,19 +88,18 @@ describe('formatUpdateNotice', () => {
|
||||
expect(notice).toContain('Update available');
|
||||
});
|
||||
|
||||
it('uses @mosaic/mosaic hints for modern installs', async () => {
|
||||
it('uses @mosaic/mosaic for installs', async () => {
|
||||
execSyncMock.mockImplementation((command: string) => {
|
||||
if (command.includes('ls -g --depth=0 --json')) {
|
||||
return JSON.stringify({
|
||||
dependencies: {
|
||||
'@mosaic/mosaic': { version: '0.0.17' },
|
||||
'@mosaic/cli': { version: '0.0.16' },
|
||||
'@mosaic/mosaic': { version: '0.0.19' },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (command.includes('view @mosaic/mosaic version')) {
|
||||
return '0.0.18';
|
||||
return '0.0.20';
|
||||
}
|
||||
|
||||
throw new Error(`Unexpected command: ${command}`);
|
||||
@@ -110,28 +109,29 @@ describe('formatUpdateNotice', () => {
|
||||
const result = checkForUpdate({ skipCache: true });
|
||||
const notice = formatUpdateNotice(result);
|
||||
|
||||
expect(result.current).toBe('0.0.17');
|
||||
expect(result.latest).toBe('0.0.18');
|
||||
expect(result.current).toBe('0.0.19');
|
||||
expect(result.latest).toBe('0.0.20');
|
||||
expect(result.currentPackage).toBe('@mosaic/mosaic');
|
||||
expect(result.targetPackage).toBe('@mosaic/mosaic');
|
||||
expect(notice).toContain('@mosaic/mosaic@latest');
|
||||
expect(notice).not.toContain('@mosaic/cli@latest');
|
||||
});
|
||||
|
||||
it('falls back to @mosaic/mosaic for legacy @mosaic/cli installs when cli is unavailable', async () => {
|
||||
it('does not query legacy @mosaic/cli package', async () => {
|
||||
execSyncMock.mockImplementation((command: string) => {
|
||||
if (command.includes('view @mosaic/cli')) {
|
||||
throw new Error('Should not query @mosaic/cli');
|
||||
}
|
||||
|
||||
if (command.includes('ls -g --depth=0 --json')) {
|
||||
return JSON.stringify({
|
||||
dependencies: {
|
||||
'@mosaic/cli': { version: '0.0.16' },
|
||||
'@mosaic/mosaic': { version: '0.0.19' },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (command.includes('view @mosaic/cli version')) {
|
||||
throw new Error('not found');
|
||||
}
|
||||
|
||||
if (command.includes('view @mosaic/mosaic version')) {
|
||||
return '0.0.17';
|
||||
return '0.0.20';
|
||||
}
|
||||
|
||||
throw new Error(`Unexpected command: ${command}`);
|
||||
@@ -139,57 +139,31 @@ describe('formatUpdateNotice', () => {
|
||||
|
||||
const { checkForUpdate } = await importUpdateChecker();
|
||||
const result = checkForUpdate({ skipCache: true });
|
||||
const notice = formatUpdateNotice(result);
|
||||
|
||||
expect(result.current).toBe('0.0.16');
|
||||
expect(result.latest).toBe('0.0.17');
|
||||
expect(notice).toContain('@mosaic/mosaic@latest');
|
||||
expect(result.targetPackage).toBe('@mosaic/mosaic');
|
||||
expect(result.latest).toBe('0.0.20');
|
||||
// Verify no @mosaic/cli queries were made
|
||||
const calls = execSyncMock.mock.calls.map((c: any[]) => c[0] as string);
|
||||
expect(calls.some((c) => c.includes('@mosaic/cli'))).toBe(false);
|
||||
});
|
||||
|
||||
it('does not reuse a cached modern-package result for a legacy install', async () => {
|
||||
let installedPackage = '@mosaic/mosaic';
|
||||
|
||||
it('returns empty result when package is not installed', async () => {
|
||||
execSyncMock.mockImplementation((command: string) => {
|
||||
if (command.includes('ls -g --depth=0 --json')) {
|
||||
return JSON.stringify({
|
||||
dependencies:
|
||||
installedPackage === '@mosaic/mosaic'
|
||||
? { '@mosaic/mosaic': { version: '0.0.17' } }
|
||||
: { '@mosaic/cli': { version: '0.0.16' } },
|
||||
});
|
||||
return JSON.stringify({ dependencies: {} });
|
||||
}
|
||||
|
||||
if (command.includes('view @mosaic/mosaic version')) {
|
||||
return installedPackage === '@mosaic/mosaic' ? '0.0.18' : '0.0.17';
|
||||
}
|
||||
|
||||
if (command.includes('view @mosaic/cli version')) {
|
||||
throw new Error('not found');
|
||||
return '';
|
||||
}
|
||||
|
||||
throw new Error(`Unexpected command: ${command}`);
|
||||
});
|
||||
|
||||
const { checkForUpdate } = await importUpdateChecker();
|
||||
const result = checkForUpdate({ skipCache: true });
|
||||
|
||||
const modernResult = checkForUpdate();
|
||||
installedPackage = '@mosaic/cli';
|
||||
const legacyResult = checkForUpdate();
|
||||
|
||||
expect(modernResult.currentPackage).toBe('@mosaic/mosaic');
|
||||
expect(modernResult.targetPackage).toBe('@mosaic/mosaic');
|
||||
expect(modernResult.latest).toBe('0.0.18');
|
||||
|
||||
expect(legacyResult.currentPackage).toBe('@mosaic/cli');
|
||||
expect(legacyResult.targetPackage).toBe('@mosaic/mosaic');
|
||||
expect(legacyResult.latest).toBe('0.0.17');
|
||||
expect(execSyncMock).toHaveBeenCalledWith(
|
||||
expect.stringContaining('view @mosaic/cli version'),
|
||||
expect.any(Object),
|
||||
);
|
||||
expect(execSyncMock).toHaveBeenCalledWith(
|
||||
expect.stringContaining('view @mosaic/mosaic version'),
|
||||
expect.any(Object),
|
||||
);
|
||||
expect(result.current).toBe('');
|
||||
expect(result.updateAvailable).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user