-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Chores] Automated API doc generation and added packages/samples filt…
…er (#1470) * Update configuration * Test API doc generation and samples linting * Revert changes * Update * Test changes for API doc * Update script * Update * Update * Test linting * Update script * Update API docs [skip ci] * Update [skip ci] * Revert "Update API docs [skip ci]" This reverts commit 458c93f. * Apply [skip ci] * Update comments [skip ci] * Revert changes * Revert [skip ci] * Add comment [skip ci] * Update path * update CHANGELOG * test * Update according to review --------- Co-authored-by: Automated Build <builds@sitecore.com>
- Loading branch information
1 parent
653c646
commit 0546fca
Showing
6 changed files
with
84 additions
and
15 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const { execSync } = require('child_process'); | ||
const samples = require('./samples.json'); | ||
const { getAppName } = require('./utils'); | ||
|
||
/** | ||
* Start linting process only for the samples that were affected by the new changes in: | ||
* - create-sitecore-jss/src/templates/** | ||
* - create-sitecore-jss/src/initializers/** | ||
*/ | ||
|
||
const affectedTemplates = execSync( | ||
'git diff --name-only origin/dev... -- packages/create-sitecore-jss', | ||
{ | ||
encoding: 'utf-8', | ||
} | ||
) | ||
.split('\n') | ||
.map((filepath) => { | ||
// Extracting template names from the filepath | ||
const template = filepath.match(/(templates|initializers)\/([^\/]*)/); | ||
|
||
return template && template[2]; | ||
}) | ||
// Removing null values and leaving unique template names | ||
.filter((template, index, list) => template && list.indexOf(template) === index); | ||
|
||
if (!affectedTemplates.length) { | ||
console.log('No modified templates to lint'); | ||
|
||
return; | ||
} | ||
|
||
const affectedSamples = samples | ||
.filter((sample) => sample.initializers.some((template) => affectedTemplates.includes(template))) | ||
.map((sample) => getAppName(sample.args)); | ||
|
||
if (!affectedSamples.length) { | ||
console.log('No modified samples to lint'); | ||
|
||
return; | ||
} | ||
|
||
execSync(`npx lerna run lint --scope={${affectedSamples.join(',')}} -- --fix`, { | ||
stdio: 'inherit', | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* Generates unique app name based on sample app configuration | ||
* @param {Record<string, string>} args sample app arguments | ||
* @returns unique app name | ||
*/ | ||
module.exports.getAppName = (args) => | ||
`sample-${args.appName}-${args.fetchWith || ''}-${args.prerender || ''}`; |