Skip to content

Commit

Permalink
Merge pull request #1767 from flexn-io/fix/tizen_cert_edgecases
Browse files Browse the repository at this point in the history
Fix tizen certificate edgecases
  • Loading branch information
pauliusguzas authored Oct 25, 2024
2 parents 909416b + 59d8497 commit 6f8dd87
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions packages/sdk-tizen/src/tasks/taskChangeCertificate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ export default createTask({
if (!confirm) {
return;
}
const { platform } = await inquirerPrompt({
const { selectedPlatforms } = await inquirerPrompt({
message: 'For which platform do you want to set the new certificate?',
type: 'list',
name: 'platform',
choices: ['tizen', 'tizenwatch', 'tizenmobile'],
type: 'checkbox',
name: 'selectedPlatforms',
choices: ctx.buildConfig.defaults?.supportedPlatforms?.filter((platform) =>
platform.includes('tizen')
),
pageSize: 20,
validate: (val) => !!val.length || 'Please select at least a platform',
});
const { name } = await inquirerPrompt({
message: 'Enter the new certificate name:',
Expand All @@ -37,7 +41,7 @@ export default createTask({
const configContent = JSON.stringify(
{
platforms: {
[platform]: {
[selectedPlatforms[0]]: {
certificateProfile: name,
},
},
Expand All @@ -47,16 +51,17 @@ export default createTask({
);

fs.writeFileSync(config, configContent);
return;
}

const configFile = await JSON.parse(fs.readFileSync(config, 'utf-8'));

if (!configFile.platforms[platform]) {
configFile.platforms[platform] = {};
}
selectedPlatforms.forEach((platform: string) => {
if (!configFile.platforms[platform]) {
configFile.platforms[platform] = {};
}

configFile.platforms[`${platform}`].certificateProfile = name;
configFile.platforms[`${platform}`].certificateProfile = name;
});

fs.writeFileSync(config, JSON.stringify(configFile, null, 2));

Expand Down

0 comments on commit 6f8dd87

Please sign in to comment.