Skip to content

Commit 7253da3

Browse files
committedSep 7, 2021
chore: add umd example.
1 parent 30e44e7 commit 7253da3

File tree

13 files changed

+272
-15
lines changed

13 files changed

+272
-15
lines changed
 

‎.github/workflows/ci.dev.yml

+4
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,7 @@ jobs:
6161
- name: example @example/transform-typescript
6262
working-directory: example/transform-typescript
6363
run: npm run build
64+
65+
- name: example @example/umd
66+
working-directory: example/umd
67+
run: npm run build

‎.github/workflows/ci.yml

+29-15
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ jobs:
3333
working-directory: example/express
3434
run: npm run build
3535

36-
- name: example @example/hapi
37-
working-directory: example/hapi
38-
run: npm run build
39-
4036
- name: example @example/express-typeorm
4137
working-directory: example/express-typeorm
4238
run: npm run build
4339

40+
- name: example @example/hapi
41+
working-directory: example/hapi
42+
run: npm run build
43+
4444
- name: example @example/koa
4545
working-directory: example/koa
4646
run: npm run build
@@ -61,9 +61,13 @@ jobs:
6161
working-directory: example/transform-typescript
6262
run: npm run build
6363

64+
- name: example @example/umd
65+
working-directory: example/umd
66+
run: npm run build
67+
6468
- name: Is a tag created auto?
6569
id: create_tag
66-
uses: jaywcjlove/create-tag-action@v1.2.0
70+
uses: jaywcjlove/create-tag-action@v1.2.1
6771
with:
6872
token: ${{ secrets.GITHUB_TOKEN }}
6973
package-path: ./packages/tsbb/package.json
@@ -99,39 +103,49 @@ jobs:
99103
- run: mkdir -p zip
100104

101105
- name: Compress basic Example.
102-
run: zip -r -y basic.zip . -x "node_modules/*" -x "build/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
106+
run: zip -r -y basic.zip . -x "node_modules/*" -x "build/*" -x "lib/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
103107
working-directory: example/basic
104108
- run: cp -rp example/basic/basic.zip ./zip
105109

106110
- name: Compress express Example.
107-
run: zip -r -y express.zip . -x "node_modules/*" -x "build/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
111+
run: zip -r -y express.zip . -x "node_modules/*" -x "build/*" -x "lib/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
108112
working-directory: example/express
109113
- run: cp -rp example/express/express.zip ./zip
110114

115+
- name: Compress express-typeorm Example.
116+
run: zip -r -y express-typeorm.zip . -x "node_modules/*" -x "build/*" -x "lib/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
117+
working-directory: example/express-typeorm
118+
- run: cp -rp example/express-typeorm/express-typeorm.zip ./zip
119+
111120
- name: Compress hapi Example.
112-
run: zip -r -y hapi.zip . -x "node_modules/*" -x "build/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
121+
run: zip -r -y hapi.zip . -x "node_modules/*" -x "build/*" -x "lib/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
113122
working-directory: example/hapi
114123
- run: cp -rp example/hapi/hapi.zip ./zip
115124

116125
- name: Compress koa Example.
117-
run: zip -r -y koa.zip . -x "node_modules/*" -x "build/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
126+
run: zip -r -y koa.zip . -x "node_modules/*" -x "build/*" -x "lib/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
118127
working-directory: example/koa
119128
- run: cp -rp example/koa/koa.zip ./zip
120129

121130
- name: Compress react-component Example.
122-
run: zip -r -y react-component.zip . -x "node_modules/*" -x "build/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
131+
run: zip -r -y react-component.zip . -x "node_modules/*" -x "build/*" -x "lib/*" -x "esm/*" -x "dist/*" -x "doc/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
123132
working-directory: example/react-component
124133
- run: cp -rp example/react-component/react-component.zip ./zip
125134

126135
- name: Compress react-component-tsx Example.
127-
run: zip -r -y react-component-tsx.zip . -x "node_modules/*" -x "build/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
136+
run: zip -r -y react-component-tsx.zip . -x "node_modules/*" -x "build/*" -x "lib/*" -x "esm/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
128137
working-directory: example/react-component-tsx
129138
- run: cp -rp example/react-component-tsx/react-component-tsx.zip ./zip
130139

131-
- name: Compress express-typeorm Example.
132-
run: zip -r -y express-typeorm.zip . -x "node_modules/*" -x "build/*.sqlite" -x "build/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
133-
working-directory: example/express-typeorm
134-
- run: cp -rp example/express-typeorm/express-typeorm.zip ./zip
140+
- name: Compress transform-typescript Example.
141+
run: zip -r -y transform-typescript.zip . -x "node_modules/*" -x "build/*" -x "lib/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
142+
working-directory: example/transform-typescript
143+
- run: cp -rp example/transform-typescript/transform-typescript.zip ./zip
144+
145+
- name: Compress umd Example.
146+
run: zip -r -y umd.zip . -x "node_modules/*" -x "build/*.sqlite" -x "build/*" -x "lib/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
147+
working-directory: example/umd
148+
- run: cp -rp example/umd/umd.zip ./zip
135149

136150
- name: Compress TSBB Example Download webpage.
137151
working-directory: zip

‎example/umd/.gitignore

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Created by https://www.gitignore.io/api/node
2+
# Edit at https://www.gitignore.io/?templates=node
3+
4+
esm
5+
cjs
6+
lib
7+
package-lock.json
8+
__snapshots__
9+
10+
### Node ###
11+
# Logs
12+
logs
13+
*.log
14+
npm-debug.log*
15+
yarn-debug.log*
16+
yarn-error.log*
17+
lerna-debug.log*
18+
19+
# Diagnostic reports (https://nodejs.org/api/report.html)
20+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
21+
22+
# Runtime data
23+
pids
24+
*.pid
25+
*.seed
26+
*.pid.lock
27+
28+
# Directory for instrumented libs generated by jscoverage/JSCover
29+
lib-cov
30+
31+
# Coverage directory used by tools like istanbul
32+
coverage
33+
34+
# nyc test coverage
35+
.nyc_output
36+
37+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
38+
.grunt
39+
40+
# Bower dependency directory (https://bower.io/)
41+
bower_components
42+
43+
# node-waf configuration
44+
.lock-wscript
45+
46+
# Compiled binary addons (https://nodejs.org/api/addons.html)
47+
build/Release
48+
49+
# Dependency directories
50+
node_modules/
51+
jspm_packages/
52+
53+
# TypeScript v1 declaration files
54+
typings/
55+
56+
# Optional npm cache directory
57+
.npm
58+
59+
# Optional eslint cache
60+
.eslintcache
61+
62+
# Optional REPL history
63+
.node_repl_history
64+
65+
# Output of 'npm pack'
66+
*.tgz
67+
68+
# Yarn Integrity file
69+
.yarn-integrity
70+
71+
# dotenv environment variables file
72+
.env
73+
.env.test
74+
75+
# parcel-bundler cache (https://parceljs.org/)
76+
.cache
77+
78+
# next.js build output
79+
.next
80+
81+
# nuxt.js build output
82+
.nuxt
83+
84+
# vuepress build output
85+
.vuepress/dist
86+
87+
# Serverless directories
88+
.serverless/
89+
90+
# FuseBox cache
91+
.fusebox/
92+
93+
# DynamoDB Local files
94+
.dynamodb/
95+
96+
# End of https://www.gitignore.io/api/node
97+
98+
.DS_Store
99+
.cache
100+
.vscode
101+
.idea
102+
.env
103+
104+
*.bak
105+
*.tem
106+
*.temp
107+
#.swp
108+
*.*~
109+
~*.*
110+
111+
# IDEA
112+
*.iml
113+
*.ipr
114+
*.iws
115+
.idea/

‎example/umd/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
UMD Example
2+
---
3+
4+
## Quick Start
5+
6+
```shell
7+
$ npx create-kkt my-app -e umd
8+
cd my-app
9+
$ npm install
10+
11+
$ npm run watch # Listen compile .ts files.
12+
$ npm run build # compile .ts files.
13+
14+
$ npm run start
15+
```

‎example/umd/package.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "@template/umd",
3+
"private": true,
4+
"version": "3.0.4",
5+
"description": "UMD Example.",
6+
"scripts": {
7+
"watch": "tsbb watch --no-esm --disable-babel",
8+
"build": "tsbb build --no-esm --disable-babel",
9+
"test": "tsbb test",
10+
"coverage": "tsbb test --coverage"
11+
},
12+
"keywords": [],
13+
"license": "MIT",
14+
"devDependencies": {
15+
"tsbb": "^3.0.4"
16+
}
17+
}

‎example/umd/src/index.test.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import index from './';
2+
3+
describe('sum', () => {
4+
it('works', async () => {
5+
const num = await index();
6+
expect(num).toBe('22 Hello World');
7+
});
8+
});

‎example/umd/src/index.ts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { sum } from './utils/sum';
2+
import { test } from './utils/Test';
3+
4+
class Test {
5+
constructor() {}
6+
public a: string = 'A';
7+
count() {
8+
return 10;
9+
}
10+
}
11+
12+
(() => {
13+
const { sum } = require('./utils/sum');
14+
const data = { a: 1 };
15+
const result = { ...data };
16+
})();
17+
18+
export default async () => {
19+
const testHandle = new Test();
20+
return `${sum(1, testHandle.count())} ${test('Hello World')}`;
21+
};

‎example/umd/src/utils/Test.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export type Test = {
2+
a: string;
3+
b: number;
4+
};
5+
6+
export type TestGood = {
7+
a: string;
8+
g: string;
9+
b: number;
10+
c: number;
11+
e: number;
12+
e333: number;
13+
};
14+
15+
export function test(str: string) {
16+
return `${str}`;
17+
}

‎example/umd/src/utils/a/a.ts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* 这里是注释
3+
* @param a
4+
* @param b
5+
*/
6+
export function abs(a: number, b: number, c?: string) {
7+
return a + b;
8+
}
9+
10+
export type TestGood2333 = {
11+
aaaa: string;
12+
xxxx: number;
13+
wwww: number;
14+
good: number;
15+
};

‎example/umd/src/utils/sum.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { abs } from './a/a';
2+
3+
export function sum(a: number, b: number) {
4+
return a + b + abs(a, b);
5+
}

‎example/umd/test/index.test.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { sum } from '../src/utils/sum';
2+
3+
describe('sum', () => {
4+
it('works', async () => {
5+
expect(sum(1, 1)).toEqual(4);
6+
});
7+
});

‎example/umd/tsconfig.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"compilerOptions": {
3+
"noImplicitAny": true,
4+
"module": "UMD",
5+
"target": "es2015",
6+
"lib": ["es5", "es6", "dom"],
7+
"declaration": true,
8+
"preserveConstEnums": true,
9+
"isolatedModules": true,
10+
"allowUmdGlobalAccess": true,
11+
"noLib": false,
12+
"rootDir": "./src/"
13+
},
14+
"files": ["src/index.ts", "src/utils/sum.ts", "src/utils/Test.ts", "src/utils/a/a.ts"],
15+
"include": ["src/**/*"]
16+
}

‎package.json

+3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
"license": "MIT",
55
"scripts": {
66
"prepare": "husky install",
7+
"build:example": "lerna exec \"npm run build\" --scope @template/*",
78
"build:basic": "lerna exec \"npm run build\" --scope @template/basic",
89
"watch:basic": "lerna exec \"npm run watch\" --scope @template/basic",
910
"test:basic": "lerna exec \"npm run coverage\" --scope @template/basic",
11+
"build:umd": "lerna exec \"npm run build\" --scope @template/umd",
12+
"watch:umd": "lerna exec \"npm run watch\" --scope @template/umd",
1013
"build:express": "lerna exec \"npm run build\" --scope @template/express",
1114
"watch:express": "lerna exec \"npm run watch\" --scope @template/express",
1215
"build:express-typeorm": "lerna exec \"npm run build\" --scope @template/express-typeorm",

0 commit comments

Comments
 (0)
Please sign in to comment.