Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(feat): rewrite to TypeScript #186

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 0 additions & 6 deletions .babelrc

This file was deleted.

120 changes: 2 additions & 118 deletions .gitignore
@@ -1,118 +1,2 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# autogenerated files
docs/
lib/types.d.ts

# IDEA/WebStorm files
.idea/
*.iml

# Stock editor trash files
*~

examples/devel-*

node_modules
build
4 changes: 0 additions & 4 deletions .ncurc.js

This file was deleted.

3 changes: 0 additions & 3 deletions .npmignore

This file was deleted.

21 changes: 0 additions & 21 deletions Gruntfile.js

This file was deleted.

6 changes: 2 additions & 4 deletions lib/commands/append.js → lib/commands/append.ts
@@ -1,9 +1,7 @@
'use strict';

const { getStatusCode, formatFlag, canUseFlag, formatDateTime, normalizePath, encodePath, comparePaths, getErrorText } = require('../tools.js');
import { getStatusCode, formatFlag, canUseFlag, formatDateTime, normalizePath, encodePath, comparePaths, getErrorText } from '../tools.js';

// Appends a message to a mailbox
module.exports = async (connection, destination, content, flags, idate) => {
export const APPEND = async (connection, destination, content, flags, idate) => {
if (![connection.states.AUTHENTICATED, connection.states.SELECTED].includes(connection.state) || !destination) {
// nothing to do here
return;
Expand Down
6 changes: 2 additions & 4 deletions lib/commands/authenticate.js → lib/commands/authenticate.ts
@@ -1,9 +1,7 @@
'use strict';

const { getStatusCode, getErrorText } = require('../tools.js');
import { getStatusCode, getErrorText } from '../tools.js';

// Authenticates user using LOGIN
module.exports = async (connection, username, accessToken) => {
export const AUTHENTICATE = async (connection, username, accessToken) => {
if (connection.state !== connection.states.NOT_AUTHENTICATED) {
// nothing to do here
return;
Expand Down
4 changes: 1 addition & 3 deletions lib/commands/capability.js → lib/commands/capability.ts
@@ -1,7 +1,5 @@
'use strict';

// Refresh capabilities from server
module.exports = async connection => {
export const CAPABILITY = async connection => {
if (connection.capabilities.size && !connection.expectCapabilityUpdate) {
return connection.capabilities;
}
Expand Down
4 changes: 1 addition & 3 deletions lib/commands/close.js → lib/commands/close.ts
@@ -1,7 +1,5 @@
'use strict';

// Closes a mailbox
module.exports = async connection => {
export const CLOSE = async connection => {
if (connection.state !== connection.states.SELECTED) {
// nothing to do here
return;
Expand Down
4 changes: 1 addition & 3 deletions lib/commands/compress.js → lib/commands/compress.ts
@@ -1,7 +1,5 @@
'use strict';

// Requests compression from server
module.exports = async connection => {
export const COMPRESS = async connection => {
if (!connection.capabilities.has('COMPRESS=DEFLATE') || connection._inflate) {
// nothing to do here
return false;
Expand Down
6 changes: 2 additions & 4 deletions lib/commands/copy.js → lib/commands/copy.ts
@@ -1,9 +1,7 @@
'use strict';

const { getStatusCode, normalizePath, encodePath, expandRange, getErrorText } = require('../tools.js');
import { getStatusCode, normalizePath, encodePath, expandRange, getErrorText } from '../tools.js';

// Copies messages from current mailbox to some other mailbox
module.exports = async (connection, range, destination, options) => {
export const COPY = async (connection, range, destination, options) => {
if (connection.state !== connection.states.SELECTED || !range || !destination) {
// nothing to do here
return;
Expand Down
6 changes: 2 additions & 4 deletions lib/commands/create.js → lib/commands/create.ts
@@ -1,9 +1,7 @@
'use strict';

const { encodePath, normalizePath, getStatusCode, getErrorText } = require('../tools.js');
import { encodePath, normalizePath, getStatusCode, getErrorText } from '../tools.js';

// Creates a new mailbox
module.exports = async (connection, path) => {
export const CREATE = async (connection, path) => {
if (![connection.states.AUTHENTICATED, connection.states.SELECTED].includes(connection.state)) {
// nothing to do here
return;
Expand Down
6 changes: 2 additions & 4 deletions lib/commands/delete.js → lib/commands/delete.ts
@@ -1,9 +1,7 @@
'use strict';

const { encodePath, normalizePath, getStatusCode, getErrorText } = require('../tools.js');
import { encodePath, normalizePath, getStatusCode, getErrorText } from '../tools.js';

// Deletes an existing mailbox
module.exports = async (connection, path) => {
export const DELETE = async (connection, path) => {
if (![connection.states.AUTHENTICATED, connection.states.SELECTED].includes(connection.state)) {
// nothing to do here
return;
Expand Down
4 changes: 1 addition & 3 deletions lib/commands/enable.js → lib/commands/enable.ts
@@ -1,7 +1,5 @@
'use strict';

// Enables extensions
module.exports = async (connection, extensionList) => {
export const ENABLE = async (connection, extensionList) => {
if (!connection.capabilities.has('ENABLE') || connection.state !== connection.states.AUTHENTICATED) {
// nothing to do here
return;
Expand Down
6 changes: 2 additions & 4 deletions lib/commands/expunge.js → lib/commands/expunge.ts
@@ -1,9 +1,7 @@
'use strict';

const { getStatusCode, getErrorText } = require('../tools.js');
import { getStatusCode, getErrorText } from '../tools.js';

// Deletes specified messages
module.exports = async (connection, range, options) => {
export const EXPUNGE = async (connection, range, options) => {
if (connection.state !== connection.states.SELECTED || !range) {
// nothing to do here
return;
Expand Down
6 changes: 2 additions & 4 deletions lib/commands/fetch.js → lib/commands/fetch.ts
@@ -1,9 +1,7 @@
'use strict';

const { formatMessageResponse } = require('../tools');
import { formatMessageResponse } from '../tools';

// Fetches emails from server
module.exports = async (connection, range, query, options) => {
export const FETCH = async (connection, range, query, options) => {
if (connection.state !== connection.states.SELECTED || !range) {
// nothing to do here
return;
Expand Down
6 changes: 2 additions & 4 deletions lib/commands/id.js → lib/commands/id.ts
@@ -1,9 +1,7 @@
'use strict';

const { formatDateTime } = require('../tools.js');
import { formatDateTime } from '../tools.js';

// Sends ID info to server and updates server info data based on response
module.exports = async (connection, clientInfo) => {
export const ID = async (connection, clientInfo) => {
if (!connection.capabilities.has('ID')) {
// nothing to do here
return;
Expand Down
4 changes: 1 addition & 3 deletions lib/commands/idle.js → lib/commands/idle.ts
@@ -1,5 +1,3 @@
'use strict';

const NOOP_INTERVAL = 2 * 60 * 1000;

async function runIdle(connection) {
Expand Down Expand Up @@ -104,7 +102,7 @@ async function runIdle(connection) {
}

// Listes for changes in mailbox
module.exports = async (connection, maxIdleTime) => {
export const IDLE = async (connection, maxIdleTime) => {
if (connection.state !== connection.states.SELECTED) {
// nothing to do here
return;
Expand Down
8 changes: 3 additions & 5 deletions lib/commands/list.js → lib/commands/list.ts
@@ -1,10 +1,8 @@
'use strict';

const { decodePath, encodePath, normalizePath } = require('../tools.js');
const { specialUse } = require('../special-use');
import { decodePath, encodePath, normalizePath } from '../tools.js';
import { specialUse } from '../special-use';

// Lists mailboxes from server
module.exports = async (connection, reference, mailbox, options) => {
export const LIST = async (connection, reference, mailbox, options) => {
options = options || {};

const FLAG_SORT_ORDER = ['\\Inbox', '\\Flagged', '\\Sent', '\\Drafts', '\\All', '\\Archive', '\\Junk', '\\Trash'];
Expand Down
6 changes: 2 additions & 4 deletions lib/commands/login.js → lib/commands/login.ts
@@ -1,9 +1,7 @@
'use strict';

const { getStatusCode, getErrorText } = require('../tools.js');
import { getStatusCode, getErrorText } from '../tools.js';

// Authenticates user using LOGIN
module.exports = async (connection, username, password) => {
export const LOGIN = async (connection, username, password) => {
if (connection.state !== connection.states.NOT_AUTHENTICATED) {
// nothing to do here
return;
Expand Down
4 changes: 1 addition & 3 deletions lib/commands/logout.js → lib/commands/logout.ts
@@ -1,7 +1,5 @@
'use strict';

// Logs out user and closes connection
module.exports = async connection => {
export const LOGOUT = async connection => {
if (connection.state === connection.states.LOGOUT) {
// nothing to do here
return false;
Expand Down
6 changes: 2 additions & 4 deletions lib/commands/move.js → lib/commands/move.ts
@@ -1,9 +1,7 @@
'use strict';

const { getStatusCode, normalizePath, encodePath, expandRange, getErrorText } = require('../tools.js');
import { getStatusCode, normalizePath, encodePath, expandRange, getErrorText } from '../tools.js';

// Moves messages from current mailbox to some other mailbox
module.exports = async (connection, range, destination, options) => {
export const MOVE = async (connection, range, destination, options) => {
if (connection.state !== connection.states.SELECTED || !range || !destination) {
// nothing to do here
return;
Expand Down
4 changes: 1 addition & 3 deletions lib/commands/namespace.js → lib/commands/namespace.ts
@@ -1,7 +1,5 @@
'use strict';

// Requests NAMESPACE info from server
module.exports = async connection => {
export const NAMESPACE = async connection => {
if (![connection.states.AUTHENTICATED, connection.states.SELECTED].includes(connection.state)) {
// nothing to do here
return;
Expand Down
4 changes: 1 addition & 3 deletions lib/commands/noop.js → lib/commands/noop.ts
@@ -1,7 +1,5 @@
'use strict';

// Sends a NO-OP command
module.exports = async connection => {
export const NOOP = async connection => {
try {
let response = await connection.exec('NOOP', false, { comment: 'Requested by command' });
response.next();
Expand Down
6 changes: 2 additions & 4 deletions lib/commands/quota.js → lib/commands/quota.ts
@@ -1,9 +1,7 @@
'use strict';

const { encodePath, getStatusCode, normalizePath, getErrorText } = require('../tools.js');
import { encodePath, getStatusCode, normalizePath, getErrorText } from '../tools.js';

// Requests quota information for a mailbox
module.exports = async (connection, path) => {
export const QUOTA = async (connection, path) => {
if (![connection.states.AUTHENTICATED, connection.states.SELECTED].includes(connection.state) || !path) {
// nothing to do here
return;
Expand Down
6 changes: 2 additions & 4 deletions lib/commands/rename.js → lib/commands/rename.ts
@@ -1,9 +1,7 @@
'use strict';

const { encodePath, normalizePath, getStatusCode, getErrorText } = require('../tools.js');
import { encodePath, normalizePath, getStatusCode, getErrorText } from '../tools.js';

// Renames existing mailbox
module.exports = async (connection, path, newPath) => {
export const RENAME = async (connection, path, newPath) => {
if (![connection.states.AUTHENTICATED, connection.states.SELECTED].includes(connection.state)) {
// nothing to do here
return;
Expand Down