Skip to content

feat: review error message if Satellite ID is missing in config #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion plugins/plugin-tools/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@ const junoConfigSatelliteId = async ({mode}: ConfigArgs): Promise<string> => {
const satelliteId = ids?.[mode] ?? id ?? deprecatedSatelliteId;

if (satelliteId === undefined) {
if (mode === MODE_DEVELOPMENT) {
throw new JunoPluginError(
`Your configuration is invalid. A Satellite ID for ${mode} must be provided.`
);
}

throw new JunoPluginError(
`Your configuration is invalid. A satellite ID for ${mode} must be set in your configuration file.`
`Your project needs a Satellite for ${mode}. Create one at https://console.juno.build and set its ID in your configuration file.`
);
}

Expand Down
25 changes: 22 additions & 3 deletions plugins/plugin-tools/src/init.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,35 @@ describe('init', () => {
},
mode: MODE_DEVELOPMENT
})
).rejects.toThrow(/A satellite ID for development must be set/);
).rejects.toThrow(
'Your configuration is invalid. A Satellite ID for development must be provided.'
);
});

it('throws if satelliteId is missing in config in development', async () => {
vi.spyOn(configLoader, 'readJunoConfig').mockResolvedValueOnce({
satellite: {}
} as unknown as JunoConfig);

await expect(
initConfig({
params: {
container: false
},
mode: MODE_DEVELOPMENT
})
).rejects.toThrow(
'Your configuration is invalid. A Satellite ID for development must be provided.'
);
});

it('throws if satelliteId is missing in config', async () => {
it('throws if satelliteId is missing in config in production', async () => {
vi.spyOn(configLoader, 'readJunoConfig').mockResolvedValueOnce({
satellite: {}
} as unknown as JunoConfig);

await expect(initConfig(args)).rejects.toThrow(
/Your configuration is invalid. A satellite ID for production must be set in your configuration file./
'Your project needs a Satellite for production. Create one at https://console.juno.build and set its ID in your configuration file.'
);
});
});