-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
149 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,52 @@ | ||
import * as browser from '@sentry/browser'; | ||
import * as renderer from '../esm/renderer/index.js'; | ||
|
||
import * as node from '@sentry/node'; | ||
|
||
// We need to shim electron to avoid errors when importing the main process code into plain-old-node that doesn't have | ||
// the electron module built-in. | ||
import './electron-shim.mjs'; | ||
|
||
const main = await import('../esm/main/index.js'); | ||
|
||
const browserExports = Object.keys(browser); | ||
const rendererExports = Object.keys(renderer); | ||
const nodeExports = Object.keys(node); | ||
const mainExports = Object.keys(main); | ||
|
||
const ignoredBrowser = [ | ||
'SDK_VERSION', | ||
'WINDOW', | ||
'Integrations', | ||
'close', | ||
'flush', | ||
'defaultStackLineParsers', | ||
// These wont ever be used | ||
'geckoStackLineParser', | ||
'opera10StackLineParser', | ||
'opera11StackLineParser', | ||
'winjsStackLineParser', | ||
// If you use the browser transports, just use the browser SDK | ||
'makeBrowserOfflineTransport', | ||
'makeFetchTransport', | ||
'makeMultiplexedTransport', | ||
'lazyLoadIntegration', | ||
]; | ||
|
||
const ignoredNode = ['SDK_VERSION', 'makeNodeTransport', 'getSentryRelease']; | ||
|
||
const missingRenderer = browserExports.filter((key) => !rendererExports.includes(key) && !ignoredBrowser.includes(key)); | ||
const missingMain = nodeExports.filter((key) => !mainExports.includes(key) && !ignoredNode.includes(key)); | ||
|
||
if (missingRenderer.length || missingMain.length) { | ||
if (missingRenderer.length) { | ||
console.error('Missing renderer exports:', missingRenderer); | ||
} | ||
|
||
if (missingMain.length) { | ||
console.error('Missing main exports:', missingMain); | ||
export default async function () { | ||
// We need to shim electron to avoid errors when importing the main process code into plain-old-node that doesn't have | ||
// the electron module built-in. | ||
await import('./electron-shim.mjs'); | ||
|
||
const renderer = await import('../esm/renderer/index.js'); | ||
const main = await import('../esm/main/index.js'); | ||
|
||
const browserExports = Object.keys(browser); | ||
const rendererExports = Object.keys(renderer); | ||
const nodeExports = Object.keys(node); | ||
const mainExports = Object.keys(main); | ||
|
||
const ignoredBrowser = [ | ||
'SDK_VERSION', | ||
'WINDOW', | ||
'Integrations', | ||
'close', | ||
'flush', | ||
'defaultStackLineParsers', | ||
// These wont ever be used | ||
'geckoStackLineParser', | ||
'opera10StackLineParser', | ||
'opera11StackLineParser', | ||
'winjsStackLineParser', | ||
// If you use the browser transports, just use the browser SDK | ||
'makeBrowserOfflineTransport', | ||
'makeFetchTransport', | ||
'makeMultiplexedTransport', | ||
'lazyLoadIntegration', | ||
]; | ||
|
||
const ignoredNode = ['SDK_VERSION', 'makeNodeTransport', 'getSentryRelease']; | ||
|
||
const missingRenderer = browserExports.filter( | ||
(key) => !rendererExports.includes(key) && !ignoredBrowser.includes(key), | ||
); | ||
const missingMain = nodeExports.filter((key) => !mainExports.includes(key) && !ignoredNode.includes(key)); | ||
|
||
if (missingRenderer.length || missingMain.length) { | ||
if (missingRenderer.length) { | ||
console.error('⚠️ Missing renderer exports ⚠️\n', missingRenderer); | ||
} | ||
|
||
if (missingMain.length) { | ||
console.error('⚠️ Missing main exports ⚠️\n', missingMain); | ||
} | ||
} | ||
|
||
process.exit(1); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import updateVersion from './update-version.mjs'; | ||
import updateSdkVersions from './update-sdk-versions.mjs'; | ||
import checkPackageExports from './check-exports.mjs'; | ||
|
||
/** | ||
* Each script is made up of one or more commands. | ||
* | ||
* Commands can be: | ||
* - String commands to be executed in the shell | ||
* - String that refers to another script | ||
* - JavaScript functions (sync or async) | ||
*/ | ||
scripts({ | ||
clean: 'rimraf --glob coverage common esm main preload renderer index.* sentry-electron*.tgz .eslintcache', | ||
build: ['clean', updateVersion, 'rollup --config rollup.config.mjs', checkPackageExports], | ||
lint: [updateVersion, 'lint:prettier', 'lint:eslint'], | ||
'lint:prettier': 'prettier --check "{src,test}/**/*.ts"', | ||
'lint:eslint': 'eslint . --cache --format stylish', | ||
fix: [updateVersion, 'fix:prettier', 'fix:eslint'], | ||
'fix:prettier': 'prettier --write "{src,test}/**/*.ts"', | ||
'fix:eslint': 'eslint . --cache --format --fix', | ||
'update-electron-versions': 'electron-latest-versions --start 15 --beta > ./test/e2e/versions.json', | ||
'update-sdk-versions': updateSdkVersions, | ||
test: ['build', 'vitest run --root=./test/unit'], | ||
e2e: [ | ||
'rimraf --glob test/e2e/dist/**/node_modules/@sentry/** test/e2e/dist/**/yarn.lock test/e2e/dist/**/package-lock.json', | ||
'yarn cache clean', | ||
'build', | ||
'npm pack', | ||
'xvfb-maybe vitest run --root=./test/e2e --silent=false --disable-console-intercept', | ||
], | ||
}); | ||
|
||
import { execSync } from 'child_process'; | ||
|
||
function scripts(scripts) { | ||
async function run(cmd) { | ||
for (const next of Array.isArray(scripts[cmd]) ? scripts[cmd] : [scripts[cmd]]) { | ||
if (typeof next === 'function') await next(); | ||
else if (next in scripts) await run(next); | ||
else { | ||
console.log(`\n> ${next}`); | ||
execSync(next, { stdio: 'inherit' }); | ||
} | ||
} | ||
} | ||
|
||
run(process.argv[2]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { join } from 'path'; | ||
import { readFileSync, writeFileSync } from 'fs'; | ||
import { fileURLToPath } from 'url'; | ||
|
||
const __dirname = fileURLToPath(new URL('.', import.meta.url)); | ||
|
||
export default function () { | ||
const packageJson = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'))); | ||
|
||
// SDK_VERSION to 'src/main/version.ts' | ||
const versionPath = join(__dirname, '../src/main/version.ts'); | ||
writeFileSync(versionPath, `export const SDK_VERSION = '${packageJson.version}';\n`); | ||
|
||
// Write @sentry/core version into options variable name so TypeScript error includes useful hint | ||
const coreVersion = packageJson.dependencies['@sentry/core']; | ||
const coreVersionVar = coreVersion.replace(/[\.-]/g, '_'); | ||
const rendererSdkPath = join(__dirname, '../src/renderer/sdk.ts'); | ||
let rendererSdk = readFileSync(rendererSdkPath, { encoding: 'utf8' }); | ||
rendererSdk = rendererSdk.replace(/version_v\d+_\d+_\d+[a-z_0-9]*/, `version_v${coreVersionVar}`); | ||
writeFileSync(rendererSdkPath, rendererSdk); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters