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

Commit

Permalink
code cleanups and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mkloubert committed Dec 29, 2017
1 parent 6925d82 commit dad4884
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 46 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log (vscode-deploy-reloaded)

## 0.9.0 (December 30th, 2017; improvements)

* bugfixes
* code improvements

## 0.8.0 (December 29th, 2017; target operations)

* bugfixes
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

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.8.0",
"version": "0.9.0",
"publisher": "mkloubert",
"engines": {
"vscode": "^1.19.0"
Expand Down
5 changes: 4 additions & 1 deletion src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import * as deploy_contracts from './contracts';
import * as deploy_events from './events';
import * as deploy_helpers from './helpers';
import * as deploy_log from './log';
import * as deploy_session from './session';
import * as deploy_values from './values';
import * as deploy_workspaces from './workspaces';
import * as Events from 'events';
Expand Down Expand Up @@ -188,7 +189,8 @@ export async function reloadCommands(newCfg: deploy_contracts.Configuration) {
const CTX: ScriptCommandExecutionContext = {
button: btn,
command: id,
events: ME.sessionState['commands']['events'],
events: ME.workspaceSessionState['commands']['events'],
extension: ME.context.extension,
globalEvents: deploy_events.EVENTS,
globals: ME.globals,
globalState: GLOBAL_STATE,
Expand All @@ -200,6 +202,7 @@ export async function reloadCommands(newCfg: deploy_contracts.Configuration) {
require: (moduleId) => {
return deploy_helpers.requireFromExtension(moduleId);
},
sessionState: deploy_session.SESSION_STATE,
state: undefined,
};

Expand Down
9 changes: 9 additions & 0 deletions src/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ export interface ScriptArguments {
* Event emitter for scripts of that kind.
*/
readonly events: NodeJS.EventEmitter;
/**
* The context of the underlying extension.
*/
readonly extension: vscode.ExtensionContext;
/**
* Gets the emitter for global extension events.
*/
Expand Down Expand Up @@ -406,6 +410,11 @@ export interface ScriptArguments {
* Imports a module from the extension context.
*/
readonly require: (id: any) => any;
/**
* The extension wide object that shares data with anything
* across the extension.
*/
readonly sessionState: KeyValuePairs;
/**
* Gets or sets a state value for the underlying script.
*/
Expand Down
11 changes: 7 additions & 4 deletions src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import * as deploy_files from './files';
import * as deploy_helpers from './helpers';
import * as deploy_log from './log';
import * as deploy_objects from './objects';
import * as deploy_session from './session';
import * as deploy_targets from './targets';
import * as deploy_transformers from './transformers';
import * as deploy_values from './values';
Expand Down Expand Up @@ -534,10 +535,11 @@ export abstract class FileToUploadBase implements FileToUpload {
);

const CONTEXT: deploy_transformers.DataTransformerContext = {
events: ME.workspace.sessionState['upload']['events'],
events: ME.workspace.workspaceSessionState['upload']['events'],
extension: ME.workspace.context.extension,
globalEvents: deploy_events.EVENTS,
globals: ME.workspace.globals,
globalState: ME.workspace.sessionState['upload']['states']['global'],
globalState: ME.workspace.workspaceSessionState['upload']['states']['global'],
logger: deploy_log.CONSOLE,
mode: deploy_transformers.DataTransformerMode.Transform,
options: ME.transformerOptions,
Expand All @@ -548,6 +550,7 @@ export abstract class FileToUploadBase implements FileToUpload {
require: (id) => {
return deploy_helpers.requireFromExtension(id);
},
sessionState: deploy_session.SESSION_STATE,
state: undefined,
};

Expand All @@ -556,11 +559,11 @@ export abstract class FileToUploadBase implements FileToUpload {
enumerable: true,

get: () => {
return ME.workspace.sessionState['upload']['states']['data_transformers'][STATE_KEY];
return ME.workspace.workspaceSessionState['upload']['states']['data_transformers'][STATE_KEY];
},

set: (newValue) => {
ME.workspace.sessionState['upload']['states']['data_transformers'][STATE_KEY] = newValue;
ME.workspace.workspaceSessionState['upload']['states']['data_transformers'][STATE_KEY] = newValue;
}
});

Expand Down
5 changes: 4 additions & 1 deletion src/plugins/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import * as deploy_files from '../files';
import * as deploy_helpers from '../helpers';
import * as deploy_log from '../log';
import * as deploy_plugins from '../plugins';
import * as deploy_session from '../session';
import * as deploy_targets from '../targets';
import * as deploy_workspaces from '../workspaces';
import * as Events from 'events';
Expand Down Expand Up @@ -122,10 +123,11 @@ class ScriptPlugin extends deploy_plugins.PluginBase<ScriptTarget> {
cancellationToken: undefined,
dir: context['dir'],
events: ME._EVENTS,
extension: context.target.__workspace.context.extension,
files: context['files'],
globalEvents: deploy_events.EVENTS,
globals: context.target.__workspace.globals,
globalState: this._GLOBAL_STATE,
globalState: ME._GLOBAL_STATE,
isCancelling: undefined,
logger: deploy_log.CONSOLE,
operation: operation,
Expand All @@ -137,6 +139,7 @@ class ScriptPlugin extends deploy_plugins.PluginBase<ScriptTarget> {
require: (id) => {
return deploy_helpers.requireFromExtension(id);
},
sessionState: deploy_session.SESSION_STATE,
state: undefined,
target: context.target,
workspace: undefined,
Expand Down
11 changes: 7 additions & 4 deletions src/pull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import * as deploy_helpers from './helpers';
import * as deploy_log from './log';
import * as deploy_packages from './packages';
import * as deploy_plugins from './plugins';
import * as deploy_session from './session';
import * as deploy_targets from './targets';
import * as deploy_transformers from './transformers';
import * as deploy_workspaces from './workspaces';
Expand Down Expand Up @@ -268,10 +269,11 @@ export async function pullFilesFrom(files: string[],
);

const CONTEXT: deploy_transformers.DataTransformerContext = {
events: ME.sessionState['pull']['events'],
events: ME.workspaceSessionState['pull']['events'],
extension: ME.context.extension,
globalEvents: deploy_events.EVENTS,
globals: ME.globals,
globalState: ME.sessionState['pull']['states']['global'],
globalState: ME.workspaceSessionState['pull']['states']['global'],
logger: deploy_log.CONSOLE,
mode: deploy_transformers.DataTransformerMode.Restore,
options: TRANSFORMER_OPTIONS,
Expand All @@ -281,6 +283,7 @@ export async function pullFilesFrom(files: string[],
require: (id) => {
return deploy_helpers.requireFromExtension(id);
},
sessionState: deploy_session.SESSION_STATE,
state: undefined,
};

Expand All @@ -289,11 +292,11 @@ export async function pullFilesFrom(files: string[],
enumerable: true,

get: () => {
return ME.sessionState['pull']['states']['data_transformers'][STATE_KEY];
return ME.workspaceSessionState['pull']['states']['data_transformers'][STATE_KEY];
},

set: (newValue) => {
ME.sessionState['pull']['states']['data_transformers'][STATE_KEY] = newValue;
ME.workspaceSessionState['pull']['states']['data_transformers'][STATE_KEY] = newValue;
}
});

Expand Down
24 changes: 24 additions & 0 deletions src/session.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* This file is part of the vscode-deploy-reloaded distribution.
* Copyright (c) Marcel Joachim Kloubert.
*
* vscode-deploy-reloaded is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, version 3.
*
* vscode-deploy-reloaded is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import * as deploy_contracts from './contracts';


/**
* The global extension wide state object.
*/
export const SESSION_STATE: deploy_contracts.KeyValuePairs = {};
11 changes: 7 additions & 4 deletions src/targets/operations/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import * as deploy_events from '../../events';
import * as deploy_helpers from '../../helpers';
import * as deploy_http from '../../http';
import * as deploy_log from '../../log';
import * as deploy_session from '../../session';
import * as deploy_targets from '../../targets';
import * as i18 from '../../i18';
import * as OS from 'os';
Expand Down Expand Up @@ -203,10 +204,11 @@ export async function execute(context: deploy_targets.TargetOperationExecutionCo
getBodyToSend = async () => {
const ARGS: HttpBodyModuleExecutionArguments = {
context: context,
events: WORKSPACE.sessionState['target_operations']['http']['events'],
events: WORKSPACE.workspaceSessionState['target_operations']['http']['events'],
extension: WORKSPACE.context.extension,
globalEvents: deploy_events.EVENTS,
globals: WORKSPACE.globals,
globalState: WORKSPACE.sessionState['target_operations']['http']['global'],
globalState: WORKSPACE.workspaceSessionState['target_operations']['http']['global'],
logger: deploy_log.CONSOLE,
options: deploy_helpers.cloneObject(OPERATION.options),
replaceWithValues: (val) => {
Expand All @@ -215,6 +217,7 @@ export async function execute(context: deploy_targets.TargetOperationExecutionCo
require: (id) => {
return deploy_helpers.requireFromExtension(id);
},
sessionState: deploy_session.SESSION_STATE,
state: undefined,
url: URL,
};
Expand All @@ -224,11 +227,11 @@ export async function execute(context: deploy_targets.TargetOperationExecutionCo
enumerable: true,

get: () => {
return WORKSPACE.sessionState['target_operations']['http']['body_scripts'][<string>bodyScriptFullPath];
return WORKSPACE.workspaceSessionState['target_operations']['http']['body_scripts'][<string>bodyScriptFullPath];
},

set: (newValue) => {
WORKSPACE.sessionState['target_operations']['http']['body_scripts'][<string>bodyScriptFullPath] = newValue;
WORKSPACE.workspaceSessionState['target_operations']['http']['body_scripts'][<string>bodyScriptFullPath] = newValue;
}
});

Expand Down
11 changes: 7 additions & 4 deletions src/targets/operations/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import * as deploy_contracts from '../../contracts';
import * as deploy_events from '../../events';
import * as deploy_helpers from '../../helpers';
import * as deploy_log from '../../log';
import * as deploy_session from '../../session';
import * as deploy_targets from '../../targets';
import * as i18 from '../../i18';

Expand Down Expand Up @@ -101,10 +102,11 @@ export async function execute(context: deploy_targets.TargetOperationExecutionCo
if (EXECUTE) {
const ARGS: ScriptTargetOperationExecutionArguments = {
context: context,
events: WORKSPACE.sessionState['target_operations']['script']['events'],
events: WORKSPACE.workspaceSessionState['target_operations']['script']['events'],
extension: WORKSPACE.context.extension,
globalEvents: deploy_events.EVENTS,
globals: WORKSPACE.globals,
globalState: WORKSPACE.sessionState['target_operations']['script']['global'],
globalState: WORKSPACE.workspaceSessionState['target_operations']['script']['global'],
logger: deploy_log.CONSOLE,
options: deploy_helpers.cloneObject(OPERATION.options),
replaceWithValues: (val) => {
Expand All @@ -113,6 +115,7 @@ export async function execute(context: deploy_targets.TargetOperationExecutionCo
require: (id) => {
return deploy_helpers.requireFromExtension(id);
},
sessionState: deploy_session.SESSION_STATE,
state: undefined,
};

Expand All @@ -121,11 +124,11 @@ export async function execute(context: deploy_targets.TargetOperationExecutionCo
enumerable: true,

get: () => {
return WORKSPACE.sessionState['target_operations']['script']['scripts'][<string>scriptFullPath];
return WORKSPACE.workspaceSessionState['target_operations']['script']['scripts'][<string>scriptFullPath];
},

set: (newValue) => {
WORKSPACE.sessionState['target_operations']['script']['scripts'][<string>scriptFullPath] = newValue;
WORKSPACE.workspaceSessionState['target_operations']['script']['scripts'][<string>scriptFullPath] = newValue;
}
});

Expand Down
Loading

0 comments on commit dad4884

Please sign in to comment.