@servable/tools 1.3.0 → 1.3.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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "source": "src/index.js",
5
5
  "main": "src/index.js",
6
- "version": "1.3.0",
6
+ "version": "1.3.1",
7
7
  "description": "Servable tools is a utility that builds a feature's manifest and documents it.",
8
8
  "author": "Servable Community",
9
9
  "license": "ISC",
@@ -12,6 +12,9 @@ import directoryFilesRecursive from '../../lib/directoryFilesRecursive.js'
12
12
  import { FeatureEnum } from '../../manifest/data/1.0.0/enums.js'
13
13
 
14
14
  import triggerItems from './lib/triggerItems.js'
15
+ import fs from 'fs'
16
+ import fspath from 'path'
17
+ import semver from 'semver'
15
18
 
16
19
  export default class FeatureLoaderV1_0_0 extends BaseClass {
17
20
 
@@ -825,25 +828,54 @@ export default class FeatureLoaderV1_0_0 extends BaseClass {
825
828
  }
826
829
 
827
830
  async routes() {
828
- const cacheKey = 'routes'
829
- if (this._valueInCache(cacheKey)) {
830
- return this._valueInCache(cacheKey)
831
- }
832
-
833
831
  let path = `${this.path}/routes`
834
832
  if (!(await checkFileExists(path))) {
835
833
  return null
836
834
  }
837
835
 
838
- const data = (await directoryGlob({
839
- path: `${path}/**/*.js`, globOptions: {
840
- mark: true,
841
- ignore: ['**/lib/**']
836
+ let data = {}
837
+ const items = await fs.promises.readdir(path)
838
+ if (!items || !items.length) {
839
+ return null
840
+ }
841
+
842
+ for (let i = 0; i < items.length; i++) {
843
+ const item = items[i]
844
+ if (!item) {
845
+ continue
842
846
  }
843
- }))
847
+
848
+ if (item[0] !== 'v') {
849
+ continue
850
+ }
851
+
852
+ if (!semver.valid(semver.coerce(item))) {
853
+ continue
854
+ }
855
+ const __path = fspath.join(path, item)
856
+ const _stat = await fs.promises.stat(__path)
857
+ if (!_stat) {
858
+ continue
859
+ }
860
+
861
+ const isDir = _stat.isDirectory()
862
+ if (!isDir) {
863
+ continue
864
+ }
865
+
866
+ let _data = (await directoryGlob({
867
+ path: `${__path}/**/*.js`, globOptions: {
868
+ mark: true,
869
+ ignore: ['**/lib/**']
870
+ }
871
+ }))
872
+ data[item] = _data
873
+ }
874
+
844
875
  return data
845
876
  }
846
877
 
878
+
847
879
  async liveQueries() {
848
880
  let path = `${this.path}/livequeries`
849
881
  if (!(await checkFileExists(path))) {
@@ -12,6 +12,9 @@ import directoryFilesRecursive from '../../lib/directoryFilesRecursive.js'
12
12
  import { FeatureEnum } from '../../manifest/data/1.0.0/enums.js'
13
13
 
14
14
  import triggerItems from './lib/triggerItems.js'
15
+ import fs from 'fs'
16
+ import fspath from 'path'
17
+ import semver from 'semver'
15
18
 
16
19
  export default class FeatureLoaderV1_1_0 extends BaseClass {
17
20
 
@@ -830,16 +833,50 @@ export default class FeatureLoaderV1_1_0 extends BaseClass {
830
833
  return null
831
834
  }
832
835
 
833
- const data = (await directoryGlob({
834
- path: `${path}/**/*.js`, globOptions: {
835
- mark: true,
836
- ignore: ['**/lib/**']
836
+ let data = {}
837
+ const items = await fs.promises.readdir(path)
838
+ if (!items || !items.length) {
839
+ return null
840
+ }
841
+
842
+ for (let i = 0; i < items.length; i++) {
843
+ const item = items[i]
844
+ if (!item) {
845
+ continue
837
846
  }
838
- }))
847
+
848
+ if (item[0] !== 'v') {
849
+ continue
850
+ }
851
+
852
+ if (!semver.valid(semver.coerce(item))) {
853
+ continue
854
+ }
855
+ const __path = fspath.join(path, item)
856
+ const _stat = await fs.promises.stat(__path)
857
+ if (!_stat) {
858
+ continue
859
+ }
860
+
861
+ const isDir = _stat.isDirectory()
862
+ if (!isDir) {
863
+ continue
864
+ }
865
+
866
+ let _data = (await directoryGlob({
867
+ path: `${__path}/**/*.js`, globOptions: {
868
+ mark: true,
869
+ ignore: ['**/lib/**']
870
+ }
871
+ }))
872
+ data[item] = _data
873
+ }
874
+
839
875
  return data
840
876
  }
841
877
 
842
878
  async targetRoutes() {
879
+ //#TODO:
843
880
  let path = `${this.path}/target/routes`
844
881
  if (!(await checkFileExists(path))) {
845
882
  return null