Skip to content

Commit

Permalink
Merge pull request #18 from zanerock/work-liquid-labs/liq-controls/17
Browse files Browse the repository at this point in the history
Update `getQuestionControls()` to deal with unscoped packages
  • Loading branch information
zanerock authored Nov 10, 2023
2 parents c7a28db + 051030e commit 0aeb6b0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
15 changes: 4 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"files": [
"dist/*"
],
"engines": {
"node": ">=18.0.0"
},
"keywords": [],
"author": "Zane Rockenbaugh <[email protected]>",
"license": "UNLICENSED",
Expand All @@ -27,7 +30,7 @@
"@liquid-labs/http-smart-response": "^1.0.0-alpha.3",
"@liquid-labs/liq-handlers-lib": "^1.0.0-alpha.15",
"@liquid-labs/liq-qa-lib": "^1.0.0-alpha.8",
"@liquid-labs/npm-toolkit": "^1.0.0-alpha.10",
"@liquid-labs/npm-toolkit": "file:.yalc/@liquid-labs/npm-toolkit",
"@liquid-labs/resource-item": "^1.0.0-alpha.4",
"@liquid-labs/resource-model": "file:.yalc/@liquid-labs/resource-model",
"http-errors": "^2.0.0",
Expand All @@ -38,15 +41,5 @@
},
"devDependencies": {
"@liquid-labs/catalyst-scripts-node-project": "^1.0.0-alpha.5"
},
"engines": {
"node": ">=18.0.0"
},
"catalyst-scripts": {
"preset-env": {
"targets": {
"node": "18.0"
}
}
}
}
11 changes: 9 additions & 2 deletions src/lib/integrations/get-question-controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as fsPath from 'node:path'
import yaml from 'js-yaml'

const getQuestionControls = async({ app, controlsName, projectName, reporter }) => {
const { projectPath } = app.ext._liqProjects.playgroundMonitor.getProjectData(projectName)
const { pkgJSON, projectPath } = app.ext._liqProjects.playgroundMonitor.getProjectData(projectName)

const packageControlsPath = fsPath.join(projectPath, 'controls', controlsName + '.qcontrols.yaml')
let controlsContent
Expand All @@ -22,7 +22,14 @@ const getQuestionControls = async({ app, controlsName, projectName, reporter })
throw e
} // else, no problem, just doesn't define the control at the package level
reporter.log(' not found')
const [orgKey] = projectName.split('/')
let [orgKey, basename] = projectName.split('/')
if (basename === undefined) {
// then we have an unscoped project and we look at the package.json to determine the org key
orgKey = pkgJSON._comply?.orgKey
if (orgKey === undefined) {
throw new Error("Did not find expected '_comply.orgKey' in the 'package.json' file. This value must be defined for unscoped packages.")
}
}
const org = app.ext._liqOrgs.orgs[orgKey]
if (org !== undefined) {
const controlsSpec = org.controls.getControl(controlsName)
Expand Down

0 comments on commit 0aeb6b0

Please sign in to comment.