feat: npm updates, security zero, test corrections (#296)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
version: 2.1
|
||||
|
||||
orbs:
|
||||
node: circleci/node@4.1.0
|
||||
node: circleci/node@5.0.2
|
||||
|
||||
commands:
|
||||
setup_git_bot:
|
||||
@@ -58,6 +58,32 @@ jobs:
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
|
||||
release_scheduled:
|
||||
triggers:
|
||||
# 6:03 UTC (mornings) 1 monday
|
||||
- schedule:
|
||||
cron: "3 6 * * 1"
|
||||
filters:
|
||||
branches:
|
||||
only:
|
||||
- main
|
||||
jobs:
|
||||
- lint
|
||||
- node/test:
|
||||
matrix:
|
||||
parameters:
|
||||
version:
|
||||
- '12.22'
|
||||
- '14.19'
|
||||
- '16.14'
|
||||
- 'current'
|
||||
- release:
|
||||
context: npm-deploy-av
|
||||
requires:
|
||||
- node/test
|
||||
- lint
|
||||
|
||||
test:
|
||||
jobs:
|
||||
- lint
|
||||
@@ -65,14 +91,14 @@ workflows:
|
||||
matrix:
|
||||
parameters:
|
||||
version:
|
||||
- '10.23'
|
||||
- '12.20'
|
||||
- '14.15'
|
||||
- '12.22'
|
||||
- '14.19'
|
||||
- '16.14'
|
||||
- 'current'
|
||||
- release_dry_run:
|
||||
filters:
|
||||
branches:
|
||||
only: master
|
||||
only: main
|
||||
requires:
|
||||
- node/test
|
||||
- lint
|
||||
|
||||
20524
package-lock.json
generated
20524
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
17
package.json
17
package.json
@@ -31,8 +31,10 @@
|
||||
},
|
||||
"release": {
|
||||
"verifyConditions": "condition-circle",
|
||||
"branch": "master",
|
||||
"branches": ["master"]
|
||||
"branch": "main",
|
||||
"branches": [
|
||||
"main"
|
||||
]
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
@@ -42,8 +44,7 @@
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.js": [
|
||||
"eslint --fix",
|
||||
"git add"
|
||||
"eslint --fix"
|
||||
]
|
||||
},
|
||||
"commitlint": {
|
||||
@@ -74,16 +75,16 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^10.0.0",
|
||||
"@commitlint/config-conventional": "^8.1.0",
|
||||
"@commitlint/config-conventional": "^16.2.1",
|
||||
"@icetee/ftp": "^1.0.2",
|
||||
"chai": "^4.2.0",
|
||||
"condition-circle": "^2.0.2",
|
||||
"eslint": "^5.14.1",
|
||||
"husky": "^1.3.1",
|
||||
"lint-staged": "^8.2.1",
|
||||
"mocha": "^8.1.1",
|
||||
"lint-staged": "^12.3.7",
|
||||
"mocha": "^9.2.2",
|
||||
"rimraf": "^2.6.1",
|
||||
"semantic-release": "^17.2.3",
|
||||
"semantic-release": "^19.0.2",
|
||||
"sinon": "^2.3.5"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
23
src/index.js
23
src/index.js
@@ -117,17 +117,22 @@ class FtpServer extends EventEmitter {
|
||||
}
|
||||
|
||||
disconnectClient(id) {
|
||||
return new Promise((resolve) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const client = this.connections[id];
|
||||
if (!client) return resolve();
|
||||
delete this.connections[id];
|
||||
|
||||
setTimeout(() => {
|
||||
reject('Timed out disconnecting client')
|
||||
}, this.options.timeout || 1000)
|
||||
|
||||
try {
|
||||
client.close(0);
|
||||
} catch (err) {
|
||||
this.log.error(err, 'Error closing connection', {id});
|
||||
} finally {
|
||||
resolve('Disconnected');
|
||||
}
|
||||
|
||||
resolve('Disconnected');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -137,16 +142,22 @@ class FtpServer extends EventEmitter {
|
||||
}
|
||||
|
||||
close() {
|
||||
this.log.info('Server closing...');
|
||||
this.server.maxConnections = 0;
|
||||
return Promise.map(Object.keys(this.connections), (id) => Promise.try(this.disconnectClient.bind(this, id)))
|
||||
this.log.info('Closing connections:', Object.keys(this.connections).length);
|
||||
|
||||
return Promise.all(Object.keys(this.connections).map((id) => this.disconnectClient(id)))
|
||||
.then(() => new Promise((resolve) => {
|
||||
this.server.close((err) => {
|
||||
this.log.info('Server closing...');
|
||||
if (err) this.log.error(err, 'Error closing server');
|
||||
resolve('Closed');
|
||||
});
|
||||
}))
|
||||
.then(() => this.removeAllListeners());
|
||||
.then(() => {
|
||||
this.log.debug('Removing event listeners...')
|
||||
this.removeAllListeners();
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,10 +24,13 @@ describe('Integration', function () {
|
||||
before(() => {
|
||||
return startServer({url: 'ftp://127.0.0.1:8880'});
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
sandbox = sinon.sandbox.create().usingPromise(Promise);
|
||||
});
|
||||
|
||||
afterEach(() => sandbox.restore());
|
||||
|
||||
after(() => server.close());
|
||||
|
||||
before(() => {
|
||||
@@ -101,7 +104,8 @@ describe('Integration', function () {
|
||||
if (stat.isDirectory()) directoryPurge(item);
|
||||
else fs.unlinkSync(item);
|
||||
});
|
||||
fs.rmdirSync(dir);
|
||||
|
||||
fs.rmdirSync(dir, { recursive: true });
|
||||
}
|
||||
|
||||
function runFileSystemTests(name) {
|
||||
@@ -259,13 +263,16 @@ describe('Integration', function () {
|
||||
client.get('tést.txt', (err, stream) => {
|
||||
expect(err).to.not.exist;
|
||||
let text = '';
|
||||
|
||||
stream.on('data', (data) => {
|
||||
text += data.toString();
|
||||
});
|
||||
stream.on('end', () => {
|
||||
|
||||
stream.on('finish', () => {
|
||||
expect(text).to.equal('test text file, awesome!');
|
||||
done();
|
||||
});
|
||||
|
||||
stream.resume();
|
||||
});
|
||||
});
|
||||
@@ -339,18 +346,24 @@ describe('Integration', function () {
|
||||
});
|
||||
|
||||
it('MKD témp multiple levels deep', (done) => {
|
||||
const path = `${clientDirectory}/${name}/témp/first/second`;
|
||||
const path = `${clientDirectory}/${name}/témp`;
|
||||
if (fs.existsSync(path)) {
|
||||
fs.rmdirSync(path);
|
||||
fs.rmdirSync(path, {recursive: true});
|
||||
}
|
||||
|
||||
client.mkdir('témp/first/second', (err) => {
|
||||
expect(err).to.not.exist;
|
||||
expect(fs.existsSync(path)).to.equal(true);
|
||||
|
||||
fs.rmdirSync(path, {recursive: true});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('CWD témp', (done) => {
|
||||
const path = `${clientDirectory}/${name}/témp`;
|
||||
fs.mkdirSync(path)
|
||||
|
||||
client.cwd('témp', (err, data) => {
|
||||
expect(err).to.not.exist;
|
||||
expect(data).to.to.be.a('string');
|
||||
|
||||
Reference in New Issue
Block a user