Skip to content

Commit

Permalink
chore: init
Browse files Browse the repository at this point in the history
  • Loading branch information
wuct committed Feb 18, 2019
0 parents commit e9005dd
Show file tree
Hide file tree
Showing 16 changed files with 9,051 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .babelrc
@@ -0,0 +1,4 @@
{
"presets": ["@babel/env", "@babel/typescript"],
"plugins": ["@babel/proposal-class-properties", "@babel/proposal-object-rest-spread"]
}
13 changes: 13 additions & 0 deletions .editorconfig
@@ -0,0 +1,13 @@
#root = true

[*]
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 100
indent_size = 2

[*.md]
trim_trailing_whitespace = false
4 changes: 4 additions & 0 deletions .eslintignore
@@ -0,0 +1,4 @@
node_modules
coverage
dist
docs
8 changes: 8 additions & 0 deletions .eslintrc
@@ -0,0 +1,8 @@
{
"parser": "babel-eslint",
"extends": "eslint:recommended",
"env": {
"jest": true,
"node": true
}
}
12 changes: 12 additions & 0 deletions .gitignore
@@ -0,0 +1,12 @@
node_modules
coverage
.nyc_output
.DS_Store
*.log
.vscode
.idea
dist
compiled
.awcache
.rpt2_cache
docs
17 changes: 17 additions & 0 deletions .travis.yml
@@ -0,0 +1,17 @@
language: node_js
cache:
directories:
- ~/.npm
notifications:
email: false
node_js:
- '10'
script:
- npm run test:prod && npm run build
after_success:
- npm run report-coverage
- if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run travis-deploy-once "npm run deploy-docs"; fi
- if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run travis-deploy-once "npm run semantic-release"; fi
branches:
except:
- /^v\d+\.\d+\.\d+$/
7 changes: 7 additions & 0 deletions LICENSE
@@ -0,0 +1,7 @@
Copyright 2017 wuct <wu.chingting@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 change: 1 addition & 0 deletions README.md
@@ -0,0 +1 @@
# elastic-apm-sourcemap-webpack-plugin
121 changes: 121 additions & 0 deletions package.json
@@ -0,0 +1,121 @@
{
"name": "elastic-apm-sourcemap-webpack-plugin",
"version": "0.0.0",
"description": "",
"keywords": [],
"main": "dist/elastic-apm-sourcemap-webpack-plugin.umd.js",
"module": "dist/elastic-apm-sourcemap-webpack-plugin.es5.js",
"typings": "dist/types/elastic-apm-sourcemap-webpack-plugin.d.ts",
"files": [
"dist"
],
"author": "wuct <wu.chingting@gmail.com>",
"repository": {
"type": "git",
"url": ""
},
"license": "MIT",
"engines": {
"node": ">=6.0.0"
},
"scripts": {
"lint": "eslint --ext .js,.ts ./",
"prebuild": "rimraf dist",
"build": "tsc --module commonjs && rollup -c rollup.config.ts && typedoc --out docs --target es6 --theme minimal --mode file src",
"start": "rollup -c rollup.config.ts -w",
"test": "jest --coverage",
"test:watch": "jest --coverage --watch",
"test:prod": "npm run lint && npm run test -- --no-cache",
"type-check": "tsc --noEmit",
"type-check:watch": "npm run type-check -- --watch",
"deploy-docs": "ts-node tools/gh-pages-publish",
"report-coverage": "cat ./coverage/lcov.info | coveralls",
"commit": "git-cz",
"semantic-release": "semantic-release",
"semantic-release-prepare": "ts-node tools/semantic-release-prepare",
"precommit": "lint-staged",
"travis-deploy-once": "travis-deploy-once"
},
"lint-staged": {
"{src,test}/**/*.ts": [
"prettier --write",
"git add"
]
},
"config": {
"commitizen": {
"path": "node_modules/cz-conventional-changelog"
}
},
"jest": {
"testEnvironment": "node",
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js"
],
"coveragePathIgnorePatterns": [
"/node_modules/",
"/test/"
],
"coverageThreshold": {
"global": {
"branches": 90,
"functions": 95,
"lines": 95,
"statements": 95
}
},
"collectCoverageFrom": [
"src/*.{js,ts}"
]
},
"prettier": {
"semi": false,
"singleQuote": true
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
},
"devDependencies": {
"@babel/cli": "^7.2.0",
"@babel/core": "^7.2.0",
"@babel/node": "^7.2.2",
"@babel/plugin-proposal-class-properties": "^7.2.1",
"@babel/plugin-proposal-object-rest-spread": "^7.2.0",
"@babel/preset-env": "^7.2.0",
"@babel/preset-typescript": "^7.1.0",
"@commitlint/cli": "^7.1.2",
"@commitlint/config-conventional": "^7.1.2",
"babel-eslint": "^10.0.1",
"babel-jest": "^24.1.0",
"colors": "^1.3.2",
"commitizen": "^3.0.0",
"coveralls": "^3.0.2",
"cross-env": "^5.2.0",
"cz-conventional-changelog": "^2.1.0",
"eslint": "^5.14.0",
"husky": "^1.0.1",
"jest": "^24.1.0",
"jest-config": "^24.1.0",
"lint-staged": "^8.0.0",
"lodash.camelcase": "^4.3.0",
"prettier": "^1.14.3",
"prompt": "^1.0.0",
"replace-in-file": "^3.4.2",
"rimraf": "^2.6.2",
"rollup": "^1.2.1",
"rollup-plugin-commonjs": "^9.1.8",
"rollup-plugin-json": "^3.1.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-typescript2": "^0.19.2",
"semantic-release": "^15.9.16",
"shelljs": "^0.8.3",
"typedoc": "^0.14.2",
"typescript": "^3.0.3"
}
}
38 changes: 38 additions & 0 deletions rollup.config.ts
@@ -0,0 +1,38 @@
import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import sourceMaps from 'rollup-plugin-sourcemaps'
import camelCase from 'lodash.camelcase'
import typescript from 'rollup-plugin-typescript2'
import json from 'rollup-plugin-json'

const pkg = require('./package.json')

const libraryName = 'elastic-apm-sourcemap-webpack-plugin'

export default {
input: `src/${libraryName}.ts`,
output: [
{ file: pkg.main, name: camelCase(libraryName), format: 'umd', sourcemap: true },
{ file: pkg.module, format: 'es', sourcemap: true }
],
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
external: [],
watch: {
include: 'src/**'
},
plugins: [
// Allow json resolution
json(),
// Compile TypeScript files
typescript({ useTsconfigDeclarationDir: true }),
// Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs)
commonjs(),
// Allow node_modules resolution, so you can use 'external' to control
// which external modules to include in the bundle
// https://github.com/rollup/rollup-plugin-node-resolve#usage
resolve(),

// Resolve source maps to the original source
sourceMaps()
]
}
5 changes: 5 additions & 0 deletions src/elastic-apm-sourcemap-webpack-plugin.ts
@@ -0,0 +1,5 @@
export default class ElasticAPMSourceMapPlugin {
apply() {
// console.log('hi')
}
}
9 changes: 9 additions & 0 deletions test/elastic-apm-sourcemap-webpack-plugin.test.ts
@@ -0,0 +1,9 @@
import ElasticAPMSourceMapPlugin from '../src/elastic-apm-sourcemap-webpack-plugin'

test('works if true is truthy', () => {
expect(true).toBeTruthy()
})

test('DummyClass is instantiable', () => {
expect(new ElasticAPMSourceMapPlugin()).toBeInstanceOf(ElasticAPMSourceMapPlugin)
})
29 changes: 29 additions & 0 deletions tools/gh-pages-publish.ts
@@ -0,0 +1,29 @@
const { cd, exec, echo, touch } = require('shelljs')
const { readFileSync } = require('fs')
const url = require('url')

let repoUrl
let pkg = JSON.parse(readFileSync('package.json'))
if (typeof pkg.repository === 'object') {
if (!pkg.repository.hasOwnProperty('url')) {
throw new Error('URL does not exist in repository section')
}
repoUrl = pkg.repository.url
} else {
repoUrl = pkg.repository
}

let parsedUrl = url.parse(repoUrl)
let repository = (parsedUrl.host || '') + (parsedUrl.path || '')
let ghToken = process.env.GH_TOKEN

echo('Deploying docs!!!')
cd('docs')
touch('.nojekyll')
exec('git init')
exec('git add .')
exec('git config user.name "wuct"')
exec('git config user.email "wu.chingting@gmail.com"')
exec('git commit -m "docs(docs): update gh-pages"')
exec(`git push --force --quiet "https://${ghToken}@${repository}" master:gh-pages`)
echo('Docs deployed!!')
40 changes: 40 additions & 0 deletions tools/semantic-release-prepare.ts
@@ -0,0 +1,40 @@
/* eslint no-console: "off" */
const path = require('path')
const { fork } = require('child_process')
const colors = require('colors')

const { readFileSync, writeFileSync } = require('fs')
const pkg = JSON.parse(readFileSync(path.resolve(__dirname, '..', 'package.json')))

pkg.scripts.prepush = 'npm run test:prod && npm run build'
pkg.scripts.commitmsg = 'commitlint -E HUSKY_GIT_PARAMS'

writeFileSync(path.resolve(__dirname, '..', 'package.json'), JSON.stringify(pkg, null, 2))

// Call husky to set up the hooks
fork(path.resolve(__dirname, '..', 'node_modules', 'husky', 'lib', 'installer', 'bin'), ['install'])

console.log()
console.log(colors.green('Done!!'))
console.log()

if (pkg.repository.url.trim()) {
console.log(colors.cyan('Now run:'))
console.log(colors.cyan(' npm install -g semantic-release-cli'))
console.log(colors.cyan(' semantic-release-cli setup'))
console.log()
console.log(colors.cyan('Important! Answer NO to "Generate travis.yml" question'))
console.log()
console.log(
colors.gray('Note: Make sure "repository.url" in your package.json is correct before')
)
} else {
console.log(colors.red('First you need to set the "repository.url" property in package.json'))
console.log(colors.cyan('Then run:'))
console.log(colors.cyan(' npm install -g semantic-release-cli'))
console.log(colors.cyan(' semantic-release-cli setup'))
console.log()
console.log(colors.cyan('Important! Answer NO to "Generate travis.yml" question'))
}

console.log()
22 changes: 22 additions & 0 deletions tsconfig.json
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"moduleResolution": "node",
"target": "es5",
"module":"es2015",
"lib": ["es2015", "es2016", "es2017", "dom"],
"strict": true,
"sourceMap": true,
"declaration": true,
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declarationDir": "dist/types",
"outDir": "dist/lib",
"typeRoots": [
"node_modules/@types"
]
},
"include": [
"src"
]
}

0 comments on commit e9005dd

Please sign in to comment.