mirror of
https://github.com/yldio/copilot.git
synced 2024-12-01 07:30:07 +02:00
chore: properly handle full and relative paths in format
This commit is contained in:
parent
ca27ac2200
commit
8887fa3384
@ -5,7 +5,7 @@
|
|||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"repository": "github:yldio/joyent-portal",
|
"repository": "github:yldio/joyent-portal",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"fmt": "node ./scripts/prettier",
|
"fmt": "node ./scripts/format",
|
||||||
"test": "lerna run test",
|
"test": "lerna run test",
|
||||||
"lint-license": "node ./scripts/license-to-fail",
|
"lint-license": "node ./scripts/license-to-fail",
|
||||||
"lint-docs": "node ./scripts/quality-docs",
|
"lint-docs": "node ./scripts/quality-docs",
|
||||||
@ -63,6 +63,7 @@
|
|||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"*.js": [
|
"*.js": [
|
||||||
|
"npm run fmt",
|
||||||
"git add"
|
"git add"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -4,7 +4,7 @@ const { expect } = require('code');
|
|||||||
const Lab = require('lab');
|
const Lab = require('lab');
|
||||||
const PortalData = require('../');
|
const PortalData = require('../');
|
||||||
|
|
||||||
const lab = exports.lab = Lab.script();
|
const lab = (exports.lab = Lab.script());
|
||||||
const it = lab.it;
|
const it = lab.it;
|
||||||
const describe = lab.describe;
|
const describe = lab.describe;
|
||||||
|
|
||||||
@ -12,8 +12,7 @@ const internals = {
|
|||||||
options: { name: 'test', db: { test: true } }
|
options: { name: 'test', db: { test: true } }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
describe('connect()', function() {
|
||||||
describe('connect()', () => {
|
|
||||||
it('connects to the database', () => {
|
it('connects to the database', () => {
|
||||||
const data = new PortalData(internals.options);
|
const data = new PortalData(internals.options);
|
||||||
|
|
||||||
@ -22,28 +21,33 @@ describe('connect()', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe.skip('createDeployment()', () => {
|
describe.skip('createDeployment()', () => {
|
||||||
it('creates a deployment record in the deployment table', (done) => {
|
it('creates a deployment record in the deployment table', done => {
|
||||||
const data = new PortalData(internals.options);
|
const data = new PortalData(internals.options);
|
||||||
const deployment = {
|
const deployment = {
|
||||||
name: 'User Services',
|
name: 'User Services',
|
||||||
datacenter: 'us-sw-1'
|
datacenter: 'us-sw-1'
|
||||||
};
|
};
|
||||||
|
|
||||||
data.connect().then(() => {
|
data
|
||||||
data.createDeployment({
|
.connect()
|
||||||
|
.then(() => {
|
||||||
|
data
|
||||||
|
.createDeployment({
|
||||||
deployment
|
deployment
|
||||||
}).then((deployment) => {
|
})
|
||||||
|
.then(deployment => {
|
||||||
expect(deployment.id).to.exist();
|
expect(deployment.id).to.exist();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
}).catch((err) => {
|
})
|
||||||
|
.catch(err => {
|
||||||
expect(err).to.not.exist();
|
expect(err).to.not.exist();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe.skip('getDeployment()', () => {
|
describe.skip('getDeployment()', () => {
|
||||||
it('will retrieve an existing deployment', (done) => {
|
it('will retrieve an existing deployment', done => {
|
||||||
const data = new PortalData(internals.options);
|
const data = new PortalData(internals.options);
|
||||||
data.connect().then(() => {
|
data.connect().then(() => {
|
||||||
const deployment = {
|
const deployment = {
|
||||||
@ -51,9 +55,9 @@ describe.skip('getDeployment()', () => {
|
|||||||
datacenter: 'us-sw-1'
|
datacenter: 'us-sw-1'
|
||||||
};
|
};
|
||||||
|
|
||||||
data.createDeployment(deployment).then((deployment) => {
|
data.createDeployment(deployment).then(deployment => {
|
||||||
expect(deployment.id).to.exist();
|
expect(deployment.id).to.exist();
|
||||||
data.getDeployment(deployment.id).then((retrievedDeployment) => {
|
data.getDeployment(deployment.id).then(retrievedDeployment => {
|
||||||
expect(deployment).to.equal(retrievedDeployment);
|
expect(deployment).to.equal(retrievedDeployment);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -63,7 +67,7 @@ describe.skip('getDeployment()', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe.skip('updateService()', () => {
|
describe.skip('updateService()', () => {
|
||||||
it('will update the services for an existing deployment', (done) => {
|
it('will update the services for an existing deployment', done => {
|
||||||
const data = new PortalData(internals.options);
|
const data = new PortalData(internals.options);
|
||||||
data.connect().then(() => {
|
data.connect().then(() => {
|
||||||
const deployment = {
|
const deployment = {
|
||||||
@ -84,9 +88,9 @@ describe.skip('updateService()', () => {
|
|||||||
count: 1
|
count: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
data.createDeployment(deployment).then((deployment) => {
|
data.createDeployment(deployment).then(deployment => {
|
||||||
expect(deployment.id).to.exist();
|
expect(deployment.id).to.exist();
|
||||||
data.updateService(deployment.id, service).then((updatedService) => {
|
data.updateService(deployment.id, service).then(updatedService => {
|
||||||
expect(updatedService).to.equal(service);
|
expect(updatedService).to.equal(service);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -96,7 +100,7 @@ describe.skip('updateService()', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe.skip('deploymentChanges()', () => {
|
describe.skip('deploymentChanges()', () => {
|
||||||
it('will execute the handler when a deployment service changes', (done) => {
|
it('will execute the handler when a deployment service changes', done => {
|
||||||
const data = new PortalData(internals.options);
|
const data = new PortalData(internals.options);
|
||||||
data.connect().then(() => {
|
data.connect().then(() => {
|
||||||
const deployment = {
|
const deployment = {
|
||||||
@ -145,9 +149,9 @@ describe.skip('deploymentChanges()', () => {
|
|||||||
count: 3
|
count: 3
|
||||||
};
|
};
|
||||||
|
|
||||||
data.createDeployment(deployment).then((deployment) => {
|
data.createDeployment(deployment).then(deployment => {
|
||||||
expect(deployment.id).to.exist();
|
expect(deployment.id).to.exist();
|
||||||
data.updateService(deployment.id, service1).then((updatedService1) => {
|
data.updateService(deployment.id, service1).then(updatedService1 => {
|
||||||
expect(updatedService1).to.equal(service1);
|
expect(updatedService1).to.equal(service1);
|
||||||
|
|
||||||
let executed = false;
|
let executed = false;
|
||||||
@ -166,7 +170,7 @@ describe.skip('deploymentChanges()', () => {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
data
|
data
|
||||||
.updateService(deployment.id, service2)
|
.updateService(deployment.id, service2)
|
||||||
.then((updatedService2) => {
|
.then(updatedService2 => {
|
||||||
expect(updatedService2).to.equal(service2);
|
expect(updatedService2).to.equal(service2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -177,7 +181,7 @@ describe.skip('deploymentChanges()', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe.skip('insertMetrics()', () => {
|
describe.skip('insertMetrics()', () => {
|
||||||
it("will add new metrics to a service and won't overwrite existing ones", (done) => {
|
it("will add new metrics to a service and won't overwrite existing ones", done => {
|
||||||
const data = new PortalData(internals.options);
|
const data = new PortalData(internals.options);
|
||||||
data.connect().then(() => {
|
data.connect().then(() => {
|
||||||
const containerId = '81205d4a-92f4-c4d9-da8a-aafd689eeabb';
|
const containerId = '81205d4a-92f4-c4d9-da8a-aafd689eeabb';
|
||||||
@ -199,12 +203,12 @@ describe.skip('insertMetrics()', () => {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
data.insertMetrics(containerId, metrics1).then((result1) => {
|
data.insertMetrics(containerId, metrics1).then(result1 => {
|
||||||
expect(result1.id).to.equal(containerId);
|
expect(result1.id).to.equal(containerId);
|
||||||
expect(result1.metrics).to.equal(metrics1);
|
expect(result1.metrics).to.equal(metrics1);
|
||||||
data.insertMetrics(containerId, metrics2).then((result2) => {
|
data.insertMetrics(containerId, metrics2).then(result2 => {
|
||||||
expect(result2.id).to.equal(containerId);
|
expect(result2.id).to.equal(containerId);
|
||||||
data.getMetrics(containerId).then((results) => {
|
data.getMetrics(containerId).then(results => {
|
||||||
expect(results.metrics.length).to.equal(2);
|
expect(results.metrics.length).to.equal(2);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -7,13 +7,18 @@ const globby = require('globby');
|
|||||||
const main = require('apr-main');
|
const main = require('apr-main');
|
||||||
const argv = require('yargs').argv;
|
const argv = require('yargs').argv;
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
const optOut = forceArray(config['fmt-opt-out']);
|
const root = path.join(__dirname, '../');
|
||||||
|
const optOut = forceArray(config['fmt-opt-out']).map(pkg =>
|
||||||
|
path.join(root, `packages/${pkg}`)
|
||||||
|
);
|
||||||
|
|
||||||
const filter = (files = []) =>
|
const filter = (files = []) =>
|
||||||
files
|
files
|
||||||
.filter(file => !/node_modules/.test(file))
|
.filter(file => !/node_modules/.test(file))
|
||||||
.filter(file => !optOut.some(pkg => file.indexOf(`packages/${pkg}`) === 0));
|
.map(file => path.resolve(root, file))
|
||||||
|
.filter(file => !optOut.some(pkg => file.indexOf(pkg) === 0));
|
||||||
|
|
||||||
const run = async (files = []) => {
|
const run = async (files = []) => {
|
||||||
const cp = execa(
|
const cp = execa(
|
Loading…
Reference in New Issue
Block a user