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