Skip to content

Commit 0589554

Browse files
authored
Bootstrap signals package boilerplate (#1093)
1 parent 9a19a3c commit 0589554

27 files changed

+334
-0
lines changed

.buildkite/pipeline.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,23 @@ steps:
127127
- yarn turbo run --filter='./packages/consent/*' lint
128128
- echo "+++ Run Tests"
129129
- yarn turbo run --filter='./packages/consent/*' test
130+
plugins:
131+
- ssh://[email protected]/segmentio/cache-buildkite-plugin#v2.0.0:
132+
key: "v1.1-cache-dev-{{ checksum 'yarn.lock' }}"
133+
134+
- label: '[Signals] Lint + Test'
135+
agents:
136+
queue: v1
137+
commands:
138+
- npm config set "//registry.npmjs.org/:_authToken" $${NPM_TOKEN}
139+
- echo "--- Install dependencies"
140+
- PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 HUSKY=0 yarn install --immutable
141+
- echo "--- Build bundles"
142+
- yarn turbo run --filter='./packages/signals/*' build
143+
- echo "+++ Run Lint"
144+
- yarn turbo run --filter='./packages/signals/*' lint
145+
- echo "+++ Run Tests"
146+
- yarn turbo run --filter='./packages/signals/*' test
130147
plugins:
131148
- ssh://[email protected]/segmentio/cache-buildkite-plugin#v2.0.0:
132149
key: "v1.1-cache-dev-{{ checksum 'yarn.lock' }}"

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ module.exports = () =>
1717
'<rootDir>/packages/consent/consent-tools',
1818
'<rootDir>/packages/consent/consent-wrapper-onetrust',
1919
'<rootDir>/scripts',
20+
'<rootDir>/packages/signals/browser-signals',
2021
],
2122
})

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"playgrounds/*",
77
"packages/*",
88
"packages/consent/*",
9+
"packages/signals/*",
910
"scripts"
1011
],
1112
"engines": {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/** @type { import('eslint').Linter.Config } */
2+
module.exports = {
3+
extends: ['../../../.eslintrc'],
4+
env: {
5+
browser: true,
6+
},
7+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require("@internal/config").lintStagedConfig
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright © 2023 Segment
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# @segment/analytics-browser-signals
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const { createJestTSConfig } = require('@internal/config')
2+
3+
module.exports = createJestTSConfig(__dirname, {
4+
testEnvironment: 'jsdom',
5+
})
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"name": "@segment/analytics-browser-signals",
3+
"version": "0.0.1",
4+
"main": "./dist/cjs/index.js",
5+
"private": true,
6+
"module": "./dist/esm/index.js",
7+
"types": "./dist/types/index.d.ts",
8+
"sideEffects": [
9+
"./dist/umd/analytics-browser-signals.umd.js"
10+
],
11+
"jsdelivr": "./dist/umd/analytics-browser-signals.umd.js",
12+
"unpkg": "./dist/umd/analytics-browser-signals.umd.js",
13+
"files": [
14+
"LICENSE",
15+
"dist/",
16+
"src/",
17+
"!**/__tests__/**",
18+
"!**/test-helpers/**",
19+
"!*.tsbuildinfo"
20+
],
21+
"scripts": {
22+
".": "yarn run -T turbo run --filter=@segment/analytics-browser-signals...",
23+
"test": "yarn jest",
24+
"lint": "yarn concurrently 'yarn:eslint .' 'yarn:tsc --noEmit'",
25+
"build": "rm -rf dist && yarn concurrently 'yarn:build:*'",
26+
"build:esm": "yarn tsc -p tsconfig.build.json",
27+
"build:cjs": "yarn tsc -p tsconfig.build.json --outDir ./dist/cjs --module commonjs",
28+
"build:bundle": "NODE_ENV=production yarn run webpack",
29+
"build:bundle-dev": "NODE_ENV=development yarn run webpack",
30+
"watch": "yarn concurrently 'yarn build:bundle-dev --watch' 'yarn build:esm --watch'",
31+
"version": "sh scripts/version.sh",
32+
"watch:test": "yarn test --watch",
33+
"tsc": "yarn run -T tsc",
34+
"eslint": "yarn run -T eslint",
35+
"concurrently": "yarn run -T concurrently --raw",
36+
"jest": "yarn run -T jest",
37+
"webpack": "yarn run -T webpack"
38+
},
39+
"dependencies": {
40+
"tslib": "^2.4.1"
41+
},
42+
"peerDependencies": {
43+
"@segment/analytics-next": ">=1.70.0"
44+
},
45+
"peerDependenciesMeta": {
46+
"@segment/analytics-next": {
47+
"optional": true
48+
}
49+
},
50+
"packageManager": "[email protected]",
51+
"devDependencies": {
52+
"@internal/config-webpack": "workspace:^",
53+
"@internal/test-helpers": "workspace:^"
54+
}
55+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
# Generate a version.ts file from the version in the package.json
3+
4+
PKG_VERSION=$(node --eval="process.stdout.write(require('./package.json').version)")
5+
6+
cat <<EOF >src/generated/version.ts
7+
// This file is generated.
8+
export const version = '$PKG_VERSION'
9+
EOF
10+
11+
git add src/generated/version.ts

0 commit comments

Comments
 (0)