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

fix(schematic:ng-add): fix import path in theme file #1611

Merged
merged 1 commit into from
Jun 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 0 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ echo 'Generate schematics by demos'
npm run schematic:demo

echo 'Building schematics'
node ./schematics_script/set-version.js
node ./schematics_script/set-theme.js
npm run schematic:demo
npm run schematic:build
rm -rf schematics/demo
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"site": "node site_scripts/generate-site",
"schematic:demo": "node schematics_script/demo2schematics",
"schematic:tsc": "tsc -p schematics/tsconfig.json",
"schematic:build": "npm run schematic:tsc && node schematics_script/copy-resources",
"schematic:build": "node ./schematics_script/set-theme.js && node ./schematics_script/set-version.js && npm run schematic:tsc && node schematics_script/copy-resources",
"ng": "ng",
"start": "ng serve -p 0",
"build": "node site_scripts/generate-site init && ng build",
Expand Down
13 changes: 7 additions & 6 deletions schematics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,21 @@ $ ng add ng-zorro-antd [--locale=zh-CN] [--theme] [--skipPackageJson]
- `node ./schematics_script/set-version.js` 从 package.json 设置版本号
- `node ./schematics_script/set-theme.js` 从 site_scripts/_site/src/theme.less 设置自定义样式内容

### 开发
### 首次运行

只有首次运行才需要以下步骤
生成 publish 之后,创建一个新的 ng 项目

1. 运行 `npm run generate` 生成 `publish` 文件夹
2. `cd publish && npm link`
3. `ng new schematic-debug`
4. `cd schematic-debug && npm link ng-zorro-antd`

调试
### 调试

1. `cd schematic-debug`
1. `git checkout . && git clean -fd`
1. `ng g ng-zorro-antd:[schematics]`
1. `schematic:build` 修改代码后编译
2 `cd schematic-debug` 切换到 ng 项目
3. `git checkout . && git clean -fd` 还原更改
4. `ng g ng-zorro-antd:[schematic]` 运行 schematic

发布

Expand Down
4 changes: 2 additions & 2 deletions schematics/ng-add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ export default function (options: Schema): Rule {
]);
}

/** 添加 i18n 配置, 取决于 options.locale */
/** 添加 i18n 配置, 取决于 options.i18n */
function addI18n(options: Schema): (host: Tree) => Tree {
return function (host: Tree): Tree {
const workspace = getWorkspace(host);
const project = getProjectFromWorkspace(workspace, options.project);
const modulePath = getAppModulePath(host, project.architect.build.options.main);
const moduleSource = getSourceFile(host, modulePath);
const locale = options.locale;
const locale = options.i18n;
const localePrefix = locale.split('_')[0];

if (!moduleSource) {
Expand Down
2 changes: 1 addition & 1 deletion schematics/ng-add/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"default": false,
"description": "Do not add ng-zorro dependencies to package.json (e.g., --skipPackageJson)"
},
"locale": {
"i18n": {
"type": "string",
"default": "zh_CN",
"enum": ["ar_EG","bg_BG","ca_ES","cs_CZ","de_DE","el_GR","en_GB","en_US","es_ES","et_EE","fa_IR","fi_FI","fr_BE","fr_FR","is_IS","it_IT","ja_JP","ko_KR","nb_NO","nl_BE","nl_NL","pl_PL","pt_BR","pt_PT","sk_SK","sr_RS","sv_SE","th_TH","tr_TR","ru_RU","uk_UA","vi_VN","zh_CN","zh_TW"],
Expand Down
2 changes: 1 addition & 1 deletion schematics/ng-add/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export interface Schema {
/** Name of the project to target. */
project?: string;

locale: 'ar_EG' | 'bg_BG' | 'ca_ES' | 'cs_CZ' | 'de_DE' | 'el_GR' | 'en_GB' | 'en_US' | 'es_ES' | 'et_EE' | 'fa_IR' | 'fi_FI' | 'fr_BE' | 'fr_FR' | 'is_IS' | 'it_IT' | 'ja_JP' | 'ko_KR' | 'nb_NO' | 'nl_BE' | 'nl_NL' | 'pl_PL' | 'pt_BR' | 'pt_PT' | 'sk_SK' | 'sr_RS' | 'sv_SE' | 'th_TH' | 'tr_TR' | 'ru_RU' | 'uk_UA' | 'vi_VN' | 'zh_CN' | 'zh_TW';
i18n: 'ar_EG' | 'bg_BG' | 'ca_ES' | 'cs_CZ' | 'de_DE' | 'el_GR' | 'en_GB' | 'en_US' | 'es_ES' | 'et_EE' | 'fa_IR' | 'fi_FI' | 'fr_BE' | 'fr_FR' | 'is_IS' | 'it_IT' | 'ja_JP' | 'ko_KR' | 'nb_NO' | 'nl_BE' | 'nl_NL' | 'pl_PL' | 'pt_BR' | 'pt_PT' | 'sk_SK' | 'sr_RS' | 'sv_SE' | 'th_TH' | 'tr_TR' | 'ru_RU' | 'uk_UA' | 'vi_VN' | 'zh_CN' | 'zh_TW';
}
4 changes: 0 additions & 4 deletions schematics/utils/custom-theme.ts

This file was deleted.

1 change: 0 additions & 1 deletion schematics/utils/lib-versions.ts

This file was deleted.

2 changes: 1 addition & 1 deletion schematics_script/set-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const theme = fs.readFileSync(path.resolve(__dirname, `../site_scripts/_site/src
fs.outputFileSync(
path.resolve(__dirname, `../schematics/utils/custom-theme.ts`),
`export function createCustomTheme() {
return \`@import "~ng-zorro-antd/src/ng-zorro-antd.less";
return \`@import "../node_modules/ng-zorro-antd/src/ng-zorro-antd.less";
${theme.replace(/`/g, '\\`')}
\`;
}
Expand Down