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
7 changes: 4 additions & 3 deletions .claude/skills/bump-cdxgen/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ user-invocable: true
Take the exact released version as `$ARGUMENTS`; ask if missing. Read
[the VFS and provenance reference](references/vfs-provenance.md), update the
exact dev dependency and lockfile with
`pnpm add -D --save-exact "@cyclonedx/cdxgen@$ARGUMENTS"`, then rebuild the
macOS arm64 SEA prototype with `pnpm build:sea -- --prototype`.
`pnpm add -D --save-exact "@cyclonedx/cdxgen@$ARGUMENTS"`, then run
`pnpm build:sea` to rebuild the SEA for the local OS and architecture.
Run this check on macOS arm64 to include the cdxgen payload.

Check the new dependency graph and update package-version-specific provenance,
license text, and notices where required. Keep the cdxgen capability unavailable
Expand All @@ -21,7 +22,7 @@ unavailable:
```sh
pnpm run test:unit \
test/unit/sea/build-sea.test.mts test/unit/sea/runtime.test.mts
pnpm build:sea -- --prototype
pnpm build:sea
```

Create one signed conventional commit and a PR against `v1.x`.
2 changes: 1 addition & 1 deletion .claude/skills/bump-node-sea/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ supported SEA target and exposes the SEA/VFS APIs the builder uses. Build the
native prototype first. It updates the README marker from the new pin:

```sh
pnpm build:sea -- --prototype
pnpm build:sea
```

Then run the Node pin and SEA builder tests:
Expand Down
2 changes: 1 addition & 1 deletion .claude/skills/bump-socket/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dry run for the requested lane:
gh workflow run publish-npm.yml --ref v1.x \
-f mode=release-pr -f dry-run=true -f release-major=1

# Native 2.1 prerelease: socket only
# Native 2.1 prerelease: socket launcher and five platform packages
gh workflow run publish-npm.yml --ref v1.x \
-f mode=release-pr -f dry-run=true -f release-major=2
```
Expand Down
5 changes: 3 additions & 2 deletions .claude/skills/bump-socket/references/release-lanes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ first; publishing is a separate dispatch after that PR is merged.
| Lane | Release line | npm packages | npm dist-tag |
| --- | --- | --- | --- |
| Stable | v1.x | `socket`, `@socketsecurity/cli`, `@socketsecurity/cli-with-sentry` | `latest` |
| Native prerelease | 2.1.0 RCs | `socket` only | `rc-2.1.0` |
| Native prerelease | 2.1.0 RCs | `socket` launcher and five exact-version platform packages | `rc-2.1.0` |

The package list is enforced by `scripts/release/packages.mts`. The build
matrix is defined in `scripts/build-package-matrix.mts`. Prerelease versions
Expand All @@ -22,5 +22,6 @@ preparation PR.

After the merged version PR, the separate `mode=publish` workflow builds and
tests package tarballs. Stable releases stage all three packages; RC releases
stage only `socket`. A human approves each npm stage ID locally. Approval and
stage the five platform packages and the `socket` launcher. Approve the platform
stages first, then the launcher. Approval and
GitHub release creation are not part of the bump skill.
5 changes: 3 additions & 2 deletions .claude/skills/bump-synp/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ user-invocable: true
Take the exact released version as `$ARGUMENTS`; ask if missing. Read
[the VFS and notice reference](references/vfs-notices.md), update the exact dev
dependency and lockfile with `pnpm add -D --save-exact "synp@$ARGUMENTS"`, then
rebuild the macOS arm64 SEA prototype with `pnpm build:sea -- --prototype`.
run `pnpm build:sea` to rebuild the SEA for the local OS and architecture.
Run this check on macOS arm64 to include the synp payload.

Keep the Yarn Classic capability unavailable while source provenance or notice
obligations remain unresolved. Run the SEA builder and runtime tests, then
Expand All @@ -18,7 +19,7 @@ inspect the manifest and confirm the capability remains unavailable:
```sh
pnpm run test:unit \
test/unit/sea/build-sea.test.mts test/unit/sea/runtime.test.mts
pnpm build:sea -- --prototype
pnpm build:sea
```

Create one signed conventional commit and a PR against `v1.x`.
2 changes: 1 addition & 1 deletion .claude/skills/bump-uv/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ target:
```sh
pnpm run test:unit \
test/unit/sea/build-sea.test.mts test/unit/sea/runtime.test.mts
pnpm build:sea -- --prototype
pnpm build:sea
```

Confirm the adjacent `build/sea/*.manifest.json` reports the new uv version
Expand Down
13 changes: 13 additions & 0 deletions .config/release-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"npm": {
"version": "12.2.3",
"integrity": "sha512-ovmNRRe76Jvcp1E6iOePQ6H9Zr4XMOrqgfaeGNhtRvP3XSl2Lo/a9C1N5/jRlLLrsqCem/omgGdZHpZ5a6yn1Q=="
},
"pnpm": {
"darwin-arm64": "52bb314bf0d48928fc15126ccce42aa199275e29018bef112a04ae8acdcaaf14",
"linux-arm64": "dd03f7616625ff8f13d952f641f0864a2300d73d0a751a682737615bd9f9a7a2",
"linux-x64": "b515e29f2ac1adc0fbe63173414a6682827baff24f17e7ad3476821bdef236ac",
"win32-arm64": "d38e823fad07b42edbba6206c56dcb3b5bcf1a6e18a6ba7cd0602490c02fb186",
"win32-x64": "1a954bdc1b15ff036294279391d01a09407b7d46ff972a59d81f23becce96c1c"
}
}
16 changes: 15 additions & 1 deletion .config/rollup.base.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ const {
INLINED_SOCKET_CLI_VERSION_HASH,
NODE_MODULES,
ROLLUP_EXTERNAL_SUFFIX,
SOCKET_CLI_LEGACY_PACKAGE_NAME,
SOCKET_CLI_PACKAGE_NAME,
SOCKET_CLI_SENTRY_PACKAGE_NAME,
UTF8,
VITEST,
} = constants
Expand All @@ -47,6 +50,17 @@ const builtinAliases = builtinModules.reduce((o, n) => {
return o
}, {})

// The previous variant can still be named in package.json while Rollup runs.
export function getBuildPackageName() {
if (constants.ENV[INLINED_SOCKET_CLI_LEGACY_BUILD]) {
return SOCKET_CLI_LEGACY_PACKAGE_NAME
}
if (constants.ENV[INLINED_SOCKET_CLI_SENTRY_BUILD]) {
return SOCKET_CLI_SENTRY_PACKAGE_NAME
}
return SOCKET_CLI_PACKAGE_NAME
}

let _rootPkgJson
function getRootPkgJsonSync() {
if (_rootPkgJson === undefined) {
Expand Down Expand Up @@ -205,7 +219,7 @@ export default function baseConfig(extendConfig = {}) {
],
[
INLINED_SOCKET_CLI_NAME,
() => JSON.stringify(getRootPkgJsonSync().name),
() => JSON.stringify(getBuildPackageName()),
],
[
INLINED_SOCKET_CLI_PUBLISHED_BUILD,
Expand Down
10 changes: 5 additions & 5 deletions .config/rollup.cdxgen-sea.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import commonjsPlugin from '@rollup/plugin-commonjs'
import jsonPlugin from '@rollup/plugin-json'
import { nodeResolve } from '@rollup/plugin-node-resolve'

import { parsePnpmLock } from '../src/sea/pnpm-lock.mts'
import { readPnpmLock } from '../src/sea/pnpm-lock.mts'

const root = path.resolve(
path.dirname(url.fileURLToPath(import.meta.url)),
Expand Down Expand Up @@ -146,10 +146,10 @@ function thirdPartyNoticePlugin() {
const packages = new Map()
const sourceModules = new Map()
const unmappedModuleCount = { count: 0 }
const lock = parsePnpmLock(
await fs.readFile(path.join(root, 'pnpm-lock.yaml'), 'utf8'),
await fs.readFile(path.join(root, 'pnpm-workspace.yaml'), 'utf8'),
)
const lock = await readPnpmLock(root)
if (!lock || typeof lock.packages !== 'object' || !lock.packages) {
throw new Error('pnpm-lock.yaml does not contain a packages graph')
}
const lockPackages = lock.packages
const patchedDependencies = lock.patchedDependencies ?? {}
for (const id of this.getModuleIds()) {
Expand Down
118 changes: 47 additions & 71 deletions .config/rollup.dist.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import jsonPlugin from '@rollup/plugin-json'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import fastGlob from 'fast-glob'
import trash from 'trash'

import constants from '../scripts/constants.js'
import { isDirEmptySync } from '../scripts/lib/fs.js'
import { hasKeys } from '../scripts/lib/objects.js'
import { readPackageJson } from '../scripts/lib/packages.js'
import { normalizePath } from '../scripts/lib/path.js'
import { escapeRegExp } from '../scripts/lib/regexps.js'
import { naturalCompare } from '../scripts/lib/sorts.js'
import { fetchPackageManifest, spawnAsync } from '../scripts/lib/spawn.js'
import { spawnAsync } from '../scripts/lib/spawn.js'
import socketModifyPlugin from '../scripts/rollup/socket-modify-plugin.js'
import {
getPackageName,
Expand All @@ -28,7 +29,10 @@ import {
includedModulesInventoryPlugin,
writeCopiedPackageInventory,
} from '../src/sea/rollup-provenance.mjs'
import baseConfig, { EXTERNAL_PACKAGES } from './rollup.base.config.mjs'
import baseConfig, {
EXTERNAL_PACKAGES,
getBuildPackageName,
} from './rollup.base.config.mjs'

const {
CONSTANTS,
Expand All @@ -47,16 +51,13 @@ const {
SLASH_NODE_MODULES_SLASH,
SOCKET_CLI_BIN_NAME,
SOCKET_CLI_BIN_NAME_ALIAS,
SOCKET_CLI_LEGACY_PACKAGE_NAME,
SOCKET_CLI_NPM_BIN_NAME,
SOCKET_CLI_NPX_BIN_NAME,
SOCKET_CLI_PACKAGE_NAME,
SOCKET_CLI_PNPM_BIN_NAME,
SOCKET_CLI_SENTRY_BIN_NAME,
SOCKET_CLI_SENTRY_BIN_NAME_ALIAS,
SOCKET_CLI_SENTRY_NPM_BIN_NAME,
SOCKET_CLI_SENTRY_NPX_BIN_NAME,
SOCKET_CLI_SENTRY_PACKAGE_NAME,
SOCKET_CLI_SENTRY_PNPM_BIN_NAME,
SOCKET_CLI_SENTRY_YARN_BIN_NAME,
SOCKET_CLI_YARN_BIN_NAME,
Expand All @@ -65,7 +66,7 @@ const {
const BLESSED = 'blessed'
const BLESSED_CONTRIB = 'blessed-contrib'
const FLAGS = 'flags'
const LICENSE_MD = 'LICENSE.md'
const LICENSE_MD = `LICENSE.md`
const SENTRY_NODE = '@sentry/node'
const SEA_BUILD_ENV = 'SOCKET_SEA_BUILD'
const SOCKET_DESCRIPTION = 'CLI for Socket.dev'
Expand All @@ -84,10 +85,7 @@ function newBareBlessedRequireRegExp() {
function relativeBlessedPath(filepath) {
return (
normalizePath(
path.relative(
path.dirname(path.resolve(filepath)),
constants.blessedPath,
),
path.relative(path.dirname(filepath), constants.blessedPath),
) || '.'
)
}
Expand Down Expand Up @@ -262,44 +260,33 @@ function blessedContribInventoryPlugin(filepath) {
})
}

async function copyPackage(pkgName, options) {
const { strict = true } = { __proto__: null, ...options }
async function copyPackage(pkgName) {
const nmPath = path.join(constants.rootPath, NODE_MODULES)
const pkgDestPath = path.join(constants.externalPath, pkgName)
const pkgNmPath = path.join(nmPath, pkgName)
// Copy entire package folder over to dist with dereference to follow symlinks.
await fs.cp(pkgNmPath, pkgDestPath, { recursive: true, dereference: true })
if (strict) {
// Add 'use strict' directive to js files.
const jsFiles = await fastGlob.glob(['**/*.js'], {
absolute: true,
cwd: pkgDestPath,
ignore: [NODE_MODULES_GLOB_RECURSIVE],
})
await Promise.all(
jsFiles.map(async p => {
const content = await fs.readFile(p, 'utf8')
// Start by trimming the hashbang.
const hashbang = /^#!.*(?:\r?\n)*/.exec(content)?.[0] ?? ''
let trimmed = content.slice(hashbang.length).trimStart()
// Then, trim "use strict" directive.
const useStrict =
/^(['"])use strict\1;?(?:\r?\n)*/.exec(trimmed)?.[0] ?? ''
trimmed = trimmed.slice(useStrict.length).trimStart()
// Add back hashbang and add "use strict" directive.
const modded = `${hashbang.trim()}${hashbang ? os.EOL : ''}${useStrict.trim() || "'use strict'"}${os.EOL}${os.EOL}${trimmed}`
await fs.writeFile(p, modded, 'utf8')
}),
)
}
}

let _sentryManifest
async function getSentryManifest() {
if (_sentryManifest === undefined) {
_sentryManifest = await fetchPackageManifest(`${SENTRY_NODE}@latest`)
}
return _sentryManifest
// Add 'use strict' directive to js files.
const jsFiles = await fastGlob.glob(['**/*.js'], {
absolute: true,
cwd: pkgDestPath,
ignore: [NODE_MODULES_GLOB_RECURSIVE],
})
await Promise.all(
jsFiles.map(async p => {
const content = await fs.readFile(p, 'utf8')
// Start by trimming the hashbang.
const hashbang = /^#!.*(?:\r?\n)*/.exec(content)?.[0] ?? ''
let trimmed = content.slice(hashbang.length).trimStart()
// Then, trim "use strict" directive.
const useStrict =
/^(['"])use strict\1;?(?:\r?\n)*/.exec(trimmed)?.[0] ?? ''
trimmed = trimmed.slice(useStrict.length).trimStart()
// Add back hashbang and add "use strict" directive.
const modded = `${hashbang.trim()}${hashbang ? os.EOL : ''}${useStrict.trim() || "'use strict'"}${os.EOL}${os.EOL}${trimmed}`
await fs.writeFile(p, modded, 'utf8')
}),
)
}

async function updatePackageJson() {
Expand All @@ -310,22 +297,23 @@ async function updatePackageJson() {
const bin = resetBin(editablePkgJson.content.bin)
const dependencies = resetDependencies(editablePkgJson.content.dependencies)
editablePkgJson.update({
name: SOCKET_CLI_PACKAGE_NAME,
name: getBuildPackageName(),
description: SOCKET_DESCRIPTION,
bin,
dependencies: hasKeys(dependencies) ? dependencies : undefined,
})
if (constants.ENV[INLINED_SOCKET_CLI_LEGACY_BUILD]) {
editablePkgJson.update({
name: SOCKET_CLI_LEGACY_PACKAGE_NAME,
bin: {
[SOCKET_CLI_BIN_NAME_ALIAS]: bin[SOCKET_CLI_BIN_NAME],
...bin,
},
})
} else if (constants.ENV[INLINED_SOCKET_CLI_SENTRY_BUILD]) {
const sentry = await readPackageJson(
path.join(constants.rootPath, NODE_MODULES, SENTRY_NODE),
)
editablePkgJson.update({
name: SOCKET_CLI_SENTRY_PACKAGE_NAME,
description: SOCKET_DESCRIPTION_WITH_SENTRY,
bin: {
[SOCKET_CLI_SENTRY_BIN_NAME_ALIAS]: bin[SOCKET_CLI_BIN_NAME],
Expand All @@ -337,7 +325,7 @@ async function updatePackageJson() {
},
dependencies: {
...dependencies,
[SENTRY_NODE]: (await getSentryManifest()).version,
[SENTRY_NODE]: sentry.version,
},
})
}
Expand All @@ -349,22 +337,18 @@ async function updatePackageLockFile() {
if (!existsSync(rootPackageLockPath)) {
return
}
try {
await spawnAsync(
'pnpm',
[
'install',
'--frozen-lockfile=false',
'--config.confirmModulesPurge=false',
],
{
cwd: constants.rootPath,
stdio: 'inherit',
},
)
} catch (e) {
console.warn('Failed to update pnpm lockfile:', e?.message)
}
await spawnAsync(
'pnpm',
[
'install',
'--frozen-lockfile=false',
'--config.confirmModulesPurge=false',
],
{
cwd: constants.rootPath,
stdio: 'inherit',
},
)
}

async function removeEmptyDirs(thePath) {
Expand Down Expand Up @@ -505,14 +489,6 @@ export default async () => {
switch (id) {
case constantsSrcPath:
return CONSTANTS
case normalizePath(path.join(srcPath, 'constants/runtime.mts')):
return 'runtime-constants'
case normalizePath(path.join(utilsSrcPath, 'env.mts')):
return 'env-helpers'
case normalizePath(path.join(utilsSrcPath, 'spawn-sync.mts')):
return 'spawn-sync'
case normalizePath(path.join(utilsSrcPath, 'spinner.mts')):
return 'spinner'
case flagsSrcPath:
return FLAGS
case shadowNpmBinSrcPath:
Expand Down
Loading
Loading