Skip to content

Commit

Permalink
build: refactor scripts and sort dependencies (#2192)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsuanxyz authored and vthinkxie committed Sep 30, 2018
1 parent 95954cc commit 34f4a4b
Show file tree
Hide file tree
Showing 139 changed files with 85 additions and 111 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

# compiled output
dist/
site/
/site/
tmp/
out-tsc/
publish/
/publish/
integration/**/lib/
integration/**/*.ngfactory.ts
integration/**/*.ngsummary.json
Expand Down
30 changes: 0 additions & 30 deletions build_scripts/inline-template.js

This file was deleted.

2 changes: 1 addition & 1 deletion docs/customize-theme.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Here is an example of `theme.less`
```


All less vars can be checked [here](https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/site_scripts/_site/src/theme.less) is a sample of theme define file.
All less vars can be checked [here](https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/scripts/site/_site/src/theme.less) is a sample of theme define file.


## Local deployment fonts
Expand Down
2 changes: 1 addition & 1 deletion docs/customize-theme.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Ant Design 的样式使用了 [Less](http://lesscss.org/) 作为开发语言,
@primary-color : #f5222d;
```

全部可被自定义 less 变量可以参考 [这里](https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/site_scripts/_site/src/theme.less)
全部可被自定义 less 变量可以参考 [这里](https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/scripts/site/_site/src/theme.less)

## 本地部署字体

Expand Down
75 changes: 38 additions & 37 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,80 +4,77 @@
"license": "MIT",
"description": "An enterprise-class UI components based on Ant Design and Angular",
"scripts": {
"site:start": "node site_scripts/generate-site init && node site_scripts/generateColorLess && ng serve --port 0 --open",
"site:init": "node site_scripts/generate-site init && node site_scripts/generateColorLess",
"site": "node site_scripts/generate-site",
"schematic:demo": "node schematics_script/demo2schematics",
"schematic:tsc": "tsc -p schematics/tsconfig.json",
"schematic:build": "node ./schematics_script/set-theme.js && node ./schematics_script/set-version.js && npm run schematic:tsc && node schematics_script/copy-resources",
"schematic:generate": "npm run schematic:demo && npm run schematic:build && rm -rf schematics/demo",
"ng": "ng",
"start": "ng serve -port 0",
"build": "node site_scripts/generate-site init && ng build",
"doc": "npm run site:init && node --max_old_space_size=5120 ./node_modules/@angular/cli/bin/ng build --prod --build-optimizer",
"helper": "bash ./release-helper.sh",
"migration-styles": "node build_scripts/migration-styles.js",
"generate": "ng build ng-zorro-antd-lib",
"postgenerate": "node ./build_scripts/generate-less.js && cp README.md publish/README.md && npm run migration-styles && npm run schematic:generate",
"pre-release": "npm run site:init && bash ./build_scripts/replace-publish.sh && npm run generate && node --max_old_space_size=5120 ./node_modules/@angular/cli/bin/ng build --prod && npm run helper",
"build": "node ./scripts/site/generate-site init && ng build",
"test": "ng test --watch=false --code-coverage",
"lint": "tslint -c tslint.json 'components/*/*.ts'",
"release": "node ./scripts/publish/publish.js",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --pkg components/package.json && node ./scripts/site/replace-scope-prefix.js",
"doc": "npm run site:init && node --max_old_space_size=5120 ./node_modules/@angular/cli/bin/ng build --prod --build-optimizer",
"helper": "bash ./scripts/release-helper.sh",
"migration-styles": "node ./scripts/build/migration-styles.js",
"ng": "ng",
"site": "node ./scripts/site/generate-site",
"site:start": "node ./scripts/site/generate-site init && node ./scripts/site/generateColorLess && ng serve --port 0 --open",
"site:init": "node ./scripts/site/generate-site init && node ./scripts/site/generateColorLess",
"schematic:demo": "node ./scripts/schematics/demo2schematics",
"schematic:tsc": "tsc -p schematics/tsconfig.json",
"schematic:build": "node ./scripts/schematics/set-theme.js && node ./scripts/schematics/set-version.js && npm run schematic:tsc && node ./scripts/schematics/copy-resources",
"schematic:generate": "npm run schematic:demo && npm run schematic:build && rm -rf schematics/demo",
"integration": "npm run generate && bash ./integration-test.sh",
"integration-cli": "npm run generate && cd integration/angular-cli && npm run integration",
"integration-webpack": "npm run generate && cd integration/webpack && npm run integration",
"integration-rollup": "npm run generate && cd integration/rollup && npm run integration",
"lint": "tslint -c tslint.json 'components/*/*.ts'",
"release": "node ./publish_scripts/publish.js",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --pkg components/package.json && node site_scripts/replace-scope-prefix.js"
"postgenerate": "node ./scripts/build/generate-less.js && cp README.md publish/README.md && npm run migration-styles && npm run schematic:generate",
"generate": "ng build ng-zorro-antd-lib",
"pre-release": "npm run site:init && bash ./scripts/build/replace-publish.sh && npm run generate && node --max_old_space_size=5120 ./node_modules/@angular/cli/bin/ng build --prod && npm run helper"
},
"dependencies": {
"@angular/cdk": "^6.0.0",
"date-fns": "^1.29.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.6.0",
"@angular/cli": "~6.2.1",
"@angular/compiler-cli": "^6.1.0",
"@angular/language-service": "^6.1.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.3.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~1.7.1",
"karma-chrome-launcher": "~2.2.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "~1.4.2",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~2.9.2",
"@angular-devkit/build-ng-packagr": "^0.6.8",
"@angular-devkit/core": "^0.6.0",
"@angular-devkit/schematics": "^0.6.0",
"@angular/animations": "^6.0.0",
"@angular/cli": "~6.2.1",
"@angular/common": "^6.0.0",
"@angular/compiler": "^6.0.0",
"@angular/compiler-cli": "^6.1.0",
"@angular/core": "^6.0.0",
"@angular/forms": "^6.0.0",
"@angular/http": "^6.0.0",
"@angular/language-service": "^6.1.0",
"@angular/platform-browser": "^6.0.0",
"@angular/platform-browser-dynamic": "^6.0.0",
"@angular/router": "^6.0.0",
"@schematics/angular": "^0.6.0",
"@stackblitz/sdk": "^1.1.1",
"@types/fs-extra": "^5.0.4",
"@types/hammerjs": "^2.0.35",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"antd-theme-generator": "^1.0.7",
"chalk": "^2.4.1",
"classlist.js": "^1.1.20150312",
"clean-css": "~4.1.11",
"codecov": "^3.0.0",
"codelyzer": "~4.3.0",
"conventional-changelog-cli": "^2.0.1",
"core-js": "^2.5.4",
"fs-extra": "^6.0.1",
"hammerjs": "^2.0.8",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~1.7.1",
"karma-chrome-launcher": "~2.2.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "~1.4.2",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"less": "^2.7.3",
"less-plugin-clean-css": "^1.5.1",
"marked": "^0.3.6",
Expand All @@ -87,6 +84,7 @@
"node-prismjs": "^0.1.1",
"parse5": "^4.0.0",
"prismjs": "^1.10.0",
"protractor": "~5.4.0",
"readline-sync": "^1.4.9",
"remark": "^8.0.0",
"rollup": "^0.49.2",
Expand All @@ -95,8 +93,11 @@
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-uglify": "^2.0.1",
"rxjs": "~6.2.2",
"ts-node": "~7.0.0",
"tsickle": "^0.30.0",
"tslib": "^1.9.0",
"tslint": "~5.11.0",
"typescript": "~2.9.2",
"yaml-front-matter": "^3.4.0",
"zone.js": "^0.8.26"
}
Expand Down
2 changes: 1 addition & 1 deletion schematics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ $ ng add ng-zorro-antd [--locale=zh-CN] [--theme] [--skipPackageJson]
- `npm run schematic:build` 编译到 publish 文件夹
- `npm run schematic:demo` 从 demo 生成 schematics
- `node ./schematics_script/set-version.js` 从 package.json 设置版本号
- `node ./schematics_script/set-theme.js`site_scripts/_site/src/theme.less 设置自定义样式内容
- `node ./schematics_script/set-theme.js`scripts/site/_site/src/theme.less 设置自定义样式内容

### 首次运行

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ function compileLess(content, savePath, min) {
});
}

const sourcePath = path.resolve(__dirname, '../components');
const targetPath = path.resolve(__dirname, '../publish');
const sourcePath = path.resolve(__dirname, '../../components');
const targetPath = path.resolve(__dirname, '../../publish');

const targetFolder = fs.readdirSync(targetPath);
let componentsLessContent = '';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const fs = require('fs-extra');
const path = require('path');

const sourcePath = path.resolve(__dirname, `../publish`);
const targetPath = path.resolve(__dirname, `../publish/src`);
const sourcePath = path.resolve(__dirname, `../../publish`);
const targetPath = path.resolve(__dirname, `../../publish/src`);

fs.mkdirsSync(targetPath);
fs.copySync(path.resolve(sourcePath, `style`), path.resolve(targetPath, `style`));
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions publish_scripts/publish.js → scripts/publish/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ checkout();
function changeVersion() {
log.info('Updating version number...');

const packageJson = path.join(__dirname, '../components/package.json');
const appComponent = path.join(__dirname, '../site_scripts/_site/src/app/app.component.ts') ;
const codeBox = path.join(__dirname, '../site_scripts/_site/src/app/share/nz-codebox/nz-codebox.component.ts');
const packageJson = path.join(__dirname, '../../components/package.json');
const appComponent = path.join(__dirname, '../site/_site/src/app/app.component.ts') ;
const codeBox = path.join(__dirname, '../site/_site/src/app/share/nz-codebox/nz-codebox.component.ts');
const currentVersion = fs.readFileSync(packageJson, 'utf-8').match(/"version": "([0-9.]+)"/)[ 1 ];

let versionNumberValid = false;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const fs = require('fs-extra');
const path = require('path');

const srcPath = path.resolve(__dirname, `../schematics`);
const targetPath = path.resolve(__dirname, `../publish/schematics`);
const srcPath = path.resolve(__dirname, `../../schematics`);
const targetPath = path.resolve(__dirname, `../../publish/schematics`);
const copyFilter = (path) => (!/.+\.ts/.test(path)) || (/files\/__path__/.test(path));


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ const fs = require('fs-extra');
const path = require('path');
const glob = require('glob').sync;

const componentsPath = path.resolve(__dirname, '../../components');
const demoDirPath = path.resolve(__dirname, '../../schematics/demo');
const collectionPath = path.resolve(__dirname, '../../schematics/demo/collection.json');

const TEST_FILE_CONTENT =
`import { fakeAsync, ComponentFixture, TestBed } from '@angular/core/testing';
import { <%= classify(name) %>Component } from './<%= dasherize(name) %>.component';
Expand Down Expand Up @@ -31,7 +35,7 @@ describe('<%= classify(name) %>Component', () => {
* @returns {string[]}
*/
function getComponentPaths() {
return glob(path.join(path.resolve(__dirname, '../components'), '**/demo/*.ts'))
return glob(path.join(componentsPath, '**/demo/*.ts'))
}

/**
Expand Down Expand Up @@ -106,10 +110,9 @@ function replaceTemplate(demoComponent) {
* @param {{fileContent: string, componentName: string, demoName: string, template: string, styles: string, selector: string, className: string}} demoComponent
*/
function createSchematic(demoComponent) {
const demoPath = path.resolve(__dirname, `../schematics/demo/${demoComponent.componentName}-${demoComponent.demoName}`);
const demoPath = path.resolve(demoDirPath, `./${demoComponent.componentName}-${demoComponent.demoName}`);
const filesPath = path.resolve(__dirname, `${demoPath}/files/__path__/__name@dasherize@if-flat__`);
const schemaPath = `${demoPath}/schema.json`;
const collectionPath = path.resolve(__dirname, `../schematics/demo/collection.json`);
fs.mkdirsSync(filesPath);
fs.copySync(path.resolve(__dirname, `./template`), demoPath);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const fs = require('fs-extra');
const path = require('path');

const theme = fs.readFileSync(path.resolve(__dirname, `../site_scripts/_site/src/theme.less`), 'utf8');
const theme = fs.readFileSync(path.resolve(__dirname, `../site/_site/src/theme.less`), 'utf8');
fs.outputFileSync(
path.resolve(__dirname, `../schematics/utils/custom-theme.ts`),
path.resolve(__dirname, `../../schematics/utils/custom-theme.ts`),
`export function createCustomTheme() {
return \`@import "../node_modules/ng-zorro-antd/ng-zorro-antd.less";
${theme.replace(/`/g, '\\`')}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const fs = require('fs-extra');
const path = require('path');

const packageJson = fs.readJsonSync(path.resolve(__dirname, `../components/package.json`));
const packageJson = fs.readJsonSync(path.resolve(__dirname, `../../components/package.json`));
fs.outputFileSync(
path.resolve(__dirname, `../schematics/utils/lib-versions.ts`),
path.resolve(__dirname, `../../schematics/utils/lib-versions.ts`),
`export const zorroVersion = '^${packageJson.version}';\n`
);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import './colors';
@import 'colors';

@padding-space: 144px;

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* You can add global styles to this file, and also import other style files */
@import "../../components/ng-zorro-antd.less";
@import "./style/index";
@import "./theme";
@import "style/index";
@import "theme";
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const getMeta = require('./utils/get-meta');
const target = process.argv[2];
const isSyncSpecific = target && (target !== 'init');
// 创建site文件夹
const showCasePath = path.resolve(__dirname, '../site');
const showCasePath = path.resolve(__dirname, '../../site');

if (!target) {
fs.removeSync(`${showCasePath}/src`);
Expand All @@ -24,7 +24,7 @@ if (!target) {
}
const showCaseTargetPath = `${showCasePath}/src/app/`;
// 读取components文件夹
const rootPath = path.resolve(__dirname, '../components');
const rootPath = path.resolve(__dirname, '../../components');
const rootDir = fs.readdirSync(rootPath);
const componentsMap = {};
rootDir.forEach(componentName => {
Expand Down Expand Up @@ -79,7 +79,7 @@ rootDir.forEach(componentName => {

if (!isSyncSpecific) {
// 读取docs文件夹
const docsPath = path.resolve(__dirname, '../docs');
const docsPath = path.resolve(__dirname, '../../docs');
const docsDir = fs.readdirSync(docsPath);
let docsMap = {};
let docsMeta = {};
Expand Down
16 changes: 16 additions & 0 deletions scripts/site/generateColorLess.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env node
const path = require('path');
const { generateTheme } = require('antd-theme-generator');

const options = {
stylesDir: path.join(__dirname, '../../site/src/'),
antdStylesDir: path.join(__dirname, '../../components'),
varFile: path.join(__dirname, '../../components/style/themes/default.less'),
mainLessFile: path.join(__dirname, '../../site/src/styles.less'),
themeVariables: [
'@primary-color',
],
outputFilePath: path.join(__dirname, '../../site/src/assets/color.less'),
};

generateTheme(options);
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const fs = require('fs-extra');
const path = require('path');

const changelogPath = path.resolve(__dirname, `../CHANGELOG.md`);
const changelogPath = path.resolve(__dirname, `../../CHANGELOG.md`);

async function replace(path) {
const content = await fs.readFile(path, 'utf8');
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 0 additions & 16 deletions site_scripts/generateColorLess.js

This file was deleted.

0 comments on commit 34f4a4b

Please sign in to comment.