├── packages ├── utils-scripts │ ├── lib │ │ ├── tasks │ │ │ ├── publish.js │ │ │ ├── index.js │ │ │ ├── default.js │ │ │ ├── tools │ │ │ │ └── pipes.js │ │ │ ├── clean.js │ │ │ ├── publish-doc.js │ │ │ ├── doc.js │ │ │ ├── typing.js │ │ │ ├── build.js │ │ │ └── dev.js │ │ ├── config │ │ │ ├── env │ │ │ │ ├── prod.js │ │ │ │ ├── index.js │ │ │ │ └── dev.js │ │ │ ├── index.js │ │ │ ├── base.js │ │ │ ├── target │ │ │ │ ├── es.js │ │ │ │ ├── cjs.js │ │ │ │ ├── index.js │ │ │ │ └── target.js │ │ │ ├── target.js │ │ │ ├── plugins │ │ │ │ └── dts-export.js │ │ │ ├── jest.config.js │ │ │ └── esdoc.js │ │ ├── cli │ │ │ ├── publish.js │ │ │ ├── dev.js │ │ │ ├── doc.js │ │ │ ├── build.js │ │ │ └── test.js │ │ └── index.js │ ├── src │ │ ├── config │ │ │ ├── env │ │ │ │ ├── prod.js │ │ │ │ ├── index.js │ │ │ │ └── dev.js │ │ │ ├── index.js │ │ │ ├── base.js │ │ │ ├── target.js │ │ │ ├── esdoc.js │ │ │ └── jest.config.js │ │ ├── tasks │ │ │ ├── default.js │ │ │ ├── index.js │ │ │ ├── clean.js │ │ │ ├── tools │ │ │ │ └── pipes.js │ │ │ ├── publish-doc.js │ │ │ ├── doc.js │ │ │ ├── typing.js │ │ │ ├── build.js │ │ │ └── dev.js │ │ ├── cli │ │ │ ├── dev.ts │ │ │ ├── doc.ts │ │ │ ├── build.ts │ │ │ └── test.ts │ │ └── index.ts │ ├── docs-template │ │ ├── index.html │ │ ├── manual.html │ │ ├── single.html │ │ ├── image │ │ │ ├── search.png │ │ │ ├── esdoc-logo-mini.png │ │ │ ├── esdoc-logo-mini-black.png │ │ │ ├── badge.svg │ │ │ └── manual-badge.svg │ │ ├── manualIndex.html │ │ ├── file.html │ │ ├── script │ │ │ ├── patch-for-local.js │ │ │ ├── manual.js │ │ │ ├── pretty-print.js │ │ │ ├── inherited-summary.js │ │ │ ├── inner-link.js │ │ │ ├── test-summary.js │ │ │ ├── search.js │ │ │ └── prettify │ │ │ │ ├── Apache-License-2.0.txt │ │ │ │ └── prettify.js │ │ ├── testInterface.html │ │ ├── test.html │ │ ├── nav.html │ │ ├── identifiers.html │ │ ├── manualCardIndex.html │ │ ├── properties.html │ │ ├── css │ │ │ ├── identifiers.css │ │ │ ├── source.css │ │ │ ├── test.css │ │ │ ├── github.css │ │ │ ├── search.css │ │ │ ├── prettify-tomorrow.css │ │ │ ├── manual.css │ │ │ └── style.css │ │ ├── source.html │ │ ├── summary.html │ │ ├── layout.html │ │ ├── class.html │ │ └── details.html │ ├── __tests__ │ │ └── utils-scripts.test.js │ ├── README.md │ ├── tsconfig.json │ ├── LICENSE │ ├── package.json │ └── package-lock.json └── create-utils │ ├── template-javascript │ ├── src │ │ ├── money │ │ │ ├── index.js │ │ │ └── tozhCN.js │ │ ├── string │ │ │ ├── index.js │ │ │ └── addZero.js │ │ └── index.js │ ├── .prettierrc │ ├── .editorconfig │ ├── __tests__ │ │ ├── string │ │ │ └── addZero.test.js │ │ └── money │ │ │ └── tozhCN.test.js │ ├── .travis.yml │ ├── tsconfig.json │ ├── README.md │ └── .gitignore │ ├── template-typescript │ ├── src │ │ ├── money │ │ │ ├── index.ts │ │ │ └── tozhCN.ts │ │ ├── string │ │ │ ├── index.ts │ │ │ └── addZero.ts │ │ └── index.ts │ ├── .prettierrc │ ├── .editorconfig │ ├── __tests__ │ │ ├── string │ │ │ └── addZero.test.ts │ │ └── money │ │ │ └── tozhCN.test.ts │ ├── .travis.yml │ ├── tsconfig.json │ ├── README.md │ ├── tslint.json │ └── .gitignore │ ├── __tests__ │ └── create-utils.test.js │ ├── README.md │ ├── tsconfig.json │ ├── src │ ├── index.ts │ └── cli │ │ └── create.ts │ ├── LICENSE │ ├── lib │ ├── index.js │ └── cli │ │ └── create.js │ ├── package.json │ ├── package-lock.json │ └── yarn.lock ├── lerna.json ├── tslint.json ├── package.json ├── CONTRIBUTING.md ├── LICENSE ├── .gitignore └── README.md /packages/utils-scripts/lib/tasks/publish.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | -------------------------------------------------------------------------------- /packages/utils-scripts/src/config/env/prod.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | prod: true, 3 | }; 4 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/index.html: -------------------------------------------------------------------------------- 1 |
2 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/manual.html: -------------------------------------------------------------------------------- 1 |
2 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/config/env/prod.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | module.exports = { 3 | prod: true, 4 | }; 5 | -------------------------------------------------------------------------------- /packages/create-utils/template-javascript/src/money/index.js: -------------------------------------------------------------------------------- 1 | import tozhCN from './tozhCN'; 2 | export default { 3 | tozhCN, 4 | }; 5 | -------------------------------------------------------------------------------- /packages/create-utils/template-javascript/src/string/index.js: -------------------------------------------------------------------------------- 1 | import addZero from './addZero'; 2 | export default { 3 | addZero, 4 | }; 5 | -------------------------------------------------------------------------------- /packages/create-utils/template-typescript/src/money/index.ts: -------------------------------------------------------------------------------- 1 | import tozhCN from './tozhCN'; 2 | 3 | export default { 4 | tozhCN, 5 | }; 6 | -------------------------------------------------------------------------------- /packages/create-utils/template-typescript/src/string/index.ts: -------------------------------------------------------------------------------- 1 | import addZero from './addZero'; 2 | 3 | export default { 4 | addZero, 5 | } -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/single.html: -------------------------------------------------------------------------------- 1 |

2 |
3 |
4 | -------------------------------------------------------------------------------- /packages/utils-scripts/src/tasks/default.js: -------------------------------------------------------------------------------- 1 | import gulp from 'gulp'; 2 | 3 | gulp.task('default', gulp.series('clean', 'dev', 'typing', 'doc')); 4 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "npmClient": "yarn", 3 | "useWorkspaces": true, 4 | "version": "independent", 5 | "packages": [ 6 | "packages/*" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/image/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/youzan/create-utils/HEAD/packages/utils-scripts/docs-template/image/search.png -------------------------------------------------------------------------------- /packages/create-utils/template-javascript/src/index.js: -------------------------------------------------------------------------------- 1 | import money from './money'; 2 | import string from './string'; 3 | export default { 4 | money, 5 | string, 6 | }; 7 | -------------------------------------------------------------------------------- /packages/create-utils/template-typescript/src/index.ts: -------------------------------------------------------------------------------- 1 | import money from './money'; 2 | import string from './string'; 3 | 4 | export default { 5 | money, 6 | string, 7 | }; 8 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/image/esdoc-logo-mini.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/youzan/create-utils/HEAD/packages/utils-scripts/docs-template/image/esdoc-logo-mini.png -------------------------------------------------------------------------------- /packages/create-utils/template-javascript/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "tabWidth": 2, 3 | "semi": true, 4 | "singleQuote": true, 5 | "printWidth": 120, 6 | "trailingComma": "all" 7 | } 8 | -------------------------------------------------------------------------------- /packages/create-utils/template-typescript/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "tabWidth": 2, 3 | "semi": true, 4 | "singleQuote": true, 5 | "printWidth": 120, 6 | "trailingComma": "all" 7 | } 8 | -------------------------------------------------------------------------------- /packages/create-utils/__tests__/create-utils.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const createUtils = require('..'); 4 | 5 | describe('create-utils', () => { 6 | it('needs tests'); 7 | }); 8 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/image/esdoc-logo-mini-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/youzan/create-utils/HEAD/packages/utils-scripts/docs-template/image/esdoc-logo-mini-black.png -------------------------------------------------------------------------------- /packages/utils-scripts/__tests__/utils-scripts.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const utilsScripts = require('..'); 4 | 5 | describe('utils-scripts', () => { 6 | it('needs tests'); 7 | }); 8 | -------------------------------------------------------------------------------- /packages/utils-scripts/src/tasks/index.js: -------------------------------------------------------------------------------- 1 | import './clean'; 2 | import './typing'; 3 | import './doc'; 4 | import './dev'; 5 | import './build'; 6 | import './default'; 7 | import './publish-doc'; 8 | -------------------------------------------------------------------------------- /packages/create-utils/README.md: -------------------------------------------------------------------------------- 1 | # `create-utils` 2 | 3 | > TODO: description 4 | 5 | ## Usage 6 | 7 | ``` 8 | const createUtils = require('create-utils'); 9 | 10 | // TODO: DEMONSTRATE API 11 | ``` 12 | -------------------------------------------------------------------------------- /packages/utils-scripts/README.md: -------------------------------------------------------------------------------- 1 | # `utils-scripts` 2 | 3 | > TODO: description 4 | 5 | ## Usage 6 | 7 | ``` 8 | const utilsScripts = require('utils-scripts'); 9 | 10 | // TODO: DEMONSTRATE API 11 | ``` 12 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint-config-standard", 3 | "rules": { 4 | "ter-indent": [true, 2, { 5 | "SwitchCase": 1 6 | }], 7 | "no-eval": false, 8 | "semicolon": [true, "always"], 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/utils-scripts/src/config/env/index.js: -------------------------------------------------------------------------------- 1 | const devConfig = require('./dev'); 2 | const prodConfig = require('./prod'); 3 | 4 | const isProd = process.env.NODE_ENV === 'production'; 5 | module.exports = isProd ? prodConfig : devConfig; 6 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/config/env/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var devConfig = require('./dev'); 3 | var prodConfig = require('./prod'); 4 | var isProd = process.env.NODE_ENV === 'production'; 5 | module.exports = isProd ? prodConfig : devConfig; 6 | -------------------------------------------------------------------------------- /packages/utils-scripts/src/config/env/dev.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | prod: false, 3 | connect: { 4 | port: parseInt(process.env.PORT) || 3001, 5 | host: '127.0.0.1', 6 | debug: false, 7 | livereload: true, 8 | } 9 | }; 10 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/manualIndex.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 6 |
7 |
8 | -------------------------------------------------------------------------------- /packages/create-utils/template-javascript/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [Makefile] 12 | indent_style = tab -------------------------------------------------------------------------------- /packages/create-utils/template-typescript/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [Makefile] 12 | indent_style = tab -------------------------------------------------------------------------------- /packages/utils-scripts/src/config/index.js: -------------------------------------------------------------------------------- 1 | const base = require('./base'); 2 | const env = require('./env'); 3 | const esdoc = require('./esdoc'); 4 | const target = require('./target'); 5 | 6 | module.exports = { 7 | base, 8 | env, 9 | target, 10 | esdoc, 11 | }; 12 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/file.html: -------------------------------------------------------------------------------- 1 |

2 |

3 | 

Sorry, this documentation does not provide source code.

4 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/config/env/dev.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | module.exports = { 3 | prod: false, 4 | connect: { 5 | port: parseInt(process.env.PORT) || 3001, 6 | host: '127.0.0.1', 7 | debug: false, 8 | livereload: true, 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/script/patch-for-local.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | if (location.protocol === 'file:') { 3 | var elms = document.querySelectorAll('a[href="./"]'); 4 | for (var i = 0; i < elms.length; i++) { 5 | elms[i].href = './index.html'; 6 | } 7 | } 8 | })(); 9 | -------------------------------------------------------------------------------- /packages/create-utils/template-javascript/__tests__/string/addZero.test.js: -------------------------------------------------------------------------------- 1 | import addZero from '../../src/string/addZero'; 2 | 3 | describe('string:addZero', () => { 4 | test('addZero is work', () => { 5 | expect(addZero(2)).toBe('02'); 6 | expect(addZero(11)).toBe('11'); 7 | }); 8 | }); 9 | -------------------------------------------------------------------------------- /packages/create-utils/template-typescript/__tests__/string/addZero.test.ts: -------------------------------------------------------------------------------- 1 | import addZero from '../../src/string/addZero'; 2 | 3 | describe('string:addZero', () => { 4 | test('addZero is work', () => { 5 | expect(addZero(2)).toBe('02'); 6 | expect(addZero(11)).toBe('11'); 7 | }); 8 | }); 9 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/testInterface.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/tasks/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | require("./clean"); 4 | require("./typing"); 5 | require("./doc"); 6 | require("./dev"); 7 | require("./build"); 8 | require("./default"); 9 | require("./publish-doc"); 10 | -------------------------------------------------------------------------------- /packages/utils-scripts/src/tasks/clean.js: -------------------------------------------------------------------------------- 1 | import gulp from 'gulp'; 2 | import del from 'del'; 3 | import config from '../config'; 4 | 5 | gulp.task('clean', () => { 6 | return del([config.base.esTemp, config.base.docCache, config.base.dist, config.base.publishCache, config.esdoc.destination]); 7 | }); 8 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/tasks/default.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var tslib_1 = require("tslib"); 4 | var gulp_1 = tslib_1.__importDefault(require("gulp")); 5 | gulp_1.default.task('default', gulp_1.default.series('clean', 'dev', 'typing', 'doc')); 6 | -------------------------------------------------------------------------------- /packages/utils-scripts/src/cli/dev.ts: -------------------------------------------------------------------------------- 1 | import gulp from 'gulp'; 2 | 3 | import '../tasks'; 4 | 5 | process.env.NODE_ENV = 'development'; 6 | 7 | 8 | gulp.on('error', e => console.log('error', e)); 9 | 10 | export default function() { 11 | 12 | gulp.task('dev')((err) => {console.log('dev done')}); 13 | } -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/test.html: -------------------------------------------------------------------------------- 1 |

Test

2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
DescriptionIdentifier
12 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/config/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var base = require('./base'); 3 | var env = require('./env'); 4 | var esdoc = require('./esdoc'); 5 | var target = require('./target'); 6 | module.exports = { 7 | base: base, 8 | env: env, 9 | target: target, 10 | esdoc: esdoc, 11 | }; 12 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/nav.html: -------------------------------------------------------------------------------- 1 |
2 | 11 |
12 | -------------------------------------------------------------------------------- /packages/create-utils/template-javascript/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | os: 4 | - linux 5 | - osx 6 | node_js: 7 | - 6 8 | - 8 9 | - 9 10 | - 10 11 | branches: 12 | only: 13 | - master 14 | install: 15 | - npm install 16 | script: 17 | - npm run cover 18 | after_success: 19 | - cat ./coverage/lcov.info | coveralls 20 | -------------------------------------------------------------------------------- /packages/create-utils/template-typescript/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | os: 4 | - linux 5 | - osx 6 | node_js: 7 | - 6 8 | - 8 9 | - 9 10 | - 10 11 | branches: 12 | only: 13 | - master 14 | install: 15 | - npm install 16 | script: 17 | - npm run cover 18 | after_success: 19 | - cat ./coverage/lcov.info | coveralls 20 | -------------------------------------------------------------------------------- /packages/utils-scripts/src/tasks/tools/pipes.js: -------------------------------------------------------------------------------- 1 | /** 2 | * pipe多个管道 3 | * 4 | * @param {NodeJS.ReadableStream} sourceStream 5 | * @param {Function[]} plugins 6 | * @returns {NodeJS.ReadableStream} 7 | */ 8 | export default function pipes(sourceStream, plugins) { 9 | return plugins.reduce((stream, plugin) => stream.pipe(plugin), sourceStream); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "create-utils", 3 | "workspaces": [ 4 | "packages/*" 5 | ], 6 | "private": true, 7 | "scripts": { 8 | "build": "lerna run build", 9 | "release": "lerna publish" 10 | }, 11 | "devDependencies": { 12 | "lerna": "^3.8.1", 13 | "tslint": "^5.12.0", 14 | "tslint-config-standard": "^8.0.1" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/create-utils/template-javascript/src/string/addZero.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 如果数字小于10前面自动添加0 3 | * @param {number} num 数字 4 | * @return {string} 处理后的字符串 5 | * @example 6 | * addZero(9); 7 | * // '09' 8 | * addZero(11); 9 | * // '11' 10 | */ 11 | function addZero(num) { 12 | return (num >= 0 && num < 10) ? `0${num}` : String(num); 13 | } 14 | export default addZero; 15 | -------------------------------------------------------------------------------- /packages/create-utils/template-javascript/__tests__/money/tozhCN.test.js: -------------------------------------------------------------------------------- 1 | import tozhCN from '../../src/money/tozhCN'; 2 | 3 | describe('money:tozhCN', () => { 4 | test('100', () => { 5 | expect(tozhCN(100)).toBe('壹佰元整'); 6 | }); 7 | 8 | test('string error', () => { 9 | const data = 'exception'; 10 | expect(() => tozhCN(data)).toThrowError(); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /packages/create-utils/template-typescript/__tests__/money/tozhCN.test.ts: -------------------------------------------------------------------------------- 1 | import tozhCN from '../../src/money/tozhCN'; 2 | 3 | describe('money:tozhCN', () => { 4 | test('100', () => { 5 | expect(tozhCN(100)).toBe('壹佰元整'); 6 | }); 7 | 8 | test('string error', () => { 9 | const data = 'exception'; 10 | expect(() => tozhCN(data)).toThrowError(); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /packages/create-utils/template-typescript/src/string/addZero.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 如果数字小于10前面自动添加0 3 | * @param {number} num 数字 4 | * @return {string} 处理后的字符串 5 | * @example 6 | * addZero(9); 7 | * // '09' 8 | * addZero(11); 9 | * // '11' 10 | */ 11 | function addZero(num: number) { 12 | return (num >= 0 && num < 10) ? `0${num}` : String(num); 13 | } 14 | export default addZero; 15 | -------------------------------------------------------------------------------- /packages/create-utils/template-javascript/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["src"], 3 | "compilerOptions": { 4 | "target": "es5", 5 | "module": "commonjs", 6 | "lib": ["es2015"], 7 | "allowJs": false, 8 | "declaration": true, 9 | "importHelpers": true, 10 | "strict": true, 11 | "alwaysStrict": true, 12 | "moduleResolution": "node", 13 | "allowSyntheticDefaultImports": true 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/create-utils/template-typescript/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["src"], 3 | "compilerOptions": { 4 | "target": "es5", 5 | "module": "commonjs", 6 | "lib": ["es2015"], 7 | "allowJs": false, 8 | "declaration": true, 9 | "importHelpers": true, 10 | "strict": true, 11 | "alwaysStrict": true, 12 | "moduleResolution": "node", 13 | "allowSyntheticDefaultImports": true 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/utils-scripts/src/cli/doc.ts: -------------------------------------------------------------------------------- 1 | import gulp from 'gulp'; 2 | import chalk from 'chalk'; 3 | 4 | import '../tasks'; 5 | 6 | 7 | gulp.on('error', e => console.log('error', e)); 8 | 9 | export default function() { 10 | gulp.task('publish-doc')((err) => { 11 | console.log('Automatically generate documents via esdoc'); 12 | console.log(`Documents has been posted to the ${chalk.cyan('gh-pages')} branch`); 13 | }); 14 | } -------------------------------------------------------------------------------- /packages/utils-scripts/src/tasks/publish-doc.js: -------------------------------------------------------------------------------- 1 | import gulp from 'gulp'; 2 | import ghPages from 'gulp-gh-pages'; 3 | import config from '../config'; 4 | 5 | function publishDoc() { 6 | return gulp.src(config.base.distCwd + '/docs/**/*', { dot: true }) 7 | .pipe(ghPages({ 8 | cacheDir: config.base.docCache, 9 | force: true 10 | })); 11 | } 12 | 13 | gulp.task('publish-doc', gulp.series('clean', 'dev:build', 'doc', publishDoc, 'clean')); 14 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/cli/publish.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var tslib_1 = require("tslib"); 4 | var gulp_1 = tslib_1.__importDefault(require("gulp")); 5 | require("../tasks"); 6 | gulp_1.default.on('error', function (e) { return console.log('error', e); }); 7 | function default_1() { 8 | gulp_1.default.task('publish')(function (err) { console.log('publish done'); }); 9 | } 10 | exports.default = default_1; 11 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/tasks/tools/pipes.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | /** 4 | * pipe多个管道 5 | * 6 | * @param {NodeJS.ReadableStream} sourceStream 7 | * @param {Function[]} plugins 8 | * @returns {NodeJS.ReadableStream} 9 | */ 10 | function pipes(sourceStream, plugins) { 11 | return plugins.reduce(function (stream, plugin) { return stream.pipe(plugin); }, sourceStream); 12 | } 13 | exports.default = pipes; 14 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/cli/dev.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var tslib_1 = require("tslib"); 4 | var gulp_1 = tslib_1.__importDefault(require("gulp")); 5 | require("../tasks"); 6 | process.env.NODE_ENV = 'development'; 7 | gulp_1.default.on('error', function (e) { return console.log('error', e); }); 8 | function default_1() { 9 | gulp_1.default.task('dev')(function (err) { console.log('dev done'); }); 10 | } 11 | exports.default = default_1; 12 | -------------------------------------------------------------------------------- /packages/utils-scripts/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "rootDir": "./src", 4 | "module": "commonjs", 5 | "target": "es5", 6 | "esModuleInterop": true, 7 | "checkJs": false, 8 | "allowJs": true, 9 | "alwaysStrict": true, 10 | "moduleResolution": "node", 11 | "resolveJsonModule": true, 12 | "allowSyntheticDefaultImports": true, 13 | "lib": ["es2017"], 14 | "importHelpers": true, 15 | "outDir": "./lib" 16 | }, 17 | "include": ["./src"] 18 | } 19 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/identifiers.html: -------------------------------------------------------------------------------- 1 |

References

2 | 3 |
4 |
5 |
6 |

7 |
8 |
9 |
10 | 11 |
12 |
Directories
13 |
14 |
15 |
16 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/manualCardIndex.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 |

5 | 6 |
7 |
8 |
9 |
10 | 11 |
12 |
13 |
14 |
15 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/properties.html: -------------------------------------------------------------------------------- 1 |
2 |

3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
NameTypeAttributeDescription
16 |
17 | -------------------------------------------------------------------------------- /packages/utils-scripts/src/cli/build.ts: -------------------------------------------------------------------------------- 1 | import gulp from 'gulp'; 2 | import chalk from 'chalk'; 3 | import config from '../config'; 4 | import '../tasks'; 5 | 6 | process.env.NODE_ENV = 'production' 7 | 8 | gulp.on('error', e => console.log('error', e)); 9 | 10 | export default function() { 11 | gulp.task('build')((err) => { 12 | console.log('Build task has been completed'); 13 | 14 | console.log(); 15 | console.log(`Please checkout to ${chalk.cyan('publish/' + config.target.tsconfig.module)} branch, and publish it`); 16 | }); 17 | } -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | There are two packages here in the packages directory. 2 | - create-utils(initialize project template) 3 | - utils-scripts(contains the scripts for setting up the development server, buildiing production builds,etc) 4 | 5 | ### Set Up 6 | ``` 7 | yarn add lerna -g 8 | yarn install 9 | 10 | cd package/utils-scripts 11 | npm run dev 12 | ``` 13 | 14 | ### Test 15 | ``` 16 | cd package/utils-scripts 17 | yarn link 18 | cd 19 | yarn link 'utils-scripts' 20 | ``` 21 | 22 | ### Publish 23 | ``` 24 | npm run build 25 | npm run publish 26 | ``` -------------------------------------------------------------------------------- /packages/create-utils/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "rootDir": "./src", 4 | "module": "commonjs", 5 | "target": "es5", 6 | "esModuleInterop": true, 7 | "checkJs": false, 8 | "allowJs": true, 9 | "alwaysStrict": true, 10 | "moduleResolution": "node", 11 | "resolveJsonModule": true, 12 | "allowSyntheticDefaultImports": true, 13 | "lib": ["es2017"], 14 | "importHelpers": true, 15 | "outDir": "lib", 16 | "types": ["node"] 17 | }, 18 | "include": ["src"], 19 | "exclude": ["node_modules"] 20 | } 21 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/script/manual.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | var matched = location.pathname.match(/\/(manual\/.*\.html)$/); 3 | if (!matched) return; 4 | 5 | var currentName = matched[1]; 6 | var cssClass = '.navigation .manual-toc li[data-link="' + currentName + '"]'; 7 | var styleText = cssClass + '{ display: block; }\n'; 8 | styleText += cssClass + '.indent-h1 a { color: #039BE5 }'; 9 | var style = document.createElement('style'); 10 | style.textContent = styleText; 11 | document.querySelector('head').appendChild(style); 12 | })(); 13 | -------------------------------------------------------------------------------- /packages/utils-scripts/src/tasks/doc.js: -------------------------------------------------------------------------------- 1 | import gulp from 'gulp'; 2 | import ESDoc from 'esdoc'; 3 | import fs from 'fs-extra'; 4 | import path from 'path'; 5 | import config from '../config'; 6 | 7 | const configName = 'esdoc.js'; 8 | const exists = fs.pathExistsSync(path.resolve(config.base.distCwd, configName)); 9 | let esdocConfig = {}; 10 | if (exists) { 11 | esdocConfig = require(path.resolve(config.base.distCwd, configName)); 12 | } 13 | 14 | gulp.task('doc', () => { 15 | ESDoc.generate({ ...config.esdoc, ...esdocConfig }); 16 | return Promise.resolve(); 17 | }); 18 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/tasks/clean.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var tslib_1 = require("tslib"); 4 | var gulp_1 = tslib_1.__importDefault(require("gulp")); 5 | var del_1 = tslib_1.__importDefault(require("del")); 6 | var config_1 = tslib_1.__importDefault(require("../config")); 7 | gulp_1.default.task('clean', function () { 8 | return del_1.default([config_1.default.base.esTemp, config_1.default.base.docCache, config_1.default.base.dist, config_1.default.base.publishCache, config_1.default.esdoc.destination]); 9 | }); 10 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/cli/doc.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var tslib_1 = require("tslib"); 4 | var gulp_1 = tslib_1.__importDefault(require("gulp")); 5 | var chalk_1 = tslib_1.__importDefault(require("chalk")); 6 | require("../tasks"); 7 | gulp_1.default.on('error', function (e) { return console.log('error', e); }); 8 | function default_1() { 9 | gulp_1.default.task('publish-doc')(function (err) { 10 | console.log('Automatically generate documents via esdoc'); 11 | console.log("Documents has been posted to the " + chalk_1.default.cyan('gh-pages') + " branch"); 12 | }); 13 | } 14 | exports.default = default_1; 15 | -------------------------------------------------------------------------------- /packages/utils-scripts/src/tasks/typing.js: -------------------------------------------------------------------------------- 1 | import gulp from 'gulp'; 2 | import path from 'path'; 3 | import { createProject } from 'gulp-typescript'; 4 | import config from '../config'; 5 | // import pipes from './tools/pipes'; 6 | 7 | gulp.task('typing', () => { 8 | if (config.base.useTypeScript) { 9 | const tsProject = createProject({ 10 | ...config.target.tsconfig, 11 | declaration: true, 12 | }); 13 | 14 | const tsResult = gulp 15 | .src('src/**/**/*', { base: path.join(config.base.distCwd, "src") }) 16 | .pipe(tsProject()); 17 | return tsResult.dts.pipe(gulp.dest(config.base.dist)); 18 | } else { 19 | return Promise.resolve(); 20 | } 21 | 22 | }); 23 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/tasks/publish-doc.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var tslib_1 = require("tslib"); 4 | var gulp_1 = tslib_1.__importDefault(require("gulp")); 5 | var gulp_gh_pages_1 = tslib_1.__importDefault(require("gulp-gh-pages")); 6 | var config_1 = tslib_1.__importDefault(require("../config")); 7 | function publishDoc() { 8 | return gulp_1.default.src(config_1.default.base.distCwd + '/docs/**/*', { dot: true }) 9 | .pipe(gulp_gh_pages_1.default({ 10 | cacheDir: config_1.default.base.docCache, 11 | force: true 12 | })); 13 | } 14 | gulp_1.default.task('publish-doc', gulp_1.default.series('clean', 'dev:build', 'doc', publishDoc, 'clean')); 15 | -------------------------------------------------------------------------------- /packages/utils-scripts/src/cli/test.ts: -------------------------------------------------------------------------------- 1 | import { jsWithTs as tsjPreset } from 'ts-jest/presets'; 2 | const jest = require('jest'); 3 | import fs from 'fs-extra'; 4 | import path from 'path'; 5 | 6 | 7 | import base from '../config/base'; 8 | import jestConfig from '../config/jest.config'; 9 | const configName = 'jest.config.js'; 10 | 11 | export default async function() { 12 | let argv = process.argv.slice(2); 13 | 14 | const exists = await fs.pathExists(path.resolve(base.distCwd, configName)); 15 | let config = {}; 16 | if (exists) { 17 | config = require(path.resolve(base.distCwd, configName)); 18 | } 19 | const argConfig = { ...jestConfig, ...config, rootDir: base.distCwd, ...tsjPreset }; 20 | console.log(argv); 21 | argv.push( 22 | '--config', 23 | JSON.stringify(argConfig) 24 | ); 25 | jest.run(argv); 26 | } -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/css/identifiers.css: -------------------------------------------------------------------------------- 1 | .identifiers-wrap { 2 | display: flex; 3 | align-items: flex-start; 4 | } 5 | 6 | .identifier-dir-tree { 7 | background: #fff; 8 | border: solid 1px #ddd; 9 | border-radius: 0.25em; 10 | top: 52px; 11 | position: -webkit-sticky; 12 | position: sticky; 13 | max-height: calc(100vh - 155px); 14 | overflow-y: scroll; 15 | min-width: 200px; 16 | margin-left: 1em; 17 | } 18 | 19 | .identifier-dir-tree-header { 20 | padding: 0.5em; 21 | background-color: #fafafa; 22 | border-bottom: solid 1px #ddd; 23 | } 24 | 25 | .identifier-dir-tree-content { 26 | padding: 0 0.5em 0; 27 | } 28 | 29 | .identifier-dir-tree-content > div { 30 | padding-top: 0.25em; 31 | padding-bottom: 0.25em; 32 | } 33 | 34 | .identifier-dir-tree-content a { 35 | color: inherit; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/cli/build.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var tslib_1 = require("tslib"); 4 | var gulp_1 = tslib_1.__importDefault(require("gulp")); 5 | var chalk_1 = tslib_1.__importDefault(require("chalk")); 6 | var config_1 = tslib_1.__importDefault(require("../config")); 7 | require("../tasks"); 8 | process.env.NODE_ENV = 'production'; 9 | gulp_1.default.on('error', function (e) { return console.log('error', e); }); 10 | function default_1() { 11 | gulp_1.default.task('build')(function (err) { 12 | console.log('Build task has been completed'); 13 | console.log(); 14 | console.log("Please checkout to " + chalk_1.default.cyan('publish/' + config_1.default.target.tsconfig.module) + " branch, and publish it"); 15 | }); 16 | } 17 | exports.default = default_1; 18 | -------------------------------------------------------------------------------- /packages/utils-scripts/src/config/base.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const distCwd = process.cwd(); 4 | const appPackage = require(path.join(distCwd, 'package.json')); 5 | appPackage.devDependencies = appPackage.devDependencies || {}; 6 | 7 | module.exports = { 8 | useTypeScript: appPackage.devDependencies['typescript'] != null, 9 | distCwd, 10 | pkg: 'package.json', 11 | curCwd: path.resolve(__dirname, '../../'), 12 | src: path.join(distCwd, 'src'), 13 | config: path.join(__dirname, '../config'), 14 | template: path.join(__dirname, '../../docs-template'), 15 | esTemp: path.join(distCwd, 'temp'), 16 | dist: path.join(distCwd, 'dist'), 17 | publishCache: path.join(distCwd, '.publish'), 18 | docCache: path.join(distCwd, '.docs'), 19 | static: ['README.md', '.gitignore'], 20 | types: path.join(distCwd, 'typings') 21 | }; 22 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/config/base.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var path = require('path'); 3 | var distCwd = process.cwd(); 4 | var appPackage = require(path.join(distCwd, 'package.json')); 5 | appPackage.devDependencies = appPackage.devDependencies || {}; 6 | module.exports = { 7 | useTypeScript: appPackage.devDependencies['typescript'] != null, 8 | distCwd: distCwd, 9 | pkg: 'package.json', 10 | curCwd: path.resolve(__dirname, '../../'), 11 | src: path.join(distCwd, 'src'), 12 | config: path.join(__dirname, '../config'), 13 | template: path.join(__dirname, '../../docs-template'), 14 | esTemp: path.join(distCwd, 'temp'), 15 | dist: path.join(distCwd, 'dist'), 16 | publishCache: path.join(distCwd, '.publish'), 17 | docCache: path.join(distCwd, '.docs'), 18 | static: ['README.md', '.gitignore'], 19 | types: path.join(distCwd, 'typings') 20 | }; 21 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/image/badge.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | document 13 | document 14 | @ratio@ 15 | @ratio@ 16 | 17 | 18 | -------------------------------------------------------------------------------- /packages/utils-scripts/src/tasks/build.js: -------------------------------------------------------------------------------- 1 | import gulp from "gulp"; 2 | import ghPages from 'gulp-gh-pages'; 3 | import merge from 'merge2'; 4 | import jsonEditor from 'gulp-json-editor'; 5 | 6 | import config from "../config"; 7 | 8 | function publishGit() { 9 | return merge( 10 | gulp.src('package.json').pipe(jsonEditor((json) => { 11 | const name = { name: `${json.name}${config.target.prefix ? config.target.prefix : ''}`} 12 | return Object.assign({}, json, { types: './index.d.ts' }, name); 13 | })), 14 | gulp.src([config.base.dist + '/**', ...config.base.static, config.base.types + '/**'], { dot: true }), 15 | ).pipe( 16 | ghPages({ 17 | branch: config.target.branch, 18 | cacheDir: config.base.publishCache, 19 | push: true, 20 | }), 21 | ); 22 | } 23 | 24 | 25 | gulp.task("build", gulp.series('clean', 'dev:build', 'typing', publishGit, 'clean')); 26 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/image/manual-badge.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | manual 13 | manual 14 | @value@ 15 | @value@ 16 | 17 | 18 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/script/pretty-print.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | prettyPrint(); 3 | var lines = document.querySelectorAll('.prettyprint.linenums li[class^="L"]'); 4 | for (var i = 0; i < lines.length; i++) { 5 | lines[i].id = 'lineNumber' + (i + 1); 6 | } 7 | 8 | var matched = location.hash.match(/errorLines=([\d,]+)/); 9 | if (matched) { 10 | var lines = matched[1].split(','); 11 | for (var i = 0; i < lines.length; i++) { 12 | var id = '#lineNumber' + lines[i]; 13 | var el = document.querySelector(id); 14 | el.classList.add('error-line'); 15 | } 16 | return; 17 | } 18 | 19 | if (location.hash) { 20 | // ``[ ] . ' " @`` are not valid in DOM id. so must escape these. 21 | var id = location.hash.replace(/([\[\].'"@$])/g, '\\$1'); 22 | var line = document.querySelector(id); 23 | if (line) line.classList.add('active'); 24 | } 25 | })(); 26 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/tasks/doc.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var tslib_1 = require("tslib"); 4 | var gulp_1 = tslib_1.__importDefault(require("gulp")); 5 | var esdoc_1 = tslib_1.__importDefault(require("esdoc")); 6 | var fs_extra_1 = tslib_1.__importDefault(require("fs-extra")); 7 | var path_1 = tslib_1.__importDefault(require("path")); 8 | var config_1 = tslib_1.__importDefault(require("../config")); 9 | var configName = 'esdoc.js'; 10 | var exists = fs_extra_1.default.pathExistsSync(path_1.default.resolve(config_1.default.base.distCwd, configName)); 11 | var esdocConfig = {}; 12 | if (exists) { 13 | esdocConfig = require(path_1.default.resolve(config_1.default.base.distCwd, configName)); 14 | } 15 | gulp_1.default.task('doc', function () { 16 | esdoc_1.default.generate(tslib_1.__assign({}, config_1.default.esdoc, esdocConfig)); 17 | return Promise.resolve(); 18 | }); 19 | -------------------------------------------------------------------------------- /packages/create-utils/template-javascript/README.md: -------------------------------------------------------------------------------- 1 | This project was bootstrapped with [create-utils](https://github.com/youzan/create-utils). 2 | 3 | ## Available Scripts 4 | 5 | In the project directory, you can run: 6 | 7 | ### `npm dev` 8 | 9 | Runs the app in the development mode.
10 | Open [http://localhost:3001](http://localhost:3001) to view it in the browser. 11 | 12 | The page will reload if you make edits. 13 | 14 | ### `npm test` 15 | 16 | Launches the test runner in the interactive watch mode. 17 | 18 | ### `npm run build` 19 | 20 | Builds the project for production to the `dist` folder. 21 | 22 | - ESModules: `target=es npm run build` 23 | - CommonJs: `target=cjs npm run build` 24 | 25 | Copy dist directory to the publish/es or publish/cjs branch, you need publish package to npm by yourself. 26 | 27 | ### `npm run doc` 28 | 29 | Automatically generate documents by ESDoc, and Copy docs directory to the gh-pages barnch. 30 | 31 | -------------------------------------------------------------------------------- /packages/create-utils/template-typescript/README.md: -------------------------------------------------------------------------------- 1 | This project was bootstrapped with [create-utils](https://github.com/youzan/create-utils). 2 | 3 | ## Available Scripts 4 | 5 | In the project directory, you can run: 6 | 7 | ### `npm dev` 8 | 9 | Runs the app in the development mode.
10 | Open [http://localhost:3001](http://localhost:3001) to view it in the browser. 11 | 12 | The page will reload if you make edits. 13 | 14 | ### `npm test` 15 | 16 | Launches the test runner in the interactive watch mode. 17 | 18 | ### `npm run build` 19 | 20 | Builds the project for production to the `dist` folder. 21 | 22 | - ESModules: `target=es npm run build` 23 | - CommonJs: `target=cjs npm run build` 24 | 25 | Copy dist directory to the publish/es or publish/cjs branch, you need publish package to npm by yourself. 26 | 27 | ### `npm run doc` 28 | 29 | Automatically generate documents by ESDoc, and Copy docs directory to the gh-pages barnch. 30 | 31 | -------------------------------------------------------------------------------- /packages/utils-scripts/src/config/target.js: -------------------------------------------------------------------------------- 1 | const path =require('path'); 2 | const fs = require('fs-extra'); 3 | const base = require('./base'); 4 | 5 | let tsconfig = { 6 | "alwaysStrict": true, 7 | "target": "es6", 8 | "moduleResolution": "node", 9 | "allowSyntheticDefaultImports": true, 10 | "declaration": false, 11 | "sourceMap": false, 12 | "importHelpers": true, 13 | "baseUrl": ".", 14 | }; 15 | const configName = 'tsconfig.json'; 16 | const exists = fs.pathExistsSync(path.resolve(base.distCwd, configName)); 17 | if (exists) { 18 | const tsconfigJson = require(path.join(base.distCwd, configName)); 19 | tsconfig = { ...tsconfig, ...tsconfigJson.compilerOptions }; 20 | } 21 | 22 | const target = process.env.target || tsconfig.module || 'commonjs'; 23 | 24 | module.exports = { 25 | tsconfig: { ...tsconfig, module: target }, 26 | branch: `publish/${target}`, 27 | prefix: target === 'commonjs' ? null : `-${target}`, 28 | }; 29 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/config/target/es.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | module.exports = { 3 | // build config 4 | tsconfig: { 5 | "alwaysStrict": true, 6 | "target": "es6", 7 | "moduleResolution": "node", 8 | "allowSyntheticDefaultImports": true, 9 | "declaration": true, 10 | "sourceMap": false, 11 | "baseUrl": ".", 12 | module: 'esnext', 13 | }, 14 | js: { 15 | tsconfig: { 16 | module: 'esnext', 17 | }, 18 | }, 19 | dts: { 20 | tsconfig: { 21 | module: 'esnext', 22 | removeComments: true, 23 | }, 24 | plugins: [], 25 | }, 26 | babel: false, 27 | // publish config 28 | branch: 'publish/es', 29 | prefix: '-es', 30 | packageRewrite: { 31 | main: './index.js', 32 | typings: './index.d.ts', 33 | scripts: {}, 34 | devDependencies: {}, 35 | } 36 | }; 37 | -------------------------------------------------------------------------------- /packages/create-utils/src/index.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | import commander from 'commander'; 4 | import chalk from 'chalk'; 5 | import create from './cli/create'; 6 | 7 | const packageJson = require('../package.json'); 8 | let projectName; 9 | 10 | const program = commander 11 | .version(packageJson.version, '-v, --version') 12 | .arguments('') 13 | .usage(`${chalk.green('')} [options]`) 14 | .option('--js') 15 | .action(name => { 16 | projectName = name; 17 | }) 18 | .action(create) 19 | .parse(process.argv); 20 | 21 | 22 | if (typeof projectName === 'undefined') { 23 | console.error('Please specify the project directory:'); 24 | console.log( 25 | ` ${chalk.cyan(program.name())} ${chalk.green('')}` 26 | ); 27 | console.log(); 28 | console.log('For example:'); 29 | console.log(` ${chalk.cyan(program.name())} ${chalk.green('my-utils')}`); 30 | console.log(); 31 | process.exit(1); 32 | } -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/script/inherited-summary.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | function toggle(ev) { 3 | var button = ev.target; 4 | var parent = ev.target.parentElement; 5 | while(parent) { 6 | if (parent.tagName === 'TABLE' && parent.classList.contains('summary')) break; 7 | parent = parent.parentElement; 8 | } 9 | 10 | if (!parent) return; 11 | 12 | var tbody = parent.querySelector('tbody'); 13 | if (button.classList.contains('opened')) { 14 | button.classList.remove('opened'); 15 | button.classList.add('closed'); 16 | tbody.style.display = 'none'; 17 | } else { 18 | button.classList.remove('closed'); 19 | button.classList.add('opened'); 20 | tbody.style.display = 'block'; 21 | } 22 | } 23 | 24 | var buttons = document.querySelectorAll('.inherited-summary thead .toggle'); 25 | for (var i = 0; i < buttons.length; i++) { 26 | buttons[i].addEventListener('click', toggle); 27 | } 28 | })(); 29 | -------------------------------------------------------------------------------- /packages/create-utils/template-typescript/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "defaultSeverity": "error", 3 | "extends": [ 4 | "tslint:recommended", 5 | "tslint-config-prettier", 6 | "tslint-eslint-rules" 7 | ], 8 | "rules": { 9 | "no-unused-expression": false, 10 | "semicolon": [true, "always"], 11 | "no-shadowed-variable": false, 12 | "only-arrow-functions": false, 13 | "trailing-comma": [ 14 | true, 15 | { 16 | "multiline": "always", 17 | "singleline": "never", 18 | "esSpecCompliant": true 19 | } 20 | ], 21 | "comment-format": [true, "check-space"], 22 | "ter-indent": [ 23 | true, 24 | 2, 25 | { 26 | "SwitchCase": 1 27 | } 28 | ], 29 | "triple-equals": true, 30 | "no-eval": true, 31 | "eofline": true, 32 | "quotemark": [true, "single"] 33 | }, 34 | "linterOptions": { 35 | "exclude": [ 36 | "./dist", 37 | "node_module", 38 | "docs" 39 | ] 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/tasks/typing.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var tslib_1 = require("tslib"); 4 | var gulp_1 = tslib_1.__importDefault(require("gulp")); 5 | var path_1 = tslib_1.__importDefault(require("path")); 6 | var gulp_typescript_1 = require("gulp-typescript"); 7 | var config_1 = tslib_1.__importDefault(require("../config")); 8 | // import pipes from './tools/pipes'; 9 | gulp_1.default.task('typing', function () { 10 | if (config_1.default.base.useTypeScript) { 11 | var tsProject = gulp_typescript_1.createProject(tslib_1.__assign({}, config_1.default.target.tsconfig, { declaration: true })); 12 | var tsResult = gulp_1.default 13 | .src('src/**/**/*', { base: path_1.default.join(config_1.default.base.distCwd, "src") }) 14 | .pipe(tsProject()); 15 | return tsResult.dts.pipe(gulp_1.default.dest(config_1.default.base.dist)); 16 | } 17 | else { 18 | return Promise.resolve(); 19 | } 20 | }); 21 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/config/target.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var tslib_1 = require("tslib"); 3 | var path = require('path'); 4 | var fs = require('fs-extra'); 5 | var base = require('./base'); 6 | var tsconfig = { 7 | "alwaysStrict": true, 8 | "target": "es6", 9 | "moduleResolution": "node", 10 | "allowSyntheticDefaultImports": true, 11 | "declaration": false, 12 | "sourceMap": false, 13 | "importHelpers": true, 14 | "baseUrl": ".", 15 | }; 16 | var configName = 'tsconfig.json'; 17 | var exists = fs.pathExistsSync(path.resolve(base.distCwd, configName)); 18 | if (exists) { 19 | var tsconfigJson = require(path.join(base.distCwd, configName)); 20 | tsconfig = tslib_1.__assign({}, tsconfig, tsconfigJson.compilerOptions); 21 | } 22 | var target = process.env.target || tsconfig.module || 'commonjs'; 23 | module.exports = { 24 | tsconfig: tslib_1.__assign({}, tsconfig, { module: target }), 25 | branch: "publish/" + target, 26 | prefix: target === 'commonjs' ? null : "-" + target, 27 | }; 28 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/source.html: -------------------------------------------------------------------------------- 1 |

Source

2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
FileIdentifierDocumentSizeLinesUpdated
25 | -------------------------------------------------------------------------------- /packages/utils-scripts/src/index.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | import commander from 'commander'; 4 | import dev from './cli/dev'; 5 | import doc from './cli/doc'; 6 | import test from './cli/test'; 7 | import build from './cli/build'; 8 | 9 | const pkg = require('../package.json'); 10 | 11 | 12 | commander 13 | .version(pkg.version, '-v, --version'); 14 | 15 | commander 16 | .command('dev') 17 | .description('build doc and watch reload') 18 | .action(dev); 19 | 20 | commander 21 | .command('build') 22 | .description('build file to dist and copy to publish branch') 23 | .action(build); 24 | 25 | commander 26 | .command('doc') 27 | .description('genarate docs and and copy to gh-path branch') 28 | .action(doc); 29 | 30 | commander 31 | .command('test') 32 | .option('--watch', 'Watch files for changes and rerun tests related to changed files') 33 | .option('--runTestsByPath', 'Run only the tests that were specified with their exact paths.') 34 | .description('run test') 35 | .action(test); 36 | console.log(process.argv) 37 | commander.parse(process.argv); -------------------------------------------------------------------------------- /packages/utils-scripts/src/config/esdoc.js: -------------------------------------------------------------------------------- 1 | const base = require('./base'); 2 | 3 | module.exports = { 4 | source: base.esTemp, 5 | index: './README.md', 6 | destination: 'docs', 7 | plugins: [ 8 | { 9 | name: 'esdoc-coverage-plugin', 10 | option: { 11 | enable: true, 12 | kind: ['class', 'method', 'member', 'get', 'set', 'constructor', 'function', 'variable'], 13 | }, 14 | }, 15 | { 16 | name: 'esdoc-importpath-plugin', 17 | option: { 18 | replaces: [{ from: 'temp/', to: '' }], 19 | }, 20 | }, 21 | { 22 | name: 'esdoc-node', 23 | }, 24 | { 25 | name: 'esdoc-publish-html-plugin', 26 | option: { 27 | template: base.template, 28 | }, 29 | }, 30 | { 31 | name: 'esdoc-standard-plugin', 32 | option: { 33 | lint: { 34 | enable: false 35 | }, 36 | brand: { 37 | title: '有赞工具函数库', 38 | description: '有赞工具函数库', 39 | author: 'wulv@youzan.com', 40 | } 41 | } 42 | }, 43 | ], 44 | }; 45 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 wulv 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/create-utils/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 wulv 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/utils-scripts/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 wulv 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/config/plugins/dts-export.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // through2 是一个对 node 的 transform streams 简单封装 3 | var through = require('through2'); 4 | // 插件级别函数 (处理文件) 5 | function dtsExport() { 6 | // 创建一个让每个文件通过的 stream 通道 7 | var stream = through.obj(function (file, enc, cb) { 8 | if (file.isNull()) { 9 | // 返回空文件 10 | cb(null, file); 11 | } 12 | if (file.isStream()) { 13 | this.emit('error', new Error('dtsExport plugin is not support stream')); 14 | } 15 | if (file.isBuffer()) { 16 | var typingStr = file.contents.toString(enc); 17 | var transformedStr = typingStr.split('\n').map(function (line) { 18 | if (line.startsWith('export default')) { 19 | return line + '\n' + line.replace('export default', 'export ='); 20 | } 21 | return line; 22 | }).join('\n'); 23 | file.contents = Buffer.from(transformedStr, enc); 24 | } 25 | cb(null, file); 26 | }); 27 | return stream; 28 | } 29 | // 暴露(export)插件主函数 30 | module.exports = dtsExport; 31 | -------------------------------------------------------------------------------- /packages/utils-scripts/src/config/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'ts-jest', 3 | testEnvironment: 'node', 4 | // Automatically clear mock calls and instances between every test 5 | clearMocks: true, 6 | // The directory where Jest should output its coverage files 7 | collectCoverage: true, 8 | coverageDirectory: 'coverage', 9 | 10 | // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href 11 | testURL: 'http://localhost/', 12 | 13 | // transform: { 14 | // '^.+\\.tsx?$': 'ts-jest', 15 | // }, 16 | 17 | globals: { 18 | 'ts-jest': { 19 | // isolatedModules: false, 20 | // diagnostics: false, 21 | tsConfig: { 22 | esModuleInterop: true, 23 | importHelpers: true, 24 | allowJs: true 25 | } 26 | } 27 | }, 28 | 29 | moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], 30 | moduleNameMapper: { 31 | '^src/(.*)$': '/src/$1', 32 | }, 33 | 34 | coverageReporters: ['lcov', 'json'], 35 | testPathIgnorePatterns: ['/node_modules/'], 36 | transformIgnorePatterns: ['/node_modules/'] 37 | }; 38 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/script/inner-link.js: -------------------------------------------------------------------------------- 1 | // inner link(#foo) can not correctly scroll, because page has fixed header, 2 | // so, I manually scroll. 3 | (function(){ 4 | var matched = location.hash.match(/errorLines=([\d,]+)/); 5 | if (matched) return; 6 | 7 | function adjust() { 8 | window.scrollBy(0, -55); 9 | var el = document.querySelector('.inner-link-active'); 10 | if (el) el.classList.remove('inner-link-active'); 11 | 12 | // ``[ ] . ' " @`` are not valid in DOM id. so must escape these. 13 | var id = location.hash.replace(/([\[\].'"@$])/g, '\\$1'); 14 | var el = document.querySelector(id); 15 | if (el) el.classList.add('inner-link-active'); 16 | } 17 | 18 | window.addEventListener('hashchange', adjust); 19 | 20 | if (location.hash) { 21 | setTimeout(adjust, 0); 22 | } 23 | })(); 24 | 25 | (function(){ 26 | var els = document.querySelectorAll('[href^="#"]'); 27 | var href = location.href.replace(/#.*$/, ''); // remove existed hash 28 | for (var i = 0; i < els.length; i++) { 29 | var el = els[i]; 30 | el.href = href + el.getAttribute('href'); // because el.href is absolute path 31 | } 32 | })(); 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # TypeScript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | # next.js build output 61 | .next 62 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/config/target/cjs.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var dtsExport = require('../plugins/dts-export'); 3 | var transformEs2015ModulesSimpleCommonjs = require('babel-plugin-transform-es2015-modules-simple-commonjs'); 4 | module.exports = { 5 | // build config 6 | tsconfig: { 7 | "alwaysStrict": true, 8 | "target": "es6", 9 | "moduleResolution": "node", 10 | "allowSyntheticDefaultImports": true, 11 | "declaration": true, 12 | "sourceMap": false, 13 | "baseUrl": ".", 14 | "module": "esnext", 15 | }, 16 | js: { 17 | tsconfig: { 18 | module: 'esnext', 19 | }, 20 | }, 21 | dts: { 22 | tsconfig: { 23 | module: 'esnext', 24 | removeComments: true, 25 | }, 26 | plugins: [dtsExport()], 27 | }, 28 | babel: { 29 | plugins: [ 30 | [transformEs2015ModulesSimpleCommonjs] 31 | ] 32 | }, 33 | // publish config 34 | branch: 'publish/cjs', 35 | packageRewrite: { 36 | main: './index.js', 37 | typings: './index.d.ts', 38 | scripts: {}, 39 | devDependencies: {}, 40 | } 41 | }; 42 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/css/source.css: -------------------------------------------------------------------------------- 1 | table.files-summary { 2 | width: 100%; 3 | margin: 10px 0; 4 | border-spacing: 0; 5 | border: 0; 6 | border-collapse: collapse; 7 | text-align: right; 8 | } 9 | 10 | table.files-summary tbody tr:hover { 11 | background: #eee; 12 | } 13 | 14 | table.files-summary td:first-child, 15 | table.files-summary td:nth-of-type(2) { 16 | text-align: left; 17 | } 18 | 19 | table.files-summary[data-use-coverage="false"] td.coverage { 20 | display: none; 21 | } 22 | 23 | table.files-summary thead { 24 | background: #fafafa; 25 | } 26 | 27 | table.files-summary td { 28 | border: solid 1px #ddd; 29 | padding: 4px 10px; 30 | vertical-align: top; 31 | } 32 | 33 | table.files-summary td.identifiers > span { 34 | display: block; 35 | margin-top: 4px; 36 | } 37 | table.files-summary td.identifiers > span:first-child { 38 | margin-top: 0; 39 | } 40 | 41 | table.files-summary .coverage-count { 42 | font-size: 12px; 43 | color: #aaa; 44 | display: inline-block; 45 | min-width: 40px; 46 | } 47 | 48 | .total-coverage-count { 49 | position: relative; 50 | bottom: 2px; 51 | font-size: 12px; 52 | color: #666; 53 | font-weight: 500; 54 | padding-left: 5px; 55 | } 56 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/config/jest.config.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | module.exports = { 3 | preset: 'ts-jest', 4 | testEnvironment: 'node', 5 | // Automatically clear mock calls and instances between every test 6 | clearMocks: true, 7 | // The directory where Jest should output its coverage files 8 | collectCoverage: true, 9 | coverageDirectory: 'coverage', 10 | // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href 11 | testURL: 'http://localhost/', 12 | // transform: { 13 | // '^.+\\.tsx?$': 'ts-jest', 14 | // }, 15 | globals: { 16 | 'ts-jest': { 17 | // isolatedModules: false, 18 | // diagnostics: false, 19 | tsConfig: { 20 | esModuleInterop: true, 21 | importHelpers: true, 22 | allowJs: true 23 | } 24 | } 25 | }, 26 | moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], 27 | moduleNameMapper: { 28 | '^src/(.*)$': '/src/$1', 29 | }, 30 | coverageReporters: ['lcov', 'json'], 31 | testPathIgnorePatterns: ['/node_modules/'], 32 | transformIgnorePatterns: ['/node_modules/'] 33 | }; 34 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/config/target/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var tslib_1 = require("tslib"); 4 | var path_1 = tslib_1.__importDefault(require("path")); 5 | var fs_extra_1 = tslib_1.__importDefault(require("fs-extra")); 6 | var base_1 = tslib_1.__importDefault(require("../base")); 7 | var tsconfig = { 8 | "alwaysStrict": true, 9 | "target": "es6", 10 | "moduleResolution": "node", 11 | "allowSyntheticDefaultImports": true, 12 | "declaration": false, 13 | "sourceMap": false, 14 | "importHelpers": true, 15 | "baseUrl": ".", 16 | }; 17 | var configName = 'tsconfig.json'; 18 | var exists = fs_extra_1.default.pathExistsSync(path_1.default.resolve(base_1.default.distCwd, configName)); 19 | if (exists) { 20 | var tsconfigJson = require(path_1.default.join(base_1.default.distCwd, configName)); 21 | tsconfig = tslib_1.__assign({}, tsconfig, tsconfigJson.compilerOptions); 22 | } 23 | var target = process.env.target || tsconfig.module || 'commonjs'; 24 | module.exports = { 25 | tsconfig: tslib_1.__assign({}, tsconfig, { module: target }), 26 | branch: "publish/" + target, 27 | prefix: target === 'commonjs' ? null : "-" + target, 28 | }; 29 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/config/target/target.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var tslib_1 = require("tslib"); 4 | var path_1 = tslib_1.__importDefault(require("path")); 5 | var fs_extra_1 = tslib_1.__importDefault(require("fs-extra")); 6 | var base_1 = tslib_1.__importDefault(require("../base")); 7 | var tsconfig = { 8 | "alwaysStrict": true, 9 | "target": "es6", 10 | "moduleResolution": "node", 11 | "allowSyntheticDefaultImports": true, 12 | "declaration": false, 13 | "sourceMap": false, 14 | "importHelpers": true, 15 | "baseUrl": ".", 16 | }; 17 | var configName = 'tsconfig.json'; 18 | var exists = fs_extra_1.default.pathExistsSync(path_1.default.resolve(base_1.default.distCwd, configName)); 19 | if (exists) { 20 | var tsconfigJson = require(path_1.default.join(base_1.default.distCwd, configName)); 21 | tsconfig = tslib_1.__assign({}, tsconfig, tsconfigJson.compilerOptions); 22 | } 23 | var target = process.env.target || tsconfig.module || 'commonjs'; 24 | module.exports = { 25 | tsconfig: tslib_1.__assign({}, tsconfig, { module: target }), 26 | branch: "publish/" + target, 27 | prefix: target === 'commonjs' ? null : "-" + target, 28 | }; 29 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 12 | 27 | 31 | 32 | 33 |
6 | 7 | 8 | 9 | 10 | 11 | 13 |
14 |

15 | 16 | 17 | 18 | 19 |

20 |
21 |
22 |
23 |
24 |
25 |
26 |
28 | version 29 | since 30 |
34 | -------------------------------------------------------------------------------- /packages/create-utils/lib/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | "use strict"; 3 | Object.defineProperty(exports, "__esModule", { value: true }); 4 | var tslib_1 = require("tslib"); 5 | var commander_1 = tslib_1.__importDefault(require("commander")); 6 | var chalk_1 = tslib_1.__importDefault(require("chalk")); 7 | var create_1 = tslib_1.__importDefault(require("./cli/create")); 8 | var packageJson = require('../package.json'); 9 | var projectName; 10 | var program = commander_1.default 11 | .version(packageJson.version, '-v, --version') 12 | .arguments('') 13 | .usage(chalk_1.default.green('') + " [options]") 14 | .option('--js') 15 | .action(function (name) { 16 | projectName = name; 17 | }) 18 | .action(create_1.default) 19 | .parse(process.argv); 20 | if (typeof projectName === 'undefined') { 21 | console.error('Please specify the project directory:'); 22 | console.log(" " + chalk_1.default.cyan(program.name()) + " " + chalk_1.default.green('')); 23 | console.log(); 24 | console.log('For example:'); 25 | console.log(" " + chalk_1.default.cyan(program.name()) + " " + chalk_1.default.green('my-utils')); 26 | console.log(); 27 | process.exit(1); 28 | } 29 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/css/test.css: -------------------------------------------------------------------------------- 1 | table.test-summary thead { 2 | background: #fafafa; 3 | } 4 | 5 | table.test-summary thead .test-description { 6 | width: 50%; 7 | } 8 | 9 | table.test-summary { 10 | width: 100%; 11 | margin: 10px 0; 12 | border-spacing: 0; 13 | border: 0; 14 | border-collapse: collapse; 15 | } 16 | 17 | table.test-summary thead .test-count { 18 | width: 3em; 19 | } 20 | 21 | table.test-summary tbody tr:hover { 22 | background-color: #eee; 23 | } 24 | 25 | table.test-summary td { 26 | border: solid 1px #ddd; 27 | padding: 4px 10px; 28 | vertical-align: top; 29 | } 30 | 31 | table.test-summary td p { 32 | margin: 0; 33 | } 34 | 35 | table.test-summary tr.test-interface .toggle { 36 | display: inline-block; 37 | float: left; 38 | margin-right: 4px; 39 | cursor: pointer; 40 | font-size: 0.8em; 41 | padding-top: 0.25em; 42 | } 43 | 44 | table.test-summary tr.test-interface .toggle.opened:before { 45 | content: '▼'; 46 | } 47 | 48 | table.test-summary tr.test-interface .toggle.closed:before { 49 | content: '▶'; 50 | } 51 | 52 | table.test-summary .test-target > span { 53 | display: block; 54 | margin-top: 4px; 55 | } 56 | table.test-summary .test-target > span:first-child { 57 | margin-top: 0; 58 | } 59 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/tasks/build.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var tslib_1 = require("tslib"); 4 | var gulp_1 = tslib_1.__importDefault(require("gulp")); 5 | var gulp_gh_pages_1 = tslib_1.__importDefault(require("gulp-gh-pages")); 6 | var merge2_1 = tslib_1.__importDefault(require("merge2")); 7 | var gulp_json_editor_1 = tslib_1.__importDefault(require("gulp-json-editor")); 8 | var config_1 = tslib_1.__importDefault(require("../config")); 9 | function publishGit() { 10 | return merge2_1.default(gulp_1.default.src('package.json').pipe(gulp_json_editor_1.default(function (json) { 11 | var name = { name: "" + json.name + (config_1.default.target.prefix ? config_1.default.target.prefix : '') }; 12 | return Object.assign({}, json, { types: './index.d.ts' }, name); 13 | })), gulp_1.default.src([config_1.default.base.dist + '/**'].concat(config_1.default.base.static, [config_1.default.base.types + '/**']), { dot: true })).pipe(gulp_gh_pages_1.default({ 14 | branch: config_1.default.target.branch, 15 | cacheDir: config_1.default.base.publishCache, 16 | push: true, 17 | })); 18 | } 19 | gulp_1.default.task("build", gulp_1.default.series('clean', 'dev:build', 'typing', publishGit, 'clean')); 20 | -------------------------------------------------------------------------------- /packages/create-utils/template-javascript/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Optional npm cache directory 40 | .npm 41 | 42 | # Optional eslint cache 43 | .eslintcache 44 | 45 | # Optional REPL history 46 | .node_repl_history 47 | 48 | # Output of 'npm pack' 49 | *.tgz 50 | 51 | # Yarn Integrity file 52 | .yarn-integrity 53 | 54 | # dotenv environment variables file 55 | .env 56 | 57 | .idea/ 58 | .DS_Store 59 | 60 | # build files 61 | static 62 | dist 63 | docs 64 | 65 | # ide 66 | .vscode 67 | 68 | # cahce dir 69 | .publish 70 | .pulish-doc 71 | .temp 72 | -------------------------------------------------------------------------------- /packages/create-utils/template-typescript/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Optional npm cache directory 40 | .npm 41 | 42 | # Optional eslint cache 43 | .eslintcache 44 | 45 | # Optional REPL history 46 | .node_repl_history 47 | 48 | # Output of 'npm pack' 49 | *.tgz 50 | 51 | # Yarn Integrity file 52 | .yarn-integrity 53 | 54 | # dotenv environment variables file 55 | .env 56 | 57 | .idea/ 58 | .DS_Store 59 | 60 | # build files 61 | static 62 | dist 63 | docs 64 | 65 | # ide 66 | .vscode 67 | 68 | # cahce dir 69 | .publish 70 | .pulish-doc 71 | .temp 72 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/config/esdoc.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var base = require('./base'); 3 | module.exports = { 4 | source: base.esTemp, 5 | index: './README.md', 6 | destination: 'docs', 7 | plugins: [ 8 | { 9 | name: 'esdoc-coverage-plugin', 10 | option: { 11 | enable: true, 12 | kind: ['class', 'method', 'member', 'get', 'set', 'constructor', 'function', 'variable'], 13 | }, 14 | }, 15 | { 16 | name: 'esdoc-importpath-plugin', 17 | option: { 18 | replaces: [{ from: 'temp/', to: '' }], 19 | }, 20 | }, 21 | { 22 | name: 'esdoc-node', 23 | }, 24 | { 25 | name: 'esdoc-publish-html-plugin', 26 | option: { 27 | template: base.template, 28 | }, 29 | }, 30 | { 31 | name: 'esdoc-standard-plugin', 32 | option: { 33 | lint: { 34 | enable: false 35 | }, 36 | brand: { 37 | title: '有赞工具函数库', 38 | description: '有赞工具函数库', 39 | author: 'wulv@youzan.com', 40 | } 41 | } 42 | }, 43 | ], 44 | }; 45 | -------------------------------------------------------------------------------- /packages/create-utils/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "create-utils", 3 | "version": "0.0.7", 4 | "description": "Create js utils function", 5 | "keywords": [ 6 | "utils" 7 | ], 8 | "author": "wulv ", 9 | "homepage": "https://github.com/youzan/create-utils#readme", 10 | "license": "ISC", 11 | "main": "lib/index.js", 12 | "bin": { 13 | "create-utils": "./lib/index.js" 14 | }, 15 | "files": [ 16 | "lib", 17 | "template-javascript", 18 | "template-typescript" 19 | ], 20 | "repository": { 21 | "type": "git", 22 | "url": "git+https://github.com/youzan/create-utils.git" 23 | }, 24 | "scripts": { 25 | "dev": "tsc --watch", 26 | "build": "tsc", 27 | "prepublish": "tsc", 28 | "test": "echo \"Error: run tests from root\" && exit 1" 29 | }, 30 | "bugs": { 31 | "url": "https://github.com/youzan/create-utils/issues" 32 | }, 33 | "dependencies": { 34 | "chalk": "^2.4.1", 35 | "commander": "^2.19.0", 36 | "cross-spawn": "^6.0.5", 37 | "fs-extra": "^7.0.1", 38 | "tslib": "^1.9.3", 39 | "validate-npm-package-name": "^3.0.0" 40 | }, 41 | "devDependencies": { 42 | "@types/cross-spawn": "^6.0.0", 43 | "@types/fs-extra": "^5.0.4", 44 | "@types/node": "^10.12.18", 45 | "typescript": "^3.2.2" 46 | }, 47 | "gitHead": "68e59d2a3f165efbbb9d6172105c075850b3c4e6" 48 | } 49 | -------------------------------------------------------------------------------- /packages/create-utils/template-typescript/src/money/tozhCN.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * tozhCN 把字符串转成以分为单位的整数。 3 | * @memberof module:money 4 | * @param {number|string} num 金额 5 | * @returns {string} 中文大写的金额, 标准会计格式 6 | * @runkit true 7 | * @example 8 | * const tozhCN = require('zan-utils/money/tozhCN'); 9 | * tozhCN(500.3); 10 | * // => 伍佰元叁角整 11 | */ 12 | function tozhCN(num: string | number): string { 13 | if (typeof num === 'number') { 14 | num = String(num); 15 | } 16 | if (!/^(0|[1-9]\d*)(\.\d+)?$/.test(num)) { 17 | throw new Error(`非法数据: ${JSON.stringify(num)}`); 18 | } 19 | let unit = '京亿万仟佰拾兆万仟佰拾亿仟佰拾万仟佰拾元角分'; 20 | let str: string = ''; 21 | num += '00'; 22 | const pos = num.indexOf('.'); 23 | if (pos >= 0) { 24 | num = num.substring(0, pos) + num.substr(pos + 1, 2); 25 | } 26 | unit = unit.substr(unit.length - num.length); 27 | for (let i = 0, len = num.length; i < len; i++) { 28 | str += 29 | '零壹贰叁肆伍陆柒捌玖'.charAt(Number(num.charAt(i))) + unit.charAt(i); 30 | } 31 | return str 32 | .replace(/零(仟|佰|拾|角)/g, '零') 33 | .replace(/(零)+/g, '零') 34 | .replace(/零(兆|万|亿|元)/g, '$1') 35 | .replace(/(兆|亿)万/g, '$1') 36 | .replace(/(京|兆)亿/g, '$1') 37 | .replace(/(京)兆/g, '$1') 38 | .replace(/(京|兆|亿|仟|佰|拾)(万?)(.)仟/g, '$1$2零$3仟') 39 | .replace(/^元零?|零分/g, '') 40 | .replace(/(元|角)$/g, '$1整'); 41 | } 42 | 43 | export default tozhCN; 44 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | "use strict"; 3 | Object.defineProperty(exports, "__esModule", { value: true }); 4 | var tslib_1 = require("tslib"); 5 | var commander_1 = tslib_1.__importDefault(require("commander")); 6 | var dev_1 = tslib_1.__importDefault(require("./cli/dev")); 7 | var doc_1 = tslib_1.__importDefault(require("./cli/doc")); 8 | var test_1 = tslib_1.__importDefault(require("./cli/test")); 9 | var build_1 = tslib_1.__importDefault(require("./cli/build")); 10 | var pkg = require('../package.json'); 11 | commander_1.default 12 | .version(pkg.version, '-v, --version'); 13 | commander_1.default 14 | .command('dev') 15 | .description('build doc and watch reload') 16 | .action(dev_1.default); 17 | commander_1.default 18 | .command('build') 19 | .description('build file to dist and copy to publish branch') 20 | .action(build_1.default); 21 | commander_1.default 22 | .command('doc') 23 | .description('genarate docs and and copy to gh-path branch') 24 | .action(doc_1.default); 25 | commander_1.default 26 | .command('test') 27 | .option('--watch', 'Watch files for changes and rerun tests related to changed files') 28 | .option('--runTestsByPath', 'Run only the tests that were specified with their exact paths.') 29 | .description('run test') 30 | .action(test_1.default); 31 | console.log(process.argv); 32 | commander_1.default.parse(process.argv); 33 | -------------------------------------------------------------------------------- /packages/create-utils/template-javascript/src/money/tozhCN.js: -------------------------------------------------------------------------------- 1 | /** 2 | * tozhCN 把字符串转成以分为单位的整数。 3 | * @memberof module:money 4 | * @param {number|string} num 金额 5 | * @returns {string} 中文大写的金额, 标准会计格式 6 | * @runkit true 7 | * @example 8 | * const tozhCN = require('zan-utils/money/tozhCN'); 9 | * tozhCN(500.3); 10 | * // => 伍佰元叁角整 11 | */ 12 | function tozhCN(num) { 13 | if (typeof num === 'number') { 14 | num = String(num); 15 | } 16 | if (!/^(0|[1-9]\d*)(\.\d+)?$/.test(num)) { 17 | throw new Error(`非法数据: ${JSON.stringify(num)}`); 18 | } 19 | let unit = '京亿万仟佰拾兆万仟佰拾亿仟佰拾万仟佰拾元角分'; 20 | let str = ''; 21 | num += '00'; 22 | const pos = num.indexOf('.'); 23 | if (pos >= 0) { 24 | num = num.substring(0, pos) + num.substr(pos + 1, 2); 25 | } 26 | unit = unit.substr(unit.length - num.length); 27 | for (let i = 0, len = num.length; i < len; i++) { 28 | str += 29 | '零壹贰叁肆伍陆柒捌玖'.charAt(Number(num.charAt(i))) + unit.charAt(i); 30 | } 31 | return str 32 | .replace(/零(仟|佰|拾|角)/g, '零') 33 | .replace(/(零)+/g, '零') 34 | .replace(/零(兆|万|亿|元)/g, '$1') 35 | .replace(/(兆|亿)万/g, '$1') 36 | .replace(/(京|兆)亿/g, '$1') 37 | .replace(/(京)兆/g, '$1') 38 | .replace(/(京|兆|亿|仟|佰|拾)(万?)(.)仟/g, '$1$2零$3仟') 39 | .replace(/^元零?|零分/g, '') 40 | .replace(/(元|角)$/g, '$1整'); 41 | } 42 | export default tozhCN; 43 | -------------------------------------------------------------------------------- /packages/utils-scripts/src/tasks/dev.js: -------------------------------------------------------------------------------- 1 | import gulp from 'gulp'; 2 | import connect from 'gulp-connect'; 3 | import { createProject } from "gulp-typescript"; 4 | import gulpIf from "gulp-if"; 5 | import path from "path"; 6 | 7 | import config from '../config'; 8 | 9 | function server() { 10 | return connect.server({ 11 | ...config.env.connect, 12 | root: config.esdoc.destination, 13 | }); 14 | } 15 | 16 | function livereload() { 17 | return gulp.watch(config.esdoc.destination, () => gulp.src(config.base.dist).pipe(connect.reload())); 18 | } 19 | 20 | function watch() { 21 | gulp.watch(config.base.template, gulp.series('doc')); 22 | gulp.watch(config.base.config, gulp.series('doc')); 23 | return gulp.watch(config.base.src, gulp.series('dev:build', 'doc')); 24 | } 25 | 26 | function build() { 27 | const tsProject = createProject({ 28 | ...config.target.tsconfig, module: 'ESNext', declaration: null 29 | }); 30 | const tsProjectWithJs = createProject({ 31 | ...config.target.tsconfig, allowJs: true, declaration: null 32 | }); 33 | 34 | return gulp 35 | .src('src/**/**/*', { base: path.join(config.base.distCwd, "src") }) 36 | .pipe(gulpIf(config.base.useTypeScript, tsProject())) 37 | .pipe(gulp.dest(config.base.esTemp)) 38 | .pipe(tsProjectWithJs()) 39 | .pipe(gulp.dest(config.base.dist)); 40 | 41 | } 42 | gulp.task('dev:build', gulp.series(build)); 43 | gulp.task('dev', gulp.series(build, 'doc', gulp.parallel(server, watch, livereload))); 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | logo 3 | 4 |

5 | 6 | [![npm version](https://img.shields.io/npm/v/create-utils.svg?style=flat)](https://www.npmjs.com/package/create-utils) [![downloads](https://img.shields.io/npm/dt/create-utils.svg)](https://www.npmjs.com/package/create-utils) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](./CONTRIBUTING.md) 7 | 8 | # create-utils 9 | Create javascript function with no build configuration,build your own JavaScript utility library like [Lodash](https://github.com/lodash/lodash). 10 | 11 | ## Usage 12 | 13 | ``` 14 | npx create-utils zan-utils 15 | cd zan-utils 16 | npm run dev 17 | ``` 18 | Typescript is used by default, if you want to use javascript: 19 | 20 | ``` 21 | npx create-utils zan-utils --js 22 | ``` 23 | 24 | ## Why Create-utils? 25 | Create-utils makes create a modern JavaScript utility library easier, 26 | 27 | - No configuration 28 | - Default support typescript, Automatically generate typings 29 | - Automatically generate documents via `ESDoc` 30 | - Support multiple modular,eg 'ESModule', 'CommonJs' 31 | - Test by jest 32 | - Load on demand 33 | 34 | ## Contributing 35 | We'd love to have your helping hand on create-utils! See [CONTRIBUTING.md](./CONTRIBUTING.md) for more information on what we're looking for and how to get started. 36 | 37 | ## License 38 | Create utils is open source software licensed as MIT. -------------------------------------------------------------------------------- /packages/utils-scripts/lib/cli/test.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var tslib_1 = require("tslib"); 4 | var presets_1 = require("ts-jest/presets"); 5 | var jest = require('jest'); 6 | var fs_extra_1 = tslib_1.__importDefault(require("fs-extra")); 7 | var path_1 = tslib_1.__importDefault(require("path")); 8 | var base_1 = tslib_1.__importDefault(require("../config/base")); 9 | var jest_config_1 = tslib_1.__importDefault(require("../config/jest.config")); 10 | var configName = 'jest.config.js'; 11 | function default_1() { 12 | return tslib_1.__awaiter(this, void 0, void 0, function () { 13 | var argv, exists, config, argConfig; 14 | return tslib_1.__generator(this, function (_a) { 15 | switch (_a.label) { 16 | case 0: 17 | argv = process.argv.slice(2); 18 | return [4 /*yield*/, fs_extra_1.default.pathExists(path_1.default.resolve(base_1.default.distCwd, configName))]; 19 | case 1: 20 | exists = _a.sent(); 21 | config = {}; 22 | if (exists) { 23 | config = require(path_1.default.resolve(base_1.default.distCwd, configName)); 24 | } 25 | argConfig = tslib_1.__assign({}, jest_config_1.default, config, { rootDir: base_1.default.distCwd }, presets_1.jsWithTs); 26 | console.log(argv); 27 | argv.push('--config', JSON.stringify(argConfig)); 28 | jest.run(argv); 29 | return [2 /*return*/]; 30 | } 31 | }); 32 | }); 33 | } 34 | exports.default = default_1; 35 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | Home 16 | Manual 17 | Reference 18 | Source 19 | Test 20 | 27 |
28 | 29 | 30 | 31 |
32 | 33 |
34 | Generated by ESDoc 35 |
36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/css/github.css: -------------------------------------------------------------------------------- 1 | /* github markdown */ 2 | .github-markdown { 3 | font-size: 16px; 4 | } 5 | 6 | .github-markdown h1, 7 | .github-markdown h2, 8 | .github-markdown h3, 9 | .github-markdown h4, 10 | .github-markdown h5 { 11 | margin-top: 1em; 12 | margin-bottom: 16px; 13 | font-weight: bold; 14 | padding: 0; 15 | } 16 | 17 | .github-markdown h1:nth-of-type(1) { 18 | margin-top: 0; 19 | } 20 | 21 | .github-markdown h1 { 22 | font-size: 2em; 23 | padding-bottom: 0.3em; 24 | } 25 | 26 | .github-markdown h2 { 27 | font-size: 1.75em; 28 | padding-bottom: 0.3em; 29 | } 30 | 31 | .github-markdown h3 { 32 | font-size: 1.5em; 33 | } 34 | 35 | .github-markdown h4 { 36 | font-size: 1.25em; 37 | } 38 | 39 | .github-markdown h5 { 40 | font-size: 1em; 41 | } 42 | 43 | .github-markdown ul, .github-markdown ol { 44 | padding-left: 2em; 45 | } 46 | 47 | .github-markdown pre > code { 48 | font-size: 0.85em; 49 | } 50 | 51 | .github-markdown table { 52 | margin-bottom: 1em; 53 | border-collapse: collapse; 54 | border-spacing: 0; 55 | } 56 | 57 | .github-markdown table tr { 58 | background-color: #fff; 59 | border-top: 1px solid #ccc; 60 | } 61 | 62 | .github-markdown table th, 63 | .github-markdown table td { 64 | padding: 6px 13px; 65 | border: 1px solid #ddd; 66 | } 67 | 68 | .github-markdown table tr:nth-child(2n) { 69 | background-color: #f8f8f8; 70 | } 71 | 72 | .github-markdown hr { 73 | border-right: 0; 74 | border-bottom: 1px solid #e5e5e5; 75 | border-left: 0; 76 | border-top: 0; 77 | } 78 | 79 | /** badge(.svg) does not have border */ 80 | .github-markdown img:not([src*=".svg"]) { 81 | max-width: 100%; 82 | box-shadow: 1px 1px 1px rgba(0,0,0,0.5); 83 | } 84 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/css/search.css: -------------------------------------------------------------------------------- 1 | /* search box */ 2 | .search-box { 3 | position: absolute; 4 | top: 15px; 5 | right: 50px; 6 | padding-right: 8px; 7 | padding-bottom: 10px; 8 | line-height: normal; 9 | font-size: 12px; 10 | } 11 | 12 | .search-box img { 13 | width: 20px; 14 | vertical-align: top; 15 | } 16 | 17 | .search-input { 18 | display: inline; 19 | visibility: hidden; 20 | width: 0; 21 | padding: 2px; 22 | height: 1.5em; 23 | outline: none; 24 | background: transparent; 25 | border: 1px #0af; 26 | border-style: none none solid none; 27 | vertical-align: bottom; 28 | } 29 | 30 | .search-input-edge { 31 | display: none; 32 | width: 1px; 33 | height: 5px; 34 | background-color: #0af; 35 | vertical-align: bottom; 36 | } 37 | 38 | .search-result { 39 | position: absolute; 40 | display: none; 41 | height: 600px; 42 | width: 100%; 43 | padding: 0; 44 | margin-top: 5px; 45 | margin-left: 24px; 46 | background: white; 47 | box-shadow: 1px 1px 4px rgb(0,0,0); 48 | white-space: nowrap; 49 | overflow-y: scroll; 50 | } 51 | 52 | .search-result-import-path { 53 | color: #aaa; 54 | font-size: 12px; 55 | } 56 | 57 | .search-result li { 58 | list-style: none; 59 | padding: 2px 4px; 60 | } 61 | 62 | .search-result li a { 63 | display: block; 64 | } 65 | 66 | .search-result li.selected { 67 | background: #ddd; 68 | } 69 | 70 | .search-result li.search-separator { 71 | background: rgb(37, 138, 175); 72 | color: white; 73 | } 74 | 75 | .search-box.active .search-input { 76 | visibility: visible; 77 | transition: width 0.2s ease-out; 78 | width: 300px; 79 | } 80 | 81 | .search-box.active .search-input-edge { 82 | display: inline-block; 83 | } 84 | 85 | -------------------------------------------------------------------------------- /packages/utils-scripts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "utils-scripts", 3 | "version": "0.0.10", 4 | "description": "Configuration and scripts for Create Utils", 5 | "keywords": [ 6 | "utils", 7 | "scripts" 8 | ], 9 | "author": "wulv ", 10 | "homepage": "https://github.com/youzan/create-utils#readme", 11 | "license": "ISC", 12 | "main": "lib/index.js", 13 | "bin": { 14 | "utils-scripts": "./lib/index.js" 15 | }, 16 | "files": [ 17 | "lib", 18 | "docs-template" 19 | ], 20 | "repository": { 21 | "type": "git", 22 | "url": "git+https://github.com/youzan/create-utils.git" 23 | }, 24 | "scripts": { 25 | "dev": "tsc --watch", 26 | "build": "tsc", 27 | "prepublish": "tsc", 28 | "test": "echo \"Error: run tests from root\" && exit 1" 29 | }, 30 | "bugs": { 31 | "url": "https://github.com/youzan/create-utils/issues" 32 | }, 33 | "devDependencies": { 34 | "@types/cross-spawn": "^6.0.0", 35 | "@types/del": "^3.0.1", 36 | "@types/gulp": "^4.0.5", 37 | "@types/jest": "^23.3.11", 38 | "@types/node": "^10.12.18" 39 | }, 40 | "dependencies": { 41 | "chalk": "^2.4.1", 42 | "commander": "^2.19.0", 43 | "cross-spawn": "^6.0.5", 44 | "del": "^3.0.0", 45 | "esdoc": "^1.1.0", 46 | "esdoc-coverage-plugin": "^1.1.0", 47 | "esdoc-importpath-plugin": "^1.0.2", 48 | "esdoc-node": "^1.0.4", 49 | "esdoc-publish-html-plugin": "^1.1.2", 50 | "esdoc-standard-plugin": "^1.0.0", 51 | "fs-extra": "^7.0.1", 52 | "gulp": "^4.0.0", 53 | "gulp-connect": "^5.7.0", 54 | "gulp-gh-pages": "0.5.4", 55 | "gulp-if": "^2.0.2", 56 | "gulp-json-editor": "^2.5.0", 57 | "gulp-typescript": "^5.0.0", 58 | "jest": "^23.6.0", 59 | "merge2": "^1.2.3", 60 | "ts-jest": "^23.10.5", 61 | "tslib": "^1.9.3", 62 | "typescript": "^3.2.2" 63 | }, 64 | "gitHead": "68e59d2a3f165efbbb9d6172105c075850b3c4e6" 65 | } 66 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/script/test-summary.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | function toggle(ev) { 3 | var button = ev.target; 4 | var parent = ev.target.parentElement; 5 | while(parent) { 6 | if (parent.tagName === 'TR' && parent.classList.contains('test-interface')) break; 7 | parent = parent.parentElement; 8 | } 9 | 10 | if (!parent) return; 11 | 12 | var direction; 13 | if (button.classList.contains('opened')) { 14 | button.classList.remove('opened'); 15 | button.classList.add('closed'); 16 | direction = 'closed'; 17 | } else { 18 | button.classList.remove('closed'); 19 | button.classList.add('opened'); 20 | direction = 'opened'; 21 | } 22 | 23 | var targetDepth = parseInt(parent.dataset.testDepth, 10) + 1; 24 | var nextElement = parent.nextElementSibling; 25 | while (nextElement) { 26 | var depth = parseInt(nextElement.dataset.testDepth, 10); 27 | if (depth >= targetDepth) { 28 | if (direction === 'opened') { 29 | if (depth === targetDepth) nextElement.style.display = ''; 30 | } else if (direction === 'closed') { 31 | nextElement.style.display = 'none'; 32 | var innerButton = nextElement.querySelector('.toggle'); 33 | if (innerButton && innerButton.classList.contains('opened')) { 34 | innerButton.classList.remove('opened'); 35 | innerButton.classList.add('closed'); 36 | } 37 | } 38 | } else { 39 | break; 40 | } 41 | nextElement = nextElement.nextElementSibling; 42 | } 43 | } 44 | 45 | var buttons = document.querySelectorAll('.test-summary tr.test-interface .toggle'); 46 | for (var i = 0; i < buttons.length; i++) { 47 | buttons[i].addEventListener('click', toggle); 48 | } 49 | 50 | var topDescribes = document.querySelectorAll('.test-summary tr[data-test-depth="0"]'); 51 | for (var i = 0; i < topDescribes.length; i++) { 52 | topDescribes[i].style.display = ''; 53 | } 54 | })(); 55 | -------------------------------------------------------------------------------- /packages/utils-scripts/lib/tasks/dev.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var tslib_1 = require("tslib"); 4 | var gulp_1 = tslib_1.__importDefault(require("gulp")); 5 | var gulp_connect_1 = tslib_1.__importDefault(require("gulp-connect")); 6 | var gulp_typescript_1 = require("gulp-typescript"); 7 | var gulp_if_1 = tslib_1.__importDefault(require("gulp-if")); 8 | var path_1 = tslib_1.__importDefault(require("path")); 9 | var config_1 = tslib_1.__importDefault(require("../config")); 10 | function server() { 11 | return gulp_connect_1.default.server(tslib_1.__assign({}, config_1.default.env.connect, { root: config_1.default.esdoc.destination })); 12 | } 13 | function livereload() { 14 | return gulp_1.default.watch(config_1.default.esdoc.destination, function () { return gulp_1.default.src(config_1.default.base.dist).pipe(gulp_connect_1.default.reload()); }); 15 | } 16 | function watch() { 17 | gulp_1.default.watch(config_1.default.base.template, gulp_1.default.series('doc')); 18 | gulp_1.default.watch(config_1.default.base.config, gulp_1.default.series('doc')); 19 | return gulp_1.default.watch(config_1.default.base.src, gulp_1.default.series('dev:build', 'doc')); 20 | } 21 | function build() { 22 | var tsProject = gulp_typescript_1.createProject(tslib_1.__assign({}, config_1.default.target.tsconfig, { module: 'ESNext', declaration: null })); 23 | var tsProjectWithJs = gulp_typescript_1.createProject(tslib_1.__assign({}, config_1.default.target.tsconfig, { allowJs: true, declaration: null })); 24 | return gulp_1.default 25 | .src('src/**/**/*', { base: path_1.default.join(config_1.default.base.distCwd, "src") }) 26 | .pipe(gulp_if_1.default(config_1.default.base.useTypeScript, tsProject())) 27 | .pipe(gulp_1.default.dest(config_1.default.base.esTemp)) 28 | .pipe(tsProjectWithJs()) 29 | .pipe(gulp_1.default.dest(config_1.default.base.dist)); 30 | } 31 | gulp_1.default.task('dev:build', gulp_1.default.series(build)); 32 | gulp_1.default.task('dev', gulp_1.default.series(build, 'doc', gulp_1.default.parallel(server, watch, livereload))); 33 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/css/prettify-tomorrow.css: -------------------------------------------------------------------------------- 1 | /* Tomorrow Theme */ 2 | /* Original theme - https://github.com/chriskempson/tomorrow-theme */ 3 | /* Pretty printing styles. Used with prettify.js. */ 4 | /* SPAN elements with the classes below are added by prettyprint. */ 5 | /* plain text */ 6 | .pln { 7 | color: #4d4d4c; } 8 | 9 | @media screen { 10 | /* string content */ 11 | .str { 12 | color: #718c00; } 13 | 14 | /* a keyword */ 15 | .kwd { 16 | color: #8959a8; } 17 | 18 | /* a comment */ 19 | .com { 20 | color: #8e908c; } 21 | 22 | /* a type name */ 23 | .typ { 24 | color: #4271ae; } 25 | 26 | /* a literal value */ 27 | .lit { 28 | color: #f5871f; } 29 | 30 | /* punctuation */ 31 | .pun { 32 | color: #4d4d4c; } 33 | 34 | /* lisp open bracket */ 35 | .opn { 36 | color: #4d4d4c; } 37 | 38 | /* lisp close bracket */ 39 | .clo { 40 | color: #4d4d4c; } 41 | 42 | /* a markup tag name */ 43 | .tag { 44 | color: #c82829; } 45 | 46 | /* a markup attribute name */ 47 | .atn { 48 | color: #f5871f; } 49 | 50 | /* a markup attribute value */ 51 | .atv { 52 | color: #3e999f; } 53 | 54 | /* a declaration */ 55 | .dec { 56 | color: #f5871f; } 57 | 58 | /* a variable name */ 59 | .var { 60 | color: #c82829; } 61 | 62 | /* a function name */ 63 | .fun { 64 | color: #4271ae; } } 65 | /* Use higher contrast and text-weight for printable form. */ 66 | @media print, projection { 67 | .str { 68 | color: #060; } 69 | 70 | .kwd { 71 | color: #006; 72 | font-weight: bold; } 73 | 74 | .com { 75 | color: #600; 76 | font-style: italic; } 77 | 78 | .typ { 79 | color: #404; 80 | font-weight: bold; } 81 | 82 | .lit { 83 | color: #044; } 84 | 85 | .pun, .opn, .clo { 86 | color: #440; } 87 | 88 | .tag { 89 | color: #006; 90 | font-weight: bold; } 91 | 92 | .atn { 93 | color: #404; } 94 | 95 | .atv { 96 | color: #060; } } 97 | /* Style */ 98 | /* 99 | pre.prettyprint { 100 | background: white; 101 | font-family: Consolas, Monaco, 'Andale Mono', monospace; 102 | font-size: 12px; 103 | line-height: 1.5; 104 | border: 1px solid #ccc; 105 | padding: 10px; } 106 | */ 107 | 108 | /* Specify class=linenums on a pre to get line numbering */ 109 | ol.linenums { 110 | margin-top: 0; 111 | margin-bottom: 0; } 112 | 113 | /* IE indents via margin-left */ 114 | li.L0, 115 | li.L1, 116 | li.L2, 117 | li.L3, 118 | li.L4, 119 | li.L5, 120 | li.L6, 121 | li.L7, 122 | li.L8, 123 | li.L9 { 124 | /* */ } 125 | 126 | /* Alternate shading for lines */ 127 | li.L1, 128 | li.L3, 129 | li.L5, 130 | li.L7, 131 | li.L9 { 132 | /* */ } 133 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/css/manual.css: -------------------------------------------------------------------------------- 1 | .github-markdown .manual-toc { 2 | padding-left: 0; 3 | } 4 | 5 | .manual-index .manual-cards { 6 | display: flex; 7 | flex-wrap: wrap; 8 | } 9 | 10 | .manual-index .manual-card-wrap { 11 | width: 280px; 12 | padding: 10px 20px 10px 0; 13 | box-sizing: border-box; 14 | } 15 | 16 | .manual-index .manual-card-wrap > h1 { 17 | margin: 0; 18 | font-size: 1em; 19 | font-weight: 600; 20 | padding: 0.2em 0 0.2em 0.5em; 21 | border-radius: 0.1em 0.1em 0 0; 22 | border: none; 23 | } 24 | 25 | .manual-index .manual-card-wrap > h1 span { 26 | color: #555; 27 | } 28 | 29 | .manual-index .manual-card { 30 | height: 200px; 31 | overflow: hidden; 32 | border: solid 1px rgba(230, 230, 230, 0.84); 33 | border-radius: 0 0 0.1em 0.1em; 34 | padding: 8px; 35 | position: relative; 36 | } 37 | 38 | .manual-index .manual-card > div { 39 | transform: scale(0.4); 40 | transform-origin: 0 0; 41 | width: 250%; 42 | } 43 | 44 | .manual-index .manual-card > a { 45 | position: absolute; 46 | top: 0; 47 | left: 0; 48 | width: 100%; 49 | height: 100%; 50 | background: rgba(210, 210, 210, 0.1); 51 | } 52 | 53 | .manual-index .manual-card > a:hover { 54 | background: none; 55 | } 56 | 57 | .manual-index .manual-badge { 58 | margin: 0; 59 | } 60 | 61 | .manual-index .manual-user-index { 62 | margin-bottom: 1em; 63 | border-bottom: solid 1px #ddd; 64 | } 65 | 66 | .manual-root .navigation { 67 | padding-left: 4px; 68 | margin-top: 4px; 69 | } 70 | 71 | .navigation .manual-toc-root > div { 72 | padding-left: 0.25em; 73 | padding-right: 0.75em; 74 | } 75 | 76 | .github-markdown .manual-toc-title a { 77 | color: inherit; 78 | } 79 | 80 | .manual-breadcrumb-list { 81 | font-size: 0.8em; 82 | margin-bottom: 1em; 83 | } 84 | 85 | .manual-toc-title a:hover { 86 | color: #039BE5; 87 | } 88 | 89 | .manual-toc li { 90 | margin: 0.75em 0; 91 | list-style-type: none; 92 | } 93 | 94 | .navigation .manual-toc [class^="indent-h"] a { 95 | color: #666; 96 | } 97 | 98 | .navigation .manual-toc .indent-h1 a { 99 | color: #555; 100 | font-weight: 600; 101 | display: block; 102 | } 103 | 104 | .manual-toc .indent-h1 { 105 | display: block; 106 | margin: 0.4em 0 0 0.25em; 107 | padding: 0.2em 0 0.2em 0.5em; 108 | border-radius: 0.1em; 109 | } 110 | 111 | .manual-root .navigation .manual-toc li:not(.indent-h1) { 112 | margin-top: 0.5em; 113 | } 114 | 115 | .manual-toc .indent-h2 { 116 | display: none; 117 | margin-left: 1.5em; 118 | } 119 | .manual-toc .indent-h3 { 120 | display: none; 121 | margin-left: 2.5em; 122 | } 123 | .manual-toc .indent-h4 { 124 | display: none; 125 | margin-left: 3.5em; 126 | } 127 | .manual-toc .indent-h5 { 128 | display: none; 129 | margin-left: 4.5em; 130 | } 131 | 132 | .manual-nav li { 133 | margin: 0.75em 0; 134 | } 135 | -------------------------------------------------------------------------------- /packages/create-utils/src/cli/create.ts: -------------------------------------------------------------------------------- 1 | import chalk from 'chalk'; 2 | import path from 'path'; 3 | import fs from 'fs-extra'; 4 | import os from 'os'; 5 | import spawn from 'cross-spawn'; 6 | import { execSync } from 'child_process'; 7 | import validateProjectName from 'validate-npm-package-name'; 8 | 9 | function printValidationResults(results: string[]): void { 10 | if (typeof results !== 'undefined') { 11 | results.forEach(error => { 12 | console.error(chalk.red(` * ${error}`)); 13 | }); 14 | } 15 | } 16 | 17 | const packageToInstall = 'utils-scripts'; 18 | 19 | export default function(name: string): void{ 20 | //check name 21 | const validationResult = validateProjectName(name); 22 | 23 | if (!validationResult.validForNewPackages) { 24 | console.error( 25 | `Could not create a project called ${chalk.red( 26 | `"${name}"` 27 | )} because of npm naming restrictions:` 28 | ); 29 | printValidationResults(validationResult.errors); 30 | printValidationResults(validationResult.warnings); 31 | process.exit(1); 32 | } 33 | 34 | const root = path.resolve(name); 35 | fs.ensureDirSync(name); 36 | console.log(`Creating a new utils library in ${chalk.green(root)}`); 37 | console.log(); 38 | 39 | const packageJson = { 40 | name, 41 | version: '0.0.1', 42 | scripts: { 43 | dev: "utils-scripts dev", 44 | build: "utils-scripts build", 45 | test: "utils-scripts test", 46 | doc: "utils-scripts doc" 47 | }, 48 | }; 49 | fs.writeFileSync( 50 | path.join(root, 'package.json'), 51 | JSON.stringify(packageJson, null, 2) + os.EOL 52 | ); 53 | // copy template 54 | let templateSrc = path.resolve(__dirname, '../../template-typescript'); 55 | if (this.js) { 56 | templateSrc = path.resolve(__dirname, '../../template-javascript'); 57 | } 58 | fs.copySync(templateSrc, root); 59 | // cd root 60 | process.chdir(root); 61 | 62 | console.log( 63 | `Installing ${chalk.cyan(packageToInstall)}` 64 | ); 65 | 66 | const args = ['add', '--exact']; 67 | args.push(packageToInstall); 68 | if (!this.js) { 69 | args.push('@types/node', '@types/jest', 'typescript', 'tslib'); 70 | } 71 | args.push('-D'); 72 | args.push('--cwd'); 73 | args.push(root); 74 | const output = spawn.sync('yarn', args, { stdio: 'inherit' }); 75 | 76 | if (output.error) { 77 | console.error(chalk.red('Unexpected error. Please report it as a bug')); 78 | return; 79 | } 80 | 81 | console.log(chalk.green('Dependencies has installed')); 82 | 83 | // git init 84 | execSync('git init', { stdio: 'ignore' }); 85 | execSync('git add -A', { stdio: 'ignore' }); 86 | execSync('git commit -m "Initial commit from Create Utils"', { 87 | stdio: 'ignore', 88 | }); 89 | 90 | console.log('We suggest that you begin by typing:'); 91 | console.log(); 92 | console.log(chalk.cyan(' cd'), name); 93 | console.log(` ${chalk.cyan('npm run dev')}`); 94 | process.exit(1); 95 | } 96 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/class.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 | 5 | | variation 6 | | version 7 | | since 8 | | 9 |
10 | 11 |
12 |

13 | 14 |
15 | You can directly use an instance of this class. 16 | 17 |
18 | 19 |

Expression Extends:

20 |

Mixin Extends:

21 |

Extends:

22 |

Direct Subclass:

23 |

Indirect Subclass:

24 |

Implements:

25 |

Indirect Implements:

26 |

Direct Implemented:

27 |

Indirect Implemented:

28 | 29 |
30 |
31 |
32 |

Decorators:

33 | 34 |

See:

35 | 36 |
37 |

Example:

38 |
39 |
40 |

41 |     
42 |
43 | 44 |
45 |

Test:

46 |
    47 |
  • 48 |
49 |
50 | 51 |

TODO:

52 |
53 | 54 |

Static Member Summary

55 |

Static Method Summary

56 |

Constructor Summary

57 |

Member Summary

58 |

Method Summary

59 | 60 |

Inherited Summary

61 | 62 |
63 |
64 |
65 |
66 |
67 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/details.html: -------------------------------------------------------------------------------- 1 |

2 |
3 |

4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | version 13 | since 14 | 15 | 16 |

17 | 18 |
19 |
20 |
21 |
22 | 23 |

Override:

24 | 25 |
26 | 27 |
28 |

Return:

29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 |
37 |
38 |
39 | 40 |
41 |

Emit:

42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 |

50 |
51 | 52 |
53 |

Listen:

54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |

62 |
63 | 64 |
65 |

Throw:

66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 |

74 |
75 | 76 |

Decorators:

77 | 78 |
79 |

Example:

80 |
81 |
82 |

83 |     
84 |
85 | 86 |
87 |

Test:

88 |
    89 |
  • 90 |
91 |
92 | 93 |

See:

94 |

TODO:

95 |
96 | -------------------------------------------------------------------------------- /packages/create-utils/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "create-utils", 3 | "version": "0.1.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@types/node": { 8 | "version": "10.12.18", 9 | "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", 10 | "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==", 11 | "dev": true 12 | }, 13 | "ansi-styles": { 14 | "version": "3.2.1", 15 | "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", 16 | "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", 17 | "requires": { 18 | "color-convert": "1.9.3" 19 | } 20 | }, 21 | "chalk": { 22 | "version": "2.4.1", 23 | "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", 24 | "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", 25 | "requires": { 26 | "ansi-styles": "3.2.1", 27 | "escape-string-regexp": "1.0.5", 28 | "supports-color": "5.5.0" 29 | } 30 | }, 31 | "color-convert": { 32 | "version": "1.9.3", 33 | "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", 34 | "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", 35 | "requires": { 36 | "color-name": "1.1.3" 37 | } 38 | }, 39 | "color-name": { 40 | "version": "1.1.3", 41 | "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", 42 | "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" 43 | }, 44 | "commander": { 45 | "version": "2.19.0", 46 | "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz", 47 | "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==" 48 | }, 49 | "escape-string-regexp": { 50 | "version": "1.0.5", 51 | "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", 52 | "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" 53 | }, 54 | "has-flag": { 55 | "version": "3.0.0", 56 | "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", 57 | "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" 58 | }, 59 | "supports-color": { 60 | "version": "5.5.0", 61 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", 62 | "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", 63 | "requires": { 64 | "has-flag": "3.0.0" 65 | } 66 | }, 67 | "tslib": { 68 | "version": "1.9.3", 69 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", 70 | "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==" 71 | }, 72 | "typescript": { 73 | "version": "3.2.2", 74 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.2.2.tgz", 75 | "integrity": "sha512-VCj5UiSyHBjwfYacmDuc/NOk4QQixbE+Wn7MFJuS0nRuPQbof132Pw4u53dm264O8LPc2MVsc7RJNml5szurkg==", 76 | "dev": true 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /packages/create-utils/lib/cli/create.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var tslib_1 = require("tslib"); 4 | var chalk_1 = tslib_1.__importDefault(require("chalk")); 5 | var path_1 = tslib_1.__importDefault(require("path")); 6 | var fs_extra_1 = tslib_1.__importDefault(require("fs-extra")); 7 | var os_1 = tslib_1.__importDefault(require("os")); 8 | var cross_spawn_1 = tslib_1.__importDefault(require("cross-spawn")); 9 | var child_process_1 = require("child_process"); 10 | var validate_npm_package_name_1 = tslib_1.__importDefault(require("validate-npm-package-name")); 11 | function printValidationResults(results) { 12 | if (typeof results !== 'undefined') { 13 | results.forEach(function (error) { 14 | console.error(chalk_1.default.red(" * " + error)); 15 | }); 16 | } 17 | } 18 | var packageToInstall = 'utils-scripts'; 19 | function default_1(name) { 20 | //check name 21 | var validationResult = validate_npm_package_name_1.default(name); 22 | if (!validationResult.validForNewPackages) { 23 | console.error("Could not create a project called " + chalk_1.default.red("\"" + name + "\"") + " because of npm naming restrictions:"); 24 | printValidationResults(validationResult.errors); 25 | printValidationResults(validationResult.warnings); 26 | process.exit(1); 27 | } 28 | var root = path_1.default.resolve(name); 29 | fs_extra_1.default.ensureDirSync(name); 30 | console.log("Creating a new utils library in " + chalk_1.default.green(root)); 31 | console.log(); 32 | var packageJson = { 33 | name: name, 34 | version: '0.0.1', 35 | scripts: { 36 | dev: "utils-scripts dev", 37 | build: "utils-scripts build", 38 | test: "utils-scripts test", 39 | doc: "utils-scripts doc" 40 | }, 41 | }; 42 | fs_extra_1.default.writeFileSync(path_1.default.join(root, 'package.json'), JSON.stringify(packageJson, null, 2) + os_1.default.EOL); 43 | // copy template 44 | var templateSrc = path_1.default.resolve(__dirname, '../../template-typescript'); 45 | if (this.js) { 46 | templateSrc = path_1.default.resolve(__dirname, '../../template-javascript'); 47 | } 48 | fs_extra_1.default.copySync(templateSrc, root); 49 | // cd root 50 | process.chdir(root); 51 | console.log("Installing " + chalk_1.default.cyan(packageToInstall)); 52 | var args = ['add', '--exact']; 53 | args.push(packageToInstall); 54 | if (!this.js) { 55 | args.push('@types/node', '@types/jest', 'typescript', 'tslib'); 56 | } 57 | args.push('-D'); 58 | args.push('--cwd'); 59 | args.push(root); 60 | var output = cross_spawn_1.default.sync('yarn', args, { stdio: 'inherit' }); 61 | if (output.error) { 62 | console.error(chalk_1.default.red('Unexpected error. Please report it as a bug')); 63 | return; 64 | } 65 | console.log(chalk_1.default.green('Dependencies has installed')); 66 | // git init 67 | child_process_1.execSync('git init', { stdio: 'ignore' }); 68 | child_process_1.execSync('git add -A', { stdio: 'ignore' }); 69 | child_process_1.execSync('git commit -m "Initial commit from Create Utils"', { 70 | stdio: 'ignore', 71 | }); 72 | console.log('We suggest that you begin by typing:'); 73 | console.log(); 74 | console.log(chalk_1.default.cyan(' cd'), name); 75 | console.log(" " + chalk_1.default.cyan('npm run dev')); 76 | process.exit(1); 77 | } 78 | exports.default = default_1; 79 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/script/search.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | var searchIndex = window.esdocSearchIndex; 3 | var searchBox = document.querySelector('.search-box'); 4 | var input = document.querySelector('.search-input'); 5 | var result = document.querySelector('.search-result'); 6 | var selectedIndex = -1; 7 | var prevText; 8 | 9 | // active search box and focus when mouse enter on search box. 10 | searchBox.addEventListener('mouseenter', function(){ 11 | searchBox.classList.add('active'); 12 | input.focus(); 13 | }); 14 | 15 | // search with text when key is upped. 16 | input.addEventListener('keyup', function(ev){ 17 | var text = ev.target.value.toLowerCase(); 18 | if (!text) { 19 | result.style.display = 'none'; 20 | result.innerHTML = ''; 21 | return; 22 | } 23 | 24 | if (text === prevText) return; 25 | prevText = text; 26 | 27 | var html = {class: [], method: [], member: [], function: [], variable: [], typedef: [], external: [], file: [], test: [], testFile: []}; 28 | var len = searchIndex.length; 29 | var kind; 30 | for (var i = 0; i < len; i++) { 31 | var pair = searchIndex[i]; 32 | if (pair[0].indexOf(text) !== -1) { 33 | kind = pair[3]; 34 | html[kind].push('
  • ' + pair[2] + '
  • '); 35 | } 36 | } 37 | 38 | var innerHTML = ''; 39 | for (kind in html) { 40 | var list = html[kind]; 41 | if (!list.length) continue; 42 | innerHTML += '
  • ' + kind + '
  • \n' + list.join('\n'); 43 | } 44 | result.innerHTML = innerHTML; 45 | if (innerHTML) result.style.display = 'block'; 46 | selectedIndex = -1; 47 | }); 48 | 49 | // down, up and enter key are pressed, select search result. 50 | input.addEventListener('keydown', function(ev){ 51 | if (ev.keyCode === 40) { 52 | // arrow down 53 | var current = result.children[selectedIndex]; 54 | var selected = result.children[selectedIndex + 1]; 55 | if (selected && selected.classList.contains('search-separator')) { 56 | var selected = result.children[selectedIndex + 2]; 57 | selectedIndex++; 58 | } 59 | 60 | if (selected) { 61 | if (current) current.classList.remove('selected'); 62 | selectedIndex++; 63 | selected.classList.add('selected'); 64 | } 65 | } else if (ev.keyCode === 38) { 66 | // arrow up 67 | var current = result.children[selectedIndex]; 68 | var selected = result.children[selectedIndex - 1]; 69 | if (selected && selected.classList.contains('search-separator')) { 70 | var selected = result.children[selectedIndex - 2]; 71 | selectedIndex--; 72 | } 73 | 74 | if (selected) { 75 | if (current) current.classList.remove('selected'); 76 | selectedIndex--; 77 | selected.classList.add('selected'); 78 | } 79 | } else if (ev.keyCode === 13) { 80 | // enter 81 | var current = result.children[selectedIndex]; 82 | if (current) { 83 | var link = current.querySelector('a'); 84 | if (link) location.href = link.href; 85 | } 86 | } else { 87 | return; 88 | } 89 | 90 | ev.preventDefault(); 91 | }); 92 | 93 | // select search result when search result is mouse over. 94 | result.addEventListener('mousemove', function(ev){ 95 | var current = result.children[selectedIndex]; 96 | if (current) current.classList.remove('selected'); 97 | 98 | var li = ev.target; 99 | while (li) { 100 | if (li.nodeName === 'LI') break; 101 | li = li.parentElement; 102 | } 103 | 104 | if (li) { 105 | selectedIndex = Array.prototype.indexOf.call(result.children, li); 106 | li.classList.add('selected'); 107 | } 108 | }); 109 | 110 | // clear search result when body is clicked. 111 | document.body.addEventListener('click', function(ev){ 112 | selectedIndex = -1; 113 | result.style.display = 'none'; 114 | result.innerHTML = ''; 115 | }); 116 | 117 | })(); 118 | -------------------------------------------------------------------------------- /packages/utils-scripts/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "utils-scripts", 3 | "version": "0.1.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@types/cross-spawn": { 8 | "version": "6.0.0", 9 | "resolved": "http://registry.npm.taobao.org/@types/cross-spawn/download/@types/cross-spawn-6.0.0.tgz", 10 | "integrity": "sha1-MgqvHRoSl58bhP56VZCn6GC/OoA=", 11 | "dev": true, 12 | "requires": { 13 | "@types/node": "*" 14 | } 15 | }, 16 | "@types/node": { 17 | "version": "10.12.18", 18 | "resolved": "http://registry.npm.taobao.org/@types/node/download/@types/node-10.12.18.tgz", 19 | "integrity": "sha1-HTynZHGJFVhPzZ9jRGIbdnJmXGc=", 20 | "dev": true 21 | }, 22 | "ansi-styles": { 23 | "version": "3.2.1", 24 | "resolved": "http://registry.npm.taobao.org/ansi-styles/download/ansi-styles-3.2.1.tgz", 25 | "integrity": "sha1-QfuyAkPlCxK+DwS43tvwdSDOhB0=", 26 | "requires": { 27 | "color-convert": "^1.9.0" 28 | } 29 | }, 30 | "chalk": { 31 | "version": "2.4.1", 32 | "resolved": "http://registry.npm.taobao.org/chalk/download/chalk-2.4.1.tgz", 33 | "integrity": "sha1-GMSasWoDe26wFSzIPjRxM4IVtm4=", 34 | "requires": { 35 | "ansi-styles": "^3.2.1", 36 | "escape-string-regexp": "^1.0.5", 37 | "supports-color": "^5.3.0" 38 | } 39 | }, 40 | "color-convert": { 41 | "version": "1.9.3", 42 | "resolved": "http://registry.npm.taobao.org/color-convert/download/color-convert-1.9.3.tgz", 43 | "integrity": "sha1-u3GFBpDh8TZWfeYp0tVHHe2kweg=", 44 | "requires": { 45 | "color-name": "1.1.3" 46 | } 47 | }, 48 | "color-name": { 49 | "version": "1.1.3", 50 | "resolved": "http://registry.npm.taobao.org/color-name/download/color-name-1.1.3.tgz", 51 | "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" 52 | }, 53 | "commander": { 54 | "version": "2.19.0", 55 | "resolved": "http://registry.npm.taobao.org/commander/download/commander-2.19.0.tgz", 56 | "integrity": "sha1-9hmKqE5bg8RgVLlN3tv+1e6f8So=" 57 | }, 58 | "cross-spawn": { 59 | "version": "6.0.5", 60 | "resolved": "http://registry.npm.taobao.org/cross-spawn/download/cross-spawn-6.0.5.tgz", 61 | "integrity": "sha1-Sl7Hxk364iw6FBJNus3uhG2Ay8Q=", 62 | "requires": { 63 | "nice-try": "^1.0.4", 64 | "path-key": "^2.0.1", 65 | "semver": "^5.5.0", 66 | "shebang-command": "^1.2.0", 67 | "which": "^1.2.9" 68 | } 69 | }, 70 | "escape-string-regexp": { 71 | "version": "1.0.5", 72 | "resolved": "http://registry.npm.taobao.org/escape-string-regexp/download/escape-string-regexp-1.0.5.tgz", 73 | "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" 74 | }, 75 | "fs-extra": { 76 | "version": "7.0.1", 77 | "resolved": "http://registry.npm.taobao.org/fs-extra/download/fs-extra-7.0.1.tgz", 78 | "integrity": "sha1-TxicRKoSO4lfcigE9V6iPq3DSOk=", 79 | "requires": { 80 | "graceful-fs": "^4.1.2", 81 | "jsonfile": "^4.0.0", 82 | "universalify": "^0.1.0" 83 | } 84 | }, 85 | "graceful-fs": { 86 | "version": "4.1.15", 87 | "resolved": "http://registry.npm.taobao.org/graceful-fs/download/graceful-fs-4.1.15.tgz", 88 | "integrity": "sha1-/7cD4QZuig7qpMi4C6klPu77+wA=" 89 | }, 90 | "has-flag": { 91 | "version": "3.0.0", 92 | "resolved": "http://registry.npm.taobao.org/has-flag/download/has-flag-3.0.0.tgz", 93 | "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" 94 | }, 95 | "isexe": { 96 | "version": "2.0.0", 97 | "resolved": "http://registry.npm.taobao.org/isexe/download/isexe-2.0.0.tgz", 98 | "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" 99 | }, 100 | "jsonfile": { 101 | "version": "4.0.0", 102 | "resolved": "http://registry.npm.taobao.org/jsonfile/download/jsonfile-4.0.0.tgz", 103 | "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", 104 | "requires": { 105 | "graceful-fs": "^4.1.6" 106 | } 107 | }, 108 | "nice-try": { 109 | "version": "1.0.5", 110 | "resolved": "http://registry.npm.taobao.org/nice-try/download/nice-try-1.0.5.tgz", 111 | "integrity": "sha1-ozeKdpbOfSI+iPybdkvX7xCJ42Y=" 112 | }, 113 | "path-key": { 114 | "version": "2.0.1", 115 | "resolved": "http://registry.npm.taobao.org/path-key/download/path-key-2.0.1.tgz", 116 | "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=" 117 | }, 118 | "semver": { 119 | "version": "5.6.0", 120 | "resolved": "http://registry.npm.taobao.org/semver/download/semver-5.6.0.tgz", 121 | "integrity": "sha1-fnQlb7qknHWqfHogXMInmcrIAAQ=" 122 | }, 123 | "shebang-command": { 124 | "version": "1.2.0", 125 | "resolved": "http://registry.npm.taobao.org/shebang-command/download/shebang-command-1.2.0.tgz", 126 | "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", 127 | "requires": { 128 | "shebang-regex": "^1.0.0" 129 | } 130 | }, 131 | "shebang-regex": { 132 | "version": "1.0.0", 133 | "resolved": "http://registry.npm.taobao.org/shebang-regex/download/shebang-regex-1.0.0.tgz", 134 | "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=" 135 | }, 136 | "supports-color": { 137 | "version": "5.5.0", 138 | "resolved": "http://registry.npm.taobao.org/supports-color/download/supports-color-5.5.0.tgz", 139 | "integrity": "sha1-4uaaRKyHcveKHsCzW2id9lMO/I8=", 140 | "requires": { 141 | "has-flag": "^3.0.0" 142 | } 143 | }, 144 | "tslib": { 145 | "version": "1.9.3", 146 | "resolved": "http://registry.npm.taobao.org/tslib/download/tslib-1.9.3.tgz", 147 | "integrity": "sha1-1+TdeSRdhUKMTX5IIqeZF5VMooY=" 148 | }, 149 | "typescript": { 150 | "version": "3.2.2", 151 | "resolved": "http://registry.npm.taobao.org/typescript/download/typescript-3.2.2.tgz", 152 | "integrity": "sha1-/oEBxGqhI/g1NSPr3PVzDCrkk+U=", 153 | "dev": true 154 | }, 155 | "universalify": { 156 | "version": "0.1.2", 157 | "resolved": "http://registry.npm.taobao.org/universalify/download/universalify-0.1.2.tgz", 158 | "integrity": "sha1-tkb2m+OULavOzJ1mOcgNwQXvqmY=" 159 | }, 160 | "which": { 161 | "version": "1.3.1", 162 | "resolved": "http://registry.npm.taobao.org/which/download/which-1.3.1.tgz", 163 | "integrity": "sha1-pFBD1U9YBTFtqNYvn1CRjT2nCwo=", 164 | "requires": { 165 | "isexe": "^2.0.0" 166 | } 167 | } 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /packages/create-utils/yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | "@types/cross-spawn@^6.0.0": 6 | version "6.0.0" 7 | resolved "https://registry.yarnpkg.com/@types/cross-spawn/-/cross-spawn-6.0.0.tgz#320aaf1d1a12979f1b84fe7a5590a7e860bf3a80" 8 | integrity sha512-evp2ZGsFw9YKprDbg8ySgC9NA15g3YgiI8ANkGmKKvvi0P2aDGYLPxQIC5qfeKNUOe3TjABVGuah6omPRpIYhg== 9 | dependencies: 10 | "@types/node" "*" 11 | 12 | "@types/fs-extra@^5.0.4": 13 | version "5.0.4" 14 | resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-5.0.4.tgz#b971134d162cc0497d221adde3dbb67502225599" 15 | integrity sha512-DsknoBvD8s+RFfSGjmERJ7ZOP1HI0UZRA3FSI+Zakhrc/Gy26YQsLI+m5V5DHxroHRJqCDLKJp7Hixn8zyaF7g== 16 | dependencies: 17 | "@types/node" "*" 18 | 19 | "@types/node@*", "@types/node@^10.12.18": 20 | version "10.12.18" 21 | resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.18.tgz#1d3ca764718915584fcd9f6344621b7672665c67" 22 | integrity sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ== 23 | 24 | ansi-styles@^3.2.1: 25 | version "3.2.1" 26 | resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" 27 | integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== 28 | dependencies: 29 | color-convert "^1.9.0" 30 | 31 | builtins@^1.0.3: 32 | version "1.0.3" 33 | resolved "https://registry.yarnpkg.com/builtins/-/builtins-1.0.3.tgz#cb94faeb61c8696451db36534e1422f94f0aee88" 34 | integrity sha1-y5T662HIaWRR2zZTThQi+U8K7og= 35 | 36 | chalk@^2.4.1: 37 | version "2.4.1" 38 | resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e" 39 | integrity sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ== 40 | dependencies: 41 | ansi-styles "^3.2.1" 42 | escape-string-regexp "^1.0.5" 43 | supports-color "^5.3.0" 44 | 45 | color-convert@^1.9.0: 46 | version "1.9.3" 47 | resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" 48 | integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== 49 | dependencies: 50 | color-name "1.1.3" 51 | 52 | color-name@1.1.3: 53 | version "1.1.3" 54 | resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" 55 | integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= 56 | 57 | commander@^2.19.0: 58 | version "2.19.0" 59 | resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a" 60 | integrity sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg== 61 | 62 | cross-spawn@^6.0.5: 63 | version "6.0.5" 64 | resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" 65 | integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ== 66 | dependencies: 67 | nice-try "^1.0.4" 68 | path-key "^2.0.1" 69 | semver "^5.5.0" 70 | shebang-command "^1.2.0" 71 | which "^1.2.9" 72 | 73 | escape-string-regexp@^1.0.5: 74 | version "1.0.5" 75 | resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" 76 | integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= 77 | 78 | fs-extra@^7.0.1: 79 | version "7.0.1" 80 | resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9" 81 | integrity sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw== 82 | dependencies: 83 | graceful-fs "^4.1.2" 84 | jsonfile "^4.0.0" 85 | universalify "^0.1.0" 86 | 87 | graceful-fs@^4.1.2, graceful-fs@^4.1.6: 88 | version "4.1.15" 89 | resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00" 90 | integrity sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA== 91 | 92 | has-flag@^3.0.0: 93 | version "3.0.0" 94 | resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" 95 | integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= 96 | 97 | isexe@^2.0.0: 98 | version "2.0.0" 99 | resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" 100 | integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= 101 | 102 | jsonfile@^4.0.0: 103 | version "4.0.0" 104 | resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" 105 | integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss= 106 | optionalDependencies: 107 | graceful-fs "^4.1.6" 108 | 109 | nice-try@^1.0.4: 110 | version "1.0.5" 111 | resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" 112 | integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== 113 | 114 | path-key@^2.0.1: 115 | version "2.0.1" 116 | resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" 117 | integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A= 118 | 119 | semver@^5.5.0: 120 | version "5.6.0" 121 | resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004" 122 | integrity sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg== 123 | 124 | shebang-command@^1.2.0: 125 | version "1.2.0" 126 | resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" 127 | integrity sha1-RKrGW2lbAzmJaMOfNj/uXer98eo= 128 | dependencies: 129 | shebang-regex "^1.0.0" 130 | 131 | shebang-regex@^1.0.0: 132 | version "1.0.0" 133 | resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" 134 | integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM= 135 | 136 | supports-color@^5.3.0: 137 | version "5.5.0" 138 | resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" 139 | integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== 140 | dependencies: 141 | has-flag "^3.0.0" 142 | 143 | tslib@^1.9.3: 144 | version "1.9.3" 145 | resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" 146 | integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ== 147 | 148 | typescript@^3.2.2: 149 | version "3.2.2" 150 | resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.2.2.tgz#fe8101c46aa123f8353523ebdcf5730c2ae493e5" 151 | integrity sha512-VCj5UiSyHBjwfYacmDuc/NOk4QQixbE+Wn7MFJuS0nRuPQbof132Pw4u53dm264O8LPc2MVsc7RJNml5szurkg== 152 | 153 | universalify@^0.1.0: 154 | version "0.1.2" 155 | resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" 156 | integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== 157 | 158 | validate-npm-package-name@^3.0.0: 159 | version "3.0.0" 160 | resolved "https://registry.yarnpkg.com/validate-npm-package-name/-/validate-npm-package-name-3.0.0.tgz#5fa912d81eb7d0c74afc140de7317f0ca7df437e" 161 | integrity sha1-X6kS2B630MdK/BQN5zF/DKffQ34= 162 | dependencies: 163 | builtins "^1.0.3" 164 | 165 | which@^1.2.9: 166 | version "1.3.1" 167 | resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" 168 | integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== 169 | dependencies: 170 | isexe "^2.0.0" 171 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/script/prettify/Apache-License-2.0.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/css/style.css: -------------------------------------------------------------------------------- 1 | /* @import url(https://fonts.googleapis.com/css?family=Roboto:400,300,700); */ 2 | /* @import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400italic,600,700); */ 3 | @import url(./manual.css); 4 | @import url(./source.css); 5 | @import url(./test.css); 6 | @import url(./identifiers.css); 7 | @import url(./github.css); 8 | @import url(./search.css); 9 | 10 | * { 11 | margin: 0; 12 | padding: 0; 13 | text-decoration: none; 14 | } 15 | 16 | html 17 | { 18 | font-family: Helvetica Neue,Helvetica,PingFang SC,Hiragino Sans GB,Microsoft YaHei,\\5FAE\8F6F\96C5\9ED1,Arial,sans-serif; 19 | font-size: 14px; 20 | line-height: 1.5; 21 | color: #515a6e; 22 | background-color: #fff; 23 | -webkit-font-smoothing: antialiased; 24 | -moz-osx-font-smoothing: grayscale 25 | } 26 | 27 | a { 28 | /*color: #0095dd;*/ 29 | /*color:rgb(37, 138, 175);*/ 30 | color: #2d8cf0; 31 | transition: color .2s ease; 32 | } 33 | 34 | code a:hover { 35 | text-decoration: underline; 36 | } 37 | 38 | code, kbd, pre, samp { 39 | font-family: Consolas,Menlo,Courier,monospace; 40 | } 41 | 42 | ul, ol { 43 | padding-left: 20px; 44 | } 45 | 46 | ul li { 47 | list-style: disc; 48 | margin: 4px 0; 49 | } 50 | 51 | ol li { 52 | margin: 4px 0; 53 | } 54 | 55 | h1 { 56 | margin-bottom: 10px; 57 | font-size: 34px; 58 | font-weight: 300; 59 | border-bottom: solid 1px #ddd; 60 | } 61 | 62 | h2 { 63 | margin-top: 24px; 64 | margin-bottom: 10px; 65 | font-size: 20px; 66 | border-bottom: solid 1px #ddd; 67 | font-weight: 300; 68 | } 69 | 70 | h3 { 71 | position: relative; 72 | font-size: 16px; 73 | margin-bottom: 12px; 74 | padding: 4px; 75 | font-weight: 300; 76 | } 77 | 78 | details { 79 | cursor: pointer; 80 | } 81 | 82 | del { 83 | text-decoration: line-through; 84 | } 85 | 86 | p { 87 | margin-bottom: 15px; 88 | line-height: 1.5; 89 | } 90 | 91 | code { 92 | font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace; 93 | white-space: normal; 94 | } 95 | 96 | pre > code { 97 | display: block; 98 | } 99 | 100 | pre.prettyprint, pre > code { 101 | padding: 4px; 102 | margin: 1em 0; 103 | background: #f7f7f7; 104 | border-radius: 3px; 105 | } 106 | 107 | pre.prettyprint > code { 108 | margin: 0; 109 | } 110 | 111 | p > code, 112 | li > code { 113 | padding: 0.2em 0.5em; 114 | margin: 0; 115 | font-size: 85%; 116 | background-color: rgba(0,0,0,0.04); 117 | border-radius: 3px; 118 | } 119 | 120 | .code { 121 | font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace; 122 | font-size: 13px; 123 | } 124 | 125 | .import-path pre.prettyprint, 126 | .import-path pre.prettyprint code { 127 | margin: 0; 128 | padding: 0; 129 | border: none; 130 | background: white; 131 | } 132 | 133 | .layout-container { 134 | /*display: flex;*/ 135 | /*flex-direction: row;*/ 136 | /*justify-content: flex-start;*/ 137 | /*align-items: stretch;*/ 138 | } 139 | 140 | .layout-container > header { 141 | display: flex; 142 | height: 50px; 143 | line-height: 50px; 144 | font-size: 16px; 145 | padding: 0 10px; 146 | margin: 0; 147 | position: fixed; 148 | width: 100%; 149 | z-index: 1; 150 | background-color: #fafafa; 151 | top: 0; 152 | border-bottom: solid 1px #ddd; 153 | } 154 | .layout-container > header > a{ 155 | margin: 0 5px; 156 | color: #444; 157 | } 158 | 159 | .layout-container > header > a.repo-url-github { 160 | font-size: 0; 161 | display: inline-block; 162 | width: 20px; 163 | height: 38px; 164 | background: url("../image/github.png") no-repeat center; 165 | background-size: 20px; 166 | vertical-align: top; 167 | } 168 | 169 | .navigation { 170 | position: fixed; 171 | top: 0; 172 | left: 0; 173 | box-sizing: border-box; 174 | width: 16%; 175 | height: 100%; 176 | padding-top: 40px; 177 | padding-left: 15px; 178 | padding-bottom: 2em; 179 | margin-top:1em; 180 | overflow-x: scroll; 181 | box-shadow: rgba(255, 255, 255, 1) -1px 0 0 inset; 182 | border-right: 1px solid #dcdee2; 183 | } 184 | 185 | .navigation .nav-item { 186 | display: block; 187 | outline: 0; 188 | list-style: none; 189 | font-size: 14px; 190 | position: relative; 191 | z-index: 1; 192 | cursor: pointer; 193 | transition: all .2s ease-in-out; 194 | padding: 0px 0; 195 | position: relative; 196 | cursor: pointer; 197 | } 198 | 199 | .navigation ul { 200 | padding: 0; 201 | } 202 | 203 | .navigation li { 204 | list-style: none; 205 | margin: 4px 0; 206 | white-space: nowrap; 207 | } 208 | 209 | .navigation li a { 210 | color: #666; 211 | } 212 | 213 | .navigation .nav-dir-path { 214 | display: block; 215 | /* margin-top: 0.7em; 216 | margin-bottom: 0.25em;*/ 217 | font-weight: 600; 218 | height: 30px; 219 | line-height: 30px; 220 | font-size: 14px; 221 | } 222 | 223 | .kind-class, 224 | .kind-interface, 225 | .kind-function, 226 | .kind-typedef, 227 | .kind-variable, 228 | .kind-external { 229 | margin-left: 0.75em; 230 | width: 1.2em; 231 | height: 1.2em; 232 | display: inline-block; 233 | text-align: center; 234 | border-radius: 0.2em; 235 | margin-right: 0.2em; 236 | font-weight: bold; 237 | line-height: 1.2em; 238 | } 239 | 240 | .kind-class { 241 | color: #009800; 242 | background-color: #bfe5bf; 243 | } 244 | 245 | .kind-interface { 246 | color: #fbca04; 247 | background-color: #fef2c0; 248 | } 249 | 250 | .kind-function { 251 | color: #6b0090; 252 | background-color: #d6bdde; 253 | } 254 | 255 | .kind-variable { 256 | color: #eb6420; 257 | background-color: #fad8c7; 258 | } 259 | 260 | .kind-typedef { 261 | color: #db001e; 262 | background-color: #edbec3; 263 | } 264 | 265 | .kind-external { 266 | color: #0738c3; 267 | background-color: #bbcbea; 268 | } 269 | 270 | .summary span[class^="kind-"] { 271 | margin-left: 0; 272 | } 273 | 274 | h1 .version, 275 | h1 .url a { 276 | font-size: 14px; 277 | color: #aaa; 278 | } 279 | 280 | .content { 281 | margin-top: 40px; 282 | margin-left: 16%; 283 | padding: 10px 50px 10px 20px; 284 | } 285 | 286 | .header-notice { 287 | font-size: 14px; 288 | color: #aaa; 289 | margin: 0; 290 | } 291 | 292 | .expression-extends .prettyprint { 293 | margin-left: 10px; 294 | background: white; 295 | } 296 | 297 | .extends-chain { 298 | border-bottom: 1px solid#ddd; 299 | padding-bottom: 10px; 300 | margin-bottom: 10px; 301 | } 302 | 303 | .extends-chain span:nth-of-type(1) { 304 | padding-left: 10px; 305 | } 306 | 307 | .extends-chain > div { 308 | margin: 5px 0; 309 | } 310 | 311 | .description table { 312 | font-size: 14px; 313 | border-spacing: 0; 314 | border: 0; 315 | border-collapse: collapse; 316 | } 317 | 318 | .description thead { 319 | background: #f7f7f7; 320 | color: white; 321 | } 322 | 323 | .description table td, 324 | .description table th { 325 | border: solid 1px #ddd; 326 | padding: 4px; 327 | font-weight: normal; 328 | } 329 | 330 | .flat-list ul { 331 | padding-left: 0; 332 | } 333 | 334 | .flat-list li { 335 | display: inline; 336 | list-style: none; 337 | } 338 | 339 | table.summary { 340 | font-family: Consolas,Menlo,Courier,monospace; 341 | font-size: 12px; 342 | border-collapse: collapse; 343 | border-spacing: 0; 344 | empty-cells: show; 345 | border: 1px solid #e9e9e9; 346 | width: calc(100% - 10px); 347 | margin-bottom: 1em; 348 | margin-top: 1em; 349 | } 350 | 351 | table.summary thead { 352 | background: #f7f7f7; 353 | } 354 | 355 | table.summary thead td { 356 | padding: 10px; 357 | } 358 | 359 | table.summary td { 360 | border: solid 1px #ddd; 361 | padding: 8px 10px; 362 | white-space: nowrap; 363 | color: #5c6b77; 364 | font-weight: 600 365 | } 366 | 367 | table.summary tbody td:nth-child(1) { 368 | text-align: right; 369 | white-space: nowrap; 370 | min-width: 64px; 371 | vertical-align: top; 372 | } 373 | 374 | table.summary tbody td:nth-child(2) { 375 | width: 100%; 376 | border-right: none; 377 | } 378 | 379 | table.summary tbody td:nth-child(3) { 380 | white-space: nowrap; 381 | border-left: none; 382 | vertical-align: top; 383 | } 384 | 385 | table.summary td > div:nth-of-type(2) { 386 | padding-top: 4px; 387 | padding-left: 15px; 388 | } 389 | 390 | table.summary td p { 391 | margin-bottom: 0; 392 | } 393 | 394 | .inherited-summary thead td { 395 | padding-left: 2px; 396 | } 397 | 398 | .inherited-summary thead a { 399 | color: white; 400 | } 401 | 402 | .inherited-summary .summary tbody { 403 | display: none; 404 | } 405 | 406 | .inherited-summary .summary .toggle { 407 | padding: 0 4px; 408 | font-size: 12px; 409 | cursor: pointer; 410 | } 411 | .inherited-summary .summary .toggle.closed:before { 412 | content: "▶"; 413 | } 414 | .inherited-summary .summary .toggle.opened:before { 415 | content: "▼"; 416 | } 417 | 418 | .member, .method { 419 | margin-bottom: 24px; 420 | } 421 | 422 | table.params { 423 | font-family: Consolas,Menlo,Courier,monospace; 424 | font-size: 12px; 425 | border-collapse: collapse; 426 | border-spacing: 0; 427 | empty-cells: show; 428 | border: 1px solid #e9e9e9; 429 | width: calc(100% - 10px); 430 | margin-bottom: 1em; 431 | margin-top: 1em; 432 | } 433 | 434 | table.params thead td { 435 | background: #f7f7f7; 436 | white-space: nowrap; 437 | color: #5c6b77; 438 | font-weight: 600 439 | } 440 | 441 | table.params td,table.params th { 442 | border: 1px solid #e9e9e9; 443 | padding: 8px 16px; 444 | text-align: left 445 | } 446 | 447 | table.params td p { 448 | margin: 0; 449 | } 450 | 451 | .content .detail > * { 452 | margin: 15px 0; 453 | } 454 | 455 | .content .detail > h3 { 456 | color: black; 457 | background: #f7f7f7; 458 | padding: 15px; 459 | margin-top: 0; 460 | } 461 | 462 | .content .detail > div { 463 | margin-left: 10px; 464 | } 465 | 466 | .content .detail > .import-path { 467 | font-size: 16px; 468 | } 469 | 470 | .content .detail { 471 | border: 1px solid #dcdee2; 472 | border-radius: 6px; 473 | padding: 15px; 474 | } 475 | 476 | .content .detail:hover { 477 | box-shadow: 0 2px 7px rgba(0,0,0,.35); 478 | border-color: transparent; 479 | } 480 | 481 | .content .detail + .detail { 482 | margin-top: 30px; 483 | } 484 | 485 | .content .detail .throw td:first-child { 486 | padding-right: 10px; 487 | } 488 | 489 | .content .detail h4 + :not(pre) { 490 | padding-left: 0; 491 | margin-left: 10px; 492 | } 493 | 494 | .content .detail h4 + ul li { 495 | list-style: none; 496 | } 497 | 498 | .return-param * { 499 | display: inline; 500 | } 501 | 502 | .argument-params { 503 | margin-bottom: 20px; 504 | } 505 | 506 | .return-type { 507 | padding-right: 10px; 508 | font-weight: normal; 509 | } 510 | 511 | .return-desc { 512 | margin-left: 10px; 513 | margin-top: 4px; 514 | } 515 | 516 | .return-desc p { 517 | margin: 0; 518 | } 519 | 520 | .deprecated, .experimental, .instance-docs { 521 | border-left: solid 5px orange; 522 | padding-left: 4px; 523 | margin: 4px 0; 524 | } 525 | 526 | tr.listen p, 527 | tr.throw p, 528 | tr.emit p{ 529 | margin-bottom: 10px; 530 | } 531 | 532 | .version, .since { 533 | color: #aaa; 534 | } 535 | 536 | h3 .right-info { 537 | position: absolute; 538 | right: 4px; 539 | font-size: 14px; 540 | } 541 | 542 | .version + .since:before { 543 | content: '| '; 544 | } 545 | 546 | .see { 547 | margin-top: 10px; 548 | } 549 | 550 | .see h4 { 551 | margin: 4px 0; 552 | } 553 | 554 | .content .detail h4 + .example-doc { 555 | margin: 6px 0; 556 | } 557 | 558 | .example-caption { 559 | position: relative; 560 | bottom: -1px; 561 | display: inline-block; 562 | padding: 4px; 563 | font-style: italic; 564 | background-color: #f5f5f5; 565 | font-weight: bold; 566 | border-radius: 3px; 567 | border-bottom-left-radius: 0; 568 | border-bottom-right-radius: 0; 569 | } 570 | 571 | .example-caption + pre.source-code { 572 | margin-top: 0; 573 | border-top-left-radius: 0; 574 | } 575 | 576 | footer, .file-footer { 577 | text-align: right; 578 | font-style: italic; 579 | font-weight: 100; 580 | font-size: 13px; 581 | margin-right: 50px; 582 | margin-left: 270px; 583 | border-top: 1px solid #ddd; 584 | padding-top: 30px; 585 | margin-top: 20px; 586 | padding-bottom: 10px; 587 | } 588 | 589 | footer img { 590 | width: 24px; 591 | vertical-align: middle; 592 | padding-left: 4px; 593 | position: relative; 594 | top: -3px; 595 | opacity: 0.6; 596 | } 597 | 598 | pre.source-code { 599 | padding: 4px; 600 | } 601 | 602 | pre.raw-source-code > code { 603 | padding: 0; 604 | margin: 0; 605 | font-size: 12px; 606 | background: #fff; 607 | border: solid 1px #ddd; 608 | line-height: 1.5; 609 | } 610 | 611 | pre.raw-source-code > code > ol { 612 | counter-reset:number; 613 | list-style:none; 614 | margin:0; 615 | padding:0; 616 | overflow: hidden; 617 | } 618 | 619 | pre.raw-source-code > code > ol li:before { 620 | counter-increment: number; 621 | content: counter(number); 622 | display: inline-block; 623 | min-width: 3em; 624 | color: #aaa; 625 | text-align: right; 626 | padding-right: 1em; 627 | } 628 | 629 | pre.source-code.line-number { 630 | padding: 0; 631 | } 632 | 633 | pre.source-code ol { 634 | background: #eee; 635 | padding-left: 40px; 636 | } 637 | 638 | pre.source-code li { 639 | background: white; 640 | padding-left: 4px; 641 | list-style: decimal; 642 | margin: 0; 643 | } 644 | 645 | pre.source-code.line-number li.active { 646 | background: rgb(255, 255, 150) !important; 647 | } 648 | 649 | pre.source-code.line-number li.error-line { 650 | background: #ffb8bf; 651 | } 652 | 653 | .inner-link-active { 654 | /*background: rgb(255, 255, 150) !important;*/ 655 | background: #f0faff !important; 656 | color: #515a6e !important; 657 | border: 1px solid #abdcff; 658 | border-radius: 5px; 659 | } 660 | 661 | .inner-link-active a { 662 | color: inherit; 663 | } 664 | -------------------------------------------------------------------------------- /packages/utils-scripts/docs-template/script/prettify/prettify.js: -------------------------------------------------------------------------------- 1 | !function(){/* 2 | 3 | Copyright (C) 2006 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | window.PR_SHOULD_USE_CONTINUATION=!0; 18 | (function(){function T(a){function d(e){var b=e.charCodeAt(0);if(92!==b)return b;var a=e.charAt(1);return(b=w[a])?b:"0"<=a&&"7">=a?parseInt(e.substring(1),8):"u"===a||"x"===a?parseInt(e.substring(2),16):e.charCodeAt(1)}function f(e){if(32>e)return(16>e?"\\x0":"\\x")+e.toString(16);e=String.fromCharCode(e);return"\\"===e||"-"===e||"]"===e||"^"===e?"\\"+e:e}function b(e){var b=e.substring(1,e.length-1).match(/\\u[0-9A-Fa-f]{4}|\\x[0-9A-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\s\S]|-|[^-\\]/g);e= 19 | [];var a="^"===b[0],c=["["];a&&c.push("^");for(var a=a?1:0,g=b.length;ak||122k||90k||122h[0]&&(h[1]+1>h[0]&&c.push("-"),c.push(f(h[1])));c.push("]");return c.join("")}function v(e){for(var a=e.source.match(/(?:\[(?:[^\x5C\x5D]|\\[\s\S])*\]|\\u[A-Fa-f0-9]{4}|\\x[A-Fa-f0-9]{2}|\\[0-9]+|\\[^ux0-9]|\(\?[:!=]|[\(\)\^]|[^\x5B\x5C\(\)\^]+)/g),c=a.length,d=[],g=0,h=0;g/,null])):d.push(["com",/^#[^\r\n]*/,null,"#"]));a.cStyleComments&&(f.push(["com",/^\/\/[^\r\n]*/,null]),f.push(["com",/^\/\*[\s\S]*?(?:\*\/|$)/,null]));if(b=a.regexLiterals){var v=(b=1|\\/=?|::?|<>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*("+ 28 | ("/(?=[^/*"+b+"])(?:[^/\\x5B\\x5C"+b+"]|\\x5C"+v+"|\\x5B(?:[^\\x5C\\x5D"+b+"]|\\x5C"+v+")*(?:\\x5D|$))+/")+")")])}(b=a.types)&&f.push(["typ",b]);b=(""+a.keywords).replace(/^ | $/g,"");b.length&&f.push(["kwd",new RegExp("^(?:"+b.replace(/[\s,]+/g,"|")+")\\b"),null]);d.push(["pln",/^\s+/,null," \r\n\t\u00a0"]);b="^.[^\\s\\w.$@'\"`/\\\\]*";a.regexLiterals&&(b+="(?!s*/)");f.push(["lit",/^@[a-z_$][a-z_$@0-9]*/i,null],["typ",/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],["pln",/^[a-z_$][a-z_$@0-9]*/i, 29 | null],["lit",/^(?:0x[a-f0-9]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+\-]?\d+)?)[a-z]*/i,null,"0123456789"],["pln",/^\\[\s\S]?/,null],["pun",new RegExp(b),null]);return G(d,f)}function L(a,d,f){function b(a){var c=a.nodeType;if(1==c&&!A.test(a.className))if("br"===a.nodeName)v(a),a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)b(a);else if((3==c||4==c)&&f){var d=a.nodeValue,q=d.match(n);q&&(c=d.substring(0,q.index),a.nodeValue=c,(d=d.substring(q.index+q[0].length))&& 30 | a.parentNode.insertBefore(l.createTextNode(d),a.nextSibling),v(a),c||a.parentNode.removeChild(a))}}function v(a){function b(a,c){var d=c?a.cloneNode(!1):a,k=a.parentNode;if(k){var k=b(k,1),e=a.nextSibling;k.appendChild(d);for(var f=e;f;f=e)e=f.nextSibling,k.appendChild(f)}return d}for(;!a.nextSibling;)if(a=a.parentNode,!a)return;a=b(a.nextSibling,0);for(var d;(d=a.parentNode)&&1===d.nodeType;)a=d;c.push(a)}for(var A=/(?:^|\s)nocode(?:\s|$)/,n=/\r\n?|\n/,l=a.ownerDocument,m=l.createElement("li");a.firstChild;)m.appendChild(a.firstChild); 31 | for(var c=[m],p=0;p=+v[1],d=/\n/g,A=a.a,n=A.length,f=0,l=a.c,m=l.length,b=0,c=a.g,p=c.length,w=0;c[p]=n;var r,e;for(e=r=0;e=h&&(b+=2);f>=k&&(w+=2)}}finally{g&&(g.style.display=a)}}catch(x){E.console&&console.log(x&&x.stack||x)}}var E=window,C=["break,continue,do,else,for,if,return,while"], 34 | F=[[C,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,restrict,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],H=[F,"alignas,alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,noexcept,noreturn,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"], 35 | O=[F,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],P=[F,"abstract,add,alias,as,ascending,async,await,base,bool,by,byte,checked,decimal,delegate,descending,dynamic,event,finally,fixed,foreach,from,get,global,group,implicit,in,interface,internal,into,is,join,let,lock,null,object,out,override,orderby,params,partial,readonly,ref,remove,sbyte,sealed,select,set,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,value,var,virtual,where,yield"], 36 | F=[F,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],Q=[C,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],R=[C,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],C=[C,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"], 37 | S=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,W=/\S/,X=y({keywords:[H,P,O,F,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",Q,R,C],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),I={};t(X,["default-code"]);t(G([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),"default-markup htm html mxml xhtml xml xsl".split(" "));t(G([["pln",/^[\s]+/,null," \t\r\n"],["atv",/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null, 39 | "\"'"]],[["tag",/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],["pun",/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);t(G([],[["atv",/^[\s\S]+/]]),["uq.val"]);t(y({keywords:H, 40 | hashComments:!0,cStyleComments:!0,types:S}),"c cc cpp cxx cyc m".split(" "));t(y({keywords:"null,true,false"}),["json"]);t(y({keywords:P,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:S}),["cs"]);t(y({keywords:O,cStyleComments:!0}),["java"]);t(y({keywords:C,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]);t(y({keywords:Q,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]);t(y({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END", 41 | hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]);t(y({keywords:R,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]);t(y({keywords:F,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]);t(y({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0, 42 | regexLiterals:!0}),["coffee"]);t(G([],[["str",/^[\s\S]+/]]),["regex"]);var Y=E.PR={createSimpleLexer:G,registerLangHandler:t,sourceDecorator:y,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ",prettyPrintOne:E.prettyPrintOne=function(a,d,f){f=f||!1;d=d||null;var b=document.createElement("div");b.innerHTML="
    "+a+"
    "; 43 | b=b.firstChild;f&&L(b,f,!0);M({j:d,m:f,h:b,l:1,a:null,i:null,c:null,g:null});return b.innerHTML},prettyPrint:E.prettyPrint=function(a,d){function f(){for(var b=E.PR_SHOULD_USE_CONTINUATION?c.now()+250:Infinity;p