formatting
This commit is contained in:
parent
fba74f66bc
commit
9a40686bcc
@ -236,8 +236,9 @@ describe('Command line', () => {
|
||||
}, 1000000);
|
||||
|
||||
it('should pass tests', () => {
|
||||
expect(runCommand('npm run test -- --single-run').toString())
|
||||
.toContain('Executed 1 of 1 SUCCESS');
|
||||
expect(runCommand('npm run test -- --single-run').toString()).toContain(
|
||||
'Executed 1 of 1 SUCCESS'
|
||||
);
|
||||
});
|
||||
|
||||
it('should not be able to run tests on an individual app', () => {
|
||||
@ -246,14 +247,16 @@ describe('Command line', () => {
|
||||
fail('boom');
|
||||
} catch (e) {
|
||||
const errorOutput = e.stderr.toString();
|
||||
expect(errorOutput)
|
||||
.toContain('Nx only supports running unit tests for all apps and libs.');
|
||||
expect(errorOutput).toContain(
|
||||
'Nx only supports running unit tests for all apps and libs.'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
it('should pass e2e tests', () => {
|
||||
expect(runCommand('npm run e2e -- --app app1').toString())
|
||||
.toContain('should display welcome message');
|
||||
expect(runCommand('npm run e2e -- --app app1').toString()).toContain(
|
||||
'should display welcome message'
|
||||
);
|
||||
});
|
||||
|
||||
it('should not be able to run e2e tests without specifying an app', () => {
|
||||
@ -262,8 +265,9 @@ describe('Command line', () => {
|
||||
fail('boom');
|
||||
} catch (e) {
|
||||
const errorOutput = e.stderr.toString();
|
||||
expect(errorOutput)
|
||||
.toContain('Please provide the app name using --app or -a.')
|
||||
expect(errorOutput).toContain(
|
||||
'Please provide the app name using --app or -a.'
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -82,9 +82,15 @@ describe('Nrwl Convert to Nx Workspace', () => {
|
||||
'@nrwl/schematics'
|
||||
);
|
||||
|
||||
expect(updatedAngularCLIJson.lint[0].project).toEqual('apps/proj/src/tsconfig.app.json');
|
||||
expect(updatedAngularCLIJson.lint[1].project).toEqual('./tsconfig.spec.json');
|
||||
expect(updatedAngularCLIJson.lint[2].project).toEqual('apps/proj/e2e/tsconfig.e2e.json');
|
||||
expect(updatedAngularCLIJson.lint[0].project).toEqual(
|
||||
'apps/proj/src/tsconfig.app.json'
|
||||
);
|
||||
expect(updatedAngularCLIJson.lint[1].project).toEqual(
|
||||
'./tsconfig.spec.json'
|
||||
);
|
||||
expect(updatedAngularCLIJson.lint[2].project).toEqual(
|
||||
'apps/proj/e2e/tsconfig.e2e.json'
|
||||
);
|
||||
|
||||
// check if tsconfig.json get merged
|
||||
const updatedTsConfig = JSON.parse(readFile('tsconfig.json'));
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
"scripts": {
|
||||
"build": "./scripts/build.sh",
|
||||
"e2e": "./scripts/e2e.sh",
|
||||
"format": "precise-commits --whitelist=\"{packages,e2e}/**/*.ts\"",
|
||||
"format": "prettier \"{packages,e2e}/**/*.ts\" --write",
|
||||
"linknpm": "./scripts/link.sh",
|
||||
"package": "./scripts/package.sh",
|
||||
"release": "./scripts/release.sh",
|
||||
@ -16,9 +16,8 @@
|
||||
"test:nx": "yarn linknpm fast && ./scripts/test_nx.sh",
|
||||
"test":
|
||||
"yarn linknpm && ./scripts/test_nx.sh && ./scripts/test_schematics.sh",
|
||||
"checkformat": "yarn format --check-only",
|
||||
"publish_npm": "./scripts/publish.sh",
|
||||
"precommit": "yarn checkformat"
|
||||
"checkformat": "prettier \"{packages,e2e}/**/*.ts\" --list-different",
|
||||
"publish_npm": "./scripts/publish.sh"
|
||||
},
|
||||
"dependencies": {
|
||||
"jasmine-marbles": "0.2.0"
|
||||
|
||||
@ -1,12 +1,34 @@
|
||||
import { apply, branchAndMerge, chain, mergeWith, noop, Rule, template, Tree, url } from '@angular-devkit/schematics';
|
||||
import {
|
||||
apply,
|
||||
branchAndMerge,
|
||||
chain,
|
||||
mergeWith,
|
||||
noop,
|
||||
Rule,
|
||||
template,
|
||||
Tree,
|
||||
url
|
||||
} from '@angular-devkit/schematics';
|
||||
import { insertImport } from '@schematics/angular/utility/route-utils';
|
||||
import * as path from 'path';
|
||||
import * as ts from 'typescript';
|
||||
|
||||
import { addGlobal, addImportToModule, addIncludeToTsConfig, addReexport, addRoute, insert } from '../../utils/ast-utils';
|
||||
import {
|
||||
addGlobal,
|
||||
addImportToModule,
|
||||
addIncludeToTsConfig,
|
||||
addReexport,
|
||||
addRoute,
|
||||
insert
|
||||
} from '../../utils/ast-utils';
|
||||
import { offsetFromRoot } from '../../utils/common';
|
||||
import { addApp, cliConfig, serializeJson } from '../../utils/fileutils';
|
||||
import { names, toClassName, toFileName, toPropertyName } from '../../utils/name-utils';
|
||||
import {
|
||||
names,
|
||||
toClassName,
|
||||
toFileName,
|
||||
toPropertyName
|
||||
} from '../../utils/name-utils';
|
||||
import { wrapIntoFormat } from '../../utils/tasks';
|
||||
import { Schema } from './schema';
|
||||
|
||||
@ -236,28 +258,32 @@ function validateLibSchema(schema) {
|
||||
}
|
||||
|
||||
const routingRules: Array<Rule> = [
|
||||
options.routing && options.lazy ?
|
||||
addLazyLoadedRouterConfiguration(modulePath) :
|
||||
noop(),
|
||||
options.routing && options.lazy && options.parentModule ?
|
||||
addLoadChildren(options) :
|
||||
noop(),
|
||||
options.routing && options.lazy
|
||||
? addLazyLoadedRouterConfiguration(modulePath)
|
||||
: noop(),
|
||||
options.routing && options.lazy && options.parentModule
|
||||
? addLoadChildren(options)
|
||||
: noop(),
|
||||
|
||||
options.routing && !options.lazy ?
|
||||
addRouterConfiguration(options, indexFile, moduleFileName, modulePath) :
|
||||
noop(),
|
||||
options.routing && !options.lazy && options.parentModule ?
|
||||
addChildren(options) :
|
||||
noop()
|
||||
options.routing && !options.lazy
|
||||
? addRouterConfiguration(options, indexFile, moduleFileName, modulePath)
|
||||
: noop(),
|
||||
options.routing && !options.lazy && options.parentModule
|
||||
? addChildren(options)
|
||||
: noop()
|
||||
];
|
||||
|
||||
const templateSource =
|
||||
apply(url(options.nomodule ? './files' : './ngfiles'), [template({
|
||||
...names(options.name),
|
||||
dot: '.',
|
||||
tmpl: '',
|
||||
...(options as object)
|
||||
})]);
|
||||
const templateSource = apply(
|
||||
url(options.nomodule ? './files' : './ngfiles'),
|
||||
[
|
||||
template({
|
||||
...names(options.name),
|
||||
dot: '.',
|
||||
tmpl: '',
|
||||
...(options as object)
|
||||
})
|
||||
]
|
||||
);
|
||||
|
||||
return {
|
||||
options,
|
||||
@ -271,9 +297,11 @@ function validateLibSchema(schema) {
|
||||
|
||||
export default function(schema: Schema): Rule {
|
||||
return wrapIntoFormat(() => {
|
||||
const {templateSource, routingRules} = validateLibSchema(schema);
|
||||
const { templateSource, routingRules } = validateLibSchema(schema);
|
||||
|
||||
return chain(
|
||||
[branchAndMerge(chain([mergeWith(templateSource)])), ...routingRules]);
|
||||
return chain([
|
||||
branchAndMerge(chain([mergeWith(templateSource)])),
|
||||
...routingRules
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ import {
|
||||
Tree,
|
||||
url,
|
||||
TaskConfigurationGenerator,
|
||||
TaskConfiguration,
|
||||
TaskConfiguration
|
||||
} from '@angular-devkit/schematics';
|
||||
|
||||
import { Schema } from './schema';
|
||||
|
||||
@ -7,16 +7,22 @@ export default {
|
||||
description: 'Add makeSureNoAppIsSelected(); to karma conf',
|
||||
run: async () => {
|
||||
const contents = fs.readFileSync('karma.conf.js').toString();
|
||||
const sourceFile = ts.createSourceFile('karma.conf.js', contents, ts.ScriptTarget.Latest);
|
||||
const sourceFile = ts.createSourceFile(
|
||||
'karma.conf.js',
|
||||
contents,
|
||||
ts.ScriptTarget.Latest
|
||||
);
|
||||
const nodes = getSourceNodes(sourceFile);
|
||||
const isPresent = nodes
|
||||
.filter(ts.isCallExpression)
|
||||
.filter((callExpr: ts.CallExpression) => ts.isIdentifier(callExpr.expression))
|
||||
.filter((callExpr: ts.CallExpression) =>
|
||||
ts.isIdentifier(callExpr.expression)
|
||||
)
|
||||
.some((callExpr: ts.CallExpression) => {
|
||||
const identifier = callExpr.expression as ts.Identifier;
|
||||
return identifier.escapedText === 'makeSureNoAppIsSelected';
|
||||
});
|
||||
|
||||
|
||||
if (isPresent) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -52,12 +52,15 @@ function build(apps: string[], rest: string[]) {
|
||||
|
||||
console.log(`Building ${apps.join(', ')}`);
|
||||
const buildCommands = rest.filter(a => !a.startsWith('--parallel'));
|
||||
runAll(apps.map(app => `ng build -- ${buildCommands.join(' ')} -a=${app}`), {
|
||||
parallel,
|
||||
stdin: process.stdin,
|
||||
stdout: process.stdout,
|
||||
stderr: process.stderr
|
||||
})
|
||||
runAll(
|
||||
apps.map(app => `ng build -- ${buildCommands.join(' ')} -a=${app}`),
|
||||
{
|
||||
parallel,
|
||||
stdin: process.stdin,
|
||||
stdout: process.stdout,
|
||||
stderr: process.stderr
|
||||
}
|
||||
)
|
||||
.then(() => console.log('Build succeeded.'))
|
||||
.catch(err => console.error('Build failed.'));
|
||||
} else {
|
||||
|
||||
@ -75,7 +75,9 @@ export function getProjectNodes(config) {
|
||||
}
|
||||
|
||||
export function readCliConfig(): any {
|
||||
const config = JSON.parse(fs.readFileSync(`${appRoot.path}/.angular-cli.json`, 'utf-8'));
|
||||
const config = JSON.parse(
|
||||
fs.readFileSync(`${appRoot.path}/.angular-cli.json`, 'utf-8')
|
||||
);
|
||||
|
||||
if (!config.project.npmScope) {
|
||||
throw new Error(`.angular-cli.json must define the npmScope property.`);
|
||||
@ -97,7 +99,9 @@ export function getAffectedApps(touchedFiles: string[]): string[] {
|
||||
}
|
||||
|
||||
export function getTouchedProjects(touchedFiles: string[]): string[] {
|
||||
return touchedProjects(getProjectNodes(readCliConfig()), touchedFiles).filter(p => !!p);
|
||||
return touchedProjects(getProjectNodes(readCliConfig()), touchedFiles).filter(
|
||||
p => !!p
|
||||
);
|
||||
}
|
||||
|
||||
export function getProjectRoots(projectNames: string[]): string[] {
|
||||
@ -131,7 +135,10 @@ export function readDependencies(
|
||||
if (!directoryExists(`${appRoot.path}/dist`)) {
|
||||
fs.mkdirSync(`${appRoot.path}/dist`);
|
||||
}
|
||||
if (!fileExists(`${appRoot.path}/dist/nxdeps.json`) || m > mtime(`${appRoot.path}/dist/nxdeps.json`)) {
|
||||
if (
|
||||
!fileExists(`${appRoot.path}/dist/nxdeps.json`) ||
|
||||
m > mtime(`${appRoot.path}/dist/nxdeps.json`)
|
||||
) {
|
||||
const deps = dependencies(npmScope, projectNodes, f =>
|
||||
fs.readFileSync(`${appRoot.path}/${f}`, 'UTF-8')
|
||||
);
|
||||
@ -142,7 +149,9 @@ export function readDependencies(
|
||||
);
|
||||
return deps;
|
||||
} else {
|
||||
return JSON.parse(fs.readFileSync(`${appRoot.path}/dist/nxdeps.json`, 'UTF-8'));
|
||||
return JSON.parse(
|
||||
fs.readFileSync(`${appRoot.path}/dist/nxdeps.json`, 'UTF-8')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ rm -rf build
|
||||
#Nx client side lib
|
||||
cp -r packages/nx/dist build/packages/nx
|
||||
rm -rf build/packages/nx/dist
|
||||
rm -rf packages/nx/dist
|
||||
|
||||
#TODO This is a temporary hack until we can publish named umds
|
||||
sed -i.bak "s/define(\[/define('@nrwl\/nx',\[/" build/packages/nx/bundles/nrwl-nx.umd.js
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user