Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signals: fix dirty git repo after publish #1193

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ steps:
- HUSKY=0 yarn install --immutable
- echo "--- Build bundles"
- yarn turbo run --filter='./packages/signals/*' build
- echo "--- Assert Workerbox Up-to-Date"
- yarn workspace @segment/analytics-signals run assert-workerbox-built
- echo "+++ Assert Generated Files Up-to-Date"
- yarn turbo run --filter='./packages/signals/*' assert-generated
- echo "+++ Run Lint"
- yarn turbo run --filter='./packages/signals/*' lint
- echo "+++ Run Tests"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ const esbuild = require('esbuild')
const path = require('path')
const fs = require('fs')
const fsPromises = fs.promises
const pkgJSON = require('./package.json')

const getBanner = (entryPoint) => {
const content = [
`// GENERATED, DO NOT EDIT`,
`// ${pkgJSON.name}@${pkgJSON.version}`,
`// Entry point: ${entryPoint}`,
].join('\n')
return content
Expand Down
1 change: 1 addition & 0 deletions packages/signals/signals-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"build:esm": "yarn tsc -p tsconfig.build.json",
"build:cjs": "yarn tsc -p tsconfig.build.json --outDir ./dist/cjs --module commonjs",
"build:global": "node build-signals-runtime-global.js",
"assert-generated": "bash scripts/assert-generated.sh",
"watch": "yarn build:esm --watch",
"watch:test": "yarn test --watch",
"tsc": "yarn run -T tsc",
Expand Down
17 changes: 17 additions & 0 deletions packages/signals/signals-runtime/scripts/assert-generated.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh
# A CI script to ensure people remember to rebuild workerbox related files if workerbox changes

yarn build:global

# Check for changes in the workerbox directory
changed_files=$(git diff --name-only | grep 'generated')

# Check for changes in the workerbox directory
if [ -n "$changed_files" ]; then
echo "Error: Changes detected. Please commit the changed files:"
echo "$changed_files"
exit 1
else
echo "Files have not changed"
exit 0
fi
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable */
// GENERATED, DO NOT EDIT
// @segment/[email protected]
// Entry point: src/mobile/index.signals-runtime.ts
export const getRuntimeCode = (): string => `
"use strict";(()=>{var g=Object.defineProperty;var f=(r,n)=>{for(var e in n)g(r,e,{get:n[e],enumerable:!0})};var l={};f(l,{EventType:()=>d,LocalDataAction:()=>c,NavigationAction:()=>S,NetworkAction:()=>u,SignalType:()=>p});var p=Object.freeze({Interaction:"interaction",Navigation:"navigation",Network:"network",LocalData:"localData",Instrumentation:"instrumentation",UserDefined:"userDefined"}),d=Object.freeze({Track:"track",Page:"page",Screen:"screen",Identify:"identify",Group:"group",Alias:"alias"}),S=Object.freeze({Forward:"forward",Backward:"backward",Modal:"modal",Entering:"entering",Leaving:"leaving",Page:"page",Popup:"popup"}),u=Object.freeze({Request:"request",Response:"response"}),c=Object.freeze({Loaded:"loaded",Updated:"updated",Saved:"saved",Deleted:"deleted",Undefined:"undefined"});var a=class{constructor(n=[]){this.find=(n,e,i)=>this.filter(n,e,i)[0];this.filter=(n,e,i)=>{let o=s=>s.type===e;return this.signalBuffer.slice(this.signalBuffer.indexOf(n)+1).filter(o).filter(s=>i?i(s):()=>!0)};this.signalBuffer=n}};var t=class extends a{constructor(e=[]){super(e);this.add=e=>{this.signalCounter<0&&(this.signalCounter=0),"index"in e&&e.index==-1&&(e.index=this.getNextIndex()),this.signalBuffer.unshift(e),this.signalBuffer.length>this.maxBufferSize&&this.signalBuffer.pop()};this.getNextIndex=()=>{let e=this.signalCounter;return this.signalCounter+=1,e};this.signalCounter=0,this.maxBufferSize=1e3}};Object.assign(globalThis,{signals:new t},l);})();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable */
// GENERATED, DO NOT EDIT
// @segment/[email protected]
// Entry point: src/web/index.signals-runtime.ts
export const getRuntimeCode = (): string => `
"use strict";(()=>{var o=Object.defineProperty;var S=(l,e)=>{for(var n in e)o(l,n,{get:e[n],enumerable:!0})};var i=class{constructor(e=[]){this.find=(e,n,a)=>this.filter(e,n,a)[0];this.filter=(e,n,a)=>{let s=g=>g.type===n;return this.signalBuffer.slice(this.signalBuffer.indexOf(e)+1).filter(s).filter(g=>a?a(g):()=>!0)};this.signalBuffer=e}};var t=class extends i{};var r={};S(r,{EventType:()=>f,NavigationAction:()=>p,SignalType:()=>y});var f=Object.freeze({Track:"track",Page:"page",Screen:"screen",Identify:"identify",Group:"group",Alias:"alias"}),p=Object.freeze({URLChange:"urlChange",PageLoad:"pageLoad"}),y=Object.freeze({Interaction:"interaction",Navigation:"navigation",Network:"network",LocalData:"localData",Instrumentation:"instrumentation",UserDefined:"userDefined"});Object.assign(globalThis,{signals:new t},r);})();
Expand Down
2 changes: 1 addition & 1 deletion packages/signals/signals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"build:cjs": "yarn tsc -p tsconfig.build.json --outDir ./dist/cjs --module commonjs",
"build:bundle": "NODE_ENV=production yarn run webpack",
"workerbox": "node scripts/build-workerbox.js",
"assert-workerbox-built": "sh scripts/assert-workerbox-built.sh",
"assert-generated": "sh scripts/assert-workerbox-built.sh",
"watch": "yarn concurrently 'yarn build:bundle --watch' 'yarn build:esm --watch'",
"version": "sh scripts/version.sh",
"watch:test": "yarn test --watch",
Expand Down
3 changes: 3 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
"tsc": {
"cache": false
},
"assert-generated": {
"cache": false
},
"watch": {
"cache": false,
"outputs": ["dist/**"]
Expand Down
Loading