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

Commit

Permalink
added initComposer setting
Browse files Browse the repository at this point in the history
  • Loading branch information
mkloubert committed Dec 29, 2017
1 parent 166c947 commit 8030fa7
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 4 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Change Log (vscode-deploy-reloaded)

## 0.9.0 (December 30th, 2017; scripts)
## 0.9.0 (December 30th, 2017; [composer](https://getcomposer.org/))

* bugfixes
* code improvements
* added `initComposer` [setting](https://github.com/mkloubert/vscode-deploy-reloaded/wiki#settings--), which runs `composer install` inside the workspace folder on startup, if a `composer.json` file exists and NO `vendor` sub folder has been found
* added `extension`, `folder` and `sessionState` properties to [ScriptArguments](https://mkloubert.github.io/vscode-deploy-reloaded/interfaces/_contracts_.scriptarguments.html)

## 0.8.0 (December 29th, 2017; target operations)
Expand All @@ -14,7 +15,7 @@
* improved use of `if` properties and [placeholders](https://github.com/mkloubert/vscode-deploy-reloaded/wiki/values)
* fixed loading settings from parent folder

## 0.7.0 (December 29th, 2017; npm)
## 0.7.0 (December 29th, 2017; [npm](https://www.npmjs.com/package/npm))

* bugfixes
* code improvements
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,13 @@
}
]
},
"initComposer": {
"description": "Runs 'composer install' inside the workspace folder on startup, if a 'composer.json' file exists and NO 'vendor' folder has been found.",
"type": "boolean",
"default": false
},
"initNodeModules": {
"description": "Runs 'npm install' inside the workspace folder on startup, if a 'package.json' file exists and NO 'node_modules' has been found.",
"description": "Runs 'npm install' inside the workspace folder on startup, if a 'package.json' file exists and NO 'node_modules' folder has been found.",
"type": "boolean",
"default": false
},
Expand Down
6 changes: 5 additions & 1 deletion src/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ export interface Configuration extends deploy_values.WithValueItems {
*/
readonly imports?: ImportType | ImportType[];
/**
* Runs 'npm install' inside the workspace folder on startup, if a 'package.json' file exists and NO 'node_modules' has been found.
* Runs 'composer install' inside the workspace folder on startup, if a 'composer.json' file exists and NO 'vendor' folder has been found.
*/
readonly initComposer?: boolean;
/**
* Runs 'npm install' inside the workspace folder on startup, if a 'package.json' file exists and NO 'node_modules' folder has been found.
*/
readonly initNodeModules?: boolean;
/**
Expand Down
8 changes: 8 additions & 0 deletions src/i18.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,14 @@ export interface Translation {
noneFound?: string;
selectWorkspace?: string;
};
composer?: {
install?: {
errors?: {
failed?: string;
};
running?: string;
}
};
errors?: {
cannotDetectMappedPathInfoForFile?: string;
cannotDetectPathInfoForFile?: string;
Expand Down
8 changes: 8 additions & 0 deletions src/lang/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,14 @@ export const translation: Translation = {
noneFound: "Keine aktiven Arbeitsbereiche gefunden!",
selectWorkspace: "Wählen Sie den aktiven Arbeitsbereich aus ...",
},
composer: {
install: {
errors: {
failed: "'composer install' konnte nicht ausgeführt werden:{0:trim,surround,leading_space}",
},
running: "Führe 'composer install' in{0:trim,surround,leading_space} aus ...",
}
},
errors: {
cannotDetectMappedPathInfoForFile: "Gemappte Pfad-Informationen konnten für die Datei{0:trim,surround,leading_space} nicht ermittelt werden!",
cannotDetectPathInfoForFile: "Pfad-Informationen konnten für die Datei{0:trim,surround,leading_space} nicht ermittelt werden!",
Expand Down
8 changes: 8 additions & 0 deletions src/lang/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,14 @@ export const translation: Translation = {
noneFound: "No active workspaces found!",
selectWorkspace: "Select the active workspace ...",
},
composer: {
install: {
errors: {
failed: "'composer install' failed:{0:trim,surround,leading_space}",
},
running: "Running 'composer install' in{0:trim,surround,leading_space} ...",
}
},
errors: {
cannotDetectMappedPathInfoForFile: "Cannot detect mapped path information for file{0:trim,surround,leading_space}!",
cannotDetectPathInfoForFile: "Cannot detect path information for file{0:trim,surround,leading_space}!",
Expand Down
59 changes: 59 additions & 0 deletions src/workspaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,64 @@ export class Workspace extends deploy_objects.DisposableBase implements deploy_c
return deploy_helpers.cloneObject(this.config.globals);
}

private async initComposer(cfg: WorkspaceSettings) {
if (!cfg) {
return;
}

if (!deploy_helpers.toBooleanSafe(cfg.initComposer)) {
return;
}

const ME = this;

try {
const COMPOSER_JSON = Path.resolve(
Path.join(
ME.rootPath, 'composer.json',
)
);

const VENDOR = Path.resolve(
Path.join(
ME.rootPath, 'vendor',
)
);

if (!(await deploy_helpers.exists(COMPOSER_JSON))) {
return; // no 'composer.json'
}

if (await deploy_helpers.exists(VENDOR)) {
return; // 'vendor' already exist
}

ME.context.outputChannel.appendLine('');
ME.context.outputChannel.append(
ME.t('workspaces.composer.install.running',
ME.rootPath) + ' '
);
try {
await ME.exec('composer install');

ME.context.outputChannel.appendLine(
`[${ME.t('ok')}]`
);
}
catch (e) {
ME.context.outputChannel.appendLine(
`[${ME.t('error', e)}]`
);
}
}
catch (e) {
ME.showErrorMessage(
ME.t('workspaces.composer.install.errors.failed',
e)
);
}
}

/**
* Initializes that workspace.
*
Expand Down Expand Up @@ -2173,6 +2231,7 @@ export class Workspace extends deploy_objects.DisposableBase implements deploy_c

finalizer = async () => {
await ME.initNodeModules(loadedCfg);
await ME.initComposer(loadedCfg);

// runBuildTaskOnStartup
try {
Expand Down

0 comments on commit 8030fa7

Please sign in to comment.