From 33bf0fb2ae675337a2f47f0db6576cd0f767e237 Mon Sep 17 00:00:00 2001 From: Sertonix <83883937+Sertonix@users.noreply.github.com> Date: Thu, 10 Nov 2022 09:00:10 +0100 Subject: [PATCH] removed unused snippets --- .gitattributes | 10 -- package.json | 3 +- script/config.js | 143 --------------------------- src/initialize-application-window.js | 55 ----------- src/main-process/main.js | 4 - src/pane-container.js | 11 +-- static/index.js | 65 ++---------- 7 files changed, 13 insertions(+), 278 deletions(-) delete mode 100644 script/config.js diff --git a/.gitattributes b/.gitattributes index d2728b926..4505149da 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15,13 +15,3 @@ spec/fixtures/sample.txt text eol=lf # Windows bash scripts are also Unix LF endings *.sh eol=lf - -# The script executables should be LF so they can be edited on Windows -script/bootstrap text eol=lf -script/build text eol=lf -script/cibuild text eol=lf -script/clean text eol=lf -script/lint text eol=lf -script/postprocess-junit-results text eol=lf -script/test text eol=lf -script/verify-snapshot-script text eol=lf diff --git a/package.json b/package.json index 76fa803a8..c6abf0ef0 100644 --- a/package.json +++ b/package.json @@ -289,8 +289,7 @@ "node": true }, "globals": [ - "atom", - "snapshotResult" + "atom" ] }, "devDependencies": { diff --git a/script/config.js b/script/config.js deleted file mode 100644 index da91892a5..000000000 --- a/script/config.js +++ /dev/null @@ -1,143 +0,0 @@ -// This module exports paths, names, and other metadata that is referenced -// throughout the build. - -'use strict'; - -const path = require('path'); -const spawnSync = require('./lib/spawn-sync'); - -const repositoryRootPath = path.resolve(__dirname, '..'); -const apmRootPath = path.join(repositoryRootPath, 'ppm'); -const scriptRootPath = path.join(repositoryRootPath, 'script'); -const scriptRunnerRootPath = path.join(scriptRootPath, 'script-runner'); -const scriptRunnerModulesPath = path.join(scriptRunnerRootPath, 'node_modules'); -const buildOutputPath = path.join(repositoryRootPath, 'out'); -const docsOutputPath = path.join(repositoryRootPath, 'docs', 'output'); -const intermediateAppPath = path.join(buildOutputPath, 'app'); -const symbolsPath = path.join(buildOutputPath, 'symbols'); -const electronDownloadPath = path.join(repositoryRootPath, 'electron'); -const homeDirPath = process.env.HOME || process.env.USERPROFILE; -const atomHomeDirPath = - process.env.ATOM_HOME || path.join(homeDirPath, '.pulsar'); - -const appMetadata = require(path.join(repositoryRootPath, 'package.json')); -const apmMetadata = require(path.join(apmRootPath, 'package.json')); -const computedAppVersion = computeAppVersion( - process.env.ATOM_RELEASE_VERSION || appMetadata.version -); -const channel = getChannel(computedAppVersion); -const appName = getAppName(channel); -const executableName = getExecutableName(channel, appName); -const channelName = getChannelName(channel); - -// Sets the installation jobs to run maximally in parallel if the user has -// not already configured this. This is applied just by requiring this file. -if (process.env.npm_config_jobs === undefined) { - process.env.npm_config_jobs = 'max'; -} - -const REPO_OWNER = process.env.REPO_OWNER || 'pulsar-edit'; -const MAIN_REPO = process.env.MAIN_REPO || 'pulsar'; -const NIGHTLY_RELEASE_REPO = - process.env.NIGHTLY_RELEASE_REPO || 'pulsar-nightly-releases'; - -module.exports = { - appMetadata, - apmMetadata, - channel, - channelName, - appName, - executableName, - computedAppVersion, - repositoryRootPath, - apmRootPath, - scriptRootPath, - scriptRunnerRootPath, - scriptRunnerModulesPath, - buildOutputPath, - docsOutputPath, - intermediateAppPath, - symbolsPath, - electronDownloadPath, - atomHomeDirPath, - homeDirPath, - getApmBinPath, - getNpmBinPath, - getLocalNpmBinPath, - snapshotAuxiliaryData: {}, - REPO_OWNER, - MAIN_REPO, - NIGHTLY_RELEASE_REPO -}; - -function getChannelName(channel) { - return channel === 'stable' ? 'pulsar' : `pulsar-${channel}`; -} - -function getChannel(version) { - const match = version.match(/\d+\.\d+\.\d+(-([a-z]+)(\d+|-\w{4,})?)?$/); - if (!match) { - throw new Error(`Found incorrectly formatted Pulsar version ${version}`); - } else if (match[2]) { - return match[2]; - } - - return 'stable'; -} - -function getAppName(channel) { - return channel === 'stable' - ? 'Pulsar' - : `Pulsar ${process.env.ATOM_CHANNEL_DISPLAY_NAME || - channel.charAt(0).toUpperCase() + channel.slice(1)}`; -} - -function getExecutableName(channel, appName) { - if (process.platform === 'darwin') { - return appName; - } else if (process.platform === 'win32') { - return channel === 'stable' ? 'pulsar.exe' : `pulsar-${channel}.exe`; - } else { - return 'pulsar'; - } -} - -function computeAppVersion(version) { - if (version.match(/-dev$/)) { - const result = spawnSync('git', ['rev-parse', '--short', 'HEAD'], { - cwd: repositoryRootPath - }); - const commitHash = result.stdout.toString().trim(); - version += '-' + commitHash; - } - return version; -} - -function getApmBinPath() { - const apmBinName = process.platform === 'win32' ? 'apm.cmd' : 'apm'; - return path.join( - apmRootPath, - 'node_modules', - 'pulsar-package-manager', - 'bin', - apmBinName - ); -} - -function getNpmBinPath() { - return process.platform === 'win32' ? 'npm.cmd' : 'npm'; -} - -function getLocalNpmBinPath() { - // NOTE this assumes that npm is installed as a script-runner dependency - const npmBinName = process.platform === 'win32' ? 'npm.cmd' : 'npm'; - const localNpmBinPath = path.resolve( - repositoryRootPath, - 'script', - 'script-runner', - 'node_modules', - '.bin', - npmBinName - ); - return localNpmBinPath; -} diff --git a/src/initialize-application-window.js b/src/initialize-application-window.js index 00594fcf9..8abb102ba 100644 --- a/src/initialize-application-window.js +++ b/src/initialize-application-window.js @@ -9,61 +9,6 @@ require('./native-compile-cache'); require('./compile-cache'); require('./module-cache'); -if (global.isGeneratingSnapshot) { - require('about'); - require('archive-view'); - require('autocomplete-atom-api'); - require('autocomplete-css'); - require('autocomplete-html'); - require('autocomplete-plus'); - require('autocomplete-snippets'); - require('autoflow'); - require('autosave'); - require('background-tips'); - require('bookmarks'); - require('bracket-matcher'); - require('command-palette'); - require('deprecation-cop'); - require('dev-live-reload'); - require('encoding-selector'); - require('exception-reporting'); - require('dalek'); - require('find-and-replace'); - require('fuzzy-finder'); - require('github'); - require('git-diff'); - require('go-to-line'); - require('grammar-selector'); - require('image-view'); - require('incompatible-packages'); - require('keybinding-resolver'); - require('language-c'); - require('language-html'); - require('language-javascript'); - require('language-ruby'); - require('language-rust-bundled'); - require('language-typescript'); - require('line-ending-selector'); - require('link'); - require('markdown-preview'); - require('notifications'); - require('open-on-github'); - require('package-generator'); - require('settings-view'); - require('snippets'); - require('spell-check'); - require('status-bar'); - require('styleguide'); - require('symbols-view'); - require('tabs'); - require('timecop'); - require('tree-view'); - require('update-package-dependencies'); - require('welcome'); - require('whitespace'); - require('wrap-guide'); -} - const clipboard = new Clipboard(); TextEditor.setClipboard(clipboard); TextEditor.viewForItem = item => atom.views.getView(item); diff --git a/src/main-process/main.js b/src/main-process/main.js index c632c32c3..cc195d102 100644 --- a/src/main-process/main.js +++ b/src/main-process/main.js @@ -1,7 +1,3 @@ -if (typeof snapshotResult !== 'undefined') { - snapshotResult.setGlobals(global, process, global, {}, console, require); -} - const startTime = Date.now(); const StartupTime = require('../startup-time'); StartupTime.setStartTime(); diff --git a/src/pane-container.js b/src/pane-container.js index bc2f2a6f6..0a6d2f80e 100644 --- a/src/pane-container.js +++ b/src/pane-container.js @@ -333,13 +333,10 @@ module.exports = class PaneContainer { this.emitter.emit('did-change-active-pane-item', activeItem); this.cancelStoppedChangingActivePaneItemTimeout(); - // `setTimeout()` isn't available during the snapshotting phase, but that's okay. - if (!global.isGeneratingSnapshot) { - this.stoppedChangingActivePaneItemTimeout = setTimeout(() => { - this.stoppedChangingActivePaneItemTimeout = null; - this.emitter.emit('did-stop-changing-active-pane-item', activeItem); - }, STOPPED_CHANGING_ACTIVE_PANE_ITEM_DELAY); - } + this.stoppedChangingActivePaneItemTimeout = setTimeout(() => { + this.stoppedChangingActivePaneItemTimeout = null; + this.emitter.emit('did-stop-changing-active-pane-item', activeItem); + }, STOPPED_CHANGING_ACTIVE_PANE_ITEM_DELAY); } } diff --git a/static/index.js b/static/index.js index 3f9085139..0d2157b40 100644 --- a/static/index.js +++ b/static/index.js @@ -11,7 +11,6 @@ const StartupTime = require('../src/startup-time'); const entryPointDirPath = __dirname; let blobStore = null; - let useSnapshot = false; const startupMarkers = electron.remote.getCurrentWindow().startupMarkers; @@ -42,47 +41,13 @@ !getWindowLoadSettings().resourcePath.startsWith( process.resourcesPath + path.sep ); - useSnapshot = !devMode && typeof snapshotResult !== 'undefined'; - if (useSnapshot) { - Module.prototype.require = function(module) { - const absoluteFilePath = Module._resolveFilename(module, this, false); - let relativeFilePath = path.relative( - entryPointDirPath, - absoluteFilePath - ); - if (process.platform === 'win32') { - relativeFilePath = relativeFilePath.replace(/\\/g, '/'); - } - let cachedModule = - snapshotResult.customRequire.cache[relativeFilePath]; - if (!cachedModule) { - cachedModule = { exports: Module._load(module, this, false) }; - snapshotResult.customRequire.cache[relativeFilePath] = cachedModule; - } - return cachedModule.exports; - }; - - snapshotResult.setGlobals( - global, - process, - window, - document, - console, - require - ); - } - - const FileSystemBlobStore = useSnapshot - ? snapshotResult.customRequire('../src/file-system-blob-store.js') - : require('../src/file-system-blob-store'); + const FileSystemBlobStore = require('../src/file-system-blob-store'); blobStore = FileSystemBlobStore.load( path.join(process.env.ATOM_HOME, 'blob-store') ); - const NativeCompileCache = useSnapshot - ? snapshotResult.customRequire('../src/native-compile-cache.js') - : require('../src/native-compile-cache'); + const NativeCompileCache = require('../src/native-compile-cache'); NativeCompileCache.setCacheStore(blobStore); NativeCompileCache.setV8Version(process.versions.v8); NativeCompileCache.install(); @@ -118,26 +83,16 @@ } function setupWindow() { - const CompileCache = useSnapshot - ? snapshotResult.customRequire('../src/compile-cache.js') - : require('../src/compile-cache'); + const CompileCache = require('../src/compile-cache'); CompileCache.setAtomHomeDirectory(process.env.ATOM_HOME); CompileCache.install(process.resourcesPath, require); - const ModuleCache = useSnapshot - ? snapshotResult.customRequire('../src/module-cache.js') - : require('../src/module-cache'); + const ModuleCache = require('../src/module-cache'); ModuleCache.register(getWindowLoadSettings()); - useSnapshot - ? snapshotResult.customRequire( - '../node_modules/document-register-element/build/document-register-element.node.js' - ) - : require('document-register-element'); + require('document-register-element'); - const Grim = useSnapshot - ? snapshotResult.customRequire('../node_modules/grim/lib/grim.js') - : require('grim'); + const Grim = require('grim'); const documentRegisterElement = document.registerElement; document.registerElement = (type, options) => { @@ -150,18 +105,14 @@ const { userSettings, appVersion } = getWindowLoadSettings(); - const CSON = useSnapshot - ? snapshotResult.customRequire('../node_modules/season/lib/cson.js') - : require('season'); + const CSON = require('season'); CSON.setCacheDir(path.join(CompileCache.getCacheDirectory(), 'cson')); const initScriptPath = path.relative( entryPointDirPath, getWindowLoadSettings().windowInitializationScript ); - const initialize = useSnapshot - ? snapshotResult.customRequire(initScriptPath) - : require(initScriptPath); + const initialize = require(initScriptPath); StartupTime.addMarker('window:initialize:start');