From 9b678d1013dc4087393611ea380b065989c68a68 Mon Sep 17 00:00:00 2001 From: Justinas Date: Fri, 27 Sep 2024 07:43:26 +0300 Subject: [PATCH] wip: being able to change tizen certificate, and not only just RNV one easier --- packages/core/src/enums/taskName.ts | 1 + packages/sdk-tizen/src/index.ts | 3 +- .../src/tasks/taskChangeCertificate.ts | 28 +++++++++++++++++++ .../appConfigs/base/renative.json | 6 ++-- 4 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 packages/sdk-tizen/src/tasks/taskChangeCertificate.ts diff --git a/packages/core/src/enums/taskName.ts b/packages/core/src/enums/taskName.ts index 393e1edd5..d61f291fe 100644 --- a/packages/core/src/enums/taskName.ts +++ b/packages/core/src/enums/taskName.ts @@ -61,4 +61,5 @@ export const RnvTaskName = { telemetryStatus: 'telemetry status', config: 'config', patchReset: 'patch reset', + tizenCertificate: 'tizen certificate', } as const; diff --git a/packages/sdk-tizen/src/index.ts b/packages/sdk-tizen/src/index.ts index f8b85b384..500c73958 100644 --- a/packages/sdk-tizen/src/index.ts +++ b/packages/sdk-tizen/src/index.ts @@ -6,10 +6,11 @@ export * from './constants'; import taskTargetLaunch from './tasks/taskTargetLaunch'; import taskTargetList from './tasks/taskTargetList'; import taskSdkConfigure from './tasks/taskSdkConfigure'; +import taskChangeCertificate from './tasks/taskChangeCertificate'; import { GetContextType, createRnvModule } from '@rnv/core'; const RnvModule = createRnvModule({ - tasks: [taskTargetLaunch, taskTargetList, taskSdkConfigure] as const, + tasks: [taskTargetLaunch, taskTargetList, taskSdkConfigure, taskChangeCertificate] as const, name: '@rnv/sdk-tizen', type: 'internal', }); diff --git a/packages/sdk-tizen/src/tasks/taskChangeCertificate.ts b/packages/sdk-tizen/src/tasks/taskChangeCertificate.ts new file mode 100644 index 000000000..8e38bc6a5 --- /dev/null +++ b/packages/sdk-tizen/src/tasks/taskChangeCertificate.ts @@ -0,0 +1,28 @@ +import { createTask, RnvTaskName } from '@rnv/core'; +import { SdkPlatforms } from '../constants'; +import fs from 'fs'; +export default createTask({ + description: 'Change tizen certificate', + fn: async ({ ctx }) => { + console.log('good'); + + // bad approach? + ctx.paths.appConfig.configs.forEach(async (config: string) => { + if (config.includes('base')) { + const configFile = await JSON.parse(fs.readFileSync(config, 'utf-8')); + + configFile.platforms.tizen.certificateProfile = 'newCert'; + configFile.platforms.tizenwatch.certificateProfile = 'newCert'; + configFile.platforms.tizenmobile.certificateProfile = 'newCert'; + + fs.writeFileSync(config, JSON.stringify(configFile, null, 2)); + } + }); + + // should do a simple thing - update core/src/schema/defaults.ts certificateProfile key + // AND update certificateProfile key in template-starter/appConfigs/base/renative.json platforms.tizen, platforms.tizenwatch and platforms.tizenmobile + }, + task: RnvTaskName.tizenCertificate, + platforms: SdkPlatforms, + isGlobalScope: true, +}); diff --git a/packages/template-starter/appConfigs/base/renative.json b/packages/template-starter/appConfigs/base/renative.json index 8102adbc3..b9edc790e 100644 --- a/packages/template-starter/appConfigs/base/renative.json +++ b/packages/template-starter/appConfigs/base/renative.json @@ -209,7 +209,7 @@ "tizen": { "appName": "RNVanillaTV", "entryFile": "index", - "certificateProfile": "RNVanillaCert", + "certificateProfile": "newCert", "package": "NkVRhWHJSX", "id": "NkVRhWHJSX.RNVanillaTV", "buildSchemes": { @@ -225,7 +225,7 @@ "tizenwatch": { "appName": "RNVanillaWatch", "entryFile": "index", - "certificateProfile": "RNVanillaCert", + "certificateProfile": "newCert", "package": "cHIP2fIRQZ", "id": "cHIP2fIRQZ.RNVanillaWatch", "buildSchemes": { @@ -241,7 +241,7 @@ "tizenmobile": { "appName": "RNVanillaMobile", "entryFile": "index", - "certificateProfile": "RNVanillaCert", + "certificateProfile": "newCert", "package": "PauodvCU2r", "id": "PauodvCU2r.RNVanillaMobile", "buildSchemes": {