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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
15 changes: 5 additions & 10 deletions .config/rollup.base.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ import { nodeResolve } from '@rollup/plugin-node-resolve'
import replacePlugin from '@rollup/plugin-replace'
import { purgePolyfills } from 'unplugin-purge-polyfills'

import { readPackageJsonSync } from '@socketsecurity/registry/lib/packages'
import { escapeRegExp } from '@socketsecurity/registry/lib/regexps'
import { spawnSync } from '@socketsecurity/registry/lib/spawn'
import { stripAnsi } from '@socketsecurity/registry/lib/strings'

import constants from '../scripts/constants.js'
import { readPackageJsonSync } from '../scripts/lib/packages.js'
import { escapeRegExp } from '../scripts/lib/regexps.js'
import { spawnSync } from '../scripts/lib/spawn.js'
import { stripAnsi } from '../scripts/lib/strings.js'
import socketModifyPlugin from '../scripts/rollup/socket-modify-plugin.js'
import {
getPackageName,
Expand All @@ -39,11 +38,7 @@ const {
VITEST,
} = constants

export const EXTERNAL_PACKAGES = [
'@socketsecurity/registry',
'blessed',
'blessed-contrib',
]
export const EXTERNAL_PACKAGES = ['blessed', 'blessed-contrib']

const builtinAliases = builtinModules.reduce((o, n) => {
if (!n.startsWith('node:')) {
Expand Down
9 changes: 4 additions & 5 deletions .config/rollup.cdxgen-sea.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import url from 'node:url'
import commonjsPlugin from '@rollup/plugin-commonjs'
import jsonPlugin from '@rollup/plugin-json'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import { parse as parseYaml } from 'yaml'

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

const root = path.resolve(
path.dirname(url.fileURLToPath(import.meta.url)),
Expand Down Expand Up @@ -145,12 +146,10 @@ function thirdPartyNoticePlugin() {
const packages = new Map()
const sourceModules = new Map()
const unmappedModuleCount = { count: 0 }
const lock = parseYaml(
const lock = parsePnpmLock(
await fs.readFile(path.join(root, 'pnpm-lock.yaml'), 'utf8'),
await fs.readFile(path.join(root, 'pnpm-workspace.yaml'), 'utf8'),
)
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
75 changes: 25 additions & 50 deletions .config/rollup.dist.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,14 @@ import jsonPlugin from '@rollup/plugin-json'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import fastGlob from 'fast-glob'
import trash from 'trash'

import { isDirEmptySync } from '@socketsecurity/registry/lib/fs'
import { hasKeys } from '@socketsecurity/registry/lib/objects'
import {
fetchPackageManifest,
readPackageJson,
} from '@socketsecurity/registry/lib/packages'
import { normalizePath } from '@socketsecurity/registry/lib/path'
import { escapeRegExp } from '@socketsecurity/registry/lib/regexps'
import { naturalCompare } from '@socketsecurity/registry/lib/sorts'
import { spawn } from '@socketsecurity/registry/lib/spawn'

import baseConfig, { EXTERNAL_PACKAGES } from './rollup.base.config.mjs'
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 socketModifyPlugin from '../scripts/rollup/socket-modify-plugin.js'
import {
getPackageName,
Expand All @@ -34,6 +28,7 @@ import {
includedModulesInventoryPlugin,
writeCopiedPackageInventory,
} from '../src/sea/rollup-provenance.mjs'
import baseConfig, { EXTERNAL_PACKAGES } from './rollup.base.config.mjs'

const {
CONSTANTS,
Expand Down Expand Up @@ -70,13 +65,12 @@ 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'
const SOCKET_DESCRIPTION_WITH_SENTRY = `${SOCKET_DESCRIPTION}, includes Sentry error handling, otherwise identical to the regular \`${SOCKET_CLI_BIN_NAME}\` package`
const UTILS = 'utils'
const SOCKET_SECURITY_REGISTRY = '@socketsecurity/registry'
const VENDOR = 'vendor'

// A fresh regexp per call: socketModifyPlugin advances lastIndex, so a shared
Expand All @@ -90,7 +84,10 @@ function newBareBlessedRequireRegExp() {
function relativeBlessedPath(filepath) {
return (
normalizePath(
path.relative(path.dirname(filepath), constants.blessedPath),
path.relative(
path.dirname(path.resolve(filepath)),
constants.blessedPath,
),
) || '.'
)
}
Expand Down Expand Up @@ -159,9 +156,7 @@ async function copyManifestScripts() {
jarPath,
path.join(destDir, 'maven-extension', 'coana-maven-extension.jar'),
)
} else if (
constants.ENV[INLINED_SOCKET_CLI_PUBLISHED_BUILD]
) {
} else if (constants.ENV[INLINED_SOCKET_CLI_PUBLISHED_BUILD]) {
// Fail closed: a published build without the jar would ship a package whose
// `socket manifest maven` / Maven reachability silently produces an empty
// SBOM. Run `pnpm run build:maven-extension` before `build:dist`. (A local
Expand All @@ -184,7 +179,7 @@ async function copyBashCompletion() {
}

async function copyExternalPackages() {
const { blessedContribPath, blessedPath, socketRegistryPath } = constants
const { blessedContribPath, blessedPath } = constants
const nmPath = path.join(constants.rootPath, NODE_MODULES)
const blessedContribNmPath = path.join(nmPath, BLESSED_CONTRIB)

Expand All @@ -195,11 +190,7 @@ async function copyExternalPackages() {
// have it bundled as ./external/blessed-contrib.
.filter(n => n !== BLESSED_CONTRIB)
// Copy the other packages over to ./external/.
.map(n =>
copyPackage(n, {
strict: n !== SOCKET_SECURITY_REGISTRY,
}),
),
.map(n => copyPackage(n)),
// Copy 'blessed-contrib' license over to
// ./external/blessed-contrib/LICENSE.md.
await fs.cp(
Expand All @@ -222,16 +213,6 @@ async function copyExternalPackages() {
// would be dropped too).
[blessedPath, ['lib/**/*.js', 'usr/*', 'vendor/**/*.js']],
[blessedContribPath, ['lib/**/*.js', 'index.js']],
[
socketRegistryPath,
[
'external/**/*.js',
'lib/**/*.js',
'index.js',
'extensions.json',
'manifest.json',
],
],
].map(async ({ 0: thePath, 1: ignorePatterns }) => {
await removeFiles(thePath, {
exclude: [...alwaysIgnoredPatterns, ...ignorePatterns],
Expand Down Expand Up @@ -369,7 +350,7 @@ async function updatePackageLockFile() {
return
}
try {
await spawn(
await spawnAsync(
'pnpm',
[
'install',
Expand Down Expand Up @@ -524,6 +505,14 @@ 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 Expand Up @@ -590,20 +579,6 @@ export default async () => {
// Copy external packages AFTER other operations to avoid conflicts.
await copyExternalPackages()
if (process.env[SEA_BUILD_ENV] === 'true') {
await writeCopiedPackageInventory({
root: rootPath,
packageName: SOCKET_SECURITY_REGISTRY,
packageRoot: path.join(
rootPath,
NODE_MODULES,
SOCKET_SECURITY_REGISTRY,
),
outputPackageRoot: constants.socketRegistryPath,
outputRoot: distPath,
inventoryFile:
'THIRD-PARTY-NOTICES-external-socket-registry.json',
bundleId: 'external-socket-registry',
})
await writeCopiedPackageInventory({
root: rootPath,
packageName: BLESSED,
Expand Down
2 changes: 2 additions & 0 deletions .config/taze.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export default defineConfig({
'terminal-link',
'yargs-parser',
],
// CI pins pnpm with checksummed binaries; update it alongside those workflows.
depFields: { packageManager: false },
// Interactive mode disabled for automation.
interactive: false,
// Use minimal logging similar to ncu loglevel.
Expand Down
6 changes: 5 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
* text=auto eol=lfs
* text=auto eol=lf

# Generated terminal image baselines are reviewed through the screenshot report.
test/snapshots/termless/**/*.svg binary linguist-generated=true
test/snapshots/termless/**/*.png binary linguist-generated=true
Loading
Loading