-
-
Notifications
You must be signed in to change notification settings - Fork 183
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 #1734 from flexn-io/fix/tizen-change-certificates
Being able to change tizen certificate from default RNV to custom ones
- Loading branch information
Showing
5 changed files
with
60 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { createTask, inquirerPrompt, logInfo, RnvTaskName } from '@rnv/core'; | ||
import fs from 'fs'; | ||
import { checkTizenStudioCert } from '../runner'; | ||
|
||
export default createTask({ | ||
description: 'Change tizen certificate', | ||
dependsOn: [RnvTaskName.appConfigure], | ||
fn: async ({ ctx }) => { | ||
for (const config of ctx.paths.appConfig.configs) { | ||
if (config.includes('base')) { | ||
const configFile = await JSON.parse(fs.readFileSync(config, 'utf-8')); | ||
const { confirm } = await inquirerPrompt({ | ||
message: | ||
'Tizen - used certificate change. NOTE: you must create the certificate first through the tizens certificate-manager. Continue?', | ||
type: 'confirm', | ||
name: 'confirm', | ||
}); | ||
if (!confirm) { | ||
return; | ||
} | ||
const { platform } = await inquirerPrompt({ | ||
message: 'For which platform do you want to set the new certificate?', | ||
type: 'list', | ||
name: 'platform', | ||
choices: ['tizen', 'tizenwatch', 'tizenmobile'], | ||
}); | ||
const { name } = await inquirerPrompt({ | ||
message: 'Enter the new certificate name:', | ||
type: 'input', | ||
name: 'name', | ||
}); | ||
if (name === '') { | ||
logInfo('No certificate name entered.'); | ||
return; | ||
} | ||
|
||
configFile.platforms[`${platform}`].certificateProfile = name; | ||
|
||
fs.writeFileSync(config, JSON.stringify(configFile, null, 2)); | ||
|
||
await checkTizenStudioCert(); | ||
|
||
// if user inputs a certificate name that doesn't exist, it still sets the certificate name. | ||
// This isn't a problem if running rnv run -p tizen, because it will create the certificate, but that isn't ideal, so should be fixed. | ||
return; | ||
} | ||
} | ||
}, | ||
task: RnvTaskName.tizenCertificate, | ||
isGlobalScope: true, | ||
}); |