Skip to content

Commit

Permalink
intial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
xtoolkit committed Nov 21, 2021
0 parents commit 912b674
Show file tree
Hide file tree
Showing 44 changed files with 1,659 additions and 0 deletions.
168 changes: 168 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
dist/
package-lock.json
yarn.lock
TODO.md
temp
.vscode

# Created by https://www.gitignore.io/api/webstorm,phpstorm,osx,linux,node

### WebStorm ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm

*.iml

## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:

# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries
# .idea/shelf

# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml

# Gradle:
# .idea/gradle.xml
# .idea/libraries

# Mongo Explorer plugin:
# .idea/mongoSettings.xml

## File-based project format:
*.ipr
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties


### PhpStorm ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm

## Directory-based project format:
# if you remove the above rule, at least ignore the following:

# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries
# .idea/shelf

# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml

# Gradle:
# .idea/gradle.xml
# .idea/libraries

# Mongo Explorer plugin:
# .idea/mongoSettings.xml

## File-based project format:
## Plugin-specific files:

# IntelliJ
# mpeltonen/sbt-idea plugin
# JIRA plugin
# Crashlytics plugin (for Android Studio and IntelliJ)
### OSX ###
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk


### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*


### Node ###
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

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

# Coverage directory used by tools like istanbul
coverage

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

# node-waf configuration
.lock-wscript

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

# Dependency directory
node_modules

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history
19 changes: 19 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"arrowParens": "avoid",
"bracketSameLine": true,
"bracketSpacing": false,
"embeddedLanguageFormatting": "auto",
"htmlWhitespaceSensitivity": "ignore",
"insertPragma": false,
"jsxSingleQuote": true,
"printWidth": 80,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none",
"useTabs": false,
"vueIndentScriptAndStyle": true
}
117 changes: 117 additions & 0 deletions config/rollup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import fs from 'fs';
import {resolve, basename} from 'path';
import commonjs from '@rollup/plugin-commonjs';
import replace from '@rollup/plugin-replace';
import ts from 'rollup-plugin-typescript2';
import {terser} from 'rollup-plugin-terser';
import dts from 'rollup-plugin-dts';
import originPkg from '../package.json';

export default function (config) {
config.path = resolve(config.path);
const name = basename(config.path);
const getPath = x => resolve(config.path, x);
const pkg = require(getPath('package.json'));

fs.rmSync(getPath('dist'), {recursive: true, force: true});

const banner = `/*!
* ${pkg.name} v${originPkg.version}
* @license MIT
*/`;

const commonInput = {
input: getPath('src/index.ts'),
external: config.external,
plugins: [
replace({
preventAssignment: true,
values: {
'process.env.NODE_ENV': `'${config.env}'`
}
}),
commonjs()
]
};

const commonOutput = {
banner,
globals: config.globals,
exports: config.exports
};

return [
{
file: getPath('dist/index.d.ts'),
format: 'es',
dts: true
},
{
file: getPath('dist/index.esm-bundler.js'),
format: 'esm',
target: 'es2015'
},
{
file: getPath('dist/index.cjs.js'),
format: 'cjs',
target: 'es2015'
},
{
file: getPath('dist/index.global.js'),
format: 'iife',
name: name.toLowerCase() + 'ClientApi',
target: 'es5'
},
{
file: getPath('dist/index.global.min.js'),
format: 'iife',
name: name.toLowerCase() + 'ClientApi',
target: 'es5',
minify: true
}
].map(x => createConfigs(x, commonInput, commonOutput));
}

function createConfigs(config, commonInput, commonOutput) {
let plugins = [];
if (config.dts) {
plugins.push(dts());
} else {
plugins = [...commonInput.plugins];
plugins.push(
ts({
check: false,
tsconfigOverride: {
compilerOptions: {
target: config.target
}
},
exclude: ['node_modules']
})
);
if (config.minify) {
plugins.push(
terser({
compress: {
ecma: 5,
pure_getters: true
},
format: {
comments: false
}
})
);
}
}
return {
input: commonInput.input,
external: commonInput.external,
output: {
file: config.file,
format: config.format,
name: config.name,
...commonOutput
},
plugins
};
}
12 changes: 12 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
testEnvironment: 'jsdom',
coverageDirectory: 'coverage',
coverageReporters: ['html', 'json', 'lcov', 'text-summary', 'clover'],
collectCoverageFrom: ['packages/*/src/**/*.ts'],
coveragePathIgnorePatterns: ['/node_modules/'],
testMatch: ['<rootDir>/packages/*/__tests__/**/*.spec.ts'],
watchPathIgnorePatterns: ['<rootDir>/node_modules'],
transform: {
'^.+\\.ts?$': 'ts-jest'
}
};
10 changes: 10 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"packages": ["packages/*"],
"npmClient": "yarn",
"version": "independent",
"command": {
"publish": {
"message": "chore(release): publish"
}
}
}
34 changes: 34 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "client-fetch",
"private": true,
"version": "1.0.0",
"license": "MIT",
"scripts": {
"postinstall": "lerna bootstrap",
"build": "lerna run prepack --stream",
"release": "lerna publish",
"test": "jest",
"test:coverage": "jest --coverage"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-replace": "^3.0.0",
"@types/jest": "^27.0.2",
"jest": "^27.3.1",
"lerna": "^4.0.0",
"rollup": "^2.60.0",
"rollup-plugin-dts": "^4.0.1",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.30.0",
"ts-jest": "^27.0.7",
"typescript": "^4.4.4"
},
"lint-staged": {
"*.js": [
"prettier --write"
],
"*.ts": [
"prettier --parser=typescript --write"
]
}
}
Loading

0 comments on commit 912b674

Please sign in to comment.