occam-entities 1.0.1
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/.swcrc +5 -0
- package/README.md +78 -0
- package/lib/constants.js +26 -0
- package/lib/dependencies.js +114 -0
- package/lib/dependency.js +68 -0
- package/lib/directory.js +107 -0
- package/lib/entries.js +251 -0
- package/lib/file.js +155 -0
- package/lib/fileNames.js +59 -0
- package/lib/files.js +121 -0
- package/lib/index.js +79 -0
- package/lib/mixins/bnf.js +47 -0
- package/lib/mixins/entries.js +103 -0
- package/lib/mixins/files.js +41 -0
- package/lib/mixins/metaJSON.js +36 -0
- package/lib/mixins/pattern.js +47 -0
- package/lib/multiplers.js +26 -0
- package/lib/project.js +98 -0
- package/lib/projects.js +112 -0
- package/lib/release.js +148 -0
- package/lib/releases.js +112 -0
- package/lib/shortenedVersion.js +105 -0
- package/lib/types.js +22 -0
- package/lib/utilities/content.js +34 -0
- package/lib/utilities/filePath.js +63 -0
- package/lib/utilities/files.js +85 -0
- package/lib/utilities/metaJSON.js +127 -0
- package/lib/utilities/name.js +18 -0
- package/lib/utilities/query.js +41 -0
- package/lib/utilities/version.js +71 -0
- package/lib/version.js +160 -0
- package/license.txt +48 -0
- package/package.json +34 -0
- package/src/constants.js +5 -0
- package/src/dependencies.js +75 -0
- package/src/dependency.js +29 -0
- package/src/directory.js +60 -0
- package/src/entries.js +217 -0
- package/src/file.js +107 -0
- package/src/fileNames.js +22 -0
- package/src/files.js +78 -0
- package/src/index.js +17 -0
- package/src/mixins/bnf.js +59 -0
- package/src/mixins/entries.js +73 -0
- package/src/mixins/files.js +52 -0
- package/src/mixins/metaJSON.js +48 -0
- package/src/mixins/pattern.js +59 -0
- package/src/multiplers.js +5 -0
- package/src/project.js +63 -0
- package/src/projects.js +66 -0
- package/src/release.js +145 -0
- package/src/releases.js +66 -0
- package/src/shortenedVersion.js +71 -0
- package/src/types.js +4 -0
- package/src/utilities/content.js +12 -0
- package/src/utilities/filePath.js +36 -0
- package/src/utilities/files.js +95 -0
- package/src/utilities/metaJSON.js +149 -0
- package/src/utilities/name.js +13 -0
- package/src/utilities/query.js +31 -0
- package/src/utilities/version.js +70 -0
- package/src/version.js +123 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { versionFromNode, repositoryFromNode, dependenciesFromNode, dependencyNamesFromNode, metaJSONNodeFromMetaJSONFile } from "../utilities/metaJSON";
|
|
4
|
+
|
|
5
|
+
function getVersion() {
|
|
6
|
+
const metaJSONFile = this.getMetaJSONFile(),
|
|
7
|
+
metaJSONNode = metaJSONNodeFromMetaJSONFile(metaJSONFile),
|
|
8
|
+
node = metaJSONNode, ///
|
|
9
|
+
version = versionFromNode(node);
|
|
10
|
+
|
|
11
|
+
return version;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function getRepository() {
|
|
15
|
+
const metaJSONFile = this.getMetaJSONFile(),
|
|
16
|
+
metaJSONNode = metaJSONNodeFromMetaJSONFile(metaJSONFile),
|
|
17
|
+
node = metaJSONNode, ///
|
|
18
|
+
repository = repositoryFromNode(node);
|
|
19
|
+
|
|
20
|
+
return repository;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getDependencies() {
|
|
24
|
+
const metaJSONFile = this.getMetaJSONFile(),
|
|
25
|
+
metaJSONNode = metaJSONNodeFromMetaJSONFile(metaJSONFile),
|
|
26
|
+
node = metaJSONNode, ///
|
|
27
|
+
dependencies = dependenciesFromNode(node);
|
|
28
|
+
|
|
29
|
+
return dependencies;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function getDependencyNames() {
|
|
33
|
+
const metaJSONFile = this.getMetaJSONFile(),
|
|
34
|
+
metaJSONNode = metaJSONNodeFromMetaJSONFile(metaJSONFile),
|
|
35
|
+
node = metaJSONNode, ///
|
|
36
|
+
dependencyNames = dependencyNamesFromNode(node);
|
|
37
|
+
|
|
38
|
+
return dependencyNames;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const metaJSONMixins = {
|
|
42
|
+
getVersion,
|
|
43
|
+
getRepository,
|
|
44
|
+
getDependencies,
|
|
45
|
+
getDependencyNames
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default metaJSONMixins;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { fileNameFromFilePath } from "../utilities/name";
|
|
4
|
+
import { TYPE_PATTERN_FILE_NAME, SYMBOL_PATTERN_FILE_NAME, OPERATOR_PATTERN_FILE_NAME } from "../fileNames";
|
|
5
|
+
|
|
6
|
+
function getPattern(patternFileName) {
|
|
7
|
+
let pattern = null;
|
|
8
|
+
|
|
9
|
+
const customGrammarPatternFiles = this.getCustomGrammarPatternFiles(),
|
|
10
|
+
customGrammarPatternFile = customGrammarPatternFiles.find((customGrammarPatternFile) => {
|
|
11
|
+
const customGrammarPatternFilePath = customGrammarPatternFile.getPath(),
|
|
12
|
+
customGrammarPatternFileName = fileNameFromFilePath(customGrammarPatternFilePath);
|
|
13
|
+
|
|
14
|
+
if (customGrammarPatternFileName === patternFileName) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
}) || null;
|
|
18
|
+
|
|
19
|
+
if (customGrammarPatternFile !== null) {
|
|
20
|
+
const customGrammarPatternFileContent = customGrammarPatternFile.getContent();
|
|
21
|
+
|
|
22
|
+
pattern = customGrammarPatternFileContent; ///
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return pattern;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getTypePattern() {
|
|
29
|
+
const fileName = TYPE_PATTERN_FILE_NAME, ///
|
|
30
|
+
pattern = this.getPattern(fileName),
|
|
31
|
+
typePattern = pattern; ///
|
|
32
|
+
|
|
33
|
+
return typePattern;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function getSymbolPattern() {
|
|
37
|
+
const fileName = SYMBOL_PATTERN_FILE_NAME, ///
|
|
38
|
+
pattern = this.getPattern(fileName),
|
|
39
|
+
symbolPattern = pattern; ///
|
|
40
|
+
|
|
41
|
+
return symbolPattern;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function getOperatorPattern() {
|
|
45
|
+
const fileName = OPERATOR_PATTERN_FILE_NAME, ///
|
|
46
|
+
pattern = this.getPattern(fileName),
|
|
47
|
+
operatorPattern = pattern; ///
|
|
48
|
+
|
|
49
|
+
return operatorPattern;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const patternMixins = {
|
|
53
|
+
getPattern,
|
|
54
|
+
getTypePattern,
|
|
55
|
+
getSymbolPattern,
|
|
56
|
+
getOperatorPattern
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export default patternMixins;
|
package/src/project.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Entries from "./entries";
|
|
4
|
+
import entriesMixins from "./mixins/entries";
|
|
5
|
+
|
|
6
|
+
class Project {
|
|
7
|
+
constructor(name, entries) {
|
|
8
|
+
this.name = name;
|
|
9
|
+
this.entries = entries;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
getName() {
|
|
13
|
+
return this.name;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
getEntries() {
|
|
17
|
+
return this.entries;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
toJSON() {
|
|
21
|
+
const entriesJSON = this.entries.toJSON(),
|
|
22
|
+
name = this.name,
|
|
23
|
+
entries = entriesJSON, ///
|
|
24
|
+
json = {
|
|
25
|
+
name,
|
|
26
|
+
entries
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return json;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static fromJSON(json) {
|
|
33
|
+
let { entries } = json;
|
|
34
|
+
|
|
35
|
+
const { name } = json,
|
|
36
|
+
entriesJSON = entries; ///
|
|
37
|
+
|
|
38
|
+
json = entriesJSON; ///
|
|
39
|
+
|
|
40
|
+
entries = Entries.fromJSON(json); ///
|
|
41
|
+
|
|
42
|
+
const project = new Project(name, entries);
|
|
43
|
+
|
|
44
|
+
return project;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static fromName(name) {
|
|
48
|
+
const entries = Entries.fromNothing(),
|
|
49
|
+
project = new Project(name, entries);
|
|
50
|
+
|
|
51
|
+
return project;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static fromNameAndEntries(name, entries) {
|
|
55
|
+
const project = new Project(name, entries);
|
|
56
|
+
|
|
57
|
+
return project;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
Object.assign(Project.prototype, entriesMixins);
|
|
62
|
+
|
|
63
|
+
export default Project;
|
package/src/projects.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { asynchronousUtilities } from "necessary";
|
|
4
|
+
|
|
5
|
+
import Project from "./project";
|
|
6
|
+
|
|
7
|
+
const { forEach } = asynchronousUtilities;
|
|
8
|
+
|
|
9
|
+
export default class Projects {
|
|
10
|
+
constructor(array) {
|
|
11
|
+
this.array = array;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
getLength() {
|
|
15
|
+
return this.array.length;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
addProject(project) {
|
|
19
|
+
this.array.push(project);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
mapProject(callback) {
|
|
23
|
+
return this.array.map(callback);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
reduceProject(callback, initialValue) {
|
|
27
|
+
return this.array.reduce(callback, initialValue);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
forEachProject(callback) {
|
|
31
|
+
this.array.forEach(callback);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
asynchronousForEachProject(callback, done) {
|
|
35
|
+
forEach(this.array, callback, done);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
toJSON() {
|
|
39
|
+
const json = this.array.map((project) => {
|
|
40
|
+
const projectJSON = project.toJSON();
|
|
41
|
+
|
|
42
|
+
return projectJSON;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return json;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static fromJSON(json) {
|
|
49
|
+
const array = json.map((json) => { ///
|
|
50
|
+
const project = Project.fromJSON(json);
|
|
51
|
+
|
|
52
|
+
return project;
|
|
53
|
+
}),
|
|
54
|
+
projects = new Projects(array);
|
|
55
|
+
|
|
56
|
+
return projects;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static fromNothing() {
|
|
60
|
+
const array = [],
|
|
61
|
+
projects = new Projects(array);
|
|
62
|
+
|
|
63
|
+
return projects;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
package/src/release.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import File from "./file";
|
|
4
|
+
import Entries from "./entries";
|
|
5
|
+
import entriesMixins from "./mixins/entries";
|
|
6
|
+
|
|
7
|
+
import { DOUBLE_SPACE } from "./constants";
|
|
8
|
+
import { isMetaJSONFileValid } from "./utilities/metaJSON";
|
|
9
|
+
import { readmeFileFromFiles, metaJSONFileFromFiles } from "./utilities/files";
|
|
10
|
+
|
|
11
|
+
class Release {
|
|
12
|
+
constructor(name, entries) {
|
|
13
|
+
this.name = name;
|
|
14
|
+
this.entries = entries;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getName() {
|
|
18
|
+
return this.name;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
getEntries() {
|
|
22
|
+
return this.entries;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
updateVersion(version) {
|
|
26
|
+
let repository = this.getRepository(),
|
|
27
|
+
dependencies = this.getDependencies();
|
|
28
|
+
|
|
29
|
+
const versionString = version.toString(),
|
|
30
|
+
repositoryJSON = repository, ///
|
|
31
|
+
dependenciesJSON = dependencies.toJSON();
|
|
32
|
+
|
|
33
|
+
version = versionString; ///
|
|
34
|
+
repository = repositoryJSON; ///
|
|
35
|
+
dependencies = dependenciesJSON; ///
|
|
36
|
+
|
|
37
|
+
const metaJSONFile = this.getMetaJSONFile(),
|
|
38
|
+
json = {
|
|
39
|
+
version,
|
|
40
|
+
repository,
|
|
41
|
+
dependencies
|
|
42
|
+
},
|
|
43
|
+
jsonString = JSON.stringify(json, null, DOUBLE_SPACE),
|
|
44
|
+
file = metaJSONFile, ///
|
|
45
|
+
content = jsonString; ///
|
|
46
|
+
|
|
47
|
+
file.setContent(content);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
toJSON() {
|
|
51
|
+
const entriesJSON = this.entries.toJSON(),
|
|
52
|
+
name = this.name,
|
|
53
|
+
entries = entriesJSON, ///
|
|
54
|
+
json = {
|
|
55
|
+
name,
|
|
56
|
+
entries
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return json;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static fromJSON(json) {
|
|
63
|
+
let { entries } = json;
|
|
64
|
+
|
|
65
|
+
const { name } = json,
|
|
66
|
+
entriesJSON = entries; ///
|
|
67
|
+
|
|
68
|
+
json = entriesJSON; ///
|
|
69
|
+
|
|
70
|
+
entries = Entries.fromJSON(json); ///
|
|
71
|
+
|
|
72
|
+
const release = new Release(name, entries);
|
|
73
|
+
|
|
74
|
+
return release;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static fromNameAndEntries(name, entries) {
|
|
78
|
+
let release = null;
|
|
79
|
+
|
|
80
|
+
const entriesReleasable = areEntriesReleasable(entries);
|
|
81
|
+
|
|
82
|
+
if (entriesReleasable) {
|
|
83
|
+
release = new Release(name, entries);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return release;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
static fromProject(project) {
|
|
90
|
+
let release = null,
|
|
91
|
+
entries = project.getEntries();
|
|
92
|
+
|
|
93
|
+
const entriesReleasable = areEntriesReleasable(entries);
|
|
94
|
+
|
|
95
|
+
if (entriesReleasable) {
|
|
96
|
+
const name = project.getName(),
|
|
97
|
+
releasedEntries = releaseEntries(entries);
|
|
98
|
+
|
|
99
|
+
entries = releasedEntries; ///
|
|
100
|
+
|
|
101
|
+
release = new Release(name, entries);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return release;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
Object.assign(Release.prototype, entriesMixins);
|
|
109
|
+
|
|
110
|
+
export default Release;
|
|
111
|
+
|
|
112
|
+
function releaseEntries(entries) {
|
|
113
|
+
const releasedEntries = Entries.fromNothing(), ///
|
|
114
|
+
files = entries.getFiles();
|
|
115
|
+
|
|
116
|
+
files.forEachFile((file) => {
|
|
117
|
+
const path = file.getPath(),
|
|
118
|
+
content = file.getContent(),
|
|
119
|
+
released = true;
|
|
120
|
+
|
|
121
|
+
file = File.fromPathContentAndReleased(path, content, released); ///
|
|
122
|
+
|
|
123
|
+
releasedEntries.addFile(file);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
return releasedEntries;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function areEntriesReleasable(entries) {
|
|
130
|
+
let entriesReleasable = false;
|
|
131
|
+
|
|
132
|
+
const files = entries.getFiles(),
|
|
133
|
+
readmeFile = readmeFileFromFiles(files),
|
|
134
|
+
metaJSONFile = metaJSONFileFromFiles(files);
|
|
135
|
+
|
|
136
|
+
if ((readmeFile !== null) && (metaJSONFile !== null)) {
|
|
137
|
+
const metaJSONFileValid = isMetaJSONFileValid(metaJSONFile);
|
|
138
|
+
|
|
139
|
+
if (metaJSONFileValid) {
|
|
140
|
+
entriesReleasable = true;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return entriesReleasable;
|
|
145
|
+
}
|
package/src/releases.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { asynchronousUtilities } from "necessary";
|
|
4
|
+
|
|
5
|
+
import Release from "./release";
|
|
6
|
+
|
|
7
|
+
const { forEach } = asynchronousUtilities;
|
|
8
|
+
|
|
9
|
+
export default class Releases {
|
|
10
|
+
constructor(array) {
|
|
11
|
+
this.array = array;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
getLength() {
|
|
15
|
+
return this.array.length;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
addRelease(release) {
|
|
19
|
+
this.array.push(release);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
mapRelease(callback) {
|
|
23
|
+
return this.array.map(callback);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
reduceRelease(callback, initialValue) {
|
|
27
|
+
return this.array.reduce(callback, initialValue);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
forEachRelease(callback) {
|
|
31
|
+
this.array.forEach(callback);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
asynchronousForEachRelease(callback, done) {
|
|
35
|
+
forEach(this.array, callback, done);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
toJSON() {
|
|
39
|
+
const json = this.array.map((release) => {
|
|
40
|
+
const releaseJSON = release.toJSON();
|
|
41
|
+
|
|
42
|
+
return releaseJSON;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return json;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static fromJSON(json) {
|
|
49
|
+
const array = json.map((json) => { ///
|
|
50
|
+
const release = Release.fromJSON(json);
|
|
51
|
+
|
|
52
|
+
return release;
|
|
53
|
+
}),
|
|
54
|
+
releases = new Releases(array);
|
|
55
|
+
|
|
56
|
+
return releases;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static fromNothing() {
|
|
60
|
+
const array = [],
|
|
61
|
+
releases = new Releases(array);
|
|
62
|
+
|
|
63
|
+
return releases;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { MAJOR_NUMBER_MULTIPLIER, MINOR_NUMBER_MULTIPLIER } from "./multiplers";
|
|
4
|
+
import { majorNumberFromNumber, minorNumberFromNumber, majorNumberFromString, minorNumberFromString } from "./utilities/version";
|
|
5
|
+
|
|
6
|
+
export default class ShortenedVersion {
|
|
7
|
+
constructor(majorNumber, minorNumber) {
|
|
8
|
+
this.majorNumber = majorNumber;
|
|
9
|
+
this.minorNumber = minorNumber;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
getMajorNumber() {
|
|
13
|
+
return this.majorNumber;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
getMinorNumber() {
|
|
17
|
+
return this.minorNumber;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
toString() {
|
|
21
|
+
const string = `${this.majorNumber}.${this.minorNumber}`;
|
|
22
|
+
|
|
23
|
+
return string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
toVersionNumber() {
|
|
27
|
+
const versionNumber = this.majorNumber * MAJOR_NUMBER_MULTIPLIER + this.minorNumber * MINOR_NUMBER_MULTIPLIER;
|
|
28
|
+
|
|
29
|
+
return versionNumber;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getLeastMatchingVersionNumber() {
|
|
33
|
+
const versionNumber = this.toVersionNumber(),
|
|
34
|
+
leastMatchingVersionNumber = versionNumber; ///
|
|
35
|
+
|
|
36
|
+
return leastMatchingVersionNumber;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getGreatestMatchingVersionNumber() {
|
|
40
|
+
const majorNumber = this.majorNumber + 1,
|
|
41
|
+
minorNumber = 0,
|
|
42
|
+
shortenedVersion = ShortenedVersion.fromMajorNumberAndMinorNumber(majorNumber, minorNumber),
|
|
43
|
+
shortenedVersionNumber = shortenedVersion.toVersionNumber(),
|
|
44
|
+
greatestMatchingVersionNumber = shortenedVersionNumber - 1;
|
|
45
|
+
|
|
46
|
+
return greatestMatchingVersionNumber;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static fromString(string) {
|
|
50
|
+
const majorNumber = majorNumberFromString(string),
|
|
51
|
+
minorNumber = minorNumberFromString(string),
|
|
52
|
+
shortenedVersion = new ShortenedVersion(majorNumber, minorNumber);
|
|
53
|
+
|
|
54
|
+
return shortenedVersion;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static fromVersionNumber(versionNumber) {
|
|
58
|
+
const number = versionNumber, ///
|
|
59
|
+
majorNumber = majorNumberFromNumber(number),
|
|
60
|
+
minorNumber = minorNumberFromNumber(number),
|
|
61
|
+
shortenedVersion = new ShortenedVersion(majorNumber, minorNumber);
|
|
62
|
+
|
|
63
|
+
return shortenedVersion;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
static fromMajorNumberAndMinorNumber(majorNumber, minorNumber) {
|
|
67
|
+
const shortenedVersion = new ShortenedVersion(majorNumber, minorNumber);
|
|
68
|
+
|
|
69
|
+
return shortenedVersion;
|
|
70
|
+
}
|
|
71
|
+
}
|
package/src/types.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { EMPTY_STRING, DOUBLE_SPACE } from "../constants";
|
|
4
|
+
|
|
5
|
+
export function trimDoubleQuotes(content) { return content.replace(/(^"|"$)/g, EMPTY_STRING); } ///
|
|
6
|
+
|
|
7
|
+
export function convertContentTabsToWhitespace(content) { return content.replace(/\t/g, DOUBLE_SPACE); } ///
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
trimDoubleQuotes,
|
|
11
|
+
convertContentTabsToWhitespace
|
|
12
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const readmeFilePathPattern = "^(?:[^\\/]+\\/){1}README\\.md$",
|
|
4
|
+
florenceFilePathPattern = "^(?:[^\\/]+\\/){1,}[^\\.]+\\.fls$",
|
|
5
|
+
metaJSONFilePathPattern = "^(?:[^\\/]+\\/){1}meta\\.json$",
|
|
6
|
+
customGrammarBNFFilePathPattern = "^(?:[^\\/]+\\/){1}(term|statement|metastatement)\\.bnf$",
|
|
7
|
+
customGrammarPatternFilePathPattern = "^(?:[^\\/]+\\/){1}(type|symbol|operator)\\.ptn$",
|
|
8
|
+
recognisedFilePathPattern = `${readmeFilePathPattern}|${florenceFilePathPattern}|${metaJSONFilePathPattern}|${customGrammarBNFFilePathPattern}|${customGrammarPatternFilePathPattern}`;
|
|
9
|
+
|
|
10
|
+
const readmeFilePathRegularExpression = new RegExp(readmeFilePathPattern),
|
|
11
|
+
florenceFilePathRegularExpression = new RegExp(florenceFilePathPattern),
|
|
12
|
+
metaJSONFilePathRegularExpression = new RegExp(metaJSONFilePathPattern),
|
|
13
|
+
recognisedFilePathRegularExpression = new RegExp(recognisedFilePathPattern),
|
|
14
|
+
customGrammarBNFFilePathRegularExpression = new RegExp(customGrammarBNFFilePathPattern),
|
|
15
|
+
customGrammarPatternFilePathRegularExpression = new RegExp(customGrammarPatternFilePathPattern);
|
|
16
|
+
|
|
17
|
+
export function isFilePathReadmeFilePath(filePath) { return readmeFilePathRegularExpression.test(filePath); }
|
|
18
|
+
|
|
19
|
+
export function isFilePathFlorenceFilePath(filePath) { return florenceFilePathRegularExpression.test(filePath); }
|
|
20
|
+
|
|
21
|
+
export function isFilePathMetaJSONFilePath(filePath) { return metaJSONFilePathRegularExpression.test(filePath); }
|
|
22
|
+
|
|
23
|
+
export function isFilePathRecognisedFilePath(filePath) { return recognisedFilePathRegularExpression.test(filePath); }
|
|
24
|
+
|
|
25
|
+
export function isFilePathCustomGrammarBNFFilePath(filePath) { return customGrammarBNFFilePathRegularExpression.test(filePath); }
|
|
26
|
+
|
|
27
|
+
export function isFilePathCustomGrammarPatternFilePath(filePath) { return customGrammarPatternFilePathRegularExpression.test(filePath); }
|
|
28
|
+
|
|
29
|
+
export default {
|
|
30
|
+
isFilePathReadmeFilePath,
|
|
31
|
+
isFilePathFlorenceFilePath,
|
|
32
|
+
isFilePathMetaJSONFilePath,
|
|
33
|
+
isFilePathRecognisedFilePath,
|
|
34
|
+
isFilePathCustomGrammarBNFFilePath,
|
|
35
|
+
isFilePathCustomGrammarPatternFilePath
|
|
36
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { isFilePathReadmeFilePath,
|
|
4
|
+
isFilePathFlorenceFilePath,
|
|
5
|
+
isFilePathMetaJSONFilePath,
|
|
6
|
+
isFilePathCustomGrammarBNFFilePath,
|
|
7
|
+
isFilePathCustomGrammarPatternFilePath } from "../utilities/filePath";
|
|
8
|
+
|
|
9
|
+
export function readmeFileFromFiles(files) {
|
|
10
|
+
let readmeFile = null;
|
|
11
|
+
|
|
12
|
+
files.someFile((file) => {
|
|
13
|
+
const filePath = file.getPath(),
|
|
14
|
+
filePathReadmeFilePath = isFilePathReadmeFilePath(filePath);
|
|
15
|
+
|
|
16
|
+
if (filePathReadmeFilePath) {
|
|
17
|
+
readmeFile = file; ///
|
|
18
|
+
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return readmeFile;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function metaJSONFileFromFiles(files) {
|
|
27
|
+
let metaJSONFile = null;
|
|
28
|
+
|
|
29
|
+
files.someFile((file) => {
|
|
30
|
+
const filePath = file.getPath(),
|
|
31
|
+
filePathMetaJSONFilePath = isFilePathMetaJSONFilePath(filePath);
|
|
32
|
+
|
|
33
|
+
if (filePathMetaJSONFilePath) {
|
|
34
|
+
metaJSONFile = file; ///
|
|
35
|
+
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return metaJSONFile;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function florenceFilesFromFiles(files) {
|
|
44
|
+
const florenceFiles = files.reduceFile((florenceFiles, file) => {
|
|
45
|
+
const filePath = file.getPath(),
|
|
46
|
+
filePathFlorenceFilePath = isFilePathFlorenceFilePath(filePath),
|
|
47
|
+
fileFlorenceFile = filePathFlorenceFilePath; ///
|
|
48
|
+
|
|
49
|
+
if (fileFlorenceFile) {
|
|
50
|
+
const florenceFile = file; ///
|
|
51
|
+
|
|
52
|
+
florenceFiles.push(florenceFile);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return florenceFiles;
|
|
56
|
+
}, []);
|
|
57
|
+
|
|
58
|
+
return florenceFiles;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function customGrammarBNFFilesFromFiles(files) {
|
|
62
|
+
const customGrammarBNFFiles = files.reduceFile((customGrammarBNFFiles, file) => {
|
|
63
|
+
const filePath = file.getPath(),
|
|
64
|
+
filePathCustomGrammarBNFFilePath = isFilePathCustomGrammarBNFFilePath(filePath),
|
|
65
|
+
fileCustomGrammarBNFFile = filePathCustomGrammarBNFFilePath; ///
|
|
66
|
+
|
|
67
|
+
if (fileCustomGrammarBNFFile) {
|
|
68
|
+
const customGrammarBNFFile = file; ///
|
|
69
|
+
|
|
70
|
+
customGrammarBNFFiles.push(customGrammarBNFFile);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return customGrammarBNFFiles;
|
|
74
|
+
}, []);
|
|
75
|
+
|
|
76
|
+
return customGrammarBNFFiles;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function customGrammarPatternFilesFromFiles(files) {
|
|
80
|
+
const customGrammarPatternFiles = files.reduceFile((customGrammarPatternFiles, file) => {
|
|
81
|
+
const filePath = file.getPath(),
|
|
82
|
+
filePathCustomGrammarPatternFilePath = isFilePathCustomGrammarPatternFilePath(filePath),
|
|
83
|
+
fileCustomGrammarPatternFile = filePathCustomGrammarPatternFilePath; ///
|
|
84
|
+
|
|
85
|
+
if (fileCustomGrammarPatternFile) {
|
|
86
|
+
const customGrammarPatternFile = file; ///
|
|
87
|
+
|
|
88
|
+
customGrammarPatternFiles.push(customGrammarPatternFile);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return customGrammarPatternFiles;
|
|
92
|
+
}, []);
|
|
93
|
+
|
|
94
|
+
return customGrammarPatternFiles;
|
|
95
|
+
}
|