🔬 testing Lightning FS

Table of Contents

Bugs 🐜

  • wikiLinks and 404 behaviour results in incorrect/dangling lfs due to incorrect baseUrl.

Tour of the API

js
return lit.fs.readdir("/testing/log");

js> json !collapse
return lit.lfs.promises.writeFile('/testing/data.json', "{}", {encoding: 'utf8'})
js> json !collapse
return lit.fs.readFile('/doesntexist.json')
js> json !collapse
return lit.fs.readStat('/manifest.json')
js> json !collapse
return lit.fs
          .readStat('/manifest.json')
          .then(stat => [!!stat.local.value, !!stat.remote.value])
js> json !collapse
return lit.fs
          .stat('/notfound')
          .catch(s => "404 Not Found")
js> json !collapse
return lit.fs
          .stat('/index.lit')
          .then(stat => stat)
js> diff !collapse
// https://github.com/kpdecker/jsdiff
const {root,src} = lit.location
const {join} = lit.utils.path
const filename = join(root,src)

const withStats = async stats => {
  const cp = lit.utils.diff.createPatch
  // const f = 
  const local = stats.local.value
  const remote = stats.remote.value
  const patch = cp(filename, local, remote)
  console.log(patch.split('\n').map(l=>'    '+l).join('\n'))
  return "logged patch"
}

const stats = lit.fs.readStat(filename, {encoding: 'utf8'})
return stats.then(withStats)
jslocalonlydelete
const path = "/throwaway/test.txt"
console.log(ast)
return lit.fs.writeFile(path, "content", {
  encoding: 'utf8',
  localOnly: true
})
txtUpdated 140.8w ago
{ type: 'element',
  tagName: 'cell',
  properties: { class: 'cell' },
  children: 
   [ { type: 'element',
       tagName: 'pre',
       properties: {},
       children: [Object],
       position: [Object] },
     { type: 'element',
       tagName: 'pre',
       properties: {},
       children: [Object],
       position: [Object] } ],
  position: 
   { start: { line: 155, column: 1, offset: 51462 },
     end: { line: 177, column: 4, offset: 52007 } } }
undefined

Plugins

fs plugin

js
return lit.utils.momento
txtUpdated 140.8w ago
{ MsToRelative: [Getter], DatesToRelativeDelta: [Getter] }
fs
/

Finder (local fs)

jsonUpdated 139.8w ago
undefined

Finder (from manifest)

Sync local|remote|origin

txtUpdated 131w ago
Synced 172/249 files in 6.866 seconds. Duds: 52 Errors: 8
{ duds: 
   [ '/testing/log/2021-w30.lit',
     '/testing/log/2021-w29.lit',
     '/',
     'transcludes/plain.js',
     '/transformers.lit',
     '/experiment.lit',
     '/testing/log/2021-w28.lit',
     '/meta/settings.lit#plantuml-viewer--repl',
     '/utils/fs.lit',
     '/utils/unist-patch-source.lit',
     '/components.lit',
     'repl-output.svg',
     '/themes.lit',
     '../.github/workflows/generate.yaml',
     '/wiki.lit',
     '/rapid_prototyping.lit',
     '/interactive_notebooks.lit',
     '/remark.lit',
     '/renderer/viewers.lit',
     '/markdown.lit',
     '/experimental_social_network.lit',
     '/testing/log/2021-w22.lit',
     '/undefined.lit',
     '/testing/log/2021-w26.lit',
     'log/today.js',
     '/unified.lit',
     'worker2.js',
     '/guided_learning.lit',
     '/agora.lit',
     '/testing/log/2021-07.lit',
     'log/checkforinput.js',
     'filename',
     'worker.js',
     '/testing/log/2021-w25.lit',
     'gitworker.js',
     '/testing/undefined.lit',
     'testing/missingFile.txt',
     'custom-module.mjs',
     'meta/.github/workflows/npm-publish.yaml',
     '/parser.lit',
     'runkit-express-cors-proxy.js',
     'rk.jsx',
     'runkit-repl-endpoint.js',
     'viewers/meta.js',
     '/utils/uri.lit',
     '/testing/log/2021-w23.lit',
     '/transfomers.lit',
     'overview.svg',
     'fsviewer.jsx',
     '/testing/log/2021-w27.lit',
     '/distributed_knowledge_graph.lit',
     '/testing/log/2021-w24.lit' ],
  errors: 
   [ '../plugins/menu/depth.js : Unable to normalize path - traverses above root directory',
     '../plugins/viewers/search.js : Unable to normalize path - traverses above root directory',
     '../plugins/transformers/prettier.js : Unable to normalize path - traverses above root directory',
     '../plugins/other/cors-proxy.js : Unable to normalize path - traverses above root directory',
     '../plugins/viewers/esm.js : Unable to normalize path - traverses above root directory',
     '../plugins/repls/module.js : Unable to normalize path - traverses above root directory',
     '../plugins/repls/search.js : Unable to normalize path - traverses above root directory',
     '../utils/git-commit-all.js : Unable to normalize path - traverses above root directory' ] }

⚠️ Emergency wipe

mdwarn

Clicking on the following link will prompt you to confirm you want to wipe the local file system!