Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jaywcjlove/tsbb
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.0.3
Choose a base ref
...
head repository: jaywcjlove/tsbb
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.0.4
Choose a head ref
  • 7 commits
  • 22 files changed
  • 3 contributors

Commits on Sep 2, 2021

  1. fix(deps): update dependency recursive-readdir-files to v1.1.0 (#260)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Sep 2, 2021
    Copy the full SHA
    217d46b View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    targos Michaël Zasso
    Copy the full SHA
    a984882 View commit details
  3. fix(deps): update dependency create-kkt to v2.3.0 (#261)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Sep 2, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    targos Michaël Zasso
    Copy the full SHA
    a7f0a76 View commit details

Commits on Sep 3, 2021

  1. fix(deps): update babel monorepo to v7.15.4 (#240)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Sep 3, 2021
    Copy the full SHA
    804fdef View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    marco-ippolito Marco Ippolito
    Copy the full SHA
    d421ab7 View commit details
  3. released v3.0.4

    jaywcjlove committed Sep 3, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    marco-ippolito Marco Ippolito
    Copy the full SHA
    af5e7ad View commit details
  4. Copy the full SHA
    c9377fc View commit details
4 changes: 2 additions & 2 deletions example/basic/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@template/basic",
"private": true,
"version": "3.0.3",
"version": "3.0.4",
"description": "Basic Example.",
"scripts": {
"start": "node lib/index.js",
@@ -17,6 +17,6 @@
"keywords": [],
"license": "MIT",
"devDependencies": {
"tsbb": "^3.0.3"
"tsbb": "^3.0.4"
}
}
1 change: 1 addition & 0 deletions example/basic/src/index.ts
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ import { test } from './utils/Test';

class Test {
constructor() {}
public a: string = 'A';
count() {
return 10;
}
9 changes: 5 additions & 4 deletions example/basic/tsconfig.json
Original file line number Diff line number Diff line change
@@ -3,16 +3,17 @@
"module": "commonjs",
"esModuleInterop": true,
"declaration": true,
"target": "ES2017",
"target": "es2017",
"noImplicitAny": true,
"resolveJsonModule": true,
"strict": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"strict": false,
"skipLibCheck": true,
"outDir": "lib",
"baseUrl": "."
},
"include": ["src/**/*"],
"exclude": ["lib", "esm"]
"include": ["src/**/*"]
}
4 changes: 2 additions & 2 deletions example/express-typeorm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@template/express-typeorm",
"version": "3.0.3",
"version": "3.0.4",
"private": true,
"description": "Express Typeorm Example.",
"scripts": {
@@ -35,7 +35,7 @@
"nodemon": "2.0.12",
"ts-node": "10.2.1",
"ts-node-dev": "1.1.8",
"tsbb": "^3.0.3"
"tsbb": "^3.0.4"
},
"dependencies": {
"compression": "1.7.4",
4 changes: 2 additions & 2 deletions example/express/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@template/express",
"version": "3.0.3",
"version": "3.0.4",
"private": true,
"description": "Express Example.",
"scripts": {
@@ -33,7 +33,7 @@
"@types/http-errors": "1.8.1",
"nodemon": "2.0.12",
"ts-node-dev": "1.1.8",
"tsbb": "^3.0.3"
"tsbb": "^3.0.4"
},
"dependencies": {
"compression": "1.7.4",
6 changes: 3 additions & 3 deletions example/hapi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@template/hapi",
"version": "3.0.3",
"version": "3.0.4",
"private": true,
"description": "hapi Example.",
"main": "index.js",
@@ -30,10 +30,10 @@
"devDependencies": {
"@types/hapi__hapi": "20.0.9",
"nodemon": "2.0.12",
"tsbb": "^3.0.3"
"tsbb": "^3.0.4"
},
"dependencies": {
"@babel/runtime": "7.15.3",
"@babel/runtime": "7.15.4",
"@hapi/hapi": "20.1.5"
}
}
4 changes: 2 additions & 2 deletions example/koa/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@template/koa",
"version": "3.0.3",
"version": "3.0.4",
"private": true,
"description": "Koa Example",
"scripts": {
@@ -28,7 +28,7 @@
"devDependencies": {
"@types/koa": "2.13.4",
"nodemon": "2.0.12",
"tsbb": "^3.0.3"
"tsbb": "^3.0.4"
},
"dependencies": {
"koa": "2.13.1"
9 changes: 3 additions & 6 deletions example/react-component-tsx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@template/react-component-tsx",
"version": "3.0.3",
"version": "3.0.4",
"description": "React Component Example for TypeScript.",
"private": true,
"main": "lib/index.js",
@@ -35,11 +35,8 @@
"react": ">=16.9.0",
"react-dom": ">=16.9.0"
},
"dependencies": {
"prop-types": "15.7.2"
},
"devDependencies": {
"@babel/runtime": "7.15.3",
"@babel/runtime": "7.15.4",
"@kkt/less-modules": "6.11.0",
"@kkt/raw-modules": "6.11.0",
"@kkt/scope-plugin-options": "6.11.0",
@@ -53,7 +50,7 @@
"prettier": "2.3.2",
"react": "17.0.2",
"react-dom": "17.0.2",
"tsbb": "^3.0.3"
"tsbb": "^3.0.4"
},
"eslintConfig": {
"extends": [
72 changes: 23 additions & 49 deletions example/react-component-tsx/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import PropTypes from 'prop-types';
import './style/index.less';

export interface ButtonProps {
@@ -15,53 +14,28 @@ export interface ButtonProps {
children?: React.ReactNode;
htmlType?: React.ButtonHTMLAttributes<HTMLButtonElement>['type'];
}
export default function Button(props: ButtonProps = {}) {
const { prefixCls, type, size, active, disabled, block, basic, className, loading, children, htmlType, ...others } =
props;

const cls = [
className,
prefixCls,
size ? `${prefixCls}-${size}` : false,
type ? `${prefixCls}-${type}` : false,
basic ? `${prefixCls}-basic` : false,
loading ? `${prefixCls}-loading` : false,
disabled || loading ? 'disabled' : false,
active ? 'active' : false,
block ? 'block' : false,
]
.filter(Boolean)
.join(' ');
return (
<button {...others} disabled={disabled || loading} type={htmlType} className={cls}>
{children &&
React.Children.map(children, (child) => {
if (React.isValidElement(child)) return child;
return <span> {child} </span>;
})}
</button>
);
export default class Button extends React.PureComponent<ButtonProps> {
public static defaultProps: ButtonProps = {
type: 'light',
prefixCls: 'w-btn',
size: 'default',
htmlType: 'button',
};
render() {
const { prefixCls, className, children, type, htmlType, size } = this.props;
const cls = [className, prefixCls, size ? `${prefixCls}-${size}` : false, type ? `${prefixCls}-${type}` : false]
.filter(Boolean)
.join(' ');
return (
<button type={htmlType} className={cls}>
{children &&
React.Children.map(children, (child) => {
if (!child) return child;
if (React.isValidElement(child)) return child;
return <span>{child}</span>;
})}
</button>
);
}
}

Button.defaultProps = {
prefixCls: 'w-btn',
disabled: false,
active: false,
loading: false,
block: false,
basic: false,
htmlType: 'button',
type: 'light',
size: 'default',
};
Button.propTypes = {
prefixCls: PropTypes.string,
loading: PropTypes.bool,
disabled: PropTypes.bool,
block: PropTypes.bool,
active: PropTypes.bool,
basic: PropTypes.bool,
htmlType: PropTypes.string,
type: PropTypes.oneOf(['primary', 'success', 'warning', 'danger', 'light', 'dark', 'link']),
size: PropTypes.oneOf(['large', 'default', 'small']),
};
2 changes: 1 addition & 1 deletion example/react-component-tsx/tsconfig.json
Original file line number Diff line number Diff line change
@@ -18,5 +18,5 @@
"moduleResolution": "node",
"noEmit": true
},
"include": ["src", "react-app-env.d.ts"]
"include": ["src"]
}
40 changes: 0 additions & 40 deletions example/react-component/.babelrc

This file was deleted.

6 changes: 3 additions & 3 deletions example/react-component/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@template/react-component",
"version": "3.0.3",
"version": "3.0.4",
"private": true,
"description": "React Component Example.",
"scripts": {
@@ -33,7 +33,7 @@
"devDependencies": {
"@babel/plugin-transform-modules-umd": "7.14.5",
"@babel/plugin-transform-runtime": "7.15.0",
"@babel/runtime": "7.15.3",
"@babel/runtime": "7.15.4",
"@parcel/transformer-less": "2.0.0-rc.0",
"@tsbb/babel-preset-tsbb": "1.14.2",
"babel-plugin-transform-remove-imports": "1.5.5",
@@ -42,7 +42,7 @@
"less": "4.1.1",
"parcel": "2.0.0-rc.0",
"react-test-renderer": "17.0.2",
"tsbb": "^3.0.3"
"tsbb": "^3.0.4"
},
"dependencies": {
"@parcel/transformer-react-refresh-wrap": "2.0.0-alpha.3",
4 changes: 2 additions & 2 deletions example/transform-typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@template/transform-typescript",
"private": true,
"version": "3.0.3",
"version": "3.0.4",
"description": "Transform Typescript Example.",
"scripts": {
"start": "node lib/index.js",
@@ -18,6 +18,6 @@
"keywords": [],
"license": "MIT",
"devDependencies": {
"tsbb": "^3.0.3"
"tsbb": "^3.0.4"
}
}
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "3.0.3",
"version": "3.0.4",
"packages": [
"example/*",
"packages/*"
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
"private": true,
"license": "MIT",
"scripts": {
"prepare": "husky install",
"build:basic": "lerna exec \"npm run build\" --scope @template/basic",
"watch:basic": "lerna exec \"npm run watch\" --scope @template/basic",
"test:basic": "lerna exec \"npm run coverage\" --scope @template/basic",
@@ -31,11 +32,6 @@
"hoist": "lerna bootstrap --hoist",
"publish": "lerna publish from-package"
},
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged"
}
},
"dependencies": {
"husky": "7.0.2",
"lerna": "4.0.0",
1 change: 1 addition & 0 deletions packages/create-tsbb/README.md
Original file line number Diff line number Diff line change
@@ -45,6 +45,7 @@ Usage: create-tsbb <app-name> [options] [--help|h]
Options:
--version, -v Show version number
--help, -h Displays help information.
--output, -o Output directory.
--example, -e Example from: https://jaywcjlove.github.io/tsbb , default: "basic"
--force, -f Overwrite target directory if it exists. default: false
--path, -p Specify the download target git address. default: "https://jaywcjlove.github.io/tsbb"
6 changes: 3 additions & 3 deletions packages/create-tsbb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-tsbb",
"version": "3.0.3",
"version": "3.0.4",
"description": "Creates a TSBB application using the command line.",
"homepage": "https://jaywcjlove.github.io/tsbb",
"author": "Kenny Wong <wowohoo@qq.com> (https://github.com/jaywcjlove)",
@@ -36,9 +36,9 @@
"frontend"
],
"devDependencies": {
"tsbb": "^3.0.3"
"tsbb": "^3.0.4"
},
"dependencies": {
"create-kkt": "2.1.6"
"create-kkt": "2.3.0"
}
}
20 changes: 16 additions & 4 deletions packages/create-tsbb/src/cli.ts
Original file line number Diff line number Diff line change
@@ -5,12 +5,26 @@ import { create } from 'create-kkt';

async function run(): Promise<void> {
try {
const argvs = minimist(process.argv.slice(2));
const argvs = minimist(process.argv.slice(2), {
alias: {
output: 'o',
force: 'f',
path: 'p',
example: 'e',
},
default: {
path: 'http://jaywcjlove.github.io/tsbb/',
output: '.',
force: false,
example: 'basic',
},
});
if (argvs.h || argvs.help) {
console.log('\n Usage: create-tsbb <app-name> [options] [--help|h]');
console.log('\n Options:');
console.log(' --version, -v', 'Show version number');
console.log(' --help, -h', 'Displays help information.');
console.log(' --output, -o', 'Output directory.');
console.log(
' --example, -e',
'Example from: \x1b[34mhttp://jaywcjlove.github.io/tsbb/ \x1b[0m , default: "basic"',
@@ -31,9 +45,7 @@ async function run(): Promise<void> {
return;
}
argvs.appName = argvs._[0];
argvs.path = argvs.p = argvs.path || argvs.p || 'http://jaywcjlove.github.io/tsbb/';
argvs.force = argvs.f = argvs.force || argvs.f || false;
argvs.example = argvs.e = (argvs.example || argvs.e || 'basic').toLocaleLowerCase();
argvs.example = argvs.e = String(argvs.example).toLocaleLowerCase();
create(argvs, exampleHelp);
} catch (error) {
console.log(`\x1b[31m${error.message}\x1b[0m`);
10 changes: 5 additions & 5 deletions packages/tsbb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tsbb",
"version": "3.0.3",
"version": "3.0.4",
"description": "TSBB is a zero-config CLI that helps you develop, test, and publish modern TypeScript project.",
"author": "kenny wang <wowohoo@qq.com>",
"license": "MIT",
@@ -25,12 +25,12 @@
"node.js"
],
"dependencies": {
"@babel/core": "7.15.0",
"@babel/core": "7.15.4",
"@babel/plugin-proposal-class-properties": "7.14.5",
"@babel/plugin-proposal-decorators": "7.14.5",
"@babel/plugin-proposal-decorators": "7.15.4",
"@babel/plugin-proposal-export-default-from": "7.14.5",
"@babel/plugin-transform-runtime": "7.15.0",
"@babel/preset-env": "7.15.0",
"@babel/preset-env": "7.15.4",
"@babel/preset-react": "7.14.5",
"@babel/preset-typescript": "7.15.0",
"@types/babel__core": "7.1.15",
@@ -53,7 +53,7 @@
"identity-obj-proxy": "3.0.0",
"jest": "27.1.0",
"micromatch": "4.0.4",
"recursive-readdir-files": "1.0.3",
"recursive-readdir-files": "1.1.0",
"semver": "7.3.5",
"typescript": "4.4.2",
"yargs-parser": "20.2.9"
48 changes: 25 additions & 23 deletions packages/tsbb/src/utils/compile.ts
Original file line number Diff line number Diff line change
@@ -23,29 +23,28 @@ export async function compile(
const dirToFiles = await recursiveReaddirFiles(path.dirname(entry), {
exclude: /(tsconfig.json|.(test|spec).(ts|tsx|js|jsx))$/,
});
await Promise.all(
dirToFiles.map(async (item) => {
if (disableBabel) {
return;
}
if (cjs) {
const cjsPath = item.path.replace(entryDir, cjs);
if (isMatch(item.path, ['**/*.[jt]s?(x)']) && !isMatch(item.path, ['**/?(*.)+(spec|test).[jt]s?(x)', '**/*.d.ts'])) {
transform(item.path, { entryDir, cjs, ...other });
} else {
copyFiles(item.path, cjsPath);
if (!disableBabel) {
await Promise.all(
dirToFiles.map(async (item) => {
if (cjs) {
const cjsPath = item.path.replace(entryDir, cjs);
if (isMatch(item.path, ['**/*.[jt]s?(x)']) && !isMatch(item.path, ['**/?(*.)+(spec|test).[jt]s?(x)'])) {
transform(item.path, { entryDir, cjs, ...other });
} else {
copyFiles(item.path, cjsPath);
}
}
}
if (esm) {
const esmPath = item.path.replace(entryDir, esm);
if (isMatch(item.path, ['**/*.[jt]s?(x)']) && !isMatch(item.path, ['**/?(*.)+(spec|test).[jt]s?(x)', '**/*.d.ts'])) {
transform(item.path, { entryDir, esm, ...other });
} else {
copyFiles(item.path, esmPath);
if (esm) {
const esmPath = item.path.replace(entryDir, esm);
if (isMatch(item.path, ['**/*.[jt]s?(x)']) && !isMatch(item.path, ['**/?(*.)+(spec|test).[jt]s?(x)'])) {
transform(item.path, { entryDir, esm, ...other });
} else {
copyFiles(item.path, esmPath);
}
}
}
}),
);
}),
);
}

// Create a Program with an in-memory emit
const createdFiles: Record<string, string> = {};
@@ -57,11 +56,14 @@ export async function compile(

const host = ts.createCompilerHost(tsOptions, true);
// ts.getParsedCommandLineOfConfigFile('', tsOptions, host)
const files: string[] = [];
host.readFile = (file) => {
const result = ts.sys.readFile(file);
if (!/node_modules/.test(file)) {
files.push(file);
// const output = path.resolve(tsOptions.outDir || cjs, path.relative(entryDir, file));
// const outputLib = path.relative(process.cwd(), output);
// if (/.d.ts$/.test(outputLib)) {
// createdFiles[outputLib] = result;
// }
}
return result;
};
8 changes: 4 additions & 4 deletions packages/tsbb/src/utils/watchCompile.ts
Original file line number Diff line number Diff line change
@@ -30,18 +30,18 @@ export async function watchCompile(
watcher.on('change', async (filepath) => {
if (esm) {
const output = filepath.replace(entryDir, esm);
if (!disableBabel && isMatch(output, ['**/*.[jt]s?(x)']) && !isMatch(output, ['**/?(*.)+(spec|test).[jt]s?(x)'])) {
if (!disableBabel && isMatch(output, ['**/*.[jt]s?(x)']) && !isMatch(output, ['**/?(*.)+(spec|test).[jt]s?(x)', '**/?(*.)+d.ts'])) {
transform(filepath, { entryDir, esm, ...other });
} else if (!isMatch(output, ['**/?(*.)+(spec|test).[jt]s?(x)', 'tsconfig.json'])) {
} else if (!isMatch(output, ['**/?(*.)+(spec|test).[jt]s?(x)', 'tsconfig.json', '**/?(*.)+d.ts'])) {
const result = ts.sys.readFile(filepath);
outputFiles(output, result);
}
}
if (cjs) {
const output = filepath.replace(entryDir, cjs);
if (!disableBabel && isMatch(output, ['**/*.[jt]s?(x)']) && !isMatch(output, ['**/?(*.)+(spec|test).[jt]s?(x)'])) {
if (!disableBabel && isMatch(output, ['**/*.[jt]s?(x)']) && !isMatch(output, ['**/?(*.)+(spec|test).[jt]s?(x)', '**/?(*.)+d.ts'])) {
transform(filepath, { entryDir, cjs, ...other });
} else if (!isMatch(output, ['**/?(*.)+(spec|test).[jt]s?(x)', 'tsconfig.json'])) {
} else if (!isMatch(output, ['**/?(*.)+(spec|test).[jt]s?(x)', 'tsconfig.json', '**/?(*.)+d.ts'])) {
const result = ts.sys.readFile(filepath);
outputFiles(output, result);
}