-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from tractr/next
feat(cli): improve errors logging
- Loading branch information
Showing
15 changed files
with
165 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { ExtensionClient, NO_ID_MAP_MESSAGE } from './extension-client'; | ||
import { MigrationClient } from './migration-client'; | ||
import { Service } from 'typedi'; | ||
|
||
@Service() | ||
export class PingClient extends ExtensionClient { | ||
constructor(migrationClient: MigrationClient) { | ||
super(migrationClient); | ||
} | ||
|
||
/** Try to get a fake id map in order to check if the server is up and the extension is installed */ | ||
async test() { | ||
const response = await this.fetch<unknown>( | ||
`/table/__ping_test__/sync_id/__ping_test__`, | ||
'GET', | ||
) | ||
.then(() => ({ success: true })) | ||
.catch((error: Error) => ({ error })); | ||
|
||
if ('success' in response) { | ||
return; // Should not happen | ||
} | ||
|
||
if (response.error.message === NO_ID_MAP_MESSAGE) { | ||
return; | ||
} | ||
|
||
throw response.error; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
packages/e2e/configs/config-path-info/directus-sync.config.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module.exports = { | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Context } from '../helpers/index.js'; | ||
|
||
export const configPathInfo = (context: Context) => { | ||
it('ensure logs show info about missing config file when wrong path is provided', async () => { | ||
// Init sync client | ||
const sync = await context.getSync( | ||
'sources/empty-collections', | ||
'wrong-path/directus-sync.config.cjs', | ||
); | ||
|
||
const output = await sync.diff(); | ||
const log = output.find((l) => l.msg.includes('No config file found')); | ||
|
||
expect(log).toBeDefined(); | ||
expect(log?.msg).toContain('wrong-path/directus-sync.config.cjs'); | ||
}); | ||
|
||
it('ensure log shows info about missing config file for default files', async () => { | ||
// Init sync client | ||
const sync = await context.getSync('sources/empty-collections'); | ||
|
||
const output = await sync.diff(); | ||
const log = output.find((l) => l.msg.includes('No config file found')); | ||
|
||
expect(log).toBeDefined(); | ||
expect(log?.msg).toContain('e2e/directus-sync.config.cjs'); | ||
expect(log?.msg).toContain('e2e/directus-sync.config.js'); | ||
expect(log?.msg).toContain('e2e/directus-sync.config.json'); | ||
}); | ||
|
||
it('ensure logs show info when config path exists', async () => { | ||
// Init sync client | ||
const sync = await context.getSync( | ||
'sources/empty-collections', | ||
'config-path-info/directus-sync.config.cjs', | ||
); | ||
|
||
const output = await sync.diff(); | ||
const log = output.find((l) => l.msg.includes('Loaded config file from')); | ||
|
||
expect(log?.msg).toContain('config-path-info/directus-sync.config.cjs'); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './config-path-info.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters