occam-file-system 5.0.13 → 5.0.15

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.
Files changed (68) hide show
  1. package/README.md +4 -4
  2. package/lib/browser.js +63 -0
  3. package/lib/constants.js +13 -1
  4. package/lib/dependencies.js +81 -0
  5. package/lib/dependency.js +89 -0
  6. package/lib/directory.js +100 -0
  7. package/lib/entries.js +228 -0
  8. package/lib/file.js +141 -0
  9. package/lib/fileNames.js +38 -0
  10. package/lib/files.js +121 -0
  11. package/lib/loadProjects.js +1 -1
  12. package/lib/loadReleases.js +18 -0
  13. package/lib/main.js +103 -0
  14. package/lib/messages.js +13 -0
  15. package/lib/mixins/bnf.js +47 -0
  16. package/lib/mixins/entries.js +31 -0
  17. package/lib/mixins/files.js +41 -0
  18. package/lib/mixins/pattern.js +47 -0
  19. package/lib/project.js +123 -0
  20. package/lib/projects.js +112 -0
  21. package/lib/release.js +127 -0
  22. package/lib/releases.js +112 -0
  23. package/lib/shortenedVersion.js +125 -0
  24. package/lib/types.js +22 -0
  25. package/lib/utilities/content.js +34 -0
  26. package/lib/utilities/filePath.js +63 -0
  27. package/lib/utilities/fileSystem.js +130 -12
  28. package/lib/utilities/files.js +95 -0
  29. package/lib/utilities/metaJSON.js +80 -0
  30. package/lib/utilities/name.js +25 -4
  31. package/lib/utilities/query.js +48 -0
  32. package/lib/version.js +163 -0
  33. package/package.json +5 -3
  34. package/src/browser.js +14 -0
  35. package/src/constants.js +3 -0
  36. package/src/dependencies.js +46 -0
  37. package/src/dependency.js +52 -0
  38. package/src/directory.js +54 -0
  39. package/src/entries.js +192 -0
  40. package/src/file.js +95 -0
  41. package/src/fileNames.js +8 -0
  42. package/src/files.js +78 -0
  43. package/src/loadProjects.js +1 -1
  44. package/src/loadReleases.js +13 -0
  45. package/src/main.js +25 -0
  46. package/src/messages.js +3 -0
  47. package/src/mixins/bnf.js +59 -0
  48. package/src/mixins/entries.js +18 -0
  49. package/src/mixins/files.js +52 -0
  50. package/src/mixins/pattern.js +59 -0
  51. package/src/project.js +92 -0
  52. package/src/projects.js +66 -0
  53. package/src/release.js +97 -0
  54. package/src/releases.js +66 -0
  55. package/src/shortenedVersion.js +109 -0
  56. package/src/types.js +4 -0
  57. package/src/utilities/content.js +12 -0
  58. package/src/utilities/filePath.js +36 -0
  59. package/src/utilities/fileSystem.js +186 -15
  60. package/src/utilities/files.js +103 -0
  61. package/src/utilities/metaJSON.js +82 -0
  62. package/src/utilities/name.js +17 -0
  63. package/src/utilities/query.js +36 -0
  64. package/src/version.js +151 -0
  65. package/lib/index.js +0 -55
  66. package/lib/utilities/pathMaps.js +0 -31
  67. package/src/index.js +0 -11
  68. package/src/utilities/pathMaps.js +0 -21
package/src/file.js ADDED
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+
3
+ import { FILE_TYPE } from "./types";
4
+ import { convertContentTabsToWhitespace } from "./utilities/content"
5
+
6
+ export default class File {
7
+ constructor(path, content) {
8
+ this.path = path;
9
+ this.content = content;
10
+ }
11
+
12
+ getPath() {
13
+ return this.path;
14
+ }
15
+
16
+ getContent() {
17
+ return this.content;
18
+ }
19
+
20
+ isFile() {
21
+ const file = true;
22
+
23
+ return file;
24
+ }
25
+
26
+ isDirectory() {
27
+ const directory = false;
28
+
29
+ return directory;
30
+ }
31
+
32
+ setPath(path) {
33
+ this.path = path;
34
+ }
35
+
36
+ setContent(content) {
37
+ this.content = content;
38
+ }
39
+
40
+ toJSON() {
41
+ const { type } = File,
42
+ path = this.path,
43
+ content = this.content,
44
+ json = {
45
+ type,
46
+ path,
47
+ content
48
+ };
49
+
50
+ return json;
51
+ }
52
+
53
+ static type = FILE_TYPE;
54
+
55
+ static fromJSON(json) {
56
+ let file = null;
57
+
58
+ if (json !== null) {
59
+ const { type } = json;
60
+
61
+ if (type === FILE_TYPE) {
62
+ let { content } = json;
63
+
64
+ const { path } = json;
65
+
66
+ content = convertContentTabsToWhitespace(content); ///
67
+
68
+ file = new File(path, content);
69
+ }
70
+ }
71
+
72
+ return file;
73
+ }
74
+
75
+ static fromDocument(document) {
76
+ const filePath = document.getFilePath(),
77
+ path = filePath; ///
78
+
79
+ let content = document.getContent();
80
+
81
+ content = convertContentTabsToWhitespace(content); ///
82
+
83
+ const file = new File(path, content);
84
+
85
+ return file;
86
+ }
87
+
88
+ static fromPathAndContent(path, content) {
89
+ content = convertContentTabsToWhitespace(content); ///
90
+
91
+ const file = new File(path, content);
92
+
93
+ return file;
94
+ }
95
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ export const TERM_BNF_FILE_NAME = "term.bnf";
4
+ export const STATEMENT_BNF_FILE_NAME = "statement.bnf";
5
+ export const METASTATEMENT_BNF_FILE_NAME = "metastatement.bnf";
6
+ export const TYPE_PATTERN_FILE_NAME = "type.ptn";
7
+ export const SYMBOL_PATTERN_FILE_NAME = "symbol.ptn";
8
+ export const OPERATOR_PATTERN_FILE_NAME = "operator.ptn";
package/src/files.js ADDED
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+
3
+ import File from "./file";
4
+
5
+ export default class Files {
6
+ constructor(array) {
7
+ this.array = array;
8
+ }
9
+
10
+ getFilePaths() {
11
+ const filePaths = this.mapFile((file) => {
12
+ const filePath = file.getPath();
13
+
14
+ return filePath;
15
+ });
16
+
17
+ return filePaths;
18
+ }
19
+
20
+ addFile(file) {
21
+ this.array.push(file);
22
+ }
23
+
24
+ mapFile(callback) {
25
+ return this.array.map(callback);
26
+ }
27
+
28
+ someFile(callback) {
29
+ return this.array.some(callback);
30
+ }
31
+
32
+ reduceFile(callback, initialValue) {
33
+ return this.array.reduce(callback, initialValue);
34
+ }
35
+
36
+ forEachFile(callback) {
37
+ this.array.forEach(callback);
38
+ }
39
+
40
+ findFile(callback) {
41
+ return this.array.find(callback) || null; ///
42
+ }
43
+
44
+ toJSON() {
45
+ const filesJSON = this.array.map((file) => {
46
+ const fileJSON = (file !== null) ?
47
+ file.toJSON() :
48
+ null;
49
+
50
+ return fileJSON;
51
+ }),
52
+ json = filesJSON; ///
53
+
54
+ return json;
55
+ }
56
+
57
+ static fromJSON(json) {
58
+ const filesJSON = json, ///
59
+ array = [],
60
+ files = new Files(array);
61
+
62
+ filesJSON.forEach((fileJSON) => {
63
+ const json = fileJSON, ///
64
+ file = File.fromJSON(json);
65
+
66
+ files.addFile(file);
67
+ });
68
+
69
+ return files;
70
+ }
71
+
72
+ static fromNothing() {
73
+ const array = [],
74
+ files = new Files(array);
75
+
76
+ return files;
77
+ }
78
+ }
@@ -9,7 +9,7 @@ export default function loadProjects(projectsDirectoryPath, json, callback) {
9
9
 
10
10
  json = (projects !== null) ? ///
11
11
  projects.toJSON():
12
- null;
12
+ null;
13
13
 
14
14
  callback(json);
15
15
  }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ import { loadReleases as loadReleasesEx } from "./utilities/fileSystem";
4
+
5
+ export default function loadReleases(projectsDirectoryPath, json, callback) {
6
+ const releases = loadReleasesEx(projectsDirectoryPath);
7
+
8
+ json = (releases !== null) ? ///
9
+ releases.toJSON():
10
+ null;
11
+
12
+ callback(json);
13
+ }
package/src/main.js ADDED
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ export { default as File } from "./file";
4
+ export { default as Files } from "./files";
5
+ export { default as Version } from "./version";
6
+ export { default as Release } from "./release";
7
+ export { default as Entries } from "./entries";
8
+ export { default as Project } from "./project";
9
+ export { default as Projects } from "./projects";
10
+ export { default as Dependency } from "./dependency";
11
+ export { default as Dependencies } from "./dependencies";
12
+ export { default as ShortenedVersion } from "./shortenedVersion";
13
+
14
+ export { default as httpUtilities } from "./utilities/http";
15
+ export { default as contentUtilities } from "./utilities/content";
16
+ export { default as metaJSONUtilities } from "./utilities/metaJSON";
17
+
18
+ export { default as loadFile } from "./loadFile";
19
+ export { default as saveFile } from "./saveFile";
20
+ export { default as loadFiles } from "./loadFiles";
21
+ export { default as saveFiles } from "./saveFiles";
22
+ export { default as loadProjects } from "./loadProjects";
23
+ export { default as loadReleases } from "./loadReleases";
24
+ export { default as moveProjectEntries } from "./moveProjectEntries";
25
+ export { default as removeProjectEntries } from "./removeProjectEntries";
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ export const ENTRIES_MAXIMUM_LENGTH_EXCEEDED_MESSAGE = "The maximum entries length has been exceeded.";
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ import { fileNameFromFilePath } from "../utilities/name";
4
+ import { TERM_BNF_FILE_NAME, STATEMENT_BNF_FILE_NAME, METASTATEMENT_BNF_FILE_NAME } from "../fileNames";
5
+
6
+ function getBNF(bnfFileName) {
7
+ let bnf = null;
8
+
9
+ const customGrammarBNFFiles = this.getCustomGrammarBNFFiles(),
10
+ customGrammarBNFFile = customGrammarBNFFiles.find((customGrammarBNFFile) => {
11
+ const customGrammarBNFFilePath = customGrammarBNFFile.getPath(),
12
+ customGrammarBNFFileName = fileNameFromFilePath(customGrammarBNFFilePath);
13
+
14
+ if (customGrammarBNFFileName === bnfFileName) {
15
+ return true;
16
+ }
17
+ }) || null;
18
+
19
+ if (customGrammarBNFFile !== null) {
20
+ const customGrammarBNFFileContent = customGrammarBNFFile.getContent();
21
+
22
+ bnf = customGrammarBNFFileContent; ///
23
+ }
24
+
25
+ return bnf;
26
+ }
27
+
28
+ function getTermBNF() {
29
+ const fileName = TERM_BNF_FILE_NAME, ///
30
+ bnf = this.getBNF(fileName),
31
+ termBNF = bnf; ///
32
+
33
+ return termBNF;
34
+ }
35
+
36
+ function getStatementBNF() {
37
+ const fileName = STATEMENT_BNF_FILE_NAME, ///
38
+ bnf = this.getBNF(fileName),
39
+ statementBNF = bnf; ///
40
+
41
+ return statementBNF;
42
+ }
43
+
44
+ function getMetastatementBNF() {
45
+ const fileName = METASTATEMENT_BNF_FILE_NAME, ///
46
+ bnf = this.getBNF(fileName),
47
+ metastatementBNF = bnf; ///
48
+
49
+ return metastatementBNF;
50
+ }
51
+
52
+ const bnfMixins = {
53
+ getBNF,
54
+ getTermBNF,
55
+ getStatementBNF,
56
+ getMetastatementBNF
57
+ };
58
+
59
+ export default bnfMixins;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ function getFile(filePath) { return this.entries.getFile(filePath); }
4
+
5
+ function getFiles() { return this.entries.getFiles(); }
6
+
7
+ function getFilePaths() { return this.entries.getFilePaths(); }
8
+
9
+ function getDirectoryPaths() { return this.entries.getDirectoryPaths(); }
10
+
11
+ const entriesMixins = {
12
+ getFile,
13
+ getFiles,
14
+ getFilePaths,
15
+ getDirectoryPaths
16
+ };
17
+
18
+ export default entriesMixins;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ import { readmeFileFromFiles,
4
+ metaJSONFileFromFiles,
5
+ florenceFilesFromFiles,
6
+ customGrammarBNFFilesFromFiles,
7
+ customGrammarPatternFilesFromFiles } from "../utilities/files";
8
+
9
+ function getReadmeFile() {
10
+ const files = this.getFiles(),
11
+ readmeFile = readmeFileFromFiles(files);
12
+
13
+ return readmeFile;
14
+ }
15
+
16
+ function getMetaJSONFile() {
17
+ const files = this.getFiles(),
18
+ metaJSONFile = metaJSONFileFromFiles(files);
19
+
20
+ return metaJSONFile;
21
+ }
22
+
23
+ function getFlorenceFiles() {
24
+ const files = this.getFiles(),
25
+ florenceFiles = florenceFilesFromFiles(files);
26
+
27
+ return florenceFiles;
28
+ }
29
+
30
+ function getCustomGrammarBNFFiles() {
31
+ const files = this.getFiles(),
32
+ customGrammarBNFFiles = customGrammarBNFFilesFromFiles(files);
33
+
34
+ return customGrammarBNFFiles;
35
+ }
36
+
37
+ function getCustomGrammarPatternFiles() {
38
+ const files = this.getFiles(),
39
+ customGrammarPatternFiles = customGrammarPatternFilesFromFiles(files);
40
+
41
+ return customGrammarPatternFiles;
42
+ }
43
+
44
+ const filesMixins = {
45
+ getReadmeFile,
46
+ getMetaJSONFile,
47
+ getFlorenceFiles,
48
+ getCustomGrammarBNFFiles,
49
+ getCustomGrammarPatternFiles
50
+ };
51
+
52
+ export default filesMixins;
@@ -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,92 @@
1
+ "use strict";
2
+
3
+ import Entries from "./entries";
4
+ import bnfMixins from "./mixins/bnf";
5
+ import filesMixins from "./mixins/files";
6
+ import Dependencies from "./dependencies";
7
+ import entriesMixins from "./mixins/entries";
8
+ import patternMixins from "./mixins/pattern";
9
+
10
+ class Project {
11
+ constructor(name, entries, repository, dependencies) {
12
+ this.name = name;
13
+ this.entries = entries;
14
+ this.repository = repository;
15
+ this.dependendies = dependencies;
16
+ }
17
+
18
+ getName() {
19
+ return this.name;
20
+ }
21
+
22
+ getEntries() {
23
+ return this.entries;
24
+ }
25
+
26
+ getRepository() {
27
+ return this.repository;
28
+ }
29
+
30
+ getDependencies() {
31
+ return this.dependendies;
32
+ }
33
+
34
+ toJSON() {
35
+ const entriesJSON = this.entries.toJSON(),
36
+ dependenciesJSON = this.dependendies.toJSON(),
37
+ name = this.name,
38
+ entries = entriesJSON, ///
39
+ repository = this.repository,
40
+ dependencies = dependenciesJSON, ///
41
+ json = {
42
+ name,
43
+ entries,
44
+ repository,
45
+ dependencies
46
+ };
47
+
48
+ return json;
49
+ }
50
+
51
+ static fromJSON(json) {
52
+ let { entries, dependencies } = json;
53
+
54
+ const { name, repository } = json,
55
+ entriesJSON = entries, ///
56
+ dependenciesJSON = dependencies; ///
57
+
58
+ json = entriesJSON; ///
59
+
60
+ entries = Entries.fromJSON(json); ///
61
+
62
+ json = dependenciesJSON; ///
63
+
64
+ dependencies = Dependencies.fromJSON(json);
65
+
66
+ const release = new Release(name, entries, repository, dependencies);
67
+
68
+ return release;
69
+ }
70
+
71
+ static fromName(name) {
72
+ const entries = Entries.fromNothing(),
73
+ repository = null, ///
74
+ dependencies = Dependencies.fromNothing(),
75
+ project = new Project(name, entries, repository, dependencies);
76
+
77
+ return project;
78
+ }
79
+
80
+ static fromNameEntriesRepositoryAndDependencies(name, entries, repository, dependencies) {
81
+ const project = new Project(name, entries, repository, dependencies);
82
+
83
+ return project;
84
+ }
85
+ }
86
+
87
+ Object.assign(Project.prototype, bnfMixins);
88
+ Object.assign(Project.prototype, filesMixins);
89
+ Object.assign(Project.prototype, entriesMixins);
90
+ Object.assign(Project.prototype, patternMixins);
91
+
92
+ export default Project;
@@ -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,97 @@
1
+ "use strict";
2
+
3
+ import Entries from "./entries";
4
+ import Version from "./version";
5
+ import bnfMixins from "./mixins/bnf";
6
+ import filesMixins from "./mixins/files";
7
+ import Dependencies from "./dependencies";
8
+ import entriesMixins from "./mixins/entries";
9
+ import patternMixins from "./mixins/pattern";
10
+
11
+ class Release {
12
+ constructor(name, entries, version, repository, dependencies) {
13
+ this.name = name;
14
+ this.entries = entries;
15
+ this.version = version;
16
+ this.repository = repository;
17
+ this.dependendies = dependencies;
18
+ }
19
+
20
+ getName() {
21
+ return this.name;
22
+ }
23
+
24
+ getEntries() {
25
+ return this.entries;
26
+ }
27
+
28
+ getVersion() {
29
+ return this.version;
30
+ }
31
+
32
+ getRepository() {
33
+ return this.repository;
34
+ }
35
+
36
+ getDependencies() {
37
+ return this.dependendies;
38
+ }
39
+
40
+ toJSON() {
41
+ const entriesJSON = this.entries.toJSON(),
42
+ versionJSON = this.version.toJSON(),
43
+ dependenciesJSON = this.dependendies.toJSON(),
44
+ name = this.name,
45
+ entries = entriesJSON, ///
46
+ version = versionJSON, ///
47
+ repository = this.repository,
48
+ dependencies = dependenciesJSON, ///
49
+ json = {
50
+ name,
51
+ entries,
52
+ version,
53
+ repository,
54
+ dependencies
55
+ };
56
+
57
+ return json;
58
+ }
59
+
60
+ static fromJSON(json) {
61
+ let { entries, version, dependencies } = json;
62
+
63
+ const { name, repository } = json,
64
+ entriesJSON = entries, ///
65
+ versionJSOM = version, ///
66
+ dependenciesJSON = dependencies; ///
67
+
68
+ json = entriesJSON; ///
69
+
70
+ entries = Entries.fromJSON(json); ///
71
+
72
+ json = versionJSOM; ///
73
+
74
+ version = Version.fromJSON(json);
75
+
76
+ json = dependenciesJSON; ///
77
+
78
+ dependencies = Dependencies.fromJSON(json);
79
+
80
+ const release = new Release(name, entries, version, repository, dependencies);
81
+
82
+ return release;
83
+ }
84
+
85
+ static fromNameEntriesVersionRepositoryAndDependencies(name, entries, version, repository, dependencies) {
86
+ const release = new Release(name, entries, version, repository, dependencies);
87
+
88
+ return release;
89
+ }
90
+ }
91
+
92
+ Object.assign(Release.prototype, bnfMixins);
93
+ Object.assign(Release.prototype, filesMixins);
94
+ Object.assign(Release.prototype, entriesMixins);
95
+ Object.assign(Release.prototype, patternMixins);
96
+
97
+ export default Release;