Skip to content

Commit

Permalink
chore: add umd example.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Sep 7, 2021
1 parent 30e44e7 commit 7253da3
Show file tree
Hide file tree
Showing 13 changed files with 272 additions and 15 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.dev.yml
Expand Up @@ -61,3 +61,7 @@ jobs:
- name: example @example/transform-typescript
working-directory: example/transform-typescript
run: npm run build

- name: example @example/umd
working-directory: example/umd
run: npm run build
44 changes: 29 additions & 15 deletions .github/workflows/ci.yml
Expand Up @@ -33,14 +33,14 @@ jobs:
working-directory: example/express
run: npm run build

- name: example @example/hapi
working-directory: example/hapi
run: npm run build

- name: example @example/express-typeorm
working-directory: example/express-typeorm
run: npm run build

- name: example @example/hapi
working-directory: example/hapi
run: npm run build

- name: example @example/koa
working-directory: example/koa
run: npm run build
Expand All @@ -61,9 +61,13 @@ jobs:
working-directory: example/transform-typescript
run: npm run build

- name: example @example/umd
working-directory: example/umd
run: npm run build

- name: Is a tag created auto?
id: create_tag
uses: jaywcjlove/create-tag-action@v1.2.0
uses: jaywcjlove/create-tag-action@v1.2.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
package-path: ./packages/tsbb/package.json
Expand Down Expand Up @@ -99,39 +103,49 @@ jobs:
- run: mkdir -p zip

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

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

- name: Compress express-typeorm Example.
run: zip -r -y express-typeorm.zip . -x "node_modules/*" -x "build/*" -x "lib/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
working-directory: example/express-typeorm
- run: cp -rp example/express-typeorm/express-typeorm.zip ./zip

- name: Compress hapi Example.
run: zip -r -y hapi.zip . -x "node_modules/*" -x "build/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
run: zip -r -y hapi.zip . -x "node_modules/*" -x "build/*" -x "lib/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
working-directory: example/hapi
- run: cp -rp example/hapi/hapi.zip ./zip

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

- name: Compress react-component Example.
run: zip -r -y react-component.zip . -x "node_modules/*" -x "build/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
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"
working-directory: example/react-component
- run: cp -rp example/react-component/react-component.zip ./zip

- name: Compress react-component-tsx Example.
run: zip -r -y react-component-tsx.zip . -x "node_modules/*" -x "build/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
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"
working-directory: example/react-component-tsx
- run: cp -rp example/react-component-tsx/react-component-tsx.zip ./zip

- name: Compress express-typeorm Example.
run: zip -r -y express-typeorm.zip . -x "node_modules/*" -x "build/*.sqlite" -x "build/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
working-directory: example/express-typeorm
- run: cp -rp example/express-typeorm/express-typeorm.zip ./zip
- name: Compress transform-typescript Example.
run: zip -r -y transform-typescript.zip . -x "node_modules/*" -x "build/*" -x "lib/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
working-directory: example/transform-typescript
- run: cp -rp example/transform-typescript/transform-typescript.zip ./zip

- name: Compress umd Example.
run: zip -r -y umd.zip . -x "node_modules/*" -x "build/*.sqlite" -x "build/*" -x "lib/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
working-directory: example/umd
- run: cp -rp example/umd/umd.zip ./zip

- name: Compress TSBB Example Download webpage.
working-directory: zip
Expand Down
115 changes: 115 additions & 0 deletions example/umd/.gitignore
@@ -0,0 +1,115 @@
# Created by https://www.gitignore.io/api/node
# Edit at https://www.gitignore.io/?templates=node

esm
cjs
lib
package-lock.json
__snapshots__

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# End of https://www.gitignore.io/api/node

.DS_Store
.cache
.vscode
.idea
.env

*.bak
*.tem
*.temp
#.swp
*.*~
~*.*

# IDEA
*.iml
*.ipr
*.iws
.idea/
15 changes: 15 additions & 0 deletions example/umd/README.md
@@ -0,0 +1,15 @@
UMD Example
---

## Quick Start

```shell
$ npx create-kkt my-app -e umd
cd my-app
$ npm install

$ npm run watch # Listen compile .ts files.
$ npm run build # compile .ts files.

$ npm run start
```
17 changes: 17 additions & 0 deletions example/umd/package.json
@@ -0,0 +1,17 @@
{
"name": "@template/umd",
"private": true,
"version": "3.0.4",
"description": "UMD Example.",
"scripts": {
"watch": "tsbb watch --no-esm --disable-babel",
"build": "tsbb build --no-esm --disable-babel",
"test": "tsbb test",
"coverage": "tsbb test --coverage"
},
"keywords": [],
"license": "MIT",
"devDependencies": {
"tsbb": "^3.0.4"
}
}
8 changes: 8 additions & 0 deletions example/umd/src/index.test.ts
@@ -0,0 +1,8 @@
import index from './';

describe('sum', () => {
it('works', async () => {
const num = await index();
expect(num).toBe('22 Hello World');
});
});
21 changes: 21 additions & 0 deletions example/umd/src/index.ts
@@ -0,0 +1,21 @@
import { sum } from './utils/sum';
import { test } from './utils/Test';

class Test {
constructor() {}
public a: string = 'A';
count() {
return 10;
}
}

(() => {
const { sum } = require('./utils/sum');
const data = { a: 1 };
const result = { ...data };
})();

export default async () => {
const testHandle = new Test();
return `${sum(1, testHandle.count())} ${test('Hello World')}`;
};
17 changes: 17 additions & 0 deletions example/umd/src/utils/Test.ts
@@ -0,0 +1,17 @@
export type Test = {
a: string;
b: number;
};

export type TestGood = {
a: string;
g: string;
b: number;
c: number;
e: number;
e333: number;
};

export function test(str: string) {
return `${str}`;
}
15 changes: 15 additions & 0 deletions example/umd/src/utils/a/a.ts
@@ -0,0 +1,15 @@
/**
* 这里是注释
* @param a
* @param b
*/
export function abs(a: number, b: number, c?: string) {
return a + b;
}

export type TestGood2333 = {
aaaa: string;
xxxx: number;
wwww: number;
good: number;
};
5 changes: 5 additions & 0 deletions example/umd/src/utils/sum.ts
@@ -0,0 +1,5 @@
import { abs } from './a/a';

export function sum(a: number, b: number) {
return a + b + abs(a, b);
}
7 changes: 7 additions & 0 deletions example/umd/test/index.test.ts
@@ -0,0 +1,7 @@
import { sum } from '../src/utils/sum';

describe('sum', () => {
it('works', async () => {
expect(sum(1, 1)).toEqual(4);
});
});
16 changes: 16 additions & 0 deletions example/umd/tsconfig.json
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"noImplicitAny": true,
"module": "UMD",
"target": "es2015",
"lib": ["es5", "es6", "dom"],
"declaration": true,
"preserveConstEnums": true,
"isolatedModules": true,
"allowUmdGlobalAccess": true,
"noLib": false,
"rootDir": "./src/"
},
"files": ["src/index.ts", "src/utils/sum.ts", "src/utils/Test.ts", "src/utils/a/a.ts"],
"include": ["src/**/*"]
}
3 changes: 3 additions & 0 deletions package.json
Expand Up @@ -4,9 +4,12 @@
"license": "MIT",
"scripts": {
"prepare": "husky install",
"build:example": "lerna exec \"npm run build\" --scope @template/*",
"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",
"build:umd": "lerna exec \"npm run build\" --scope @template/umd",
"watch:umd": "lerna exec \"npm run watch\" --scope @template/umd",
"build:express": "lerna exec \"npm run build\" --scope @template/express",
"watch:express": "lerna exec \"npm run watch\" --scope @template/express",
"build:express-typeorm": "lerna exec \"npm run build\" --scope @template/express-typeorm",
Expand Down

0 comments on commit 7253da3

Please sign in to comment.