-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #550 from FabienArcellier/517-custom-component-nam…
…e-should-be-constrained-explicitely fix: custom component name should be constrained explicitely - WF-52
- Loading branch information
Showing
7 changed files
with
99 additions
and
8 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
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,42 @@ | ||
import { importVue } from "./core.mjs"; | ||
|
||
async function checkDeclarationKey() { | ||
let hasFailed = false; | ||
const module = await importVue("../src/custom_components/index.ts"); | ||
const { checkComponentKey } = await importVue( | ||
"../src/core/loadExtensions.ts", | ||
); | ||
const invalidCustomComponentKeys = []; | ||
Object.keys(module.default).forEach((key) => { | ||
if (!checkComponentKey(key)) { | ||
invalidCustomComponentKeys.push(key); | ||
hasFailed = true; | ||
} | ||
}); | ||
|
||
if (invalidCustomComponentKeys.length !== 0) { | ||
// eslint-disable-next-line no-console | ||
console.error( | ||
`ERROR: Invalid component declaration: ${invalidCustomComponentKeys} into 'src/custom_components/index.ts'. Their key must be declared using only lowercase and alphanumeric characters.`, | ||
); | ||
} | ||
return hasFailed; | ||
} | ||
|
||
/** | ||
* Check the custom components in continuous integration | ||
* | ||
* npm run custom.check | ||
* | ||
*/ | ||
async function check() { | ||
let hasFailed = false; | ||
|
||
hasFailed |= await checkDeclarationKey(); | ||
|
||
if (hasFailed) { | ||
process.exit(1); | ||
} | ||
} | ||
|
||
check(); |