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 auth selection to the compare file command. #795

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
21 changes: 20 additions & 1 deletion packages/vscode-extension/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const rules = require("@typescript-eslint/eslint-plugin").rules

module.exports = {
"env": {
"es6": true,
Expand All @@ -15,6 +17,7 @@ module.exports = {
"plugins": [
"@typescript-eslint"
],
"ignorePatterns": ['.eslintrc.js'],
"rules": {
"@typescript-eslint/member-delimiter-style": [
"warn",
Expand All @@ -29,7 +32,23 @@ module.exports = {
}
}
],
"@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/naming-convention": [
"warn",
...rules["naming-convention"].defaultOptions,
{
"selector": ["enumMember"],
"format": ["UPPER_CASE"]
},
{
"selector": ["property"],
"format": ["camelCase", "UPPER_CASE"]
},
{
"selector": ["variable"],
"modifiers": ["const"],
"format": ["camelCase", "UPPER_CASE", "PascalCase"]
}
],
"@typescript-eslint/no-unused-expressions": "warn",
"@typescript-eslint/semi": [
"warn",
Expand Down
5 changes: 4 additions & 1 deletion packages/vscode-extension/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@
"IMPORT_OBJECTS_QUESTIONS_SELECT_OBJECTS": "Select the object you want to import.",
"IMPORT_OBJECTS_QUESTIONS_SELECT_TYPES": "Select the object types you want to import, or make no selection to list all object types.",

"LIST_AUTH_LOADING": "Loading the configured authentication IDs in this machine...",
"LIST_AUTH_SELECT": "Select the authentication ID to use",

"LIST_FILES_ERROR_NO_FILES_FOUND": "No files found.",
"LIST_FILES_ERROR_NO_FOLDERS_FOUND": "No folders available.",
"LIST_FILES_LISTING": "Listing files...",
Expand All @@ -123,7 +126,7 @@
"MANAGE_AUTH_REMOVE_CANCEL": "Cancel",
"MANAGE_AUTH_REMOVE_CONFIRMATION_MESSAGE": "This auth ID will be removed locally but still be valid in your account: {0}.",
"MANAGE_AUTH_REMOVE_CONTINUE": "Continue",
"MANAGE_AUTH_REMOVE_REMOVING_AUTH_ID": "Removing auhtID...",
"MANAGE_AUTH_REMOVE_REMOVING_AUTH_ID": "Removing auth ID...",
"MANAGE_AUTH_RENAME_ENTER_NEW_AUTH_ID": "Enter the new auth ID.",
"MANAGE_AUTH_RENAME_RENAMING_AUTH_ID": "Renaming auth ID...",

Expand Down
56 changes: 35 additions & 21 deletions packages/vscode-extension/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 17 additions & 5 deletions packages/vscode-extension/src/commands/CompareFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import * as vscode from 'vscode';
import { Uri } from 'vscode';
import { ACP_UNRESTRICTED_FOLDERS } from '../ApplicationConstants';
import { COMPARE_FILE } from '../service/TranslationKeys';
import { actionResultStatus, ApplicationConstants, ProjectInfoService } from '../util/ExtensionUtil';
import { actionResultStatus, ApplicationConstants, ProjectInfoService, AuthenticationUtils } from '../util/ExtensionUtil';
import FileImportCommon from './FileImportCommon';
import ListAuthService from '../service/ListAuthService';

export default class CompareFile extends FileImportCommon {
private static readonly ACCOUNT_COPY_BASE_NAME = 'accountCopy';
Expand Down Expand Up @@ -46,11 +47,23 @@ export default class CompareFile extends FileImportCommon {
}

protected async execute() {
const listAuthService = new ListAuthService(this.messageService, this.translationService, this.rootWorkspaceFolder!);

const activeFilePath = this.activeFile!;
const tempFolderPath = fs.mkdtempSync(path.join(os.tmpdir(), CompareFile.TEMP_FOLDER_PREFIX));

const authIds = await listAuthService.getAuthIds();
if(!authIds) {
return;
}

const selectedAuthId = await listAuthService.selectAuthId(authIds);
if(!selectedAuthId) {
return;
}

this.copyManifestFileToTempFolder(tempFolderPath);
this.copyProjectJsonToTempFolder(tempFolderPath);
this.createProjectJsonInTempFolder(tempFolderPath, selectedAuthId.authId);
const activeFileRelativePath = activeFilePath.split(this.getFileCabinetFolderPath())[1]?.replace(/\\/g, '/');
const importFilePath = this.getImportFilePath(tempFolderPath, activeFilePath, activeFileRelativePath);

Expand Down Expand Up @@ -125,9 +138,8 @@ export default class CompareFile extends FileImportCommon {
return path.join(importFileParentFolderPath, path.basename(activeFilePath));
}

private copyProjectJsonToTempFolder(tempFolderPath: string) {
const projectJsonPath = path.join(this.rootWorkspaceFolder!, ApplicationConstants.FILES.PROJECT_JSON);
fs.copyFileSync(projectJsonPath, path.join(tempFolderPath, ApplicationConstants.FILES.PROJECT_JSON));
private createProjectJsonInTempFolder(tempFolderPath: string, authId: string) {
AuthenticationUtils.setDefaultAuthentication(tempFolderPath, authId);
}

private copyManifestFileToTempFolder(tempFolderPath: string) {
Expand Down
Loading