Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split out dotnet + utils to libraries in preparation for new packages #17

Merged
merged 4 commits into from
Apr 15, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore(): beginning progress
  • Loading branch information
AgentEnder committed Apr 15, 2021
commit 413cc0ecf3bb7c9c6bbbcfd51d19e1c49dc55439
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ module.exports = {
'<rootDir>/e2e\\core-e2e',
'<rootDir>/packages/typescript',
'<rootDir>/e2e\\typescript-e2e',
'<rootDir>/packages/dotnet',
'<rootDir>/packages/utils',
'<rootDir>/packages/utils',
'<rootDir>/packages/dotnet',
],
};
42 changes: 34 additions & 8 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{
"npmScope": "nx-dotnet",
"affected": { "defaultBase": "master" },
"affected": {
"defaultBase": "master"
},
"implicitDependencies": {
"workspace.json": "*",
"package.json": { "dependencies": "*", "devDependencies": "*" },
"package.json": {
"dependencies": "*",
"devDependencies": "*"
},
"tsconfig.base.json": "*",
"tslint.json": "*",
".eslintrc.json": "*",
Expand All @@ -12,14 +17,35 @@
"tasksRunnerOptions": {
"default": {
"runner": "@nrwl/workspace/tasks-runners/default",
"options": { "cacheableOperations": ["build", "lint", "test", "e2e"] }
"options": {
"cacheableOperations": ["build", "lint", "test", "e2e"]
}
}
},
"projects": {
"core": { "tags": [] },
"core-e2e": { "tags": [], "implicitDependencies": ["core"] },
"typescript": { "tags": [] },
"typescript-e2e": { "tags": [], "implicitDependencies": ["typescript"] }
"core": {
"tags": []
},
"core-e2e": {
"tags": [],
"implicitDependencies": ["core"]
},
"typescript": {
"tags": []
},
"typescript-e2e": {
"tags": [],
"implicitDependencies": ["typescript"]
},
"utils": {
"tags": []
},
"dotnet": {
"tags": []
}
},
"workspaceLayout": { "appsDir": "e2e", "libsDir": "packages" }
"workspaceLayout": {
"appsDir": "e2e",
"libsDir": "packages"
}
}
4 changes: 2 additions & 2 deletions packages/core/src/executors/build/executor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ExecutorContext } from '@nrwl/devkit';
import { promises as fs } from 'fs';
import { DotNetClient, mockDotnetFactory } from '../../core';
import { rimraf } from '../../utils';
import { DotNetClient, mockDotnetFactory } from '@nx-dotnet/dotnet';
import { rimraf } from '@nx-dotnet/utils';

import executor from './executor';
import { BuildExecutorSchema } from './schema';
Expand Down
44 changes: 29 additions & 15 deletions packages/core/src/executors/build/executor.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,48 @@
import { ExecutorContext } from '@nrwl/devkit';
import { BuildExecutorSchema } from './schema';
import { DotNetClient, dotnetFactory } from '../../core';
import { glob } from '../../utils';
import { dotnetBuildFlags } from '../../models';

import { glob } from '@nx-dotnet/utils';
import {
dotnetBuildFlags,
DotNetClient,
dotnetFactory,
} from '@nx-dotnet/dotnet';

export default async function runExecutor(
options: BuildExecutorSchema,
context: ExecutorContext,
dotnetClient: DotNetClient = new DotNetClient(dotnetFactory())
) {
const nxProjectConfiguration = context.workspace.projects[context.projectName];
const projectFilePath = await glob(`${nxProjectConfiguration.root}/**/*.*proj`);
const nxProjectConfiguration =
context.workspace.projects[context.projectName];
const projectFilePath = await glob(
`${nxProjectConfiguration.root}/**/*.*proj`
);

console.log(
`Looking for project files at '${nxProjectConfiguration.root}/**/*.*proj'`
);

console.log(`Looking for project files at '${nxProjectConfiguration.root}/**/*.*proj'`)

if (!projectFilePath || projectFilePath.length === 0) {
throw new Error('Unable to find a build-able project within project\'s source directory!');
throw new Error(
"Unable to find a build-able project within project's source directory!"
);
}

if (projectFilePath.length > 1) {
throw new Error(`More than one build-able projects are contained within the project's source directory! \r\n ${projectFilePath}`)
throw new Error(
`More than one build-able projects are contained within the project's source directory! \r\n ${projectFilePath}`
);
}

dotnetClient.build(projectFilePath[0], Object.keys(options).map((x: dotnetBuildFlags) => ({
flag: x,
value: options[x]
})));
dotnetClient.build(
projectFilePath[0],
Object.keys(options).map((x: dotnetBuildFlags) => ({
flag: x,
value: options[x],
}))
);

return {
success: true
success: true,
};
}
2 changes: 1 addition & 1 deletion packages/core/src/executors/build/schema.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { dotnetBuildFlags } from '../../models';
import { dotnetBuildFlags } from '@nx-dotnet/dotnet';

export type BuildExecutorSchema = {
[key in dotnetBuildFlags]?: string
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/generators/app/generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Tree, readProjectConfiguration } from '@nrwl/devkit';

import generator from './generator';
import { NxDotnetGeneratorSchema } from './schema';
import { rimraf } from '../../utils';
import { rimraf } from '@nx-dotnet/utils';
import { promises as fs } from 'fs';

describe('nx-dotnet app generator', () => {
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/generators/app/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import {
Tree,
} from '@nrwl/devkit';
import { NxDotnetGeneratorSchema } from './schema';
import { DotNetClient, dotnetFactory, LoadedCLI } from '../../core';
import { dotnetNewOptions } from '../../models';
import { isDryRun } from '../../utils';
import { DotNetClient, dotnetFactory, LoadedCLI, dotnetNewOptions } from '@nx-dotnet/dotnet';
import { isDryRun } from '@nx-dotnet/utils';

interface NormalizedSchema extends NxDotnetGeneratorSchema {
projectName: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/generators/lib/generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Tree, readProjectConfiguration } from '@nrwl/devkit';

import generator from './generator';
import { NxDotnetGeneratorSchema } from './schema';
import { rimraf } from '../../utils';
import { rimraf } from '@nx-dotnet/utils';

describe('nx-dotnet library generator', () => {
let appTree: Tree;
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/generators/lib/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import {
Tree,
} from '@nrwl/devkit';

import { DotNetClient, dotnetFactory } from '../../core';
import { dotnetNewOptions } from '../../models';
import { isDryRun } from '../../utils';
import { DotNetClient, dotnetFactory } from '@nx-dotnet/dotnet';
import { dotnetNewOptions } from '@nx-dotnet/dotnet';
import { isDryRun } from '@nx-dotnet/utils';
import { NxDotnetGeneratorSchema } from './schema';

interface NormalizedSchema extends NxDotnetGeneratorSchema {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {

import generator from './generator';
import { NxDotnetGeneratorSchema } from './schema';
import { DotNetClient } from '../../core';
import { DotNetClient } from '@nx-dotnet/dotnet';

describe('nx-dotnet project reference', () => {
let appTree: Tree;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/generators/project-reference/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
updateProjectConfiguration,
} from '@nrwl/devkit';

import { DotNetClient, dotnetFactory } from '../../core';
import { getProjectFileForNxProject } from '../../utils/workspace';
import { DotNetClient, dotnetFactory } from '@nx-dotnet/dotnet';
import { getProjectFileForNxProject } from '@nx-dotnet/utils';
import { NxDotnetGeneratorSchema } from './schema';

export default async function (
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/models/dotnet-build/index.ts

This file was deleted.

15 changes: 0 additions & 15 deletions packages/core/src/utils/parameters.ts

This file was deleted.

3 changes: 3 additions & 0 deletions packages/dotnet/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": [["@nrwl/web/babel", { "useBuiltIns": "usage" }]]
}
21 changes: 21 additions & 0 deletions packages/dotnet/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"extends": "../../.eslintrc.json",
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"parserOptions": {
"project": ["packages/dotnet2/tsconfig.*?.json"]
},
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
7 changes: 7 additions & 0 deletions packages/dotnet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# dotnet2

This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `nx test dotnet2` to execute the unit tests via [Jest](https://jestjs.io).
14 changes: 14 additions & 0 deletions packages/dotnet/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
displayName: 'dotnet',
preset: '../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
},
},
transform: {
'^.+\\.[tj]sx?$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/packages/dotnet',
};
9 changes: 9 additions & 0 deletions packages/dotnet/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "@nx-dotnet/dotnet",
"version": "0.0.6-dev.23",
"private": false,
"peerDependencies": {
"glob": "^7.1.6",
"rimraf": "^3.0.2"
}
}
1 change: 1 addition & 0 deletions packages/dotnet/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib';
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { execSync } from 'child_process';
import {
dotnetTemplate,
dotnetNewOptions,
} from '../models';
import { dotnetBuildOptions } from '../models/dotnet-build/dotnet-build-options';
import { getParameterString } from '../utils/parameters';
import { dotnetBuildOptions, dotnetTemplate, dotnetNewOptions } from '../models';
import { getParameterString } from '@nx-dotnet/utils';
import { LoadedCLI } from './dotnet.factory';

export class DotNetClient {
Expand All @@ -19,7 +15,7 @@ export class DotNetClient {
build(project, parameters?: dotnetBuildOptions): Buffer {
const paramString = getParameterString(parameters);
const cmd = `${this.cliCommand.command} build ${project} ${paramString}`;
return this.logAndExecute(cmd)
return this.logAndExecute(cmd);
}

addProjectReference(hostCsProj: string, targetCsProj: string): Buffer {
Expand All @@ -30,6 +26,6 @@ export class DotNetClient {

private logAndExecute(cmd): Buffer {
console.log(`Executing Command: ${cmd}`);
return execSync(cmd, {stdio: 'inherit'});
return execSync(cmd, { stdio: 'inherit' });
}
}
}
File renamed without changes.
2 changes: 2 additions & 0 deletions packages/dotnet/src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './core';
export * from './models';
2 changes: 2 additions & 0 deletions packages/dotnet/src/lib/models/dotnet-build/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './dotnet-build-flags';
export * from './dotnet-build-options';
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './cmd-line-parameter';
export * from './dotnet-new';
export * from './dotnet-build';
13 changes: 13 additions & 0 deletions packages/dotnet/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
9 changes: 9 additions & 0 deletions packages/dotnet/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": ["node"]
},
"include": ["**/*.ts"],
"exclude": ["**/*.spec.ts"]
}
15 changes: 15 additions & 0 deletions packages/dotnet/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": [
"**/*.spec.ts",
"**/*.spec.tsx",
"**/*.spec.js",
"**/*.spec.jsx",
"**/*.d.ts"
]
}
3 changes: 3 additions & 0 deletions packages/utils/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": [["@nrwl/web/babel", { "useBuiltIns": "usage" }]]
}
Loading