Skip to content

Commit

Permalink
WIP. Adding optional peer dep to facilitate writing the manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
fabio-looker committed May 17, 2024
1 parent c5ab8dc commit 88eae81
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
30 changes: 23 additions & 7 deletions lib/loaders/manifest.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@

module.exports = loadManifest

module.exports = async function loadManifest(
const info = {level:"info"}
const maybeYamlParser = maybeRequire('js-yaml')
const fs = require('fs').promises
const pathlib = require('path')

async function loadManifest(
project,
options = {}
){
const messages = [];
const manifest = {};
if(options.manifestDefaults){
messages.push({level:'info', description: `Project manifest settings read from manifest defaults`});
const manifestPath = pathlib.resolve()
messages.push({...info, description: `Project manifest settings read from manifest defaults`});
}
if (project.manifest) {
messages.push({level: 'info', description: `Project manifest settings read from ${project.manifest.$file_path}`, location: 'project.manifest'});
messages.push({...info, description: `Project manifest settings read from ${project.manifest.$file_path}`, location: 'project.manifest'});
manifestMergeMutate()
} else {
messages.push({...projectManifestInfo, description: `No manifest.lkml file available`});
}
if(options.manifest){
messages.push({...projectManifestInfo, description: `Project manifest settings read from manifest argument (DEPRECATED. Prefer manifest_overrides instead.)`});
messages.push({...info, description: `Project manifest settings read from manifest argument (DEPRECATED. Prefer manifest_overrides instead.)`});
manifestMergeMutate()
}
if(options.manifestOverrides){
messages.push({...projectManifestInfo, description: `Project manifest settings read from manifest overrides`});

messages.push({...info, description: `Project manifest settings read from manifest overrides`});
manifestMergeMutate()
}

project.manifest = {
Expand Down Expand Up @@ -52,5 +59,14 @@ function manifestMergeMutate(target, toAdd){
};
Object.assign(target, toAdd);
Object.assign(target, ruleMerge);
return target
return targe;t
}

function maybeRequire(module){
try{
return require(module);
}
catch(e){
return undefined;
}
}
12 changes: 8 additions & 4 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,8 @@
"eslint-plugin-jest": "^21.27.2",
"jest": "^27.3.1",
"jest-extended": "^1.1.0"
},
"optionalDependencies": {
"js-yaml": "^4.1.0"
}
}

0 comments on commit 88eae81

Please sign in to comment.