Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Commit

Permalink
use new evidence.templateProjectUrl setting in project.ts (#62)
Browse files Browse the repository at this point in the history
and provide the local `/template` extension folder as default for that setting value. see (#61)
  • Loading branch information
RandomFractals committed Jun 4, 2023
1 parent 8c9e6e6 commit 12c0a35
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/commands/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import {

import * as path from 'path';

import { getConfig } from '../config';
import { showSelectFolderDialog, showOpenFolder } from '../views/prompts';
import { gitHubUrlBase, templateProjectUrl, cloneTemplateRepository } from './template';
import { gitHubUrlBase, cloneTemplateRepository } from './template';
import { getOutputChannel } from '../output';
import { getFileUri } from '../extensionContext';

Expand All @@ -18,6 +19,13 @@ import { getFileUri } from '../extensionContext';
*/
const defaultTemplateProjectUrl = '../../template';

/**
* Evidence template project Url setting name.
*
* @see https://github.com/evidence-dev/evidence-vscode/issues/62
*/
const templateProjectUrlSetting = 'templateProjectUrl';

/**
* Creates a new Evidence project.
*
Expand Down Expand Up @@ -62,17 +70,15 @@ export async function createNewProject(projectFolder?: Uri) {
outputChannel.show();
outputChannel.append(`\nCreating new project ...\n- New Project Folder: ${projectFolderPath}\n`);

// TODO: add and use new evidence.templateProjectUrl setting
// to determine if user prefers to create new project
// from the template project github url or
// use new simple template from exension /template folder
// @see https://github.com/evidence-dev/evidence-vscode/issues/61
// use new evidence template project Url setting
// @see https://github.com/evidence-dev/evidence-vscode/issues/62
const templateProjectUrl = <string>getConfig('templateProjectUrl', defaultTemplateProjectUrl);
const projectTemplateUrl = templateProjectUrl;

if (projectTemplateUrl.startsWith(gitHubUrlBase)) {
// clone Evidence template project from a github repository
// into the selected new Evidence project folder
await cloneTemplateRepository(templateProjectUrl, projectFolderPath);
await cloneTemplateRepository(projectTemplateUrl, projectFolderPath);
}
else if (projectTemplateUrl === defaultTemplateProjectUrl) {
// get embedded /template folder Uri from extension context
Expand Down

0 comments on commit 12c0a35

Please sign in to comment.