-
Notifications
You must be signed in to change notification settings - Fork 462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changing build to possible use parser output for learningObjectives #1681
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,7 +96,7 @@ const parse = (dir, validate) => new Promise((resolve) => { | |
}); | ||
|
||
// | ||
// Create projects.json and topics.json with indeces of all projects and topics. | ||
// Create projects.json and topics.json with indices of all projects and topics. | ||
// | ||
const createIndexes = async (results) => { | ||
const resultsWithJson = await Promise.all(results.map(async result => ({ | ||
|
@@ -122,30 +122,59 @@ const createIndexes = async (results) => { | |
))); | ||
}; | ||
|
||
const addLearningObjectives = async () => { | ||
const dir = path.join(__dirname, '../learning-objectives') | ||
const [tree, es, pt] = await Promise.all([ | ||
loadYaml(path.join(dir, 'data.yml')), | ||
loadYaml(path.join(dir, 'intl', 'es.yml')), | ||
loadYaml(path.join(dir, 'intl', 'pt.yml')), | ||
]); | ||
|
||
const flat = flattenLearningObjectives(tree); | ||
const json = { | ||
tree, | ||
flat, | ||
intl: { es, pt }, | ||
table: flat.map(key => ({ | ||
key, | ||
es: es[key]?.title || es[key], | ||
pt: pt[key]?.title || pt[key], | ||
})), | ||
}; | ||
|
||
await writeFile( | ||
path.join(buildDir, 'learning-objectives.json'), | ||
JSON.stringify(json, null, 2), | ||
); | ||
const addLearningObjectives = async (validate) => { | ||
|
||
const parseObjectives = (validate) => new Promise((resolve) => { | ||
const dir = path.join(__dirname, '../learning-objectives'); | ||
const dest = path.join(buildDir, 'learning-objectives.json') | ||
const fd = openSync(validate ? '/dev/null' : dest, 'w'); | ||
|
||
const args = [ | ||
'curriculum-parser', | ||
'learning-objectives', | ||
dir, | ||
// '--repo', repository, | ||
// '--version', version, | ||
]; | ||
unjust marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if (validate) { | ||
args.push('--validate'); // TODO: put strict here? | ||
} | ||
|
||
console.log(args); | ||
const child = spawn( | ||
'npx', | ||
args, | ||
{ stdio: [null, fd, 'pipe'] }, | ||
); | ||
|
||
const stderrChunks = []; | ||
child.stderr.on('data', chunk => stderrChunks.push(chunk)); | ||
|
||
child.on('close', (code) => { | ||
if (code > 0) { | ||
const err = Object.assign(new Error(`Error parsing learning objectives`), { | ||
stderr: stderrChunks.join(''), | ||
}); | ||
console.error(err.stderr); | ||
return resolve(err); | ||
} | ||
|
||
console.log(`<= OK parsing objectives`); | ||
return resolve({ dest }); | ||
}); | ||
}); | ||
|
||
const { dest } = await parseObjectives(validate); | ||
console.log(buildDir, dest); | ||
if (!validate) { | ||
const json = await JSON.parse(await readFile(dest)); | ||
await writeFile( | ||
path.join(buildDir, 'learning-objectives.json'), | ||
JSON.stringify(json, null, 2), | ||
); | ||
Comment on lines
+171
to
+175
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this step may be unnecessary since |
||
} | ||
|
||
}; | ||
|
||
const main = async (args, opts) => { | ||
|
@@ -172,8 +201,9 @@ const main = async (args, opts) => { | |
|
||
if (!validate) { | ||
await createIndexes(results); | ||
await addLearningObjectives(); | ||
} | ||
|
||
await addLearningObjectives(validate); | ||
}; | ||
|
||
const { _: args, ...opts } = minimist(process.argv.slice(2)); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repo y version seran necesarios?