@nx-dotnet/core
Advanced tools
Comparing version 0.0.6 to 0.1.0
@@ -5,5 +5,10 @@ { | ||
"build": { | ||
"implementation": "./src/executors/build/builder", | ||
"implementation": "./src/executors/build/executor", | ||
"schema": "./src/executors/build/schema.json", | ||
"description": "build executor" | ||
}, | ||
"serve": { | ||
"implementation": "./src/executors/serve/executor", | ||
"schema": "./src/executors/serve/schema.json", | ||
"description": "serve executor" | ||
} | ||
@@ -13,3 +18,3 @@ }, | ||
"build": { | ||
"implementation": "./src/executors/build/executor", | ||
"implementation": "./src/executors/build/builder", | ||
"schema": "./src/executors/build/schema.json", | ||
@@ -16,0 +21,0 @@ "description": "build executor" |
@@ -20,4 +20,11 @@ { | ||
"description": "Adds a reference from one project to another." | ||
}, | ||
"init": { | ||
"factory": "./src/generators/init/generator", | ||
"schema": "./src/generators/init/schema.json", | ||
"description": "init generator", | ||
"alias": ["ng-add"], | ||
"hidden": true | ||
} | ||
} | ||
} |
{ | ||
"name": "@nx-dotnet/core", | ||
"version": "0.0.6", | ||
"version": "0.1.0", | ||
"main": "src/index.js", | ||
@@ -9,6 +9,6 @@ "generators": "./generators.json", | ||
"dependencies": { | ||
"glob": "^7.1.6", | ||
"rimraf": "^3.0.2" | ||
}, | ||
"typings": "src/index.d.ts" | ||
} | ||
"@nx-dotnet/dotnet": "0.1.0", | ||
"@nx-dotnet/utils": "0.1.0", | ||
"chokidar": "^3.5.1" | ||
} | ||
} |
import { ExecutorContext } from '@nrwl/devkit'; | ||
import { BuildExecutorSchema } from './schema'; | ||
export default function runExecutor(options: BuildExecutorSchema, context: ExecutorContext): Promise<{ | ||
import { DotNetClient } from '@nx-dotnet/dotnet'; | ||
export default function runExecutor(options: BuildExecutorSchema, context: ExecutorContext, dotnetClient?: DotNetClient): Promise<{ | ||
success: boolean; | ||
}>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
const execute_dotnet_1 = require("../utils/execute-dotnet"); | ||
function runExecutor(options, context) { | ||
const utils_1 = require("@nx-dotnet/utils"); | ||
const dotnet_1 = require("@nx-dotnet/dotnet"); | ||
function runExecutor(options, context, dotnetClient = new dotnet_1.DotNetClient(dotnet_1.dotnetFactory())) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const params = { | ||
'-c': options.configuration | ||
const nxProjectConfiguration = utils_1.getExecutedProjectConfiguration(context); | ||
const projectFilePath = yield utils_1.getProjectFileForNxProject(nxProjectConfiguration); | ||
dotnetClient.build(projectFilePath, Object.keys(options).map((x) => ({ | ||
flag: x, | ||
value: options[x], | ||
}))); | ||
return { | ||
success: true, | ||
}; | ||
if (options.versionSuffix) { | ||
params['--version-suffix'] = options.versionSuffix; | ||
} | ||
if (options.framework) { | ||
params['-f'] = options.framework; | ||
} | ||
return execute_dotnet_1.ExecuteDotNet('build', context, params); | ||
}); | ||
@@ -18,0 +18,0 @@ } |
@@ -1,18 +0,23 @@ | ||
import { BuildExecutorSchema } from './schema'; | ||
import executor from './executor'; | ||
import { ExecutorContext } from '@nrwl/devkit'; | ||
import { promises as fs } from 'fs'; | ||
import { DotNetClient, mockDotnetFactory } from '@nx-dotnet/dotnet'; | ||
import { rimraf } from '@nx-dotnet/utils'; | ||
import executor from './executor'; | ||
import { BuildExecutorSchema } from './schema'; | ||
const options: BuildExecutorSchema = { | ||
configuration: 'Debug', | ||
versionSuffix: 1 | ||
}; | ||
const root = process.cwd() + '/tmp'; | ||
describe('Build Executor', () => { | ||
let context: ExecutorContext; | ||
let dotnetClient: DotNetClient; | ||
beforeEach(() => { | ||
context = { | ||
root: '/root', | ||
cwd: '/root', | ||
root: root, | ||
cwd: root, | ||
projectName: 'my-app', | ||
@@ -22,12 +27,72 @@ targetName: 'build', | ||
version: 2, | ||
projects: {}, | ||
projects: { | ||
'my-app': { | ||
root: `${root}/apps/my-app`, | ||
sourceRoot: `${root}/apps/my-app`, | ||
targets: { | ||
build: { | ||
executor: '@nx-dotnet/core:build' | ||
} | ||
}, | ||
}, | ||
}, | ||
}, | ||
isVerbose: false, | ||
}; | ||
}) | ||
it('can run', async () => { | ||
const output = await executor(options, context); | ||
// expect(output.success).toBe(true); | ||
dotnetClient = new DotNetClient(mockDotnetFactory()); | ||
}); | ||
afterEach(() => { | ||
return rimraf(root); | ||
}); | ||
it('detects no dotnet project', async () => { | ||
expect.assertions(1); | ||
try { | ||
await executor(options, context, dotnetClient); | ||
} catch (e) { | ||
console.log(e.message); | ||
expect(e.message).toMatch( | ||
"Unable to find a build-able project within project's source directory!" | ||
); | ||
} | ||
}); | ||
it('detects multiple dotnet projects', async () => { | ||
expect.assertions(1); | ||
try { | ||
const directoryPath = `${root}/apps/my-app`; | ||
await fs.mkdir(directoryPath, { recursive: true }); | ||
await Promise.all([ | ||
fs.writeFile(`${directoryPath}/1.csproj`, ''), | ||
fs.writeFile(`${directoryPath}/2.csproj`, ''), | ||
]); | ||
} catch (e) { | ||
console.warn(e.message); | ||
} | ||
try { | ||
await executor(options, context, dotnetClient); | ||
} catch (e) { | ||
console.log(e.message); | ||
expect(e.message).toMatch( | ||
"More than one build-able projects are contained within the project's source directory!" | ||
); | ||
} | ||
}); | ||
it('calls build when 1 project file is found', async () => { | ||
try { | ||
const directoryPath = `${root}/apps/my-app`; | ||
await fs.mkdir(directoryPath, { recursive: true }); | ||
await Promise.all([fs.writeFile(`${directoryPath}/1.csproj`, '')]); | ||
} catch (e) { | ||
console.warn(e.message); | ||
} | ||
const res = await executor(options, context, dotnetClient); | ||
expect(res.success).toBeTruthy(); | ||
}); | ||
}); |
@@ -1,5 +0,5 @@ | ||
export interface BuildExecutorSchema { | ||
framework?: string; | ||
versionSuffix: number; | ||
configuration: 'Debug' | 'Release'; | ||
import { dotnetBuildFlags } from '@nx-dotnet/dotnet'; | ||
export type BuildExecutorSchema = { | ||
[key in dotnetBuildFlags]?: string | ||
} |
@@ -10,5 +10,5 @@ { | ||
"type": "string", | ||
"description": "Compiles for a specific framework. The framework must be defined in the project file" | ||
"description": "Compiles for a specific framework. The framework must be defined in the project file" | ||
}, | ||
"versionSuffix": { | ||
"version-suffix": { | ||
"type": "number", | ||
@@ -22,2 +22,31 @@ "description": "Sets the value of the $(VersionSuffix) property to use when building the project. This only works if the $(Version) property isn't set. Then, $(Version) is set to the $(VersionPrefix) combined with the $(VersionSuffix), separated by a dash." | ||
"description": "Defines the build configuration. The default for most projects is Debug, but you can override the build configuration settings in your project" | ||
}, | ||
"force": { | ||
"type": "boolean", | ||
"description": "Forces all dependencies to be resolved even if the last restore was successful. Specifying this flag is the same as deleting the project.assets.json file." | ||
}, | ||
"no-dependencies": { | ||
"type": "boolean", | ||
"description": "Ignores project-to-project (P2P) references and only builds the specified root project." | ||
}, | ||
"no-incremental": { | ||
"type": "boolean", | ||
"description": "Marks the build as unsafe for incremental build. This flag turns off incremental compilation and forces a clean rebuild of the project's dependency graph." | ||
}, | ||
"no-restore": { | ||
"type": "boolean", | ||
"description": "Doesn't execute an implicit restore during build." | ||
}, | ||
"nologo": { | ||
"type": "boolean", | ||
"description": "Doesn't display the startup banner or the copyright message. Available since .NET Core 3.0 SDK." | ||
}, | ||
"output": { | ||
"type": "string", | ||
"description": "Directory in which to place the built binaries. If not specified, the default path is ./bin/<configuration>/<framework>/. For projects with multiple target frameworks (via the TargetFrameworks property), you also need to define --framework when you specify this option." | ||
}, | ||
"verbosity": { | ||
"type": "string", | ||
"enum": ["quiet", "minimal", "normal", "detailed", "diagnostic"], | ||
"default": "minimal" | ||
} | ||
@@ -24,0 +53,0 @@ }, |
import { Tree } from '@nrwl/devkit'; | ||
import { NxDotnetGeneratorSchema } from './schema'; | ||
export default function (host: Tree, options: NxDotnetGeneratorSchema): Promise<void>; | ||
export default function (host: Tree, options: NxDotnetGeneratorSchema, dotnetClient?: any): Promise<void>; |
@@ -5,4 +5,5 @@ "use strict"; | ||
const devkit_1 = require("@nrwl/devkit"); | ||
const core_1 = require("../../core"); | ||
const utils_1 = require("../../utils"); | ||
const dotnet_1 = require("@nx-dotnet/dotnet"); | ||
const utils_1 = require("@nx-dotnet/utils"); | ||
const generator_1 = require("../init/generator"); | ||
function normalizeOptions(host, options) { | ||
@@ -18,3 +19,4 @@ const name = devkit_1.names(options.name).fileName; | ||
: []; | ||
return Object.assign(Object.assign({}, options), { projectName, | ||
return Object.assign(Object.assign({}, options), { name, | ||
projectName, | ||
projectRoot, | ||
@@ -24,5 +26,5 @@ projectDirectory, | ||
} | ||
function default_1(host, options) { | ||
function default_1(host, options, dotnetClient = new dotnet_1.DotNetClient(dotnet_1.dotnetFactory())) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const dotnetClient = new core_1.DotNetClient(core_1.dotnetFactory()); | ||
generator_1.default(host); | ||
const normalizedOptions = normalizeOptions(host, options); | ||
@@ -36,3 +38,26 @@ devkit_1.addProjectConfiguration(host, normalizedOptions.projectName, { | ||
executor: '@nx-dotnet/core:build', | ||
options: { | ||
output: `dist/${normalizedOptions.name}`, | ||
configuration: 'Debug' | ||
}, | ||
configurations: { | ||
production: { | ||
configuration: 'Release' | ||
} | ||
} | ||
}, | ||
serve: { | ||
executor: '@nx-dotnet/core:serve', | ||
options: { | ||
configuration: 'Debug' | ||
}, | ||
configurations: { | ||
production: { | ||
configuration: 'Release' | ||
} | ||
} | ||
}, | ||
test: { | ||
executor: '@nx-dotnet/core:test', | ||
}, | ||
}, | ||
@@ -57,3 +82,3 @@ tags: normalizedOptions.parsedTags, | ||
newParams.push({ | ||
flag: 'dryRun' | ||
flag: 'dry-run', | ||
}); | ||
@@ -60,0 +85,0 @@ } |
@@ -6,7 +6,8 @@ import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; | ||
import { NxDotnetGeneratorSchema } from './schema'; | ||
import { rimraf } from '../../utils'; | ||
import { promises as fs } from 'fs'; | ||
import { DotNetClient, mockDotnetFactory } from '@nx-dotnet/dotnet'; | ||
describe('nx-dotnet app generator', () => { | ||
let appTree: Tree; | ||
let dotnetClient: DotNetClient; | ||
const options: NxDotnetGeneratorSchema = { | ||
@@ -20,15 +21,10 @@ name: 'test', | ||
appTree = createTreeWithEmptyWorkspace(); | ||
dotnetClient = new DotNetClient(mockDotnetFactory()) | ||
}); | ||
afterEach(async () => { | ||
await rimraf('apps/test'); | ||
}); | ||
it('should run successfully', async () => { | ||
await generator(appTree, options); | ||
await generator(appTree, options, dotnetClient); | ||
const config = readProjectConfiguration(appTree, 'test'); | ||
expect(config).toBeDefined(); | ||
const directoryCreated = await (await fs.stat(config.sourceRoot)).isDirectory(); | ||
expect(directoryCreated).toBeTruthy(); | ||
}); | ||
}); |
import { Tree } from '@nrwl/devkit'; | ||
import { NxDotnetGeneratorSchema } from './schema'; | ||
export default function (host: Tree, options: NxDotnetGeneratorSchema): Promise<void>; | ||
export default function (host: Tree, options: NxDotnetGeneratorSchema, dotnetClient?: any): Promise<void>; |
@@ -5,4 +5,5 @@ "use strict"; | ||
const devkit_1 = require("@nrwl/devkit"); | ||
const core_1 = require("../../core"); | ||
const utils_1 = require("../../utils"); | ||
const dotnet_1 = require("@nx-dotnet/dotnet"); | ||
const utils_1 = require("@nx-dotnet/utils"); | ||
const generator_1 = require("../init/generator"); | ||
function normalizeOptions(host, options) { | ||
@@ -18,3 +19,4 @@ const name = devkit_1.names(options.name).fileName; | ||
: []; | ||
return Object.assign(Object.assign({}, options), { projectName, | ||
return Object.assign(Object.assign({}, options), { name, | ||
projectName, | ||
projectRoot, | ||
@@ -24,6 +26,6 @@ projectDirectory, | ||
} | ||
function default_1(host, options) { | ||
function default_1(host, options, dotnetClient = new dotnet_1.DotNetClient(dotnet_1.dotnetFactory())) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
generator_1.default(host); | ||
const normalizedOptions = normalizeOptions(host, options); | ||
const dotnetClient = new core_1.DotNetClient(core_1.dotnetFactory()); | ||
devkit_1.addProjectConfiguration(host, normalizedOptions.projectName, { | ||
@@ -36,2 +38,11 @@ root: normalizedOptions.projectRoot, | ||
executor: '@nx-dotnet/core:build', | ||
options: { | ||
output: `dist/${normalizedOptions.name}`, | ||
configuration: 'Debug', | ||
}, | ||
configurations: { | ||
production: { | ||
configuration: 'Release', | ||
}, | ||
}, | ||
}, | ||
@@ -57,3 +68,3 @@ }, | ||
newParams.push({ | ||
flag: 'dryRun', | ||
flag: 'dry-run', | ||
}); | ||
@@ -60,0 +71,0 @@ } |
@@ -6,6 +6,8 @@ import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; | ||
import { NxDotnetGeneratorSchema } from './schema'; | ||
import { rimraf } from '../../utils'; | ||
import { DotNetClient, mockDotnetFactory } from '@nx-dotnet/dotnet'; | ||
describe('nx-dotnet library generator', () => { | ||
let appTree: Tree; | ||
let dotnetClient: DotNetClient; | ||
const options: NxDotnetGeneratorSchema = { | ||
@@ -19,10 +21,7 @@ name: 'test', | ||
appTree = createTreeWithEmptyWorkspace(); | ||
dotnetClient = new DotNetClient(mockDotnetFactory()); | ||
}); | ||
afterEach(async () => { | ||
await rimraf('libs/test'); | ||
}); | ||
it('should run successfully', async () => { | ||
await generator(appTree, options); | ||
await generator(appTree, options, dotnetClient); | ||
const config = readProjectConfiguration(appTree, 'test'); | ||
@@ -29,0 +28,0 @@ expect(config).toBeDefined(); |
import { Tree } from '@nrwl/devkit'; | ||
import { DotNetClient } from '../../core'; | ||
import { NxDotnetGeneratorSchema } from './schema'; | ||
export default function (host: Tree, options: NxDotnetGeneratorSchema, client?: DotNetClient): Promise<void>; | ||
export default function (host: Tree, options: NxDotnetGeneratorSchema, client?: any): Promise<void>; |
@@ -5,12 +5,18 @@ "use strict"; | ||
const devkit_1 = require("@nrwl/devkit"); | ||
const core_1 = require("../../core"); | ||
const workspace_1 = require("../../utils/workspace"); | ||
function default_1(host, options, client = new core_1.DotNetClient(core_1.dotnetFactory())) { | ||
const dotnet_1 = require("@nx-dotnet/dotnet"); | ||
const utils_1 = require("@nx-dotnet/utils"); | ||
function default_1(host, options, client = new dotnet_1.DotNetClient(dotnet_1.dotnetFactory())) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const hostProject = devkit_1.readProjectConfiguration(host, options.project); | ||
const sourceProject = devkit_1.readProjectConfiguration(host, options.reference); | ||
const [hostProjectFile, sourceProjectFile] = yield Promise.all([ | ||
workspace_1.getProjectFileForNxProject(hostProject), | ||
workspace_1.getProjectFileForNxProject(sourceProject), | ||
]); | ||
let [hostProjectFile, sourceProjectFile] = [null, null]; | ||
try { | ||
[hostProjectFile, sourceProjectFile] = yield Promise.all([ | ||
utils_1.getProjectFileForNxProject(hostProject), | ||
utils_1.getProjectFileForNxProject(sourceProject), | ||
]); | ||
} | ||
catch (_a) { | ||
console.warn('Unable to find project files to add dependency!'); | ||
} | ||
client.addProjectReference(hostProjectFile, sourceProjectFile); | ||
@@ -17,0 +23,0 @@ hostProject.implicitDependencies = hostProject.implicitDependencies || []; |
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; | ||
import { Tree, readProjectConfiguration, addProjectConfiguration } from '@nrwl/devkit'; | ||
import { | ||
Tree, | ||
readProjectConfiguration, | ||
addProjectConfiguration, | ||
} from '@nrwl/devkit'; | ||
import generator from './generator'; | ||
import { NxDotnetGeneratorSchema } from './schema'; | ||
import { DotNetClient } from '../../core'; | ||
import { DotNetClient } from '@nx-dotnet/dotnet'; | ||
@@ -24,7 +28,7 @@ describe('nx-dotnet project reference', () => { | ||
global: false, | ||
version: 0 | ||
} | ||
version: 0, | ||
}, | ||
}); | ||
client.addProjectReference = () => Buffer.from([]); | ||
}) | ||
}); | ||
@@ -39,3 +43,3 @@ beforeEach(() => { | ||
targets: {}, | ||
tags: [] | ||
tags: [], | ||
}); | ||
@@ -47,3 +51,3 @@ | ||
targets: {}, | ||
tags: [] | ||
tags: [], | ||
}); | ||
@@ -55,12 +59,12 @@ }); | ||
await generator(appTree, options, client); | ||
expect(spy).toHaveBeenCalled(); | ||
}); | ||
it('should update dependencies', async () => { | ||
await generator(appTree, options, client); | ||
expect(readProjectConfiguration(appTree, appId).implicitDependencies).toContain(libId); | ||
expect( | ||
readProjectConfiguration(appTree, appId).implicitDependencies | ||
).toContain(libId); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
865
1
0
41419
3
48
+ Added@nx-dotnet/dotnet@0.1.0
+ Added@nx-dotnet/utils@0.1.0
+ Addedchokidar@^3.5.1
+ Added@nx-dotnet/dotnet@0.1.0(transitive)
+ Added@nx-dotnet/utils@0.1.0(transitive)
+ Addedanymatch@3.1.3(transitive)
+ Addedbinary-extensions@2.3.0(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addedchokidar@3.6.0(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedfsevents@2.3.3(transitive)
+ Addedglob-parent@5.1.2(transitive)
+ Addedis-binary-path@2.1.0(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-glob@4.0.3(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addednormalize-path@3.0.0(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedreaddirp@3.6.0(transitive)
+ Addedto-regex-range@5.0.1(transitive)
- Removedglob@^7.1.6
- Removedrimraf@^3.0.2