Skip to content
Open
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
62 changes: 62 additions & 0 deletions build/package/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,41 @@ conditions of the following licenses.
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

- '@protobuf-ts/runtime' in extension/dist/ext/extension.js
- '@protobuf-ts/runtime' in node_modules/@omega-edit/client
This product bundles '@protobuf-ts/runtime' from the above files.
This package is available under the BSD-3-Clause License and Apache License 2.0:

BSD 3-Clause License

Copyright (c) Timo Stamm
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

- 'protobufjs' in extension/dist/ext/extension.js
- 'protobufjs' in node_modules/@omega-edit/client
This product bundles 'protobufjs' from the above files.
Expand Down Expand Up @@ -5214,6 +5249,33 @@ conditions of the following licenses.
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

- '@pinojs/redact' in extension/dist/ext/extension.js
- '@pinojs/redact' in node_modules/@omega-edit/client
This product bundles '@pinojs/redact' from the above files.
These files are available under the MIT License:

MIT License

Copyright (c) 2025 pinojs contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

- 'unicorn-magic' in extension/dist/ext/extension.js
This produces bundles 'unicorn-magic' from the above files
Expand Down
6 changes: 6 additions & 0 deletions build/package/NONOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ The following binary components distributed with this project are licensed under
This package is available under the Apache License v2 without a NOTICE:
Repository at: https://github.com/dcodeIO/long.js

- '@protobuf-ts/runtime-rpc' in extension/dist/ext/extension.js
- '@protobuf-ts/runtime-rpc' in node_modules/@omega-edit/client
This product bundles '@protobuf-ts/runtime-rpc' from the above files.
This package is available under the Apache License v2 without a NOTICE:
Repository at: https://github.com/timostamm/protobuf-ts

- com.fasterxml.woodstox.woodstox-core-<VERSION>.jar in daffodil-debugger-<VERSION>.zip
This product bundles 'woodstox-core' from the above files.
These packages are available under the Apache License v2 without a NOTICE:
Expand Down
234 changes: 231 additions & 3 deletions build/yarn-scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,236 @@ function package() {
# limitations under the License.

**/node_modules/**/*
!node_modules/@omega-edit/server/bin
!node_modules/@omega-edit/server/lib
!node_modules/@vscode/webview-ui-toolkit/**/*
!node_modules/
!node_modules/**/*
`
)
}

function packageNamePath(packageName) {
return path.join(...packageName.split('/'))
}

function readPackageVersion(packageRoot) {
const packageJsonPath = path.join(packageRoot, 'package.json')
if (!fs.existsSync(packageJsonPath)) return undefined

try {
return JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')).version
} catch (err) {
console.warn(
`[omega-edit] Unable to read package version for ${packageRoot}: ${String(
err
)}`
)
return undefined
}
}

function shouldPatchOmegaEditPackage(packageRoot, expectedVersion, label) {
const version = readPackageVersion(packageRoot)
if (version === expectedVersion) {
return true
}

const versionLabel = version ?? 'unknown'
console.warn(
`[omega-edit] Skipping ${label} patch for ${packageRoot}; expected ${expectedVersion}, found ${versionLabel}.`
)
return false
}

function patchOmegaEditClientLogger(
packageRoot = 'node_modules/@omega-edit/client'
) {
if (!shouldPatchOmegaEditPackage(packageRoot, '2.0.0', 'client logger')) {
return
}

const loggerTargets = [
path.join(packageRoot, 'dist/cjs/logger.js'),
path.join(packageRoot, 'dist/esm/logger.js'),
]
const transportPattern =
/setLogger\(buildLogger\(pino(?:_1\.default)?\.transport\(\{[\s\S]*?\}\)\)\);/

loggerTargets.forEach((loggerPath) => {
if (!fs.existsSync(loggerPath)) {
console.warn(`[omega-edit] Client logger not found: ${loggerPath}`)
return
}

const source = fs.readFileSync(loggerPath, 'utf-8')
const patched = source.replace(
transportPattern,
'setLogger(buildLogger(process.stderr));'
)

if (patched === source) {
if (!source.includes('setLogger(buildLogger(process.stderr));')) {
console.warn(
`[omega-edit] Unable to patch OmegaEdit client logger at ${loggerPath}; leaving upstream source unchanged.`
)
}
return
}

fs.writeFileSync(loggerPath, patched, 'utf-8')
})
}

function patchOmegaEditServerLocator(searchRoot = 'node_modules') {
const serverTargets = glob.sync('**/@omega-edit/server/out/index.js', {
cwd: searchRoot,
absolute: true,
nodir: true,
})
const buggyLocator = '.replace("node_modules","")'
const knownFixedLocators = [
'.slice(0,-"node_modules".length)',
'.slice(0,-12)',
]

if (serverTargets.length === 0) {
return
}

serverTargets.forEach((serverPath) => {
const packageRoot = path.dirname(path.dirname(serverPath))
if (!shouldPatchOmegaEditPackage(packageRoot, '2.0.0', 'server locator')) {
return
}

const source = fs.readFileSync(serverPath, 'utf-8')
const patched = source.replaceAll(buggyLocator, knownFixedLocators[0])

if (patched === source) {
if (!knownFixedLocators.some((locator) => source.includes(locator))) {
console.warn(
`[omega-edit] Unable to patch OmegaEdit server locator at ${serverPath}; leaving upstream source unchanged.`
)
}
return
}

fs.writeFileSync(serverPath, patched, 'utf-8')
})
}

function patchOmegaEditRuntime(
packageRoot = 'node_modules/@omega-edit/client',
searchRoot = 'node_modules'
) {
patchOmegaEditClientLogger(packageRoot)
patchOmegaEditServerLocator(searchRoot)
}
Comment thread
scholarsmate marked this conversation as resolved.

function copyPackageRuntimeTree(
packageName,
sourcePackageDir,
destinationPackageDir,
seen = new Set()
) {
const visitKey = `${sourcePackageDir}|${destinationPackageDir}`
if (seen.has(visitKey)) return
seen.add(visitKey)

if (!fs.existsSync(sourcePackageDir)) {
throw new Error(
`Package source not found for ${packageName}: ${sourcePackageDir}`
)
}

rmFileOrDirectory(destinationPackageDir)
fs.mkdirSync(path.dirname(destinationPackageDir), { recursive: true })
fs.cpSync(sourcePackageDir, destinationPackageDir, {
recursive: true,
force: true,
})

const packageJsonPath = path.join(sourcePackageDir, 'package.json')
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'))
const dependencies = Object.keys(packageJson.dependencies || {})

if (dependencies.length === 0) return

const destinationNodeModulesDir = path.join(
destinationPackageDir,
'node_modules'
)

dependencies.forEach((dependencyName) => {
const sourceDependencyDirCandidates = [
path.join(
sourcePackageDir,
'node_modules',
packageNamePath(dependencyName)
),
path.join('node_modules', packageNamePath(dependencyName)),
]
const sourceDependencyDir = sourceDependencyDirCandidates.find(
(candidate) => fs.existsSync(candidate)
)

if (!sourceDependencyDir) {
throw new Error(
`Unable to resolve runtime dependency ${dependencyName} for ${packageName}`
)
}

copyPackageRuntimeTree(
dependencyName,
sourceDependencyDir,
path.join(destinationNodeModulesDir, packageNamePath(dependencyName)),
seen
)
})
}

function syncOmegaEditClientRuntime() {
const clientPackageName = '@omega-edit/client'
const sourceClientDir = path.join(
'node_modules',
packageNamePath(clientPackageName)
)
const destinationClientDir = path.join(
'dist/package/node_modules',
packageNamePath(clientPackageName)
)

patchOmegaEditRuntime(sourceClientDir, 'node_modules')
copyPackageRuntimeTree(
clientPackageName,
sourceClientDir,
destinationClientDir
)
patchOmegaEditRuntime(destinationClientDir, 'dist/package/node_modules')
}

function packageVsix() {
const vsceCommand =
process.platform === 'win32'
? path.resolve('node_modules', '.bin', 'vsce.cmd')
: path.resolve('node_modules', '.bin', 'vsce')

const result = child_process.spawnSync(
vsceCommand,
['package', '--out', '../../'],
{
cwd: 'dist/package',
stdio: 'inherit',
shell: process.platform === 'win32',
}
)

if (result.error) {
console.error(result.error)
process.exit(1)
}

process.exit(result.status === null ? 1 : result.status)
}

/* START SECTION: Update version */
// helper function to get the version passed in
function parseArgs() {
Expand Down Expand Up @@ -257,6 +480,11 @@ module.exports = {
updateVersion: updateVersion,
watch: watch,
package: package,
patchOmegaEditClientLogger: patchOmegaEditClientLogger,
patchOmegaEditServerLocator: patchOmegaEditServerLocator,
patchOmegaEditRuntime: patchOmegaEditRuntime,
syncOmegaEditClientRuntime: syncOmegaEditClientRuntime,
packageVsix: packageVsix,
checkMissingLicenseData: checkMissingLicenseData,
checkLicenseCompatibility: checkLicenseCompatibility,
}
Loading
Loading