Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.

Commit bdc86fb

Browse files
author
Julio Farah
authored
Add support to Typescript (#151)
* Add support to Typescript * 3.13.4-beta.0 * add typescript support for karma * bump history * remove tests from tsconfig include * use module commonjs * remove commit message rules * bump node to 13.14 * point tests to /build dir * bump node to 12.18 * add .npmignore
1 parent 497822c commit bdc86fb

23 files changed

+164
-704
lines changed

.circleci/config.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defaults: &defaults
22
working_directory: ~/analytics.js-core
33
docker:
4-
- image: circleci/node:8-browsers
4+
- image: circleci/node:12-browsers
55

66
version: 2
77
jobs:
@@ -17,7 +17,6 @@ jobs:
1717
key: yarn-dependency-cache-{{ checksum "yarn.lock" }}
1818
paths:
1919
- node_modules
20-
- run: yarn commitlint-circle
2120
- run: make test
2221
- store_test_results:
2322
path: junit-reports
@@ -33,6 +32,7 @@ jobs:
3332
key: yarn-dependency-cache-{{ checksum "yarn.lock" }}
3433
paths:
3534
- node_modules
35+
- run: yarn run tsc
3636
- run: yarn run karma start karma.conf.coverage.js
3737
- store_test_results:
3838
path: junit-reports
@@ -61,6 +61,7 @@ jobs:
6161
- checkout
6262
- attach_workspace: { at: . }
6363
- run: npm config set "//registry.npmjs.org/:_authToken" $NPM_AUTH
64+
- run: yarn tsc
6465
- run: npm publish .
6566

6667
workflows:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ coverage
22
node_modules
33
package-lock.json
44
junit-reports
5+
6+
build/
7+
.DS_Store

.npmignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.circleci
2+
.github
3+
node_modules
4+
test/**/*
5+
lib/**/*
6+
.eslintrc
7+
.gitignore
8+
.nvmrc
9+
.prettierrc
10+
*.md
11+
karma.*
12+
Makefile
13+
tsconfig.json

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.17.0
1+
12.18.0

HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 3.13.4 / 2020-06-02
2+
3+
- refactor: enable typescript support
4+
15
# 3.13.3 / 2020-05-26
26

37
- feat: add destination middleware

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,14 @@ GREP ?= .
4545
install:
4646
yarn
4747

48+
# Build typescript
49+
build: clean install
50+
yarn tsc
51+
.PHONY: build
52+
4853
# Remove temporary files and build artifacts.
4954
clean:
50-
rm -rf *.log coverage
55+
rm -rf *.log coverage build
5156
.PHONY: clean
5257

5358
# Remove temporary files, build artifacts, and vendor dependencies.
@@ -67,7 +72,7 @@ fmt: install
6772
.PHONY: fmt
6873

6974
# Run browser unit tests in a browser.
70-
test-browser: install
75+
test-browser: build
7176
@$(KARMA) start $(KARMA_FLAGS) $(KARMA_CONF)
7277
.PHONY: test-browser
7378

karma.conf.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
var TEST_TIMEOUT = 10 * 60 * 1000;
66

77
module.exports = function(config) {
8+
require('ts-node').register({
9+
compilerOptions: {
10+
module: 'commonjs'
11+
}
12+
});
813
config.set({
914
files: [
1015
{ pattern: 'test/support/*.html', included: false },

package.json

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
{
22
"name": "@segment/analytics.js-core",
33
"author": "Segment <[email protected]>",
4-
"version": "3.13.3",
4+
"version": "3.13.4",
55
"description": "The hassle-free way to integrate analytics into any web application.",
66
"keywords": [
77
"analytics",
88
"analytics.js",
99
"segment",
1010
"segment.io"
1111
],
12-
"main": "lib/index.js",
12+
"main": "build/index.js",
1313
"scripts": {
1414
"test": "make test",
1515
"lint": "eslint \"./{lib,test}/**/*.js\"",
1616
"format": "prettier-eslint --write --list-different \"./{lib,test}/**/*.{js,json,md}\"",
1717
"precommit": "lint-staged",
1818
"np": "np --no-publish",
19-
"cz": "git-cz",
20-
"commitmsg": "commitlint -E GIT_PARAMS"
19+
"cz": "git-cz"
2120
},
2221
"repository": {
2322
"type": "git",
@@ -63,15 +62,12 @@
6362
"uuid": "^3.4.0"
6463
},
6564
"devDependencies": {
66-
"@commitlint/cli": "^7.0.0",
67-
"@commitlint/config-conventional": "^7.0.1",
6865
"@segment/analytics.js-integration": "^3.2.1",
6966
"@segment/eslint-config": "^4.0.0",
67+
"@types/node": "^14.0.6",
7068
"browserify": "13.0.0",
7169
"browserify-istanbul": "^2.0.0",
7270
"codecov": "^3.0.2",
73-
"commitizen": "^2.10.1",
74-
"commitlint-circle": "^1.0.0",
7571
"compat-trigger-event": "^1.0.0",
7672
"component-each": "^0.2.6",
7773
"cz-conventional-changelog": "^2.1.0",
@@ -101,13 +97,10 @@
10197
"proclaim": "^3.4.1",
10298
"sinon": "^1.7.3",
10399
"snyk": "^1.83.0",
100+
"ts-node": "^8.10.2",
101+
"typescript": "^3.9.3",
104102
"watchify": "^3.7.0"
105103
},
106-
"commitlint": {
107-
"extends": [
108-
"@commitlint/config-conventional"
109-
]
110-
},
111104
"lint-staged": {
112105
"linters": {
113106
"*.{js,json,md}": [
@@ -116,11 +109,6 @@
116109
]
117110
}
118111
},
119-
"config": {
120-
"commitizen": {
121-
"path": "cz-conventional-changelog"
122-
}
123-
},
124112
"browserify": {
125113
"transform": [
126114
"package-json-versionify"

test/analytics.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
'use strict';
22

3-
var Analytics = require('../lib').constructor;
3+
var Analytics = require('../build').constructor;
44
var Facade = require('segmentio-facade');
5-
var analytics = require('../lib');
5+
var analytics = require('../build');
66
var assert = require('proclaim');
77
var bind = require('component-event').bind;
88
var createIntegration = require('@segment/analytics.js-integration');
99
var extend = require('@ndhoule/extend');
1010
var type = require('component-type');
1111
var jQuery = require('jquery');
12-
var pageDefaults = require('../lib/pageDefaults');
12+
var pageDefaults = require('../build/pageDefaults');
1313
var sinon = require('sinon');
1414
var tick = require('next-tick');
1515
var trigger = require('compat-trigger-event');

test/clone.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
var assert = require('proclaim');
4-
var clone = require('../lib/utils/clone');
4+
var clone = require('../build/utils/clone');
55

66
describe('clone', function() {
77
it('should be a function', function() {

0 commit comments

Comments
 (0)