@nx-dotnet/dotnet
Advanced tools
Comparing version 1.9.12 to 1.10.0
@@ -0,1 +1,7 @@ | ||
# [1.10.0](https://github.com/nx-dotnet/nx-dotnet/compare/v1.9.12...v1.10.0) (2022-05-18) | ||
### Features | ||
- **core:** update prompt for installed template to present available options ([#436](https://github.com/nx-dotnet/nx-dotnet/issues/436)) ([5a941ae](https://github.com/nx-dotnet/nx-dotnet/commit/5a941ae0ac4c4a30290604a23ce3b0e1bed89619)) | ||
## [1.9.12](https://github.com/nx-dotnet/nx-dotnet/compare/v1.9.11...v1.9.12) (2022-04-25) | ||
@@ -2,0 +8,0 @@ |
@@ -20,6 +20,6 @@ { | ||
"homepage": "https://nx-dotnet.com/", | ||
"version": "1.9.12", | ||
"version": "1.10.0", | ||
"typings": "./src/index.d.ts", | ||
"peerDependencies": { | ||
"@nx-dotnet/utils": "1.9.12", | ||
"@nx-dotnet/utils": "1.10.0", | ||
"fast-glob": "3.2.7", | ||
@@ -26,0 +26,0 @@ "rimraf": "^3.0.2", |
/// <reference types="node" /> | ||
import { ChildProcess } from 'child_process'; | ||
import { dotnetAddPackageOptions, dotnetBuildOptions, dotnetFormatOptions, dotnetNewOptions, dotnetPublishOptions, dotnetRunOptions, dotnetTemplate, dotnetTestOptions } from '../models'; | ||
import { dotnetAddPackageOptions, dotnetBuildOptions, dotnetFormatOptions, dotnetNewOptions, dotnetPublishOptions, dotnetRunOptions, KnownDotnetTemplates, dotnetTestOptions, DotnetTemplate } from '../models'; | ||
import { LoadedCLI } from './dotnet.factory'; | ||
@@ -9,3 +9,7 @@ export declare class DotNetClient { | ||
constructor(cliCommand: LoadedCLI, cwd?: string | undefined); | ||
new(template: dotnetTemplate, parameters?: dotnetNewOptions): void; | ||
new(template: KnownDotnetTemplates, parameters?: dotnetNewOptions): void; | ||
listInstalledTemplates(opts?: { | ||
search?: string; | ||
language?: string; | ||
}): DotnetTemplate[]; | ||
build(project: string, parameters?: dotnetBuildOptions): void; | ||
@@ -25,3 +29,4 @@ run(project: string, watch?: boolean, parameters?: dotnetRunOptions): ChildProcess; | ||
private logAndExecute; | ||
private spawnAndGetOutput; | ||
private logAndSpawn; | ||
} |
@@ -6,3 +6,5 @@ "use strict"; | ||
const child_process_1 = require("child_process"); | ||
const semver = require("semver"); | ||
const models_1 = require("../models"); | ||
const parse_dotnet_new_list_output_1 = require("../utils/parse-dotnet-new-list-output"); | ||
class DotNetClient { | ||
@@ -21,2 +23,23 @@ constructor(cliCommand, cwd) { | ||
} | ||
listInstalledTemplates(opts) { | ||
const version = this.getSdkVersion(); | ||
const params = ['new']; | ||
if (semver.lt(version, '6.0.100') && (opts === null || opts === void 0 ? void 0 : opts.search)) { | ||
params.push(opts.search); | ||
} | ||
if (semver.gte(version, '7.0.100')) { | ||
params.push('list'); | ||
} | ||
else { | ||
params.push('--list'); | ||
} | ||
if (semver.gte(version, '6.0.100') && (opts === null || opts === void 0 ? void 0 : opts.search)) { | ||
params.push(opts.search); | ||
} | ||
if (opts === null || opts === void 0 ? void 0 : opts.language) { | ||
params.push('--language', opts.language); | ||
} | ||
const output = this.spawnAndGetOutput(params); | ||
return (0, parse_dotnet_new_list_output_1.parseDotnetNewListOutput)(output); | ||
} | ||
build(project, parameters) { | ||
@@ -120,3 +143,3 @@ const params = [`build`, project]; | ||
logAndExecute(params) { | ||
params = params.map((param) => param.replace(/\$(\w+)/, (match, varName) => { var _a; return (_a = process.env[varName]) !== null && _a !== void 0 ? _a : ''; })); | ||
params = params.map((param) => param.replace(/\$(\w+)/, (_, varName) => { var _a; return (_a = process.env[varName]) !== null && _a !== void 0 ? _a : ''; })); | ||
const cmd = `${this.cliCommand.command} "${params.join('" "')}"`; | ||
@@ -132,2 +155,13 @@ console.log(`Executing Command: ${cmd}`); | ||
} | ||
spawnAndGetOutput(params) { | ||
params = params.map((param) => param.replace(/\$(\w+)/, (_, varName) => { var _a; return (_a = process.env[varName]) !== null && _a !== void 0 ? _a : ''; })); | ||
const res = (0, child_process_1.spawnSync)(this.cliCommand.command, params, { | ||
cwd: this.cwd || process.cwd(), | ||
stdio: 'pipe', | ||
}); | ||
if (res.status !== 0) { | ||
throw new Error(`dotnet execution returned status code ${res.status} \n ${res.stderr}`); | ||
} | ||
return res.stdout.toString(); | ||
} | ||
logAndSpawn(params) { | ||
@@ -134,0 +168,0 @@ console.log(`Executing Command: ${this.cliCommand.command} "${params.join('" "')}"`); |
@@ -36,5 +36,5 @@ "use strict"; | ||
function mockDotnetFactory() { | ||
return { command: 'echo', info: { global: true, version: 0 } }; | ||
return { command: 'echo', info: { global: true, version: '6.0.100' } }; | ||
} | ||
exports.mockDotnetFactory = mockDotnetFactory; | ||
//# sourceMappingURL=dotnet.factory.js.map |
@@ -1,1 +0,7 @@ | ||
export declare type dotnetTemplate = 'console' | 'classlib' | 'wpf' | 'wpflib' | 'wpfcustomcontrollib' | 'wpfusercontrollib' | 'winforms' | 'winformslib' | 'worker' | 'grpc' | 'mstest' | 'xunit' | 'nunit' | 'page' | 'viewimports' | 'proto' | 'blazorserver' | 'blazorwasm' | 'web' | 'mvc' | 'webapp' | 'angular' | 'react' | 'reactredux' | 'razorclasslib' | 'webapi' | 'globaljson' | string; | ||
export declare type KnownDotnetTemplates = 'console' | 'classlib' | 'wpf' | 'wpflib' | 'wpfcustomcontrollib' | 'wpfusercontrollib' | 'winforms' | 'winformslib' | 'worker' | 'grpc' | 'mstest' | 'xunit' | 'nunit' | 'page' | 'viewimports' | 'proto' | 'blazorserver' | 'blazorwasm' | 'web' | 'mvc' | 'webapp' | 'angular' | 'react' | 'reactredux' | 'razorclasslib' | 'webapi' | 'globaljson' | string; | ||
export interface DotnetTemplate { | ||
templateName: string; | ||
shortNames: [string, ...string[]]; | ||
languages?: string[]; | ||
tags?: string[]; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
75502
91
612
2