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

add correct xmlbuilder before running ios for the first time #1451

Merged
2 commits merged into from Mar 15, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 11 additions & 7 deletions packages/core/jsonSchema/rnv.template.json
Expand Up @@ -189,23 +189,27 @@
},
"description": "Defines list of custom bootstrap questions"
},
"rnvNewPatchDependencies": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"description": "This ensures that the correct version of the package will be used to run the project for the first time after creation"
},
"packageTemplate": {
"type": "object",
"properties": {
"dependencies": {
"type": "object",
"additionalProperties": {
"type": "string"
}
"$ref": "#/definitions/rnv.template/properties/templateConfig/properties/rnvNewPatchDependencies"
},
"devDependencies": {
"$ref": "#/definitions/rnv.template/properties/templateConfig/properties/packageTemplate/properties/dependencies"
"$ref": "#/definitions/rnv.template/properties/templateConfig/properties/rnvNewPatchDependencies"
},
"peerDependencies": {
"$ref": "#/definitions/rnv.template/properties/templateConfig/properties/packageTemplate/properties/dependencies"
"$ref": "#/definitions/rnv.template/properties/templateConfig/properties/rnvNewPatchDependencies"
},
"optionalDependencies": {
"$ref": "#/definitions/rnv.template/properties/templateConfig/properties/packageTemplate/properties/dependencies"
"$ref": "#/definitions/rnv.template/properties/templateConfig/properties/rnvNewPatchDependencies"
},
"name": {
"type": "string"
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/schema/configFiles/template.ts
Expand Up @@ -36,6 +36,11 @@ export const RootTemplateSchema = z.object({
.describe('Defines list of all file/dir paths you want to include in template')
.optional(),
bootstrapQuestions: BootstrapQuestionsSchema,
rnvNewPatchDependencies: z
.optional(NpmDep)
.describe(
'This ensures that the correct version of the npm packages will be used to run the project for the first time after creation'
),
packageTemplate: z.optional(
z.object({
dependencies: z.optional(NpmDep),
Expand Down
25 changes: 16 additions & 9 deletions packages/engine-core/src/tasks/global/taskNew.ts
Expand Up @@ -501,10 +501,6 @@ const taskNew = async (c: RnvContext) => {
await executeAsync(`${isYarnInstalled() ? 'yarn' : 'npm'} add rnv@${c.rnvVersion}`, {
cwd: c.paths.project.dir,
});
// Add pkg-dir to have the correct version before the first run
await executeAsync(`${isYarnInstalled() ? 'yarn' : 'npm'} add pkg-dir@7.0.0`, {
cwd: c.paths.project.dir,
});

// Check if node_modules folder exists
if (!fsExistsSync(path.join(c.paths.project.dir, 'node_modules'))) {
Expand All @@ -515,6 +511,22 @@ const taskNew = async (c: RnvContext) => {
);
return;
}
// This ensures that the correct version of the npm packages will be used to run the project for the first time after creation

const renativeTemplateConfig =
readObjectSync<ConfigFileTemplate>(
path.join(c.paths.project.dir, 'node_modules', selectedInputTemplate, ConfigName.renativeTemplate)
) || {};

const rnvNewPatchDependencies = renativeTemplateConfig.templateConfig?.rnvNewPatchDependencies;

if (rnvNewPatchDependencies) {
const patchDeps = Object.entries(rnvNewPatchDependencies);
for (const [dependency, version] of patchDeps) {
const command = `${isYarnInstalled() ? 'yarn' : 'npm'} add ${dependency}@${version}`;
await executeAsync(command, { cwd: c.paths.project.dir });
}
}

if (!data.optionTemplates.keysAsArray?.includes(selectedInputTemplate)) {
const { confirmAddTemplate } = await inquirerPrompt({
Expand All @@ -541,11 +553,6 @@ const taskNew = async (c: RnvContext) => {
}
}

const renativeTemplateConfig =
readObjectSync<ConfigFileTemplate>(
path.join(c.paths.project.dir, 'node_modules', selectedInputTemplate, ConfigName.renativeTemplate)
) || {};

const renativeConfig = readObjectSync<ConfigFileProject>(
path.join(c.paths.project.dir, 'node_modules', selectedInputTemplate, ConfigName.renative)
);
Expand Down
18 changes: 7 additions & 11 deletions packages/template-starter/renative.template.json
Expand Up @@ -16,6 +16,10 @@
"typings",
"webpack.config.js"
],
"rnvNewPatchDependencies": {
"pkg-dir": "7.0.0",
"xmlbuilder": "^15.1.1"
},
"packageTemplate": {
"devDependencies": {
"typescript": "5.0.4",
Expand All @@ -27,16 +31,8 @@
"babel-loader": "9.1.3"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
"production": [">0.2%", "not dead", "not op_mini all"],
"development": ["last 1 chrome version", "last 1 firefox version", "last 1 safari version"]
},
"resolutions": {
"@babel/traverse": "7.15.0",
Expand All @@ -47,4 +43,4 @@
"platforms": {},
"plugins": {},
"extendsTemplate": "@rnv/template-starter/renative.json"
}
}