Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Rollup #1341

Draft
wants to merge 30 commits into
base: master
Choose a base branch
from
Draft

Rollup #1341

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
74b9ba3
rollup deps
aminya May 29, 2020
52f570a
scripts
aminya May 29, 2020
004185a
rollup config
aminya May 29, 2020
c0ed22d
bump pathwatcher to 8.1
aminya May 29, 2020
ac6009b
Update package-lock.json
aminya May 29, 2020
bf0f3b1
tree-view import/export
aminya May 29, 2020
0d4ca06
tree-view-package import/export
aminya May 29, 2020
039da05
root-drag-and-drop import/export
aminya May 29, 2020
fa2fe4c
root-drag-drop using normal for loop
aminya May 29, 2020
48716e7
move-dialog import export
aminya May 29, 2020
889b5de
move dialog assign to @ after calling super
aminya May 29, 2020
b59f806
main import/export
aminya May 29, 2020
a096214
ignored-names import/export
aminya May 29, 2020
af43127
helpers import export
aminya May 29, 2020
7b61955
get-icon-services import/export
aminya May 29, 2020
122b1f0
file import/export
aminya May 29, 2020
0229b04
file-view import/export
aminya May 29, 2020
4062fe2
directory import/export
aminya May 29, 2020
703312b
directory-view import/export
aminya May 29, 2020
915971b
dialog import/export
aminya May 29, 2020
053cecc
default-file-icons import/export
aminya May 29, 2020
d4eeddc
copy dialog import/export
aminya May 29, 2020
2e39af3
copy-dialog assign to @ after caling super
aminya May 29, 2020
dd8190f
add-projects-view import/export
aminya May 29, 2020
a8484fe
add-dialog import/export
aminya May 29, 2020
6692cfb
add-dialog assign to @ after calling super
aminya May 29, 2020
e289294
dynamic import ignored-names
aminya May 29, 2020
ebdeaf3
use babel plugin
aminya May 30, 2020
2b0136a
test the bundle in specs
aminya May 30, 2020
157dd25
Update package-lock.json
aminya May 30, 2020
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
dist
14 changes: 14 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const presets = [['@babel/preset-env', { targets: { electron: 5 } }]]

const plugins = []

if (process.env.BABEL_ENV === 'development') {
plugins.push('@babel/plugin-transform-modules-commonjs')
}

module.exports = {
presets,
plugins,
exclude: 'node_modules/**',
sourceMaps: 'inline',
}
18 changes: 10 additions & 8 deletions lib/add-dialog.coffee
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
path = require 'path'
fs = require 'fs-plus'
Dialog = require './dialog'
{repoForPath} = require './helpers'
import path from 'path'
import fs from 'fs-plus'
import Dialog from './dialog'
import {repoForPath} from './helpers'

module.exports =
class AddDialog extends Dialog
export default class AddDialog extends Dialog
constructor: (initialPath, isCreatingFile) ->
@isCreatingFile = isCreatingFile

if fs.isFileSync(initialPath)
directoryPath = path.dirname(initialPath)
else
directoryPath = initialPath

relativeDirectoryPath = directoryPath
[@rootProjectPath, relativeDirectoryPath] = atom.project.relativizePath(directoryPath)
[rootProjectPath, relativeDirectoryPath] = atom.project.relativizePath(directoryPath)
relativeDirectoryPath += path.sep if relativeDirectoryPath.length > 0

super
Expand All @@ -23,6 +21,10 @@ class AddDialog extends Dialog
select: false
iconClass: if isCreatingFile then 'icon-file-add' else 'icon-file-directory-create'

@isCreatingFile = isCreatingFile
@rootProjectPath = rootProjectPath


onDidCreateFile: (callback) ->
@emitter.on('did-create-file', callback)

Expand Down
3 changes: 1 addition & 2 deletions lib/add-projects-view.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module.exports =
class AddProjectView {
export default class AddProjectView {
constructor () {
this.element = document.createElement('div')
this.element.id = 'add-projects-view'
Expand Down
20 changes: 11 additions & 9 deletions lib/copy-dialog.coffee
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
path = require 'path'
fs = require 'fs-plus'
Dialog = require './dialog'
{repoForPath} = require "./helpers"

module.exports =
class CopyDialog extends Dialog
constructor: (@initialPath, {@onCopy}) ->
import path from 'path'
import fs from 'fs-plus'
import Dialog from './dialog'
import {repoForPath} from "./helpers"

export default class CopyDialog extends Dialog
constructor: (initialPath, {onCopy}) ->
super
prompt: 'Enter the new path for the duplicate.'
initialPath: atom.project.relativize(@initialPath)
initialPath: atom.project.relativize(initialPath)
select: true
iconClass: 'icon-arrow-right'

@initialPath = initialPath
@onCopy = onCopy

onConfirm: (newPath) ->
newPath = newPath.replace(/\s+$/, '') # Remove trailing whitespace
unless path.isAbsolute(newPath)
Expand Down
6 changes: 3 additions & 3 deletions lib/default-file-icons.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fs = require 'fs-plus'
path = require 'path'
import path from 'path'
import fs from 'fs-plus'

class DefaultFileIcons
iconClassForPath: (filePath) ->
Expand All @@ -20,4 +20,4 @@ class DefaultFileIcons
else
'icon-file-text'

module.exports = new DefaultFileIcons
export default new DefaultFileIcons
9 changes: 4 additions & 5 deletions lib/dialog.coffee
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{TextEditor, CompositeDisposable, Disposable, Emitter, Range, Point} = require 'atom'
path = require 'path'
{getFullExtension} = require "./helpers"
import {TextEditor, CompositeDisposable, Disposable, Emitter, Range, Point} from'atom'
import path from 'path'
import {getFullExtension} from "./helpers"

module.exports =
class Dialog
export default class Dialog
constructor: ({initialPath, select, iconClass, prompt} = {}) ->
@emitter = new Emitter()
@disposables = new CompositeDisposable()
Expand Down
11 changes: 5 additions & 6 deletions lib/directory-view.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
const {CompositeDisposable} = require('atom')
const getIconServices = require('./get-icon-services')
const Directory = require('./directory')
const FileView = require('./file-view')
import {CompositeDisposable} from 'atom'
import getIconServices from './get-icon-services'
import Directory from './directory'
import FileView from './file-view'

module.exports =
class DirectoryView {
export default class DirectoryView {
constructor (directory) {
this.directory = directory
this.subscriptions = new CompositeDisposable()
Expand Down
19 changes: 9 additions & 10 deletions lib/directory.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
const path = require('path')
const _ = require('underscore-plus')
const {CompositeDisposable, Emitter} = require('atom')
const fs = require('fs-plus')
const PathWatcher = require('pathwatcher')
const File = require('./file')
const {repoForPath} = require('./helpers')

module.exports =
class Directory {
import path from 'path'
import _ from 'underscore-plus'
import {CompositeDisposable, Emitter} from 'atom'
import fs from 'fs-plus'
import PathWatcher from 'pathwatcher'
import File from './file'
import {repoForPath} from './helpers'

export default class Directory {
constructor ({name, fullPath, symlink, expansionState, isRoot, ignoredNames, useSyncFS, stats}) {
this.name = name
this.symlink = symlink
Expand Down
7 changes: 3 additions & 4 deletions lib/file-view.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const {CompositeDisposable} = require('atom')
const getIconServices = require('./get-icon-services')
import {CompositeDisposable} from 'atom'
import getIconServices from './get-icon-services'

module.exports =
class FileView {
export default class FileView {
constructor (file) {
this.file = file
this.subscriptions = new CompositeDisposable()
Expand Down
9 changes: 4 additions & 5 deletions lib/file.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const fs = require('fs-plus')
const {CompositeDisposable, Emitter} = require('atom')
const {repoForPath} = require('./helpers')
import fs from 'fs-plus'
import {CompositeDisposable, Emitter} from 'atom'
import {repoForPath} from './helpers'

module.exports =
class File {
export default class File {
constructor ({name, fullPath, symlink, ignoredNames, useSyncFS, stats}) {
this.name = name
this.symlink = symlink
Expand Down
8 changes: 4 additions & 4 deletions lib/get-icon-services.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const DefaultFileIcons = require('./default-file-icons')
const {Emitter, CompositeDisposable} = require('atom')
const {repoForPath} = require('./helpers')
import DefaultFileIcons from './default-file-icons'
import {Emitter, CompositeDisposable} from 'atom'
import {repoForPath} from './helpers'

let iconServices
module.exports = function getIconServices () {
export default function getIconServices () {
if (!iconServices) iconServices = new IconServices()
return iconServices
}
Expand Down
37 changes: 18 additions & 19 deletions lib/helpers.coffee
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
path = require "path"
import path from "path"

module.exports =
repoForPath: (goalPath) ->
for projectPath, i in atom.project.getPaths()
if goalPath is projectPath or goalPath.indexOf(projectPath + path.sep) is 0
return atom.project.getRepositories()[i]
null
export repoForPath = (goalPath) ->
for projectPath, i in atom.project.getPaths()
if goalPath is projectPath or goalPath.indexOf(projectPath + path.sep) is 0
return atom.project.getRepositories()[i]
null

getStyleObject: (el) ->
styleProperties = window.getComputedStyle(el)
styleObject = {}
for property of styleProperties
value = styleProperties.getPropertyValue property
camelizedAttr = property.replace /\-([a-z])/g, (a, b) -> b.toUpperCase()
styleObject[camelizedAttr] = value
styleObject
export getStyleObject = (el) ->
styleProperties = window.getComputedStyle(el)
styleObject = {}
for property of styleProperties
value = styleProperties.getPropertyValue property
camelizedAttr = property.replace /\-([a-z])/g, (a, b) -> b.toUpperCase()
styleObject[camelizedAttr] = value
styleObject

getFullExtension: (filePath) ->
basename = path.basename(filePath)
position = basename.indexOf('.')
if position > 0 then basename[position..] else ''
export getFullExtension = (filePath) ->
basename = path.basename(filePath)
position = basename.indexOf('.')
if position > 0 then basename[position..] else ''
3 changes: 3 additions & 0 deletions lib/ignored-names-importer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export async function ignoredNamesImporter() {
return await import('./ignored-names')
}
10 changes: 4 additions & 6 deletions lib/ignored-names.coffee
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
Minimatch = null # Defer requiring until actually needed
# this file is lazy loaded by ignored-names-importer
import minimatch from 'minimatch'

module.exports =
class IgnoredNames
export default class IgnoredNames
constructor: ->
@ignoredPatterns = []

Minimatch ?= require('minimatch').Minimatch

ignoredNames = atom.config.get('core.ignoredNames') ? []
ignoredNames = [ignoredNames] if typeof ignoredNames is 'string'
for ignoredName in ignoredNames when ignoredName
try
@ignoredPatterns.push(new Minimatch(ignoredName, matchBase: true, dot: true))
@ignoredPatterns.push(new minimatch(ignoredName, matchBase: true, dot: true))
catch error
atom.notifications.addWarning("Error parsing ignore pattern (#{ignoredName})", detail: error.message)

Expand Down
4 changes: 2 additions & 2 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const TreeViewPackage = require('./tree-view-package')
import TreeViewPackage from './tree-view-package'

module.exports = new TreeViewPackage()
export default new TreeViewPackage()
23 changes: 13 additions & 10 deletions lib/move-dialog.coffee
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
path = require 'path'
fs = require 'fs-plus'
Dialog = require './dialog'
{repoForPath} = require "./helpers"

module.exports =
class MoveDialog extends Dialog
constructor: (@initialPath, {@willMove, @onMove, @onMoveFailed}) ->
if fs.isDirectorySync(@initialPath)
import path from 'path'
import fs from 'fs-plus'
import Dialog from './dialog'
import {repoForPath} from "./helpers"

export default class MoveDialog extends Dialog
constructor: (initialPath, {willMove, onMove, onMoveFailed}) ->
if fs.isDirectorySync(initialPath)
prompt = 'Enter the new path for the directory.'
else
prompt = 'Enter the new path for the file.'

super
prompt: prompt
initialPath: atom.project.relativize(@initialPath)
initialPath: atom.project.relativize(initialPath)
select: true
iconClass: 'icon-arrow-right'

@willMove = willMove
@onMove = onMove
@onMoveFailed = onMoveFailed

onConfirm: (newPath) ->
newPath = newPath.replace(/\s+$/, '') # Remove trailing whitespace
unless path.isAbsolute(newPath)
Expand Down
13 changes: 8 additions & 5 deletions lib/root-drag-and-drop.coffee
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
url = require 'url'
import url from 'url'

{ipcRenderer, remote} = require 'electron'
import {ipcRenderer, remote} from 'electron'

# TODO: Support dragging external folders and using the drag-and-drop indicators for them
# Currently they're handled in TreeView's drag listeners

module.exports =
class RootDragAndDropHandler
export default class RootDragAndDropHandler
constructor: (@treeView) ->
ipcRenderer.on('tree-view:project-folder-dropped', @onDropOnOtherWindow)
@handleEvents()
Expand Down Expand Up @@ -34,7 +33,11 @@ class RootDragAndDropHandler
e.dataTransfer.setData 'project-root-index', Array.from(projectRoot.parentElement.children).indexOf(projectRoot)

rootIndex = -1
(rootIndex = index; break) for root, index in @treeView.roots when root.directory is directory
for index in [[email protected]] by 1
root = this.treeView.roots[index]
if (root.directory is directory)
rootIndex = index
break

e.dataTransfer.setData 'from-root-index', rootIndex
e.dataTransfer.setData 'from-root-path', directory.path
Expand Down
9 changes: 4 additions & 5 deletions lib/tree-view-package.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
const {Disposable, CompositeDisposable} = require('atom')
import {Disposable, CompositeDisposable} from 'atom'

const getIconServices = require('./get-icon-services')
const TreeView = require('./tree-view')
import getIconServices from './get-icon-services'
import TreeView from './tree-view'

module.exports =
class TreeViewPackage {
export default class TreeViewPackage {
activate () {
this.disposables = new CompositeDisposable()
this.disposables.add(atom.commands.add('atom-workspace', {
Expand Down
Loading