Conversation
any announcements new ALKiln versions have even if ALKilnInThePlayground isn't itself updated. Closes #1014 Co-authored-by: will-morningstar <mxwillmorningstar@gmail.com>
…n into 1014_breaking_news_2
tobynorth
left a comment
There was a problem hiding this comment.
Looks good to me! Didn't find any major issues. One high-level, almost certainly out of scope question for my own understanding: it seems like the need for this PR arose out of ALKiln and ALKiP being separate packages -- why is that? (would you ever want to install ALKiP without wanting to install ALKiln?)
And a general question: how are all the logging changes (artifacts.js, validate.js, Log.js) and path changes (files.js, session_vars.js, set_sources_path.js, scope.js) related to the new notifications feature? For clarity, I'd suggest either putting something about these changes in the PR description or moving them to separate PR(s).
| const argv = require(`minimist`)( process.argv.slice(2) ); | ||
| const artifacts_path = files.make_artifacts_folder( argv.path ); | ||
|
|
||
| const artifacts_path = files.make_artifacts_folder(); |
There was a problem hiding this comment.
nit: argv is no longer used -- consider either cleaning it up or (if this was accidental) restoring it as an arg to make_artifacts_folder
| // Save Scenario data in Scenario folder | ||
| // '@alkiln @generated' | ||
| // console.log( JSON.stringify( scenario ) ); |
There was a problem hiding this comment.
question/nit: did you mean to commit these comments?
| { | ||
| "name": "@suffolklitlab/alkiln", | ||
| "version": "5.15.4", | ||
| "version": "5.15.0-feat-news-17", |
There was a problem hiding this comment.
question (non-blocking): just to satisfy my own curiosity, what's going on with the version number here? (in particular, why did the patch version number drop from 4 to 0?)
| scope.paths.scenario_report = `${ scope.paths.scenario }/report.txt`; | ||
| // If it's a generated Scenario, save the `.feature` file in here | ||
| // GENERATED_FILES_FOLDER_NAME | ||
| if ( scenario.gherkinDocument.uri.includes("_alkiln_generated") ) { |
There was a problem hiding this comment.
nit: _alkiln_generated is a magic string, ideally would be defined in a more maintainable location. (Where did it come from, anyway? I don't see any other references to it in this PR)
| * Note that the function prints the value to the console before returning the | ||
| * value. This is the only way ALKilnInThePlayground can get the value. |
There was a problem hiding this comment.
question: why is this? Seems cleaner to use a temp file; is that not feasible for some reason?
| for ( let subhead of shuffled_subheads ) { | ||
|
|
||
| if ( subhead.includes(`!`) && used_exclamation ) { continue; } | ||
| if ( subhead.includes(`?`) && used_question ) { continue; } | ||
| if ( subhead.includes(`"`) && used_quotes ) { continue; } | ||
| if ( subheads_used[ subhead ]) { continue; } | ||
|
|
||
| if ( subhead.includes(`!`)) { used_exclamation = true; } | ||
| if ( subhead.includes(`?`)) { used_question = true; } | ||
| if ( subhead.includes(`"`)) { used_quotes = true; } | ||
|
|
||
| final_subhead = subhead; | ||
| subheads_used[ subhead ] = true; | ||
| } |
There was a problem hiding this comment.
suggestion: it feels like it would be a little cleaner to refactor this into get_shuffled_subheads by just ensuring that a max of 1 subhead with each checked char (and no duplicate subheads) are added to the return array. Then in this function, you could just pop or shift an element off the array to pass to get_one_articles_parts
| let html_paragraphs = []; | ||
| for ( let one_paragraph of paragraphs ) { | ||
| html_paragraphs.push(`<p class="body_copy">${ one_paragraph }</p>`); | ||
| } | ||
| return html_paragraphs; |
There was a problem hiding this comment.
suggestion: this could be simplified to:
| let html_paragraphs = []; | |
| for ( let one_paragraph of paragraphs ) { | |
| html_paragraphs.push(`<p class="body_copy">${ one_paragraph }</p>`); | |
| } | |
| return html_paragraphs; | |
| return paragraphs.map(paragraph => `<p class="body_copy">${ paragraph }</p>`); |
| if ( typeof list_or_str === `string` ) { | ||
| indent_str = ` `.repeat( indent ); | ||
| return [ indent_str + list_or_str ]; | ||
| } | ||
|
|
||
| let flattened = []; | ||
| for ( let nested_str_or_list of list_or_str ) { | ||
| let result = indent_and_flatten_html_list( | ||
| nested_str_or_list, | ||
| indent + 1 | ||
| ); | ||
| // // .concat() feels evil because it accepts a string as well | ||
| // flattened = flattened.concat( result ); | ||
| flattened.push( ...result ); | ||
| } | ||
|
|
||
| return flattened; |
There was a problem hiding this comment.
suggestion: I think this could be simplified to:
| if ( typeof list_or_str === `string` ) { | |
| indent_str = ` `.repeat( indent ); | |
| return [ indent_str + list_or_str ]; | |
| } | |
| let flattened = []; | |
| for ( let nested_str_or_list of list_or_str ) { | |
| let result = indent_and_flatten_html_list( | |
| nested_str_or_list, | |
| indent + 1 | |
| ); | |
| // // .concat() feels evil because it accepts a string as well | |
| // flattened = flattened.concat( result ); | |
| flattened.push( ...result ); | |
| } | |
| return flattened; | |
| return list_or_str.flatMap(nested_str_or_list => | |
| Array.isArray(nested_str_or_list) | |
| ? indent_and_flatten_html_list(nested_str_or_list, indent + 1) | |
| : ` `.repeat(indent) + nested_str_or_list | |
| ); |
| } | ||
|
|
||
|
|
||
| function get_semver_parts( version_str ) { |
There was a problem hiding this comment.
suggestion: Consider using a 3rd party library to replace all your semver-related functions if you haven't already (example). Since this is neither related to the core ALKiln logic nor (it seems) something ALKiln needs to go outside the semver spec for, probably better to let someone else maintain it
| // If we switch to module (import) instead of common (require), use | ||
| // https://nodejs.org/api/esm.html#importmetafilename for file path | ||
| let most_recent_file_sha = execSync( | ||
| `git rev-list -1 HEAD -- "${ __filename }"` |
There was a problem hiding this comment.
question: this is running on users' servers, right? Is it safe to assume they have git installed and have cloned the ALKiln repo locally?...
In this PR, I have:
Reason for this PR
[Early PR for quick top-level sanity check review, failing tests are fine for now.]
Summary: Add notifications to ALKilnInThePlayground (ALKiP) for ALKiln changes
Details:
This is a testing framework. One of the environments in which it runs is on a test author's own server. ALKiP is a package of mine that helps authors runs these tests on their server. I work hard to ensure backwards compatibility, but it can be useful to keep both up to date with the other and sometimes to notify authors of other changes to their server that might affect how ALKiP is running. It's hard for authors to tell which versions match up with each other and when to update in general.
This ALKiln PR generates HTML that ALKiP can use to add notifications about relevant changes to ALKiln, to the author's server, or about whatever else ALKiln thinks is helpful. We will use notifications sparingly.
Demo of the visual appearance of a notification. Visual preview:
Links to any solved or related issues
Closes #1014
Any manual testing I have done to ensure my PR is working
Publishing to npm and testing on ALKiP