From 6150e0dbb2faea440028e9df1be62ef80594cd95 Mon Sep 17 00:00:00 2001 From: ElenaDiachenko Date: Wed, 1 Nov 2023 19:20:07 +0200 Subject: [PATCH 1/3] fix project version --- packages/core/src/projects/package.ts | 4 ++-- packages/core/src/schema/configFiles/project.ts | 1 + packages/core/src/schema/configFiles/template.ts | 1 + packages/engine-core/src/tasks/task.rnv.new.ts | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/core/src/projects/package.ts b/packages/core/src/projects/package.ts index bbb386a2d1..9e851892eb 100644 --- a/packages/core/src/projects/package.ts +++ b/packages/core/src/projects/package.ts @@ -22,7 +22,7 @@ export const checkAndCreateProjectPackage = async (c: RnvContext) => { logInfo(`Your ${c.paths.project.package} is missing. CREATING...DONE`); const packageName = c.files.project.config?.projectName || c.paths.project.dir.split('/').pop(); - // const version = c.files.project.config?.defaults?.package?.version || '0.1.0'; + const packageVersion = c.files.project.config?.projectVersion || '0.1.0'; const templateName = c.files.project.config?.currentTemplate; if (!templateName) { logWarning('You are missing currentTemplate in your renative.json'); @@ -42,7 +42,7 @@ export const checkAndCreateProjectPackage = async (c: RnvContext) => { const pkgJson = templateObj?.templateConfig?.packageTemplate || {}; pkgJson.name = packageName; - // pkgJson.version = version; + pkgJson.version = packageVersion; pkgJson.dependencies = pkgJson.dependencies || {}; // No longer good option to assume same version // pkgJson.dependencies.renative = rnvVersion; diff --git a/packages/core/src/schema/configFiles/project.ts b/packages/core/src/schema/configFiles/project.ts index 8ae44590d4..7a13735da3 100644 --- a/packages/core/src/schema/configFiles/project.ts +++ b/packages/core/src/schema/configFiles/project.ts @@ -220,6 +220,7 @@ const Paths = z const RootProjectBaseFragment = { workspaceID: WorkspaceID, + projectVersion: z.string(), projectName: ProjectName, isMonorepo: z.optional(IsMonoRepo), isTemplate: z.boolean().optional(), diff --git a/packages/core/src/schema/configFiles/template.ts b/packages/core/src/schema/configFiles/template.ts index dc5d652c18..6530e4b484 100644 --- a/packages/core/src/schema/configFiles/template.ts +++ b/packages/core/src/schema/configFiles/template.ts @@ -43,6 +43,7 @@ export const RootTemplateSchema = z.object({ peerDependencies: z.optional(NpmDep), optionalDependencies: z.optional(NpmDep), name: z.string().optional(), + version: z.string().optional(), }) ), }) diff --git a/packages/engine-core/src/tasks/task.rnv.new.ts b/packages/engine-core/src/tasks/task.rnv.new.ts index 7b777969ce..3a927e8f73 100644 --- a/packages/engine-core/src/tasks/task.rnv.new.ts +++ b/packages/engine-core/src/tasks/task.rnv.new.ts @@ -664,6 +664,7 @@ export const taskRnvNew = async (c: RnvContext) => { ...renativeTemplateConfig, ...renativeTemplateConfigExt, projectName: data.projectName || 'my-project', + projectVersion: data.inputVersion || '0.1.0', workspaceID: data.optionWorkspaces.selectedOption || 'project description', // paths: { // appConfigsDir: './appConfigs', @@ -716,6 +717,7 @@ export const taskRnvNew = async (c: RnvContext) => { config.platforms = platforms; config.engines = engines; config.defaults = defaults; + console.log(c.paths.project.config, ' =========> c.paths.project.config @@@@@'); writeFileSync(c.paths.project.config, config); if (data.gitEnabled) { From 1afe378823b3cea2b29c092749c53f897ab9087a Mon Sep 17 00:00:00 2001 From: ElenaDiachenko Date: Wed, 1 Nov 2023 20:40:41 +0200 Subject: [PATCH 2/3] hide project info in the summary <= rnv new --- packages/cli/src/logger/index.ts | 2 +- packages/engine-core/src/tasks/task.rnv.new.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/logger/index.ts b/packages/cli/src/logger/index.ts index 3955b381e1..3e07d07d9a 100644 --- a/packages/cli/src/logger/index.ts +++ b/packages/cli/src/logger/index.ts @@ -214,7 +214,7 @@ export const logSummary = (header = 'SUMMARY') => { let str = printBoxStart(`${ICN_ROCKET} ${header} ${timeString}`, getCurrentCommand()); str += printIntoBox(`ReNative Version: ${_highlightColor(ctx.rnvVersion)}`); - if (ctx.files?.project?.package) { + if (ctx.files?.project?.package?.name && ctx.files?.project?.package?.version) { str += printIntoBox(`Project Name ($package.name): ${_highlightColor(ctx.files.project.package.name)}`); str += printIntoBox( `Project Version ($package.version): ${_highlightColor(ctx.files.project.package.version)}` diff --git a/packages/engine-core/src/tasks/task.rnv.new.ts b/packages/engine-core/src/tasks/task.rnv.new.ts index 3a927e8f73..fe21d2b010 100644 --- a/packages/engine-core/src/tasks/task.rnv.new.ts +++ b/packages/engine-core/src/tasks/task.rnv.new.ts @@ -717,7 +717,7 @@ export const taskRnvNew = async (c: RnvContext) => { config.platforms = platforms; config.engines = engines; config.defaults = defaults; - console.log(c.paths.project.config, ' =========> c.paths.project.config @@@@@'); + writeFileSync(c.paths.project.config, config); if (data.gitEnabled) { From a67b9e36d137063f502be9adea50473e97d08af5 Mon Sep 17 00:00:00 2001 From: ElenaDiachenko Date: Wed, 1 Nov 2023 21:05:02 +0200 Subject: [PATCH 3/3] fix/task.rnv.new_test --- packages/engine-core/src/__tests__/tasks.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/engine-core/src/__tests__/tasks.test.ts b/packages/engine-core/src/__tests__/tasks.test.ts index 8c9775d73c..c8e55480bd 100644 --- a/packages/engine-core/src/__tests__/tasks.test.ts +++ b/packages/engine-core/src/__tests__/tasks.test.ts @@ -160,6 +160,7 @@ test('Execute task.rnv.new', async () => { isNew: true, platforms: {}, projectName: 'test', + projectVersion: '1.0.0', templates: { '@rnv/template-starter': { version: '1.0.0-canary.7',