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: v4.0.8
Choose a base ref
...
head repository: jaywcjlove/tsbb
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4.1.0
Choose a head ref
  • 3 commits
  • 24 files changed
  • 1 contributor

Commits on Mar 31, 2023

  1. Copy the full SHA
    da2c83a View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    targos Michaël Zasso
    Copy the full SHA
    a324d26 View commit details
  3. released v4.1.0

    jaywcjlove committed Mar 31, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    targos Michaël Zasso
    Copy the full SHA
    9636588 View commit details
6 changes: 3 additions & 3 deletions examples/babel-transform-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@template/babel-transform-ts",
"private": true,
"version": "4.0.8",
"version": "4.1.0",
"description": "Transform Typescript Example.",
"scripts": {
"watch": "tsbb watch \"src/**/*.ts\" --use-babel --no-esm",
"build": "tsbb build \"src/**/*.ts\" --use-babel --no-esm",
"build": "tsbb build \"src/**/*.ts\" --use-babel --no-esm --bail",
"test": "tsbb test",
"coverage": "tsbb test --coverage --bail"
},
@@ -17,6 +17,6 @@
"keywords": [],
"license": "MIT",
"devDependencies": {
"tsbb": "4.0.8"
"tsbb": "4.1.0"
}
}
6 changes: 3 additions & 3 deletions examples/basic/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@template/basic",
"version": "4.0.8",
"version": "4.1.0",
"description": "Basic Example.",
"license": "MIT",
"private": true,
"scripts": {
"start": "node lib/index.js",
"watch": "tsbb watch",
"build": "tsbb build",
"build": "tsbb build --bail",
"test": "tsbb test",
"coverage": "tsbb test --coverage --bail"
},
@@ -17,6 +17,6 @@
},
"keywords": [],
"devDependencies": {
"tsbb": "4.0.8"
"tsbb": "4.1.0"
}
}
6 changes: 3 additions & 3 deletions examples/express/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "@template/express",
"version": "4.0.8",
"version": "4.1.0",
"private": true,
"description": "Express Example.",
"scripts": {
"start": "npm run build && node lib/app.js",
"dev:ts": "ts-node-dev --inspect -- src/app.ts",
"dev": "npm run build && nodemon --inspect lib/app.js",
"watch": "tsbb watch",
"build": "tsbb build",
"build": "tsbb build --bail",
"test": "tsbb test",
"coverage": "tsbb test --coverage --bail"
},
@@ -31,7 +31,7 @@
"@types/http-errors": "~2.0.1",
"nodemon": "~2.0.22",
"ts-node-dev": "~2.0.0",
"tsbb": "4.0.8"
"tsbb": "4.1.0"
},
"dependencies": {
"compression": "~1.7.4",
6 changes: 3 additions & 3 deletions examples/hapi/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "@template/hapi",
"version": "4.0.8",
"version": "4.1.0",
"private": true,
"description": "hapi Example.",
"main": "index.js",
"scripts": {
"start": "npm run build && node lib/app.js",
"dev": "nodemon --inspect lib/app.js",
"watch": "tsbb watch",
"build": "tsbb build",
"build": "tsbb build --bail",
"test": "tsbb test",
"coverage": "tsbb test --coverage --bail"
},
@@ -29,7 +29,7 @@
},
"devDependencies": {
"nodemon": "~2.0.22",
"tsbb": "4.0.8"
"tsbb": "4.1.0"
},
"dependencies": {
"@hapi/hapi": "^21.3.0"
6 changes: 3 additions & 3 deletions examples/koa/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@template/koa",
"version": "4.0.8",
"version": "4.1.0",
"private": true,
"description": "Koa Example",
"scripts": {
"start": "npm run build && node lib/app.js",
"dev": "nodemon --inspect lib/app.js",
"watch": "tsbb watch --entry ./src/app.ts --no-esm",
"build": "tsbb build --entry ./src/app.ts --no-esm",
"build": "tsbb build --entry ./src/app.ts --no-esm --bail",
"test": "tsbb test",
"coverage": "tsbb test --coverage --bail"
},
@@ -28,7 +28,7 @@
"devDependencies": {
"@types/koa": "^2.13.5",
"nodemon": "~2.0.22",
"tsbb": "4.0.8"
"tsbb": "4.1.0"
},
"dependencies": {
"koa": "^2.14.1"
6 changes: 3 additions & 3 deletions examples/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": "4.0.8",
"version": "4.1.0",
"description": "React Component Example for TypeScript.",
"private": true,
"main": "lib/index.js",
@@ -9,7 +9,7 @@
"doc": "kkt build --app-src ./website",
"start": "kkt start --app-src ./website",
"watch": "tsbb watch src/*.{tsx,ts} --useBabel & npm run css:watch",
"build": "tsbb build src/*.{tsx,ts} --useBabel && npm run css:build",
"build": "tsbb build src/*.{tsx,ts} --useBabel --bail && npm run css:build",
"css:build": "compile-less -d src -o esm",
"css:watch": "compile-less -d src -o esm --watch",
"css:build:dist": "compile-less -d src --combine lib/dist.css --rm-global",
@@ -51,7 +51,7 @@
"prettier": "^2.8.6",
"react": "~18.2.0",
"react-dom": "~18.2.0",
"tsbb": "4.0.8"
"tsbb": "4.1.0"
},
"eslintConfig": {
"extends": [
6 changes: 3 additions & 3 deletions examples/react-component/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@template/react-component",
"version": "4.0.8",
"version": "4.1.0",
"private": true,
"description": "React Component Example.",
"scripts": {
"watch": "tsbb watch src/*.{jsx,js} --useBabel",
"build": "tsbb build src/*.{jsx,js} --useBabel && npm run css:build && npm run css:build:dist",
"build": "tsbb build src/*.{jsx,js} --useBabel --bail && npm run css:build && npm run css:build:dist",
"css:build": "compile-less -d src -o esm",
"css:watch": "compile-less -d src -o esm --watch",
"css:build:dist": "compile-less -d src --combine dist/markdown-editor.css --rm-global",
@@ -43,7 +43,7 @@
"less": "~4.1.3",
"parcel": "~2.8.3",
"react-test-renderer": "~18.2.0",
"tsbb": "4.0.8"
"tsbb": "4.1.0"
},
"dependencies": {
"@parcel/transformer-react-refresh-wrap": "~2.8.3",
6 changes: 3 additions & 3 deletions examples/typenexus/package.json
Original file line number Diff line number Diff line change
@@ -2,13 +2,13 @@
"name": "@template/typenexus",
"private": true,
"type": "module",
"version": "4.0.8",
"version": "4.1.0",
"description": "TypeNexus Example.",
"scripts": {
"start": "npm run build && node dist/main.js",
"dev": "nodemon --inspect dist/main.js",
"watch": "tsbb watch",
"build": "tsbb build",
"build": "tsbb build --bail",
"test": "tsbb test",
"coverage": "tsbb test --coverage --bail"
},
@@ -32,6 +32,6 @@
"supertest": "^6.3.3",
"supertest-session": "^4.1.0",
"ts-node": "^10.9.1",
"tsbb": "4.0.8"
"tsbb": "4.1.0"
}
}
6 changes: 3 additions & 3 deletions examples/umd/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@template/umd",
"private": true,
"version": "4.0.8",
"version": "4.1.0",
"description": "UMD Example.",
"scripts": {
"watch": "tsbb watch",
"build": "tsbb build",
"build": "tsbb build --bail",
"test": "tsbb test",
"coverage": "tsbb test --coverage --bail"
},
@@ -16,6 +16,6 @@
"keywords": [],
"license": "MIT",
"devDependencies": {
"tsbb": "4.0.8"
"tsbb": "4.1.0"
}
}
6 changes: 3 additions & 3 deletions examples/vue/package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"name": "@template/vue",
"private": true,
"version": "4.0.8",
"version": "4.1.0",
"description": "",
"main": "./cjs/index.js",
"module": "./esm/index.js",
"author": "jaywcjlove",
"license": "ISC",
"scripts": {
"watch": "tsbb watch src/*.tsx --use-vue --use-babel --cjs cjs",
"build": "tsbb build src/*.tsx --use-vue --use-babel --cjs cjs"
"build": "tsbb build src/*.tsx --use-vue --use-babel --cjs cjs --bail"
},
"dependencies": {
"vue": "^3.0.0"
},
"devDependencies": {
"tsbb": "4.0.8"
"tsbb": "4.1.0"
}
}
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "4.0.8",
"version": "4.1.0",
"packages": ["examples/*", "packages/*"],
"useWorkspaces": true
}
4 changes: 2 additions & 2 deletions packages/babel/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tsbb/babel",
"version": "4.0.8",
"version": "4.1.0",
"description": "TSBB is a zero-config CLI that helps you develop, test, and publish modern TypeScript project.",
"author": "kenny wang <wowohoo@qq.com>",
"homepage": "https://jaywcjlove.github.io/tsbb",
@@ -38,7 +38,7 @@
"@babel/preset-env": "~7.20.2",
"@babel/preset-react": "~7.18.6",
"@babel/preset-typescript": "~7.21.0",
"@tsbb/typescript": "4.0.8",
"@tsbb/typescript": "4.1.0",
"@types/babel__core": "^7.20.0",
"@types/semver": "~7.3.13",
"@vue/babel-plugin-jsx": "~1.1.1",
35 changes: 32 additions & 3 deletions packages/babel/src/index.ts
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ import { getCjsTransformOption, getESMTransformOption } from './config.js';
export * from './utils.js';

export interface BabelCompileOptions {
watch?: boolean;
/**
* The specified entry file, for example:
* @example
@@ -64,10 +65,15 @@ export interface BabelCompileOptions {
* @default `false`
*/
sourceMaps?: TransformOptions['sourceMaps'];
/**
* Exit the compile as soon as the compile fails(default: true).
* @default `true`
*/
bail?: boolean;
}

export default async function compile(fileName: string, options: BabelCompileOptions = {}) {
const { cjs = 'lib', esm = 'esm', envName, useVue = false } = options;
const { cjs = 'lib', esm = 'esm', envName, useVue = false, bail, watch } = options;
const dt = getOutputPath(fileName, options);
const log = new Log();
log.name();
@@ -89,7 +95,16 @@ export default async function compile(fileName: string, options: BabelCompileOpt
esmBabelOptions.cwd = dt.projectDirectory;

if (typeof esm === 'string') {
transformFile(fileName, dt.esm.path, dt.folderFilePath, dt.projectDirectory, dt.esm.fileName, esmBabelOptions);
transformFile(
fileName,
dt.esm.path,
dt.folderFilePath,
dt.projectDirectory,
dt.esm.fileName,
esmBabelOptions,
bail,
watch,
);
}

let cjsBabelOptions = getCjsTransformOption();
@@ -106,7 +121,16 @@ export default async function compile(fileName: string, options: BabelCompileOpt
cjsBabelOptions.cwd = dt.projectDirectory;

if (typeof cjs === 'string') {
transformFile(fileName, dt.cjs.path, dt.folderFilePath, dt.projectDirectory, dt.cjs.fileName, cjsBabelOptions);
transformFile(
fileName,
dt.cjs.path,
dt.folderFilePath,
dt.projectDirectory,
dt.cjs.fileName,
cjsBabelOptions,
bail,
watch,
);
}
}

@@ -117,6 +141,8 @@ function transformFile(
projectDirectory: string,
outFileName: string,
options: TransformOptions,
bail?: boolean,
isWatch?: boolean,
) {
const log = new Log();
log.name();
@@ -149,5 +175,8 @@ function transformFile(
} else {
log.icon('\n🚨').error(`\x1b[33;1m ${JSON.stringify(error)}\x1b[0m\n`);
}
if (bail && isWatch !== true) {
process.exitCode = 1;
}
});
}
8 changes: 4 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tsbb/core",
"version": "4.0.8",
"version": "4.1.0",
"description": "TSBB is a zero-config CLI that helps you develop, test, and publish modern TypeScript project.",
"author": "kenny wang <wowohoo@qq.com>",
"homepage": "https://jaywcjlove.github.io/tsbb",
@@ -32,9 +32,9 @@
"node": ">=16.0.0"
},
"dependencies": {
"@tsbb/babel": "4.0.8",
"@tsbb/jest": "4.0.8",
"@tsbb/typescript": "4.0.8",
"@tsbb/babel": "4.1.0",
"@tsbb/jest": "4.1.0",
"@tsbb/typescript": "4.1.0",
"@types/fs-extra": "^11.0.1",
"chokidar": "~3.5.3",
"fs-extra": "^11.1.1",
4 changes: 3 additions & 1 deletion packages/core/src/compile.ts
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import { watcherCopyFiles } from './watcher/copyFiles.js';

export interface CompileOptions extends BabelCompileOptions {
watch?: boolean;
bail?: boolean;
build?: boolean;
entry?: string[];
[key: string]: any;
@@ -13,6 +14,7 @@ export interface CompileOptions extends BabelCompileOptions {
export async function compile(options: CompileOptions = {}) {
if (!options.useBabel) {
return tsCompile({
bail: options.bail,
watch: options.watch,
onCopyFiles: watcherCopyFiles,
});
@@ -31,7 +33,7 @@ export async function compile(options: CompileOptions = {}) {
];
(options.entry || []).forEach((fileNames) => err.push(` \x1b[35;1m${fileNames}\x1b[0m`));
!options.entry?.length &&
err.push('\x1b[33;1mNo files were indexed. Please check your command line arguments.\x1b[0m');
err.push(' \x1b[33;1mNo files were indexed. Please check your command line arguments.\x1b[0m');
if (process.platform === 'win32') {
err.push('\n Please note that on \x1b[33;1mWindows\x1b[0m platform, double(") quotes should be used to ');
err.push(" index file parameters instead of single(') quotes.\n");
11 changes: 6 additions & 5 deletions packages/core/src/helpStr.ts
Original file line number Diff line number Diff line change
@@ -9,11 +9,12 @@ Usage:\x1b[34;1m tsbb\x1b[0m <command>
Options:[build|watch]
\x1b[35;1m--use-babel\x1b[0m Use Babel.(works in babel)
\x1b[35;1m--source-maps\x1b[0m Enables the generation of sourcemap files.(works in babel)
\x1b[35;1m--env-name\x1b[0m The current active environment used during configuration loading.(works in babel)
\x1b[35;1m--esm\x1b[0m Output "esm" directory.(works in babel)
\x1b[35;1m--cjs\x1b[0m Output "cjs" directory.(works in babel)
\x1b[35;1m--bail\x1b[0m Exit the compile as soon as the compile fails(default: true).
\x1b[35;1m--use-babel\x1b[0m Use Babel.(works in babel)
\x1b[35;1m--source-maps\x1b[0m Enables the generation of sourcemap files.(works in babel)
\x1b[35;1m--env-name\x1b[0m The current active environment used during configuration loading.(works in babel)
\x1b[35;1m--esm\x1b[0m Output "esm" directory.(works in babel)
\x1b[35;1m--cjs\x1b[0m Output "cjs" directory.(works in babel)
Options:
4 changes: 4 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -20,6 +20,10 @@ export async function tsbb() {
sourceMaps: {
default: false,
},
bail: {
type: 'boolean',
default: true,
},
},
});
const flags: CamelCase<TypedFlags<CompileOptions>> & Record<string, unknown> = cli.flags;
1 change: 1 addition & 0 deletions packages/core/src/watcher/babelTransform.ts
Original file line number Diff line number Diff line change
@@ -71,6 +71,7 @@ export function babelTransform(options: CompileOptions = {}) {
const tsConfigPath = findConfigFile();
if (tsConfigPath) {
tsCompile({
bail: options.bail,
emitDeclarationOnly: true,
watch: options.watch,
isCopyFiles: false,
4 changes: 2 additions & 2 deletions packages/create-tsbb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-tsbb",
"version": "4.0.8",
"version": "4.1.0",
"description": "Creates a TSBB application using the command line.",
"homepage": "https://jaywcjlove.github.io/tsbb/create-tsbb.html",
"author": "Kenny Wong <wowohoo@qq.com> (https://github.com/jaywcjlove)",
@@ -55,6 +55,6 @@
},
"devDependencies": {
"cpy": "^9.0.1",
"tsbb": "4.0.8"
"tsbb": "4.1.0"
}
}
2 changes: 1 addition & 1 deletion packages/jest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tsbb/jest",
"version": "4.0.8",
"version": "4.1.0",
"description": "TSBB is a zero-config CLI that helps you develop, test, and publish modern TypeScript project.",
"author": "kenny wang <wowohoo@qq.com>",
"homepage": "https://jaywcjlove.github.io/tsbb",
1 change: 1 addition & 0 deletions packages/tsbb/README.md
Original file line number Diff line number Diff line change
@@ -180,6 +180,7 @@ Commands:

Options:[build|watch]

--bail Exit the compile as soon as the compile fails(default: true).
--use-babel Use Babel.(works in babel)
--source-maps Enables the generation of sourcemap files.(works in babel)
--env-name The current active environment used during configuration loading.(works in babel)
4 changes: 2 additions & 2 deletions packages/tsbb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tsbb",
"version": "4.0.8",
"version": "4.1.0",
"description": "TSBB is a zero-config CLI that helps you develop, test, and publish modern TypeScript project.",
"author": "kenny wang <wowohoo@qq.com>",
"homepage": "https://jaywcjlove.github.io/tsbb",
@@ -33,6 +33,6 @@
"node": ">=16.0.0"
},
"dependencies": {
"@tsbb/core": "4.0.8"
"@tsbb/core": "4.1.0"
}
}
2 changes: 1 addition & 1 deletion packages/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tsbb/typescript",
"version": "4.0.8",
"version": "4.1.0",
"description": "TSBB is a zero-config CLI that helps you develop, test, and publish modern TypeScript project.",
"author": "kenny wang <wowohoo@qq.com>",
"homepage": "https://jaywcjlove.github.io/tsbb",
11 changes: 10 additions & 1 deletion packages/typescript/src/index.ts
Original file line number Diff line number Diff line change
@@ -39,6 +39,11 @@ export interface CopyFilesOptions {

export interface TsCompileOptions {
watch?: boolean;
/**
* Exit the compile as soon as the compile fails(default: true).
* @default `true`
*/
bail?: boolean;
emitDeclarationOnly?: boolean;
/**
* @default true
@@ -52,7 +57,7 @@ export interface TsCompileOptions {
export const findConfigFile = () => ts.findConfigFile('.', ts.sys.fileExists, 'tsconfig.json');

export default async function compile(options: TsCompileOptions = {}) {
const { isCopyFiles = true, onWriteFile, onCopyFiles } = options;
const { isCopyFiles = true, onWriteFile, onCopyFiles, bail } = options;
const tsConfigPath = findConfigFile();
const log = new Log();
if (!tsConfigPath) {
@@ -147,6 +152,10 @@ export default async function compile(options: TsCompileOptions = {}) {
const emitResult = program.emit();
const diagnostics = ts.getPreEmitDiagnostics(program);
diagnostics.forEach(reportDiagnostic);
if (bail && diagnostics.length) {
diagnostics.forEach(reportDiagnostic);
process.exitCode = 1;
}
if (isCopyFiles && onCopyFiles) {
await onCopyFiles(rootDirs, { isWatch: options.watch, outputDir, currentDir, rootDirsRelative });
}