Skip to content
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

Fix/web new project #1221

Merged
merged 3 commits into from
Nov 1, 2023
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
2 changes: 1 addition & 1 deletion packages/cli/src/logger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/projects/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/schema/configFiles/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ const Paths = z

const RootProjectBaseFragment = {
workspaceID: WorkspaceID,
projectVersion: z.string(),
projectName: ProjectName,
isMonorepo: z.optional(IsMonoRepo),
isTemplate: z.boolean().optional(),
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/schema/configFiles/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
})
),
})
Expand Down
1 change: 1 addition & 0 deletions packages/engine-core/src/__tests__/tasks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions packages/engine-core/src/tasks/task.rnv.new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -716,6 +717,7 @@ export const taskRnvNew = async (c: RnvContext) => {
config.platforms = platforms;
config.engines = engines;
config.defaults = defaults;

writeFileSync(c.paths.project.config, config);

if (data.gitEnabled) {
Expand Down