@itentialopensource/adapter-azure_devops 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/adapter.js +0 -5
- package/package.json +1 -1
- package/pronghorn.json +8 -3
- package/refs?service=git-upload-pack +0 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/README.md +0 -59
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/specificCallScript.js +0 -97
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/update.js +0 -532
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/adapter.js +0 -11651
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/AnnotatedTags/action.json +0 -43
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/AnnotatedTags/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/AnnotatedTags/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Blobs/action.json +0 -43
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Blobs/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Blobs/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/CherryPicks/action.json +0 -64
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/CherryPicks/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/CherryPicks/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Commits/action.json +0 -85
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Commits/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Commits/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Diffs/action.json +0 -23
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Diffs/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Diffs/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Forks/action.json +0 -85
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Forks/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Forks/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/ImportRequests/action.json +0 -84
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/ImportRequests/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/ImportRequests/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Items/action.json +0 -43
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Items/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Items/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/MergeBases/action.json +0 -23
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/MergeBases/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/MergeBases/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Merges/action.json +0 -43
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Merges/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Merges/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PolicyConfigurations/action.json +0 -23
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PolicyConfigurations/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PolicyConfigurations/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestAttachments/action.json +0 -84
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestAttachments/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestAttachments/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestCommentLikes/action.json +0 -63
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestCommentLikes/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestCommentLikes/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestCommits/action.json +0 -44
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestCommits/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestCommits/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterationChanges/action.json +0 -23
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterationChanges/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterationChanges/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterationStatuses/action.json +0 -104
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterationStatuses/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterationStatuses/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterations/action.json +0 -44
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterations/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterations/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestLabels/action.json +0 -84
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestLabels/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestLabels/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestProperties/action.json +0 -43
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestProperties/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestProperties/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestQuery/action.json +0 -22
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestQuery/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestQuery/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestReviewers/action.json +0 -164
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestReviewers/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestReviewers/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestShare/action.json +0 -22
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestShare/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestShare/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestStatuses/action.json +0 -104
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestStatuses/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestStatuses/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestThreadComments/action.json +0 -104
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestThreadComments/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestThreadComments/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestThreads/action.json +0 -84
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestThreads/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestThreads/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestWorkItems/action.json +0 -23
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestWorkItems/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestWorkItems/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequests/action.json +0 -126
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequests/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequests/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Pushes/action.json +0 -64
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Pushes/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Pushes/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Refs/action.json +0 -63
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Refs/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Refs/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/RefsFavorites/action.json +0 -84
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/RefsFavorites/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/RefsFavorites/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Repositories/action.json +0 -186
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Repositories/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Repositories/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Reverts/action.json +0 -64
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Reverts/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Reverts/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Stats/action.json +0 -23
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Stats/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Stats/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Statuses/action.json +0 -43
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Statuses/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Statuses/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Suggestions/action.json +0 -23
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Suggestions/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Suggestions/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Trees/action.json +0 -23
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Trees/mockdatafiles/mockdata.json +0 -20817
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Trees/schema.json +0 -125
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/methods.json +0 -74975
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/pronghorn.json +0 -11730
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/test/integration/adapterTestIntegration.js +0 -5493
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/test/unit/adapterTestUnit.js +0 -10889
|
@@ -1,532 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
|
|
3
|
-
const fs = require('fs-extra');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const { spawn } = require('child_process');
|
|
6
|
-
|
|
7
|
-
const folder = process.argv[2];
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
* This is the file to run in order to update your existing adapter.
|
|
12
|
-
* Make sure the zip is in the adapter's top level directory, then navigate there in the terminal and run 'node update'.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @summary the main function to be run in this file.
|
|
17
|
-
* @function run
|
|
18
|
-
*/
|
|
19
|
-
function run() {
|
|
20
|
-
|
|
21
|
-
// To ensure that the names of each group are brought in.
|
|
22
|
-
console.log('Updating...\n');
|
|
23
|
-
const names = JSON.parse(fs.readFileSync(path.join(__dirname, `./${folder}/components/methods.json`), 'utf8'));
|
|
24
|
-
const toDeleteNames = names.toDelByName.map(d => d.fnName);
|
|
25
|
-
const toAppendNames = names.toAppByName.map(d => d.fnName);
|
|
26
|
-
const toAppByName = names.toAppByName.map(d => ({name: d.name, fnName: d.fnName, parameters: d.func.parameters}));
|
|
27
|
-
const toUpdateNames = [];
|
|
28
|
-
toDeleteNames.forEach((n) => {
|
|
29
|
-
toAppendNames.forEach((a) => {
|
|
30
|
-
if (n === a && !toUpdateNames.includes(n)) {
|
|
31
|
-
toUpdateNames.push(n);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
// Creating copy of this object to be used later.
|
|
37
|
-
const curAppByName = JSON.parse(JSON.stringify(toAppByName));
|
|
38
|
-
|
|
39
|
-
// This object will contain any methods we attempt to add but already exist in the adapter, marking them for versioning.
|
|
40
|
-
const reAddingMethods = {};
|
|
41
|
-
const reAddingEmitMethods = {};
|
|
42
|
-
|
|
43
|
-
const adapterName = __dirname.split('/')[__dirname.split('/').length - 2].split('-')[1];
|
|
44
|
-
// Note that this assumes that the adapter name starts with 'adapter-'; if it does not, this will have to be edited.
|
|
45
|
-
|
|
46
|
-
// Filtering out and adding functions to the pronghorn.
|
|
47
|
-
if (fs.existsSync(path.join(__dirname, '../pronghorn.json'))) {
|
|
48
|
-
let pFile = JSON.parse(fs.readFileSync(path.join(__dirname, '../pronghorn.json'), 'utf8'));
|
|
49
|
-
pFile.methods = pFile.methods.filter(m => !toDeleteNames.includes(m.name));
|
|
50
|
-
//console.log(pFile.methods);
|
|
51
|
-
const methsToAdd = JSON.parse(fs.readFileSync(path.join(__dirname, `./${folder}/components/pronghorn.json`)));
|
|
52
|
-
methsToAdd.forEach((m) => {
|
|
53
|
-
//console.log(m.input);
|
|
54
|
-
if (toUpdateNames.includes(m.name)) {
|
|
55
|
-
pFile.methods.push(m);
|
|
56
|
-
}
|
|
57
|
-
// loop through methods and check signatures for versioning
|
|
58
|
-
let version = false;
|
|
59
|
-
let alreadyExists = false;
|
|
60
|
-
pFile.methods.forEach((pm) => {
|
|
61
|
-
if (pm.name === m.name) {
|
|
62
|
-
alreadyExists = true;
|
|
63
|
-
if (pm.input.length !== m.input.length) {
|
|
64
|
-
version = true;
|
|
65
|
-
} else {
|
|
66
|
-
for (let x = 0; x < m.input.length; x++) {
|
|
67
|
-
if (pm.input[x].name !== m.input[x].name || pm.input[x].required !== m.input[x].required || pm.input[x].type !== m.input[x].type) {
|
|
68
|
-
version = true;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
if (version) {
|
|
75
|
-
// add for versioning
|
|
76
|
-
reAddingMethods[m.name] = {};
|
|
77
|
-
reAddingEmitMethods[m.name] = {};
|
|
78
|
-
reAddingMethods[m.name].pronghorn = m;
|
|
79
|
-
} else if (toAppendNames.includes(m.name) && !alreadyExists && !version) {
|
|
80
|
-
pFile.methods.push(m);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
fs.writeFileSync(path.join(__dirname, '../pronghorn.json'), JSON.stringify(pFile, null, 2));
|
|
84
|
-
} else {
|
|
85
|
-
console.log('Your pronghorn.json file is missing; are you sure your adapter works?');
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
if (fs.existsSync(path.join(__dirname, '../test/unit/adapterTestUnit.js'))) {
|
|
89
|
-
let uFile = fs.readFileSync(path.join(__dirname, '../test/unit/adapterTestUnit.js'), 'utf8');
|
|
90
|
-
const last = uFile.split('\n').slice(uFile.split('\n').length - 3).join('\n');
|
|
91
|
-
let list = uFile.split('\n').slice(0, uFile.split('\n').length - 3).join('\n').split(/(?=\n {4}describe\()/g).filter((u) => {
|
|
92
|
-
let remain = true;
|
|
93
|
-
toDeleteNames.forEach((n) => {
|
|
94
|
-
if (u.indexOf('#'.concat(n, ' - ')) >= 0 || u.indexOf('#'.concat(n, 'Emit - ')) >= 0) {
|
|
95
|
-
remain = false;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
return remain;
|
|
99
|
-
});
|
|
100
|
-
list = list.join('');
|
|
101
|
-
let uChanges = fs.readFileSync(path.join(__dirname, `./${folder}/components/test/unit/adapterTestUnit.js`), 'utf8');
|
|
102
|
-
const units = uChanges.split(/(?=\n {4}describe\()/g);
|
|
103
|
-
if (units.length > 0) {
|
|
104
|
-
list = list.concat('\n');
|
|
105
|
-
}
|
|
106
|
-
units.forEach((un) => {
|
|
107
|
-
const u = un.replace(/Test-append-adapter/g, `Test-${adapterName}-adapter`); // See above about adapter name starting with 'adapter-'.
|
|
108
|
-
let remain = true;
|
|
109
|
-
toAppendNames.forEach((n) => {
|
|
110
|
-
if (list.includes('#'.concat(n, ' - ')) && u.includes('#'.concat(n, ' - '))) {
|
|
111
|
-
remain = false;
|
|
112
|
-
if (reAddingMethods[n] && !reAddingMethods[n].unit) {
|
|
113
|
-
reAddingMethods[n].unit = u;
|
|
114
|
-
}
|
|
115
|
-
} else if (list.includes('#'.concat(n, 'Emit - ')) && u.includes('#'.concat(n, 'Emit - '))) {
|
|
116
|
-
remain = false;
|
|
117
|
-
if (reAddingEmitMethods[n] && !reAddingEmitMethods[n].unit) {
|
|
118
|
-
reAddingEmitMethods[n].unit = u;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
if (remain) {
|
|
123
|
-
list = list.concat(u);
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
list = list.replace('\n\n\n ', '\n\n ').concat(last);
|
|
127
|
-
fs.writeFileSync(path.join(__dirname, '../test/unit/adapterTestUnit.js'), list);
|
|
128
|
-
} else {
|
|
129
|
-
console.log('Your unit test file does not exist, will not delete or add any tests.');
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (fs.existsSync(path.join(__dirname, '../test/integration/adapterTestIntegration.js'))) {
|
|
133
|
-
let iFile = fs.readFileSync(path.join(__dirname, '../test/integration/adapterTestIntegration.js'), 'utf8');
|
|
134
|
-
const last = iFile.split('\n').slice(iFile.split('\n').length - 3).join('\n');
|
|
135
|
-
let list = iFile.split('\n').slice(0, iFile.split('\n').length - 3).join('\n').split(/(?=\n {4}describe\()|(?=\n {4}const [a-zA-Z]+)/g).filter((i) => {
|
|
136
|
-
let remain = true;
|
|
137
|
-
toDeleteNames.forEach((n) => {
|
|
138
|
-
if (i.indexOf('#'.concat(n, ' - ')) >= 0 || i.indexOf('#'.concat(n, 'Emit - ')) >= 0) {
|
|
139
|
-
remain = false;
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
return remain;
|
|
143
|
-
});
|
|
144
|
-
list = list.join('');
|
|
145
|
-
|
|
146
|
-
let iChanges = fs.readFileSync(path.join(__dirname, `./${folder}/components/test/integration/adapterTestIntegration.js`), 'utf8');
|
|
147
|
-
const integrations = iChanges.split(/(?=\n {4}describe\()|(?=\n {4}const [a-zA-Z]+)/g);
|
|
148
|
-
if (integrations.length > 0) {
|
|
149
|
-
list = list.concat('\n');
|
|
150
|
-
}
|
|
151
|
-
integrations.forEach((integ) => {
|
|
152
|
-
const i = integ.replace(/Test-append/g, `Test-${adapterName}`);
|
|
153
|
-
let remain = true;
|
|
154
|
-
// This portion determines if this part is a body parameter or test. Note that both body parameters and tests are both versioned if necessary.
|
|
155
|
-
let bodyParamMatch = i.match(/const [a-zA-Z]+BodyParam/g);
|
|
156
|
-
if (bodyParamMatch && list.match(bodyParamMatch[0])) {
|
|
157
|
-
if (reAddingMethods && !reAddingMethods.bodyParams) {
|
|
158
|
-
reAddingMethods.bodyParams = [];
|
|
159
|
-
}
|
|
160
|
-
reAddingMethods.bodyParams.push(i);
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
toAppendNames.forEach((n) => {
|
|
164
|
-
if (list.includes('#'.concat(n, ' - ')) && i.includes('#'.concat(n, ' - '))) {
|
|
165
|
-
remain = false;
|
|
166
|
-
if (reAddingMethods[n] && !reAddingMethods[n].integration) {
|
|
167
|
-
reAddingMethods[n].integration = i;
|
|
168
|
-
}
|
|
169
|
-
} else if (list.includes('#'.concat(n, 'Emit - ')) && i.includes('#'.concat(n, 'Emit - '))) {
|
|
170
|
-
remain = false;
|
|
171
|
-
if (reAddingEmitMethods[n] && !reAddingEmitMethods[n].integration) {
|
|
172
|
-
reAddingEmitMethods[n].integration = i;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
if (remain) {
|
|
177
|
-
list = list.concat(i);
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
list = list.replace('\n\n\n ', '\n\n ').concat(last);
|
|
181
|
-
fs.writeFileSync(path.join(__dirname, '../test/integration/adapterTestIntegration.js'), list);
|
|
182
|
-
} else {
|
|
183
|
-
console.log('Your integration test file does not exist, will not delete or add any tests.');
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const uEntitiesDir = path.join(__dirname, `./${folder}/components/entities/`);
|
|
187
|
-
const uEntities = fs.readdirSync(uEntitiesDir, { withFileTypes: true })
|
|
188
|
-
.filter(files => files.isDirectory())
|
|
189
|
-
.map(files => files.name);
|
|
190
|
-
|
|
191
|
-
const entitiesDir = path.join(__dirname, '../entities');
|
|
192
|
-
const entities = fs.readdirSync(entitiesDir, { withFileTypes: true })
|
|
193
|
-
.filter(files => files.isDirectory())
|
|
194
|
-
.map(files => files.name);
|
|
195
|
-
const filtered = [];
|
|
196
|
-
entities.forEach((e) => {
|
|
197
|
-
if (!filtered.includes(e)) {
|
|
198
|
-
filtered.push(e);
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
if (!fs.existsSync(path.join(__dirname, '../entities'))) {
|
|
202
|
-
fs.mkdirSync(path.join(__dirname, '../entities'));
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
uEntities.forEach((e) => {
|
|
206
|
-
// If an entity that may attempt to have an action removed from it does not exist, it will be created with no actions in it. If it remains that way, a user can go and delete it later.
|
|
207
|
-
if (!fs.existsSync(path.join(__dirname, `../entities/${e}`))) {
|
|
208
|
-
fs.mkdirSync(path.join(__dirname, `../entities/${e}`));
|
|
209
|
-
fs.writeFileSync(path.join(__dirname, `../entities/${e}/action.json`), "{\n \"actions\": [\n ]\n}\n");
|
|
210
|
-
fs.writeFileSync(path.join(__dirname, `../entities/${e}/schema.json`), "{\n \"$id\": \"schema.json\",\n \"type\": \"object\",\n \"schema\": \"http://json-schema.org/draft-07/schema#\",\n \"translate\": false,\n \"dynamicfields\": true,\n \"properties\": {\n \"ph_request_type\": {\n \"type\": \"string\",\n \"description\": \"type of request (internal to adapter)\",\n \"default\": \"\",\n \"enum\": [\n ],\n \"external_name\": \"ph_request_type\"\n }\n },\n \"definitions\": {}\n}\n");
|
|
211
|
-
}
|
|
212
|
-
if (!fs.existsSync(path.join(__dirname, `../entities/${e}/action.json`))) {
|
|
213
|
-
fs.writeFileSync(path.join(__dirname, `../entities/${e}/action.json`), "{\n \"actions\": [\n ]\n}\n");
|
|
214
|
-
}
|
|
215
|
-
if (!fs.existsSync(path.join(__dirname, `../entities/${e}/schema.json`))) {
|
|
216
|
-
fs.writeFileSync(path.join(__dirname, `../entities/${e}/schema.json`), "{\n \"$id\": \"schema.json\",\n \"type\": \"object\",\n \"schema\": \"http://json-schema.org/draft-07/schema#\",\n \"translate\": false,\n \"dynamicfields\": true,\n \"properties\": {\n \"ph_request_type\": {\n \"type\": \"string\",\n \"description\": \"type of request (internal to adapter)\",\n \"default\": \"\",\n \"enum\": [\n ],\n \"external_name\": \"ph_request_type\"\n }\n },\n \"definitions\": {}\n}\n");
|
|
217
|
-
}
|
|
218
|
-
// The entities that will have functions deleted from them.
|
|
219
|
-
const thisEntityNames = names.toDelByName.filter(n => n.name === e).map(n => n.fnName);
|
|
220
|
-
|
|
221
|
-
// The entities that will have functions appended to them.
|
|
222
|
-
const thisMethodEntity = curAppByName.filter(n => n.name === e).map(n => n.fnName);
|
|
223
|
-
|
|
224
|
-
let aFile = JSON.parse(fs.readFileSync(path.join(__dirname, `../entities/${e}/action.json`), 'utf8'));
|
|
225
|
-
const aCopy = JSON.parse(JSON.stringify(aFile));
|
|
226
|
-
aFile.actions = aFile.actions.filter(a => !thisEntityNames.includes(a.name));
|
|
227
|
-
|
|
228
|
-
if (fs.readFileSync(path.join(__dirname, `./${folder}/components/entities/${e}/action.json`), 'utf8') !== '[]') {
|
|
229
|
-
let acts = JSON.parse(fs.readFileSync(path.join(__dirname, `./${folder}/components/entities/${e}/action.json`), 'utf8'));
|
|
230
|
-
acts.forEach((a) => {
|
|
231
|
-
if (reAddingMethods && Object.keys(reAddingMethods).includes(a.name)) {
|
|
232
|
-
reAddingMethods[a.name].action = a;
|
|
233
|
-
} else if (thisMethodEntity.includes(a.name) && !aFile.actions.map(ac => ac.name).includes(a.name)) {
|
|
234
|
-
aFile.actions.push(a);
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
fs.writeFileSync(path.join(__dirname, `../entities/${e}/action.json`), JSON.stringify(aFile, null, 2));
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
let sFile = JSON.parse(fs.readFileSync(path.join(__dirname, `../entities/${e}/schema.json`), 'utf8'));
|
|
241
|
-
sFile.properties.ph_request_type.enum = sFile.properties.ph_request_type.enum.filter(p => !thisEntityNames.includes(p));
|
|
242
|
-
if (fs.readFileSync(path.join(__dirname, `./${folder}/components/entities/${e}/schema.json`), 'utf8') !== '[]') {
|
|
243
|
-
let sches = JSON.parse(fs.readFileSync(path.join(__dirname, `./${folder}/components/entities/${e}/schema.json`), 'utf8')).properties.ph_request_type.enum;
|
|
244
|
-
sches.forEach((s) => {
|
|
245
|
-
if (reAddingMethods && Object.keys(reAddingMethods).includes(s)) {
|
|
246
|
-
reAddingMethods[s].schema = s;
|
|
247
|
-
} else if (thisMethodEntity.includes(s) && !sFile.properties.ph_request_type.enum.includes(s)) {
|
|
248
|
-
sFile.properties.ph_request_type.enum.push(s);
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
fs.writeFileSync(path.join(__dirname, `../entities/${e}/schema.json`), JSON.stringify(sFile, null, 2));
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
if (!fs.existsSync(path.join(__dirname, `../entities/${e}/mockdatafiles`))) {
|
|
255
|
-
fs.mkdirSync(path.join(__dirname, `../entities/${e}/mockdatafiles`));
|
|
256
|
-
}
|
|
257
|
-
const mock = JSON.parse(fs.readFileSync(path.join(__dirname, `./${folder}/components/entities/${e}/mockdatafiles/mockdata.json`), 'utf8'));
|
|
258
|
-
mock.forEach((m) => {
|
|
259
|
-
if (m.entity === e) {
|
|
260
|
-
// Currently do not have a .id field in the mock data (will always end in -default); future improvement.
|
|
261
|
-
const fileName = m.name || m.function.concat(m.id || '-default.json');
|
|
262
|
-
if (!fs.existsSync(path.join(__dirname, `../entities/${e}/mockdatafiles/${fileName}`)) || toUpdateNames.includes(m.function) || !aCopy.actions.map(ac => ac.name).includes(m.function)) {
|
|
263
|
-
fs.writeFileSync(path.join(__dirname, `../entities/${e}/mockdatafiles/${fileName}`), JSON.stringify(m.contents, null, 2));
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
// thisEntityNames.forEach((n) => {
|
|
268
|
-
// console.log(`We are not currently deleting existing mock data. path entities/${e}/mockdatafiles/${n}-default.json is intact if it exists.`);
|
|
269
|
-
// });
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
if (fs.existsSync(path.join(__dirname, '../adapter.js'))) {
|
|
273
|
-
let adFile = fs.readFileSync(path.join(__dirname, '../adapter.js'), 'utf8');
|
|
274
|
-
let splitArray = adFile.split('}\n\nmodule');
|
|
275
|
-
//if (splitArray[1] === undefined) {
|
|
276
|
-
//splitArray = adFile.split('}\nmodule');
|
|
277
|
-
//}
|
|
278
|
-
|
|
279
|
-
// const last = adFile.split('\n').slice(adFile.split('\n').length - 4).join('\n');
|
|
280
|
-
let list = adFile.split('\n').slice(0, adFile.split('\n').length - 4).join('\n').split(/(?=\n {2}\/\*\*\n {3}\* @summary)/g).filter((u) => {
|
|
281
|
-
let remain = true;
|
|
282
|
-
toDeleteNames.forEach((n) => {
|
|
283
|
-
if (u.indexOf('\n '.concat(n, '(')) >= 0) {
|
|
284
|
-
remain = false;
|
|
285
|
-
} else if (reAddingMethods && Object.keys(reAddingMethods).includes(n)) {
|
|
286
|
-
remain = false;
|
|
287
|
-
reAddingMethods[n].adapter = u;
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
return remain;
|
|
291
|
-
}).join('');
|
|
292
|
-
let adChanges = fs.readFileSync(path.join(__dirname, `./${folder}/components/adapter.js`), 'utf8');
|
|
293
|
-
const adMethods = adChanges.split(/(?=\n {2}\/\*\*\n {3}\* @function)/g);
|
|
294
|
-
if (adMethods.length > 0) {
|
|
295
|
-
list = list.concat('\n');
|
|
296
|
-
}
|
|
297
|
-
adMethods.forEach((a) => {
|
|
298
|
-
let remain = true;
|
|
299
|
-
//console.log(toAppendNames);
|
|
300
|
-
|
|
301
|
-
toAppendNames.forEach((n) => {
|
|
302
|
-
if (list.includes(n.concat('(')) && a.includes(n.concat('('))) {
|
|
303
|
-
let checkPrefix = a.split('@function ');
|
|
304
|
-
checkPrefix = checkPrefix[1].split('\n');
|
|
305
|
-
checkPrefix = checkPrefix[0];
|
|
306
|
-
if (checkPrefix === n) {
|
|
307
|
-
remain = false;
|
|
308
|
-
if (reAddingMethods[n] && !reAddingMethods[n].adapter) {
|
|
309
|
-
reAddingMethods[n].adapter = a;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
/**
|
|
315
|
-
toAppendNames.forEach((n) => {
|
|
316
|
-
if (list.includes(n.concat('(')) && a.includes(n.concat('('))) {
|
|
317
|
-
remain = false;
|
|
318
|
-
if (reAddingMethods[n] && !reAddingMethods[n].adapter) {
|
|
319
|
-
reAddingMethods[n].adapter = a;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
**/
|
|
324
|
-
if (remain) {
|
|
325
|
-
list = list.concat(a);
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
list = list.concat('}\n\nmodule', splitArray[1]);
|
|
329
|
-
fs.writeFileSync(path.join(__dirname, '../adapter.js'), list);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
// This is the object to be used in determining what version to assign methods that already exist.
|
|
333
|
-
let versionList = {};
|
|
334
|
-
if (fs.existsSync(path.join(__dirname, '../versions.json'))) {
|
|
335
|
-
versionList = JSON.parse(fs.readFileSync(path.join(__dirname, '../versions.json'), 'utf8'));
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
const newAdapter = fs.readFileSync(path.join(__dirname, '../adapter.js'), 'utf8');
|
|
339
|
-
const methods = newAdapter.match(/\n {2}[a-zA-Z]+\(/g).map(s => s.substr(3, s.length - 4));
|
|
340
|
-
let aRet = fs.readFileSync(path.join(__dirname, '../adapter.js'), 'utf8');
|
|
341
|
-
let versionedAdapters = "";
|
|
342
|
-
methods.forEach((m) => {
|
|
343
|
-
if (['constructor', 'hasEntity', 'verifyCapability', 'updateEntityCache'].includes(m)) {
|
|
344
|
-
versionList[m] = -1;
|
|
345
|
-
return;
|
|
346
|
-
// Those are the default methods: should not ever change unless by user directly or itential update.
|
|
347
|
-
} else if (!Object.keys(versionList).includes(m)) {
|
|
348
|
-
versionList[m] = 0;
|
|
349
|
-
// This method does not yet exist, it will be added as the original (version 0).
|
|
350
|
-
}
|
|
351
|
-
// console.log(reAddingMethods['uploadFile']);
|
|
352
|
-
if (typeof reAddingMethods[m] !== 'undefined') {
|
|
353
|
-
versionList[m] += 1;
|
|
354
|
-
const newMethodName = `${m}__v${versionList[m]}`; // The old name, double underscore then v(version#)
|
|
355
|
-
//console.log(newMethodName);
|
|
356
|
-
// The below code replaces all existences of the previous name with the new one in the relevant files, then performs an append as it would if this were a unique method.
|
|
357
|
-
const ph = JSON.parse(fs.readFileSync(path.join(__dirname, '../pronghorn.json'), 'utf8'));
|
|
358
|
-
reAddingMethods[m].pronghorn.name = newMethodName;
|
|
359
|
-
reAddingMethods[m].pronghorn.route.path = `\/${newMethodName}`;
|
|
360
|
-
ph.methods.push(reAddingMethods[m].pronghorn);
|
|
361
|
-
fs.writeFileSync(path.join(__dirname, '../pronghorn.json'), JSON.stringify(ph, null, 2));
|
|
362
|
-
|
|
363
|
-
const uFile = fs.readFileSync(path.join(__dirname, '../test/unit/adapterTestUnit.js'), 'utf8');
|
|
364
|
-
const uLast = uFile.split('\n').slice(uFile.split('\n').length - 3).join('\n');
|
|
365
|
-
|
|
366
|
-
if (typeof reAddingMethods[m].unit !== 'undefined') {
|
|
367
|
-
reAddingMethods[m].unit = reAddingMethods[m].unit.replace(`#${m} `, `#${newMethodName} `).replace(`\.${m} `, `\.${newMethodName} `).replace(` ${m} `, ` ${newMethodName} `);
|
|
368
|
-
const re = new RegExp(`\\.${m}\\(`, 'g');
|
|
369
|
-
const re1 = new RegExp(`-${m}\\'`, 'g');
|
|
370
|
-
reAddingMethods[m].unit = reAddingMethods[m].unit.replace(re, `\.${newMethodName}\(`);
|
|
371
|
-
reAddingMethods[m].unit = reAddingMethods[m].unit.replace(re1, `-${newMethodName}\'`);
|
|
372
|
-
const uRet = uFile.split('\n').slice(0, uFile.split('\n').length - 3).join('\n').concat('\n', reAddingMethods[m].unit, uLast);
|
|
373
|
-
fs.writeFileSync(path.join(__dirname, '../test/unit/adapterTestUnit.js'), uRet);
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
const iFile = fs.readFileSync(path.join(__dirname, '../test/integration/adapterTestIntegration.js'), 'utf8');
|
|
377
|
-
const iLast = iFile.split('\n').slice(iFile.split('\n').length - 3).join('\n');
|
|
378
|
-
|
|
379
|
-
if (typeof reAddingMethods[m].integration !== 'undefined') {
|
|
380
|
-
reAddingMethods[m].integration = reAddingMethods[m].integration.replace(`#${m} - `, `#${newMethodName} - `).replace(`\.${m}\(`, `\.${newMethodName}\(`).replace(`\'${m}\'`, `\'${newMethodName}\'`).concat(reAddingMethods[m].integration.endsWith('\n') ? '' : '\n');
|
|
381
|
-
|
|
382
|
-
// check for typeof undefined
|
|
383
|
-
if (typeof reAddingMethods.bodyParams !== 'undefined') {
|
|
384
|
-
reAddingMethods.bodyParams.forEach((b) => {
|
|
385
|
-
const varName = b.split(' = ')[0].substring(10);
|
|
386
|
-
if (reAddingMethods[m].integration.match(new RegExp(varName.concat(',')))) {
|
|
387
|
-
const nb = b.replace(varName, `${varName}__v${versionList[m]}`);
|
|
388
|
-
reAddingMethods[m].integration = nb.concat(reAddingMethods[m].integration);
|
|
389
|
-
reAddingMethods[m].integration = reAddingMethods[m].integration.replace(new RegExp(varName.concat(','), 'g'), varName.concat(`__v${versionList[m]},`));
|
|
390
|
-
}
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
const iRet = iFile.split('\n').slice(0, iFile.split('\n').length - 3).join('\n').concat('\n', reAddingMethods[m].integration, iLast);
|
|
395
|
-
fs.writeFileSync(path.join(__dirname, '../test/integration/adapterTestIntegration.js'), iRet);
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
const thisMethodEntity = curAppByName.filter(a => a.fnName === m)[0].name;
|
|
399
|
-
const action = JSON.parse(fs.readFileSync(path.join(__dirname, `../entities/${thisMethodEntity}/action.json`)));
|
|
400
|
-
|
|
401
|
-
if (typeof reAddingMethods[m].action !== 'undefined') {
|
|
402
|
-
reAddingMethods[m].action.name = newMethodName;
|
|
403
|
-
reAddingMethods[m].action.responseObjects.forEach((r) => {
|
|
404
|
-
r.mockFile = r.mockFile.replace(m, newMethodName);
|
|
405
|
-
});
|
|
406
|
-
action.actions.push(reAddingMethods[m].action);
|
|
407
|
-
fs.writeFileSync(path.join(__dirname, `../entities/${thisMethodEntity}/action.json`), JSON.stringify(action, null, 2));
|
|
408
|
-
}
|
|
409
|
-
if (fs.readFileSync(path.join(__dirname, `./${folder}/components/entities/${thisMethodEntity}/schema.json`), 'utf8') !== '[]') {
|
|
410
|
-
const schema = JSON.parse(fs.readFileSync(path.join(__dirname, `../entities/${thisMethodEntity}/schema.json`)));
|
|
411
|
-
reAddingMethods[m].schema = newMethodName;
|
|
412
|
-
schema.properties.ph_request_type.enum.push(reAddingMethods[m].schema);
|
|
413
|
-
fs.writeFileSync(path.join(__dirname, `../entities/${thisMethodEntity}/schema.json`), JSON.stringify(schema, null, 2));
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
const mock = JSON.parse(fs.readFileSync(path.join(__dirname, `./${folder}/components/entities/${thisMethodEntity}/mockdatafiles/mockdata.json`), 'utf8'));
|
|
417
|
-
mock.forEach((mo) => {
|
|
418
|
-
const moc = mo;
|
|
419
|
-
if (moc.function === m && thisMethodEntity === moc.entity) {
|
|
420
|
-
moc.name = moc.name.replace(m, newMethodName);
|
|
421
|
-
moc.function = newMethodName;
|
|
422
|
-
fs.writeFileSync(path.join(__dirname, `../entities/${thisMethodEntity}/mockdatafiles/${moc.name}`), JSON.stringify(moc.contents, null, 2));
|
|
423
|
-
}
|
|
424
|
-
});
|
|
425
|
-
|
|
426
|
-
if (typeof reAddingMethods[m].adapter !== 'undefined') {
|
|
427
|
-
reAddingMethods[m].adapter = reAddingMethods[m].adapter.replace(`\n ${m}(`, `\n ${newMethodName}(`).replace(`\@function ${m}`, `\@function ${newMethodName}`).replace(`adapter-${m}\'`, `adapter-${newMethodName}\'`).replace(new RegExp(`\'${m}\'`, 'g'), `\'${newMethodName}\'`);
|
|
428
|
-
versionedAdapters = versionedAdapters.concat('\n', reAddingMethods[m].adapter).replace(/\n{2,}/, '\n');
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
if (reAddingEmitMethods[m]) {
|
|
433
|
-
const newMethodName = `${m}__v${versionList[m]}`;
|
|
434
|
-
const newEmitMethodName = `${m}Emit__v${versionList[m]}`; // The old name, double underscore then v(version#)
|
|
435
|
-
|
|
436
|
-
const uFile = fs.readFileSync(path.join(__dirname, '../test/unit/adapterTestUnit.js'), 'utf8');
|
|
437
|
-
const uLast = uFile.split('\n').slice(uFile.split('\n').length - 3).join('\n');
|
|
438
|
-
|
|
439
|
-
if (typeof reAddingEmitMethods[m].unit !== 'undefined') {
|
|
440
|
-
reAddingEmitMethods[m].unit = reAddingEmitMethods[m].unit.replace(`#${m}Emit `, `#${newEmitMethodName} `).replace(`\.${m}Emit `, `\.${newEmitMethodName} `).replace(` ${m}Emit `, ` ${newEmitMethodName} `).replace(`\.${m}Emit\(`, `\.${newEmitMethodName}\(`).replace(`-${m}\'`, `-${newMethodName}\'`);
|
|
441
|
-
const uRet = uFile.split('\n').slice(0, uFile.split('\n').length - 3).join('\n').concat(reAddingEmitMethods[m].unit, uLast);
|
|
442
|
-
fs.writeFileSync(path.join(__dirname, '../test/unit/adapterTestUnit.js'), uRet);
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
const iFile = fs.readFileSync(path.join(__dirname, '../test/integration/adapterTestIntegration.js'), 'utf8');
|
|
446
|
-
const iLast = iFile.split('\n').slice(iFile.split('\n').length - 3).join('\n');
|
|
447
|
-
|
|
448
|
-
if (typeof reAddingEmitMethods[m].integration !== 'undefined') {
|
|
449
|
-
reAddingEmitMethods[m].integration = reAddingEmitMethods[m].integration.replace(`#${m}Emit - `, `#${newEmitMethodName} - `).replace(`\.${m}Emit\(`, `\.${newEmitMethodName}\(`).replace(`\'${m}Emit\'`, `\'${newEmitMethodName}\'`).concat(reAddingEmitMethods[m].integration.endsWith('\n') ? '' : '\n');
|
|
450
|
-
|
|
451
|
-
// check for typeof undefined
|
|
452
|
-
if (typeof reAddingEmitMethods.bodyParams !== 'undefined') {
|
|
453
|
-
reAddingEmitMethods.bodyParams.forEach((b) => {
|
|
454
|
-
const varName = b.split(' = ')[0].substring(10);
|
|
455
|
-
if (reAddingEmitMethods[m].integration.match(new RegExp(varName.concat(',')))) {
|
|
456
|
-
const nb = b.replace(varName, `${varName}__v${versionList[m]}`);
|
|
457
|
-
reAddingEmitMethods[m].integration = nb.concat(reAddingEmitMethods[m].integration);
|
|
458
|
-
reAddingEmitMethods[m].integration = reAddingEmitMethods[m].integration.replace(new RegExp(varName.concat(','), 'g'), varName.concat(`__v${versionList[m]},`));
|
|
459
|
-
}
|
|
460
|
-
});
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
const iRet = iFile.split('\n').slice(0, iFile.split('\n').length - 3).join('\n').concat('\n', reAddingEmitMethods[m].integration, iLast);
|
|
464
|
-
fs.writeFileSync(path.join(__dirname, '../test/integration/adapterTestIntegration.js'), iRet);
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
});
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
// Read in the adapter.js file and add the versioned adapters to the end. String manipulation to add correct brackets & export
|
|
471
|
-
if (versionedAdapters != "") {
|
|
472
|
-
let finalAdapter = fs.readFileSync(path.join(__dirname, '../adapter.js'), 'utf8');
|
|
473
|
-
const splitArray = finalAdapter.split('}\n\nmodule');
|
|
474
|
-
// const aFinal = finalAdapter.split('\n').slice(finalAdapter.split('\n').length - 4).join('\n')
|
|
475
|
-
// finalAdapter = finalAdapter.replace(aFinal, "");
|
|
476
|
-
// const adapterNameCaps = adapterName.charAt(0).toUpperCase() + adapterName.slice(1);
|
|
477
|
-
finalAdapter = splitArray[0].concat(versionedAdapters, '}\n\nmodule', splitArray[1]);
|
|
478
|
-
|
|
479
|
-
// write the new adapter.js and updated versions.json
|
|
480
|
-
fs.writeFileSync(path.join(__dirname, '../adapter.js'), finalAdapter);
|
|
481
|
-
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
fs.writeFileSync(path.join(__dirname, '../versions.json'), JSON.stringify(versionList, null, 2));
|
|
485
|
-
|
|
486
|
-
// Here, the lint, unit, and integration tests are run to ensure the operations succeeded. If not, the user may have to go and fix things.
|
|
487
|
-
console.log('Update Done\n')
|
|
488
|
-
console.log('Linting...\n');
|
|
489
|
-
const lint = spawn('npm', ['run', 'lint'], {
|
|
490
|
-
cwd: path.join(__dirname, '..')
|
|
491
|
-
});
|
|
492
|
-
let testLintErr = '';
|
|
493
|
-
lint.stderr.on('data', (err) => {
|
|
494
|
-
testLintErr = testLintErr.concat(err);
|
|
495
|
-
});
|
|
496
|
-
let testLintOut = '';
|
|
497
|
-
lint.stdout.on('data', (out) => {
|
|
498
|
-
testLintOut = testLintOut.concat(out);
|
|
499
|
-
});
|
|
500
|
-
lint.on('close', (code) => {
|
|
501
|
-
console.log(`Lint exited with code ${code}`);
|
|
502
|
-
if (code == 0) {
|
|
503
|
-
console.log('Lint test passed with no errors');
|
|
504
|
-
console.log('\n\nRunning unit and integration tests...\n\n');
|
|
505
|
-
} else {
|
|
506
|
-
console.log(testLintErr);
|
|
507
|
-
console.log('\n\nRunning unit and integration tests...\n\n')
|
|
508
|
-
}
|
|
509
|
-
});
|
|
510
|
-
|
|
511
|
-
const tests = spawn('npm', ['run', 'test'], {
|
|
512
|
-
cwd: path.join(__dirname, '..')
|
|
513
|
-
});
|
|
514
|
-
let testErr = '';
|
|
515
|
-
tests.stderr.on('data', (err) => {
|
|
516
|
-
testErr = testErr.concat(err);
|
|
517
|
-
});
|
|
518
|
-
let testOut = '';
|
|
519
|
-
tests.stdout.on('data', (out) => {
|
|
520
|
-
testOut = testOut.concat(out);
|
|
521
|
-
});
|
|
522
|
-
tests.on('close', (code) => {
|
|
523
|
-
console.log(`Tests exited with code ${code}`);
|
|
524
|
-
if (code === 0) {
|
|
525
|
-
console.log(testOut);
|
|
526
|
-
} else {
|
|
527
|
-
console.log(testErr);
|
|
528
|
-
}
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
run();
|