Skip to content

Commit

Permalink
Merge pull request #1670 from flexn-io/chore/cherry-pick-local-templa…
Browse files Browse the repository at this point in the history
…te-path-fix

Merge pull request #1664 from flexn-io/localTemplatePath_option_added
  • Loading branch information
ElenaDiachenko committed Sep 2, 2024
2 parents d534553 + cfb58e6 commit ff63bac
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e-harness-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
yarn bootstrap
- name: Run
run: |
cd packages/app-harness && yarn run:ios-test & sleep 540
cd packages/app-harness && yarn run:ios-test & sleep 600
- name: E2E
run: |
cd packages/app-harness && yarn e2e:ios && kill $(lsof -t -i:8092)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-template-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
yarn bootstrap
- name: Run
run: |
cd packages/template-starter && yarn run:ios-test & sleep 540
cd packages/template-starter && yarn run:ios-test & sleep 600
- name: E2E
run: |
cd packages/template-starter && yarn e2e:ios && kill $(lsof -t -i:8082)
Expand Down
6 changes: 6 additions & 0 deletions packages/engine-core/src/taskOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ export const TaskOptions = createTaskOptionsMap([
isValueType: true,
description: 'select the template version',
},
{
key: 'local-template-path',
altKey: 'localTemplatePath',
isValueType: true,
description: 'select the local template path (absolute)',
},
{
key: 'title',
isValueType: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,34 +45,36 @@ const Question = async (data: NewProjectData) => {

const c = getContext();
const { templateVersion, projectTemplate } = c.program.opts();
let { localTemplatePath } = c.program.opts();

const projectTemplates = c.buildConfig.projectTemplates || {}; // c.files.rnvConfigTemplates.config?.projectTemplates || {};

const options: TemplateOption[] = [];
let defaultOverride;
Object.keys(projectTemplates).forEach((k) => {
const value = projectTemplates[k];
const option: TemplateOption = {
name: `${k} ${chalk().grey(`- ${value.localPath || value.description}`)}`,
value: { ...value, type: 'existing', packageName: value?.packageName || k },
};
options.push(option);
if (value.localPath) {
defaultOverride = option.value;
}
});

options.push(inquirerSeparator('Advanced:----------------'));
options.push(customTemplate);
options.push(localTemplate);
options.push(noTemplate);
let localTemplatePath: string | undefined;
const projectTemplateKeys = Object.keys(projectTemplates);

inputs.template = {};

if (checkInputValue(projectTemplate)) {
inputs.template.packageName = projectTemplate;
} else {
} else if (!checkInputValue(localTemplatePath)) {
const options: TemplateOption[] = [];
let defaultOverride;
projectTemplateKeys.forEach((k) => {
const value = projectTemplates[k];

const option: TemplateOption = {
name: `${k} ${chalk().grey(`- ${value.localPath || value.description}`)}`,
value: { ...value, type: 'existing', packageName: value?.packageName || k },
};
options.push(option);
if (value.localPath) {
defaultOverride = option.value;
}
});

options.push(inquirerSeparator('Advanced:----------------'));
options.push(customTemplate);
options.push(localTemplate);
options.push(noTemplate);

const iRes = await inquirerPrompt({
name: 'inputTemplate',
type: 'list',
Expand Down Expand Up @@ -112,7 +114,7 @@ const Question = async (data: NewProjectData) => {

const npmCacheDir = path.join(c.paths.project.dir, RnvFolderName.dotRnv, RnvFolderName.npmCache);

if (localTemplatePath) {
if (checkInputValue(localTemplatePath)) {
if (!fsExistsSync(localTemplatePath)) {
return Promise.reject(`Local template path ${localTemplatePath} does not exist`);
}
Expand All @@ -136,6 +138,12 @@ const Question = async (data: NewProjectData) => {
inputs.template.packageName = pkg.name;
inputs.template.version = pkg.version;
inputs.template.localPath = localTemplatePath;
projectTemplateKeys.find((tpl) => {
const value = projectTemplates[tpl];
if (value.localPath === localTemplatePath && inputs.template) {
inputs.template.type = 'existing';
}
});

if (!inputs.template) return;

Expand Down
1 change: 1 addition & 0 deletions packages/engine-core/src/tasks/bootstrap/taskNew.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export default createTask({
TaskOptions.projectName,
TaskOptions.projectTemplate,
TaskOptions.templateVersion,
TaskOptions.localTemplatePath,
TaskOptions.title,
TaskOptions.appVersion,
TaskOptions.id,
Expand Down

0 comments on commit ff63bac

Please sign in to comment.