Skip to content

Commit

Permalink
Updates based on review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
khawkins committed Jun 16, 2023
1 parent 164d3c1 commit 8327de4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
23 changes: 17 additions & 6 deletions src/commands/configureProjectCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ class DefaultProjectConfigurationProcessor
}

export class ConfigureProjectCommand {
static readonly STARTER_KIT_INITIAL_COMMIT =
'99b1fa9377694beb7918580aab445a2e9981f611';
static readonly STARTER_KIT_REPO_URI =
'https://github.com/salesforce/offline-app-developer-starter-kit.git';

extensionUri: Uri;
projectConfigurationProcessor: ProjectConfigurationProcessor;

Expand Down Expand Up @@ -133,6 +138,10 @@ export class ConfigureProjectCommand {
const folderUri =
await this.projectConfigurationProcessor.getProjectFolderPath();
if (!folderUri || folderUri.length === 0) {
// We explicitly do not want to resolve the Promise here, since the
// user "canceled", but could retry with the action request dialog
// that's still open. Only resolve the Promise when the user makes
// a choice.
return;
}

Expand Down Expand Up @@ -160,13 +169,19 @@ export class ConfigureProjectCommand {
const folderUri =
await this.projectConfigurationProcessor.getProjectFolderPath();
if (!folderUri || folderUri.length === 0) {
// We explicitly do not want to resolve the Promise here, since the
// user "canceled", but could retry with the action request dialog
// that's still open. Only resolve the Promise when the user makes
// a choice.
return;
}

try {
await this.validateProjectFolder(folderUri[0]);
} catch (error) {
window.showErrorMessage((error as Error).message);
// Same as above. If they chose an invalid folder, "soft"-error
// and allow them to pick a different choice.
return;
}

Expand All @@ -189,11 +204,9 @@ export class ConfigureProjectCommand {

async executeProjectCreation(folderUri: Uri): Promise<string> {
return new Promise(async (resolve) => {
const githubRepoUri: string =
'https://github.com/salesforce/offline-app-developer-starter-kit.git';
await commands.executeCommand(
'git.clone',
githubRepoUri,
ConfigureProjectCommand.STARTER_KIT_REPO_URI,
folderUri.fsPath
);
return resolve(folderUri.fsPath);
Expand Down Expand Up @@ -244,10 +257,8 @@ export class ConfigureProjectCommand {

// Is this the Offline Starter Kit repo?
try {
const oskInitialCommit =
'99b1fa9377694beb7918580aab445a2e9981f611';
await CommonUtils.executeCommandAsync(
`git merge-base HEAD ${oskInitialCommit}`
`git merge-base HEAD ${ConfigureProjectCommand.STARTER_KIT_INITIAL_COMMIT}`
);
} catch (error) {
return reject(
Expand Down
6 changes: 3 additions & 3 deletions src/test/suite/commands/configureProjectCommand.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ suite('Configure Project Command Test Suite', () => {
process.chdir(projectFolderUri.fsPath);
await CommonUtils.executeCommandAsync('git init');
await CommonUtils.executeCommandAsync(
'git remote add origin https://github.com/salesforce/offline-app-developer-starter-kit.git'
`git remote add origin ${ConfigureProjectCommand.STARTER_KIT_REPO_URI}`
);
await CommonUtils.executeCommandAsync(
'git fetch origin 99b1fa9377694beb7918580aab445a2e9981f611'
`git fetch origin ${ConfigureProjectCommand.STARTER_KIT_INITIAL_COMMIT}`
);
await CommonUtils.executeCommandAsync(
'git checkout -b main FETCH_HEAD'
Expand All @@ -163,5 +163,5 @@ suite('Configure Project Command Test Suite', () => {
assert.equal(origCwd, process.cwd());
removeTempProjectDir(projectFolderUri.fsPath);
}
}).timeout(10000);
}).timeout(60000); // 1 min, just to be safe. This test should ideally land < 10s.
});

0 comments on commit 8327de4

Please sign in to comment.