Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Commit

Permalink
fixed folder mappings in batch targets
Browse files Browse the repository at this point in the history
  • Loading branch information
mkloubert committed Jan 3, 2018
1 parent 5dc6fed commit 52f7b63
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 7 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
[![Share via Facebook](https://raw.githubusercontent.com/mkloubert/vscode-deploy-reloaded/master/img/share/Facebook.png)](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3Dmkloubert.vscode-deploy-reloaded&quote=vscode-deploy-reloaded) [![Share via Twitter](https://raw.githubusercontent.com/mkloubert/vscode-deploy-reloaded/master/img/share/Twitter.png)](https://twitter.com/intent/tweet?source=https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3Dmkloubert.vscode-deploy-reloaded&text=vscode-deploy-reloaded:%20https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3Dmkloubert.vscode-deploy-reloaded&via=mjkloubert) [![Share via Google+](https://raw.githubusercontent.com/mkloubert/vscode-deploy-reloaded/master/img/share/Google+.png)](https://plus.google.com/share?url=https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3Dmkloubert.vscode-deploy-reloaded) [![Share via Pinterest](https://raw.githubusercontent.com/mkloubert/vscode-deploy-reloaded/master/img/share/Pinterest.png)](https://pinterest.com/pin/create/button/?url=https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3Dmkloubert.vscode-deploy-reloaded&media=https://raw.githubusercontent.com/mkloubert/vscode-deploy-reloaded/master/img/demo1.gif&description=Recoded%20version%20of%20Visual%20Studio%20Code%20extension%20%27vs-deploy%27%2C%20which%20provides%20commands%20to%20deploy%20files%20to%20one%20or%20more%20destinations.) [![Share via Reddit](https://raw.githubusercontent.com/mkloubert/vscode-deploy-reloaded/master/img/share/Reddit.png)](https://www.reddit.com/submit?url=https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3Dmkloubert.vscode-deploy-reloaded&title=vscode-deploy-reloaded) [![Share via LinkedIn](https://raw.githubusercontent.com/mkloubert/vscode-deploy-reloaded/master/img/share/LinkedIn.png)](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3Dmkloubert.vscode-deploy-reloaded&title=vscode-deploy-reloaded&summary=Recoded%20version%20of%20Visual%20Studio%20Code%20extension%20%27vs-deploy%27%2C%20which%20provides%20commands%20to%20deploy%20files%20to%20one%20or%20more%20destinations.&source=https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3Dmkloubert.vscode-deploy-reloaded) [![Share via Wordpress](https://raw.githubusercontent.com/mkloubert/vscode-deploy-reloaded/master/img/share/Wordpress.png)](https://wordpress.com/press-this.php?u=https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3Dmkloubert.vscode-deploy-reloaded&quote=vscode-deploy-reloaded&s=Recoded%20version%20of%20Visual%20Studio%20Code%20extension%20%27vs-deploy%27%2C%20which%20provides%20commands%20to%20deploy%20files%20to%20one%20or%20more%20destinations.&i=https://raw.githubusercontent.com/mkloubert/vscode-deploy-reloaded/master/img/demo1.gif) [![Share via Email](https://raw.githubusercontent.com/mkloubert/vscode-deploy-reloaded/master/img/share/Email.png)](mailto:?subject=vscode-deploy-reloaded&body=Recoded%20version%20of%20Visual%20Studio%20Code%20extension%20'vs-deploy'%2C%20which%20provides%20commands%20to%20deploy%20files%20to%20one%20or%20more%20destinations.:%20https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3Dmkloubert.vscode-deploy-reloaded)


## 0.14.1 (January 3rd, 2018; deploy git commits)
## 0.14.2 (January 3rd, 2018; deploy git commits)

* can deploy changes of a git commit now

![Demo Deploy git commit](https://raw.githubusercontent.com/mkloubert/vscode-deploy-reloaded/master/img/demo12.gif)

* fixed `privateKey` setting for [sftp targets](https://github.com/mkloubert/vscode-deploy-reloaded/wiki/target_sftp), thanks to [Robert Ehlers](https://github.com/rehlers)!
* fixed using [folder mappings](https://github.com/mkloubert/vscode-deploy-reloaded/wiki/folder_mappings) in [batch targets](https://github.com/mkloubert/vscode-deploy-reloaded/wiki/target_batch), s. [issue #2](https://github.com/mkloubert/vscode-deploy-reloaded/issues/2)

## 0.13.0 (January 2nd, 2018; setting up requirements)

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ The extension supports the following destinations:
* [Targets](#targets-)
* [How to execute](#how-to-execute-)
5. [Support and contribute](#support-and-contribute-)
* [Contributors](#contributors-)

## Demos [[↑](#table-of-contents)]

Expand Down Expand Up @@ -333,3 +334,7 @@ To work with the code:
If you like to create a translation, for example, you can take a look at [this directory](https://github.com/mkloubert/vscode-deploy-reloaded/tree/master/src/lang).

The API documentation can be found [here](https://mkloubert.github.io/vscode-deploy-reloaded/).

### Contributors [[↑](#support-and-contribute-)]

* [Robert Ehlers](https://github.com/rehlers)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-deploy-reloaded",
"displayName": "Deploy (Reloaded)",
"description": "Deploys files of a workspace to a destination.",
"version": "0.14.1",
"version": "0.14.2",
"publisher": "mkloubert",
"engines": {
"vscode": "^1.19.0"
Expand Down
40 changes: 35 additions & 5 deletions src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ export abstract class FileToUploadBase implements FileToUpload {
}

/** @inheritdoc */
public async read() {
public readonly read = async function() {
const ME = this;

let data = await ME.onRead();
Expand Down Expand Up @@ -576,7 +576,7 @@ export abstract class FileToUploadBase implements FileToUpload {
}

return data;
}
};

/**
* The logic for the 'read()' method.
Expand Down Expand Up @@ -1074,7 +1074,11 @@ export abstract class IterablePluginBase<TTarget extends deploy_targets.Target &
async (target, plugin) => {
const CTX: DeleteContext = {
cancellationToken: undefined,
files: context.files,
files: await ME.mapFilesForTarget(
context.target,
target,
context.files
),
isCancelling: undefined,
target: target,
};
Expand Down Expand Up @@ -1118,7 +1122,11 @@ export abstract class IterablePluginBase<TTarget extends deploy_targets.Target &
async (target, plugin) => {
const CTX: DownloadContext = {
cancellationToken: undefined,
files: context.files,
files: await ME.mapFilesForTarget(
context.target,
target,
context.files
),
isCancelling: undefined,
target: target,
};
Expand Down Expand Up @@ -1370,6 +1378,24 @@ export abstract class IterablePluginBase<TTarget extends deploy_targets.Target &
return result;
}

/**
* Maps file objects for a specific target.
*
* @param {TTarget} baseTarget The base target, using by that plugin.
* @param {Target} target The underlying target.
* @param {TFile|TFile[]} files The file targets to (re)map.
*
* @return {Promise<TFile[]>} The promise with the new, mapped objects.
*/
protected async mapFilesForTarget<TFile extends deploy_contracts.WithNameAndPath = deploy_contracts.WithNameAndPath>(
baseTarget: TTarget,
target: deploy_targets.Target,
files: TFile | TFile[]
)
{
return await deploy_targets.mapFilesForTarget(target, files);
}

/** @inheritdoc */
public async uploadFiles(context: UploadContext<TTarget>) {
const ME = this;
Expand All @@ -1384,7 +1410,11 @@ export abstract class IterablePluginBase<TTarget extends deploy_targets.Target &
async (target, plugin) => {
const CTX: UploadContext = {
cancellationToken: undefined,
files: context.files,
files: await ME.mapFilesForTarget(
context.target,
target,
context.files
),
isCancelling: undefined,
target: target,
};
Expand Down
53 changes: 53 additions & 0 deletions src/targets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,59 @@ export function isVisibleForPackage(target: Target, pkg: deploy_packages.Package
return SHOW_IF.indexOf(PACKAGE_NAME) > -1;
}

/**
* Maps file objects for a specific target.
*
* @param {Target} target The underlying target.
* @param {TFile|TFile[]} files The file targets to (re)map.
*
* @return {Promise<TFile[]>} The promise with the new, mapped objects.
*/
export async function mapFilesForTarget<TFile extends deploy_contracts.WithNameAndPath = deploy_contracts.WithNameAndPath>(
target: Target,
files: TFile | TFile[]
) {
const WORKSPACE = target.__workspace;

const ALL_DIRS = await WORKSPACE.getAllDirectories();

files = deploy_helpers.asArray(files);

const MAPPED_FILES: TFile[] = [];
for (const F of files) {
const CLONED_FILE = deploy_helpers.cloneObjectFlat(F, false);

const FULL_PATH = Path.resolve(
Path.join(
WORKSPACE.rootPath,
deploy_helpers.normalizePath(
F.path + '/' + F.name
)
)
);
if (!WORKSPACE.isPathOf(FULL_PATH)) {
continue;
}

const NEW_MAPPING = await WORKSPACE.getNameAndPathForFileDeployment(
target, FULL_PATH,
ALL_DIRS
);
if (false === NEW_MAPPING) {
continue;
}

(<any>CLONED_FILE).name = NEW_MAPPING.name;
(<any>CLONED_FILE).path = NEW_MAPPING.path;

MAPPED_FILES.push(
CLONED_FILE
);
}

return MAPPED_FILES;
}

/**
* Normalizes the type of a target.
*
Expand Down

0 comments on commit 52f7b63

Please sign in to comment.