Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: nrwl/nx
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6.3.0
Choose a base ref
...
head repository: nrwl/nx
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6.3.1
Choose a head ref
  • 6 commits
  • 9 files changed
  • 5 contributors

Commits on Sep 14, 2018

  1. build(prettier): ignore package.json from prettier (#759)

    ## Current Behavior
    
    `package.json` was reformatted incorrectly after publishing.
    
    ## Expected Behavior
    
    `/package.json` is ignored from `prettier`. This makes it so the two formatters do not conflict with one another.
    
    ## Notes
    
    This is causing all PRs to fail currently
    FrozenPandaz authored and bcabanes committed Sep 14, 2018

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    c9e29a2 View commit details
  2. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    5c4db34 View commit details
  3. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    f960d5a View commit details

Commits on Sep 19, 2018

  1. Copy the full SHA
    463948c View commit details
  2. Copy the full SHA
    634fd6e View commit details
  3. Release 6.3.1

    jeffbcross committed Sep 19, 2018
    Copy the full SHA
    bd31278 View commit details
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
tmp
build
node_modules
/package.json
packages/schematics/src/collection/**/files/*.json
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nrwl/nx-source",
"version": "6.3.0",
"version": "6.3.1",
"description": "Nrwl Extensions for Angular",
"main": "index.js",
"private": true,
11 changes: 11 additions & 0 deletions packages/schematics/src/collection/application/application.spec.ts
Original file line number Diff line number Diff line change
@@ -239,6 +239,17 @@ describe('app', () => {
getFileContent(tree, 'apps/my-dir/my-app/src/app/app.component.spec.ts')
).toContain('imports: [RouterTestingModule]');
});

it('should not modify tests when --skip-tests is set', () => {
const tree = schematicRunner.runSchematic(
'app',
{ name: 'myApp', directory: 'myDir', routing: true, skipTests: true },
appTree
);
expect(
tree.exists('apps/my-dir/my-app/src/app/app.component.spec.ts')
).toBeFalsy();
});
});

describe('template generation mode', () => {
49 changes: 27 additions & 22 deletions packages/schematics/src/collection/application/index.ts
Original file line number Diff line number Diff line change
@@ -73,29 +73,34 @@ function addRouterRootConfiguration(options: NormalizedSchema): Rule {
)
]);

const componentSpecPath = `${
options.appProjectRoot
}/src/app/app.component.spec.ts`;
const componentSpecSource = host.read(componentSpecPath)!.toString('utf-8');
const componentSpecSourceFile = ts.createSourceFile(
componentSpecPath,
componentSpecSource,
ts.ScriptTarget.Latest,
true
);
insert(host, componentSpecPath, [
insertImport(
componentSpecSourceFile,
componentSpecPath,
'RouterTestingModule',
'@angular/router/testing'
),
...addImportToTestBed(
componentSpecSourceFile,
if (options.skipTests !== true) {
const componentSpecPath = `${
options.appProjectRoot
}/src/app/app.component.spec.ts`;
const componentSpecSource = host.read(componentSpecPath)!.toString(
'utf-8'
);
const componentSpecSourceFile = ts.createSourceFile(
componentSpecPath,
`RouterTestingModule`
)
]);
componentSpecSource,
ts.ScriptTarget.Latest,
true
);
insert(host, componentSpecPath, [
insertImport(
componentSpecSourceFile,
componentSpecPath,
'RouterTestingModule',
'@angular/router/testing'
),
...addImportToTestBed(
componentSpecSourceFile,
componentSpecPath,
`RouterTestingModule`
)
]);
}

return host;
};
}
Original file line number Diff line number Diff line change
@@ -5,6 +5,6 @@
"module": "commonjs",
"types": ["jest", "node"]
},
"files": [<% if(!skipSetupFile) { %>"src/test-setup.ts", <% } %>"src/polyfills.ts"],
<% if(!skipSetupFile) { %>"files": ["src/test-setup.ts"],<% } %>
"include": ["**/*.spec.ts", "**/*.d.ts"]
}
Original file line number Diff line number Diff line change
@@ -16,9 +16,6 @@ describe('lib', () => {
appTree = new VirtualTree();
appTree = createEmptyWorkspace(appTree);
appTree = schematicRunner.runSchematic('jest', {}, appTree);
});

it('should generate files', () => {
appTree = schematicRunner.runSchematic(
'lib',
{
@@ -27,6 +24,9 @@ describe('lib', () => {
},
appTree
);
});

it('should generate files', () => {
const resultTree = schematicRunner.runSchematic(
'jest-project',
{
@@ -40,14 +40,6 @@ describe('lib', () => {
});

it('should alter angular.json', () => {
appTree = schematicRunner.runSchematic(
'lib',
{
name: 'lib1',
unitTestRunner: 'none'
},
appTree
);
const resultTree = schematicRunner.runSchematic(
'jest-project',
{
@@ -69,15 +61,24 @@ describe('lib', () => {
);
});

it('should create a tsconfig.spec.json', () => {
appTree = schematicRunner.runSchematic(
'lib',
it('should create a jest.config.js', () => {
const resultTree = schematicRunner.runSchematic(
'jest-project',
{
name: 'lib1',
unitTestRunner: 'none'
project: 'lib1'
},
appTree
);
expect(resultTree.readContent('libs/lib1/jest.config.js'))
.toBe(`module.exports = {
name: 'lib1',
preset: '../../jest.config.js',
coverageDirectory: '../../coverage/libs/lib1'
};
`);
});

it('should create a tsconfig.spec.json', () => {
const resultTree = schematicRunner.runSchematic(
'jest-project',
{
@@ -93,21 +94,13 @@ describe('lib', () => {
outDir: '../../dist/out-tsc/libs/lib1',
types: ['jest', 'node']
},
files: ['src/test-setup.ts', 'src/polyfills.ts'],
files: ['src/test-setup.ts'],
include: ['**/*.spec.ts', '**/*.d.ts']
});
});

describe('--skip-setup-file', () => {
it('should generate src/test-setup.ts', () => {
appTree = schematicRunner.runSchematic(
'lib',
{
name: 'lib1',
unitTestRunner: 'none'
},
appTree
);
const resultTree = schematicRunner.runSchematic(
'jest-project',
{
@@ -120,14 +113,6 @@ describe('lib', () => {
});

it('should not list the setup file in angular.json', () => {
appTree = schematicRunner.runSchematic(
'lib',
{
name: 'lib1',
unitTestRunner: 'none'
},
appTree
);
const resultTree = schematicRunner.runSchematic(
'jest-project',
{
@@ -143,14 +128,6 @@ describe('lib', () => {
});

it('should not list the setup file in tsconfig.spec.json', () => {
appTree = schematicRunner.runSchematic(
'lib',
{
name: 'lib1',
unitTestRunner: 'none'
},
appTree
);
const resultTree = schematicRunner.runSchematic(
'jest-project',
{
@@ -163,7 +140,7 @@ describe('lib', () => {
resultTree,
'libs/lib1/tsconfig.spec.json'
);
expect(tsConfig.files).not.toContain('src/test-setup.ts');
expect(tsConfig.files).toBeUndefined();
});
});
});
19 changes: 19 additions & 0 deletions packages/schematics/src/utils/common.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { offsetFromRoot } from './common';
describe('offsetFromRoot', () => {
it('should work for normal paths', () => {
const result = offsetFromRoot('apps/appname');
expect(result).toBe('../../');
});
it('should work for paths with a trailing slash', () => {
const result = offsetFromRoot('apps/appname/');
expect(result).toBe('../../');
});
it('should work for deep paths', () => {
const result = offsetFromRoot('apps/dirname/appname');
expect(result).toBe('../../../');
});
it('should work for deep paths with a trailing slash', () => {
const result = offsetFromRoot('apps/dirname/appname/');
expect(result).toBe('../../../');
});
});
3 changes: 2 additions & 1 deletion packages/schematics/src/utils/common.ts
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import * as cosmiconfig from 'cosmiconfig';

import { angularJsVersion } from '../lib-versions';
import { updateJsonInTree } from './ast-utils';
import { normalize } from '@angular-devkit/core';

export function addUpgradeToPackageJson(): Rule {
return updateJsonInTree('package.json', packageJson => {
@@ -24,7 +25,7 @@ export function addUpgradeToPackageJson(): Rule {
}

export function offsetFromRoot(fullPathToSourceDir: string): string {
const parts = fullPathToSourceDir.split('/');
const parts = normalize(fullPathToSourceDir).split('/');
let offset = '';
for (let i = 0; i < parts.length; ++i) {
offset += '../';
11 changes: 7 additions & 4 deletions scripts/commit-lint.js
Original file line number Diff line number Diff line change
@@ -5,22 +5,25 @@ const gitMessage = require('child_process')
.execSync('git log -1 --no-merges')
.toString()
.trim();
const matchTest = /([a-z]){0,8}\([a-z.0-9\-]+\):\s(([a-z0-9:\-\s])+)/g.test(
const matchCommit = /([a-z]){0,8}\([a-z.0-9\-]+\):\s(([a-z0-9:\-\s])+)/g.test(
gitMessage
);
const exitCode = +!matchTest;
const matchRelease = /release/gi.test(gitMessage);
const exitCode = +!(matchRelease || matchCommit);

if (exitCode === 0) {
console.log('Commit ACCEPTED 👌');
} else {
console.log(
'[Error]: Ho no! 😦 Your commit message: \n' +
'-------------------------------------------------------------------\n' +
gitMessage +
'\ndoes not follow the commit message convention specified in the CONTRIBUTING.MD file.'
'\n-------------------------------------------------------------------' +
'\n\n 👉️ Does not follow the commit message convention specified in the CONTRIBUTING.MD file.'
);
console.log('\ntype(scope): subject \n BLANK LINE \n body');
console.log(
'\nExample: \n ' +
'\nEXAMPLE: \n ' +
'feat(schematics): add an option to generate lazy-loadable modules\n' +
'\n`ng generate lib mylib --lazy` provisions the mylib project in tslint.json'
);