Skip to content

Commit

Permalink
fix(schematics): fix parse module name error (#3848)
Browse files Browse the repository at this point in the history
* fix(schematics): fix parse module name error

close #3844

* style(schematics): fix lint

* chore: update bot config

* chore: update schematics API
  • Loading branch information
hsuanxyz authored and chensimeng committed Jul 28, 2019
1 parent 3dbb6dc commit d4e7210
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions .github/nz-boot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ issue:
Progress: wendzhue
Radio: vthinkxie
Rate: wendzhue
Result: wendzhue
Select: vthinkxie
Slider: wendzhue
Spin: vthinkxie
Expand Down
18 changes: 9 additions & 9 deletions schematics/utils/build-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
import { strings, template as interpolateTemplate } from '@angular-devkit/core';
import {
apply,
applyTemplates,
branchAndMerge,
chain,
filter,
mergeWith,
move,
noop,
url,
Rule,
SchematicsException,
template,
Tree,
url
Tree
} from '@angular-devkit/schematics';
import { FileSystemSchematicContext } from '@angular-devkit/schematics/tools';
import { getDefaultComponentOptions, getProjectFromWorkspace, ts } from '@angular/cdk/schematics';
Expand Down Expand Up @@ -232,8 +232,8 @@ export function buildComponent(options: ZorroComponentOptions,
options.module = findModuleFromOptions(host, options);

const parsedPath = parseName(options.path!, options.name);
const source = readIntoSourceFile(host, options.module);
if (options.classnameWithModule) {
if (options.classnameWithModule && !options.skipImport && options.module) {
const source = readIntoSourceFile(host, options.module);
modulePrefix = getModuleClassnamePrefix(source);
}

Expand Down Expand Up @@ -279,13 +279,13 @@ export function buildComponent(options: ZorroComponentOptions,
}

const templateSource = apply(url(schematicFilesUrl), [
options.skipTests ? filter(path => !path.endsWith('.spec.ts')) : noop(),
options.inlineStyle ? filter(path => !path.endsWith('.__style__')) : noop(),
options.inlineTemplate ? filter(path => !path.endsWith('.html')) : noop(),
options.skipTests ? filter(path => !path.endsWith('.spec.ts.template')) : noop(),
options.inlineStyle ? filter(path => !path.endsWith('.__style__.template')) : noop(),
options.inlineTemplate ? filter(path => !path.endsWith('.html.template')) : noop(),
// Treat the template options as any, because the type definition for the template options
// is made unnecessarily explicit. Every type of object can be used in the EJS template.
// tslint:disable-next-line no-any
template({ indentTextContent, resolvedFiles, ...baseTemplateContext } as any),
applyTemplates({ indentTextContent, resolvedFiles, ...baseTemplateContext } as any),
// TODO(devversion): figure out why we cannot just remove the first parameter
// See for example: angular-cli#schematics/angular/component/index.ts#L160
// tslint:disable-next-line no-any
Expand Down
8 changes: 4 additions & 4 deletions scripts/schematics/demo2schematics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ function createSchematic(demoComponent: DemoMeta): void {
schemaJson.title = `NG-ZORRO ${demoComponent.demoName} ${demoComponent.componentName}`;
fs.outputJsonSync(schemaPath, schemaJson);

fs.outputFileSync(`${filesPath}/__name@dasherize__.component.__style__`, demoComponent.styles);
fs.outputFileSync(`${filesPath}/__name@dasherize__.component.html`, demoComponent.template);
fs.outputFileSync(`${filesPath}/__name@dasherize__.component.spec.ts`, TEST_FILE_CONTENT);
fs.outputFileSync(`${filesPath}/__name@dasherize__.component.ts`, replaceTemplate(demoComponent));
fs.outputFileSync(`${filesPath}/__name@dasherize__.component.__style__.template`, demoComponent.styles);
fs.outputFileSync(`${filesPath}/__name@dasherize__.component.html.template`, demoComponent.template);
fs.outputFileSync(`${filesPath}/__name@dasherize__.component.spec.ts.template`, TEST_FILE_CONTENT);
fs.outputFileSync(`${filesPath}/__name@dasherize__.component.ts.template`, replaceTemplate(demoComponent));

const collectionJson = fs.readJsonSync(collectionPath, { throws: false }) || {schematics: {}};
collectionJson.schematics = {
Expand Down

0 comments on commit d4e7210

Please sign in to comment.