Skip to content

Commit 12a6926

Browse files
committed
Add AboutCode Manager header information #198
* Add AboutCode Manager notice and version to exported conclusion files Signed-off-by: Jillian Daguil <[email protected]>
1 parent 416a379 commit 12a6926

File tree

2 files changed

+42
-11
lines changed

2 files changed

+42
-11
lines changed

assets/app/js/aboutCodeDB.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ class AboutCodeDB {
111111
this.db = this.sequelize.sync();
112112
}
113113

114+
// Get AboutCode Manager app information
115+
getAboutCodeInfo() {
116+
return this.db
117+
.then(() => this.AboutCode.findOne({
118+
attributes: ["notice", "version"]
119+
}));
120+
}
121+
114122
// Uses the components table to do a findAll query
115123
findAllComponents(query) {
116124
return this.db.then(() => this.Component.findAll(query));
@@ -235,7 +243,12 @@ class AboutCodeDB {
235243
header = header.header;
236244
}
237245
promiseChain = promiseChain
238-
.then(() => this.AboutCode.create({ version: version }))
246+
.then(() => this.AboutCode.create(
247+
{
248+
version: version,
249+
notice: "Exported from AboutCode Manager ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\\nAboutCode Manager should be considered or used as legal advice. Consult an Attorney\\nfor any legal advice.\\nAboutCode Manager is a free software analysis application from nexB Inc. and others.\\nVisit https://github.com/nexB/aboutcode-manager/ for support and download.\""
250+
}
251+
))
239252
.then(() => this.ScanCode.create(header))
240253
.then((result) => scancode = result);
241254
})
@@ -400,7 +413,8 @@ const TABLE = {
400413
ABOUTCODE: {
401414
name: "aboutcode-manager",
402415
columns: {
403-
version: Sequelize.STRING
416+
version: Sequelize.STRING,
417+
notice: Sequelize.STRING
404418
}
405419
},
406420
SCANCODE: {

assets/app/js/renderer.js

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,12 @@ $(document).ready(function () {
302302
return;
303303
}
304304

305+
let aboutCodeInfoPromise = aboutCodeDB.getAboutCodeInfo({
306+
attributes: {
307+
exclude: ["id", "createdAt", "updatedAt"]
308+
}
309+
});
310+
305311
let clueFilesPromise = aboutCodeDB.findAll({
306312
attributes: {
307313
exclude: ["id", "createdAt", "updatedAt"]
@@ -314,9 +320,11 @@ $(document).ready(function () {
314320
}
315321
});
316322

317-
Promise.all([clueFilesPromise, componentsPromise])
318-
.then(([clueFiles, components]) => {
323+
Promise.all([aboutCodeInfoPromise, clueFilesPromise, componentsPromise])
324+
.then(([aboutCodeInfo, clueFiles, components]) => {
319325
let json = {
326+
aboutcode_manager_notice: aboutCodeInfo.notice,
327+
aboutcode_manager_version: aboutCodeInfo.version,
320328
files: clueFiles,
321329
components: components
322330
};
@@ -344,14 +352,23 @@ $(document).ready(function () {
344352
return;
345353
}
346354

347-
aboutCodeDB
348-
.findAllComponents({
349-
attributes: {
350-
exclude: ["id", "createdAt", "updatedAt"]
351-
}
352-
})
353-
.then((components) => {
355+
let aboutCodeInfoPromise = aboutCodeDB.getAboutCodeInfo({
356+
attributes: {
357+
exclude: ["id", "createdAt", "updatedAt"]
358+
}
359+
});
360+
361+
let componentsPromise = aboutCodeDB.findAllComponents({
362+
attributes: {
363+
exclude: ["id", "createdAt", "updatedAt"]
364+
}
365+
});
366+
367+
Promise.all([aboutCodeInfoPromise, componentsPromise])
368+
.then(([aboutCodeInfo, components]) => {
354369
let json = {
370+
aboutcode_manager_notice: aboutCodeInfo.notice,
371+
aboutcode_manager_version: aboutCodeInfo.version,
355372
components: components
356373
};
357374

0 commit comments

Comments
 (0)