Allow users to specify whether to install Node.js template (#329)
* Leverage npx to do 'npm install' w/o sudo * Allow install latest and specific Node.js template * Allow use specify whether to install Node.js template * Add space-within-parens rule to tslint
This commit is contained in:
Родитель
8138b45ed3
Коммит
44346b1232
20
package.json
20
package.json
|
@ -204,17 +204,17 @@
|
|||
"azure-iot-edge.version.cmodule": {
|
||||
"type": "string",
|
||||
"default": "master",
|
||||
"description": "Set the C module template version, which will be refernced during scaffolding C module."
|
||||
"description": "Set the C module template version, which will be referenced during scaffolding C module."
|
||||
},
|
||||
"azure-iot-edge.version.pythonmodule": {
|
||||
"type": "string",
|
||||
"default": "master",
|
||||
"description": "Set the Python module template version, which will be refernced during scaffolding Python module."
|
||||
"description": "Set the Python module template version, which will be referenced during scaffolding Python module."
|
||||
},
|
||||
"azure-iot-edge.version.csharpmodule": {
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"description": "Set the C# module template version, which will be refernced during scaffolding C# module."
|
||||
"description": "Set the C# module template version, which will be referenced during scaffolding C# module."
|
||||
},
|
||||
"azure-iot-edge.templateInstall.csharpmodule": {
|
||||
"type": "boolean",
|
||||
|
@ -226,15 +226,25 @@
|
|||
"default": true,
|
||||
"description": "Switch to install C# function module template before scaffolding. Default is true."
|
||||
},
|
||||
"azure-iot-edge.templateInstall.nodemodule": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Switch to install Node.js module template before scaffolding. Default is true."
|
||||
},
|
||||
"azure-iot-edge.version.csfunctionmodule": {
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"description": "Set the C# fuction module template version, which will be refernced during scaffolding C# function module."
|
||||
"description": "Set the C# function module template version, which will be referenced during scaffolding C# function module."
|
||||
},
|
||||
"azure-iot-edge.version.javamodule": {
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"description": "Set the Java module template version, which will be refernced during scaffolding Java module."
|
||||
"description": "Set the Java module template version, which will be referenced during scaffolding Java module."
|
||||
},
|
||||
"azure-iot-edge.version.nodemodule": {
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"description": "Set the Node.js module template version, which will be referenced during scaffolding Node.js module."
|
||||
},
|
||||
"azure-iot-edge.terminalRoot": {
|
||||
"type": "string",
|
||||
|
|
|
@ -134,6 +134,7 @@ export class Constants {
|
|||
|
||||
public static installCSharpModule = "templateInstall.csharpmodule";
|
||||
public static installCSFunctionModule = "templateInstall.csfunctionmodule";
|
||||
public static installNodeModule = "templateInstall.nodemodule";
|
||||
|
||||
public static edgeAgentVerPlaceHolder = "VERSION.edgeAgent";
|
||||
public static edgeHubVerPlaceHolder = "VERSION.edgeHub";
|
||||
|
|
|
@ -18,6 +18,10 @@ export class Versions {
|
|||
return Versions.getValue(Constants.installCSFunctionModule, true) as boolean;
|
||||
}
|
||||
|
||||
public static installNodeTemplate(): boolean {
|
||||
return Versions.getValue(Constants.installNodeModule, true) as boolean;
|
||||
}
|
||||
|
||||
public static csTemplateVersion(): string {
|
||||
return Versions.getValue(Constants.versionCSharpModule) as string;
|
||||
}
|
||||
|
@ -38,6 +42,10 @@ export class Versions {
|
|||
return Versions.getValue(Constants.versionJavaModule) as string;
|
||||
}
|
||||
|
||||
public static nodeTemplateVersion(): string {
|
||||
return Versions.getValue(Constants.versionNodeModule) as string;
|
||||
}
|
||||
|
||||
private static edgeAgentVersion(): string {
|
||||
return Versions.getValue(Constants.versionEdgeAgent) as string;
|
||||
}
|
||||
|
|
|
@ -215,19 +215,22 @@ export class EdgeManager {
|
|||
case Constants.LANGUAGE_NODE:
|
||||
debugCreateOptions = {
|
||||
ExposedPorts: { "9229/tcp": {} },
|
||||
HostConfig: {PortBindings: {"9229/tcp": [{HostPort: "9229"}]}}};
|
||||
HostConfig: { PortBindings: { "9229/tcp": [{ HostPort: "9229" }] } },
|
||||
};
|
||||
break;
|
||||
case Constants.LANGUAGE_C:
|
||||
debugCreateOptions = { HostConfig: { Privileged: true } };
|
||||
break;
|
||||
case Constants.LANGUAGE_JAVA:
|
||||
debugCreateOptions = {
|
||||
HostConfig: {PortBindings: {"5005/tcp": [{HostPort: "5005"}]}}};
|
||||
HostConfig: { PortBindings: { "5005/tcp": [{ HostPort: "5005" }] } },
|
||||
};
|
||||
break;
|
||||
case Constants.LANGUAGE_PYTHON:
|
||||
debugCreateOptions = {
|
||||
ExposedPorts: { "5678/tcp": {} },
|
||||
HostConfig: {PortBindings: {"5678/tcp": [{HostPort: "5678"}]}}};
|
||||
HostConfig: { PortBindings: { "5678/tcp": [{ HostPort: "5678" }] } },
|
||||
};
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -432,7 +435,22 @@ export class EdgeManager {
|
|||
`--no-input ${gitHubSource} module_name=${name} image_repository=${repositoryName} --checkout ${branch}`);
|
||||
break;
|
||||
case Constants.LANGUAGE_NODE:
|
||||
if (Versions.installNodeTemplate()) {
|
||||
// Have to install Node.js module template and Yeoman in the same space (either global or npx environment)
|
||||
// https://github.com/Microsoft/vscode-azure-iot-edge/issues/326
|
||||
const nodeModuleVersion = Versions.nodeTemplateVersion();
|
||||
const nodeVersionConfig = nodeModuleVersion != null ? `@${nodeModuleVersion}` : "";
|
||||
if (os.platform() === "win32") {
|
||||
await Executor.executeCMD(outputChannel, "npm", { cwd: `${parent}`, shell: true },
|
||||
`i -g generator-azure-iot-edge-module${nodeVersionConfig}`);
|
||||
await Executor.executeCMD(outputChannel, "yo", { cwd: `${parent}`, shell: true }, `azure-iot-edge-module -n "${name}" -r ${repositoryName}`);
|
||||
} else {
|
||||
await Executor.executeCMD(outputChannel, "npx", { cwd: `${parent}`, shell: true },
|
||||
`-p yo -p generator-azure-iot-edge-module${nodeVersionConfig} -- yo azure-iot-edge-module -n "${name}" -r ${repositoryName}`);
|
||||
}
|
||||
} else {
|
||||
await Executor.executeCMD(outputChannel, "yo", { cwd: `${parent}`, shell: true }, `azure-iot-edge-module -n "${name}" -r ${repositoryName}`);
|
||||
}
|
||||
break;
|
||||
case Constants.LANGUAGE_C:
|
||||
await new Promise((resolve, reject) => {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
200
|
||||
],
|
||||
"no-empty": false,
|
||||
"object-literal-sort-keys": false
|
||||
"object-literal-sort-keys": false,
|
||||
"space-within-parens": true
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче