Skip to content
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
1 change: 1 addition & 0 deletions .config/tsconfig.check.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
},
"include": [
"../packages/cli/src/**/*.mts",
"../packages/cli/src/**/*.d.ts",
"../packages/cli/*.config.mts",
"../packages/cli/.config/*.mts"
],
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/provenance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
- name: Generate platform matrix
id: matrix
run: |
MATRIX=$(node scripts/get-platform-matrix.mjs)
MATRIX=$(node scripts/get-platform-matrix.mts)
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT

- name: Upload CLI bundle
Expand Down Expand Up @@ -195,7 +195,7 @@ jobs:
set -euo pipefail

# Get platform targets from single source of truth.
PLATFORMS_STR=$(node scripts/get-platform-targets.mjs)
PLATFORMS_STR=$(node scripts/get-platform-targets.mts)
read -ra PLATFORMS <<< "$PLATFORMS_STR"

for target in "${PLATFORMS[@]}"; do
Expand Down Expand Up @@ -227,7 +227,7 @@ jobs:
if [ -n "$LIBC" ]; then
LIBC_FLAG="--libc=$LIBC"
fi
node scripts/prepublish-socketbin.mjs \
node scripts/prepublish-socketbin.mts \
--platform="$PLATFORM" --arch="$ARCH" $LIBC_FLAG --prod \
--version="$VERSION" --method=sea

Expand All @@ -253,7 +253,7 @@ jobs:
TAG: ${{ steps.version.outputs.cli_tag }}
run: |
PKG_DIR="packages/package-builder/build/prod/out/cli"
node scripts/prepare-package-for-publish.mjs "$PKG_DIR" "$VERSION"
node scripts/prepare-package-for-publish.mts "$PKG_DIR" "$VERSION"
cd "$PKG_DIR"
npm publish --provenance --access public --no-git-checks --tag "$TAG"

Expand All @@ -264,7 +264,7 @@ jobs:
TAG: ${{ steps.version.outputs.cli_tag }}
run: |
PKG_DIR="packages/package-builder/build/prod/out/cli-with-sentry"
node scripts/prepare-package-for-publish.mjs "$PKG_DIR" "$VERSION"
node scripts/prepare-package-for-publish.mts "$PKG_DIR" "$VERSION"
cd "$PKG_DIR"
npm publish --provenance --access public --no-git-checks --tag "$TAG"

Expand All @@ -276,7 +276,7 @@ jobs:
TAG: ${{ steps.version.outputs.cli_tag }}
run: |
PKG_DIR="packages/package-builder/build/prod/out/socket"
node scripts/prepare-package-for-publish.mjs "$PKG_DIR" "$VERSION"
node scripts/prepare-package-for-publish.mts "$PKG_DIR" "$VERSION"
cd "$PKG_DIR"
npm publish --provenance --access public --no-git-checks --tag "$TAG"

Expand All @@ -285,7 +285,7 @@ jobs:
if: ${{ inputs.iocraft }}
run: |
echo "Downloading iocraft .node binaries for all platforms..."
node scripts/download-iocraft-binaries.mjs
node scripts/download-iocraft-binaries.mts

# Copy iocraft binaries to package directories.
- name: Copy iocraft binaries to packages
Expand All @@ -295,7 +295,7 @@ jobs:
set -euo pipefail

# Get platform targets from single source of truth.
PLATFORMS_STR=$(node scripts/get-platform-targets.mjs)
PLATFORMS_STR=$(node scripts/get-platform-targets.mts)
read -ra PLATFORMS <<< "$PLATFORMS_STR"

for target in "${PLATFORMS[@]}"; do
Expand All @@ -320,7 +320,7 @@ jobs:
TAG: ${{ steps.version.outputs.iocraft_tag }}
run: |
PKG_DIR="packages/package-builder/build/prod/out/socketaddon-iocraft"
node scripts/prepare-package-for-publish.mjs "$PKG_DIR" "$VERSION"
node scripts/prepare-package-for-publish.mts "$PKG_DIR" "$VERSION"
cd "$PKG_DIR"
npm publish --provenance --access public --no-git-checks --tag "$TAG"

Expand All @@ -334,7 +334,7 @@ jobs:
set -euo pipefail

# Get platform targets from single source of truth.
PLATFORMS_STR=$(node scripts/get-platform-targets.mjs)
PLATFORMS_STR=$(node scripts/get-platform-targets.mts)
read -ra PLATFORMS <<< "$PLATFORMS_STR"

for target in "${PLATFORMS[@]}"; do
Expand All @@ -343,7 +343,7 @@ jobs:
PKG_DIR="packages/package-builder/build/prod/out/socketaddon-iocraft-${target}"

# Prepare package.
node scripts/prepare-package-for-publish.mjs "$PKG_DIR" "$VERSION"
node scripts/prepare-package-for-publish.mts "$PKG_DIR" "$VERSION"

# Publish.
cd "$PKG_DIR"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,4 @@ packages/socket/*.png
!docs/build/
!packages/package-builder/templates/**/*.d.ts
!src/types/**/*.d.ts
!packages/*/src/types/**/*.d.ts
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@
},
"scripts": {
"// Build": "",
"build": "node scripts/build.mjs",
"build:force": "node scripts/build.mjs --force",
"build": "node scripts/build.mts",
"build:force": "node scripts/build.mts --force",
"build:cli": "pnpm --filter @socketsecurity/cli run build",
"build:watch": "pnpm --filter @socketsecurity/cli run build:watch",
"build:sea": "pnpm --filter @socketsecurity/cli run build:sea",
"build:js": "pnpm --filter @socketsecurity/cli run build:js",
"dev": "pnpm run build:watch",
"prebuild": "node scripts/setup.mjs --restore-cache --quiet",
"prebuild": "node scripts/setup.mts --restore-cache --quiet",
"// Quality Checks": "",
"check": "node scripts/check.mjs",
"check:all": "node scripts/check.mjs --all",
"fix": "node scripts/fix.mjs",
"fix:all": "node scripts/fix.mjs --all",
"lint": "node scripts/lint.mjs",
"lint:all": "node scripts/lint.mjs --all",
"check": "node scripts/check.mts",
"check:all": "node scripts/check.mts --all",
"fix": "node scripts/fix.mts",
"fix:all": "node scripts/fix.mts --all",
"lint": "node scripts/lint.mts",
"lint:all": "node scripts/lint.mts --all",
"format": "oxfmt --write .",
"format:check": "oxfmt --check .",
"// Claude": "",
"claude": "pnpm --filter @socketsecurity/cli run claude --",
"// Type Checking": "",
"type": "node scripts/type.mjs",
"type:all": "node scripts/type.mjs",
"type": "node scripts/type.mts",
"type:all": "node scripts/type.mts",
"// Testing": "",
"test": "node scripts/test-monorepo.mjs",
"test:all": "node scripts/test-monorepo.mjs --all",
"test": "node scripts/test-monorepo.mts",
"test:all": "node scripts/test-monorepo.mts --all",
"test:unit": "pnpm --filter @socketsecurity/cli run test:unit",
"pretest:all": "pnpm run build",
"testu": "pnpm --filter @socketsecurity/cli run test:unit:update",
Expand All @@ -42,12 +42,12 @@
"security": "agentshield scan && { command -v zizmor >/dev/null && zizmor .github/ || echo 'zizmor not installed — run pnpm run setup to install'; }",
"// Maintenance": "",
"clean": "pnpm --filter \"./packages/**\" run clean",
"clean:cache": "node scripts/clean-cache.mjs",
"clean:cache:all": "node scripts/clean-cache.mjs --all",
"update": "node scripts/update.mjs",
"clean:cache": "node scripts/clean-cache.mts",
"clean:cache:all": "node scripts/clean-cache.mts --all",
"update": "node scripts/update.mts",
"// Setup": "",
"setup": "node scripts/setup.mjs",
"postinstall": "node scripts/setup.mjs --install --quiet",
"setup": "node scripts/setup.mts",
"postinstall": "node scripts/setup.mts --install --quiet",
"prepare": "husky",
"pretest": "pnpm run build:cli"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
* }
*/

import { transformUnicodePropertyEscapes } from './unicode-property-escape-transform.mjs'
import type { PluginBuild, BuildResult } from 'esbuild'

import { transformUnicodePropertyEscapes } from './unicode-property-escape-transform.mts'

/**
* Create esbuild plugin for Unicode property escape transformations.
Expand All @@ -22,8 +24,8 @@ import { transformUnicodePropertyEscapes } from './unicode-property-escape-trans
export function unicodeTransformPlugin() {
return {
name: 'unicode-transform',
setup(build) {
build.onEnd(result => {
setup(build: PluginBuild) {
build.onEnd((result: BuildResult) => {
const outputs = result.outputFiles
if (!outputs || !outputs.length) {
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,9 @@ export function parsePlatformTarget(target) {
// Handle standard platform-arch.
const parts = target.split('-')
if (parts.length === 2) {
let [platform, arch] = parts
const [rawPlatform, arch] = parts
// Normalize 'win' to 'win32' for internal use.
if (platform === 'win') {
platform = 'win32'
}
const platform = rawPlatform === 'win' ? 'win32' : rawPlatform
if (VALID_PLATFORMS.includes(platform) && VALID_ARCHS.includes(arch)) {
return { arch, platform }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { getDefaultLogger } from '@socketsecurity/lib/logger'

const logger = getDefaultLogger()
const traverse =
typeof traverseImport === 'function' ? traverseImport : traverseImport.default
typeof traverseImport === 'function' ? traverseImport : (traverseImport as any).default

/**
* Map of Unicode property escapes to explicit character ranges.
Expand Down Expand Up @@ -140,7 +140,7 @@ export const unicodePropertyMap = {
/**
* Check if a regex pattern has unsupported Unicode features.
*/
function hasUnsupportedUnicodeFeatures(pattern) {
function hasUnsupportedUnicodeFeatures(pattern: string) {
// Check for \u{} escapes (require /u flag).
if (/\\u\{[0-9a-fA-F]+\}/.test(pattern)) {
return true
Expand All @@ -155,7 +155,7 @@ function hasUnsupportedUnicodeFeatures(pattern) {
/**
* Transform a regex pattern by replacing \p{Property} with character classes.
*/
function transformRegexPattern(pattern) {
function transformRegexPattern(pattern: string) {
let transformed = pattern

// Replace \p{Property} with character class equivalents.
Expand All @@ -176,7 +176,7 @@ function transformRegexPattern(pattern) {
* When we get a pattern from Babel's StringLiteral.value, backslashes are interpreted.
* But when writing back into source code, we need to re-escape them.
*/
function escapeForStringLiteral(str) {
function escapeForStringLiteral(str: string) {
return (
str
// Backslash must be doubled.
Expand All @@ -196,7 +196,7 @@ function escapeForStringLiteral(str) {
* @param {string} content - Source code to transform
* @returns {string} Transformed source code
*/
export function transformUnicodePropertyEscapes(content) {
export function transformUnicodePropertyEscapes(content: string) {
let ast
try {
ast = parse(content, {
Expand All @@ -205,14 +205,14 @@ export function transformUnicodePropertyEscapes(content) {
})
} catch (e) {
// If parsing fails, return content unchanged.
logger.warn('Failed to parse code for Unicode transform:', e.message)
logger.warn('Failed to parse code for Unicode transform:', e instanceof Error ? e.message : e)
return content
}

const s = new MagicString(content)

traverse(ast, {
RegExpLiteral(path) {
RegExpLiteral(path: any) {
const { node } = path
const { flags, pattern } = node
const { end, start } = node
Expand Down Expand Up @@ -280,7 +280,7 @@ export function transformUnicodePropertyEscapes(content) {
}
},

NewExpression(path) {
NewExpression(path: any) {
const { node } = path

// Check if this is a RegExp constructor.
Expand Down
14 changes: 7 additions & 7 deletions packages/build-infra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
"private": true,
"type": "module",
"exports": {
"./lib/esbuild-helpers": "./lib/esbuild-helpers.mjs",
"./lib/esbuild-plugin-unicode-transform": "./lib/esbuild-plugin-unicode-transform.mjs",
"./lib/extraction-cache": "./lib/extraction-cache.mjs",
"./lib/github-error-utils": "./lib/github-error-utils.mjs",
"./lib/github-releases": "./lib/github-releases.mjs",
"./lib/platform-targets": "./lib/platform-targets.mjs",
"./lib/unicode-property-escape-transform": "./lib/unicode-property-escape-transform.mjs"
"./lib/esbuild-helpers": "./lib/esbuild-helpers.mts",
"./lib/esbuild-plugin-unicode-transform": "./lib/esbuild-plugin-unicode-transform.mts",
"./lib/extraction-cache": "./lib/extraction-cache.mts",
"./lib/github-error-utils": "./lib/github-error-utils.mts",
"./lib/github-releases": "./lib/github-releases.mts",
"./lib/platform-targets": "./lib/platform-targets.mts",
"./lib/unicode-property-escape-transform": "./lib/unicode-property-escape-transform.mts"
},
"dependencies": {
"@babel/parser": "catalog:",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
* Builds all variants (CLI bundle + entry point) in parallel.
*
* Usage:
* node .config/esbuild.build.mjs # Build all variants
* node .config/esbuild.build.mjs cli # Build CLI bundle
* node .config/esbuild.build.mjs index # Build entry point
* node .config/esbuild.build.mts # Build all variants
* node .config/esbuild.build.mts cli # Build CLI bundle
* node .config/esbuild.build.mts index # Build entry point
*/

import { fileURLToPath } from 'node:url'

import { getDefaultLogger } from '@socketsecurity/lib/logger'

import { runBuild } from '../scripts/esbuild-utils.mjs'
import cliConfig from './esbuild.cli.mjs'
import indexConfig from './esbuild.index.mjs'
import type { BuildOptions } from 'esbuild'

import { runBuild } from '../scripts/esbuild-utils.mts'
import cliConfig from './esbuild.cli.mts'
import indexConfig from './esbuild.index.mts'

const logger = getDefaultLogger()

Expand All @@ -34,13 +36,14 @@ async function main() {
return
}

const configRecord = CONFIGS as unknown as Record<string, BuildOptions>
const targets =
variant === 'all'
? Object.entries(CONFIGS)
: [[variant, CONFIGS[variant]]]
? Object.entries(configRecord)
: [[variant, configRecord[variant]]]

const results = await Promise.allSettled(
targets.map(({ 0: name, 1: config }) => runBuild(config, name)),
targets.map(({ 0: name, 1: config }) => runBuild(config as BuildOptions, name as string)),
)
const failed = results.filter(r => r.status === 'rejected')
if (failed.length > 0) {
Expand Down
Loading