occam-open-cli 5.0.45 → 5.0.47

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/src/release.js CHANGED
@@ -1,18 +1,20 @@
1
1
  "use strict";
2
2
 
3
3
  import Entries from "./entries";
4
-
5
- import { isFilePathReadmeFilePath,
6
- isFilePathFlorenceFilePath,
7
- isFilePathMetaJSONFilePath,
8
- isFilePathCustomGrammarBNFFilePath,
9
- isFilePathCustomGrammarPatternFilePath } from "./utilities/filePath";
10
-
11
- export default class Release {
12
- constructor(name, entries, versionNumber) {
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
13
  this.name = name;
14
14
  this.entries = entries;
15
- this.versionNumber = versionNumber;
15
+ this.version = version;
16
+ this.repository = repository;
17
+ this.dependendies = dependencies;
16
18
  }
17
19
 
18
20
  getName() {
@@ -23,143 +25,75 @@ export default class Release {
23
25
  return this.entries;
24
26
  }
25
27
 
26
- getVersionNumber() {
27
- return this.versionNumber;
28
+ getVersion() {
29
+ return this.version;
28
30
  }
29
31
 
30
- getFile(filePath) { return this.entries.getFile(filePath); }
31
-
32
- getFiles() { return this.entries.getFiles(); }
33
-
34
- getFilePaths() { return this.entries.getFilePaths(); }
35
-
36
- getReadmeFile() {
37
- let readmeFile = null;
38
-
39
- const files = this.getFiles();
40
-
41
- files.someFile((file) => {
42
- const filePath = file.getPath(),
43
- filePathReadmeFilePath = isFilePathReadmeFilePath(filePath);
44
-
45
- if (filePathReadmeFilePath) {
46
- readmeFile = file; ///
47
-
48
- return true;
49
- }
50
- });
51
-
52
- return readmeFile;
32
+ getRepository() {
33
+ return this.repository;
53
34
  }
54
35
 
55
- getMetaJSONFile() {
56
- let metaJSONFile = null;
57
-
58
- const files = this.getFiles();
59
-
60
- files.someFile((file) => {
61
- const filePath = file.getPath(),
62
- filePathMetaJSONFilePath = isFilePathMetaJSONFilePath(filePath);
63
-
64
- if (filePathMetaJSONFilePath) {
65
- metaJSONFile = file; ///
66
-
67
- return true;
68
- }
69
- });
70
-
71
- return metaJSONFile;
72
- }
73
-
74
- getFlorenceFiles() {
75
- const files = this.getFiles(),
76
- florenceFiles = files.reduceFile((florenceFiles, file) => {
77
- const filePath = file.getPath(),
78
- filePathFlorenceFilePath = isFilePathFlorenceFilePath(filePath),
79
- fileFlorenceFile = filePathFlorenceFilePath; ///
80
-
81
- if (fileFlorenceFile) {
82
- const florenceFile = file; ///
83
-
84
- florenceFiles.push(florenceFile);
85
- }
86
-
87
- return florenceFiles;
88
- }, []);
89
-
90
- return florenceFiles;
91
- }
92
-
93
- getCustomGrammarBNFFiles() {
94
- const files = this.getFiles(),
95
- customGrammarBNFFiles = files.reduceFile((customGrammarBNFFiles, file) => {
96
- const filePath = file.getPath(),
97
- filePathCustomGrammarBNFFilePath = isFilePathCustomGrammarBNFFilePath(filePath),
98
- fileCustomGrammarBNFFile = filePathCustomGrammarBNFFilePath; ///
99
-
100
- if (fileCustomGrammarBNFFile) {
101
- const customGrammarBNFFile = file; ///
102
-
103
- customGrammarBNFFiles.push(customGrammarBNFFile);
104
- }
105
-
106
- return customGrammarBNFFiles;
107
- }, []);
108
-
109
- return customGrammarBNFFiles;
110
- }
111
-
112
- getCustomGrammarPatternFiles() {
113
- const files = this.getFiles(),
114
- customGrammarPatternFiles = files.reduceFile((customGrammarPatternFiles, file) => {
115
- const filePath = file.getPath(),
116
- filePathCustomGrammarPatternFilePath = isFilePathCustomGrammarPatternFilePath(filePath),
117
- fileCustomGrammarPatternFile = filePathCustomGrammarPatternFilePath; ///
118
-
119
- if (fileCustomGrammarPatternFile) {
120
- const customGrammarPatternFile = file; ///
121
-
122
- customGrammarPatternFiles.push(customGrammarPatternFile);
123
- }
124
-
125
- return customGrammarPatternFiles;
126
- }, []);
127
-
128
- return customGrammarPatternFiles;
36
+ getDependencies() {
37
+ return this.dependendies;
129
38
  }
130
39
 
131
40
  toJSON() {
132
41
  const entriesJSON = this.entries.toJSON(),
42
+ versionJSON = this.version.toJSON(),
43
+ dependenciesJSON = this.dependendies.toJSON(),
133
44
  name = this.name,
134
45
  entries = entriesJSON, ///
135
- versionNumber = this.versionNumber,
46
+ version = versionJSON, ///
47
+ repository = this.repository,
48
+ dependencies = dependenciesJSON, ///
136
49
  json = {
137
50
  name,
138
51
  entries,
139
- versionNumber
52
+ version,
53
+ repository,
54
+ dependencies
140
55
  };
141
56
 
142
57
  return json;
143
58
  }
144
59
 
145
60
  static fromJSON(json) {
146
- let { entries } = json;
61
+ let { entries, version, dependencies } = json;
147
62
 
148
- const { name, versionNumber } = json,
149
- entriesJSON = entries; ///
63
+ const { name, repository } = json,
64
+ entriesJSON = entries, ///
65
+ versionJSOM = version, ///
66
+ dependenciesJSON = dependencies; ///
150
67
 
151
68
  json = entriesJSON; ///
152
69
 
153
70
  entries = Entries.fromJSON(json); ///
154
71
 
155
- const release = new Release(name, entries, versionNumber);
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);
156
81
 
157
82
  return release;
158
83
  }
159
84
 
160
- static fromNameEntriesAndVersionNumber(name, entries, versionNumber) {
161
- const release = new Release(name, entries, versionNumber);
85
+ static fromNameEntriesAndVersion(name, entries, version) {
86
+ const repository = repository,
87
+ dependencies = Dependencies.fromNothing(),
88
+ release = new Release(name, entries, version, repository, dependencies);
162
89
 
163
90
  return release;
164
91
  }
165
92
  }
93
+
94
+ Objecct.assign(Release.prototype, bnfMixins);
95
+ Objecct.assign(Release.prototype, filesMixins);
96
+ Objecct.assign(Release.prototype, entriesMixins);
97
+ Objecct.assign(Release.prototype, patternMixins);
98
+
99
+ export default Release;
@@ -30,6 +30,24 @@ export default class ShortenedVersion {
30
30
  return number;
31
31
  }
32
32
 
33
+ toJSON() {
34
+ const majorNumber = this.majorNumber,
35
+ minorNumber = this.minorNumber,
36
+ json = {
37
+ majorNumber,
38
+ minorNumber
39
+ };
40
+
41
+ return json;
42
+ }
43
+
44
+ static fromJSON(json) {
45
+ const { majorNumber, minorNumber } = json,
46
+ shortenedVersion = new ShortenedVersion(majorNumber, minorNumber);
47
+
48
+ return shortenedVersion;
49
+ }
50
+
33
51
  static fromString(string) {
34
52
  const majorNumber = majorNumberFromString(string),
35
53
  minorNumber = minorNumberFromString(string),
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
2
 
3
- import { DOUBLE_SPACE } from "../constants";
3
+ import { EMPTY_STRING, DOUBLE_SPACE } from "../constants";
4
+
5
+ export function trimDoubleQuotes(content) { return content.replace(/(^"|"$)/g, EMPTY_STRING); } ///
4
6
 
5
7
  export function convertContentTabsToWhitespace(content) { return content.replace(/\t/g, DOUBLE_SPACE); } ///
6
8
 
7
9
  export default {
10
+ trimDoubleQuotes,
8
11
  convertContentTabsToWhitespace
9
12
  };
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+
3
+ import { isFilePathReadmeFilePath,
4
+ isFilePathFlorenceFilePath,
5
+ isFilePathMetaJSONFilePath,
6
+ isFilePathCustomGrammarBNFFilePath,
7
+ isFilePathCustomGrammarPatternFilePath } from "../utilities/filePath";
8
+
9
+ 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
+ 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
+ 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
+ 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
+ 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
+ }
96
+
97
+ export default {
98
+ readmeFileFromFiles,
99
+ metaJSONFileFromFiles,
100
+ florenceFilesFromFiles,
101
+ customGrammarBNFFilesFromFiles,
102
+ customGrammarPatternFilesFromFiles
103
+ };
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ import Version from "../version";
4
+ import Dependency from "../dependency";
5
+ import ShortenedVersion from "../shortenedVersion";
6
+
7
+ import { trimDoubleQuotes } from "../utilities/content";
8
+ import { nodeQuery, nodesQuery } from "../utilities/query";
9
+
10
+ const dependencyNodesQuery = nodesQuery("//dependencies/dependency"),
11
+ repositoryTerminalNodeQuery = nodeQuery("//repository!/@*!"),
12
+ versionNumberTerminalNodeQuery = nodeQuery("//version!/versionNumber!/@*!"),
13
+ dependencyNameTerminalNodeQuery = nodeQuery("/dependency/name!/@*!"),
14
+ shortenedVersionNumberTerminalNodeQuery = nodeQuery("//dependency/shortenedVersionNumber/@*!");
15
+
16
+ export function versionFromNode(node) {
17
+ let version = null;
18
+
19
+ if (node !== null) {
20
+ const versionNumberTerminalNode = versionNumberTerminalNodeQuery(node),
21
+ versionNumberTerminalNodeContent = versionNumberTerminalNode.getContent(),
22
+ versionNumber = trimDoubleQuotes(versionNumberTerminalNodeContent); //
23
+
24
+ version = Version.fromVersionNumber(versionNumber);
25
+ }
26
+
27
+ return version;
28
+ }
29
+
30
+ export function repositoryFromNode(node) {
31
+ let repository = null;
32
+
33
+ if (node !== null) {
34
+ const repositoryTerminalNode = repositoryTerminalNodeQuery(node),
35
+ repositoryTerminalNodeContent = repositoryTerminalNode.getContent();
36
+
37
+ repository = trimDoubleQuotes(repositoryTerminalNodeContent); //
38
+ }
39
+
40
+ return repository;
41
+ }
42
+
43
+ export function dependenciesFromNode(node) {
44
+ const dependencies = [];
45
+
46
+ if (node !== null) {
47
+ const dependencyNodes = dependencyNodesQuery(node);
48
+
49
+ dependencyNodes.forEach((dependencyNode) => {
50
+ const dependencyNameTerminalNode = dependencyNameTerminalNodeQuery(dependencyNode),
51
+ shortenedVersionNumberTerminalNode = shortenedVersionNumberTerminalNodeQuery(dependencyNode),
52
+ dependencyNameTerminalNodeContent = dependencyNameTerminalNode.getContent(),
53
+ shortenedVersionNumberTerminalNodeContent = shortenedVersionNumberTerminalNode.getContent(),
54
+ string = trimDoubleQuotes(shortenedVersionNumberTerminalNodeContent), ///
55
+ name = trimDoubleQuotes(dependencyNameTerminalNodeContent),///
56
+ shortenedVersion = ShortenedVersion.fromString(string),
57
+ dependency = Dependency.fromNameAndShortenedVersion(name, shortenedVersion);
58
+
59
+ dependencies.push(dependency);
60
+ });
61
+ }
62
+
63
+ return dependencies;
64
+ }
65
+
66
+ export function dependencyNamesFromNode(node) {
67
+ const dependencies = this.dependenciesFromNode(node),
68
+ dependencyNames = dependencies.map((dependency) => {
69
+ const dependencyName = dependency.getName();
70
+
71
+ return dependencyName;
72
+ })
73
+
74
+ return dependencyNames;
75
+ }
76
+
77
+ export default {
78
+ versionFromNode,
79
+ repositoryFromNode,
80
+ dependenciesFromNode,
81
+ dependencyNamesFromNode
82
+ };
@@ -1,13 +1,26 @@
1
1
  "use strict";
2
2
 
3
+ import { pathUtilities } from "necessary";
4
+
3
5
  const hiddenNameRegularExpression = /^\..+/;
4
6
 
7
+ const { bottommostNameFromPath } = pathUtilities;
8
+
5
9
  export function isNameHiddenName(name) {
6
10
  const nameHiddenName = hiddenNameRegularExpression.test(name);
7
11
 
8
12
  return nameHiddenName;
9
13
  }
10
14
 
15
+ function fileNameFromFilePath(filePath) {
16
+ const path = filePath, ///
17
+ bottommostName = bottommostNameFromPath(path),
18
+ fileName = bottommostName; //
19
+
20
+ return fileName;
21
+ }
22
+
11
23
  export default {
12
- isNameHiddenName
24
+ isNameHiddenName,
25
+ fileNameFromFilePath
13
26
  };
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ import { Query } from "occam-dom";
4
+
5
+ export function nodeQuery(expression) {
6
+ const query = Query.fromExpression(expression);
7
+
8
+ return function(node) {
9
+ if (node !== null) {
10
+ const nodes = query.execute(node);
11
+
12
+ node = nodes.shift() || null; ///
13
+ }
14
+
15
+ return node;
16
+ };
17
+ }
18
+
19
+ export function nodesQuery(expression) {
20
+ const query = Query.fromExpression(expression);
21
+
22
+ return function(node) {
23
+ let nodes = null;
24
+
25
+ if (node !== null) {
26
+ nodes = query.execute(node);
27
+ }
28
+
29
+ return nodes;
30
+ };
31
+ }
package/src/version.js CHANGED
@@ -47,6 +47,26 @@ export default class Version {
47
47
  return number;
48
48
  }
49
49
 
50
+ toJSON() {
51
+ const majorNumber = this.majorNumber,
52
+ minorNumber = this.minorNumber,
53
+ patchNumber = this.patchNumber,
54
+ json = {
55
+ majorNumber,
56
+ minorNumber,
57
+ patchNumber
58
+ };
59
+
60
+ return json;
61
+ }
62
+
63
+ static fromJSON(json) {
64
+ const { majorNumber, minorNumber, patchNumber } = json,
65
+ version = new Version(majorNumber, minorNumber, patchNumber);
66
+
67
+ return version;
68
+ }
69
+
50
70
  static fromString(string) {
51
71
  const majorNumber = majorNumberFromString(string),
52
72
  minorNumber = minorNumberFromString(string),